@cardenelabs/dragon 0.44.0 → 0.45.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/README.md +21 -0
- package/dist/cli.cjs +3603 -3541
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +3603 -3541
- package/dist/cli.js.map +1 -1
- package/dist/export.cjs +3462 -3400
- package/dist/export.cjs.map +1 -1
- package/dist/export.js +3461 -3401
- package/dist/export.js.map +1 -1
- package/dist/index.cjs +12239 -12177
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +12239 -12177
- package/dist/index.js.map +1 -1
- package/dist/light/chunk-6ZUKJ3VO.js +489 -0
- package/dist/light/chunk-6ZUKJ3VO.js.map +1 -0
- package/dist/light/chunk-CLS6JVKK.cjs +84 -0
- package/dist/light/chunk-CLS6JVKK.cjs.map +1 -0
- package/dist/light/chunk-JNSHZTPF.js +1141 -0
- package/dist/light/chunk-JNSHZTPF.js.map +1 -0
- package/dist/light/chunk-OUQ44P45.cjs +489 -0
- package/dist/light/chunk-OUQ44P45.cjs.map +1 -0
- package/dist/light/chunk-VRAW7VAQ.cjs +1141 -0
- package/dist/light/chunk-VRAW7VAQ.cjs.map +1 -0
- package/dist/light/chunk-YDKPEKGZ.js +84 -0
- package/dist/light/chunk-YDKPEKGZ.js.map +1 -0
- package/dist/light/git-C4RVNFT6.js +637 -0
- package/dist/light/git-C4RVNFT6.js.map +1 -0
- package/dist/light/git-I7D7RIW2.cjs +637 -0
- package/dist/light/git-I7D7RIW2.cjs.map +1 -0
- package/dist/light/index.cjs +9885 -0
- package/dist/light/index.cjs.map +1 -0
- package/dist/light/index.d.cts +976 -0
- package/dist/light/index.d.ts +976 -0
- package/dist/light/index.js +9885 -0
- package/dist/light/index.js.map +1 -0
- package/dist/light/lineup-FAIKTH3Y.cjs +283 -0
- package/dist/light/lineup-FAIKTH3Y.cjs.map +1 -0
- package/dist/light/lineup-YEG4HHEI.js +283 -0
- package/dist/light/lineup-YEG4HHEI.js.map +1 -0
- package/dist/light/state-P3LIVI3K.js +335 -0
- package/dist/light/state-P3LIVI3K.js.map +1 -0
- package/dist/light/state-ZZUK6AQT.cjs +335 -0
- package/dist/light/state-ZZUK6AQT.cjs.map +1 -0
- package/dist/light/time-64DJKYAL.cjs +719 -0
- package/dist/light/time-64DJKYAL.cjs.map +1 -0
- package/dist/light/time-B5WUQOFP.js +719 -0
- package/dist/light/time-B5WUQOFP.js.map +1 -0
- package/dist/light/tree-5HPREYW2.js +478 -0
- package/dist/light/tree-5HPREYW2.js.map +1 -0
- package/dist/light/tree-66EH4QVI.cjs +478 -0
- package/dist/light/tree-66EH4QVI.cjs.map +1 -0
- package/dist/player.global.js +3 -3
- package/package.json +14 -2
- package/src/api.ts +71 -0
- package/src/figure-text.ts +4 -0
- package/src/index.ts +6 -69
- package/src/kinds/all.ts +16 -0
- package/src/kinds/git.ts +3 -0
- package/src/kinds/lineup.ts +3 -0
- package/src/kinds/registry.ts +46 -0
- package/src/kinds/state.ts +2 -0
- package/src/kinds/time.ts +3 -0
- package/src/kinds/tree.ts +3 -0
- package/src/layout/git.ts +0 -1
- package/src/layout/lineup.ts +0 -1
- package/src/layout/time.ts +0 -1
- package/src/layout/tree.ts +0 -1
- package/src/light.ts +31 -0
- package/src/player-global.ts +3 -0
- package/src/player.ts +1 -1
- package/src/render/draw.ts +731 -0
- package/src/render/parts.ts +3 -0
- package/src/render/svg.ts +4 -725
- package/src/render/time.ts +1 -4
- package/src/view.ts +1 -1
|
@@ -0,0 +1,719 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
var _chunkOUQ44P45cjs = require('./chunk-OUQ44P45.cjs');
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
var _chunkVRAW7VAQcjs = require('./chunk-VRAW7VAQ.cjs');
|
|
36
|
+
|
|
37
|
+
// src/layout/time.ts
|
|
38
|
+
var SECONDS = { d: 86400, h: 3600, min: 60, s: 1, ms: 1e-3 };
|
|
39
|
+
var UNITS = Object.keys(SECONDS);
|
|
40
|
+
function durationOf(text) {
|
|
41
|
+
const m = /^([0-9]+(?:\.[0-9]+)?)(ms|s|min|h|d)$/u.exec(text);
|
|
42
|
+
if (!m) return { seconds: 1, unit: "s" };
|
|
43
|
+
const unit = m[2];
|
|
44
|
+
return { seconds: Number(m[1]) * SECONDS[unit], unit };
|
|
45
|
+
}
|
|
46
|
+
var unitFor = (max, fallback) => _nullishCoalesce(UNITS.find((u) => max / SECONDS[u] >= 2 - 1e-9), () => ( fallback));
|
|
47
|
+
var timeText = (seconds, unit, lang) => `${Number((seconds / SECONDS[unit]).toFixed(2))} ${_chunkVRAW7VAQcjs.FIGURE_TEXT[lang].timeUnits[unit]}`;
|
|
48
|
+
function majorTicks(count, period, unitPx) {
|
|
49
|
+
let step = 1;
|
|
50
|
+
if (period) step = period * Math.max(1, Math.ceil(count / period / 8));
|
|
51
|
+
else {
|
|
52
|
+
for (let k = 1; ; k *= 10) {
|
|
53
|
+
const found = [k, k * 2, k * 5].find((n) => count / n <= _chunkVRAW7VAQcjs.LOOK.time.ticks);
|
|
54
|
+
if (found !== void 0) {
|
|
55
|
+
step = found;
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
const at = [];
|
|
61
|
+
for (let u = 0; u <= count; u += step) at.push(u);
|
|
62
|
+
const last = at[at.length - 1];
|
|
63
|
+
if (last !== count && (count - last) * unitPx >= _chunkVRAW7VAQcjs.LOOK.time.minorPx) at.push(count);
|
|
64
|
+
return { at, step };
|
|
65
|
+
}
|
|
66
|
+
function minorTicks(count, step, unitPx, majors) {
|
|
67
|
+
const by = Array.from({ length: step - 1 }, (_, k) => k + 1).find((d) => step % d === 0 && d * unitPx >= _chunkVRAW7VAQcjs.LOOK.time.minorPx);
|
|
68
|
+
if (by === void 0) return [];
|
|
69
|
+
const out = [];
|
|
70
|
+
for (let u = by; u < count; u += by) if (!majors.includes(u)) out.push(u);
|
|
71
|
+
return out;
|
|
72
|
+
}
|
|
73
|
+
function needleSteps(diagram) {
|
|
74
|
+
let at = 0;
|
|
75
|
+
return diagram.steps.map((step) => {
|
|
76
|
+
const from = at;
|
|
77
|
+
for (const event of step.events) if (event.type === "now") at = Math.max(at, event.to + 1);
|
|
78
|
+
return [from, at];
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
function layoutTime(diagram, lang = "ja") {
|
|
82
|
+
const T = _chunkVRAW7VAQcjs.LOOK.time;
|
|
83
|
+
const { margin, gap } = _chunkVRAW7VAQcjs.LOOK;
|
|
84
|
+
const R = _chunkVRAW7VAQcjs.LOOK.region;
|
|
85
|
+
const text = _chunkVRAW7VAQcjs.FIGURE_TEXT[lang];
|
|
86
|
+
const spec = _nullishCoalesce(diagram.time, () => ( { scale: { unit: "", length: "1s", count: 1 }, rows: [] }));
|
|
87
|
+
const { scale } = spec;
|
|
88
|
+
const count = Math.max(1, scale.count);
|
|
89
|
+
const length = durationOf(scale.length);
|
|
90
|
+
const width = Math.max(T.width, _chunkVRAW7VAQcjs.stripNeed.call(void 0, diagram) + margin * 2);
|
|
91
|
+
const nameRight = Math.max(0, ...spec.rows.map((r) => _chunkVRAW7VAQcjs.textWidth.call(void 0, r.name, _chunkVRAW7VAQcjs.TYPE.timeRow)));
|
|
92
|
+
const axisX = Math.max(T.axisX, margin + R.inset + nameRight + T.gutterGap);
|
|
93
|
+
const axisW = width - T.right - axisX;
|
|
94
|
+
const unit = axisW / count;
|
|
95
|
+
const colors = _chunkVRAW7VAQcjs.boxColors.call(void 0, diagram);
|
|
96
|
+
const rooms = _chunkVRAW7VAQcjs.slotRooms.call(void 0, diagram);
|
|
97
|
+
const regions = [];
|
|
98
|
+
const boxes = [];
|
|
99
|
+
const edges = [];
|
|
100
|
+
const wires = [];
|
|
101
|
+
const rowIds = new Map(spec.rows.map((r) => [r.id, r]));
|
|
102
|
+
let zoom;
|
|
103
|
+
let axisTop = margin;
|
|
104
|
+
if (spec.zoom) {
|
|
105
|
+
const { from, to } = spec.zoom;
|
|
106
|
+
const n = to - from + 1;
|
|
107
|
+
const colW = axisW / n;
|
|
108
|
+
const top = margin;
|
|
109
|
+
const headUnit = unitFor(to * length.seconds, length.unit);
|
|
110
|
+
const columns = [];
|
|
111
|
+
for (let k = 0; k < n; k++) {
|
|
112
|
+
const u = from + k;
|
|
113
|
+
const x = axisX + k * colW;
|
|
114
|
+
const placed = diagram.boxes.map((b, j) => {
|
|
115
|
+
const room = rooms.get(b.id);
|
|
116
|
+
const w = Math.max(_chunkVRAW7VAQcjs.boxWidth.call(void 0, diagram, b.id, false), _chunkVRAW7VAQcjs.slotBoxWidth.call(void 0, room, b.icon !== void 0, _chunkVRAW7VAQcjs.LOOK.box.padX));
|
|
117
|
+
const y2 = top + T.boxTop + j * (_chunkVRAW7VAQcjs.LOOK.box.h + T.boxGap);
|
|
118
|
+
const row = rowIds.get(b.id);
|
|
119
|
+
const box = {
|
|
120
|
+
id: b.id,
|
|
121
|
+
name: b.name,
|
|
122
|
+
...b.sub !== void 0 ? { sub: b.sub } : {},
|
|
123
|
+
...b.icon !== void 0 ? { icon: b.icon } : {},
|
|
124
|
+
color: _nullishCoalesce(colors.get(b.id), () => ( "slate")),
|
|
125
|
+
x: x + colW / 2 - w / 2,
|
|
126
|
+
y: y2,
|
|
127
|
+
w,
|
|
128
|
+
h: _chunkVRAW7VAQcjs.LOOK.box.h,
|
|
129
|
+
cx: x + colW / 2,
|
|
130
|
+
cy: y2 + _chunkVRAW7VAQcjs.LOOK.box.h / 2,
|
|
131
|
+
...row ? { row: row.id } : {},
|
|
132
|
+
..._optionalChain([row, 'optionalAccess', _2 => _2.empty, 'optionalAccess', _3 => _3.includes, 'call', _4 => _4(u)]) ? { empty: true } : {}
|
|
133
|
+
};
|
|
134
|
+
_chunkVRAW7VAQcjs.placeSlot.call(void 0, box, room);
|
|
135
|
+
return box;
|
|
136
|
+
});
|
|
137
|
+
boxes.push(...placed);
|
|
138
|
+
const head = `${scale.unit} ${(_nullishCoalesce(scale.from, () => ( 0))) + u}${text.headJoin}${timeText(u * length.seconds, headUnit, lang)}`;
|
|
139
|
+
columns.push({ unit: u, head, boxes: placed, x, y: top, w: colW, h: 0 });
|
|
140
|
+
}
|
|
141
|
+
const last = Math.max(top + T.boxTop, ...boxes.map((b) => b.y + b.h));
|
|
142
|
+
const bottom2 = last + T.zoomBottom;
|
|
143
|
+
for (const c of columns) c.h = bottom2 - top;
|
|
144
|
+
regions.push({
|
|
145
|
+
id: "zoom",
|
|
146
|
+
lines: [text.zoom],
|
|
147
|
+
note: `${n} ${scale.unit}`,
|
|
148
|
+
icon: "clock",
|
|
149
|
+
color: "blue",
|
|
150
|
+
x: margin,
|
|
151
|
+
y: top,
|
|
152
|
+
w: width - margin * 2,
|
|
153
|
+
h: bottom2 - top,
|
|
154
|
+
header: { x: margin + R.inset, y: top + R.inset, w: Math.max(R.icon, _chunkVRAW7VAQcjs.textWidth.call(void 0, text.zoom, _chunkVRAW7VAQcjs.TYPE.regionName)), h: R.nameY - R.inset + R.line }
|
|
155
|
+
});
|
|
156
|
+
zoom = { from, to, frame: { x: 0, y: 0, w: 0, h: 0 }, guides: [], columns, empty: text.empty, headY: top + T.head };
|
|
157
|
+
axisTop = bottom2 + T.zoomGap;
|
|
158
|
+
}
|
|
159
|
+
const rowsTop = axisTop + T.rowsTop;
|
|
160
|
+
const rows = spec.rows.map((r, k) => ({
|
|
161
|
+
id: r.id,
|
|
162
|
+
name: r.name,
|
|
163
|
+
// 色を書かない列は、同じ名札の箱の色にそろえる。印と拡大の帯の箱が同じ物だと見て分かるため
|
|
164
|
+
color: _nullishCoalesce(_nullishCoalesce(r.color, () => ( colors.get(r.id))), () => ( _chunkVRAW7VAQcjs.COLOR_ORDER[k % _chunkVRAW7VAQcjs.COLOR_ORDER.length])),
|
|
165
|
+
x: axisX,
|
|
166
|
+
y: rowsTop + k * (T.row + T.rowGap),
|
|
167
|
+
w: axisW,
|
|
168
|
+
h: T.row
|
|
169
|
+
}));
|
|
170
|
+
const rowsBottom = rows.length > 0 ? Math.max(...rows.map((r) => r.y + r.h)) : rowsTop;
|
|
171
|
+
const markW = Math.min(T.markMax, Math.max(T.markMin, unit * T.markRatio));
|
|
172
|
+
const marks = rows.flatMap(
|
|
173
|
+
(row, k) => Array.from({ length: count }, (_, u) => ({
|
|
174
|
+
row: row.id,
|
|
175
|
+
unit: u,
|
|
176
|
+
empty: _optionalChain([spec, 'access', _5 => _5.rows, 'access', _6 => _6[k], 'optionalAccess', _7 => _7.empty, 'optionalAccess', _8 => _8.includes, 'call', _9 => _9(u)]) === true,
|
|
177
|
+
color: row.color,
|
|
178
|
+
colors: [],
|
|
179
|
+
x: axisX + (u + 0.5) * unit - markW / 2,
|
|
180
|
+
y: row.y,
|
|
181
|
+
w: markW,
|
|
182
|
+
h: row.h
|
|
183
|
+
}))
|
|
184
|
+
);
|
|
185
|
+
diagram.steps.forEach(
|
|
186
|
+
(step, s) => step.events.forEach((event, e) => {
|
|
187
|
+
if (event.type !== "mark") return;
|
|
188
|
+
for (const m of marks) if (m.row === event.row && m.unit >= event.from && m.unit <= event.to && !m.empty) m.colors.push({ step: s, event: e, color: event.color });
|
|
189
|
+
})
|
|
190
|
+
);
|
|
191
|
+
if (zoom) {
|
|
192
|
+
const frame = { x: axisX + zoom.from * unit - T.frame, y: rowsTop - T.frame, w: (zoom.to - zoom.from + 1) * unit + T.frame * 2, h: rowsBottom - rowsTop + T.frame * 2 };
|
|
193
|
+
const band = Math.max(...zoom.columns.map((c) => c.y + c.h));
|
|
194
|
+
zoom.frame = frame;
|
|
195
|
+
zoom.guides = [
|
|
196
|
+
[
|
|
197
|
+
[frame.x, frame.y],
|
|
198
|
+
[axisX, band]
|
|
199
|
+
],
|
|
200
|
+
[
|
|
201
|
+
[frame.x + frame.w, frame.y],
|
|
202
|
+
[axisX + axisW, band]
|
|
203
|
+
]
|
|
204
|
+
];
|
|
205
|
+
}
|
|
206
|
+
const pointCy = rowsBottom + T.point.drop;
|
|
207
|
+
const points = (_nullishCoalesce(spec.points, () => ( []))).map((p) => {
|
|
208
|
+
const changes = [];
|
|
209
|
+
diagram.steps.forEach(
|
|
210
|
+
(step, s) => step.events.forEach((event, e) => {
|
|
211
|
+
if (event.type === "swap" && event.box === p.id) changes.push({ step: s, event: e, text: event.text, ...event.color ? { color: event.color } : {} });
|
|
212
|
+
})
|
|
213
|
+
);
|
|
214
|
+
const cx = axisX + (p.at + 0.5) * unit;
|
|
215
|
+
const tx = cx + T.point.text;
|
|
216
|
+
const w = Math.max(_chunkVRAW7VAQcjs.textWidth.call(void 0, p.id, _chunkVRAW7VAQcjs.TYPE.pointName), ...changes.map((c) => _chunkVRAW7VAQcjs.textWidth.call(void 0, c.text, _chunkVRAW7VAQcjs.TYPE.pointState)));
|
|
217
|
+
const top = pointCy + T.point.nameY - _chunkVRAW7VAQcjs.TYPE.pointName.size * 0.8;
|
|
218
|
+
const bottom2 = pointCy + T.point.stateY + _chunkVRAW7VAQcjs.TYPE.pointState.size * 0.2;
|
|
219
|
+
return { id: p.id, unit: p.at, cx, cy: pointCy, r: T.point.r, text: { x: tx, y: top, w, h: bottom2 - top }, changes };
|
|
220
|
+
});
|
|
221
|
+
const pointOf = new Map(points.map((p) => [p.id, p]));
|
|
222
|
+
const colorAt = (id, step) => {
|
|
223
|
+
const point = pointOf.get(id);
|
|
224
|
+
return _optionalChain([point, 'optionalAccess', _10 => _10.changes, 'access', _11 => _11.filter, 'call', _12 => _12((c) => c.step <= step && c.color), 'access', _13 => _13.at, 'call', _14 => _14(-1), 'optionalAccess', _15 => _15.color]);
|
|
225
|
+
};
|
|
226
|
+
diagram.steps.forEach(
|
|
227
|
+
(step, s) => step.events.forEach((event, e) => {
|
|
228
|
+
if (event.type !== "edge") return;
|
|
229
|
+
if (event.at === void 0) {
|
|
230
|
+
const a = pointOf.get(event.from);
|
|
231
|
+
const b = pointOf.get(event.to);
|
|
232
|
+
if (!a || !b || a === b) return;
|
|
233
|
+
const right = b.cx > a.cx;
|
|
234
|
+
const x0 = right ? Math.max(a.cx + a.r, a.text.x + a.text.w + T.point.link) : a.cx - a.r - T.point.end;
|
|
235
|
+
const x1 = right ? b.cx - b.r - T.point.end : Math.min(b.cx - b.r, b.text.x + b.text.w + T.point.link);
|
|
236
|
+
const edge2 = { step: s, event: e, from: event.from, to: event.to, points: [[x0, a.cy], [x1, b.cy]], color: event.carry.kind === "coin" ? "coin" : _nullishCoalesce(colorAt(event.to, s), () => ( "slate")), carry: event.carry };
|
|
237
|
+
if (event.carry.kind !== "none") edge2.settle = [x1 - (right ? 1 : -1) * (_chunkVRAW7VAQcjs.LOOK.carrier.coinR + _chunkVRAW7VAQcjs.LOOK.edge.arrow), b.cy];
|
|
238
|
+
edges.push(edge2);
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
const wired = wire(event, zoom);
|
|
242
|
+
if (!wired) return;
|
|
243
|
+
const edge = { step: s, event: e, from: event.from, to: event.to, points: wired.points, color: _chunkVRAW7VAQcjs.edgeColor.call(void 0, event, colors), carry: event.carry };
|
|
244
|
+
seat(edge, wired.from, wired.to, rooms);
|
|
245
|
+
edges.push(edge);
|
|
246
|
+
wires.push({ step: s, event: e, from: wired.from, to: wired.to, column: event.at, into: _nullishCoalesce(event.into, () => ( event.at)) });
|
|
247
|
+
})
|
|
248
|
+
);
|
|
249
|
+
const layout = {
|
|
250
|
+
kind: "time",
|
|
251
|
+
width,
|
|
252
|
+
height: 0,
|
|
253
|
+
regions,
|
|
254
|
+
boxes,
|
|
255
|
+
lifelines: [],
|
|
256
|
+
edges,
|
|
257
|
+
labels: [],
|
|
258
|
+
actions: [],
|
|
259
|
+
badges: [],
|
|
260
|
+
paths: [],
|
|
261
|
+
ends: [],
|
|
262
|
+
axis: { x: axisX, w: axisW, unit, count, line: 0 },
|
|
263
|
+
rows,
|
|
264
|
+
marks,
|
|
265
|
+
ticks: [],
|
|
266
|
+
minor: [],
|
|
267
|
+
periods: [],
|
|
268
|
+
points,
|
|
269
|
+
...zoom ? { zoom } : {},
|
|
270
|
+
spans: [],
|
|
271
|
+
wires,
|
|
272
|
+
needle: { y1: rowsTop - T.needle.over, y2: rowsBottom + T.needle.over }
|
|
273
|
+
};
|
|
274
|
+
const marksBottom = rowsBottom;
|
|
275
|
+
const named = diagram.steps.some((step) => step.events.some((e) => e.type === "edge" && e.at === void 0 && e.label !== void 0));
|
|
276
|
+
const { r: badgeR, inset } = _chunkVRAW7VAQcjs.LOOK.badge;
|
|
277
|
+
let y = points.length > 0 ? pointCy + T.point.r + (named ? T.point.room : T.point.plain) : marksBottom + (badgeR + inset) * 2;
|
|
278
|
+
const spans = [];
|
|
279
|
+
const events = diagram.steps.flatMap((step, s) => step.events.flatMap((event, e) => event.type === "span" ? [{ s, e, event }] : []));
|
|
280
|
+
for (const { s, e, event } of events) {
|
|
281
|
+
const kind = event.shape === "box" ? "box" : "bracket";
|
|
282
|
+
const later = events.find((o) => o.s > s && (o.event.shape === "box" ? "box" : "bracket") === kind && o.event.from <= event.to && event.from <= o.event.to);
|
|
283
|
+
const color = _nullishCoalesce(event.color, () => ( "slate"));
|
|
284
|
+
const x0 = axisX + event.from * unit;
|
|
285
|
+
const x1 = axisX + (event.to + 1) * unit;
|
|
286
|
+
const base = { step: s, event: e, kind, from: event.from, to: event.to, text: event.text, color, ...later ? { until: later.s } : {} };
|
|
287
|
+
if (kind === "box") {
|
|
288
|
+
const B = T.box;
|
|
289
|
+
const rect = { x: x0 - B.pad, y: rowsTop - B.pad, w: x1 - x0 + B.pad * 2, h: rowsBottom - rowsTop + B.pad * 2 };
|
|
290
|
+
const w = _chunkVRAW7VAQcjs.textWidth.call(void 0, event.text, _chunkVRAW7VAQcjs.TYPE.tag) + B.tagPadX * 2;
|
|
291
|
+
const textRect = { x: rect.x + B.tagX, y: rect.y - B.tagH / 2, w, h: B.tagH };
|
|
292
|
+
spans.push({ ...base, ...rect, textRect, textY: rect.y + _chunkVRAW7VAQcjs.LOOK.baseline.tag });
|
|
293
|
+
} else spans.push({ ...base, x: x0, y: 0, w: x1 - x0, h: T.bracket.tick, textRect: { x: 0, y: 0, w: 0, h: 0 }, textY: 0 });
|
|
294
|
+
}
|
|
295
|
+
layout.spans = spans;
|
|
296
|
+
layout.badges = badgesOf(diagram, layout, needleSteps(diagram));
|
|
297
|
+
layout.labels = labelsOf(diagram, layout);
|
|
298
|
+
y = Math.max(y, ...layout.labels.map((l) => l.y + l.h + _chunkVRAW7VAQcjs.LOOK.label.soft));
|
|
299
|
+
const lanes = [];
|
|
300
|
+
for (const span of spans.filter((x) => x.kind === "bracket")) {
|
|
301
|
+
const w = _chunkVRAW7VAQcjs.textWidth.call(void 0, span.text, _chunkVRAW7VAQcjs.TYPE.spanText);
|
|
302
|
+
const cx = Math.min(axisX + axisW - w / 2, Math.max(axisX + w / 2, span.x + span.w / 2));
|
|
303
|
+
const reach = { x: Math.min(span.x, cx - w / 2), w: Math.max(span.x + span.w, cx + w / 2) - Math.min(span.x, cx - w / 2) };
|
|
304
|
+
const clash = (other) => {
|
|
305
|
+
const seen = other.until === void 0 || other.until > span.step;
|
|
306
|
+
const ox = Math.min(other.x, other.textRect.x);
|
|
307
|
+
const ow = Math.max(other.x + other.w, other.textRect.x + other.textRect.w) - ox;
|
|
308
|
+
return seen && reach.x < ox + ow && ox < reach.x + reach.w;
|
|
309
|
+
};
|
|
310
|
+
let lane = lanes.findIndex((list) => !list.some(clash));
|
|
311
|
+
if (lane < 0) {
|
|
312
|
+
lanes.push([]);
|
|
313
|
+
lane = lanes.length - 1;
|
|
314
|
+
}
|
|
315
|
+
lanes[lane].push(span);
|
|
316
|
+
span.y = y + T.bracket.gap + lane * T.bracket.lane;
|
|
317
|
+
span.textY = span.y + T.bracket.tick + T.bracket.text;
|
|
318
|
+
span.textRect = _chunkVRAW7VAQcjs.textBox.call(void 0, span.text, cx, span.textY, _chunkVRAW7VAQcjs.TYPE.spanText, "middle");
|
|
319
|
+
}
|
|
320
|
+
if (lanes.length > 0) y = Math.max(...spans.filter((x) => x.kind === "bracket").map((x) => x.textRect.y + x.textRect.h));
|
|
321
|
+
const axisLine = y + T.axisGap;
|
|
322
|
+
layout.axis.line = axisLine;
|
|
323
|
+
const majors = majorTicks(count, _optionalChain([spec, 'access', _16 => _16.period, 'optionalAccess', _17 => _17.length]), unit);
|
|
324
|
+
const tickY = axisLine + T.tickY;
|
|
325
|
+
const tickUnit = unitFor(count * length.seconds, length.unit);
|
|
326
|
+
layout.ticks = majors.at.map((at) => {
|
|
327
|
+
const label = timeText(at * length.seconds, tickUnit, lang);
|
|
328
|
+
const w = _chunkVRAW7VAQcjs.textWidth.call(void 0, label, _chunkVRAW7VAQcjs.TYPE.timeTick);
|
|
329
|
+
const x = axisX + at * unit;
|
|
330
|
+
const left = at === 0 ? x : at === count ? x - w : Math.min(axisX + axisW - w, Math.max(axisX, x - w / 2));
|
|
331
|
+
return { at, x, text: label, left, y: tickY };
|
|
332
|
+
});
|
|
333
|
+
layout.minor = minorTicks(count, majors.step, unit, majors.at);
|
|
334
|
+
let bottom = tickY + _chunkVRAW7VAQcjs.TYPE.timeTick.size * 0.2;
|
|
335
|
+
if (spec.period) {
|
|
336
|
+
const P = spec.period;
|
|
337
|
+
const list = [];
|
|
338
|
+
for (let index = 0, from = 0; from < count; index++, from += P.length) {
|
|
339
|
+
const to = Math.min(count, from + P.length) - 1;
|
|
340
|
+
const name = `${P.name} ${(_nullishCoalesce(P.from, () => ( 0))) + index}`;
|
|
341
|
+
const first = (_nullishCoalesce(scale.from, () => ( 0))) + from;
|
|
342
|
+
const range = `${scale.unit} ${text.range(String(first), String((_nullishCoalesce(scale.from, () => ( 0))) + to))}`;
|
|
343
|
+
list.push({ index, from, to, name, range, x: axisX + from * unit, y: axisLine, w: (to - from + 1) * unit, h: 0, nameY: tickY, rangeY: tickY + T.rangeY });
|
|
344
|
+
}
|
|
345
|
+
const tickRects = layout.ticks.map((t) => _chunkVRAW7VAQcjs.textBox.call(void 0, t.text, t.left, t.y, _chunkVRAW7VAQcjs.TYPE.timeTick));
|
|
346
|
+
const clash = list.some((p) => {
|
|
347
|
+
const r = _chunkVRAW7VAQcjs.textBox.call(void 0, p.name, p.x + p.w / 2, p.nameY, _chunkVRAW7VAQcjs.TYPE.timePeriod, "middle");
|
|
348
|
+
return tickRects.some((t) => r.x < t.x + t.w + T.nameGap && t.x < r.x + r.w + T.nameGap);
|
|
349
|
+
});
|
|
350
|
+
for (const p of list) {
|
|
351
|
+
if (clash) {
|
|
352
|
+
p.nameY = tickY + T.rangeY + 2;
|
|
353
|
+
p.rangeY = p.nameY + T.rangeY;
|
|
354
|
+
}
|
|
355
|
+
p.h = p.rangeY + _chunkVRAW7VAQcjs.TYPE.timeRange.size * 0.2 - axisLine;
|
|
356
|
+
}
|
|
357
|
+
layout.periods = list;
|
|
358
|
+
bottom = Math.max(bottom, ...list.map((p) => p.rangeY + _chunkVRAW7VAQcjs.TYPE.timeRange.size * 0.2));
|
|
359
|
+
}
|
|
360
|
+
const axisBottom = bottom + T.bottom;
|
|
361
|
+
regions.push({ id: "axis", lines: [], color: "slate", x: margin, y: axisTop, w: width - margin * 2, h: axisBottom - axisTop, header: { x: margin + R.inset, y: axisTop + R.inset, w: 0, h: 0 } });
|
|
362
|
+
const strip = _chunkVRAW7VAQcjs.layoutStrip.call(void 0, diagram, margin, axisBottom + gap, width - margin * 2);
|
|
363
|
+
if (strip) layout.strip = strip;
|
|
364
|
+
layout.height = (strip ? strip.y + strip.h : axisBottom) + margin;
|
|
365
|
+
layout.badges = badgesOf(diagram, layout, needleSteps(diagram));
|
|
366
|
+
return layout;
|
|
367
|
+
}
|
|
368
|
+
function wire(event, zoom) {
|
|
369
|
+
if (!zoom || event.at === void 0) return void 0;
|
|
370
|
+
const into = _nullishCoalesce(event.into, () => ( event.at));
|
|
371
|
+
const fromColumn = zoom.columns.find((c) => c.unit === event.at);
|
|
372
|
+
const toColumn = zoom.columns.find((c) => c.unit === into);
|
|
373
|
+
const from = _optionalChain([fromColumn, 'optionalAccess', _18 => _18.boxes, 'access', _19 => _19.find, 'call', _20 => _20((b) => b.id === event.from)]);
|
|
374
|
+
const to = _optionalChain([toColumn, 'optionalAccess', _21 => _21.boxes, 'access', _22 => _22.find, 'call', _23 => _23((b) => b.id === event.to)]);
|
|
375
|
+
if (!fromColumn || !toColumn || !from || !to || from === to) return void 0;
|
|
376
|
+
const jf = fromColumn.boxes.indexOf(from);
|
|
377
|
+
const jt = toColumn.boxes.indexOf(to);
|
|
378
|
+
const down = jt > jf;
|
|
379
|
+
if (fromColumn === toColumn) {
|
|
380
|
+
if (Math.abs(jt - jf) === 1) return { from, to, points: [[from.cx, down ? from.y + from.h + 1 : from.y - 1], [to.cx, down ? to.y - 1 : to.y + to.h + 1]] };
|
|
381
|
+
const lane = Math.min(fromColumn.x + fromColumn.w - _chunkVRAW7VAQcjs.LOOK.gap, Math.max(from.x + from.w, to.x + to.w) + _chunkVRAW7VAQcjs.LOOK.gap);
|
|
382
|
+
return {
|
|
383
|
+
from,
|
|
384
|
+
to,
|
|
385
|
+
points: [
|
|
386
|
+
[from.x + from.w + 1, from.cy],
|
|
387
|
+
[lane, from.cy],
|
|
388
|
+
[lane, to.cy],
|
|
389
|
+
[to.x + to.w + 1, to.cy]
|
|
390
|
+
]
|
|
391
|
+
};
|
|
392
|
+
}
|
|
393
|
+
const right = toColumn.x > fromColumn.x;
|
|
394
|
+
if (jf === jt) return { from, to, points: [[right ? from.x + from.w + 1 : from.x - 1, from.cy], [right ? to.x - 1 : to.x + to.w + 1, to.cy]] };
|
|
395
|
+
const fx = from.cx + (right ? 1 : -1) * from.w / 4;
|
|
396
|
+
const tx = to.cx - (right ? 1 : -1) * to.w / 4;
|
|
397
|
+
return { from, to, points: [[fx, down ? from.y + from.h + 1 : from.y - 1], [tx, down ? to.y - 1 : to.y + to.h + 1]] };
|
|
398
|
+
}
|
|
399
|
+
function seat(edge, from, to, rooms) {
|
|
400
|
+
const arrive = { ...edge };
|
|
401
|
+
_chunkVRAW7VAQcjs.seatCarriers.call(void 0, [arrive], /* @__PURE__ */ new Map([[edge.to, to]]), rooms);
|
|
402
|
+
const leave = { ...edge };
|
|
403
|
+
_chunkVRAW7VAQcjs.seatCarriers.call(void 0, [leave], /* @__PURE__ */ new Map([[edge.from, from]]), rooms);
|
|
404
|
+
if (arrive.settle) edge.settle = arrive.settle;
|
|
405
|
+
if (leave.wait) edge.wait = leave.wait;
|
|
406
|
+
}
|
|
407
|
+
function badgesOf(diagram, layout, needle) {
|
|
408
|
+
const { r, inset } = _chunkVRAW7VAQcjs.LOOK.badge;
|
|
409
|
+
const { axis } = layout;
|
|
410
|
+
const taken = [];
|
|
411
|
+
const out = [];
|
|
412
|
+
const top = Math.min(...layout.rows.map((row) => row.y), layout.needle.y1 + _chunkVRAW7VAQcjs.LOOK.time.needle.over);
|
|
413
|
+
const bottom = Math.max(...layout.rows.map((row) => row.y + row.h), top);
|
|
414
|
+
const between = layout.points[0] ? (bottom + layout.points[0].cy - layout.points[0].r) / 2 : bottom + r + inset;
|
|
415
|
+
diagram.steps.forEach((step, s) => {
|
|
416
|
+
const push = (p, color) => {
|
|
417
|
+
taken.push(p);
|
|
418
|
+
out.push({ step: s, x: p[0], y: p[1], color });
|
|
419
|
+
};
|
|
420
|
+
const edge = layout.edges.filter((e) => e.step === s).sort((a, b) => a.event - b.event)[0];
|
|
421
|
+
if (edge) {
|
|
422
|
+
const waits = edge.carry.kind !== "none" && !edge.wait ? [edge.points[0]] : [];
|
|
423
|
+
const others = layout.edges.filter((e) => e !== edge).map((e) => e.points);
|
|
424
|
+
push(_chunkVRAW7VAQcjs.badgeOnPath.call(void 0, edge.points, [...taken, ...waits], others), edge.color);
|
|
425
|
+
return;
|
|
426
|
+
}
|
|
427
|
+
const [from, to] = _nullishCoalesce(needle[s], () => ( [0, 0]));
|
|
428
|
+
if (to > from) {
|
|
429
|
+
let x = axis.x + (from + to) / 2 * axis.unit;
|
|
430
|
+
const near = layout.points.find((p) => Math.abs(p.cx - x) < r + inset);
|
|
431
|
+
if (near) x = near.cx + r + inset * 2;
|
|
432
|
+
push([x, between], "slate");
|
|
433
|
+
return;
|
|
434
|
+
}
|
|
435
|
+
for (const event of step.events) {
|
|
436
|
+
const spot = spotOf(event, s, layout);
|
|
437
|
+
if (spot) {
|
|
438
|
+
push(spot.at, spot.color);
|
|
439
|
+
return;
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
if (layout.strip && step.events.some((e) => e.type === "strip")) {
|
|
443
|
+
out.push({ step: s, x: layout.strip.x + inset, y: layout.strip.y + inset, color: "slate" });
|
|
444
|
+
return;
|
|
445
|
+
}
|
|
446
|
+
const before = out[out.length - 1];
|
|
447
|
+
out.push(before ? { ...before, step: s } : { step: s, x: axis.x - r - inset, y: top, color: "slate" });
|
|
448
|
+
});
|
|
449
|
+
return _chunkVRAW7VAQcjs.replaceSameSpot.call(void 0, out);
|
|
450
|
+
}
|
|
451
|
+
function spotOf(event, step, layout) {
|
|
452
|
+
const { r, inset } = _chunkVRAW7VAQcjs.LOOK.badge;
|
|
453
|
+
if (event.type === "span") {
|
|
454
|
+
const span = layout.spans.find((x) => x.step === step && x.from === event.from && x.to === event.to && x.text === event.text);
|
|
455
|
+
if (!span) return void 0;
|
|
456
|
+
if (span.kind === "box") return { at: [span.x, span.y], color: span.color };
|
|
457
|
+
return { at: [span.x - r - inset, span.y + span.h / 2], color: span.color };
|
|
458
|
+
}
|
|
459
|
+
if (event.type === "swap") {
|
|
460
|
+
const point = layout.points.find((p) => p.id === event.box);
|
|
461
|
+
if (point) return { at: [point.cx - point.r - inset - r, point.cy], color: _nullishCoalesce(event.color, () => ( "slate")) };
|
|
462
|
+
}
|
|
463
|
+
if (event.type === "mark") {
|
|
464
|
+
const row = layout.rows.find((x) => x.id === event.row);
|
|
465
|
+
const top = Math.min(...layout.rows.map((x) => x.y));
|
|
466
|
+
if (row) return { at: [layout.axis.x + (event.from + event.to + 1) / 2 * layout.axis.unit, top - r - inset], color: event.color };
|
|
467
|
+
}
|
|
468
|
+
return void 0;
|
|
469
|
+
}
|
|
470
|
+
function labelsOf(diagram, layout) {
|
|
471
|
+
const labels = [];
|
|
472
|
+
const circles = layout.points.map((p) => ({ x: p.cx - p.r, y: p.cy - p.r, w: p.r * 2, h: p.r * 2 }));
|
|
473
|
+
const texts = layout.points.map((p) => p.text);
|
|
474
|
+
const heads = (_nullishCoalesce(_optionalChain([layout, 'access', _24 => _24.zoom, 'optionalAccess', _25 => _25.columns]), () => ( []))).map((c) => _chunkVRAW7VAQcjs.textBox.call(void 0, c.head, c.x + c.w / 2, _nullishCoalesce(_optionalChain([layout, 'access', _26 => _26.zoom, 'optionalAccess', _27 => _27.headY]), () => ( 0)), _chunkVRAW7VAQcjs.TYPE.timeHead, "middle"));
|
|
475
|
+
for (const edge of layout.edges) {
|
|
476
|
+
const source = _optionalChain([diagram, 'access', _28 => _28.steps, 'access', _29 => _29[edge.step], 'optionalAccess', _30 => _30.events, 'access', _31 => _31[edge.event]]);
|
|
477
|
+
if (_optionalChain([source, 'optionalAccess', _32 => _32.type]) !== "edge" || source.label === void 0) continue;
|
|
478
|
+
const seen = layout.badges.filter((b) => b.step <= edge.step).map((b) => _chunkVRAW7VAQcjs.badgeRect.call(void 0, [b.x, b.y]));
|
|
479
|
+
const side = _nullishCoalesce(source.labelSide, () => ( (source.at === void 0 ? "below" : void 0)));
|
|
480
|
+
labels.push(
|
|
481
|
+
_chunkVRAW7VAQcjs.placeLabel.call(void 0,
|
|
482
|
+
{ step: edge.step, event: edge.event, text: source.label, points: edge.points, color: edge.color, ...side ? { side } : {}, flip: source.at !== void 0 },
|
|
483
|
+
{ hard: [...circles, ...layout.boxes], soft: [...texts, ...heads, ...labels.filter((l) => l.step === edge.step)], touch: seen }
|
|
484
|
+
)
|
|
485
|
+
);
|
|
486
|
+
}
|
|
487
|
+
return labels;
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
// src/render/time.ts
|
|
491
|
+
var r1 = (v) => Math.round(v * 100) / 100;
|
|
492
|
+
var ja = (cls, text) => _chunkVRAW7VAQcjs.hasWide.call(void 0, text) ? `${cls} ${cls}j` : cls;
|
|
493
|
+
function simplify(keys) {
|
|
494
|
+
const out = [];
|
|
495
|
+
for (const key of keys) {
|
|
496
|
+
const a = out[out.length - 2];
|
|
497
|
+
const b = out[out.length - 1];
|
|
498
|
+
if (a && b) {
|
|
499
|
+
const s1 = b[0] === a[0] ? Number.NaN : (b[1] - a[1]) / (b[0] - a[0]);
|
|
500
|
+
const s2 = key[0] === b[0] ? Number.NaN : (key[1] - b[1]) / (key[0] - b[0]);
|
|
501
|
+
if (Number.isFinite(s1) && Number.isFinite(s2) && Math.abs(s1 - s2) < 1e-9) out[out.length - 1] = key;
|
|
502
|
+
else out.push(key);
|
|
503
|
+
} else out.push(key);
|
|
504
|
+
}
|
|
505
|
+
return out;
|
|
506
|
+
}
|
|
507
|
+
function valueAt(keys, t) {
|
|
508
|
+
const first = keys[0];
|
|
509
|
+
if (!first) return 0;
|
|
510
|
+
if (t <= first[0]) return first[1];
|
|
511
|
+
for (let k = 1; k < keys.length; k++) {
|
|
512
|
+
const [t1, v1] = keys[k];
|
|
513
|
+
const [t0, v0] = keys[k - 1];
|
|
514
|
+
if (t <= t1) return t1 === t0 ? v1 : v0 + (v1 - v0) * (t - t0) / (t1 - t0);
|
|
515
|
+
}
|
|
516
|
+
return keys[keys.length - 1][1];
|
|
517
|
+
}
|
|
518
|
+
function drawTime(layout, diagram, timeline, ctx, subs) {
|
|
519
|
+
const { m, ink } = ctx;
|
|
520
|
+
const T = _chunkVRAW7VAQcjs.LOOK.time;
|
|
521
|
+
const { axis } = layout;
|
|
522
|
+
const passed = new Map((_nullishCoalesce(timeline.units, () => ( []))).map((u) => [u.unit, u.passed]));
|
|
523
|
+
const at = (step, event) => _optionalChain([timeline, 'access', _33 => _33.events, 'access', _34 => _34.find, 'call', _35 => _35((t) => t.step === step && t.event === event), 'optionalAccess', _36 => _36.at]);
|
|
524
|
+
const drawnOf = (step, event) => _optionalChain([timeline, 'access', _37 => _37.edges, 'access', _38 => _38.find, 'call', _39 => _39((t) => t.step === step && t.event === event), 'optionalAccess', _40 => _40.drawn]);
|
|
525
|
+
const base = [];
|
|
526
|
+
const lit = [];
|
|
527
|
+
const node = [];
|
|
528
|
+
const top = [];
|
|
529
|
+
const rowsTop = Math.min(...layout.rows.map((r) => r.y));
|
|
530
|
+
const rowsBottom = Math.max(...layout.rows.map((r) => r.y + r.h));
|
|
531
|
+
const arrivals = /* @__PURE__ */ new Map();
|
|
532
|
+
for (const w of layout.wires) {
|
|
533
|
+
const drawn = drawnOf(w.step, w.event);
|
|
534
|
+
if (drawn !== void 0) arrivals.set(w.to, Math.min(_nullishCoalesce(arrivals.get(w.to), () => ( Number.POSITIVE_INFINITY)), drawn));
|
|
535
|
+
}
|
|
536
|
+
const filled = (row, u) => {
|
|
537
|
+
const box = _optionalChain([layout, 'access', _41 => _41.zoom, 'optionalAccess', _42 => _42.columns, 'access', _43 => _43.find, 'call', _44 => _44((c) => c.unit === u), 'optionalAccess', _45 => _45.boxes, 'access', _46 => _46.find, 'call', _47 => _47((b) => b.id === row)]);
|
|
538
|
+
const times = [passed.get(u), box ? arrivals.get(box) : void 0].filter((t) => t !== void 0);
|
|
539
|
+
return times.length > 0 ? Math.min(...times) : void 0;
|
|
540
|
+
};
|
|
541
|
+
for (const p of layout.periods) if (p.index % 2 === 1) base.push(`<rect class="dg-tm-ep" x="${r1(p.x)}" y="${r1(rowsTop - T.shade)}" width="${r1(p.w)}" height="${r1(rowsBottom - rowsTop + T.shade * 2)}" rx="4"/>`);
|
|
542
|
+
if (layout.zoom) {
|
|
543
|
+
const z = layout.zoom;
|
|
544
|
+
z.columns.forEach((c, k) => {
|
|
545
|
+
if (k > 0) base.push(`<line class="dg-tm-sep" x1="${r1(c.x)}" y1="${r1(c.y + T.sep)}" x2="${r1(c.x)}" y2="${r1(c.y + c.h - T.sep)}"/>`);
|
|
546
|
+
base.push(_chunkOUQ44P45cjs.write.call(void 0, ink, ja("dg-tm-hd", c.head), c.x + c.w / 2, z.headY, c.head, _chunkVRAW7VAQcjs.TYPE.timeHead, _chunkOUQ44P45cjs.ALWAYS, "middle"));
|
|
547
|
+
for (const box of c.boxes) node.push(columnBox(box, c.unit));
|
|
548
|
+
});
|
|
549
|
+
}
|
|
550
|
+
function columnBox(box, unit) {
|
|
551
|
+
const on = [...new Set(layout.wires.filter((w) => w.from === box || w.to === box).map((w) => w.step))].sort((a, b) => a - b);
|
|
552
|
+
const frame = (cls) => `<rect class="${cls}" x="${r1(box.x)}" y="${r1(box.y)}" width="${r1(box.w)}" height="${box.h}" rx="${_chunkVRAW7VAQcjs.LOOK.box.radius}"/>`;
|
|
553
|
+
if (box.empty) {
|
|
554
|
+
const shown2 = passed.get(unit);
|
|
555
|
+
const word = _nullishCoalesce(_optionalChain([layout, 'access', _48 => _48.zoom, 'optionalAccess', _49 => _49.empty]), () => ( ""));
|
|
556
|
+
const mark = shown2 === void 0 ? "" : `<g class="dg-a" style="${m.vis(shown2)}">${frame("dg-tm-ex")}${_chunkOUQ44P45cjs.write.call(void 0, ink, "dg-tm-ext", box.cx, box.cy + _chunkVRAW7VAQcjs.LOOK.baseline.mark, word, _chunkVRAW7VAQcjs.TYPE.emptyText, [[shown2, Number.POSITIVE_INFINITY]], "middle")}</g>`;
|
|
557
|
+
return `<g data-empty="${_chunkOUQ44P45cjs.esc.call(void 0, box.id)}">${frame("dg-tm-ph")}${mark}</g>`;
|
|
558
|
+
}
|
|
559
|
+
const drawn = _chunkOUQ44P45cjs.linkTo.call(void 0, _optionalChain([diagram, 'access', _50 => _50.boxes, 'access', _51 => _51.find, 'call', _52 => _52((b) => b.id === box.id), 'optionalAccess', _53 => _53.link]), _chunkOUQ44P45cjs.card.call(void 0, box, ctx, on, _nullishCoalesce(subs.get(box.id), () => ( []))));
|
|
560
|
+
if (!box.row) return drawn;
|
|
561
|
+
const shown = filled(box.row, unit);
|
|
562
|
+
if (shown === void 0) return frame("dg-tm-ph");
|
|
563
|
+
return `<g class="dg-a" style="${m.until(shown)}">${frame("dg-tm-ph")}</g><g class="dg-popc dg-a" style="${m.pop(shown)}">${drawn}</g>`;
|
|
564
|
+
}
|
|
565
|
+
for (const row of layout.rows) {
|
|
566
|
+
const parts = [];
|
|
567
|
+
for (const mark of layout.marks.filter((x2) => x2.row === row.id)) {
|
|
568
|
+
const rect = (cls, extra = "") => `<rect class="${cls}" x="${r1(mark.x)}" y="${r1(mark.y)}" width="${r1(mark.w)}" height="${r1(mark.h)}" rx="${T.markRadius}"${extra}/>`;
|
|
569
|
+
parts.push(rect("dg-tm-slot"));
|
|
570
|
+
if (mark.empty) {
|
|
571
|
+
const shown2 = passed.get(mark.unit);
|
|
572
|
+
if (shown2 !== void 0) parts.push(`<circle class="dg-tm-x dg-a" cx="${r1(mark.x + mark.w / 2)}" cy="${r1(mark.y + mark.h / 2)}" r="${T.emptyR}" style="${m.vis(shown2, m.last, { f: 0.2 })}"/>`);
|
|
573
|
+
continue;
|
|
574
|
+
}
|
|
575
|
+
const shown = filled(row.id, mark.unit);
|
|
576
|
+
if (shown !== void 0) parts.push(rect("dg-tm-m dg-a", ` style="${m.vis(shown, m.last, { f: 0.2 })}"`));
|
|
577
|
+
mark.colors.forEach((c, k) => {
|
|
578
|
+
const t = at(c.step, c.event);
|
|
579
|
+
if (t === void 0) return;
|
|
580
|
+
const next = mark.colors[k + 1];
|
|
581
|
+
const until = next ? at(next.step, next.event) : void 0;
|
|
582
|
+
parts.push(`<g style="${_chunkOUQ44P45cjs.cs.call(void 0, c.color)}">${rect("dg-tm-m dg-a", ` style="${m.vis(t, _nullishCoalesce(until, () => ( m.last)), { f: 0.35 })}"`)}</g>`);
|
|
583
|
+
});
|
|
584
|
+
}
|
|
585
|
+
base.push(`<g data-row="${_chunkOUQ44P45cjs.esc.call(void 0, row.id)}" style="${_chunkOUQ44P45cjs.cs.call(void 0, row.color)}">${parts.join("")}</g>`);
|
|
586
|
+
base.push(_chunkOUQ44P45cjs.write.call(void 0, ink, "dg-tm-rn", _chunkVRAW7VAQcjs.LOOK.margin + _chunkVRAW7VAQcjs.LOOK.region.inset, row.y + row.h / 2 + _chunkVRAW7VAQcjs.LOOK.baseline.mark, row.name, _chunkVRAW7VAQcjs.TYPE.timeRow));
|
|
587
|
+
}
|
|
588
|
+
if (layout.zoom) {
|
|
589
|
+
const z = layout.zoom;
|
|
590
|
+
const hide = layout.spans.filter((s) => s.kind === "box" && s.from <= z.to && z.from <= s.to).map((s) => at(s.step, s.event)).filter((t) => t !== void 0).sort((a, b) => a - b)[0];
|
|
591
|
+
const guides = z.guides.map((g) => `<path class="dg-tm-gd" d="${_chunkOUQ44P45cjs.pathOf.call(void 0, g)}"/>`).join("");
|
|
592
|
+
const lens = `<rect class="dg-tm-fr" x="${r1(z.frame.x)}" y="${r1(z.frame.y)}" width="${r1(z.frame.w)}" height="${r1(z.frame.h)}" rx="4"/>${guides}`;
|
|
593
|
+
base.push(hide === void 0 ? lens : `<g class="dg-a" style="${m.until(hide)}">${lens}</g>`);
|
|
594
|
+
}
|
|
595
|
+
const x = (u) => r1(axis.x + u * axis.unit);
|
|
596
|
+
const majors = layout.ticks.map((t) => `M ${x(t.at)} ${r1(axis.line - T.major / 2)} V ${r1(axis.line + T.major / 2)}`);
|
|
597
|
+
const minors = layout.minor.map((u) => `M ${x(u)} ${r1(axis.line - T.minor / 2)} V ${r1(axis.line + T.minor / 2)}`);
|
|
598
|
+
base.push(`<path class="dg-tm-ax" d="M ${x(0)} ${r1(axis.line)} H ${x(axis.count)} ${[...majors, ...minors].join(" ")}"/>`);
|
|
599
|
+
for (const t of layout.ticks) base.push(_chunkOUQ44P45cjs.write.call(void 0, ink, ja("dg-tm-tk", t.text), t.left, t.y, t.text, _chunkVRAW7VAQcjs.TYPE.timeTick));
|
|
600
|
+
for (const p of layout.periods) {
|
|
601
|
+
base.push(_chunkOUQ44P45cjs.write.call(void 0, ink, ja("dg-tm-en", p.name), p.x + p.w / 2, p.nameY, p.name, _chunkVRAW7VAQcjs.TYPE.timePeriod, _chunkOUQ44P45cjs.ALWAYS, "middle"));
|
|
602
|
+
base.push(_chunkOUQ44P45cjs.write.call(void 0, ink, ja("dg-tm-er", p.range), p.x + p.w / 2, p.rangeY, p.range, _chunkVRAW7VAQcjs.TYPE.timeRange, _chunkOUQ44P45cjs.ALWAYS, "middle"));
|
|
603
|
+
}
|
|
604
|
+
for (const span of layout.spans) {
|
|
605
|
+
const a = at(span.step, span.event);
|
|
606
|
+
if (a === void 0) continue;
|
|
607
|
+
const until = span.until === void 0 ? void 0 : timeline.steps[span.until].start;
|
|
608
|
+
const shown = [[a, _nullishCoalesce(until, () => ( Number.POSITIVE_INFINITY))]];
|
|
609
|
+
const vis = until === void 0 ? m.vis(a) : m.vis(a, until, { within: true });
|
|
610
|
+
if (span.kind === "bracket") {
|
|
611
|
+
const [x0, x1, y0, y12] = [r1(span.x + 1), r1(span.x + span.w - 1), r1(span.y), r1(span.y + span.h)];
|
|
612
|
+
const words = _chunkOUQ44P45cjs.write.call(void 0, ink, ja("dg-tm-bt", span.text), span.textRect.x + span.textRect.w / 2, span.textY, span.text, _chunkVRAW7VAQcjs.TYPE.spanText, shown, "middle");
|
|
613
|
+
base.push(`<g class="dg-a" data-span="${span.step}" style="${_chunkOUQ44P45cjs.cs.call(void 0, span.color)};${vis}"><path class="dg-tm-br" d="M ${x0} ${y0} L ${x0} ${y12} L ${x1} ${y12} L ${x1} ${y0}"/>${words}</g>`);
|
|
614
|
+
continue;
|
|
615
|
+
}
|
|
616
|
+
base.push(`<g class="dg-a" data-span="${span.step}" style="${_chunkOUQ44P45cjs.cs.call(void 0, span.color)};${vis}"><rect class="dg-tm-bx" x="${r1(span.x)}" y="${r1(span.y)}" width="${r1(span.w)}" height="${r1(span.h)}" rx="6"/></g>`);
|
|
617
|
+
const tag = span.textRect;
|
|
618
|
+
ink.push({ text: span.text, rect: tag, shown, boxed: true });
|
|
619
|
+
top.push(
|
|
620
|
+
`<g class="dg-tg dg-popc dg-a" style="${_chunkOUQ44P45cjs.cs.call(void 0, span.color)};${until === void 0 ? m.pop(a) : m.pop(a, until)}"><rect x="${r1(tag.x)}" y="${r1(tag.y)}" width="${r1(tag.w)}" height="${tag.h}" rx="${tag.h / 2}"/><text x="${r1(tag.x + tag.w / 2)}" y="${r1(span.textY)}" text-anchor="middle">${_chunkOUQ44P45cjs.esc.call(void 0, span.text)}</text></g>`
|
|
621
|
+
);
|
|
622
|
+
}
|
|
623
|
+
const P = T.point;
|
|
624
|
+
for (const point of layout.points) {
|
|
625
|
+
const { cx, cy, r } = point;
|
|
626
|
+
const times = point.changes.map((c) => _nullishCoalesce(at(c.step, c.event), () => ( Number.POSITIVE_INFINITY)));
|
|
627
|
+
const first = times[0];
|
|
628
|
+
base.push(`<path class="dg-tm-con" d="M ${r1(cx)} ${r1(rowsBottom + 3)} L ${r1(cx)} ${r1(cy - r - 2)}"/>`);
|
|
629
|
+
const tx = point.text.x;
|
|
630
|
+
const name = _chunkOUQ44P45cjs.write.call(void 0, ink, ja("dg-tm-pn", point.id), tx, cy + P.nameY, point.id, _chunkVRAW7VAQcjs.TYPE.pointName);
|
|
631
|
+
const grey = name.replace(/class="([^"]*)"/u, 'class="$1 dg-tm-pn-g"');
|
|
632
|
+
const label = first === void 0 || !Number.isFinite(first) ? grey : `<g class="dg-a" style="${m.until(first)}">${grey}</g><g class="dg-a" style="${m.vis(first)}">${name}</g>`;
|
|
633
|
+
const states = point.changes.map((c, k) => {
|
|
634
|
+
const t = times[k];
|
|
635
|
+
if (!Number.isFinite(t)) return "";
|
|
636
|
+
const next = times[k + 1];
|
|
637
|
+
const end2 = next !== void 0 && Number.isFinite(next) ? next - _chunkVRAW7VAQcjs.MOTION.untilFade : void 0;
|
|
638
|
+
const words = _chunkOUQ44P45cjs.write.call(void 0, ink, ja("dg-tm-ps", c.text), tx, cy + P.stateY, c.text, _chunkVRAW7VAQcjs.TYPE.pointState, [[t, _nullishCoalesce(end2, () => ( Number.POSITIVE_INFINITY))]]);
|
|
639
|
+
return `<g class="dg-a" style="${_chunkOUQ44P45cjs.cs.call(void 0, _nullishCoalesce(c.color, () => ( "slate")))};${end2 === void 0 ? m.rise(t) : m.rise(t, end2)}">${words}</g>`;
|
|
640
|
+
}).join("");
|
|
641
|
+
const rings = point.changes.map((c, k) => {
|
|
642
|
+
const t = times[k];
|
|
643
|
+
if (!c.color || !Number.isFinite(t)) return "";
|
|
644
|
+
return `<g class="dg-popc dg-a" style="${_chunkOUQ44P45cjs.cs.call(void 0, c.color)};${m.pop(t)}"><circle class="dg-tm-pc" cx="${r1(cx)}" cy="${r1(cy)}" r="${r + 0.5}"/>${_chunkOUQ44P45cjs.glyph.call(void 0, "flag", cx, cy, P.glyph, "dg-tm-pcg")}</g>`;
|
|
645
|
+
}).join("");
|
|
646
|
+
node.push(`<g data-point="${_chunkOUQ44P45cjs.esc.call(void 0, point.id)}"><circle class="dg-tm-pg" cx="${r1(cx)}" cy="${r1(cy)}" r="${r}"/>${_chunkOUQ44P45cjs.glyph.call(void 0, "flag", cx, cy, P.glyph, "dg-tm-pgl")}${rings}${label}${states}</g>`);
|
|
647
|
+
}
|
|
648
|
+
const wired = new Set(layout.wires.map((w) => `${w.step}/${w.event}`));
|
|
649
|
+
for (const e of layout.edges) {
|
|
650
|
+
if (wired.has(`${e.step}/${e.event}`)) continue;
|
|
651
|
+
const time = timeline.edges.find((t) => t.step === e.step && t.event === e.event);
|
|
652
|
+
if (!time) continue;
|
|
653
|
+
ctx.traces.push({ from: e.from, to: e.to, points: e.points, shown: [[time.start, Number.POSITIVE_INFINITY]] });
|
|
654
|
+
const kf = m.kf([
|
|
655
|
+
[0, { opacity: 0, "stroke-dashoffset": 1 }],
|
|
656
|
+
[time.start, { opacity: 0, "stroke-dashoffset": 1 }, _chunkVRAW7VAQcjs.EASE.inOut],
|
|
657
|
+
[time.start + 0.05, { opacity: 1 }],
|
|
658
|
+
[time.drawn, { "stroke-dashoffset": 0 }],
|
|
659
|
+
[m.last, { opacity: 1, "stroke-dashoffset": 0 }, _chunkVRAW7VAQcjs.EASE.inOut],
|
|
660
|
+
[m.total, { opacity: 0, "stroke-dashoffset": 0 }]
|
|
661
|
+
]);
|
|
662
|
+
const head = m.kf([
|
|
663
|
+
[0, { opacity: 0 }],
|
|
664
|
+
[time.drawn - 0.05, { opacity: 0 }],
|
|
665
|
+
[time.drawn, { opacity: 1 }],
|
|
666
|
+
[m.last, { opacity: 1 }, _chunkVRAW7VAQcjs.EASE.inOut],
|
|
667
|
+
[m.total, { opacity: 0 }]
|
|
668
|
+
]);
|
|
669
|
+
lit.push(`<g data-link="${_chunkOUQ44P45cjs.esc.call(void 0, `${e.from}->${e.to}`)}" style="${_chunkOUQ44P45cjs.cs.call(void 0, e.color)}"><path class="dg-tm-ln dg-a" pathLength="1" d="${_chunkOUQ44P45cjs.pathOf.call(void 0, e.points)}" style="${kf}"/><path class="dg-eh-on dg-a" d="${_chunkOUQ44P45cjs.arrowHead.call(void 0, e.points)}" style="${head}"/></g>`);
|
|
670
|
+
}
|
|
671
|
+
const keys = _nullishCoalesce(timeline.needle, () => ( []));
|
|
672
|
+
const moved = simplify(keys.filter(([t]) => t < m.total));
|
|
673
|
+
const end = _nullishCoalesce(_optionalChain([moved, 'access', _54 => _54[moved.length - 1], 'optionalAccess', _55 => _55[1]]), () => ( 0));
|
|
674
|
+
const path = [...moved.map(([t, u]) => [t, axis.x + u * axis.unit, 0]), [m.last, axis.x + end * axis.unit, 0], [m.total, axis.x, 0]];
|
|
675
|
+
const { y1, y2 } = layout.needle;
|
|
676
|
+
const N = T.needle;
|
|
677
|
+
top.push(
|
|
678
|
+
`<g class="dg-a" data-needle="" style="${m.move(path)}"><line class="dg-tm-nd" x1="0" y1="${r1(y1)}" x2="0" y2="${r1(y2)}"/><path class="dg-tm-nh" d="M ${-N.head * 0.75} ${r1(y1 - N.head)} L ${N.head * 0.75} ${r1(y1 - N.head)} L 0 ${r1(y1)} Z"/><circle class="dg-tm-nh" cy="${r1(axis.line)}" r="${N.dot}"/></g>`
|
|
679
|
+
);
|
|
680
|
+
return { base: base.join(""), lit: lit.join(""), node: node.join(""), top: top.join("") };
|
|
681
|
+
}
|
|
682
|
+
function meterField(field, keys, ctx) {
|
|
683
|
+
const { m } = ctx;
|
|
684
|
+
const M = _chunkVRAW7VAQcjs.LOOK.time.meter;
|
|
685
|
+
const { x, w, line, text } = field.meter;
|
|
686
|
+
const y = field.y + M.y;
|
|
687
|
+
const kf = m.kf([
|
|
688
|
+
...simplify(keys).map(([t, v]) => [t, { transform: `scaleX(${r1(v * 1e3) / 1e3})` }]),
|
|
689
|
+
[m.last, { transform: `scaleX(${r1(valueAt(keys, m.last) * 1e3) / 1e3})` }, _chunkVRAW7VAQcjs.EASE.inOut],
|
|
690
|
+
[m.total, { transform: "scaleX(0)" }]
|
|
691
|
+
]);
|
|
692
|
+
const lx = x + w * line;
|
|
693
|
+
return `<rect class="dg-tm-mt" x="${r1(x)}" y="${r1(y)}" width="${r1(w)}" height="${M.h}" rx="${M.h / 2}"/><rect class="dg-tm-mf dg-a" x="${r1(x)}" y="${r1(y)}" width="${r1(w)}" height="${M.h}" rx="${M.h / 2}" style="${_chunkOUQ44P45cjs.cs.call(void 0, M.color)};${kf}"/><line class="dg-tm-mk" x1="${r1(lx)}" y1="${r1(y - M.mark)}" x2="${r1(lx)}" y2="${r1(y + M.h + M.mark)}"/>` + _chunkOUQ44P45cjs.write.call(void 0, ctx.ink, "dg-tm-ml", lx, field.y + M.textY, text, _chunkVRAW7VAQcjs.TYPE.meterLine, _chunkOUQ44P45cjs.ALWAYS, "middle");
|
|
694
|
+
}
|
|
695
|
+
function timeFocus(layout, timeline, step, parts, vw, vh) {
|
|
696
|
+
const span = timeline.steps[step];
|
|
697
|
+
const position = valueAt(_nullishCoalesce(timeline.needle, () => ( [])), span.end - _chunkVRAW7VAQcjs.MOTION.still);
|
|
698
|
+
const nx = layout.axis.x + position * layout.axis.unit;
|
|
699
|
+
const top = Math.min(...layout.rows.map((r) => r.y));
|
|
700
|
+
const bottom = Math.max(...layout.rows.map((r) => r.y + r.h));
|
|
701
|
+
let held = { x: nx - 1, y: top, w: 2, h: bottom - top };
|
|
702
|
+
const badge = layout.badges.find((b) => b.step === step);
|
|
703
|
+
const near = (p) => Math.hypot(Math.max(0, p.x - nx, nx - p.x - p.w), Math.max(0, p.y - top, top - p.y - p.h));
|
|
704
|
+
const extra = [...badge ? [{ x: badge.x - _chunkVRAW7VAQcjs.LOOK.badge.r, y: badge.y - _chunkVRAW7VAQcjs.LOOK.badge.r, w: _chunkVRAW7VAQcjs.LOOK.badge.r * 2, h: _chunkVRAW7VAQcjs.LOOK.badge.r * 2 }] : [], ...[...parts].sort((a, b) => near(a) - near(b))];
|
|
705
|
+
for (const p of extra) {
|
|
706
|
+
const x = Math.min(held.x, p.x);
|
|
707
|
+
const y = Math.min(held.y, p.y);
|
|
708
|
+
const next = { x, y, w: Math.max(held.x + held.w, p.x + p.w) - x, h: Math.max(held.y + held.h, p.y + p.h) - y };
|
|
709
|
+
if (next.w <= vw && next.h <= vh) held = next;
|
|
710
|
+
}
|
|
711
|
+
return held;
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
|
|
715
|
+
|
|
716
|
+
|
|
717
|
+
|
|
718
|
+
exports.drawTime = drawTime; exports.layoutTime = layoutTime; exports.meterField = meterField; exports.timeFocus = timeFocus;
|
|
719
|
+
//# sourceMappingURL=time-64DJKYAL.cjs.map
|