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