@netless/appliance-plugin 1.0.0-beta.8 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/cdn/cdn.js +1 -1
  2. package/cdn/fullWorker-CIvt1j.js +453 -0
  3. package/cdn/subWorker-BE-0dg.js +453 -0
  4. package/dist/appliance-plugin.js +1 -1
  5. package/dist/appliance-plugin.mjs +13 -13
  6. package/dist/core/enum.d.ts +8 -1
  7. package/dist/core/mainEngine.d.ts +9 -2
  8. package/dist/core/mainThread/base.d.ts +2 -2
  9. package/dist/core/mainThread/index.d.ts +2 -2
  10. package/dist/core/mainThread/snapshotThread.d.ts +4 -4
  11. package/dist/core/mainThread/subLocalThread.d.ts +17 -13
  12. package/dist/core/mainThread/subTopThread.d.ts +7 -7
  13. package/dist/core/mainThread/vNodeManager.d.ts +2 -1
  14. package/dist/core/msgEvent/base.d.ts +6 -2
  15. package/dist/core/msgEvent/copyNode/forMain.d.ts +1 -0
  16. package/dist/core/msgEvent/deleteNode/forMain.d.ts +1 -0
  17. package/dist/core/msgEvent/deleteNode/forMainThread.d.ts +1 -4
  18. package/dist/core/msgEvent/deleteNode/forWorker.d.ts +1 -4
  19. package/dist/core/msgEvent/index.d.ts +4 -0
  20. package/dist/core/msgEvent/rotateNode/forMain.d.ts +2 -1
  21. package/dist/core/msgEvent/scaleNode/forMain.d.ts +2 -1
  22. package/dist/core/msgEvent/setColor/forMain.d.ts +1 -0
  23. package/dist/core/msgEvent/setFont/forMain.d.ts +1 -0
  24. package/dist/core/msgEvent/setLock/forMain.d.ts +1 -0
  25. package/dist/core/msgEvent/setPoint/forMain.d.ts +1 -0
  26. package/dist/core/msgEvent/setShape/forMain.d.ts +1 -0
  27. package/dist/core/msgEvent/setZIndex/forMain.d.ts +1 -0
  28. package/dist/core/msgEvent/translateNode/forMain.d.ts +2 -1
  29. package/dist/core/tools/base.d.ts +1 -1
  30. package/dist/core/tools/text.d.ts +2 -8
  31. package/dist/core/tools/utils.d.ts +2 -2
  32. package/dist/core/types.d.ts +1 -1
  33. package/dist/core/worker/base.d.ts +21 -13
  34. package/dist/core/worker/fullWorkerLocal.d.ts +1 -0
  35. package/dist/core/worker/subWorkerLocal.d.ts +3 -0
  36. package/dist/core/worker/subWorkerTopLayer.d.ts +7 -7
  37. package/dist/core/worker/vNodeManager.d.ts +2 -1
  38. package/dist/core/worker/workerManager.d.ts +2 -1
  39. package/dist/fullWorker.js +453 -566
  40. package/dist/index-BcIJbozZ.js +1 -0
  41. package/dist/index-C1YKkWHE.mjs +9090 -0
  42. package/dist/{index-Bt9t1FKB.mjs → index-ClJPZxV-.mjs} +1195 -1151
  43. package/dist/index-SsMz_ohn.js +1 -0
  44. package/dist/plugin/single/applianceDisplayer.d.ts +0 -1
  45. package/dist/plugin/types.d.ts +6 -14
  46. package/dist/style.css +1 -1
  47. package/dist/subWorker.js +453 -566
  48. package/package.json +5 -2
  49. package/cdn/fullWorker-BlZ1Wa.js +0 -566
  50. package/cdn/subWorker-BKoiIW.js +0 -566
  51. package/dist/index-BUCsfWH1.js +0 -1
  52. package/dist/index-Bz3L5rvA.js +0 -1
  53. package/dist/index-CTYUQm0L.mjs +0 -8859
@@ -1,14 +1,15 @@
1
1
  var Bt = Object.defineProperty;
2
- var zt = (R, n, e) => n in R ? Bt(R, n, { enumerable: !0, configurable: !0, writable: !0, value: e }) : R[n] = e;
3
- var m = (R, n, e) => (zt(R, typeof n != "symbol" ? n + "" : n, e), e);
4
- import { i as V, c as B, a as tt, P as O, g as z, s as Ft, b as pt, d as Tt, r as Ut, p as rt, e as nt, E as U, f as P, h as w, j as C, k as D, l as X, t as K, V as S, m as ht, S as Y, n as ct, o as gt, q as ot, u as vt, v as Xt, w as Yt, x as $t, y as It, z as dt, A as Vt, B as Ht, C as E, D as Pt, F as qt } from "./index-CTYUQm0L.mjs";
5
- import { Group as _, Path as it, Rect as St, Polyline as st, Ellipse as Gt, Sprite as jt, Label as Zt, Scene as Nt } from "spritejs";
2
+ var zt = (M, n, e) => n in M ? Bt(M, n, { enumerable: !0, configurable: !0, writable: !0, value: e }) : M[n] = e;
3
+ var m = (M, n, e) => (zt(M, typeof n != "symbol" ? n + "" : n, e), e);
4
+ import { i as q, c as B, a as tt, P as O, g as z, s as Ft, b as pt, d as Tt, r as Ut, p as rt, e as nt, E as X, f as P, h as y, j as C, k as A, l as Y, t as K, V as k, m as ht, S as $, n as ct, o as gt, q as ot, u as vt, v as Xt, w as Yt, x as $t, y as It, z as dt, A as Ht, B as Vt, C as E, D as Pt, F as Gt } from "./index-C1YKkWHE.mjs";
5
+ import { Group as _, Path as it, Rect as kt, Polyline as st, Ellipse as qt, Sprite as jt, Label as Zt, Scene as Nt } from "spritejs";
6
6
  import Kt from "lineclip";
7
7
  import "lz-string";
8
8
  import "white-web-sdk";
9
9
  import "react-dom";
10
10
  import "react";
11
- const j = class j {
11
+ import "lodash";
12
+ const V = class V {
12
13
  constructor(n) {
13
14
  m(this, "syncUnitTime", 1e3);
14
15
  m(this, "vNodes");
@@ -45,14 +46,14 @@ const j = class j {
45
46
  const i = this.fullLayer.getElementsByName(t) || this.drawLayer && this.drawLayer.getElementsByName(t) || [];
46
47
  if (i.length !== 1)
47
48
  return;
48
- const r = i[0], { pos: a, zIndex: c, scale: l, angle: h, translate: p } = n, f = {};
49
- V(c) && (f.zIndex = c), a && (f.pos = [a[0], a[1]]), l && (f.scale = l), h && (f.rotate = h), p && (f.translate = p), r.attr(f);
49
+ const r = i[0], { pos: a, zIndex: c, scale: l, angle: h, translate: p } = n, u = {};
50
+ q(c) && (u.zIndex = c), a && (u.pos = [a[0], a[1]]), l && (u.scale = l), h && (u.rotate = h), p && (u.translate = p), r.attr(u);
50
51
  const d = r == null ? void 0 : r.getBoundingClientRect();
51
52
  return d && (e = B(e, {
52
- x: Math.floor(d.x - j.SafeBorderPadding),
53
- y: Math.floor(d.y - j.SafeBorderPadding),
54
- w: Math.floor(d.width + j.SafeBorderPadding * 2),
55
- h: Math.floor(d.height + j.SafeBorderPadding * 2)
53
+ x: Math.floor(d.x - V.SafeBorderPadding),
54
+ y: Math.floor(d.y - V.SafeBorderPadding),
55
+ w: Math.floor(d.width + V.SafeBorderPadding * 2),
56
+ h: Math.floor(d.height + V.SafeBorderPadding * 2)
56
57
  })), (s = this.vNodes) == null || s.setInfo(t, {
57
58
  rect: e,
58
59
  centerPos: a
@@ -76,51 +77,61 @@ const j = class j {
76
77
  });
77
78
  }
78
79
  static updateNodeOpt(n) {
79
- const { node: e, opt: t, vNodes: o, willSerializeData: s, targetNode: i } = n, { zIndex: r, translate: a, angle: c, box: l, boxScale: h, boxTranslate: p, pointMap: f } = t;
80
+ const { node: e, opt: t, vNodes: o, willSerializeData: s, targetNode: i } = n, { zIndex: r, translate: a, angle: c, box: l, boxScale: h, boxTranslate: p, pointMap: u } = t;
80
81
  let d;
81
- const u = i && tt(i) || o.get(e.name);
82
- if (!u)
82
+ const f = i && tt(i) || o.get(e.name);
83
+ if (!f)
83
84
  return;
84
- V(r) && (e.setAttribute("zIndex", r), u.opt.zIndex = r);
85
- const y = e.parent;
86
- if (y) {
85
+ q(r) && (e.setAttribute("zIndex", r), f.opt.zIndex = r);
86
+ const w = e.parent;
87
+ if (w) {
87
88
  if (l && p && h) {
88
- const { rect: k } = u, b = [];
89
- for (let M = 0; M < u.op.length; M += 3)
90
- b.push(new O(u.op[M], u.op[M + 1], u.op[M + 2]));
91
- const v = z(b), g = [v.w * y.worldScaling[0], v.h * y.worldScaling[0]], L = [k.w - g[0], k.h - g[1]], N = [(k.w * h[0] - L[0]) / g[0], (k.h * h[1] - L[1]) / g[1]], I = [p[0] / y.worldScaling[0], p[1] / y.worldScaling[1]], A = u.op.map((M, $) => {
92
- const F = $ % 3;
93
- return F === 0 ? M + I[0] : F === 1 ? M + I[1] : M;
94
- }), T = [u.centerPos[0] + I[0], u.centerPos[1] + I[1]];
95
- Ft(A, T, N);
89
+ const { rect: S } = f, b = [];
90
+ for (let R = 0; R < f.op.length; R += 3)
91
+ b.push(new O(f.op[R], f.op[R + 1], f.op[R + 2]));
92
+ const I = z(b), g = [I.w * w.worldScaling[0], I.h * w.worldScaling[0]], L = [S.w - g[0], S.h - g[1]], v = [(S.w * h[0] - L[0]) / g[0], (S.h * h[1] - L[1]) / g[1]], W = [p[0] / w.worldScaling[0], p[1] / w.worldScaling[1]], D = f.op.map((R, U) => {
93
+ const F = U % 3;
94
+ return F === 0 ? R + W[0] : F === 1 ? R + W[1] : R;
95
+ }), T = [f.centerPos[0] + W[0], f.centerPos[1] + W[1]];
96
+ Ft(D, T, v);
96
97
  const x = [];
97
- for (let M = 0; M < A.length; M += 3)
98
- x.push(new O(A[M], A[M + 1], A[M + 2]));
99
- u.op = A, u.centerPos = T;
100
- } else if (a) {
101
- const k = [a[0] / y.worldScaling[0], a[1] / y.worldScaling[1]];
102
- e.setAttribute("translate", k), u.opt.translate = k, i && (d = pt(u.rect, a), u.rect = d);
103
- } else
104
- V(c) && (e.setAttribute("rotate", c), u.opt.rotate = c, i && (d = Tt(u.rect, c), u.rect = d));
105
- if (f) {
106
- const k = f.get(e.name);
107
- if (k)
108
- for (let b = 0, v = 0; b < u.op.length; b += 3, v++)
109
- u.op[b] = k[v][0], u.op[b + 1] = k[v][1];
98
+ for (let R = 0; R < D.length; R += 3)
99
+ x.push(new O(D[R], D[R + 1], D[R + 2]));
100
+ f.op = D, f.centerPos = T;
101
+ } else if (a)
102
+ if (e.setAttribute("translate", a), f.opt.translate = a, i) {
103
+ const S = [a[0] * w.worldScaling[0], a[1] * w.worldScaling[1]];
104
+ d = pt(f.rect, S), f.rect = d;
105
+ } else {
106
+ const S = V.getRectFromLayer(w, e.name);
107
+ f.rect = S || f.rect;
108
+ }
109
+ else if (q(c))
110
+ if (e.setAttribute("rotate", c), f.opt.rotate = c, i)
111
+ d = Tt(f.rect, c), f.rect = d;
112
+ else {
113
+ const S = V.getRectFromLayer(w, e.name);
114
+ f.rect = S || f.rect;
115
+ }
116
+ if (u) {
117
+ const S = u.get(e.name);
118
+ if (S)
119
+ for (let b = 0, I = 0; b < f.op.length; b += 3, I++)
120
+ f.op[b] = S[I][0], f.op[b + 1] = S[I][1];
110
121
  }
111
122
  if (s) {
112
123
  if (a) {
113
- const k = [a[0] / y.worldScaling[0], a[1] / y.worldScaling[1]], b = u.op.map((v, g) => {
124
+ const S = [a[0], a[1]], b = f.op.map((I, g) => {
114
125
  const L = g % 3;
115
- return L === 0 ? v + k[0] : L === 1 ? v + k[1] : v;
126
+ return L === 0 ? I + S[0] : L === 1 ? I + S[1] : I;
116
127
  });
117
- u.op = b, u.centerPos = [u.centerPos[0] + k[0], u.centerPos[1] + k[1]], u != null && u.opt && (u.opt.translate = void 0);
118
- } else if (V(c)) {
119
- const k = u.op;
120
- Ut(k, u.centerPos, c), u.op = k, u != null && u.opt && (u.opt.rotate = void 0);
128
+ f.op = b, f.centerPos = [f.centerPos[0] + S[0], f.centerPos[1] + S[1]], f != null && f.opt && (f.opt.translate = void 0);
129
+ } else if (q(c)) {
130
+ const S = f.op;
131
+ Ut(S, f.centerPos, c), f.op = S, f != null && f.opt && (f.opt.rotate = void 0);
121
132
  }
122
133
  }
123
- u && o.setInfo(e.name, u);
134
+ f && o.setInfo(e.name, f);
124
135
  }
125
136
  }
126
137
  static getCenterPos(n, e) {
@@ -135,36 +146,36 @@ const j = class j {
135
146
  if (t) {
136
147
  const o = t.getBoundingClientRect();
137
148
  return {
138
- x: Math.floor(o.x - j.SafeBorderPadding),
139
- y: Math.floor(o.y - j.SafeBorderPadding),
140
- w: Math.floor(o.width + j.SafeBorderPadding * 2),
141
- h: Math.floor(o.height + j.SafeBorderPadding * 2)
149
+ x: Math.floor(o.x - V.SafeBorderPadding),
150
+ y: Math.floor(o.y - V.SafeBorderPadding),
151
+ w: Math.floor(o.width + V.SafeBorderPadding * 2),
152
+ h: Math.floor(o.height + V.SafeBorderPadding * 2)
142
153
  };
143
154
  }
144
155
  }
145
156
  };
146
- m(j, "SafeBorderPadding", 10);
147
- let W = j;
148
- function lt(R, n = !0) {
149
- const e = R.length;
157
+ m(V, "SafeBorderPadding", 10);
158
+ let N = V;
159
+ function lt(M, n = !0) {
160
+ const e = M.length;
150
161
  if (e < 2)
151
162
  return "";
152
- let t = R[0], o = R[1];
163
+ let t = M[0], o = M[1];
153
164
  if (e === 2)
154
165
  return `M${rt(t)}L${rt(o)}`;
155
166
  let s = "";
156
167
  for (let i = 2, r = e - 1; i < r; i++)
157
- t = R[i], o = R[i + 1], s += nt(t, o);
158
- return n ? `M${nt(R[0], R[1])}Q${rt(R[1])}${nt(
159
- R[1],
160
- R[2]
161
- )}T${s}${nt(R[e - 1], R[0])}${nt(R[0], R[1])}Z` : `M${rt(R[0])}Q${rt(R[1])}${nt(R[1], R[2])}${R.length > 3 ? "T" : ""}${s}L${rt(R[e - 1])}`;
168
+ t = M[i], o = M[i + 1], s += nt(t, o);
169
+ return n ? `M${nt(M[0], M[1])}Q${rt(M[1])}${nt(
170
+ M[1],
171
+ M[2]
172
+ )}T${s}${nt(M[e - 1], M[0])}${nt(M[0], M[1])}Z` : `M${rt(M[0])}Q${rt(M[1])}${nt(M[1], M[2])}${M.length > 3 ? "T" : ""}${s}L${rt(M[e - 1])}`;
162
173
  }
163
- class Wt extends W {
174
+ class Wt extends N {
164
175
  constructor(e) {
165
176
  super(e);
166
177
  m(this, "canRotate", !0);
167
- m(this, "scaleType", U.all);
178
+ m(this, "scaleType", X.all);
168
179
  m(this, "toolsType", P.Pencil);
169
180
  m(this, "syncTimestamp");
170
181
  m(this, "syncIndex", 0);
@@ -186,7 +197,7 @@ class Wt extends W {
186
197
  const i = this.drawLayer || this.fullLayer;
187
198
  return t.length && (s = this.draw({ attrs: o, tasks: t, replaceId: e, layer: i })), {
188
199
  rect: s,
189
- type: w.DrawWork,
200
+ type: y.DrawWork,
190
201
  dataType: C.Local
191
202
  };
192
203
  }
@@ -197,46 +208,46 @@ class Wt extends W {
197
208
  var b;
198
209
  const { data: t, isFullWork: o, isSubWorker: s, isMainThread: i, drawCount: r, replaceId: a } = e;
199
210
  if (((b = t.op) == null ? void 0 : b.length) === 0)
200
- return { type: w.None };
211
+ return { type: y.None };
201
212
  const { workId: c } = t, { tasks: l, effects: h, consumeIndex: p } = this.transformData(t, !1);
202
213
  this.syncIndex = Math.min(this.syncIndex, p, Math.max(0, this.tmpPoints.length - 2));
203
- const f = {
214
+ const u = {
204
215
  name: c == null ? void 0 : c.toString(),
205
216
  id: r == null ? void 0 : r.toString()
206
217
  };
207
- let d, u = !1;
208
- const y = this.syncIndex;
209
- if (this.syncTimestamp === 0 && (this.syncTimestamp = Date.now()), l.length && (l[0].taskId - this.syncTimestamp > this.syncUnitTime && (u = !0, this.syncTimestamp = l[0].taskId, this.syncIndex = this.tmpPoints.length), s || i)) {
210
- const v = o ? this.fullLayer : this.drawLayer || this.fullLayer;
211
- d = this.draw({ attrs: f, tasks: l, effects: h, layer: v, replaceId: a });
218
+ let d, f = !1;
219
+ const w = this.syncIndex;
220
+ if (this.syncTimestamp === 0 && (this.syncTimestamp = Date.now()), l.length && (l[0].taskId - this.syncTimestamp > this.syncUnitTime && (f = !0, this.syncTimestamp = l[0].taskId, this.syncIndex = this.tmpPoints.length), s || i)) {
221
+ const I = o ? this.fullLayer : this.drawLayer || this.fullLayer;
222
+ d = this.draw({ attrs: u, tasks: l, effects: h, layer: I, replaceId: a });
212
223
  }
213
224
  if (s)
214
225
  return p > 10 && this.tmpPoints.splice(0, p - 10), {
215
226
  rect: d,
216
- type: w.DrawWork,
227
+ type: y.DrawWork,
217
228
  dataType: C.Local
218
229
  };
219
- const k = [];
220
- return this.tmpPoints.slice(y).forEach((v) => {
221
- k.push(v.x, v.y, this.computRadius(v.z, this.workOptions.thickness));
230
+ const S = [];
231
+ return this.tmpPoints.slice(w).forEach((I) => {
232
+ S.push(I.x, I.y, this.computRadius(I.z, this.workOptions.thickness));
222
233
  }), {
223
234
  rect: d,
224
- type: w.DrawWork,
235
+ type: y.DrawWork,
225
236
  dataType: C.Local,
226
- workId: u ? c : void 0,
227
- op: u ? k : void 0,
228
- index: u ? y * 3 : void 0
237
+ workId: f ? c : void 0,
238
+ op: f ? S : void 0,
239
+ index: f ? w * 3 : void 0
229
240
  };
230
241
  }
231
242
  consumeAll(e) {
232
243
  var l, h;
233
244
  if (e.data) {
234
- const { op: p, workState: f } = e.data;
235
- p != null && p.length && f === D.Done && this.workOptions.strokeType === X.Stroke && this.updateTempPointsWithPressureWhenDone(p);
245
+ const { op: p, workState: u } = e.data;
246
+ p != null && p.length && u === A.Done && this.workOptions.strokeType === Y.Stroke && this.updateTempPointsWithPressureWhenDone(p);
236
247
  }
237
248
  const t = (l = this.workId) == null ? void 0 : l.toString();
238
249
  if (!t)
239
- return { type: w.None };
250
+ return { type: y.None };
240
251
  const o = this.transformDataAll(!0), s = {
241
252
  name: t
242
253
  };
@@ -255,10 +266,10 @@ class Wt extends W {
255
266
  toolsType: this.toolsType,
256
267
  scaleType: this.scaleType,
257
268
  canRotate: this.canRotate,
258
- centerPos: i && W.getCenterPos(i, r)
269
+ centerPos: i && N.getCenterPos(i, r)
259
270
  }), {
260
271
  rect: i,
261
- type: w.FullWork,
272
+ type: y.FullWork,
262
273
  dataType: C.Local,
263
274
  workId: t,
264
275
  ops: c,
@@ -277,12 +288,12 @@ class Wt extends W {
277
288
  const { op: t, isFullWork: o, replaceId: s } = e;
278
289
  this.tmpPoints.length = 0;
279
290
  for (let p = 0; p < t.length; p += 3) {
280
- const f = new O(t[p], t[p + 1], t[p + 2]);
291
+ const u = new O(t[p], t[p + 1], t[p + 2]);
281
292
  if (this.tmpPoints.length > 0) {
282
- const d = this.tmpPoints[this.tmpPoints.length - 1], u = S.Sub(f, d).uni();
283
- f.setv(u);
293
+ const d = this.tmpPoints[this.tmpPoints.length - 1], f = k.Sub(u, d).uni();
294
+ u.setv(f);
284
295
  }
285
- this.tmpPoints.push(f);
296
+ this.tmpPoints.push(u);
286
297
  }
287
298
  const i = this.transformDataAll(!1), r = (l = this.workId) == null ? void 0 : l.toString(), a = {
288
299
  name: r
@@ -297,7 +308,7 @@ class Wt extends W {
297
308
  toolsType: this.toolsType,
298
309
  scaleType: this.scaleType,
299
310
  canRotate: this.canRotate,
300
- centerPos: c && W.getCenterPos(c, p)
311
+ centerPos: c && N.getCenterPos(c, p)
301
312
  });
302
313
  }
303
314
  return c;
@@ -306,63 +317,63 @@ class Wt extends W {
306
317
  return this.getTaskPoints(this.tmpPoints, e && this.workOptions.thickness || void 0);
307
318
  }
308
319
  draw(e) {
309
- const { attrs: t, tasks: o, replaceId: s, effects: i, layer: r } = e, { strokeColor: a, strokeType: c, thickness: l, zIndex: h, scale: p, rotate: f, translate: d } = this.workOptions;
320
+ const { attrs: t, tasks: o, replaceId: s, effects: i, layer: r } = e, { strokeColor: a, strokeType: c, thickness: l, zIndex: h, scale: p, rotate: u, translate: d } = this.workOptions;
310
321
  i != null && i.size && (i.forEach((g) => {
311
322
  var L;
312
323
  (L = r.getElementById(g + "")) == null || L.remove();
313
324
  }), i.clear());
314
- let u;
315
- const y = [], k = r.worldPosition, b = r.worldScaling;
325
+ let f;
326
+ const w = [], S = r.worldPosition, b = r.worldScaling;
316
327
  for (let g = 0; g < o.length; g++) {
317
- const { pos: L, points: N } = o[g], { ps: I, rect: A } = this.computDrawPoints(N);
328
+ const { pos: L, points: v } = o[g], { ps: W, rect: D } = this.computDrawPoints(v);
318
329
  let T;
319
- const x = N.length === 1;
320
- c === X.Stroke || x ? T = lt(I, !0) : T = lt(I, !1);
321
- const M = {
330
+ const x = v.length === 1;
331
+ c === Y.Stroke || x ? T = lt(W, !0) : T = lt(W, !1);
332
+ const R = {
322
333
  pos: L,
323
334
  d: T,
324
- fillColor: c === X.Stroke || x ? a : void 0,
325
- lineDash: c === X.Dotted && !x ? [1, l * 2] : c === X.LongDotted && !x ? [l, l * 2] : void 0,
335
+ fillColor: c === Y.Stroke || x ? a : void 0,
336
+ lineDash: c === Y.Dotted && !x ? [1, l * 2] : c === Y.LongDotted && !x ? [l, l * 2] : void 0,
326
337
  strokeColor: a,
327
- lineCap: c === X.Stroke || x ? void 0 : "round",
328
- lineWidth: c === X.Stroke || x ? 0 : l
338
+ lineCap: c === Y.Stroke || x ? void 0 : "round",
339
+ lineWidth: c === Y.Stroke || x ? 0 : l
329
340
  };
330
- u = B(u, {
331
- x: Math.floor((A.x + L[0]) * b[0] + k[0] - W.SafeBorderPadding),
332
- y: Math.floor((A.y + L[1]) * b[1] + k[1] - W.SafeBorderPadding),
333
- w: Math.floor(A.w * b[0] + 2 * W.SafeBorderPadding),
334
- h: Math.floor(A.h * b[1] + 2 * W.SafeBorderPadding)
335
- }), y.push(M);
341
+ f = B(f, {
342
+ x: Math.floor((D.x + L[0]) * b[0] + S[0] - N.SafeBorderPadding),
343
+ y: Math.floor((D.y + L[1]) * b[1] + S[1] - N.SafeBorderPadding),
344
+ w: Math.floor(D.w * b[0] + 2 * N.SafeBorderPadding),
345
+ h: Math.floor(D.h * b[1] + 2 * N.SafeBorderPadding)
346
+ }), w.push(R);
336
347
  }
337
- p && (t.scale = p), f && (t.rotate = f), d && (t.translate = d);
338
- const v = new _();
339
- if (u) {
340
- this.centerPos = W.getCenterPos(u, r), v.attr({
348
+ p && (t.scale = p), u && (t.rotate = u), d && (t.translate = d);
349
+ const I = new _();
350
+ if (f) {
351
+ this.centerPos = N.getCenterPos(f, r), I.attr({
341
352
  ...t,
342
353
  normalize: !0,
343
354
  anchor: [0.5, 0.5],
344
- bgcolor: c === X.Stroke ? a : void 0,
355
+ bgcolor: c === Y.Stroke ? a : void 0,
345
356
  pos: this.centerPos,
346
- size: [(u.w - 2 * W.SafeBorderPadding) / b[0], (u.h - 2 * W.SafeBorderPadding) / b[1]],
357
+ size: [(f.w - 2 * N.SafeBorderPadding) / b[0], (f.h - 2 * N.SafeBorderPadding) / b[1]],
347
358
  zIndex: h
348
359
  });
349
- const g = y.map((L) => (L.pos = [L.pos[0] - this.centerPos[0], L.pos[1] - this.centerPos[1]], new it(L)));
350
- v.append(...g), c === X.Stroke && v.seal(), this.replace(r, s || t.workId, v);
360
+ const g = w.map((L) => (L.pos = [L.pos[0] - this.centerPos[0], L.pos[1] - this.centerPos[1]], new it(L)));
361
+ I.append(...g), c === Y.Stroke && I.seal(), this.replace(r, s || t.workId, I);
351
362
  }
352
- if (p || f || d) {
353
- const g = v == null ? void 0 : v.getBoundingClientRect();
363
+ if (p || u || d) {
364
+ const g = I == null ? void 0 : I.getBoundingClientRect();
354
365
  if (g)
355
366
  return {
356
- x: Math.floor(g.x - W.SafeBorderPadding),
357
- y: Math.floor(g.y - W.SafeBorderPadding),
358
- w: Math.floor(g.width + W.SafeBorderPadding * 2),
359
- h: Math.floor(g.height + W.SafeBorderPadding * 2)
367
+ x: Math.floor(g.x - N.SafeBorderPadding),
368
+ y: Math.floor(g.y - N.SafeBorderPadding),
369
+ w: Math.floor(g.width + N.SafeBorderPadding * 2),
370
+ h: Math.floor(g.height + N.SafeBorderPadding * 2)
360
371
  };
361
372
  }
362
- return u;
373
+ return f;
363
374
  }
364
375
  computDrawPoints(e) {
365
- return this.workOptions.strokeType === X.Stroke || e.length === 1 ? this.computStroke(e) : this.computNomal(e);
376
+ return this.workOptions.strokeType === Y.Stroke || e.length === 1 ? this.computStroke(e) : this.computNomal(e);
366
377
  }
367
378
  computNomal(e) {
368
379
  let t = this.workOptions.thickness;
@@ -378,8 +389,8 @@ class Wt extends W {
378
389
  const { point: l, radius: h } = e[c];
379
390
  let p = l.v;
380
391
  c === 0 && e.length > 1 && (p = e[c + 1].point.v);
381
- const f = S.Per(p).mul(h);
382
- t.push(O.Sub(l, f)), o.push(O.Add(l, f));
392
+ const u = k.Per(p).mul(h);
393
+ t.push(O.Sub(l, u)), o.push(O.Add(l, u));
383
394
  }
384
395
  const s = e[e.length - 1], i = O.GetSemicircleStroke(s.point, t[t.length - 1], -1, 8), r = O.GetSemicircleStroke(e[0].point, o[0], -1, 8), a = t.concat(i, o.reverse(), r);
385
396
  return { ps: a, rect: z(a) };
@@ -393,7 +404,7 @@ class Wt extends W {
393
404
  let i = this.tmpPoints.length - 1, r = [];
394
405
  if (o != null && o.length && s) {
395
406
  const { strokeType: a, thickness: c } = this.workOptions, l = /* @__PURE__ */ new Set();
396
- i = a === X.Stroke ? this.updateTempPointsWithPressure(o, c, l) : this.updateTempPoints(o, c, l);
407
+ i = a === Y.Stroke ? this.updateTempPointsWithPressure(o, c, l) : this.updateTempPoints(o, c, l);
397
408
  const h = t ? this.tmpPoints : this.tmpPoints.slice(i);
398
409
  return r = this.getTaskPoints(h, c), { tasks: r, effects: l, consumeIndex: i };
399
410
  }
@@ -413,26 +424,26 @@ class Wt extends W {
413
424
  return [];
414
425
  let s = 0, i = e[0].x, r = e[0].y, a = [i, r], c = [], l = e[0].t;
415
426
  for (; s < e.length; ) {
416
- const p = e[s], f = p.x - i, d = p.y - r, u = p.z, y = t ? this.computRadius(u, t) : u;
427
+ const p = e[s], u = p.x - i, d = p.y - r, f = p.z, w = t ? this.computRadius(f, t) : f;
417
428
  if (c.push({
418
- point: new O(f, d, u, e[s].v),
419
- radius: y
429
+ point: new O(u, d, f, e[s].v),
430
+ radius: w
420
431
  }), s > 0 && s < e.length - 1) {
421
- const k = e[s].getAngleByPoints(e[s - 1], e[s + 1]);
422
- if (k < 90 || k > 270) {
432
+ const S = e[s].getAngleByPoints(e[s - 1], e[s + 1]);
433
+ if (S < 90 || S > 270) {
423
434
  const b = (h = c.pop()) == null ? void 0 : h.point.clone();
424
435
  b && o.push({
425
436
  taskId: l,
426
437
  pos: a,
427
438
  points: [...c, {
428
439
  point: b,
429
- radius: y
440
+ radius: w
430
441
  }]
431
442
  }), i = e[s].x, r = e[s].y, a = [i, r];
432
- const v = p.x - i, g = p.y - r;
443
+ const I = p.x - i, g = p.y - r;
433
444
  c = [{
434
- point: new O(v, g, u),
435
- radius: y
445
+ point: new O(I, g, f),
446
+ radius: w
436
447
  }], l = Date.now();
437
448
  }
438
449
  }
@@ -454,16 +465,16 @@ class Wt extends W {
454
465
  this.tmpPoints.push(h);
455
466
  continue;
456
467
  }
457
- const p = l - 1, f = this.tmpPoints[p], d = S.Sub(h, f).uni();
458
- if (h.isNear(f, t)) {
459
- if (f.z < this.MAX_REPEAR) {
460
- if (f.setz(Math.min(f.z + 1, this.MAX_REPEAR)), r = Math.min(r, p), l > 1) {
461
- let k = l - 1;
462
- for (; k > 0; ) {
463
- const b = this.tmpPoints[k].distance(this.tmpPoints[k - 1]), v = Math.max(this.tmpPoints[k].z - this.uniThickness * b, 0);
464
- if (this.tmpPoints[k - 1].z >= v)
468
+ const p = l - 1, u = this.tmpPoints[p], d = k.Sub(h, u).uni();
469
+ if (h.isNear(u, t)) {
470
+ if (u.z < this.MAX_REPEAR) {
471
+ if (u.setz(Math.min(u.z + 1, this.MAX_REPEAR)), r = Math.min(r, p), l > 1) {
472
+ let S = l - 1;
473
+ for (; S > 0; ) {
474
+ const b = this.tmpPoints[S].distance(this.tmpPoints[S - 1]), I = Math.max(this.tmpPoints[S].z - this.uniThickness * b, 0);
475
+ if (this.tmpPoints[S - 1].z >= I)
465
476
  break;
466
- this.tmpPoints[k - 1].setz(v), r = Math.min(r, k - 1), k--;
477
+ this.tmpPoints[S - 1].setz(I), r = Math.min(r, S - 1), S--;
467
478
  }
468
479
  }
469
480
  } else
@@ -471,8 +482,8 @@ class Wt extends W {
471
482
  continue;
472
483
  }
473
484
  h.setv(d);
474
- const u = h.distance(f), y = Math.max(f.z - this.uniThickness * u, 0);
475
- l > 1 && S.Equals(d, f.v, 0.02) && (y > 0 || f.z <= 0) && (o && f.t && o.add(f.t), this.tmpPoints.pop(), r = Math.min(p, r)), h.setz(y), this.tmpPoints.push(h);
485
+ const f = h.distance(u), w = Math.max(u.z - this.uniThickness * f, 0);
486
+ l > 1 && k.Equals(d, u.v, 0.02) && (w > 0 || u.z <= 0) && (o && u.t && o.add(u.t), this.tmpPoints.pop(), r = Math.min(p, r)), h.setz(w), this.tmpPoints.push(h);
476
487
  }
477
488
  if (r === 1 / 0)
478
489
  return this.tmpPoints.length;
@@ -504,12 +515,12 @@ class Wt extends W {
504
515
  this.tmpPoints.push(p);
505
516
  continue;
506
517
  }
507
- const f = h - 1, d = this.tmpPoints[f], u = S.Sub(p, d).uni();
518
+ const u = h - 1, d = this.tmpPoints[u], f = k.Sub(p, d).uni();
508
519
  if (p.isNear(d, t / 2)) {
509
- r = Math.min(f, r);
520
+ r = Math.min(u, r);
510
521
  continue;
511
522
  }
512
- S.Equals(u, d.v, 0.02) && (o && d.t && o.add(d.t), this.tmpPoints.pop(), r = Math.min(f, r)), p.setv(u), this.tmpPoints.push(p);
523
+ k.Equals(f, d.v, 0.02) && (o && d.t && o.add(d.t), this.tmpPoints.pop(), r = Math.min(u, r)), p.setv(f), this.tmpPoints.push(p);
513
524
  }
514
525
  let a = i;
515
526
  if (r === i) {
@@ -537,24 +548,24 @@ class Wt extends W {
537
548
  this.tmpPoints.push(a);
538
549
  continue;
539
550
  }
540
- const c = r - 1, l = this.tmpPoints[c], h = S.Sub(a, l).uni(), p = a.distance(l);
551
+ const c = r - 1, l = this.tmpPoints[c], h = k.Sub(a, l).uni(), p = a.distance(l);
541
552
  if (r > 1 && l.z === s)
542
553
  break;
543
554
  if (a.isNear(l, t / 2)) {
544
555
  if (o < 3 && l.z < this.MAX_REPEAR && (l.setz(Math.min(l.z + 1, this.MAX_REPEAR)), r > 1)) {
545
556
  let d = r - 1;
546
557
  for (; d > 0; ) {
547
- const u = this.tmpPoints[d].distance(this.tmpPoints[d - 1]), y = Math.max(this.tmpPoints[d].z - this.uniThickness * u, -t / 4);
548
- if (this.tmpPoints[d - 1].z >= y)
558
+ const f = this.tmpPoints[d].distance(this.tmpPoints[d - 1]), w = Math.max(this.tmpPoints[d].z - this.uniThickness * f, -t / 4);
559
+ if (this.tmpPoints[d - 1].z >= w)
549
560
  break;
550
- this.tmpPoints[d - 1].setz(y), d--;
561
+ this.tmpPoints[d - 1].setz(w), d--;
551
562
  }
552
563
  }
553
564
  continue;
554
565
  }
555
566
  a.setv(h);
556
- const f = Math.max(l.z - this.uniThickness * p, s);
557
- r > 1 && S.Equals(h, l.v, 0.02) && l.z <= 0 && this.tmpPoints.pop(), a.setz(f), this.tmpPoints.push(a);
567
+ const u = Math.max(l.z - this.uniThickness * p, s);
568
+ r > 1 && k.Equals(h, l.v, 0.02) && l.z <= 0 && this.tmpPoints.pop(), a.setz(u), this.tmpPoints.push(a);
558
569
  }
559
570
  }
560
571
  static updateNodeOpt(e) {
@@ -562,29 +573,15 @@ class Wt extends W {
562
573
  const { node: t, opt: o, vNodes: s } = e, { strokeColor: i } = o, r = s.get(t.name);
563
574
  return i && (t.tagName === "GROUP" ? Jt(t) ? t.setAttribute("bgcolor", i) : t.children.forEach((c) => {
564
575
  c.setAttribute("strokeColor", i), c.getAttribute("fillColor") && c.setAttribute("fillColor", i);
565
- }) : (t.setAttribute("strokeColor", i), t.setAttribute("fillColor", i)), (a = r == null ? void 0 : r.opt) != null && a.strokeColor && (r.opt.strokeColor = i)), r && s.setInfo(t.name, r), W.updateNodeOpt(e);
566
- }
567
- // static getRectFromLayer(layer: Group, name:string): IRectType|undefined {
568
- // const node = layer.getElementsByName(name)[0] as ShapeNodes;
569
- // if (node) {
570
- // const r = node.getBoundingClientRect();
571
- // console.log('r', r.x, r.y, r.width, r.height)
572
- // return {
573
- // x: Math.floor(r.x - BaseShapeTool.SafeBorderPadding),
574
- // y: Math.floor(r.y - BaseShapeTool.SafeBorderPadding),
575
- // w: Math.floor(r.width + BaseShapeTool.SafeBorderPadding * 2),
576
- // h: Math.floor(r.height + BaseShapeTool.SafeBorderPadding * 2)
577
- // }
578
- // }
579
- // return undefined
580
- // }
576
+ }) : (t.setAttribute("strokeColor", i), t.setAttribute("fillColor", i)), (a = r == null ? void 0 : r.opt) != null && a.strokeColor && (r.opt.strokeColor = i)), r && s.setInfo(t.name, r), N.updateNodeOpt(e);
577
+ }
581
578
  }
582
- class Lt extends W {
579
+ class Lt extends N {
583
580
  constructor(e) {
584
581
  super(e);
585
582
  m(this, "toolsType", P.LaserPen);
586
583
  m(this, "canRotate", !1);
587
- m(this, "scaleType", U.none);
584
+ m(this, "scaleType", X.none);
588
585
  m(this, "syncTimestamp");
589
586
  m(this, "syncIndex", 0);
590
587
  m(this, "tmpPoints", []);
@@ -600,29 +597,29 @@ class Lt extends W {
600
597
  consume(e) {
601
598
  const { data: t, isSubWorker: o } = e, { workId: s, op: i } = t;
602
599
  if ((i == null ? void 0 : i.length) === 0)
603
- return { type: w.None };
600
+ return { type: y.None };
604
601
  if (this.updateTempPoints(i || []), this.consumeIndex > this.tmpPoints.length - 4)
605
- return { type: w.None };
602
+ return { type: y.None };
606
603
  const { strokeColor: r, thickness: a, strokeType: c } = this.workOptions, l = z(this.tmpPoints, a);
607
604
  let h = !1;
608
- const p = this.syncIndex, f = this.tmpPoints.slice(this.consumeIndex);
605
+ const p = this.syncIndex, u = this.tmpPoints.slice(this.consumeIndex);
609
606
  this.consumeIndex = this.tmpPoints.length - 1, this.syncTimestamp === 0 && (this.syncTimestamp = Date.now());
610
607
  const d = {
611
608
  name: s == null ? void 0 : s.toString(),
612
609
  opacity: 1,
613
- lineDash: c === X.Dotted ? [1, a * 2] : c === X.LongDotted ? [a, a * 2] : void 0,
610
+ lineDash: c === Y.Dotted ? [1, a * 2] : c === Y.LongDotted ? [a, a * 2] : void 0,
614
611
  strokeColor: r,
615
612
  lineCap: "round",
616
613
  lineWidth: a,
617
614
  anchor: [0.5, 0.5]
618
- }, u = this.getTaskPoints(f);
619
- if (u.length) {
620
- const k = Date.now();
621
- k - this.syncTimestamp > this.syncUnitTime && (h = !0, this.syncTimestamp = k, this.syncIndex = this.tmpPoints.length), o && this.draw({ attrs: d, tasks: u, isDot: !1, layer: this.drawLayer || this.fullLayer });
615
+ }, f = this.getTaskPoints(u);
616
+ if (f.length) {
617
+ const S = Date.now();
618
+ S - this.syncTimestamp > this.syncUnitTime && (h = !0, this.syncTimestamp = S, this.syncIndex = this.tmpPoints.length), o && this.draw({ attrs: d, tasks: f, isDot: !1, layer: this.drawLayer || this.fullLayer });
622
619
  }
623
- const y = [];
624
- return this.tmpPoints.slice(p).forEach((k) => {
625
- y.push(k.x, k.y);
620
+ const w = [];
621
+ return this.tmpPoints.slice(p).forEach((S) => {
622
+ w.push(S.x, S.y);
626
623
  }), {
627
624
  rect: {
628
625
  x: l.x * this.fullLayer.worldScaling[0] + this.fullLayer.worldPosition[0],
@@ -630,10 +627,10 @@ class Lt extends W {
630
627
  w: l.w * this.fullLayer.worldScaling[0],
631
628
  h: l.h * this.fullLayer.worldScaling[1]
632
629
  },
633
- type: w.DrawWork,
630
+ type: y.DrawWork,
634
631
  dataType: C.Local,
635
632
  workId: h ? s : void 0,
636
- op: h ? y : void 0,
633
+ op: h ? w : void 0,
637
634
  index: h ? p * 2 : void 0
638
635
  };
639
636
  }
@@ -656,13 +653,13 @@ class Lt extends W {
656
653
  name: e == null ? void 0 : e.toString(),
657
654
  fillColor: a ? c : void 0,
658
655
  opacity: 1,
659
- lineDash: h === X.Dotted && !a ? [1, l * 2] : h === X.LongDotted && !a ? [l, l * 2] : void 0,
656
+ lineDash: h === Y.Dotted && !a ? [1, l * 2] : h === Y.LongDotted && !a ? [l, l * 2] : void 0,
660
657
  strokeColor: c,
661
658
  lineCap: a ? void 0 : "round",
662
659
  lineWidth: a ? 0 : l,
663
660
  anchor: [0.5, 0.5]
664
- }, f = this.getTaskPoints(r);
665
- f.length && this.draw({ attrs: p, tasks: f, isDot: a, layer: this.drawLayer || this.fullLayer });
661
+ }, u = this.getTaskPoints(r);
662
+ u.length && this.draw({ attrs: p, tasks: u, isDot: a, layer: this.drawLayer || this.fullLayer });
666
663
  }
667
664
  const o = [];
668
665
  this.tmpPoints.forEach((r) => {
@@ -676,7 +673,7 @@ class Lt extends W {
676
673
  w: t.w * this.fullLayer.worldScaling[0],
677
674
  h: t.h * this.fullLayer.worldScaling[1]
678
675
  },
679
- type: w.FullWork,
676
+ type: y.FullWork,
680
677
  dataType: C.Local,
681
678
  workId: e,
682
679
  ops: s,
@@ -687,15 +684,15 @@ class Lt extends W {
687
684
  this.tmpPoints.length = 0, this.syncTimestamp = 0, this.syncIndex = 0;
688
685
  }
689
686
  consumeService(e) {
690
- var u;
687
+ var f;
691
688
  const { op: t, replaceId: o, isFullWork: s } = e, { strokeColor: i, thickness: r, strokeType: a } = this.workOptions;
692
689
  if (!t.length) {
693
- const y = z(this.tmpPoints, r);
690
+ const w = z(this.tmpPoints, r);
694
691
  return {
695
- x: y.x * this.fullLayer.worldScaling[0] + this.fullLayer.worldPosition[0],
696
- y: y.y * this.fullLayer.worldScaling[1] + this.fullLayer.worldPosition[1],
697
- w: y.w * this.fullLayer.worldScaling[0],
698
- h: y.h * this.fullLayer.worldScaling[1]
692
+ x: w.x * this.fullLayer.worldScaling[0] + this.fullLayer.worldPosition[0],
693
+ y: w.y * this.fullLayer.worldScaling[1] + this.fullLayer.worldPosition[1],
694
+ w: w.w * this.fullLayer.worldScaling[0],
695
+ h: w.h * this.fullLayer.worldScaling[1]
699
696
  };
700
697
  }
701
698
  const c = Math.max(0, this.tmpPoints.length - 1);
@@ -703,26 +700,26 @@ class Lt extends W {
703
700
  let l, h = this.tmpPoints.slice(c);
704
701
  const p = h.length === 1;
705
702
  if (p) {
706
- const y = this.computDotStroke({
703
+ const w = this.computDotStroke({
707
704
  point: h[0],
708
705
  radius: r / 2
709
706
  });
710
- h = y.ps, l = y.rect;
707
+ h = w.ps, l = w.rect;
711
708
  } else
712
709
  l = z(this.tmpPoints, r);
713
- const f = {
714
- name: (u = this.workId) == null ? void 0 : u.toString(),
710
+ const u = {
711
+ name: (f = this.workId) == null ? void 0 : f.toString(),
715
712
  fillColor: p ? i : void 0,
716
713
  opacity: 1,
717
- lineDash: a === X.Dotted && !p ? [1, r * 2] : a === X.LongDotted && !p ? [r, r * 2] : void 0,
714
+ lineDash: a === Y.Dotted && !p ? [1, r * 2] : a === Y.LongDotted && !p ? [r, r * 2] : void 0,
718
715
  strokeColor: i,
719
716
  lineCap: p ? void 0 : "round",
720
717
  lineWidth: p ? 0 : r,
721
718
  anchor: [0.5, 0.5]
722
719
  }, d = this.getTaskPoints(h);
723
720
  if (d.length) {
724
- const y = s ? this.fullLayer : this.drawLayer || this.fullLayer;
725
- this.draw({ attrs: f, tasks: d, isDot: p, replaceId: o, layer: y });
721
+ const w = s ? this.fullLayer : this.drawLayer || this.fullLayer;
722
+ this.draw({ attrs: u, tasks: d, isDot: p, replaceId: o, layer: w });
726
723
  }
727
724
  return {
728
725
  x: l.x * this.fullLayer.worldScaling[0] + this.fullLayer.worldPosition[0],
@@ -755,13 +752,13 @@ class Lt extends W {
755
752
  pos: l,
756
753
  d: p
757
754
  });
758
- const { vertex: f, fragment: d } = this.workOptions;
759
- if (f && d) {
760
- const u = i.renderer.createProgram({ vertex: f, fragment: d }), { width: y, height: k } = i.getResolution();
755
+ const { vertex: u, fragment: d } = this.workOptions;
756
+ if (u && d) {
757
+ const f = i.renderer.createProgram({ vertex: u, fragment: d }), { width: w, height: S } = i.getResolution();
761
758
  c.setUniforms({
762
759
  u_time: 0,
763
- u_resolution: [y, k]
764
- }), c.setProgram(u);
760
+ u_resolution: [w, S]
761
+ }), c.setProgram(f);
765
762
  }
766
763
  i.appendChild(c), c.transition(r).attr({
767
764
  scale: s ? [0.1, 0.1] : [1, 1],
@@ -780,15 +777,15 @@ class Lt extends W {
780
777
  for (; o < e.length; ) {
781
778
  const l = e[o], h = l.x - s, p = l.y - i;
782
779
  if (a.push(new O(h, p)), o > 0 && o < e.length - 1) {
783
- const f = e[o].getAngleByPoints(e[o - 1], e[o + 1]);
784
- if (f < 90 || f > 270) {
780
+ const u = e[o].getAngleByPoints(e[o - 1], e[o + 1]);
781
+ if (u < 90 || u > 270) {
785
782
  const d = (c = a.pop()) == null ? void 0 : c.clone();
786
783
  d && t.push({
787
784
  pos: r,
788
785
  points: [...a, d]
789
786
  }), s = e[o].x, i = e[o].y, r = [s, i];
790
- const u = l.x - s, y = l.y - i;
791
- a = [new O(u, y)];
787
+ const f = l.x - s, w = l.y - i;
788
+ a = [new O(f, w)];
792
789
  }
793
790
  }
794
791
  o++;
@@ -816,11 +813,11 @@ class Lt extends W {
816
813
  }), o.length && o.forEach((s) => s.remove()), t;
817
814
  }
818
815
  }
819
- const at = class at extends W {
816
+ const at = class at extends N {
820
817
  constructor(e, t) {
821
818
  super(e);
822
819
  m(this, "canRotate", !1);
823
- m(this, "scaleType", U.none);
820
+ m(this, "scaleType", X.none);
824
821
  m(this, "toolsType", P.Eraser);
825
822
  m(this, "serviceWork");
826
823
  m(this, "tmpPoints", []);
@@ -850,12 +847,12 @@ const at = class at extends W {
850
847
  computRectCenterPoints() {
851
848
  const e = this.tmpPoints.slice(-2);
852
849
  if (this.tmpPoints.length === 4) {
853
- const t = new S(this.tmpPoints[0], this.tmpPoints[1]), o = new S(this.tmpPoints[2], this.tmpPoints[3]), s = S.Sub(o, t).uni(), i = S.Dist(t, o), { width: r, height: a } = at.eraserSizes[this.workOptions.thickness], c = Math.min(r, a), l = Math.round(i / c);
850
+ const t = new k(this.tmpPoints[0], this.tmpPoints[1]), o = new k(this.tmpPoints[2], this.tmpPoints[3]), s = k.Sub(o, t).uni(), i = k.Dist(t, o), { width: r, height: a } = at.eraserSizes[this.workOptions.thickness], c = Math.min(r, a), l = Math.round(i / c);
854
851
  if (l > 1) {
855
852
  const h = [];
856
853
  for (let p = 0; p < l; p++) {
857
- const f = S.Mul(s, p * c);
858
- h.push(this.tmpPoints[0] + f.x, this.tmpPoints[1] + f.y);
854
+ const u = k.Mul(s, p * c);
855
+ h.push(this.tmpPoints[0] + u.x, this.tmpPoints[1] + u.y);
859
856
  }
860
857
  return h.concat(e);
861
858
  }
@@ -863,8 +860,8 @@ const at = class at extends W {
863
860
  return e;
864
861
  }
865
862
  isNear(e, t) {
866
- const o = new S(e[0], e[1]), s = new S(t[0], t[1]), { width: i, height: r } = at.eraserSizes[this.workOptions.thickness];
867
- return S.Dist(o, s) < Math.hypot(i, r) * 0.5;
863
+ const o = new k(e[0], e[1]), s = new k(t[0], t[1]), { width: i, height: r } = at.eraserSizes[this.workOptions.thickness];
864
+ return k.Dist(o, s) < Math.hypot(i, r) * 0.5;
868
865
  }
869
866
  cutPolyline(e, t) {
870
867
  let o = [t], s = 0;
@@ -878,12 +875,12 @@ const at = class at extends W {
878
875
  function i(a, c) {
879
876
  const l = a;
880
877
  for (let h = 0; h < a.length; h++) {
881
- const p = a[h], f = p.findIndex((d, u) => u < p.length - 1 ? r([d, p[u + 1]], [c[0], c[1]]) : !1);
882
- if (f !== -1 && f > -1) {
883
- const d = [], u = p.slice(0, f + 1);
884
- if (S.Equals(p[f], c[0]) || u.push(c[0].clone().setz(p[f].z)), u.length > 1 && d.push(u), f + c.length - 1 < p.length - 1) {
885
- const y = f + c.length - 1, k = p.slice(y), b = c[c.length - 1];
886
- S.Equals(p[y], b) || k.unshift(b.clone().setz(p[y].z)), k.length > 1 && d.push(k);
878
+ const p = a[h], u = p.findIndex((d, f) => f < p.length - 1 ? r([d, p[f + 1]], [c[0], c[1]]) : !1);
879
+ if (u !== -1 && u > -1) {
880
+ const d = [], f = p.slice(0, u + 1);
881
+ if (k.Equals(p[u], c[0]) || f.push(c[0].clone().setz(p[u].z)), f.length > 1 && d.push(f), u + c.length - 1 < p.length - 1) {
882
+ const w = u + c.length - 1, S = p.slice(w), b = c[c.length - 1];
883
+ k.Equals(p[w], b) || S.unshift(b.clone().setz(p[w].z)), S.length > 1 && d.push(S);
887
884
  }
888
885
  return l.splice(h, 1, ...d), l;
889
886
  }
@@ -891,8 +888,8 @@ const at = class at extends W {
891
888
  return l;
892
889
  }
893
890
  function r(a, c) {
894
- const l = S.Sub(a[1], a[0]), h = S.Sub(c[1], c[0]), p = S.Sub(c[0], a[0]);
895
- return Math.abs(S.Cpr(l, h)) < 0.1 && Math.abs(S.Cpr(l, p)) < 0.1;
891
+ const l = k.Sub(a[1], a[0]), h = k.Sub(c[1], c[0]), p = k.Sub(c[0], a[0]);
892
+ return Math.abs(k.Cpr(l, h)) < 0.1 && Math.abs(k.Cpr(l, p)) < 0.1;
896
893
  }
897
894
  }
898
895
  isSamePoint(e, t) {
@@ -904,7 +901,7 @@ const at = class at extends W {
904
901
  const s = e[o].filter((a, c, l) => !(c > 0 && this.isSamePoint(a, l[c - 1]))), i = [];
905
902
  let r = 0;
906
903
  for (; r < s.length; ) {
907
- const a = s[r], c = new S(a[0], a[1]);
904
+ const a = s[r], c = new k(a[0], a[1]);
908
905
  i.push(c), r++;
909
906
  }
910
907
  t.push(i);
@@ -919,23 +916,23 @@ const at = class at extends W {
919
916
  let r;
920
917
  for (const [a, c] of t.entries())
921
918
  if (c.rect && this.eraserRect && this.eraserPolyline && ht(this.eraserRect, c.rect)) {
922
- const { op: l, toolsType: h } = c, p = this.isLineEraser(h, i), f = [], d = [];
923
- for (let y = 0; y < l.length; y += 3) {
924
- const k = new S(l[y] * this.worldScaling[0] + this.worldPosition[0], l[y + 1] * this.worldScaling[1] + this.worldPosition[1], l[y + 2]);
925
- d.push(k), f.push(new O(k.x, k.y));
919
+ const { op: l, toolsType: h } = c, p = this.isLineEraser(h, i), u = [], d = [];
920
+ for (let w = 0; w < l.length; w += 3) {
921
+ const S = new k(l[w] * this.worldScaling[0] + this.worldPosition[0], l[w + 1] * this.worldScaling[1] + this.worldPosition[1], l[w + 2]);
922
+ d.push(S), u.push(new O(S.x, S.y));
926
923
  }
927
- const u = f.length && z(f) || c.rect;
928
- if (ht(u, this.eraserRect)) {
924
+ const f = u.length && z(u) || c.rect;
925
+ if (ht(f, this.eraserRect)) {
929
926
  if (d.length > 1) {
930
- const y = Kt.polyline(d.map((k) => k.XY), this.eraserPolyline);
931
- if (y.length && (o.add(c.name), !p)) {
932
- const k = this.translateIntersect(y), b = this.cutPolyline(k, d);
933
- for (let v = 0; v < b.length; v++) {
934
- const g = `${a}_s_${v}`, L = [];
935
- b[v].forEach((N) => {
936
- L.push((N.x - this.worldPosition[0]) / this.worldScaling[0], (N.y - this.worldPosition[1]) / this.worldScaling[1], N.z);
927
+ const w = Kt.polyline(d.map((S) => S.XY), this.eraserPolyline);
928
+ if (w.length && (o.add(c.name), !p)) {
929
+ const S = this.translateIntersect(w), b = this.cutPolyline(S, d);
930
+ for (let I = 0; I < b.length; I++) {
931
+ const g = `${a}_s_${I}`, L = [];
932
+ b[I].forEach((v) => {
933
+ L.push((v.x - this.worldPosition[0]) / this.worldScaling[0], (v.y - this.worldPosition[1]) / this.worldScaling[1], v.z);
937
934
  }), c.opt && c.toolsType && this.vNodes && (this.vNodes.setInfo(g, {
938
- rect: u,
935
+ rect: f,
939
936
  op: L,
940
937
  opt: c.opt,
941
938
  canRotate: c.canRotate,
@@ -951,24 +948,24 @@ const at = class at extends W {
951
948
  }
952
949
  } else
953
950
  o.add(c.name);
954
- r = B(r, u);
951
+ r = B(r, f);
955
952
  }
956
953
  }
957
954
  return o.forEach((a) => {
958
955
  var c;
959
956
  return (c = this.vNodes) == null ? void 0 : c.delete(a);
960
- }), r && (r.x -= W.SafeBorderPadding, r.y -= W.SafeBorderPadding, r.w += W.SafeBorderPadding * 2, r.h += W.SafeBorderPadding * 2), r;
957
+ }), r && (r.x -= N.SafeBorderPadding, r.y -= N.SafeBorderPadding, r.w += N.SafeBorderPadding * 2, r.h += N.SafeBorderPadding * 2), r;
961
958
  }
962
959
  consume(e) {
963
960
  const { op: t } = e.data;
964
961
  if (!t || t.length === 0)
965
962
  return {
966
- type: w.None
963
+ type: y.None
967
964
  };
968
965
  const o = this.tmpPoints.length;
969
966
  if (o > 1 && this.isNear([t[0], t[1]], [this.tmpPoints[o - 2], this.tmpPoints[o - 1]]))
970
967
  return {
971
- type: w.None
968
+ type: y.None
972
969
  };
973
970
  o === 4 && (this.tmpPoints.shift(), this.tmpPoints.shift()), this.tmpPoints.push(t[0], t[1]);
974
971
  const s = this.computRectCenterPoints();
@@ -976,7 +973,7 @@ const at = class at extends W {
976
973
  const r = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Map();
977
974
  if (!this.vNodes)
978
975
  return {
979
- type: w.None
976
+ type: y.None
980
977
  };
981
978
  this.vNodes.setTarget();
982
979
  const c = this.getUnLockNodeMap(this.vNodes.getLastTarget());
@@ -989,7 +986,7 @@ const at = class at extends W {
989
986
  for (const l of a.keys())
990
987
  r.has(l) && a.delete(l);
991
988
  return {
992
- type: w.RemoveNode,
989
+ type: y.RemoveNode,
993
990
  dataType: C.Local,
994
991
  rect: i,
995
992
  removeIds: [...r],
@@ -997,7 +994,7 @@ const at = class at extends W {
997
994
  };
998
995
  }
999
996
  return {
1000
- type: w.None
997
+ type: y.None
1001
998
  };
1002
999
  }
1003
1000
  consumeAll(e) {
@@ -1026,8 +1023,8 @@ m(at, "eraserSizes", Object.freeze([
1026
1023
  Object.freeze({ width: 26, height: 34 }),
1027
1024
  Object.freeze({ width: 34, height: 50 })
1028
1025
  ]));
1029
- let mt = at;
1030
- const Q = class Q extends W {
1026
+ let ft = at;
1027
+ const Q = class Q extends N {
1031
1028
  constructor(e) {
1032
1029
  super(e);
1033
1030
  m(this, "toolsType", P.Selector);
@@ -1042,7 +1039,7 @@ const Q = class Q extends W {
1042
1039
  m(this, "canRotate", !1);
1043
1040
  m(this, "canTextEdit", !1);
1044
1041
  m(this, "canLock", !1);
1045
- m(this, "scaleType", U.all);
1042
+ m(this, "scaleType", X.all);
1046
1043
  m(this, "toolsTypes");
1047
1044
  m(this, "shapeOpt");
1048
1045
  m(this, "textOpt");
@@ -1081,7 +1078,7 @@ const Q = class Q extends W {
1081
1078
  zIndex: 1e3
1082
1079
  }), c = [];
1083
1080
  if (r) {
1084
- const l = new St({
1081
+ const l = new kt({
1085
1082
  normalize: !0,
1086
1083
  pos: [t.w / 2, t.h / 2],
1087
1084
  lineWidth: 1,
@@ -1096,7 +1093,7 @@ const Q = class Q extends W {
1096
1093
  const p = [
1097
1094
  l.rect.x + l.rect.w / 2 - t.x,
1098
1095
  l.rect.y + l.rect.h / 2 - t.y
1099
- ], f = new St({
1096
+ ], u = new kt({
1100
1097
  normalize: !0,
1101
1098
  pos: p,
1102
1099
  lineWidth: 1,
@@ -1106,7 +1103,7 @@ const Q = class Q extends W {
1106
1103
  id: `selector-${h}`,
1107
1104
  name: `selector-${h}`
1108
1105
  });
1109
- c.push(f);
1106
+ c.push(u);
1110
1107
  }), c && a.append(...c), (i == null ? void 0 : i.parent).appendChild(a);
1111
1108
  }
1112
1109
  draw(e, t, o, s = !1) {
@@ -1121,18 +1118,18 @@ const Q = class Q extends W {
1121
1118
  });
1122
1119
  }
1123
1120
  getSelecteorInfo(e) {
1124
- this.scaleType = U.all, this.canRotate = !1, this.textOpt = void 0, this.strokeColor = void 0, this.fillColor = void 0, this.canTextEdit = !1, this.canLock = !1, this.isLocked = !1, this.toolsTypes = void 0, this.shapeOpt = void 0;
1121
+ this.scaleType = X.all, this.canRotate = !1, this.textOpt = void 0, this.strokeColor = void 0, this.fillColor = void 0, this.canTextEdit = !1, this.canLock = !1, this.isLocked = !1, this.toolsTypes = void 0, this.shapeOpt = void 0;
1125
1122
  const t = /* @__PURE__ */ new Set();
1126
1123
  let o;
1127
1124
  for (const s of e.values()) {
1128
1125
  const { opt: i, canRotate: r, scaleType: a, toolsType: c } = s;
1129
- this.selectorColor = this.workOptions.strokeColor, i.strokeColor && (this.strokeColor = i.strokeColor), i.fillColor && (this.fillColor = i.fillColor), i.textOpt && (this.textOpt = i.textOpt), c === P.SpeechBalloon && (t.add(c), this.shapeOpt || (this.shapeOpt = {}), this.shapeOpt.placement = i.placement), c === P.Polygon && (t.add(c), this.shapeOpt || (this.shapeOpt = {}), this.shapeOpt.vertices = i.vertices), c === P.Star && (t.add(c), this.shapeOpt || (this.shapeOpt = {}), this.shapeOpt.vertices = i.vertices, this.shapeOpt.innerRatio = i.innerRatio, this.shapeOpt.innerVerticeStep = i.innerVerticeStep), c === P.Text && (this.textOpt = i), e.size === 1 && (this.textOpt && (this.canTextEdit = !0), this.canRotate = r, this.scaleType = a), a === U.none && (this.scaleType = a), c === P.Image && (o = s);
1126
+ this.selectorColor = this.workOptions.strokeColor, i.strokeColor && (this.strokeColor = i.strokeColor), i.fillColor && (this.fillColor = i.fillColor), i.textOpt && (this.textOpt = i.textOpt), c === P.SpeechBalloon && (t.add(c), this.shapeOpt || (this.shapeOpt = {}), this.shapeOpt.placement = i.placement), c === P.Polygon && (t.add(c), this.shapeOpt || (this.shapeOpt = {}), this.shapeOpt.vertices = i.vertices), c === P.Star && (t.add(c), this.shapeOpt || (this.shapeOpt = {}), this.shapeOpt.vertices = i.vertices, this.shapeOpt.innerRatio = i.innerRatio, this.shapeOpt.innerVerticeStep = i.innerVerticeStep), c === P.Text && (this.textOpt = i), e.size === 1 && (this.textOpt && (this.canTextEdit = !0), this.canRotate = r, this.scaleType = a), a === X.none && (this.scaleType = a), c === P.Image && (o = s);
1130
1127
  }
1131
- t.size && (this.toolsTypes = [...t]), o && (e.size === 1 ? (this.canLock = !0, o.opt.locked && (this.isLocked = !0, this.scaleType = U.none, this.canRotate = !1, this.textOpt = void 0, this.fillColor = void 0, this.selectorColor = "rgb(177,177,177)", this.strokeColor = void 0, this.canTextEdit = !1)) : e.size > 1 && !o.opt.locked && (this.canLock = !1, this.canRotate = !1));
1128
+ t.size && (this.toolsTypes = [...t]), o && (e.size === 1 ? (this.canLock = !0, o.opt.locked && (this.isLocked = !0, this.scaleType = X.none, this.canRotate = !1, this.textOpt = void 0, this.fillColor = void 0, this.selectorColor = "rgb(177,177,177)", this.strokeColor = void 0, this.canTextEdit = !1)) : e.size > 1 && !o.opt.locked && (this.canLock = !1, this.canRotate = !1));
1132
1129
  }
1133
1130
  getChildrenPoints() {
1134
1131
  var e, t;
1135
- if (this.scaleType === U.both && ((e = this.selectIds) == null ? void 0 : e.length) === 1) {
1132
+ if (this.scaleType === X.both && ((e = this.selectIds) == null ? void 0 : e.length) === 1) {
1136
1133
  const o = this.selectIds[0], s = (t = this.vNodes.get(o)) == null ? void 0 : t.op;
1137
1134
  if (s) {
1138
1135
  const i = [];
@@ -1145,18 +1142,18 @@ const Q = class Q extends W {
1145
1142
  consume(e) {
1146
1143
  const { op: t, workState: o } = e.data;
1147
1144
  let s = this.oldSelectRect;
1148
- if (o === D.Start && (s = this.unSelectedAllIds()), !(t != null && t.length) || !this.vNodes.curNodeMap.size)
1149
- return { type: w.None };
1145
+ if (o === A.Start && (s = this.unSelectedAllIds()), !(t != null && t.length) || !this.vNodes.curNodeMap.size)
1146
+ return { type: y.None };
1150
1147
  this.updateTempPoints(t);
1151
1148
  const i = this.computSelector();
1152
1149
  if (this.selectIds && ct(this.selectIds, i.selectIds))
1153
- return { type: w.None };
1150
+ return { type: y.None };
1154
1151
  this.selectIds = i.selectIds;
1155
1152
  const r = i.intersectRect;
1156
1153
  this.getSelecteorInfo(i.subNodeMap), this.draw(Q.selectorId, this.fullLayer, i), this.oldSelectRect = r;
1157
1154
  const a = this.getChildrenPoints();
1158
1155
  return {
1159
- type: w.Select,
1156
+ type: y.Select,
1160
1157
  dataType: C.Local,
1161
1158
  rect: B(r, s),
1162
1159
  selectIds: i.selectIds,
@@ -1183,7 +1180,7 @@ const Q = class Q extends W {
1183
1180
  if (!((t = this.selectIds) != null && t.length) && this.tmpPoints[0] && this.selectSingleTool(this.tmpPoints[0].XY, Q.selectorId, !1), (o = this.selectIds) != null && o.length && (e = this.selectedByIds(this.selectIds)), e) {
1184
1181
  const s = this.getChildrenPoints();
1185
1182
  return {
1186
- type: w.Select,
1183
+ type: y.Select,
1187
1184
  dataType: C.Local,
1188
1185
  rect: this.oldSelectRect,
1189
1186
  selectIds: this.selectIds,
@@ -1205,7 +1202,7 @@ const Q = class Q extends W {
1205
1202
  };
1206
1203
  }
1207
1204
  return {
1208
- type: w.None
1205
+ type: y.None
1209
1206
  };
1210
1207
  }
1211
1208
  consumeService() {
@@ -1223,7 +1220,7 @@ const Q = class Q extends W {
1223
1220
  const { nodeRange: a } = this.vNodes.getRectIntersectRange({ x: s, y: i, w: 0, h: 0 }, !1), c = [...a.values()].sort((l, h) => (h.opt.zIndex || 0) - (l.opt.zIndex || 0));
1224
1221
  for (const l of c) {
1225
1222
  const h = this.fullLayer.getElementsByName(l.name);
1226
- if (Et(h).find((f) => f.isPointCollision(s, i))) {
1223
+ if (Et(h).find((u) => u.isPointCollision(s, i))) {
1227
1224
  r = l;
1228
1225
  break;
1229
1226
  }
@@ -1283,12 +1280,12 @@ const Q = class Q extends W {
1283
1280
  if (!h)
1284
1281
  return;
1285
1282
  let p;
1286
- const f = /* @__PURE__ */ new Map(), { box: d, workState: u, angle: y, translate: k } = t;
1287
- let b = [0, 0], v = [1, 1], g = [0, 0], L, N;
1288
- if (d || k || V(y)) {
1289
- if (u === D.Start)
1283
+ const u = /* @__PURE__ */ new Map(), { box: d, workState: f, angle: w, translate: S } = t;
1284
+ let b = [0, 0], I = [1, 1], g = [0, 0], L, v;
1285
+ if (d || S || q(w)) {
1286
+ if (f === A.Start)
1290
1287
  return s.setTarget(), {
1291
- type: w.Select,
1288
+ type: y.Select,
1292
1289
  dataType: C.Local,
1293
1290
  selectRect: this.oldSelectRect,
1294
1291
  rect: this.oldSelectRect
@@ -1296,121 +1293,122 @@ const Q = class Q extends W {
1296
1293
  if (L = s.getLastTarget(), L && d) {
1297
1294
  let T;
1298
1295
  o == null || o.forEach((x) => {
1299
- const M = L == null ? void 0 : L.get(x);
1300
- T = B(T, M == null ? void 0 : M.rect);
1301
- }), T && (v = [d.w / T.w, d.h / T.h], b = [d.x + d.w / 2 - (T.x + T.w / 2), d.y + d.h / 2 - (T.y + T.h / 2)], g = [T.x + T.w / 2, T.y + T.h / 2]), N = T;
1296
+ const R = L == null ? void 0 : L.get(x);
1297
+ T = B(T, R == null ? void 0 : R.rect);
1298
+ }), T && (I = [d.w / T.w, d.h / T.h], b = [d.x + d.w / 2 - (T.x + T.w / 2), d.y + d.h / 2 - (T.y + T.h / 2)], g = [T.x + T.w / 2, T.y + T.h / 2]), v = T;
1302
1299
  }
1303
1300
  }
1304
1301
  if (o)
1305
1302
  for (const T of o) {
1306
1303
  const x = s.get(T);
1307
1304
  if (x) {
1308
- const { toolsType: M } = x;
1309
- let $ = (h == null ? void 0 : h.getElementsByName(T))[0];
1310
- if ($) {
1305
+ const { toolsType: R } = x;
1306
+ let U = (h == null ? void 0 : h.getElementsByName(T))[0];
1307
+ if (U) {
1311
1308
  const F = { ...t };
1312
- let q;
1313
- if (M) {
1314
- if (L && (q = L.get(T), q && d)) {
1315
- F.boxScale = v;
1316
- const G = [q.rect.x + q.rect.w / 2, q.rect.y + q.rect.h / 2], et = [G[0] - g[0], G[1] - g[1]];
1317
- F.boxTranslate = [et[0] * (v[0] - 1) + b[0] + (a && a[0] || 0), et[1] * (v[1] - 1) + b[1] + (a && a[1] || 0)];
1309
+ let H;
1310
+ if (R) {
1311
+ if (H = L == null ? void 0 : L.get(T), H && d) {
1312
+ F.boxScale = I;
1313
+ const j = [H.rect.x + H.rect.w / 2, H.rect.y + H.rect.h / 2], et = [j[0] - g[0], j[1] - g[1]];
1314
+ F.boxTranslate = [et[0] * (I[0] - 1) + b[0] + (a && a[0] || 0), et[1] * (I[1] - 1) + b[1] + (a && a[1] || 0)];
1318
1315
  }
1319
- const wt = At(M);
1320
- if (wt == null || wt.updateNodeOpt({
1321
- node: $,
1316
+ const St = At(R);
1317
+ if (St == null || St.updateNodeOpt({
1318
+ node: U,
1322
1319
  opt: F,
1323
1320
  vNodes: s,
1324
1321
  willSerializeData: i,
1325
- targetNode: q
1326
- }), x && r && (i && (F.angle || F.translate) || F.box && F.workState !== D.Start || F.pointMap && F.pointMap.has(T) || M === P.Text && (F.fontSize || F.translate || F.textInfos && F.textInfos.get(T)) || M === P.Image && (F.angle || F.translate || F.boxScale) || M === F.toolsType && F.willRefresh)) {
1327
- const G = r.createWorkShapeNode({
1328
- toolsType: M,
1322
+ targetNode: H
1323
+ }), x && r && // itemOpt.angle || itemOpt.translate || itemOpt.boxScale ||
1324
+ (i && (F.angle || F.translate) || F.box && F.workState !== A.Start || F.pointMap && F.pointMap.has(T) || R === P.Text && (F.fontSize || F.translate || F.textInfos && F.textInfos.get(T)) || R === P.Image && (F.angle || F.translate || F.boxScale) || R === F.toolsType && F.willRefresh)) {
1325
+ const j = r.createWorkShapeNode({
1326
+ toolsType: R,
1329
1327
  toolsOpt: x.opt
1330
1328
  });
1331
- G == null || G.setWorkId(T);
1329
+ j == null || j.setWorkId(T);
1332
1330
  let et;
1333
- M === P.Image && c ? et = await G.consumeServiceAsync({
1331
+ R === P.Image && c ? et = await j.consumeServiceAsync({
1334
1332
  isFullWork: !0,
1335
1333
  replaceId: T,
1336
1334
  scene: c,
1337
1335
  isMainThread: l
1338
- }) : M === P.Text ? et = await G.consumeServiceAsync({
1336
+ }) : R === P.Text ? et = await j.consumeServiceAsync({
1339
1337
  isFullWork: !0,
1340
1338
  replaceId: T
1341
- }) : et = G == null ? void 0 : G.consumeService({
1339
+ }) : et = j == null ? void 0 : j.consumeService({
1342
1340
  op: x.op,
1343
1341
  isFullWork: !0,
1344
1342
  replaceId: T
1345
- }), et && (x.rect = et), $ = (h == null ? void 0 : h.getElementsByName(T))[0];
1343
+ }), et && (x.rect = et), U = (h == null ? void 0 : h.getElementsByName(T))[0];
1346
1344
  }
1347
- x && (f.set(T, x), p = B(p, x.rect));
1345
+ x && (u.set(T, x), p = B(p, x.rect));
1348
1346
  }
1349
1347
  }
1350
1348
  }
1351
1349
  }
1352
- L && u === D.Done && s.deleteLastTarget();
1353
- const I = p;
1354
- if (N && t.dir && I && !a) {
1350
+ L && f === A.Done && (s.deleteLastTarget(), L = void 0);
1351
+ const W = p;
1352
+ if (v && t.dir && W && !a) {
1355
1353
  const T = [0, 0];
1356
1354
  switch (t.dir) {
1357
1355
  case "top": {
1358
- const x = [N.x, N.y + N.h];
1359
- t.reverseY ? T[1] = x[1] - I.y : T[1] = x[1] - (I.y + I.h);
1356
+ const x = [v.x, v.y + v.h];
1357
+ t.reverseY ? T[1] = x[1] - W.y : T[1] = x[1] - (W.y + W.h);
1360
1358
  break;
1361
1359
  }
1362
1360
  case "topLeft": {
1363
- const x = [N.x + N.w, N.y + N.h];
1364
- t.reverseY ? T[1] = x[1] - I.y : T[1] = x[1] - (I.y + I.h), t.reverseX ? T[0] = x[0] - I.x : T[0] = x[0] - (I.x + I.w);
1361
+ const x = [v.x + v.w, v.y + v.h];
1362
+ t.reverseY ? T[1] = x[1] - W.y : T[1] = x[1] - (W.y + W.h), t.reverseX ? T[0] = x[0] - W.x : T[0] = x[0] - (W.x + W.w);
1365
1363
  break;
1366
1364
  }
1367
1365
  case "topRight": {
1368
- const x = [N.x, N.y + N.h];
1369
- t.reverseY ? T[1] = x[1] - I.y : T[1] = x[1] - (I.y + I.h), t.reverseX ? T[0] = x[0] - (I.x + I.w) : T[0] = x[0] - I.x;
1366
+ const x = [v.x, v.y + v.h];
1367
+ t.reverseY ? T[1] = x[1] - W.y : T[1] = x[1] - (W.y + W.h), t.reverseX ? T[0] = x[0] - (W.x + W.w) : T[0] = x[0] - W.x;
1370
1368
  break;
1371
1369
  }
1372
1370
  case "bottom": {
1373
- const x = [N.x, N.y];
1374
- t.reverseY ? T[1] = x[1] - (I.y + I.h) : T[1] = x[1] - I.y;
1371
+ const x = [v.x, v.y];
1372
+ t.reverseY ? T[1] = x[1] - (W.y + W.h) : T[1] = x[1] - W.y;
1375
1373
  break;
1376
1374
  }
1377
1375
  case "bottomLeft": {
1378
- const x = [N.x + N.w, N.y];
1379
- t.reverseY ? T[1] = x[1] - (I.y + I.h) : T[1] = x[1] - I.y, t.reverseX ? T[0] = x[0] - I.x : T[0] = x[0] - (I.x + I.w);
1376
+ const x = [v.x + v.w, v.y];
1377
+ t.reverseY ? T[1] = x[1] - (W.y + W.h) : T[1] = x[1] - W.y, t.reverseX ? T[0] = x[0] - W.x : T[0] = x[0] - (W.x + W.w);
1380
1378
  break;
1381
1379
  }
1382
1380
  case "bottomRight": {
1383
- const x = [N.x, N.y];
1384
- t.reverseY ? T[1] = x[1] - (I.y + I.h) : T[1] = x[1] - I.y, t.reverseX ? T[0] = x[0] - (I.x + I.w) : T[0] = x[0] - I.x;
1381
+ const x = [v.x, v.y];
1382
+ t.reverseY ? T[1] = x[1] - (W.y + W.h) : T[1] = x[1] - W.y, t.reverseX ? T[0] = x[0] - (W.x + W.w) : T[0] = x[0] - W.x;
1385
1383
  break;
1386
1384
  }
1387
1385
  case "right": {
1388
- const x = [N.x, N.y];
1389
- t.reverseX ? T[0] = x[0] - (I.x + I.w) : T[0] = x[0] - I.x;
1386
+ const x = [v.x, v.y];
1387
+ t.reverseX ? T[0] = x[0] - (W.x + W.w) : T[0] = x[0] - W.x;
1390
1388
  break;
1391
1389
  }
1392
1390
  }
1393
1391
  if (T[0] || T[1])
1394
- return I.x = I.x + T[0], I.y = I.y + T[1], await this.updateSelector({ ...e, offset: T });
1392
+ return W.x = W.x + T[0], W.y = W.y + T[1], await this.updateSelector({ ...e, offset: T });
1395
1393
  }
1396
- this.getSelecteorInfo(f), this.draw(Q.selectorId, h, {
1394
+ this.getSelecteorInfo(u), this.draw(Q.selectorId, h, {
1397
1395
  selectIds: o || [],
1398
- subNodeMap: f,
1399
- intersectRect: I
1396
+ subNodeMap: u,
1397
+ intersectRect: W
1400
1398
  });
1401
- const A = B(this.oldSelectRect, I);
1402
- return this.oldSelectRect = I, {
1403
- type: w.Select,
1399
+ const D = B(this.oldSelectRect, W);
1400
+ return this.oldSelectRect = W, {
1401
+ type: y.Select,
1404
1402
  dataType: C.Local,
1405
- selectRect: I,
1403
+ selectRect: W,
1406
1404
  renderRect: p,
1407
- rect: B(A, I)
1405
+ rect: B(D, W)
1408
1406
  };
1409
1407
  }
1410
1408
  blurSelector() {
1411
1409
  const e = this.unSelectedAllIds();
1412
1410
  return {
1413
- type: w.Select,
1411
+ type: y.Select,
1414
1412
  dataType: C.Local,
1415
1413
  rect: e,
1416
1414
  selectIds: [],
@@ -1468,7 +1466,7 @@ const Q = class Q extends W {
1468
1466
  const o = (i = this.workId) == null ? void 0 : i.toString(), s = [e[0] * this.fullLayer.worldScaling[0] + this.fullLayer.worldPosition[0], e[1] * this.fullLayer.worldScaling[0] + this.fullLayer.worldPosition[1]];
1469
1467
  if (this.selectSingleTool(s, o, !0), this.oldSelectRect && !ct(t, this.oldSelectRect))
1470
1468
  return {
1471
- type: w.CursorHover,
1469
+ type: y.CursorHover,
1472
1470
  dataType: C.Local,
1473
1471
  rect: B(t, this.oldSelectRect),
1474
1472
  selectorColor: this.selectorColor,
@@ -1476,7 +1474,7 @@ const Q = class Q extends W {
1476
1474
  };
1477
1475
  if ((r = this.selectIds) != null && r.length || (this.oldSelectRect = void 0), t && !this.oldSelectRect)
1478
1476
  return this.cursorBlur(), {
1479
- type: w.CursorHover,
1477
+ type: y.CursorHover,
1480
1478
  dataType: C.Local,
1481
1479
  rect: t,
1482
1480
  selectorColor: this.selectorColor,
@@ -1492,13 +1490,13 @@ const Q = class Q extends W {
1492
1490
  });
1493
1491
  }
1494
1492
  };
1495
- m(Q, "selectorId", Y), m(Q, "selectorBorderId", "selector-border");
1496
- let H = Q;
1497
- class xt extends W {
1493
+ m(Q, "selectorId", $), m(Q, "selectorBorderId", "selector-border");
1494
+ let G = Q;
1495
+ class xt extends N {
1498
1496
  constructor(e) {
1499
1497
  super(e);
1500
1498
  m(this, "canRotate", !1);
1501
- m(this, "scaleType", U.both);
1499
+ m(this, "scaleType", X.both);
1502
1500
  m(this, "toolsType", P.Arrow);
1503
1501
  m(this, "tmpPoints", []);
1504
1502
  m(this, "workOptions");
@@ -1511,33 +1509,33 @@ class xt extends W {
1511
1509
  var d;
1512
1510
  const { data: t, isFullWork: o, isSubWorker: s, isMainThread: i } = e, r = (d = t == null ? void 0 : t.workId) == null ? void 0 : d.toString();
1513
1511
  if (!r)
1514
- return { type: w.None };
1512
+ return { type: y.None };
1515
1513
  const { op: a, workState: c } = t, l = a == null ? void 0 : a.length;
1516
1514
  if (!l || l < 2)
1517
- return { type: w.None };
1515
+ return { type: y.None };
1518
1516
  let h;
1519
- if (c === D.Start ? (this.tmpPoints = [new O(a[0], a[1])], h = !1) : h = this.updateTempPoints(a), !h)
1520
- return { type: w.None };
1517
+ if (c === A.Start ? (this.tmpPoints = [new O(a[0], a[1])], h = !1) : h = this.updateTempPoints(a), !h)
1518
+ return { type: y.None };
1521
1519
  let p;
1522
1520
  if (s || i) {
1523
- const u = o ? this.fullLayer : this.drawLayer || this.fullLayer;
1524
- p = this.draw({ workId: r, layer: u });
1521
+ const f = o ? this.fullLayer : this.drawLayer || this.fullLayer;
1522
+ p = this.draw({ workId: r, layer: f });
1525
1523
  }
1526
1524
  if (!s) {
1527
- const u = Date.now();
1528
- return u - this.syncTimestamp > this.syncUnitTime ? (this.syncTimestamp = u, {
1529
- type: w.DrawWork,
1525
+ const f = Date.now();
1526
+ return f - this.syncTimestamp > this.syncUnitTime ? (this.syncTimestamp = f, {
1527
+ type: y.DrawWork,
1530
1528
  dataType: C.Local,
1531
1529
  workId: r,
1532
- op: this.tmpPoints.map((y) => [...y.XY, 0]).flat(1),
1530
+ op: this.tmpPoints.map((w) => [...w.XY, 0]).flat(1),
1533
1531
  isSync: !0,
1534
1532
  index: 0
1535
- }) : { type: w.None };
1533
+ }) : { type: y.None };
1536
1534
  }
1537
- const f = B(p, this.oldRect);
1535
+ const u = B(p, this.oldRect);
1538
1536
  return this.oldRect = p, {
1539
- rect: f,
1540
- type: w.DrawWork,
1537
+ rect: u,
1538
+ type: y.DrawWork,
1541
1539
  dataType: C.Local,
1542
1540
  workId: r
1543
1541
  };
@@ -1546,10 +1544,10 @@ class xt extends W {
1546
1544
  var c, l;
1547
1545
  const { data: t } = e, o = (c = t == null ? void 0 : t.workId) == null ? void 0 : c.toString();
1548
1546
  if (!o)
1549
- return { type: w.None };
1547
+ return { type: y.None };
1550
1548
  if (this.tmpPoints.length < 2)
1551
1549
  return {
1552
- type: w.RemoveNode,
1550
+ type: y.RemoveNode,
1553
1551
  removeIds: [o]
1554
1552
  };
1555
1553
  const s = this.fullLayer, i = this.draw({ workId: o, layer: s });
@@ -1562,10 +1560,10 @@ class xt extends W {
1562
1560
  toolsType: this.toolsType,
1563
1561
  canRotate: this.canRotate,
1564
1562
  scaleType: this.scaleType,
1565
- centerPos: W.getCenterPos(i, s)
1563
+ centerPos: N.getCenterPos(i, s)
1566
1564
  }), {
1567
1565
  rect: i,
1568
- type: w.FullWork,
1566
+ type: y.FullWork,
1569
1567
  dataType: C.Local,
1570
1568
  workId: o,
1571
1569
  ops: a,
@@ -1574,7 +1572,7 @@ class xt extends W {
1574
1572
  };
1575
1573
  }
1576
1574
  draw(e) {
1577
- const { workId: t, layer: o } = e, { strokeColor: s, thickness: i, zIndex: r, scale: a, rotate: c, translate: l } = this.workOptions, h = o.worldPosition, p = o.worldScaling, { points: f, rect: d } = this.computDrawPoints(i), y = {
1575
+ const { workId: t, layer: o } = e, { strokeColor: s, thickness: i, zIndex: r, scale: a, rotate: c, translate: l } = this.workOptions, h = o.worldPosition, p = o.worldScaling, { points: u, rect: d } = this.computDrawPoints(i), w = {
1578
1576
  pos: [
1579
1577
  d.x + d.w / 2,
1580
1578
  d.y + d.h / 2
@@ -1582,53 +1580,53 @@ class xt extends W {
1582
1580
  name: t,
1583
1581
  id: t,
1584
1582
  close: !0,
1585
- points: f,
1583
+ points: u,
1586
1584
  fillColor: s,
1587
1585
  strokeColor: s,
1588
1586
  lineWidth: 0,
1589
1587
  normalize: !0,
1590
1588
  zIndex: r
1591
1589
  };
1592
- a && (y.scale = a), c && (y.rotate = c), l && (y.translate = l);
1593
- const k = new st(y);
1594
- if (this.replace(o, t, k), a || c || l) {
1595
- const b = k.getBoundingClientRect();
1590
+ a && (w.scale = a), c && (w.rotate = c), l && (w.translate = l);
1591
+ const S = new st(w);
1592
+ if (this.replace(o, t, S), a || c || l) {
1593
+ const b = S.getBoundingClientRect();
1596
1594
  return {
1597
- x: Math.floor(b.x - W.SafeBorderPadding),
1598
- y: Math.floor(b.y - W.SafeBorderPadding),
1599
- w: Math.floor(b.width + W.SafeBorderPadding * 2),
1600
- h: Math.floor(b.height + W.SafeBorderPadding * 2)
1595
+ x: Math.floor(b.x - N.SafeBorderPadding),
1596
+ y: Math.floor(b.y - N.SafeBorderPadding),
1597
+ w: Math.floor(b.width + N.SafeBorderPadding * 2),
1598
+ h: Math.floor(b.height + N.SafeBorderPadding * 2)
1601
1599
  };
1602
1600
  }
1603
1601
  return {
1604
- x: Math.floor(d.x * p[0] + h[0] - W.SafeBorderPadding),
1605
- y: Math.floor(d.y * p[1] + h[1] - W.SafeBorderPadding),
1606
- w: Math.floor(d.w * p[0] + 2 * W.SafeBorderPadding),
1607
- h: Math.floor(d.h * p[1] + 2 * W.SafeBorderPadding)
1602
+ x: Math.floor(d.x * p[0] + h[0] - N.SafeBorderPadding),
1603
+ y: Math.floor(d.y * p[1] + h[1] - N.SafeBorderPadding),
1604
+ w: Math.floor(d.w * p[0] + 2 * N.SafeBorderPadding),
1605
+ h: Math.floor(d.h * p[1] + 2 * N.SafeBorderPadding)
1608
1606
  };
1609
1607
  }
1610
1608
  computDrawPoints(e) {
1611
1609
  return this.tmpPoints[1].distance(this.tmpPoints[0]) > this.arrowTipWidth ? this.computFullArrowPoints(e) : this.computTrianglePoints();
1612
1610
  }
1613
1611
  computFullArrowPoints(e) {
1614
- const t = S.Sub(this.tmpPoints[1], this.tmpPoints[0]).uni(), o = S.Per(t).mul(e / 2), s = O.Sub(this.tmpPoints[0], o), i = O.Add(this.tmpPoints[0], o), r = S.Mul(t, this.arrowTipWidth), a = S.Sub(this.tmpPoints[1], r), c = O.Sub(a, o), l = O.Add(a, o), h = S.Per(t).mul(e * 1.5), p = O.Sub(a, h), f = O.Add(a, h), d = [
1612
+ const t = k.Sub(this.tmpPoints[1], this.tmpPoints[0]).uni(), o = k.Per(t).mul(e / 2), s = O.Sub(this.tmpPoints[0], o), i = O.Add(this.tmpPoints[0], o), r = k.Mul(t, this.arrowTipWidth), a = k.Sub(this.tmpPoints[1], r), c = O.Sub(a, o), l = O.Add(a, o), h = k.Per(t).mul(e * 1.5), p = O.Sub(a, h), u = O.Add(a, h), d = [
1615
1613
  s,
1616
1614
  c,
1617
1615
  p,
1618
1616
  this.tmpPoints[1],
1619
- f,
1617
+ u,
1620
1618
  l,
1621
1619
  i
1622
1620
  ];
1623
1621
  return {
1624
- points: d.map((u) => O.Sub(u, this.tmpPoints[0]).XY).flat(1),
1622
+ points: d.map((f) => O.Sub(f, this.tmpPoints[0]).XY).flat(1),
1625
1623
  rect: z(d),
1626
1624
  isTriangle: !1,
1627
1625
  pos: this.tmpPoints[0].XY
1628
1626
  };
1629
1627
  }
1630
1628
  computTrianglePoints() {
1631
- const e = S.Sub(this.tmpPoints[1], this.tmpPoints[0]).uni(), t = this.tmpPoints[1].distance(this.tmpPoints[0]), o = S.Per(e).mul(Math.floor(t * 3 / 8)), s = O.Sub(this.tmpPoints[0], o), i = O.Add(this.tmpPoints[0], o), r = [s, this.tmpPoints[1], i];
1629
+ const e = k.Sub(this.tmpPoints[1], this.tmpPoints[0]).uni(), t = this.tmpPoints[1].distance(this.tmpPoints[0]), o = k.Per(e).mul(Math.floor(t * 3 / 8)), s = O.Sub(this.tmpPoints[0], o), i = O.Add(this.tmpPoints[0], o), r = [s, this.tmpPoints[1], i];
1632
1630
  return {
1633
1631
  points: r.map((a) => O.Sub(a, this.tmpPoints[0]).XY).flat(1),
1634
1632
  rect: z(r),
@@ -1664,7 +1662,7 @@ class xt extends W {
1664
1662
  toolsType: this.toolsType,
1665
1663
  canRotate: this.canRotate,
1666
1664
  scaleType: this.scaleType,
1667
- centerPos: W.getCenterPos(r, i)
1665
+ centerPos: N.getCenterPos(r, i)
1668
1666
  }), r;
1669
1667
  }
1670
1668
  clearTmpPoints() {
@@ -1673,14 +1671,14 @@ class xt extends W {
1673
1671
  static updateNodeOpt(e) {
1674
1672
  var a;
1675
1673
  const { node: t, opt: o, vNodes: s } = e, { strokeColor: i } = o, r = s.get(t.name);
1676
- return i && (t.setAttribute("strokeColor", i), t.setAttribute("fillColor", i), (a = r == null ? void 0 : r.opt) != null && a.strokeColor && (r.opt.strokeColor = i), r && s.setInfo(t.name, r)), W.updateNodeOpt(e);
1674
+ return i && (t.setAttribute("strokeColor", i), t.setAttribute("fillColor", i), (a = r == null ? void 0 : r.opt) != null && a.strokeColor && (r.opt.strokeColor = i), r && s.setInfo(t.name, r)), N.updateNodeOpt(e);
1677
1675
  }
1678
1676
  }
1679
- class bt extends W {
1677
+ class bt extends N {
1680
1678
  constructor(e) {
1681
1679
  super(e);
1682
1680
  m(this, "canRotate", !1);
1683
- m(this, "scaleType", U.all);
1681
+ m(this, "scaleType", X.all);
1684
1682
  m(this, "toolsType", P.Ellipse);
1685
1683
  m(this, "tmpPoints", []);
1686
1684
  m(this, "workOptions");
@@ -1692,33 +1690,33 @@ class bt extends W {
1692
1690
  var d;
1693
1691
  const { data: t, isFullWork: o, isSubWorker: s, isMainThread: i } = e, r = (d = t == null ? void 0 : t.workId) == null ? void 0 : d.toString();
1694
1692
  if (!r)
1695
- return { type: w.None };
1693
+ return { type: y.None };
1696
1694
  const { op: a, workState: c } = t, l = a == null ? void 0 : a.length;
1697
1695
  if (!l || l < 2)
1698
- return { type: w.None };
1696
+ return { type: y.None };
1699
1697
  let h;
1700
- if (c === D.Start ? (this.tmpPoints = [new O(a[0], a[1])], h = !1) : h = this.updateTempPoints(a), !h)
1701
- return { type: w.None };
1698
+ if (c === A.Start ? (this.tmpPoints = [new O(a[0], a[1])], h = !1) : h = this.updateTempPoints(a), !h)
1699
+ return { type: y.None };
1702
1700
  let p;
1703
1701
  if (s || i) {
1704
- const u = o ? this.fullLayer : this.drawLayer || this.fullLayer;
1705
- p = this.draw({ workId: r, layer: u, isDrawing: !0 });
1702
+ const f = o ? this.fullLayer : this.drawLayer || this.fullLayer;
1703
+ p = this.draw({ workId: r, layer: f, isDrawing: !0 });
1706
1704
  }
1707
1705
  if (!s) {
1708
- const u = Date.now();
1709
- return u - this.syncTimestamp > this.syncUnitTime ? (this.syncTimestamp = u, {
1710
- type: w.DrawWork,
1706
+ const f = Date.now();
1707
+ return f - this.syncTimestamp > this.syncUnitTime ? (this.syncTimestamp = f, {
1708
+ type: y.DrawWork,
1711
1709
  dataType: C.Local,
1712
1710
  workId: r,
1713
- op: this.tmpPoints.map((y) => [...y.XY, 0]).flat(1),
1711
+ op: this.tmpPoints.map((w) => [...w.XY, 0]).flat(1),
1714
1712
  isSync: !0,
1715
1713
  index: 0
1716
- }) : { type: w.None };
1714
+ }) : { type: y.None };
1717
1715
  }
1718
- const f = B(p, this.oldRect);
1716
+ const u = B(p, this.oldRect);
1719
1717
  return this.oldRect = p, {
1720
- rect: f,
1721
- type: w.DrawWork,
1718
+ rect: u,
1719
+ type: y.DrawWork,
1722
1720
  dataType: C.Local,
1723
1721
  workId: r
1724
1722
  };
@@ -1727,10 +1725,10 @@ class bt extends W {
1727
1725
  var c, l;
1728
1726
  const { data: t } = e, o = (c = t == null ? void 0 : t.workId) == null ? void 0 : c.toString();
1729
1727
  if (!o)
1730
- return { type: w.None };
1728
+ return { type: y.None };
1731
1729
  if (this.tmpPoints.length < 2)
1732
1730
  return {
1733
- type: w.RemoveNode,
1731
+ type: y.RemoveNode,
1734
1732
  removeIds: [o]
1735
1733
  };
1736
1734
  const s = this.fullLayer, i = this.draw({ workId: o, layer: s, isDrawing: !1 });
@@ -1743,10 +1741,10 @@ class bt extends W {
1743
1741
  toolsType: this.toolsType,
1744
1742
  canRotate: this.canRotate,
1745
1743
  scaleType: this.scaleType,
1746
- centerPos: i && W.getCenterPos(i, s)
1744
+ centerPos: i && N.getCenterPos(i, s)
1747
1745
  }), {
1748
1746
  rect: i,
1749
- type: w.FullWork,
1747
+ type: y.FullWork,
1750
1748
  dataType: C.Local,
1751
1749
  workId: o,
1752
1750
  ops: a,
@@ -1755,8 +1753,8 @@ class bt extends W {
1755
1753
  };
1756
1754
  }
1757
1755
  draw(e) {
1758
- const { workId: t, layer: o, isDrawing: s } = e, { strokeColor: i, fillColor: r, thickness: a, zIndex: c, scale: l, rotate: h, translate: p } = this.workOptions, f = o.worldScaling, { radius: d, rect: u, pos: y } = this.computDrawPoints(a), k = {
1759
- pos: y,
1756
+ const { workId: t, layer: o, isDrawing: s } = e, { strokeColor: i, fillColor: r, thickness: a, zIndex: c, scale: l, rotate: h, translate: p } = this.workOptions, u = o.worldScaling, { radius: d, rect: f, pos: w } = this.computDrawPoints(a), S = {
1757
+ pos: w,
1760
1758
  name: t,
1761
1759
  id: t,
1762
1760
  radius: d,
@@ -1768,34 +1766,34 @@ class bt extends W {
1768
1766
  name: t,
1769
1767
  id: t,
1770
1768
  zIndex: c,
1771
- pos: y,
1769
+ pos: w,
1772
1770
  anchor: [0.5, 0.5],
1773
- size: [u.w, u.h]
1771
+ size: [f.w, f.h]
1774
1772
  };
1775
1773
  l && (b.scale = l), h && (b.rotate = h), p && (b.translate = p);
1776
- const v = new _(b);
1774
+ const I = new _(b);
1777
1775
  if (s) {
1778
- const N = new it({
1776
+ const v = new it({
1779
1777
  d: "M-4,0H4M0,-4V4",
1780
1778
  normalize: !0,
1781
1779
  pos: [0, 0],
1782
1780
  strokeColor: i,
1783
1781
  lineWidth: 1,
1784
- scale: [1 / f[0], 1 / f[1]]
1782
+ scale: [1 / u[0], 1 / u[1]]
1785
1783
  });
1786
- v.append(N);
1784
+ I.append(v);
1787
1785
  }
1788
- const g = new Gt({
1789
- ...k,
1786
+ const g = new qt({
1787
+ ...S,
1790
1788
  pos: [0, 0]
1791
1789
  });
1792
- v.append(g), this.replace(o, t, v);
1793
- const L = v.getBoundingClientRect();
1790
+ I.append(g), this.replace(o, t, I);
1791
+ const L = I.getBoundingClientRect();
1794
1792
  return {
1795
- x: Math.floor(L.x - W.SafeBorderPadding),
1796
- y: Math.floor(L.y - W.SafeBorderPadding),
1797
- w: Math.floor(L.width + W.SafeBorderPadding * 2),
1798
- h: Math.floor(L.height + W.SafeBorderPadding * 2)
1793
+ x: Math.floor(L.x - N.SafeBorderPadding),
1794
+ y: Math.floor(L.y - N.SafeBorderPadding),
1795
+ w: Math.floor(L.width + N.SafeBorderPadding * 2),
1796
+ h: Math.floor(L.height + N.SafeBorderPadding * 2)
1799
1797
  };
1800
1798
  }
1801
1799
  computDrawPoints(e) {
@@ -1834,7 +1832,7 @@ class bt extends W {
1834
1832
  toolsType: this.toolsType,
1835
1833
  canRotate: this.canRotate,
1836
1834
  scaleType: this.scaleType,
1837
- centerPos: W.getCenterPos(r, i)
1835
+ centerPos: N.getCenterPos(r, i)
1838
1836
  }), r;
1839
1837
  }
1840
1838
  clearTmpPoints() {
@@ -1844,14 +1842,14 @@ class bt extends W {
1844
1842
  var l, h;
1845
1843
  const { node: t, opt: o, vNodes: s } = e, { strokeColor: i, fillColor: r } = o, a = s.get(t.name);
1846
1844
  let c = t;
1847
- return t.tagName === "GROUP" && (c = t.children[0]), i && (c.setAttribute("strokeColor", i), (l = a == null ? void 0 : a.opt) != null && l.strokeColor && (a.opt.strokeColor = i)), r && (r === "transparent" ? c.setAttribute("fillColor", "rgba(0,0,0,0)") : c.setAttribute("fillColor", r), (h = a == null ? void 0 : a.opt) != null && h.fillColor && (a.opt.fillColor = r)), a && s.setInfo(t.name, a), W.updateNodeOpt(e);
1845
+ return t.tagName === "GROUP" && (c = t.children[0]), i && (c.setAttribute("strokeColor", i), (l = a == null ? void 0 : a.opt) != null && l.strokeColor && (a.opt.strokeColor = i)), r && (r === "transparent" ? c.setAttribute("fillColor", "rgba(0,0,0,0)") : c.setAttribute("fillColor", r), (h = a == null ? void 0 : a.opt) != null && h.fillColor && (a.opt.fillColor = r)), a && s.setInfo(t.name, a), N.updateNodeOpt(e);
1848
1846
  }
1849
1847
  }
1850
- class Rt extends W {
1848
+ class Rt extends N {
1851
1849
  constructor(e) {
1852
1850
  super(e);
1853
1851
  m(this, "canRotate", !0);
1854
- m(this, "scaleType", U.all);
1852
+ m(this, "scaleType", X.all);
1855
1853
  m(this, "toolsType", P.Rectangle);
1856
1854
  m(this, "tmpPoints", []);
1857
1855
  m(this, "workOptions");
@@ -1871,7 +1869,7 @@ class Rt extends W {
1871
1869
  computDrawPoints(e) {
1872
1870
  const { thickness: t } = this.workOptions, o = [];
1873
1871
  for (const r of e)
1874
- o.push(new S(...r));
1872
+ o.push(new k(...r));
1875
1873
  const s = z(o, t), i = [s.x + s.w / 2, s.y + s.h / 2];
1876
1874
  return {
1877
1875
  rect: s,
@@ -1880,37 +1878,37 @@ class Rt extends W {
1880
1878
  };
1881
1879
  }
1882
1880
  consume(e) {
1883
- var u;
1884
- const { data: t, isFullWork: o, isSubWorker: s, isMainThread: i } = e, r = (u = t == null ? void 0 : t.workId) == null ? void 0 : u.toString();
1881
+ var f;
1882
+ const { data: t, isFullWork: o, isSubWorker: s, isMainThread: i } = e, r = (f = t == null ? void 0 : t.workId) == null ? void 0 : f.toString();
1885
1883
  if (!r)
1886
- return { type: w.None };
1884
+ return { type: y.None };
1887
1885
  const { op: a, workState: c } = t, l = a == null ? void 0 : a.length;
1888
1886
  if (!l || l < 2)
1889
- return { type: w.None };
1887
+ return { type: y.None };
1890
1888
  let h;
1891
- if (c === D.Start ? (this.tmpPoints = [new O(a[0], a[1])], h = !1) : h = this.updateTempPoints(a), !h)
1892
- return { type: w.None };
1889
+ if (c === A.Start ? (this.tmpPoints = [new O(a[0], a[1])], h = !1) : h = this.updateTempPoints(a), !h)
1890
+ return { type: y.None };
1893
1891
  const p = this.transformData();
1894
- let f;
1892
+ let u;
1895
1893
  if (s || i) {
1896
- const y = o ? this.fullLayer : this.drawLayer || this.fullLayer;
1897
- f = this.draw({ ps: p, workId: r, layer: y, isDrawing: !0 });
1894
+ const w = o ? this.fullLayer : this.drawLayer || this.fullLayer;
1895
+ u = this.draw({ ps: p, workId: r, layer: w, isDrawing: !0 });
1898
1896
  }
1899
1897
  if (!s) {
1900
- const y = Date.now();
1901
- return y - this.syncTimestamp > this.syncUnitTime ? (this.syncTimestamp = y, {
1902
- type: w.DrawWork,
1898
+ const w = Date.now();
1899
+ return w - this.syncTimestamp > this.syncUnitTime ? (this.syncTimestamp = w, {
1900
+ type: y.DrawWork,
1903
1901
  dataType: C.Local,
1904
1902
  workId: r,
1905
1903
  op: p.flat(1),
1906
1904
  isSync: !0,
1907
1905
  index: 0
1908
- }) : { type: w.None };
1906
+ }) : { type: y.None };
1909
1907
  }
1910
- const d = B(f, this.oldRect);
1911
- return this.oldRect = f, {
1908
+ const d = B(u, this.oldRect);
1909
+ return this.oldRect = u, {
1912
1910
  rect: d,
1913
- type: w.DrawWork,
1911
+ type: y.DrawWork,
1914
1912
  dataType: C.Local,
1915
1913
  workId: r
1916
1914
  };
@@ -1919,10 +1917,10 @@ class Rt extends W {
1919
1917
  var l, h;
1920
1918
  const { data: t } = e, o = (l = t == null ? void 0 : t.workId) == null ? void 0 : l.toString();
1921
1919
  if (!o)
1922
- return { type: w.None };
1920
+ return { type: y.None };
1923
1921
  if (this.tmpPoints.length < 2)
1924
1922
  return {
1925
- type: w.RemoveNode,
1923
+ type: y.RemoveNode,
1926
1924
  removeIds: [o]
1927
1925
  };
1928
1926
  const s = this.transformData(), i = this.fullLayer, r = this.draw({ ps: s, workId: o, layer: i, isDrawing: !1 });
@@ -1935,10 +1933,10 @@ class Rt extends W {
1935
1933
  toolsType: this.toolsType,
1936
1934
  scaleType: this.scaleType,
1937
1935
  canRotate: this.canRotate,
1938
- centerPos: r && W.getCenterPos(r, i)
1936
+ centerPos: r && N.getCenterPos(r, i)
1939
1937
  }), {
1940
1938
  rect: r,
1941
- type: w.FullWork,
1939
+ type: y.FullWork,
1942
1940
  dataType: C.Local,
1943
1941
  workId: o,
1944
1942
  ops: c,
@@ -1947,7 +1945,7 @@ class Rt extends W {
1947
1945
  };
1948
1946
  }
1949
1947
  draw(e) {
1950
- const { workId: t, layer: o, isDrawing: s, ps: i, replaceId: r } = e, { strokeColor: a, fillColor: c, thickness: l, zIndex: h, scale: p, rotate: f, translate: d, textOpt: u } = this.workOptions, y = o.worldPosition, k = o.worldScaling, { points: b, rect: v, pos: g } = this.computDrawPoints(i), L = {
1948
+ const { workId: t, layer: o, isDrawing: s, ps: i, replaceId: r } = e, { strokeColor: a, fillColor: c, thickness: l, zIndex: h, scale: p, rotate: u, translate: d, textOpt: f } = this.workOptions, w = o.worldPosition, S = o.worldScaling, { points: b, rect: I, pos: g } = this.computDrawPoints(i), L = {
1951
1949
  close: !0,
1952
1950
  normalize: !0,
1953
1951
  points: b,
@@ -1955,49 +1953,49 @@ class Rt extends W {
1955
1953
  fillColor: c !== "transparent" && c || void 0,
1956
1954
  strokeColor: a,
1957
1955
  lineJoin: "round"
1958
- }, N = {
1959
- x: Math.floor(v.x * k[0] + y[0] - W.SafeBorderPadding),
1960
- y: Math.floor(v.y * k[1] + y[1] - W.SafeBorderPadding),
1961
- w: Math.floor(v.w * k[0] + 2 * W.SafeBorderPadding),
1962
- h: Math.floor(v.h * k[0] + 2 * W.SafeBorderPadding)
1963
- }, I = new _({
1956
+ }, v = {
1957
+ x: Math.floor(I.x * S[0] + w[0] - N.SafeBorderPadding),
1958
+ y: Math.floor(I.y * S[1] + w[1] - N.SafeBorderPadding),
1959
+ w: Math.floor(I.w * S[0] + 2 * N.SafeBorderPadding),
1960
+ h: Math.floor(I.h * S[0] + 2 * N.SafeBorderPadding)
1961
+ }, W = new _({
1964
1962
  name: t,
1965
1963
  id: t,
1966
1964
  zIndex: h,
1967
1965
  pos: g,
1968
1966
  anchor: [0.5, 0.5],
1969
1967
  size: [
1970
- v.w,
1971
- v.h
1968
+ I.w,
1969
+ I.h
1972
1970
  ],
1973
1971
  scale: p,
1974
- rotate: f,
1972
+ rotate: u,
1975
1973
  translate: d
1976
- }), A = new st({
1974
+ }), D = new st({
1977
1975
  ...L,
1978
1976
  pos: [0, 0]
1979
1977
  });
1980
- if (I.appendChild(A), s) {
1978
+ if (W.appendChild(D), s) {
1981
1979
  const T = new it({
1982
1980
  d: "M-4,0H4M0,-4V4",
1983
1981
  normalize: !0,
1984
1982
  pos: [0, 0],
1985
1983
  strokeColor: a,
1986
1984
  lineWidth: 1,
1987
- scale: [1 / k[0], 1 / k[1]]
1985
+ scale: [1 / S[0], 1 / S[1]]
1988
1986
  });
1989
- I.appendChild(T);
1987
+ W.appendChild(T);
1990
1988
  }
1991
- if (this.replace(o, r || t, I), p || f || d) {
1992
- const T = I.getBoundingClientRect();
1989
+ if (this.replace(o, r || t, W), p || u || d) {
1990
+ const T = W.getBoundingClientRect();
1993
1991
  return {
1994
- x: Math.floor(T.x - W.SafeBorderPadding),
1995
- y: Math.floor(T.y - W.SafeBorderPadding),
1996
- w: Math.floor(T.width + 2 * W.SafeBorderPadding),
1997
- h: Math.floor(T.height + 2 * W.SafeBorderPadding)
1992
+ x: Math.floor(T.x - N.SafeBorderPadding),
1993
+ y: Math.floor(T.y - N.SafeBorderPadding),
1994
+ w: Math.floor(T.width + 2 * N.SafeBorderPadding),
1995
+ h: Math.floor(T.height + 2 * N.SafeBorderPadding)
1998
1996
  };
1999
1997
  }
2000
- return N;
1998
+ return v;
2001
1999
  }
2002
2000
  updateTempPoints(e) {
2003
2001
  const t = e.slice(-2), o = new O(t[0], t[1]), s = this.tmpPoints[0], { thickness: i } = this.workOptions;
@@ -2027,14 +2025,14 @@ class Rt extends W {
2027
2025
  toolsType: this.toolsType,
2028
2026
  scaleType: this.scaleType,
2029
2027
  canRotate: this.canRotate,
2030
- centerPos: c && W.getCenterPos(c, a)
2028
+ centerPos: c && N.getCenterPos(c, a)
2031
2029
  }), c;
2032
2030
  }
2033
2031
  clearTmpPoints() {
2034
2032
  this.tmpPoints.length = 0;
2035
2033
  }
2036
2034
  static updateNodeOpt(e) {
2037
- var k, b;
2035
+ var S, b;
2038
2036
  const { node: t, opt: o, vNodes: s } = e, {
2039
2037
  strokeColor: i,
2040
2038
  fillColor: r,
@@ -2043,22 +2041,22 @@ class Rt extends W {
2043
2041
  bold: l,
2044
2042
  italic: h,
2045
2043
  lineThrough: p,
2046
- underline: f,
2044
+ underline: u,
2047
2045
  fontSize: d
2048
- } = o, u = s.get(t.name);
2049
- let y = t;
2050
- if (t.tagName === "GROUP" && (y = t.children[0]), i && (y.setAttribute("strokeColor", i), (k = u == null ? void 0 : u.opt) != null && k.strokeColor && (u.opt.strokeColor = i)), r && (r === "transparent" ? y.setAttribute("fillColor", "rgba(0,0,0,0)") : y.setAttribute("fillColor", r), (b = u == null ? void 0 : u.opt) != null && b.fillColor && (u.opt.fillColor = r)), u != null && u.opt.textOpt) {
2051
- const v = u.opt.textOpt;
2052
- a && v.fontColor && (v.fontColor = a), c && v.fontBgColor && (v.fontBgColor = c), l && (v.bold = l), h && (v.italic = h), ot(p) && (v.lineThrough = p), ot(f) && (v.underline = f), d && (v.fontSize = d);
2046
+ } = o, f = s.get(t.name);
2047
+ let w = t;
2048
+ if (t.tagName === "GROUP" && (w = t.children[0]), i && (w.setAttribute("strokeColor", i), (S = f == null ? void 0 : f.opt) != null && S.strokeColor && (f.opt.strokeColor = i)), r && (r === "transparent" ? w.setAttribute("fillColor", "rgba(0,0,0,0)") : w.setAttribute("fillColor", r), (b = f == null ? void 0 : f.opt) != null && b.fillColor && (f.opt.fillColor = r)), f != null && f.opt.textOpt) {
2049
+ const I = f.opt.textOpt;
2050
+ a && I.fontColor && (I.fontColor = a), c && I.fontBgColor && (I.fontBgColor = c), l && (I.bold = l), h && (I.italic = h), ot(p) && (I.lineThrough = p), ot(u) && (I.underline = u), d && (I.fontSize = d);
2053
2051
  }
2054
- return u && s.setInfo(t.name, u), W.updateNodeOpt(e);
2052
+ return f && s.setInfo(t.name, f), N.updateNodeOpt(e);
2055
2053
  }
2056
2054
  }
2057
- class Ct extends W {
2055
+ class Ct extends N {
2058
2056
  constructor(e) {
2059
2057
  super(e);
2060
2058
  m(this, "canRotate", !1);
2061
- m(this, "scaleType", U.all);
2059
+ m(this, "scaleType", X.all);
2062
2060
  m(this, "toolsType", P.Star);
2063
2061
  m(this, "tmpPoints", []);
2064
2062
  m(this, "workOptions");
@@ -2070,33 +2068,33 @@ class Ct extends W {
2070
2068
  var d;
2071
2069
  const { data: t, isFullWork: o, isSubWorker: s, isMainThread: i } = e, r = (d = t == null ? void 0 : t.workId) == null ? void 0 : d.toString();
2072
2070
  if (!r)
2073
- return { type: w.None };
2071
+ return { type: y.None };
2074
2072
  const { op: a, workState: c } = t, l = a == null ? void 0 : a.length;
2075
2073
  if (!l || l < 2)
2076
- return { type: w.None };
2074
+ return { type: y.None };
2077
2075
  let h;
2078
- if (c === D.Start ? (this.tmpPoints = [new O(a[0], a[1])], h = !1) : h = this.updateTempPoints(a), !h)
2079
- return { type: w.None };
2076
+ if (c === A.Start ? (this.tmpPoints = [new O(a[0], a[1])], h = !1) : h = this.updateTempPoints(a), !h)
2077
+ return { type: y.None };
2080
2078
  let p;
2081
2079
  if (s || i) {
2082
- const u = o ? this.fullLayer : this.drawLayer || this.fullLayer;
2083
- p = this.draw({ workId: r, layer: u, isDrawing: !0 });
2080
+ const f = o ? this.fullLayer : this.drawLayer || this.fullLayer;
2081
+ p = this.draw({ workId: r, layer: f, isDrawing: !0 });
2084
2082
  }
2085
2083
  if (!s) {
2086
- const u = Date.now();
2087
- return u - this.syncTimestamp > this.syncUnitTime ? (this.syncTimestamp = u, {
2088
- type: w.DrawWork,
2084
+ const f = Date.now();
2085
+ return f - this.syncTimestamp > this.syncUnitTime ? (this.syncTimestamp = f, {
2086
+ type: y.DrawWork,
2089
2087
  dataType: C.Local,
2090
2088
  workId: r,
2091
- op: this.tmpPoints.map((y) => [...y.XY, 0]).flat(1),
2089
+ op: this.tmpPoints.map((w) => [...w.XY, 0]).flat(1),
2092
2090
  isSync: !0,
2093
2091
  index: 0
2094
- }) : { type: w.None };
2092
+ }) : { type: y.None };
2095
2093
  }
2096
- const f = B(p, this.oldRect);
2094
+ const u = B(p, this.oldRect);
2097
2095
  return this.oldRect = p, {
2098
- rect: f,
2099
- type: w.DrawWork,
2096
+ rect: u,
2097
+ type: y.DrawWork,
2100
2098
  dataType: C.Local,
2101
2099
  workId: r
2102
2100
  // op: this.tmpPoints.map(c=>[...c.XY,0]).flat(1)
@@ -2106,10 +2104,10 @@ class Ct extends W {
2106
2104
  var c, l;
2107
2105
  const { data: t } = e, o = (c = t == null ? void 0 : t.workId) == null ? void 0 : c.toString();
2108
2106
  if (!o)
2109
- return { type: w.None };
2107
+ return { type: y.None };
2110
2108
  if (this.tmpPoints.length < 2)
2111
2109
  return {
2112
- type: w.RemoveNode,
2110
+ type: y.RemoveNode,
2113
2111
  removeIds: [o]
2114
2112
  };
2115
2113
  const s = this.fullLayer, i = this.draw({ workId: o, layer: s, isDrawing: !1 });
@@ -2122,10 +2120,10 @@ class Ct extends W {
2122
2120
  toolsType: this.toolsType,
2123
2121
  scaleType: this.scaleType,
2124
2122
  canRotate: this.canRotate,
2125
- centerPos: i && W.getCenterPos(i, s)
2123
+ centerPos: i && N.getCenterPos(i, s)
2126
2124
  }), {
2127
2125
  rect: i,
2128
- type: w.FullWork,
2126
+ type: y.FullWork,
2129
2127
  dataType: C.Local,
2130
2128
  workId: o,
2131
2129
  ops: a,
@@ -2134,9 +2132,9 @@ class Ct extends W {
2134
2132
  };
2135
2133
  }
2136
2134
  draw(e) {
2137
- const { workId: t, layer: o, isDrawing: s } = e, { strokeColor: i, fillColor: r, thickness: a, zIndex: c, vertices: l, innerVerticeStep: h, innerRatio: p, scale: f, rotate: d, translate: u } = this.workOptions, y = o.worldScaling, { rect: k, pos: b, points: v } = this.computDrawPoints(a, l, h, p), g = {
2135
+ const { workId: t, layer: o, isDrawing: s } = e, { strokeColor: i, fillColor: r, thickness: a, zIndex: c, vertices: l, innerVerticeStep: h, innerRatio: p, scale: u, rotate: d, translate: f } = this.workOptions, w = o.worldScaling, { rect: S, pos: b, points: I } = this.computDrawPoints(a, l, h, p), g = {
2138
2136
  close: !0,
2139
- points: v,
2137
+ points: I,
2140
2138
  lineWidth: a,
2141
2139
  fillColor: r !== "transparent" && r || void 0,
2142
2140
  strokeColor: i,
@@ -2148,11 +2146,11 @@ class Ct extends W {
2148
2146
  zIndex: c,
2149
2147
  pos: b,
2150
2148
  anchor: [0.5, 0.5],
2151
- size: [k.w, k.h],
2149
+ size: [S.w, S.h],
2152
2150
  className: `${b[0]},${b[1]}`
2153
2151
  };
2154
- f && (L.scale = f), d && (L.rotate = d), u && (L.translate = u);
2155
- const N = new _(L);
2152
+ u && (L.scale = u), d && (L.rotate = d), f && (L.translate = f);
2153
+ const v = new _(L);
2156
2154
  if (s) {
2157
2155
  const T = new it({
2158
2156
  d: "M-4,0H4M0,-4V4",
@@ -2160,29 +2158,29 @@ class Ct extends W {
2160
2158
  pos: [0, 0],
2161
2159
  strokeColor: i,
2162
2160
  lineWidth: 1,
2163
- scale: [1 / y[0], 1 / y[1]]
2161
+ scale: [1 / w[0], 1 / w[1]]
2164
2162
  });
2165
- N.append(T);
2163
+ v.append(T);
2166
2164
  }
2167
- const I = new st({
2165
+ const W = new st({
2168
2166
  ...g,
2169
2167
  pos: [0, 0]
2170
2168
  });
2171
- N.append(I), this.replace(o, t, N);
2172
- const A = N.getBoundingClientRect();
2169
+ v.append(W), this.replace(o, t, v);
2170
+ const D = v.getBoundingClientRect();
2173
2171
  return {
2174
- x: Math.floor(A.x - W.SafeBorderPadding),
2175
- y: Math.floor(A.y - W.SafeBorderPadding),
2176
- w: Math.floor(A.width + W.SafeBorderPadding * 2),
2177
- h: Math.floor(A.height + W.SafeBorderPadding * 2)
2172
+ x: Math.floor(D.x - N.SafeBorderPadding),
2173
+ y: Math.floor(D.y - N.SafeBorderPadding),
2174
+ w: Math.floor(D.width + N.SafeBorderPadding * 2),
2175
+ h: Math.floor(D.height + N.SafeBorderPadding * 2)
2178
2176
  };
2179
2177
  }
2180
2178
  computDrawPoints(e, t, o, s) {
2181
2179
  const i = z(this.tmpPoints), r = [Math.floor(i.x + i.w / 2), Math.floor(i.y + i.h / 2)], a = vt(i.w, i.h), c = Math.floor(Math.min(i.w, i.h) / 2), l = s * c, h = [], p = 2 * Math.PI / t;
2182
2180
  for (let d = 0; d < t; d++) {
2183
- const u = d * p - 0.5 * Math.PI;
2184
- let y, k;
2185
- d % o === 1 ? (y = l * a[0] * Math.cos(u), k = l * a[1] * Math.sin(u)) : (y = c * a[0] * Math.cos(u), k = c * a[1] * Math.sin(u), h.push(y, k)), h.push(y, k);
2181
+ const f = d * p - 0.5 * Math.PI;
2182
+ let w, S;
2183
+ d % o === 1 ? (w = l * a[0] * Math.cos(f), S = l * a[1] * Math.sin(f)) : (w = c * a[0] * Math.cos(f), S = c * a[1] * Math.sin(f), h.push(w, S)), h.push(w, S);
2186
2184
  }
2187
2185
  return {
2188
2186
  rect: z(this.tmpPoints, e),
@@ -2218,23 +2216,23 @@ class Ct extends W {
2218
2216
  toolsType: this.toolsType,
2219
2217
  scaleType: this.scaleType,
2220
2218
  canRotate: this.canRotate,
2221
- centerPos: r && W.getCenterPos(r, i)
2219
+ centerPos: r && N.getCenterPos(r, i)
2222
2220
  }), r;
2223
2221
  }
2224
2222
  clearTmpPoints() {
2225
2223
  this.tmpPoints.length = 0;
2226
2224
  }
2227
2225
  static updateNodeOpt(e) {
2228
- const { node: t, opt: o, vNodes: s } = e, { strokeColor: i, fillColor: r, toolsType: a, vertices: c, innerVerticeStep: l, innerRatio: h } = o, p = s.get(t.name), f = p == null ? void 0 : p.opt;
2226
+ const { node: t, opt: o, vNodes: s } = e, { strokeColor: i, fillColor: r, toolsType: a, vertices: c, innerVerticeStep: l, innerRatio: h } = o, p = s.get(t.name), u = p == null ? void 0 : p.opt;
2229
2227
  let d = t;
2230
- return t.tagName === "GROUP" && (d = t.children[0]), i && (d.setAttribute("strokeColor", i), f != null && f.strokeColor && (f.strokeColor = i)), r && (r === "transparent" ? d.setAttribute("fillColor", "rgba(0,0,0,0)") : d.setAttribute("fillColor", r), f != null && f.fillColor && (f.fillColor = r)), a === P.Star && (c && (f.vertices = c), l && (f.innerVerticeStep = l), h && (f.innerRatio = h)), p && s.setInfo(t.name, { ...p, opt: f }), W.updateNodeOpt(e);
2228
+ return t.tagName === "GROUP" && (d = t.children[0]), i && (d.setAttribute("strokeColor", i), u != null && u.strokeColor && (u.strokeColor = i)), r && (r === "transparent" ? d.setAttribute("fillColor", "rgba(0,0,0,0)") : d.setAttribute("fillColor", r), u != null && u.fillColor && (u.fillColor = r)), a === P.Star && (c && (u.vertices = c), l && (u.innerVerticeStep = l), h && (u.innerRatio = h)), p && s.setInfo(t.name, { ...p, opt: u }), N.updateNodeOpt(e);
2231
2229
  }
2232
2230
  }
2233
- class Mt extends W {
2231
+ class Mt extends N {
2234
2232
  constructor(e) {
2235
2233
  super(e);
2236
2234
  m(this, "canRotate", !1);
2237
- m(this, "scaleType", U.all);
2235
+ m(this, "scaleType", X.all);
2238
2236
  m(this, "toolsType", P.Polygon);
2239
2237
  m(this, "tmpPoints", []);
2240
2238
  m(this, "workOptions");
@@ -2246,33 +2244,33 @@ class Mt extends W {
2246
2244
  var d;
2247
2245
  const { data: t, isFullWork: o, isSubWorker: s, isMainThread: i } = e, r = (d = t == null ? void 0 : t.workId) == null ? void 0 : d.toString();
2248
2246
  if (!r)
2249
- return { type: w.None };
2247
+ return { type: y.None };
2250
2248
  const { op: a, workState: c } = t, l = a == null ? void 0 : a.length;
2251
2249
  if (!l || l < 2)
2252
- return { type: w.None };
2250
+ return { type: y.None };
2253
2251
  let h;
2254
- if (c === D.Start ? (this.tmpPoints = [new O(a[0], a[1])], h = !1) : h = this.updateTempPoints(a), !h)
2255
- return { type: w.None };
2252
+ if (c === A.Start ? (this.tmpPoints = [new O(a[0], a[1])], h = !1) : h = this.updateTempPoints(a), !h)
2253
+ return { type: y.None };
2256
2254
  let p;
2257
2255
  if (s || i) {
2258
- const u = o ? this.fullLayer : this.drawLayer || this.fullLayer;
2259
- p = this.draw({ workId: r, layer: u, isDrawing: !0 });
2256
+ const f = o ? this.fullLayer : this.drawLayer || this.fullLayer;
2257
+ p = this.draw({ workId: r, layer: f, isDrawing: !0 });
2260
2258
  }
2261
2259
  if (!s) {
2262
- const u = Date.now();
2263
- return u - this.syncTimestamp > this.syncUnitTime ? (this.syncTimestamp = u, {
2264
- type: w.DrawWork,
2260
+ const f = Date.now();
2261
+ return f - this.syncTimestamp > this.syncUnitTime ? (this.syncTimestamp = f, {
2262
+ type: y.DrawWork,
2265
2263
  dataType: C.Local,
2266
2264
  workId: r,
2267
- op: this.tmpPoints.map((y) => [...y.XY, 0]).flat(1),
2265
+ op: this.tmpPoints.map((w) => [...w.XY, 0]).flat(1),
2268
2266
  isSync: !0,
2269
2267
  index: 0
2270
- }) : { type: w.None };
2268
+ }) : { type: y.None };
2271
2269
  }
2272
- const f = B(p, this.oldRect);
2270
+ const u = B(p, this.oldRect);
2273
2271
  return this.oldRect = p, {
2274
- rect: f,
2275
- type: w.DrawWork,
2272
+ rect: u,
2273
+ type: y.DrawWork,
2276
2274
  dataType: C.Local,
2277
2275
  workId: r
2278
2276
  };
@@ -2281,10 +2279,10 @@ class Mt extends W {
2281
2279
  var c, l;
2282
2280
  const { data: t } = e, o = (c = t == null ? void 0 : t.workId) == null ? void 0 : c.toString();
2283
2281
  if (!o)
2284
- return { type: w.None };
2282
+ return { type: y.None };
2285
2283
  if (this.tmpPoints.length < 2)
2286
2284
  return {
2287
- type: w.RemoveNode,
2285
+ type: y.RemoveNode,
2288
2286
  removeIds: [o]
2289
2287
  };
2290
2288
  const s = this.fullLayer, i = this.draw({ workId: o, layer: s, isDrawing: !1 });
@@ -2297,10 +2295,10 @@ class Mt extends W {
2297
2295
  toolsType: this.toolsType,
2298
2296
  scaleType: this.scaleType,
2299
2297
  canRotate: this.canRotate,
2300
- centerPos: i && W.getCenterPos(i, s)
2298
+ centerPos: i && N.getCenterPos(i, s)
2301
2299
  }), {
2302
2300
  rect: i,
2303
- type: w.FullWork,
2301
+ type: y.FullWork,
2304
2302
  dataType: C.Local,
2305
2303
  workId: o,
2306
2304
  ops: a,
@@ -2309,26 +2307,26 @@ class Mt extends W {
2309
2307
  };
2310
2308
  }
2311
2309
  draw(e) {
2312
- const { workId: t, layer: o, isDrawing: s } = e, { strokeColor: i, fillColor: r, thickness: a, zIndex: c, vertices: l, scale: h, rotate: p, translate: f } = this.workOptions, d = o.worldScaling, { rect: u, pos: y, points: k } = this.computDrawPoints(a, l), b = {
2310
+ const { workId: t, layer: o, isDrawing: s } = e, { strokeColor: i, fillColor: r, thickness: a, zIndex: c, vertices: l, scale: h, rotate: p, translate: u } = this.workOptions, d = o.worldScaling, { rect: f, pos: w, points: S } = this.computDrawPoints(a, l), b = {
2313
2311
  close: !0,
2314
- points: k,
2312
+ points: S,
2315
2313
  lineWidth: a,
2316
2314
  fillColor: r !== "transparent" && r || void 0,
2317
2315
  strokeColor: i,
2318
2316
  normalize: !0,
2319
2317
  lineJoin: "round"
2320
- }, v = {
2318
+ }, I = {
2321
2319
  name: t,
2322
2320
  id: t,
2323
2321
  zIndex: c,
2324
- pos: y,
2322
+ pos: w,
2325
2323
  anchor: [0.5, 0.5],
2326
- size: [u.w, u.h]
2324
+ size: [f.w, f.h]
2327
2325
  };
2328
- h && (v.scale = h), p && (v.rotate = p), f && (v.translate = f);
2329
- const g = new _(v);
2326
+ h && (I.scale = h), p && (I.rotate = p), u && (I.translate = u);
2327
+ const g = new _(I);
2330
2328
  if (s) {
2331
- const I = new it({
2329
+ const W = new it({
2332
2330
  d: "M-4,0H4M0,-4V4",
2333
2331
  normalize: !0,
2334
2332
  pos: [0, 0],
@@ -2336,26 +2334,26 @@ class Mt extends W {
2336
2334
  lineWidth: 1,
2337
2335
  scale: [1 / d[0], 1 / d[1]]
2338
2336
  });
2339
- g.append(I);
2337
+ g.append(W);
2340
2338
  }
2341
2339
  const L = new st({
2342
2340
  ...b,
2343
2341
  pos: [0, 0]
2344
2342
  });
2345
2343
  g.append(L), this.replace(o, t, g);
2346
- const N = g.getBoundingClientRect();
2344
+ const v = g.getBoundingClientRect();
2347
2345
  return {
2348
- x: Math.floor(N.x - W.SafeBorderPadding),
2349
- y: Math.floor(N.y - W.SafeBorderPadding),
2350
- w: Math.floor(N.width + W.SafeBorderPadding * 2),
2351
- h: Math.floor(N.height + W.SafeBorderPadding * 2)
2346
+ x: Math.floor(v.x - N.SafeBorderPadding),
2347
+ y: Math.floor(v.y - N.SafeBorderPadding),
2348
+ w: Math.floor(v.width + N.SafeBorderPadding * 2),
2349
+ h: Math.floor(v.height + N.SafeBorderPadding * 2)
2352
2350
  };
2353
2351
  }
2354
2352
  computDrawPoints(e, t) {
2355
2353
  const o = z(this.tmpPoints), s = [Math.floor(o.x + o.w / 2), Math.floor(o.y + o.h / 2)], i = vt(o.w, o.h), r = Math.floor(Math.min(o.w, o.h) / 2), a = [], c = 2 * Math.PI / t;
2356
2354
  for (let h = 0; h < t; h++) {
2357
- const p = h * c - 0.5 * Math.PI, f = r * i[0] * Math.cos(p), d = r * i[1] * Math.sin(p);
2358
- a.push(f, d);
2355
+ const p = h * c - 0.5 * Math.PI, u = r * i[0] * Math.cos(p), d = r * i[1] * Math.sin(p);
2356
+ a.push(u, d);
2359
2357
  }
2360
2358
  return {
2361
2359
  rect: z(this.tmpPoints, e),
@@ -2391,7 +2389,7 @@ class Mt extends W {
2391
2389
  toolsType: this.toolsType,
2392
2390
  scaleType: this.scaleType,
2393
2391
  canRotate: this.canRotate,
2394
- centerPos: r && W.getCenterPos(r, i)
2392
+ centerPos: r && N.getCenterPos(r, i)
2395
2393
  }), r;
2396
2394
  }
2397
2395
  clearTmpPoints() {
@@ -2400,7 +2398,7 @@ class Mt extends W {
2400
2398
  static updateNodeOpt(e) {
2401
2399
  const { node: t, opt: o, vNodes: s } = e, { strokeColor: i, fillColor: r, toolsType: a, vertices: c } = o, l = s.get(t.name), h = l == null ? void 0 : l.opt;
2402
2400
  let p = t;
2403
- return t.tagName === "GROUP" && (p = t.children[0]), i && (p.setAttribute("strokeColor", i), h != null && h.strokeColor && (h.strokeColor = i)), r && (r === "transparent" ? p.setAttribute("fillColor", "rgba(0,0,0,0)") : p.setAttribute("fillColor", r), h != null && h.fillColor && (h.fillColor = r)), a === P.Polygon && c && (h.vertices = c), l && s.setInfo(t.name, { ...l, opt: h }), W.updateNodeOpt(e);
2401
+ return t.tagName === "GROUP" && (p = t.children[0]), i && (p.setAttribute("strokeColor", i), h != null && h.strokeColor && (h.strokeColor = i)), r && (r === "transparent" ? p.setAttribute("fillColor", "rgba(0,0,0,0)") : p.setAttribute("fillColor", r), h != null && h.fillColor && (h.fillColor = r)), a === P.Polygon && c && (h.vertices = c), l && s.setInfo(t.name, { ...l, opt: h }), N.updateNodeOpt(e);
2404
2402
  }
2405
2403
  }
2406
2404
  class Z {
@@ -2439,7 +2437,7 @@ class Z {
2439
2437
  */
2440
2438
  static oneBezier(n, e, t) {
2441
2439
  const o = e.x + (t.x - e.x) * n, s = e.y + (t.y - e.y) * n;
2442
- return new S(o, s);
2440
+ return new k(o, s);
2443
2441
  }
2444
2442
  /**
2445
2443
  * @desc 二阶贝塞尔
@@ -2450,7 +2448,7 @@ class Z {
2450
2448
  */
2451
2449
  static twoBezier(n, e, t, o) {
2452
2450
  const s = (1 - n) * (1 - n) * e.x + 2 * n * (1 - n) * t.x + n * n * o.x, i = (1 - n) * (1 - n) * e.y + 2 * n * (1 - n) * t.y + n * n * o.y;
2453
- return new S(s, i);
2451
+ return new k(s, i);
2454
2452
  }
2455
2453
  /**
2456
2454
  * @desc 三阶贝塞尔
@@ -2462,14 +2460,14 @@ class Z {
2462
2460
  */
2463
2461
  static threeBezier(n, e, t, o, s) {
2464
2462
  const i = e.x * (1 - n) * (1 - n) * (1 - n) + 3 * t.x * n * (1 - n) * (1 - n) + 3 * o.x * n * n * (1 - n) + s.x * n * n * n, r = e.y * (1 - n) * (1 - n) * (1 - n) + 3 * t.y * n * (1 - n) * (1 - n) + 3 * o.y * n * n * (1 - n) + s.y * n * n * n;
2465
- return new S(i, r);
2463
+ return new k(i, r);
2466
2464
  }
2467
2465
  }
2468
- class Ot extends W {
2466
+ class Ot extends N {
2469
2467
  constructor(e) {
2470
2468
  super(e);
2471
2469
  m(this, "canRotate", !1);
2472
- m(this, "scaleType", U.all);
2470
+ m(this, "scaleType", X.all);
2473
2471
  m(this, "toolsType", P.SpeechBalloon);
2474
2472
  m(this, "ratio", 0.8);
2475
2473
  m(this, "tmpPoints", []);
@@ -2482,33 +2480,33 @@ class Ot extends W {
2482
2480
  var d;
2483
2481
  const { data: t, isFullWork: o, isSubWorker: s, isMainThread: i } = e, r = (d = t == null ? void 0 : t.workId) == null ? void 0 : d.toString();
2484
2482
  if (!r)
2485
- return { type: w.None };
2483
+ return { type: y.None };
2486
2484
  const { op: a, workState: c } = t, l = a == null ? void 0 : a.length;
2487
2485
  if (!l || l < 2)
2488
- return { type: w.None };
2486
+ return { type: y.None };
2489
2487
  let h;
2490
- if (c === D.Start ? (this.tmpPoints = [new O(a[0], a[1])], h = !1) : h = this.updateTempPoints(a), !h)
2491
- return { type: w.None };
2488
+ if (c === A.Start ? (this.tmpPoints = [new O(a[0], a[1])], h = !1) : h = this.updateTempPoints(a), !h)
2489
+ return { type: y.None };
2492
2490
  let p;
2493
2491
  if (s || i) {
2494
- const u = o ? this.fullLayer : this.drawLayer || this.fullLayer;
2495
- p = this.draw({ workId: r, layer: u, isDrawing: !0 });
2492
+ const f = o ? this.fullLayer : this.drawLayer || this.fullLayer;
2493
+ p = this.draw({ workId: r, layer: f, isDrawing: !0 });
2496
2494
  }
2497
2495
  if (!s) {
2498
- const u = Date.now();
2499
- return u - this.syncTimestamp > this.syncUnitTime ? (this.syncTimestamp = u, {
2500
- type: w.DrawWork,
2496
+ const f = Date.now();
2497
+ return f - this.syncTimestamp > this.syncUnitTime ? (this.syncTimestamp = f, {
2498
+ type: y.DrawWork,
2501
2499
  dataType: C.Local,
2502
2500
  workId: r,
2503
- op: this.tmpPoints.map((y) => [...y.XY, 0]).flat(1),
2501
+ op: this.tmpPoints.map((w) => [...w.XY, 0]).flat(1),
2504
2502
  isSync: !0,
2505
2503
  index: 0
2506
- }) : { type: w.None };
2504
+ }) : { type: y.None };
2507
2505
  }
2508
- const f = B(p, this.oldRect);
2506
+ const u = B(p, this.oldRect);
2509
2507
  return this.oldRect = p, {
2510
- rect: f,
2511
- type: w.DrawWork,
2508
+ rect: u,
2509
+ type: y.DrawWork,
2512
2510
  dataType: C.Local,
2513
2511
  workId: r
2514
2512
  };
@@ -2517,10 +2515,10 @@ class Ot extends W {
2517
2515
  var c, l;
2518
2516
  const { data: t } = e, o = (c = t == null ? void 0 : t.workId) == null ? void 0 : c.toString();
2519
2517
  if (!o)
2520
- return { type: w.None };
2518
+ return { type: y.None };
2521
2519
  if (this.tmpPoints.length < 2)
2522
2520
  return {
2523
- type: w.RemoveNode,
2521
+ type: y.RemoveNode,
2524
2522
  removeIds: [o]
2525
2523
  };
2526
2524
  const s = this.fullLayer, i = this.draw({ workId: o, layer: s, isDrawing: !1 });
@@ -2533,10 +2531,10 @@ class Ot extends W {
2533
2531
  toolsType: this.toolsType,
2534
2532
  scaleType: this.scaleType,
2535
2533
  canRotate: this.canRotate,
2536
- centerPos: i && W.getCenterPos(i, s)
2534
+ centerPos: i && N.getCenterPos(i, s)
2537
2535
  }), {
2538
2536
  rect: i,
2539
- type: w.FullWork,
2537
+ type: y.FullWork,
2540
2538
  dataType: C.Local,
2541
2539
  workId: o,
2542
2540
  ops: a,
@@ -2545,8 +2543,8 @@ class Ot extends W {
2545
2543
  };
2546
2544
  }
2547
2545
  draw(e) {
2548
- const { workId: t, layer: o } = e, { strokeColor: s, fillColor: i, thickness: r, zIndex: a, placement: c, scale: l, rotate: h, translate: p } = this.workOptions, { rect: f, pos: d, points: u } = this.computDrawPoints(r, c), y = {
2549
- points: u.map((L) => L.XY),
2546
+ const { workId: t, layer: o } = e, { strokeColor: s, fillColor: i, thickness: r, zIndex: a, placement: c, scale: l, rotate: h, translate: p } = this.workOptions, { rect: u, pos: d, points: f } = this.computDrawPoints(r, c), w = {
2547
+ points: f.map((L) => L.XY),
2550
2548
  lineWidth: r,
2551
2549
  fillColor: i !== "transparent" && i || void 0,
2552
2550
  strokeColor: s,
@@ -2554,26 +2552,26 @@ class Ot extends W {
2554
2552
  className: `${d[0]},${d[1]}`,
2555
2553
  lineJoin: "round",
2556
2554
  close: !0
2557
- }, k = {
2555
+ }, S = {
2558
2556
  name: t,
2559
2557
  id: t,
2560
2558
  zIndex: a,
2561
2559
  pos: d,
2562
2560
  anchor: [0.5, 0.5],
2563
- size: [f.w, f.h]
2561
+ size: [u.w, u.h]
2564
2562
  };
2565
- l && (k.scale = l), h && (k.rotate = h), p && (k.translate = p);
2566
- const b = new _(k), v = new st({
2567
- ...y,
2563
+ l && (S.scale = l), h && (S.rotate = h), p && (S.translate = p);
2564
+ const b = new _(S), I = new st({
2565
+ ...w,
2568
2566
  pos: [0, 0]
2569
2567
  });
2570
- b.append(v), this.replace(o, t, b);
2568
+ b.append(I), this.replace(o, t, b);
2571
2569
  const g = b.getBoundingClientRect();
2572
2570
  return {
2573
- x: Math.floor(g.x - W.SafeBorderPadding),
2574
- y: Math.floor(g.y - W.SafeBorderPadding),
2575
- w: Math.floor(g.width + W.SafeBorderPadding * 2),
2576
- h: Math.floor(g.height + W.SafeBorderPadding * 2)
2571
+ x: Math.floor(g.x - N.SafeBorderPadding),
2572
+ y: Math.floor(g.y - N.SafeBorderPadding),
2573
+ w: Math.floor(g.width + N.SafeBorderPadding * 2),
2574
+ h: Math.floor(g.height + N.SafeBorderPadding * 2)
2577
2575
  };
2578
2576
  }
2579
2577
  transformControlPoints(e) {
@@ -2584,10 +2582,10 @@ class Ot extends W {
2584
2582
  case "bottomRight": {
2585
2583
  const o = t.y + t.h * this.ratio;
2586
2584
  return [
2587
- new S(t.x, t.y, 0),
2588
- new S(t.x + t.w, t.y, 0),
2589
- new S(t.x + t.w, o, 0),
2590
- new S(t.x, o, 0)
2585
+ new k(t.x, t.y, 0),
2586
+ new k(t.x + t.w, t.y, 0),
2587
+ new k(t.x + t.w, o, 0),
2588
+ new k(t.x, o, 0)
2591
2589
  ];
2592
2590
  }
2593
2591
  case "top":
@@ -2595,10 +2593,10 @@ class Ot extends W {
2595
2593
  case "topRight": {
2596
2594
  const o = t.y + t.h * (1 - this.ratio);
2597
2595
  return [
2598
- new S(t.x, o, 0),
2599
- new S(t.x + t.w, o, 0),
2600
- new S(t.x + t.w, t.y + t.h, 0),
2601
- new S(t.x, t.y + t.h, 0)
2596
+ new k(t.x, o, 0),
2597
+ new k(t.x + t.w, o, 0),
2598
+ new k(t.x + t.w, t.y + t.h, 0),
2599
+ new k(t.x, t.y + t.h, 0)
2602
2600
  ];
2603
2601
  }
2604
2602
  case "left":
@@ -2606,10 +2604,10 @@ class Ot extends W {
2606
2604
  case "leftTop": {
2607
2605
  const o = t.x + t.w * (1 - this.ratio);
2608
2606
  return [
2609
- new S(o, t.y, 0),
2610
- new S(t.x + t.w, t.y, 0),
2611
- new S(t.x + t.w, t.y + t.h, 0),
2612
- new S(o, t.y + t.h, 0)
2607
+ new k(o, t.y, 0),
2608
+ new k(t.x + t.w, t.y, 0),
2609
+ new k(t.x + t.w, t.y + t.h, 0),
2610
+ new k(o, t.y + t.h, 0)
2613
2611
  ];
2614
2612
  }
2615
2613
  case "right":
@@ -2617,82 +2615,82 @@ class Ot extends W {
2617
2615
  case "rightTop": {
2618
2616
  const o = t.x + t.w * this.ratio;
2619
2617
  return [
2620
- new S(t.x, t.y, 0),
2621
- new S(o, t.y, 0),
2622
- new S(o, t.y + t.h, 0),
2623
- new S(t.x, t.y + t.h, 0)
2618
+ new k(t.x, t.y, 0),
2619
+ new k(o, t.y, 0),
2620
+ new k(o, t.y + t.h, 0),
2621
+ new k(t.x, t.y + t.h, 0)
2624
2622
  ];
2625
2623
  }
2626
2624
  }
2627
2625
  }
2628
2626
  computDrawPoints(e, t) {
2629
- const o = z(this.tmpPoints), s = this.transformControlPoints(t), i = Math.floor(o.w * 0.1), r = Math.floor(o.h * 0.1), a = [], c = S.Add(s[0], new S(0, r, 0)), l = S.Add(s[0], new S(i, 0, 0)), h = Z.getBezierPoints(10, c, s[0], l), p = S.Sub(s[1], new S(i, 0, 0)), f = S.Add(s[1], new S(0, r, 0)), d = Z.getBezierPoints(10, p, s[1], f), u = S.Sub(s[2], new S(0, r, 0)), y = S.Sub(s[2], new S(i, 0, 0)), k = Z.getBezierPoints(10, u, s[2], y), b = S.Add(s[3], new S(i, 0, 0)), v = S.Sub(s[3], new S(0, r, 0)), g = Z.getBezierPoints(10, b, s[3], v), L = i * (1 - this.ratio) * 10, N = r * (1 - this.ratio) * 10;
2627
+ const o = z(this.tmpPoints), s = this.transformControlPoints(t), i = Math.floor(o.w * 0.1), r = Math.floor(o.h * 0.1), a = [], c = k.Add(s[0], new k(0, r, 0)), l = k.Add(s[0], new k(i, 0, 0)), h = Z.getBezierPoints(10, c, s[0], l), p = k.Sub(s[1], new k(i, 0, 0)), u = k.Add(s[1], new k(0, r, 0)), d = Z.getBezierPoints(10, p, s[1], u), f = k.Sub(s[2], new k(0, r, 0)), w = k.Sub(s[2], new k(i, 0, 0)), S = Z.getBezierPoints(10, f, s[2], w), b = k.Add(s[3], new k(i, 0, 0)), I = k.Sub(s[3], new k(0, r, 0)), g = Z.getBezierPoints(10, b, s[3], I), L = i * (1 - this.ratio) * 10, v = r * (1 - this.ratio) * 10;
2630
2628
  switch (t) {
2631
2629
  case "bottom": {
2632
- const T = S.Sub(s[2], new S(i * 5 - L / 2, 0, 0)), x = S.Sub(s[2], new S(i * 5, -N, 0)), M = S.Sub(s[2], new S(i * 5 + L / 2, 0, 0));
2633
- a.push(x, M, ...g, ...h, ...d, ...k, T);
2630
+ const T = k.Sub(s[2], new k(i * 5 - L / 2, 0, 0)), x = k.Sub(s[2], new k(i * 5, -v, 0)), R = k.Sub(s[2], new k(i * 5 + L / 2, 0, 0));
2631
+ a.push(x, R, ...g, ...h, ...d, ...S, T);
2634
2632
  break;
2635
2633
  }
2636
2634
  case "bottomRight": {
2637
- const T = S.Sub(s[2], new S(i * 1.1, 0, 0)), x = S.Sub(s[2], new S(i * 1.1 + L / 2, -N, 0)), M = S.Sub(s[2], new S(i * 1.1 + L, 0, 0));
2638
- a.push(x, M, ...g, ...h, ...d, ...k, T);
2635
+ const T = k.Sub(s[2], new k(i * 1.1, 0, 0)), x = k.Sub(s[2], new k(i * 1.1 + L / 2, -v, 0)), R = k.Sub(s[2], new k(i * 1.1 + L, 0, 0));
2636
+ a.push(x, R, ...g, ...h, ...d, ...S, T);
2639
2637
  break;
2640
2638
  }
2641
2639
  case "bottomLeft": {
2642
- const T = S.Add(s[3], new S(i * 1.1 + L, 0, 0)), x = S.Add(s[3], new S(i * 1.1 + L / 2, N, 0)), M = S.Add(s[3], new S(i * 1.1, 0, 0));
2643
- a.push(x, M, ...g, ...h, ...d, ...k, T);
2640
+ const T = k.Add(s[3], new k(i * 1.1 + L, 0, 0)), x = k.Add(s[3], new k(i * 1.1 + L / 2, v, 0)), R = k.Add(s[3], new k(i * 1.1, 0, 0));
2641
+ a.push(x, R, ...g, ...h, ...d, ...S, T);
2644
2642
  break;
2645
2643
  }
2646
2644
  case "top": {
2647
- const T = S.Sub(s[1], new S(i * 5 - L / 2, 0, 0)), x = S.Sub(s[1], new S(i * 5, N, 0)), M = S.Sub(s[1], new S(i * 5 + L / 2, 0, 0));
2648
- a.push(x, T, ...d, ...k, ...g, ...h, M);
2645
+ const T = k.Sub(s[1], new k(i * 5 - L / 2, 0, 0)), x = k.Sub(s[1], new k(i * 5, v, 0)), R = k.Sub(s[1], new k(i * 5 + L / 2, 0, 0));
2646
+ a.push(x, T, ...d, ...S, ...g, ...h, R);
2649
2647
  break;
2650
2648
  }
2651
2649
  case "topRight": {
2652
- const T = S.Sub(s[1], new S(i * 1.1, 0, 0)), x = S.Sub(s[1], new S(i * 1.1 + L / 2, N, 0)), M = S.Sub(s[1], new S(i * 1.1 + L, 0, 0));
2653
- a.push(x, T, ...d, ...k, ...g, ...h, M);
2650
+ const T = k.Sub(s[1], new k(i * 1.1, 0, 0)), x = k.Sub(s[1], new k(i * 1.1 + L / 2, v, 0)), R = k.Sub(s[1], new k(i * 1.1 + L, 0, 0));
2651
+ a.push(x, T, ...d, ...S, ...g, ...h, R);
2654
2652
  break;
2655
2653
  }
2656
2654
  case "topLeft": {
2657
- const T = S.Add(s[0], new S(i * 1.1 + L, 0, 0)), x = S.Add(s[0], new S(i * 1.1 + L / 2, -N, 0)), M = S.Add(s[0], new S(i * 1.1, 0, 0));
2658
- a.push(x, T, ...d, ...k, ...g, ...h, M);
2655
+ const T = k.Add(s[0], new k(i * 1.1 + L, 0, 0)), x = k.Add(s[0], new k(i * 1.1 + L / 2, -v, 0)), R = k.Add(s[0], new k(i * 1.1, 0, 0));
2656
+ a.push(x, T, ...d, ...S, ...g, ...h, R);
2659
2657
  break;
2660
2658
  }
2661
2659
  case "left": {
2662
- const T = S.Add(s[0], new S(0, r * 5 - N / 2, 0)), x = S.Add(s[0], new S(-L, r * 5, 0)), M = S.Add(s[0], new S(0, r * 5 + N / 2, 0));
2663
- a.push(x, T, ...h, ...d, ...k, ...g, M);
2660
+ const T = k.Add(s[0], new k(0, r * 5 - v / 2, 0)), x = k.Add(s[0], new k(-L, r * 5, 0)), R = k.Add(s[0], new k(0, r * 5 + v / 2, 0));
2661
+ a.push(x, T, ...h, ...d, ...S, ...g, R);
2664
2662
  break;
2665
2663
  }
2666
2664
  case "leftTop": {
2667
- const T = S.Add(s[0], new S(0, r * 1.1, 0)), x = S.Add(s[0], new S(-L, r * 1.1 + N / 2, 0)), M = S.Add(s[0], new S(0, r * 1.1 + N, 0));
2668
- a.push(x, T, ...h, ...d, ...k, ...g, M);
2665
+ const T = k.Add(s[0], new k(0, r * 1.1, 0)), x = k.Add(s[0], new k(-L, r * 1.1 + v / 2, 0)), R = k.Add(s[0], new k(0, r * 1.1 + v, 0));
2666
+ a.push(x, T, ...h, ...d, ...S, ...g, R);
2669
2667
  break;
2670
2668
  }
2671
2669
  case "leftBottom": {
2672
- const T = S.Sub(s[3], new S(0, r * 1.1 + N, 0)), x = S.Sub(s[3], new S(L, r * 1.1 + N / 2, 0)), M = S.Sub(s[3], new S(0, r * 1.1, 0));
2673
- a.push(x, T, ...h, ...d, ...k, ...g, M);
2670
+ const T = k.Sub(s[3], new k(0, r * 1.1 + v, 0)), x = k.Sub(s[3], new k(L, r * 1.1 + v / 2, 0)), R = k.Sub(s[3], new k(0, r * 1.1, 0));
2671
+ a.push(x, T, ...h, ...d, ...S, ...g, R);
2674
2672
  break;
2675
2673
  }
2676
2674
  case "right": {
2677
- const T = S.Add(s[1], new S(0, r * 5 - N / 2, 0)), x = S.Add(s[1], new S(L, r * 5, 0)), M = S.Add(s[1], new S(0, r * 5 + N / 2, 0));
2678
- a.push(x, M, ...k, ...g, ...h, ...d, T);
2675
+ const T = k.Add(s[1], new k(0, r * 5 - v / 2, 0)), x = k.Add(s[1], new k(L, r * 5, 0)), R = k.Add(s[1], new k(0, r * 5 + v / 2, 0));
2676
+ a.push(x, R, ...S, ...g, ...h, ...d, T);
2679
2677
  break;
2680
2678
  }
2681
2679
  case "rightTop": {
2682
- const T = S.Add(s[1], new S(0, r * 1.1, 0)), x = S.Add(s[1], new S(L, r * 1.1 + N / 2, 0)), M = S.Add(s[1], new S(0, r * 1.1 + N, 0));
2683
- a.push(x, M, ...k, ...g, ...h, ...d, T);
2680
+ const T = k.Add(s[1], new k(0, r * 1.1, 0)), x = k.Add(s[1], new k(L, r * 1.1 + v / 2, 0)), R = k.Add(s[1], new k(0, r * 1.1 + v, 0));
2681
+ a.push(x, R, ...S, ...g, ...h, ...d, T);
2684
2682
  break;
2685
2683
  }
2686
2684
  case "rightBottom": {
2687
- const T = S.Sub(s[2], new S(0, r * 1.1 + N, 0)), x = S.Sub(s[2], new S(-L, r * 1.1 + N / 2, 0)), M = S.Sub(s[2], new S(0, r * 1.1, 0));
2688
- a.push(x, M, ...k, ...g, ...h, ...d, T);
2685
+ const T = k.Sub(s[2], new k(0, r * 1.1 + v, 0)), x = k.Sub(s[2], new k(-L, r * 1.1 + v / 2, 0)), R = k.Sub(s[2], new k(0, r * 1.1, 0));
2686
+ a.push(x, R, ...S, ...g, ...h, ...d, T);
2689
2687
  break;
2690
2688
  }
2691
2689
  }
2692
- const I = z(this.tmpPoints, e), A = [Math.floor(I.x + I.w / 2), Math.floor(I.y + I.h / 2)];
2690
+ const W = z(this.tmpPoints, e), D = [Math.floor(W.x + W.w / 2), Math.floor(W.y + W.h / 2)];
2693
2691
  return {
2694
- rect: I,
2695
- pos: A,
2692
+ rect: W,
2693
+ pos: D,
2696
2694
  points: a
2697
2695
  };
2698
2696
  }
@@ -2724,7 +2722,7 @@ class Ot extends W {
2724
2722
  toolsType: this.toolsType,
2725
2723
  scaleType: this.scaleType,
2726
2724
  canRotate: this.canRotate,
2727
- centerPos: r && W.getCenterPos(r, i)
2725
+ centerPos: r && N.getCenterPos(r, i)
2728
2726
  }), r;
2729
2727
  }
2730
2728
  clearTmpPoints() {
@@ -2733,14 +2731,14 @@ class Ot extends W {
2733
2731
  static updateNodeOpt(e) {
2734
2732
  const { node: t, opt: o, vNodes: s } = e, { strokeColor: i, fillColor: r, toolsType: a, placement: c } = o, l = s.get(t.name), h = l == null ? void 0 : l.opt;
2735
2733
  let p = t;
2736
- return t.tagName === "GROUP" && (p = t.children[0]), i && (p.setAttribute("strokeColor", i), h != null && h.strokeColor && (h.strokeColor = i)), r && (r === "transparent" ? p.setAttribute("fillColor", "rgba(0,0,0,0)") : p.setAttribute("fillColor", r), h != null && h.fillColor && (h.fillColor = r)), a === P.SpeechBalloon && c && (h.placement = c), l && s.setInfo(t.name, { ...l, opt: h }), W.updateNodeOpt(e);
2734
+ return t.tagName === "GROUP" && (p = t.children[0]), i && (p.setAttribute("strokeColor", i), h != null && h.strokeColor && (h.strokeColor = i)), r && (r === "transparent" ? p.setAttribute("fillColor", "rgba(0,0,0,0)") : p.setAttribute("fillColor", r), h != null && h.fillColor && (h.fillColor = r)), a === P.SpeechBalloon && c && (h.placement = c), l && s.setInfo(t.name, { ...l, opt: h }), N.updateNodeOpt(e);
2737
2735
  }
2738
2736
  }
2739
- class ut extends W {
2737
+ class ut extends N {
2740
2738
  constructor(e) {
2741
2739
  super(e);
2742
2740
  m(this, "canRotate", !0);
2743
- m(this, "scaleType", U.all);
2741
+ m(this, "scaleType", X.all);
2744
2742
  m(this, "toolsType", P.Image);
2745
2743
  m(this, "tmpPoints", []);
2746
2744
  m(this, "workOptions");
@@ -2748,50 +2746,51 @@ class ut extends W {
2748
2746
  this.workOptions = e.toolsOpt, this.scaleType = ut.getScaleType(this.workOptions);
2749
2747
  }
2750
2748
  consume() {
2751
- return { type: w.None };
2749
+ return { type: y.None };
2752
2750
  }
2753
2751
  consumeAll() {
2754
- return { type: w.None };
2752
+ return { type: y.None };
2755
2753
  }
2756
2754
  draw(e) {
2757
- const { layer: t, workId: o, replaceId: s, imageBitmap: i, isMainThread: r } = e, { centerX: a, centerY: c, width: l, height: h, rotate: p, zIndex: f } = this.workOptions, d = {
2755
+ const { layer: t, workId: o, replaceId: s, imageBitmap: i, isMainThread: r } = e, { centerX: a, centerY: c, width: l, height: h, rotate: p, zIndex: u } = this.workOptions, d = !!t.parent.gl, f = {
2758
2756
  anchor: [0.5, 0.5],
2759
2757
  pos: [a, c],
2760
2758
  name: o,
2761
2759
  size: [l, h],
2762
- zIndex: f,
2763
- rotate: !r && 180 + (p || 0) || p,
2760
+ zIndex: u,
2761
+ rotate: !r && !d && 180 + (p || 0) || p,
2762
+ // rotate,
2764
2763
  texture: i
2765
- }, u = new jt(d);
2766
- this.replace(t, s || o, u);
2767
- const y = u.getBoundingClientRect();
2768
- if (y)
2764
+ }, w = new jt(f);
2765
+ this.replace(t, s || o, w);
2766
+ const S = w.getBoundingClientRect();
2767
+ if (S)
2769
2768
  return {
2770
- x: Math.floor(y.x - W.SafeBorderPadding),
2771
- y: Math.floor(y.y - W.SafeBorderPadding),
2772
- w: Math.floor(y.width + W.SafeBorderPadding * 2),
2773
- h: Math.floor(y.height + W.SafeBorderPadding * 2)
2769
+ x: Math.floor(S.x - N.SafeBorderPadding),
2770
+ y: Math.floor(S.y - N.SafeBorderPadding),
2771
+ w: Math.floor(S.width + N.SafeBorderPadding * 2),
2772
+ h: Math.floor(S.height + N.SafeBorderPadding * 2)
2774
2773
  };
2775
2774
  }
2776
2775
  consumeService() {
2777
2776
  }
2778
2777
  async consumeServiceAsync(e) {
2779
- var h, p, f, d;
2778
+ var h, p, u, d;
2780
2779
  const { isFullWork: t, replaceId: o, scene: s, isMainThread: i } = e, { src: r, uuid: a } = this.workOptions, c = ((h = this.workId) == null ? void 0 : h.toString()) || a, l = t ? this.fullLayer : this.drawLayer || this.fullLayer;
2781
2780
  if (r) {
2782
- const u = await s.preload({
2781
+ const f = await s.preload({
2783
2782
  id: a,
2784
2783
  src: this.workOptions.src
2785
- }), y = this.draw({ workId: c, layer: l, replaceId: o, imageBitmap: u[0], isMainThread: i });
2786
- return this.oldRect = c && ((f = (p = this.vNodes) == null ? void 0 : p.get(c)) == null ? void 0 : f.rect) || void 0, (d = this.vNodes) == null || d.setInfo(c, {
2787
- rect: y,
2784
+ }), w = this.draw({ workId: c, layer: l, replaceId: o, imageBitmap: f[0], isMainThread: i });
2785
+ return this.oldRect = c && ((u = (p = this.vNodes) == null ? void 0 : p.get(c)) == null ? void 0 : u.rect) || void 0, (d = this.vNodes) == null || d.setInfo(c, {
2786
+ rect: w,
2788
2787
  op: [],
2789
2788
  opt: this.workOptions,
2790
2789
  toolsType: this.toolsType,
2791
2790
  scaleType: this.scaleType,
2792
2791
  canRotate: this.canRotate,
2793
- centerPos: y && W.getCenterPos(y, l)
2794
- }), y;
2792
+ centerPos: w && N.getCenterPos(w, l)
2793
+ }), w;
2795
2794
  }
2796
2795
  }
2797
2796
  clearTmpPoints() {
@@ -2799,48 +2798,57 @@ class ut extends W {
2799
2798
  }
2800
2799
  static getScaleType(e) {
2801
2800
  const { uniformScale: t, rotate: o } = e;
2802
- return t !== !1 ? U.proportional : o && Math.abs(o) % 90 > 0 ? U.proportional : U.all;
2801
+ return t !== !1 ? X.proportional : o && Math.abs(o) % 90 > 0 ? X.proportional : X.all;
2803
2802
  }
2804
2803
  static updateNodeOpt(e) {
2805
- const { node: t, opt: o, vNodes: s, targetNode: i } = e, { translate: r, box: a, boxScale: c, boxTranslate: l, angle: h, isLocked: p, zIndex: f } = o, d = i && tt(i) || s.get(t.name);
2804
+ const { node: t, opt: o, vNodes: s, targetNode: i } = e, { translate: r, box: a, boxScale: c, boxTranslate: l, angle: h, isLocked: p, zIndex: u } = o, d = i && tt(i) || s.get(t.name);
2806
2805
  if (!d)
2807
2806
  return;
2808
- const u = t.parent;
2809
- if (u) {
2810
- if (V(f) && (t.setAttribute("zIndex", f), d.opt.zIndex = f), ot(p) && (d.opt.locked = p), a && l && c) {
2811
- const { centerX: y, centerY: k, width: b, height: v, uniformScale: g, rotate: L } = d.opt, N = Math.min(c[0], c[1]), I = g !== !1 ? [N, N] : c, A = Xt({
2812
- x: y - b / 2,
2813
- y: k - v / 2,
2807
+ const f = t.parent;
2808
+ if (f) {
2809
+ if (q(u) && (t.setAttribute("zIndex", u), d.opt.zIndex = u), ot(p) && (d.opt.locked = p), a && l && c) {
2810
+ const { centerX: w, centerY: S, width: b, height: I, uniformScale: g, rotate: L } = d.opt, v = Math.min(c[0], c[1]), W = g !== !1 ? [v, v] : c, D = Xt({
2811
+ x: w - b / 2,
2812
+ y: S - I / 2,
2814
2813
  w: b,
2815
- h: v
2816
- }, L || 0), T = Yt(A, new S(y, k), I), x = $t(T, new S(y, k), -(L || 0)), M = z(x);
2817
- d.opt.width = Math.round(M.w), d.opt.height = Math.round(M.h);
2818
- const $ = [l[0] / u.worldScaling[0], l[1] / u.worldScaling[1]];
2819
- d.opt.centerX = y + $[0], d.opt.centerY = k + $[1];
2820
- const F = [d.centerPos[0] + $[0], d.centerPos[1] + $[1]];
2814
+ h: I
2815
+ }, L || 0), T = Yt(D, new k(w, S), W), x = $t(T, new k(w, S), -(L || 0)), R = z(x);
2816
+ d.opt.width = Math.round(R.w), d.opt.height = Math.round(R.h);
2817
+ const U = [l[0] / f.worldScaling[0], l[1] / f.worldScaling[1]];
2818
+ d.opt.centerX = w + U[0], d.opt.centerY = S + U[1];
2819
+ const F = [d.centerPos[0] + U[0], d.centerPos[1] + U[1]];
2821
2820
  if (d.centerPos = F, i) {
2822
- let q = It(d.rect, c);
2823
- q = pt(q, $), d.rect = q;
2821
+ let H = It(d.rect, c);
2822
+ H = pt(H, U), d.rect = H;
2823
+ } else {
2824
+ const H = N.getRectFromLayer(f, t.name);
2825
+ d.rect = H || d.rect;
2824
2826
  }
2825
- } else if (r) {
2826
- const y = [r[0] / u.worldScaling[0], r[1] / u.worldScaling[1]];
2827
- if (d.opt.centerX = d.opt.centerX + y[0], d.opt.centerY = d.opt.centerY + y[1], d.centerPos = [d.centerPos[0] + y[0], d.centerPos[1] + y[1]], i) {
2828
- const k = pt(d.rect, y);
2829
- d.rect = k;
2827
+ } else if (r)
2828
+ if (d.opt.centerX = d.opt.centerX + r[0], d.opt.centerY = d.opt.centerY + r[1], d.centerPos = [d.centerPos[0] + r[0], d.centerPos[1] + r[1]], i) {
2829
+ const w = [r[0] * f.worldScaling[0], r[1] * f.worldScaling[1]], S = pt(d.rect, w);
2830
+ d.rect = S;
2831
+ } else {
2832
+ const w = N.getRectFromLayer(f, t.name);
2833
+ d.rect = w || d.rect;
2834
+ }
2835
+ else if (q(h))
2836
+ if (d.opt.rotate = h, d.scaleType = ut.getScaleType(d.opt), i) {
2837
+ const w = Tt(d.rect, h);
2838
+ d.rect = w;
2839
+ } else {
2840
+ const w = N.getRectFromLayer(f, t.name);
2841
+ d.rect = w || d.rect;
2830
2842
  }
2831
- } else if (V(h) && (d.opt.rotate = h, d.scaleType = ut.getScaleType(d.opt), i)) {
2832
- const y = Tt(d.rect, h);
2833
- d.rect = y;
2834
- }
2835
2843
  return d && s.setInfo(t.name, d), d == null ? void 0 : d.rect;
2836
2844
  }
2837
2845
  }
2838
2846
  }
2839
- class Dt extends W {
2847
+ class Dt extends N {
2840
2848
  constructor(e) {
2841
2849
  super(e);
2842
2850
  m(this, "canRotate", !1);
2843
- m(this, "scaleType", U.both);
2851
+ m(this, "scaleType", X.both);
2844
2852
  m(this, "toolsType", P.Straight);
2845
2853
  m(this, "tmpPoints", []);
2846
2854
  m(this, "workOptions");
@@ -2853,33 +2861,33 @@ class Dt extends W {
2853
2861
  var d;
2854
2862
  const { data: t, isFullWork: o, isSubWorker: s, isMainThread: i } = e, r = (d = t == null ? void 0 : t.workId) == null ? void 0 : d.toString();
2855
2863
  if (!r)
2856
- return { type: w.None };
2864
+ return { type: y.None };
2857
2865
  const { op: a, workState: c } = t, l = a == null ? void 0 : a.length;
2858
2866
  if (!l || l < 2)
2859
- return { type: w.None };
2867
+ return { type: y.None };
2860
2868
  let h;
2861
- if (c === D.Start ? (this.tmpPoints = [new O(a[0], a[1])], h = !1) : h = this.updateTempPoints(a), !h)
2862
- return { type: w.None };
2869
+ if (c === A.Start ? (this.tmpPoints = [new O(a[0], a[1])], h = !1) : h = this.updateTempPoints(a), !h)
2870
+ return { type: y.None };
2863
2871
  let p;
2864
2872
  if (s || i) {
2865
- const u = o ? this.fullLayer : this.drawLayer || this.fullLayer;
2866
- p = this.draw({ workId: r, layer: u });
2873
+ const f = o ? this.fullLayer : this.drawLayer || this.fullLayer;
2874
+ p = this.draw({ workId: r, layer: f });
2867
2875
  }
2868
2876
  if (!s) {
2869
- const u = Date.now();
2870
- return u - this.syncTimestamp > this.syncUnitTime ? (this.syncTimestamp = u, {
2871
- type: w.DrawWork,
2877
+ const f = Date.now();
2878
+ return f - this.syncTimestamp > this.syncUnitTime ? (this.syncTimestamp = f, {
2879
+ type: y.DrawWork,
2872
2880
  dataType: C.Local,
2873
2881
  workId: r,
2874
- op: this.tmpPoints.map((y) => [...y.XY, 0]).flat(1),
2882
+ op: this.tmpPoints.map((w) => [...w.XY, 0]).flat(1),
2875
2883
  isSync: !0,
2876
2884
  index: 0
2877
- }) : { type: w.None };
2885
+ }) : { type: y.None };
2878
2886
  }
2879
- const f = B(p, this.oldRect);
2887
+ const u = B(p, this.oldRect);
2880
2888
  return this.oldRect = p, {
2881
- rect: f,
2882
- type: w.DrawWork,
2889
+ rect: u,
2890
+ type: y.DrawWork,
2883
2891
  dataType: C.Local,
2884
2892
  workId: r
2885
2893
  };
@@ -2888,10 +2896,10 @@ class Dt extends W {
2888
2896
  var c, l;
2889
2897
  const { data: t } = e, o = (c = t == null ? void 0 : t.workId) == null ? void 0 : c.toString();
2890
2898
  if (!o)
2891
- return { type: w.None };
2899
+ return { type: y.None };
2892
2900
  if (this.tmpPoints.length < 2)
2893
2901
  return {
2894
- type: w.RemoveNode,
2902
+ type: y.RemoveNode,
2895
2903
  removeIds: [o]
2896
2904
  };
2897
2905
  const s = this.fullLayer, i = this.draw({ workId: o, layer: s });
@@ -2904,10 +2912,10 @@ class Dt extends W {
2904
2912
  toolsType: this.toolsType,
2905
2913
  scaleType: this.scaleType,
2906
2914
  canRotate: this.canRotate,
2907
- centerPos: i && W.getCenterPos(i, s)
2915
+ centerPos: i && N.getCenterPos(i, s)
2908
2916
  }), {
2909
2917
  rect: i,
2910
- type: w.FullWork,
2918
+ type: y.FullWork,
2911
2919
  dataType: C.Local,
2912
2920
  workId: o,
2913
2921
  ops: a,
@@ -2916,44 +2924,44 @@ class Dt extends W {
2916
2924
  };
2917
2925
  }
2918
2926
  draw(e) {
2919
- const { workId: t, layer: o } = e, { strokeColor: s, thickness: i, zIndex: r, scale: a, rotate: c, translate: l } = this.workOptions, h = o.worldPosition, p = o.worldScaling, { d: f, rect: d } = this.computDrawPoints(i), u = [
2927
+ const { workId: t, layer: o } = e, { strokeColor: s, thickness: i, zIndex: r, scale: a, rotate: c, translate: l } = this.workOptions, h = o.worldPosition, p = o.worldScaling, { d: u, rect: d } = this.computDrawPoints(i), f = [
2920
2928
  d.x + d.w / 2,
2921
2929
  d.y + d.h / 2
2922
- ], y = {
2923
- pos: u,
2930
+ ], w = {
2931
+ pos: f,
2924
2932
  name: t,
2925
2933
  id: t,
2926
- d: f,
2934
+ d: u,
2927
2935
  fillColor: s,
2928
2936
  strokeColor: s,
2929
2937
  lineWidth: 0,
2930
- className: `${u[0]},${u[1]}`,
2938
+ className: `${f[0]},${f[1]}`,
2931
2939
  normalize: !0,
2932
2940
  zIndex: r
2933
2941
  };
2934
- a && (y.scale = a), c && (y.rotate = c), l && (y.translate = l);
2935
- const k = new it(y);
2936
- if (this.replace(o, t, k), c || a || l) {
2937
- const v = k.getBoundingClientRect();
2942
+ a && (w.scale = a), c && (w.rotate = c), l && (w.translate = l);
2943
+ const S = new it(w);
2944
+ if (this.replace(o, t, S), c || a || l) {
2945
+ const I = S.getBoundingClientRect();
2938
2946
  return {
2939
- x: Math.floor(v.x - W.SafeBorderPadding),
2940
- y: Math.floor(v.y - W.SafeBorderPadding),
2941
- w: Math.floor(v.width + W.SafeBorderPadding * 2),
2942
- h: Math.floor(v.height + W.SafeBorderPadding * 2)
2947
+ x: Math.floor(I.x - N.SafeBorderPadding),
2948
+ y: Math.floor(I.y - N.SafeBorderPadding),
2949
+ w: Math.floor(I.width + N.SafeBorderPadding * 2),
2950
+ h: Math.floor(I.height + N.SafeBorderPadding * 2)
2943
2951
  };
2944
2952
  }
2945
2953
  return {
2946
- x: Math.floor(d.x * p[0] + h[0] - W.SafeBorderPadding),
2947
- y: Math.floor(d.y * p[1] + h[1] - W.SafeBorderPadding),
2948
- w: Math.floor(d.w * p[0] + 2 * W.SafeBorderPadding),
2949
- h: Math.floor(d.h * p[1] + 2 * W.SafeBorderPadding)
2954
+ x: Math.floor(d.x * p[0] + h[0] - N.SafeBorderPadding),
2955
+ y: Math.floor(d.y * p[1] + h[1] - N.SafeBorderPadding),
2956
+ w: Math.floor(d.w * p[0] + 2 * N.SafeBorderPadding),
2957
+ h: Math.floor(d.h * p[1] + 2 * N.SafeBorderPadding)
2950
2958
  };
2951
2959
  }
2952
2960
  computDrawPoints(e) {
2953
2961
  return this.tmpPoints[1].distance(this.tmpPoints[0]) > this.straightTipWidth ? this.computFullPoints(e) : this.computDotPoints(e);
2954
2962
  }
2955
2963
  computFullPoints(e) {
2956
- const t = S.Sub(this.tmpPoints[1], this.tmpPoints[0]).uni(), o = S.Per(t).mul(e / 2), s = O.Sub(this.tmpPoints[0], o), i = O.Add(this.tmpPoints[0], o), r = O.Sub(this.tmpPoints[1], o), a = O.Add(this.tmpPoints[1], o), c = O.GetSemicircleStroke(this.tmpPoints[1], r, -1, 8), l = O.GetSemicircleStroke(this.tmpPoints[0], i, -1, 8), h = [s, r, ...c, a, i, ...l];
2964
+ const t = k.Sub(this.tmpPoints[1], this.tmpPoints[0]).uni(), o = k.Per(t).mul(e / 2), s = O.Sub(this.tmpPoints[0], o), i = O.Add(this.tmpPoints[0], o), r = O.Sub(this.tmpPoints[1], o), a = O.Add(this.tmpPoints[1], o), c = O.GetSemicircleStroke(this.tmpPoints[1], r, -1, 8), l = O.GetSemicircleStroke(this.tmpPoints[0], i, -1, 8), h = [s, r, ...c, a, i, ...l];
2957
2965
  return {
2958
2966
  d: lt(h, !0),
2959
2967
  rect: z(h),
@@ -2998,7 +3006,7 @@ class Dt extends W {
2998
3006
  toolsType: this.toolsType,
2999
3007
  scaleType: this.scaleType,
3000
3008
  canRotate: this.canRotate,
3001
- centerPos: r && W.getCenterPos(r, i)
3009
+ centerPos: r && N.getCenterPos(r, i)
3002
3010
  }), r;
3003
3011
  }
3004
3012
  clearTmpPoints() {
@@ -3007,14 +3015,14 @@ class Dt extends W {
3007
3015
  static updateNodeOpt(e) {
3008
3016
  var a;
3009
3017
  const { node: t, opt: o, vNodes: s } = e, { strokeColor: i } = o, r = s.get(t.name);
3010
- return i && (t.setAttribute("strokeColor", i), t.setAttribute("fillColor", i), (a = r == null ? void 0 : r.opt) != null && a.strokeColor && (r.opt.strokeColor = i)), r && s.setInfo(t.name, r), W.updateNodeOpt(e);
3018
+ return i && (t.setAttribute("strokeColor", i), t.setAttribute("fillColor", i), (a = r == null ? void 0 : r.opt) != null && a.strokeColor && (r.opt.strokeColor = i)), r && s.setInfo(t.name, r), N.updateNodeOpt(e);
3011
3019
  }
3012
3020
  }
3013
- class ft extends W {
3021
+ class yt extends N {
3014
3022
  constructor(e) {
3015
3023
  super(e);
3016
3024
  m(this, "canRotate", !1);
3017
- m(this, "scaleType", U.all);
3025
+ m(this, "scaleType", X.all);
3018
3026
  m(this, "toolsType", P.Text);
3019
3027
  m(this, "tmpPoints", []);
3020
3028
  m(this, "workOptions");
@@ -3023,12 +3031,12 @@ class ft extends W {
3023
3031
  }
3024
3032
  consume() {
3025
3033
  return {
3026
- type: w.None
3034
+ type: y.None
3027
3035
  };
3028
3036
  }
3029
3037
  consumeAll() {
3030
3038
  return {
3031
- type: w.None
3039
+ type: y.None
3032
3040
  };
3033
3041
  }
3034
3042
  consumeService() {
@@ -3045,23 +3053,25 @@ class ft extends W {
3045
3053
  size: i,
3046
3054
  zIndex: a
3047
3055
  // bgcolor:"rgba(109,212,0,0.5)"
3048
- }, p = new _(h), f = {
3056
+ }, p = new _(h), u = {
3049
3057
  x: r[0],
3050
3058
  y: r[1],
3051
3059
  w: i[0],
3052
3060
  h: i[1]
3053
- }, d = new St({
3061
+ }, d = new kt({
3054
3062
  normalize: !0,
3055
3063
  pos: [0, 0],
3056
3064
  size: i
3057
- }), u = s && ft.createLabels(this.workOptions, o) || [];
3058
- return p.append(...u, d), this.replace(o, t, p), s && (await new Promise((y) => {
3059
- setTimeout(y, 0);
3060
- }), this.updateLabelsWidth(p)), {
3061
- x: Math.floor(f.x * l[0] + c[0]),
3062
- y: Math.floor(f.y * l[1] + c[1]),
3063
- w: Math.floor(f.w * l[0]),
3064
- h: Math.floor(f.h * l[1])
3065
+ });
3066
+ if (p.append(d), s) {
3067
+ const f = s && await yt.createLabels(this.workOptions, p, o) || [];
3068
+ p.append(...f);
3069
+ }
3070
+ return this.replace(o, t, p), {
3071
+ x: Math.floor(u.x * l[0] + c[0]),
3072
+ y: Math.floor(u.y * l[1] + c[1]),
3073
+ w: Math.floor(u.w * l[0]),
3074
+ h: Math.floor(u.h * l[1])
3065
3075
  };
3066
3076
  }
3067
3077
  async consumeServiceAsync(e) {
@@ -3071,7 +3081,7 @@ class ft extends W {
3071
3081
  return;
3072
3082
  const { isFullWork: o, replaceId: s, isDrawLabel: i } = e;
3073
3083
  this.oldRect = s && ((h = (l = this.vNodes) == null ? void 0 : l.get(s)) == null ? void 0 : h.rect) || void 0;
3074
- const r = o ? this.fullLayer : this.drawLayer || this.fullLayer, a = await this.draw({ workId: t, layer: r, isDrawLabel: i || this.workOptions.workState === D.Done });
3084
+ const r = o ? this.fullLayer : this.drawLayer || this.fullLayer, a = await this.draw({ workId: t, layer: r, isDrawLabel: i || this.workOptions.workState === A.Done });
3075
3085
  return (p = this.vNodes) == null || p.setInfo(t, {
3076
3086
  rect: a,
3077
3087
  op: [],
@@ -3079,35 +3089,23 @@ class ft extends W {
3079
3089
  toolsType: this.toolsType,
3080
3090
  scaleType: this.scaleType,
3081
3091
  canRotate: this.canRotate,
3082
- centerPos: a && W.getCenterPos(a, r)
3092
+ centerPos: a && N.getCenterPos(a, r)
3083
3093
  }), a;
3084
3094
  }
3085
- updateLabelsWidth(e) {
3086
- e.children.forEach((t) => {
3087
- if (t.tagName === "LABEL") {
3088
- const o = t.name, { width: s } = t.getBoundingClientRect(), [i] = e.worldScaling, { underline: r, lineThrough: a } = this.getWorkOptions();
3089
- r && e.getElementsByName(`${o}_underline`)[0].attr({
3090
- points: [0, 0, s / i, 0]
3091
- }), a && e.getElementsByName(`${o}_lineThrough`)[0].attr({
3092
- points: [0, 0, s / i, 0]
3093
- });
3094
- }
3095
- });
3096
- }
3097
3095
  updataOptService() {
3098
3096
  }
3099
3097
  async updataOptServiceAsync(e) {
3100
- var f, d;
3098
+ var u, d;
3101
3099
  if (!this.workId)
3102
3100
  return;
3103
- const t = this.workId.toString(), { fontColor: o, fontBgColor: s, bold: i, italic: r, lineThrough: a, underline: c, zIndex: l } = e, h = (f = this.vNodes) == null ? void 0 : f.get(t);
3101
+ const t = this.workId.toString(), { fontColor: o, fontBgColor: s, bold: i, italic: r, lineThrough: a, underline: c, zIndex: l } = e, h = (u = this.vNodes) == null ? void 0 : u.get(t);
3104
3102
  if (!h)
3105
3103
  return;
3106
- o && (h.opt.fontColor = o), s && (h.opt.fontBgColor = s), i && (h.opt.bold = i), r && (h.opt.italic = r), ot(a) && (h.opt.lineThrough = a), ot(c) && (h.opt.underline = c), s && (h.opt.fontBgColor = s), V(l) && (h.opt.zIndex = l), this.oldRect = h.rect;
3104
+ o && (h.opt.fontColor = o), s && (h.opt.fontBgColor = s), i && (h.opt.bold = i), r && (h.opt.italic = r), ot(a) && (h.opt.lineThrough = a), ot(c) && (h.opt.underline = c), q(l) && (h.opt.zIndex = l), this.oldRect = h.rect;
3107
3105
  const p = await this.draw({
3108
3106
  workId: t,
3109
3107
  layer: this.fullLayer,
3110
- isDrawLabel: this.workOptions.workState === D.Done
3108
+ isDrawLabel: this.workOptions.workState === A.Done
3111
3109
  });
3112
3110
  return (d = this.vNodes) == null || d.setInfo(t, {
3113
3111
  rect: p,
@@ -3116,71 +3114,88 @@ class ft extends W {
3116
3114
  toolsType: this.toolsType,
3117
3115
  scaleType: this.scaleType,
3118
3116
  canRotate: this.canRotate,
3119
- centerPos: p && W.getCenterPos(p, this.fullLayer)
3117
+ centerPos: p && N.getCenterPos(p, this.fullLayer)
3120
3118
  }), p;
3121
3119
  }
3122
3120
  clearTmpPoints() {
3123
3121
  this.tmpPoints.length = 0;
3124
3122
  }
3125
- static getFontWidth(e) {
3126
- const { ctx: t, opt: o, text: s } = e, { bold: i, italic: r, fontSize: a, fontFamily: c } = o;
3127
- return t.font = `${i} ${r} ${a}px ${c}`, t.measureText(s).width;
3128
- }
3129
- static createLabels(e, t) {
3130
- const o = [], s = e.text.split(","), i = s.length;
3131
- for (let r = 0; r < i; r++) {
3132
- const a = s[r], { fontSize: c, lineHeight: l, bold: h, textAlign: p, italic: f, boxSize: d, fontFamily: u, verticalAlign: y, fontColor: k, underline: b, lineThrough: v } = e, g = l || c * 1.2, L = t && t.parent.canvas.getContext("2d"), N = L && ft.getFontWidth({ text: a, opt: e, ctx: L, worldScaling: t.worldScaling });
3133
- if (N) {
3134
- const I = {
3123
+ static async createLabels(e, t, o) {
3124
+ const s = [], i = e.text.split(","), r = i.length, { fontSize: a, lineHeight: c, bold: l, textAlign: h, italic: p, boxSize: u, fontFamily: d, verticalAlign: f, fontColor: w, fontBgColor: S, underline: b, lineThrough: I } = e, g = ((o == null ? void 0 : o.parent).displayRatio || 1) * ((o == null ? void 0 : o.worldScaling[0]) || 1), L = a * g;
3125
+ for (let v = 0; v < r; v++) {
3126
+ const W = i[v], D = c || L * 1.2;
3127
+ if (W) {
3128
+ const T = {
3135
3129
  anchor: [0, 0.5],
3136
- text: a,
3137
- fontSize: c,
3138
- lineHeight: g,
3139
- fontFamily: u,
3140
- fontWeight: h,
3141
- fillColor: k,
3142
- textAlign: p,
3143
- fontStyle: f,
3144
- name: r.toString(),
3145
- className: "label"
3146
- }, A = [0, 0];
3147
- if (y === "middle") {
3148
- const x = (i - 1) / 2;
3149
- A[1] = (r - x) * g;
3130
+ text: W,
3131
+ fontSize: L,
3132
+ lineHeight: D,
3133
+ fontFamily: d,
3134
+ fontWeight: l,
3135
+ fillColor: w,
3136
+ bgcolor: S,
3137
+ textAlign: h,
3138
+ fontStyle: p,
3139
+ name: v.toString(),
3140
+ className: "label",
3141
+ scale: [1 / g, 1 / g]
3142
+ }, x = [0, 0];
3143
+ if (f === "middle") {
3144
+ const U = (r - 1) / 2;
3145
+ x[1] = (v - U) * (c || a * 1.2);
3150
3146
  }
3151
- if (p === "left") {
3152
- const x = d && -d[0] / 2 || 0;
3153
- A[0] = f === "italic" && x || x + 5, console.log("text-left", A);
3147
+ if (h === "left") {
3148
+ const U = u && -u[0] / 2 || 0;
3149
+ x[0] = p === "italic" && U || U + 5;
3154
3150
  }
3155
- I.pos = A;
3156
- const T = new Zt(I);
3157
- if (o.push(T), b) {
3158
- const x = {
3159
- normalize: !1,
3160
- pos: [I.pos[0], I.pos[1] + c / 2],
3161
- lineWidth: Math.floor(c / 10),
3162
- points: [0, 0, N, 0],
3163
- strokeColor: k,
3164
- name: `${r}_underline`,
3165
- className: "underline"
3166
- }, M = new st(x);
3167
- o.push(M);
3168
- }
3169
- if (v) {
3170
- const x = {
3171
- normalize: !1,
3172
- pos: I.pos,
3173
- lineWidth: Math.floor(c / 10),
3174
- points: [0, 0, N, 0],
3175
- strokeColor: k,
3176
- name: `${r}_lineThrough`,
3177
- className: "lineThrough"
3178
- }, M = new st(x);
3179
- o.push(M);
3151
+ T.pos = x;
3152
+ const R = new Zt(T);
3153
+ s.push(R);
3154
+ }
3155
+ }
3156
+ if (await new Promise((v) => {
3157
+ setTimeout(v, 0);
3158
+ }), b || I) {
3159
+ const v = [], [W] = t.worldScaling;
3160
+ for (let D = 0; D < s.length; D++) {
3161
+ const { width: T } = s[D].getBoundingClientRect();
3162
+ if (T) {
3163
+ const x = s[D].getAttribute("pos");
3164
+ if (b) {
3165
+ const R = {
3166
+ normalize: !1,
3167
+ pos: [x[0], x[1] + a / 2],
3168
+ lineWidth: Math.floor(a / 10),
3169
+ points: [0, 0, T / W, 0],
3170
+ strokeColor: w,
3171
+ name: `${D}_underline`,
3172
+ className: "underline"
3173
+ }, U = new st(R);
3174
+ v.push(U);
3175
+ }
3176
+ if (I) {
3177
+ const R = {
3178
+ normalize: !1,
3179
+ pos: x,
3180
+ lineWidth: Math.floor(a / 10),
3181
+ points: [0, 0, T / W, 0],
3182
+ strokeColor: w,
3183
+ name: `${D}_lineThrough`,
3184
+ className: "lineThrough"
3185
+ }, U = new st(R);
3186
+ v.push(U);
3187
+ }
3180
3188
  }
3181
3189
  }
3190
+ return s.concat(v);
3182
3191
  }
3183
- return o;
3192
+ return s;
3193
+ }
3194
+ static async updateLabels(e, t, o) {
3195
+ const { fontSize: s } = e.opt, i = ((o == null ? void 0 : o.parent).displayRatio || 1) * ((o == null ? void 0 : o.worldScaling[0]) || 1), r = s * i;
3196
+ t.children.forEach((a) => {
3197
+ a.tagName === "LABEL" && (a.setAttribute("fontSize", r), a.setAttribute("scale", [1 / i, 1 / i]), a.setAttribute("lineHeight", r * 1.2));
3198
+ });
3184
3199
  }
3185
3200
  static updateNodeOpt(e) {
3186
3201
  const { node: t, opt: o, vNodes: s, targetNode: i } = e, {
@@ -3190,33 +3205,35 @@ class ft extends W {
3190
3205
  box: l,
3191
3206
  boxScale: h,
3192
3207
  boxTranslate: p,
3193
- bold: f,
3208
+ bold: u,
3194
3209
  italic: d,
3195
- lineThrough: u,
3196
- underline: y,
3197
- fontSize: k,
3210
+ lineThrough: f,
3211
+ underline: w,
3212
+ fontSize: S,
3198
3213
  textInfos: b,
3199
- zIndex: v
3214
+ zIndex: I
3200
3215
  } = o, g = i && tt(i) || s.get(t.name);
3201
3216
  if (!g)
3202
3217
  return;
3203
3218
  const L = t.parent;
3204
3219
  if (!L)
3205
3220
  return;
3206
- const N = g.opt;
3207
- if (V(v) && (t.setAttribute("zIndex", v), g.opt.zIndex = v), a && N.fontColor && (N.fontColor = a, t.children.forEach((I) => {
3208
- I.tagName === "LABEL" ? I.setAttribute("fillColor", a) : I.tagName === "POLYLINE" && I.setAttribute("strokeColor", a);
3209
- })), r && N.fontBgColor && (N.fontBgColor = r), f && (N.bold = f), d && (N.italic = d), ot(u) && (N.lineThrough = u), ot(y) && (N.underline = y), k && (N.fontSize = k), l && p && h) {
3210
- const I = b == null ? void 0 : b.get(t.name);
3211
- if (I) {
3212
- const { fontSize: x, boxSize: M } = I;
3213
- N.boxSize = M || N.boxSize, N.fontSize = x || N.fontSize;
3221
+ const v = g.opt;
3222
+ if (q(I) && (t.setAttribute("zIndex", I), g.opt.zIndex = I), a && v.fontColor && (v.fontColor = a, t.children.forEach((W) => {
3223
+ W.tagName === "LABEL" ? W.setAttribute("fillColor", a) : W.tagName === "POLYLINE" && W.setAttribute("strokeColor", a);
3224
+ })), r && v.fontBgColor && (v.fontBgColor = r, t.children.forEach((W) => {
3225
+ W.tagName === "LABEL" && W.setAttribute("bgcolor", r);
3226
+ })), u && (v.bold = u), d && (v.italic = d), ot(f) && (v.lineThrough = f), ot(w) && (v.underline = w), S && (v.fontSize = S), l && p && h) {
3227
+ const W = b == null ? void 0 : b.get(t.name);
3228
+ if (W) {
3229
+ const { fontSize: x, boxSize: R } = W;
3230
+ v.boxSize = R || v.boxSize, v.fontSize = x || v.fontSize;
3214
3231
  }
3215
- const A = g.rect, T = pt(It(A, h), p);
3216
- N.boxPoint = T && [(T.x - L.worldPosition[0]) / L.worldScaling[0], (T.y - L.worldPosition[1]) / L.worldScaling[1]];
3217
- } else if (c && N.boxPoint) {
3218
- const I = [c[0] / L.worldScaling[0], c[1] / L.worldScaling[1]];
3219
- N.boxPoint = [N.boxPoint[0] + I[0], N.boxPoint[1] + I[1]], g.centerPos = [g.centerPos[0] + I[0], g.centerPos[1] + I[1]], g.rect = pt(g.rect, I);
3232
+ const D = g.rect, T = pt(It(D, h), p);
3233
+ v.boxPoint = T && [(T.x - L.worldPosition[0]) / L.worldScaling[0], (T.y - L.worldPosition[1]) / L.worldScaling[1]];
3234
+ } else if (c && v.boxPoint && (v.boxPoint = [v.boxPoint[0] + c[0], v.boxPoint[1] + c[1]], g.centerPos = [g.centerPos[0] + c[0], g.centerPos[1] + c[1]], i)) {
3235
+ const W = [c[0] / L.worldScaling[0], c[1] / L.worldScaling[1]];
3236
+ g.rect = pt(g.rect, W);
3220
3237
  }
3221
3238
  return g && s.setInfo(t.name, g), g == null ? void 0 : g.rect;
3222
3239
  }
@@ -3233,8 +3250,8 @@ class ft extends W {
3233
3250
  }
3234
3251
  }
3235
3252
  }
3236
- function At(R) {
3237
- switch (R) {
3253
+ function At(M) {
3254
+ switch (M) {
3238
3255
  case P.Arrow:
3239
3256
  return xt;
3240
3257
  case P.Pencil:
@@ -3254,19 +3271,19 @@ function At(R) {
3254
3271
  case P.SpeechBalloon:
3255
3272
  return Ot;
3256
3273
  case P.Text:
3257
- return ft;
3274
+ return yt;
3258
3275
  case P.LaserPen:
3259
3276
  return Lt;
3260
3277
  case P.Eraser:
3261
- return mt;
3278
+ return ft;
3262
3279
  case P.Selector:
3263
- return H;
3280
+ return G;
3264
3281
  case P.Image:
3265
3282
  return ut;
3266
3283
  }
3267
3284
  }
3268
- function yt(R, n) {
3269
- const { toolsType: e, ...t } = R;
3285
+ function wt(M, n) {
3286
+ const { toolsType: e, ...t } = M;
3270
3287
  switch (e) {
3271
3288
  case P.Arrow:
3272
3289
  return new xt(t);
@@ -3287,36 +3304,36 @@ function yt(R, n) {
3287
3304
  case P.SpeechBalloon:
3288
3305
  return new Ot(t);
3289
3306
  case P.Text:
3290
- return new ft(t);
3307
+ return new yt(t);
3291
3308
  case P.LaserPen:
3292
3309
  return new Lt(t);
3293
3310
  case P.Eraser:
3294
- return new mt(t, n);
3311
+ return new ft(t, n);
3295
3312
  case P.Selector:
3296
- return t.vNodes ? new H({ ...t, vNodes: t.vNodes, drawLayer: t.fullLayer }) : void 0;
3313
+ return t.vNodes ? new G({ ...t, vNodes: t.vNodes, drawLayer: t.fullLayer }) : void 0;
3297
3314
  case P.Image:
3298
3315
  return new ut(t);
3299
3316
  default:
3300
3317
  return;
3301
3318
  }
3302
3319
  }
3303
- function Et(R) {
3320
+ function Et(M) {
3304
3321
  const n = [], e = ["PATH", "SPRITE", "POLYLINE", "RECT", "ELLIPSE"];
3305
- for (const t of R) {
3322
+ for (const t of M) {
3306
3323
  if (t.tagName === "GROUP" && t.children.length)
3307
3324
  return Et(t.children);
3308
3325
  t.tagName && e.includes(t.tagName) && n.push(t);
3309
3326
  }
3310
3327
  return n;
3311
3328
  }
3312
- const Jt = (R) => {
3313
- if (R.tagName === "GROUP") {
3314
- const n = Object.getOwnPropertySymbols(R).find((e) => e.toString() === "Symbol(sealed)");
3315
- if (n && R[n])
3329
+ const Jt = (M) => {
3330
+ if (M.tagName === "GROUP") {
3331
+ const n = Object.getOwnPropertySymbols(M).find((e) => e.toString() === "Symbol(sealed)");
3332
+ if (n && M[n])
3316
3333
  return !0;
3317
3334
  }
3318
3335
  return !1;
3319
- }, Qt = (R) => !R.isHid, kt = "cursorhover";
3336
+ }, Qt = (M) => !M.isHid, mt = "cursorhover";
3320
3337
  class _t {
3321
3338
  constructor(n, e) {
3322
3339
  m(this, "viewId");
@@ -3339,7 +3356,7 @@ class _t {
3339
3356
  return n;
3340
3357
  }
3341
3358
  has(n) {
3342
- this.curNodeMap.has(n);
3359
+ return this.curNodeMap.has(n);
3343
3360
  }
3344
3361
  setInfo(n, e) {
3345
3362
  const t = this.curNodeMap.get(n) || {
@@ -3363,7 +3380,7 @@ class _t {
3363
3380
  hasRectIntersectRange(n, e = !0) {
3364
3381
  for (const t of this.curNodeMap.values())
3365
3382
  if (ht(n, t.rect)) {
3366
- if (e && t.toolsType === P.Image && t.opt.locked || e && t.toolsType === P.Text && (t.opt.workState === D.Doing || t.opt.workState === D.Start))
3383
+ if (e && t.toolsType === P.Image && t.opt.locked || e && t.toolsType === P.Text && (t.opt.workState === A.Doing || t.opt.workState === A.Start))
3367
3384
  continue;
3368
3385
  return !0;
3369
3386
  }
@@ -3374,7 +3391,7 @@ class _t {
3374
3391
  const o = /* @__PURE__ */ new Map();
3375
3392
  for (const [s, i] of this.curNodeMap.entries())
3376
3393
  if (ht(n, i.rect)) {
3377
- if (e && i.toolsType === P.Image && i.opt.locked || e && i.toolsType === P.Text && (i.opt.workState === D.Doing || i.opt.workState === D.Start))
3394
+ if (e && i.toolsType === P.Image && i.opt.locked || e && i.toolsType === P.Text && (i.opt.workState === A.Doing || i.opt.workState === A.Start))
3378
3395
  continue;
3379
3396
  t = B(t, i.rect), o.set(s, i);
3380
3397
  }
@@ -3384,14 +3401,19 @@ class _t {
3384
3401
  };
3385
3402
  }
3386
3403
  getNodeRectFormShape(n, e) {
3404
+ var s;
3387
3405
  const t = At(e.toolsType);
3406
+ if (e.toolsType === P.Text) {
3407
+ const i = (s = this.fullLayer) == null ? void 0 : s.getElementsByName(n)[0];
3408
+ i && t.updateLabels(e, i, this.fullLayer);
3409
+ }
3388
3410
  return this.fullLayer && (t == null ? void 0 : t.getRectFromLayer(this.fullLayer, n));
3389
3411
  }
3390
3412
  updateNodesRect() {
3391
- this.curNodeMap.forEach((n, e) => {
3392
- const t = this.getNodeRectFormShape(e, n);
3393
- t ? (n.rect = t, this.curNodeMap.set(e, n)) : this.curNodeMap.delete(e);
3394
- });
3413
+ for (const [n, e] of this.curNodeMap.entries()) {
3414
+ const t = this.getNodeRectFormShape(n, e);
3415
+ t ? (e.rect = t, this.curNodeMap.set(n, e)) : this.curNodeMap.delete(n);
3416
+ }
3395
3417
  }
3396
3418
  combineIntersectRect(n) {
3397
3419
  let e = n;
@@ -3414,6 +3436,9 @@ class _t {
3414
3436
  deleteTarget(n) {
3415
3437
  this.targetNodeMap.length = n;
3416
3438
  }
3439
+ clearTarget() {
3440
+ this.targetNodeMap.length = 0;
3441
+ }
3417
3442
  }
3418
3443
  class te {
3419
3444
  constructor(n) {
@@ -3443,11 +3468,11 @@ class te {
3443
3468
  if (t === C.Service)
3444
3469
  this.activeServiceWorkShape(n);
3445
3470
  else {
3446
- const o = this.localWorkShapes.get(e);
3447
- if (!o)
3471
+ const o = e == null ? void 0 : e.toString(), s = o && this.localWorkShapes.get(o);
3472
+ if (!s)
3448
3473
  return;
3449
- const s = o.node.consume({ data: n, isFullWork: !1, isSubWorker: !0 });
3450
- s.rect && (o.result = s, o.workState = D.Doing, e && this.localWorkShapes.set(e, o));
3474
+ const i = s.node.consume({ data: n, isFullWork: !1, isSubWorker: !0 });
3475
+ i.rect && (s.result = i, s.workState = A.Doing, o && this.localWorkShapes.set(o, s));
3451
3476
  }
3452
3477
  this.runAnimation();
3453
3478
  }
@@ -3457,7 +3482,7 @@ class te {
3457
3482
  createWorkShapeNode(n) {
3458
3483
  const { toolsType: e } = n;
3459
3484
  if (e === P.LaserPen)
3460
- return yt({ ...n, vNodes: this.vNodes, fullLayer: this.thread.topLayer, drawLayer: this.thread.topLayer });
3485
+ return wt({ ...n, vNodes: this.vNodes, fullLayer: this.thread.topLayer, drawLayer: this.thread.topLayer });
3461
3486
  }
3462
3487
  getTmpWorkShapeNode() {
3463
3488
  return this.tmpWorkShapeNode;
@@ -3467,7 +3492,7 @@ class te {
3467
3492
  this.tmpWorkShapeNode.setWorkId(n), this.localWorkShapes.set(n, {
3468
3493
  node: this.tmpWorkShapeNode,
3469
3494
  toolsType: this.tmpWorkShapeNode.toolsType,
3470
- workState: D.Start
3495
+ workState: A.Start
3471
3496
  }), this.tmpOpt && this.setToolsOpt(this.tmpOpt);
3472
3497
  return;
3473
3498
  }
@@ -3476,12 +3501,12 @@ class te {
3476
3501
  return n.toolsType = e, n.node = this.createWorkShapeNode({ toolsType: e, toolsOpt: t }), n;
3477
3502
  }
3478
3503
  activeServiceWorkShape(n) {
3479
- var p, f;
3504
+ var p, u;
3480
3505
  const { workId: e, opt: t, toolsType: o, type: s, updateNodeOpt: i, ops: r, op: a } = n;
3481
3506
  if (!e)
3482
3507
  return;
3483
3508
  const c = e.toString(), l = (p = this.vNodes.get(c)) == null ? void 0 : p.rect;
3484
- if (!((f = this.serviceWorkShapes) != null && f.has(c))) {
3509
+ if (!((u = this.serviceWorkShapes) != null && u.has(c))) {
3485
3510
  let d = {
3486
3511
  toolsType: o,
3487
3512
  animationWorkData: a || [],
@@ -3509,13 +3534,13 @@ class te {
3509
3534
  for (const [a, c] of this.serviceWorkShapes.entries())
3510
3535
  switch (c.toolsType) {
3511
3536
  case P.LaserPen: {
3512
- const h = this.computNextAnimationIndex(c, 8), p = Math.max(0, c.animationIndex || 0), f = (c.animationWorkData || []).slice(p, h);
3537
+ const h = this.computNextAnimationIndex(c, 8), p = Math.max(0, c.animationIndex || 0), u = (c.animationWorkData || []).slice(p, h);
3513
3538
  if ((c.animationIndex || 0) < h && ((o = c.node) == null || o.consumeService({
3514
- op: f,
3539
+ op: u,
3515
3540
  isFullWork: !1
3516
- }), c.animationIndex = h, f.length && e.set(a, {
3517
- workState: p === 0 ? D.Start : h === ((s = c.animationWorkData) == null ? void 0 : s.length) ? D.Done : D.Doing,
3518
- op: f.slice(-2)
3541
+ }), c.animationIndex = h, u.length && e.set(a, {
3542
+ workState: p === 0 ? A.Start : h === ((s = c.animationWorkData) == null ? void 0 : s.length) ? A.Done : A.Doing,
3543
+ op: u.slice(-2)
3519
3544
  })), c.isDel) {
3520
3545
  (i = c.node) == null || i.clearTmpPoints(), this.serviceWorkShapes.delete(a);
3521
3546
  break;
@@ -3525,24 +3550,24 @@ class te {
3525
3550
  }
3526
3551
  }
3527
3552
  for (const [a, c] of this.localWorkShapes.entries()) {
3528
- const { result: l, toolsType: h, isDel: p, workState: f } = c;
3553
+ const { result: l, toolsType: h, isDel: p, workState: u } = c;
3529
3554
  switch (h) {
3530
3555
  case P.LaserPen: {
3531
3556
  if (p) {
3532
3557
  c.node.clearTmpPoints(), this.localWorkShapes.delete(a), t.push({
3533
3558
  removeIds: [a.toString()],
3534
- type: w.RemoveNode
3559
+ type: y.RemoveNode
3535
3560
  });
3536
3561
  break;
3537
3562
  }
3538
- l && ((l.op || l.ops) && t.push(l), c.result = void 0), !this.thread.topLayer.getElementsByName(a.toString())[0] && f === D.Done && (c.isDel = !0, this.localWorkShapes.set(a, c)), n = !0;
3563
+ l && ((l.op || l.ops) && t.push(l), c.result = void 0), !this.thread.topLayer.getElementsByName(a.toString())[0] && u === A.Done && (c.isDel = !0, this.localWorkShapes.set(a, c)), n = !0;
3539
3564
  break;
3540
3565
  }
3541
3566
  }
3542
3567
  }
3543
3568
  n && this.runAnimation(), e.size && e.forEach((a, c) => {
3544
3569
  t.push({
3545
- type: w.Cursor,
3570
+ type: y.Cursor,
3546
3571
  uid: c.split(gt)[0],
3547
3572
  op: a.op,
3548
3573
  workState: a.workState,
@@ -3562,11 +3587,11 @@ class te {
3562
3587
  if (t === C.Service)
3563
3588
  this.activeServiceWorkShape(n);
3564
3589
  else {
3565
- const o = this.localWorkShapes.get(e);
3566
- if (!o)
3590
+ const o = e == null ? void 0 : e.toString(), s = o && this.localWorkShapes.get(o);
3591
+ if (!s)
3567
3592
  return;
3568
- const s = o.node.consumeAll({ data: n });
3569
- o.result = s, o.workState = D.Done, e && this.localWorkShapes.set(e, o);
3593
+ const i = s.node.consumeAll({ data: n });
3594
+ s.result = i, s.workState = A.Done, o && this.localWorkShapes.set(o, s);
3570
3595
  }
3571
3596
  this.runAnimation();
3572
3597
  }
@@ -3576,21 +3601,30 @@ class ee {
3576
3601
  m(this, "vNodes");
3577
3602
  m(this, "thread");
3578
3603
  m(this, "workShapes", /* @__PURE__ */ new Map());
3579
- // workShapeState: Map<IworkId, ShapeStateInfo> = new Map();
3580
3604
  m(this, "effectSelectNodeData", /* @__PURE__ */ new Set());
3581
3605
  m(this, "batchEraserRemoveNodes", /* @__PURE__ */ new Set());
3582
3606
  m(this, "batchEraserWorks", /* @__PURE__ */ new Set());
3583
3607
  m(this, "tmpOpt");
3584
3608
  m(this, "tmpWorkShapeNode");
3585
3609
  m(this, "drawCount", 0);
3586
- m(this, "batchEraserCombine", Ht(() => {
3610
+ m(this, "batchEraserCombine", Vt(() => {
3587
3611
  this.updateBatchEraserCombineNode(this.batchEraserWorks, this.batchEraserRemoveNodes), this.batchEraserWorks.clear(), this.batchEraserRemoveNodes.clear();
3588
3612
  }, 100, { leading: !1 }));
3589
3613
  this.vNodes = n.vNodes, this.thread = n.thread;
3590
3614
  }
3615
+ workShapesDone(n, e) {
3616
+ for (const t of this.workShapes.keys())
3617
+ this.consumeDrawAll({
3618
+ workId: t,
3619
+ scenePath: n,
3620
+ viewId: this.thread.viewId,
3621
+ msgType: y.DrawWork,
3622
+ dataType: C.Local
3623
+ }, e);
3624
+ }
3591
3625
  async updateSelector(n) {
3592
3626
  var p;
3593
- const e = this.workShapes.get(Y);
3627
+ const e = this.workShapes.get($);
3594
3628
  if (!((p = e == null ? void 0 : e.selectIds) != null && p.length))
3595
3629
  return;
3596
3630
  const { callback: t, ...o } = n, { updateSelectorOpt: s, willSerializeData: i, scene: r } = o, a = await (e == null ? void 0 : e.updateSelector({
@@ -3602,14 +3636,14 @@ class ee {
3602
3636
  scene: r,
3603
3637
  isMainThread: !0
3604
3638
  })), c = /* @__PURE__ */ new Map();
3605
- e.selectIds.forEach((f) => {
3606
- const d = this.vNodes.get(f);
3639
+ e.selectIds.forEach((u) => {
3640
+ const d = this.vNodes.get(u);
3607
3641
  if (d) {
3608
- const { toolsType: u, op: y, opt: k } = d;
3609
- c.set(f, {
3610
- opt: k,
3611
- toolsType: u,
3612
- ops: (y == null ? void 0 : y.length) && K(y) || void 0
3642
+ const { toolsType: f, op: w, opt: S } = d;
3643
+ c.set(u, {
3644
+ opt: S,
3645
+ toolsType: f,
3646
+ ops: (w == null ? void 0 : w.length) && K(w) || void 0
3613
3647
  });
3614
3648
  }
3615
3649
  });
@@ -3631,10 +3665,10 @@ class ee {
3631
3665
  clearAll() {
3632
3666
  if (this.thread.localLayer.children.length && (this.thread.topLayer.parent.children.forEach((e) => {
3633
3667
  e.name !== "viewport" && e.remove();
3634
- }), this.thread.localLayer.removeAllChildren()), this.workShapes.get(Y)) {
3668
+ }), this.thread.localLayer.removeAllChildren()), this.workShapes.get($)) {
3635
3669
  const e = [];
3636
3670
  e.push({
3637
- type: w.Select,
3671
+ type: y.Select,
3638
3672
  dataType: C.Local,
3639
3673
  selectIds: [],
3640
3674
  willSyncService: !1
@@ -3648,19 +3682,19 @@ class ee {
3648
3682
  let s;
3649
3683
  for (const i of this.vNodes.curNodeMap.values()) {
3650
3684
  const { rect: r, name: a, toolsType: c, opt: l } = i, h = e[0] * this.thread.fullLayer.worldScaling[0] + this.thread.fullLayer.worldPosition[0], p = e[1] * this.thread.fullLayer.worldScaling[1] + this.thread.fullLayer.worldPosition[1];
3651
- if (c === P.Text && Vt([h, p], r) && l.workState === D.Done) {
3685
+ if (c === P.Text && Ht([h, p], r) && l.workState === A.Done) {
3652
3686
  s = a;
3653
3687
  break;
3654
3688
  }
3655
3689
  }
3656
3690
  s && (await this.blurSelector({
3657
3691
  viewId: t,
3658
- msgType: w.Select,
3692
+ msgType: y.Select,
3659
3693
  dataType: o,
3660
3694
  isSync: !0
3661
3695
  }), this.thread.post({
3662
3696
  sp: [{
3663
- type: w.GetTextActive,
3697
+ type: y.GetTextActive,
3664
3698
  toolsType: P.Text,
3665
3699
  workId: s
3666
3700
  }]
@@ -3669,7 +3703,7 @@ class ee {
3669
3703
  }
3670
3704
  cursorHover(n) {
3671
3705
  const { opt: e, toolsType: t, point: o } = n, s = this.setFullWork({
3672
- workId: kt,
3706
+ workId: mt,
3673
3707
  toolsType: t,
3674
3708
  opt: e
3675
3709
  });
@@ -3677,13 +3711,13 @@ class ee {
3677
3711
  }
3678
3712
  updateFullSelectWork(n) {
3679
3713
  var o, s, i, r, a;
3680
- const e = this.workShapes.get(Y), { selectIds: t } = n;
3714
+ const e = this.workShapes.get($), { selectIds: t } = n;
3681
3715
  if (!(t != null && t.length)) {
3682
3716
  this.blurSelector(n);
3683
3717
  return;
3684
3718
  }
3685
3719
  if (!e) {
3686
- !this.setFullWork(n) && n.workId && ((o = this.tmpWorkShapeNode) == null ? void 0 : o.toolsType) === P.Selector && this.setTmpWorkId(n.workId), this.updateFullSelectWork(n);
3720
+ !this.setFullWork(n) && n.workId && ((o = this.tmpWorkShapeNode) == null ? void 0 : o.toolsType) === P.Selector && this.setTmpWorkId(n.workId.toString()), this.updateFullSelectWork(n);
3687
3721
  return;
3688
3722
  }
3689
3723
  if (e && (t != null && t.length)) {
@@ -3696,7 +3730,7 @@ class ee {
3696
3730
  canTextEdit: e.canTextEdit,
3697
3731
  canRotate: e.canRotate,
3698
3732
  scaleType: e.scaleType,
3699
- type: w.Select,
3733
+ type: y.Select,
3700
3734
  selectRect: c,
3701
3735
  points: e.getChildrenPoints(),
3702
3736
  willSyncService: (n == null ? void 0 : n.willSyncService) || !1,
@@ -3714,20 +3748,22 @@ class ee {
3714
3748
  t && this.removeNode(t);
3715
3749
  }
3716
3750
  removeNode(n) {
3717
- var t;
3718
- this.workShapes.has(n) && this.clearWorkShapeNodeCache(n), this.vNodes.get(n) && (this.thread.fullLayer.getElementsByName(n).concat(((t = this.thread.localLayer) == null ? void 0 : t.getElementsByName(n)) || []).forEach((o) => {
3719
- o.remove();
3720
- }), this.vNodes.delete(n));
3751
+ var o;
3752
+ this.vNodes.get(n) && ((o = this.thread.fullLayer) == null || o.getElementsByName(n).forEach((s) => {
3753
+ s.remove();
3754
+ }), this.vNodes.delete(n)), this.workShapes.has(n) && (this.thread.localLayer.getElementsByName(n).forEach((s) => {
3755
+ s.remove();
3756
+ }), this.clearWorkShapeNodeCache(n));
3721
3757
  }
3722
3758
  setFullWork(n) {
3723
3759
  const { workId: e, opt: t, toolsType: o } = n;
3724
3760
  if (e && t && o) {
3725
- const s = e && this.workShapes.get(e) || this.createWorkShapeNode({
3761
+ const s = e.toString(), i = this.workShapes.get(s) || this.createWorkShapeNode({
3726
3762
  toolsOpt: t,
3727
3763
  toolsType: o,
3728
- workId: e
3764
+ workId: s
3729
3765
  });
3730
- return s ? (s.setWorkId(e), this.workShapes.set(e, s), s) : void 0;
3766
+ return i ? (i.setWorkId(s), this.workShapes.set(s, i), i) : void 0;
3731
3767
  }
3732
3768
  }
3733
3769
  async consumeFull(n, e) {
@@ -3749,22 +3785,21 @@ class ee {
3749
3785
  replaceId: i
3750
3786
  }), n != null && n.updateNodeOpt && t.updataOptService(n.updateNodeOpt);
3751
3787
  const r = [];
3752
- n.workId && this.workShapes.delete(n.workId), n.willSyncService && r.push({
3788
+ n.workId && this.workShapes.delete(n.workId.toString()), n.willSyncService && r.push({
3753
3789
  opt: n.opt,
3754
3790
  toolsType: n.toolsType,
3755
- type: w.FullWork,
3791
+ type: y.FullWork,
3756
3792
  workId: n.workId,
3757
3793
  ops: n.ops,
3758
3794
  updateNodeOpt: n.updateNodeOpt,
3759
- // undoTickerId: data.undoTickerId,
3760
3795
  viewId: this.thread.viewId
3761
3796
  }), r.length && this.thread.post({ sp: r });
3762
3797
  }
3763
3798
  }
3764
3799
  async colloctEffectSelectWork(n) {
3765
- const e = this.workShapes.get(Y), { workId: t, msgType: o } = n;
3800
+ const e = this.workShapes.get($), { workId: t, msgType: o } = n;
3766
3801
  if (e && t && e.selectIds && e.selectIds.includes(t.toString())) {
3767
- o === w.RemoveNode ? e.selectIds = e.selectIds.filter((s) => s !== t.toString()) : this.effectSelectNodeData.add(n), await new Promise((s) => {
3802
+ o === y.RemoveNode ? e.selectIds = e.selectIds.filter((s) => s !== t.toString()) : this.effectSelectNodeData.add(n), await new Promise((s) => {
3768
3803
  setTimeout(() => {
3769
3804
  s(!0);
3770
3805
  }, 0);
@@ -3802,14 +3837,14 @@ class ee {
3802
3837
  replaceId: r
3803
3838
  }), s != null && s.updateNodeOpt && i.updataOptService(s.updateNodeOpt);
3804
3839
  }
3805
- s.workId && this.workShapes.delete(s.workId);
3840
+ s.workId && this.workShapes.delete(s.workId.toString());
3806
3841
  }
3807
3842
  }
3808
3843
  this.reRenderSelector(n);
3809
3844
  }
3810
3845
  reRenderSelector(n = !1) {
3811
3846
  var o;
3812
- const e = this.workShapes.get(Y);
3847
+ const e = this.workShapes.get($);
3813
3848
  if (!e)
3814
3849
  return;
3815
3850
  if (e && !((o = e.selectIds) != null && o.length))
@@ -3817,7 +3852,7 @@ class ee {
3817
3852
  const t = e.reRenderSelector();
3818
3853
  t && this.thread.post({
3819
3854
  sp: [{
3820
- type: w.Select,
3855
+ type: y.Select,
3821
3856
  selectIds: e.selectIds,
3822
3857
  selectRect: t,
3823
3858
  willSyncService: n,
@@ -3840,9 +3875,9 @@ class ee {
3840
3875
  }
3841
3876
  async blurSelector(n) {
3842
3877
  var o;
3843
- const e = this.workShapes.get(Y), t = e == null ? void 0 : e.blurSelector();
3844
- if (this.clearWorkShapeNodeCache(Y), ((o = this.thread.fullLayer) == null ? void 0 : o.parent).children.forEach((s) => {
3845
- s.name === Y && s.remove();
3878
+ const e = this.workShapes.get($), t = e == null ? void 0 : e.blurSelector();
3879
+ if (this.clearWorkShapeNodeCache($), ((o = this.thread.fullLayer) == null ? void 0 : o.parent).children.forEach((s) => {
3880
+ s.name === $ && s.remove();
3846
3881
  }), t) {
3847
3882
  const s = [];
3848
3883
  s.push({
@@ -3853,8 +3888,8 @@ class ee {
3853
3888
  }
3854
3889
  }
3855
3890
  clearWorkShapeNodeCache(n) {
3856
- var e;
3857
- (e = this.getWorkShape(n)) == null || e.clearTmpPoints(), this.workShapes.delete(n);
3891
+ var e, t;
3892
+ (e = this.getWorkShape(n)) == null || e.clearTmpPoints(), this.workShapes.delete(n), ((t = this.tmpWorkShapeNode) == null ? void 0 : t.getWorkId()) === n && this.setTmpWorkId(void 0);
3858
3893
  }
3859
3894
  drawEraser(n) {
3860
3895
  var t, o;
@@ -3863,7 +3898,7 @@ class ee {
3863
3898
  for (const s of n.newWorkDatas.values()) {
3864
3899
  const i = s.workId.toString();
3865
3900
  this.batchEraserWorks.add(i), e.push({
3866
- type: w.FullWork,
3901
+ type: y.FullWork,
3867
3902
  workId: i,
3868
3903
  ops: K(s.op),
3869
3904
  opt: s.opt,
@@ -3877,7 +3912,7 @@ class ee {
3877
3912
  }
3878
3913
  (o = n.removeIds) == null || o.forEach((s) => {
3879
3914
  this.batchEraserRemoveNodes.add(s);
3880
- }), console.log("first", n), e.push(n), this.thread.post({ sp: e }), this.batchEraserCombine();
3915
+ }), e.push(n), this.thread.post({ sp: e }), this.batchEraserCombine();
3881
3916
  }
3882
3917
  updateBatchEraserCombineNode(n, e) {
3883
3918
  for (const t of e.keys())
@@ -3898,10 +3933,13 @@ class ee {
3898
3933
  getWorkShape(n) {
3899
3934
  return this.workShapes.get(n);
3900
3935
  }
3936
+ getWorkShapes() {
3937
+ return this.workShapes;
3938
+ }
3901
3939
  consumeDraw(n, e) {
3902
3940
  const { op: t, workId: o, scenePath: s } = n;
3903
3941
  if (t != null && t.length && o) {
3904
- const i = this.workShapes.get(o);
3942
+ const i = this.workShapes.get(o.toString());
3905
3943
  if (!i)
3906
3944
  return;
3907
3945
  const r = i.toolsType;
@@ -3914,7 +3952,7 @@ class ee {
3914
3952
  data: n,
3915
3953
  isFullWork: !0
3916
3954
  });
3917
- a.type === w.Select && (a.selectIds && e.runReverseSelectWork(a.selectIds), this.thread.post({ sp: [a] }));
3955
+ a.type === y.Select && (a.selectIds && e.runReverseSelectWork(a.selectIds), this.thread.post({ sp: [a] }));
3918
3956
  }
3919
3957
  break;
3920
3958
  case P.Eraser:
@@ -3953,19 +3991,19 @@ class ee {
3953
3991
  var s, i, r;
3954
3992
  const { workId: t, scenePath: o } = n;
3955
3993
  if (t) {
3956
- const a = this.workShapes.get(t);
3957
- if (!a)
3994
+ const a = t.toString(), c = this.workShapes.get(a);
3995
+ if (!c)
3958
3996
  return;
3959
- const c = a.toolsType;
3960
- if (c === P.LaserPen)
3997
+ const l = c.toolsType;
3998
+ if (l === P.LaserPen)
3961
3999
  return;
3962
- const l = this.workShapes.get(kt), h = (s = l == null ? void 0 : l.selectIds) == null ? void 0 : s[0], p = a.consumeAll({ data: n });
3963
- switch (c) {
4000
+ const h = this.workShapes.get(mt), p = (s = h == null ? void 0 : h.selectIds) == null ? void 0 : s[0], u = c.consumeAll({ data: n });
4001
+ switch (l) {
3964
4002
  case P.Selector:
3965
- p.selectIds && h && ((i = p.selectIds) != null && i.includes(h)) && l.cursorBlur(), p.type === w.Select && (p.selectIds && e.runReverseSelectWork(p.selectIds), this.thread.post({ sp: [{ ...p, scenePath: o }] })), (r = a.selectIds) != null && r.length ? a.clearTmpPoints() : this.clearWorkShapeNodeCache(t);
4003
+ u.selectIds && p && ((i = u.selectIds) != null && i.includes(p)) && h.cursorBlur(), u.type === y.Select && (u.selectIds && e.runReverseSelectWork(u.selectIds), this.thread.post({ sp: [{ ...u, scenePath: o }] })), (r = c.selectIds) != null && r.length ? c.clearTmpPoints() : this.clearWorkShapeNodeCache(a);
3966
4004
  break;
3967
4005
  case P.Eraser:
3968
- p != null && p.rect && this.drawEraser({ ...p, scenePath: o }), a.clearTmpPoints();
4006
+ u != null && u.rect && this.drawEraser({ ...u, scenePath: o }), c.clearTmpPoints();
3969
4007
  break;
3970
4008
  case P.Arrow:
3971
4009
  case P.Straight:
@@ -3975,10 +4013,10 @@ class ee {
3975
4013
  case P.Polygon:
3976
4014
  case P.SpeechBalloon:
3977
4015
  case P.Pencil:
3978
- p && (this.drawCount = 0, this.thread.post({
4016
+ u && (this.drawCount = 0, this.thread.post({
3979
4017
  drawCount: this.drawCount,
3980
- sp: [p]
3981
- })), this.clearWorkShapeNodeCache(t);
4018
+ sp: [u]
4019
+ })), this.clearWorkShapeNodeCache(a);
3982
4020
  break;
3983
4021
  }
3984
4022
  }
@@ -4002,7 +4040,7 @@ class ee {
4002
4040
  this.workShapes.get(n) || this.setTmpWorkId(n), (o = this.workShapes.get(n)) == null || o.setWorkOptions(e);
4003
4041
  }
4004
4042
  createWorkShapeNode(n) {
4005
- return yt({ ...n, vNodes: this.vNodes, fullLayer: this.thread.fullLayer, drawLayer: this.thread.localLayer }, this.thread.serviceWork);
4043
+ return wt({ ...n, vNodes: this.vNodes, fullLayer: this.thread.fullLayer, drawLayer: this.thread.localLayer }, this.thread.serviceWork);
4006
4044
  }
4007
4045
  }
4008
4046
  class oe {
@@ -4075,31 +4113,31 @@ class oe {
4075
4113
  return Math.min((n.animationIndex || 0) + (t || e), (n.animationWorkData || []).length);
4076
4114
  }
4077
4115
  async animationDraw() {
4078
- var t, o, s, i, r, a, c, l, h, p, f, d, u, y, k, b;
4116
+ var t, o, s, i, r, a, c, l, h, p, u, d, f, w, S, b;
4079
4117
  this.animationId = void 0;
4080
4118
  let n = !1;
4081
4119
  const e = /* @__PURE__ */ new Map();
4082
- for (const [v, g] of this.workShapes.entries())
4120
+ for (const [I, g] of this.workShapes.entries())
4083
4121
  switch (g.toolsType) {
4084
4122
  case P.Image: {
4085
4123
  await ((o = g.node) == null ? void 0 : o.consumeServiceAsync({
4086
4124
  isFullWork: !0,
4087
4125
  scene: (t = this.thread.fullLayer.parent) == null ? void 0 : t.parent,
4088
4126
  isMainThread: !0
4089
- })), this.selectorWorkShapes.forEach((L, N) => {
4090
- var I;
4091
- (I = L.selectIds) != null && I.includes(v) && (this.willRunEffectSelectorIds.add(N), this.runEffect());
4092
- }), this.workShapes.delete(v);
4127
+ })), this.selectorWorkShapes.forEach((L, v) => {
4128
+ var W;
4129
+ (W = L.selectIds) != null && W.includes(I) && (this.willRunEffectSelectorIds.add(v), this.runEffect());
4130
+ }), this.workShapes.delete(I);
4093
4131
  break;
4094
4132
  }
4095
4133
  case P.Text: {
4096
4134
  g.node && (await ((s = g.node) == null ? void 0 : s.consumeServiceAsync({
4097
4135
  isFullWork: !0,
4098
- replaceId: v
4099
- })), this.selectorWorkShapes.forEach((L, N) => {
4100
- var I;
4101
- (I = L.selectIds) != null && I.includes(v) && (this.willRunEffectSelectorIds.add(N), this.runEffect());
4102
- }), (i = g.node) == null || i.clearTmpPoints(), this.workShapes.delete(v));
4136
+ replaceId: I
4137
+ })), this.selectorWorkShapes.forEach((L, v) => {
4138
+ var W;
4139
+ (W = L.selectIds) != null && W.includes(I) && (this.willRunEffectSelectorIds.add(v), this.runEffect());
4140
+ }), (i = g.node) == null || i.clearTmpPoints(), this.workShapes.delete(I));
4103
4141
  break;
4104
4142
  }
4105
4143
  case P.Arrow:
@@ -4111,17 +4149,17 @@ class oe {
4111
4149
  case P.SpeechBalloon: {
4112
4150
  const L = !!g.ops;
4113
4151
  if ((r = g.animationWorkData) != null && r.length) {
4114
- const N = g.oldRect;
4152
+ const v = g.oldRect;
4115
4153
  (a = g.node) == null || a.consumeService({
4116
4154
  op: g.animationWorkData,
4117
4155
  isFullWork: L
4118
- }), L && (this.selectorWorkShapes.forEach((I, A) => {
4156
+ }), L && (this.selectorWorkShapes.forEach((W, D) => {
4119
4157
  var T;
4120
- (T = I.selectIds) != null && T.includes(v) && (this.willRunEffectSelectorIds.add(A), this.runEffect());
4121
- }), (c = g.node) == null || c.clearTmpPoints(), this.workShapes.delete(v)), e.set(v, {
4122
- workState: N ? g.ops ? D.Done : D.Doing : D.Start,
4123
- op: g.animationWorkData.filter((I, A) => {
4124
- if (A % 3 !== 2)
4158
+ (T = W.selectIds) != null && T.includes(I) && (this.willRunEffectSelectorIds.add(D), this.runEffect());
4159
+ }), (c = g.node) == null || c.clearTmpPoints(), this.workShapes.delete(I)), e.set(I, {
4160
+ workState: v ? g.ops ? A.Done : A.Doing : A.Start,
4161
+ op: g.animationWorkData.filter((W, D) => {
4162
+ if (D % 3 !== 2)
4125
4163
  return !0;
4126
4164
  }).slice(-2)
4127
4165
  }), g.animationWorkData.length = 0;
@@ -4133,28 +4171,28 @@ class oe {
4133
4171
  (l = g.node) == null || l.consumeService({
4134
4172
  op: g.animationWorkData || [],
4135
4173
  isFullWork: !0,
4136
- replaceId: v
4137
- }), (h = g.node) == null || h.updataOptService(g.updateNodeOpt), this.selectorWorkShapes.forEach((L, N) => {
4138
- var I;
4139
- (I = L.selectIds) != null && I.includes(v) && (this.willRunEffectSelectorIds.add(N), this.runEffect());
4140
- }), (p = g.node) == null || p.clearTmpPoints(), this.workShapes.delete(v);
4174
+ replaceId: I
4175
+ }), (h = g.node) == null || h.updataOptService(g.updateNodeOpt), this.selectorWorkShapes.forEach((L, v) => {
4176
+ var W;
4177
+ (W = L.selectIds) != null && W.includes(I) && (this.willRunEffectSelectorIds.add(v), this.runEffect());
4178
+ }), (p = g.node) == null || p.clearTmpPoints(), this.workShapes.delete(I);
4141
4179
  else if (g.useAnimation) {
4142
4180
  if (g.isDel) {
4143
- (f = g.node) == null || f.clearTmpPoints(), this.workShapes.delete(v);
4181
+ (u = g.node) == null || u.clearTmpPoints(), this.workShapes.delete(I);
4144
4182
  break;
4145
4183
  }
4146
- const L = 3, N = this.computNextAnimationIndex(g, L), I = g.isDiff ? 0 : Math.max(0, (g.animationIndex || 0) - L), A = (g.animationWorkData || []).slice(I, N), T = (u = (d = g.node) == null ? void 0 : d.getWorkId()) == null ? void 0 : u.toString();
4147
- if ((g.animationIndex || 0) < N || g.isDiff) {
4148
- if ((y = g.node) == null || y.consumeService({
4149
- op: A,
4184
+ const L = 3, v = this.computNextAnimationIndex(g, L), W = g.isDiff ? 0 : Math.max(0, (g.animationIndex || 0) - L), D = (g.animationWorkData || []).slice(W, v), T = (f = (d = g.node) == null ? void 0 : d.getWorkId()) == null ? void 0 : f.toString();
4185
+ if ((g.animationIndex || 0) < v || g.isDiff) {
4186
+ if ((w = g.node) == null || w.consumeService({
4187
+ op: D,
4150
4188
  isFullWork: !1
4151
- }), g.animationIndex = N, g.isDiff && (g.isDiff = !1), A.length) {
4152
- const x = A.filter((M, $) => {
4153
- if ($ % L !== L - 1)
4189
+ }), g.animationIndex = v, g.isDiff && (g.isDiff = !1), D.length) {
4190
+ const x = D.filter((R, U) => {
4191
+ if (U % L !== L - 1)
4154
4192
  return !0;
4155
4193
  }).slice(-2);
4156
- e.set(v, {
4157
- workState: I === 0 ? D.Start : N === ((k = g.animationWorkData) == null ? void 0 : k.length) ? D.Done : D.Doing,
4194
+ e.set(I, {
4195
+ workState: W === 0 ? A.Start : v === ((S = g.animationWorkData) == null ? void 0 : S.length) ? A.Done : A.Doing,
4158
4196
  op: x
4159
4197
  });
4160
4198
  }
@@ -4163,10 +4201,10 @@ class oe {
4163
4201
  op: g.animationWorkData || [],
4164
4202
  isFullWork: !0,
4165
4203
  replaceId: T
4166
- }), g.isDel = !0, e.set(v, {
4167
- workState: D.Done,
4168
- op: A.filter((x, M) => {
4169
- if (M % L !== L - 1)
4204
+ }), g.isDel = !0, e.set(I, {
4205
+ workState: A.Done,
4206
+ op: D.filter((x, R) => {
4207
+ if (R % L !== L - 1)
4170
4208
  return !0;
4171
4209
  }).slice(-2)
4172
4210
  }));
@@ -4177,16 +4215,16 @@ class oe {
4177
4215
  }
4178
4216
  }
4179
4217
  if (n && this.runAnimation(), e.size) {
4180
- const v = [];
4218
+ const I = [];
4181
4219
  e.forEach((g, L) => {
4182
- v.push({
4183
- type: w.Cursor,
4220
+ I.push({
4221
+ type: y.Cursor,
4184
4222
  uid: L.split(gt)[0],
4185
4223
  op: g.op,
4186
4224
  workState: g.workState,
4187
4225
  viewId: this.thread.viewId
4188
4226
  });
4189
- }), this.thread.post({ sp: v });
4227
+ }), this.thread.post({ sp: I });
4190
4228
  }
4191
4229
  }
4192
4230
  runAnimation() {
@@ -4213,13 +4251,13 @@ class oe {
4213
4251
  return !1;
4214
4252
  }
4215
4253
  activeWorkShape(n) {
4216
- var f, d, u, y;
4254
+ var u, d, f, w;
4217
4255
  const { workId: e, opt: t, toolsType: o, type: s, updateNodeOpt: i, ops: r, op: a, useAnimation: c } = n;
4218
4256
  if (!e)
4219
4257
  return;
4220
- const l = e.toString(), h = (f = this.vNodes.get(l)) == null ? void 0 : f.rect;
4258
+ const l = e.toString(), h = (u = this.vNodes.get(l)) == null ? void 0 : u.rect;
4221
4259
  if (!((d = this.workShapes) != null && d.has(l))) {
4222
- let k = {
4260
+ let S = {
4223
4261
  toolsType: o,
4224
4262
  animationWorkData: a || [],
4225
4263
  animationIndex: 0,
@@ -4230,13 +4268,13 @@ class oe {
4230
4268
  oldRect: h,
4231
4269
  isDiff: !1
4232
4270
  };
4233
- o && t && (k = this.setNodeKey(k, o, t)), (u = this.workShapes) == null || u.set(l, k);
4271
+ o && t && (S = this.setNodeKey(S, o, t)), (f = this.workShapes) == null || f.set(l, S);
4234
4272
  }
4235
- const p = (y = this.workShapes) == null ? void 0 : y.get(l);
4273
+ const p = (w = this.workShapes) == null ? void 0 : w.get(l);
4236
4274
  s && (p.type = s), r && (p.animationWorkData = dt(r), p.ops = r), i && (p.updateNodeOpt = i), a && (p.isDiff = this.hasDiffData(p.animationWorkData || [], a, p.toolsType), p.animationWorkData = a), p.node && p.node.getWorkId() !== l && p.node.setWorkId(l), h && (p.oldRect = h), o && t && (p.toolsType !== o && o && t && this.setNodeKey(p, o, t), p.node && p.node.setWorkOptions(t));
4237
4275
  }
4238
4276
  removeNode(n, e) {
4239
- n.indexOf(Y) > -1 && this.removeSelectWork(e), this.thread.fullLayer.getElementsByName(n).forEach((t) => {
4277
+ n.indexOf($) > -1 && this.removeSelectWork(e), this.thread.fullLayer.getElementsByName(n).forEach((t) => {
4240
4278
  t.remove();
4241
4279
  }), this.thread.serviceLayer.getElementsByName(n).forEach((t) => {
4242
4280
  t.remove();
@@ -4265,7 +4303,7 @@ class oe {
4265
4303
  s && (a.type = s), a.node && a.node.getWorkId() !== r && a.node.setWorkId(r), a.selectIds = i || [];
4266
4304
  }
4267
4305
  setNodeKey(n, e, t) {
4268
- return n.toolsType = e, n.node = yt({
4306
+ return n.toolsType = e, n.node = wt({
4269
4307
  toolsType: e,
4270
4308
  toolsOpt: t,
4271
4309
  vNodes: this.vNodes,
@@ -4291,7 +4329,7 @@ class se extends J {
4291
4329
  }
4292
4330
  async consume(e) {
4293
4331
  const { msgType: t, dataType: o, emitEventType: s } = e;
4294
- if (t === w.FullWork && o === C.Local && s === this.emitEventType)
4332
+ if (t === y.FullWork && o === C.Local && s === this.emitEventType)
4295
4333
  return this.consumeForLocalWorker(e), !0;
4296
4334
  }
4297
4335
  async consumeForLocalWorker(e) {
@@ -4307,13 +4345,13 @@ class ie extends J {
4307
4345
  }
4308
4346
  async consume(e) {
4309
4347
  const { msgType: t, dataType: o, emitEventType: s } = e;
4310
- if (t === w.UpdateNode && o === C.Local && s === this.emitEventType)
4348
+ if (t === y.UpdateNode && o === C.Local && s === this.emitEventType)
4311
4349
  return this.consumeForLocalWorker(e), !0;
4312
4350
  }
4313
4351
  async consumeForLocalWorker(e) {
4314
4352
  var c;
4315
4353
  const { workId: t, updateNodeOpt: o, willRefreshSelector: s, willSyncService: i, willSerializeData: r, textUpdateForWoker: a } = e;
4316
- t === H.selectorId && o && await ((c = this.localWork) == null ? void 0 : c.updateSelector({
4354
+ t === G.selectorId && o && await ((c = this.localWork) == null ? void 0 : c.updateSelector({
4317
4355
  updateSelectorOpt: o,
4318
4356
  willRefreshSelector: s,
4319
4357
  willSyncService: i,
@@ -4329,14 +4367,14 @@ class ie extends J {
4329
4367
  a && h.toolsType === P.Text ? c.push({
4330
4368
  ...h,
4331
4369
  workId: l,
4332
- type: w.TextUpdate,
4370
+ type: y.TextUpdate,
4333
4371
  dataType: C.Local,
4334
4372
  willSyncService: !0
4335
4373
  }) : c.push(
4336
4374
  {
4337
4375
  ...h,
4338
4376
  workId: l,
4339
- type: w.UpdateNode,
4377
+ type: y.UpdateNode,
4340
4378
  updateNodeOpt: {
4341
4379
  useAnimation: !1
4342
4380
  },
@@ -4355,13 +4393,13 @@ class re extends J {
4355
4393
  }
4356
4394
  async consume(e) {
4357
4395
  const { msgType: t, dataType: o, emitEventType: s } = e;
4358
- if (t === w.UpdateNode && o === C.Local && s === this.emitEventType)
4396
+ if (t === y.UpdateNode && o === C.Local && s === this.emitEventType)
4359
4397
  return this.consumeForLocalWorker(e), !0;
4360
4398
  }
4361
4399
  async consumeForLocalWorker(e) {
4362
4400
  var a;
4363
4401
  const { workId: t, updateNodeOpt: o, willRefreshSelector: s, willSyncService: i, willSerializeData: r } = e;
4364
- t === H.selectorId && o && await ((a = this.localWork) == null ? void 0 : a.updateSelector({
4402
+ t === G.selectorId && o && await ((a = this.localWork) == null ? void 0 : a.updateSelector({
4365
4403
  updateSelectorOpt: o,
4366
4404
  willRefreshSelector: s,
4367
4405
  willSyncService: i,
@@ -4377,7 +4415,7 @@ class re extends J {
4377
4415
  {
4378
4416
  ...l,
4379
4417
  workId: c,
4380
- type: w.UpdateNode,
4418
+ type: y.UpdateNode,
4381
4419
  updateNodeOpt: {
4382
4420
  useAnimation: !1
4383
4421
  },
@@ -4396,13 +4434,13 @@ class ne extends J {
4396
4434
  }
4397
4435
  async consume(e) {
4398
4436
  const { msgType: t, dataType: o, emitEventType: s } = e;
4399
- if (t === w.UpdateNode && o === C.Local && s === this.emitEventType)
4437
+ if (t === y.UpdateNode && o === C.Local && s === this.emitEventType)
4400
4438
  return await this.consumeForLocalWorker(e), !0;
4401
4439
  }
4402
4440
  async consumeForLocalWorker(e) {
4403
4441
  var l, h;
4404
4442
  const { workId: t, updateNodeOpt: o, willRefreshSelector: s, willSyncService: i, willSerializeData: r, textUpdateForWoker: a, emitEventType: c } = e;
4405
- t === H.selectorId && o && (o.workState === D.Done && (o != null && o.translate) && (o.translate[0] || o.translate[1]) || o.workState !== D.Done ? await ((l = this.localWork) == null ? void 0 : l.updateSelector({
4443
+ t === G.selectorId && o && (o.workState === A.Done && (o != null && o.translate) && (o.translate[0] || o.translate[1]) || o.workState !== A.Done ? await ((l = this.localWork) == null ? void 0 : l.updateSelector({
4406
4444
  updateSelectorOpt: o,
4407
4445
  willRefreshSelector: s,
4408
4446
  willSyncService: i,
@@ -4412,19 +4450,19 @@ class ne extends J {
4412
4450
  emitEventType: c,
4413
4451
  scene: this.scene,
4414
4452
  callback: this.updateSelectorCallback
4415
- })) : o.workState === D.Done && ((h = this.localWork) == null || h.vNodes.deleteLastTarget()));
4453
+ })) : o.workState === A.Done && ((h = this.localWork) == null || h.vNodes.deleteLastTarget()));
4416
4454
  }
4417
4455
  updateSelectorCallback(e) {
4418
- const { param: t, postData: o, newServiceStore: s, workShapeNode: i, res: r } = e, { willSyncService: a, isSync: c, updateSelectorOpt: l, textUpdateForWoker: h } = t, p = l.workState, f = o.sp || [];
4419
- if (p === D.Start)
4456
+ const { param: t, postData: o, newServiceStore: s, workShapeNode: i, res: r } = e, { willSyncService: a, isSync: c, updateSelectorOpt: l, textUpdateForWoker: h } = t, p = l.workState, u = o.sp || [];
4457
+ if (p === A.Start)
4420
4458
  return {
4421
4459
  sp: [],
4422
4460
  render: []
4423
4461
  };
4424
4462
  const d = r == null ? void 0 : r.selectRect;
4425
4463
  if (a) {
4426
- p === D.Doing && f.push({
4427
- type: w.Select,
4464
+ p === A.Doing && u.push({
4465
+ type: y.Select,
4428
4466
  selectIds: i.selectIds,
4429
4467
  selectRect: d,
4430
4468
  willSyncService: !0,
@@ -4432,18 +4470,18 @@ class ne extends J {
4432
4470
  points: i.getChildrenPoints(),
4433
4471
  textOpt: i.textOpt
4434
4472
  });
4435
- for (const [u, y] of s.entries())
4436
- h && y.toolsType === P.Text ? f.push({
4437
- ...y,
4438
- workId: u,
4439
- type: w.TextUpdate,
4473
+ for (const [f, w] of s.entries())
4474
+ h && w.toolsType === P.Text ? u.push({
4475
+ ...w,
4476
+ workId: f,
4477
+ type: y.TextUpdate,
4440
4478
  dataType: C.Local,
4441
4479
  willSyncService: !0
4442
- }) : f.push(
4480
+ }) : u.push(
4443
4481
  {
4444
- ...y,
4445
- workId: u,
4446
- type: w.UpdateNode,
4482
+ ...w,
4483
+ workId: f,
4484
+ type: y.UpdateNode,
4447
4485
  updateNodeOpt: {
4448
4486
  useAnimation: !1
4449
4487
  },
@@ -4452,7 +4490,7 @@ class ne extends J {
4452
4490
  );
4453
4491
  }
4454
4492
  return {
4455
- sp: f
4493
+ sp: u
4456
4494
  };
4457
4495
  }
4458
4496
  }
@@ -4463,7 +4501,7 @@ class ae extends J {
4463
4501
  }
4464
4502
  async consume(e) {
4465
4503
  const { msgType: t, dataType: o, emitEventType: s } = e;
4466
- if (t === w.RemoveNode) {
4504
+ if (t === y.RemoveNode) {
4467
4505
  if (o === C.Local && s === this.emitEventType)
4468
4506
  return this.consumeForLocalWorker(e), !0;
4469
4507
  if (o === C.Service && s === this.emitEventType)
@@ -4478,15 +4516,15 @@ class ae extends J {
4478
4516
  return;
4479
4517
  const s = [], i = [];
4480
4518
  for (const r of t) {
4481
- if (r === Y) {
4482
- const c = this.localWork.workShapes.get(Y);
4519
+ if (r === $) {
4520
+ const c = this.localWork.workShapes.get($);
4483
4521
  if (!c)
4484
4522
  return;
4485
4523
  const l = c.selectIds && [...c.selectIds] || [];
4486
4524
  for (const h of l) {
4487
4525
  if (this.localWork.vNodes.get(h)) {
4488
- const f = this.commandDeleteText(h);
4489
- f && s.push(f);
4526
+ const u = this.commandDeleteText(h);
4527
+ u && s.push(u);
4490
4528
  }
4491
4529
  this.localWork.removeNode(h), i.push(h);
4492
4530
  }
@@ -4497,7 +4535,7 @@ class ae extends J {
4497
4535
  a && s.push(a), this.localWork.removeNode(r), i.push(r);
4498
4536
  }
4499
4537
  o && s.push({
4500
- type: w.RemoveNode,
4538
+ type: y.RemoveNode,
4501
4539
  removeIds: i
4502
4540
  }), s.length && this.localWork.thread.post({ sp: s });
4503
4541
  }
@@ -4509,7 +4547,7 @@ class ae extends J {
4509
4547
  const t = (o = this.localWork) == null ? void 0 : o.vNodes.get(e);
4510
4548
  if (t && t.toolsType === P.Text)
4511
4549
  return {
4512
- type: w.TextUpdate,
4550
+ type: y.TextUpdate,
4513
4551
  toolsType: P.Text,
4514
4552
  workId: e,
4515
4553
  dataType: C.Local
@@ -4523,13 +4561,13 @@ class ce extends J {
4523
4561
  }
4524
4562
  async consume(e) {
4525
4563
  const { msgType: t, dataType: o, emitEventType: s } = e;
4526
- if (t === w.UpdateNode && o === C.Local && s === this.emitEventType)
4564
+ if (t === y.UpdateNode && o === C.Local && s === this.emitEventType)
4527
4565
  return await this.consumeForLocalWorker(e), !0;
4528
4566
  }
4529
4567
  async consumeForLocalWorker(e) {
4530
4568
  var r;
4531
4569
  const { workId: t, updateNodeOpt: o, willSyncService: s, willSerializeData: i } = e;
4532
- t === H.selectorId && o && await ((r = this.localWork) == null ? void 0 : r.updateSelector({
4570
+ t === G.selectorId && o && await ((r = this.localWork) == null ? void 0 : r.updateSelector({
4533
4571
  updateSelectorOpt: o,
4534
4572
  willSyncService: s,
4535
4573
  willSerializeData: i,
@@ -4539,42 +4577,42 @@ class ce extends J {
4539
4577
  }));
4540
4578
  }
4541
4579
  updateSelectorCallback(e) {
4542
- const { param: t, postData: o, workShapeNode: s, res: i, newServiceStore: r } = e, { updateSelectorOpt: a, willSyncService: c, willSerializeData: l } = t, h = a.workState, p = o.sp || [], f = i == null ? void 0 : i.selectRect;
4543
- if (h === D.Start)
4580
+ const { param: t, postData: o, workShapeNode: s, res: i, newServiceStore: r } = e, { updateSelectorOpt: a, willSyncService: c, willSerializeData: l } = t, h = a.workState, p = o.sp || [], u = i == null ? void 0 : i.selectRect;
4581
+ if (h === A.Start)
4544
4582
  return {
4545
4583
  sp: [],
4546
4584
  render: []
4547
4585
  };
4548
4586
  if (c) {
4549
- h === D.Doing && p.push({
4550
- type: w.Select,
4587
+ h === A.Doing && p.push({
4588
+ type: y.Select,
4551
4589
  selectIds: s.selectIds,
4552
- selectRect: f,
4590
+ selectRect: u,
4553
4591
  willSyncService: !0,
4554
4592
  isSync: !0,
4555
4593
  points: s.getChildrenPoints(),
4556
4594
  textOpt: s.textOpt
4557
- }), l && h === D.Done && p.push({
4558
- type: w.Select,
4595
+ }), l && h === A.Done && p.push({
4596
+ type: y.Select,
4559
4597
  selectIds: s.selectIds,
4560
- selectRect: f,
4598
+ selectRect: u,
4561
4599
  willSyncService: !1,
4562
4600
  isSync: !0,
4563
4601
  points: s.getChildrenPoints(),
4564
4602
  textOpt: s.textOpt
4565
4603
  });
4566
- for (const [d, u] of r.entries())
4567
- u.toolsType === P.Text ? p.push({
4568
- ...u,
4604
+ for (const [d, f] of r.entries())
4605
+ f.toolsType === P.Text ? p.push({
4606
+ ...f,
4569
4607
  workId: d,
4570
- type: w.TextUpdate,
4608
+ type: y.TextUpdate,
4571
4609
  dataType: C.Local,
4572
4610
  willSyncService: !0
4573
4611
  }) : p.push(
4574
4612
  {
4575
- ...u,
4613
+ ...f,
4576
4614
  workId: d,
4577
- type: w.UpdateNode,
4615
+ type: y.UpdateNode,
4578
4616
  updateNodeOpt: {
4579
4617
  useAnimation: !1
4580
4618
  },
@@ -4594,13 +4632,13 @@ class le extends J {
4594
4632
  }
4595
4633
  async consume(e) {
4596
4634
  const { msgType: t, dataType: o, emitEventType: s } = e;
4597
- if (t === w.UpdateNode && o === C.Local && s === this.emitEventType)
4635
+ if (t === y.UpdateNode && o === C.Local && s === this.emitEventType)
4598
4636
  return await this.consumeForLocalWorker(e), !0;
4599
4637
  }
4600
4638
  async consumeForLocalWorker(e) {
4601
4639
  var c;
4602
4640
  const { workId: t, updateNodeOpt: o, willRefreshSelector: s, willSyncService: i, willSerializeData: r, emitEventType: a } = e;
4603
- t === H.selectorId && o && await ((c = this.localWork) == null ? void 0 : c.updateSelector({
4641
+ t === G.selectorId && o && await ((c = this.localWork) == null ? void 0 : c.updateSelector({
4604
4642
  updateSelectorOpt: o,
4605
4643
  willRefreshSelector: s,
4606
4644
  willSyncService: i,
@@ -4612,22 +4650,22 @@ class le extends J {
4612
4650
  }));
4613
4651
  }
4614
4652
  updateSelectorCallback(e) {
4615
- const { param: t, postData: o, workShapeNode: s, res: i, newServiceStore: r } = e, { updateSelectorOpt: a, willSyncService: c, willSerializeData: l, isSync: h } = t, p = a.workState, f = o.sp || [], d = i == null ? void 0 : i.selectRect;
4653
+ const { param: t, postData: o, workShapeNode: s, res: i, newServiceStore: r } = e, { updateSelectorOpt: a, willSyncService: c, willSerializeData: l, isSync: h } = t, p = a.workState, u = o.sp || [], d = i == null ? void 0 : i.selectRect;
4616
4654
  if (c) {
4617
- l && p === D.Done && f.push({
4618
- type: w.Select,
4655
+ l && p === A.Done && u.push({
4656
+ type: y.Select,
4619
4657
  selectIds: s.selectIds,
4620
4658
  selectRect: d,
4621
4659
  willSyncService: !0,
4622
4660
  isSync: h,
4623
4661
  points: s.getChildrenPoints()
4624
4662
  });
4625
- for (const [u, y] of r.entries())
4626
- f.push(
4663
+ for (const [f, w] of r.entries())
4664
+ u.push(
4627
4665
  {
4628
- ...y,
4629
- workId: u,
4630
- type: w.UpdateNode,
4666
+ ...w,
4667
+ workId: f,
4668
+ type: y.UpdateNode,
4631
4669
  updateNodeOpt: {
4632
4670
  useAnimation: !1
4633
4671
  },
@@ -4636,7 +4674,7 @@ class le extends J {
4636
4674
  );
4637
4675
  }
4638
4676
  return {
4639
- sp: f
4677
+ sp: u
4640
4678
  };
4641
4679
  }
4642
4680
  }
@@ -4647,13 +4685,13 @@ class he extends J {
4647
4685
  }
4648
4686
  async consume(e) {
4649
4687
  const { msgType: t, dataType: o, emitEventType: s } = e;
4650
- if (t === w.UpdateNode && o === C.Local && s === this.emitEventType)
4688
+ if (t === y.UpdateNode && o === C.Local && s === this.emitEventType)
4651
4689
  return await this.consumeForLocalWorker(e), !0;
4652
4690
  }
4653
4691
  async consumeForLocalWorker(e) {
4654
4692
  var c;
4655
4693
  const { workId: t, updateNodeOpt: o, willRefreshSelector: s, willSyncService: i, willSerializeData: r, textUpdateForWoker: a } = e;
4656
- t === H.selectorId && o && await ((c = this.localWork) == null ? void 0 : c.updateSelector({
4694
+ t === G.selectorId && o && await ((c = this.localWork) == null ? void 0 : c.updateSelector({
4657
4695
  updateSelectorOpt: o,
4658
4696
  willRefreshSelector: s,
4659
4697
  willSyncService: i,
@@ -4663,28 +4701,28 @@ class he extends J {
4663
4701
  }));
4664
4702
  }
4665
4703
  updateSelectorCallback(e) {
4666
- const { param: t, postData: o, newServiceStore: s, workShapeNode: i, res: r } = e, { willSyncService: a, isSync: c, updateSelectorOpt: l, textUpdateForWoker: h } = t, p = o.sp || [], f = r == null ? void 0 : r.selectRect;
4704
+ const { param: t, postData: o, newServiceStore: s, workShapeNode: i, res: r } = e, { willSyncService: a, isSync: c, updateSelectorOpt: l, textUpdateForWoker: h } = t, p = o.sp || [], u = r == null ? void 0 : r.selectRect;
4667
4705
  if (a && p) {
4668
4706
  l.fontSize && p.push({
4669
- type: w.Select,
4707
+ type: y.Select,
4670
4708
  selectIds: i.selectIds,
4671
- selectRect: f,
4709
+ selectRect: u,
4672
4710
  willSyncService: a,
4673
4711
  isSync: c,
4674
4712
  points: i.getChildrenPoints()
4675
4713
  });
4676
- for (const [d, u] of s.entries())
4677
- h && u.toolsType === P.Text ? p.push({
4678
- ...u,
4714
+ for (const [d, f] of s.entries())
4715
+ h && f.toolsType === P.Text ? p.push({
4716
+ ...f,
4679
4717
  workId: d,
4680
- type: w.TextUpdate,
4718
+ type: y.TextUpdate,
4681
4719
  dataType: C.Local,
4682
4720
  willSyncService: !0
4683
4721
  }) : p.push(
4684
4722
  {
4685
- ...u,
4723
+ ...f,
4686
4724
  workId: d,
4687
- type: w.UpdateNode,
4725
+ type: y.UpdateNode,
4688
4726
  updateNodeOpt: {
4689
4727
  useAnimation: !1
4690
4728
  },
@@ -4704,13 +4742,13 @@ class pe extends J {
4704
4742
  }
4705
4743
  async consume(e) {
4706
4744
  const { msgType: t, dataType: o, emitEventType: s } = e;
4707
- if (t === w.UpdateNode && o === C.Local && s === this.emitEventType)
4745
+ if (t === y.UpdateNode && o === C.Local && s === this.emitEventType)
4708
4746
  return this.consumeForLocalWorker(e), !0;
4709
4747
  }
4710
4748
  async consumeForLocalWorker(e) {
4711
4749
  var c;
4712
4750
  const { workId: t, updateNodeOpt: o, willRefreshSelector: s, willSyncService: i, willSerializeData: r, textUpdateForWoker: a } = e;
4713
- t === H.selectorId && o && await ((c = this.localWork) == null ? void 0 : c.updateSelector({
4751
+ t === G.selectorId && o && await ((c = this.localWork) == null ? void 0 : c.updateSelector({
4714
4752
  updateSelectorOpt: o,
4715
4753
  willRefreshSelector: s,
4716
4754
  willSyncService: i,
@@ -4724,12 +4762,12 @@ class pe extends J {
4724
4762
  updateSelectorCallback(e) {
4725
4763
  const { param: t, postData: o, newServiceStore: s, workShapeNode: i, res: r } = e, { willSyncService: a, isSync: c } = t, l = o.sp || [], h = r == null ? void 0 : r.selectRect;
4726
4764
  if (a && l) {
4727
- for (const [p, f] of s.entries())
4765
+ for (const [p, u] of s.entries())
4728
4766
  l.push(
4729
4767
  {
4730
- ...f,
4768
+ ...u,
4731
4769
  workId: p,
4732
- type: w.UpdateNode,
4770
+ type: y.UpdateNode,
4733
4771
  updateNodeOpt: {
4734
4772
  useAnimation: !1
4735
4773
  },
@@ -4737,7 +4775,7 @@ class pe extends J {
4737
4775
  }
4738
4776
  );
4739
4777
  l.push({
4740
- type: w.Select,
4778
+ type: y.Select,
4741
4779
  selectIds: i.selectIds,
4742
4780
  selectRect: h,
4743
4781
  willSyncService: a,
@@ -4757,13 +4795,13 @@ class de extends J {
4757
4795
  }
4758
4796
  async consume(e) {
4759
4797
  const { msgType: t, dataType: o, emitEventType: s } = e;
4760
- if (t === w.UpdateNode && o === C.Local && s === this.emitEventType)
4798
+ if (t === y.UpdateNode && o === C.Local && s === this.emitEventType)
4761
4799
  return this.consumeForLocalWorker(e), !0;
4762
4800
  }
4763
4801
  async consumeForLocalWorker(e) {
4764
4802
  var a;
4765
4803
  const { workId: t, updateNodeOpt: o, willRefreshSelector: s, willSyncService: i, willSerializeData: r } = e;
4766
- t === H.selectorId && o && await ((a = this.localWork) == null ? void 0 : a.updateSelector({
4804
+ t === G.selectorId && o && await ((a = this.localWork) == null ? void 0 : a.updateSelector({
4767
4805
  updateSelectorOpt: o,
4768
4806
  willRefreshSelector: s,
4769
4807
  willSyncService: i,
@@ -4774,12 +4812,12 @@ class de extends J {
4774
4812
  updateSelectorCallback(e) {
4775
4813
  const { param: t, postData: o, newServiceStore: s, workShapeNode: i, res: r } = e, { willSyncService: a, isSync: c, updateSelectorOpt: l } = t, h = o.sp || [], p = r == null ? void 0 : r.selectRect;
4776
4814
  if (a && h) {
4777
- for (const [f, d] of s.entries())
4815
+ for (const [u, d] of s.entries())
4778
4816
  h.push(
4779
4817
  {
4780
4818
  ...d,
4781
- workId: f,
4782
- type: w.UpdateNode,
4819
+ workId: u,
4820
+ type: y.UpdateNode,
4783
4821
  updateNodeOpt: {
4784
4822
  useAnimation: !1
4785
4823
  },
@@ -4791,7 +4829,7 @@ class de extends J {
4791
4829
  selectorColor: i.selectorColor,
4792
4830
  scaleType: i.scaleType,
4793
4831
  canRotate: i.canRotate,
4794
- type: w.Select,
4832
+ type: y.Select,
4795
4833
  selectIds: i.selectIds,
4796
4834
  selectRect: p,
4797
4835
  willSyncService: a,
@@ -4810,13 +4848,13 @@ class ue extends J {
4810
4848
  }
4811
4849
  async consume(e) {
4812
4850
  const { msgType: t, dataType: o, emitEventType: s } = e;
4813
- if (t === w.UpdateNode && o === C.Local && s === this.emitEventType)
4851
+ if (t === y.UpdateNode && o === C.Local && s === this.emitEventType)
4814
4852
  return this.consumeForLocalWorker(e), !0;
4815
4853
  }
4816
4854
  async consumeForLocalWorker(e) {
4817
4855
  var a;
4818
4856
  const { workId: t, updateNodeOpt: o, willRefreshSelector: s, willSyncService: i, willSerializeData: r } = e;
4819
- t === H.selectorId && o && await ((a = this.localWork) == null ? void 0 : a.updateSelector({
4857
+ t === G.selectorId && o && await ((a = this.localWork) == null ? void 0 : a.updateSelector({
4820
4858
  updateSelectorOpt: o,
4821
4859
  willRefreshSelector: s,
4822
4860
  willSyncService: i,
@@ -4832,7 +4870,7 @@ class ue extends J {
4832
4870
  {
4833
4871
  ...l,
4834
4872
  workId: c,
4835
- type: w.UpdateNode,
4873
+ type: y.UpdateNode,
4836
4874
  updateNodeOpt: {
4837
4875
  useAnimation: !1
4838
4876
  },
@@ -4928,72 +4966,72 @@ class me {
4928
4966
  post(n) {
4929
4967
  this.combinePostMsg.add(n), this.runBatchPostData();
4930
4968
  }
4931
- async on(n, e) {
4969
+ async on(n) {
4932
4970
  if (!await this.methodBuilder.consumeForMainThread(n)) {
4933
- const { msgType: t, toolsType: o, opt: s, dataType: i, workId: r, workState: a } = n;
4934
- switch (t) {
4935
- case w.Destroy:
4971
+ const { msgType: e, toolsType: t, opt: o, dataType: s, workId: i, workState: r } = n, a = i == null ? void 0 : i.toString();
4972
+ switch (e) {
4973
+ case y.Destroy:
4936
4974
  this.destroy();
4937
4975
  break;
4938
- case w.Clear:
4976
+ case y.Clear:
4939
4977
  this.clearAll();
4940
4978
  break;
4941
- case w.UpdateCamera:
4942
- this.updateCamera(n), e && this.post({ workerTasksqueueCount: e });
4979
+ case y.UpdateCamera:
4980
+ this.updateCamera(n);
4943
4981
  break;
4944
- case w.UpdateTools:
4945
- if (i === C.Local && o && s) {
4982
+ case y.UpdateTools:
4983
+ if (s === C.Local && t && o) {
4946
4984
  const c = {
4947
- toolsType: o,
4948
- toolsOpt: s
4985
+ toolsType: t,
4986
+ toolsOpt: o
4949
4987
  };
4950
4988
  this.localWork.setToolsOpt(c);
4951
4989
  }
4952
4990
  break;
4953
- case w.CreateWork:
4954
- if (r && s && o) {
4955
- if (o === P.LaserPen) {
4991
+ case y.CreateWork:
4992
+ if (i && o && t) {
4993
+ if (t === P.LaserPen) {
4956
4994
  this.topWork.getTmpWorkShapeNode() || this.topWork.setToolsOpt({
4957
- toolsType: o,
4958
- toolsOpt: s
4959
- }), this.topWork.setWorkOptions(r, s);
4995
+ toolsType: t,
4996
+ toolsOpt: o
4997
+ }), a && this.topWork.setWorkOptions(a, o);
4960
4998
  break;
4961
4999
  }
4962
5000
  this.localWork.getTmpWorkShapeNode() || this.localWork.setToolsOpt({
4963
- toolsType: o,
4964
- toolsOpt: s
4965
- }), this.localWork.setWorkOptions(r, s);
5001
+ toolsType: t,
5002
+ toolsOpt: o
5003
+ }), a && this.localWork.setWorkOptions(a, o);
4966
5004
  }
4967
5005
  break;
4968
- case w.DrawWork:
4969
- a === D.Done && i === C.Local ? this.consumeDrawAll(i, n) : this.consumeDraw(i, n);
5006
+ case y.DrawWork:
5007
+ r === A.Done && s === C.Local ? this.consumeDrawAll(s, n) : this.consumeDraw(s, n);
4970
5008
  break;
4971
- case w.UpdateNode:
4972
- case w.FullWork:
4973
- if (o === P.LaserPen) {
4974
- this.consumeDrawAll(i, n);
5009
+ case y.UpdateNode:
5010
+ case y.FullWork:
5011
+ if (t === P.LaserPen) {
5012
+ this.consumeDrawAll(s, n);
4975
5013
  break;
4976
5014
  }
4977
- this.consumeFull(i, n);
5015
+ this.consumeFull(s, n);
4978
5016
  break;
4979
- case w.RemoveNode:
5017
+ case y.RemoveNode:
4980
5018
  this.removeNode(n);
4981
5019
  return;
4982
- case w.Select:
4983
- i === C.Service && (r === Y ? this.localWork.updateFullSelectWork(n) : this.serviceWork.runSelectWork(n));
5020
+ case y.Select:
5021
+ s === C.Service && (i === $ ? this.localWork.updateFullSelectWork(n) : this.serviceWork.runSelectWork(n));
4984
5022
  break;
4985
- case w.CursorHover:
5023
+ case y.CursorHover:
4986
5024
  this.localWork.cursorHover(n);
4987
5025
  break;
4988
- case w.GetTextActive:
4989
- i === C.Local && this.localWork.checkTextActive(n);
5026
+ case y.GetTextActive:
5027
+ s === C.Local && this.localWork.checkTextActive(n);
4990
5028
  break;
4991
5029
  }
4992
5030
  }
4993
5031
  }
4994
5032
  async removeNode(n) {
4995
5033
  const { dataType: e, workId: t } = n;
4996
- if (t === Y) {
5034
+ if (t === $) {
4997
5035
  this.localWork.blurSelector(n);
4998
5036
  return;
4999
5037
  }
@@ -5012,47 +5050,51 @@ class me {
5012
5050
  this.mainThreadPostId || (this.mainThreadPostId = requestAnimationFrame(this.combinePost.bind(this)));
5013
5051
  }
5014
5052
  combinePostData() {
5015
- var o;
5053
+ var t;
5016
5054
  this.mainThreadPostId = void 0;
5017
5055
  const n = [];
5018
- let e, t;
5019
- for (const s of this.combinePostMsg.values()) {
5020
- if ((o = s.sp) != null && o.length)
5021
- for (const i of s.sp) {
5022
- let r = !1;
5023
- for (const a of n)
5024
- if (ct(i, a)) {
5025
- r = !0;
5056
+ let e;
5057
+ for (const o of this.combinePostMsg.values()) {
5058
+ if ((t = o.sp) != null && t.length)
5059
+ for (const s of o.sp) {
5060
+ let i = !1;
5061
+ for (const r of n)
5062
+ if (ct(s, r)) {
5063
+ i = !0;
5026
5064
  break;
5027
5065
  }
5028
- r || n.push(i);
5066
+ i || n.push(s);
5029
5067
  }
5030
- V(s.drawCount) && (e = s.drawCount), V(s.workerTasksqueueCount) && (t = s.workerTasksqueueCount);
5068
+ q(o.drawCount) && (e = o.drawCount);
5031
5069
  }
5032
5070
  return this.combinePostMsg.clear(), {
5033
5071
  sp: n,
5034
- drawCount: e,
5035
- workerTasksqueueCount: t
5072
+ drawCount: e
5036
5073
  };
5037
5074
  }
5038
5075
  combinePost() {
5039
5076
  var t, o, s;
5040
- const n = this.combinePostData(), e = (t = n.sp) == null ? void 0 : t.filter((i) => i.type !== w.None || Object.keys(i).filter((r) => r === "type").length);
5041
- e != null && e.length && (n.sp = e.map((i) => i.viewId ? i : { ...i, viewId: this.viewId })), ((o = n.sp) == null ? void 0 : o.length) === 0 && delete n.sp, n.drawCount === void 0 && delete n.drawCount, n.workerTasksqueueCount === void 0 && delete n.workerTasksqueueCount, (n != null && n.drawCount || n != null && n.workerTasksqueueCount || (s = n.sp) != null && s.length) && (console.log("mainThread-post-end--001", this.fullLayer.children.length, this.localLayer.children.length, this.topLayer.children.length, this.serviceLayer.children.length), this.opt.post(n));
5077
+ const n = this.combinePostData(), e = (t = n.sp) == null ? void 0 : t.filter((i) => i.type !== y.None || Object.keys(i).filter((r) => r === "type").length);
5078
+ e != null && e.length && (n.sp = e.map((i) => i.viewId ? i : { ...i, viewId: this.viewId })), ((o = n.sp) == null ? void 0 : o.length) === 0 && delete n.sp, n.drawCount === void 0 && delete n.drawCount, (n != null && n.drawCount || (s = n.sp) != null && s.length) && this.opt.post(n);
5042
5079
  }
5043
5080
  clearAll() {
5044
5081
  this.fullLayer.children.length && (this.fullLayer.parent.children.forEach((n) => {
5045
5082
  n.name !== "viewport" && n.remove();
5046
- }), this.fullLayer.removeAllChildren()), this.localWork.clearAll(), this.topWork.clearAll(), this.serviceWork.clearAll(), this.vNodes.clear();
5083
+ }), this.fullLayer.removeAllChildren()), this.localWork.clearAll(), this.topWork.clearAll(), this.serviceWork.clearAll(), this.vNodes.clear(), this.post({
5084
+ sp: [{
5085
+ type: y.Clear
5086
+ }]
5087
+ });
5047
5088
  }
5048
5089
  consumeDrawAll(n, e) {
5049
5090
  const { ops: t, op: o, workId: s } = e;
5050
5091
  if ((t || o != null && o.length) && s) {
5051
- if (this.topWork.localWorkShapes.get(s)) {
5092
+ const i = s.toString();
5093
+ if (this.topWork.localWorkShapes.get(i)) {
5052
5094
  this.topWork.consumeDrawAll(e);
5053
5095
  return;
5054
5096
  }
5055
- if (this.localWork.workShapes.get(s)) {
5097
+ if (this.localWork.workShapes.get(i)) {
5056
5098
  this.localWork.consumeDrawAll(e, this.serviceWork);
5057
5099
  return;
5058
5100
  }
@@ -5061,11 +5103,12 @@ class me {
5061
5103
  consumeDraw(n, e) {
5062
5104
  const { op: t, workId: o } = e;
5063
5105
  if (t != null && t.length && o) {
5064
- if (this.topWork.localWorkShapes.get(o)) {
5106
+ const s = o.toString();
5107
+ if (this.topWork.localWorkShapes.get(s)) {
5065
5108
  this.topWork.consumeDraw(e);
5066
5109
  return;
5067
5110
  }
5068
- if (this.localWork.workShapes.get(o)) {
5111
+ if (this.localWork.workShapes.get(s)) {
5069
5112
  this.localWork.consumeDraw(e, this.serviceWork);
5070
5113
  return;
5071
5114
  }
@@ -5073,16 +5116,16 @@ class me {
5073
5116
  }
5074
5117
  }
5075
5118
  updateCamera(n) {
5076
- var t;
5077
- const { cameraOpt: e } = n;
5119
+ var o;
5120
+ const { cameraOpt: e, scenePath: t } = n;
5078
5121
  if (e && !ct(this.cameraOpt, e)) {
5079
- const o = this.localWork.getWorkShape(kt);
5080
- if (o && ((t = o.selectIds) != null && t.length) && o.cursorBlur(), this.setCameraOpt(e), this.vNodes.curNodeMap.size && (this.vNodes.updateNodesRect(), this.localWork.reRenderSelector(), this.serviceWork.selectorWorkShapes.size))
5081
- for (const [s, i] of this.serviceWork.selectorWorkShapes.entries())
5122
+ const s = this.localWork.getWorkShape(mt);
5123
+ if (s && ((o = s.selectIds) != null && o.length) && s.cursorBlur(), t && [...this.localWork.getWorkShapes().keys()].filter((r) => r !== mt).length && this.localWork.workShapesDone(t, this.serviceWork), this.setCameraOpt(e), this.vNodes.curNodeMap.size && (this.vNodes.clearTarget(), this.vNodes.updateNodesRect(), this.localWork.reRenderSelector(), this.serviceWork.selectorWorkShapes.size))
5124
+ for (const [i, r] of this.serviceWork.selectorWorkShapes.entries())
5082
5125
  this.serviceWork.runSelectWork({
5083
- workId: s,
5084
- selectIds: i.selectIds,
5085
- msgType: w.Select,
5126
+ workId: i,
5127
+ selectIds: r.selectIds,
5128
+ msgType: y.Select,
5086
5129
  dataType: C.Service,
5087
5130
  viewId: this.viewId
5088
5131
  });
@@ -5094,7 +5137,8 @@ class me {
5094
5137
  depth: !1,
5095
5138
  desynchronized: !0,
5096
5139
  ...n,
5097
- autoRender: !0
5140
+ autoRender: !0,
5141
+ id: this.viewId
5098
5142
  });
5099
5143
  }
5100
5144
  createLayer(n, e, t) {
@@ -5138,26 +5182,26 @@ class ye {
5138
5182
  async on(n) {
5139
5183
  const { msgType: e } = n;
5140
5184
  switch (e) {
5141
- case w.Snapshot:
5185
+ case y.Snapshot:
5142
5186
  await this.getSnapshot(n), this.destroy();
5143
5187
  return;
5144
- case w.BoundingBox:
5188
+ case y.BoundingBox:
5145
5189
  await this.getBoundingRect(n), this.destroy();
5146
5190
  return;
5147
5191
  }
5148
5192
  }
5149
5193
  createWorkShapeNode(n) {
5150
- return yt({ ...n, fullLayer: this.fullLayer, drawLayer: void 0 });
5194
+ return wt({ ...n, fullLayer: this.fullLayer, drawLayer: void 0 });
5151
5195
  }
5152
5196
  setFullWork(n) {
5153
5197
  const { workId: e, opt: t, toolsType: o } = n;
5154
5198
  if (e && t && o) {
5155
- const s = e && this.workShapes.get(e) || this.createWorkShapeNode({
5199
+ const s = e.toString(), i = this.workShapes.get(s) || this.createWorkShapeNode({
5156
5200
  toolsOpt: t,
5157
5201
  toolsType: o,
5158
- workId: e
5202
+ workId: s
5159
5203
  });
5160
- return s ? (s.setWorkId(e), this.workShapes.set(e, s), s) : void 0;
5204
+ return i ? (i.setWorkId(e.toString()), this.workShapes.set(s, i), i) : void 0;
5161
5205
  }
5162
5206
  }
5163
5207
  async runFullWork(n) {
@@ -5189,13 +5233,13 @@ class ye {
5189
5233
  for (const [c, l] of Object.entries(t))
5190
5234
  if (l != null && l.type)
5191
5235
  switch (l == null ? void 0 : l.type) {
5192
- case w.UpdateNode:
5193
- case w.FullWork: {
5236
+ case y.UpdateNode:
5237
+ case y.FullWork: {
5194
5238
  const { opt: h } = l, p = await this.runFullWork({
5195
5239
  ...l,
5196
5240
  opt: h,
5197
5241
  workId: c,
5198
- msgType: w.FullWork,
5242
+ msgType: y.FullWork,
5199
5243
  dataType: C.Service,
5200
5244
  viewId: this.viewId
5201
5245
  });
@@ -5220,7 +5264,7 @@ class ye {
5220
5264
  };
5221
5265
  }
5222
5266
  getRectImageBitmap(n, e) {
5223
- const t = n.x * this.opt.displayer.dpr, o = n.y * this.opt.displayer.dpr, s = n.w * this.opt.displayer.dpr, i = n.h * this.opt.displayer.dpr;
5267
+ const t = n.x * this.opt.displayer.dpr, o = n.y * this.opt.displayer.dpr, s = n.w > 0 && n.w * this.opt.displayer.dpr || 1, i = n.h > 0 && n.h * this.opt.displayer.dpr || 1;
5224
5268
  return createImageBitmap(this.fullLayer.parent.canvas, t, o, s, i, e);
5225
5269
  }
5226
5270
  async getSnapshotRender(n) {
@@ -5230,7 +5274,7 @@ class ye {
5230
5274
  const o = await this.getRectImageBitmap(this.getSceneRect(), t);
5231
5275
  o && (this.post({
5232
5276
  sp: [{
5233
- type: w.Snapshot,
5277
+ type: y.Snapshot,
5234
5278
  scenePath: e,
5235
5279
  imageBitmap: o,
5236
5280
  viewId: this.viewId
@@ -5245,12 +5289,12 @@ class ye {
5245
5289
  for (const [i, r] of Object.entries(t))
5246
5290
  if (r != null && r.type)
5247
5291
  switch (r == null ? void 0 : r.type) {
5248
- case w.UpdateNode:
5249
- case w.FullWork: {
5292
+ case y.UpdateNode:
5293
+ case y.FullWork: {
5250
5294
  const a = await this.runFullWork({
5251
5295
  ...r,
5252
5296
  workId: i,
5253
- msgType: w.FullWork,
5297
+ msgType: y.FullWork,
5254
5298
  dataType: C.Service,
5255
5299
  viewId: this.viewId
5256
5300
  });
@@ -5260,7 +5304,7 @@ class ye {
5260
5304
  }
5261
5305
  s && this.post({
5262
5306
  sp: [{
5263
- type: w.BoundingBox,
5307
+ type: y.BoundingBox,
5264
5308
  scenePath: e,
5265
5309
  rect: s
5266
5310
  }]
@@ -5295,8 +5339,8 @@ class ye {
5295
5339
  }
5296
5340
  combinePost() {
5297
5341
  var t, o, s;
5298
- const n = this.combinePostData(), e = (t = n.sp) == null ? void 0 : t.filter((i) => i.type !== w.None || Object.keys(i).filter((r) => r === "type").length);
5299
- e != null && e.length && (n.sp = e.map((i) => i.viewId ? i : { ...i, viewId: this.viewId })), ((o = n.sp) == null ? void 0 : o.length) === 0 && delete n.sp, (n != null && n.drawCount || n != null && n.workerTasksqueueCount || (s = n.sp) != null && s.length) && (console.log("mainThread-post-end--001", this.fullLayer.children.length), this.opt.post(n));
5342
+ const n = this.combinePostData(), e = (t = n.sp) == null ? void 0 : t.filter((i) => i.type !== y.None || Object.keys(i).filter((r) => r === "type").length);
5343
+ e != null && e.length && (n.sp = e.map((i) => i.viewId ? i : { ...i, viewId: this.viewId })), ((o = n.sp) == null ? void 0 : o.length) === 0 && delete n.sp, (n != null && n.drawCount || (s = n.sp) != null && s.length) && this.opt.post(n);
5300
5344
  }
5301
5345
  createScene(n) {
5302
5346
  return new Nt({
@@ -5330,7 +5374,7 @@ class ye {
5330
5374
  this.fullLayer.remove(), this.scene.remove();
5331
5375
  }
5332
5376
  }
5333
- class Ne {
5377
+ class We {
5334
5378
  constructor(n) {
5335
5379
  m(this, "mainThreadMap", /* @__PURE__ */ new Map());
5336
5380
  m(this, "snapshotThread");
@@ -5339,7 +5383,7 @@ class Ne {
5339
5383
  }
5340
5384
  post(n) {
5341
5385
  const { drawCount: e, sp: t, workerTasksqueueCount: o } = n;
5342
- console.log("mainThread-post-end", n), V(o) && this.master.setWorkerTasksqueueCount(o), V(e) && this.master.setMaxDrawCount(e), t && this.master.collectorSyncData(t);
5386
+ this.master.isBusy && q(o) && this.master.setWorkerTasksqueueCount(o), q(e) && this.master.setMaxDrawCount(e), t && this.master.collectorSyncData(t);
5343
5387
  }
5344
5388
  destroy() {
5345
5389
  this.mainThreadMap.clear();
@@ -5350,69 +5394,69 @@ class Ne {
5350
5394
  createSnapshotThread(n, e) {
5351
5395
  return new ye(n, e);
5352
5396
  }
5353
- consume(n) {
5397
+ async consume(n) {
5354
5398
  var e, t, o, s;
5355
5399
  for (const i of n.values()) {
5356
- const { msgType: r, viewId: a, tasksqueue: c, mainTasksqueueCount: l, layerOpt: h, offscreenCanvasOpt: p, cameraOpt: f } = i;
5357
- if (r === w.Init) {
5358
- const u = (e = this.master.control.viewContainerManager.getView(a)) == null ? void 0 : e.displayer, y = u == null ? void 0 : u.canvasContainerRef.current;
5359
- if (u && y && h && p) {
5360
- const k = this.createMainThread(a, {
5361
- displayer: u,
5362
- container: y,
5400
+ const { msgType: r, viewId: a, tasksqueue: c, mainTasksqueueCount: l, layerOpt: h, offscreenCanvasOpt: p, cameraOpt: u } = i;
5401
+ if (r === y.Init) {
5402
+ const f = (e = this.master.control.viewContainerManager.getView(a)) == null ? void 0 : e.displayer, w = f == null ? void 0 : f.canvasContainerRef.current;
5403
+ if (f && w && h && p) {
5404
+ const S = this.createMainThread(a, {
5405
+ displayer: f,
5406
+ container: w,
5363
5407
  layerOpt: h,
5364
5408
  master: this.master,
5365
5409
  canvasOpt: p,
5366
5410
  post: this.post.bind(this)
5367
5411
  });
5368
- this.mainThreadMap.set(a, k), k && f && k.setCameraOpt(f);
5412
+ this.mainThreadMap.set(a, S), S && u && S.setCameraOpt(u);
5369
5413
  }
5370
5414
  continue;
5371
5415
  }
5372
- if ((r === w.Snapshot || r === w.BoundingBox) && a === ((t = this.master.control.viewContainerManager.mainView) == null ? void 0 : t.id)) {
5373
- const u = (o = this.master.control.viewContainerManager.getView(a)) == null ? void 0 : o.displayer, y = (s = u.snapshotContainerRef) == null ? void 0 : s.current;
5374
- if (u && y && f) {
5375
- y.style.width = `${f.width}px`, y.style.height = `${f.height}px`;
5376
- const k = {
5416
+ if ((r === y.Snapshot || r === y.BoundingBox) && a === ((t = this.master.control.viewContainerManager.mainView) == null ? void 0 : t.id)) {
5417
+ const f = (o = this.master.control.viewContainerManager.getView(a)) == null ? void 0 : o.displayer, w = (s = f.snapshotContainerRef) == null ? void 0 : s.current;
5418
+ if (f && w && u) {
5419
+ w.style.width = `${u.width}px`, w.style.height = `${u.height}px`;
5420
+ const S = {
5377
5421
  ...Pt.defaultLayerOpt,
5378
5422
  offscreen: !1,
5379
- width: f.width,
5380
- height: f.height
5423
+ width: u.width,
5424
+ height: u.height
5381
5425
  }, b = {
5382
5426
  ...Pt.defaultScreenCanvasOpt,
5383
- width: f.width,
5384
- height: f.height
5427
+ width: u.width,
5428
+ height: u.height
5385
5429
  };
5386
5430
  this.snapshotThread = this.createSnapshotThread(a, {
5387
- displayer: u,
5388
- container: y,
5389
- layerOpt: k,
5431
+ displayer: f,
5432
+ container: w,
5433
+ layerOpt: S,
5390
5434
  master: this.master,
5391
5435
  canvasOpt: b,
5392
5436
  post: this.post.bind(this)
5393
5437
  }), this.snapshotThread.on(i).then(() => {
5394
- this.snapshotThread = void 0, y.innerHTML = "", y.style.width = "", y.style.height = "";
5438
+ this.snapshotThread = void 0, w.innerHTML = "", w.style.width = "", w.style.height = "";
5395
5439
  });
5396
5440
  continue;
5397
5441
  }
5398
5442
  }
5399
- if (r === w.TasksQueue && (c != null && c.size) && l) {
5400
- for (const [u, y] of this.mainThreadMap.entries()) {
5401
- const k = c.get(u);
5402
- k && y.on(k, l);
5443
+ if (r === y.TasksQueue && (c != null && c.size)) {
5444
+ for (const [f, w] of this.mainThreadMap.entries()) {
5445
+ const S = c.get(f);
5446
+ S && (await w.on(S), l && this.post({ workerTasksqueueCount: l }));
5403
5447
  }
5404
5448
  continue;
5405
5449
  }
5406
- if (a === qt) {
5407
- for (const u of this.mainThreadMap.values())
5408
- u.on(i), r === w.Destroy && this.mainThreadMap.delete(a);
5450
+ if (a === Gt) {
5451
+ for (const f of this.mainThreadMap.values())
5452
+ f.on(i), r === y.Destroy && this.mainThreadMap.delete(a);
5409
5453
  continue;
5410
5454
  }
5411
5455
  const d = this.mainThreadMap.get(a);
5412
- d && (d.on(i), r === w.Destroy && this.mainThreadMap.delete(a));
5456
+ d && (d.on(i), r === y.Destroy && this.mainThreadMap.delete(a));
5413
5457
  }
5414
5458
  }
5415
5459
  }
5416
5460
  export {
5417
- Ne as MainThreadManagerImpl
5461
+ We as MainThreadManagerImpl
5418
5462
  };