@idraw/util 0.3.0 → 0.4.0-alpha.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 (55) hide show
  1. package/dist/esm/index.d.ts +26 -71
  2. package/dist/esm/index.js +26 -29
  3. package/dist/esm/lib/canvas.d.ts +15 -0
  4. package/dist/esm/lib/canvas.js +36 -0
  5. package/dist/esm/lib/check.d.ts +8 -8
  6. package/dist/esm/lib/check.js +32 -33
  7. package/dist/esm/lib/color.d.ts +1 -0
  8. package/dist/esm/lib/color.js +152 -1
  9. package/dist/esm/lib/context2d.d.ts +75 -0
  10. package/dist/esm/lib/context2d.js +226 -0
  11. package/dist/esm/lib/controller.d.ts +6 -0
  12. package/dist/esm/lib/controller.js +99 -0
  13. package/dist/esm/lib/data.d.ts +5 -1
  14. package/dist/esm/lib/data.js +67 -2
  15. package/dist/esm/lib/element.d.ts +18 -0
  16. package/dist/esm/lib/element.js +241 -0
  17. package/dist/esm/lib/event.d.ts +9 -0
  18. package/dist/esm/lib/event.js +50 -0
  19. package/dist/esm/lib/html.d.ts +3 -0
  20. package/dist/esm/lib/html.js +170 -0
  21. package/dist/esm/lib/image.d.ts +4 -0
  22. package/dist/esm/lib/image.js +27 -0
  23. package/dist/esm/lib/is.d.ts +4 -2
  24. package/dist/esm/lib/is.js +34 -15
  25. package/dist/esm/lib/istype.d.ts +1 -2
  26. package/dist/esm/lib/istype.js +3 -4
  27. package/dist/esm/lib/{loader.js → load.js} +2 -2
  28. package/dist/esm/lib/middleware.d.ts +3 -0
  29. package/dist/esm/lib/middleware.js +22 -0
  30. package/dist/esm/lib/number.d.ts +3 -0
  31. package/dist/esm/lib/number.js +4 -0
  32. package/dist/esm/lib/parser.js +4 -1
  33. package/dist/esm/lib/point.d.ts +8 -0
  34. package/dist/esm/lib/point.js +30 -0
  35. package/dist/esm/lib/rect.d.ts +2 -0
  36. package/dist/esm/lib/rect.js +11 -0
  37. package/dist/esm/lib/rotate.d.ts +13 -0
  38. package/dist/esm/lib/rotate.js +205 -0
  39. package/dist/esm/lib/store.d.ts +12 -0
  40. package/dist/esm/lib/store.js +22 -0
  41. package/dist/esm/lib/svg-path.d.ts +10 -0
  42. package/dist/esm/lib/svg-path.js +36 -0
  43. package/dist/esm/lib/uuid.d.ts +2 -0
  44. package/dist/esm/lib/uuid.js +27 -2
  45. package/dist/esm/lib/vertex.d.ts +10 -0
  46. package/dist/esm/lib/vertex.js +73 -0
  47. package/dist/esm/lib/view-calc.d.ts +49 -0
  48. package/dist/esm/lib/view-calc.js +167 -0
  49. package/dist/index.global.js +1706 -330
  50. package/dist/index.global.min.js +1 -1
  51. package/package.json +4 -4
  52. package/LICENSE +0 -21
  53. package/dist/esm/lib/context.d.ts +0 -80
  54. package/dist/esm/lib/context.js +0 -194
  55. /package/dist/esm/lib/{loader.d.ts → load.d.ts} +0 -0
@@ -54,13 +54,189 @@ var iDrawUtil = function(exports) {
54
54
  return "#" + color2.toString(16);
55
55
  }
56
56
  function isColorStr(color2) {
57
- return typeof color2 === "string" && /^\#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(color2);
57
+ return typeof color2 === "string" && (/^\#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(color2) || /^[a-z]{1,}$/i.test(color2));
58
+ }
59
+ const colorNameMap = {
60
+ aliceblue: "#f0f8ff",
61
+ antiquewhite: "#faebd7",
62
+ aqua: "#00ffff",
63
+ aquamarine: "#7fffd4",
64
+ azure: "#f0ffff",
65
+ beige: "#f5f5dc",
66
+ bisque: "#ffe4c4",
67
+ black: "#000000",
68
+ blanchedalmond: "#ffebcd",
69
+ blue: "#0000ff",
70
+ blueviolet: "#8a2be2",
71
+ brown: "#a52a2a",
72
+ burlywood: "#deb887",
73
+ cadetblue: "#5f9ea0",
74
+ chartreuse: "#7fff00",
75
+ chocolate: "#d2691e",
76
+ coral: "#ff7f50",
77
+ cornflowerblue: "#6495ed",
78
+ cornsilk: "#fff8dc",
79
+ crimson: "#dc143c",
80
+ cyan: "#00ffff",
81
+ darkblue: "#00008b",
82
+ darkcyan: "#008b8b",
83
+ darkgoldenrod: "#b8860b",
84
+ darkgray: "#a9a9a9",
85
+ darkgreen: "#006400",
86
+ darkkhaki: "#bdb76b",
87
+ darkmagenta: "#8b008b",
88
+ darkolivegreen: "#556b2f",
89
+ darkorange: "#ff8c00",
90
+ darkorchid: "#9932cc",
91
+ darkred: "#8b0000",
92
+ darksalmon: "#e9967a",
93
+ darkseagreen: "#8fbc8f",
94
+ darkslateblue: "#483d8b",
95
+ darkslategray: "#2f4f4f",
96
+ darkturquoise: "#00ced1",
97
+ darkviolet: "#9400d3",
98
+ deeppink: "#ff1493",
99
+ deepskyblue: "#00bfff",
100
+ dimgray: "#696969",
101
+ dodgerblue: "#1e90ff",
102
+ firebrick: "#b22222",
103
+ floralwhite: "#fffaf0",
104
+ forestgreen: "#228b22",
105
+ fuchsia: "#ff00ff",
106
+ gainsboro: "#dcdcdc",
107
+ ghostwhite: "#f8f8ff",
108
+ gold: "#ffd700",
109
+ goldenrod: "#daa520",
110
+ gray: "#808080",
111
+ green: "#008000",
112
+ greenyellow: "#adff2f",
113
+ honeydew: "#f0fff0",
114
+ hotpink: "#ff69b4",
115
+ "indianred ": "#cd5c5c",
116
+ indigo: "#4b0082",
117
+ ivory: "#fffff0",
118
+ khaki: "#f0e68c",
119
+ lavender: "#e6e6fa",
120
+ lavenderblush: "#fff0f5",
121
+ lawngreen: "#7cfc00",
122
+ lemonchiffon: "#fffacd",
123
+ lightblue: "#add8e6",
124
+ lightcoral: "#f08080",
125
+ lightcyan: "#e0ffff",
126
+ lightgoldenrodyellow: "#fafad2",
127
+ lightgrey: "#d3d3d3",
128
+ lightgreen: "#90ee90",
129
+ lightpink: "#ffb6c1",
130
+ lightsalmon: "#ffa07a",
131
+ lightseagreen: "#20b2aa",
132
+ lightskyblue: "#87cefa",
133
+ lightslategray: "#778899",
134
+ lightsteelblue: "#b0c4de",
135
+ lightyellow: "#ffffe0",
136
+ lime: "#00ff00",
137
+ limegreen: "#32cd32",
138
+ linen: "#faf0e6",
139
+ magenta: "#ff00ff",
140
+ maroon: "#800000",
141
+ mediumaquamarine: "#66cdaa",
142
+ mediumblue: "#0000cd",
143
+ mediumorchid: "#ba55d3",
144
+ mediumpurple: "#9370d8",
145
+ mediumseagreen: "#3cb371",
146
+ mediumslateblue: "#7b68ee",
147
+ mediumspringgreen: "#00fa9a",
148
+ mediumturquoise: "#48d1cc",
149
+ mediumvioletred: "#c71585",
150
+ midnightblue: "#191970",
151
+ mintcream: "#f5fffa",
152
+ mistyrose: "#ffe4e1",
153
+ moccasin: "#ffe4b5",
154
+ navajowhite: "#ffdead",
155
+ navy: "#000080",
156
+ oldlace: "#fdf5e6",
157
+ olive: "#808000",
158
+ olivedrab: "#6b8e23",
159
+ orange: "#ffa500",
160
+ orangered: "#ff4500",
161
+ orchid: "#da70d6",
162
+ palegoldenrod: "#eee8aa",
163
+ palegreen: "#98fb98",
164
+ paleturquoise: "#afeeee",
165
+ palevioletred: "#d87093",
166
+ papayawhip: "#ffefd5",
167
+ peachpuff: "#ffdab9",
168
+ peru: "#cd853f",
169
+ pink: "#ffc0cb",
170
+ plum: "#dda0dd",
171
+ powderblue: "#b0e0e6",
172
+ purple: "#800080",
173
+ rebeccapurple: "#663399",
174
+ red: "#ff0000",
175
+ rosybrown: "#bc8f8f",
176
+ royalblue: "#4169e1",
177
+ saddlebrown: "#8b4513",
178
+ salmon: "#fa8072",
179
+ sandybrown: "#f4a460",
180
+ seagreen: "#2e8b57",
181
+ seashell: "#fff5ee",
182
+ sienna: "#a0522d",
183
+ silver: "#c0c0c0",
184
+ skyblue: "#87ceeb",
185
+ slateblue: "#6a5acd",
186
+ slategray: "#708090",
187
+ snow: "#fffafa",
188
+ springgreen: "#00ff7f",
189
+ steelblue: "#4682b4",
190
+ tan: "#d2b48c",
191
+ teal: "#008080",
192
+ thistle: "#d8bfd8",
193
+ tomato: "#ff6347",
194
+ turquoise: "#40e0d0",
195
+ violet: "#ee82ee",
196
+ wheat: "#f5deb3",
197
+ white: "#ffffff",
198
+ whitesmoke: "#f5f5f5",
199
+ yellow: "#ffff00",
200
+ yellowgreen: "#9acd32"
201
+ };
202
+ function colorNameToHex(name) {
203
+ const n = name.toLowerCase();
204
+ const hex = colorNameMap[n];
205
+ if (typeof hex === "string") {
206
+ return hex;
207
+ }
208
+ return null;
58
209
  }
59
210
  function createUUID() {
60
- function str4() {
211
+ function _createStr() {
61
212
  return ((1 + Math.random()) * 65536 | 0).toString(16).substring(1);
62
213
  }
63
- return `${str4()}${str4()}-${str4()}-${str4()}-${str4()}-${str4()}${str4()}${str4()}`;
214
+ return `${_createStr()}${_createStr()}-${_createStr()}-${_createStr()}-${_createStr()}-${_createStr()}${_createStr()}${_createStr()}`;
215
+ }
216
+ function limitHexStr(str) {
217
+ let count = 0;
218
+ for (let i = 0; i < str.length; i++) {
219
+ count += str.charCodeAt(i) * str.charCodeAt(i) * i * i;
220
+ }
221
+ return count.toString(16).substring(0, 4);
222
+ }
223
+ function createAssetId(assetStr) {
224
+ const len = assetStr.length;
225
+ const mid = Math.floor(len / 2);
226
+ const start4 = assetStr.substring(0, 4).padEnd(4, "0");
227
+ const end4 = assetStr.substring(0, 4).padEnd(4, "0");
228
+ const str1 = limitHexStr(len.toString(16).padEnd(4, start4));
229
+ const str2 = limitHexStr(assetStr.substring(mid - 4, mid).padEnd(4, start4)).padEnd(4, "f");
230
+ const str3 = limitHexStr(assetStr.substring(mid - 8, mid - 4).padEnd(4, start4)).padEnd(4, "f");
231
+ const str4 = limitHexStr(assetStr.substring(mid - 12, mid - 8).padEnd(4, start4)).padEnd(4, "f");
232
+ const str5 = limitHexStr(assetStr.substring(mid - 16, mid - 12).padEnd(4, end4)).padEnd(4, "f");
233
+ const str6 = limitHexStr(assetStr.substring(mid, mid + 4).padEnd(4, end4)).padEnd(4, "f");
234
+ const str7 = limitHexStr(assetStr.substring(mid + 4, mid + 8).padEnd(4, end4)).padEnd(4, "f");
235
+ const str8 = limitHexStr(end4.padEnd(4, start4).padEnd(4, end4));
236
+ return `@assets/${str1}${str2}-${str3}-${str4}-${str5}-${str6}${str7}${str8}`;
237
+ }
238
+ function isAssetId(id) {
239
+ return /^@assets\/[0-9a-z]{8,8}\-[0-9a-z]{4,4}\-[0-9a-z]{4,4}\-[0-9a-z]{4,4}\-[0-9a-z]{12,12}$/.test(`${id}`);
64
240
  }
65
241
  function deepClone(target) {
66
242
  function _clone(t) {
@@ -79,20 +255,78 @@ var iDrawUtil = function(exports) {
79
255
  keys.forEach((key) => {
80
256
  obj[key] = _clone(t[key]);
81
257
  });
258
+ const symbolKeys = Object.getOwnPropertySymbols(t);
259
+ symbolKeys.forEach((key) => {
260
+ obj[key] = _clone(t[key]);
261
+ });
82
262
  return obj;
83
263
  }
84
264
  }
85
265
  return _clone(target);
86
266
  }
87
- function is$1(data) {
88
- return Object.prototype.toString.call(data).replace(/[\]|\[]{1,1}/ig, "").split(" ")[1];
267
+ function is$1(target) {
268
+ return Object.prototype.toString.call(target).replace(/[\]|\[]{1,1}/gi, "").split(" ")[1];
269
+ }
270
+ function sortDataAsserts(data, opts) {
271
+ const assets = data.assets || {};
272
+ let sortedData = data;
273
+ if ((opts == null ? void 0 : opts.clone) === true) {
274
+ sortedData = deepClone(data);
275
+ }
276
+ const _scanElements = (elems) => {
277
+ elems.forEach((elem) => {
278
+ if (elem.type === "image" && elem.detail.src) {
279
+ const src = elem.detail.src;
280
+ const assetUUID = createAssetId(src);
281
+ if (!assets[assetUUID]) {
282
+ assets[assetUUID] = {
283
+ type: "image",
284
+ value: src
285
+ };
286
+ }
287
+ elem.detail.src = assetUUID;
288
+ } else if (elem.type === "svg") {
289
+ const svg2 = elem.detail.svg;
290
+ const assetUUID = createAssetId(svg2);
291
+ if (!assets[assetUUID]) {
292
+ assets[assetUUID] = {
293
+ type: "svg",
294
+ value: svg2
295
+ };
296
+ }
297
+ elem.detail.svg = assetUUID;
298
+ } else if (elem.type === "html") {
299
+ const html2 = elem.detail.html;
300
+ const assetUUID = createAssetId(html2);
301
+ if (!assets[assetUUID]) {
302
+ assets[assetUUID] = {
303
+ type: "svg",
304
+ value: html2
305
+ };
306
+ }
307
+ elem.detail.html = assetUUID;
308
+ } else if (elem.type === "group" && Array.isArray(elem.detail.children)) {
309
+ const groupAssets = elem.detail.assets || {};
310
+ Object.keys(groupAssets).forEach((assetId) => {
311
+ if (!assets[assetId]) {
312
+ assets[assetId] = groupAssets[assetId];
313
+ }
314
+ });
315
+ delete elem.detail.assets;
316
+ _scanElements(elem.detail.children);
317
+ }
318
+ });
319
+ };
320
+ _scanElements(sortedData.elements);
321
+ sortedData.assets = assets;
322
+ return sortedData;
89
323
  }
90
324
  function parsePrototype(data) {
91
325
  const typeStr = Object.prototype.toString.call(data) || "";
92
- const result = typeStr.replace(/(\[object|\])/ig, "").trim();
326
+ const result = typeStr.replace(/(\[object|\])/gi, "").trim();
93
327
  return result;
94
328
  }
95
- const istype = {
329
+ const istype$1 = {
96
330
  type(data, lowerCase) {
97
331
  const result = parsePrototype(data);
98
332
  return lowerCase === true ? result.toLocaleLowerCase() : result;
@@ -135,7 +369,10 @@ var iDrawUtil = function(exports) {
135
369
  const { width, height } = opts;
136
370
  return new Promise((resolve, reject) => {
137
371
  const _svg = `
138
- <svg xmlns="http://www.w3.org/2000/svg" width="${width || ""}" height = "${height || ""}">
372
+ <svg
373
+ xmlns="http://www.w3.org/2000/svg"
374
+ width="${width || ""}"
375
+ height = "${height || ""}">
139
376
  <foreignObject width="100%" height="100%">
140
377
  <div xmlns = "http://www.w3.org/1999/xhtml">
141
378
  ${html2}
@@ -172,10 +409,10 @@ var iDrawUtil = function(exports) {
172
409
  };
173
410
  });
174
411
  }
175
- const { Image } = window;
412
+ const { Image: Image$1 } = window;
176
413
  function loadImage(src) {
177
414
  return new Promise((resolve, reject) => {
178
- const img = new Image();
415
+ const img = new Image$1();
179
416
  img.crossOrigin = "anonymous";
180
417
  img.onload = function() {
181
418
  resolve(img);
@@ -191,7 +428,7 @@ var iDrawUtil = function(exports) {
191
428
  return image;
192
429
  }
193
430
  function filterAmpersand(str) {
194
- return str.replace(/\&/ig, "&amp;");
431
+ return str.replace(/\&/gi, "&amp;");
195
432
  }
196
433
  async function loadHTML(html2, opts) {
197
434
  html2 = filterAmpersand(html2);
@@ -199,262 +436,6 @@ var iDrawUtil = function(exports) {
199
436
  const image = await loadImage(dataURL);
200
437
  return image;
201
438
  }
202
- class Context {
203
- // private _scale: number;
204
- // private _scrollX: number;
205
- // private _scrollY: number;
206
- constructor(ctx, opts) {
207
- this._opts = opts;
208
- this._ctx = ctx;
209
- this._transform = {
210
- scale: 1,
211
- scrollX: 0,
212
- scrollY: 0
213
- };
214
- }
215
- getContext() {
216
- return this._ctx;
217
- }
218
- resetSize(opts) {
219
- this._opts = { ...this._opts, ...opts };
220
- }
221
- calcDeviceNum(num) {
222
- return num * this._opts.devicePixelRatio;
223
- }
224
- calcScreenNum(num) {
225
- return num / this._opts.devicePixelRatio;
226
- }
227
- getSize() {
228
- return {
229
- width: this._opts.width,
230
- height: this._opts.height,
231
- contextWidth: this._opts.contextWidth,
232
- contextHeight: this._opts.contextHeight,
233
- devicePixelRatio: this._opts.devicePixelRatio
234
- };
235
- }
236
- setTransform(config) {
237
- this._transform = { ...this._transform, ...config };
238
- }
239
- getTransform() {
240
- return {
241
- scale: this._transform.scale,
242
- scrollX: this._transform.scrollX,
243
- scrollY: this._transform.scrollY
244
- };
245
- }
246
- setFillStyle(color2) {
247
- this._ctx.fillStyle = color2;
248
- }
249
- fill(fillRule) {
250
- return this._ctx.fill(fillRule || "nonzero");
251
- }
252
- arc(x2, y2, radius, startAngle, endAngle, anticlockwise) {
253
- return this._ctx.arc(
254
- this._doSize(x2),
255
- this._doSize(y2),
256
- this._doSize(radius),
257
- startAngle,
258
- endAngle,
259
- anticlockwise
260
- );
261
- }
262
- rect(x2, y2, w2, h2) {
263
- return this._ctx.rect(
264
- this._doSize(x2),
265
- this._doSize(y2),
266
- this._doSize(w2),
267
- this._doSize(h2)
268
- );
269
- }
270
- fillRect(x2, y2, w2, h2) {
271
- return this._ctx.fillRect(
272
- this._doSize(x2),
273
- this._doSize(y2),
274
- this._doSize(w2),
275
- this._doSize(h2)
276
- );
277
- }
278
- clearRect(x2, y2, w2, h2) {
279
- return this._ctx.clearRect(
280
- this._doSize(x2),
281
- this._doSize(y2),
282
- this._doSize(w2),
283
- this._doSize(h2)
284
- );
285
- }
286
- beginPath() {
287
- return this._ctx.beginPath();
288
- }
289
- closePath() {
290
- return this._ctx.closePath();
291
- }
292
- lineTo(x2, y2) {
293
- return this._ctx.lineTo(this._doSize(x2), this._doSize(y2));
294
- }
295
- moveTo(x2, y2) {
296
- return this._ctx.moveTo(this._doSize(x2), this._doSize(y2));
297
- }
298
- arcTo(x1, y1, x2, y2, radius) {
299
- return this._ctx.arcTo(
300
- this._doSize(x1),
301
- this._doSize(y1),
302
- this._doSize(x2),
303
- this._doSize(y2),
304
- this._doSize(radius)
305
- );
306
- }
307
- setLineWidth(w2) {
308
- return this._ctx.lineWidth = this._doSize(w2);
309
- }
310
- setLineDash(nums) {
311
- return this._ctx.setLineDash(nums.map((n) => this._doSize(n)));
312
- }
313
- isPointInPath(x2, y2) {
314
- return this._ctx.isPointInPath(this._doX(x2), this._doY(y2));
315
- }
316
- isPointInPathWithoutScroll(x2, y2) {
317
- return this._ctx.isPointInPath(this._doSize(x2), this._doSize(y2));
318
- }
319
- setStrokeStyle(color2) {
320
- this._ctx.strokeStyle = color2;
321
- }
322
- stroke() {
323
- return this._ctx.stroke();
324
- }
325
- translate(x2, y2) {
326
- return this._ctx.translate(this._doSize(x2), this._doSize(y2));
327
- }
328
- rotate(angle2) {
329
- return this._ctx.rotate(angle2);
330
- }
331
- drawImage(...args) {
332
- const image = args[0];
333
- const sx = args[1];
334
- const sy = args[2];
335
- const sw = args[3];
336
- const sh = args[4];
337
- const dx = args[args.length - 4];
338
- const dy = args[args.length - 3];
339
- const dw = args[args.length - 2];
340
- const dh = args[args.length - 1];
341
- if (args.length === 9) {
342
- return this._ctx.drawImage(
343
- image,
344
- this._doSize(sx),
345
- this._doSize(sy),
346
- this._doSize(sw),
347
- this._doSize(sh),
348
- this._doSize(dx),
349
- this._doSize(dy),
350
- this._doSize(dw),
351
- this._doSize(dh)
352
- );
353
- } else {
354
- return this._ctx.drawImage(
355
- image,
356
- this._doSize(dx),
357
- this._doSize(dy),
358
- this._doSize(dw),
359
- this._doSize(dh)
360
- );
361
- }
362
- }
363
- createPattern(image, repetition) {
364
- return this._ctx.createPattern(image, repetition);
365
- }
366
- measureText(text2) {
367
- return this._ctx.measureText(text2);
368
- }
369
- setTextAlign(align) {
370
- this._ctx.textAlign = align;
371
- }
372
- fillText(text2, x2, y2, maxWidth) {
373
- if (maxWidth !== void 0) {
374
- return this._ctx.fillText(
375
- text2,
376
- this._doSize(x2),
377
- this._doSize(y2),
378
- this._doSize(maxWidth)
379
- );
380
- } else {
381
- return this._ctx.fillText(text2, this._doSize(x2), this._doSize(y2));
382
- }
383
- }
384
- strokeText(text2, x2, y2, maxWidth) {
385
- if (maxWidth !== void 0) {
386
- return this._ctx.strokeText(
387
- text2,
388
- this._doSize(x2),
389
- this._doSize(y2),
390
- this._doSize(maxWidth)
391
- );
392
- } else {
393
- return this._ctx.strokeText(text2, this._doSize(x2), this._doSize(y2));
394
- }
395
- }
396
- setFont(opts) {
397
- const strList = [];
398
- if (opts.fontWeight === "bold") {
399
- strList.push(`${opts.fontWeight}`);
400
- }
401
- strList.push(`${this._doSize(opts.fontSize || 12)}px`);
402
- strList.push(`${opts.fontFamily || "sans-serif"}`);
403
- this._ctx.font = `${strList.join(" ")}`;
404
- }
405
- setTextBaseline(baseline) {
406
- this._ctx.textBaseline = baseline;
407
- }
408
- setGlobalAlpha(alpha) {
409
- this._ctx.globalAlpha = alpha;
410
- }
411
- save() {
412
- this._ctx.save();
413
- }
414
- restore() {
415
- this._ctx.restore();
416
- }
417
- scale(ratioX, ratioY) {
418
- this._ctx.scale(ratioX, ratioY);
419
- }
420
- setShadowColor(color2) {
421
- this._ctx.shadowColor = color2;
422
- }
423
- setShadowOffsetX(offsetX) {
424
- this._ctx.shadowOffsetX = this._doSize(offsetX);
425
- }
426
- setShadowOffsetY(offsetY) {
427
- this._ctx.shadowOffsetY = this._doSize(offsetY);
428
- }
429
- setShadowBlur(blur) {
430
- this._ctx.shadowBlur = this._doSize(blur);
431
- }
432
- ellipse(x2, y2, radiusX, radiusY, rotation, startAngle, endAngle, counterclockwise) {
433
- this._ctx.ellipse(
434
- this._doSize(x2),
435
- this._doSize(y2),
436
- this._doSize(radiusX),
437
- this._doSize(radiusY),
438
- rotation,
439
- startAngle,
440
- endAngle,
441
- counterclockwise
442
- );
443
- }
444
- _doSize(num) {
445
- return this._opts.devicePixelRatio * num;
446
- }
447
- _doX(x2) {
448
- const { scale, scrollX } = this._transform;
449
- const _x = (x2 - scrollX) / scale;
450
- return this._doSize(_x);
451
- }
452
- _doY(y2) {
453
- const { scale, scrollY } = this._transform;
454
- const _y = (y2 - scrollY) / scale;
455
- return this._doSize(_y);
456
- }
457
- }
458
439
  function number(value) {
459
440
  return typeof value === "number" && (value > 0 || value <= 0);
460
441
  }
@@ -527,6 +508,9 @@ var iDrawUtil = function(exports) {
527
508
  function fontWeight(value) {
528
509
  return ["bold"].includes(value);
529
510
  }
511
+ function numberStr(value) {
512
+ return /^(-?\d+(?:\.\d+)?)$/.test(`${value}`);
513
+ }
530
514
  const is = {
531
515
  x,
532
516
  y,
@@ -534,6 +518,7 @@ var iDrawUtil = function(exports) {
534
518
  h,
535
519
  angle,
536
520
  number,
521
+ numberStr,
537
522
  borderWidth,
538
523
  borderRadius,
539
524
  color,
@@ -560,76 +545,65 @@ var iDrawUtil = function(exports) {
560
545
  }
561
546
  return true;
562
547
  }
563
- function box(desc = {}) {
564
- const { borderColor, borderRadius: borderRadius2, borderWidth: borderWidth2 } = desc;
565
- if (desc.hasOwnProperty("borderColor") && !is.color(borderColor)) {
548
+ function box(detail = {}) {
549
+ const { borderColor, borderRadius: borderRadius2, borderWidth: borderWidth2 } = detail;
550
+ if (detail.hasOwnProperty("borderColor") && !is.color(borderColor)) {
566
551
  return false;
567
552
  }
568
- if (desc.hasOwnProperty("borderRadius") && !is.number(borderRadius2)) {
553
+ if (detail.hasOwnProperty("borderRadius") && !is.number(borderRadius2)) {
569
554
  return false;
570
555
  }
571
- if (desc.hasOwnProperty("borderWidth") && !is.number(borderWidth2)) {
556
+ if (detail.hasOwnProperty("borderWidth") && !is.number(borderWidth2)) {
572
557
  return false;
573
558
  }
574
559
  return true;
575
560
  }
576
- function rectDesc(desc) {
577
- const { bgColor } = desc;
578
- if (desc.hasOwnProperty("bgColor") && !is.color(bgColor)) {
561
+ function rectDesc(detail) {
562
+ const { background } = detail;
563
+ if (detail.hasOwnProperty("background") && !is.color(background)) {
579
564
  return false;
580
565
  }
581
- if (!box(desc)) {
566
+ if (!box(detail)) {
582
567
  return false;
583
568
  }
584
569
  return true;
585
570
  }
586
- function circleDesc(desc) {
587
- const { bgColor, borderColor, borderWidth: borderWidth2 } = desc;
588
- if (desc.hasOwnProperty("bgColor") && !is.color(bgColor)) {
571
+ function circleDesc(detail) {
572
+ const { background, borderColor, borderWidth: borderWidth2 } = detail;
573
+ if (detail.hasOwnProperty("background") && !is.color(background)) {
589
574
  return false;
590
575
  }
591
- if (desc.hasOwnProperty("borderColor") && !is.color(borderColor)) {
576
+ if (detail.hasOwnProperty("borderColor") && !is.color(borderColor)) {
592
577
  return false;
593
578
  }
594
- if (desc.hasOwnProperty("borderWidth") && !is.number(borderWidth2)) {
579
+ if (detail.hasOwnProperty("borderWidth") && !is.number(borderWidth2)) {
595
580
  return false;
596
581
  }
597
582
  return true;
598
583
  }
599
- function imageDesc(desc) {
600
- const { src } = desc;
584
+ function imageDesc(detail) {
585
+ const { src } = detail;
601
586
  if (!is.imageSrc(src)) {
602
587
  return false;
603
588
  }
604
589
  return true;
605
590
  }
606
- function svgDesc(desc) {
607
- const { svg: svg2 } = desc;
591
+ function svgDesc(detail) {
592
+ const { svg: svg2 } = detail;
608
593
  if (!is.svg(svg2)) {
609
594
  return false;
610
595
  }
611
596
  return true;
612
597
  }
613
- function htmlDesc(desc) {
614
- const { html: html2 } = desc;
598
+ function htmlDesc(detail) {
599
+ const { html: html2 } = detail;
615
600
  if (!is.html(html2)) {
616
601
  return false;
617
602
  }
618
603
  return true;
619
604
  }
620
- function textDesc(desc) {
621
- const {
622
- text: text2,
623
- color: color2,
624
- fontSize: fontSize2,
625
- lineHeight: lineHeight2,
626
- fontFamily: fontFamily2,
627
- textAlign: textAlign2,
628
- fontWeight: fontWeight2,
629
- bgColor,
630
- strokeWidth: strokeWidth2,
631
- strokeColor
632
- } = desc;
605
+ function textDesc(detail) {
606
+ const { text: text2, color: color2, fontSize: fontSize2, lineHeight: lineHeight2, fontFamily: fontFamily2, textAlign: textAlign2, fontWeight: fontWeight2, background, strokeWidth: strokeWidth2, strokeColor } = detail;
633
607
  if (!is.text(text2)) {
634
608
  return false;
635
609
  }
@@ -639,28 +613,28 @@ var iDrawUtil = function(exports) {
639
613
  if (!is.fontSize(fontSize2)) {
640
614
  return false;
641
615
  }
642
- if (desc.hasOwnProperty("bgColor") && !is.color(bgColor)) {
616
+ if (detail.hasOwnProperty("background") && !is.color(background)) {
643
617
  return false;
644
618
  }
645
- if (desc.hasOwnProperty("fontWeight") && !is.fontWeight(fontWeight2)) {
619
+ if (detail.hasOwnProperty("fontWeight") && !is.fontWeight(fontWeight2)) {
646
620
  return false;
647
621
  }
648
- if (desc.hasOwnProperty("lineHeight") && !is.lineHeight(lineHeight2)) {
622
+ if (detail.hasOwnProperty("lineHeight") && !is.lineHeight(lineHeight2)) {
649
623
  return false;
650
624
  }
651
- if (desc.hasOwnProperty("fontFamily") && !is.fontFamily(fontFamily2)) {
625
+ if (detail.hasOwnProperty("fontFamily") && !is.fontFamily(fontFamily2)) {
652
626
  return false;
653
627
  }
654
- if (desc.hasOwnProperty("textAlign") && !is.textAlign(textAlign2)) {
628
+ if (detail.hasOwnProperty("textAlign") && !is.textAlign(textAlign2)) {
655
629
  return false;
656
630
  }
657
- if (desc.hasOwnProperty("strokeWidth") && !is.strokeWidth(strokeWidth2)) {
631
+ if (detail.hasOwnProperty("strokeWidth") && !is.strokeWidth(strokeWidth2)) {
658
632
  return false;
659
633
  }
660
- if (desc.hasOwnProperty("strokeColor") && !is.color(strokeColor)) {
634
+ if (detail.hasOwnProperty("strokeColor") && !is.color(strokeColor)) {
661
635
  return false;
662
636
  }
663
- if (!box(desc)) {
637
+ if (!box(detail)) {
664
638
  return false;
665
639
  }
666
640
  return true;
@@ -674,41 +648,1443 @@ var iDrawUtil = function(exports) {
674
648
  svgDesc,
675
649
  htmlDesc
676
650
  };
677
- const index = {
678
- is,
679
- check,
680
- delay,
681
- compose,
682
- throttle,
683
- loadImage,
684
- loadSVG,
685
- loadHTML,
686
- downloadImageFromCanvas,
687
- toColorHexStr,
688
- toColorHexNum,
689
- isColorStr,
690
- createUUID,
691
- istype,
692
- deepClone,
693
- Context
694
- };
695
- exports.Context = Context;
651
+ class Context2D {
652
+ // private _width: number = 0;
653
+ // private _height: number = 0;
654
+ constructor(ctx, opts) {
655
+ this._devicePixelRatio = 1;
656
+ const { devicePixelRatio = 1 } = opts;
657
+ this._ctx = ctx;
658
+ this._devicePixelRatio = devicePixelRatio;
659
+ }
660
+ $undoPixelRatio(num) {
661
+ return num / this._devicePixelRatio;
662
+ }
663
+ $doPixelRatio(num) {
664
+ return this._devicePixelRatio * num;
665
+ }
666
+ $getContext() {
667
+ return this._ctx;
668
+ }
669
+ $setFont(opts) {
670
+ const strList = [];
671
+ if (opts.fontWeight) {
672
+ strList.push(`${opts.fontWeight}`);
673
+ }
674
+ strList.push(`${this.$doPixelRatio(opts.fontSize || 12)}px`);
675
+ strList.push(`${opts.fontFamily || "sans-serif"}`);
676
+ this._ctx.font = `${strList.join(" ")}`;
677
+ }
678
+ $resize(opts) {
679
+ const { width, height, devicePixelRatio } = opts;
680
+ const { canvas } = this._ctx;
681
+ canvas.width = width * devicePixelRatio;
682
+ canvas.height = height * devicePixelRatio;
683
+ this._devicePixelRatio = devicePixelRatio;
684
+ }
685
+ get canvas() {
686
+ return this._ctx.canvas;
687
+ }
688
+ get fillStyle() {
689
+ return this._ctx.fillStyle;
690
+ }
691
+ set fillStyle(value) {
692
+ this._ctx.fillStyle = value;
693
+ }
694
+ get strokeStyle() {
695
+ return this._ctx.strokeStyle;
696
+ }
697
+ set strokeStyle(color2) {
698
+ this._ctx.strokeStyle = color2;
699
+ }
700
+ get lineWidth() {
701
+ return this.$undoPixelRatio(this._ctx.lineWidth);
702
+ }
703
+ set lineWidth(w2) {
704
+ this._ctx.lineWidth = this.$doPixelRatio(w2);
705
+ }
706
+ get textAlign() {
707
+ return this._ctx.textAlign;
708
+ }
709
+ set textAlign(align) {
710
+ this._ctx.textAlign = align;
711
+ }
712
+ get textBaseline() {
713
+ return this._ctx.textBaseline;
714
+ }
715
+ set textBaseline(baseline) {
716
+ this._ctx.textBaseline = baseline;
717
+ }
718
+ get globalAlpha() {
719
+ return this._ctx.globalAlpha;
720
+ }
721
+ set globalAlpha(alpha) {
722
+ this._ctx.globalAlpha = alpha;
723
+ }
724
+ get shadowColor() {
725
+ return this._ctx.shadowColor;
726
+ }
727
+ set shadowColor(color2) {
728
+ this._ctx.shadowColor = color2;
729
+ }
730
+ get shadowOffsetX() {
731
+ return this.$undoPixelRatio(this._ctx.shadowOffsetX);
732
+ }
733
+ set shadowOffsetX(offsetX) {
734
+ this._ctx.shadowOffsetX = this.$doPixelRatio(offsetX);
735
+ }
736
+ get shadowOffsetY() {
737
+ return this.$undoPixelRatio(this._ctx.shadowOffsetY);
738
+ }
739
+ set shadowOffsetY(offsetY) {
740
+ this._ctx.shadowOffsetY = this.$doPixelRatio(offsetY);
741
+ }
742
+ get shadowBlur() {
743
+ return this.$undoPixelRatio(this._ctx.shadowBlur);
744
+ }
745
+ set shadowBlur(blur) {
746
+ this._ctx.shadowBlur = this.$doPixelRatio(blur);
747
+ }
748
+ get lineCap() {
749
+ return this._ctx.lineCap;
750
+ }
751
+ set lineCap(lineCap) {
752
+ this._ctx.lineCap = lineCap;
753
+ }
754
+ get globalCompositeOperation() {
755
+ return this._ctx.globalCompositeOperation;
756
+ }
757
+ set globalCompositeOperation(operations) {
758
+ this._ctx.globalCompositeOperation = operations;
759
+ }
760
+ fill(...args) {
761
+ return this._ctx.fill(...args);
762
+ }
763
+ arc(x2, y2, radius, startAngle, endAngle, anticlockwise) {
764
+ return this._ctx.arc(this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(radius), startAngle, endAngle, anticlockwise);
765
+ }
766
+ rect(x2, y2, w2, h2) {
767
+ return this._ctx.rect(this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(w2), this.$doPixelRatio(h2));
768
+ }
769
+ fillRect(x2, y2, w2, h2) {
770
+ return this._ctx.fillRect(this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(w2), this.$doPixelRatio(h2));
771
+ }
772
+ clearRect(x2, y2, w2, h2) {
773
+ return this._ctx.clearRect(this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(w2), this.$doPixelRatio(h2));
774
+ }
775
+ beginPath() {
776
+ return this._ctx.beginPath();
777
+ }
778
+ closePath() {
779
+ return this._ctx.closePath();
780
+ }
781
+ lineTo(x2, y2) {
782
+ return this._ctx.lineTo(this.$doPixelRatio(x2), this.$doPixelRatio(y2));
783
+ }
784
+ moveTo(x2, y2) {
785
+ return this._ctx.moveTo(this.$doPixelRatio(x2), this.$doPixelRatio(y2));
786
+ }
787
+ arcTo(x1, y1, x2, y2, radius) {
788
+ return this._ctx.arcTo(this.$doPixelRatio(x1), this.$doPixelRatio(y1), this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(radius));
789
+ }
790
+ getLineDash() {
791
+ return this._ctx.getLineDash();
792
+ }
793
+ setLineDash(nums) {
794
+ return this._ctx.setLineDash(nums.map((n) => this.$doPixelRatio(n)));
795
+ }
796
+ stroke(path) {
797
+ return path ? this._ctx.stroke(path) : this._ctx.stroke();
798
+ }
799
+ translate(x2, y2) {
800
+ return this._ctx.translate(this.$doPixelRatio(x2), this.$doPixelRatio(y2));
801
+ }
802
+ rotate(angle2) {
803
+ return this._ctx.rotate(angle2);
804
+ }
805
+ drawImage(...args) {
806
+ const image = args[0];
807
+ const sx = args[1];
808
+ const sy = args[2];
809
+ const sw = args[3];
810
+ const sh = args[4];
811
+ const dx = args[args.length - 4];
812
+ const dy = args[args.length - 3];
813
+ const dw = args[args.length - 2];
814
+ const dh = args[args.length - 1];
815
+ if (args.length === 9) {
816
+ return this._ctx.drawImage(
817
+ image,
818
+ this.$doPixelRatio(sx),
819
+ this.$doPixelRatio(sy),
820
+ this.$doPixelRatio(sw),
821
+ this.$doPixelRatio(sh),
822
+ this.$doPixelRatio(dx),
823
+ this.$doPixelRatio(dy),
824
+ this.$doPixelRatio(dw),
825
+ this.$doPixelRatio(dh)
826
+ );
827
+ } else {
828
+ return this._ctx.drawImage(image, this.$doPixelRatio(dx), this.$doPixelRatio(dy), this.$doPixelRatio(dw), this.$doPixelRatio(dh));
829
+ }
830
+ }
831
+ createPattern(image, repetition) {
832
+ return this._ctx.createPattern(image, repetition);
833
+ }
834
+ measureText(text2) {
835
+ const textMetrics = this._ctx.measureText(text2);
836
+ return textMetrics;
837
+ }
838
+ fillText(text2, x2, y2, maxWidth) {
839
+ if (maxWidth !== void 0) {
840
+ return this._ctx.fillText(text2, this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(maxWidth));
841
+ } else {
842
+ return this._ctx.fillText(text2, this.$doPixelRatio(x2), this.$doPixelRatio(y2));
843
+ }
844
+ }
845
+ strokeText(text2, x2, y2, maxWidth) {
846
+ if (maxWidth !== void 0) {
847
+ return this._ctx.strokeText(text2, this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(maxWidth));
848
+ } else {
849
+ return this._ctx.strokeText(text2, this.$doPixelRatio(x2), this.$doPixelRatio(y2));
850
+ }
851
+ }
852
+ save() {
853
+ this._ctx.save();
854
+ }
855
+ restore() {
856
+ this._ctx.restore();
857
+ }
858
+ scale(ratioX, ratioY) {
859
+ this._ctx.scale(ratioX, ratioY);
860
+ }
861
+ circle(x2, y2, radiusX, radiusY, rotation, startAngle, endAngle, counterclockwise) {
862
+ this._ctx.ellipse(
863
+ this.$doPixelRatio(x2),
864
+ this.$doPixelRatio(y2),
865
+ this.$doPixelRatio(radiusX),
866
+ this.$doPixelRatio(radiusY),
867
+ rotation,
868
+ startAngle,
869
+ endAngle,
870
+ counterclockwise
871
+ );
872
+ }
873
+ isPointInPath(x2, y2) {
874
+ return this._ctx.isPointInPath(this.$doPixelRatio(x2), this.$doPixelRatio(y2));
875
+ }
876
+ // clip(fillRule?: CanvasFillRule): void;
877
+ // clip(path: Path2D, fillRule?: CanvasFillRule): void;
878
+ clip(...args) {
879
+ return this._ctx.clip(...args);
880
+ }
881
+ setTransform(a, b, c, d, e, f) {
882
+ return this._ctx.setTransform(a, b, c, d, e, f);
883
+ }
884
+ getTransform() {
885
+ return this._ctx.getTransform();
886
+ }
887
+ createLinearGradient(x0, y0, x1, y1) {
888
+ return this._ctx.createLinearGradient(this.$doPixelRatio(x0), this.$doPixelRatio(y0), this.$doPixelRatio(x1), this.$doPixelRatio(y1));
889
+ }
890
+ createRadialGradient(x0, y0, r0, x1, y1, r1) {
891
+ return this._ctx.createRadialGradient(
892
+ this.$doPixelRatio(x0),
893
+ this.$doPixelRatio(y0),
894
+ this.$doPixelRatio(r0),
895
+ this.$doPixelRatio(x1),
896
+ this.$doPixelRatio(y1),
897
+ this.$doPixelRatio(r1)
898
+ );
899
+ }
900
+ createConicGradient(startAngle, x2, y2) {
901
+ return this._ctx.createConicGradient(startAngle, this.$doPixelRatio(x2), this.$doPixelRatio(y2));
902
+ }
903
+ }
904
+ function createContext2D(opts) {
905
+ const { width, height, ctx, devicePixelRatio } = opts;
906
+ let context = ctx;
907
+ if (!context) {
908
+ const canvas = document.createElement("canvas");
909
+ canvas.width = width * devicePixelRatio;
910
+ canvas.height = height * devicePixelRatio;
911
+ context = canvas.getContext("2d");
912
+ }
913
+ const context2d = new Context2D(context, opts);
914
+ return context2d;
915
+ }
916
+ function createOffscreenContext2D(opts) {
917
+ const { width, height } = opts;
918
+ const offCanvas = new OffscreenCanvas(width, height);
919
+ const offRenderCtx = offCanvas.getContext("2d");
920
+ const offCtx = offRenderCtx.canvas.getContext("2d");
921
+ return offCtx;
922
+ }
923
+ function createBoardContexts(ctx, opts) {
924
+ const ctxOpts = {
925
+ width: ctx.canvas.width,
926
+ height: ctx.canvas.height,
927
+ devicePixelRatio: (opts == null ? void 0 : opts.devicePixelRatio) || 1
928
+ };
929
+ const viewContext = createContext2D(ctxOpts);
930
+ const helperContext = createContext2D(ctxOpts);
931
+ const boardContext = createContext2D({ ctx, ...ctxOpts });
932
+ const content = {
933
+ viewContext,
934
+ helperContext,
935
+ boardContext
936
+ };
937
+ return content;
938
+ }
939
+ class EventEmitter {
940
+ constructor() {
941
+ this._listeners = /* @__PURE__ */ new Map();
942
+ }
943
+ on(eventKey, callback) {
944
+ if (this._listeners.has(eventKey)) {
945
+ const callbacks = this._listeners.get(eventKey) || [];
946
+ callbacks == null ? void 0 : callbacks.push(callback);
947
+ this._listeners.set(eventKey, callbacks);
948
+ } else {
949
+ this._listeners.set(eventKey, [callback]);
950
+ }
951
+ }
952
+ off(eventKey, callback) {
953
+ if (this._listeners.has(eventKey)) {
954
+ const callbacks = this._listeners.get(eventKey);
955
+ if (Array.isArray(callbacks)) {
956
+ for (let i = 0; i < (callbacks == null ? void 0 : callbacks.length); i++) {
957
+ if (callbacks[i] === callback) {
958
+ callbacks.splice(i, 1);
959
+ break;
960
+ }
961
+ }
962
+ }
963
+ this._listeners.set(eventKey, callbacks || []);
964
+ }
965
+ }
966
+ trigger(eventKey, e) {
967
+ const callbacks = this._listeners.get(eventKey);
968
+ if (Array.isArray(callbacks)) {
969
+ callbacks.forEach((cb) => {
970
+ cb(e);
971
+ });
972
+ return true;
973
+ } else {
974
+ return false;
975
+ }
976
+ }
977
+ has(name) {
978
+ if (this._listeners.has(name)) {
979
+ const list = this._listeners.get(name);
980
+ if (Array.isArray(list) && list.length > 0) {
981
+ return true;
982
+ }
983
+ }
984
+ return false;
985
+ }
986
+ }
987
+ function calcDistance(start, end) {
988
+ const distance = (start.x - end.x) * (start.x - end.x) + (start.y - end.y) * (start.y - end.y);
989
+ return distance === 0 ? distance : Math.sqrt(distance);
990
+ }
991
+ function calcSpeed(start, end) {
992
+ const distance = calcDistance(start, end);
993
+ const speed = distance / Math.abs(end.t - start.t);
994
+ return speed;
995
+ }
996
+ function equalPoint(p1, p2) {
997
+ return p1.x === p2.x && p1.y === p2.y && p1.t === p2.t;
998
+ }
999
+ function equalTouchPoint(p1, p2) {
1000
+ return equalPoint(p1, p2) === true && p1.f === p2.f;
1001
+ }
1002
+ function isNum(num) {
1003
+ return num >= 0 || num < 0;
1004
+ }
1005
+ function vaildPoint(p) {
1006
+ return isNum(p.x) && isNum(p.y) && p.t > 0;
1007
+ }
1008
+ function vaildTouchPoint(p) {
1009
+ return vaildPoint(p) === true && p.f >= 0;
1010
+ }
1011
+ function getCenterFromTwoPoints(p1, p2) {
1012
+ return {
1013
+ x: p1.x + (p2.x - p1.x) / 2,
1014
+ y: p1.y + (p2.y - p1.y) / 2
1015
+ };
1016
+ }
1017
+ class Store {
1018
+ constructor(opts) {
1019
+ this._backUpDefaultStorage = deepClone(opts.defaultStorage);
1020
+ this._temp = this._createTempStorage();
1021
+ }
1022
+ set(name, value) {
1023
+ this._temp[name] = value;
1024
+ }
1025
+ get(name) {
1026
+ return this._temp[name];
1027
+ }
1028
+ getSnapshot() {
1029
+ return deepClone(this._temp);
1030
+ }
1031
+ clear() {
1032
+ this._temp = this._createTempStorage();
1033
+ }
1034
+ _createTempStorage() {
1035
+ return deepClone(this._backUpDefaultStorage);
1036
+ }
1037
+ }
1038
+ function getViewScaleInfoFromSnapshot(snapshot) {
1039
+ const { activeStore } = snapshot;
1040
+ const sacelInfo = {
1041
+ scale: activeStore == null ? void 0 : activeStore.scale,
1042
+ offsetTop: activeStore == null ? void 0 : activeStore.offsetTop,
1043
+ offsetBottom: activeStore == null ? void 0 : activeStore.offsetBottom,
1044
+ offsetLeft: activeStore == null ? void 0 : activeStore.offsetLeft,
1045
+ offsetRight: activeStore == null ? void 0 : activeStore.offsetRight
1046
+ };
1047
+ return sacelInfo;
1048
+ }
1049
+ function getViewSizeInfoFromSnapshot(snapshot) {
1050
+ const { activeStore } = snapshot;
1051
+ const sacelInfo = {
1052
+ devicePixelRatio: activeStore.devicePixelRatio,
1053
+ width: activeStore == null ? void 0 : activeStore.width,
1054
+ height: activeStore == null ? void 0 : activeStore.height,
1055
+ contextWidth: activeStore == null ? void 0 : activeStore.contextWidth,
1056
+ contextHeight: activeStore == null ? void 0 : activeStore.contextHeight
1057
+ };
1058
+ return sacelInfo;
1059
+ }
1060
+ function parseRadianToAngle(radian) {
1061
+ return radian / Math.PI * 180;
1062
+ }
1063
+ function parseAngleToRadian(angle2) {
1064
+ return angle2 / 180 * Math.PI;
1065
+ }
1066
+ function rotateElement(ctx, elemSize, callback) {
1067
+ const center = calcElementCenter(elemSize);
1068
+ const radian = parseAngleToRadian(elemSize.angle || 0);
1069
+ if (center && (radian > 0 || radian < 0)) {
1070
+ ctx.translate(center.x, center.y);
1071
+ ctx.rotate(radian);
1072
+ ctx.translate(-center.x, -center.y);
1073
+ }
1074
+ callback(ctx);
1075
+ if (center && (radian > 0 || radian < 0)) {
1076
+ ctx.translate(center.x, center.y);
1077
+ ctx.rotate(-radian);
1078
+ ctx.translate(-center.x, -center.y);
1079
+ }
1080
+ }
1081
+ function calcElementCenter(elem) {
1082
+ const p = {
1083
+ x: elem.x + elem.w / 2,
1084
+ y: elem.y + elem.h / 2
1085
+ };
1086
+ return p;
1087
+ }
1088
+ function calcElementCenterFromVertexes(ves) {
1089
+ const startX = Math.min(ves[0].x, ves[1].x, ves[2].x, ves[3].x);
1090
+ const startY = Math.min(ves[0].y, ves[1].y, ves[2].y, ves[3].y);
1091
+ const endX = Math.max(ves[0].x, ves[1].x, ves[2].x, ves[3].x);
1092
+ const endY = Math.max(ves[0].y, ves[1].y, ves[2].y, ves[3].y);
1093
+ const elemSize = {
1094
+ x: startX,
1095
+ y: startY,
1096
+ w: endX - startX,
1097
+ h: endY - startY
1098
+ };
1099
+ return calcElementCenter(elemSize);
1100
+ }
1101
+ function calcLineRadian(center, p) {
1102
+ const x2 = p.x - center.x;
1103
+ const y2 = p.y - center.y;
1104
+ if (x2 === 0) {
1105
+ if (y2 < 0) {
1106
+ return 0;
1107
+ } else if (y2 > 0) {
1108
+ return Math.PI;
1109
+ }
1110
+ } else if (y2 === 0) {
1111
+ if (x2 < 0) {
1112
+ return Math.PI * 3 / 2;
1113
+ } else if (x2 > 0) {
1114
+ return Math.PI / 2;
1115
+ }
1116
+ }
1117
+ if (x2 > 0 && y2 < 0) {
1118
+ return Math.atan(Math.abs(x2) / Math.abs(y2));
1119
+ } else if (x2 > 0 && y2 > 0) {
1120
+ return Math.PI - Math.atan(Math.abs(x2) / Math.abs(y2));
1121
+ } else if (x2 < 0 && y2 > 0) {
1122
+ return Math.PI + Math.atan(Math.abs(x2) / Math.abs(y2));
1123
+ } else if (x2 < 0 && y2 < 0) {
1124
+ return 2 * Math.PI - Math.atan(Math.abs(x2) / Math.abs(y2));
1125
+ }
1126
+ return 0;
1127
+ }
1128
+ function rotatePoint(center, start, radian) {
1129
+ const startRadian = calcLineRadian(center, start);
1130
+ const rotateRadian = radian;
1131
+ let endRadian = startRadian + rotateRadian;
1132
+ if (endRadian > Math.PI * 2) {
1133
+ endRadian = endRadian - Math.PI * 2;
1134
+ } else if (endRadian < 0 - Math.PI * 2) {
1135
+ endRadian = endRadian + Math.PI * 2;
1136
+ }
1137
+ if (endRadian < 0) {
1138
+ endRadian = endRadian + Math.PI * 2;
1139
+ }
1140
+ const length = calcDistance(center, start);
1141
+ let x2 = 0;
1142
+ let y2 = 0;
1143
+ if (endRadian === 0) {
1144
+ x2 = 0;
1145
+ y2 = 0 - length;
1146
+ } else if (endRadian > 0 && endRadian < Math.PI / 2) {
1147
+ x2 = Math.sin(endRadian) * length;
1148
+ y2 = 0 - Math.cos(endRadian) * length;
1149
+ } else if (endRadian === Math.PI / 2) {
1150
+ x2 = length;
1151
+ y2 = 0;
1152
+ } else if (endRadian > Math.PI / 2 && endRadian < Math.PI) {
1153
+ x2 = Math.sin(Math.PI - endRadian) * length;
1154
+ y2 = Math.cos(Math.PI - endRadian) * length;
1155
+ } else if (endRadian === Math.PI) {
1156
+ x2 = 0;
1157
+ y2 = length;
1158
+ } else if (endRadian > Math.PI && endRadian < 3 / 2 * Math.PI) {
1159
+ x2 = 0 - Math.sin(endRadian - Math.PI) * length;
1160
+ y2 = Math.cos(endRadian - Math.PI) * length;
1161
+ } else if (endRadian === 3 / 2 * Math.PI) {
1162
+ x2 = 0 - length;
1163
+ y2 = 0;
1164
+ } else if (endRadian > 3 / 2 * Math.PI && endRadian < 2 * Math.PI) {
1165
+ x2 = 0 - Math.sin(2 * Math.PI - endRadian) * length;
1166
+ y2 = 0 - Math.cos(2 * Math.PI - endRadian) * length;
1167
+ } else if (endRadian === 2 * Math.PI) {
1168
+ x2 = 0;
1169
+ y2 = 0 - length;
1170
+ }
1171
+ x2 += center.x;
1172
+ y2 += center.y;
1173
+ return { x: x2, y: y2 };
1174
+ }
1175
+ function rotatePointInGroup(point, groupQueue) {
1176
+ if ((groupQueue == null ? void 0 : groupQueue.length) > 0) {
1177
+ let resultX = point.x;
1178
+ let resultY = point.y;
1179
+ groupQueue.forEach((group) => {
1180
+ const { x: x2, y: y2, w: w2, h: h2, angle: angle2 = 0 } = group;
1181
+ const center = calcElementCenter({ x: x2, y: y2, w: w2, h: h2, angle: angle2 });
1182
+ const temp = rotatePoint(center, { x: resultX, y: resultY }, parseAngleToRadian(angle2));
1183
+ resultX = temp.x;
1184
+ resultY = temp.y;
1185
+ });
1186
+ return {
1187
+ x: resultX,
1188
+ y: resultY
1189
+ };
1190
+ }
1191
+ return point;
1192
+ }
1193
+ function getElementRotateVertexes(elemSize, center, angle2) {
1194
+ const { x: x2, y: y2, w: w2, h: h2 } = elemSize;
1195
+ let p1 = { x: x2, y: y2 };
1196
+ let p2 = { x: x2 + w2, y: y2 };
1197
+ let p3 = { x: x2 + w2, y: y2 + h2 };
1198
+ let p4 = { x: x2, y: y2 + h2 };
1199
+ if (angle2 && (angle2 > 0 || angle2 < 0)) {
1200
+ const radian = parseAngleToRadian(limitAngle(angle2));
1201
+ p1 = rotatePoint(center, p1, radian);
1202
+ p2 = rotatePoint(center, p2, radian);
1203
+ p3 = rotatePoint(center, p3, radian);
1204
+ p4 = rotatePoint(center, p4, radian);
1205
+ }
1206
+ return [p1, p2, p3, p4];
1207
+ }
1208
+ function rotateElementVertexes(elemSize) {
1209
+ const { angle: angle2 = 0 } = elemSize;
1210
+ const center = calcElementCenter(elemSize);
1211
+ return getElementRotateVertexes(elemSize, center, angle2);
1212
+ }
1213
+ function rotateVertexes(center, ves, radian) {
1214
+ return [
1215
+ rotatePoint(center, { x: ves[0].x, y: ves[0].y }, radian),
1216
+ rotatePoint(center, { x: ves[1].x, y: ves[1].y }, radian),
1217
+ rotatePoint(center, { x: ves[2].x, y: ves[2].y }, radian),
1218
+ rotatePoint(center, { x: ves[3].x, y: ves[3].y }, radian)
1219
+ ];
1220
+ }
1221
+ function limitAngle(angle2) {
1222
+ if (!(angle2 > 0 || angle2 < 0) || angle2 === 0) {
1223
+ return 0;
1224
+ }
1225
+ let num = angle2 % 360;
1226
+ if (num < 0) {
1227
+ num += 360;
1228
+ }
1229
+ return num;
1230
+ }
1231
+ function getGroupUUIDs(elements, index) {
1232
+ var _a;
1233
+ const uuids = [];
1234
+ if (typeof index === "string" && /^\d+(\.\d+)*$/.test(index)) {
1235
+ const nums = index.split(".");
1236
+ let target = elements;
1237
+ while (nums.length > 0) {
1238
+ const num = nums.shift();
1239
+ if (typeof num === "string") {
1240
+ const elem = target[parseInt(num)];
1241
+ if (elem && nums.length === 0) {
1242
+ uuids.push(elem.uuid);
1243
+ } else if (elem.type === "group" && nums.length > 0) {
1244
+ target = ((_a = elem == null ? void 0 : elem.detail) == null ? void 0 : _a.children) || [];
1245
+ }
1246
+ }
1247
+ break;
1248
+ }
1249
+ }
1250
+ return uuids;
1251
+ }
1252
+ function getSelectedElementUUIDs(data, indexes) {
1253
+ var _a;
1254
+ let uuids = [];
1255
+ if (Array.isArray(data == null ? void 0 : data.elements) && ((_a = data == null ? void 0 : data.elements) == null ? void 0 : _a.length) > 0 && Array.isArray(indexes) && indexes.length > 0) {
1256
+ indexes.forEach((idx) => {
1257
+ var _a2;
1258
+ if (typeof idx === "number") {
1259
+ if ((_a2 = data == null ? void 0 : data.elements) == null ? void 0 : _a2[idx]) {
1260
+ uuids.push(data.elements[idx].uuid);
1261
+ }
1262
+ } else if (typeof idx === "string") {
1263
+ uuids = uuids.concat(getGroupUUIDs(data.elements, idx));
1264
+ }
1265
+ });
1266
+ }
1267
+ return uuids;
1268
+ }
1269
+ function validateElements(elements) {
1270
+ let isValid = true;
1271
+ if (Array.isArray(elements)) {
1272
+ const uuids = [];
1273
+ elements.forEach((elem) => {
1274
+ var _a;
1275
+ if (typeof elem.uuid === "string" && elem.uuid) {
1276
+ if (uuids.includes(elem.uuid)) {
1277
+ isValid = false;
1278
+ console.warn(`Duplicate uuids: ${elem.uuid}`);
1279
+ } else {
1280
+ uuids.push(elem.uuid);
1281
+ }
1282
+ } else {
1283
+ isValid = false;
1284
+ console.warn("Element missing uuid", elem);
1285
+ }
1286
+ if (elem.type === "group") {
1287
+ isValid = validateElements((_a = elem == null ? void 0 : elem.detail) == null ? void 0 : _a.children);
1288
+ }
1289
+ });
1290
+ }
1291
+ return isValid;
1292
+ }
1293
+ function calcElementsContextSize(elements, opts) {
1294
+ const area = { x: 0, y: 0, w: 0, h: 0 };
1295
+ elements.forEach((elem) => {
1296
+ const elemSize = {
1297
+ x: elem.x,
1298
+ y: elem.y,
1299
+ w: elem.w,
1300
+ h: elem.h,
1301
+ angle: elem.angle
1302
+ };
1303
+ if (elemSize.angle && (elemSize.angle > 0 || elemSize.angle < 0)) {
1304
+ const ves = rotateElementVertexes(elemSize);
1305
+ if (ves.length === 4) {
1306
+ const xList = [ves[0].x, ves[1].x, ves[2].x, ves[3].x];
1307
+ const yList = [ves[0].y, ves[1].y, ves[2].y, ves[3].y];
1308
+ elemSize.x = Math.min(...xList);
1309
+ elemSize.y = Math.min(...yList);
1310
+ elemSize.w = Math.abs(Math.max(...xList) - Math.min(...xList));
1311
+ elemSize.h = Math.abs(Math.max(...yList) - Math.min(...yList));
1312
+ }
1313
+ }
1314
+ const areaStartX = Math.min(elemSize.x, area.x);
1315
+ const areaStartY = Math.min(elemSize.y, area.y);
1316
+ const areaEndX = Math.max(elemSize.x + elemSize.w, area.x + area.w);
1317
+ const areaEndY = Math.max(elemSize.y + elemSize.h, area.y + area.h);
1318
+ area.x = areaStartX;
1319
+ area.y = areaStartY;
1320
+ area.w = Math.abs(areaEndX - areaStartX);
1321
+ area.h = Math.abs(areaEndY - areaStartY);
1322
+ });
1323
+ if (opts == null ? void 0 : opts.extend) {
1324
+ area.x = Math.min(area.x, 0);
1325
+ area.y = Math.min(area.y, 0);
1326
+ }
1327
+ const ctxSize = {
1328
+ contextWidth: area.w,
1329
+ contextHeight: area.h
1330
+ };
1331
+ if ((opts == null ? void 0 : opts.viewWidth) && (opts == null ? void 0 : opts.viewHeight) && (opts == null ? void 0 : opts.viewWidth) > 0 && (opts == null ? void 0 : opts.viewHeight) > 0) {
1332
+ if (opts.viewWidth > area.x + area.w) {
1333
+ ctxSize.contextWidth = opts.viewWidth - area.x;
1334
+ }
1335
+ if (opts.viewHeight > area.y + area.h) {
1336
+ ctxSize.contextHeight = opts.viewHeight - area.y;
1337
+ }
1338
+ }
1339
+ return ctxSize;
1340
+ }
1341
+ function calcElementsViewInfo(elements, prevViewSize, options) {
1342
+ const contextSize = calcElementsContextSize(elements, { viewWidth: prevViewSize.width, viewHeight: prevViewSize.height, extend: options == null ? void 0 : options.extend });
1343
+ if ((options == null ? void 0 : options.extend) === true) {
1344
+ contextSize.contextWidth = Math.max(contextSize.contextWidth, prevViewSize.contextWidth);
1345
+ contextSize.contextHeight = Math.max(contextSize.contextHeight, prevViewSize.contextHeight);
1346
+ }
1347
+ return {
1348
+ contextSize
1349
+ };
1350
+ }
1351
+ function getElemenetsAssetIds(elements) {
1352
+ const assetIds = [];
1353
+ const _scanElements = (elems) => {
1354
+ elems.forEach((elem) => {
1355
+ if (elem.type === "image" && isAssetId(elem.detail.src)) {
1356
+ assetIds.push(elem.detail.src);
1357
+ } else if (elem.type === "svg" && isAssetId(elem.detail.svg)) {
1358
+ assetIds.push(elem.detail.svg);
1359
+ } else if (elem.type === "html" && elem.detail.html) {
1360
+ assetIds.push(elem.detail.html);
1361
+ } else if (elem.type === "group" && Array.isArray(elem.detail.children)) {
1362
+ _scanElements(elem.detail.children);
1363
+ }
1364
+ });
1365
+ };
1366
+ _scanElements(elements);
1367
+ return assetIds;
1368
+ }
1369
+ function findElementFromList(uuid, list) {
1370
+ var _a;
1371
+ let result = null;
1372
+ for (let i = 0; i < list.length; i++) {
1373
+ const elem = list[i];
1374
+ if (elem.uuid === uuid) {
1375
+ result = elem;
1376
+ break;
1377
+ } else if (!result && elem.type === "group") {
1378
+ const resultInGroup = findElementFromList(uuid, ((_a = elem == null ? void 0 : elem.detail) == null ? void 0 : _a.children) || []);
1379
+ if ((resultInGroup == null ? void 0 : resultInGroup.uuid) === uuid) {
1380
+ result = resultInGroup;
1381
+ break;
1382
+ }
1383
+ }
1384
+ }
1385
+ return result;
1386
+ }
1387
+ function findElementsFromList(uuids, list) {
1388
+ const result = [];
1389
+ function _find(elements) {
1390
+ var _a;
1391
+ for (let i = 0; i < elements.length; i++) {
1392
+ const elem = elements[i];
1393
+ if (uuids.includes(elem.uuid)) {
1394
+ result.push(elem);
1395
+ } else if (elem.type === "group") {
1396
+ _find(((_a = elem == null ? void 0 : elem.detail) == null ? void 0 : _a.children) || []);
1397
+ }
1398
+ }
1399
+ }
1400
+ _find(list);
1401
+ return result;
1402
+ }
1403
+ function getGroupQueueFromList(uuid, elements) {
1404
+ const groupQueue = [];
1405
+ function _scan(uuid2, elements2) {
1406
+ var _a;
1407
+ let result = null;
1408
+ for (let i = 0; i < elements2.length; i++) {
1409
+ const elem = elements2[i];
1410
+ if (elem.uuid === uuid2) {
1411
+ result = elem;
1412
+ break;
1413
+ } else if (!result && elem.type === "group") {
1414
+ groupQueue.push(elem);
1415
+ const resultInGroup = _scan(uuid2, ((_a = elem == null ? void 0 : elem.detail) == null ? void 0 : _a.children) || []);
1416
+ if ((resultInGroup == null ? void 0 : resultInGroup.uuid) === uuid2) {
1417
+ result = resultInGroup;
1418
+ break;
1419
+ }
1420
+ groupQueue.pop();
1421
+ }
1422
+ }
1423
+ return result;
1424
+ }
1425
+ _scan(uuid, elements);
1426
+ return groupQueue;
1427
+ }
1428
+ function mergeElement(originElem, updateContent) {
1429
+ const commonKeys = Object.keys(updateContent);
1430
+ for (let i = 0; i < commonKeys.length; i++) {
1431
+ const commonKey = commonKeys[i];
1432
+ if (["x", "y", "w", "h", "angle", "name"].includes(commonKey)) {
1433
+ originElem[commonKey] = updateContent[commonKey];
1434
+ } else if (["detail", "operations"].includes(commonKey)) {
1435
+ if (istype.json(updateContent[commonKey]) && istype.json(originElem[commonKey])) {
1436
+ originElem[commonKey] = { ...originElem[commonKey], ...updateContent[commonKey] };
1437
+ } else if (istype.array(updateContent[commonKey]) && istype.array(originElem[commonKey])) {
1438
+ originElem[commonKey] = { ...originElem[commonKey], ...updateContent[commonKey] };
1439
+ }
1440
+ }
1441
+ }
1442
+ return originElem;
1443
+ }
1444
+ function updateElementInList(uuid, updateContent, elements) {
1445
+ var _a;
1446
+ for (let i = 0; i < elements.length; i++) {
1447
+ const elem = elements[i];
1448
+ if (elem.uuid === uuid) {
1449
+ mergeElement(elem, updateContent);
1450
+ break;
1451
+ } else if (elem.type === "group") {
1452
+ updateElementInList(uuid, updateContent, ((_a = elem == null ? void 0 : elem.detail) == null ? void 0 : _a.children) || []);
1453
+ }
1454
+ }
1455
+ return elements;
1456
+ }
1457
+ function checkRectIntersect(rect1, rect2) {
1458
+ const react1MinX = rect1.x;
1459
+ const react1MinY = rect1.y;
1460
+ const react1MaxX = rect1.x + rect1.w;
1461
+ const react1MaxY = rect1.y + rect1.h;
1462
+ const react2MinX = rect2.x;
1463
+ const react2MinY = rect2.y;
1464
+ const react2MaxX = rect2.x + rect2.w;
1465
+ const react2MaxY = rect2.y + rect2.h;
1466
+ return react1MinX <= react2MaxX && react1MaxX >= react2MinX && react1MinY <= react2MaxY && react1MaxY >= react2MinY;
1467
+ }
1468
+ function viewScale(opts) {
1469
+ const { scale, point, viewScaleInfo: prevViewScaleInfo } = opts;
1470
+ const { offsetLeft, offsetTop } = prevViewScaleInfo;
1471
+ const scaleDiff = scale / prevViewScaleInfo.scale;
1472
+ const x0 = point.x;
1473
+ const y0 = point.y;
1474
+ const moveX = x0 - x0 * scaleDiff + (offsetLeft * scaleDiff - offsetLeft);
1475
+ const moveY = y0 - y0 * scaleDiff + (offsetTop * scaleDiff - offsetTop);
1476
+ return {
1477
+ moveX,
1478
+ moveY
1479
+ };
1480
+ }
1481
+ function viewScroll(opts) {
1482
+ const { moveX = 0, moveY = 0, viewScaleInfo, viewSizeInfo } = opts;
1483
+ const { scale } = viewScaleInfo;
1484
+ const { width, height, contextWidth, contextHeight } = viewSizeInfo;
1485
+ let offsetLeft = viewScaleInfo.offsetLeft;
1486
+ let offsetRight = viewScaleInfo.offsetRight;
1487
+ let offsetTop = viewScaleInfo.offsetTop;
1488
+ let offsetBottom = viewScaleInfo.offsetBottom;
1489
+ offsetLeft += moveX;
1490
+ offsetTop += moveY;
1491
+ const w2 = contextWidth * scale;
1492
+ const h2 = contextHeight * scale;
1493
+ offsetRight = width - (w2 + offsetLeft);
1494
+ offsetBottom = height - (h2 + offsetTop);
1495
+ return {
1496
+ scale,
1497
+ offsetTop,
1498
+ offsetLeft,
1499
+ offsetRight,
1500
+ offsetBottom
1501
+ };
1502
+ }
1503
+ function calcViewElementSize(size, opts) {
1504
+ const { viewScaleInfo } = opts;
1505
+ const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = size;
1506
+ const { scale, offsetTop, offsetLeft } = viewScaleInfo;
1507
+ const newSize = {
1508
+ x: x2 * scale + offsetLeft,
1509
+ y: y2 * scale + offsetTop,
1510
+ w: w2 * scale,
1511
+ h: h2 * scale,
1512
+ angle: angle2
1513
+ };
1514
+ return newSize;
1515
+ }
1516
+ function calcViewPointSize(size, opts) {
1517
+ const { viewScaleInfo } = opts;
1518
+ const { x: x2, y: y2 } = size;
1519
+ const { scale, offsetTop, offsetLeft } = viewScaleInfo;
1520
+ const newSize = {
1521
+ x: x2 * scale + offsetLeft,
1522
+ y: y2 * scale + offsetTop
1523
+ };
1524
+ return newSize;
1525
+ }
1526
+ function calcViewVertexes(vertexes, opts) {
1527
+ return [
1528
+ calcViewPointSize(vertexes[0], opts),
1529
+ calcViewPointSize(vertexes[1], opts),
1530
+ calcViewPointSize(vertexes[2], opts),
1531
+ calcViewPointSize(vertexes[3], opts)
1532
+ ];
1533
+ }
1534
+ function isViewPointInElement(p, opts) {
1535
+ const { context2d: ctx, element: elem, viewScaleInfo, viewSizeInfo } = opts;
1536
+ const { angle: angle2 = 0 } = elem;
1537
+ const { x: x2, y: y2, w: w2, h: h2 } = calcViewElementSize(elem, { viewScaleInfo, viewSizeInfo });
1538
+ const vertexes = rotateElementVertexes({ x: x2, y: y2, w: w2, h: h2, angle: angle2 });
1539
+ if (vertexes.length >= 2) {
1540
+ ctx.beginPath();
1541
+ ctx.moveTo(vertexes[0].x, vertexes[0].y);
1542
+ for (let i = 1; i < vertexes.length; i++) {
1543
+ ctx.lineTo(vertexes[i].x, vertexes[i].y);
1544
+ }
1545
+ ctx.closePath();
1546
+ }
1547
+ if (ctx.isPointInPath(p.x, p.y)) {
1548
+ return true;
1549
+ }
1550
+ return false;
1551
+ }
1552
+ function getViewPointAtElement(p, opts) {
1553
+ var _a, _b, _c;
1554
+ const { context2d: ctx, data, viewScaleInfo, viewSizeInfo, groupQueue } = opts;
1555
+ const result = {
1556
+ index: -1,
1557
+ element: null,
1558
+ groupQueueIndex: -1
1559
+ };
1560
+ if (groupQueue && Array.isArray(groupQueue) && (groupQueue == null ? void 0 : groupQueue.length) > 0) {
1561
+ for (let gIdx = groupQueue.length - 1; gIdx >= 0; gIdx--) {
1562
+ let totalX = 0;
1563
+ let totalY = 0;
1564
+ let totalAngle = 0;
1565
+ for (let i = 0; i <= gIdx; i++) {
1566
+ totalX += groupQueue[i].x;
1567
+ totalY += groupQueue[i].y;
1568
+ totalAngle += groupQueue[i].angle || 0;
1569
+ }
1570
+ const lastGroup = groupQueue[gIdx];
1571
+ if (lastGroup && lastGroup.type === "group" && Array.isArray((_a = lastGroup.detail) == null ? void 0 : _a.children)) {
1572
+ for (let i = 0; i < lastGroup.detail.children.length; i++) {
1573
+ const child = lastGroup.detail.children[i];
1574
+ if (((_b = child == null ? void 0 : child.operations) == null ? void 0 : _b.invisible) === true) {
1575
+ continue;
1576
+ }
1577
+ if (child) {
1578
+ const elemSize = {
1579
+ x: totalX + child.x,
1580
+ y: totalY + child.y,
1581
+ w: child.w,
1582
+ h: child.h,
1583
+ angle: totalAngle + (child.angle || 0)
1584
+ };
1585
+ if (isViewPointInElement(p, { context2d: ctx, element: elemSize, viewScaleInfo, viewSizeInfo })) {
1586
+ result.element = child;
1587
+ if (gIdx < groupQueue.length - 1 || child.type !== "group") {
1588
+ result.groupQueueIndex = gIdx;
1589
+ }
1590
+ break;
1591
+ }
1592
+ } else {
1593
+ break;
1594
+ }
1595
+ }
1596
+ }
1597
+ if (result.element) {
1598
+ break;
1599
+ }
1600
+ }
1601
+ }
1602
+ if (result.element) {
1603
+ return result;
1604
+ }
1605
+ for (let i = data.elements.length - 1; i >= 0; i--) {
1606
+ const elem = data.elements[i];
1607
+ if (((_c = elem == null ? void 0 : elem.operations) == null ? void 0 : _c.invisible) === true) {
1608
+ continue;
1609
+ }
1610
+ if (isViewPointInElement(p, { context2d: ctx, element: elem, viewScaleInfo, viewSizeInfo })) {
1611
+ result.index = i;
1612
+ result.element = elem;
1613
+ break;
1614
+ }
1615
+ }
1616
+ return result;
1617
+ }
1618
+ function isElementInView(elem, opts) {
1619
+ const { viewSizeInfo, viewScaleInfo } = opts;
1620
+ const { width, height } = viewSizeInfo;
1621
+ const { angle: angle2 } = elem;
1622
+ const { x: x2, y: y2, w: w2, h: h2 } = calcViewElementSize(elem, { viewScaleInfo, viewSizeInfo });
1623
+ const ves = rotateElementVertexes({ x: x2, y: y2, w: w2, h: h2, angle: angle2 });
1624
+ const viewSize = { x: 0, y: 0, w: width, h: height };
1625
+ const elemStartX = Math.min(ves[0].x, ves[1].x, ves[2].x, ves[3].x);
1626
+ const elemStartY = Math.min(ves[0].y, ves[1].y, ves[2].y, ves[3].y);
1627
+ const elemEndX = Math.max(ves[0].x, ves[1].x, ves[2].x, ves[3].x);
1628
+ const elemEndY = Math.max(ves[0].y, ves[1].y, ves[2].y, ves[3].y);
1629
+ const elemSize = { x: elemStartX, y: elemStartY, w: elemEndX - elemStartX, h: elemEndY - elemStartY };
1630
+ return checkRectIntersect(viewSize, elemSize);
1631
+ }
1632
+ function getElementVertexes(elemSize) {
1633
+ const { x: x2, y: y2, h: h2, w: w2 } = elemSize;
1634
+ return [
1635
+ { x: x2, y: y2 },
1636
+ { x: x2 + w2, y: y2 },
1637
+ { x: x2 + w2, y: y2 + h2 },
1638
+ { x: x2, y: y2 + h2 }
1639
+ ];
1640
+ }
1641
+ function calcElementVertexes(elemSize) {
1642
+ const { x: x2, y: y2, w: w2, h: h2, angle: angle2 = 0 } = elemSize;
1643
+ if (angle2 === 0) {
1644
+ return getElementVertexes(elemSize);
1645
+ }
1646
+ return getElementRotateVertexes(elemSize, calcElementCenter({ x: x2, y: y2, w: w2, h: h2, angle: angle2 }), angle2);
1647
+ }
1648
+ function calcElementQueueVertexesQueueInGroup(groupQueue) {
1649
+ const vesList = [];
1650
+ let totalX = 0;
1651
+ let totalY = 0;
1652
+ const rotateActionList = [];
1653
+ const elemQueue = [...groupQueue];
1654
+ for (let i = 0; i < elemQueue.length; i++) {
1655
+ const { x: x2, y: y2, w: w2, h: h2, angle: angle2 = 0 } = elemQueue[i];
1656
+ totalX += x2;
1657
+ totalY += y2;
1658
+ let ves;
1659
+ if (i === 0) {
1660
+ const elemSize = { x: totalX, y: totalY, w: w2, h: h2, angle: angle2 };
1661
+ ves = calcElementVertexes({ x: x2, y: y2, w: w2, h: h2, angle: angle2 });
1662
+ rotateActionList.push({
1663
+ center: calcElementCenter(elemSize),
1664
+ angle: angle2,
1665
+ radian: parseAngleToRadian(angle2)
1666
+ });
1667
+ } else {
1668
+ const elemSize = { x: totalX, y: totalY, w: w2, h: h2, angle: angle2 };
1669
+ ves = getElementVertexes(elemSize);
1670
+ for (let aIdx = 0; aIdx < rotateActionList.length; aIdx++) {
1671
+ const { center, radian } = rotateActionList[aIdx];
1672
+ ves = rotateVertexes(center, ves, radian);
1673
+ }
1674
+ const vesCenter = calcElementCenterFromVertexes(ves);
1675
+ if (angle2 > 0 || angle2 < 0) {
1676
+ const radian = parseAngleToRadian(angle2);
1677
+ ves = rotateVertexes(vesCenter, ves, radian);
1678
+ }
1679
+ rotateActionList.push({
1680
+ center: vesCenter,
1681
+ angle: angle2,
1682
+ radian: parseAngleToRadian(angle2)
1683
+ });
1684
+ }
1685
+ vesList.push(ves);
1686
+ }
1687
+ return vesList;
1688
+ }
1689
+ function calcElementVertexesQueueInGroup(targetElem, opts) {
1690
+ const { groupQueue } = opts;
1691
+ if (!(groupQueue.length > 0)) {
1692
+ return [calcElementVertexes(targetElem)];
1693
+ }
1694
+ const elemQueue = [...groupQueue, ...[targetElem]];
1695
+ const vesList = calcElementQueueVertexesQueueInGroup(elemQueue);
1696
+ return vesList;
1697
+ }
1698
+ function calcElementVertexesInGroup(targetElem, opts) {
1699
+ const vesList = calcElementVertexesQueueInGroup(targetElem, opts);
1700
+ const ves = vesList.pop();
1701
+ return ves || null;
1702
+ }
1703
+ function createControllerElementSizeFromCenter(center, opts) {
1704
+ const { x: x2, y: y2 } = center;
1705
+ const { size, angle: angle2 } = opts;
1706
+ return {
1707
+ x: x2 - size / 2,
1708
+ y: y2 - size / 2,
1709
+ w: size,
1710
+ h: size,
1711
+ angle: angle2
1712
+ };
1713
+ }
1714
+ function calcElementSizeController(elemSize, opts) {
1715
+ const { groupQueue, controllerSize, viewScaleInfo } = opts;
1716
+ const ctrlSize = (controllerSize && controllerSize > 0 ? controllerSize : 8) / viewScaleInfo.scale;
1717
+ const { x: x2, y: y2, w: w2, h: h2, angle: angle2 = 0 } = elemSize;
1718
+ const ctrlGroupQueue = [
1719
+ ...[
1720
+ {
1721
+ uuid: createUUID(),
1722
+ x: x2,
1723
+ y: y2,
1724
+ w: w2,
1725
+ h: h2,
1726
+ angle: angle2,
1727
+ type: "group",
1728
+ detail: { children: [] }
1729
+ }
1730
+ ],
1731
+ ...groupQueue
1732
+ ];
1733
+ let totalAngle = 0;
1734
+ ctrlGroupQueue.forEach(({ angle: angle22 = 0 }) => {
1735
+ totalAngle += angle22;
1736
+ });
1737
+ const vertexes = calcElementVertexesInGroup(elemSize, { groupQueue });
1738
+ const topCenter = getCenterFromTwoPoints(vertexes[0], vertexes[1]);
1739
+ const rightCenter = getCenterFromTwoPoints(vertexes[1], vertexes[2]);
1740
+ const bottomCenter = getCenterFromTwoPoints(vertexes[2], vertexes[3]);
1741
+ const leftCenter = getCenterFromTwoPoints(vertexes[3], vertexes[0]);
1742
+ const topLeftCenter = vertexes[0];
1743
+ const topRightCenter = vertexes[1];
1744
+ const bottomRightCenter = vertexes[2];
1745
+ const bottomLeftCenter = vertexes[3];
1746
+ const topSize = createControllerElementSizeFromCenter(topCenter, { size: ctrlSize, angle: totalAngle });
1747
+ const rightSize = createControllerElementSizeFromCenter(rightCenter, { size: ctrlSize, angle: totalAngle });
1748
+ const bottomSize = createControllerElementSizeFromCenter(bottomCenter, { size: ctrlSize, angle: totalAngle });
1749
+ const leftSize = createControllerElementSizeFromCenter(leftCenter, { size: ctrlSize, angle: totalAngle });
1750
+ const topLeftSize = createControllerElementSizeFromCenter(topLeftCenter, { size: ctrlSize, angle: totalAngle });
1751
+ const topRightSize = createControllerElementSizeFromCenter(topRightCenter, { size: ctrlSize, angle: totalAngle });
1752
+ const bottomLeftSize = createControllerElementSizeFromCenter(bottomLeftCenter, { size: ctrlSize, angle: totalAngle });
1753
+ const bottomRightSize = createControllerElementSizeFromCenter(bottomRightCenter, { size: ctrlSize, angle: totalAngle });
1754
+ const sizeController = {
1755
+ elementWrapper: vertexes,
1756
+ left: {
1757
+ type: "left",
1758
+ vertexes: calcElementVertexes(leftSize),
1759
+ center: leftCenter
1760
+ },
1761
+ right: {
1762
+ type: "right",
1763
+ vertexes: calcElementVertexes(rightSize),
1764
+ center: rightCenter
1765
+ },
1766
+ top: {
1767
+ type: "top",
1768
+ vertexes: calcElementVertexes(topSize),
1769
+ center: topCenter
1770
+ },
1771
+ bottom: {
1772
+ type: "bottom",
1773
+ vertexes: calcElementVertexes(bottomSize),
1774
+ center: bottomCenter
1775
+ },
1776
+ topLeft: {
1777
+ type: "top-left",
1778
+ vertexes: calcElementVertexes(topLeftSize),
1779
+ center: topLeftCenter
1780
+ },
1781
+ topRight: {
1782
+ type: "top-right",
1783
+ vertexes: calcElementVertexes(topRightSize),
1784
+ center: topRightCenter
1785
+ },
1786
+ bottomLeft: {
1787
+ type: "bottom-left",
1788
+ vertexes: calcElementVertexes(bottomLeftSize),
1789
+ center: bottomLeftCenter
1790
+ },
1791
+ bottomRight: {
1792
+ type: "bottom-right",
1793
+ vertexes: calcElementVertexes(bottomRightSize),
1794
+ center: bottomRightCenter
1795
+ }
1796
+ };
1797
+ return sizeController;
1798
+ }
1799
+ const cmdReg = /([astvzqmhlc])([^astvzqmhlc]*)/gi;
1800
+ const numReg = /(-?\d+(?:\.\d+)?)/gi;
1801
+ function parseSVGPath(path) {
1802
+ const commands = [];
1803
+ path.replace(cmdReg, (match, cmd, paramStr) => {
1804
+ const matchParams = paramStr.match(numReg);
1805
+ const params = matchParams ? matchParams.map(Number) : [];
1806
+ const command = {
1807
+ type: cmd,
1808
+ params
1809
+ };
1810
+ commands.push(command);
1811
+ return match;
1812
+ });
1813
+ return commands;
1814
+ }
1815
+ function generateSVGPath(commands) {
1816
+ let path = "";
1817
+ commands.forEach((item) => {
1818
+ path += item.type + item.params.join(" ");
1819
+ });
1820
+ return path;
1821
+ }
1822
+ const attrRegExp = /\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g;
1823
+ const elemRegExp = /<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g;
1824
+ const whitespaceReg = /^\s*$/;
1825
+ const singleElements = {};
1826
+ function parseElement(element) {
1827
+ const node = {
1828
+ type: "element",
1829
+ name: "",
1830
+ isVoid: false,
1831
+ attributes: {},
1832
+ children: []
1833
+ };
1834
+ const elementMatch = element.match(/<\/?([^\s]+?)[/\s>]/);
1835
+ if (elementMatch) {
1836
+ node.name = elementMatch[1];
1837
+ if (singleElements[elementMatch[1]] || element.charAt(element.length - 2) === "/") {
1838
+ node.isVoid = true;
1839
+ }
1840
+ if (node.name.startsWith("!--")) {
1841
+ const endIndex = element.indexOf("-->");
1842
+ return {
1843
+ type: "comment",
1844
+ name: null,
1845
+ attributes: {},
1846
+ children: [],
1847
+ isVoid: false,
1848
+ comment: endIndex !== -1 ? element.slice(4, endIndex) : ""
1849
+ };
1850
+ }
1851
+ }
1852
+ const reg = new RegExp(attrRegExp);
1853
+ let result = null;
1854
+ while (true) {
1855
+ result = reg.exec(element);
1856
+ if (result === null) {
1857
+ break;
1858
+ }
1859
+ if (!result[0].trim()) {
1860
+ continue;
1861
+ }
1862
+ if (result[1]) {
1863
+ const attr = result[1].trim();
1864
+ let arr = [attr, ""];
1865
+ if (attr.indexOf("=") > -1) {
1866
+ arr = attr.split("=");
1867
+ }
1868
+ node.attributes[arr[0]] = arr[1];
1869
+ reg.lastIndex--;
1870
+ } else if (result[2]) {
1871
+ node.attributes[result[2]] = result[3].trim().substring(1, result[3].length - 1);
1872
+ }
1873
+ }
1874
+ return node;
1875
+ }
1876
+ function parseHTML(html2) {
1877
+ const result = [];
1878
+ const arr = [];
1879
+ let current;
1880
+ let level = -1;
1881
+ let inComponent = false;
1882
+ html2.replace(elemRegExp, (element, index) => {
1883
+ const isOpen = element.charAt(1) !== "/";
1884
+ const isComment = element.startsWith("<!--");
1885
+ const start = index + element.length;
1886
+ const nextChar = html2.charAt(start);
1887
+ let parent;
1888
+ if (isComment) {
1889
+ const comment = parseElement(element);
1890
+ if (level < 0) {
1891
+ result.push(comment);
1892
+ return element;
1893
+ }
1894
+ parent = arr[level];
1895
+ parent.children.push(comment);
1896
+ return element;
1897
+ }
1898
+ if (isOpen) {
1899
+ level++;
1900
+ current = parseElement(element);
1901
+ if (!current.isVoid && !inComponent && nextChar && nextChar !== "<") {
1902
+ const content = html2.slice(start, html2.indexOf("<", start));
1903
+ if (content.trim()) {
1904
+ current.children.push({
1905
+ type: "text",
1906
+ name: null,
1907
+ attributes: {},
1908
+ children: [],
1909
+ isVoid: false,
1910
+ textContent: content.trim()
1911
+ });
1912
+ }
1913
+ }
1914
+ if (level === 0) {
1915
+ result.push(current);
1916
+ }
1917
+ parent = arr[level - 1];
1918
+ if (parent) {
1919
+ parent.children.push(current);
1920
+ }
1921
+ arr[level] = current;
1922
+ }
1923
+ if (!isOpen || !Array.isArray(current) && current.isVoid) {
1924
+ if (level > -1 && !Array.isArray(current) && (current.isVoid || current.name === element.slice(2, -1))) {
1925
+ level--;
1926
+ current = level === -1 ? result : arr[level];
1927
+ }
1928
+ if (nextChar !== "<" && nextChar) {
1929
+ parent = level === -1 ? result : arr[level].children;
1930
+ const end = html2.indexOf("<", start);
1931
+ let content = html2.slice(start, end === -1 ? void 0 : end);
1932
+ if (whitespaceReg.test(content)) {
1933
+ content = " ";
1934
+ }
1935
+ if (end > -1 && level + parent.length >= 0 || content !== " ") {
1936
+ if (content.trim()) {
1937
+ parent.push({
1938
+ type: "text",
1939
+ name: null,
1940
+ attributes: {},
1941
+ children: [],
1942
+ isVoid: false,
1943
+ textContent: content.trim()
1944
+ });
1945
+ }
1946
+ }
1947
+ }
1948
+ }
1949
+ return element;
1950
+ });
1951
+ return result;
1952
+ }
1953
+ function attrString(attrs2) {
1954
+ const buff = [];
1955
+ for (let key in attrs2) {
1956
+ buff.push(key + '="' + attrs2[key] + '"');
1957
+ }
1958
+ if (!buff.length) {
1959
+ return "";
1960
+ }
1961
+ return " " + buff.join(" ");
1962
+ }
1963
+ function stringify(buff, htmlNode) {
1964
+ switch (htmlNode.type) {
1965
+ case "text":
1966
+ return buff + htmlNode.textContent;
1967
+ case "element":
1968
+ buff += "<" + htmlNode.name + (htmlNode.attributes ? attrString(htmlNode.attributes) : "") + (htmlNode.isVoid ? "/>" : ">");
1969
+ if (htmlNode.isVoid) {
1970
+ return buff;
1971
+ }
1972
+ return buff + htmlNode.children.reduce(stringify, "") + "</" + htmlNode.name + ">";
1973
+ case "comment":
1974
+ buff += "<!--" + htmlNode.comment + "-->";
1975
+ return buff;
1976
+ }
1977
+ }
1978
+ function generateHTML(htmlNodes) {
1979
+ return htmlNodes.reduce(function(token, rootEl) {
1980
+ return token + stringify("", rootEl);
1981
+ }, "");
1982
+ }
1983
+ function compressImage(src, opts) {
1984
+ let radio = 0.5;
1985
+ const type = (opts == null ? void 0 : opts.type) || "image/png";
1986
+ if ((opts == null ? void 0 : opts.radio) && (opts == null ? void 0 : opts.radio) > 0 && (opts == null ? void 0 : opts.radio) <= 1) {
1987
+ radio = opts == null ? void 0 : opts.radio;
1988
+ }
1989
+ return new Promise((resolve, reject) => {
1990
+ const image = new Image();
1991
+ image.addEventListener("load", () => {
1992
+ const { width, height } = image;
1993
+ const resultW = width * radio;
1994
+ const resultH = height * radio;
1995
+ let canvas = document.createElement("canvas");
1996
+ canvas.width = resultW;
1997
+ canvas.height = resultH;
1998
+ const ctx = canvas.getContext("2d");
1999
+ ctx.drawImage(image, 0, 0, resultW, resultH);
2000
+ const base64 = canvas.toDataURL(type);
2001
+ canvas = null;
2002
+ resolve(base64);
2003
+ });
2004
+ image.addEventListener("error", (err) => {
2005
+ reject(err);
2006
+ });
2007
+ image.src = src;
2008
+ });
2009
+ }
2010
+ function formatNumber(num, opts) {
2011
+ const decimalPlaces = (opts == null ? void 0 : opts.decimalPlaces) || 2;
2012
+ return parseFloat(num.toFixed(decimalPlaces));
2013
+ }
2014
+ exports.Context2D = Context2D;
2015
+ exports.EventEmitter = EventEmitter;
2016
+ exports.Store = Store;
2017
+ exports.calcDistance = calcDistance;
2018
+ exports.calcElementCenter = calcElementCenter;
2019
+ exports.calcElementCenterFromVertexes = calcElementCenterFromVertexes;
2020
+ exports.calcElementQueueVertexesQueueInGroup = calcElementQueueVertexesQueueInGroup;
2021
+ exports.calcElementSizeController = calcElementSizeController;
2022
+ exports.calcElementVertexesInGroup = calcElementVertexesInGroup;
2023
+ exports.calcElementVertexesQueueInGroup = calcElementVertexesQueueInGroup;
2024
+ exports.calcElementsContextSize = calcElementsContextSize;
2025
+ exports.calcElementsViewInfo = calcElementsViewInfo;
2026
+ exports.calcSpeed = calcSpeed;
2027
+ exports.calcViewElementSize = calcViewElementSize;
2028
+ exports.calcViewPointSize = calcViewPointSize;
2029
+ exports.calcViewVertexes = calcViewVertexes;
696
2030
  exports.check = check;
2031
+ exports.checkRectIntersect = checkRectIntersect;
2032
+ exports.colorNameToHex = colorNameToHex;
697
2033
  exports.compose = compose;
2034
+ exports.compressImage = compressImage;
2035
+ exports.createAssetId = createAssetId;
2036
+ exports.createBoardContexts = createBoardContexts;
2037
+ exports.createContext2D = createContext2D;
2038
+ exports.createOffscreenContext2D = createOffscreenContext2D;
698
2039
  exports.createUUID = createUUID;
699
2040
  exports.deepClone = deepClone;
700
- exports.default = index;
701
2041
  exports.delay = delay;
702
2042
  exports.downloadImageFromCanvas = downloadImageFromCanvas;
2043
+ exports.equalPoint = equalPoint;
2044
+ exports.equalTouchPoint = equalTouchPoint;
2045
+ exports.findElementFromList = findElementFromList;
2046
+ exports.findElementsFromList = findElementsFromList;
2047
+ exports.formatNumber = formatNumber;
2048
+ exports.generateHTML = generateHTML;
2049
+ exports.generateSVGPath = generateSVGPath;
2050
+ exports.getCenterFromTwoPoints = getCenterFromTwoPoints;
2051
+ exports.getElemenetsAssetIds = getElemenetsAssetIds;
2052
+ exports.getElementRotateVertexes = getElementRotateVertexes;
2053
+ exports.getElementVertexes = getElementVertexes;
2054
+ exports.getGroupQueueFromList = getGroupQueueFromList;
2055
+ exports.getSelectedElementUUIDs = getSelectedElementUUIDs;
2056
+ exports.getViewPointAtElement = getViewPointAtElement;
2057
+ exports.getViewScaleInfoFromSnapshot = getViewScaleInfoFromSnapshot;
2058
+ exports.getViewSizeInfoFromSnapshot = getViewSizeInfoFromSnapshot;
703
2059
  exports.is = is;
2060
+ exports.isAssetId = isAssetId;
704
2061
  exports.isColorStr = isColorStr;
705
- exports.istype = istype;
2062
+ exports.isElementInView = isElementInView;
2063
+ exports.isViewPointInElement = isViewPointInElement;
2064
+ exports.istype = istype$1;
2065
+ exports.limitAngle = limitAngle;
706
2066
  exports.loadHTML = loadHTML;
707
2067
  exports.loadImage = loadImage;
708
2068
  exports.loadSVG = loadSVG;
2069
+ exports.parseAngleToRadian = parseAngleToRadian;
2070
+ exports.parseHTML = parseHTML;
2071
+ exports.parseRadianToAngle = parseRadianToAngle;
2072
+ exports.parseSVGPath = parseSVGPath;
2073
+ exports.rotateElement = rotateElement;
2074
+ exports.rotateElementVertexes = rotateElementVertexes;
2075
+ exports.rotatePoint = rotatePoint;
2076
+ exports.rotatePointInGroup = rotatePointInGroup;
2077
+ exports.rotateVertexes = rotateVertexes;
2078
+ exports.sortDataAsserts = sortDataAsserts;
709
2079
  exports.throttle = throttle;
710
2080
  exports.toColorHexNum = toColorHexNum;
711
2081
  exports.toColorHexStr = toColorHexStr;
712
- Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
2082
+ exports.updateElementInList = updateElementInList;
2083
+ exports.vaildPoint = vaildPoint;
2084
+ exports.vaildTouchPoint = vaildTouchPoint;
2085
+ exports.validateElements = validateElements;
2086
+ exports.viewScale = viewScale;
2087
+ exports.viewScroll = viewScroll;
2088
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
713
2089
  return exports;
714
2090
  }({});