web-annotation-renderer 0.6.0 → 0.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/dist/index.cjs +1 -1
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.js +52 -51
  4. package/dist/index.js.map +1 -1
  5. package/dist/index10.cjs +1 -1
  6. package/dist/index10.cjs.map +1 -1
  7. package/dist/index10.js +13 -210
  8. package/dist/index10.js.map +1 -1
  9. package/dist/index11.cjs +1 -1
  10. package/dist/index11.cjs.map +1 -1
  11. package/dist/index11.js +50 -13
  12. package/dist/index11.js.map +1 -1
  13. package/dist/index12.cjs +1 -1
  14. package/dist/index12.cjs.map +1 -1
  15. package/dist/index12.js +155 -48
  16. package/dist/index12.js.map +1 -1
  17. package/dist/index13.cjs +1 -1
  18. package/dist/index13.cjs.map +1 -1
  19. package/dist/index13.js +34 -169
  20. package/dist/index13.js.map +1 -1
  21. package/dist/index14.cjs +1 -1
  22. package/dist/index14.cjs.map +1 -1
  23. package/dist/index14.js +65 -28
  24. package/dist/index14.js.map +1 -1
  25. package/dist/index15.cjs +1 -1
  26. package/dist/index15.cjs.map +1 -1
  27. package/dist/index15.js +33 -71
  28. package/dist/index15.js.map +1 -1
  29. package/dist/index16.cjs +1 -1
  30. package/dist/index16.cjs.map +1 -1
  31. package/dist/index16.js +77 -22
  32. package/dist/index16.js.map +1 -1
  33. package/dist/index17.cjs +1 -1
  34. package/dist/index17.cjs.map +1 -1
  35. package/dist/index17.js +31 -52
  36. package/dist/index17.js.map +1 -1
  37. package/dist/index18.cjs +1 -1
  38. package/dist/index18.cjs.map +1 -1
  39. package/dist/index18.js +22 -23
  40. package/dist/index18.js.map +1 -1
  41. package/dist/index2.cjs +1 -1
  42. package/dist/index2.cjs.map +1 -1
  43. package/dist/index2.js +5 -6
  44. package/dist/index2.js.map +1 -1
  45. package/dist/index21.cjs +1 -1
  46. package/dist/index21.cjs.map +1 -1
  47. package/dist/index21.js +48 -27
  48. package/dist/index21.js.map +1 -1
  49. package/dist/index24.cjs +1 -1
  50. package/dist/index24.js +1 -1
  51. package/dist/index25.cjs +1 -1
  52. package/dist/index25.js +1 -1
  53. package/dist/index29.cjs +1 -1
  54. package/dist/index29.cjs.map +1 -1
  55. package/dist/index29.js +70 -4
  56. package/dist/index29.js.map +1 -1
  57. package/dist/index3.cjs +1 -1
  58. package/dist/index3.js +1 -1
  59. package/dist/index30.cjs +2 -0
  60. package/dist/index30.cjs.map +1 -0
  61. package/dist/index30.js +8 -0
  62. package/dist/index30.js.map +1 -0
  63. package/dist/index31.cjs +2 -0
  64. package/dist/index31.cjs.map +1 -0
  65. package/dist/index31.js +995 -0
  66. package/dist/index31.js.map +1 -0
  67. package/dist/index5.cjs +1 -1
  68. package/dist/index5.cjs.map +1 -1
  69. package/dist/index5.js +189 -80
  70. package/dist/index5.js.map +1 -1
  71. package/dist/index6.cjs +1 -1
  72. package/dist/index6.cjs.map +1 -1
  73. package/dist/index6.js +18 -60
  74. package/dist/index6.js.map +1 -1
  75. package/dist/index7.cjs +1 -1
  76. package/dist/index7.cjs.map +1 -1
  77. package/dist/index7.js +17 -17
  78. package/dist/index7.js.map +1 -1
  79. package/dist/index8.cjs +1 -1
  80. package/dist/index8.cjs.map +1 -1
  81. package/dist/index8.js +125 -16
  82. package/dist/index8.js.map +1 -1
  83. package/dist/index9.cjs +1 -1
  84. package/dist/index9.cjs.map +1 -1
  85. package/dist/index9.js +201 -118
  86. package/dist/index9.js.map +1 -1
  87. package/package.json +4 -2
@@ -0,0 +1,995 @@
1
+ function X(a, e, s) {
2
+ if (a && a.length) {
3
+ const [t, n] = e, o = Math.PI / 180 * s, r = Math.cos(o), h = Math.sin(o);
4
+ for (const i of a) {
5
+ const [l, c] = i;
6
+ i[0] = (l - t) * r - (c - n) * h + t, i[1] = (l - t) * h + (c - n) * r + n;
7
+ }
8
+ }
9
+ }
10
+ function Ot(a, e) {
11
+ return a[0] === e[0] && a[1] === e[1];
12
+ }
13
+ function Lt(a, e, s, t = 1) {
14
+ const n = s, o = Math.max(e, 0.1), r = a[0] && a[0][0] && typeof a[0][0] == "number" ? [a] : a, h = [0, 0];
15
+ if (n) for (const l of r) X(l, h, n);
16
+ const i = (function(l, c, d) {
17
+ const p = [];
18
+ for (const M of l) {
19
+ const m = [...M];
20
+ Ot(m[0], m[m.length - 1]) || m.push([m[0][0], m[0][1]]), m.length > 2 && p.push(m);
21
+ }
22
+ const u = [];
23
+ c = Math.max(c, 0.1);
24
+ const f = [];
25
+ for (const M of p) for (let m = 0; m < M.length - 1; m++) {
26
+ const P = M[m], x = M[m + 1];
27
+ if (P[1] !== x[1]) {
28
+ const w = Math.min(P[1], x[1]);
29
+ f.push({ ymin: w, ymax: Math.max(P[1], x[1]), x: w === P[1] ? P[0] : x[0], islope: (x[0] - P[0]) / (x[1] - P[1]) });
30
+ }
31
+ }
32
+ if (f.sort(((M, m) => M.ymin < m.ymin ? -1 : M.ymin > m.ymin ? 1 : M.x < m.x ? -1 : M.x > m.x ? 1 : M.ymax === m.ymax ? 0 : (M.ymax - m.ymax) / Math.abs(M.ymax - m.ymax))), !f.length) return u;
33
+ let g = [], k = f[0].ymin, b = 0;
34
+ for (; g.length || f.length; ) {
35
+ if (f.length) {
36
+ let M = -1;
37
+ for (let m = 0; m < f.length && !(f[m].ymin > k); m++) M = m;
38
+ f.splice(0, M + 1).forEach(((m) => {
39
+ g.push({ s: k, edge: m });
40
+ }));
41
+ }
42
+ if (g = g.filter(((M) => !(M.edge.ymax <= k))), g.sort(((M, m) => M.edge.x === m.edge.x ? 0 : (M.edge.x - m.edge.x) / Math.abs(M.edge.x - m.edge.x))), (d !== 1 || b % c == 0) && g.length > 1) for (let M = 0; M < g.length; M += 2) {
43
+ const m = M + 1;
44
+ if (m >= g.length) break;
45
+ const P = g[M].edge, x = g[m].edge;
46
+ u.push([[Math.round(P.x), k], [Math.round(x.x), k]]);
47
+ }
48
+ k += d, g.forEach(((M) => {
49
+ M.edge.x = M.edge.x + d * M.edge.islope;
50
+ })), b++;
51
+ }
52
+ return u;
53
+ })(r, o, t);
54
+ if (n) {
55
+ for (const l of r) X(l, h, -n);
56
+ (function(l, c, d) {
57
+ const p = [];
58
+ l.forEach(((u) => p.push(...u))), X(p, c, d);
59
+ })(i, h, -n);
60
+ }
61
+ return i;
62
+ }
63
+ function j(a, e) {
64
+ var s;
65
+ const t = e.hachureAngle + 90;
66
+ let n = e.hachureGap;
67
+ n < 0 && (n = 4 * e.strokeWidth), n = Math.round(Math.max(n, 0.1));
68
+ let o = 1;
69
+ return e.roughness >= 1 && (((s = e.randomizer) === null || s === void 0 ? void 0 : s.next()) || Math.random()) > 0.7 && (o = n), Lt(a, n, t, o || 1);
70
+ }
71
+ class ht {
72
+ constructor(e) {
73
+ this.helper = e;
74
+ }
75
+ fillPolygons(e, s) {
76
+ return this._fillPolygons(e, s);
77
+ }
78
+ _fillPolygons(e, s) {
79
+ const t = j(e, s);
80
+ return { type: "fillSketch", ops: this.renderLines(t, s) };
81
+ }
82
+ renderLines(e, s) {
83
+ const t = [];
84
+ for (const n of e) t.push(...this.helper.doubleLineOps(n[0][0], n[0][1], n[1][0], n[1][1], s));
85
+ return t;
86
+ }
87
+ }
88
+ function U(a) {
89
+ const e = a[0], s = a[1];
90
+ return Math.sqrt(Math.pow(e[0] - s[0], 2) + Math.pow(e[1] - s[1], 2));
91
+ }
92
+ class Tt extends ht {
93
+ fillPolygons(e, s) {
94
+ let t = s.hachureGap;
95
+ t < 0 && (t = 4 * s.strokeWidth), t = Math.max(t, 0.1);
96
+ const n = j(e, Object.assign({}, s, { hachureGap: t })), o = Math.PI / 180 * s.hachureAngle, r = [], h = 0.5 * t * Math.cos(o), i = 0.5 * t * Math.sin(o);
97
+ for (const [l, c] of n) U([l, c]) && r.push([[l[0] - h, l[1] + i], [...c]], [[l[0] + h, l[1] - i], [...c]]);
98
+ return { type: "fillSketch", ops: this.renderLines(r, s) };
99
+ }
100
+ }
101
+ class Dt extends ht {
102
+ fillPolygons(e, s) {
103
+ const t = this._fillPolygons(e, s), n = Object.assign({}, s, { hachureAngle: s.hachureAngle + 90 }), o = this._fillPolygons(e, n);
104
+ return t.ops = t.ops.concat(o.ops), t;
105
+ }
106
+ }
107
+ class At {
108
+ constructor(e) {
109
+ this.helper = e;
110
+ }
111
+ fillPolygons(e, s) {
112
+ const t = j(e, s = Object.assign({}, s, { hachureAngle: 0 }));
113
+ return this.dotsOnLines(t, s);
114
+ }
115
+ dotsOnLines(e, s) {
116
+ const t = [];
117
+ let n = s.hachureGap;
118
+ n < 0 && (n = 4 * s.strokeWidth), n = Math.max(n, 0.1);
119
+ let o = s.fillWeight;
120
+ o < 0 && (o = s.strokeWidth / 2);
121
+ const r = n / 4;
122
+ for (const h of e) {
123
+ const i = U(h), l = i / n, c = Math.ceil(l) - 1, d = i - c * n, p = (h[0][0] + h[1][0]) / 2 - n / 4, u = Math.min(h[0][1], h[1][1]);
124
+ for (let f = 0; f < c; f++) {
125
+ const g = u + d + f * n, k = p - r + 2 * Math.random() * r, b = g - r + 2 * Math.random() * r, M = this.helper.ellipse(k, b, o, o, s);
126
+ t.push(...M.ops);
127
+ }
128
+ }
129
+ return { type: "fillSketch", ops: t };
130
+ }
131
+ }
132
+ class _t {
133
+ constructor(e) {
134
+ this.helper = e;
135
+ }
136
+ fillPolygons(e, s) {
137
+ const t = j(e, s);
138
+ return { type: "fillSketch", ops: this.dashedLine(t, s) };
139
+ }
140
+ dashedLine(e, s) {
141
+ const t = s.dashOffset < 0 ? s.hachureGap < 0 ? 4 * s.strokeWidth : s.hachureGap : s.dashOffset, n = s.dashGap < 0 ? s.hachureGap < 0 ? 4 * s.strokeWidth : s.hachureGap : s.dashGap, o = [];
142
+ return e.forEach(((r) => {
143
+ const h = U(r), i = Math.floor(h / (t + n)), l = (h + n - i * (t + n)) / 2;
144
+ let c = r[0], d = r[1];
145
+ c[0] > d[0] && (c = r[1], d = r[0]);
146
+ const p = Math.atan((d[1] - c[1]) / (d[0] - c[0]));
147
+ for (let u = 0; u < i; u++) {
148
+ const f = u * (t + n), g = f + t, k = [c[0] + f * Math.cos(p) + l * Math.cos(p), c[1] + f * Math.sin(p) + l * Math.sin(p)], b = [c[0] + g * Math.cos(p) + l * Math.cos(p), c[1] + g * Math.sin(p) + l * Math.sin(p)];
149
+ o.push(...this.helper.doubleLineOps(k[0], k[1], b[0], b[1], s));
150
+ }
151
+ })), o;
152
+ }
153
+ }
154
+ class It {
155
+ constructor(e) {
156
+ this.helper = e;
157
+ }
158
+ fillPolygons(e, s) {
159
+ const t = s.hachureGap < 0 ? 4 * s.strokeWidth : s.hachureGap, n = s.zigzagOffset < 0 ? t : s.zigzagOffset, o = j(e, s = Object.assign({}, s, { hachureGap: t + n }));
160
+ return { type: "fillSketch", ops: this.zigzagLines(o, n, s) };
161
+ }
162
+ zigzagLines(e, s, t) {
163
+ const n = [];
164
+ return e.forEach(((o) => {
165
+ const r = U(o), h = Math.round(r / (2 * s));
166
+ let i = o[0], l = o[1];
167
+ i[0] > l[0] && (i = o[1], l = o[0]);
168
+ const c = Math.atan((l[1] - i[1]) / (l[0] - i[0]));
169
+ for (let d = 0; d < h; d++) {
170
+ const p = 2 * d * s, u = 2 * (d + 1) * s, f = Math.sqrt(2 * Math.pow(s, 2)), g = [i[0] + p * Math.cos(c), i[1] + p * Math.sin(c)], k = [i[0] + u * Math.cos(c), i[1] + u * Math.sin(c)], b = [g[0] + f * Math.cos(c + Math.PI / 4), g[1] + f * Math.sin(c + Math.PI / 4)];
171
+ n.push(...this.helper.doubleLineOps(g[0], g[1], b[0], b[1], t), ...this.helper.doubleLineOps(b[0], b[1], k[0], k[1], t));
172
+ }
173
+ })), n;
174
+ }
175
+ }
176
+ const S = {};
177
+ class Ct {
178
+ constructor(e) {
179
+ this.seed = e;
180
+ }
181
+ next() {
182
+ return this.seed ? (2 ** 31 - 1 & (this.seed = Math.imul(48271, this.seed))) / 2 ** 31 : Math.random();
183
+ }
184
+ }
185
+ const zt = 0, Y = 1, lt = 2, F = { A: 7, a: 7, C: 6, c: 6, H: 1, h: 1, L: 2, l: 2, M: 2, m: 2, Q: 4, q: 4, S: 4, s: 4, T: 2, t: 2, V: 1, v: 1, Z: 0, z: 0 };
186
+ function tt(a, e) {
187
+ return a.type === e;
188
+ }
189
+ function rt(a) {
190
+ const e = [], s = (function(r) {
191
+ const h = new Array();
192
+ for (; r !== ""; ) if (r.match(/^([ \t\r\n,]+)/)) r = r.substr(RegExp.$1.length);
193
+ else if (r.match(/^([aAcChHlLmMqQsStTvVzZ])/)) h[h.length] = { type: zt, text: RegExp.$1 }, r = r.substr(RegExp.$1.length);
194
+ else {
195
+ if (!r.match(/^(([-+]?[0-9]+(\.[0-9]*)?|[-+]?\.[0-9]+)([eE][-+]?[0-9]+)?)/)) return [];
196
+ h[h.length] = { type: Y, text: `${parseFloat(RegExp.$1)}` }, r = r.substr(RegExp.$1.length);
197
+ }
198
+ return h[h.length] = { type: lt, text: "" }, h;
199
+ })(a);
200
+ let t = "BOD", n = 0, o = s[n];
201
+ for (; !tt(o, lt); ) {
202
+ let r = 0;
203
+ const h = [];
204
+ if (t === "BOD") {
205
+ if (o.text !== "M" && o.text !== "m") return rt("M0,0" + a);
206
+ n++, r = F[o.text], t = o.text;
207
+ } else tt(o, Y) ? r = F[t] : (n++, r = F[o.text], t = o.text);
208
+ if (!(n + r < s.length)) throw new Error("Path data ended short");
209
+ for (let i = n; i < n + r; i++) {
210
+ const l = s[i];
211
+ if (!tt(l, Y)) throw new Error("Param not a number: " + t + "," + l.text);
212
+ h[h.length] = +l.text;
213
+ }
214
+ if (typeof F[t] != "number") throw new Error("Bad segment: " + t);
215
+ {
216
+ const i = { key: t, data: h };
217
+ e.push(i), n += r, o = s[n], t === "M" && (t = "L"), t === "m" && (t = "l");
218
+ }
219
+ }
220
+ return e;
221
+ }
222
+ function bt(a) {
223
+ let e = 0, s = 0, t = 0, n = 0;
224
+ const o = [];
225
+ for (const { key: r, data: h } of a) switch (r) {
226
+ case "M":
227
+ o.push({ key: "M", data: [...h] }), [e, s] = h, [t, n] = h;
228
+ break;
229
+ case "m":
230
+ e += h[0], s += h[1], o.push({ key: "M", data: [e, s] }), t = e, n = s;
231
+ break;
232
+ case "L":
233
+ o.push({ key: "L", data: [...h] }), [e, s] = h;
234
+ break;
235
+ case "l":
236
+ e += h[0], s += h[1], o.push({ key: "L", data: [e, s] });
237
+ break;
238
+ case "C":
239
+ o.push({ key: "C", data: [...h] }), e = h[4], s = h[5];
240
+ break;
241
+ case "c": {
242
+ const i = h.map(((l, c) => c % 2 ? l + s : l + e));
243
+ o.push({ key: "C", data: i }), e = i[4], s = i[5];
244
+ break;
245
+ }
246
+ case "Q":
247
+ o.push({ key: "Q", data: [...h] }), e = h[2], s = h[3];
248
+ break;
249
+ case "q": {
250
+ const i = h.map(((l, c) => c % 2 ? l + s : l + e));
251
+ o.push({ key: "Q", data: i }), e = i[2], s = i[3];
252
+ break;
253
+ }
254
+ case "A":
255
+ o.push({ key: "A", data: [...h] }), e = h[5], s = h[6];
256
+ break;
257
+ case "a":
258
+ e += h[5], s += h[6], o.push({ key: "A", data: [h[0], h[1], h[2], h[3], h[4], e, s] });
259
+ break;
260
+ case "H":
261
+ o.push({ key: "H", data: [...h] }), e = h[0];
262
+ break;
263
+ case "h":
264
+ e += h[0], o.push({ key: "H", data: [e] });
265
+ break;
266
+ case "V":
267
+ o.push({ key: "V", data: [...h] }), s = h[0];
268
+ break;
269
+ case "v":
270
+ s += h[0], o.push({ key: "V", data: [s] });
271
+ break;
272
+ case "S":
273
+ o.push({ key: "S", data: [...h] }), e = h[2], s = h[3];
274
+ break;
275
+ case "s": {
276
+ const i = h.map(((l, c) => c % 2 ? l + s : l + e));
277
+ o.push({ key: "S", data: i }), e = i[2], s = i[3];
278
+ break;
279
+ }
280
+ case "T":
281
+ o.push({ key: "T", data: [...h] }), e = h[0], s = h[1];
282
+ break;
283
+ case "t":
284
+ e += h[0], s += h[1], o.push({ key: "T", data: [e, s] });
285
+ break;
286
+ case "Z":
287
+ case "z":
288
+ o.push({ key: "Z", data: [] }), e = t, s = n;
289
+ }
290
+ return o;
291
+ }
292
+ function yt(a) {
293
+ const e = [];
294
+ let s = "", t = 0, n = 0, o = 0, r = 0, h = 0, i = 0;
295
+ for (const { key: l, data: c } of a) {
296
+ switch (l) {
297
+ case "M":
298
+ e.push({ key: "M", data: [...c] }), [t, n] = c, [o, r] = c;
299
+ break;
300
+ case "C":
301
+ e.push({ key: "C", data: [...c] }), t = c[4], n = c[5], h = c[2], i = c[3];
302
+ break;
303
+ case "L":
304
+ e.push({ key: "L", data: [...c] }), [t, n] = c;
305
+ break;
306
+ case "H":
307
+ t = c[0], e.push({ key: "L", data: [t, n] });
308
+ break;
309
+ case "V":
310
+ n = c[0], e.push({ key: "L", data: [t, n] });
311
+ break;
312
+ case "S": {
313
+ let d = 0, p = 0;
314
+ s === "C" || s === "S" ? (d = t + (t - h), p = n + (n - i)) : (d = t, p = n), e.push({ key: "C", data: [d, p, ...c] }), h = c[0], i = c[1], t = c[2], n = c[3];
315
+ break;
316
+ }
317
+ case "T": {
318
+ const [d, p] = c;
319
+ let u = 0, f = 0;
320
+ s === "Q" || s === "T" ? (u = t + (t - h), f = n + (n - i)) : (u = t, f = n);
321
+ const g = t + 2 * (u - t) / 3, k = n + 2 * (f - n) / 3, b = d + 2 * (u - d) / 3, M = p + 2 * (f - p) / 3;
322
+ e.push({ key: "C", data: [g, k, b, M, d, p] }), h = u, i = f, t = d, n = p;
323
+ break;
324
+ }
325
+ case "Q": {
326
+ const [d, p, u, f] = c, g = t + 2 * (d - t) / 3, k = n + 2 * (p - n) / 3, b = u + 2 * (d - u) / 3, M = f + 2 * (p - f) / 3;
327
+ e.push({ key: "C", data: [g, k, b, M, u, f] }), h = d, i = p, t = u, n = f;
328
+ break;
329
+ }
330
+ case "A": {
331
+ const d = Math.abs(c[0]), p = Math.abs(c[1]), u = c[2], f = c[3], g = c[4], k = c[5], b = c[6];
332
+ d === 0 || p === 0 ? (e.push({ key: "C", data: [t, n, k, b, k, b] }), t = k, n = b) : (t !== k || n !== b) && (mt(t, n, k, b, d, p, u, f, g).forEach((function(M) {
333
+ e.push({ key: "C", data: M });
334
+ })), t = k, n = b);
335
+ break;
336
+ }
337
+ case "Z":
338
+ e.push({ key: "Z", data: [] }), t = o, n = r;
339
+ }
340
+ s = l;
341
+ }
342
+ return e;
343
+ }
344
+ function $(a, e, s) {
345
+ return [a * Math.cos(s) - e * Math.sin(s), a * Math.sin(s) + e * Math.cos(s)];
346
+ }
347
+ function mt(a, e, s, t, n, o, r, h, i, l) {
348
+ const c = (d = r, Math.PI * d / 180);
349
+ var d;
350
+ let p = [], u = 0, f = 0, g = 0, k = 0;
351
+ if (l) [u, f, g, k] = l;
352
+ else {
353
+ [a, e] = $(a, e, -c), [s, t] = $(s, t, -c);
354
+ const T = (a - s) / 2, v = (e - t) / 2;
355
+ let _ = T * T / (n * n) + v * v / (o * o);
356
+ _ > 1 && (_ = Math.sqrt(_), n *= _, o *= _);
357
+ const W = n * n, E = o * o, vt = W * E - W * v * v - E * T * T, St = W * v * v + E * T * T, ct = (h === i ? -1 : 1) * Math.sqrt(Math.abs(vt / St));
358
+ g = ct * n * v / o + (a + s) / 2, k = ct * -o * T / n + (e + t) / 2, u = Math.asin(parseFloat(((e - k) / o).toFixed(9))), f = Math.asin(parseFloat(((t - k) / o).toFixed(9))), a < g && (u = Math.PI - u), s < g && (f = Math.PI - f), u < 0 && (u = 2 * Math.PI + u), f < 0 && (f = 2 * Math.PI + f), i && u > f && (u -= 2 * Math.PI), !i && f > u && (f -= 2 * Math.PI);
359
+ }
360
+ let b = f - u;
361
+ if (Math.abs(b) > 120 * Math.PI / 180) {
362
+ const T = f, v = s, _ = t;
363
+ f = i && f > u ? u + 120 * Math.PI / 180 * 1 : u + 120 * Math.PI / 180 * -1, p = mt(s = g + n * Math.cos(f), t = k + o * Math.sin(f), v, _, n, o, r, 0, i, [f, T, g, k]);
364
+ }
365
+ b = f - u;
366
+ const M = Math.cos(u), m = Math.sin(u), P = Math.cos(f), x = Math.sin(f), w = Math.tan(b / 4), L = 4 / 3 * n * w, A = 4 / 3 * o * w, q = [a, e], D = [a + L * m, e - A * M], C = [s + L * x, t - A * P], it = [s, t];
367
+ if (D[0] = 2 * q[0] - D[0], D[1] = 2 * q[1] - D[1], l) return [D, C, it].concat(p);
368
+ {
369
+ p = [D, C, it].concat(p);
370
+ const T = [];
371
+ for (let v = 0; v < p.length; v += 3) {
372
+ const _ = $(p[v][0], p[v][1], c), W = $(p[v + 1][0], p[v + 1][1], c), E = $(p[v + 2][0], p[v + 2][1], c);
373
+ T.push([_[0], _[1], W[0], W[1], E[0], E[1]]);
374
+ }
375
+ return T;
376
+ }
377
+ }
378
+ const Wt = { randOffset: function(a, e) {
379
+ return y(a, e);
380
+ }, randOffsetWithRange: function(a, e, s) {
381
+ return N(a, e, s);
382
+ }, ellipse: function(a, e, s, t, n) {
383
+ const o = xt(s, t, n);
384
+ return nt(a, e, n, o).opset;
385
+ }, doubleLineOps: function(a, e, s, t, n) {
386
+ return I(a, e, s, t, n, !0);
387
+ } };
388
+ function wt(a, e, s, t, n) {
389
+ return { type: "path", ops: I(a, e, s, t, n) };
390
+ }
391
+ function Q(a, e, s) {
392
+ const t = (a || []).length;
393
+ if (t > 2) {
394
+ const n = [];
395
+ for (let o = 0; o < t - 1; o++) n.push(...I(a[o][0], a[o][1], a[o + 1][0], a[o + 1][1], s));
396
+ return e && n.push(...I(a[t - 1][0], a[t - 1][1], a[0][0], a[0][1], s)), { type: "path", ops: n };
397
+ }
398
+ return t === 2 ? wt(a[0][0], a[0][1], a[1][0], a[1][1], s) : { type: "path", ops: [] };
399
+ }
400
+ function Et(a, e, s, t, n) {
401
+ return (function(o, r) {
402
+ return Q(o, !0, r);
403
+ })([[a, e], [a + s, e], [a + s, e + t], [a, e + t]], n);
404
+ }
405
+ function ut(a, e) {
406
+ if (a.length) {
407
+ const s = typeof a[0][0] == "number" ? [a] : a, t = V(s[0], 1 * (1 + 0.2 * e.roughness), e), n = e.disableMultiStroke ? [] : V(s[0], 1.5 * (1 + 0.22 * e.roughness), dt(e));
408
+ for (let o = 1; o < s.length; o++) {
409
+ const r = s[o];
410
+ if (r.length) {
411
+ const h = V(r, 1 * (1 + 0.2 * e.roughness), e), i = e.disableMultiStroke ? [] : V(r, 1.5 * (1 + 0.22 * e.roughness), dt(e));
412
+ for (const l of h) l.op !== "move" && t.push(l);
413
+ for (const l of i) l.op !== "move" && n.push(l);
414
+ }
415
+ }
416
+ return { type: "path", ops: t.concat(n) };
417
+ }
418
+ return { type: "path", ops: [] };
419
+ }
420
+ function xt(a, e, s) {
421
+ const t = Math.sqrt(2 * Math.PI * Math.sqrt((Math.pow(a / 2, 2) + Math.pow(e / 2, 2)) / 2)), n = Math.ceil(Math.max(s.curveStepCount, s.curveStepCount / Math.sqrt(200) * t)), o = 2 * Math.PI / n;
422
+ let r = Math.abs(a / 2), h = Math.abs(e / 2);
423
+ const i = 1 - s.curveFitting;
424
+ return r += y(r * i, s), h += y(h * i, s), { increment: o, rx: r, ry: h };
425
+ }
426
+ function nt(a, e, s, t) {
427
+ const [n, o] = gt(t.increment, a, e, t.rx, t.ry, 1, t.increment * N(0.1, N(0.4, 1, s), s), s);
428
+ let r = B(n, null, s);
429
+ if (!s.disableMultiStroke && s.roughness !== 0) {
430
+ const [h] = gt(t.increment, a, e, t.rx, t.ry, 1.5, 0, s), i = B(h, null, s);
431
+ r = r.concat(i);
432
+ }
433
+ return { estimatedPoints: o, opset: { type: "path", ops: r } };
434
+ }
435
+ function pt(a, e, s, t, n, o, r, h, i) {
436
+ const l = a, c = e;
437
+ let d = Math.abs(s / 2), p = Math.abs(t / 2);
438
+ d += y(0.01 * d, i), p += y(0.01 * p, i);
439
+ let u = n, f = o;
440
+ for (; u < 0; ) u += 2 * Math.PI, f += 2 * Math.PI;
441
+ f - u > 2 * Math.PI && (u = 0, f = 2 * Math.PI);
442
+ const g = 2 * Math.PI / i.curveStepCount, k = Math.min(g / 2, (f - u) / 2), b = Mt(k, l, c, d, p, u, f, 1, i);
443
+ if (!i.disableMultiStroke) {
444
+ const M = Mt(k, l, c, d, p, u, f, 1.5, i);
445
+ b.push(...M);
446
+ }
447
+ return r && (h ? b.push(...I(l, c, l + d * Math.cos(u), c + p * Math.sin(u), i), ...I(l, c, l + d * Math.cos(f), c + p * Math.sin(f), i)) : b.push({ op: "lineTo", data: [l, c] }, { op: "lineTo", data: [l + d * Math.cos(u), c + p * Math.sin(u)] })), { type: "path", ops: b };
448
+ }
449
+ function ft(a, e) {
450
+ const s = yt(bt(rt(a))), t = [];
451
+ let n = [0, 0], o = [0, 0];
452
+ for (const { key: r, data: h } of s) switch (r) {
453
+ case "M":
454
+ o = [h[0], h[1]], n = [h[0], h[1]];
455
+ break;
456
+ case "L":
457
+ t.push(...I(o[0], o[1], h[0], h[1], e)), o = [h[0], h[1]];
458
+ break;
459
+ case "C": {
460
+ const [i, l, c, d, p, u] = h;
461
+ t.push(...Gt(i, l, c, d, p, u, o, e)), o = [p, u];
462
+ break;
463
+ }
464
+ case "Z":
465
+ t.push(...I(o[0], o[1], n[0], n[1], e)), o = [n[0], n[1]];
466
+ }
467
+ return { type: "path", ops: t };
468
+ }
469
+ function et(a, e) {
470
+ const s = [];
471
+ for (const t of a) if (t.length) {
472
+ const n = e.maxRandomnessOffset || 0, o = t.length;
473
+ if (o > 2) {
474
+ s.push({ op: "move", data: [t[0][0] + y(n, e), t[0][1] + y(n, e)] });
475
+ for (let r = 1; r < o; r++) s.push({ op: "lineTo", data: [t[r][0] + y(n, e), t[r][1] + y(n, e)] });
476
+ }
477
+ }
478
+ return { type: "fillPath", ops: s };
479
+ }
480
+ function G(a, e) {
481
+ return (function(s, t) {
482
+ let n = s.fillStyle || "hachure";
483
+ if (!S[n]) switch (n) {
484
+ case "zigzag":
485
+ S[n] || (S[n] = new Tt(t));
486
+ break;
487
+ case "cross-hatch":
488
+ S[n] || (S[n] = new Dt(t));
489
+ break;
490
+ case "dots":
491
+ S[n] || (S[n] = new At(t));
492
+ break;
493
+ case "dashed":
494
+ S[n] || (S[n] = new _t(t));
495
+ break;
496
+ case "zigzag-line":
497
+ S[n] || (S[n] = new It(t));
498
+ break;
499
+ default:
500
+ n = "hachure", S[n] || (S[n] = new ht(t));
501
+ }
502
+ return S[n];
503
+ })(e, Wt).fillPolygons(a, e);
504
+ }
505
+ function dt(a) {
506
+ const e = Object.assign({}, a);
507
+ return e.randomizer = void 0, a.seed && (e.seed = a.seed + 1), e;
508
+ }
509
+ function Pt(a) {
510
+ return a.randomizer || (a.randomizer = new Ct(a.seed || 0)), a.randomizer.next();
511
+ }
512
+ function N(a, e, s, t = 1) {
513
+ return s.roughness * t * (Pt(s) * (e - a) + a);
514
+ }
515
+ function y(a, e, s = 1) {
516
+ return N(-a, a, e, s);
517
+ }
518
+ function I(a, e, s, t, n, o = !1) {
519
+ const r = o ? n.disableMultiStrokeFill : n.disableMultiStroke, h = at(a, e, s, t, n, !0, !1);
520
+ if (r) return h;
521
+ const i = at(a, e, s, t, n, !0, !0);
522
+ return h.concat(i);
523
+ }
524
+ function at(a, e, s, t, n, o, r) {
525
+ const h = Math.pow(a - s, 2) + Math.pow(e - t, 2), i = Math.sqrt(h);
526
+ let l = 1;
527
+ l = i < 200 ? 1 : i > 500 ? 0.4 : -16668e-7 * i + 1.233334;
528
+ let c = n.maxRandomnessOffset || 0;
529
+ c * c * 100 > h && (c = i / 10);
530
+ const d = c / 2, p = 0.2 + 0.2 * Pt(n);
531
+ let u = n.bowing * n.maxRandomnessOffset * (t - e) / 200, f = n.bowing * n.maxRandomnessOffset * (a - s) / 200;
532
+ u = y(u, n, l), f = y(f, n, l);
533
+ const g = [], k = () => y(d, n, l), b = () => y(c, n, l), M = n.preserveVertices;
534
+ return r ? g.push({ op: "move", data: [a + (M ? 0 : k()), e + (M ? 0 : k())] }) : g.push({ op: "move", data: [a + (M ? 0 : y(c, n, l)), e + (M ? 0 : y(c, n, l))] }), r ? g.push({ op: "bcurveTo", data: [u + a + (s - a) * p + k(), f + e + (t - e) * p + k(), u + a + 2 * (s - a) * p + k(), f + e + 2 * (t - e) * p + k(), s + (M ? 0 : k()), t + (M ? 0 : k())] }) : g.push({ op: "bcurveTo", data: [u + a + (s - a) * p + b(), f + e + (t - e) * p + b(), u + a + 2 * (s - a) * p + b(), f + e + 2 * (t - e) * p + b(), s + (M ? 0 : b()), t + (M ? 0 : b())] }), g;
535
+ }
536
+ function V(a, e, s) {
537
+ if (!a.length) return [];
538
+ const t = [];
539
+ t.push([a[0][0] + y(e, s), a[0][1] + y(e, s)]), t.push([a[0][0] + y(e, s), a[0][1] + y(e, s)]);
540
+ for (let n = 1; n < a.length; n++) t.push([a[n][0] + y(e, s), a[n][1] + y(e, s)]), n === a.length - 1 && t.push([a[n][0] + y(e, s), a[n][1] + y(e, s)]);
541
+ return B(t, null, s);
542
+ }
543
+ function B(a, e, s) {
544
+ const t = a.length, n = [];
545
+ if (t > 3) {
546
+ const o = [], r = 1 - s.curveTightness;
547
+ n.push({ op: "move", data: [a[1][0], a[1][1]] });
548
+ for (let h = 1; h + 2 < t; h++) {
549
+ const i = a[h];
550
+ o[0] = [i[0], i[1]], o[1] = [i[0] + (r * a[h + 1][0] - r * a[h - 1][0]) / 6, i[1] + (r * a[h + 1][1] - r * a[h - 1][1]) / 6], o[2] = [a[h + 1][0] + (r * a[h][0] - r * a[h + 2][0]) / 6, a[h + 1][1] + (r * a[h][1] - r * a[h + 2][1]) / 6], o[3] = [a[h + 1][0], a[h + 1][1]], n.push({ op: "bcurveTo", data: [o[1][0], o[1][1], o[2][0], o[2][1], o[3][0], o[3][1]] });
551
+ }
552
+ } else t === 3 ? (n.push({ op: "move", data: [a[1][0], a[1][1]] }), n.push({ op: "bcurveTo", data: [a[1][0], a[1][1], a[2][0], a[2][1], a[2][0], a[2][1]] })) : t === 2 && n.push(...at(a[0][0], a[0][1], a[1][0], a[1][1], s, !0, !0));
553
+ return n;
554
+ }
555
+ function gt(a, e, s, t, n, o, r, h) {
556
+ const i = [], l = [];
557
+ if (h.roughness === 0) {
558
+ a /= 4, l.push([e + t * Math.cos(-a), s + n * Math.sin(-a)]);
559
+ for (let c = 0; c <= 2 * Math.PI; c += a) {
560
+ const d = [e + t * Math.cos(c), s + n * Math.sin(c)];
561
+ i.push(d), l.push(d);
562
+ }
563
+ l.push([e + t * Math.cos(0), s + n * Math.sin(0)]), l.push([e + t * Math.cos(a), s + n * Math.sin(a)]);
564
+ } else {
565
+ const c = y(0.5, h) - Math.PI / 2;
566
+ l.push([y(o, h) + e + 0.9 * t * Math.cos(c - a), y(o, h) + s + 0.9 * n * Math.sin(c - a)]);
567
+ const d = 2 * Math.PI + c - 0.01;
568
+ for (let p = c; p < d; p += a) {
569
+ const u = [y(o, h) + e + t * Math.cos(p), y(o, h) + s + n * Math.sin(p)];
570
+ i.push(u), l.push(u);
571
+ }
572
+ l.push([y(o, h) + e + t * Math.cos(c + 2 * Math.PI + 0.5 * r), y(o, h) + s + n * Math.sin(c + 2 * Math.PI + 0.5 * r)]), l.push([y(o, h) + e + 0.98 * t * Math.cos(c + r), y(o, h) + s + 0.98 * n * Math.sin(c + r)]), l.push([y(o, h) + e + 0.9 * t * Math.cos(c + 0.5 * r), y(o, h) + s + 0.9 * n * Math.sin(c + 0.5 * r)]);
573
+ }
574
+ return [l, i];
575
+ }
576
+ function Mt(a, e, s, t, n, o, r, h, i) {
577
+ const l = o + y(0.1, i), c = [];
578
+ c.push([y(h, i) + e + 0.9 * t * Math.cos(l - a), y(h, i) + s + 0.9 * n * Math.sin(l - a)]);
579
+ for (let d = l; d <= r; d += a) c.push([y(h, i) + e + t * Math.cos(d), y(h, i) + s + n * Math.sin(d)]);
580
+ return c.push([e + t * Math.cos(r), s + n * Math.sin(r)]), c.push([e + t * Math.cos(r), s + n * Math.sin(r)]), B(c, null, i);
581
+ }
582
+ function Gt(a, e, s, t, n, o, r, h) {
583
+ const i = [], l = [h.maxRandomnessOffset || 1, (h.maxRandomnessOffset || 1) + 0.3];
584
+ let c = [0, 0];
585
+ const d = h.disableMultiStroke ? 1 : 2, p = h.preserveVertices;
586
+ for (let u = 0; u < d; u++) u === 0 ? i.push({ op: "move", data: [r[0], r[1]] }) : i.push({ op: "move", data: [r[0] + (p ? 0 : y(l[0], h)), r[1] + (p ? 0 : y(l[0], h))] }), c = p ? [n, o] : [n + y(l[u], h), o + y(l[u], h)], i.push({ op: "bcurveTo", data: [a + y(l[u], h), e + y(l[u], h), s + y(l[u], h), t + y(l[u], h), c[0], c[1]] });
587
+ return i;
588
+ }
589
+ function R(a) {
590
+ return [...a];
591
+ }
592
+ function kt(a, e = 0) {
593
+ const s = a.length;
594
+ if (s < 3) throw new Error("A curve must have at least three points.");
595
+ const t = [];
596
+ if (s === 3) t.push(R(a[0]), R(a[1]), R(a[2]), R(a[2]));
597
+ else {
598
+ const n = [];
599
+ n.push(a[0], a[0]);
600
+ for (let h = 1; h < a.length; h++) n.push(a[h]), h === a.length - 1 && n.push(a[h]);
601
+ const o = [], r = 1 - e;
602
+ t.push(R(n[0]));
603
+ for (let h = 1; h + 2 < n.length; h++) {
604
+ const i = n[h];
605
+ o[0] = [i[0], i[1]], o[1] = [i[0] + (r * n[h + 1][0] - r * n[h - 1][0]) / 6, i[1] + (r * n[h + 1][1] - r * n[h - 1][1]) / 6], o[2] = [n[h + 1][0] + (r * n[h][0] - r * n[h + 2][0]) / 6, n[h + 1][1] + (r * n[h][1] - r * n[h + 2][1]) / 6], o[3] = [n[h + 1][0], n[h + 1][1]], t.push(o[1], o[2], o[3]);
606
+ }
607
+ }
608
+ return t;
609
+ }
610
+ function H(a, e) {
611
+ return Math.pow(a[0] - e[0], 2) + Math.pow(a[1] - e[1], 2);
612
+ }
613
+ function $t(a, e, s) {
614
+ const t = H(e, s);
615
+ if (t === 0) return H(a, e);
616
+ let n = ((a[0] - e[0]) * (s[0] - e[0]) + (a[1] - e[1]) * (s[1] - e[1])) / t;
617
+ return n = Math.max(0, Math.min(1, n)), H(a, z(e, s, n));
618
+ }
619
+ function z(a, e, s) {
620
+ return [a[0] + (e[0] - a[0]) * s, a[1] + (e[1] - a[1]) * s];
621
+ }
622
+ function ot(a, e, s, t) {
623
+ const n = t || [];
624
+ if ((function(h, i) {
625
+ const l = h[i + 0], c = h[i + 1], d = h[i + 2], p = h[i + 3];
626
+ let u = 3 * c[0] - 2 * l[0] - p[0];
627
+ u *= u;
628
+ let f = 3 * c[1] - 2 * l[1] - p[1];
629
+ f *= f;
630
+ let g = 3 * d[0] - 2 * p[0] - l[0];
631
+ g *= g;
632
+ let k = 3 * d[1] - 2 * p[1] - l[1];
633
+ return k *= k, u < g && (u = g), f < k && (f = k), u + f;
634
+ })(a, e) < s) {
635
+ const h = a[e + 0];
636
+ n.length ? (o = n[n.length - 1], r = h, Math.sqrt(H(o, r)) > 1 && n.push(h)) : n.push(h), n.push(a[e + 3]);
637
+ } else {
638
+ const i = a[e + 0], l = a[e + 1], c = a[e + 2], d = a[e + 3], p = z(i, l, 0.5), u = z(l, c, 0.5), f = z(c, d, 0.5), g = z(p, u, 0.5), k = z(u, f, 0.5), b = z(g, k, 0.5);
639
+ ot([i, p, g, b], 0, s, n), ot([b, k, f, d], 0, s, n);
640
+ }
641
+ var o, r;
642
+ return n;
643
+ }
644
+ function Rt(a, e) {
645
+ return J(a, 0, a.length, e);
646
+ }
647
+ function J(a, e, s, t, n) {
648
+ const o = n || [], r = a[e], h = a[s - 1];
649
+ let i = 0, l = 1;
650
+ for (let c = e + 1; c < s - 1; ++c) {
651
+ const d = $t(a[c], r, h);
652
+ d > i && (i = d, l = c);
653
+ }
654
+ return Math.sqrt(i) > t ? (J(a, e, l + 1, t, o), J(a, l, s, t, o)) : (o.length || o.push(r), o.push(h)), o;
655
+ }
656
+ function st(a, e = 0.15, s) {
657
+ const t = [], n = (a.length - 1) / 3;
658
+ for (let o = 0; o < n; o++)
659
+ ot(a, 3 * o, e, t);
660
+ return s && s > 0 ? J(t, 0, t.length, s) : t;
661
+ }
662
+ const O = "none";
663
+ class K {
664
+ constructor(e) {
665
+ this.defaultOptions = { maxRandomnessOffset: 2, roughness: 1, bowing: 1, stroke: "#000", strokeWidth: 1, curveTightness: 0, curveFitting: 0.95, curveStepCount: 9, fillStyle: "hachure", fillWeight: -1, hachureAngle: -41, hachureGap: -1, dashOffset: -1, dashGap: -1, zigzagOffset: -1, seed: 0, disableMultiStroke: !1, disableMultiStrokeFill: !1, preserveVertices: !1, fillShapeRoughnessGain: 0.8 }, this.config = e || {}, this.config.options && (this.defaultOptions = this._o(this.config.options));
666
+ }
667
+ static newSeed() {
668
+ return Math.floor(Math.random() * 2 ** 31);
669
+ }
670
+ _o(e) {
671
+ return e ? Object.assign({}, this.defaultOptions, e) : this.defaultOptions;
672
+ }
673
+ _d(e, s, t) {
674
+ return { shape: e, sets: s || [], options: t || this.defaultOptions };
675
+ }
676
+ line(e, s, t, n, o) {
677
+ const r = this._o(o);
678
+ return this._d("line", [wt(e, s, t, n, r)], r);
679
+ }
680
+ rectangle(e, s, t, n, o) {
681
+ const r = this._o(o), h = [], i = Et(e, s, t, n, r);
682
+ if (r.fill) {
683
+ const l = [[e, s], [e + t, s], [e + t, s + n], [e, s + n]];
684
+ r.fillStyle === "solid" ? h.push(et([l], r)) : h.push(G([l], r));
685
+ }
686
+ return r.stroke !== O && h.push(i), this._d("rectangle", h, r);
687
+ }
688
+ ellipse(e, s, t, n, o) {
689
+ const r = this._o(o), h = [], i = xt(t, n, r), l = nt(e, s, r, i);
690
+ if (r.fill) if (r.fillStyle === "solid") {
691
+ const c = nt(e, s, r, i).opset;
692
+ c.type = "fillPath", h.push(c);
693
+ } else h.push(G([l.estimatedPoints], r));
694
+ return r.stroke !== O && h.push(l.opset), this._d("ellipse", h, r);
695
+ }
696
+ circle(e, s, t, n) {
697
+ const o = this.ellipse(e, s, t, t, n);
698
+ return o.shape = "circle", o;
699
+ }
700
+ linearPath(e, s) {
701
+ const t = this._o(s);
702
+ return this._d("linearPath", [Q(e, !1, t)], t);
703
+ }
704
+ arc(e, s, t, n, o, r, h = !1, i) {
705
+ const l = this._o(i), c = [], d = pt(e, s, t, n, o, r, h, !0, l);
706
+ if (h && l.fill) if (l.fillStyle === "solid") {
707
+ const p = Object.assign({}, l);
708
+ p.disableMultiStroke = !0;
709
+ const u = pt(e, s, t, n, o, r, !0, !1, p);
710
+ u.type = "fillPath", c.push(u);
711
+ } else c.push((function(p, u, f, g, k, b, M) {
712
+ const m = p, P = u;
713
+ let x = Math.abs(f / 2), w = Math.abs(g / 2);
714
+ x += y(0.01 * x, M), w += y(0.01 * w, M);
715
+ let L = k, A = b;
716
+ for (; L < 0; ) L += 2 * Math.PI, A += 2 * Math.PI;
717
+ A - L > 2 * Math.PI && (L = 0, A = 2 * Math.PI);
718
+ const q = (A - L) / M.curveStepCount, D = [];
719
+ for (let C = L; C <= A; C += q) D.push([m + x * Math.cos(C), P + w * Math.sin(C)]);
720
+ return D.push([m + x * Math.cos(A), P + w * Math.sin(A)]), D.push([m, P]), G([D], M);
721
+ })(e, s, t, n, o, r, l));
722
+ return l.stroke !== O && c.push(d), this._d("arc", c, l);
723
+ }
724
+ curve(e, s) {
725
+ const t = this._o(s), n = [], o = ut(e, t);
726
+ if (t.fill && t.fill !== O) if (t.fillStyle === "solid") {
727
+ const r = ut(e, Object.assign(Object.assign({}, t), { disableMultiStroke: !0, roughness: t.roughness ? t.roughness + t.fillShapeRoughnessGain : 0 }));
728
+ n.push({ type: "fillPath", ops: this._mergedShape(r.ops) });
729
+ } else {
730
+ const r = [], h = e;
731
+ if (h.length) {
732
+ const i = typeof h[0][0] == "number" ? [h] : h;
733
+ for (const l of i) l.length < 3 ? r.push(...l) : l.length === 3 ? r.push(...st(kt([l[0], l[0], l[1], l[2]]), 10, (1 + t.roughness) / 2)) : r.push(...st(kt(l), 10, (1 + t.roughness) / 2));
734
+ }
735
+ r.length && n.push(G([r], t));
736
+ }
737
+ return t.stroke !== O && n.push(o), this._d("curve", n, t);
738
+ }
739
+ polygon(e, s) {
740
+ const t = this._o(s), n = [], o = Q(e, !0, t);
741
+ return t.fill && (t.fillStyle === "solid" ? n.push(et([e], t)) : n.push(G([e], t))), t.stroke !== O && n.push(o), this._d("polygon", n, t);
742
+ }
743
+ path(e, s) {
744
+ const t = this._o(s), n = [];
745
+ if (!e) return this._d("path", n, t);
746
+ e = (e || "").replace(/\n/g, " ").replace(/(-\s)/g, "-").replace("/(ss)/g", " ");
747
+ const o = t.fill && t.fill !== "transparent" && t.fill !== O, r = t.stroke !== O, h = !!(t.simplification && t.simplification < 1), i = (function(c, d, p) {
748
+ const u = yt(bt(rt(c))), f = [];
749
+ let g = [], k = [0, 0], b = [];
750
+ const M = () => {
751
+ b.length >= 4 && g.push(...st(b, d)), b = [];
752
+ }, m = () => {
753
+ M(), g.length && (f.push(g), g = []);
754
+ };
755
+ for (const { key: x, data: w } of u) switch (x) {
756
+ case "M":
757
+ m(), k = [w[0], w[1]], g.push(k);
758
+ break;
759
+ case "L":
760
+ M(), g.push([w[0], w[1]]);
761
+ break;
762
+ case "C":
763
+ if (!b.length) {
764
+ const L = g.length ? g[g.length - 1] : k;
765
+ b.push([L[0], L[1]]);
766
+ }
767
+ b.push([w[0], w[1]]), b.push([w[2], w[3]]), b.push([w[4], w[5]]);
768
+ break;
769
+ case "Z":
770
+ M(), g.push([k[0], k[1]]);
771
+ }
772
+ if (m(), !p) return f;
773
+ const P = [];
774
+ for (const x of f) {
775
+ const w = Rt(x, p);
776
+ w.length && P.push(w);
777
+ }
778
+ return P;
779
+ })(e, 1, h ? 4 - 4 * (t.simplification || 1) : (1 + t.roughness) / 2), l = ft(e, t);
780
+ if (o) if (t.fillStyle === "solid") if (i.length === 1) {
781
+ const c = ft(e, Object.assign(Object.assign({}, t), { disableMultiStroke: !0, roughness: t.roughness ? t.roughness + t.fillShapeRoughnessGain : 0 }));
782
+ n.push({ type: "fillPath", ops: this._mergedShape(c.ops) });
783
+ } else n.push(et(i, t));
784
+ else n.push(G(i, t));
785
+ return r && (h ? i.forEach(((c) => {
786
+ n.push(Q(c, !1, t));
787
+ })) : n.push(l)), this._d("path", n, t);
788
+ }
789
+ opsToPath(e, s) {
790
+ let t = "";
791
+ for (const n of e.ops) {
792
+ const o = typeof s == "number" && s >= 0 ? n.data.map(((r) => +r.toFixed(s))) : n.data;
793
+ switch (n.op) {
794
+ case "move":
795
+ t += `M${o[0]} ${o[1]} `;
796
+ break;
797
+ case "bcurveTo":
798
+ t += `C${o[0]} ${o[1]}, ${o[2]} ${o[3]}, ${o[4]} ${o[5]} `;
799
+ break;
800
+ case "lineTo":
801
+ t += `L${o[0]} ${o[1]} `;
802
+ }
803
+ }
804
+ return t.trim();
805
+ }
806
+ toPaths(e) {
807
+ const s = e.sets || [], t = e.options || this.defaultOptions, n = [];
808
+ for (const o of s) {
809
+ let r = null;
810
+ switch (o.type) {
811
+ case "path":
812
+ r = { d: this.opsToPath(o), stroke: t.stroke, strokeWidth: t.strokeWidth, fill: O };
813
+ break;
814
+ case "fillPath":
815
+ r = { d: this.opsToPath(o), stroke: O, strokeWidth: 0, fill: t.fill || O };
816
+ break;
817
+ case "fillSketch":
818
+ r = this.fillSketch(o, t);
819
+ }
820
+ r && n.push(r);
821
+ }
822
+ return n;
823
+ }
824
+ fillSketch(e, s) {
825
+ let t = s.fillWeight;
826
+ return t < 0 && (t = s.strokeWidth / 2), { d: this.opsToPath(e), stroke: s.fill || O, strokeWidth: t, fill: O };
827
+ }
828
+ _mergedShape(e) {
829
+ return e.filter(((s, t) => t === 0 || s.op !== "move"));
830
+ }
831
+ }
832
+ class jt {
833
+ constructor(e, s) {
834
+ this.canvas = e, this.ctx = this.canvas.getContext("2d"), this.gen = new K(s);
835
+ }
836
+ draw(e) {
837
+ const s = e.sets || [], t = e.options || this.getDefaultOptions(), n = this.ctx, o = e.options.fixedDecimalPlaceDigits;
838
+ for (const r of s) switch (r.type) {
839
+ case "path":
840
+ n.save(), n.strokeStyle = t.stroke === "none" ? "transparent" : t.stroke, n.lineWidth = t.strokeWidth, t.strokeLineDash && n.setLineDash(t.strokeLineDash), t.strokeLineDashOffset && (n.lineDashOffset = t.strokeLineDashOffset), this._drawToContext(n, r, o), n.restore();
841
+ break;
842
+ case "fillPath": {
843
+ n.save(), n.fillStyle = t.fill || "";
844
+ const h = e.shape === "curve" || e.shape === "polygon" || e.shape === "path" ? "evenodd" : "nonzero";
845
+ this._drawToContext(n, r, o, h), n.restore();
846
+ break;
847
+ }
848
+ case "fillSketch":
849
+ this.fillSketch(n, r, t);
850
+ }
851
+ }
852
+ fillSketch(e, s, t) {
853
+ let n = t.fillWeight;
854
+ n < 0 && (n = t.strokeWidth / 2), e.save(), t.fillLineDash && e.setLineDash(t.fillLineDash), t.fillLineDashOffset && (e.lineDashOffset = t.fillLineDashOffset), e.strokeStyle = t.fill || "", e.lineWidth = n, this._drawToContext(e, s, t.fixedDecimalPlaceDigits), e.restore();
855
+ }
856
+ _drawToContext(e, s, t, n = "nonzero") {
857
+ e.beginPath();
858
+ for (const o of s.ops) {
859
+ const r = typeof t == "number" && t >= 0 ? o.data.map(((h) => +h.toFixed(t))) : o.data;
860
+ switch (o.op) {
861
+ case "move":
862
+ e.moveTo(r[0], r[1]);
863
+ break;
864
+ case "bcurveTo":
865
+ e.bezierCurveTo(r[0], r[1], r[2], r[3], r[4], r[5]);
866
+ break;
867
+ case "lineTo":
868
+ e.lineTo(r[0], r[1]);
869
+ }
870
+ }
871
+ s.type === "fillPath" ? e.fill(n) : e.stroke();
872
+ }
873
+ get generator() {
874
+ return this.gen;
875
+ }
876
+ getDefaultOptions() {
877
+ return this.gen.defaultOptions;
878
+ }
879
+ line(e, s, t, n, o) {
880
+ const r = this.gen.line(e, s, t, n, o);
881
+ return this.draw(r), r;
882
+ }
883
+ rectangle(e, s, t, n, o) {
884
+ const r = this.gen.rectangle(e, s, t, n, o);
885
+ return this.draw(r), r;
886
+ }
887
+ ellipse(e, s, t, n, o) {
888
+ const r = this.gen.ellipse(e, s, t, n, o);
889
+ return this.draw(r), r;
890
+ }
891
+ circle(e, s, t, n) {
892
+ const o = this.gen.circle(e, s, t, n);
893
+ return this.draw(o), o;
894
+ }
895
+ linearPath(e, s) {
896
+ const t = this.gen.linearPath(e, s);
897
+ return this.draw(t), t;
898
+ }
899
+ polygon(e, s) {
900
+ const t = this.gen.polygon(e, s);
901
+ return this.draw(t), t;
902
+ }
903
+ arc(e, s, t, n, o, r, h = !1, i) {
904
+ const l = this.gen.arc(e, s, t, n, o, r, h, i);
905
+ return this.draw(l), l;
906
+ }
907
+ curve(e, s) {
908
+ const t = this.gen.curve(e, s);
909
+ return this.draw(t), t;
910
+ }
911
+ path(e, s) {
912
+ const t = this.gen.path(e, s);
913
+ return this.draw(t), t;
914
+ }
915
+ }
916
+ const Z = "http://www.w3.org/2000/svg";
917
+ class qt {
918
+ constructor(e, s) {
919
+ this.svg = e, this.gen = new K(s);
920
+ }
921
+ draw(e) {
922
+ const s = e.sets || [], t = e.options || this.getDefaultOptions(), n = this.svg.ownerDocument || window.document, o = n.createElementNS(Z, "g"), r = e.options.fixedDecimalPlaceDigits;
923
+ for (const h of s) {
924
+ let i = null;
925
+ switch (h.type) {
926
+ case "path":
927
+ i = n.createElementNS(Z, "path"), i.setAttribute("d", this.opsToPath(h, r)), i.setAttribute("stroke", t.stroke), i.setAttribute("stroke-width", t.strokeWidth + ""), i.setAttribute("fill", "none"), t.strokeLineDash && i.setAttribute("stroke-dasharray", t.strokeLineDash.join(" ").trim()), t.strokeLineDashOffset && i.setAttribute("stroke-dashoffset", `${t.strokeLineDashOffset}`);
928
+ break;
929
+ case "fillPath":
930
+ i = n.createElementNS(Z, "path"), i.setAttribute("d", this.opsToPath(h, r)), i.setAttribute("stroke", "none"), i.setAttribute("stroke-width", "0"), i.setAttribute("fill", t.fill || ""), e.shape !== "curve" && e.shape !== "polygon" || i.setAttribute("fill-rule", "evenodd");
931
+ break;
932
+ case "fillSketch":
933
+ i = this.fillSketch(n, h, t);
934
+ }
935
+ i && o.appendChild(i);
936
+ }
937
+ return o;
938
+ }
939
+ fillSketch(e, s, t) {
940
+ let n = t.fillWeight;
941
+ n < 0 && (n = t.strokeWidth / 2);
942
+ const o = e.createElementNS(Z, "path");
943
+ return o.setAttribute("d", this.opsToPath(s, t.fixedDecimalPlaceDigits)), o.setAttribute("stroke", t.fill || ""), o.setAttribute("stroke-width", n + ""), o.setAttribute("fill", "none"), t.fillLineDash && o.setAttribute("stroke-dasharray", t.fillLineDash.join(" ").trim()), t.fillLineDashOffset && o.setAttribute("stroke-dashoffset", `${t.fillLineDashOffset}`), o;
944
+ }
945
+ get generator() {
946
+ return this.gen;
947
+ }
948
+ getDefaultOptions() {
949
+ return this.gen.defaultOptions;
950
+ }
951
+ opsToPath(e, s) {
952
+ return this.gen.opsToPath(e, s);
953
+ }
954
+ line(e, s, t, n, o) {
955
+ const r = this.gen.line(e, s, t, n, o);
956
+ return this.draw(r);
957
+ }
958
+ rectangle(e, s, t, n, o) {
959
+ const r = this.gen.rectangle(e, s, t, n, o);
960
+ return this.draw(r);
961
+ }
962
+ ellipse(e, s, t, n, o) {
963
+ const r = this.gen.ellipse(e, s, t, n, o);
964
+ return this.draw(r);
965
+ }
966
+ circle(e, s, t, n) {
967
+ const o = this.gen.circle(e, s, t, n);
968
+ return this.draw(o);
969
+ }
970
+ linearPath(e, s) {
971
+ const t = this.gen.linearPath(e, s);
972
+ return this.draw(t);
973
+ }
974
+ polygon(e, s) {
975
+ const t = this.gen.polygon(e, s);
976
+ return this.draw(t);
977
+ }
978
+ arc(e, s, t, n, o, r, h = !1, i) {
979
+ const l = this.gen.arc(e, s, t, n, o, r, h, i);
980
+ return this.draw(l);
981
+ }
982
+ curve(e, s) {
983
+ const t = this.gen.curve(e, s);
984
+ return this.draw(t);
985
+ }
986
+ path(e, s) {
987
+ const t = this.gen.path(e, s);
988
+ return this.draw(t);
989
+ }
990
+ }
991
+ var Ft = { canvas: (a, e) => new jt(a, e), svg: (a, e) => new qt(a, e), generator: (a) => new K(a), newSeed: () => K.newSeed() };
992
+ export {
993
+ Ft as default
994
+ };
995
+ //# sourceMappingURL=index31.js.map