pantograph2d 0.7.0 → 0.8.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.
Files changed (126) hide show
  1. package/dist/Diagram-2450b2e6.js +1750 -0
  2. package/dist/Diagram-2450b2e6.js.map +1 -0
  3. package/dist/Diagram-57e17509.cjs +4 -0
  4. package/dist/Diagram-57e17509.cjs.map +1 -0
  5. package/dist/QuadraticBezier-e116a2d6.js +3647 -0
  6. package/dist/QuadraticBezier-e116a2d6.js.map +1 -0
  7. package/dist/QuadraticBezier-e3d7218b.cjs +9 -0
  8. package/dist/QuadraticBezier-e3d7218b.cjs.map +1 -0
  9. package/dist/api/svg.d.ts +1 -0
  10. package/dist/draw-27ac6dae.cjs +2 -0
  11. package/dist/draw-27ac6dae.cjs.map +1 -0
  12. package/dist/{draw-825692f1.js → draw-c7b2705c.js} +117 -109
  13. package/dist/draw-c7b2705c.js.map +1 -0
  14. package/dist/export/svg/api.d.ts +6 -0
  15. package/dist/{types/export → export}/svg/wrapSVG.d.ts +1 -1
  16. package/dist/{types/models → models}/exports.d.ts +2 -0
  17. package/dist/pantograph/drawShape.cjs +1 -1
  18. package/dist/pantograph/drawShape.cjs.map +1 -1
  19. package/dist/pantograph/drawShape.js +12 -11
  20. package/dist/pantograph/drawShape.js.map +1 -1
  21. package/dist/pantograph/models.cjs +1 -1
  22. package/dist/pantograph/models.js +15 -12
  23. package/dist/pantograph/models.js.map +1 -1
  24. package/dist/pantograph/svg.cjs +2 -0
  25. package/dist/pantograph/svg.cjs.map +1 -0
  26. package/dist/pantograph/svg.js +11 -0
  27. package/dist/pantograph/svg.js.map +1 -0
  28. package/dist/pantograph.cjs +2 -8
  29. package/dist/pantograph.cjs.map +1 -1
  30. package/dist/pantograph.js +405 -440
  31. package/dist/pantograph.js.map +1 -1
  32. package/dist/wrapSVG-02b823ac.cjs +8 -0
  33. package/dist/wrapSVG-02b823ac.cjs.map +1 -0
  34. package/dist/wrapSVG-0ec8a111.js +62 -0
  35. package/dist/wrapSVG-0ec8a111.js.map +1 -0
  36. package/package.json +31 -23
  37. package/dist/Diagram-8c3c5e1b.js +0 -5301
  38. package/dist/Diagram-8c3c5e1b.js.map +0 -1
  39. package/dist/Diagram-d8288579.cjs +0 -11
  40. package/dist/Diagram-d8288579.cjs.map +0 -1
  41. package/dist/draw-3ee546c3.cjs +0 -2
  42. package/dist/draw-3ee546c3.cjs.map +0 -1
  43. package/dist/draw-825692f1.js.map +0 -1
  44. /package/dist/{types/algorithms → algorithms}/boolean/figureBooleans.d.ts +0 -0
  45. /package/dist/{types/algorithms → algorithms}/boolean/loopBooleans.d.ts +0 -0
  46. /package/dist/{types/algorithms → algorithms}/boolean/strandBoolean.d.ts +0 -0
  47. /package/dist/{types/algorithms → algorithms}/boolean/strandsBetweenIntersections.d.ts +0 -0
  48. /package/dist/{types/algorithms → algorithms}/distances/arcArcDistance.d.ts +0 -0
  49. /package/dist/{types/algorithms → algorithms}/distances/genericDistance.d.ts +0 -0
  50. /package/dist/{types/algorithms → algorithms}/distances/index.d.ts +0 -0
  51. /package/dist/{types/algorithms → algorithms}/distances/lineArcDistance.d.ts +0 -0
  52. /package/dist/{types/algorithms → algorithms}/distances/lineLineDistance.d.ts +0 -0
  53. /package/dist/{types/algorithms → algorithms}/filletSegments.d.ts +0 -0
  54. /package/dist/{types/algorithms → algorithms}/intersections/arcArcIntersection.d.ts +0 -0
  55. /package/dist/{types/algorithms → algorithms}/intersections/arcEllipseArcIntersection.d.ts +0 -0
  56. /package/dist/{types/algorithms → algorithms}/intersections/arcsCubicBezierIntersection.d.ts +0 -0
  57. /package/dist/{types/algorithms → algorithms}/intersections/arcsQuadraticBezierIntersection.d.ts +0 -0
  58. /package/dist/{types/algorithms → algorithms}/intersections/bezierClip.d.ts +0 -0
  59. /package/dist/{types/algorithms → algorithms}/intersections/cubicBezierCubicBezierIntersection.d.ts +0 -0
  60. /package/dist/{types/algorithms → algorithms}/intersections/ellipseArcEllipseArcIntersection.d.ts +0 -0
  61. /package/dist/{types/algorithms → algorithms}/intersections/ellipseEllipseIntersection.d.ts +0 -0
  62. /package/dist/{types/algorithms → algorithms}/intersections/index.d.ts +0 -0
  63. /package/dist/{types/algorithms → algorithms}/intersections/lineArcIntersection.d.ts +0 -0
  64. /package/dist/{types/algorithms → algorithms}/intersections/lineBezierIntersection.d.ts +0 -0
  65. /package/dist/{types/algorithms → algorithms}/intersections/lineEllipseArcIntersection.d.ts +0 -0
  66. /package/dist/{types/algorithms → algorithms}/intersections/lineLineIntersection.d.ts +0 -0
  67. /package/dist/{types/algorithms → algorithms}/intersections/quadraticBezierQuadraticBezierIntersection.d.ts +0 -0
  68. /package/dist/{types/algorithms → algorithms}/intersections/rayIntersections.d.ts +0 -0
  69. /package/dist/{types/algorithms → algorithms}/offsets/offsetFigure.d.ts +0 -0
  70. /package/dist/{types/algorithms → algorithms}/offsets/offsetSegment.d.ts +0 -0
  71. /package/dist/{types/algorithms → algorithms}/offsets/offsetStroke.d.ts +0 -0
  72. /package/dist/{types/algorithms → algorithms}/optimisation/Brent.d.ts +0 -0
  73. /package/dist/{types/algorithms → algorithms}/optimisation/DiRect.d.ts +0 -0
  74. /package/dist/{types/algorithms → algorithms}/organiseLoops.d.ts +0 -0
  75. /package/dist/{types/algorithms → algorithms}/simplify.d.ts +0 -0
  76. /package/dist/{types/algorithms → algorithms}/solvers/solvePolynomials.d.ts +0 -0
  77. /package/dist/{types/algorithms → algorithms}/stitchSegments.d.ts +0 -0
  78. /package/dist/{types/api → api}/drawShape.d.ts +0 -0
  79. /package/dist/{types/api → api}/models.d.ts +0 -0
  80. /package/dist/{types/booleanOperations.d.ts → booleanOperations.d.ts} +0 -0
  81. /package/dist/{types/definitions.d.ts → definitions.d.ts} +0 -0
  82. /package/dist/{types/draw.d.ts → draw.d.ts} +0 -0
  83. /package/dist/{types/drawShape → drawShape}/drawCircle.d.ts +0 -0
  84. /package/dist/{types/drawShape → drawShape}/drawRect.d.ts +0 -0
  85. /package/dist/{types/export → export}/json/exportJSON.d.ts +0 -0
  86. /package/dist/{types/export → export}/json/jsonDiagram.d.ts +0 -0
  87. /package/dist/{types/export → export}/json/jsonFigure.d.ts +0 -0
  88. /package/dist/{types/export → export}/json/jsonLoop.d.ts +0 -0
  89. /package/dist/{types/export → export}/json/jsonSegment.d.ts +0 -0
  90. /package/dist/{types/export → export}/svg/exportSVG.d.ts +0 -0
  91. /package/dist/{types/export → export}/svg/svgDiagram.d.ts +0 -0
  92. /package/dist/{types/export → export}/svg/svgFigure.d.ts +0 -0
  93. /package/dist/{types/export → export}/svg/svgLoop.d.ts +0 -0
  94. /package/dist/{types/export → export}/svg/svgSegment.d.ts +0 -0
  95. /package/dist/{types/export → export}/svg/svgStrand.d.ts +0 -0
  96. /package/dist/{types/import → import}/json/importJSON.d.ts +0 -0
  97. /package/dist/{types/main.d.ts → main.d.ts} +0 -0
  98. /package/dist/{types/models → models}/BoundingBox.d.ts +0 -0
  99. /package/dist/{types/models → models}/Diagram.d.ts +0 -0
  100. /package/dist/{types/models → models}/Figure.d.ts +0 -0
  101. /package/dist/{types/models → models}/Loop.d.ts +0 -0
  102. /package/dist/{types/models → models}/Strand.d.ts +0 -0
  103. /package/dist/{types/models → models}/Stroke.d.ts +0 -0
  104. /package/dist/{types/models → models}/TransformationMatrix.d.ts +0 -0
  105. /package/dist/{types/models → models}/segments/Arc.d.ts +0 -0
  106. /package/dist/{types/models → models}/segments/CubicBezier.d.ts +0 -0
  107. /package/dist/{types/models → models}/segments/EllipseArc.d.ts +0 -0
  108. /package/dist/{types/models → models}/segments/Line.d.ts +0 -0
  109. /package/dist/{types/models → models}/segments/QuadraticBezier.d.ts +0 -0
  110. /package/dist/{types/models → models}/segments/Segment.d.ts +0 -0
  111. /package/dist/{types/models → models}/segments/utils/deCasteljau.d.ts +0 -0
  112. /package/dist/{types/models → models}/segments/utils/isSegment.d.ts +0 -0
  113. /package/dist/{types/models → models}/utils/Transformable.d.ts +0 -0
  114. /package/dist/{types/offsetOperations.d.ts → offsetOperations.d.ts} +0 -0
  115. /package/dist/{types/operations.d.ts → operations.d.ts} +0 -0
  116. /package/dist/{types/utils → utils}/allCombinations.d.ts +0 -0
  117. /package/dist/{types/utils → utils}/allPairs.d.ts +0 -0
  118. /package/dist/{types/utils → utils}/angularDistance.d.ts +0 -0
  119. /package/dist/{types/utils → utils}/listOfFigures.d.ts +0 -0
  120. /package/dist/{types/utils → utils}/projectPointOnLine.d.ts +0 -0
  121. /package/dist/{types/utils → utils}/range.d.ts +0 -0
  122. /package/dist/{types/utils → utils}/removeDuplicatePoints.d.ts +0 -0
  123. /package/dist/{types/utils → utils}/removeDuplicateValues.d.ts +0 -0
  124. /package/dist/{types/utils → utils}/unitAngle.d.ts +0 -0
  125. /package/dist/{types/utils → utils}/zip.d.ts +0 -0
  126. /package/dist/{types/vectorOperations.d.ts → vectorOperations.d.ts} +0 -0
@@ -1,616 +1,581 @@
1
- import { o as Pt, D } from "./draw-825692f1.js";
2
- import { d as dn } from "./draw-825692f1.js";
3
- import { F as p, L as P, D as h, f as O, r as wt, z as mt, s as Mt, a as It, c as St, i as vt, S as C, l as $t, d as m, b as At, p as Lt, n as K, e as E, g as kt, h as Et, j as bt, k as yt, m as j, o as M, A as v, q as tt, t as I, u as Ct, v as Ft, E as nt, R as Dt, Q as et, C as it, w as xt, B as Rt } from "./Diagram-8c3c5e1b.js";
4
- import { x as wn } from "./Diagram-8c3c5e1b.js";
5
- function S(t) {
6
- if (t instanceof p)
1
+ var lt = Object.defineProperty;
2
+ var ut = (t, e, n) => e in t ? lt(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
+ var p = (t, e, n) => (ut(t, typeof e != "symbol" ? e + "" : e, n), n);
4
+ import { o as gt, D } from "./draw-c7b2705c.js";
5
+ import { d as Pe } from "./draw-c7b2705c.js";
6
+ import { F as d, L as P, D as g, f as B, s as ht, a as pt, c as dt, i as mt, S as C, l as Pt, p as wt, b as Mt, d as X, e as It } from "./Diagram-2450b2e6.js";
7
+ import { g as Me } from "./Diagram-2450b2e6.js";
8
+ import { r as St, z as bt, l as Lt, d as w, n as Y, s as E, a as vt, b as At, p as kt, c as j, L as S, A as b, e as M, t as Et, f as yt, B as Ft, E as Ct, Q as xt, C as Dt } from "./QuadraticBezier-e116a2d6.js";
9
+ import { s as Rt, a as Ot, b as Bt, c as $t, d as Gt, w as z } from "./wrapSVG-0ec8a111.js";
10
+ function I(t) {
11
+ if (t instanceof d)
7
12
  return [t];
8
13
  if (t instanceof P)
9
- return [new p(t)];
10
- if (t instanceof h)
14
+ return [new d(t)];
15
+ if (t instanceof g)
11
16
  return t.figures;
12
17
  throw new Error("Unknown shape");
13
18
  }
14
- function st(t, n, e = 1e-9) {
15
- let i = [];
16
- const r = [], s = new Array(n.segments.length).fill(0).map(() => []);
17
- n.segments.forEach((c, f) => {
19
+ function tt(t, e, n = 1e-9) {
20
+ let s = [];
21
+ const r = [], i = new Array(e.segments.length).fill(0).map(() => []);
22
+ e.segments.forEach((c, f) => {
18
23
  t.segments.forEach((a) => {
19
- const { intersections: u, overlaps: d } = O(
24
+ const { intersections: u, overlaps: m } = B(
20
25
  c,
21
26
  a,
22
- e
27
+ n
23
28
  );
24
- i.push(...u), s[f].push(...u), r.push(...d);
25
- const g = d.flatMap((l) => [
29
+ s.push(...u), i[f].push(...u), r.push(...m);
30
+ const h = m.flatMap((l) => [
26
31
  l.firstPoint,
27
32
  l.lastPoint
28
33
  ]);
29
- i.push(...g), s[f].push(...g);
34
+ s.push(...h), i[f].push(...h);
30
35
  });
31
- }), i = wt(i, e);
32
- const o = mt([n.segments, s]).flatMap(([c, f]) => f.length ? c.splitAt(f) : [c]);
36
+ }), s = St(s, n);
37
+ const o = bt([e.segments, i]).flatMap(([c, f]) => f.length ? c.splitAt(f) : [c]);
33
38
  return Array.from(
34
- Mt(
39
+ ht(
35
40
  o,
36
- i,
41
+ s,
37
42
  r
38
43
  )
39
44
  );
40
45
  }
41
- function B(t, n, e = !1) {
42
- return st(n, t).filter((r) => {
43
- const s = r.segments[0].midPoint;
44
- return n.onStroke(s) ? !e : !n.contains(s);
46
+ function $(t, e, n = !1) {
47
+ return tt(e, t).filter((r) => {
48
+ const i = r.segments[0].midPoint;
49
+ return e.onStroke(i) ? !n : !e.contains(i);
45
50
  });
46
51
  }
47
- function G(t, n, e = !1) {
48
- return st(n, t).filter((r) => {
49
- const s = r.segments[0].midPoint;
50
- return n.onStroke(s) ? !e : n.contains(s);
52
+ function G(t, e, n = !1) {
53
+ return tt(e, t).filter((r) => {
54
+ const i = r.segments[0].midPoint;
55
+ return e.onStroke(i) ? !n : e.contains(i);
51
56
  });
52
57
  }
53
- function z(t, n, e = !1) {
54
- const i = B(
58
+ function V(t, e, n = !1) {
59
+ const s = $(
55
60
  t,
56
- n.contour,
57
- e
58
- ), r = n.holes.flatMap(
59
- (s) => G(t, s, e)
61
+ e.contour,
62
+ n
63
+ ), r = e.holes.flatMap(
64
+ (i) => G(t, i, n)
60
65
  );
61
- return [...i, ...r];
66
+ return [...s, ...r];
62
67
  }
63
- function _(t, n, e = !1) {
64
- let i = G(
68
+ function _(t, e, n = !1) {
69
+ let s = G(
65
70
  t,
66
- n.contour,
67
- e
71
+ e.contour,
72
+ n
68
73
  );
69
- return n.holes.forEach((r) => {
70
- i = i.flatMap(
71
- (s) => B(s, r, e)
74
+ return e.holes.forEach((r) => {
75
+ s = s.flatMap(
76
+ (i) => $(i, r, n)
72
77
  );
73
- }), i;
78
+ }), s;
74
79
  }
75
- function Ot(t, n) {
76
- return new h(
77
- It(S(t), S(n))
80
+ function Tt(t, e) {
81
+ return new g(
82
+ pt(I(t), I(e))
78
83
  );
79
84
  }
80
- function b(t) {
85
+ function y(t) {
81
86
  return t.reduce(
82
- (n, e) => Ot(n, e),
83
- new h()
87
+ (e, n) => Tt(e, n),
88
+ new g()
84
89
  );
85
90
  }
86
- function rt(t, n) {
87
- return new h(
88
- St(S(t), S(n))
91
+ function et(t, e) {
92
+ return new g(
93
+ dt(I(t), I(e))
89
94
  );
90
95
  }
91
- function sn(t, n) {
92
- return new h(
93
- vt(S(t), S(n))
96
+ function oe(t, e) {
97
+ return new g(
98
+ mt(I(t), I(e))
94
99
  );
95
100
  }
96
- function rn(t, n, e = !0) {
97
- if (n instanceof P)
98
- return B(t, n, e);
99
- if (n instanceof p)
100
- return z(t, n, e);
101
- let i = [new C([...t.segments])];
102
- return n.figures.forEach((r) => {
103
- i = i.flatMap((s) => z(s, r, e));
104
- }), i;
105
- }
106
- function on(t, n, e = !1) {
107
- if (n instanceof P)
108
- return G(t, n, e);
109
- if (n instanceof p)
110
- return _(t, n, e);
111
- let i = [new C([...t.segments])];
112
- return n.figures.forEach((r) => {
113
- i = i.flatMap((s) => _(s, r, e));
114
- }), i;
115
- }
116
- function q(t) {
101
+ function ae(t, e, n = !0) {
102
+ if (e instanceof P)
103
+ return $(t, e, n);
104
+ if (e instanceof d)
105
+ return V(t, e, n);
106
+ let s = [new C([...t.segments])];
107
+ return e.figures.forEach((r) => {
108
+ s = s.flatMap((i) => V(i, r, n));
109
+ }), s;
110
+ }
111
+ function ce(t, e, n = !1) {
112
+ if (e instanceof P)
113
+ return G(t, e, n);
114
+ if (e instanceof d)
115
+ return _(t, e, n);
116
+ let s = [new C([...t.segments])];
117
+ return e.figures.forEach((r) => {
118
+ s = s.flatMap((i) => _(i, r, n));
119
+ }), s;
120
+ }
121
+ function N(t) {
117
122
  return t < 0 ? "before" : t > 1 ? "after" : "between";
118
123
  }
119
- const N = (t, n, e) => {
120
- if (e === "before")
121
- return t.distanceFrom(n.firstPoint);
122
- if (e === "after")
123
- return t.distanceFrom(n.lastPoint);
124
+ const q = (t, e, n) => {
125
+ if (n === "before")
126
+ return t.distanceFrom(e.firstPoint);
127
+ if (n === "after")
128
+ return t.distanceFrom(e.lastPoint);
124
129
  throw new Error("Invalid position");
125
130
  };
126
- function Bt(t, n) {
127
- const e = $t(t, n);
128
- if (e === "parallel")
131
+ function Ut(t, e) {
132
+ const n = Lt(t, e);
133
+ if (n === "parallel")
129
134
  return Math.min(
130
- t.distanceFrom(n.firstPoint),
131
- t.distanceFrom(n.lastPoint)
135
+ t.distanceFrom(e.firstPoint),
136
+ t.distanceFrom(e.lastPoint)
132
137
  );
133
- const { intersectionParam1: i, intersectionParam2: r } = e, s = q(i), o = q(r);
134
- if (s === "between" && o === "between")
138
+ const { intersectionParam1: s, intersectionParam2: r } = n, i = N(s), o = N(r);
139
+ if (i === "between" && o === "between")
135
140
  return 0;
136
- if (s === "between" && o !== "between")
137
- return N(t, n, o);
138
- if (o === "between" && s !== "between")
139
- return N(n, t, s);
140
- if (s === "before" && o === "before")
141
- return m(t.firstPoint, n.firstPoint);
142
- if (s === "after" && o === "after")
143
- return m(t.lastPoint, n.lastPoint);
144
- if (s === "before" && o === "after")
145
- return m(t.firstPoint, n.lastPoint);
146
- if (s === "after" && o === "before")
147
- return m(t.lastPoint, n.firstPoint);
141
+ if (i === "between" && o !== "between")
142
+ return q(t, e, o);
143
+ if (o === "between" && i !== "between")
144
+ return q(e, t, i);
145
+ if (i === "before" && o === "before")
146
+ return w(t.firstPoint, e.firstPoint);
147
+ if (i === "after" && o === "after")
148
+ return w(t.lastPoint, e.lastPoint);
149
+ if (i === "before" && o === "after")
150
+ return w(t.firstPoint, e.lastPoint);
151
+ if (i === "after" && o === "before")
152
+ return w(t.lastPoint, e.firstPoint);
148
153
  throw new Error("Invalid position");
149
154
  }
150
- function Q(t, n) {
151
- if (At(t, n).length > 0)
155
+ function J(t, e) {
156
+ if (Pt(t, e).length > 0)
152
157
  return 0;
153
- const e = Lt(t, n.center);
154
- if (t.isOnSegment(e)) {
155
- const i = m(e, n.center);
156
- if (Math.abs(i - n.radius) < t.precision && n.isOnSegment(e))
158
+ const n = wt(t, e.center);
159
+ if (t.isOnSegment(n)) {
160
+ const s = w(n, e.center);
161
+ if (Math.abs(s - e.radius) < t.precision && e.isOnSegment(n))
157
162
  return 0;
158
- if (i - n.radius > t.precision) {
159
- const r = K(
160
- E(e, n.center)
161
- ), s = kt(
162
- n.center,
163
- Et(r, n.radius)
163
+ if (s - e.radius > t.precision) {
164
+ const r = Y(
165
+ E(n, e.center)
166
+ ), i = vt(
167
+ e.center,
168
+ At(r, e.radius)
164
169
  );
165
- if (n.isOnSegment(s))
166
- return m(s, e);
170
+ if (e.isOnSegment(i))
171
+ return w(i, n);
167
172
  }
168
173
  }
169
174
  return Math.min(
170
- n.distanceFrom(t.firstPoint),
171
- n.distanceFrom(t.lastPoint),
172
- t.distanceFrom(n.firstPoint),
173
- t.distanceFrom(n.lastPoint)
175
+ e.distanceFrom(t.firstPoint),
176
+ e.distanceFrom(t.lastPoint),
177
+ t.distanceFrom(e.firstPoint),
178
+ t.distanceFrom(e.lastPoint)
174
179
  );
175
180
  }
176
- const Gt = (t, n) => {
177
- const e = t.angleToParam(n.firstAngle);
178
- if (t.isValidParameter(e))
181
+ const zt = (t, e) => {
182
+ const n = t.angleToParam(e.firstAngle);
183
+ if (t.isValidParameter(n))
179
184
  return !0;
180
- const i = t.angleToParam(n.lastAngle);
181
- return !!t.isValidParameter(i);
185
+ const s = t.angleToParam(e.lastAngle);
186
+ return !!t.isValidParameter(s);
182
187
  };
183
- function Tt(t, n) {
184
- if (bt(t, n, !0).length > 0)
188
+ function Vt(t, e) {
189
+ if (Mt(t, e, !0).length > 0)
185
190
  return 0;
186
- const e = m(t.center, n.center);
187
- if (e < t.precision && Gt(t, n))
188
- return Math.abs(t.radius - n.radius);
189
- const i = K(E(n.center, t.center)), r = e - Math.abs(t.radius - n.radius) < t.precision;
190
- let s = yt(i);
191
- r && n.radius > t.radius && (s += Math.PI);
192
- const o = r ? s : s + Math.PI, c = t.angleToParam(s), f = n.angleToParam(o);
193
- return t.isValidParameter(c) && n.isValidParameter(f) ? m(t.paramPoint(c), n.paramPoint(f)) : Math.min(
194
- t.distanceFrom(n.firstPoint),
195
- t.distanceFrom(n.lastPoint),
196
- n.distanceFrom(t.firstPoint),
197
- n.distanceFrom(t.lastPoint)
191
+ const n = w(t.center, e.center);
192
+ if (n < t.precision && zt(t, e))
193
+ return Math.abs(t.radius - e.radius);
194
+ const s = Y(E(e.center, t.center)), r = n - Math.abs(t.radius - e.radius) < t.precision;
195
+ let i = kt(s);
196
+ r && e.radius > t.radius && (i += Math.PI);
197
+ const o = r ? i : i + Math.PI, c = t.angleToParam(i), f = e.angleToParam(o);
198
+ return t.isValidParameter(c) && e.isValidParameter(f) ? w(t.paramPoint(c), e.paramPoint(f)) : Math.min(
199
+ t.distanceFrom(e.firstPoint),
200
+ t.distanceFrom(e.lastPoint),
201
+ e.distanceFrom(t.firstPoint),
202
+ e.distanceFrom(t.lastPoint)
198
203
  );
199
204
  }
200
- function Ut(t, n, e) {
201
- let i = 0, r = t.length - 1;
202
- for (; i <= r; ) {
203
- const s = Math.floor((i + r) / 2), o = e(t[s], n);
205
+ function _t(t, e, n) {
206
+ let s = 0, r = t.length - 1;
207
+ for (; s <= r; ) {
208
+ const i = Math.floor((s + r) / 2), o = n(t[i], e);
204
209
  if (o < 0)
205
- i = s + 1;
210
+ s = i + 1;
206
211
  else if (o > 0)
207
- r = s - 1;
212
+ r = i - 1;
208
213
  else
209
- return s;
214
+ return i;
210
215
  }
211
- return -(i + 1);
216
+ return -(s + 1);
212
217
  }
213
- function Vt(t, n, e) {
214
- const i = Ut(t, n, e);
215
- i < 0 ? t.splice(-(i + 1), 0, n) : t.splice(i, 0, n);
218
+ function Nt(t, e, n) {
219
+ const s = _t(t, e, n);
220
+ s < 0 ? t.splice(-(s + 1), 0, e) : t.splice(s, 0, e);
216
221
  }
217
- class zt {
222
+ class qt {
218
223
  constructor() {
224
+ p(this, "buckets");
219
225
  this.buckets = [];
220
226
  }
221
- addInterval(n) {
222
- const e = this.buckets[n.rectangle.diagonalBucketIndex];
223
- e === void 0 ? this.buckets[n.rectangle.diagonalBucketIndex] = [n] : Vt(e, n, (i, r) => i.value - r.value);
227
+ addInterval(e) {
228
+ const n = this.buckets[e.rectangle.diagonalBucketIndex];
229
+ n === void 0 ? this.buckets[e.rectangle.diagonalBucketIndex] = [e] : Nt(n, e, (s, r) => s.value - r.value);
224
230
  }
225
- removeInterval(n) {
226
- const e = this.buckets[n.rectangle.diagonalBucketIndex];
227
- if (e === void 0)
231
+ removeInterval(e) {
232
+ const n = this.buckets[e.rectangle.diagonalBucketIndex];
233
+ if (n === void 0)
228
234
  throw new Error("Interval not found");
229
- e.shift();
235
+ n.shift();
230
236
  }
231
237
  getBottomRightHullIntervals() {
232
- const n = [];
233
- for (let e = this.buckets.length - 1; e >= 0; e--) {
234
- const i = this.buckets[e];
235
- if (!i === void 0)
238
+ const e = [];
239
+ for (let n = this.buckets.length - 1; n >= 0; n--) {
240
+ const s = this.buckets[n];
241
+ if (!s === void 0)
236
242
  continue;
237
- const r = i[0];
243
+ const r = s[0];
238
244
  if (r !== void 0) {
239
- if (!n.length) {
240
- n.push(r);
245
+ if (!e.length) {
246
+ e.push(r);
241
247
  continue;
242
248
  }
243
- for (; n.length && n[n.length - 1].value >= r.value; )
244
- n.pop();
245
- for (; n.length >= 2; ) {
246
- const s = n[n.length - 1], o = n[n.length - 2], c = (r.value - o.value) / ((r.rectangle.diagonal - o.rectangle.diagonal) * 2);
247
- if (o.value + (s.rectangle.diagonal - o.rectangle.diagonal) / 2 * c < s.value)
248
- n.pop();
249
+ for (; e.length && e[e.length - 1].value >= r.value; )
250
+ e.pop();
251
+ for (; e.length >= 2; ) {
252
+ const i = e[e.length - 1], o = e[e.length - 2], c = (r.value - o.value) / ((r.rectangle.diagonal - o.rectangle.diagonal) * 2);
253
+ if (o.value + (i.rectangle.diagonal - o.rectangle.diagonal) / 2 * c < i.value)
254
+ e.pop();
249
255
  else
250
256
  break;
251
257
  }
252
- n.push(r);
258
+ e.push(r);
253
259
  }
254
260
  }
255
- return n;
261
+ return e;
256
262
  }
257
263
  }
258
- class _t {
259
- constructor(n, e) {
260
- this.x = n, this.y = e, this.xLength = Math.pow(3, -n), this.yLength = Math.pow(3, -e), this.diagonal = Math.sqrt(
264
+ class Jt {
265
+ constructor(e, n) {
266
+ p(this, "diagonal");
267
+ p(this, "diagonalBucketIndex");
268
+ p(this, "xLength");
269
+ p(this, "yLength");
270
+ p(this, "index");
271
+ this.x = e, this.y = n, this.xLength = Math.pow(3, -e), this.yLength = Math.pow(3, -n), this.diagonal = Math.sqrt(
261
272
  this.xLength * this.xLength + this.yLength * this.yLength
262
- ), this.diagonalBucketIndex = n + e, this.index = `${n},${e}`;
273
+ ), this.diagonalBucketIndex = e + n, this.index = `${e},${n}`;
263
274
  }
264
275
  }
265
- class qt {
266
- constructor(n, e = 1e-8, i = 1e3, r = 1e-6) {
267
- this.fcn = n, this.endTolerance = e, this.maxIterations = i, this.epsilon = r, this.fcn = n, this.epsilon = r, this.endTolerance = e, this.maxIterations = i, this.rectangles = /* @__PURE__ */ new Map(), this.buckets = new zt();
268
- const s = [0.5, 0.5], o = this.rect(0, 0), c = this.fcn(s);
269
- this.buckets.addInterval(new k(s, c, o)), this.fMin = c, this.argMin = s, this.tol = o.diagonal;
276
+ class Qt {
277
+ constructor(e, n = 1e-8, s = 1e3, r = 1e-6) {
278
+ p(this, "rectangles");
279
+ p(this, "buckets");
280
+ p(this, "fMin");
281
+ p(this, "argMin");
282
+ p(this, "tol");
283
+ this.fcn = e, this.endTolerance = n, this.maxIterations = s, this.epsilon = r, this.fcn = e, this.epsilon = r, this.endTolerance = n, this.maxIterations = s, this.rectangles = /* @__PURE__ */ new Map(), this.buckets = new qt();
284
+ const i = [0.5, 0.5], o = this.rect(0, 0), c = this.fcn(i);
285
+ this.buckets.addInterval(new k(i, c, o)), this.fMin = c, this.argMin = i, this.tol = o.diagonal;
270
286
  }
271
- registerInterval(n) {
272
- this.buckets.addInterval(n), n.value <= this.fMin && (this.fMin = n.value, this.argMin = n.center, this.tol = n.rectangle.diagonal);
287
+ registerInterval(e) {
288
+ this.buckets.addInterval(e), e.value <= this.fMin && (this.fMin = e.value, this.argMin = e.center, this.tol = e.rectangle.diagonal);
273
289
  }
274
- rect(n, e) {
275
- const i = `${n},${e}`;
276
- return this.rectangles.has(i) || this.rectangles.set(i, new _t(n, e)), this.rectangles.get(i);
290
+ rect(e, n) {
291
+ const s = `${e},${n}`;
292
+ return this.rectangles.has(s) || this.rectangles.set(s, new Jt(e, n)), this.rectangles.get(s);
277
293
  }
278
- splitInterval(n) {
279
- let e, i, r;
280
- const [s, o] = n.center;
281
- return n.rectangle.x <= n.rectangle.y ? (e = this.rect(n.rectangle.x + 1, n.rectangle.y), i = [s - e.xLength, o], r = [s + e.xLength, o]) : (e = this.rect(n.rectangle.x, n.rectangle.y + 1), i = [s, o - e.yLength], r = [s, o + e.yLength]), [
282
- new k(i, this.fcn(i), e),
283
- new k(n.center, n.value, e),
284
- new k(r, this.fcn(r), e)
294
+ splitInterval(e) {
295
+ let n, s, r;
296
+ const [i, o] = e.center;
297
+ return e.rectangle.x <= e.rectangle.y ? (n = this.rect(e.rectangle.x + 1, e.rectangle.y), s = [i - n.xLength, o], r = [i + n.xLength, o]) : (n = this.rect(e.rectangle.x, e.rectangle.y + 1), s = [i, o - n.yLength], r = [i, o + n.yLength]), [
298
+ new k(s, this.fcn(s), n),
299
+ new k(e.center, e.value, n),
300
+ new k(r, this.fcn(r), n)
285
301
  ];
286
302
  }
287
303
  single_iteration() {
288
- const n = this.buckets.getBottomRightHullIntervals();
289
- for (; n.length >= 2; ) {
290
- const e = n[0], i = n[1], r = (i.value - e.value) / ((i.rectangle.diagonal - e.rectangle.diagonal) / 2), s = e.value - r * i.value / 2;
291
- if ((this.fMin - s) / Math.abs(this.fMin) < this.epsilon)
292
- n.shift();
304
+ const e = this.buckets.getBottomRightHullIntervals();
305
+ for (; e.length >= 2; ) {
306
+ const n = e[0], s = e[1], r = (s.value - n.value) / ((s.rectangle.diagonal - n.rectangle.diagonal) / 2), i = n.value - r * s.value / 2;
307
+ if ((this.fMin - i) / Math.abs(this.fMin) < this.epsilon)
308
+ e.shift();
293
309
  else
294
310
  break;
295
311
  }
296
- n.forEach((e) => {
297
- this.buckets.removeInterval(e);
312
+ e.forEach((n) => {
313
+ this.buckets.removeInterval(n);
298
314
  });
299
- for (const e of n) {
300
- const [i, r, s] = this.splitInterval(e);
301
- this.registerInterval(i), this.registerInterval(r), this.registerInterval(s);
315
+ for (const n of e) {
316
+ const [s, r, i] = this.splitInterval(n);
317
+ this.registerInterval(s), this.registerInterval(r), this.registerInterval(i);
302
318
  }
303
319
  }
304
320
  run() {
305
- let n = 0;
306
- for (; this.tol > this.endTolerance / 2 && (this.single_iteration(), n++, !(n > this.maxIterations)); )
321
+ let e = 0;
322
+ for (; this.tol > this.endTolerance / 2 && (this.single_iteration(), e++, !(e > this.maxIterations)); )
307
323
  ;
308
324
  return {
309
325
  fMin: this.fMin,
310
326
  argMin: this.argMin,
311
327
  tol: this.tol,
312
- iterations: n
328
+ iterations: e
313
329
  };
314
330
  }
315
331
  }
316
332
  class k {
317
- constructor(n, e, i) {
318
- this.center = n, this.value = e, this.rectangle = i;
333
+ constructor(e, n, s) {
334
+ this.center = e, this.value = n, this.rectangle = s;
319
335
  }
320
336
  }
321
- function Nt(t, n = 1e-8, e = 1e3, i = 1e-6) {
322
- return new qt(
337
+ function Zt(t, e = 1e-8, n = 1e3, s = 1e-6) {
338
+ return new Qt(
323
339
  t,
324
- n,
325
340
  e,
326
- i
341
+ n,
342
+ s
327
343
  ).run();
328
344
  }
329
- function Qt(t, n, e = 1e-9) {
330
- const i = Nt((r) => {
331
- const s = t.paramPoint(r[0]), o = n.paramPoint(r[1]);
332
- return j(s, o);
333
- }, e);
334
- return Math.sqrt(i.fMin);
345
+ function Ht(t, e, n = 1e-9) {
346
+ const s = Zt((r) => {
347
+ const i = t.paramPoint(r[0]), o = e.paramPoint(r[1]);
348
+ return j(i, o);
349
+ }, n);
350
+ return Math.sqrt(s.fMin);
335
351
  }
336
- function Zt(t, n) {
337
- return t instanceof M && n instanceof M ? Bt(t, n) : t instanceof M && n instanceof v ? Q(t, n) : t instanceof v && n instanceof M ? Q(n, t) : t instanceof v && n instanceof v ? Tt(t, n) : Qt(t, n);
352
+ function Wt(t, e) {
353
+ return t instanceof S && e instanceof S ? Ut(t, e) : t instanceof S && e instanceof b ? J(t, e) : t instanceof b && e instanceof S ? J(e, t) : t instanceof b && e instanceof b ? Vt(t, e) : Ht(t, e);
338
354
  }
339
355
  const T = 1e-8;
340
- function x(t, n, e = !0) {
341
- const i = t.map((a) => ({
342
- offset: Pt(a, n),
356
+ function R(t, e, n = !0) {
357
+ const s = t.map((a) => ({
358
+ offset: gt(a, e),
343
359
  original: a
344
360
  })), r = [];
345
- let s = e ? null : i.at(-1), o = e ? i.at(-1) : null;
361
+ let i = n ? null : s.at(-1), o = n ? s.at(-1) : null;
346
362
  if (r.length === 1)
347
363
  return r;
348
364
  const c = (a) => {
349
- s ? a.offset instanceof D ? I(a.offset.firstPoint, a.offset.lastPoint) || r.push(
350
- new M(a.offset.firstPoint, a.offset.lastPoint)
351
- ) : r.push(a.offset) : s = a;
365
+ i ? a.offset instanceof D ? M(a.offset.firstPoint, a.offset.lastPoint) || r.push(
366
+ new S(a.offset.firstPoint, a.offset.lastPoint)
367
+ ) : r.push(a.offset) : i = a;
352
368
  }, f = function* () {
353
- for (const a of i.slice(0, -1))
369
+ for (const a of s.slice(0, -1))
354
370
  yield a;
355
- if (!s)
371
+ if (!i)
356
372
  throw new Error("Bug in the offset algorithm");
357
- yield s;
373
+ yield i;
358
374
  };
359
375
  for (const a of f()) {
360
376
  if (!o) {
361
377
  o = a;
362
378
  continue;
363
379
  }
364
- const u = o.offset.lastPoint, d = a.offset.firstPoint;
365
- if (I(u, d)) {
380
+ const u = o.offset.lastPoint, m = a.offset.firstPoint;
381
+ if (M(u, m)) {
366
382
  c(o), o = a;
367
383
  continue;
368
384
  }
369
- let g = [];
385
+ let h = [];
370
386
  if (!(o.offset instanceof D) && !(a.offset instanceof D)) {
371
- const { intersections: $, overlaps: F } = O(
387
+ const { intersections: L, overlaps: x } = B(
372
388
  o.offset,
373
389
  a.offset,
374
390
  T / 100
375
391
  );
376
- g = [
377
- ...$,
378
- ...F.flatMap((A) => [A.firstPoint, A.lastPoint])
392
+ h = [
393
+ ...L,
394
+ ...x.flatMap((v) => [v.firstPoint, v.lastPoint])
379
395
  ];
380
396
  }
381
- if (g.length > 0) {
382
- let $ = g[0];
383
- if (g.length > 1) {
384
- const pt = o == null ? void 0 : o.original.lastPoint, V = g.map(
385
- (dt) => j(dt, pt)
397
+ if (h.length > 0) {
398
+ let L = h[0];
399
+ if (h.length > 1) {
400
+ const ct = o == null ? void 0 : o.original.lastPoint, U = h.map(
401
+ (ft) => j(ft, ct)
386
402
  );
387
- $ = g[V.indexOf(Math.min(...V))];
403
+ L = h[U.indexOf(Math.min(...U))];
388
404
  }
389
- const F = o.offset.splitAt([
390
- $
391
- ])[0], A = a.offset.splitAt([$]).at(-1);
392
- if (!A)
405
+ const x = o.offset.splitAt([
406
+ L
407
+ ])[0], v = a.offset.splitAt([L]).at(-1);
408
+ if (!v)
393
409
  throw new Error("Bug in the splitting algo in offset");
394
410
  c({
395
- offset: F,
411
+ offset: x,
396
412
  original: o.original
397
- }), o = { offset: A, original: a.original };
413
+ }), o = { offset: v, original: a.original };
398
414
  continue;
399
415
  }
400
- const l = o.original.lastPoint, L = Ft(
401
- E(d, l),
416
+ const l = o.original.lastPoint, A = yt(
417
+ E(m, l),
402
418
  E(u, l)
403
- ) > 0, gt = new v(u, d, l, L);
404
- c(o), r.push(gt), o = a;
419
+ ) > 0, at = new b(u, m, l, A);
420
+ c(o), r.push(at), o = a;
405
421
  }
406
422
  return o && c(o), r;
407
423
  }
408
- function ot(t) {
409
- const n = /* @__PURE__ */ new Map(), e = (i, r) => {
410
- const s = n.get(i) || [];
411
- n.set(i, [...s, ...r]);
424
+ function nt(t) {
425
+ const e = /* @__PURE__ */ new Map(), n = (s, r) => {
426
+ const i = e.get(s) || [];
427
+ e.set(s, [...i, ...r]);
412
428
  };
413
- return t.forEach((i, r) => {
414
- t.slice(r + 1).forEach((s, o) => {
415
- const { intersections: c, overlaps: f } = O(i, s, T), a = [
429
+ return t.forEach((s, r) => {
430
+ t.slice(r + 1).forEach((i, o) => {
431
+ const { intersections: c, overlaps: f } = B(s, i, T), a = [
416
432
  ...c,
417
433
  ...f.flatMap((u) => [u.firstPoint, u.lastPoint])
418
434
  ].filter((u) => {
419
- const d = I(u, i.firstPoint) || I(u, i.lastPoint), g = I(u, s.firstPoint) || I(u, s.lastPoint);
420
- return !(d && g);
435
+ const m = M(u, s.firstPoint) || M(u, s.lastPoint), h = M(u, i.firstPoint) || M(u, i.lastPoint);
436
+ return !(m && h);
421
437
  });
422
- a.length && (e(r, a), e(o + r + 1, a));
438
+ a.length && (n(r, a), n(o + r + 1, a));
423
439
  });
424
- }), n;
425
- }
426
- function at(t, n) {
427
- return n.flatMap((e, i) => {
428
- if (!t.has(i))
429
- return e;
430
- const r = t.get(i);
431
- return r ? e.splitAt(r) : e;
440
+ }), e;
441
+ }
442
+ function st(t, e) {
443
+ return e.flatMap((n, s) => {
444
+ if (!t.has(s))
445
+ return n;
446
+ const r = t.get(s);
447
+ return r ? n.splitAt(r) : n;
432
448
  });
433
449
  }
434
- function ct(t, n, e) {
435
- return t.filter((i) => !n.segments.some((s) => Zt(s, i) < Math.abs(e) - T));
450
+ function it(t, e, n) {
451
+ return t.filter((s) => !e.segments.some((i) => Wt(i, s) < Math.abs(n) - T));
436
452
  }
437
- function y(t, n) {
438
- const e = t.clockwise ? n : -n, i = x(t.segments, e);
439
- if (i.length < 2)
440
- return new h();
441
- const r = ot(i);
453
+ function F(t, e) {
454
+ const n = t.clockwise ? e : -e, s = R(t.segments, n);
455
+ if (s.length < 2)
456
+ return new g();
457
+ const r = nt(s);
442
458
  if (!r.size) {
443
- const a = new P(i);
444
- return new h([new p(a)]);
459
+ const a = new P(s);
460
+ return new g([new d(a)]);
445
461
  }
446
- const s = at(
462
+ const i = st(
447
463
  r,
448
- i
449
- ), o = ct(s, t, n);
464
+ s
465
+ ), o = it(i, t, e);
450
466
  if (!o.length)
451
- return new h();
452
- const f = tt(o).filter((a) => a.length > 1).filter((a) => I(a[0].firstPoint, a.at(-1).lastPoint)).map((a) => new P(a));
453
- return f.length ? new h(f.map((a) => new p(a))) : new h();
467
+ return new g();
468
+ const f = X(o).filter((a) => a.length > 1).filter((a) => M(a[0].firstPoint, a.at(-1).lastPoint)).map((a) => new P(a));
469
+ return f.length ? new g(f.map((a) => new d(a))) : new g();
454
470
  }
455
- function Jt(t, n, e = "round") {
456
- const i = n / 2, r = x(t.segments, i, !1), s = x(t.segments, -i, !1).map(
471
+ function Kt(t, e, n = "round") {
472
+ const s = e / 2, r = R(t.segments, s, !1), i = R(t.segments, -s, !1).map(
457
473
  (l) => l.reverse()
458
474
  );
459
- s.reverse();
460
- const o = (l, L) => e === "round" ? Ct(
475
+ i.reverse();
476
+ const o = (l, A) => n === "round" ? Et(
461
477
  l.lastPoint,
462
- L.firstPoint,
478
+ A.firstPoint,
463
479
  l.tangentAtLastPoint
464
- ) : new M(l.lastPoint, L.firstPoint), c = [
480
+ ) : new S(l.lastPoint, A.firstPoint), c = [
465
481
  ...r,
466
482
  o(
467
483
  r[r.length - 1],
468
- s[0]
484
+ i[0]
469
485
  ),
470
- ...s,
486
+ ...i,
471
487
  o(
472
- s[s.length - 1],
488
+ i[i.length - 1],
473
489
  r[0]
474
490
  )
475
- ], f = ot(c);
491
+ ], f = nt(c);
476
492
  if (!f.size) {
477
493
  const l = new P(c);
478
- return new h([new p(l)]);
494
+ return new g([new d(l)]);
479
495
  }
480
- const a = at(
496
+ const a = st(
481
497
  f,
482
498
  c
483
- ), u = ct(a, t, i);
499
+ ), u = it(a, t, s);
484
500
  if (!u.length)
485
- return new h();
486
- const g = tt(u).filter((l) => l.length > 1).filter((l) => I(l[0].firstPoint, l.at(-1).lastPoint)).map((l) => new P(l));
487
- return g.length ? new h(g.map((l) => new p(l))) : new h();
488
- }
489
- function Ht(t, n) {
490
- const e = t.map((i) => {
491
- const r = b(
492
- i.holes.map((s) => y(s, n))
501
+ return new g();
502
+ const h = X(u).filter((l) => l.length > 1).filter((l) => M(l[0].firstPoint, l.at(-1).lastPoint)).map((l) => new P(l));
503
+ return h.length ? new g(h.map((l) => new d(l))) : new g();
504
+ }
505
+ function Xt(t, e) {
506
+ const n = t.map((s) => {
507
+ const r = y(
508
+ s.holes.map((i) => F(i, e))
493
509
  );
494
- return rt(y(i.contour, n), r);
510
+ return et(F(s.contour, e), r);
495
511
  });
496
- return b(e);
512
+ return y(n);
497
513
  }
498
- function Wt(t, n) {
499
- const e = Math.abs(n / 2), i = t.map(
500
- (r) => b(
501
- r.allLoops.map((s) => rt(y(s, e), y(s, -e)))
514
+ function Yt(t, e) {
515
+ const n = Math.abs(e / 2), s = t.map(
516
+ (r) => y(
517
+ r.allLoops.map((i) => et(F(i, n), F(i, -n)))
502
518
  )
503
519
  );
504
- return b(i);
505
- }
506
- function an(t, n) {
507
- return Ht(S(t), n);
508
- }
509
- function cn(t, n, { endCap: e = "round" } = {}) {
510
- return t instanceof C ? Jt(t, n, e) : Wt(S(t), n);
511
- }
512
- function w([t, n]) {
513
- return `${t} ${n}`;
514
- }
515
- function U(t) {
516
- if (t instanceof M)
517
- return `L ${w(t.lastPoint)}`;
518
- if (t instanceof v)
519
- return `A ${t.radius} ${t.radius} 0 ${t.angularLength > Math.PI ? "1" : "0"} ${t.clockwise ? "0" : "1"} ${w(t.lastPoint)}`;
520
- if (t instanceof nt)
521
- return `A ${t.majorRadius} ${t.minorRadius} ${t.tiltAngle * Dt} ${t.deltaAngle > Math.PI ? "1" : "0"} ${t.clockwise ? "0" : "1"} ${w(t.lastPoint)}`;
522
- if (t instanceof et)
523
- return `Q ${[
524
- w(t.controlPoint),
525
- w(t.lastPoint)
526
- ].join(" ")}`;
527
- if (t instanceof it)
528
- return `C ${[
529
- w(t.firstControlPoint),
530
- w(t.lastControlPoint),
531
- w(t.lastPoint)
532
- ].join(" ")}`;
533
- throw new Error("Unknown segment type");
520
+ return y(s);
534
521
  }
535
- function ft(t) {
536
- const n = `M ${t.firstPoint.join(" ")}`, e = t.segments.map(U).join(" ");
537
- return `${n} ${e} Z`;
538
- }
539
- function lt(t) {
540
- return `<path d="${t.allLoops.map(ft).join(" ")}" />`;
541
- }
542
- function Xt(t) {
543
- return `<g>
544
- ${t.figures.map(lt).join(`
545
- `)}
546
- </g>`;
547
- }
548
- function Yt(t) {
549
- const n = `M ${t.firstPoint.join(" ")}`, e = t.segments.map(U).join(" ");
550
- return `${n} ${e}`;
551
- }
552
- function Kt(t, n = 1) {
553
- const e = t.xMin - n, i = t.yMin - n;
554
- return `${e} ${i} ${t.width + 2 * n} ${t.height + 2 * n}`;
555
- }
556
- function Z(t, n, e = 1, i) {
557
- const r = Kt(n, e), s = i ? `width="${n.width + 2 * e}${i}" height="${n.height + 2 * e}${i}"` : "";
558
- return `<?xml version="1.0" encoding="UTF-8" standalone="no"?>
559
- <svg version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox="${r}" fill="none" stroke="black" stroke-width="0.2%" vector-effect="non-scaling-stroke" ${s}>
560
- ${t}
561
- </svg>`;
562
- }
563
- function J(t) {
564
- if (t instanceof h)
565
- return Xt(t);
566
- if (t instanceof p)
567
- return lt(t);
522
+ function fe(t, e) {
523
+ return Xt(I(t), e);
524
+ }
525
+ function le(t, e, { endCap: n = "round" } = {}) {
526
+ return t instanceof C ? Kt(t, e, n) : Yt(I(t), e);
527
+ }
528
+ function Q(t) {
529
+ if (t instanceof g)
530
+ return Rt(t);
531
+ if (t instanceof d)
532
+ return Ot(t);
568
533
  if (t instanceof P)
569
- return `<path d="${ft(t)}" />`;
534
+ return `<path d="${Bt(t)}" />`;
570
535
  if (t instanceof C)
571
- return `<path d="${Yt(t)}" />`;
572
- if (xt(t))
573
- return `<path d="${`M ${t.firstPoint.join(" ")}`} ${U(
536
+ return `<path d="${$t(t)}" />`;
537
+ if (It(t))
538
+ return `<path d="${`M ${t.firstPoint.join(" ")}`} ${Gt(
574
539
  t
575
540
  )}" />`;
576
541
  throw new Error("Unknown shape type");
577
542
  }
578
- const H = (t) => "shape" in t ? t.shape : t, W = (t, n) => {
543
+ const Z = (t) => "shape" in t ? t.shape : t, H = (t, e) => {
579
544
  if (!("shape" in t))
580
- return n;
581
- const { color: e } = t;
582
- return e ? `<g stroke="${e}">${n}</g>` : n;
583
- }, X = (t) => new Rt(t.xMin, -t.yMax, t.xMax, -t.yMin);
584
- function fn(t, {
585
- margin: n = 1,
586
- unit: e = null,
587
- viewBox: i
545
+ return e;
546
+ const { color: n } = t;
547
+ return n ? `<g stroke="${n}">${e}</g>` : e;
548
+ }, W = (t) => new Ft(t.xMin, -t.yMax, t.xMax, -t.yMin);
549
+ function ue(t, {
550
+ margin: e = 1,
551
+ unit: n = null,
552
+ viewBox: s
588
553
  } = {}) {
589
554
  if (Array.isArray(t)) {
590
- const s = t.map((f) => H(f).mirror()), o = s.map((f, a) => W(t[a], J(f))).join(`
591
- `), c = s.slice(1).reduce((f, a) => f.merge(a.boundingBox), s[0].boundingBox);
592
- return Z(o, i ? X(i) : c, n, e);
555
+ const i = t.map((f) => Z(f).mirror()), o = i.map((f, a) => H(t[a], Q(f))).join(`
556
+ `), c = i.slice(1).reduce((f, a) => f.merge(a.boundingBox), i[0].boundingBox);
557
+ return z(o, s ? W(s) : c, e, n);
593
558
  }
594
- const r = H(t).mirror();
595
- return Z(
596
- W(t, J(r)),
597
- i ? X(i) : r.boundingBox,
598
- n,
599
- e
559
+ const r = Z(t).mirror();
560
+ return z(
561
+ H(t, Q(r)),
562
+ s ? W(s) : r.boundingBox,
563
+ e,
564
+ n
600
565
  );
601
566
  }
602
- const ut = (t) => {
567
+ const rt = (t) => {
603
568
  if (t.type === "LINE")
604
- return new M(t.firstPoint, t.lastPoint);
569
+ return new S(t.firstPoint, t.lastPoint);
605
570
  if (t.type === "ARC")
606
- return new v(
571
+ return new b(
607
572
  t.firstPoint,
608
573
  t.lastPoint,
609
574
  t.center,
610
575
  t.clockwise
611
576
  );
612
577
  if (t.type === "ELLIPSE_ARC")
613
- return new nt(
578
+ return new Ct(
614
579
  t.firstPoint,
615
580
  t.lastPoint,
616
581
  t.center,
@@ -621,66 +586,66 @@ const ut = (t) => {
621
586
  { angleUnits: "rad" }
622
587
  );
623
588
  if (t.type === "QUADRATIC_BEZIER")
624
- return new et(
589
+ return new xt(
625
590
  t.firstPoint,
626
591
  t.lastPoint,
627
592
  t.controlPoint
628
593
  );
629
594
  if (t.type === "CUBIC_BEZIER")
630
- return new it(
595
+ return new Dt(
631
596
  t.firstPoint,
632
597
  t.lastPoint,
633
598
  t.firstControlPoint,
634
599
  t.lastControlPoint
635
600
  );
636
601
  throw new Error("Unknown segment type");
637
- }, R = (t) => {
638
- const n = t.segments.map(ut);
639
- return new P(n);
640
- }, ht = (t) => {
641
- const n = R(t.contour), e = t.holes.map(R);
642
- return new p(n, e);
602
+ }, O = (t) => {
603
+ const e = t.segments.map(rt);
604
+ return new P(e);
605
+ }, ot = (t) => {
606
+ const e = O(t.contour), n = t.holes.map(O);
607
+ return new d(e, n);
643
608
  }, jt = (t) => {
644
- const n = t.figures.map(ht);
645
- return new h(n);
609
+ const e = t.figures.map(ot);
610
+ return new g(e);
646
611
  };
647
- function ln(t) {
612
+ function ge(t) {
648
613
  if (t.type === "DIAGRAM")
649
614
  return jt(t);
650
615
  if (t.type === "FIGURE")
651
- return ht(t);
616
+ return ot(t);
652
617
  if (t.type === "LOOP")
653
- return R(t);
618
+ return O(t);
654
619
  if (t.type === "LINE" || t.type === "ARC" || t.type === "ELLIPSE_ARC" || t.type === "CUBIC_BEZIER")
655
- return ut(t);
620
+ return rt(t);
656
621
  throw new Error("Unknown shape type");
657
622
  }
658
- const Y = Math.PI / 180, tn = 180 / Math.PI;
659
- function un(t, n) {
660
- const e = Math.cos(n * Y) * t, i = Math.sin(n * Y) * t;
661
- return [e, i];
623
+ const K = Math.PI / 180, te = 180 / Math.PI;
624
+ function he(t, e) {
625
+ const n = Math.cos(e * K) * t, s = Math.sin(e * K) * t;
626
+ return [n, s];
662
627
  }
663
- function hn([t, n]) {
664
- const e = Math.sqrt(t * t + n * n), i = Math.atan2(n, t) * tn;
665
- return [e, i];
628
+ function pe([t, e]) {
629
+ const n = Math.sqrt(t * t + e * e), s = Math.atan2(e, t) * te;
630
+ return [n, s];
666
631
  }
667
632
  export {
668
- Y as DEG2RAD,
669
- tn as RAD2DEG,
670
- hn as cartesianToPolar,
671
- on as confineStrand,
672
- rt as cut,
673
- dn as draw,
674
- rn as eraseStrand,
675
- wn as exportJSON,
676
- fn as exportSVG,
677
- Ot as fuse,
678
- b as fuseAll,
679
- ln as importJSON,
680
- sn as intersect,
681
- an as offset,
682
- cn as outlineStroke,
683
- un as polarToCartesian,
684
- J as svgBody
633
+ K as DEG2RAD,
634
+ te as RAD2DEG,
635
+ pe as cartesianToPolar,
636
+ ce as confineStrand,
637
+ et as cut,
638
+ Pe as draw,
639
+ ae as eraseStrand,
640
+ Me as exportJSON,
641
+ ue as exportSVG,
642
+ Tt as fuse,
643
+ y as fuseAll,
644
+ ge as importJSON,
645
+ oe as intersect,
646
+ fe as offset,
647
+ le as outlineStroke,
648
+ he as polarToCartesian,
649
+ Q as svgBody
685
650
  };
686
651
  //# sourceMappingURL=pantograph.js.map