pantograph2d 0.3.0 → 0.4.0

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.
@@ -0,0 +1,1698 @@
1
+ function X(e, t, n, s) {
2
+ return e <= s && t >= n;
3
+ }
4
+ class q {
5
+ constructor(t = 1 / 0, n = 1 / 0, s = -1 / 0, i = -1 / 0) {
6
+ this.xMin = t, this.yMin = n, this.xMax = s, this.yMax = i;
7
+ }
8
+ get width() {
9
+ return this.xMax - this.xMin;
10
+ }
11
+ get height() {
12
+ return this.yMax - this.yMin;
13
+ }
14
+ contains(t) {
15
+ const [n, s] = t;
16
+ return X(this.xMin, this.xMax, n, n) && X(this.yMin, this.yMax, s, s);
17
+ }
18
+ overlaps(t) {
19
+ return X(this.xMin, this.xMax, t.xMin, t.xMax) && X(this.yMin, this.yMax, t.yMin, t.yMax);
20
+ }
21
+ addPoint(t) {
22
+ const [n, s] = t;
23
+ return new q(
24
+ Math.min(this.xMin, n),
25
+ Math.min(this.yMin, s),
26
+ Math.max(this.xMax, n),
27
+ Math.max(this.yMax, s)
28
+ );
29
+ }
30
+ merge(t) {
31
+ return new q(
32
+ Math.min(this.xMin, t.xMin),
33
+ Math.min(this.yMin, t.yMin),
34
+ Math.max(this.xMax, t.xMax),
35
+ Math.max(this.yMax, t.yMax)
36
+ );
37
+ }
38
+ }
39
+ const ft = (e, t = 1e-9) => {
40
+ let n = e;
41
+ return Math.abs(e) < t && (n = 0), n.toFixed(-Math.log10(t));
42
+ };
43
+ function Q(e, t = 1e-9) {
44
+ return Array.from(
45
+ new Map(
46
+ e.map(([n, s]) => [
47
+ `[${ft(n, t)},${ft(s, t)}]`,
48
+ [n, s]
49
+ ])
50
+ ).values()
51
+ );
52
+ }
53
+ const qt = Math.PI / 180, I = (e) => `[${e[0]}, ${e[1]}]`, g = ([e, t], [n, s], i = 1e-9) => Math.abs(e - n) <= i && Math.abs(t - s) <= i, A = ([e, t], [n, s]) => [e + n, t + s], y = ([e, t], [n, s]) => [e - n, t - s], z = ([e, t]) => e * e + t * t, _ = ([e, t], n) => [e * n, t * n], Y = ([e, t], [n, s] = [0, 0]) => (e - n) ** 2 + (t - s) ** 2, k = (e, t = [0, 0]) => Math.sqrt(Y(e, t));
54
+ function $([e, t], [n, s]) {
55
+ return e * s - t * n;
56
+ }
57
+ function st([e, t], [n, s]) {
58
+ return e * n + t * s;
59
+ }
60
+ function B([e, t]) {
61
+ const n = k([e, t]);
62
+ return [e / n, t / n];
63
+ }
64
+ function R(e, t) {
65
+ const n = Math.cos(t) * e, s = Math.sin(t) * e;
66
+ return [n, s];
67
+ }
68
+ function Dt([e, t]) {
69
+ return Math.atan2(t, e);
70
+ }
71
+ function Yt(e) {
72
+ const t = k(e), n = Dt(e);
73
+ return [t, n];
74
+ }
75
+ function vt(e, t, n = 1e-9) {
76
+ const s = $(e, t), i = z(e), r = z(t);
77
+ return s * s < i * r * n * n;
78
+ }
79
+ function F(e) {
80
+ return [-e[1], e[0]];
81
+ }
82
+ function tt(e) {
83
+ return [e[1], -e[0]];
84
+ }
85
+ const T = (e, t) => {
86
+ const [n, s, i, r, a, o, u, l, h] = e, [c, f, m, P, w, M, b, x, E] = t;
87
+ return [
88
+ n * c + s * P + i * b,
89
+ n * f + s * w + i * x,
90
+ n * m + s * M + i * E,
91
+ r * c + a * P + o * b,
92
+ r * f + a * w + o * x,
93
+ r * m + a * M + o * E,
94
+ u * c + l * P + h * b,
95
+ u * f + l * w + h * x,
96
+ u * m + l * M + h * E
97
+ ];
98
+ };
99
+ class C {
100
+ constructor() {
101
+ this._matrix = [1, 0, 0, 0, 1, 0, 0, 0, 1];
102
+ }
103
+ translate(t, n) {
104
+ return this._matrix = T(this._matrix, [1, 0, t, 0, 1, n, 0, 0, 1]), this;
105
+ }
106
+ rotate(t, n) {
107
+ const s = Math.cos(t), i = Math.sin(t), r = [s, -i, 0, i, s, 0, 0, 0, 1];
108
+ return n && this.translate(n[0], n[1]), this._matrix = T(this._matrix, r), n && this.translate(-n[0], -n[1]), this;
109
+ }
110
+ mirrorX() {
111
+ return this._matrix = T(this._matrix, [1, 0, 0, 0, -1, 0, 0, 0, 1]), this;
112
+ }
113
+ mirrorY() {
114
+ return this._matrix = T(this._matrix, [-1, 0, 0, 0, 1, 0, 0, 0, 1]), this;
115
+ }
116
+ mirrorLine(t, n) {
117
+ const [s, i] = t, r = Math.atan2(i, s);
118
+ return n && this.translate(n[0], n[1]), this.rotate(r), this.mirrorX(), this.rotate(-r), n && this.translate(-n[0], -n[1]), this;
119
+ }
120
+ mirrorCenter(t) {
121
+ return t && this.translate(t[0], t[1]), this._matrix = T(this._matrix, [-1, 0, 0, 0, -1, 0, 0, 0, 1]), t && this.translate(-t[0], -t[1]), this;
122
+ }
123
+ scale(t, n) {
124
+ return n && this.translate(n[0], n[1]), this._matrix = T(this._matrix, [t, 0, 0, 0, t, 0, 0, 0, 1]), n && this.translate(-n[0], -n[1]), this;
125
+ }
126
+ transform(t) {
127
+ const [n, s] = t, [i, r, a, o, u, l] = this._matrix;
128
+ return [i * n + r * s + a, o * n + u * s + l];
129
+ }
130
+ keepsOrientation() {
131
+ const [t, , , , n] = this._matrix;
132
+ return t * n > 0;
133
+ }
134
+ }
135
+ class K {
136
+ translateX(t) {
137
+ const n = new C().translate(t, 0);
138
+ return this.transform(n);
139
+ }
140
+ translateY(t) {
141
+ const n = new C().translate(0, t);
142
+ return this.transform(n);
143
+ }
144
+ translate(t, n) {
145
+ const s = new C().translate(t, n);
146
+ return this.transform(s);
147
+ }
148
+ translateTo([t, n]) {
149
+ const s = new C().translate(t, n);
150
+ return this.transform(s);
151
+ }
152
+ rotate(t, n) {
153
+ const s = new C().rotate(
154
+ t * qt,
155
+ n
156
+ );
157
+ return this.transform(s);
158
+ }
159
+ scale(t, n) {
160
+ const s = new C().scale(t, n);
161
+ return this.transform(s);
162
+ }
163
+ mirrorCenter(t) {
164
+ const n = new C().mirrorCenter(t);
165
+ return this.transform(n);
166
+ }
167
+ mirror(t = "x", n) {
168
+ const s = new C();
169
+ return t === "x" ? s.mirrorX() : t === "y" ? s.mirrorY() : s.mirrorLine(t, n), this.transform(s);
170
+ }
171
+ }
172
+ class It extends K {
173
+ constructor(t, n) {
174
+ super(), this.firstPoint = t, this.lastPoint = n, this.precision = 1e-9, this.firstPoint = t, this.lastPoint = n;
175
+ }
176
+ get repr() {
177
+ return `${this.segmentType} ${I(this.firstPoint)} - ${I(
178
+ this.lastPoint
179
+ )}`;
180
+ }
181
+ get info() {
182
+ return this.repr;
183
+ }
184
+ [Symbol.for("nodejs.util.inspect.custom")]() {
185
+ return this.repr;
186
+ }
187
+ }
188
+ class d extends It {
189
+ constructor() {
190
+ super(...arguments), this.segmentType = "LINE", this._V = null, this._boundingBox = null;
191
+ }
192
+ isValidParameter(t) {
193
+ const n = this.length * this.precision;
194
+ return t >= -n && 1 - t >= -n;
195
+ }
196
+ paramPoint(t) {
197
+ return A(this.firstPoint, _(this.V, t));
198
+ }
199
+ get length() {
200
+ return k(this.firstPoint, this.lastPoint);
201
+ }
202
+ get squareLength() {
203
+ return Y(this.firstPoint, this.lastPoint);
204
+ }
205
+ get V() {
206
+ return this._V === null && (this._V = y(this.lastPoint, this.firstPoint)), this._V;
207
+ }
208
+ get midPoint() {
209
+ return A(this.firstPoint, _(this.V, 0.5));
210
+ }
211
+ isSame(t) {
212
+ return t instanceof d ? g(this.firstPoint, t.firstPoint) && g(this.lastPoint, t.lastPoint) || g(this.lastPoint, t.firstPoint) && g(this.firstPoint, t.lastPoint) : !1;
213
+ }
214
+ clone() {
215
+ return new d(this.firstPoint, this.lastPoint);
216
+ }
217
+ reverse() {
218
+ return new d(this.lastPoint, this.firstPoint);
219
+ }
220
+ get boundingBox() {
221
+ return this._boundingBox === null && (this._boundingBox = new q(
222
+ Math.min(this.firstPoint[0], this.lastPoint[0]) - this.precision,
223
+ Math.min(this.firstPoint[1], this.lastPoint[1]) - this.precision,
224
+ Math.max(this.firstPoint[0], this.lastPoint[0]) + this.precision,
225
+ Math.max(this.firstPoint[1], this.lastPoint[1]) + this.precision
226
+ )), this._boundingBox;
227
+ }
228
+ distanceFrom(t) {
229
+ const n = y(t, this.firstPoint), s = st(n, this.V) / this.squareLength;
230
+ if (s < 0)
231
+ return k(t, this.firstPoint);
232
+ if (s > 1)
233
+ return k(t, this.lastPoint);
234
+ const i = this.paramPoint(s);
235
+ return k(t, i);
236
+ }
237
+ isOnSegment(t) {
238
+ if (g(t, this.firstPoint, this.precision))
239
+ return !0;
240
+ const n = y(t, this.firstPoint);
241
+ if (!vt(this.V, n))
242
+ return !1;
243
+ const s = st(n, this.V) / this.squareLength;
244
+ return this.isValidParameter(s);
245
+ }
246
+ tangentAt(t) {
247
+ if (!this.isOnSegment(t))
248
+ throw new Error("Point is not on segment");
249
+ return B(this.V);
250
+ }
251
+ get normalVector() {
252
+ return F(B(this.V));
253
+ }
254
+ get tangentAtFirstPoint() {
255
+ return B(this.V);
256
+ }
257
+ get tangentAtLastPoint() {
258
+ return B(this.V);
259
+ }
260
+ splitAt(t) {
261
+ let n;
262
+ if (Array.isArray(t) && t.length === 0)
263
+ return [this];
264
+ Array.isArray(t[0]) ? n = t : n = [t], n.forEach((u) => {
265
+ if (!this.isOnSegment(u))
266
+ throw new Error(
267
+ `Point ${I(u)} is not on segment ${this.repr}`
268
+ );
269
+ });
270
+ const s = [this.firstPoint, ...n, this.lastPoint], i = Q(s), r = this.lastPoint[0] - this.firstPoint[0];
271
+ let a = Math.sign(r), o = 0;
272
+ return Math.abs(r) < this.precision && (a = Math.sign(this.lastPoint[1] - this.firstPoint[1]), o = 1), i.sort(
273
+ (u, l) => a * (u[o] - l[o])
274
+ ), i.flatMap((u, l) => l === i.length - 1 ? [] : new d(u, i[l + 1]));
275
+ }
276
+ transform(t) {
277
+ return new d(
278
+ t.transform(this.firstPoint),
279
+ t.transform(this.lastPoint)
280
+ );
281
+ }
282
+ }
283
+ function Ut(e) {
284
+ return Array.from(Array(e).keys());
285
+ }
286
+ function L(e) {
287
+ const t = Math.min(...e.map((n) => n.length));
288
+ return Ut(t).map((n) => e.map((s) => s[n]));
289
+ }
290
+ function nt(e, t = 1e-9) {
291
+ return e < 0 ? e + 2 * Math.PI : e >= 2 * Math.PI ? e % (2 * Math.PI) : e > 2 * Math.PI - t ? 0 : e;
292
+ }
293
+ function gt(e, t, n, s = 1e-9) {
294
+ let i = t - e;
295
+ return n && (i = -i), i < 0 && (i += 2 * Math.PI), i > 2 * Math.PI - s ? 0 : i;
296
+ }
297
+ const Z = (e, t, n) => {
298
+ const s = $(e.V, t.V), i = z(e.V), r = z(t.V), a = n ? n * n : e.precision * t.precision;
299
+ if (s * s < i * r * a)
300
+ return "parallel";
301
+ const o = y(t.firstPoint, e.firstPoint), u = $(o, t.V) / s, l = $(o, e.V) / s;
302
+ return {
303
+ intersectionParam1: u,
304
+ intersectionParam2: l
305
+ };
306
+ };
307
+ function _t(e, t, n = !1, s) {
308
+ const i = Z(e, t, s);
309
+ if (i === "parallel") {
310
+ if (!n)
311
+ return null;
312
+ if (e.isSame(t))
313
+ return e;
314
+ const o = Q(
315
+ [
316
+ t.isOnSegment(e.firstPoint) ? e.firstPoint : null,
317
+ t.isOnSegment(e.lastPoint) ? e.lastPoint : null,
318
+ e.isOnSegment(t.firstPoint) ? t.firstPoint : null,
319
+ e.isOnSegment(t.lastPoint) ? t.lastPoint : null
320
+ ].filter((u) => u !== null)
321
+ ).sort((u, l) => u[0] - l[0]);
322
+ if (o.length === 0)
323
+ return null;
324
+ if (o.length === 1)
325
+ return null;
326
+ if (o.length === 2)
327
+ return new d(o[0], o[1]);
328
+ throw console.error(o), new Error(
329
+ "Unexpected number of points while intersecting parallel lines"
330
+ );
331
+ }
332
+ const { intersectionParam1: r, intersectionParam2: a } = i;
333
+ return !e.isValidParameter(r) || !t.isValidParameter(a) ? null : e.paramPoint(r);
334
+ }
335
+ const j = (e, t) => {
336
+ const n = y(e, t);
337
+ return Yt(n);
338
+ };
339
+ class p extends It {
340
+ constructor(t, n, s, i = !1, { ignoreChecks: r = !1 } = {}) {
341
+ if (super(t, n), this.segmentType = "ARC", this._angularLength = null, this._radius = null, this._firstAngle = null, this._lastAngle = null, this._boundingBox = null, this.center = s, this.clockwise = i, !r) {
342
+ if (g(t, n))
343
+ throw new Error("Invalid arc, cannot be a full circle");
344
+ if (Math.abs(this.radius - k(this.lastPoint, this.center)) > this.precision)
345
+ throw new Error(
346
+ "Invalid arc, radius does not match between start and end"
347
+ );
348
+ }
349
+ }
350
+ get info() {
351
+ return `ARC(${I(this.firstPoint)}, ${I(
352
+ this.lastPoint
353
+ )}, ${I(this.center)}, ${this.clockwise ? "CW" : "CCW"})`;
354
+ }
355
+ isValidParameter(t) {
356
+ return 1 - t >= -this.precision && t >= -this.precision;
357
+ }
358
+ angleToParam(t) {
359
+ return gt(this.firstAngle, nt(t), this.clockwise) / this.angularLength;
360
+ }
361
+ get angularLength() {
362
+ return this._angularLength || (this._angularLength = gt(
363
+ this.firstAngle,
364
+ this.lastAngle,
365
+ this.clockwise
366
+ )), this._angularLength;
367
+ }
368
+ paramPoint(t) {
369
+ return A(
370
+ this.center,
371
+ R(
372
+ this.radius,
373
+ this.firstAngle + t * this.angularLength * (this.clockwise ? -1 : 1)
374
+ )
375
+ );
376
+ }
377
+ pointToParam(t) {
378
+ const [n, s] = j(t, this.center);
379
+ if (Math.abs(n - this.radius) > this.precision)
380
+ throw new Error(
381
+ `Point ${I(t)} is not on segment ${this.repr}`
382
+ );
383
+ const i = this.angleToParam(s);
384
+ if (!this.isValidParameter(i))
385
+ throw new Error(
386
+ `Point ${I(t)} is not on segment ${this.repr}`
387
+ );
388
+ return i;
389
+ }
390
+ get radius() {
391
+ return this._radius === null && (this._radius = k(this.firstPoint, this.center)), this._radius;
392
+ }
393
+ get firstAngle() {
394
+ if (this._firstAngle === null) {
395
+ const [t, n] = y(this.firstPoint, this.center);
396
+ this._firstAngle = nt(Math.atan2(n, t));
397
+ }
398
+ return this._firstAngle;
399
+ }
400
+ get lastAngle() {
401
+ if (this._lastAngle === null) {
402
+ const [t, n] = y(this.lastPoint, this.center);
403
+ this._lastAngle = nt(Math.atan2(n, t));
404
+ }
405
+ return this._lastAngle;
406
+ }
407
+ get length() {
408
+ return this.radius * this.angularLength;
409
+ }
410
+ get squareLength() {
411
+ return this.length * this.length;
412
+ }
413
+ get midPoint() {
414
+ return this.paramPoint(0.5);
415
+ }
416
+ isSame(t) {
417
+ return !(t instanceof p) || !g(this.center, t.center) ? !1 : g(this.firstPoint, t.firstPoint) && g(this.lastPoint, t.lastPoint) && this.clockwise === t.clockwise || g(this.lastPoint, t.firstPoint) && g(this.firstPoint, t.lastPoint) && this.clockwise === !t.clockwise;
418
+ }
419
+ clone() {
420
+ return new p(
421
+ this.firstPoint,
422
+ this.lastPoint,
423
+ this.center,
424
+ this.clockwise
425
+ );
426
+ }
427
+ reverse() {
428
+ return new p(
429
+ this.lastPoint,
430
+ this.firstPoint,
431
+ this.center,
432
+ !this.clockwise
433
+ );
434
+ }
435
+ get boundingBox() {
436
+ if (this._boundingBox === null) {
437
+ const t = this.radius + this.precision, n = (s) => this.isValidParameter(this.angleToParam(s));
438
+ this._boundingBox = new q(
439
+ n(Math.PI) ? this.center[0] - t : Math.min(this.firstPoint[0], this.lastPoint[0]) - this.precision,
440
+ n(Math.PI * 1.5) ? this.center[1] - t : Math.min(this.firstPoint[1], this.lastPoint[1]) - this.precision,
441
+ n(0) ? this.center[0] + t : Math.max(this.firstPoint[0], this.lastPoint[0]) + this.precision,
442
+ n(Math.PI / 2) ? this.center[1] + t : Math.max(this.firstPoint[1], this.lastPoint[1]) + this.precision
443
+ );
444
+ }
445
+ return this._boundingBox;
446
+ }
447
+ distanceFrom(t) {
448
+ const [n, s] = j(t, this.center);
449
+ return this.isValidParameter(this.angleToParam(s)) ? Math.abs(n - this.radius) : Math.sqrt(
450
+ Math.min(
451
+ Y(t, this.firstPoint),
452
+ Y(t, this.lastPoint)
453
+ )
454
+ );
455
+ }
456
+ isOnSegment(t) {
457
+ if (g(t, this.firstPoint) || g(t, this.lastPoint))
458
+ return !0;
459
+ const [n, s] = j(t, this.center);
460
+ if (Math.abs(n - this.radius) > this.precision)
461
+ return !1;
462
+ const i = this.angleToParam(s);
463
+ return this.isValidParameter(i);
464
+ }
465
+ tangentAt(t) {
466
+ const [n, s] = j(t, this.center);
467
+ if (Math.abs(n - this.radius) > this.precision)
468
+ throw new Error("Point is not on the arc");
469
+ const i = this.angleToParam(s);
470
+ if (!this.isValidParameter(i))
471
+ throw new Error("Point is not on the arc");
472
+ const r = R(1, s);
473
+ return (this.clockwise ? tt : F)(B(r));
474
+ }
475
+ get tangentAtFirstPoint() {
476
+ const t = R(1, this.firstAngle);
477
+ return (this.clockwise ? tt : F)(B(t));
478
+ }
479
+ get tangentAtLastPoint() {
480
+ const t = R(1, this.lastAngle);
481
+ return (this.clockwise ? tt : F)(B(t));
482
+ }
483
+ splitAt(t) {
484
+ let n;
485
+ if (Array.isArray(t) && t.length === 0)
486
+ return [this];
487
+ Array.isArray(t[0]) ? n = t : n = [t];
488
+ const i = [0, 1, ...n.map((o) => this.pointToParam(o))], r = new Map(
489
+ L([i, [this.firstPoint, this.lastPoint, ...n]])
490
+ );
491
+ i.sort((o, u) => o - u);
492
+ let a = null;
493
+ return i.flatMap((o, u) => {
494
+ if (u === i.length - 1)
495
+ return [];
496
+ const l = i[u + 1];
497
+ if (l - o < this.precision)
498
+ return a === null && (a = o), [];
499
+ const h = a === null ? o : a, c = new p(
500
+ r.get(h) || this.paramPoint(h),
501
+ r.get(l) || this.paramPoint(l),
502
+ this.center,
503
+ this.clockwise
504
+ );
505
+ return a = null, c;
506
+ });
507
+ }
508
+ transform(t) {
509
+ return new p(
510
+ t.transform(this.firstPoint),
511
+ t.transform(this.lastPoint),
512
+ t.transform(this.center),
513
+ t.keepsOrientation() ? this.clockwise : !this.clockwise
514
+ );
515
+ }
516
+ }
517
+ function pn(e, t, n) {
518
+ const s = new d(t, e), i = new d(t, n), r = F(s.tangentAtFirstPoint), a = F(i.tangentAtLastPoint), o = Z(
519
+ { firstPoint: s.midPoint, V: r, precision: 1e-9 },
520
+ { firstPoint: i.midPoint, V: a, precision: 1e-9 }
521
+ );
522
+ if (o === "parallel")
523
+ throw new Error("Cannot create an arc from three colinear points");
524
+ const u = $(
525
+ y(e, t),
526
+ y(n, t)
527
+ ) > 0;
528
+ return new p(
529
+ e,
530
+ n,
531
+ A(s.midPoint, _(r, o.intersectionParam1)),
532
+ u,
533
+ { ignoreChecks: !0 }
534
+ );
535
+ }
536
+ function dn(e, t, n) {
537
+ const s = new d(t, e), i = F(s.tangentAtFirstPoint), r = Z(
538
+ { firstPoint: s.midPoint, V: i, precision: 1e-9 },
539
+ {
540
+ firstPoint: e,
541
+ V: F(n),
542
+ precision: 1e-9
543
+ }
544
+ );
545
+ if (r === "parallel")
546
+ throw new Error("Cannot create an arc from three colinear points");
547
+ const a = A(
548
+ s.midPoint,
549
+ _(i, r.intersectionParam1)
550
+ ), o = $(
551
+ y(a, e),
552
+ y(a, A(e, n))
553
+ ) < 0;
554
+ return new p(e, t, a, o, {
555
+ ignoreChecks: !0
556
+ });
557
+ }
558
+ function Nt(e, t) {
559
+ const n = y(t, e.firstPoint), s = st(n, e.V) / e.squareLength;
560
+ return e.paramPoint(s);
561
+ }
562
+ function G(e, t, n) {
563
+ const s = n || e.precision, i = Nt(e, t.center), r = k(i, t.center);
564
+ if (r > t.radius + s)
565
+ return [];
566
+ if (Math.abs(r - t.radius) < s) {
567
+ const c = i;
568
+ return e.isOnSegment(c) && t.isOnSegment(c) ? [c] : [];
569
+ }
570
+ const a = [], o = Math.sqrt(
571
+ t.radius * t.radius - r * r
572
+ ), u = e.tangentAtFirstPoint, l = A(i, _(u, o));
573
+ e.isOnSegment(l) && t.isOnSegment(l) && a.push(l);
574
+ const h = A(i, _(u, -o));
575
+ return e.isOnSegment(h) && t.isOnSegment(h) && a.push(h), a;
576
+ }
577
+ const Xt = (e) => {
578
+ const { firstPoint: t, lastPoint: n, center: s, clockwise: i } = e;
579
+ return new p(n, t, s, i, {
580
+ ignoreChecks: !0
581
+ });
582
+ }, Rt = (e, t) => {
583
+ if (e.isSame(t))
584
+ return [e];
585
+ const n = Q(
586
+ [
587
+ t.isOnSegment(e.firstPoint) ? e.firstPoint : null,
588
+ t.isOnSegment(e.lastPoint) ? e.lastPoint : null,
589
+ e.isOnSegment(t.firstPoint) ? t.firstPoint : null,
590
+ e.isOnSegment(t.lastPoint) ? t.lastPoint : null
591
+ ].filter((s) => s !== null)
592
+ // We sort by the param value of the first arc. This means that the points
593
+ // will be sorted with the same orientation than arc1
594
+ ).sort((s, i) => e.pointToParam(s) - e.pointToParam(i));
595
+ if (n.length === 0)
596
+ return [];
597
+ if (n.length === 1)
598
+ return [];
599
+ if (n.length === 2)
600
+ return e.isSame(Xt(t)) ? [] : [new p(n[0], n[1], e.center, e.clockwise)];
601
+ if (n.length === 3) {
602
+ const s = g(n[0], t.lastPoint) || g(n[0], t.firstPoint) ? 1 : 0;
603
+ return [
604
+ new p(
605
+ n[0 + s],
606
+ n[1 + s],
607
+ e.center,
608
+ e.clockwise
609
+ )
610
+ ];
611
+ } else if (n.length === 4)
612
+ return [
613
+ new p(n[0], n[1], e.center, e.clockwise),
614
+ new p(n[2], n[3], e.center, e.clockwise)
615
+ ];
616
+ throw new Error("Bug in the arc arc overlap algorithm");
617
+ };
618
+ function kt(e, t, n = !1, s) {
619
+ const i = s || e.precision, r = k(e.center, t.center), a = e.radius + t.radius;
620
+ if (r > a + i)
621
+ return [];
622
+ const o = Math.abs(e.radius - t.radius);
623
+ if (r < o - i)
624
+ return [];
625
+ if (r < i)
626
+ return o > i ? [] : n ? Rt(e, t) : [];
627
+ const u = B(y(t.center, e.center)), l = r > a - i;
628
+ if (
629
+ // circles are outside each other
630
+ l || // circles are inside each other
631
+ Math.abs(r - o) < i
632
+ ) {
633
+ const b = l || e.radius > t.radius ? 1 : -1, x = A(
634
+ e.center,
635
+ _(u, b * e.radius)
636
+ );
637
+ return e.isOnSegment(x) && t.isOnSegment(x) ? [x] : [];
638
+ }
639
+ const h = e.radius * e.radius / (2 * r) - t.radius * t.radius / (2 * r) + r / 2, c = A(
640
+ e.center,
641
+ _(u, h)
642
+ ), f = Math.sqrt(
643
+ e.radius * e.radius - h * h
644
+ ), m = F(u), P = A(c, _(m, f)), w = A(c, _(m, -f)), M = [];
645
+ return e.isOnSegment(P) && t.isOnSegment(P) && M.push(P), e.isOnSegment(w) && t.isOnSegment(w) && M.push(w), M;
646
+ }
647
+ function Pn(e, t, n) {
648
+ if (e instanceof d && t instanceof d) {
649
+ const s = _t(
650
+ e,
651
+ t,
652
+ !1,
653
+ n
654
+ );
655
+ return s === null ? [] : [s];
656
+ }
657
+ if (e instanceof d && t instanceof p)
658
+ return G(e, t, n);
659
+ if (e instanceof p && t instanceof d)
660
+ return G(t, e, n);
661
+ if (e instanceof p && t instanceof p)
662
+ return kt(e, t, !1, n);
663
+ throw new Error("Not implemented");
664
+ }
665
+ function W(e, t, n) {
666
+ if (e instanceof d && t instanceof d) {
667
+ const s = _t(
668
+ e,
669
+ t,
670
+ !0,
671
+ n
672
+ );
673
+ return s === null ? { intersections: [], overlaps: [], count: 0 } : s instanceof d ? { intersections: [], overlaps: [s], count: 1 } : { intersections: [s], overlaps: [], count: 1 };
674
+ }
675
+ if (!e.boundingBox.overlaps(t.boundingBox))
676
+ return { intersections: [], overlaps: [], count: 0 };
677
+ if (e instanceof d && t instanceof p) {
678
+ const s = G(e, t, n);
679
+ return { intersections: s, overlaps: [], count: s.length };
680
+ }
681
+ if (e instanceof p && t instanceof d) {
682
+ const s = G(t, e, n);
683
+ return { intersections: s, overlaps: [], count: s.length };
684
+ }
685
+ if (e instanceof p && t instanceof p) {
686
+ const s = kt(
687
+ e,
688
+ t,
689
+ !0,
690
+ n
691
+ );
692
+ return s.length ? s[0] instanceof p ? {
693
+ intersections: [],
694
+ overlaps: s,
695
+ count: s.length
696
+ } : {
697
+ intersections: s,
698
+ overlaps: [],
699
+ count: s.length
700
+ } : { intersections: [], overlaps: [], count: 0 };
701
+ }
702
+ throw new Error("Not implemented");
703
+ }
704
+ function Ft(e) {
705
+ const t = [];
706
+ for (let n = 0; n < e; n++)
707
+ for (let s = 0; s <= n; s++)
708
+ t.push([n, s]);
709
+ return t;
710
+ }
711
+ function* it(e) {
712
+ for (const [t, n] of Ft(e.length))
713
+ t !== n && (yield [e[t], e[n]]);
714
+ }
715
+ class Et extends K {
716
+ constructor(t, { ignoreChecks: n = !1 } = {}) {
717
+ super(), this._boundingBox = null, n || Ct(t), this.segments = t;
718
+ }
719
+ get repr() {
720
+ return this.segments.map((t) => t.repr).join(`
721
+ `) + `
722
+ `;
723
+ }
724
+ get info() {
725
+ return this.repr;
726
+ }
727
+ get firstPoint() {
728
+ return this.segments[0].firstPoint;
729
+ }
730
+ get lastPoint() {
731
+ return this.segments[this.segments.length - 1].lastPoint;
732
+ }
733
+ get segmentsCount() {
734
+ return this.segments.length;
735
+ }
736
+ onStroke(t) {
737
+ return this.segments.some((n) => n.isOnSegment(t));
738
+ }
739
+ intersects(t) {
740
+ return this.boundingBox.overlaps(t.boundingBox) ? this.segments.some(
741
+ (n) => t.segments.some(
742
+ (s) => W(n, s).count > 0
743
+ )
744
+ ) : !1;
745
+ }
746
+ overlappingSegments(t) {
747
+ return this.segments.flatMap((n) => t.segments.flatMap((s) => n.boundingBox.overlaps(s.boundingBox) ? W(n, s).overlaps : []));
748
+ }
749
+ get boundingBox() {
750
+ if (this._boundingBox === null) {
751
+ let t = this.segments[0].boundingBox;
752
+ this.segments.slice(1).forEach((n) => {
753
+ t = t.merge(n.boundingBox);
754
+ }), this._boundingBox = t;
755
+ }
756
+ return this._boundingBox;
757
+ }
758
+ [Symbol.for("nodejs.util.inspect.custom")]() {
759
+ return this.repr;
760
+ }
761
+ }
762
+ function jt(e, t = "Stroke") {
763
+ Ft(e.length).forEach(
764
+ ([n, s]) => {
765
+ if (n === s)
766
+ return;
767
+ const i = e[n], r = e[s], a = W(i, r);
768
+ if (a.count !== 0) {
769
+ if (a.count === 1 && !a.overlaps.length) {
770
+ const o = n - s, u = a.intersections[0];
771
+ if (o === 1 && g(i.firstPoint, u) || o === -1 && g(i.lastPoint, u) || o === e.length - 1 && g(i.lastPoint, u) && g(r.firstPoint, u) || -o === e.length - 1 && g(i.firstPoint, u) && g(r.lastPoint, u))
772
+ return;
773
+ }
774
+ throw new Error(
775
+ `${t} segments must not intersect, but segments ${i.info} and ${r.info} do at ${JSON.stringify(
776
+ a.intersections
777
+ )}`
778
+ );
779
+ }
780
+ }
781
+ );
782
+ }
783
+ function Ct(e, t = "Stroke") {
784
+ if (e.length === 0)
785
+ throw new Error(`${t} must have at least one segment`);
786
+ L([e.slice(0, -1), e.slice(1)]).forEach(
787
+ ([n, s]) => {
788
+ if (!g(n.lastPoint, s.firstPoint))
789
+ throw new Error(
790
+ `${t} segments must be connected, but ${n.info} and ${s.info} are not`
791
+ );
792
+ }
793
+ ), jt(e, t);
794
+ }
795
+ function mt(e, t) {
796
+ return !!(e instanceof d && t instanceof d && vt(e.V, t.V) || e instanceof p && t instanceof p && g(e.center, t.center) && e.radius - t.radius < e.precision);
797
+ }
798
+ function pt(e, t) {
799
+ if (e instanceof d && t instanceof d)
800
+ return new d(e.firstPoint, t.lastPoint);
801
+ if (e instanceof p && t instanceof p)
802
+ return new p(
803
+ e.firstPoint,
804
+ t.lastPoint,
805
+ e.center,
806
+ e.clockwise
807
+ );
808
+ throw new Error("Not implemented");
809
+ }
810
+ function Vt(e) {
811
+ let t = !1;
812
+ const n = [];
813
+ for (const s of e.segments) {
814
+ if (n.length === 0) {
815
+ n.push(s);
816
+ continue;
817
+ }
818
+ const i = n[n.length - 1];
819
+ mt(i, s) ? (t = !0, n.pop(), n.push(pt(i, s))) : n.push(s);
820
+ }
821
+ if (g(e.firstPoint, e.lastPoint) && mt(
822
+ n[0],
823
+ n[n.length - 1]
824
+ )) {
825
+ t = !0;
826
+ const s = n.pop();
827
+ n[0] = pt(s, n[0]);
828
+ }
829
+ return t ? n : null;
830
+ }
831
+ class v extends Et {
832
+ constructor() {
833
+ super(...arguments), this.strokeType = "STRAND";
834
+ }
835
+ reverse() {
836
+ const t = this.segments.map((n) => n.reverse());
837
+ return t.reverse(), new v(t, { ignoreChecks: !0 });
838
+ }
839
+ clone() {
840
+ return new v(
841
+ this.segments.map((t) => t.clone()),
842
+ { ignoreChecks: !0 }
843
+ );
844
+ }
845
+ extend(t) {
846
+ if (!g(this.lastPoint, t.firstPoint))
847
+ throw console.error(this.repr, t.repr), new Error("Cannot extend strand: connection point is not the same");
848
+ return new v([...this.segments, ...t.segments]);
849
+ }
850
+ simplify() {
851
+ const t = Vt(this);
852
+ return t ? new v(t, { ignoreChecks: !0 }) : this;
853
+ }
854
+ transform(t) {
855
+ return new v(
856
+ this.segments.map((n) => n.transform(t)),
857
+ { ignoreChecks: !0 }
858
+ );
859
+ }
860
+ }
861
+ const zt = (e, t) => {
862
+ const n = Z(t, {
863
+ V: [1, 0],
864
+ firstPoint: e,
865
+ precision: t.precision
866
+ });
867
+ if (n === "parallel")
868
+ return 0;
869
+ const { intersectionParam1: s, intersectionParam2: i } = n;
870
+ if (!t.isValidParameter(s) || i <= -t.precision)
871
+ return 0;
872
+ if (Math.abs(s) < t.precision || Math.abs(s - 1) < t.precision) {
873
+ const [, r] = t.midPoint;
874
+ return e[1] - r < 0 ? 1 : 0;
875
+ }
876
+ return 1;
877
+ }, Gt = (e, t) => {
878
+ const n = t.precision, s = Math.abs(e[1] - t.center[1]);
879
+ if (s > t.radius + n)
880
+ return 0;
881
+ const i = Y(e, t.center), r = t.radius * t.radius, a = n * n;
882
+ if (Math.abs(i - r) < a && t.isOnSegment(e))
883
+ return 0;
884
+ const o = i - r > a;
885
+ if (o && t.center[0] < e[0])
886
+ return 0;
887
+ const u = Math.sqrt(
888
+ t.radius * t.radius - s * s
889
+ );
890
+ let l = 0;
891
+ const h = (c) => {
892
+ t.isOnSegment(c) && (g(c, t.firstPoint) ? l += t.tangentAtFirstPoint[1] > 0 ? 1 : 0 : g(c, t.lastPoint) ? l += t.tangentAtLastPoint[1] > 0 ? 0 : 1 : l += 1);
893
+ };
894
+ return h([t.center[0] + u, e[1]]), o && h([t.center[0] - u, e[1]]), l;
895
+ };
896
+ function Wt(e, t) {
897
+ if (t instanceof d)
898
+ return zt(e, t);
899
+ if (t instanceof p)
900
+ return Gt(e, t);
901
+ throw new Error("Not implemented");
902
+ }
903
+ class O extends Et {
904
+ constructor(t, { ignoreChecks: n = !1 } = {}) {
905
+ super(t, { ignoreChecks: !0 }), this.strokeType = "LOOP", this._clockwise = null, n || Ht(t);
906
+ }
907
+ get clockwise() {
908
+ if (this._clockwise === null) {
909
+ const t = this.segments.flatMap((s) => s instanceof d ? [s.firstPoint] : [s.firstPoint, s.paramPoint(0.5)]), n = t.map((s, i) => {
910
+ const r = t[(i + 1) % t.length];
911
+ return (r[0] - s[0]) * (r[1] + s[1]);
912
+ }).reduce((s, i) => s + i, 0);
913
+ this._clockwise = n > 0;
914
+ }
915
+ return this._clockwise;
916
+ }
917
+ clone() {
918
+ return new O(
919
+ this.segments.map((t) => t.clone()),
920
+ { ignoreChecks: !0 }
921
+ );
922
+ }
923
+ reverse() {
924
+ const t = this.segments.map((n) => n.reverse());
925
+ return t.reverse(), new O(t, { ignoreChecks: !0 });
926
+ }
927
+ transform(t) {
928
+ return new O(
929
+ this.segments.map((n) => n.transform(t)),
930
+ { ignoreChecks: !0 }
931
+ );
932
+ }
933
+ contains(t) {
934
+ return this.onStroke(t) || !this.boundingBox.contains(t) ? !1 : this.segments.reduce((s, i) => s + Wt(t, i), 0) % 2 === 1;
935
+ }
936
+ simplify() {
937
+ const t = Vt(this);
938
+ return t ? new O(t, { ignoreChecks: !0 }) : this;
939
+ }
940
+ }
941
+ function Ht(e) {
942
+ if (Ct(e, "Loop"), !g(e[0].firstPoint, e[e.length - 1].lastPoint))
943
+ throw new Error("Loop segment must be closed");
944
+ }
945
+ function Bt(e) {
946
+ if (e instanceof d)
947
+ return {
948
+ type: e.segmentType,
949
+ firstPoint: e.firstPoint,
950
+ lastPoint: e.lastPoint
951
+ };
952
+ if (e instanceof p)
953
+ return {
954
+ type: e.segmentType,
955
+ firstPoint: e.firstPoint,
956
+ lastPoint: e.lastPoint,
957
+ center: e.center,
958
+ clockwise: e.clockwise
959
+ };
960
+ throw new Error("Unknown segment type");
961
+ }
962
+ function rt(e) {
963
+ return {
964
+ type: "LOOP",
965
+ segments: e.segments.map(Bt)
966
+ };
967
+ }
968
+ function Ot(e) {
969
+ return {
970
+ type: "FIGURE",
971
+ contour: rt(e.contour),
972
+ holes: e.holes.map(rt)
973
+ };
974
+ }
975
+ function Jt(e) {
976
+ return {
977
+ type: "DIAGRAM",
978
+ figures: e.figures.map(Ot)
979
+ };
980
+ }
981
+ function dt(e) {
982
+ if (e instanceof V)
983
+ return Jt(e);
984
+ if (e instanceof S)
985
+ return Ot(e);
986
+ if (e instanceof O)
987
+ return rt(e);
988
+ if (e instanceof p || e instanceof d)
989
+ return Bt(e);
990
+ throw new Error("Unknown shape type");
991
+ }
992
+ class Qt {
993
+ constructor() {
994
+ this.ids = [], this.values = [], this.length = 0;
995
+ }
996
+ clear() {
997
+ this.length = 0;
998
+ }
999
+ push(t, n) {
1000
+ let s = this.length++;
1001
+ for (; s > 0; ) {
1002
+ const i = s - 1 >> 1, r = this.values[i];
1003
+ if (n >= r)
1004
+ break;
1005
+ this.ids[s] = this.ids[i], this.values[s] = r, s = i;
1006
+ }
1007
+ this.ids[s] = t, this.values[s] = n;
1008
+ }
1009
+ pop() {
1010
+ if (this.length === 0)
1011
+ return;
1012
+ const t = this.ids[0];
1013
+ if (this.length--, this.length > 0) {
1014
+ const n = this.ids[0] = this.ids[this.length], s = this.values[0] = this.values[this.length], i = this.length >> 1;
1015
+ let r = 0;
1016
+ for (; r < i; ) {
1017
+ let a = (r << 1) + 1;
1018
+ const o = a + 1;
1019
+ let u = this.ids[a], l = this.values[a];
1020
+ const h = this.values[o];
1021
+ if (o < this.length && h < l && (a = o, u = this.ids[o], l = h), l >= s)
1022
+ break;
1023
+ this.ids[r] = u, this.values[r] = l, r = a;
1024
+ }
1025
+ this.ids[r] = n, this.values[r] = s;
1026
+ }
1027
+ return t;
1028
+ }
1029
+ peek() {
1030
+ if (this.length !== 0)
1031
+ return this.ids[0];
1032
+ }
1033
+ peekValue() {
1034
+ if (this.length !== 0)
1035
+ return this.values[0];
1036
+ }
1037
+ shrink() {
1038
+ this.ids.length = this.values.length = this.length;
1039
+ }
1040
+ }
1041
+ const Pt = [
1042
+ Int8Array,
1043
+ Uint8Array,
1044
+ Uint8ClampedArray,
1045
+ Int16Array,
1046
+ Uint16Array,
1047
+ Int32Array,
1048
+ Uint32Array,
1049
+ Float32Array,
1050
+ Float64Array
1051
+ ], et = 3;
1052
+ class ut {
1053
+ static from(t) {
1054
+ if (!t || t.byteLength === void 0 || t.buffer)
1055
+ throw new Error("Data must be an instance of ArrayBuffer or SharedArrayBuffer.");
1056
+ const [n, s] = new Uint8Array(t, 0, 2);
1057
+ if (n !== 251)
1058
+ throw new Error("Data does not appear to be in a Flatbush format.");
1059
+ if (s >> 4 !== et)
1060
+ throw new Error(`Got v${s >> 4} data when expected v${et}.`);
1061
+ const [i] = new Uint16Array(t, 2, 1), [r] = new Uint32Array(t, 4, 1);
1062
+ return new ut(r, i, Pt[s & 15], void 0, t);
1063
+ }
1064
+ constructor(t, n = 16, s = Float64Array, i = ArrayBuffer, r) {
1065
+ if (t === void 0)
1066
+ throw new Error("Missing required argument: numItems.");
1067
+ if (isNaN(t) || t <= 0)
1068
+ throw new Error(`Unexpected numItems value: ${t}.`);
1069
+ this.numItems = +t, this.nodeSize = Math.min(Math.max(+n, 2), 65535);
1070
+ let a = t, o = a;
1071
+ this._levelBounds = [a * 4];
1072
+ do
1073
+ a = Math.ceil(a / this.nodeSize), o += a, this._levelBounds.push(o * 4);
1074
+ while (a !== 1);
1075
+ this.ArrayType = s || Float64Array, this.IndexArrayType = o < 16384 ? Uint16Array : Uint32Array;
1076
+ const u = Pt.indexOf(this.ArrayType), l = o * 4 * this.ArrayType.BYTES_PER_ELEMENT;
1077
+ if (u < 0)
1078
+ throw new Error(`Unexpected typed array class: ${s}.`);
1079
+ r && r.byteLength !== void 0 && !r.buffer ? (this.data = r, this._boxes = new this.ArrayType(this.data, 8, o * 4), this._indices = new this.IndexArrayType(this.data, 8 + l, o), this._pos = o * 4, this.minX = this._boxes[this._pos - 4], this.minY = this._boxes[this._pos - 3], this.maxX = this._boxes[this._pos - 2], this.maxY = this._boxes[this._pos - 1]) : (this.data = new i(8 + l + o * this.IndexArrayType.BYTES_PER_ELEMENT), this._boxes = new this.ArrayType(this.data, 8, o * 4), this._indices = new this.IndexArrayType(this.data, 8 + l, o), this._pos = 0, this.minX = 1 / 0, this.minY = 1 / 0, this.maxX = -1 / 0, this.maxY = -1 / 0, new Uint8Array(this.data, 0, 2).set([251, (et << 4) + u]), new Uint16Array(this.data, 2, 1)[0] = n, new Uint32Array(this.data, 4, 1)[0] = t), this._queue = new Qt();
1080
+ }
1081
+ add(t, n, s, i) {
1082
+ const r = this._pos >> 2, a = this._boxes;
1083
+ return this._indices[r] = r, a[this._pos++] = t, a[this._pos++] = n, a[this._pos++] = s, a[this._pos++] = i, t < this.minX && (this.minX = t), n < this.minY && (this.minY = n), s > this.maxX && (this.maxX = s), i > this.maxY && (this.maxY = i), r;
1084
+ }
1085
+ finish() {
1086
+ if (this._pos >> 2 !== this.numItems)
1087
+ throw new Error(`Added ${this._pos >> 2} items when expected ${this.numItems}.`);
1088
+ const t = this._boxes;
1089
+ if (this.numItems <= this.nodeSize) {
1090
+ t[this._pos++] = this.minX, t[this._pos++] = this.minY, t[this._pos++] = this.maxX, t[this._pos++] = this.maxY;
1091
+ return;
1092
+ }
1093
+ const n = this.maxX - this.minX || 1, s = this.maxY - this.minY || 1, i = new Uint32Array(this.numItems), r = (1 << 16) - 1;
1094
+ for (let a = 0, o = 0; a < this.numItems; a++) {
1095
+ const u = t[o++], l = t[o++], h = t[o++], c = t[o++], f = Math.floor(r * ((u + h) / 2 - this.minX) / n), m = Math.floor(r * ((l + c) / 2 - this.minY) / s);
1096
+ i[a] = Zt(f, m);
1097
+ }
1098
+ ot(i, t, this._indices, 0, this.numItems - 1, this.nodeSize);
1099
+ for (let a = 0, o = 0; a < this._levelBounds.length - 1; a++) {
1100
+ const u = this._levelBounds[a];
1101
+ for (; o < u; ) {
1102
+ const l = o;
1103
+ let h = t[o++], c = t[o++], f = t[o++], m = t[o++];
1104
+ for (let P = 1; P < this.nodeSize && o < u; P++)
1105
+ h = Math.min(h, t[o++]), c = Math.min(c, t[o++]), f = Math.max(f, t[o++]), m = Math.max(m, t[o++]);
1106
+ this._indices[this._pos >> 2] = l, t[this._pos++] = h, t[this._pos++] = c, t[this._pos++] = f, t[this._pos++] = m;
1107
+ }
1108
+ }
1109
+ }
1110
+ search(t, n, s, i, r) {
1111
+ if (this._pos !== this._boxes.length)
1112
+ throw new Error("Data not yet indexed - call index.finish().");
1113
+ let a = this._boxes.length - 4;
1114
+ const o = [], u = [];
1115
+ for (; a !== void 0; ) {
1116
+ const l = Math.min(a + this.nodeSize * 4, xt(a, this._levelBounds));
1117
+ for (let h = a; h < l; h += 4) {
1118
+ if (s < this._boxes[h] || i < this._boxes[h + 1] || t > this._boxes[h + 2] || n > this._boxes[h + 3])
1119
+ continue;
1120
+ const c = this._indices[h >> 2] | 0;
1121
+ a >= this.numItems * 4 ? o.push(c) : (r === void 0 || r(c)) && u.push(c);
1122
+ }
1123
+ a = o.pop();
1124
+ }
1125
+ return u;
1126
+ }
1127
+ neighbors(t, n, s = 1 / 0, i = 1 / 0, r) {
1128
+ if (this._pos !== this._boxes.length)
1129
+ throw new Error("Data not yet indexed - call index.finish().");
1130
+ let a = this._boxes.length - 4;
1131
+ const o = this._queue, u = [], l = i * i;
1132
+ for (; a !== void 0; ) {
1133
+ const h = Math.min(a + this.nodeSize * 4, xt(a, this._levelBounds));
1134
+ for (let c = a; c < h; c += 4) {
1135
+ const f = this._indices[c >> 2] | 0, m = wt(t, this._boxes[c], this._boxes[c + 2]), P = wt(n, this._boxes[c + 1], this._boxes[c + 3]), w = m * m + P * P;
1136
+ a >= this.numItems * 4 ? o.push(f << 1, w) : (r === void 0 || r(f)) && o.push((f << 1) + 1, w);
1137
+ }
1138
+ for (; o.length && o.peek() & 1; )
1139
+ if (o.peekValue() > l || (u.push(o.pop() >> 1), u.length === s))
1140
+ return o.clear(), u;
1141
+ a = o.pop() >> 1;
1142
+ }
1143
+ return o.clear(), u;
1144
+ }
1145
+ }
1146
+ function wt(e, t, n) {
1147
+ return e < t ? t - e : e <= n ? 0 : e - n;
1148
+ }
1149
+ function xt(e, t) {
1150
+ let n = 0, s = t.length - 1;
1151
+ for (; n < s; ) {
1152
+ const i = n + s >> 1;
1153
+ t[i] > e ? s = i : n = i + 1;
1154
+ }
1155
+ return t[n];
1156
+ }
1157
+ function ot(e, t, n, s, i, r) {
1158
+ if (Math.floor(s / r) >= Math.floor(i / r))
1159
+ return;
1160
+ const a = e[s + i >> 1];
1161
+ let o = s - 1, u = i + 1;
1162
+ for (; ; ) {
1163
+ do
1164
+ o++;
1165
+ while (e[o] < a);
1166
+ do
1167
+ u--;
1168
+ while (e[u] > a);
1169
+ if (o >= u)
1170
+ break;
1171
+ Kt(e, t, n, o, u);
1172
+ }
1173
+ ot(e, t, n, s, u, r), ot(e, t, n, u + 1, i, r);
1174
+ }
1175
+ function Kt(e, t, n, s, i) {
1176
+ const r = e[s];
1177
+ e[s] = e[i], e[i] = r;
1178
+ const a = 4 * s, o = 4 * i, u = t[a], l = t[a + 1], h = t[a + 2], c = t[a + 3];
1179
+ t[a] = t[o], t[a + 1] = t[o + 1], t[a + 2] = t[o + 2], t[a + 3] = t[o + 3], t[o] = u, t[o + 1] = l, t[o + 2] = h, t[o + 3] = c;
1180
+ const f = n[s];
1181
+ n[s] = n[i], n[i] = f;
1182
+ }
1183
+ function Zt(e, t) {
1184
+ let n = e ^ t, s = 65535 ^ n, i = 65535 ^ (e | t), r = e & (t ^ 65535), a = n | s >> 1, o = n >> 1 ^ n, u = i >> 1 ^ s & r >> 1 ^ i, l = n & i >> 1 ^ r >> 1 ^ r;
1185
+ n = a, s = o, i = u, r = l, a = n & n >> 2 ^ s & s >> 2, o = n & s >> 2 ^ s & (n ^ s) >> 2, u ^= n & i >> 2 ^ s & r >> 2, l ^= s & i >> 2 ^ (n ^ s) & r >> 2, n = a, s = o, i = u, r = l, a = n & n >> 4 ^ s & s >> 4, o = n & s >> 4 ^ s & (n ^ s) >> 4, u ^= n & i >> 4 ^ s & r >> 4, l ^= s & i >> 4 ^ (n ^ s) & r >> 4, n = a, s = o, i = u, r = l, u ^= n & i >> 8 ^ s & r >> 8, l ^= s & i >> 8 ^ (n ^ s) & r >> 8, n = u ^ u >> 1, s = l ^ l >> 1;
1186
+ let h = e ^ t, c = s | 65535 ^ (h | n);
1187
+ return h = (h | h << 8) & 16711935, h = (h | h << 4) & 252645135, h = (h | h << 2) & 858993459, h = (h | h << 1) & 1431655765, c = (c | c << 8) & 16711935, c = (c | c << 4) & 252645135, c = (c | c << 2) & 858993459, c = (c | c << 1) & 1431655765, (c << 1 | h) >>> 0;
1188
+ }
1189
+ function Lt(e, t = 1e-7) {
1190
+ const n = new ut(e.length);
1191
+ e.forEach((r) => {
1192
+ const [a, o] = r.firstPoint;
1193
+ n.add(a - t, o - t, a + t, o + t);
1194
+ }), n.finish();
1195
+ const s = [], i = /* @__PURE__ */ new Set();
1196
+ return e.forEach((r, a) => {
1197
+ if (i.has(a))
1198
+ return;
1199
+ const o = [r];
1200
+ let u = a;
1201
+ i.add(a);
1202
+ let l = e.length;
1203
+ for (; ; ) {
1204
+ if (l-- < 0)
1205
+ throw new Error("Infinite loop detected");
1206
+ const h = o[o.length - 1].lastPoint, [c, f] = h, m = n.search(
1207
+ c - t,
1208
+ f - t,
1209
+ c + t,
1210
+ f + t
1211
+ ), P = (x) => Math.abs((u - x) % e.length), w = m.filter((x) => !i.has(x)).map((x) => [
1212
+ e[x],
1213
+ x,
1214
+ P(x)
1215
+ ]).sort(([, , x], [, , E]) => P(x) - P(E));
1216
+ if (w.length === 0) {
1217
+ s.push(o);
1218
+ break;
1219
+ }
1220
+ const [M, b] = w[0];
1221
+ o.push(M), i.add(b), u = b;
1222
+ }
1223
+ }), s;
1224
+ }
1225
+ class S extends K {
1226
+ constructor(t, n = [], { ignoreChecks: s = !1 } = {}) {
1227
+ super(), s || tn(t, n), this.contour = t, this.holes = n;
1228
+ }
1229
+ get boundingBox() {
1230
+ return this.contour.boundingBox;
1231
+ }
1232
+ get isFull() {
1233
+ return this.holes.length === 0;
1234
+ }
1235
+ get allLoops() {
1236
+ return [this.contour, ...this.holes];
1237
+ }
1238
+ clone() {
1239
+ return new S(
1240
+ this.contour.clone(),
1241
+ this.holes.map((t) => t.clone())
1242
+ );
1243
+ }
1244
+ transform(t) {
1245
+ return new S(
1246
+ this.contour.transform(t),
1247
+ this.holes.map((n) => n.transform(t))
1248
+ );
1249
+ }
1250
+ contains(t) {
1251
+ return this.contour.contains(t) && !this.holes.some((n) => n.contains(t));
1252
+ }
1253
+ intersects(t) {
1254
+ return this.allLoops.some(
1255
+ (n) => t.allLoops.some((s) => n.intersects(s))
1256
+ );
1257
+ }
1258
+ overlappingStrands(t) {
1259
+ const n = t instanceof S ? t.allLoops : [t], s = this.allLoops.flatMap((i) => n.flatMap((r) => i.overlappingSegments(r)));
1260
+ return Lt(s).map((i) => new v(i));
1261
+ }
1262
+ }
1263
+ function tn(e, t = []) {
1264
+ if (!e)
1265
+ throw new Error("Figure must have a contour");
1266
+ for (const [n, s] of it([e, ...t]))
1267
+ if (n.intersects(s))
1268
+ throw new Error("Loops in a figure must not intersect");
1269
+ if (t.some(
1270
+ (n) => !e.contains(n.firstPoint) && !e.onStroke(n.firstPoint)
1271
+ ))
1272
+ throw new Error("Holes must be inside the contour");
1273
+ for (const [n, s] of it(t))
1274
+ if (n.contains(s.firstPoint))
1275
+ throw console.error(dt(n), dt(s)), new Error("Holes must not be inside other holes");
1276
+ }
1277
+ const nn = (e) => {
1278
+ const t = e.map((i, r) => e.slice(r + 1).map((a, o) => [o + r + 1, a]).filter(([, a]) => i.boundingBox.overlaps(a.boundingBox)).map(([a]) => a)), n = [], s = Array(t.length);
1279
+ return t.forEach((i, r) => {
1280
+ let a = s[r];
1281
+ a || (a = [], n.push(a)), a.push(e[r]), i.length && i.forEach((o) => {
1282
+ s[o] = a;
1283
+ });
1284
+ }), n;
1285
+ }, Tt = (e) => e.map((t, n) => {
1286
+ const i = t.segments[0].midPoint, r = e.filter((a, o) => n === o ? !1 : a.contains(i));
1287
+ return {
1288
+ loop: t,
1289
+ isIn: r
1290
+ };
1291
+ }), en = (e, t) => e.flatMap(({ loop: n }) => ht(
1292
+ t.filter(
1293
+ ({ loop: s, isIn: i }) => s === n || i.indexOf(n) !== -1
1294
+ )
1295
+ )), sn = (e, t) => {
1296
+ const n = t.filter(({ isIn: i }) => i.length <= 1), s = ht(
1297
+ Tt(e.map(({ loop: i }) => i))
1298
+ );
1299
+ return [n, ...s];
1300
+ }, ht = (e) => {
1301
+ if (!e.length)
1302
+ return [];
1303
+ const t = e.filter(({ isIn: s }) => !s.length), n = e.filter(({ isIn: s }) => s.length > 1);
1304
+ return t.length === 1 && n.length === 0 ? [e] : t.length > 1 ? en(t, e) : sn(n, e);
1305
+ };
1306
+ function D(e) {
1307
+ return nn(e).map(Tt).flatMap(ht).map((n) => {
1308
+ if (n.length === 1)
1309
+ return new S(n[0].loop);
1310
+ n.sort((r, a) => r.isIn.length - a.isIn.length);
1311
+ const [s, ...i] = n.map(({ loop: r }) => r);
1312
+ return new S(s, i);
1313
+ });
1314
+ }
1315
+ function rn(e, t) {
1316
+ const n = [];
1317
+ for (const s of e)
1318
+ for (const i of t)
1319
+ n.push([s, i]);
1320
+ return n;
1321
+ }
1322
+ function* Mt(e, t, n) {
1323
+ const s = (a) => t.some((o) => g(o, a.lastPoint)), i = (a) => n.some((o) => a.isSame(o));
1324
+ let r = [];
1325
+ for (const a of e)
1326
+ s(a) ? (r.push(a), yield new v(r, { ignoreChecks: !0 }), r = []) : i(a) ? (r.length && (yield new v(r, { ignoreChecks: !0 }), r = []), yield new v([a], { ignoreChecks: !0 })) : r.push(a);
1327
+ r.length && (yield new v(r, { ignoreChecks: !0 }));
1328
+ }
1329
+ const yt = (e, t) => {
1330
+ const n = e.findIndex((r) => g(t, r.firstPoint)), s = e.slice(0, n);
1331
+ return e.slice(n).concat(s);
1332
+ }, At = (e, t) => {
1333
+ let n = e;
1334
+ const s = (o) => g(o.firstPoint, t.firstPoint) && g(o.lastPoint, t.lastPoint);
1335
+ let i = e.findIndex(s);
1336
+ if (i === -1) {
1337
+ const o = e.map((u) => u.reverse());
1338
+ if (o.reverse(), i = o.findIndex(s), i === -1)
1339
+ throw console.error(
1340
+ o.map((u) => u.repr),
1341
+ t.repr
1342
+ ), new Error("Failed to rotate to segment start");
1343
+ n = o;
1344
+ }
1345
+ const r = n.slice(0, i);
1346
+ return n.slice(i).concat(r);
1347
+ };
1348
+ function on(e, t, n) {
1349
+ return e.filter((s) => {
1350
+ const i = t.filter((o) => g(o.firstPoint, s) || g(o.lastPoint, s));
1351
+ if (i.length % 2)
1352
+ throw new Error("Bug in the intersection algo on non crossing point");
1353
+ const r = i.map((o) => n.contains(o.midPoint));
1354
+ return !(r.every((o) => o) || !r.some((o) => o));
1355
+ });
1356
+ }
1357
+ function an(e, t, n) {
1358
+ let s = [];
1359
+ const i = [], r = new Array(e.segments.length).fill(0).map(() => []), a = new Array(t.segments.length).fill(0).map(() => []);
1360
+ if (e.segments.forEach((f, m) => {
1361
+ t.segments.forEach((P, w) => {
1362
+ const { intersections: M, overlaps: b } = W(
1363
+ f,
1364
+ P,
1365
+ n
1366
+ );
1367
+ s.push(...M), r[m].push(...M), a[w].push(...M), i.push(...b);
1368
+ const x = b.flatMap((E) => [
1369
+ E.firstPoint,
1370
+ E.lastPoint
1371
+ ]);
1372
+ s.push(...x), r[m].push(...x), a[w].push(...x);
1373
+ });
1374
+ }), s = Q(s, n), !s.length || s.length === 1)
1375
+ return null;
1376
+ const o = ([f, m]) => m.length ? f.splitAt(m) : [f];
1377
+ let u = L([e.segments, r]).flatMap(o), l = L([t.segments, a]).flatMap(o);
1378
+ if (s = on(
1379
+ s,
1380
+ u,
1381
+ t
1382
+ ), !s.length && !i.length)
1383
+ return null;
1384
+ if (i.length) {
1385
+ const f = i[0];
1386
+ u = At(
1387
+ u,
1388
+ f
1389
+ ), l = At(
1390
+ l,
1391
+ f
1392
+ );
1393
+ } else {
1394
+ const f = s[0];
1395
+ u = yt(u, f), l = yt(l, f);
1396
+ }
1397
+ let h = Array.from(
1398
+ Mt(
1399
+ u,
1400
+ s,
1401
+ i
1402
+ )
1403
+ ), c = Array.from(
1404
+ Mt(
1405
+ l,
1406
+ s,
1407
+ i
1408
+ )
1409
+ );
1410
+ return (!g(
1411
+ c[0].lastPoint,
1412
+ h[0].lastPoint
1413
+ ) || i.length > 0 && c[0].segmentsCount !== 1) && (c = c.map((f) => f.reverse()).reverse(), g(c[0].lastPoint, h[0].lastPoint) || (h = h.map((f) => f.reverse()).reverse())), L([h, c]).map(([f, m]) => f.segmentsCount === 1 && i.some((P) => f.segments[0].isSame(P)) ? [f, "same"] : [f, m]);
1414
+ }
1415
+ function St(e) {
1416
+ let t = e[0];
1417
+ for (const n of e.slice(1))
1418
+ t = t.extend(n);
1419
+ if (!g(t.firstPoint, t.lastPoint))
1420
+ throw console.error(
1421
+ I(t.firstPoint),
1422
+ I(t.lastPoint)
1423
+ ), new Error("Bug in the intersection algo on non closing strand");
1424
+ return new O(t.segments);
1425
+ }
1426
+ function un(e, t) {
1427
+ const n = L([
1428
+ t.slice(0, -1),
1429
+ t.slice(1)
1430
+ ]).map(([i, r]) => St(e.slice(i, r)));
1431
+ let s = e.slice(
1432
+ t[t.length - 1]
1433
+ );
1434
+ return t[0] !== 0 && (s = s.concat(e.slice(0, t[0]))), n.push(St(s)), n;
1435
+ }
1436
+ function hn(e) {
1437
+ if (!e.length)
1438
+ return [];
1439
+ const t = e.map((i) => i.firstPoint);
1440
+ let n = e.map((i) => i.lastPoint);
1441
+ n = n.slice(-1).concat(n.slice(0, -1));
1442
+ const s = L([t, n]).flatMap(
1443
+ ([i, r], a) => g(i, r) ? [] : a
1444
+ );
1445
+ try {
1446
+ return un(e, s);
1447
+ } catch {
1448
+ return Lt(e.flatMap((r) => r.segments)).filter((r) => r.length > 1).filter((r) => g(r[0].firstPoint, r.at(-1).lastPoint)).map((r) => new O(r));
1449
+ }
1450
+ }
1451
+ const bt = (e, t) => {
1452
+ if (e.length === 0)
1453
+ return [t];
1454
+ const n = e.at(-1);
1455
+ return g(n.lastPoint, t.firstPoint) ? e.slice(0, -1).concat([n.extend(t)]) : g(n.lastPoint, t.lastPoint) ? e.slice(0, -1).concat([n.extend(t.reverse())]) : e.concat([t]);
1456
+ }, ln = (e, t) => e.length === 0 ? [t] : g(e[0].firstPoint, t.lastPoint) ? [t.extend(e[0])].concat(e.slice(1)) : [t].concat(e);
1457
+ function lt(e, t, {
1458
+ firstInside: n,
1459
+ secondInside: s
1460
+ }) {
1461
+ const i = an(e, t);
1462
+ if (!i) {
1463
+ const u = e.segments[0].midPoint, l = t.contains(u), h = t.segments[0].midPoint, c = e.contains(h);
1464
+ return {
1465
+ identical: !1,
1466
+ firstCurveInSecond: l,
1467
+ secondCurveInFirst: c
1468
+ };
1469
+ }
1470
+ if (i.every(([, u]) => u === "same"))
1471
+ return { identical: !0 };
1472
+ let r = null, a = null;
1473
+ const o = i.flatMap(([u, l]) => {
1474
+ let h = [], c = 0;
1475
+ if (l === "same")
1476
+ return a === 1 ? (a = 1, u) : a === 2 || a === 0 ? (a = null, []) : a === null ? (r ? r = r.extend(u) : r = u, []) : (console.error("weird situation"), []);
1477
+ const f = u.segments[0].midPoint, m = t.contains(f);
1478
+ (n === "keep" && m || n === "remove" && !m) && (c += 1, h = bt(h, u));
1479
+ const P = l.segments[0].midPoint, w = e.contains(P);
1480
+ if (s === "keep" && w || s === "remove" && !w) {
1481
+ const M = l;
1482
+ c += 1, c === 2 && h.length ? (h = bt(h, M), r = null) : h = [M];
1483
+ }
1484
+ return a === null && c === 1 && r && (h = ln(h, r)), c === 1 && (a = c, r = null), h.length ? h : (r = null, []);
1485
+ });
1486
+ return hn(o);
1487
+ }
1488
+ const cn = (e, t) => {
1489
+ const n = lt(e, t, {
1490
+ firstInside: "remove",
1491
+ secondInside: "remove"
1492
+ });
1493
+ return Array.isArray(n) ? n : n.identical ? [e] : n.firstCurveInSecond ? [t] : n.secondCurveInFirst ? [e] : [e, t];
1494
+ }, H = (e, t) => {
1495
+ const n = lt(e, t, {
1496
+ firstInside: "remove",
1497
+ secondInside: "keep"
1498
+ });
1499
+ return Array.isArray(n) ? n : n.identical ? [] : n.firstCurveInSecond ? [] : n.secondCurveInFirst ? [e, t] : [e];
1500
+ }, ct = (e, t) => {
1501
+ const n = lt(e, t, {
1502
+ firstInside: "keep",
1503
+ secondInside: "keep"
1504
+ });
1505
+ return Array.isArray(n) ? n : n.identical ? [e] : n.firstCurveInSecond ? [e] : n.secondCurveInFirst ? [t] : [];
1506
+ };
1507
+ function fn(e) {
1508
+ const t = /* @__PURE__ */ new Map(), n = [];
1509
+ return e.forEach((s, i) => {
1510
+ let r;
1511
+ t.has(i) ? r = t.get(i) : (r = { current: [s], fusedWith: /* @__PURE__ */ new Set([i]) }, n.push(r)), e.slice(i + 1).forEach((a, o) => {
1512
+ const u = r.current, l = i + o + 1;
1513
+ if (r.fusedWith.has(l))
1514
+ return;
1515
+ let h = [a], c = !1;
1516
+ if (t.has(l) && (h = t.get(l).current, c = !0), !u.some(
1517
+ (P) => h.some((w) => P.intersects(w))
1518
+ ))
1519
+ return;
1520
+ let m;
1521
+ u.length > 1 || h.length > 1 ? m = U(u, h) : m = $t(u[0], h[0]), r.fusedWith.add(l), r.current = m, c || t.set(l, r);
1522
+ });
1523
+ }), n.flatMap(({ current: s }) => s);
1524
+ }
1525
+ function $t(e, t) {
1526
+ const n = cn(e.contour, t.contour), s = t.holes.flatMap((a) => H(a, e.contour)), i = e.holes.flatMap((a) => H(a, t.contour)), r = rn(e.holes, t.holes).flatMap(
1527
+ ([a, o]) => ct(a, o)
1528
+ );
1529
+ return D([
1530
+ ...n,
1531
+ ...s,
1532
+ ...i,
1533
+ ...r
1534
+ ]);
1535
+ }
1536
+ function J(e, t) {
1537
+ if (e.isFull && t.isFull)
1538
+ return D(H(e.contour, t.contour));
1539
+ if (e.isFull) {
1540
+ const s = H(e.contour, t.contour), i = t.holes.flatMap(
1541
+ (r) => ct(r, e.contour)
1542
+ );
1543
+ return D([...s, ...i]);
1544
+ } else if (t.isFull && !e.contour.intersects(t.contour))
1545
+ if (e.contour.contains(t.contour.firstPoint)) {
1546
+ const s = U(
1547
+ e.holes.map((i) => new S(i)),
1548
+ [t]
1549
+ );
1550
+ return D([
1551
+ e.contour,
1552
+ ...s.flatMap((i) => i.allLoops)
1553
+ ]);
1554
+ } else
1555
+ return [e];
1556
+ let n = J(new S(e.contour), t);
1557
+ return e.holes.forEach((s) => {
1558
+ n = n.flatMap((i) => J(i, new S(s)));
1559
+ }), n;
1560
+ }
1561
+ function gn(e, t) {
1562
+ const n = ct(e.contour, t.contour);
1563
+ if (!n.length)
1564
+ return [];
1565
+ let s = D(n);
1566
+ return s = N(
1567
+ s,
1568
+ e.holes.map((i) => new S(i))
1569
+ ), N(
1570
+ s,
1571
+ t.holes.map((i) => new S(i))
1572
+ );
1573
+ }
1574
+ function U(e, t) {
1575
+ if (!e.length)
1576
+ return t;
1577
+ if (!t.length)
1578
+ return e;
1579
+ if (e.length === 1 && t.length > 1 || t.length === 1 && e.length > 1)
1580
+ return fn([...e, ...t]);
1581
+ if (e.length > 1 && t.length > 1) {
1582
+ let n = U([e[0]], t);
1583
+ return e.slice(1).forEach((s) => {
1584
+ n = U([s], n);
1585
+ }), n;
1586
+ }
1587
+ return e.length === 1 && t.length === 1 ? $t(e[0], t[0]) : [];
1588
+ }
1589
+ function N(e, t) {
1590
+ if (!e.length)
1591
+ return [];
1592
+ if (!t.length)
1593
+ return e;
1594
+ if (e.length === 1 && t.length === 1)
1595
+ return J(e[0], t[0]);
1596
+ if (e.length > 1)
1597
+ return e.flatMap((s) => N([s], t));
1598
+ let n = J(e[0], t[0]);
1599
+ return t.slice(1).forEach((s) => {
1600
+ n = N(n, [s]);
1601
+ }), n;
1602
+ }
1603
+ function at(e, t) {
1604
+ return !e.length || !t.length ? [] : e.length === 1 && t.length === 1 ? gn(e[0], t[0]) : e.length > 1 ? e.flatMap((n) => at([n], t)) : t.flatMap((n) => at(e, [n]));
1605
+ }
1606
+ class V extends K {
1607
+ constructor(t = [], { ignoreChecks: n = !1 } = {}) {
1608
+ super(), this._boundingBox = null, n || mn(t), this.figures = t;
1609
+ }
1610
+ get isEmpty() {
1611
+ return this.figures.length === 0;
1612
+ }
1613
+ get boundingBox() {
1614
+ if (this.isEmpty)
1615
+ return new q();
1616
+ if (this._boundingBox === null) {
1617
+ let t = this.figures[0].boundingBox;
1618
+ for (const n of this.figures.slice(1))
1619
+ t = t.merge(n.boundingBox);
1620
+ this._boundingBox = t;
1621
+ }
1622
+ return this._boundingBox;
1623
+ }
1624
+ clone() {
1625
+ return new V(this.figures.map((t) => t.clone()));
1626
+ }
1627
+ transform(t) {
1628
+ return new V(this.figures.map((n) => n.transform(t)));
1629
+ }
1630
+ contains(t) {
1631
+ return this.figures.some((n) => n.contains(t));
1632
+ }
1633
+ intersects(t) {
1634
+ return this.figures.some(
1635
+ (n) => t.figures.some((s) => n.intersects(s))
1636
+ );
1637
+ }
1638
+ overlappingStrands(t) {
1639
+ return this.figures.flatMap((n) => t instanceof V ? t.figures.flatMap(
1640
+ (s) => n.overlappingStrands(s)
1641
+ ) : n.overlappingStrands(t));
1642
+ }
1643
+ fuse(t) {
1644
+ return new V(U(this.figures, t.figures));
1645
+ }
1646
+ cut(t) {
1647
+ return new V(N(this.figures, t.figures));
1648
+ }
1649
+ intersect(t) {
1650
+ return new V(at(this.figures, t.figures));
1651
+ }
1652
+ }
1653
+ function mn(e) {
1654
+ for (const [t, n] of it(e))
1655
+ if (t.intersects(n))
1656
+ throw new Error("Diagram figures must not intersect");
1657
+ }
1658
+ export {
1659
+ p as A,
1660
+ q as B,
1661
+ Pn as C,
1662
+ V as D,
1663
+ tt as E,
1664
+ S as F,
1665
+ pn as G,
1666
+ R as H,
1667
+ qt as I,
1668
+ O as L,
1669
+ v as S,
1670
+ C as T,
1671
+ U as a,
1672
+ G as b,
1673
+ N as c,
1674
+ k as d,
1675
+ y as e,
1676
+ W as f,
1677
+ A as g,
1678
+ _ as h,
1679
+ at as i,
1680
+ kt as j,
1681
+ Dt as k,
1682
+ Z as l,
1683
+ d as m,
1684
+ B as n,
1685
+ g as o,
1686
+ Nt as p,
1687
+ Lt as q,
1688
+ Q as r,
1689
+ Mt as s,
1690
+ Y as t,
1691
+ $ as u,
1692
+ dt as v,
1693
+ K as w,
1694
+ F as x,
1695
+ dn as y,
1696
+ L as z
1697
+ };
1698
+ //# sourceMappingURL=Diagram-1c56996e.js.map