@multiplatform.one/node-graph 8.2.2 → 8.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.
- package/dist/cjs/NodeGraph.native.js.map +1 -1
- package/dist/cjs/bench/frameSampler.native.js.map +1 -1
- package/dist/cjs/bench/generateGraph.native.js.map +1 -1
- package/dist/cjs/diagnostics/GraphDiagnostics.native.js.map +1 -1
- package/dist/cjs/diagnostics/LiveGraphDiagnostics.native.js.map +1 -1
- package/dist/cjs/diagnostics/fromWire.native.js.map +1 -1
- package/dist/cjs/diagnostics/lastError.native.js.map +1 -1
- package/dist/cjs/diagnostics/types.native.js.map +1 -1
- package/dist/cjs/diagnostics/useGraphDiagnostics.native.js.map +1 -1
- package/dist/cjs/dom/GraphDomLayout.native.js.map +1 -1
- package/dist/cjs/dom/boot.native.js.map +1 -1
- package/dist/cjs/dom/wire.native.js.map +1 -1
- package/dist/cjs/edges/GraphEdge.cjs +21 -50
- package/dist/cjs/edges/GraphEdge.native.js +23 -50
- package/dist/cjs/edges/GraphEdge.native.js.map +1 -1
- package/dist/cjs/edges/edgeKinds.native.js.map +1 -1
- package/dist/cjs/edges/edgePath.cjs +94 -0
- package/dist/cjs/edges/edgePath.native.js +98 -0
- package/dist/cjs/edges/edgePath.native.js.map +1 -0
- package/dist/cjs/edges/edgeRoute.cjs +886 -0
- package/dist/cjs/edges/edgeRoute.native.js +1399 -0
- package/dist/cjs/edges/edgeRoute.native.js.map +1 -0
- package/dist/cjs/edges/edgeStyle.native.js.map +1 -1
- package/dist/cjs/edges/useEdgeObstacles.cjs +78 -0
- package/dist/cjs/edges/useEdgeObstacles.native.js +110 -0
- package/dist/cjs/edges/useEdgeObstacles.native.js.map +1 -0
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/interaction/lassoIntercept.native.js.map +1 -1
- package/dist/cjs/interaction/legalTargets.native.js.map +1 -1
- package/dist/cjs/interaction/snapAlignment.native.js.map +1 -1
- package/dist/cjs/interaction/snapChanges.native.js.map +1 -1
- package/dist/cjs/interaction/spatialHash.native.js.map +1 -1
- package/dist/cjs/interaction/useLassoSelect.native.js.map +1 -1
- package/dist/cjs/knobs/KnobEnvelopeProvider.native.js.map +1 -1
- package/dist/cjs/knobs/envelope.native.js.map +1 -1
- package/dist/cjs/knobs/graphKnobs.native.js.map +1 -1
- package/dist/cjs/knobs/useKnobEnvelope.native.js.map +1 -1
- package/dist/cjs/layout/dagre.native.js.map +1 -1
- package/dist/cjs/layout/layout.native.js.map +1 -1
- package/dist/cjs/layout/runner.native.js.map +1 -1
- package/dist/cjs/layout/structuredCloneShim.native.js.map +1 -1
- package/dist/cjs/layout/types.native.js.map +1 -1
- package/dist/cjs/layout/worker.entry.native.js.map +1 -1
- package/dist/cjs/layout/worker.generated.native.js.map +1 -1
- package/dist/cjs/model/commands.native.js.map +1 -1
- package/dist/cjs/model/connect.native.js.map +1 -1
- package/dist/cjs/model/document.native.js.map +1 -1
- package/dist/cjs/model/history.native.js.map +1 -1
- package/dist/cjs/model/index.native.js.map +1 -1
- package/dist/cjs/model/schema.native.js.map +1 -1
- package/dist/cjs/model/select.native.js.map +1 -1
- package/dist/cjs/model/serialize.native.js.map +1 -1
- package/dist/cjs/native/DomOnlyStory.native.js.map +1 -1
- package/dist/cjs/native/GraphToolbar.native.js.map +1 -1
- package/dist/cjs/native/domEntryRegistry.native.js.map +1 -1
- package/dist/cjs/native/graphChildren.native.js.map +1 -1
- package/dist/cjs/nodes/GraphNode.native.js.map +1 -1
- package/dist/cjs/nodes/GraphPort.native.js.map +1 -1
- package/dist/cjs/nodes/handleGeometry.native.js.map +1 -1
- package/dist/cjs/nodes/lod.native.js.map +1 -1
- package/dist/cjs/nodes/nodeMeasure.native.js.map +1 -1
- package/dist/cjs/nodes/overviewNode.native.js.map +1 -1
- package/dist/cjs/react-flow/ConnectionPuck.native.js.map +1 -1
- package/dist/cjs/react-flow/GraphActions.native.js.map +1 -1
- package/dist/cjs/react-flow/GraphCommandBridge.native.js.map +1 -1
- package/dist/cjs/react-flow/GraphNodeHost.native.js.map +1 -1
- package/dist/cjs/react-flow/GraphPaintProbe.native.js.map +1 -1
- package/dist/cjs/react-flow/GraphZoomVar.native.js.map +1 -1
- package/dist/cjs/react-flow/LassoOverlay.native.js.map +1 -1
- package/dist/cjs/react-flow/NodeGraphWeb.native.js.map +1 -1
- package/dist/cjs/react-flow/SnapGuides.native.js.map +1 -1
- package/dist/cjs/react-flow/demoControlBody.native.js.map +1 -1
- package/dist/cjs/react-flow/demoNodeBody.native.js.map +1 -1
- package/dist/cjs/react-flow/fixtures.native.js.map +1 -1
- package/dist/cjs/react-flow/flowAdapter.native.js.map +1 -1
- package/dist/cjs/react-flow/graphHandle.native.js.map +1 -1
- package/dist/cjs/react-flow/nodeCensus.native.js.map +1 -1
- package/dist/cjs/react-flow/useGraphController.native.js.map +1 -1
- package/dist/cjs/react-flow/xy.cjs +4 -3
- package/dist/cjs/react-flow/xy.native.js +4 -3
- package/dist/cjs/react-flow/xy.native.js.map +1 -1
- package/dist/cjs/react-flow/xyPaths.cjs +31 -0
- package/dist/cjs/react-flow/xyPaths.native.js +34 -0
- package/dist/cjs/react-flow/xyPaths.native.js.map +1 -0
- package/dist/cjs/theme/GraphFaces.native.js.map +1 -1
- package/dist/cjs/theme/GraphVarsStyle.native.js.map +1 -1
- package/dist/cjs/theme/faces.generated.native.js.map +1 -1
- package/dist/cjs/theme/faces.native.js.map +1 -1
- package/dist/cjs/theme/graphVars.native.js.map +1 -1
- package/dist/esm/edges/GraphEdge.mjs +23 -52
- package/dist/esm/edges/GraphEdge.mjs.map +1 -1
- package/dist/esm/edges/GraphEdge.native.js +25 -52
- package/dist/esm/edges/GraphEdge.native.js.map +1 -1
- package/dist/esm/edges/edgePath.mjs +68 -0
- package/dist/esm/edges/edgePath.mjs.map +1 -0
- package/dist/esm/edges/edgePath.native.js +69 -0
- package/dist/esm/edges/edgePath.native.js.map +1 -0
- package/dist/esm/edges/edgeRoute.mjs +857 -0
- package/dist/esm/edges/edgeRoute.mjs.map +1 -0
- package/dist/esm/edges/edgeRoute.native.js +1367 -0
- package/dist/esm/edges/edgeRoute.native.js.map +1 -0
- package/dist/esm/edges/useEdgeObstacles.mjs +52 -0
- package/dist/esm/edges/useEdgeObstacles.mjs.map +1 -0
- package/dist/esm/edges/useEdgeObstacles.native.js +81 -0
- package/dist/esm/edges/useEdgeObstacles.native.js.map +1 -0
- package/dist/esm/react-flow/xy.mjs +2 -1
- package/dist/esm/react-flow/xy.mjs.map +1 -1
- package/dist/esm/react-flow/xy.native.js +2 -1
- package/dist/esm/react-flow/xy.native.js.map +1 -1
- package/dist/esm/react-flow/xyPaths.mjs +3 -0
- package/dist/esm/react-flow/xyPaths.mjs.map +1 -0
- package/dist/esm/react-flow/xyPaths.native.js +3 -0
- package/dist/esm/react-flow/xyPaths.native.js.map +1 -0
- package/dist/jsx/edges/GraphEdge.mjs +23 -52
- package/dist/jsx/edges/GraphEdge.mjs.map +1 -1
- package/dist/jsx/edges/GraphEdge.native.js +23 -50
- package/dist/jsx/edges/GraphEdge.native.js.map +1 -1
- package/dist/jsx/edges/edgePath.mjs +68 -0
- package/dist/jsx/edges/edgePath.mjs.map +1 -0
- package/dist/jsx/edges/edgePath.native.js +98 -0
- package/dist/jsx/edges/edgePath.native.js.map +1 -0
- package/dist/jsx/edges/edgeRoute.mjs +857 -0
- package/dist/jsx/edges/edgeRoute.mjs.map +1 -0
- package/dist/jsx/edges/edgeRoute.native.js +1399 -0
- package/dist/jsx/edges/edgeRoute.native.js.map +1 -0
- package/dist/jsx/edges/useEdgeObstacles.mjs +52 -0
- package/dist/jsx/edges/useEdgeObstacles.mjs.map +1 -0
- package/dist/jsx/edges/useEdgeObstacles.native.js +110 -0
- package/dist/jsx/edges/useEdgeObstacles.native.js.map +1 -0
- package/dist/jsx/react-flow/xy.mjs +2 -1
- package/dist/jsx/react-flow/xy.mjs.map +1 -1
- package/dist/jsx/react-flow/xy.native.js +4 -3
- package/dist/jsx/react-flow/xy.native.js.map +1 -1
- package/dist/jsx/react-flow/xyPaths.mjs +3 -0
- package/dist/jsx/react-flow/xyPaths.mjs.map +1 -0
- package/dist/jsx/react-flow/xyPaths.native.js +34 -0
- package/dist/jsx/react-flow/xyPaths.native.js.map +1 -0
- package/package.json +6 -6
- package/src/edges/GraphEdge.tsx +18 -61
- package/src/edges/edgePath.ts +84 -0
- package/src/edges/edgeRoute.spec.ts +631 -0
- package/src/edges/edgeRoute.ts +980 -0
- package/src/edges/useEdgeObstacles.ts +71 -0
- package/src/react-flow/NodeGraphWeb.stories.tsx +80 -0
- package/src/react-flow/xy.ts +1 -3
- package/src/react-flow/xyPaths.ts +9 -0
- package/src/theme/graphVars.spec.ts +1 -0
- package/types/edges/GraphEdge.d.ts +1 -16
- package/types/edges/GraphEdge.d.ts.map +1 -1
- package/types/edges/edgePath.d.ts +25 -0
- package/types/edges/edgePath.d.ts.map +1 -0
- package/types/edges/edgeRoute.d.ts +77 -0
- package/types/edges/edgeRoute.d.ts.map +1 -0
- package/types/edges/useEdgeObstacles.d.ts +45 -0
- package/types/edges/useEdgeObstacles.d.ts.map +1 -0
- package/types/react-flow/xy.d.ts +2 -1
- package/types/react-flow/xy.d.ts.map +1 -1
- package/types/react-flow/xyPaths.d.ts +9 -0
- package/types/react-flow/xyPaths.d.ts.map +1 -0
|
@@ -0,0 +1,1367 @@
|
|
|
1
|
+
import { buildSpatialHash } from "../interaction/spatialHash.native.js";
|
|
2
|
+
function _class_call_check(instance, Constructor) {
|
|
3
|
+
if (!(instance instanceof Constructor)) {
|
|
4
|
+
throw new TypeError("Cannot call a class as a function");
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
function _defineProperties(target, props) {
|
|
8
|
+
for (var i = 0; i < props.length; i++) {
|
|
9
|
+
var descriptor = props[i];
|
|
10
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
11
|
+
descriptor.configurable = true;
|
|
12
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
13
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
17
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
18
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
19
|
+
return Constructor;
|
|
20
|
+
}
|
|
21
|
+
function _define_property(obj, key, value) {
|
|
22
|
+
if (key in obj) {
|
|
23
|
+
Object.defineProperty(obj, key, {
|
|
24
|
+
value,
|
|
25
|
+
enumerable: true,
|
|
26
|
+
configurable: true,
|
|
27
|
+
writable: true
|
|
28
|
+
});
|
|
29
|
+
} else {
|
|
30
|
+
obj[key] = value;
|
|
31
|
+
}
|
|
32
|
+
return obj;
|
|
33
|
+
}
|
|
34
|
+
function _type_of(obj) {
|
|
35
|
+
"@swc/helpers - typeof";
|
|
36
|
+
|
|
37
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
38
|
+
}
|
|
39
|
+
var edgeClearance = 8;
|
|
40
|
+
var directions = {
|
|
41
|
+
left: {
|
|
42
|
+
x: -1,
|
|
43
|
+
y: 0
|
|
44
|
+
},
|
|
45
|
+
right: {
|
|
46
|
+
x: 1,
|
|
47
|
+
y: 0
|
|
48
|
+
},
|
|
49
|
+
top: {
|
|
50
|
+
x: 0,
|
|
51
|
+
y: -1
|
|
52
|
+
},
|
|
53
|
+
bottom: {
|
|
54
|
+
x: 0,
|
|
55
|
+
y: 1
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
var cornerRadius = {
|
|
59
|
+
bezier: 24,
|
|
60
|
+
smoothstep: 5,
|
|
61
|
+
step: 0,
|
|
62
|
+
straight: 0
|
|
63
|
+
};
|
|
64
|
+
var indexes = /* @__PURE__ */new WeakMap();
|
|
65
|
+
function indexFor(boxes) {
|
|
66
|
+
var index = indexes.get(boxes);
|
|
67
|
+
if (!index) {
|
|
68
|
+
index = buildSpatialHash(boxes.map(function (box) {
|
|
69
|
+
return {
|
|
70
|
+
id: box.id,
|
|
71
|
+
rect: box
|
|
72
|
+
};
|
|
73
|
+
}));
|
|
74
|
+
indexes.set(boxes, index);
|
|
75
|
+
}
|
|
76
|
+
return index;
|
|
77
|
+
}
|
|
78
|
+
function boxesNear(obstacles, area) {
|
|
79
|
+
var byId = new Map(obstacles.boxes.map(function (box2) {
|
|
80
|
+
return [box2.id, box2];
|
|
81
|
+
}));
|
|
82
|
+
var found = [];
|
|
83
|
+
var _iteratorNormalCompletion = true,
|
|
84
|
+
_didIteratorError = false,
|
|
85
|
+
_iteratorError = void 0;
|
|
86
|
+
try {
|
|
87
|
+
for (var _iterator = indexFor(obstacles.boxes).query(area)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
88
|
+
var item = _step.value;
|
|
89
|
+
var box = byId.get(item.id);
|
|
90
|
+
if (box) found.push(box);
|
|
91
|
+
}
|
|
92
|
+
} catch (err) {
|
|
93
|
+
_didIteratorError = true;
|
|
94
|
+
_iteratorError = err;
|
|
95
|
+
} finally {
|
|
96
|
+
try {
|
|
97
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
98
|
+
_iterator.return();
|
|
99
|
+
}
|
|
100
|
+
} finally {
|
|
101
|
+
if (_didIteratorError) {
|
|
102
|
+
throw _iteratorError;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return found;
|
|
107
|
+
}
|
|
108
|
+
function tokens(d) {
|
|
109
|
+
var _d_match;
|
|
110
|
+
var raw = (_d_match = d.match(/[MLQCZ]|-?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?/gi)) !== null && _d_match !== void 0 ? _d_match : [];
|
|
111
|
+
return raw.map(function (token) {
|
|
112
|
+
return /^[MLQCZ]$/i.test(token) ? token.toUpperCase() : Number(token);
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
function samplePath(d) {
|
|
116
|
+
var list = tokens(d);
|
|
117
|
+
var points = [];
|
|
118
|
+
var at = {
|
|
119
|
+
x: 0,
|
|
120
|
+
y: 0
|
|
121
|
+
};
|
|
122
|
+
var command = "M";
|
|
123
|
+
var index = 0;
|
|
124
|
+
var take = function take2() {
|
|
125
|
+
var value = list[index];
|
|
126
|
+
index += 1;
|
|
127
|
+
return typeof value === "number" ? value : Number.NaN;
|
|
128
|
+
};
|
|
129
|
+
while (index < list.length) {
|
|
130
|
+
if (typeof list[index] === "string") {
|
|
131
|
+
command = list[index];
|
|
132
|
+
index += 1;
|
|
133
|
+
if (command === "Z") continue;
|
|
134
|
+
}
|
|
135
|
+
if (command === "M") {
|
|
136
|
+
at = {
|
|
137
|
+
x: take(),
|
|
138
|
+
y: take()
|
|
139
|
+
};
|
|
140
|
+
points.push(at);
|
|
141
|
+
command = "L";
|
|
142
|
+
} else if (command === "L") {
|
|
143
|
+
var to = {
|
|
144
|
+
x: take(),
|
|
145
|
+
y: take()
|
|
146
|
+
};
|
|
147
|
+
var steps = Math.max(1, Math.ceil(Math.hypot(to.x - at.x, to.y - at.y) / 4));
|
|
148
|
+
for (var step = 1; step <= steps; step += 1) {
|
|
149
|
+
var t = step / steps;
|
|
150
|
+
points.push({
|
|
151
|
+
x: at.x + (to.x - at.x) * t,
|
|
152
|
+
y: at.y + (to.y - at.y) * t
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
at = to;
|
|
156
|
+
} else if (command === "Q") {
|
|
157
|
+
var control = {
|
|
158
|
+
x: take(),
|
|
159
|
+
y: take()
|
|
160
|
+
};
|
|
161
|
+
var to1 = {
|
|
162
|
+
x: take(),
|
|
163
|
+
y: take()
|
|
164
|
+
};
|
|
165
|
+
for (var step1 = 1; step1 <= 8; step1 += 1) {
|
|
166
|
+
var t1 = step1 / 8;
|
|
167
|
+
var u = 1 - t1;
|
|
168
|
+
points.push({
|
|
169
|
+
x: u * u * at.x + 2 * u * t1 * control.x + t1 * t1 * to1.x,
|
|
170
|
+
y: u * u * at.y + 2 * u * t1 * control.y + t1 * t1 * to1.y
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
at = to1;
|
|
174
|
+
} else if (command === "C") {
|
|
175
|
+
var first = {
|
|
176
|
+
x: take(),
|
|
177
|
+
y: take()
|
|
178
|
+
};
|
|
179
|
+
var second = {
|
|
180
|
+
x: take(),
|
|
181
|
+
y: take()
|
|
182
|
+
};
|
|
183
|
+
var to2 = {
|
|
184
|
+
x: take(),
|
|
185
|
+
y: take()
|
|
186
|
+
};
|
|
187
|
+
var steps1 = Math.max(16, Math.ceil(Math.hypot(to2.x - at.x, to2.y - at.y) / 4));
|
|
188
|
+
for (var step2 = 1; step2 <= steps1; step2 += 1) {
|
|
189
|
+
var t2 = step2 / steps1;
|
|
190
|
+
var u1 = 1 - t2;
|
|
191
|
+
points.push({
|
|
192
|
+
x: u1 * u1 * u1 * at.x + 3 * u1 * u1 * t2 * first.x + 3 * u1 * t2 * t2 * second.x + t2 * t2 * t2 * to2.x,
|
|
193
|
+
y: u1 * u1 * u1 * at.y + 3 * u1 * u1 * t2 * first.y + 3 * u1 * t2 * t2 * second.y + t2 * t2 * t2 * to2.y
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
at = to2;
|
|
197
|
+
} else {
|
|
198
|
+
return points;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
return points;
|
|
202
|
+
}
|
|
203
|
+
function distanceToBox(point, box) {
|
|
204
|
+
var dx = Math.max(box.x - point.x, 0, point.x - (box.x + box.width));
|
|
205
|
+
var dy = Math.max(box.y - point.y, 0, point.y - (box.y + box.height));
|
|
206
|
+
return Math.hypot(dx, dy);
|
|
207
|
+
}
|
|
208
|
+
function ownBox(point, boxes) {
|
|
209
|
+
var best;
|
|
210
|
+
var bestDistance = 0.5;
|
|
211
|
+
var _iteratorNormalCompletion = true,
|
|
212
|
+
_didIteratorError = false,
|
|
213
|
+
_iteratorError = void 0;
|
|
214
|
+
try {
|
|
215
|
+
for (var _iterator = boxes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
216
|
+
var box = _step.value;
|
|
217
|
+
var distance = distanceToBox(point, box);
|
|
218
|
+
if (distance <= bestDistance) {
|
|
219
|
+
best = box;
|
|
220
|
+
bestDistance = distance;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
} catch (err) {
|
|
224
|
+
_didIteratorError = true;
|
|
225
|
+
_iteratorError = err;
|
|
226
|
+
} finally {
|
|
227
|
+
try {
|
|
228
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
229
|
+
_iterator.return();
|
|
230
|
+
}
|
|
231
|
+
} finally {
|
|
232
|
+
if (_didIteratorError) {
|
|
233
|
+
throw _iteratorError;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
return best;
|
|
238
|
+
}
|
|
239
|
+
function depth(point, side, box) {
|
|
240
|
+
if (!box) return 0;
|
|
241
|
+
switch (side) {
|
|
242
|
+
case "right":
|
|
243
|
+
return Math.max(0, box.x + box.width - point.x);
|
|
244
|
+
case "left":
|
|
245
|
+
return Math.max(0, point.x - box.x);
|
|
246
|
+
case "bottom":
|
|
247
|
+
return Math.max(0, box.y + box.height - point.y);
|
|
248
|
+
case "top":
|
|
249
|
+
return Math.max(0, point.y - box.y);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
function bounds(points, pad) {
|
|
253
|
+
var minX = Infinity;
|
|
254
|
+
var minY = Infinity;
|
|
255
|
+
var maxX = -Infinity;
|
|
256
|
+
var maxY = -Infinity;
|
|
257
|
+
var _iteratorNormalCompletion = true,
|
|
258
|
+
_didIteratorError = false,
|
|
259
|
+
_iteratorError = void 0;
|
|
260
|
+
try {
|
|
261
|
+
for (var _iterator = points[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
262
|
+
var point = _step.value;
|
|
263
|
+
minX = Math.min(minX, point.x);
|
|
264
|
+
minY = Math.min(minY, point.y);
|
|
265
|
+
maxX = Math.max(maxX, point.x);
|
|
266
|
+
maxY = Math.max(maxY, point.y);
|
|
267
|
+
}
|
|
268
|
+
} catch (err) {
|
|
269
|
+
_didIteratorError = true;
|
|
270
|
+
_iteratorError = err;
|
|
271
|
+
} finally {
|
|
272
|
+
try {
|
|
273
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
274
|
+
_iterator.return();
|
|
275
|
+
}
|
|
276
|
+
} finally {
|
|
277
|
+
if (_didIteratorError) {
|
|
278
|
+
throw _iteratorError;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
return {
|
|
283
|
+
x: minX - pad,
|
|
284
|
+
y: minY - pad,
|
|
285
|
+
width: maxX - minX + pad * 2,
|
|
286
|
+
height: maxY - minY + pad * 2
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
function pathIntrudes(d, ends, obstacles) {
|
|
290
|
+
var {
|
|
291
|
+
clearance
|
|
292
|
+
} = obstacles;
|
|
293
|
+
var from = {
|
|
294
|
+
x: ends.sourceX,
|
|
295
|
+
y: ends.sourceY
|
|
296
|
+
};
|
|
297
|
+
var to = {
|
|
298
|
+
x: ends.targetX,
|
|
299
|
+
y: ends.targetY
|
|
300
|
+
};
|
|
301
|
+
var points = samplePath(d);
|
|
302
|
+
if (points.length === 0) return false;
|
|
303
|
+
var near = boxesNear(obstacles, bounds(points, clearance));
|
|
304
|
+
var fromStub = depth(from, ends.sourceSide, ownBox(from, near)) + clearance;
|
|
305
|
+
var toStub = depth(to, ends.targetSide, ownBox(to, near)) + clearance;
|
|
306
|
+
var _iteratorNormalCompletion = true,
|
|
307
|
+
_didIteratorError = false,
|
|
308
|
+
_iteratorError = void 0;
|
|
309
|
+
try {
|
|
310
|
+
for (var _iterator = points[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
311
|
+
var point = _step.value;
|
|
312
|
+
if (Math.hypot(point.x - from.x, point.y - from.y) <= fromStub) continue;
|
|
313
|
+
if (Math.hypot(point.x - to.x, point.y - to.y) <= toStub) continue;
|
|
314
|
+
var _iteratorNormalCompletion1 = true,
|
|
315
|
+
_didIteratorError1 = false,
|
|
316
|
+
_iteratorError1 = void 0;
|
|
317
|
+
try {
|
|
318
|
+
for (var _iterator1 = near[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) {
|
|
319
|
+
var box = _step1.value;
|
|
320
|
+
if (distanceToBox(point, box) < clearance - 0.25) return true;
|
|
321
|
+
}
|
|
322
|
+
} catch (err) {
|
|
323
|
+
_didIteratorError1 = true;
|
|
324
|
+
_iteratorError1 = err;
|
|
325
|
+
} finally {
|
|
326
|
+
try {
|
|
327
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
328
|
+
_iterator1.return();
|
|
329
|
+
}
|
|
330
|
+
} finally {
|
|
331
|
+
if (_didIteratorError1) {
|
|
332
|
+
throw _iteratorError1;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
} catch (err) {
|
|
338
|
+
_didIteratorError = true;
|
|
339
|
+
_iteratorError = err;
|
|
340
|
+
} finally {
|
|
341
|
+
try {
|
|
342
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
343
|
+
_iterator.return();
|
|
344
|
+
}
|
|
345
|
+
} finally {
|
|
346
|
+
if (_didIteratorError) {
|
|
347
|
+
throw _iteratorError;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
return false;
|
|
352
|
+
}
|
|
353
|
+
function inflate(box, by) {
|
|
354
|
+
return {
|
|
355
|
+
left: box.x - by,
|
|
356
|
+
right: box.x + box.width + by,
|
|
357
|
+
top: box.y - by,
|
|
358
|
+
bottom: box.y + box.height + by
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
function strictlyInside(x, y, rect) {
|
|
362
|
+
return x > rect.left && x < rect.right && y > rect.top && y < rect.bottom;
|
|
363
|
+
}
|
|
364
|
+
function lines(values) {
|
|
365
|
+
var sorted = [...new Set(values.map(function (value) {
|
|
366
|
+
return Math.round(value * 1e3) / 1e3;
|
|
367
|
+
}))].sort(function (a, b) {
|
|
368
|
+
return a - b;
|
|
369
|
+
});
|
|
370
|
+
var out = [];
|
|
371
|
+
for (var index = 0; index < sorted.length; index += 1) {
|
|
372
|
+
out.push(sorted[index]);
|
|
373
|
+
var next = sorted[index + 1];
|
|
374
|
+
if (next !== void 0 && next - sorted[index] > 1) out.push((sorted[index] + next) / 2);
|
|
375
|
+
}
|
|
376
|
+
return out;
|
|
377
|
+
}
|
|
378
|
+
function stubEnd(point, side, box, clearance) {
|
|
379
|
+
var reach = depth(point, side, box) + clearance;
|
|
380
|
+
var dir = directions[side];
|
|
381
|
+
return {
|
|
382
|
+
x: point.x + dir.x * reach,
|
|
383
|
+
y: point.y + dir.y * reach
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
var Heap = /* @__PURE__ */function () {
|
|
387
|
+
"use strict";
|
|
388
|
+
|
|
389
|
+
function Heap2() {
|
|
390
|
+
_class_call_check(this, Heap2);
|
|
391
|
+
_define_property(this, "items", []);
|
|
392
|
+
}
|
|
393
|
+
_create_class(Heap2, [{
|
|
394
|
+
key: "size",
|
|
395
|
+
get: function get() {
|
|
396
|
+
return this.items.length;
|
|
397
|
+
}
|
|
398
|
+
}, {
|
|
399
|
+
key: "push",
|
|
400
|
+
value: function push(key, cost) {
|
|
401
|
+
var items = this.items;
|
|
402
|
+
items.push({
|
|
403
|
+
key,
|
|
404
|
+
cost
|
|
405
|
+
});
|
|
406
|
+
var index = items.length - 1;
|
|
407
|
+
while (index > 0) {
|
|
408
|
+
var parent = index - 1 >> 1;
|
|
409
|
+
if (items[parent].cost <= items[index].cost) break;
|
|
410
|
+
[items[parent], items[index]] = [items[index], items[parent]];
|
|
411
|
+
index = parent;
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
}, {
|
|
415
|
+
key: "pop",
|
|
416
|
+
value: function pop() {
|
|
417
|
+
var items = this.items;
|
|
418
|
+
var top = items[0];
|
|
419
|
+
var last = items.pop();
|
|
420
|
+
if (items.length > 0 && last) {
|
|
421
|
+
items[0] = last;
|
|
422
|
+
var index = 0;
|
|
423
|
+
for (;;) {
|
|
424
|
+
var left = index * 2 + 1;
|
|
425
|
+
var right = left + 1;
|
|
426
|
+
var smallest = index;
|
|
427
|
+
if (left < items.length && items[left].cost < items[smallest].cost) smallest = left;
|
|
428
|
+
if (right < items.length && items[right].cost < items[smallest].cost) smallest = right;
|
|
429
|
+
if (smallest === index) break;
|
|
430
|
+
[items[smallest], items[index]] = [items[index], items[smallest]];
|
|
431
|
+
index = smallest;
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
return top;
|
|
435
|
+
}
|
|
436
|
+
}]);
|
|
437
|
+
return Heap2;
|
|
438
|
+
}();
|
|
439
|
+
var stepX = [1, 0, -1, 0];
|
|
440
|
+
var stepY = [0, 1, 0, -1];
|
|
441
|
+
function directionIndex(side) {
|
|
442
|
+
var dir = directions[side];
|
|
443
|
+
return stepX.findIndex(function (dx, index) {
|
|
444
|
+
return dx === dir.x && stepY[index] === dir.y;
|
|
445
|
+
});
|
|
446
|
+
}
|
|
447
|
+
function orthogonalRoute(start, startDirection, goal, goalDirection, boxes, clearance, area) {
|
|
448
|
+
var rects = boxes.map(function (box) {
|
|
449
|
+
return inflate(box, clearance);
|
|
450
|
+
});
|
|
451
|
+
var xs = lines([start.x, goal.x, area.x, area.x + area.width, ...rects.flatMap(function (r) {
|
|
452
|
+
return [r.left, r.right];
|
|
453
|
+
})]);
|
|
454
|
+
var ys = lines([start.y, goal.y, area.y, area.y + area.height, ...rects.flatMap(function (r) {
|
|
455
|
+
return [r.top, r.bottom];
|
|
456
|
+
})]);
|
|
457
|
+
var columns = xs.length;
|
|
458
|
+
var rows = ys.length;
|
|
459
|
+
var startX = xs.indexOf(Math.round(start.x * 1e3) / 1e3);
|
|
460
|
+
var startY = ys.indexOf(Math.round(start.y * 1e3) / 1e3);
|
|
461
|
+
var goalX = xs.indexOf(Math.round(goal.x * 1e3) / 1e3);
|
|
462
|
+
var goalY = ys.indexOf(Math.round(goal.y * 1e3) / 1e3);
|
|
463
|
+
if (startX < 0 || startY < 0 || goalX < 0 || goalY < 0) return null;
|
|
464
|
+
var free = function free2(ix2, iy2) {
|
|
465
|
+
return rects.every(function (rect) {
|
|
466
|
+
return !strictlyInside(xs[ix2], ys[iy2], rect);
|
|
467
|
+
});
|
|
468
|
+
};
|
|
469
|
+
var open = function open2(ax, ay, bx, by) {
|
|
470
|
+
var minX = Math.min(xs[ax], xs[bx]);
|
|
471
|
+
var maxX = Math.max(xs[ax], xs[bx]);
|
|
472
|
+
var minY = Math.min(ys[ay], ys[by]);
|
|
473
|
+
var maxY = Math.max(ys[ay], ys[by]);
|
|
474
|
+
return rects.every(function (rect) {
|
|
475
|
+
if (minY === maxY) return !(minY > rect.top && minY < rect.bottom && maxX > rect.left && minX < rect.right);
|
|
476
|
+
return !(minX > rect.left && minX < rect.right && maxY > rect.top && minY < rect.bottom);
|
|
477
|
+
});
|
|
478
|
+
};
|
|
479
|
+
if (!free(startX, startY) || !free(goalX, goalY)) return null;
|
|
480
|
+
var turn = clearance * 4;
|
|
481
|
+
var key = function key2(ix2, iy2, dir2) {
|
|
482
|
+
return (iy2 * columns + ix2) * 4 + dir2;
|
|
483
|
+
};
|
|
484
|
+
var best = /* @__PURE__ */new Map();
|
|
485
|
+
var from = /* @__PURE__ */new Map();
|
|
486
|
+
var heap = new Heap();
|
|
487
|
+
var heuristic = function heuristic2(ix2, iy2) {
|
|
488
|
+
return Math.abs(xs[ix2] - goal.x) + Math.abs(ys[iy2] - goal.y);
|
|
489
|
+
};
|
|
490
|
+
var first = key(startX, startY, startDirection);
|
|
491
|
+
best.set(first, 0);
|
|
492
|
+
heap.push(first, heuristic(startX, startY));
|
|
493
|
+
var reached;
|
|
494
|
+
var budget = 2e5;
|
|
495
|
+
while (heap.size > 0 && budget > 0) {
|
|
496
|
+
var _best_get;
|
|
497
|
+
budget -= 1;
|
|
498
|
+
var current = heap.pop();
|
|
499
|
+
if (!current) break;
|
|
500
|
+
var dir = current.key % 4;
|
|
501
|
+
var cell = (current.key - dir) / 4;
|
|
502
|
+
var ix = cell % columns;
|
|
503
|
+
var iy = (cell - ix) / columns;
|
|
504
|
+
var cost = (_best_get = best.get(current.key)) !== null && _best_get !== void 0 ? _best_get : Infinity;
|
|
505
|
+
if (current.cost - heuristic(ix, iy) > cost + 1e-6) continue;
|
|
506
|
+
if (ix === goalX && iy === goalY) {
|
|
507
|
+
reached = current.key;
|
|
508
|
+
break;
|
|
509
|
+
}
|
|
510
|
+
for (var next = 0; next < 4; next += 1) {
|
|
511
|
+
var _best_get1;
|
|
512
|
+
if (next === (dir + 2) % 4) continue;
|
|
513
|
+
var nx = ix + stepX[next];
|
|
514
|
+
var ny = iy + stepY[next];
|
|
515
|
+
if (nx < 0 || ny < 0 || nx >= columns || ny >= rows) continue;
|
|
516
|
+
if (!free(nx, ny) || !open(ix, iy, nx, ny)) continue;
|
|
517
|
+
var atGoal = nx === goalX && ny === goalY;
|
|
518
|
+
var length = Math.abs(xs[nx] - xs[ix]) + Math.abs(ys[ny] - ys[iy]);
|
|
519
|
+
var bend = (next === dir ? 0 : turn) + (atGoal && next !== goalDirection ? turn : 0);
|
|
520
|
+
var nextKey = key(nx, ny, next);
|
|
521
|
+
var nextCost = cost + length + bend;
|
|
522
|
+
if (nextCost < ((_best_get1 = best.get(nextKey)) !== null && _best_get1 !== void 0 ? _best_get1 : Infinity)) {
|
|
523
|
+
best.set(nextKey, nextCost);
|
|
524
|
+
from.set(nextKey, current.key);
|
|
525
|
+
heap.push(nextKey, nextCost + heuristic(nx, ny));
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
if (reached === void 0) return null;
|
|
530
|
+
var route = [];
|
|
531
|
+
for (var at = reached; at !== void 0; at = from.get(at)) {
|
|
532
|
+
var cell1 = (at - at % 4) / 4;
|
|
533
|
+
var ix1 = cell1 % columns;
|
|
534
|
+
route.push({
|
|
535
|
+
x: xs[ix1],
|
|
536
|
+
y: ys[(cell1 - ix1) / columns]
|
|
537
|
+
});
|
|
538
|
+
}
|
|
539
|
+
return route.reverse();
|
|
540
|
+
}
|
|
541
|
+
function simplify(points) {
|
|
542
|
+
var out = [];
|
|
543
|
+
var _iteratorNormalCompletion = true,
|
|
544
|
+
_didIteratorError = false,
|
|
545
|
+
_iteratorError = void 0;
|
|
546
|
+
try {
|
|
547
|
+
for (var _iterator = points[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
548
|
+
var point = _step.value;
|
|
549
|
+
var last = out[out.length - 1];
|
|
550
|
+
if (last && Math.abs(last.x - point.x) < 1e-6 && Math.abs(last.y - point.y) < 1e-6) continue;
|
|
551
|
+
var before = out[out.length - 2];
|
|
552
|
+
if (before && last) {
|
|
553
|
+
var sameX = Math.abs(before.x - last.x) < 1e-6 && Math.abs(last.x - point.x) < 1e-6;
|
|
554
|
+
var sameY = Math.abs(before.y - last.y) < 1e-6 && Math.abs(last.y - point.y) < 1e-6;
|
|
555
|
+
if (sameX || sameY) out.pop();
|
|
556
|
+
}
|
|
557
|
+
out.push(point);
|
|
558
|
+
}
|
|
559
|
+
} catch (err) {
|
|
560
|
+
_didIteratorError = true;
|
|
561
|
+
_iteratorError = err;
|
|
562
|
+
} finally {
|
|
563
|
+
try {
|
|
564
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
565
|
+
_iterator.return();
|
|
566
|
+
}
|
|
567
|
+
} finally {
|
|
568
|
+
if (_didIteratorError) {
|
|
569
|
+
throw _iteratorError;
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
return out;
|
|
574
|
+
}
|
|
575
|
+
function format(value) {
|
|
576
|
+
return String(Math.round(value * 1e3) / 1e3);
|
|
577
|
+
}
|
|
578
|
+
function roundCorner(points, index, radius) {
|
|
579
|
+
var before = points[index - 1];
|
|
580
|
+
var corner = points[index];
|
|
581
|
+
var after = points[index + 1];
|
|
582
|
+
var inLength = Math.hypot(corner.x - before.x, corner.y - before.y);
|
|
583
|
+
var outLength = Math.hypot(after.x - corner.x, after.y - corner.y);
|
|
584
|
+
var r = Math.min(radius, inLength / 2, outLength / 2);
|
|
585
|
+
if (r <= 0) return null;
|
|
586
|
+
return {
|
|
587
|
+
enter: {
|
|
588
|
+
x: corner.x - (corner.x - before.x) / inLength * r,
|
|
589
|
+
y: corner.y - (corner.y - before.y) / inLength * r
|
|
590
|
+
},
|
|
591
|
+
corner,
|
|
592
|
+
leave: {
|
|
593
|
+
x: corner.x + (after.x - corner.x) / outLength * r,
|
|
594
|
+
y: corner.y + (after.y - corner.y) / outLength * r
|
|
595
|
+
}
|
|
596
|
+
};
|
|
597
|
+
}
|
|
598
|
+
function cornerPath(param) {
|
|
599
|
+
var {
|
|
600
|
+
enter,
|
|
601
|
+
corner,
|
|
602
|
+
leave
|
|
603
|
+
} = param;
|
|
604
|
+
return `M${format(enter.x)},${format(enter.y)} Q${format(corner.x)},${format(corner.y)} ${format(leave.x)},${format(leave.y)}`;
|
|
605
|
+
}
|
|
606
|
+
function fittedRadius(points, index, radius, ends, obstacles) {
|
|
607
|
+
var fits = function fits2(r) {
|
|
608
|
+
var corner = roundCorner(points, index, r);
|
|
609
|
+
return !corner || !pathIntrudes(cornerPath(corner), ends, obstacles);
|
|
610
|
+
};
|
|
611
|
+
if (fits(radius)) return radius;
|
|
612
|
+
var low = 0;
|
|
613
|
+
var high = radius;
|
|
614
|
+
for (var step = 0; step < 12; step += 1) {
|
|
615
|
+
var middle = (low + high) / 2;
|
|
616
|
+
if (fits(middle)) low = middle;else high = middle;
|
|
617
|
+
}
|
|
618
|
+
return low;
|
|
619
|
+
}
|
|
620
|
+
function polylinePath(points, radii) {
|
|
621
|
+
var d = `M${format(points[0].x)},${format(points[0].y)}`;
|
|
622
|
+
for (var index = 1; index < points.length - 1; index += 1) {
|
|
623
|
+
var _radii_index;
|
|
624
|
+
var corner = roundCorner(points, index, (_radii_index = radii[index]) !== null && _radii_index !== void 0 ? _radii_index : 0);
|
|
625
|
+
if (!corner) {
|
|
626
|
+
d += ` L${format(points[index].x)},${format(points[index].y)}`;
|
|
627
|
+
continue;
|
|
628
|
+
}
|
|
629
|
+
d += ` L${format(corner.enter.x)},${format(corner.enter.y)} Q${format(corner.corner.x)},${format(corner.corner.y)} ${format(corner.leave.x)},${format(corner.leave.y)}`;
|
|
630
|
+
}
|
|
631
|
+
var last = points[points.length - 1];
|
|
632
|
+
return `${d} L${format(last.x)},${format(last.y)}`;
|
|
633
|
+
}
|
|
634
|
+
function midpoint(points) {
|
|
635
|
+
var total = 0;
|
|
636
|
+
for (var index = 1; index < points.length; index += 1) {
|
|
637
|
+
total += Math.hypot(points[index].x - points[index - 1].x, points[index].y - points[index - 1].y);
|
|
638
|
+
}
|
|
639
|
+
var left = total / 2;
|
|
640
|
+
for (var index1 = 1; index1 < points.length; index1 += 1) {
|
|
641
|
+
var a = points[index1 - 1];
|
|
642
|
+
var b = points[index1];
|
|
643
|
+
var length = Math.hypot(b.x - a.x, b.y - a.y);
|
|
644
|
+
if (length >= left && length > 0) {
|
|
645
|
+
var t = left / length;
|
|
646
|
+
return {
|
|
647
|
+
x: a.x + (b.x - a.x) * t,
|
|
648
|
+
y: a.y + (b.y - a.y) * t
|
|
649
|
+
};
|
|
650
|
+
}
|
|
651
|
+
left -= length;
|
|
652
|
+
}
|
|
653
|
+
return points[0];
|
|
654
|
+
}
|
|
655
|
+
function routeAroundBoxes(path, ends, obstacles) {
|
|
656
|
+
var _loop = function (_i2, _iter2) {
|
|
657
|
+
var reach = _iter2[_i2];
|
|
658
|
+
var area = bounds([from, to], (largest + clearance * 2) * reach);
|
|
659
|
+
var near = boxesNear(obstacles, area);
|
|
660
|
+
var start = stubEnd(from, ends.sourceSide, ownBox(from, near), clearance);
|
|
661
|
+
var goal = stubEnd(to, ends.targetSide, ownBox(to, near), clearance);
|
|
662
|
+
var inner = orthogonalRoute(start, directionIndex(ends.sourceSide), goal, (directionIndex(ends.targetSide) + 2) % 4, near, clearance, area);
|
|
663
|
+
if (!inner) return "continue";
|
|
664
|
+
var points = simplify([from, ...inner, to]);
|
|
665
|
+
var label = midpoint(points);
|
|
666
|
+
var radius = cornerRadius[path];
|
|
667
|
+
var radii = points.map(function (_, index) {
|
|
668
|
+
return index === 0 || index === points.length - 1 ? 0 : fittedRadius(points, index, radius, ends, obstacles);
|
|
669
|
+
});
|
|
670
|
+
return {
|
|
671
|
+
v: [polylinePath(points, radii), label.x, label.y]
|
|
672
|
+
};
|
|
673
|
+
};
|
|
674
|
+
var {
|
|
675
|
+
clearance
|
|
676
|
+
} = obstacles;
|
|
677
|
+
var from = {
|
|
678
|
+
x: ends.sourceX,
|
|
679
|
+
y: ends.sourceY
|
|
680
|
+
};
|
|
681
|
+
var to = {
|
|
682
|
+
x: ends.targetX,
|
|
683
|
+
y: ends.targetY
|
|
684
|
+
};
|
|
685
|
+
var largest = obstacles.boxes.reduce(function (size, box) {
|
|
686
|
+
return Math.max(size, box.width, box.height);
|
|
687
|
+
}, 0);
|
|
688
|
+
for (var _i = 0, _iter = [1, 3]; _i < _iter.length; _i++) {
|
|
689
|
+
var _ret = _loop(_i, _iter);
|
|
690
|
+
if (_type_of(_ret) === "object") return _ret.v;
|
|
691
|
+
}
|
|
692
|
+
return null;
|
|
693
|
+
}
|
|
694
|
+
var trackSharing = "target";
|
|
695
|
+
var frames = {
|
|
696
|
+
bottom: {
|
|
697
|
+
local: function local(param) {
|
|
698
|
+
var {
|
|
699
|
+
x,
|
|
700
|
+
y
|
|
701
|
+
} = param;
|
|
702
|
+
return {
|
|
703
|
+
x,
|
|
704
|
+
y
|
|
705
|
+
};
|
|
706
|
+
},
|
|
707
|
+
world: function world(param) {
|
|
708
|
+
var {
|
|
709
|
+
x,
|
|
710
|
+
y
|
|
711
|
+
} = param;
|
|
712
|
+
return {
|
|
713
|
+
x,
|
|
714
|
+
y
|
|
715
|
+
};
|
|
716
|
+
}
|
|
717
|
+
},
|
|
718
|
+
top: {
|
|
719
|
+
local: function local2(param) {
|
|
720
|
+
var {
|
|
721
|
+
x,
|
|
722
|
+
y
|
|
723
|
+
} = param;
|
|
724
|
+
return {
|
|
725
|
+
x,
|
|
726
|
+
y: -y
|
|
727
|
+
};
|
|
728
|
+
},
|
|
729
|
+
world: function world2(param) {
|
|
730
|
+
var {
|
|
731
|
+
x,
|
|
732
|
+
y
|
|
733
|
+
} = param;
|
|
734
|
+
return {
|
|
735
|
+
x,
|
|
736
|
+
y: -y
|
|
737
|
+
};
|
|
738
|
+
}
|
|
739
|
+
},
|
|
740
|
+
right: {
|
|
741
|
+
local: function local3(param) {
|
|
742
|
+
var {
|
|
743
|
+
x,
|
|
744
|
+
y
|
|
745
|
+
} = param;
|
|
746
|
+
return {
|
|
747
|
+
x: y,
|
|
748
|
+
y: x
|
|
749
|
+
};
|
|
750
|
+
},
|
|
751
|
+
world: function world3(param) {
|
|
752
|
+
var {
|
|
753
|
+
x,
|
|
754
|
+
y
|
|
755
|
+
} = param;
|
|
756
|
+
return {
|
|
757
|
+
x: y,
|
|
758
|
+
y: x
|
|
759
|
+
};
|
|
760
|
+
}
|
|
761
|
+
},
|
|
762
|
+
left: {
|
|
763
|
+
local: function local4(param) {
|
|
764
|
+
var {
|
|
765
|
+
x,
|
|
766
|
+
y
|
|
767
|
+
} = param;
|
|
768
|
+
return {
|
|
769
|
+
x: y,
|
|
770
|
+
y: -x
|
|
771
|
+
};
|
|
772
|
+
},
|
|
773
|
+
world: function world4(param) {
|
|
774
|
+
var {
|
|
775
|
+
x,
|
|
776
|
+
y
|
|
777
|
+
} = param;
|
|
778
|
+
return {
|
|
779
|
+
x: -y,
|
|
780
|
+
y: x
|
|
781
|
+
};
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
};
|
|
785
|
+
var opposite = {
|
|
786
|
+
left: "right",
|
|
787
|
+
right: "left",
|
|
788
|
+
top: "bottom",
|
|
789
|
+
bottom: "top"
|
|
790
|
+
};
|
|
791
|
+
function localSpan(box, frame) {
|
|
792
|
+
var a = frame.local({
|
|
793
|
+
x: box.x,
|
|
794
|
+
y: box.y
|
|
795
|
+
});
|
|
796
|
+
var b = frame.local({
|
|
797
|
+
x: box.x + box.width,
|
|
798
|
+
y: box.y + box.height
|
|
799
|
+
});
|
|
800
|
+
return {
|
|
801
|
+
u0: Math.min(a.x, b.x),
|
|
802
|
+
u1: Math.max(a.x, b.x),
|
|
803
|
+
v0: Math.min(a.y, b.y),
|
|
804
|
+
v1: Math.max(a.y, b.y)
|
|
805
|
+
};
|
|
806
|
+
}
|
|
807
|
+
function trackKey(sharing, link) {
|
|
808
|
+
return sharing === "target" ? link.target : `${link.source}\0${link.target}`;
|
|
809
|
+
}
|
|
810
|
+
function ranksOf(spans) {
|
|
811
|
+
var sorted = [...spans].sort(function (a, b) {
|
|
812
|
+
return a.v0 - b.v0;
|
|
813
|
+
});
|
|
814
|
+
var ranks = [];
|
|
815
|
+
var _iteratorNormalCompletion = true,
|
|
816
|
+
_didIteratorError = false,
|
|
817
|
+
_iteratorError = void 0;
|
|
818
|
+
try {
|
|
819
|
+
for (var _iterator = sorted[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
820
|
+
var span = _step.value;
|
|
821
|
+
var last = ranks[ranks.length - 1];
|
|
822
|
+
if (last && span.v0 < last.v1) {
|
|
823
|
+
last.v1 = Math.max(last.v1, span.v1);
|
|
824
|
+
last.spans.push(span);
|
|
825
|
+
} else ranks.push({
|
|
826
|
+
v0: span.v0,
|
|
827
|
+
v1: span.v1,
|
|
828
|
+
spans: [span]
|
|
829
|
+
});
|
|
830
|
+
}
|
|
831
|
+
} catch (err) {
|
|
832
|
+
_didIteratorError = true;
|
|
833
|
+
_iteratorError = err;
|
|
834
|
+
} finally {
|
|
835
|
+
try {
|
|
836
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
837
|
+
_iterator.return();
|
|
838
|
+
}
|
|
839
|
+
} finally {
|
|
840
|
+
if (_didIteratorError) {
|
|
841
|
+
throw _iteratorError;
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
var _iteratorNormalCompletion1 = true,
|
|
846
|
+
_didIteratorError1 = false,
|
|
847
|
+
_iteratorError1 = void 0;
|
|
848
|
+
try {
|
|
849
|
+
for (var _iterator1 = ranks[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) {
|
|
850
|
+
var rank = _step1.value;
|
|
851
|
+
rank.spans.sort(function (a, b) {
|
|
852
|
+
return a.u0 - b.u0;
|
|
853
|
+
});
|
|
854
|
+
}
|
|
855
|
+
} catch (err) {
|
|
856
|
+
_didIteratorError1 = true;
|
|
857
|
+
_iteratorError1 = err;
|
|
858
|
+
} finally {
|
|
859
|
+
try {
|
|
860
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
861
|
+
_iterator1.return();
|
|
862
|
+
}
|
|
863
|
+
} finally {
|
|
864
|
+
if (_didIteratorError1) {
|
|
865
|
+
throw _iteratorError1;
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
return ranks;
|
|
870
|
+
}
|
|
871
|
+
function channels(rank, clearance) {
|
|
872
|
+
var open = [];
|
|
873
|
+
var from = Number.NEGATIVE_INFINITY;
|
|
874
|
+
var _iteratorNormalCompletion = true,
|
|
875
|
+
_didIteratorError = false,
|
|
876
|
+
_iteratorError = void 0;
|
|
877
|
+
try {
|
|
878
|
+
for (var _iterator = rank.spans[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
879
|
+
var span = _step.value;
|
|
880
|
+
var to = span.u0 - clearance;
|
|
881
|
+
if (to > from) open.push([from, to]);
|
|
882
|
+
from = Math.max(from, span.u1 + clearance);
|
|
883
|
+
}
|
|
884
|
+
} catch (err) {
|
|
885
|
+
_didIteratorError = true;
|
|
886
|
+
_iteratorError = err;
|
|
887
|
+
} finally {
|
|
888
|
+
try {
|
|
889
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
890
|
+
_iterator.return();
|
|
891
|
+
}
|
|
892
|
+
} finally {
|
|
893
|
+
if (_didIteratorError) {
|
|
894
|
+
throw _iteratorError;
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
}
|
|
898
|
+
open.push([from, Number.POSITIVE_INFINITY]);
|
|
899
|
+
return open;
|
|
900
|
+
}
|
|
901
|
+
function virtualPoint(open, ideal, goal) {
|
|
902
|
+
var held = open.findIndex(function (param) {
|
|
903
|
+
var [lo, hi] = param;
|
|
904
|
+
return lo <= goal && goal <= hi;
|
|
905
|
+
});
|
|
906
|
+
if (held >= 0) return {
|
|
907
|
+
u: goal,
|
|
908
|
+
channel: held
|
|
909
|
+
};
|
|
910
|
+
var best = {
|
|
911
|
+
u: ideal,
|
|
912
|
+
channel: 0,
|
|
913
|
+
cost: Number.POSITIVE_INFINITY
|
|
914
|
+
};
|
|
915
|
+
open.forEach(function (param, channel) {
|
|
916
|
+
var [lo, hi] = param;
|
|
917
|
+
var u = Math.min(Math.max(ideal, lo), hi);
|
|
918
|
+
var cost = Math.abs(u - ideal);
|
|
919
|
+
if (cost < best.cost) best = {
|
|
920
|
+
u,
|
|
921
|
+
channel,
|
|
922
|
+
cost
|
|
923
|
+
};
|
|
924
|
+
});
|
|
925
|
+
return {
|
|
926
|
+
u: best.u,
|
|
927
|
+
channel: best.channel
|
|
928
|
+
};
|
|
929
|
+
}
|
|
930
|
+
function linkKey(link) {
|
|
931
|
+
return `${link.source}\0${link.target}`;
|
|
932
|
+
}
|
|
933
|
+
function planTracks(links, boxes, side, clearance, sharing) {
|
|
934
|
+
var frame = frames[side];
|
|
935
|
+
var spans = new Map(boxes.map(function (box) {
|
|
936
|
+
return [box.id, localSpan(box, frame)];
|
|
937
|
+
}));
|
|
938
|
+
var ranks = ranksOf([...spans.values()]);
|
|
939
|
+
var rankOf = /* @__PURE__ */new Map();
|
|
940
|
+
ranks.forEach(function (rank, index) {
|
|
941
|
+
var _iteratorNormalCompletion5 = true,
|
|
942
|
+
_didIteratorError5 = false,
|
|
943
|
+
_iteratorError5 = void 0;
|
|
944
|
+
try {
|
|
945
|
+
for (var _iterator5 = rank.spans[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) {
|
|
946
|
+
var span = _step5.value;
|
|
947
|
+
rankOf.set(span, index);
|
|
948
|
+
}
|
|
949
|
+
} catch (err) {
|
|
950
|
+
_didIteratorError5 = true;
|
|
951
|
+
_iteratorError5 = err;
|
|
952
|
+
} finally {
|
|
953
|
+
try {
|
|
954
|
+
if (!_iteratorNormalCompletion5 && _iterator5.return != null) {
|
|
955
|
+
_iterator5.return();
|
|
956
|
+
}
|
|
957
|
+
} finally {
|
|
958
|
+
if (_didIteratorError5) {
|
|
959
|
+
throw _iteratorError5;
|
|
960
|
+
}
|
|
961
|
+
}
|
|
962
|
+
}
|
|
963
|
+
});
|
|
964
|
+
var open = ranks.map(function (rank) {
|
|
965
|
+
return channels(rank, clearance);
|
|
966
|
+
});
|
|
967
|
+
var gaps = /* @__PURE__ */new Map();
|
|
968
|
+
var pieces = /* @__PURE__ */new Map();
|
|
969
|
+
var passing = [];
|
|
970
|
+
var virtual = /* @__PURE__ */new Map();
|
|
971
|
+
var channelOf = /* @__PURE__ */new Map();
|
|
972
|
+
var _iteratorNormalCompletion = true,
|
|
973
|
+
_didIteratorError = false,
|
|
974
|
+
_iteratorError = void 0;
|
|
975
|
+
try {
|
|
976
|
+
var _loop = function () {
|
|
977
|
+
var link = _step.value;
|
|
978
|
+
var source = spans.get(link.source);
|
|
979
|
+
var target = spans.get(link.target);
|
|
980
|
+
if (!source || !target) return "continue";
|
|
981
|
+
var rs = rankOf.get(source);
|
|
982
|
+
var rt = rankOf.get(target);
|
|
983
|
+
if (rt <= rs) return "continue";
|
|
984
|
+
var id2 = linkKey(link);
|
|
985
|
+
if (pieces.has(id2)) return "continue";
|
|
986
|
+
var sourceU = (source.u0 + source.u1) / 2;
|
|
987
|
+
var targetU = (target.u0 + target.u1) / 2;
|
|
988
|
+
var us = [sourceU];
|
|
989
|
+
for (var rank = rs + 1; rank < rt; rank += 1) {
|
|
990
|
+
var ideal = sourceU + (targetU - sourceU) * (rank - rs) / (rt - rs);
|
|
991
|
+
var at = virtualPoint(open[rank], ideal, targetU);
|
|
992
|
+
us.push(at.u);
|
|
993
|
+
passing.push({
|
|
994
|
+
link: id2,
|
|
995
|
+
rank,
|
|
996
|
+
slot: us.length - 1,
|
|
997
|
+
...at
|
|
998
|
+
});
|
|
999
|
+
}
|
|
1000
|
+
us.push(targetU);
|
|
1001
|
+
virtual.set(id2, us);
|
|
1002
|
+
channelOf.set(id2, passing.filter(function (pass2) {
|
|
1003
|
+
return pass2.link === id2;
|
|
1004
|
+
}).map(function (pass2) {
|
|
1005
|
+
return open[pass2.rank][pass2.channel];
|
|
1006
|
+
}));
|
|
1007
|
+
var own2 = [];
|
|
1008
|
+
for (var gap = rs; gap < rt; gap += 1) {
|
|
1009
|
+
var last = gap === rt - 1;
|
|
1010
|
+
var key2 = last ? trackKey(sharing, link) : `${id2}\0${gap}`;
|
|
1011
|
+
own2.push({
|
|
1012
|
+
gap,
|
|
1013
|
+
key: key2
|
|
1014
|
+
});
|
|
1015
|
+
var groups = gaps.get(gap);
|
|
1016
|
+
if (!groups) {
|
|
1017
|
+
groups = /* @__PURE__ */new Map();
|
|
1018
|
+
gaps.set(gap, groups);
|
|
1019
|
+
}
|
|
1020
|
+
var a = us[gap - rs];
|
|
1021
|
+
var b = us[gap - rs + 1];
|
|
1022
|
+
var group = groups.get(key2);
|
|
1023
|
+
if (group) {
|
|
1024
|
+
group.u0 = Math.min(group.u0, a, b);
|
|
1025
|
+
group.u1 = Math.max(group.u1, a, b);
|
|
1026
|
+
} else groups.set(key2, {
|
|
1027
|
+
key: key2,
|
|
1028
|
+
lone: rt - rs === 1,
|
|
1029
|
+
u0: Math.min(a, b),
|
|
1030
|
+
u1: Math.max(a, b)
|
|
1031
|
+
});
|
|
1032
|
+
}
|
|
1033
|
+
pieces.set(id2, own2);
|
|
1034
|
+
};
|
|
1035
|
+
for (var _iterator = links[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) _loop();
|
|
1036
|
+
} catch (err) {
|
|
1037
|
+
_didIteratorError = true;
|
|
1038
|
+
_iteratorError = err;
|
|
1039
|
+
} finally {
|
|
1040
|
+
try {
|
|
1041
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
1042
|
+
_iterator.return();
|
|
1043
|
+
}
|
|
1044
|
+
} finally {
|
|
1045
|
+
if (_didIteratorError) {
|
|
1046
|
+
throw _iteratorError;
|
|
1047
|
+
}
|
|
1048
|
+
}
|
|
1049
|
+
}
|
|
1050
|
+
var byChannel = /* @__PURE__ */new Map();
|
|
1051
|
+
var _iteratorNormalCompletion1 = true,
|
|
1052
|
+
_didIteratorError1 = false,
|
|
1053
|
+
_iteratorError1 = void 0;
|
|
1054
|
+
try {
|
|
1055
|
+
for (var _iterator1 = passing[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) {
|
|
1056
|
+
var pass = _step1.value;
|
|
1057
|
+
var _byChannel_get;
|
|
1058
|
+
var key = `${pass.rank}:${pass.channel}`;
|
|
1059
|
+
byChannel.set(key, [...((_byChannel_get = byChannel.get(key)) !== null && _byChannel_get !== void 0 ? _byChannel_get : []), pass]);
|
|
1060
|
+
}
|
|
1061
|
+
} catch (err) {
|
|
1062
|
+
_didIteratorError1 = true;
|
|
1063
|
+
_iteratorError1 = err;
|
|
1064
|
+
} finally {
|
|
1065
|
+
try {
|
|
1066
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
1067
|
+
_iterator1.return();
|
|
1068
|
+
}
|
|
1069
|
+
} finally {
|
|
1070
|
+
if (_didIteratorError1) {
|
|
1071
|
+
throw _iteratorError1;
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
var _iteratorNormalCompletion2 = true,
|
|
1076
|
+
_didIteratorError2 = false,
|
|
1077
|
+
_iteratorError2 = void 0;
|
|
1078
|
+
try {
|
|
1079
|
+
var _loop1 = function () {
|
|
1080
|
+
var group = _step2.value;
|
|
1081
|
+
if (group.length < 2) return "continue";
|
|
1082
|
+
var [lo, hi] = open[group[0].rank][group[0].channel];
|
|
1083
|
+
var sorted = [...group].sort(function (a, b) {
|
|
1084
|
+
return a.u - b.u || a.link.localeCompare(b.link);
|
|
1085
|
+
});
|
|
1086
|
+
var crowded = sorted.some(function (pass2, index) {
|
|
1087
|
+
return index > 0 && pass2.u - sorted[index - 1].u < clearance;
|
|
1088
|
+
});
|
|
1089
|
+
if (!crowded) return "continue";
|
|
1090
|
+
var width = Number.isFinite(lo) && Number.isFinite(hi) ? hi - lo : clearance * (group.length + 1);
|
|
1091
|
+
var base = Number.isFinite(lo) ? lo : Number.isFinite(hi) ? hi - width : sorted[0].u;
|
|
1092
|
+
var pitch = width / (group.length + 1);
|
|
1093
|
+
sorted.forEach(function (pass2, index) {
|
|
1094
|
+
virtual.get(pass2.link)[pass2.slot] = base + pitch * (index + 1);
|
|
1095
|
+
});
|
|
1096
|
+
};
|
|
1097
|
+
for (var _iterator2 = byChannel.values()[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) _loop1();
|
|
1098
|
+
} catch (err) {
|
|
1099
|
+
_didIteratorError2 = true;
|
|
1100
|
+
_iteratorError2 = err;
|
|
1101
|
+
} finally {
|
|
1102
|
+
try {
|
|
1103
|
+
if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
|
|
1104
|
+
_iterator2.return();
|
|
1105
|
+
}
|
|
1106
|
+
} finally {
|
|
1107
|
+
if (_didIteratorError2) {
|
|
1108
|
+
throw _iteratorError2;
|
|
1109
|
+
}
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
1112
|
+
var levels = /* @__PURE__ */new Map();
|
|
1113
|
+
var _iteratorNormalCompletion3 = true,
|
|
1114
|
+
_didIteratorError3 = false,
|
|
1115
|
+
_iteratorError3 = void 0;
|
|
1116
|
+
try {
|
|
1117
|
+
var _loop2 = function () {
|
|
1118
|
+
var [gap, groups] = _step3.value;
|
|
1119
|
+
var lo = ranks[gap].v1 + clearance;
|
|
1120
|
+
var hi = ranks[gap + 1].v0 - clearance;
|
|
1121
|
+
if (lo >= hi) return "continue";
|
|
1122
|
+
var list = [...groups.values()];
|
|
1123
|
+
var parent = list.map(function (_, index2) {
|
|
1124
|
+
return index2;
|
|
1125
|
+
});
|
|
1126
|
+
var root = function root2(index2) {
|
|
1127
|
+
var at2 = index2;
|
|
1128
|
+
while (parent[at2] !== at2) at2 = parent[at2];
|
|
1129
|
+
return at2;
|
|
1130
|
+
};
|
|
1131
|
+
for (var a = 0; a < list.length; a += 1) for (var b = a + 1; b < list.length; b += 1) if (list[a].u0 <= list[b].u1 + clearance && list[b].u0 <= list[a].u1 + clearance) parent[root(b)] = root(a);
|
|
1132
|
+
var sets = /* @__PURE__ */new Map();
|
|
1133
|
+
for (var index = 0; index < list.length; index += 1) {
|
|
1134
|
+
var _sets_get;
|
|
1135
|
+
var at = root(index);
|
|
1136
|
+
sets.set(at, [...((_sets_get = sets.get(at)) !== null && _sets_get !== void 0 ? _sets_get : []), list[index]]);
|
|
1137
|
+
}
|
|
1138
|
+
var _iteratorNormalCompletion5 = true,
|
|
1139
|
+
_didIteratorError5 = false,
|
|
1140
|
+
_iteratorError5 = void 0;
|
|
1141
|
+
try {
|
|
1142
|
+
for (var _iterator5 = sets.values()[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) {
|
|
1143
|
+
var members = _step5.value;
|
|
1144
|
+
var sorted = [...members].sort(function (a2, b2) {
|
|
1145
|
+
return a2.u0 - b2.u0 || a2.key.localeCompare(b2.key);
|
|
1146
|
+
});
|
|
1147
|
+
var ends = [];
|
|
1148
|
+
var lane = /* @__PURE__ */new Map();
|
|
1149
|
+
var _iteratorNormalCompletion12 = true,
|
|
1150
|
+
_didIteratorError12 = false,
|
|
1151
|
+
_iteratorError12 = void 0;
|
|
1152
|
+
try {
|
|
1153
|
+
var _loop3 = function () {
|
|
1154
|
+
var group = _step12.value;
|
|
1155
|
+
var free = ends.findIndex(function (end) {
|
|
1156
|
+
return end + clearance < group.u0;
|
|
1157
|
+
});
|
|
1158
|
+
if (free < 0) {
|
|
1159
|
+
free = ends.length;
|
|
1160
|
+
ends.push(group.u1);
|
|
1161
|
+
} else ends[free] = group.u1;
|
|
1162
|
+
lane.set(group.key, free);
|
|
1163
|
+
};
|
|
1164
|
+
for (var _iterator12 = sorted[Symbol.iterator](), _step12; !(_iteratorNormalCompletion12 = (_step12 = _iterator12.next()).done); _iteratorNormalCompletion12 = true) _loop3();
|
|
1165
|
+
} catch (err) {
|
|
1166
|
+
_didIteratorError12 = true;
|
|
1167
|
+
_iteratorError12 = err;
|
|
1168
|
+
} finally {
|
|
1169
|
+
try {
|
|
1170
|
+
if (!_iteratorNormalCompletion12 && _iterator12.return != null) {
|
|
1171
|
+
_iterator12.return();
|
|
1172
|
+
}
|
|
1173
|
+
} finally {
|
|
1174
|
+
if (_didIteratorError12) {
|
|
1175
|
+
throw _iteratorError12;
|
|
1176
|
+
}
|
|
1177
|
+
}
|
|
1178
|
+
}
|
|
1179
|
+
if (ends.length < 2 && members.every(function (group) {
|
|
1180
|
+
return group.lone;
|
|
1181
|
+
})) continue;
|
|
1182
|
+
var pitch = (hi - lo) / (ends.length + 1);
|
|
1183
|
+
var _iteratorNormalCompletion22 = true,
|
|
1184
|
+
_didIteratorError22 = false,
|
|
1185
|
+
_iteratorError22 = void 0;
|
|
1186
|
+
try {
|
|
1187
|
+
for (var _iterator22 = lane[Symbol.iterator](), _step22; !(_iteratorNormalCompletion22 = (_step22 = _iterator22.next()).done); _iteratorNormalCompletion22 = true) {
|
|
1188
|
+
var [key2, index1] = _step22.value;
|
|
1189
|
+
levels.set(`${gap}\0${key2}`, lo + pitch * (index1 + 1));
|
|
1190
|
+
}
|
|
1191
|
+
} catch (err) {
|
|
1192
|
+
_didIteratorError22 = true;
|
|
1193
|
+
_iteratorError22 = err;
|
|
1194
|
+
} finally {
|
|
1195
|
+
try {
|
|
1196
|
+
if (!_iteratorNormalCompletion22 && _iterator22.return != null) {
|
|
1197
|
+
_iterator22.return();
|
|
1198
|
+
}
|
|
1199
|
+
} finally {
|
|
1200
|
+
if (_didIteratorError22) {
|
|
1201
|
+
throw _iteratorError22;
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
1204
|
+
}
|
|
1205
|
+
}
|
|
1206
|
+
} catch (err) {
|
|
1207
|
+
_didIteratorError5 = true;
|
|
1208
|
+
_iteratorError5 = err;
|
|
1209
|
+
} finally {
|
|
1210
|
+
try {
|
|
1211
|
+
if (!_iteratorNormalCompletion5 && _iterator5.return != null) {
|
|
1212
|
+
_iterator5.return();
|
|
1213
|
+
}
|
|
1214
|
+
} finally {
|
|
1215
|
+
if (_didIteratorError5) {
|
|
1216
|
+
throw _iteratorError5;
|
|
1217
|
+
}
|
|
1218
|
+
}
|
|
1219
|
+
}
|
|
1220
|
+
};
|
|
1221
|
+
for (var _iterator3 = gaps[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) _loop2();
|
|
1222
|
+
} catch (err) {
|
|
1223
|
+
_didIteratorError3 = true;
|
|
1224
|
+
_iteratorError3 = err;
|
|
1225
|
+
} finally {
|
|
1226
|
+
try {
|
|
1227
|
+
if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
|
|
1228
|
+
_iterator3.return();
|
|
1229
|
+
}
|
|
1230
|
+
} finally {
|
|
1231
|
+
if (_didIteratorError3) {
|
|
1232
|
+
throw _iteratorError3;
|
|
1233
|
+
}
|
|
1234
|
+
}
|
|
1235
|
+
}
|
|
1236
|
+
var courses = /* @__PURE__ */new Map();
|
|
1237
|
+
var _iteratorNormalCompletion4 = true,
|
|
1238
|
+
_didIteratorError4 = false,
|
|
1239
|
+
_iteratorError4 = void 0;
|
|
1240
|
+
try {
|
|
1241
|
+
for (var _iterator4 = pieces[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
|
|
1242
|
+
var [id, own] = _step4.value;
|
|
1243
|
+
var _channelOf_get;
|
|
1244
|
+
var vs = own.map(function (param) {
|
|
1245
|
+
var {
|
|
1246
|
+
gap,
|
|
1247
|
+
key: key2
|
|
1248
|
+
} = param;
|
|
1249
|
+
return levels.get(`${gap}\0${key2}`);
|
|
1250
|
+
});
|
|
1251
|
+
if (vs.some(function (v) {
|
|
1252
|
+
return v === void 0;
|
|
1253
|
+
})) continue;
|
|
1254
|
+
courses.set(id, {
|
|
1255
|
+
vs,
|
|
1256
|
+
us: virtual.get(id).slice(1, -1),
|
|
1257
|
+
open: (_channelOf_get = channelOf.get(id)) !== null && _channelOf_get !== void 0 ? _channelOf_get : []
|
|
1258
|
+
});
|
|
1259
|
+
}
|
|
1260
|
+
} catch (err) {
|
|
1261
|
+
_didIteratorError4 = true;
|
|
1262
|
+
_iteratorError4 = err;
|
|
1263
|
+
} finally {
|
|
1264
|
+
try {
|
|
1265
|
+
if (!_iteratorNormalCompletion4 && _iterator4.return != null) {
|
|
1266
|
+
_iterator4.return();
|
|
1267
|
+
}
|
|
1268
|
+
} finally {
|
|
1269
|
+
if (_didIteratorError4) {
|
|
1270
|
+
throw _iteratorError4;
|
|
1271
|
+
}
|
|
1272
|
+
}
|
|
1273
|
+
}
|
|
1274
|
+
return courses;
|
|
1275
|
+
}
|
|
1276
|
+
var plans = /* @__PURE__ */new WeakMap();
|
|
1277
|
+
function tracksFor(obstacles, side) {
|
|
1278
|
+
var {
|
|
1279
|
+
links,
|
|
1280
|
+
boxes,
|
|
1281
|
+
clearance
|
|
1282
|
+
} = obstacles;
|
|
1283
|
+
if (!links || links.length === 0) return void 0;
|
|
1284
|
+
var byBoxes = plans.get(links);
|
|
1285
|
+
if (!byBoxes) {
|
|
1286
|
+
byBoxes = /* @__PURE__ */new WeakMap();
|
|
1287
|
+
plans.set(links, byBoxes);
|
|
1288
|
+
}
|
|
1289
|
+
var bySide = byBoxes.get(boxes);
|
|
1290
|
+
if (!bySide) {
|
|
1291
|
+
bySide = /* @__PURE__ */new Map();
|
|
1292
|
+
byBoxes.set(boxes, bySide);
|
|
1293
|
+
}
|
|
1294
|
+
var key = `${side}:${clearance}`;
|
|
1295
|
+
var tracks = bySide.get(key);
|
|
1296
|
+
if (!tracks) {
|
|
1297
|
+
tracks = planTracks(links, boxes, side, clearance, trackSharing);
|
|
1298
|
+
bySide.set(key, tracks);
|
|
1299
|
+
}
|
|
1300
|
+
return tracks;
|
|
1301
|
+
}
|
|
1302
|
+
function routeOnTrack(path, ends, obstacles) {
|
|
1303
|
+
if (path !== "smoothstep" && path !== "step") return null;
|
|
1304
|
+
if (ends.targetSide !== opposite[ends.sourceSide]) return null;
|
|
1305
|
+
var courses = tracksFor(obstacles, ends.sourceSide);
|
|
1306
|
+
if (!courses || courses.size === 0) return null;
|
|
1307
|
+
var from = {
|
|
1308
|
+
x: ends.sourceX,
|
|
1309
|
+
y: ends.sourceY
|
|
1310
|
+
};
|
|
1311
|
+
var to = {
|
|
1312
|
+
x: ends.targetX,
|
|
1313
|
+
y: ends.targetY
|
|
1314
|
+
};
|
|
1315
|
+
var source = ownBox(from, boxesNear(obstacles, bounds([from], 1)));
|
|
1316
|
+
var target = ownBox(to, boxesNear(obstacles, bounds([to], 1)));
|
|
1317
|
+
if (!source || !target) return null;
|
|
1318
|
+
var course = courses.get(linkKey({
|
|
1319
|
+
source: source.id,
|
|
1320
|
+
target: target.id
|
|
1321
|
+
}));
|
|
1322
|
+
if (!course) return null;
|
|
1323
|
+
var frame = frames[ends.sourceSide];
|
|
1324
|
+
var a = frame.local(from);
|
|
1325
|
+
var b = frame.local(to);
|
|
1326
|
+
var {
|
|
1327
|
+
vs,
|
|
1328
|
+
us
|
|
1329
|
+
} = course;
|
|
1330
|
+
var {
|
|
1331
|
+
clearance
|
|
1332
|
+
} = obstacles;
|
|
1333
|
+
if (!(a.y < vs[0] && vs[vs.length - 1] < b.y)) return null;
|
|
1334
|
+
if (us.length === 0 && Math.abs(a.x - b.x) < 0.5) return null;
|
|
1335
|
+
var snapped = us.map(function (u, index) {
|
|
1336
|
+
var _course_open_index;
|
|
1337
|
+
var [lo, hi] = (_course_open_index = course.open[index]) !== null && _course_open_index !== void 0 ? _course_open_index : [u, u];
|
|
1338
|
+
for (var _i = 0, _iter = [index === us.length - 1 ? b.x : void 0, index === 0 ? a.x : void 0]; _i < _iter.length; _i++) {
|
|
1339
|
+
var line = _iter[_i];
|
|
1340
|
+
if (line !== void 0 && Math.abs(line - u) < clearance * 2 && lo <= line && line <= hi) return line;
|
|
1341
|
+
}
|
|
1342
|
+
return u;
|
|
1343
|
+
});
|
|
1344
|
+
var local5 = [a];
|
|
1345
|
+
var holds = [a.x, ...snapped, b.x];
|
|
1346
|
+
vs.forEach(function (v, gap) {
|
|
1347
|
+
local5.push({
|
|
1348
|
+
x: holds[gap],
|
|
1349
|
+
y: v
|
|
1350
|
+
}, {
|
|
1351
|
+
x: holds[gap + 1],
|
|
1352
|
+
y: v
|
|
1353
|
+
});
|
|
1354
|
+
});
|
|
1355
|
+
local5.push(b);
|
|
1356
|
+
var points = simplify(local5.map(frame.world));
|
|
1357
|
+
var radius = cornerRadius[path];
|
|
1358
|
+
var radii = points.map(function (_, index) {
|
|
1359
|
+
return index === 0 || index === points.length - 1 ? 0 : fittedRadius(points, index, radius, ends, obstacles);
|
|
1360
|
+
});
|
|
1361
|
+
var d = polylinePath(points, radii);
|
|
1362
|
+
if (pathIntrudes(d, ends, obstacles)) return null;
|
|
1363
|
+
var label = midpoint(points);
|
|
1364
|
+
return [d, label.x, label.y];
|
|
1365
|
+
}
|
|
1366
|
+
export { edgeClearance, pathIntrudes, routeAroundBoxes, routeOnTrack, samplePath };
|
|
1367
|
+
//# sourceMappingURL=edgeRoute.native.js.map
|