@8btc/whiteboard 0.0.1 → 0.0.2

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.
package/dist/index.js CHANGED
@@ -1,116 +1,116 @@
1
- var Dt = Object.defineProperty;
2
- var vt = (o) => {
1
+ var Wt = Object.defineProperty;
2
+ var Tt = (o) => {
3
3
  throw TypeError(o);
4
4
  };
5
- var Zt = (o, s, t) => s in o ? Dt(o, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[s] = t;
6
- var z = (o, s, t) => Zt(o, typeof s != "symbol" ? s + "" : s, t), mt = (o, s, t) => s.has(o) || vt("Cannot " + t);
7
- var i = (o, s, t) => (mt(o, s, "read from private field"), t ? t.call(o) : s.get(o)), d = (o, s, t) => s.has(o) ? vt("Cannot add the same private member more than once") : s instanceof WeakSet ? s.add(o) : s.set(o, t), N = (o, s, t, e) => (mt(o, s, "write to private field"), e ? e.call(o, t) : s.set(o, t), t), S = (o, s, t) => (mt(o, s, "access private method"), t);
8
- import { jsxs as U, jsx as w, Fragment as zt } from "react/jsx-runtime";
9
- import { useState as O, useEffect as xt, useRef as At } from "react";
10
- import R from "konva";
11
- import Yt from "mitt";
12
- import { v4 as $ } from "uuid";
13
- import { Slot as Xt } from "@radix-ui/react-slot";
14
- import { cva as Vt } from "class-variance-authority";
15
- import { clsx as Ut } from "clsx";
16
- import { twMerge as Ht } from "tailwind-merge";
17
- import { Minus as Ot, Plus as Ft, Undo2 as Lt, Redo2 as Wt } from "lucide-react";
18
- var f, l, P, K, q, j, B, J, Q, tt, et, bt;
19
- class Gt {
20
- constructor(s, t) {
21
- d(this, et);
5
+ var Gt = (o, e, t) => e in o ? Wt(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
6
+ var z = (o, e, t) => Gt(o, typeof e != "symbol" ? e + "" : e, t), wt = (o, e, t) => e.has(o) || Tt("Cannot " + t);
7
+ var r = (o, e, t) => (wt(o, e, "read from private field"), t ? t.call(o) : e.get(o)), d = (o, e, t) => e.has(o) ? Tt("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(o) : e.set(o, t), N = (o, e, t, s) => (wt(o, e, "write to private field"), s ? s.call(o, t) : e.set(o, t), t), M = (o, e, t) => (wt(o, e, "access private method"), t);
8
+ import { jsxs as F, jsx as w, Fragment as $t } from "react/jsx-runtime";
9
+ import { useState as G, useEffect as It, useRef as qt } from "react";
10
+ import D from "konva";
11
+ import Kt from "mitt";
12
+ import { v4 as J } from "uuid";
13
+ import { Slot as jt } from "@radix-ui/react-slot";
14
+ import { cva as Bt } from "class-variance-authority";
15
+ import { clsx as Jt } from "clsx";
16
+ import { twMerge as Qt } from "tailwind-merge";
17
+ import { Minus as te, Plus as ee, Undo2 as se, Redo2 as ie } from "lucide-react";
18
+ var f, l, X, Q, tt, et, st, it, nt, rt, ot, Xt;
19
+ class ne {
20
+ constructor(e, t) {
21
+ d(this, ot);
22
22
  d(this, f);
23
23
  d(this, l);
24
- d(this, P, { x: 0, y: 0, scale: 1 });
24
+ d(this, X, { x: 0, y: 0, scale: 1 });
25
25
  /**
26
26
  * 处理滚轮缩放和平移
27
27
  */
28
- d(this, K, (s) => {
29
- s.evt.preventDefault();
30
- const e = i(this, l).getPointerPosition();
31
- if (e)
32
- if (s.evt.ctrlKey) {
33
- const r = i(this, P).scale, n = {
34
- x: (e.x - i(this, P).x) / r,
35
- y: (e.y - i(this, P).y) / r
36
- }, a = 1.01, h = s.evt.deltaY > 0 ? -1 : 1, c = Math.min(Math.abs(s.evt.deltaY), 10);
37
- let m = r;
28
+ d(this, Q, (e) => {
29
+ e.evt.preventDefault();
30
+ const s = r(this, l).getPointerPosition();
31
+ if (s)
32
+ if (e.evt.ctrlKey) {
33
+ const n = r(this, X).scale, i = {
34
+ x: (s.x - r(this, X).x) / n,
35
+ y: (s.y - r(this, X).y) / n
36
+ }, a = 1.01, h = e.evt.deltaY > 0 ? -1 : 1, c = Math.min(Math.abs(e.evt.deltaY), 10);
37
+ let g = n;
38
38
  for (let p = 0; p < c; p++)
39
- m = h > 0 ? m * a : m / a;
40
- const g = Math.max(0.1, Math.min(5, m)), I = {
41
- x: e.x - n.x * g,
42
- y: e.y - n.y * g
39
+ g = h > 0 ? g * a : g / a;
40
+ const m = Math.max(0.1, Math.min(5, g)), v = {
41
+ x: s.x - i.x * m,
42
+ y: s.y - i.y * m
43
43
  };
44
- i(this, f).updateViewport({ x: I.x, y: I.y, scale: g });
44
+ r(this, f).updateViewport({ x: v.x, y: v.y, scale: m });
45
45
  } else {
46
- const r = s.evt.shiftKey ? s.evt.deltaY : s.evt.deltaX, n = s.evt.shiftKey ? 0 : s.evt.deltaY;
47
- i(this, f).updateViewport({
48
- x: i(this, P).x - r,
49
- y: i(this, P).y - n
46
+ const n = e.evt.shiftKey ? e.evt.deltaY : e.evt.deltaX, i = e.evt.shiftKey ? 0 : e.evt.deltaY;
47
+ r(this, f).updateViewport({
48
+ x: r(this, X).x - n,
49
+ y: r(this, X).y - i
50
50
  });
51
51
  }
52
52
  });
53
- d(this, q, (s) => {
54
- const t = i(this, f).getState().toolType;
55
- if (s.evt.button !== 0 || t === "hand")
53
+ d(this, tt, (e) => {
54
+ const t = r(this, f).getState().toolType;
55
+ if (e.evt.button !== 0 || t === "hand")
56
56
  return;
57
- const e = s.target === i(this, l), r = i(this, l).getRelativePointerPosition();
58
- if (t === "select" && !e) {
59
- const n = s.target.id();
60
- n && i(this, f).selectNode(n, s.evt.shiftKey);
57
+ const s = e.target === r(this, l), n = r(this, l).getRelativePointerPosition();
58
+ if (t === "select" && !s) {
59
+ const i = e.target.id();
60
+ i && r(this, f).selectNode(i, e.evt.shiftKey);
61
61
  return;
62
62
  }
63
- if (t === "rectangle" && r && i(this, f).createDraftNode(t, r), t === "image-marker" && r) {
64
- const n = i(this, f).findImageAtPosition(r);
65
- if (console.log(n, "imageShape"), n) {
66
- const a = n.width(), h = n.height();
63
+ if (t === "rectangle" && n && r(this, f).createDraftNode(t, n), t === "image-marker" && n) {
64
+ const i = r(this, f).findImageAtPosition(n);
65
+ if (console.log(i, "imageShape"), i) {
66
+ const a = i.width(), h = i.height();
67
67
  if (a && h) {
68
68
  const c = {
69
- x: n.x(),
70
- y: n.y(),
69
+ x: i.x(),
70
+ y: i.y(),
71
71
  width: a,
72
72
  height: h
73
73
  };
74
- i(this, f).createDraftNode(t, r, {
75
- parent: n.id(),
74
+ r(this, f).createDraftNode(t, n, {
75
+ parent: i.id(),
76
76
  bounds: c,
77
- startPosition: r
77
+ startPosition: n
78
78
  });
79
79
  }
80
80
  }
81
81
  }
82
- i(this, f).selectNode();
82
+ r(this, f).selectNode();
83
83
  });
84
- d(this, j, () => {
85
- const s = i(this, f).getState().toolType;
86
- if (s === "hand")
84
+ d(this, et, () => {
85
+ const e = r(this, f).getState().toolType;
86
+ if (e === "hand")
87
87
  return;
88
- const t = i(this, l).getRelativePointerPosition();
89
- (s === "rectangle" || s === "image-marker") && t && i(this, f).updateDraftNode(t);
88
+ const t = r(this, l).getRelativePointerPosition();
89
+ (e === "rectangle" || e === "image-marker") && t && r(this, f).updateDraftNode(t);
90
90
  });
91
- d(this, B, () => {
92
- const s = i(this, f).getState().toolType;
93
- s !== "hand" && (s === "rectangle" || s === "image-marker") && i(this, f).finalizeDraftNode();
91
+ d(this, st, () => {
92
+ const e = r(this, f).getState().toolType;
93
+ e !== "hand" && (e === "rectangle" || e === "image-marker") && r(this, f).finalizeDraftNode();
94
94
  });
95
- d(this, J, (s) => {
96
- if (s.target !== i(this, l))
95
+ d(this, it, (e) => {
96
+ if (e.target !== r(this, l))
97
97
  return;
98
- const t = i(this, f).getState().toolType;
98
+ const t = r(this, f).getState().toolType;
99
99
  t === "hand" ? this.setCursor("grabbing") : t === "select" && this.setCursor("all-scroll");
100
100
  });
101
- d(this, Q, (s) => {
102
- s.target === i(this, l) && i(this, f).updateViewport({
103
- x: i(this, l).x(),
104
- y: i(this, l).y()
101
+ d(this, nt, (e) => {
102
+ e.target === r(this, l) && r(this, f).updateViewport({
103
+ x: r(this, l).x(),
104
+ y: r(this, l).y()
105
105
  });
106
106
  });
107
- d(this, tt, (s) => {
108
- s.target === i(this, l) && (i(this, f).updateViewport({
109
- x: i(this, l).x(),
110
- y: i(this, l).y()
107
+ d(this, rt, (e) => {
108
+ e.target === r(this, l) && (r(this, f).updateViewport({
109
+ x: r(this, l).x(),
110
+ y: r(this, l).y()
111
111
  }), this.resetCursor());
112
112
  });
113
- N(this, f, s), N(this, l, new R.Stage({
113
+ N(this, f, e), N(this, l, new D.Stage({
114
114
  container: t.container,
115
115
  width: t.width,
116
116
  height: t.height,
@@ -120,185 +120,185 @@ class Gt {
120
120
  scaleY: 1,
121
121
  draggable: t.draggable ?? !1,
122
122
  className: t.className
123
- })), S(this, et, bt).call(this);
123
+ })), M(this, ot, Xt).call(this);
124
124
  }
125
125
  /**
126
126
  * 获取原生 Konva.Stage 实例
127
127
  */
128
128
  getStage() {
129
- return i(this, l);
129
+ return r(this, l);
130
130
  }
131
131
  /**
132
132
  * 获取当前视口状态
133
133
  */
134
134
  getViewport() {
135
- return { ...i(this, P) };
135
+ return { ...r(this, X) };
136
136
  }
137
137
  /**
138
138
  * 设置视口(包括位置、缩放和尺寸)
139
139
  */
140
- setViewport(s) {
141
- const t = { ...i(this, P), ...s };
142
- N(this, P, t), s.x !== void 0 && i(this, l).x(s.x), s.y !== void 0 && i(this, l).y(s.y), s.scale !== void 0 && (i(this, l).scaleX(s.scale), i(this, l).scaleY(s.scale)), s.width !== void 0 && i(this, l).width(s.width), s.height !== void 0 && i(this, l).height(s.height);
140
+ setViewport(e) {
141
+ const t = { ...r(this, X), ...e };
142
+ N(this, X, t), e.x !== void 0 && r(this, l).x(e.x), e.y !== void 0 && r(this, l).y(e.y), e.scale !== void 0 && (r(this, l).scaleX(e.scale), r(this, l).scaleY(e.scale)), e.width !== void 0 && r(this, l).width(e.width), e.height !== void 0 && r(this, l).height(e.height);
143
143
  }
144
144
  /**
145
145
  * 设置是否可拖拽
146
146
  */
147
- setDraggable(s) {
148
- i(this, l).draggable(s);
147
+ setDraggable(e) {
148
+ r(this, l).draggable(e);
149
149
  }
150
150
  /**
151
151
  * 设置光标样式
152
152
  */
153
- setCursor(s) {
154
- const t = i(this, l).container();
155
- t.style.cursor = s;
153
+ setCursor(e) {
154
+ const t = r(this, l).container();
155
+ t.style.cursor = e;
156
156
  }
157
157
  /**
158
158
  * 重置光标样式
159
159
  */
160
160
  resetCursor() {
161
- const s = i(this, l).container();
162
- if (i(this, f).getState().toolType === "hand") {
163
- s.style.cursor = "grab";
161
+ const e = r(this, l).container();
162
+ if (r(this, f).getState().toolType === "hand") {
163
+ e.style.cursor = "grab";
164
164
  return;
165
165
  }
166
- s.style.cursor = "default";
166
+ e.style.cursor = "default";
167
167
  }
168
168
  /**
169
169
  * 销毁 Stage
170
170
  */
171
171
  destroy() {
172
- i(this, l).destroy();
172
+ r(this, l).destroy();
173
173
  }
174
174
  }
175
- f = new WeakMap(), l = new WeakMap(), P = new WeakMap(), K = new WeakMap(), q = new WeakMap(), j = new WeakMap(), B = new WeakMap(), J = new WeakMap(), Q = new WeakMap(), tt = new WeakMap(), et = new WeakSet(), /**
175
+ f = new WeakMap(), l = new WeakMap(), X = new WeakMap(), Q = new WeakMap(), tt = new WeakMap(), et = new WeakMap(), st = new WeakMap(), it = new WeakMap(), nt = new WeakMap(), rt = new WeakMap(), ot = new WeakSet(), /**
176
176
  * 设置事件监听器
177
177
  */
178
- bt = function() {
179
- i(this, l).on("wheel", i(this, K)), i(this, l).on("pointerdown", i(this, q)), i(this, l).on("pointermove", i(this, j)), i(this, l).on("pointerup", i(this, B)), i(this, l).on("dragstart", i(this, J)), i(this, l).on("dragmove", i(this, Q)), i(this, l).on("dragend", i(this, tt));
178
+ Xt = function() {
179
+ r(this, l).on("wheel", r(this, Q)), r(this, l).on("pointerdown", r(this, tt)), r(this, l).on("pointermove", r(this, et)), r(this, l).on("pointerup", r(this, st)), r(this, l).on("dragstart", r(this, it)), r(this, l).on("dragmove", r(this, nt)), r(this, l).on("dragend", r(this, rt));
180
180
  };
181
- var F, x, st, it, rt, nt, ot, at, ht, Et;
182
- class $t {
183
- constructor(s, t) {
184
- d(this, ht);
185
- d(this, F);
186
- d(this, x);
181
+ var q, y, at, ht, ct, dt, lt, mt, gt, Dt;
182
+ class re {
183
+ constructor(e, t) {
184
+ d(this, gt);
185
+ d(this, q);
186
+ d(this, y);
187
187
  /**
188
188
  * 处理 transformstart 事件
189
189
  */
190
- d(this, st, () => {
190
+ d(this, at, () => {
191
191
  this.emitPositionChange();
192
192
  });
193
193
  /**
194
194
  * 处理 transform 事件
195
195
  */
196
- d(this, it, () => {
196
+ d(this, ht, () => {
197
197
  console.log("transforming..."), this.emitPositionChange();
198
198
  });
199
199
  /**
200
200
  * 处理 transformend 事件
201
201
  */
202
- d(this, rt, () => {
202
+ d(this, ct, () => {
203
203
  this.emitPositionChange();
204
204
  });
205
205
  /**
206
206
  * 处理 dragstart 事件
207
207
  */
208
- d(this, nt, () => {
208
+ d(this, dt, () => {
209
209
  this.emitPositionChange();
210
210
  });
211
211
  /**
212
212
  * 处理 dragmove 事件
213
213
  */
214
- d(this, ot, () => {
214
+ d(this, lt, () => {
215
215
  this.emitPositionChange();
216
216
  });
217
217
  /**
218
218
  * 处理 dragend 事件
219
219
  */
220
- d(this, at, () => {
220
+ d(this, mt, () => {
221
221
  this.emitPositionChange();
222
222
  });
223
- N(this, F, s), N(this, x, new R.Transformer({
223
+ N(this, q, e), N(this, y, new D.Transformer({
224
224
  rotateEnabled: t?.rotateEnabled ?? !0,
225
225
  ignoreStroke: t?.ignoreStroke ?? !0,
226
226
  anchorSize: t?.anchorSize ?? 8,
227
227
  borderDash: t?.borderDash ?? [4, 4],
228
228
  anchorCornerRadius: t?.anchorCornerRadius ?? 4,
229
229
  padding: t?.padding ?? 6
230
- })), S(this, ht, Et).call(this);
230
+ })), M(this, gt, Dt).call(this);
231
231
  }
232
232
  /**
233
233
  * 获取原生 Konva.Transformer 实例
234
234
  */
235
235
  getTransformer() {
236
- return i(this, x);
236
+ return r(this, y);
237
237
  }
238
238
  /**
239
239
  * 获取 Transformer 的位置信息
240
240
  */
241
241
  getPosition() {
242
- if (i(this, x).nodes().length === 0)
242
+ if (r(this, y).nodes().length === 0)
243
243
  return null;
244
- const t = i(this, x).getClientRect();
244
+ const t = r(this, y).getClientRect();
245
245
  return {
246
246
  x: t.x,
247
247
  y: t.y,
248
248
  width: t.width,
249
249
  height: t.height,
250
- rotation: i(this, x).rotation()
250
+ rotation: r(this, y).rotation()
251
251
  };
252
252
  }
253
253
  /**
254
254
  * 设置要变换的节点
255
255
  */
256
- setNodes(s) {
257
- if (s.length === 0) {
256
+ setNodes(e) {
257
+ if (e.length === 0) {
258
258
  this.clearNodes();
259
259
  return;
260
260
  }
261
- i(this, x).nodes(s), i(this, x).moveToTop(), this.emitPositionChange();
261
+ r(this, y).nodes(e), r(this, y).moveToTop(), this.emitPositionChange();
262
262
  }
263
263
  /**
264
264
  * 获取当前变换的节点
265
265
  */
266
266
  getNodes() {
267
- return i(this, x).nodes();
267
+ return r(this, y).nodes();
268
268
  }
269
269
  /**
270
270
  * 清除所有节点
271
271
  */
272
272
  clearNodes() {
273
- i(this, x).nodes([]), i(this, x).moveToBottom(), this.emitPositionChange();
273
+ r(this, y).nodes([]), r(this, y).moveToBottom(), this.emitPositionChange();
274
274
  }
275
275
  /**
276
276
  * emit Transformer 位置
277
277
  */
278
278
  emitPositionChange() {
279
- const s = this.getPosition();
280
- i(this, F).emitEvent("transformer:positionChange", s);
279
+ const e = this.getPosition();
280
+ r(this, q).emitEvent("transformer:positionChange", e);
281
281
  }
282
282
  /**
283
283
  * 销毁 Transformer
284
284
  */
285
285
  destroy() {
286
- i(this, x).destroy();
286
+ r(this, y).destroy();
287
287
  }
288
288
  }
289
- F = new WeakMap(), x = new WeakMap(), st = new WeakMap(), it = new WeakMap(), rt = new WeakMap(), nt = new WeakMap(), ot = new WeakMap(), at = new WeakMap(), ht = new WeakSet(), /**
289
+ q = new WeakMap(), y = new WeakMap(), at = new WeakMap(), ht = new WeakMap(), ct = new WeakMap(), dt = new WeakMap(), lt = new WeakMap(), mt = new WeakMap(), gt = new WeakSet(), /**
290
290
  * 设置事件监听器
291
291
  */
292
- Et = function() {
293
- i(this, x).on("transformstart", i(this, st)), i(this, x).on("transform", i(this, it)), i(this, x).on("transformend", i(this, rt)), i(this, x).on("dragstart", i(this, nt)), i(this, x).on("dragmove", i(this, ot)), i(this, x).on("dragend", i(this, at));
292
+ Dt = function() {
293
+ r(this, y).on("transformstart", r(this, at)), r(this, y).on("transform", r(this, ht)), r(this, y).on("transformend", r(this, ct)), r(this, y).on("dragstart", r(this, dt)), r(this, y).on("dragmove", r(this, lt)), r(this, y).on("dragend", r(this, mt));
294
294
  };
295
- class Kt {
296
- constructor(s) {
295
+ class oe {
296
+ constructor(e) {
297
297
  z(this, "_past", []);
298
298
  z(this, "_present");
299
299
  z(this, "_future", []);
300
300
  z(this, "_emitter");
301
- this._present = s, this._emitter = Yt();
301
+ this._present = e, this._emitter = Kt();
302
302
  }
303
303
  /**
304
304
  * 获取当前状态
@@ -331,36 +331,36 @@ class Kt {
331
331
  /**
332
332
  * 订阅状态事件
333
333
  */
334
- on(s, t) {
335
- this._emitter.on(s, t);
334
+ on(e, t) {
335
+ this._emitter.on(e, t);
336
336
  }
337
337
  /**
338
338
  * 取消订阅状态事件
339
339
  */
340
- off(s, t) {
341
- this._emitter.off(s, t);
340
+ off(e, t) {
341
+ this._emitter.off(e, t);
342
342
  }
343
343
  /**
344
344
  * 发送事件
345
345
  */
346
- emit(s, t) {
347
- this._emitter.emit(s, t);
346
+ emit(e, t) {
347
+ this._emitter.emit(e, t);
348
348
  }
349
349
  /**
350
350
  * 撤销操作
351
351
  */
352
352
  undo() {
353
353
  if (this._past.length === 0) return;
354
- const s = this._past[this._past.length - 1], t = this._past.slice(0, this._past.length - 1);
355
- this._past = t, this._future = [this._present, ...this._future], this._present = s, this._syncState(s), this._emitter.emit("state:undo", s), this._emitter.emit("state:change", s);
354
+ const e = this._past[this._past.length - 1], t = this._past.slice(0, this._past.length - 1);
355
+ this._past = t, this._future = [this._present, ...this._future], this._present = e, this._syncState(e), this._emitter.emit("state:undo", e), this._emitter.emit("state:change", e);
356
356
  }
357
357
  /**
358
358
  * 重做操作
359
359
  */
360
360
  redo() {
361
361
  if (this._future.length === 0) return;
362
- const s = this._future[0], t = this._future.slice(1);
363
- this._past = [...this._past, this._present], this._future = t, this._present = s, this._syncState(s), this._emitter.emit("state:redo", s), this._emitter.emit("state:change", s);
362
+ const e = this._future[0], t = this._future.slice(1);
363
+ this._past = [...this._past, this._present], this._future = t, this._present = e, this._syncState(e), this._emitter.emit("state:redo", e), this._emitter.emit("state:change", e);
364
364
  }
365
365
  /**
366
366
  * 重置历史记录
@@ -373,16 +373,16 @@ class Kt {
373
373
  * @param partial - 部分状态更新
374
374
  * @param addToHistory - 是否添加到历史记录
375
375
  */
376
- _updateState(s, t = !0) {
377
- const e = { ...this._present, ...s };
378
- t && (this._past = [...this._past, this._present], this._future = []), this._present = e, this._emitter.emit("state:change", e);
376
+ _updateState(e, t = !0) {
377
+ const s = { ...this._present, ...e };
378
+ t && (this._past = [...this._past, this._present], this._future = []), this._present = s, this._emitter.emit("state:change", s);
379
379
  }
380
380
  /**
381
381
  * 同步状态到外部系统(由子类实现)
382
382
  * @param _state - 要同步的状态
383
383
  */
384
384
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
385
- _syncState(s) {
385
+ _syncState(e) {
386
386
  }
387
387
  /**
388
388
  * 清理资源
@@ -391,33 +391,33 @@ class Kt {
391
391
  this._emitter.all.clear();
392
392
  }
393
393
  }
394
- const wt = "shapeNameForSelect", y = {
394
+ const $ = "shapeNameForSelect", u = {
395
395
  CORNER_RADIUS: 6,
396
396
  MIN_SIZE: 10
397
- }, V = {
397
+ }, O = {
398
398
  MIN_SIZE: 10
399
- }, St = {
399
+ }, kt = {
400
400
  MIN_SIZE: 10
401
401
  };
402
- function qt(o, s, t) {
403
- return 2 * (s + o - t * (4 - Math.PI));
402
+ function ae(o, e, t) {
403
+ return 2 * (e + o - t * (4 - Math.PI));
404
404
  }
405
- function jt(o, s, t) {
406
- let e = 1, r = 0, n = 0;
405
+ function he(o, e, t) {
406
+ let s = 1, n = 0, i = 0;
407
407
  switch (t) {
408
408
  case "dashed":
409
- r = Math.min(s * 2, o / 4);
409
+ n = Math.min(e * 2, o / 4);
410
410
  break;
411
411
  case "dotted":
412
- e = 8, r = s / e;
412
+ s = 8, n = e / s;
413
413
  break;
414
414
  default:
415
415
  return [];
416
416
  }
417
- let a = Math.floor(o / r / (2 * e));
418
- return a = Math.max(a, 3), r = o / a / (2 * e), n = (o - a * r) / a, [r, n];
417
+ let a = Math.floor(o / n / (2 * s));
418
+ return a = Math.max(a, 3), n = o / a / (2 * s), i = (o - a * n) / a, [n, i];
419
419
  }
420
- function Bt(o) {
420
+ function ce(o) {
421
421
  switch (o) {
422
422
  case "small":
423
423
  return 2;
@@ -431,24 +431,24 @@ function Bt(o) {
431
431
  return 3;
432
432
  }
433
433
  }
434
- function Jt(o) {
434
+ function de(o) {
435
435
  return Array.isArray(o) && o.length > 1 ? o[0] + o[1] : 0;
436
436
  }
437
- function _t(o) {
437
+ function Pt(o) {
438
438
  return {
439
- width: Math.max(St.MIN_SIZE, o.width() * o.scaleX()),
440
- height: Math.max(St.MIN_SIZE, o.height() * o.scaleY())
439
+ width: Math.max(kt.MIN_SIZE, o.width() * o.scaleX()),
440
+ height: Math.max(kt.MIN_SIZE, o.height() * o.scaleY())
441
441
  };
442
442
  }
443
- class Nt {
444
- constructor(s, t) {
443
+ class bt {
444
+ constructor(e, t) {
445
445
  z(this, "core");
446
446
  z(this, "node");
447
447
  z(this, "element");
448
448
  z(this, "toolTypeChangeHandler");
449
- this.core = s, this.node = t, this.element = this.createElement(), this.toolTypeChangeHandler = (e) => {
450
- const r = e === "select";
451
- this.element.listening(r);
449
+ this.core = e, this.node = t, this.element = this.createElement(), this.toolTypeChangeHandler = (s) => {
450
+ const n = s === "select";
451
+ this.element.listening(n);
452
452
  }, this.toolTypeChangeHandler(this.core.getToolType()), this.core.on("toolType:change", this.toolTypeChangeHandler);
453
453
  }
454
454
  /**
@@ -470,13 +470,13 @@ class Nt {
470
470
  this.core.off("toolType:change", this.toolTypeChangeHandler), this.element.destroy();
471
471
  }
472
472
  }
473
- function Qt(o, s) {
474
- if (!s || s === 0)
473
+ function le(o, e) {
474
+ if (!e || e === 0)
475
475
  return null;
476
- const t = new R.Animation((e) => {
477
- if (!e) return;
478
- const r = -e.time / 10 % s;
479
- o.dashOffset(r);
476
+ const t = new D.Animation((s) => {
477
+ if (!s) return;
478
+ const n = -s.time / 10 % e;
479
+ o.dashOffset(n);
480
480
  }, o.getLayer());
481
481
  return {
482
482
  start: () => t.start(),
@@ -484,37 +484,37 @@ function Qt(o, s) {
484
484
  isRunning: () => t.isRunning()
485
485
  };
486
486
  }
487
- var _, D, gt, pt, kt;
488
- class te extends Nt {
489
- constructor(t, e) {
490
- super(t, e);
491
- d(this, D);
492
- d(this, _, null);
493
- e.style.animated && S(this, D, gt).call(this), S(this, D, kt).call(this, this.getElement());
487
+ var I, Z, vt, Nt, Zt;
488
+ class me extends bt {
489
+ constructor(t, s) {
490
+ super(t, s);
491
+ d(this, Z);
492
+ d(this, I, null);
493
+ s.style.animated && M(this, Z, vt).call(this), M(this, Z, Zt).call(this, this.getElement());
494
494
  }
495
495
  createElement() {
496
496
  const t = Math.max(
497
- this.node.props.width ?? y.MIN_SIZE,
498
- y.MIN_SIZE
499
- ), e = Math.max(
500
- this.node.props.height ?? y.MIN_SIZE,
501
- y.MIN_SIZE
502
- ), r = {
497
+ this.node.props.width ?? u.MIN_SIZE,
498
+ u.MIN_SIZE
499
+ ), s = Math.max(
500
+ this.node.props.height ?? u.MIN_SIZE,
501
+ u.MIN_SIZE
502
+ ), n = {
503
503
  id: this.node.id,
504
504
  ...this.node.props,
505
505
  ...this.node.style,
506
506
  width: t,
507
- height: e,
508
- cornerRadius: y.CORNER_RADIUS,
509
- name: wt,
507
+ height: s,
508
+ cornerRadius: u.CORNER_RADIUS,
509
+ name: $,
510
510
  draggable: !0,
511
511
  stroke: "black",
512
512
  strokeWidth: 2
513
- }, n = new R.Rect(r);
514
- return n.setAttrs({
513
+ }, i = new D.Rect(n);
514
+ return i.setAttrs({
515
515
  width: t,
516
- height: e
517
- }), n;
516
+ height: s
517
+ }), i;
518
518
  }
519
519
  /**
520
520
  * 获取 Konva.Rect 实例
@@ -538,88 +538,88 @@ class te extends Nt {
538
538
  ...t.style
539
539
  }
540
540
  };
541
- const e = this.getElement();
542
- e.x(this.node.props.x), e.y(this.node.props.y);
543
- const r = Math.max(
544
- this.node.props.width ?? y.MIN_SIZE,
545
- y.MIN_SIZE
546
- ), n = Math.max(
547
- this.node.props.height ?? y.MIN_SIZE,
548
- y.MIN_SIZE
541
+ const s = this.getElement();
542
+ s.x(this.node.props.x), s.y(this.node.props.y);
543
+ const n = Math.max(
544
+ this.node.props.width ?? u.MIN_SIZE,
545
+ u.MIN_SIZE
546
+ ), i = Math.max(
547
+ this.node.props.height ?? u.MIN_SIZE,
548
+ u.MIN_SIZE
549
549
  );
550
- e.width(r), e.height(n), this.node.style.animated && !i(this, _) ? S(this, D, gt).call(this) : !this.node.style.animated && i(this, _) && S(this, D, pt).call(this);
550
+ s.width(n), s.height(i), this.node.style.animated && !r(this, I) ? M(this, Z, vt).call(this) : !this.node.style.animated && r(this, I) && M(this, Z, Nt).call(this);
551
551
  }
552
552
  /**
553
553
  * 销毁
554
554
  */
555
555
  destroy() {
556
- S(this, D, pt).call(this), super.destroy();
556
+ M(this, Z, Nt).call(this), super.destroy();
557
557
  }
558
558
  }
559
- _ = new WeakMap(), D = new WeakSet(), /**
559
+ I = new WeakMap(), Z = new WeakSet(), /**
560
560
  * 初始化动画
561
561
  */
562
- gt = function() {
563
- const t = this.getElement(), e = t.dash();
564
- if (!e || e.length === 0) return;
565
- const r = Jt(e);
566
- N(this, _, Qt(t, r)), i(this, _) && i(this, _).start();
562
+ vt = function() {
563
+ const t = this.getElement(), s = t.dash();
564
+ if (!s || s.length === 0) return;
565
+ const n = de(s);
566
+ N(this, I, le(t, n)), r(this, I) && r(this, I).start();
567
567
  }, /**
568
568
  * 销毁动画
569
569
  */
570
- pt = function() {
571
- i(this, _) && (i(this, _).stop(), N(this, _, null));
570
+ Nt = function() {
571
+ r(this, I) && (r(this, I).stop(), N(this, I, null));
572
572
  }, /**
573
573
  * 设置事件处理器
574
574
  */
575
- kt = function(t = void 0) {
576
- const e = t ?? this.getElement();
577
- e.on("transformstart", () => {
578
- this.node.style.animated && i(this, _) && i(this, _).stop();
579
- }), e.on("transform", (r) => {
580
- const n = r.target, { width: a, height: h } = _t(n), c = qt(a, h, y.CORNER_RADIUS), m = jt(
575
+ Zt = function(t = void 0) {
576
+ const s = t ?? this.getElement();
577
+ s.on("transformstart", () => {
578
+ this.node.style.animated && r(this, I) && r(this, I).stop();
579
+ }), s.on("transform", (n) => {
580
+ const i = n.target, { width: a, height: h } = Pt(i), c = ae(a, h, u.CORNER_RADIUS), g = he(
581
581
  c,
582
- Bt(this.node.style.size),
582
+ ce(this.node.style.size),
583
583
  this.node.style.line
584
584
  );
585
- n.scale({ x: 1, y: 1 }), n.width(a), n.height(h), n.dash(m.map((g) => g * this.core.getStageScale()));
586
- }), e.on("transformend", (r) => {
587
- const n = r.target, { width: a, height: h } = _t(n), c = {
585
+ i.scale({ x: 1, y: 1 }), i.width(a), i.height(h), i.dash(g.map((m) => m * this.core.getStageScale()));
586
+ }), s.on("transformend", (n) => {
587
+ const i = n.target, { width: a, height: h } = Pt(i), c = {
588
588
  ...this.node.props,
589
- x: n.x(),
590
- y: n.y(),
589
+ x: i.x(),
590
+ y: i.y(),
591
591
  width: a,
592
592
  height: h,
593
- rotation: n.rotation()
593
+ rotation: i.rotation()
594
594
  };
595
595
  this.node.props = c, this.core._syncNodeFromElement(this.node.id, {
596
596
  props: c
597
- }), this.node.style.animated && i(this, _)?.isRunning() === !1 && i(this, _).start();
598
- }), e.on("dragend", (r) => {
599
- const n = r.target, a = {
597
+ }), this.node.style.animated && r(this, I)?.isRunning() === !1 && r(this, I).start();
598
+ }), s.on("dragend", (n) => {
599
+ const i = n.target, a = {
600
600
  ...this.node.props,
601
- x: n.x(),
602
- y: n.y()
601
+ x: i.x(),
602
+ y: i.y()
603
603
  };
604
604
  this.node.props = a, this.core._syncNodeFromElement(this.node.id, {
605
605
  props: a
606
606
  });
607
607
  });
608
608
  };
609
- var E, ut, Ct, yt, ft;
610
- class ee extends Nt {
611
- constructor(t, e) {
612
- super(t, e);
613
- d(this, E);
614
- S(this, E, ut).call(this), S(this, E, Ct).call(this, this.getElement());
609
+ var k, St, zt, Mt, _t;
610
+ class ge extends bt {
611
+ constructor(t, s) {
612
+ super(t, s);
613
+ d(this, k);
614
+ M(this, k, St).call(this), M(this, k, zt).call(this, this.getElement());
615
615
  }
616
616
  createElement() {
617
617
  const t = document.createElement("canvas");
618
- return t.width = 1, t.height = 1, new R.Image({
618
+ return t.width = 1, t.height = 1, new D.Image({
619
619
  id: this.node.id,
620
620
  x: this.node.props.x,
621
621
  y: this.node.props.y,
622
- name: wt,
622
+ name: $,
623
623
  draggable: !0,
624
624
  image: t
625
625
  });
@@ -650,12 +650,12 @@ class ee extends Nt {
650
650
  ...t.meta
651
651
  }
652
652
  };
653
- const e = this.getElement();
654
- if (e.x(this.node.props.x), e.y(this.node.props.y), this.node.props.width && this.node.props.height) {
655
- const r = Math.max(this.node.props.width, V.MIN_SIZE), n = Math.max(this.node.props.height, V.MIN_SIZE);
656
- e.width(r), e.height(n);
653
+ const s = this.getElement();
654
+ if (s.x(this.node.props.x), s.y(this.node.props.y), this.node.props.width && this.node.props.height) {
655
+ const n = Math.max(this.node.props.width, O.MIN_SIZE), i = Math.max(this.node.props.height, O.MIN_SIZE);
656
+ s.width(n), s.height(i);
657
657
  }
658
- this.node.props.rotation !== void 0 && e.rotation(this.node.props.rotation), t.meta?.imageUrl && t.meta.imageUrl !== this.node.meta.imageUrl && S(this, E, ut).call(this);
658
+ this.node.props.rotation !== void 0 && s.rotation(this.node.props.rotation), t.meta?.imageUrl && t.meta.imageUrl !== this.node.meta.imageUrl && M(this, k, St).call(this);
659
659
  }
660
660
  /**
661
661
  * 销毁
@@ -664,138 +664,138 @@ class ee extends Nt {
664
664
  super.destroy();
665
665
  }
666
666
  }
667
- E = new WeakSet(), /**
667
+ k = new WeakSet(), /**
668
668
  * 加载图片
669
669
  */
670
- ut = function() {
670
+ St = function() {
671
671
  const t = this.node.meta.imageUrl;
672
672
  if (!t) {
673
673
  console.warn("Image URL is missing");
674
674
  return;
675
675
  }
676
- const e = new window.Image();
677
- e.crossOrigin = "anonymous", e.src = t, e.onload = () => {
678
- this.getElement().image(e);
679
- const r = this.node.props.width ?? e.width, n = this.node.props.height ?? e.height;
680
- this.getElement().width(Math.max(r, V.MIN_SIZE)), this.getElement().height(Math.max(n, V.MIN_SIZE));
681
- }, e.onerror = () => {
676
+ const s = new window.Image();
677
+ s.crossOrigin = "anonymous", s.src = t, s.onload = () => {
678
+ this.getElement().image(s);
679
+ const n = this.node.props.width ?? s.width, i = this.node.props.height ?? s.height;
680
+ this.getElement().width(Math.max(n, O.MIN_SIZE)), this.getElement().height(Math.max(i, O.MIN_SIZE));
681
+ }, s.onerror = () => {
682
682
  console.error("Failed to load image:", t);
683
683
  };
684
684
  }, /**
685
685
  * 设置事件处理器
686
686
  */
687
- Ct = function(t) {
688
- t.on("transform", (e) => {
689
- const r = e.target, n = Math.max(V.MIN_SIZE, r.width() * r.scaleX()), a = Math.max(V.MIN_SIZE, r.height() * r.scaleY());
690
- r.scale({ x: 1, y: 1 }), r.width(n), r.height(a), S(this, E, yt).call(this);
691
- }), t.on("transformend", (e) => {
692
- const r = e.target, n = {
687
+ zt = function(t) {
688
+ t.on("transform", (s) => {
689
+ const n = s.target, i = Math.max(O.MIN_SIZE, n.width() * n.scaleX()), a = Math.max(O.MIN_SIZE, n.height() * n.scaleY());
690
+ n.scale({ x: 1, y: 1 }), n.width(i), n.height(a), M(this, k, Mt).call(this);
691
+ }), t.on("transformend", (s) => {
692
+ const n = s.target, i = {
693
693
  ...this.node.props,
694
- x: r.x(),
695
- y: r.y(),
696
- width: r.width(),
697
- height: r.height(),
698
- rotation: r.rotation()
694
+ x: n.x(),
695
+ y: n.y(),
696
+ width: n.width(),
697
+ height: n.height(),
698
+ rotation: n.rotation()
699
699
  };
700
- this.node.props = n, this.core._syncNodeFromElement(this.node.id, {
701
- props: n
702
- }), S(this, E, ft).call(this);
700
+ this.node.props = i, this.core._syncNodeFromElement(this.node.id, {
701
+ props: i
702
+ }), M(this, k, _t).call(this);
703
703
  }), t.on("dragmove", () => {
704
- S(this, E, yt).call(this);
705
- }), t.on("dragend", (e) => {
706
- const r = e.target, n = {
704
+ M(this, k, Mt).call(this);
705
+ }), t.on("dragend", (s) => {
706
+ const n = s.target, i = {
707
707
  ...this.node.props,
708
- x: r.x(),
709
- y: r.y()
708
+ x: n.x(),
709
+ y: n.y()
710
710
  };
711
- this.node.props = n, this.core._syncNodeFromElement(this.node.id, {
712
- props: n
713
- }), S(this, E, ft).call(this);
711
+ this.node.props = i, this.core._syncNodeFromElement(this.node.id, {
712
+ props: i
713
+ }), M(this, k, _t).call(this);
714
714
  });
715
715
  }, /**
716
716
  * 同步 image-marker 节点的位置(实时更新 Konva 元素)
717
717
  */
718
- yt = function() {
719
- const t = this.getElement(), e = t.getLayer();
720
- if (!e) return;
721
- const r = t.x(), n = t.y(), a = t.width(), h = t.height(), c = e.find(
722
- (g) => g.hasName(this.node.id)
723
- ), m = this.core.getState().nodes || [];
724
- c.forEach((g) => {
725
- const I = m.find((p) => p.id === g.id());
726
- if (I?.type === "image-marker" && I.meta.relativePosition) {
727
- const { start: p, end: k } = I.meta.relativePosition, C = r + p.percentX / 100 * a, T = n + p.percentY / 100 * h, X = r + k.percentX / 100 * a, Z = n + k.percentY / 100 * h, Pt = Math.min(C, X), Rt = Math.min(T, Z), dt = Math.abs(X - C), lt = Math.abs(Z - T);
728
- g.position({ x: Pt, y: Rt }), g.setAttrs({ width: dt, height: lt }), g.getChildren().forEach((G) => {
729
- G.getClassName() === "Rect" ? G.setAttrs({ width: dt, height: lt }) : G.getClassName() === "Group" && G.setAttrs({ x: dt, y: lt });
718
+ Mt = function() {
719
+ const t = this.getElement(), s = t.getLayer();
720
+ if (!s) return;
721
+ const n = t.x(), i = t.y(), a = t.width(), h = t.height(), c = s.find(
722
+ (m) => m.hasName(this.node.id)
723
+ ), g = this.core.getState().nodes || [];
724
+ c.forEach((m) => {
725
+ const v = g.find((p) => p.id === m.id());
726
+ if (v?.type === "image-marker" && v.meta.relativePosition) {
727
+ const { start: p, end: _ } = v.meta.relativePosition, b = n + p.percentX / 100 * a, C = i + p.percentY / 100 * h, P = n + _.percentX / 100 * a, E = i + _.percentY / 100 * h, ut = Math.min(b, P), ft = Math.min(C, E), R = Math.abs(P - b), Y = Math.abs(E - C);
728
+ m.position({ x: ut, y: ft }), m.setAttrs({ width: R, height: Y }), m.getChildren().forEach((L) => {
729
+ L.getClassName() === "Rect" ? L.setAttrs({ width: R, height: Y }) : L.getClassName() === "Group" && L.setAttrs({ x: R, y: Y });
730
730
  });
731
731
  }
732
732
  });
733
733
  }, /**
734
734
  * 同步 image-marker 节点到状态
735
735
  */
736
- ft = function() {
737
- const e = this.getElement().getLayer();
738
- if (!e) return;
739
- e.find(
740
- (n) => n.hasName(this.node.id)
741
- ).forEach((n) => {
742
- this.core._syncNodeFromElement(n.id(), {
736
+ _t = function() {
737
+ const s = this.getElement().getLayer();
738
+ if (!s) return;
739
+ s.find(
740
+ (i) => i.hasName(this.node.id)
741
+ ).forEach((i) => {
742
+ this.core._syncNodeFromElement(i.id(), {
743
743
  props: {
744
- x: n.x(),
745
- y: n.y(),
746
- width: n.width(),
747
- height: n.height()
744
+ x: i.x(),
745
+ y: i.y(),
746
+ width: i.width(),
747
+ height: i.height()
748
748
  }
749
749
  });
750
750
  });
751
751
  };
752
- var Y, b, L, W, ct, Tt;
753
- class se extends Nt {
754
- constructor(t, e) {
755
- super(t, e);
756
- d(this, ct);
757
- d(this, Y);
758
- d(this, b);
759
- d(this, L);
760
- d(this, W);
761
- const r = this.getElement();
762
- N(this, Y, r.findOne(".rect")), N(this, b, r.findOne(".marker-group")), N(this, L, i(this, b).findOne("Circle")), N(this, W, i(this, b).findOne("Text")), S(this, ct, Tt).call(this);
752
+ var H, T, K, j, pt, At;
753
+ class pe extends bt {
754
+ constructor(t, s) {
755
+ super(t, s);
756
+ d(this, pt);
757
+ d(this, H);
758
+ d(this, T);
759
+ d(this, K);
760
+ d(this, j);
761
+ const n = this.getElement();
762
+ N(this, H, n.findOne(".rect")), N(this, T, n.findOne(".marker-group")), N(this, K, r(this, T).findOne("Circle")), N(this, j, r(this, T).findOne("Text")), M(this, pt, At).call(this);
763
763
  }
764
764
  createElement() {
765
765
  const t = Math.max(
766
- this.node.props.width ?? y.MIN_SIZE,
767
- y.MIN_SIZE
768
- ), e = Math.max(
769
- this.node.props.height ?? y.MIN_SIZE,
770
- y.MIN_SIZE
771
- ), r = new R.Group({
766
+ this.node.props.width ?? u.MIN_SIZE,
767
+ u.MIN_SIZE
768
+ ), s = Math.max(
769
+ this.node.props.height ?? u.MIN_SIZE,
770
+ u.MIN_SIZE
771
+ ), n = new D.Group({
772
772
  id: this.node.id,
773
773
  name: `static ${this.node.meta.parent}`,
774
774
  x: this.node.props.x,
775
775
  y: this.node.props.y,
776
776
  width: t,
777
- height: e
778
- }), n = new R.Rect({
777
+ height: s
778
+ }), i = new D.Rect({
779
779
  name: "rect",
780
780
  x: 0,
781
781
  y: 0,
782
782
  width: t,
783
- height: e,
783
+ height: s,
784
784
  stroke: this.node.style.color,
785
785
  strokeWidth: 2,
786
786
  dash: [5, 5],
787
787
  fill: "transparent",
788
- cornerRadius: y.CORNER_RADIUS
789
- }), a = new R.Group({
788
+ cornerRadius: u.CORNER_RADIUS
789
+ }), a = new D.Group({
790
790
  name: "marker-group",
791
791
  x: t,
792
- y: e
793
- }), c = 16 / this.core.getStageScale(), m = new R.Circle({
792
+ y: s
793
+ }), c = 16 / this.core.getStageScale(), g = new D.Circle({
794
794
  radius: c,
795
795
  fill: "red",
796
796
  stroke: "black",
797
797
  strokeWidth: 2
798
- }), g = new R.Text({
798
+ }), m = new D.Text({
799
799
  x: -c,
800
800
  y: -c,
801
801
  width: c * 2,
@@ -806,7 +806,7 @@ class se extends Nt {
806
806
  fontSize: 16,
807
807
  fill: "white"
808
808
  });
809
- return a.add(m), a.add(g), r.add(n), r.add(a), r;
809
+ return a.add(g), a.add(m), n.add(i), n.add(a), n;
810
810
  }
811
811
  /**
812
812
  * 获取 Konva.Group 实例
@@ -834,16 +834,16 @@ class se extends Nt {
834
834
  ...t.meta
835
835
  }
836
836
  };
837
- const e = this.getElement();
838
- e.x(this.node.props.x), e.y(this.node.props.y);
839
- const r = Math.max(
840
- this.node.props.width ?? y.MIN_SIZE,
841
- y.MIN_SIZE
842
- ), n = Math.max(
843
- this.node.props.height ?? y.MIN_SIZE,
844
- y.MIN_SIZE
837
+ const s = this.getElement();
838
+ s.x(this.node.props.x), s.y(this.node.props.y);
839
+ const n = Math.max(
840
+ this.node.props.width ?? u.MIN_SIZE,
841
+ u.MIN_SIZE
842
+ ), i = Math.max(
843
+ this.node.props.height ?? u.MIN_SIZE,
844
+ u.MIN_SIZE
845
845
  );
846
- e.width(r), e.height(n), i(this, Y).width(r), i(this, Y).height(n), i(this, b).x(r), i(this, b).y(n), t.style?.color && i(this, Y).stroke(t.style.color), t.meta?.markerNumber !== void 0 && i(this, W).text(String(t.meta.markerNumber));
846
+ s.width(n), s.height(i), r(this, H).width(n), r(this, H).height(i), r(this, T).x(n), r(this, T).y(i), t.style?.color && r(this, H).stroke(t.style.color), t.meta?.markerNumber !== void 0 && r(this, j).text(String(t.meta.markerNumber));
847
847
  }
848
848
  /**
849
849
  * 销毁
@@ -855,39 +855,39 @@ class se extends Nt {
855
855
  * 更新焦点状态(hover 或 selected)
856
856
  */
857
857
  setFocusState(t) {
858
- const e = t ? 3 : 2, r = t ? 1.2 : 1;
859
- i(this, Y).strokeWidth(e), i(this, L).strokeWidth(e), i(this, b).scaleX(r), i(this, b).scaleY(r);
858
+ const s = t ? 3 : 2, n = t ? 1.2 : 1;
859
+ r(this, H).strokeWidth(s), r(this, K).strokeWidth(s), r(this, T).scaleX(n), r(this, T).scaleY(n);
860
860
  }
861
861
  }
862
- Y = new WeakMap(), b = new WeakMap(), L = new WeakMap(), W = new WeakMap(), ct = new WeakSet(), /**
862
+ H = new WeakMap(), T = new WeakMap(), K = new WeakMap(), j = new WeakMap(), pt = new WeakSet(), /**
863
863
  * 设置事件处理器
864
864
  */
865
- Tt = function() {
866
- i(this, b).on("pointerover", () => {
865
+ At = function() {
866
+ r(this, T).on("pointerover", () => {
867
867
  this.setFocusState(!0), this.core.setCursor("pointer");
868
- }), i(this, b).on("pointerout", () => {
869
- const e = (this.core.getState().selectedNodeIds || []).includes(this.node.id);
870
- this.setFocusState(e), this.core.resetCursor();
871
- }), i(this, b).on("pointerdown", () => {
868
+ }), r(this, T).on("pointerout", () => {
869
+ const s = (this.core.getState().selectedNodeIds || []).includes(this.node.id);
870
+ this.setFocusState(s), this.core.resetCursor();
871
+ }), r(this, T).on("pointerdown", () => {
872
872
  this.core.selectNode(this.node.id);
873
873
  });
874
874
  };
875
- function Mt(o, s, t) {
876
- switch (s) {
875
+ function Rt(o, e, t) {
876
+ switch (e) {
877
877
  case "rectangle":
878
- return new te(o, t);
878
+ return new me(o, t);
879
879
  case "image":
880
- return new ee(o, t);
880
+ return new ge(o, t);
881
881
  case "image-marker":
882
- return new se(o, t);
882
+ return new pe(o, t);
883
883
  default:
884
884
  return null;
885
885
  }
886
886
  }
887
- const ie = (o, s, t, e) => {
888
- const r = {
887
+ const ue = (o, e, t, s) => {
888
+ const n = {
889
889
  type: o,
890
- id: $(),
890
+ id: J(),
891
891
  text: null,
892
892
  style: {
893
893
  opacity: 1,
@@ -897,52 +897,52 @@ const ie = (o, s, t, e) => {
897
897
  animated: !1
898
898
  },
899
899
  props: {
900
- x: s.x,
901
- y: s.y,
900
+ x: e.x,
901
+ y: e.y,
902
902
  rotation: 0,
903
903
  visible: !0
904
904
  },
905
- meta: e ?? {}
905
+ meta: s ?? {}
906
906
  };
907
907
  return o === "image-marker" ? {
908
- ...r,
908
+ ...n,
909
909
  style: {
910
- ...r.style,
910
+ ...n.style,
911
911
  color: "#ff0000",
912
912
  line: "dashed"
913
913
  }
914
- } : r;
914
+ } : n;
915
915
  };
916
- function re(o, s, t) {
917
- let e = s;
918
- o.type === "image-marker" && t && (e = {
919
- x: Math.max(t.x, Math.min(t.x + t.width, s.x)),
920
- y: Math.max(t.y, Math.min(t.y + t.height, s.y))
916
+ function fe(o, e, t) {
917
+ let s = e;
918
+ o.type === "image-marker" && t && (s = {
919
+ x: Math.max(t.x, Math.min(t.x + t.width, e.x)),
920
+ y: Math.max(t.y, Math.min(t.y + t.height, e.y))
921
921
  });
922
- const [r, n] = ne(
922
+ const [n, i] = ye(
923
923
  { x: o.props.x, y: o.props.y },
924
- e
924
+ s
925
925
  );
926
926
  return o.type === "rectangle" || o.type === "image-marker" ? {
927
927
  ...o,
928
928
  props: {
929
929
  ...o.props,
930
- x: r.x,
931
- y: r.y,
932
- width: Math.max(n.x - r.x, y.MIN_SIZE),
933
- height: Math.max(n.y - r.y, y.MIN_SIZE)
930
+ x: n.x,
931
+ y: n.y,
932
+ width: Math.max(i.x - n.x, u.MIN_SIZE),
933
+ height: Math.max(i.y - n.y, u.MIN_SIZE)
934
934
  }
935
935
  } : o;
936
936
  }
937
- function ne(o, s) {
938
- let t = o.x, e = o.y, r = s.x, n = s.y, a;
939
- return t > r && (a = Math.abs(t - r), t = r, r = t + a), e > n && (a = Math.abs(e - n), e = n, n = e + a), [
940
- { x: t, y: e },
941
- { x: r, y: n }
937
+ function ye(o, e) {
938
+ let t = o.x, s = o.y, n = e.x, i = e.y, a;
939
+ return t > n && (a = Math.abs(t - n), t = n, n = t + a), s > i && (a = Math.abs(s - i), s = i, i = s + a), [
940
+ { x: t, y: s },
941
+ { x: n, y: i }
942
942
  ];
943
943
  }
944
- var u, A, M, v;
945
- class oe extends Kt {
944
+ var x, A, V, S;
945
+ class xe extends oe {
946
946
  constructor(t) {
947
947
  super({
948
948
  viewport: {
@@ -955,53 +955,53 @@ class oe extends Kt {
955
955
  toolType: "select",
956
956
  nodes: []
957
957
  });
958
- d(this, u);
958
+ d(this, x);
959
959
  d(this, A);
960
- d(this, M);
961
- d(this, v, null);
962
- N(this, u, new Gt(this, {
960
+ d(this, V);
961
+ d(this, S, null);
962
+ N(this, x, new ne(this, {
963
963
  container: t,
964
964
  width: t.clientWidth,
965
965
  height: t.clientHeight,
966
966
  draggable: !1,
967
967
  className: "touch-none"
968
- })), N(this, A, new R.Layer()), N(this, M, new $t(this)), i(this, u).getStage().add(i(this, A)), i(this, A).add(i(this, M).getTransformer()), this.updateViewport(this.getState().viewport, !1);
968
+ })), N(this, A, new D.Layer()), N(this, V, new re(this)), r(this, x).getStage().add(r(this, A)), r(this, A).add(r(this, V).getTransformer()), this.updateViewport(this.getState().viewport, !1);
969
969
  }
970
970
  /**
971
971
  * 获取 CanvasStage 实例
972
972
  */
973
973
  getCanvasStage() {
974
- return i(this, u);
974
+ return r(this, x);
975
975
  }
976
976
  /**
977
977
  * 获取 CanvasTransformer 实例
978
978
  */
979
979
  getCanvasTransformer() {
980
- return i(this, M);
980
+ return r(this, V);
981
981
  }
982
982
  /**
983
983
  * 发射事件(供内部类使用)
984
984
  */
985
- emitEvent(t, e) {
986
- this.emit(t, e);
985
+ emitEvent(t, s) {
986
+ this.emit(t, s);
987
987
  }
988
988
  /**
989
989
  * 获取 Konva.Stage 实例
990
990
  */
991
991
  getStage() {
992
- return i(this, u).getStage();
992
+ return r(this, x).getStage();
993
993
  }
994
994
  /**
995
995
  * 获取 Stage 容器元素
996
996
  */
997
997
  getContainer() {
998
- return i(this, u).getStage().container();
998
+ return r(this, x).getStage().container();
999
999
  }
1000
1000
  /**
1001
1001
  * 获取主图层
1002
1002
  */
1003
1003
  getMainLayer() {
1004
- return i(this, A);
1004
+ return r(this, A);
1005
1005
  }
1006
1006
  /**
1007
1007
  * 获取当前工具类型
@@ -1018,108 +1018,80 @@ class oe extends Kt {
1018
1018
  toolType: t
1019
1019
  },
1020
1020
  !1
1021
- ), this.emit("toolType:change", t), t === "hand" ? (i(this, u).setDraggable(!0), i(this, u).setCursor("grab")) : (i(this, u).setDraggable(!1), i(this, u).resetCursor());
1021
+ ), this.emit("toolType:change", t), t === "hand" ? (r(this, x).setDraggable(!0), r(this, x).setCursor("grab")) : (r(this, x).setDraggable(!1), r(this, x).resetCursor());
1022
1022
  }
1023
1023
  /**
1024
1024
  * 设置是否可拖拽(内部使用)
1025
1025
  */
1026
1026
  setDraggable(t) {
1027
- i(this, u).setDraggable(t);
1027
+ r(this, x).setDraggable(t);
1028
1028
  }
1029
1029
  /**
1030
1030
  * 设置光标
1031
1031
  * @internal 仅供内部使用
1032
1032
  */
1033
1033
  setCursor(t) {
1034
- i(this, u).setCursor(t);
1034
+ r(this, x).setCursor(t);
1035
1035
  }
1036
1036
  /**
1037
1037
  * 重置光标
1038
1038
  * @internal 仅供内部使用
1039
1039
  */
1040
1040
  resetCursor() {
1041
- i(this, u).resetCursor();
1041
+ r(this, x).resetCursor();
1042
1042
  }
1043
1043
  /**
1044
1044
  * 获取当前 Stage 缩放比例
1045
1045
  */
1046
1046
  getStageScale() {
1047
- return i(this, u).getStage().scaleX();
1047
+ return r(this, x).getStage().scaleX();
1048
1048
  }
1049
1049
  /**
1050
1050
  * 更新视口位置
1051
1051
  * @internal 仅供内部使用,外部请使用 CanvasApi
1052
1052
  */
1053
- updateViewport(t, e = !1) {
1054
- i(this, u).setViewport(t);
1055
- const r = {
1053
+ updateViewport(t, s = !1) {
1054
+ r(this, x).setViewport(t);
1055
+ const n = {
1056
1056
  ...this.getState().viewport,
1057
1057
  ...t
1058
1058
  };
1059
1059
  this._updateState(
1060
1060
  {
1061
- viewport: r
1061
+ viewport: n
1062
1062
  },
1063
- e
1064
- ), this.emit("viewport:change", r), i(this, M).emitPositionChange();
1063
+ s
1064
+ ), this.emit("viewport:change", n), r(this, V).emitPositionChange();
1065
1065
  }
1066
1066
  createNodes(t) {
1067
- t.map((n) => Mt(this, n.type, n)).filter((n) => n !== null).forEach((n) => {
1068
- i(this, A).add(n.getElement());
1067
+ t.map((i) => Rt(this, i.type, i)).filter((i) => i !== null).forEach((i) => {
1068
+ r(this, A).add(i.getElement());
1069
1069
  });
1070
- const r = [...this.getState().nodes || [], ...t];
1070
+ const n = [...this.getState().nodes || [], ...t];
1071
1071
  this._updateState(
1072
1072
  {
1073
- nodes: r
1073
+ nodes: n
1074
1074
  },
1075
1075
  !0
1076
1076
  );
1077
1077
  }
1078
- /**
1079
- * 创建图片节点(内部使用)
1080
- */
1081
- _createImageNode(t, e) {
1082
- const r = e ?? { x: 100, y: 100 }, n = {
1083
- id: $(),
1084
- type: "image",
1085
- props: {
1086
- x: r.x,
1087
- y: r.y,
1088
- width: void 0,
1089
- // 将在图片加载后设置
1090
- height: void 0,
1091
- rotation: 0,
1092
- visible: !0
1093
- },
1094
- style: {
1095
- color: "#000000",
1096
- line: "solid",
1097
- size: "medium",
1098
- opacity: 1
1099
- },
1100
- meta: {
1101
- imageUrl: t
1102
- }
1103
- };
1104
- this.createNodes([n]);
1105
- }
1106
1078
  /**
1107
1079
  * 创建图片标注节点(内部使用)
1108
1080
  */
1109
- createImageMarkerNode(t, e, r, n) {
1081
+ createImageMarkerNode(t, s, n, i) {
1110
1082
  const a = this.getState().nodes || [];
1111
1083
  let h = 0;
1112
- a.forEach((Z) => {
1113
- Z.type === "image-marker" && Z.meta.parent === t && typeof Z.meta.markerNumber == "number" && (h = Math.max(h, Z.meta.markerNumber));
1084
+ a.forEach((E) => {
1085
+ E.type === "image-marker" && E.meta.parent === t && typeof E.meta.markerNumber == "number" && (h = Math.max(h, E.meta.markerNumber));
1114
1086
  });
1115
- const c = (e.x - n.x) / n.width * 100, m = (e.y - n.y) / n.height * 100, g = (r.x - n.x) / n.width * 100, I = (r.y - n.y) / n.height * 100, p = Math.min(e.x, r.x), k = Math.min(e.y, r.y), C = Math.abs(r.x - e.x), T = Math.abs(r.y - e.y), X = {
1116
- id: $(),
1087
+ const c = (s.x - i.x) / i.width * 100, g = (s.y - i.y) / i.height * 100, m = (n.x - i.x) / i.width * 100, v = (n.y - i.y) / i.height * 100, p = Math.min(s.x, n.x), _ = Math.min(s.y, n.y), b = Math.abs(n.x - s.x), C = Math.abs(n.y - s.y), P = {
1088
+ id: J(),
1117
1089
  type: "image-marker",
1118
1090
  props: {
1119
1091
  x: p,
1120
- y: k,
1121
- width: C,
1122
- height: T,
1092
+ y: _,
1093
+ width: b,
1094
+ height: C,
1123
1095
  rotation: 0,
1124
1096
  visible: !0
1125
1097
  },
@@ -1135,123 +1107,123 @@ class oe extends Kt {
1135
1107
  relativePosition: {
1136
1108
  start: {
1137
1109
  percentX: Math.max(0, Math.min(100, c)),
1138
- percentY: Math.max(0, Math.min(100, m))
1110
+ percentY: Math.max(0, Math.min(100, g))
1139
1111
  },
1140
1112
  end: {
1141
- percentX: Math.max(0, Math.min(100, g)),
1142
- percentY: Math.max(0, Math.min(100, I))
1113
+ percentX: Math.max(0, Math.min(100, m)),
1114
+ percentY: Math.max(0, Math.min(100, v))
1143
1115
  }
1144
1116
  }
1145
1117
  }
1146
1118
  };
1147
- this.createNodes([X]);
1119
+ this.createNodes([P]);
1148
1120
  }
1149
1121
  /**
1150
1122
  * 在指定位置查找图片节点
1151
1123
  * @internal 仅供内部使用
1152
1124
  */
1153
1125
  findImageAtPosition(t) {
1154
- const e = i(this, u).getStage(), r = e.find(
1126
+ const s = r(this, x).getStage(), n = s.find(
1155
1127
  (a) => a.getClassName() === "Image"
1156
- ), n = r.map(
1128
+ ), i = n.map(
1157
1129
  (a) => a.listening()
1158
1130
  );
1159
- r.forEach((a) => a.listening(!0));
1131
+ n.forEach((a) => a.listening(!0));
1160
1132
  try {
1161
- const h = e.getAllIntersections(t).filter(
1133
+ const h = s.getAllIntersections(t).filter(
1162
1134
  (c) => c.getClassName() === "Image"
1163
1135
  );
1164
1136
  return h.length === 0 ? null : h[h.length - 1];
1165
1137
  } finally {
1166
- r.forEach((a, h) => {
1167
- a.listening(n[h]);
1138
+ n.forEach((a, h) => {
1139
+ a.listening(i[h]);
1168
1140
  });
1169
1141
  }
1170
1142
  }
1171
1143
  /**
1172
1144
  * @internal 仅供内部使用
1173
1145
  */
1174
- createDraftNode(t, e, r) {
1175
- i(this, v) && i(this, v).destroy();
1176
- const n = ie(t, e, void 0, r);
1177
- N(this, v, Mt(this, t, n)), console.log(i(this, v)), i(this, v) && i(this, A).add(i(this, v).getElement());
1146
+ createDraftNode(t, s, n) {
1147
+ r(this, S) && r(this, S).destroy();
1148
+ const i = ue(t, s, void 0, n);
1149
+ N(this, S, Rt(this, t, i)), console.log(r(this, S)), r(this, S) && r(this, A).add(r(this, S).getElement());
1178
1150
  }
1179
1151
  /**
1180
1152
  * @internal 仅供内部使用
1181
1153
  */
1182
- updateDraftNode(t, e) {
1183
- if (!i(this, v)) return;
1184
- const r = i(this, v).getNode(), n = re(r, t, e);
1185
- i(this, v).updateNode(n);
1154
+ updateDraftNode(t, s) {
1155
+ if (!r(this, S)) return;
1156
+ const n = r(this, S).getNode(), i = fe(n, t, s);
1157
+ r(this, S).updateNode(i);
1186
1158
  }
1187
1159
  /**
1188
1160
  * @internal 仅供内部使用
1189
1161
  */
1190
1162
  finalizeDraftNode() {
1191
- if (!i(this, v)) return;
1192
- const t = $(), e = i(this, v).getNode();
1193
- if (e.type === "image-marker" && e.meta.parent) {
1194
- const n = e.meta.bounds, a = e.meta.startPosition, h = {
1195
- x: e.props.x + (e.props.width || 0),
1196
- y: e.props.y + (e.props.height || 0)
1163
+ if (!r(this, S)) return;
1164
+ const t = J(), s = r(this, S).getNode();
1165
+ if (s.type === "image-marker" && s.meta.parent) {
1166
+ const i = s.meta.bounds, a = s.meta.startPosition, h = {
1167
+ x: s.props.x + (s.props.width || 0),
1168
+ y: s.props.y + (s.props.height || 0)
1197
1169
  }, c = this.getState().nodes || [];
1198
- let m = 0;
1199
- c.forEach((T) => {
1200
- T.type === "image-marker" && T.meta.parent === e.meta.parent && typeof T.meta.markerNumber == "number" && (m = Math.max(m, T.meta.markerNumber));
1170
+ let g = 0;
1171
+ c.forEach((C) => {
1172
+ C.type === "image-marker" && C.meta.parent === s.meta.parent && typeof C.meta.markerNumber == "number" && (g = Math.max(g, C.meta.markerNumber));
1201
1173
  });
1202
- const g = (a.x - n.x) / n.width * 100, I = (a.y - n.y) / n.height * 100, p = (h.x - n.x) / n.width * 100, k = (h.y - n.y) / n.height * 100, C = {
1203
- ...e,
1174
+ const m = (a.x - i.x) / i.width * 100, v = (a.y - i.y) / i.height * 100, p = (h.x - i.x) / i.width * 100, _ = (h.y - i.y) / i.height * 100, b = {
1175
+ ...s,
1204
1176
  props: {
1205
- ...e.props
1177
+ ...s.props
1206
1178
  },
1207
1179
  style: {
1208
- ...e.style
1180
+ ...s.style
1209
1181
  },
1210
1182
  meta: {
1211
- parent: e.meta.parent,
1212
- markerNumber: m + 1,
1183
+ parent: s.meta.parent,
1184
+ markerNumber: g + 1,
1213
1185
  relativePosition: {
1214
1186
  start: {
1215
- percentX: Math.max(0, Math.min(100, g)),
1216
- percentY: Math.max(0, Math.min(100, I))
1187
+ percentX: Math.max(0, Math.min(100, m)),
1188
+ percentY: Math.max(0, Math.min(100, v))
1217
1189
  },
1218
1190
  end: {
1219
1191
  percentX: Math.max(0, Math.min(100, p)),
1220
- percentY: Math.max(0, Math.min(100, k))
1192
+ percentY: Math.max(0, Math.min(100, _))
1221
1193
  }
1222
1194
  }
1223
1195
  },
1224
1196
  id: t,
1225
1197
  type: "image-marker"
1226
1198
  };
1227
- this.createNodes([C]), i(this, v).destroy(), N(this, v, null), this.setToolType("select");
1199
+ this.createNodes([b]), r(this, S).destroy(), N(this, S, null), this.setToolType("select");
1228
1200
  return;
1229
1201
  }
1230
- const r = {
1231
- ...e,
1202
+ const n = {
1203
+ ...s,
1232
1204
  props: {
1233
- ...e.props
1205
+ ...s.props
1234
1206
  },
1235
1207
  style: {
1236
- ...e.style
1208
+ ...s.style
1237
1209
  },
1238
1210
  meta: {
1239
- ...e.meta
1211
+ ...s.meta
1240
1212
  },
1241
1213
  id: t
1242
1214
  };
1243
- this.createNodes([r]), i(this, v).destroy(), N(this, v, null), this.setToolType("select");
1215
+ this.createNodes([n]), r(this, S).destroy(), N(this, S, null), this.setToolType("select");
1244
1216
  }
1245
1217
  /**
1246
1218
  * 选择节点
1247
1219
  * @internal 仅供内部使用,外部请使用 CanvasApi
1248
1220
  */
1249
- selectNode(t, e = !1) {
1250
- const r = this.getState().selectedNodeIds ?? [];
1251
- if (r.length === 0 && !t)
1221
+ selectNode(t, s = !1) {
1222
+ const n = this.getState().selectedNodeIds ?? [];
1223
+ if (n.length === 0 && !t)
1252
1224
  return;
1253
1225
  if (!t) {
1254
- i(this, M).clearNodes(), this._updateState(
1226
+ r(this, V).clearNodes(), this._updateState(
1255
1227
  {
1256
1228
  selectedNodeIds: []
1257
1229
  },
@@ -1259,139 +1231,60 @@ class oe extends Kt {
1259
1231
  );
1260
1232
  return;
1261
1233
  }
1262
- let n = [];
1263
- e ? n = r.length ? [...r, t] : [t] : n = [t];
1264
- const a = this.getStage().find(`.${wt}`).filter((h) => {
1234
+ let i = [];
1235
+ s ? i = n.length ? [...n, t] : [t] : i = [t];
1236
+ const a = this.getStage().find(`.${$}`).filter((h) => {
1265
1237
  const c = h.id();
1266
- return n.includes(c);
1238
+ return i.includes(c);
1267
1239
  });
1268
- i(this, M).setNodes(a), this._updateState(
1240
+ r(this, V).setNodes(a), this._updateState(
1269
1241
  {
1270
- selectedNodeIds: n
1242
+ selectedNodeIds: i
1271
1243
  },
1272
1244
  !1
1273
1245
  );
1274
1246
  }
1247
+ /**
1248
+ * 销毁 canvas
1249
+ */
1250
+ dispose() {
1251
+ this.getCanvasTransformer().destroy(), this.getCanvasStage().destroy(), this._dispose();
1252
+ }
1275
1253
  /**
1276
1254
  * 从元素同步节点数据(供节点类内部使用)
1277
1255
  */
1278
- _syncNodeFromElement(t, e) {
1279
- const r = this.getState().nodes || [], n = r.findIndex((c) => c.id === t);
1280
- if (n === -1) return;
1256
+ _syncNodeFromElement(t, s) {
1257
+ const n = this.getState().nodes || [], i = n.findIndex((c) => c.id === t);
1258
+ if (i === -1) return;
1281
1259
  const a = {
1282
- ...r[n],
1283
- ...e,
1260
+ ...n[i],
1261
+ ...s,
1284
1262
  props: {
1285
- ...r[n].props,
1286
- ...e.props
1263
+ ...n[i].props,
1264
+ ...s.props
1287
1265
  },
1288
1266
  style: {
1289
- ...r[n].style,
1290
- ...e.style
1267
+ ...n[i].style,
1268
+ ...s.style
1291
1269
  },
1292
1270
  meta: {
1293
- ...r[n].meta,
1294
- ...e.meta
1271
+ ...n[i].meta,
1272
+ ...s.meta
1295
1273
  }
1296
- }, h = [...r];
1297
- h[n] = a, this._updateState(
1274
+ }, h = [...n];
1275
+ h[i] = a, this._updateState(
1298
1276
  {
1299
1277
  nodes: h
1300
1278
  },
1301
1279
  !0
1302
1280
  );
1303
1281
  }
1304
- /**
1305
- * 删除节点(内部使用)
1306
- */
1307
- _deleteNodes(t) {
1308
- if (t.length === 0) return;
1309
- const e = this.getState().nodes || [], r = new Set(t);
1310
- t.forEach((a) => {
1311
- e.find((c) => c.id === a)?.type === "image" && e.forEach((c) => {
1312
- c.type === "image-marker" && c.meta.parent === a && r.add(c.id);
1313
- });
1314
- }), r.forEach((a) => {
1315
- const h = this.getStage().findOne(`#${a}`);
1316
- h && h.destroy();
1317
- });
1318
- const n = e.filter((a) => !r.has(a.id));
1319
- i(this, M).clearNodes(), this._updateState(
1320
- {
1321
- nodes: n,
1322
- selectedNodeIds: []
1323
- },
1324
- !0
1325
- );
1326
- }
1327
- /**
1328
- * 删除当前选中的节点(内部使用)
1329
- */
1330
- _deleteSelectedNodes() {
1331
- const t = this.getState().selectedNodeIds || [];
1332
- t.length !== 0 && this._deleteNodes(t);
1333
- }
1334
- /**
1335
- * 获取 Transformer 的位置信息(内部使用)
1336
- */
1337
- getTransformerPosition() {
1338
- return i(this, M).getPosition();
1339
- }
1340
- /**
1341
- * 导出全部图形为图片(内部使用)
1342
- * @param options - 导出配置
1343
- * @returns DataURL 格式的图片数据
1344
- */
1345
- _exportAsImage(t) {
1346
- const e = i(this, u).getStage(), r = i(this, M).getTransformer(), n = r.visible();
1347
- r.visible(!1);
1348
- try {
1349
- return e.toDataURL({
1350
- pixelRatio: t?.pixelRatio ?? 2,
1351
- mimeType: t?.mimeType ?? "image/png",
1352
- quality: t?.quality ?? 1
1353
- });
1354
- } finally {
1355
- r.visible(n);
1356
- }
1357
- }
1358
- /**
1359
- * 导出当前选区为图片(内部使用)
1360
- * @param options - 导出配置
1361
- * @returns DataURL 格式的图片数据,如果没有选区则返回 null
1362
- */
1363
- _exportSelectionAsImage(t) {
1364
- const e = i(this, M).getPosition();
1365
- if (!e)
1366
- return console.warn("No selection to export"), null;
1367
- const r = i(this, u).getStage(), n = t?.padding ?? 10, a = i(this, M).getTransformer(), h = a.visible();
1368
- a.visible(!1);
1369
- try {
1370
- return r.toDataURL({
1371
- x: e.x - n,
1372
- y: e.y - n,
1373
- width: e.width + n * 2,
1374
- height: e.height + n * 2,
1375
- pixelRatio: t?.pixelRatio ?? 2,
1376
- mimeType: t?.mimeType ?? "image/png",
1377
- quality: t?.quality ?? 1
1378
- });
1379
- } finally {
1380
- a.visible(h);
1381
- }
1382
- }
1383
- /**
1384
- * 销毁 core(内部使用)
1385
- */
1386
- _dispose() {
1387
- i(this, M).destroy(), i(this, u).destroy(), super._dispose();
1388
- }
1389
1282
  /**
1390
1283
  * 实现父类的状态同步方法
1391
1284
  * 当 undo/redo 时被调用
1392
1285
  */
1393
1286
  _syncState(t) {
1394
- i(this, u).setViewport({
1287
+ r(this, x).setViewport({
1395
1288
  x: t.viewport.x,
1396
1289
  y: t.viewport.y,
1397
1290
  scale: t.viewport.scale,
@@ -1400,8 +1293,8 @@ class oe extends Kt {
1400
1293
  });
1401
1294
  }
1402
1295
  }
1403
- u = new WeakMap(), A = new WeakMap(), M = new WeakMap(), v = new WeakMap();
1404
- class ae extends oe {
1296
+ x = new WeakMap(), A = new WeakMap(), V = new WeakMap(), S = new WeakMap();
1297
+ class we extends xe {
1405
1298
  /**
1406
1299
  * 获取所有可用的工具类型
1407
1300
  */
@@ -1411,64 +1304,181 @@ class ae extends oe {
1411
1304
  /**
1412
1305
  * 设置当前工具类型
1413
1306
  */
1414
- setToolType(s) {
1415
- super.setToolType(s);
1307
+ setToolType(e) {
1308
+ super.setToolType(e);
1416
1309
  }
1417
1310
  /**
1418
1311
  * 更新视口位置
1419
1312
  */
1420
- updateViewport(s, t = !1) {
1421
- super.updateViewport(s, t);
1313
+ updateViewport(e, t = !1) {
1314
+ super.updateViewport(e, t);
1422
1315
  }
1423
1316
  /**
1424
1317
  * 创建图片节点
1425
1318
  */
1426
- createImageNode(s, t) {
1427
- this._createImageNode(s, t);
1319
+ createImageNode(e, t) {
1320
+ const s = t ?? { x: 100, y: 100 }, n = {
1321
+ id: J(),
1322
+ type: "image",
1323
+ props: {
1324
+ x: s.x,
1325
+ y: s.y,
1326
+ width: void 0,
1327
+ height: void 0,
1328
+ rotation: 0,
1329
+ visible: !0
1330
+ },
1331
+ style: {
1332
+ color: "#000000",
1333
+ line: "solid",
1334
+ size: "medium",
1335
+ opacity: 1
1336
+ },
1337
+ meta: {
1338
+ imageUrl: e
1339
+ }
1340
+ };
1341
+ this.createNodes([n]);
1342
+ }
1343
+ /**
1344
+ * 在当前所有节点的左下角插入图片,并将其居中显示
1345
+ * @param imageUrl - 图片 URL
1346
+ */
1347
+ insertImageAtBottomLeft(e) {
1348
+ const t = this.getState().nodes || [];
1349
+ let s = { x: 100, y: 100 };
1350
+ if (t.length > 0) {
1351
+ const n = this.getMainLayer();
1352
+ let i = 1 / 0, a = -1 / 0;
1353
+ n.children.forEach((h) => {
1354
+ if (h.visible() && h.getClassName() !== "Transformer" && h.hasName($)) {
1355
+ const c = h.getAttrs(), g = c.x || 0, m = c.y || 0, v = c.height || 0;
1356
+ i = Math.min(i, g), a = Math.max(a, m + v);
1357
+ }
1358
+ }), i !== 1 / 0 && a !== -1 / 0 && (s = { x: i, y: a + 20 });
1359
+ }
1360
+ this.createImageNode(e, s), requestAnimationFrame(() => {
1361
+ this.scrollToContent({ scale: !0 });
1362
+ });
1428
1363
  }
1429
1364
  /**
1430
1365
  * 导出全部图形为图片
1431
1366
  * @param options - 导出配置
1432
1367
  * @returns DataURL 格式的图片数据
1433
1368
  */
1434
- exportAsImage(s) {
1435
- return this._exportAsImage(s);
1369
+ exportAsImage(e) {
1370
+ const t = this.getStage(), s = this.getCanvasTransformer().getTransformer(), n = s.visible();
1371
+ s.visible(!1);
1372
+ try {
1373
+ return t.toDataURL({
1374
+ pixelRatio: e?.pixelRatio ?? 2,
1375
+ mimeType: e?.mimeType ?? "image/png",
1376
+ quality: e?.quality ?? 1
1377
+ });
1378
+ } finally {
1379
+ s.visible(n);
1380
+ }
1436
1381
  }
1437
1382
  /**
1438
1383
  * 导出当前选区为图片
1439
1384
  * @param options - 导出配置
1440
1385
  * @returns DataURL 格式的图片数据,如果没有选区则返回 null
1441
1386
  */
1442
- exportSelectionAsImage(s) {
1443
- return this._exportSelectionAsImage(s);
1387
+ exportSelectionAsImage(e) {
1388
+ const t = this.getCanvasTransformer().getPosition();
1389
+ if (!t)
1390
+ return console.warn("No selection to export"), null;
1391
+ const s = this.getStage(), n = e?.padding ?? 10, i = this.getCanvasTransformer().getTransformer(), a = i.visible();
1392
+ i.visible(!1);
1393
+ try {
1394
+ return s.toDataURL({
1395
+ x: t.x - n,
1396
+ y: t.y - n,
1397
+ width: t.width + n * 2,
1398
+ height: t.height + n * 2,
1399
+ pixelRatio: e?.pixelRatio ?? 2,
1400
+ mimeType: e?.mimeType ?? "image/png",
1401
+ quality: e?.quality ?? 1
1402
+ });
1403
+ } finally {
1404
+ i.visible(a);
1405
+ }
1444
1406
  }
1445
1407
  /**
1446
1408
  * 删除当前选中的节点
1447
1409
  * 如果删除的是 image 节点,会同步删除所有关联的 image-marker
1448
1410
  */
1449
1411
  deleteSelectedNodes() {
1450
- this._deleteSelectedNodes();
1412
+ const e = this.getState().selectedNodeIds || [];
1413
+ e.length !== 0 && this.deleteNodes(e);
1451
1414
  }
1452
1415
  /**
1453
1416
  * 删除指定的节点
1454
1417
  * 如果删除的是 image 节点,会同步删除所有关联的 image-marker
1455
1418
  * @param nodeIds - 要删除的节点 ID 数组
1456
1419
  */
1457
- deleteNodes(s) {
1458
- this._deleteNodes(s);
1420
+ deleteNodes(e) {
1421
+ if (e.length === 0) return;
1422
+ const t = this.getState().nodes || [], s = new Set(e);
1423
+ e.forEach((i) => {
1424
+ t.find((h) => h.id === i)?.type === "image" && t.forEach((h) => {
1425
+ h.type === "image-marker" && h.meta.parent === i && s.add(h.id);
1426
+ });
1427
+ }), s.forEach((i) => {
1428
+ const a = this.getStage().findOne(`#${i}`);
1429
+ a && a.destroy();
1430
+ });
1431
+ const n = t.filter((i) => !s.has(i.id));
1432
+ this.getCanvasTransformer().clearNodes(), this._updateState(
1433
+ {
1434
+ nodes: n,
1435
+ selectedNodeIds: []
1436
+ },
1437
+ !0
1438
+ );
1459
1439
  }
1460
1440
  /**
1461
- * 销毁 canvas
1462
- */
1463
- dispose() {
1464
- super._dispose();
1441
+ * 滚动到内容区域
1442
+ * - 如果有选中的节点,将选中节点居中显示
1443
+ * - 如果没有选中节点,将所有内容居中显示
1444
+ * @param options - 配置选项
1445
+ * @param options.padding - 内容周围的留白,默认 50px
1446
+ * @param options.scale - 是否自动调整缩放以适应内容,默认 false
1447
+ */
1448
+ scrollToContent(e) {
1449
+ if ((this.getState().nodes || []).length === 0) return;
1450
+ const s = e?.padding ?? 50, n = e?.scale === !0;
1451
+ let i = 1 / 0, a = 1 / 0, h = -1 / 0, c = -1 / 0;
1452
+ const g = this.getMainLayer(), m = this.getState().selectedNodeIds || [], v = m.length > 0;
1453
+ if (g.children.forEach((R) => {
1454
+ if (R.visible() && R.getClassName() !== "Transformer" && R.hasName($)) {
1455
+ if (v) {
1456
+ const U = R.id();
1457
+ if (!m.includes(U)) return;
1458
+ }
1459
+ const Y = R.getAttrs(), yt = Y.x || 0, L = Y.y || 0, Vt = Y.width || 0, Ut = Y.height || 0;
1460
+ if (Y.rotation || 0) {
1461
+ const U = R.getClientRect({ skipTransform: !1 }), xt = this.getStage(), B = xt.scaleX(), Et = xt.x(), Ct = xt.y(), Ht = (U.x - Et) / B, Lt = (U.y - Ct) / B, Ot = (U.x + U.width - Et) / B, Ft = (U.y + U.height - Ct) / B;
1462
+ i = Math.min(i, Ht), a = Math.min(a, Lt), h = Math.max(h, Ot), c = Math.max(c, Ft);
1463
+ } else
1464
+ i = Math.min(i, yt), a = Math.min(a, L), h = Math.max(h, yt + Vt), c = Math.max(c, L + Ut);
1465
+ }
1466
+ }), i === 1 / 0 || a === 1 / 0) return;
1467
+ const p = h - i, _ = c - a, b = i + p / 2, C = a + _ / 2, P = this.getState().viewport;
1468
+ let E = P.scale;
1469
+ if (n) {
1470
+ const R = (P.width - s * 2) / p, Y = (P.height - s * 2) / _;
1471
+ E = Math.min(R, Y, 1);
1472
+ }
1473
+ const ut = P.width / 2 - b * E, ft = P.height / 2 - C * E;
1474
+ this.updateViewport({ x: ut, y: ft, scale: E }, !0);
1465
1475
  }
1466
1476
  }
1467
- function he(o, s, t, e = !1) {
1468
- const [r, n] = s, [a, h] = t, c = a + (o - r) / (n - r) * (h - a);
1469
- return e ? a < h ? Math.max(Math.min(c, h), a) : Math.max(Math.min(c, a), h) : c;
1477
+ function ve(o, e, t, s = !1) {
1478
+ const [n, i] = e, [a, h] = t, c = a + (o - n) / (i - n) * (h - a);
1479
+ return s ? a < h ? Math.max(Math.min(c, h), a) : Math.max(Math.min(c, a), h) : c;
1470
1480
  }
1471
- const It = [
1481
+ const Yt = [
1472
1482
  {
1473
1483
  min: -1,
1474
1484
  mid: 0.15,
@@ -1490,15 +1500,15 @@ const It = [
1490
1500
  step: 1
1491
1501
  }
1492
1502
  ];
1493
- function ce({
1503
+ function Ne({
1494
1504
  viewportX: o,
1495
- viewportY: s,
1505
+ viewportY: e,
1496
1506
  scale: t,
1497
- size: e = 20,
1498
- showGrid: r = !0
1507
+ size: s = 20,
1508
+ showGrid: n = !0
1499
1509
  }) {
1500
- const n = o / t, a = s / t, h = t;
1501
- return r ? /* @__PURE__ */ U(
1510
+ const i = o / t, a = e / t, h = t;
1511
+ return n ? /* @__PURE__ */ F(
1502
1512
  "svg",
1503
1513
  {
1504
1514
  className: "canvas-grid w-full h-full absolute top-0 left-0",
@@ -1506,12 +1516,12 @@ function ce({
1506
1516
  xmlns: "http://www.w3.org/2000/svg",
1507
1517
  "aria-hidden": "true",
1508
1518
  children: [
1509
- /* @__PURE__ */ w("defs", { children: It.map(({ min: c, mid: m, step: g }, I) => {
1510
- const p = g * e * h, k = 0.5 + n * h, C = 0.5 + a * h, T = k > 0 ? k % p : p + k % p, X = C > 0 ? C % p : p + C % p, Z = h < m ? he(h, [c, m], [0, 1]) : 1;
1519
+ /* @__PURE__ */ w("defs", { children: Yt.map(({ min: c, mid: g, step: m }, v) => {
1520
+ const p = m * s * h, _ = 0.5 + i * h, b = 0.5 + a * h, C = _ > 0 ? _ % p : p + _ % p, P = b > 0 ? b % p : p + b % p, E = h < g ? ve(h, [c, g], [0, 1]) : 1;
1511
1521
  return /* @__PURE__ */ w(
1512
1522
  "pattern",
1513
1523
  {
1514
- id: `grid_${g}`,
1524
+ id: `grid_${m}`,
1515
1525
  width: p,
1516
1526
  height: p,
1517
1527
  patternUnits: "userSpaceOnUse",
@@ -1519,25 +1529,25 @@ function ce({
1519
1529
  "circle",
1520
1530
  {
1521
1531
  className: "tl-grid-dot",
1522
- cx: T,
1523
- cy: X,
1532
+ cx: C,
1533
+ cy: P,
1524
1534
  r: 1,
1525
- opacity: Z
1535
+ opacity: E
1526
1536
  }
1527
1537
  )
1528
1538
  },
1529
- I
1539
+ v
1530
1540
  );
1531
1541
  }) }),
1532
- It.map(({ step: c }, m) => /* @__PURE__ */ w("rect", { width: "100%", height: "100%", fill: `url(#grid_${c})` }, m))
1542
+ Yt.map(({ step: c }, g) => /* @__PURE__ */ w("rect", { width: "100%", height: "100%", fill: `url(#grid_${c})` }, g))
1533
1543
  ]
1534
1544
  }
1535
1545
  ) : null;
1536
1546
  }
1537
- function de(...o) {
1538
- return Ht(Ut(o));
1547
+ function Se(...o) {
1548
+ return Qt(Jt(o));
1539
1549
  }
1540
- const le = Vt(
1550
+ const Me = Bt(
1541
1551
  "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
1542
1552
  {
1543
1553
  variants: {
@@ -1564,56 +1574,56 @@ const le = Vt(
1564
1574
  }
1565
1575
  }
1566
1576
  );
1567
- function H({
1577
+ function W({
1568
1578
  className: o,
1569
- variant: s = "default",
1579
+ variant: e = "default",
1570
1580
  size: t = "default",
1571
- asChild: e = !1,
1572
- ...r
1581
+ asChild: s = !1,
1582
+ ...n
1573
1583
  }) {
1574
1584
  return /* @__PURE__ */ w(
1575
- e ? Xt : "button",
1585
+ s ? jt : "button",
1576
1586
  {
1577
1587
  "data-slot": "button",
1578
- "data-variant": s,
1588
+ "data-variant": e,
1579
1589
  "data-size": t,
1580
- className: de(le({ variant: s, size: t, className: o })),
1581
- ...r
1590
+ className: Se(Me({ variant: e, size: t, className: o })),
1591
+ ...n
1582
1592
  }
1583
1593
  );
1584
1594
  }
1585
- function me({ api: o }) {
1586
- const [s, t] = O(o.getState().viewport);
1587
- xt(() => {
1595
+ function _e({ api: o }) {
1596
+ const [e, t] = G(o.getState().viewport);
1597
+ It(() => {
1588
1598
  o.on("viewport:change", (c) => {
1589
1599
  t(c);
1590
1600
  });
1591
1601
  }, [t, o]);
1592
- const e = (c) => {
1593
- const m = s.width / 2, g = s.height / 2, I = (m - s.x) / s.scale, p = (g - s.y) / s.scale, k = m - I * c, C = g - p * c;
1594
- o.updateViewport({ x: k, y: C, scale: c });
1595
- }, r = () => {
1596
- const c = Math.min(s.scale * 1.2, 5);
1597
- e(c);
1602
+ const s = (c) => {
1603
+ const g = e.width / 2, m = e.height / 2, v = (g - e.x) / e.scale, p = (m - e.y) / e.scale, _ = g - v * c, b = m - p * c;
1604
+ o.updateViewport({ x: _, y: b, scale: c });
1598
1605
  }, n = () => {
1599
- const c = Math.max(s.scale / 1.2, 0.1);
1600
- e(c);
1606
+ const c = Math.min(e.scale * 1.2, 5);
1607
+ s(c);
1608
+ }, i = () => {
1609
+ const c = Math.max(e.scale / 1.2, 0.1);
1610
+ s(c);
1601
1611
  }, a = () => {
1602
- e(1);
1603
- }, h = Math.round(s.scale * 100);
1604
- return /* @__PURE__ */ U("div", { className: "zoom-panel flex items-center gap-2", children: [
1612
+ s(1);
1613
+ }, h = Math.round(e.scale * 100);
1614
+ return /* @__PURE__ */ F("div", { className: "zoom-panel flex items-center gap-2", children: [
1605
1615
  /* @__PURE__ */ w(
1606
- H,
1616
+ W,
1607
1617
  {
1608
1618
  size: "sm",
1609
1619
  variant: "secondary",
1610
- onClick: n,
1620
+ onClick: i,
1611
1621
  title: "缩小",
1612
- children: /* @__PURE__ */ w(Ot, {})
1622
+ children: /* @__PURE__ */ w(te, {})
1613
1623
  }
1614
1624
  ),
1615
- /* @__PURE__ */ U(
1616
- H,
1625
+ /* @__PURE__ */ F(
1626
+ W,
1617
1627
  {
1618
1628
  size: "sm",
1619
1629
  variant: "secondary",
@@ -1627,80 +1637,80 @@ function me({ api: o }) {
1627
1637
  }
1628
1638
  ),
1629
1639
  /* @__PURE__ */ w(
1630
- H,
1640
+ W,
1631
1641
  {
1632
1642
  size: "sm",
1633
1643
  variant: "secondary",
1634
- onClick: r,
1644
+ onClick: n,
1635
1645
  title: "放大",
1636
- children: /* @__PURE__ */ w(Ft, {})
1646
+ children: /* @__PURE__ */ w(ee, {})
1637
1647
  }
1638
1648
  )
1639
1649
  ] });
1640
1650
  }
1641
- function ge({ api: o }) {
1642
- const [s, t] = O(o.canUndo()), [e, r] = O(o.canRedo());
1643
- return xt(() => {
1644
- const n = () => {
1645
- t(o.canUndo()), r(o.canRedo());
1651
+ function Ie({ api: o }) {
1652
+ const [e, t] = G(o.canUndo()), [s, n] = G(o.canRedo());
1653
+ return It(() => {
1654
+ const i = () => {
1655
+ t(o.canUndo()), n(o.canRedo());
1646
1656
  };
1647
- return o.on("state:change", n), () => {
1648
- o.off("state:change", n);
1657
+ return o.on("state:change", i), () => {
1658
+ o.off("state:change", i);
1649
1659
  };
1650
- }, [o]), /* @__PURE__ */ U("div", { className: "history-panel flex items-center gap-2", children: [
1660
+ }, [o]), /* @__PURE__ */ F("div", { className: "history-panel flex items-center gap-2", children: [
1651
1661
  /* @__PURE__ */ w(
1652
- H,
1662
+ W,
1653
1663
  {
1654
1664
  size: "sm",
1655
1665
  variant: "secondary",
1656
- disabled: !s,
1666
+ disabled: !e,
1657
1667
  onClick: () => o.undo(),
1658
1668
  title: "撤销",
1659
- children: /* @__PURE__ */ w(Lt, {})
1669
+ children: /* @__PURE__ */ w(se, {})
1660
1670
  }
1661
1671
  ),
1662
1672
  /* @__PURE__ */ w(
1663
- H,
1673
+ W,
1664
1674
  {
1665
1675
  size: "sm",
1666
1676
  variant: "secondary",
1667
- disabled: !e,
1677
+ disabled: !s,
1668
1678
  onClick: () => o.redo(),
1669
1679
  title: "重做",
1670
- children: /* @__PURE__ */ w(Wt, {})
1680
+ children: /* @__PURE__ */ w(ie, {})
1671
1681
  }
1672
1682
  )
1673
1683
  ] });
1674
1684
  }
1675
- function be({ setApi: o }) {
1676
- const s = At(null), [t, e] = O(null), [r, n] = O({ x: 0, y: 0, scale: 1 });
1677
- return xt(() => {
1678
- if (!s.current) return;
1679
- const a = new ae(s.current);
1680
- return e(a), o?.(a), a.on("viewport:change", (h) => {
1681
- n(h);
1685
+ function Ae({ setApi: o }) {
1686
+ const e = qt(null), [t, s] = G(null), [n, i] = G({ x: 0, y: 0, scale: 1 });
1687
+ return It(() => {
1688
+ if (!e.current) return;
1689
+ const a = new we(e.current);
1690
+ return s(a), o?.(a), a.on("viewport:change", (h) => {
1691
+ i(h);
1682
1692
  }), a.on("transformer:positionChange", (h) => {
1683
1693
  console.log("Transformer position changed:", h);
1684
1694
  }), () => {
1685
1695
  a.dispose();
1686
1696
  };
1687
- }, [o]), /* @__PURE__ */ U("div", { className: "pure-canvas relative size-full", children: [
1697
+ }, [o]), /* @__PURE__ */ F("div", { className: "pure-canvas relative size-full", children: [
1688
1698
  /* @__PURE__ */ w(
1689
- ce,
1699
+ Ne,
1690
1700
  {
1691
- viewportX: r.x,
1692
- viewportY: r.y,
1693
- scale: r.scale
1701
+ viewportX: n.x,
1702
+ viewportY: n.y,
1703
+ scale: n.scale
1694
1704
  }
1695
1705
  ),
1696
- /* @__PURE__ */ w("div", { ref: s, className: "size-full" }),
1697
- t && /* @__PURE__ */ U(zt, { children: [
1698
- /* @__PURE__ */ w("div", { className: "history-panel-wrapper absolute bottom-4 left-4 z-10", children: /* @__PURE__ */ w(ge, { api: t }) }),
1699
- /* @__PURE__ */ w("div", { className: "zoom-panel-wrapper absolute bottom-4 right-4 z-10", children: /* @__PURE__ */ w(me, { api: t }) })
1706
+ /* @__PURE__ */ w("div", { ref: e, className: "size-full" }),
1707
+ t && /* @__PURE__ */ F($t, { children: [
1708
+ /* @__PURE__ */ w("div", { className: "history-panel-wrapper absolute bottom-4 left-4 z-10", children: /* @__PURE__ */ w(Ie, { api: t }) }),
1709
+ /* @__PURE__ */ w("div", { className: "zoom-panel-wrapper absolute bottom-4 right-4 z-10", children: /* @__PURE__ */ w(_e, { api: t }) })
1700
1710
  ] })
1701
1711
  ] });
1702
1712
  }
1703
1713
  export {
1704
- ae as CanvasApi,
1705
- be as PureCanvas
1714
+ we as CanvasApi,
1715
+ Ae as PureCanvas
1706
1716
  };