luo-image-annotator 0.0.15 → 0.0.16

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 ae = Object.defineProperty;
2
2
  var le = (w, t, n) => t in w ? ae(w, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : w[t] = n;
3
3
  var T = (w, t, n) => le(w, typeof t != "symbol" ? t + "" : t, n);
4
- import { defineComponent as ct, ref as M, watchEffect as ce, openBlock as v, createElementBlock as m, normalizeClass as X, computed as V, onMounted as kt, nextTick as at, watch as K, createElementVNode as h, toDisplayString as z, Fragment as N, renderList as J, normalizeStyle as U, createCommentVNode as B, createVNode as R, withModifiers as It, createBlock as vt, withDirectives as ft, vModelText as mt, createTextVNode as lt } from "vue";
4
+ import { defineComponent as ct, ref as M, watchEffect as ce, openBlock as v, createElementBlock as m, normalizeClass as X, computed as V, onMounted as yt, nextTick as at, watch as K, createElementVNode as h, toDisplayString as z, Fragment as N, renderList as J, normalizeStyle as U, createCommentVNode as B, createVNode as R, withModifiers as It, createBlock as vt, withDirectives as ft, vModelText as mt, createTextVNode as lt } from "vue";
5
5
  const pt = (w, t) => Math.sqrt(Math.pow(w.x - t.x, 2) + Math.pow(w.y - t.y, 2)), re = (w, t) => {
6
6
  let n = !1;
7
- for (let e = 0, l = t.length - 1; e < t.length; l = e++) {
8
- const o = t[e].x, c = t[e].y, g = t[l].x, u = t[l].y;
7
+ for (let e = 0, a = t.length - 1; e < t.length; a = e++) {
8
+ const o = t[e].x, c = t[e].y, g = t[a].x, u = t[a].y;
9
9
  c > w.y != u > w.y && w.x < (g - o) * (w.y - c) / (u - c) + o && (n = !n);
10
10
  }
11
11
  return n;
12
12
  }, At = (w, t, n) => {
13
- const e = n * (Math.PI / 180), l = Math.cos(e), o = Math.sin(e), c = w.x - t.x, g = w.y - t.y;
13
+ const e = n * (Math.PI / 180), a = Math.cos(e), o = Math.sin(e), c = w.x - t.x, g = w.y - t.y;
14
14
  return {
15
- x: t.x + (c * l - g * o),
16
- y: t.y + (c * o + g * l)
15
+ x: t.x + (c * a - g * o),
16
+ y: t.y + (c * o + g * a)
17
17
  };
18
18
  };
19
19
  class he {
@@ -89,8 +89,8 @@ class he {
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 l = this.canvas.width / 2, o = this.canvas.height / 2, c = this.toImageCoords(l, o);
93
- this.scale = e, this.offset.x = l - c.x * this.scale, this.offset.y = o - c.y * this.scale, this.clampViewportOffset(), this.render();
92
+ const a = this.canvas.width / 2, o = this.canvas.height / 2, c = this.toImageCoords(a, o);
93
+ this.scale = e, this.offset.x = a - c.x * this.scale, this.offset.y = o - c.y * this.scale, this.clampViewportOffset(), this.render();
94
94
  }
95
95
  resize() {
96
96
  this.fitImageToCanvas(), this.render();
@@ -120,18 +120,18 @@ class he {
120
120
  if (this.img.width === 0 || this.img.height === 0) return;
121
121
  const t = this.img.width * this.scale, n = this.img.height * this.scale, e = 100;
122
122
  if (t <= this.canvas.width) {
123
- const l = -t + e, o = this.canvas.width - e;
124
- this.offset.x = Math.min(o, Math.max(l, this.offset.x));
123
+ const a = -t + e, o = this.canvas.width - e;
124
+ this.offset.x = Math.min(o, Math.max(a, this.offset.x));
125
125
  } else {
126
- const l = this.canvas.width - t - e, o = e;
127
- this.offset.x = Math.min(o, Math.max(l, this.offset.x));
126
+ const a = this.canvas.width - t - e, o = e;
127
+ this.offset.x = Math.min(o, Math.max(a, this.offset.x));
128
128
  }
129
129
  if (n <= this.canvas.height) {
130
- const l = -n + e, o = this.canvas.height - e;
131
- this.offset.y = Math.min(o, Math.max(l, this.offset.y));
130
+ const a = -n + e, o = this.canvas.height - e;
131
+ this.offset.y = Math.min(o, Math.max(a, this.offset.y));
132
132
  } else {
133
- const l = this.canvas.height - n - e, o = e;
134
- this.offset.y = Math.min(o, Math.max(l, this.offset.y));
133
+ const a = this.canvas.height - n - e, o = e;
134
+ this.offset.y = Math.min(o, Math.max(a, this.offset.y));
135
135
  }
136
136
  }
137
137
  // --- 事件处理 ---
@@ -153,19 +153,19 @@ class he {
153
153
  }
154
154
  }
155
155
  handleMouseDown(t) {
156
- const n = this.canvas.getBoundingClientRect(), e = t.clientX - n.left, l = t.clientY - n.top, o = this.toImageCoords(e, l);
156
+ const n = this.canvas.getBoundingClientRect(), e = t.clientX - n.left, a = t.clientY - n.top, o = this.toImageCoords(e, a);
157
157
  if (this.interactionMode === "pan") {
158
- this.isPanning = !0, this.panStartPoint = { x: e, y: l }, this.canvas.style.cursor = "grabbing";
158
+ this.isPanning = !0, this.panStartPoint = { x: e, y: a }, this.canvas.style.cursor = "grabbing";
159
159
  return;
160
160
  }
161
161
  if (this.interactionMode === "select" && this.activeAnnotation) {
162
- const u = this.getHitHandle(e, l, this.activeAnnotation);
162
+ const u = this.getHitHandle(e, a, this.activeAnnotation);
163
163
  if (u !== -100) {
164
164
  this.isDragging = !0, this.dragStartPoint = o, this.selectedHandleIndex = u, this.dragStartAnnotation = JSON.parse(JSON.stringify(this.activeAnnotation));
165
165
  return;
166
166
  }
167
167
  }
168
- const c = this.interactionMode === "select" ? this.getHitCategory(e, l) : null;
168
+ const c = this.interactionMode === "select" ? this.getHitCategory(e, a) : null;
169
169
  if (c) {
170
170
  this.activeAnnotation = c, this.isDragging = !1, this.selectedHandleIndex = -1, this.emit("annotationChange", { action: "select", changedItem: c, imageUrl: this.imageUrl }), this.render();
171
171
  return;
@@ -203,10 +203,10 @@ class he {
203
203
  this.activeAnnotation = null, this.render();
204
204
  }
205
205
  handleMouseMove(t) {
206
- const n = this.canvas.getBoundingClientRect(), e = t.clientX - n.left, l = t.clientY - n.top, o = this.toImageCoords(e, l);
206
+ const n = this.canvas.getBoundingClientRect(), e = t.clientX - n.left, a = t.clientY - n.top, o = this.toImageCoords(e, a);
207
207
  if (this.isPanning && this.panStartPoint) {
208
- const c = e - this.panStartPoint.x, g = l - this.panStartPoint.y;
209
- this.offset.x += c, this.offset.y += g, this.clampViewportOffset(), this.panStartPoint = { x: e, y: l }, this.render();
208
+ const c = e - this.panStartPoint.x, g = a - this.panStartPoint.y;
209
+ this.offset.x += c, this.offset.y += g, this.clampViewportOffset(), this.panStartPoint = { x: e, y: a }, this.render();
210
210
  return;
211
211
  }
212
212
  if (this.lastMouseMovePoint = o, this.isDrawing) {
@@ -219,7 +219,7 @@ class he {
219
219
  this.isHoveringStartPoint = !1;
220
220
  }
221
221
  this.updateDrawing(o);
222
- } else this.isDragging && this.activeAnnotation && this.dragStartPoint ? this.updateDragging(o) : this.checkHover(e, l, o);
222
+ } else this.isDragging && this.activeAnnotation && this.dragStartPoint ? this.updateDragging(o) : this.checkHover(e, a, o);
223
223
  this.render();
224
224
  }
225
225
  handleMouseUp(t) {
@@ -244,8 +244,8 @@ class he {
244
244
  // 辅助函数:将 hex 转换为 rgba
245
245
  hexToRgba(t, n) {
246
246
  if (!t.startsWith("#")) return t;
247
- const e = parseInt(t.slice(1, 3), 16), l = parseInt(t.slice(3, 5), 16), o = parseInt(t.slice(5, 7), 16);
248
- return `rgba(${e}, ${l}, ${o}, ${n})`;
247
+ const e = parseInt(t.slice(1, 3), 16), a = parseInt(t.slice(3, 5), 16), o = parseInt(t.slice(5, 7), 16);
248
+ return `rgba(${e}, ${a}, ${o}, ${n})`;
249
249
  }
250
250
  startDrawing(t) {
251
251
  if (!this.currentTool) return;
@@ -300,8 +300,8 @@ class he {
300
300
  const n = this.activeAnnotation.coordinates;
301
301
  n.x2 = t.x, n.y2 = t.y;
302
302
  } else if (this.activeAnnotation.type === "rotatedRect" && this.dragStartPoint) {
303
- const n = this.activeAnnotation.coordinates, e = Math.abs(t.x - this.dragStartPoint.x), l = Math.abs(t.y - this.dragStartPoint.y);
304
- n.width = e * 2, n.height = l * 2;
303
+ const n = this.activeAnnotation.coordinates, e = Math.abs(t.x - this.dragStartPoint.x), a = Math.abs(t.y - this.dragStartPoint.y);
304
+ n.width = e * 2, n.height = a * 2;
305
305
  } else this.activeAnnotation.type;
306
306
  }
307
307
  finishDrawing() {
@@ -312,8 +312,8 @@ class he {
312
312
  this.activeAnnotation = null, this.isDrawing = !1;
313
313
  return;
314
314
  }
315
- const n = Math.min(t.x1, t.x2), e = Math.max(t.x1, t.x2), l = Math.min(t.y1, t.y2), o = Math.max(t.y1, t.y2);
316
- t.x1 = n, t.x2 = e, t.y1 = l, t.y2 = o, this.annotations.push(this.activeAnnotation), this.emit("annotationChange", { action: "add", changedItem: this.activeAnnotation, imageUrl: this.imageUrl });
315
+ const n = Math.min(t.x1, t.x2), e = Math.max(t.x1, t.x2), a = Math.min(t.y1, t.y2), o = Math.max(t.y1, t.y2);
316
+ t.x1 = n, t.x2 = e, t.y1 = a, t.y2 = o, this.annotations.push(this.activeAnnotation), this.emit("annotationChange", { action: "add", changedItem: this.activeAnnotation, imageUrl: this.imageUrl });
317
317
  } else if (this.activeAnnotation.type === "polygon") {
318
318
  if (this.activeAnnotation.coordinates.points.length < 3) {
319
319
  this.activeAnnotation = null, this.isDrawing = !1;
@@ -337,42 +337,42 @@ class he {
337
337
  const n = t.x - this.dragStartPoint.x, e = t.y - this.dragStartPoint.y;
338
338
  this.selectedHandleIndex === -1 ? this.moveAnnotation(this.activeAnnotation, this.dragStartAnnotation, n, e) : this.resizeAnnotation(this.activeAnnotation, this.dragStartAnnotation, this.selectedHandleIndex, t);
339
339
  }
340
- moveAnnotation(t, n, e, l) {
340
+ moveAnnotation(t, n, e, a) {
341
341
  if (t.type === "rectangle") {
342
342
  const o = n.coordinates, c = t.coordinates;
343
- c.x1 = o.x1 + e, c.x2 = o.x2 + e, c.y1 = o.y1 + l, c.y2 = o.y2 + l;
343
+ c.x1 = o.x1 + e, c.x2 = o.x2 + e, c.y1 = o.y1 + a, c.y2 = o.y2 + a;
344
344
  } else if (t.type === "point") {
345
345
  const o = n.coordinates, c = t.coordinates;
346
- c.points = o.points.map((g) => ({ x: g.x + e, y: g.y + l }));
346
+ c.points = o.points.map((g) => ({ x: g.x + e, y: g.y + a }));
347
347
  } else if (t.type === "rotatedRect") {
348
348
  const o = n.coordinates, c = t.coordinates;
349
- c.x = o.x + e, c.y = o.y + l;
349
+ c.x = o.x + e, c.y = o.y + a;
350
350
  } else if (t.type === "polygon") {
351
351
  const o = n.coordinates, c = t.coordinates;
352
- c.points = o.points.map((g) => ({ x: g.x + e, y: g.y + l }));
352
+ c.points = o.points.map((g) => ({ x: g.x + e, y: g.y + a }));
353
353
  } else if (t.type === "category") {
354
354
  const o = n.coordinates, c = t.coordinates;
355
- o && c && (c.x = o.x + e, c.y = o.y + l);
355
+ o && c && (c.x = o.x + e, c.y = o.y + a);
356
356
  }
357
357
  }
358
- resizeAnnotation(t, n, e, l) {
358
+ resizeAnnotation(t, n, e, a) {
359
359
  if (t.type === "rectangle") {
360
360
  const o = t.coordinates;
361
- e === 0 && (o.x1 = l.x, o.y1 = l.y), e === 1 && (o.x2 = l.x, o.y1 = l.y), e === 2 && (o.x2 = l.x, o.y2 = l.y), e === 3 && (o.x1 = l.x, o.y2 = l.y);
361
+ e === 0 && (o.x1 = a.x, o.y1 = a.y), e === 1 && (o.x2 = a.x, o.y1 = a.y), e === 2 && (o.x2 = a.x, o.y2 = a.y), e === 3 && (o.x1 = a.x, o.y2 = a.y);
362
362
  } else if (t.type === "polygon") {
363
363
  const o = t.coordinates;
364
- e >= 0 && e < o.points.length && (o.points[e] = l);
364
+ e >= 0 && e < o.points.length && (o.points[e] = a);
365
365
  } else if (t.type === "point") {
366
366
  const o = t.coordinates;
367
- e >= 0 && e < o.points.length && (o.points[e] = l);
367
+ e >= 0 && e < o.points.length && (o.points[e] = a);
368
368
  } else if (t.type === "rotatedRect") {
369
369
  const o = t.coordinates;
370
370
  if (e === -2) {
371
- const c = o.x, g = o.y, u = l.x - c, r = l.y - g;
371
+ const c = o.x, g = o.y, u = a.x - c, r = a.y - g;
372
372
  let k = Math.atan2(r, u) * 180 / Math.PI;
373
373
  k += 90, o.angle = k;
374
374
  } else {
375
- const c = o.angle * Math.PI / 180, g = Math.cos(-c), u = Math.sin(-c), r = l.x - o.x, k = l.y - o.y, x = r * g - k * u, D = r * u + k * g;
375
+ const c = o.angle * Math.PI / 180, g = Math.cos(-c), u = Math.sin(-c), r = a.x - o.x, k = a.y - o.y, x = r * g - k * u, D = r * u + k * g;
376
376
  (e === 0 || e === 3) && (o.width / 2, o.width = Math.abs(x) * 2), (e === 1 || e === 2) && (o.width = Math.abs(x) * 2), (e === 0 || e === 1) && (o.height = Math.abs(D) * 2), (e === 2 || e === 3) && (o.height = Math.abs(D) * 2);
377
377
  }
378
378
  }
@@ -394,16 +394,16 @@ class he {
394
394
  const e = n.coordinates;
395
395
  return re(t, e.points);
396
396
  } else if (n.type === "rotatedRect") {
397
- const e = n.coordinates, l = At(t, { x: e.x, y: e.y }, -e.angle), o = e.width / 2, c = e.height / 2;
398
- return l.x >= e.x - o && l.x <= e.x + o && l.y >= e.y - c && l.y <= e.y + c;
397
+ const e = n.coordinates, a = At(t, { x: e.x, y: e.y }, -e.angle), o = e.width / 2, c = e.height / 2;
398
+ return a.x >= e.x - o && a.x <= e.x + o && a.y >= e.y - c && a.y <= e.y + c;
399
399
  } else if (n.type === "point")
400
- return n.coordinates.points.some((l) => pt(t, l) < 10 / this.scale);
400
+ return n.coordinates.points.some((a) => pt(t, a) < 10 / this.scale);
401
401
  return !1;
402
402
  }
403
403
  getHitHandle(t, n, e) {
404
- const l = this.getAnnotationHandles(e), o = 6;
405
- for (let c = 0; c < l.length; c++) {
406
- const g = l[c], u = this.toScreenCoords(g.x, g.y);
404
+ const a = this.getAnnotationHandles(e), o = 6;
405
+ for (let c = 0; c < a.length; c++) {
406
+ const g = a[c], u = this.toScreenCoords(g.x, g.y);
407
407
  if (Math.abs(t - u.x) < o && Math.abs(n - u.y) < o)
408
408
  return e.type === "rotatedRect" && c === 4 ? -2 : c;
409
409
  }
@@ -428,16 +428,16 @@ class he {
428
428
  if (t.type === "point")
429
429
  return t.coordinates.points;
430
430
  if (t.type === "rotatedRect") {
431
- const n = t.coordinates, e = { x: n.x, y: n.y }, l = n.width / 2, o = n.height / 2, c = { x: n.x - l, y: n.y - o }, g = { x: n.x + l, y: n.y - o }, u = { x: n.x + l, y: n.y + o }, r = { x: n.x - l, y: n.y + o }, k = { x: n.x, y: n.y - o - 20 / this.scale };
431
+ const n = t.coordinates, e = { x: n.x, y: n.y }, a = n.width / 2, o = n.height / 2, c = { x: n.x - a, y: n.y - o }, g = { x: n.x + a, y: n.y - o }, u = { x: n.x + a, y: n.y + o }, r = { x: n.x - a, y: n.y + o }, k = { x: n.x, y: n.y - o - 20 / this.scale };
432
432
  return [c, g, u, r, k].map((x) => At(x, e, n.angle));
433
433
  }
434
434
  }
435
435
  return [];
436
436
  }
437
437
  checkHover(t, n, e) {
438
- const l = this.getHitCategory(t, n);
439
- if (l) {
440
- this.canvas.style.cursor = "pointer", this.hoverAnnotation = l;
438
+ const a = this.getHitCategory(t, n);
439
+ if (a) {
440
+ this.canvas.style.cursor = "pointer", this.hoverAnnotation = a;
441
441
  return;
442
442
  }
443
443
  if (this.activeAnnotation && this.getHitHandle(t, n, this.activeAnnotation) !== -100) {
@@ -459,21 +459,21 @@ class he {
459
459
  const n = 12;
460
460
  t.forEach((e) => {
461
461
  var _;
462
- const l = e.label || "未命名分类", o = this.ctx.measureText(l).width + n * 2, c = 28, g = this.activeAnnotation === e, u = this.hoverAnnotation === e;
462
+ const a = e.label || "未命名分类", o = this.ctx.measureText(a).width + n * 2, c = 28, g = this.activeAnnotation === e, u = this.hoverAnnotation === e;
463
463
  let r = { x: 20, y: 20 };
464
464
  e.coordinates && typeof e.coordinates.x == "number" && typeof e.coordinates.y == "number" && (r = this.toScreenCoords(e.coordinates.x, e.coordinates.y));
465
465
  const k = r.x - o / 2, x = r.y - c / 2, D = ((_ = e.style) == null ? void 0 : _.strokeColor) || "#2196F3";
466
- this.ctx.fillStyle = g ? D : this.hexToRgba(D, 0.85), u && !g && (this.ctx.fillStyle = D), g ? (this.ctx.strokeStyle = "#ffffff", this.ctx.lineWidth = 2) : (this.ctx.strokeStyle = "transparent", this.ctx.lineWidth = 0), this.ctx.beginPath(), this.ctx.roundRect(k, x, o, c, 6), this.ctx.fill(), g && (this.ctx.stroke(), this.ctx.save(), this.ctx.strokeStyle = D, this.ctx.lineWidth = 2, this.ctx.strokeRect(k - 3, x - 3, o + 6, c + 6), this.ctx.restore()), this.ctx.fillStyle = "#ffffff", this.ctx.fillText(l, r.x, r.y);
466
+ this.ctx.fillStyle = g ? D : this.hexToRgba(D, 0.85), u && !g && (this.ctx.fillStyle = D), g ? (this.ctx.strokeStyle = "#ffffff", this.ctx.lineWidth = 2) : (this.ctx.strokeStyle = "transparent", this.ctx.lineWidth = 0), this.ctx.beginPath(), this.ctx.roundRect(k, x, o, c, 6), this.ctx.fill(), g && (this.ctx.stroke(), this.ctx.save(), this.ctx.strokeStyle = D, this.ctx.lineWidth = 2, this.ctx.strokeRect(k - 3, x - 3, o + 6, c + 6), this.ctx.restore()), this.ctx.fillStyle = "#ffffff", this.ctx.fillText(a, r.x, r.y);
467
467
  }), this.ctx.restore();
468
468
  }
469
469
  getHitCategory(t, n) {
470
470
  const e = this.annotations.filter((g) => g.type === "category");
471
471
  if (e.length === 0) return null;
472
472
  this.ctx.save(), this.ctx.font = "14px sans-serif";
473
- const l = 12, o = 28;
473
+ const a = 12, o = 28;
474
474
  let c = null;
475
475
  for (let g = e.length - 1; g >= 0; g--) {
476
- const u = e[g], r = u.label || "未命名分类", k = this.ctx.measureText(r).width + l * 2;
476
+ const u = e[g], r = u.label || "未命名分类", k = this.ctx.measureText(r).width + a * 2;
477
477
  let x = { x: 20, y: 20 };
478
478
  u.coordinates && typeof u.coordinates.x == "number" && typeof u.coordinates.y == "number" && (x = this.toScreenCoords(u.coordinates.x, u.coordinates.y));
479
479
  const D = x.x - k / 2, _ = x.y - o / 2;
@@ -489,8 +489,8 @@ class he {
489
489
  if (this.visibleLabels.size > 0 && !this.visibleLabels.has(t.label) && !n)
490
490
  return;
491
491
  this.ctx.save();
492
- const e = ((o = t.style) == null ? void 0 : o.strokeColor) || "#FF4081", l = n ? "#00E5FF" : e;
493
- if (this.ctx.strokeStyle = l, this.ctx.lineWidth = 2, t.type === "rectangle") {
492
+ const e = ((o = t.style) == null ? void 0 : o.strokeColor) || "#FF4081", a = n ? "#00E5FF" : e;
493
+ if (this.ctx.strokeStyle = a, this.ctx.lineWidth = 2, t.type === "rectangle") {
494
494
  const c = t.coordinates, g = this.toScreenCoords(c.x1, c.y1), u = this.toScreenCoords(c.x2, c.y2), r = Math.min(g.x, u.x), k = Math.min(g.y, u.y), x = Math.abs(g.x - u.x), D = Math.abs(g.y - u.y);
495
495
  this.ctx.strokeRect(r, k, x, D), n && this.drawHandles(this.getAnnotationHandles(t));
496
496
  } else if (t.type === "polygon") {
@@ -546,17 +546,17 @@ const de = '<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//D
546
546
  setup(w) {
547
547
  const t = w, n = M(""), e = /* @__PURE__ */ Object.assign({ "../assets/svg/aim.svg": de, "../assets/svg/back.svg": ge, "../assets/svg/connection.svg": ue, "../assets/svg/crop.svg": ve, "../assets/svg/delete.svg": fe, "../assets/svg/download.svg": me, "../assets/svg/edit.svg": pe, "../assets/svg/first.svg": ye, "../assets/svg/hide.svg": we, "../assets/svg/last.svg": xe, "../assets/svg/pointer.svg": be, "../assets/svg/price-tag.svg": Ce, "../assets/svg/rank.svg": _e, "../assets/svg/refresh-right.svg": ke, "../assets/svg/right.svg": Ie, "../assets/svg/view.svg": Ae, "../assets/svg/zoom-in.svg": Se, "../assets/svg/zoom-out.svg": Me });
548
548
  return ce(() => {
549
- const l = `../assets/svg/${t.name}.svg`, o = e[l];
550
- o ? n.value = o : (console.warn(`Icon ${t.name} not found at path ${l}`), n.value = "");
551
- }), (l, o) => (v(), m("i", {
549
+ const a = `../assets/svg/${t.name}.svg`, o = e[a];
550
+ o ? n.value = o : (console.warn(`Icon ${t.name} not found at path ${a}`), n.value = "");
551
+ }), (a, o) => (v(), m("i", {
552
552
  class: X(["svg-icon", [w.size ? `size-${w.size}` : ""]]),
553
553
  innerHTML: n.value
554
554
  }, null, 10, Te));
555
555
  }
556
556
  }), rt = (w, t) => {
557
557
  const n = w.__vccOpts || w;
558
- for (const [e, l] of t)
559
- n[e] = l;
558
+ for (const [e, a] of t)
559
+ n[e] = a;
560
560
  return n;
561
561
  }, L = /* @__PURE__ */ rt(De, [["__scopeId", "data-v-3928607b"]]), Pe = {
562
562
  key: 0,
@@ -614,12 +614,12 @@ const de = '<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//D
614
614
  },
615
615
  emits: ["annotationChange", "batchChange", "labelChange", "ready", "error", "tool:change", "viewport:change", "annotation:add", "annotation:update", "annotation:delete", "annotation:select", "prediction:loaded", "prediction:apply", "prediction:reject"],
616
616
  setup(w, { expose: t, emit: n }) {
617
- const e = w, l = n, o = M(null), c = M(null), g = M(null), u = M([]), r = M(null), k = M(null), x = M(0), D = M(""), _ = M([]), $ = M(""), q = M(!1), C = M({ name: "", color: "#FF0000" }), S = M("none"), p = M([]), H = M({}), O = V(() => k.value === "select" && !!D.value), G = M(!1), Z = V(() => _.value.find((s) => s.id === $.value)), yt = (s) => {
617
+ const e = w, a = n, o = M(null), c = M(null), g = M(null), u = M([]), r = M(null), k = M(null), x = M(0), D = M(""), _ = M([]), $ = M(""), q = M(!1), C = M({ name: "", color: "#FF0000" }), S = M("none"), p = M([]), H = M({}), O = V(() => k.value === "select" && !!D.value), G = M(!1), Z = V(() => _.value.find((s) => s.id === $.value)), wt = (s) => {
618
618
  s.stopPropagation(), G.value = !G.value;
619
- }, wt = (s) => {
619
+ }, xt = (s) => {
620
620
  tt(s), G.value = !1;
621
621
  };
622
- kt(() => {
622
+ yt(() => {
623
623
  document.addEventListener("click", (s) => {
624
624
  s.target.closest(".floating-label-selector") || (G.value = !1);
625
625
  });
@@ -628,10 +628,10 @@ const de = '<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//D
628
628
  if (!s || H.value[s]) return;
629
629
  const i = new Image();
630
630
  i.onload = () => {
631
- const a = i.naturalWidth || 1, d = i.naturalHeight || 1;
631
+ const l = i.naturalWidth || 1, d = i.naturalHeight || 1;
632
632
  H.value = {
633
633
  ...H.value,
634
- [s]: { width: a, height: d }
634
+ [s]: { width: l, height: d }
635
635
  };
636
636
  }, i.src = s;
637
637
  }, nt = () => {
@@ -641,9 +641,9 @@ const de = '<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//D
641
641
  }, ht = (s, i) => {
642
642
  u.value[i] = s;
643
643
  }, Q = (s = x.value) => {
644
- const i = g.value, a = u.value[s];
645
- if (!i || !a) return;
646
- const d = i.scrollTop, f = d + i.clientHeight, A = a.offsetTop, P = A + a.offsetHeight;
644
+ const i = g.value, l = u.value[s];
645
+ if (!i || !l) return;
646
+ const d = i.scrollTop, f = d + i.clientHeight, A = l.offsetTop, P = A + l.offsetHeight;
647
647
  if (A < d) {
648
648
  i.scrollTo({
649
649
  top: Math.max(A - 8, 0),
@@ -656,8 +656,8 @@ const de = '<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//D
656
656
  behavior: "smooth"
657
657
  });
658
658
  }, j = () => {
659
- var a, d, f, A;
660
- const s = e.batchImages[x.value], i = (s == null ? void 0 : s.imageUrl) || ((a = e.image) == null ? void 0 : a.url);
659
+ var l, d, f, A;
660
+ const s = e.batchImages[x.value], i = (s == null ? void 0 : s.imageUrl) || ((l = e.image) == null ? void 0 : l.url);
661
661
  return {
662
662
  eventId: `${Date.now()}-${Math.random().toString(36).slice(2, 10)}`,
663
663
  timestamp: Date.now(),
@@ -670,13 +670,13 @@ const de = '<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//D
670
670
  var d;
671
671
  const i = s == null ? void 0 : s.action;
672
672
  if (!i) return;
673
- const a = {
673
+ const l = {
674
674
  meta: j(),
675
675
  action: i,
676
676
  current: s == null ? void 0 : s.changedItem,
677
677
  source: (d = s == null ? void 0 : s.changedItem) != null && d.predictionId ? "prediction" : "manual"
678
678
  };
679
- i === "add" && l("annotation:add", a), i === "update" && l("annotation:update", a), i === "delete" && l("annotation:delete", a), i === "select" && l("annotation:select", a);
679
+ i === "add" && a("annotation:add", l), i === "update" && a("annotation:update", l), i === "delete" && a("annotation:delete", l), i === "select" && a("annotation:select", l);
680
680
  }, b = V(() => e.annotationTypes), I = (s) => ({
681
681
  rectangle: "crop",
682
682
  polygon: "connection",
@@ -690,28 +690,28 @@ const de = '<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//D
690
690
  rotatedRect: "旋转矩形",
691
691
  category: "分类标签"
692
692
  })[s] || s;
693
- kt(() => {
693
+ yt(() => {
694
694
  if (nt(), o.value) {
695
695
  r.value = new he(o.value), r.value.on("annotationChange", (i) => {
696
- var a, d;
696
+ var l, d;
697
697
  if (i.action === "add" && i.changedItem) {
698
698
  const f = _.value.find((A) => A.id === $.value);
699
699
  f && (i.changedItem.label = f.name, i.changedItem.labelId = f.id);
700
700
  }
701
- i.action === "select" ? D.value = ((a = i.changedItem) == null ? void 0 : a.id) || "" : i.action === "delete" && ((d = i.changedItem) == null ? void 0 : d.id) === D.value && (D.value = ""), l("annotationChange", i), y(i);
701
+ i.action === "select" ? D.value = ((l = i.changedItem) == null ? void 0 : l.id) || "" : i.action === "delete" && ((d = i.changedItem) == null ? void 0 : d.id) === D.value && (D.value = ""), a("annotationChange", i), y(i);
702
702
  }), W(), E();
703
703
  const s = new ResizeObserver(() => {
704
704
  var i;
705
705
  (i = r.value) == null || i.resize();
706
706
  });
707
- c.value && s.observe(c.value), e.defaultActiveType && Y(e.defaultActiveType), at(() => Q()), l("ready", { meta: j() });
707
+ c.value && s.observe(c.value), e.defaultActiveType && Y(e.defaultActiveType), at(() => Q()), a("ready", { meta: j() });
708
708
  }
709
709
  });
710
710
  const E = () => {
711
711
  if (!r.value) return;
712
- const s = _.value.find((a) => a.id === $.value);
712
+ const s = _.value.find((l) => l.id === $.value);
713
713
  s && r.value.setLabelStyle(s.color);
714
- const i = _.value.filter((a) => a.visible).map((a) => a.name);
714
+ const i = _.value.filter((l) => l.visible).map((l) => l.name);
715
715
  r.value.setVisibleLabels(i);
716
716
  }, W = () => {
717
717
  var s;
@@ -724,27 +724,27 @@ const de = '<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//D
724
724
  r.value.loadImage(i.imageUrl), i.annotations ? r.value.setAnnotations(i.annotations) : r.value.setAnnotations([]);
725
725
  } else (s = e.image) != null && s.url && r.value.loadImage(e.image.url);
726
726
  }, Y = (s) => {
727
- var i, a;
727
+ var i, l;
728
728
  if (k.value = s, D.value = "", s !== "pan" && s !== "select" && _.value.length === 0) {
729
729
  alert("请先创建标签!");
730
730
  return;
731
731
  }
732
- s === "pan" || s === "select" ? (i = r.value) == null || i.setTool(s) : (a = r.value) == null || a.setTool(s), l("tool:change", { meta: j(), tool: s });
732
+ s === "pan" || s === "select" ? (i = r.value) == null || i.setTool(s) : (l = r.value) == null || l.setTool(s), a("tool:change", { meta: j(), tool: s });
733
733
  }, St = () => {
734
734
  var s;
735
735
  (s = r.value) != null && s.activeAnnotation && r.value.deleteAnnotation(r.value.activeAnnotation.id);
736
- }, xt = () => {
737
- r.value && l("viewport:change", {
736
+ }, bt = () => {
737
+ r.value && a("viewport:change", {
738
738
  meta: j(),
739
739
  scale: r.value.scale,
740
740
  offset: { ...r.value.offset }
741
741
  });
742
742
  }, Mt = () => {
743
743
  var s;
744
- (s = r.value) == null || s.zoom(1), xt();
744
+ (s = r.value) == null || s.zoom(1), bt();
745
745
  }, Tt = () => {
746
746
  var s;
747
- (s = r.value) == null || s.zoom(-1), xt();
747
+ (s = r.value) == null || s.zoom(-1), bt();
748
748
  }, Dt = () => {
749
749
  C.value = { name: "", color: "#2196F3" }, q.value = !0;
750
750
  }, dt = () => {
@@ -760,38 +760,38 @@ const de = '<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//D
760
760
  color: C.value.color,
761
761
  visible: !0
762
762
  };
763
- _.value.push(i), l("labelChange", _.value), E(), _.value.length === 1 && tt(i), dt();
763
+ _.value.push(i), a("labelChange", _.value), E(), _.value.length === 1 && tt(i), dt();
764
764
  }, tt = (s) => {
765
765
  var i;
766
766
  $.value = s.id, (i = r.value) == null || i.setLabelStyle(s.color);
767
767
  }, zt = (s, i) => {
768
768
  if (!s.startsWith("#")) return s;
769
- let a = 0, d = 0, f = 0;
770
- return s.length === 4 ? (a = parseInt(s[1] + s[1], 16), d = parseInt(s[2] + s[2], 16), f = parseInt(s[3] + s[3], 16)) : s.length === 7 && (a = parseInt(s.slice(1, 3), 16), d = parseInt(s.slice(3, 5), 16), f = parseInt(s.slice(5, 7), 16)), `rgba(${a}, ${d}, ${f}, ${i})`;
769
+ let l = 0, d = 0, f = 0;
770
+ return s.length === 4 ? (l = parseInt(s[1] + s[1], 16), d = parseInt(s[2] + s[2], 16), f = parseInt(s[3] + s[3], 16)) : s.length === 7 && (l = parseInt(s.slice(1, 3), 16), d = parseInt(s.slice(3, 5), 16), f = parseInt(s.slice(5, 7), 16)), `rgba(${l}, ${d}, ${f}, ${i})`;
771
771
  }, $t = (s) => {
772
772
  var i;
773
773
  if (s.id === $.value && ((i = r.value) == null || i.setLabelStyle(s.color)), r.value) {
774
- const a = r.value.getAnnotations();
774
+ const l = r.value.getAnnotations();
775
775
  let d = !1;
776
- a.forEach((f) => {
776
+ l.forEach((f) => {
777
777
  f.label === s.name && (f.style || (f.style = {}), f.style.strokeColor = s.color, f.style.fillColor = zt(s.color, 0.2), d = !0);
778
778
  }), d && r.value.render();
779
779
  }
780
- l("labelChange", _.value), E();
780
+ a("labelChange", _.value), E();
781
781
  }, Lt = (s) => {
782
782
  s.visible = !s.visible, E();
783
783
  }, Bt = (s) => {
784
- const i = _.value.findIndex((a) => a.id === s);
785
- i > -1 && (_.value.splice(i, 1), l("labelChange", _.value), $.value === s && ($.value = _.value.length > 0 ? _.value[0].id : "", $.value && tt(_.value[0])), E());
784
+ const i = _.value.findIndex((l) => l.id === s);
785
+ i > -1 && (_.value.splice(i, 1), a("labelChange", _.value), $.value === s && ($.value = _.value.length > 0 ? _.value[0].id : "", $.value && tt(_.value[0])), E());
786
786
  };
787
787
  K(() => e.labels, (s) => {
788
788
  const i = JSON.parse(JSON.stringify(s || []));
789
789
  if (_.value = i, _.value.length > 0)
790
- if (!$.value || !_.value.find((a) => a.id === $.value))
790
+ if (!$.value || !_.value.find((l) => l.id === $.value))
791
791
  tt(_.value[0]);
792
792
  else {
793
- const a = _.value.find((d) => d.id === $.value);
794
- a && tt(a);
793
+ const l = _.value.find((d) => d.id === $.value);
794
+ l && tt(l);
795
795
  }
796
796
  else
797
797
  $.value = "";
@@ -812,13 +812,13 @@ const de = '<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//D
812
812
  }
813
813
  }, ut = () => {
814
814
  const s = e.batchImages[x.value];
815
- l("batchChange", {
815
+ a("batchChange", {
816
816
  currentIndex: x.value,
817
817
  total: e.batchImages.length,
818
818
  currentImageUrl: s.imageUrl,
819
819
  currentAnnotations: s.annotations || []
820
820
  });
821
- }, bt = (s = []) => {
821
+ }, Ct = (s = []) => {
822
822
  var f;
823
823
  if (!r.value) return;
824
824
  if (p.value = JSON.parse(JSON.stringify(s)), p.value.length === 0) {
@@ -826,11 +826,11 @@ const de = '<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//D
826
826
  return;
827
827
  }
828
828
  S.value = "loaded";
829
- const a = (r.value.getAnnotations() || []).filter((A) => !A.predictionId), d = p.value.map((A) => {
829
+ const l = (r.value.getAnnotations() || []).filter((A) => !A.predictionId), d = p.value.map((A) => {
830
830
  const P = JSON.parse(JSON.stringify(A.annotation));
831
831
  return P.id = P.id || `pred-${A.id}`, P.predictionId = A.id, P.modelRunId = A.modelRunId || P.modelRunId, P.confidence = A.confidence ?? P.confidence, P.reviewStatus = P.reviewStatus || "draft", P;
832
832
  });
833
- r.value.setAnnotations([...a, ...d]), l("prediction:loaded", {
833
+ r.value.setAnnotations([...l, ...d]), a("prediction:loaded", {
834
834
  meta: j(),
835
835
  modelRunId: (f = p.value[0]) == null ? void 0 : f.modelRunId,
836
836
  candidates: p.value
@@ -842,7 +842,7 @@ const de = '<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//D
842
842
  const d = (r.value.getAnnotations() || []).filter((A) => A.predictionId && s.includes(A.predictionId));
843
843
  return d.forEach((A) => {
844
844
  A.reviewStatus = "accepted";
845
- }), S.value = "applied", l("prediction:apply", {
845
+ }), S.value = "applied", a("prediction:apply", {
846
846
  meta: j(),
847
847
  modelRunId: (f = d[0]) == null ? void 0 : f.modelRunId,
848
848
  candidateIds: s,
@@ -852,10 +852,10 @@ const de = '<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//D
852
852
  }, Ot = (s, i) => {
853
853
  var f;
854
854
  if (!r.value) return;
855
- const a = r.value.getAnnotations() || [], d = a.filter((A) => !(A.predictionId && s.includes(A.predictionId)));
856
- r.value.setAnnotations(d), l("prediction:reject", {
855
+ const l = r.value.getAnnotations() || [], d = l.filter((A) => !(A.predictionId && s.includes(A.predictionId)));
856
+ r.value.setAnnotations(d), a("prediction:reject", {
857
857
  meta: j(),
858
- modelRunId: (f = a.find((A) => A.predictionId && s.includes(A.predictionId))) == null ? void 0 : f.modelRunId,
858
+ modelRunId: (f = l.find((A) => A.predictionId && s.includes(A.predictionId))) == null ? void 0 : f.modelRunId,
859
859
  candidateIds: s,
860
860
  reason: i
861
861
  });
@@ -864,15 +864,15 @@ const de = '<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//D
864
864
  }, Nt = (s) => {
865
865
  var i;
866
866
  (i = r.value) == null || i.setAnnotations(s);
867
- }, Ct = () => {
867
+ }, _t = () => {
868
868
  var s;
869
869
  return ((s = r.value) == null ? void 0 : s.getAnnotations()) || [];
870
870
  }, Wt = (s = "json") => {
871
- var a, d;
872
- const i = Ct();
871
+ var l, d;
872
+ const i = _t();
873
873
  return {
874
874
  format: s,
875
- image: ((a = e.batchImages[x.value]) == null ? void 0 : a.imageUrl) || ((d = e.image) == null ? void 0 : d.url) || "",
875
+ image: ((l = e.batchImages[x.value]) == null ? void 0 : l.imageUrl) || ((d = e.image) == null ? void 0 : d.url) || "",
876
876
  annotations: i
877
877
  };
878
878
  }, ot = (s) => {
@@ -881,23 +881,23 @@ const de = '<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//D
881
881
  var i;
882
882
  return s === x.value && r.value ? r.value.getAnnotations() || [] : ((i = e.batchImages[s]) == null ? void 0 : i.annotations) || [];
883
883
  }, Yt = (s) => s.type === "rectangle", Jt = (s) => s.type === "polygon", jt = (s) => s.type === "point", Xt = (s) => s.type === "rotatedRect", qt = (s) => s.type === "category", et = (s) => {
884
- var a, d;
885
- const i = (a = _.value.find((f) => f.name === s.label)) == null ? void 0 : a.color;
884
+ var l, d;
885
+ const i = (l = _.value.find((f) => f.name === s.label)) == null ? void 0 : l.color;
886
886
  return ((d = s.style) == null ? void 0 : d.strokeColor) || i || "#409eff";
887
- }, _t = (s) => {
887
+ }, kt = (s) => {
888
888
  const i = s.coordinates;
889
889
  return (i == null ? void 0 : i.points) || [];
890
890
  }, st = (s) => {
891
891
  const i = e.batchImages[s];
892
892
  if (i != null && i.width && (i != null && i.height))
893
893
  return { width: i.width, height: i.height };
894
- const a = i != null && i.imageUrl ? H.value[i.imageUrl] : void 0;
895
- return a || (i != null && i.imageUrl && it(i.imageUrl), { width: 1, height: 1 });
894
+ const l = i != null && i.imageUrl ? H.value[i.imageUrl] : void 0;
895
+ return l || (i != null && i.imageUrl && it(i.imageUrl), { width: 1, height: 1 });
896
896
  }, Kt = (s) => {
897
897
  const i = e.batchImages[s];
898
898
  return i != null && i.width && (i != null && i.height) ? !0 : i != null && i.imageUrl ? !!H.value[i.imageUrl] : !1;
899
899
  }, Zt = (s, i) => {
900
- const a = i.coordinates, d = st(s), f = et(i), A = Math.min(a.x1, a.x2), P = Math.min(a.y1, a.y2), ne = Math.max(a.x1, a.x2), oe = Math.max(a.y1, a.y2);
900
+ const l = i.coordinates, d = st(s), f = et(i), A = Math.min(l.x1, l.x2), P = Math.min(l.y1, l.y2), ne = Math.max(l.x1, l.x2), oe = Math.max(l.y1, l.y2);
901
901
  return {
902
902
  left: `${A / d.width * 100}%`,
903
903
  top: `${P / d.height * 100}%`,
@@ -907,8 +907,8 @@ const de = '<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//D
907
907
  backgroundColor: `${f}22`
908
908
  };
909
909
  }, Qt = (s, i) => {
910
- const a = st(s);
911
- return _t(i).map((d) => `${d.x / a.width * 100},${d.y / a.height * 100}`).join(" ");
910
+ const l = st(s);
911
+ return kt(i).map((d) => `${d.x / l.width * 100},${d.y / l.height * 100}`).join(" ");
912
912
  }, te = (s) => {
913
913
  const i = et(s);
914
914
  return {
@@ -916,29 +916,29 @@ const de = '<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//D
916
916
  stroke: i,
917
917
  strokeWidth: "1.4"
918
918
  };
919
- }, ee = (s, i, a) => {
920
- const d = st(s), f = et(a);
919
+ }, ee = (s, i, l) => {
920
+ const d = st(s), f = et(l);
921
921
  return {
922
922
  left: `${i.x / d.width * 100}%`,
923
923
  top: `${i.y / d.height * 100}%`,
924
924
  backgroundColor: f
925
925
  };
926
926
  }, se = (s, i) => {
927
- const a = i.coordinates, d = st(s), f = et(i), A = Math.abs(a.width), P = Math.abs(a.height);
927
+ const l = i.coordinates, d = st(s), f = et(i), A = Math.abs(l.width), P = Math.abs(l.height);
928
928
  return {
929
- left: `${(a.x - A / 2) / d.width * 100}%`,
930
- top: `${(a.y - P / 2) / d.height * 100}%`,
929
+ left: `${(l.x - A / 2) / d.width * 100}%`,
930
+ top: `${(l.y - P / 2) / d.height * 100}%`,
931
931
  width: `${A / d.width * 100}%`,
932
932
  height: `${P / d.height * 100}%`,
933
- transform: `rotate(${a.angle || 0}deg)`,
933
+ transform: `rotate(${l.angle || 0}deg)`,
934
934
  borderColor: f,
935
935
  backgroundColor: `${f}22`
936
936
  };
937
937
  }, ie = (s, i) => {
938
- const a = i.coordinates, d = st(s), f = et(i);
938
+ const l = i.coordinates, d = st(s), f = et(i);
939
939
  return {
940
- left: `${a.x / d.width * 100}%`,
941
- top: `${a.y / d.height * 100}%`,
940
+ left: `${l.x / d.width * 100}%`,
941
+ top: `${l.y / d.height * 100}%`,
942
942
  backgroundColor: `${f}d9`
943
943
  // ~85% opacity
944
944
  };
@@ -947,9 +947,9 @@ const de = '<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//D
947
947
  jumpTo: ot,
948
948
  setImage: Ft,
949
949
  setAnnotations: Nt,
950
- getAnnotations: Ct,
950
+ getAnnotations: _t,
951
951
  selectTool: Y,
952
- loadPredictionCandidates: bt,
952
+ loadPredictionCandidates: Ct,
953
953
  applyPredictions: Vt,
954
954
  rejectPredictions: Ot,
955
955
  exportAnnotations: Wt,
@@ -961,10 +961,10 @@ const de = '<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//D
961
961
  }];
962
962
  },
963
963
  getCurrentAnnotation: () => {
964
- var s, i, a;
964
+ var s, i, l;
965
965
  return {
966
966
  imageUrl: ((s = e.batchImages[x.value]) == null ? void 0 : s.imageUrl) || ((i = e.image) == null ? void 0 : i.url) || "",
967
- annotations: ((a = r.value) == null ? void 0 : a.getAnnotations()) || []
967
+ annotations: ((l = r.value) == null ? void 0 : l.getAnnotations()) || []
968
968
  };
969
969
  }
970
970
  }), K(() => {
@@ -974,7 +974,7 @@ const de = '<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//D
974
974
  var s;
975
975
  e.batchImages.length === 0 && ((s = e.image) != null && s.url) && W();
976
976
  }), K(() => e.predictionCandidates, (s) => {
977
- s && bt(s);
977
+ s && Ct(s);
978
978
  }, { immediate: !0, deep: !0 }), K(
979
979
  () => e.batchImages.map((s) => `${s.imageUrl}:${s.width || ""}x${s.height || ""}`),
980
980
  () => {
@@ -996,8 +996,8 @@ const de = '<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//D
996
996
  ref: g,
997
997
  class: "image-list-scroll"
998
998
  }, [
999
- (v(!0), m(N, null, J(w.batchImages, (a, d) => (v(), m("button", {
1000
- key: `${a.imageUrl}-${d}`,
999
+ (v(!0), m(N, null, J(w.batchImages, (l, d) => (v(), m("button", {
1000
+ key: `${l.imageUrl}-${d}`,
1001
1001
  ref_for: !0,
1002
1002
  ref: (f) => ht(f, d),
1003
1003
  class: X(["image-list-item", { active: d === x.value }]),
@@ -1005,7 +1005,7 @@ const de = '<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//D
1005
1005
  }, [
1006
1006
  h("div", Le, [
1007
1007
  h("img", {
1008
- src: a.imageUrl,
1008
+ src: l.imageUrl,
1009
1009
  alt: `第${d + 1}张`,
1010
1010
  class: "image-list-thumb"
1011
1011
  }, null, 8, Be),
@@ -1022,7 +1022,7 @@ const de = '<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//D
1022
1022
  points: Qt(d, f),
1023
1023
  style: U(te(f))
1024
1024
  }, null, 12, Ee)
1025
- ])) : jt(f) ? (v(!0), m(N, { key: 2 }, J(_t(f), (A, P) => (v(), m("div", {
1025
+ ])) : jt(f) ? (v(!0), m(N, { key: 2 }, J(kt(f), (A, P) => (v(), m("div", {
1026
1026
  key: `${f.id}-${P}`,
1027
1027
  class: "thumb-overlay-point",
1028
1028
  style: U(ee(d, A, f))
@@ -1046,27 +1046,27 @@ const de = '<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//D
1046
1046
  w.readOnly ? B("", !0) : (v(), m("div", Oe, [
1047
1047
  h("div", {
1048
1048
  class: X(["tool-btn", { active: k.value === "pan" }]),
1049
- onClick: i[0] || (i[0] = (a) => Y("pan")),
1049
+ onClick: i[0] || (i[0] = (l) => Y("pan")),
1050
1050
  title: "拖动"
1051
1051
  }, [
1052
1052
  R(L, { name: "rank" })
1053
1053
  ], 2),
1054
1054
  h("div", {
1055
1055
  class: X(["tool-btn", { active: k.value === "select" }]),
1056
- onClick: i[1] || (i[1] = (a) => Y("select")),
1056
+ onClick: i[1] || (i[1] = (l) => Y("select")),
1057
1057
  title: "选择"
1058
1058
  }, [
1059
1059
  R(L, { name: "pointer" })
1060
1060
  ], 2),
1061
1061
  i[5] || (i[5] = h("div", { class: "divider" }, null, -1)),
1062
- (v(!0), m(N, null, J(b.value, (a) => (v(), m("div", {
1063
- key: a,
1064
- class: X(["tool-btn", { active: k.value === a }]),
1065
- onClick: (d) => Y(a),
1066
- title: F(a)
1062
+ (v(!0), m(N, null, J(b.value, (l) => (v(), m("div", {
1063
+ key: l,
1064
+ class: X(["tool-btn", { active: k.value === l }]),
1065
+ onClick: (d) => Y(l),
1066
+ title: F(l)
1067
1067
  }, [
1068
1068
  R(L, {
1069
- name: I(a)
1069
+ name: I(l)
1070
1070
  }, null, 8, ["name"])
1071
1071
  ], 10, Fe))), 128)),
1072
1072
  i[6] || (i[6] = h("div", { class: "divider" }, null, -1)),
@@ -1110,7 +1110,7 @@ const de = '<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//D
1110
1110
  w.readOnly ? B("", !0) : (v(), m("div", Ge, [
1111
1111
  h("div", {
1112
1112
  class: "selector-trigger",
1113
- onClick: yt
1113
+ onClick: wt
1114
1114
  }, [
1115
1115
  Z.value ? (v(), m("div", Ye, [
1116
1116
  h("span", {
@@ -1127,17 +1127,17 @@ const de = '<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//D
1127
1127
  }, null, 8, ["class"])
1128
1128
  ]),
1129
1129
  G.value ? (v(), m("div", Xe, [
1130
- _.value.length === 0 ? (v(), m("div", qe, "请在右侧创建标签")) : (v(!0), m(N, { key: 1 }, J(_.value, (a) => (v(), m("div", {
1131
- key: a.id,
1132
- class: X(["dropdown-item", { active: $.value === a.id }]),
1133
- onClick: (d) => wt(a)
1130
+ _.value.length === 0 ? (v(), m("div", qe, "请在右侧创建标签")) : (v(!0), m(N, { key: 1 }, J(_.value, (l) => (v(), m("div", {
1131
+ key: l.id,
1132
+ class: X(["dropdown-item", { active: $.value === l.id }]),
1133
+ onClick: (d) => xt(l)
1134
1134
  }, [
1135
1135
  h("span", {
1136
1136
  class: "color-dot",
1137
- style: U({ backgroundColor: a.color })
1137
+ style: U({ backgroundColor: l.color })
1138
1138
  }, null, 4),
1139
- h("span", Ze, z(a.name), 1),
1140
- $.value === a.id ? (v(), vt(L, {
1139
+ h("span", Ze, z(l.name), 1),
1140
+ $.value === l.id ? (v(), vt(L, {
1141
1141
  key: 0,
1142
1142
  name: "aim",
1143
1143
  class: "check-icon"
@@ -1191,34 +1191,34 @@ const de = '<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//D
1191
1191
  }, "添加标签")
1192
1192
  ]),
1193
1193
  h("div", os, [
1194
- (v(!0), m(N, null, J(_.value, (a) => (v(), m("div", {
1195
- key: a.id,
1194
+ (v(!0), m(N, null, J(_.value, (l) => (v(), m("div", {
1195
+ key: l.id,
1196
1196
  class: "label-item",
1197
- style: U({ backgroundColor: a.color + "1A", color: a.color })
1197
+ style: U({ backgroundColor: l.color + "1A", color: l.color })
1198
1198
  }, [
1199
1199
  h("div", as, [
1200
1200
  h("label", {
1201
1201
  class: "color-wrapper",
1202
- style: U({ backgroundColor: a.color })
1202
+ style: U({ backgroundColor: l.color })
1203
1203
  }, [
1204
1204
  ft(h("input", {
1205
1205
  type: "color",
1206
- "onUpdate:modelValue": (d) => a.color = d,
1207
- onChange: (d) => $t(a),
1206
+ "onUpdate:modelValue": (d) => l.color = d,
1207
+ onChange: (d) => $t(l),
1208
1208
  style: { visibility: "hidden", width: "0", height: "0" }
1209
1209
  }, null, 40, ls), [
1210
- [mt, a.color]
1210
+ [mt, l.color]
1211
1211
  ])
1212
1212
  ], 4),
1213
1213
  h("span", {
1214
1214
  class: "label-name",
1215
- title: a.name
1216
- }, z(a.name), 9, cs),
1215
+ title: l.name
1216
+ }, z(l.name), 9, cs),
1217
1217
  h("span", {
1218
1218
  class: "action-icon eye",
1219
- onClick: (d) => Lt(a)
1219
+ onClick: (d) => Lt(l)
1220
1220
  }, [
1221
- a.visible ? (v(), vt(L, {
1221
+ l.visible ? (v(), vt(L, {
1222
1222
  key: 0,
1223
1223
  name: "view"
1224
1224
  })) : (v(), vt(L, {
@@ -1230,7 +1230,7 @@ const de = '<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//D
1230
1230
  i[9] || (i[9] = h("span", { class: "dots" }, "•••", -1)),
1231
1231
  h("span", {
1232
1232
  class: "delete-btn",
1233
- onClick: (d) => Bt(a.id),
1233
+ onClick: (d) => Bt(l.id),
1234
1234
  title: "删除"
1235
1235
  }, [
1236
1236
  R(L, { name: "delete" })
@@ -1256,7 +1256,7 @@ const de = '<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//D
1256
1256
  h("span", { class: "required" }, "*")
1257
1257
  ], -1)),
1258
1258
  ft(h("input", {
1259
- "onUpdate:modelValue": i[3] || (i[3] = (a) => C.value.name = a),
1259
+ "onUpdate:modelValue": i[3] || (i[3] = (l) => C.value.name = l),
1260
1260
  placeholder: "请输入标签名称",
1261
1261
  class: "modal-input",
1262
1262
  autofocus: ""
@@ -1273,7 +1273,7 @@ const de = '<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//D
1273
1273
  }, [
1274
1274
  ft(h("input", {
1275
1275
  type: "color",
1276
- "onUpdate:modelValue": i[4] || (i[4] = (a) => C.value.color = a),
1276
+ "onUpdate:modelValue": i[4] || (i[4] = (l) => C.value.color = l),
1277
1277
  class: "modal-color-picker"
1278
1278
  }, null, 512), [
1279
1279
  [mt, C.value.color]
@@ -1316,8 +1316,8 @@ const de = '<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//D
1316
1316
  fontSize: {}
1317
1317
  },
1318
1318
  setup(w) {
1319
- const t = w, n = M(null), e = M(!1), l = M(0), o = M(0), c = () => {
1320
- n.value && (l.value = n.value.naturalWidth, o.value = n.value.naturalHeight, e.value = !0);
1319
+ const t = w, n = M(null), e = M(!1), a = M(0), o = M(0), c = () => {
1320
+ n.value && (a.value = n.value.naturalWidth, o.value = n.value.naturalHeight, e.value = !0);
1321
1321
  }, g = V(() => t.fit === "contain" ? "xMidYMid meet" : "xMidYMid slice"), u = V(() => t.strokeWidth ?? 10), r = V(() => t.fontSize ?? 30), k = (C) => {
1322
1322
  var S;
1323
1323
  if ((S = C.style) != null && S.strokeColor) return C.style.strokeColor;
@@ -1363,7 +1363,7 @@ const de = '<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//D
1363
1363
  e.value ? (v(), m("svg", {
1364
1364
  key: 0,
1365
1365
  class: "annotation-overlay",
1366
- viewBox: `0 0 ${l.value} ${o.value}`,
1366
+ viewBox: `0 0 ${a.value} ${o.value}`,
1367
1367
  preserveAspectRatio: g.value
1368
1368
  }, [
1369
1369
  (v(!0), m(N, null, J(w.annotations, (p) => (v(), m(N, {
@@ -1454,7 +1454,7 @@ const de = '<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//D
1454
1454
  },
1455
1455
  emits: ["export", "update:images", "imageClick", "update:labels", "pageChange"],
1456
1456
  setup(w, { expose: t, emit: n }) {
1457
- const e = w, l = n, o = M("gallery"), c = M([]), g = M([]), u = M(0), r = M(null), k = M(null), x = M(null), D = V(() => {
1457
+ const e = w, a = n, o = M("gallery"), c = M([]), g = M([]), u = M(0), r = M(null), k = M(null), x = M(null), D = V(() => {
1458
1458
  var y, b;
1459
1459
  return ((b = (y = e.actionBar) == null ? void 0 : y.annotateButton) == null ? void 0 : b.show) === !0;
1460
1460
  }), _ = V(() => {
@@ -1495,13 +1495,15 @@ const de = '<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//D
1495
1495
  backgroundColor: y.color + "1A"
1496
1496
  // 1A represents ~10% opacity in hex
1497
1497
  });
1498
- K(() => e.images, (y) => {
1498
+ yt(() => {
1499
+ a("pageChange", { nowPage: "listPage" });
1500
+ }), K(() => e.images, (y) => {
1499
1501
  c.value = JSON.parse(JSON.stringify(y));
1500
1502
  }, { immediate: !0, deep: !0 }), K(() => e.labels, (y) => {
1501
1503
  g.value = JSON.parse(JSON.stringify(y || []));
1502
1504
  }, { immediate: !0, deep: !0 });
1503
1505
  const O = (y) => {
1504
- u.value = y, o.value = "editor", l("pageChange", { nowPage: "editPage" }), x.value && (x.value.scrollTop = 0), at(() => {
1506
+ u.value = y, o.value = "editor", a("pageChange", { nowPage: "editPage" }), x.value && (x.value.scrollTop = 0), at(() => {
1505
1507
  k.value && (k.value.scrollTop = 0), window.scrollTo(0, 0), requestAnimationFrame(() => {
1506
1508
  var b, I;
1507
1509
  (I = (b = r.value) == null ? void 0 : b.jumpTo) == null || I.call(b, y);
@@ -1512,7 +1514,7 @@ const de = '<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//D
1512
1514
  O(y);
1513
1515
  return;
1514
1516
  }
1515
- l("imageClick", { index: y, imageId: b.id, image: b });
1517
+ a("imageClick", { index: y, imageId: b.id, image: b });
1516
1518
  }, Z = (y) => c.value.findIndex((b) => b.id === y);
1517
1519
  t({
1518
1520
  openImageById: (y) => {
@@ -1524,7 +1526,7 @@ const de = '<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//D
1524
1526
  if (b < 0)
1525
1527
  return !1;
1526
1528
  const I = c.value[b];
1527
- return I ? (l("imageClick", { index: b, imageId: I.id, image: I }), !0) : !1;
1529
+ return I ? (a("imageClick", { index: b, imageId: I.id, image: I }), !0) : !1;
1528
1530
  },
1529
1531
  getFinalData: () => ({
1530
1532
  images: JSON.parse(JSON.stringify(c.value)),
@@ -1536,18 +1538,18 @@ const de = '<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//D
1536
1538
  const y = r.value.getCurrentAnnotation();
1537
1539
  c.value[u.value] && (c.value[u.value].annotations = y.annotations);
1538
1540
  }
1539
- o.value = "gallery", l("pageChange", { nowPage: "listPage" });
1541
+ o.value = "gallery", a("pageChange", { nowPage: "listPage" });
1540
1542
  }, nt = () => {
1541
- l("export", c.value);
1543
+ a("export", c.value);
1542
1544
  }, ht = (y) => {
1543
1545
  u.value = y.currentIndex, c.value[y.currentIndex] && (c.value[y.currentIndex].annotations = y.currentAnnotations);
1544
1546
  }, Q = (y) => {
1545
1547
  if (r.value && r.value.getCurrentAnnotation) {
1546
1548
  const b = r.value.getCurrentAnnotation();
1547
- c.value[u.value] && (c.value[u.value].annotations = b.annotations, l("update:images", c.value));
1549
+ c.value[u.value] && (c.value[u.value].annotations = b.annotations, a("update:images", c.value));
1548
1550
  }
1549
1551
  }, j = (y) => {
1550
- g.value = JSON.parse(JSON.stringify(y || [])), l("update:labels", g.value);
1552
+ g.value = JSON.parse(JSON.stringify(y || [])), a("update:labels", g.value);
1551
1553
  };
1552
1554
  return (y, b) => (v(), m("div", {
1553
1555
  ref_key: "batchRootRef",
@@ -1670,7 +1672,7 @@ const de = '<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//D
1670
1672
  ]))
1671
1673
  ], 512));
1672
1674
  }
1673
- }), ii = /* @__PURE__ */ rt(ti, [["__scopeId", "data-v-701c81a6"]]);
1675
+ }), ii = /* @__PURE__ */ rt(ti, [["__scopeId", "data-v-5bb1d03b"]]);
1674
1676
  export {
1675
1677
  ii as BatchAnnotator,
1676
1678
  bs as ImageAnnotator,