@umriss-ui/schedule 0.1.7 → 0.2.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/schedule.js CHANGED
@@ -1,310 +1,310 @@
1
1
  import "./schedule.css";
2
- var He = Object.defineProperty;
3
- var Ye = (n, t, e) => t in n ? He(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
4
- var f = (n, t, e) => Ye(n, typeof t != "symbol" ? t + "" : t, e);
5
- import { jsxs as Y, Fragment as Wt, jsx as k } from "react/jsx-runtime";
6
- import { useContext as fe, createContext as pe, useRef as O, useEffect as x, forwardRef as Xe, useState as it, useId as Ke, useLayoutEffect as vt, useImperativeHandle as Ue, useSyncExternalStore as ze, useMemo as W } from "react";
7
- import { toOperatingTimeClamped as B, resolveColours as We, removedIntervals as qe, localOffset as me, MINUTE as q, calendarFrom as j, toWallClock as U, DAY as st, timeStep as je, operatingTimeTicks as Ve, HOUR as Tt, LinearScale as Ze, subscribeTheme as Je } from "@umriss-ui/charts";
8
- import { useFormats as ge, useWording as we, AngleGlyph as Qe } from "@umriss-ui/core";
9
- const ke = pe(null), ve = pe(null);
10
- function ye() {
11
- return fe(ve);
12
- }
13
- function ts(n) {
14
- const t = fe(ke);
2
+ var Ze = Object.defineProperty;
3
+ var Je = (o, t, e) => t in o ? Ze(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
4
+ var f = (o, t, e) => Je(o, typeof t != "symbol" ? t + "" : t, e);
5
+ import { jsxs as Y, Fragment as St, jsx as k } from "react/jsx-runtime";
6
+ import { useContext as Ce, createContext as Le, useRef as O, useEffect as H, forwardRef as Qe, useState as rt, useId as ts, useLayoutEffect as Tt, useImperativeHandle as es, useSyncExternalStore as ss, useMemo as q } from "react";
7
+ import { toOperatingTimeClamped as K, resolveColours as ns, removedIntervals as os, localOffset as Se, MINUTE as X, calendarFrom as V, toWallClock as W, DAY as ot, timeStep as is, operatingTimeTicks as rs, HOUR as Dt, LinearScale as as, subscribeTheme as ls } from "@umriss-ui/charts";
8
+ import { useFormats as Et, useWording as ut, AngleGlyph as hs, VisuallyHidden as oe } from "@umriss-ui/core";
9
+ const Ie = Le(null), Ae = Le(null);
10
+ function _e() {
11
+ return Ce(Ae);
12
+ }
13
+ function us(o) {
14
+ const t = Ce(Ie);
15
15
  if (t === null)
16
- throw new Error(`@umriss-ui/schedule: <${n}> must be used inside a <Schedule>.`);
16
+ throw new Error(`@umriss-ui/schedule: <${o}> must be used inside a <Schedule>.`);
17
17
  return t;
18
18
  }
19
- function Ct(n, t, e, s, o) {
20
- const i = ts(n), r = O(null);
21
- x(() => (r.current = e(i, t), () => {
22
- r.current !== null && o(i, r.current), r.current = null;
23
- }), [i]), x(() => {
19
+ function Pt(o, t, e, s, n) {
20
+ const i = us(o), r = O(null);
21
+ H(() => (r.current = e(i, t), () => {
22
+ r.current !== null && n(i, r.current), r.current = null;
23
+ }), [i]), H(() => {
24
24
  r.current !== null && s(i, r.current, t);
25
25
  });
26
26
  }
27
- function es(n) {
28
- Ct("Lane", n, (t, e) => t.registerLane(e), (t, e, s) => t.updateLane(e, s), (t, e) => t.unregisterLane(e));
27
+ function cs(o) {
28
+ Pt("Lane", o, (t, e) => t.registerLane(e), (t, e, s) => t.updateLane(e, s), (t, e) => t.unregisterLane(e));
29
29
  }
30
- function ss(n) {
31
- Ct("LaneGroup", n, (t, e) => t.registerGroup(e), (t, e, s) => t.updateGroup(e, s), (t, e) => t.unregisterGroup(e));
30
+ function ds(o) {
31
+ Pt("LaneGroup", o, (t, e) => t.registerGroup(e), (t, e, s) => t.updateGroup(e, s), (t, e) => t.unregisterGroup(e));
32
32
  }
33
- function be(n, t) {
34
- Ct(n, t, (e, s) => e.registerLayer(s), (e, s, o) => e.updateLayer(s, o), (e, s) => e.unregisterLayer(s));
33
+ function Fe(o, t) {
34
+ Pt(o, t, (e, s) => e.registerLayer(s), (e, s, n) => e.updateLayer(s, n), (e, s) => e.unregisterLayer(s));
35
35
  }
36
- function ht(n) {
37
- let t = !1, e = !1, s = !1, o = !1;
38
- for (const i of n ?? [])
39
- i === "provisional" ? (t = !0, e = !1) : i === "fixed" ? (e = !0, t = !1) : i === "muted" ? s = !0 : i === "open" && (o = !0);
40
- return { dashed: t, hatched: e, muted: s, open: o };
36
+ function ct(o) {
37
+ let t = !1, e = !1, s = !1, n = !1;
38
+ for (const i of o ?? [])
39
+ i === "provisional" ? (t = !0, e = !1) : i === "fixed" ? (e = !0, t = !1) : i === "muted" ? s = !0 : i === "open" && (n = !0);
40
+ return { dashed: t, hatched: e, muted: s, open: n };
41
41
  }
42
- const ns = 24, os = 4, is = 3, yt = 4;
43
- function qt(n) {
44
- const { lanes: t, groups: e, collapsed: s, laneHeight: o } = n, i = new Map(e.map((m) => [m.id, m])), r = (m) => m !== void 0 && i.has(m) ? m : void 0, a = /* @__PURE__ */ new Map(), u = (m) => {
42
+ const fs = 24, ps = 4, ms = 3, Ct = 4;
43
+ function ie(o) {
44
+ const { lanes: t, groups: e, collapsed: s, laneHeight: n } = o, i = new Map(e.map((m) => [m.id, m])), r = (m) => m !== void 0 && i.has(m) ? m : void 0, a = /* @__PURE__ */ new Map(), h = (m) => {
45
45
  const C = [];
46
46
  let L = r(m.parent);
47
- const E = /* @__PURE__ */ new Set();
48
- for (; L !== void 0 && !E.has(L); )
49
- E.add(L), C.unshift(L), L = r(i.get(L).parent);
47
+ const D = /* @__PURE__ */ new Set();
48
+ for (; L !== void 0 && !D.has(L); )
49
+ D.add(L), C.unshift(L), L = r(i.get(L).parent);
50
50
  return C;
51
51
  }, c = /* @__PURE__ */ new Map();
52
52
  for (const m of t) {
53
- const C = u(m);
53
+ const C = h(m);
54
54
  c.set(m.id, C);
55
55
  for (const L of C) {
56
- const E = a.get(L) ?? [];
57
- E.push(m.id), a.set(L, E);
56
+ const D = a.get(L) ?? [];
57
+ D.push(m.id), a.set(L, D);
58
58
  }
59
59
  }
60
60
  const l = [], d = /* @__PURE__ */ new Map();
61
- let p = [], g = null, b = 0;
62
- const I = (m) => (l.push({ ...m, top: b }), b += m.height, l.length - 1), _ = (m) => m.find((C) => s.has(C)), S = () => {
63
- if (g === null) return;
64
- const { row: m, lanes: C } = g, L = l[m], E = Math.max(L.height, C.length * os + 2 * yt);
65
- l[m] = { ...L, height: E }, b += E - L.height;
66
- const F = E - 2 * yt, R = Math.max(is, Math.floor(F / C.length));
67
- C.forEach((V, ot) => {
68
- const z = c.get(V) ?? [];
69
- d.set(V, {
70
- top: L.top + yt + ot * R,
71
- height: R,
61
+ let p = [], w = null, v = 0;
62
+ const A = (m) => (l.push({ ...m, top: v }), v += m.height, l.length - 1), _ = (m) => m.find((C) => s.has(C)), S = () => {
63
+ if (w === null) return;
64
+ const { row: m, lanes: C } = w, L = l[m], D = Math.max(L.height, C.length * ps + 2 * Ct);
65
+ l[m] = { ...L, height: D }, v += D - L.height;
66
+ const F = D - 2 * Ct, G = Math.max(ms, Math.floor(F / C.length));
67
+ C.forEach((J, it) => {
68
+ const z = c.get(J) ?? [];
69
+ d.set(J, {
70
+ top: L.top + Ct + it * G,
71
+ height: G,
72
72
  miniature: !0,
73
73
  group: z[z.length - 1]
74
74
  });
75
- }), g = null;
75
+ }), w = null;
76
76
  };
77
77
  for (const m of t) {
78
78
  const C = (c.get(m.id) ?? []).filter((F) => (a.get(F) ?? []).length > 0), L = _(C);
79
- if (g !== null && L === g.group) {
80
- g.lanes.push(m.id);
79
+ if (w !== null && L === w.group) {
80
+ w.lanes.push(m.id);
81
81
  continue;
82
82
  }
83
83
  S();
84
- const E = C.filter((F, R) => p[R] === F).length;
85
- p = p.slice(0, E);
86
- for (const F of C.slice(E)) {
84
+ const D = C.filter((F, G) => p[G] === F).length;
85
+ p = p.slice(0, D);
86
+ for (const F of C.slice(D)) {
87
87
  if (p.push(F), F === L) break;
88
- I({
88
+ A({
89
89
  kind: "groupHead",
90
90
  lane: void 0,
91
91
  group: F,
92
92
  depth: p.length - 1,
93
93
  within: [...p],
94
94
  lanes: (a.get(F) ?? []).length,
95
- height: ns
95
+ height: fs
96
96
  });
97
97
  }
98
98
  if (L !== void 0) {
99
- const F = C.indexOf(L), R = I({
99
+ const F = C.indexOf(L), G = A({
100
100
  kind: "miniature",
101
101
  lane: void 0,
102
102
  group: L,
103
103
  depth: F,
104
104
  within: C.slice(0, F + 1),
105
105
  lanes: (a.get(L) ?? []).length,
106
- height: o
106
+ height: n
107
107
  });
108
- g = { group: L, row: R, lanes: [m.id] };
108
+ w = { group: L, row: G, lanes: [m.id] };
109
109
  continue;
110
110
  }
111
- I({ kind: "lane", lane: m.id, group: C[C.length - 1], depth: C.length, within: C, lanes: 1, height: o }), d.set(m.id, {
111
+ A({ kind: "lane", lane: m.id, group: C[C.length - 1], depth: C.length, within: C, lanes: 1, height: n }), d.set(m.id, {
112
112
  top: l[l.length - 1].top,
113
- height: o,
113
+ height: n,
114
114
  miniature: !1,
115
115
  group: C[C.length - 1]
116
116
  });
117
117
  }
118
- return S(), { rows: l, slots: d, height: b };
118
+ return S(), { rows: l, slots: d, height: v };
119
119
  }
120
- function rs(n, t) {
121
- if (t.size === 0) return n;
120
+ function gs(o, t) {
121
+ if (t.size === 0) return o;
122
122
  const e = /* @__PURE__ */ new Set();
123
- for (const s of n) t.has(s) || e.add(s);
123
+ for (const s of o) t.has(s) || e.add(s);
124
124
  return e;
125
125
  }
126
- function nt(n, t) {
127
- if (t < 0 || t >= n.height) return null;
128
- let e = 0, s = n.rows.length - 1;
126
+ function Z(o, t) {
127
+ if (t < 0 || t >= o.height) return null;
128
+ let e = 0, s = o.rows.length - 1;
129
129
  for (; e <= s; ) {
130
- const o = e + s >> 1, i = n.rows[o];
131
- if (t < i.top) s = o - 1;
132
- else if (t >= i.top + i.height) e = o + 1;
130
+ const n = e + s >> 1, i = o.rows[n];
131
+ if (t < i.top) s = n - 1;
132
+ else if (t >= i.top + i.height) e = n + 1;
133
133
  else return i;
134
134
  }
135
135
  return null;
136
136
  }
137
- function Lt(n, t) {
138
- return n.slots.get(t) ?? null;
137
+ function Rt(o, t) {
138
+ return o.slots.get(t) ?? null;
139
139
  }
140
- function as(n, t) {
141
- const e = nt(n, t);
140
+ function ks(o, t) {
141
+ const e = Z(o, t);
142
142
  if (e === null) return null;
143
143
  if (e.kind === "lane") return e.lane ?? null;
144
144
  if (e.kind === "groupHead") return null;
145
- for (const [s, o] of n.slots)
146
- if (o.miniature && t >= o.top && t < o.top + o.height) return s;
145
+ for (const [s, n] of o.slots)
146
+ if (n.miniature && t >= n.top && t < n.top + n.height) return s;
147
147
  return null;
148
148
  }
149
- function ut(n) {
150
- return { from: n.from - (n.setup ?? 0), to: n.to + (n.teardown ?? 0) };
149
+ function dt(o) {
150
+ return { from: o.from - (o.setup ?? 0), to: o.to + (o.teardown ?? 0) };
151
151
  }
152
- function St(n, t) {
153
- return (n.leaves ?? "teardown") === "main" ? t.to : t.to + (t.teardown ?? 0);
152
+ function xt(o, t) {
153
+ return (o.leaves ?? "teardown") === "main" ? t.to : t.to + (t.teardown ?? 0);
154
154
  }
155
- function It(n, t) {
156
- return (n.arrives ?? "setup") === "main" ? t.from : t.from - (t.setup ?? 0);
155
+ function Nt(o, t) {
156
+ return (o.arrives ?? "setup") === "main" ? t.from : t.from - (t.setup ?? 0);
157
157
  }
158
- function jt(n, t) {
159
- if (t.kind === "place" || t.subtask !== n.id) return n;
158
+ function re(o, t) {
159
+ if (t.kind === "place" || t.subtask !== o.id) return o;
160
160
  switch (t.kind) {
161
161
  case "move":
162
162
  case "stretch":
163
- return { ...n, from: t.from, to: t.to };
163
+ return { ...o, from: t.from, to: t.to };
164
164
  case "setup":
165
- return { ...n, setup: t.setup };
165
+ return { ...o, setup: t.setup };
166
166
  case "teardown":
167
- return { ...n, teardown: t.teardown };
167
+ return { ...o, teardown: t.teardown };
168
168
  case "lane":
169
- return { ...n, lane: t.lane };
169
+ return { ...o, lane: t.lane };
170
170
  }
171
171
  }
172
- function _n(n, t) {
172
+ function Vn(o, t) {
173
173
  return {
174
174
  id: t,
175
- task: n.task,
176
- lane: n.lane,
177
- from: n.from,
178
- to: n.to,
179
- ...n.setup === void 0 ? {} : { setup: n.setup },
180
- ...n.teardown === void 0 ? {} : { teardown: n.teardown }
175
+ task: o.task,
176
+ lane: o.lane,
177
+ from: o.from,
178
+ to: o.to,
179
+ ...o.setup === void 0 ? {} : { setup: o.setup },
180
+ ...o.teardown === void 0 ? {} : { teardown: o.teardown }
181
181
  };
182
182
  }
183
- const ls = 6, Me = 3, et = 2, Vt = 3, Zt = 3;
184
- function N(n, t) {
185
- return Math.round(n.scale.toPx(B(t, n.calendar)));
183
+ const ws = 6, De = 3, nt = 2, ae = 3, le = 3;
184
+ function R(o, t) {
185
+ return Math.round(o.scale.toPx(K(t, o.calendar)));
186
186
  }
187
- function ct(n, t) {
188
- const e = Lt(n.rows, t);
189
- return e === null ? null : { ...e, top: e.top - n.scrollY };
187
+ function ft(o, t) {
188
+ const e = Rt(o.rows, t);
189
+ return e === null ? null : { ...e, top: e.top - o.scrollY };
190
190
  }
191
- function Jt(n, t) {
192
- return as(n.rows, t + n.scrollY);
191
+ function he(o, t) {
192
+ return ks(o.rows, t + o.scrollY);
193
193
  }
194
- function Te(n, t, e, s, o) {
195
- const i = s.miniature ? 0 : ls, r = s.miniature ? 0 : Zt * Vt, a = Math.max(s.miniature ? 1 : 4, s.height - 2 * i - r), u = s.top - n.scrollY + Math.floor((s.height - a) / 2), c = ut(t);
194
+ function Ee(o, t, e, s, n) {
195
+ const i = s.miniature ? 0 : ws, r = s.miniature ? 0 : le * ae, a = Math.max(s.miniature ? 1 : 4, s.height - 2 * i - r), h = s.top - o.scrollY + Math.floor((s.height - a) / 2), c = dt(t);
196
196
  return {
197
197
  subtask: t,
198
198
  lane: e,
199
199
  miniature: s.miniature,
200
- depth: o,
201
- y: u + (s.miniature ? 0 : Math.min(o, Zt) * Vt),
200
+ depth: n,
201
+ y: h + (s.miniature ? 0 : Math.min(n, le) * ae),
202
202
  height: a,
203
- outerFrom: N(n, c.from),
204
- mainFrom: N(n, t.from),
205
- mainTo: N(n, t.to),
206
- outerTo: N(n, c.to)
203
+ outerFrom: R(o, c.from),
204
+ mainFrom: R(o, t.from),
205
+ mainTo: R(o, t.to),
206
+ outerTo: R(o, c.to)
207
207
  };
208
208
  }
209
- function Ce(n, t, e) {
210
- if (e < n.y || e > n.y + n.height) return null;
211
- const s = Math.max(0, (6 - (n.outerTo - n.outerFrom)) / 2);
212
- return t < n.outerFrom - s || t > n.outerTo + s ? null : t < n.mainFrom ? "setup" : t > n.mainTo ? "teardown" : "main";
209
+ function Pe(o, t, e) {
210
+ if (e < o.y || e > o.y + o.height) return null;
211
+ const s = Math.max(0, (6 - (o.outerTo - o.outerFrom)) / 2);
212
+ return t < o.outerFrom - s || t > o.outerTo + s ? null : t < o.mainFrom ? "setup" : t > o.mainTo ? "teardown" : "main";
213
213
  }
214
- function hs(n, t, e, s = 5) {
215
- if (e < n.y || e > n.y + n.height) return null;
216
- const o = Math.abs(t - n.mainFrom), i = Math.abs(t - n.mainTo);
217
- return Math.min(o, i) > s ? null : o <= i ? "from" : "to";
214
+ function ys(o, t, e, s = 5) {
215
+ if (e < o.y || e > o.y + o.height) return null;
216
+ const n = Math.abs(t - o.mainFrom), i = Math.abs(t - o.mainTo);
217
+ return Math.min(n, i) > s ? null : n <= i ? "from" : "to";
218
218
  }
219
- function Le(n, t, e) {
220
- return n.outerTo >= 0 && n.outerFrom <= t && n.y + n.height >= 0 && n.y <= e;
219
+ function It(o, t, e) {
220
+ return o.outerTo >= 0 && o.outerFrom <= t && o.y + o.height >= 0 && o.y <= e;
221
221
  }
222
- const us = 64;
223
- function cs(n, t) {
224
- if (n.miniature) return null;
225
- const e = ht(n.subtask.appearance).hatched ? et + Me + 1 : 0, s = Math.max(n.mainFrom + e, 0), o = Math.min(n.mainTo - e, t) - s;
226
- return o < us ? null : { x: s, width: o, y: n.y, height: n.height };
222
+ const vs = 64;
223
+ function bs(o, t) {
224
+ if (o.miniature) return null;
225
+ const e = ct(o.subtask.appearance).hatched ? nt + De + 1 : 0, s = Math.max(o.mainFrom + e, 0), n = Math.min(o.mainTo - e, t) - s;
226
+ return n < vs ? null : { x: s, width: n, y: o.y, height: o.height };
227
227
  }
228
- const ds = 10;
229
- function Qt(n, t, e) {
228
+ const Ms = 10;
229
+ function ue(o, t, e) {
230
230
  const s = Math.round(t.y + t.height / 2);
231
- return n === "centre" || e.y === t.y ? s : Math.round(e.y > t.y ? t.y + t.height - 1 : t.y + 1);
231
+ return o === "centre" || e.y === t.y ? s : Math.round(e.y > t.y ? t.y + t.height - 1 : t.y + 1);
232
232
  }
233
- function bt(n, t, e, s, o) {
234
- const i = t.route ?? o.route, r = t.attach ?? o.attach, a = t.ends ?? o.ends, u = N(n, St(t, e.subtask)), c = N(n, It(t, s.subtask)), l = Qt(r, e, s), d = Qt(r, s, e);
233
+ function At(o, t, e, s, n) {
234
+ const i = t.route ?? n.route, r = t.attach ?? n.attach, a = t.ends ?? n.ends, h = R(o, xt(t, e.subtask)), c = R(o, Nt(t, s.subtask)), l = ue(r, e, s), d = ue(r, s, e);
235
235
  if (i === "straight")
236
- return { transport: t, kind: i, ends: a, x1: u, y1: l, x2: c, y2: d, c1x: u, c2x: c, points: [u, l, c, d] };
236
+ return { transport: t, kind: i, ends: a, x1: h, y1: l, x2: c, y2: d, c1x: h, c2x: c, points: [h, l, c, d] };
237
237
  if (i === "orthogonal") {
238
- const _ = u + ds, S = l === d ? _ : Math.round((_ + c) / 2);
239
- return { transport: t, kind: i, ends: a, x1: u, y1: l, x2: c, y2: d, c1x: u, c2x: c, points: l === d ? [u, l, c, d] : [u, l, S, l, S, d, c, d] };
238
+ const _ = h + Ms, S = l === d ? _ : Math.round((_ + c) / 2);
239
+ return { transport: t, kind: i, ends: a, x1: h, y1: l, x2: c, y2: d, c1x: h, c2x: c, points: l === d ? [h, l, c, d] : [h, l, S, l, S, d, c, d] };
240
240
  }
241
- const p = Math.max(14, Math.abs(c - u) / 2), g = u + p, b = c - p, I = [];
241
+ const p = Math.max(14, Math.abs(c - h) / 2), w = h + p, v = c - p, A = [];
242
242
  for (let _ = 0; _ <= 16; _++) {
243
243
  const S = _ / 16, m = 1 - S;
244
- I.push(
245
- m * m * m * u + 3 * m * m * S * g + 3 * m * S * S * b + S * S * S * c,
244
+ A.push(
245
+ m * m * m * h + 3 * m * m * S * w + 3 * m * S * S * v + S * S * S * c,
246
246
  m * m * m * l + 3 * m * m * S * l + 3 * m * S * S * d + S * S * S * d
247
247
  );
248
248
  }
249
- return { transport: t, kind: "curve", ends: a, x1: u, y1: l, x2: c, y2: d, c1x: g, c2x: b, points: I };
249
+ return { transport: t, kind: "curve", ends: a, x1: h, y1: l, x2: c, y2: d, c1x: w, c2x: v, points: A };
250
250
  }
251
- function fs(n, t, e) {
251
+ function Ts(o, t, e) {
252
252
  let s = 1 / 0;
253
- const o = n.points;
254
- for (let i = 0; i + 3 < o.length; i += 2) {
255
- const r = o[i], a = o[i + 1], u = o[i + 2], c = o[i + 3], l = u - r, d = c - a, p = l * l + d * d, g = p === 0 ? 0 : Math.max(0, Math.min(1, ((t - r) * l + (e - a) * d) / p));
256
- s = Math.min(s, Math.hypot(t - (r + g * l), e - (a + g * d)));
253
+ const n = o.points;
254
+ for (let i = 0; i + 3 < n.length; i += 2) {
255
+ const r = n[i], a = n[i + 1], h = n[i + 2], c = n[i + 3], l = h - r, d = c - a, p = l * l + d * d, w = p === 0 ? 0 : Math.max(0, Math.min(1, ((t - r) * l + (e - a) * d) / p));
256
+ s = Math.min(s, Math.hypot(t - (r + w * l), e - (a + w * d)));
257
257
  }
258
258
  return s;
259
259
  }
260
- function At(n) {
260
+ function Gt(o) {
261
261
  const t = [], e = /* @__PURE__ */ new Map();
262
- n.forEach((s, o) => {
263
- const { from: i, to: r } = ut(s);
262
+ o.forEach((s, n) => {
263
+ const { from: i, to: r } = dt(s);
264
264
  if (!(i < r)) return;
265
265
  const a = e.get(s.lane) ?? [];
266
- a.push({ subtask: s, index: o, from: i, to: r }), e.set(s.lane, a);
266
+ a.push({ subtask: s, index: n, from: i, to: r }), e.set(s.lane, a);
267
267
  });
268
- for (const [s, o] of e) {
269
- o.sort((i, r) => i.from - r.from || i.index - r.index);
270
- for (let i = 0; i < o.length; i++) {
271
- const r = o[i];
272
- for (let a = i + 1; a < o.length; a++) {
273
- const u = o[a];
274
- if (u.from >= r.to) break;
275
- t.push({ lane: s, first: r.subtask.id, second: u.subtask.id, from: u.from, to: Math.min(r.to, u.to) });
268
+ for (const [s, n] of e) {
269
+ n.sort((i, r) => i.from - r.from || i.index - r.index);
270
+ for (let i = 0; i < n.length; i++) {
271
+ const r = n[i];
272
+ for (let a = i + 1; a < n.length; a++) {
273
+ const h = n[a];
274
+ if (h.from >= r.to) break;
275
+ t.push({ lane: s, first: r.subtask.id, second: h.subtask.id, from: h.from, to: Math.min(r.to, h.to) });
276
276
  }
277
277
  }
278
278
  }
279
279
  return t;
280
280
  }
281
- function ps(n) {
281
+ function Cs(o) {
282
282
  const t = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map();
283
- for (const s of n) {
284
- const o = ut(s), i = e.get(s.lane) ?? [];
283
+ for (const s of o) {
284
+ const n = dt(s), i = e.get(s.lane) ?? [];
285
285
  let r = 0;
286
- if (o.from < o.to) {
287
- for (const a of i) o.from < a.to && a.from < o.to && r++;
288
- i.push(o);
286
+ if (n.from < n.to) {
287
+ for (const a of i) n.from < a.to && a.from < n.to && r++;
288
+ i.push(n);
289
289
  }
290
290
  e.set(s.lane, i), t.set(s.id, r);
291
291
  }
292
292
  return t;
293
293
  }
294
- function _t(n, t) {
295
- const e = new Map(n.map((o) => [o.id, o])), s = [];
296
- for (const o of t) {
297
- const i = e.get(o.from), r = e.get(o.to);
294
+ function $t(o, t) {
295
+ const e = new Map(o.map((n) => [n.id, n])), s = [];
296
+ for (const n of t) {
297
+ const i = e.get(n.from), r = e.get(n.to);
298
298
  if (i === void 0 || r === void 0) continue;
299
- const a = St(o, i), u = It(o, r), c = a + o.duration - u;
300
- c > 0 && s.push({ transport: o.id, departure: a, arrival: u, shortBy: c });
299
+ const a = xt(n, i), h = Nt(n, r), c = a + n.duration - h;
300
+ c > 0 && s.push({ transport: n.id, departure: a, arrival: h, shortBy: c });
301
301
  }
302
302
  return s;
303
303
  }
304
- function Fn(n, t) {
305
- return { overlaps: At(n), lateTransports: _t(n, t) };
304
+ function Zn(o, t) {
305
+ return { overlaps: Gt(o), lateTransports: $t(o, t) };
306
306
  }
307
- class ms {
307
+ class Ls {
308
308
  /** `changed` is called after every registration change. */
309
309
  constructor(t) {
310
310
  f(this, "nextId", 1);
@@ -365,7 +365,7 @@ class ms {
365
365
  rebuild() {
366
366
  if (!this.dirty) return !1;
367
367
  this.dirty = !1;
368
- const t = (e) => [...e.keys()].sort((s, o) => s - o).map((s) => e.get(s));
368
+ const t = (e) => [...e.keys()].sort((s, n) => s - n).map((s) => e.get(s));
369
369
  this.lanes = t(this.laneEntries), this.groups = t(this.groupEntries), this.laneIndex = new Map(this.lanes.map((e, s) => [e.id, s])), this.layers = t(this.layerEntries), this.subtasks = [], this.transports = [], this.tasks = /* @__PURE__ */ new Map();
370
370
  for (const e of this.layers)
371
371
  if (e.kind === "subtasks") {
@@ -373,7 +373,7 @@ class ms {
373
373
  for (const s of e.tasks) this.tasks.set(s.id, s);
374
374
  } else
375
375
  this.transports.push(...e.data);
376
- return this.subtaskById = new Map(this.subtasks.map((e) => [e.id, e])), this.overlaps = At(this.subtasks), this.lateById = new Map(_t(this.subtasks, this.transports).map((e) => [e.transport, e])), this.depth = ps(this.subtasks), !0;
376
+ return this.subtaskById = new Map(this.subtasks.map((e) => [e.id, e])), this.overlaps = Gt(this.subtasks), this.lateById = new Map($t(this.subtasks, this.transports).map((e) => [e.transport, e])), this.depth = Cs(this.subtasks), !0;
377
377
  }
378
378
  /** The task a transport belongs to: its departing subtask's. */
379
379
  taskOfTransport(t) {
@@ -384,7 +384,7 @@ class ms {
384
384
  data knows about it - its task, and the findings it stands in. */
385
385
  tooltipTargetFor(t) {
386
386
  if (t.kind === "subtask") {
387
- const o = t.subtask.id, i = this.overlaps.filter((a) => a.first === o || a.second === o).map((a) => this.subtaskById.get(a.first === o ? a.second : a.first)).filter((a) => a !== void 0), r = this.transports.filter((a) => a.from === o || a.to === o).map((a) => this.lateById.get(a.id)).filter((a) => a !== void 0);
387
+ const n = t.subtask.id, i = this.overlaps.filter((a) => a.first === n || a.second === n).map((a) => this.subtaskById.get(a.first === n ? a.second : a.first)).filter((a) => a !== void 0), r = this.transports.filter((a) => a.from === n || a.to === n).map((a) => this.lateById.get(a.id)).filter((a) => a !== void 0);
388
388
  return { kind: "subtask", subtask: t.subtask, task: this.tasks.get(t.subtask.task), overlapping: i, lateTransports: r };
389
389
  }
390
390
  if (t.kind !== "transport") return null;
@@ -399,309 +399,333 @@ class ms {
399
399
  };
400
400
  }
401
401
  }
402
- const gs = {
402
+ const Ss = {
403
403
  line: "var(--u-hairline)",
404
404
  lineStrong: "var(--u-hairline-strong)",
405
405
  text: "var(--u-color-text)",
406
406
  muted: "var(--u-color-text-muted)",
407
407
  alarm: "var(--u-color-danger)",
408
408
  surface: "var(--u-color-surface)",
409
- accent: "var(--u-color-accent)",
409
+ /* The active subtask's mark - drawn in a colour of its own only under
410
+ forced colours; outside them it is the hover's wash (`drawHover`). */
411
+ active: "var(--u-color-accent)",
412
+ now: "var(--u-color-accent)",
410
413
  /* What text and marks take ON a filled bar - the same token the bar labels
411
414
  use in CSS, so a cap and the label beside it are one colour. */
412
415
  onAccent: "var(--u-color-on-accent)"
413
- };
414
- function ws(n, t) {
415
- const e = {};
416
- for (const i of t.tasks.values()) e[`task:${i.id}`] = i.color;
417
- const s = We(n, { ...gs, ...e }), o = /* @__PURE__ */ new Map();
418
- for (const i of t.tasks.values()) o.set(i.id, s[`task:${i.id}`] ?? i.color);
416
+ }, Re = {
417
+ line: "GrayText",
418
+ lineStrong: "CanvasText",
419
+ text: "CanvasText",
420
+ muted: "GrayText",
421
+ alarm: "CanvasText",
422
+ surface: "Canvas",
423
+ active: "Highlight",
424
+ now: "GrayText",
425
+ onAccent: "Canvas"
426
+ }, Is = (o) => o ? Re : Ss, As = () => typeof window < "u" && typeof window.matchMedia == "function" && window.matchMedia("(forced-colors: active)").matches;
427
+ function _s(o, t) {
428
+ const e = As(), s = {};
429
+ for (const r of t.tasks.values()) s[`task:${r.id}`] = e ? Re.text : r.color;
430
+ const n = ns(o, { ...Is(e), ...s }), i = /* @__PURE__ */ new Map();
431
+ for (const r of t.tasks.values()) i.set(r.id, n[`task:${r.id}`] ?? r.color);
419
432
  return {
420
- line: s.line,
421
- lineStrong: s.lineStrong,
422
- text: s.text,
423
- muted: s.muted,
424
- alarm: s.alarm,
425
- surface: s.surface,
426
- accent: s.accent,
427
- onAccent: s.onAccent,
428
- tasks: o
433
+ line: n.line,
434
+ lineStrong: n.lineStrong,
435
+ text: n.text,
436
+ muted: n.muted,
437
+ alarm: n.alarm,
438
+ surface: n.surface,
439
+ active: n.active,
440
+ now: n.now,
441
+ onAccent: n.onAccent,
442
+ tasks: i,
443
+ forced: e
429
444
  };
430
445
  }
431
- function at(n) {
432
- const t = n.match(/[\d.]+/g);
446
+ function lt(o) {
447
+ const t = o.match(/[\d.]+/g);
433
448
  return t === null || t.length < 3 ? null : [Number(t[0]), Number(t[1]), Number(t[2])];
434
449
  }
435
- function te(n) {
436
- const t = at(n);
450
+ function ce(o) {
451
+ const t = lt(o);
437
452
  if (t === null) return 0;
438
- const [e, s, o] = t.map((i) => {
453
+ const [e, s, n] = t.map((i) => {
439
454
  const r = i / 255;
440
455
  return r <= 0.04045 ? r / 12.92 : ((r + 0.055) / 1.055) ** 2.4;
441
456
  });
442
- return 0.2126 * e + 0.7152 * s + 0.0722 * o;
457
+ return 0.2126 * e + 0.7152 * s + 0.0722 * n;
443
458
  }
444
- function ee(n, t) {
445
- const e = te(n), s = te(t);
459
+ function de(o, t) {
460
+ const e = ce(o), s = ce(t);
446
461
  return (Math.max(e, s) + 0.05) / (Math.min(e, s) + 0.05);
447
462
  }
448
- function se(n, t, e) {
449
- if (n === null) return null;
450
- const s = typeof window > "u" ? 1 : window.devicePixelRatio || 1, o = Math.round(t * s), i = Math.round(e * s);
451
- n.width !== o && (n.width = o), n.height !== i && (n.height = i);
452
- const r = n.getContext("2d");
463
+ function fe(o, t, e) {
464
+ if (o === null) return null;
465
+ const s = typeof window > "u" ? 1 : window.devicePixelRatio || 1, n = Math.round(t * s), i = Math.round(e * s);
466
+ o.width !== n && (o.width = n), o.height !== i && (o.height = i);
467
+ const r = o.getContext("2d");
453
468
  return r === null ? null : (r.setTransform(s, 0, 0, s, 0, 0), r.clearRect(0, 0, t, e), r);
454
469
  }
455
- function ks(n, t) {
456
- const { data: e, view: s } = t, o = s.viewport();
457
- Ms(n, t, o), Ts(n, t);
470
+ function Fs(o, t) {
471
+ const { data: e, view: s } = t, n = s.viewport();
472
+ Rs(o, t, n), xs(o, t);
458
473
  for (const i of e.layers) {
459
474
  const r = new Set(i.data);
460
475
  if (i.kind === "transports")
461
- for (const a of s.paths) r.has(a.transport) && Mt(n, t, a, !1);
476
+ for (const a of s.paths) r.has(a.transport) && _t(o, t, a, !1);
462
477
  else
463
- for (const a of s.boxes) r.has(a.subtask) && Ie(n, t, a, 1);
478
+ for (const a of s.boxes) r.has(a.subtask) && Ne(o, t, a, 1);
464
479
  }
465
- for (const i of e.overlaps) Ae(n, t, o, i);
466
- Es(n, t, o), Ns(n, t);
480
+ for (const i of e.overlaps) Ge(o, t, n, i);
481
+ Ks(o, t, n), Ws(o, t);
467
482
  }
468
- function vs(n, t) {
469
- const { view: e, hover: s } = t, o = e.viewport();
483
+ function Ds(o, t) {
484
+ const { view: e, hover: s } = t, n = e.viewport();
470
485
  if (t.ghost === null) {
471
486
  if (s.kind === "subtask") {
472
487
  const l = e.boxById.get(s.subtask.id);
473
- l !== void 0 && Ds(n, t, l);
488
+ l !== void 0 && Us(o, t, l);
474
489
  } else if (s.kind === "transport") {
475
490
  const l = e.paths.find((d) => d.transport === s.transport);
476
- l !== void 0 && Mt(n, t, l, !0);
491
+ l !== void 0 && _t(o, t, l, !0);
477
492
  }
478
493
  return;
479
494
  }
480
495
  const { ghost: i, overlaps: r, late: a } = t.ghost;
481
- ys(n, t, o, t.ghost.refusedLanes);
482
- const u = Se(o, i);
483
- if (u === null) return;
484
- for (const l of r) Ae(n, t, o, l);
496
+ Es(o, t, n, t.ghost.refusedLanes);
497
+ const h = xe(n, i);
498
+ if (h === null) return;
499
+ for (const l of r) Ge(o, t, n, l);
485
500
  const c = new Set(a.map((l) => l.transport));
486
501
  for (const l of t.data.transports) {
487
502
  if (l.from !== i.id && l.to !== i.id) continue;
488
503
  const d = e.boxById.get(l.from === i.id ? l.to : l.from);
489
504
  if (d === void 0) continue;
490
- const p = l.from === i.id ? bt(o, l, u, d, e.options) : bt(o, l, d, u, e.options);
491
- Mt(n, t, p, !0, c.has(l.id));
505
+ const p = l.from === i.id ? At(n, l, h, d, e.options) : At(n, l, d, h, e.options);
506
+ _t(o, t, p, !0, c.has(l.id));
492
507
  }
493
- Ie(n, t, u, 0.55), n.strokeStyle = t.colours.text, n.lineWidth = 1, n.setLineDash([3, 2]), n.strokeRect(u.outerFrom + 0.5, u.y + 0.5, Math.max(1, u.outerTo - u.outerFrom - 1), u.height - 1), n.setLineDash([]), t.ghost.tether !== null && bs(n, t, u, t.ghost.tether);
508
+ Ne(o, t, h, 0.55), o.strokeStyle = t.colours.text, o.lineWidth = 1, o.setLineDash([3, 2]), o.strokeRect(h.outerFrom + 0.5, h.y + 0.5, Math.max(1, h.outerTo - h.outerFrom - 1), h.height - 1), o.setLineDash([]), t.ghost.tether !== null && Ps(o, t, h, t.ghost.tether);
494
509
  }
495
- function ys(n, t, e, s) {
510
+ function Es(o, t, e, s) {
496
511
  if (s.size === 0) return;
497
- const { width: o, height: i } = t.view;
512
+ const { width: n, height: i } = t.view;
498
513
  for (const r of s) {
499
- const a = ct(e, r);
514
+ const a = ft(e, r);
500
515
  if (a === null) continue;
501
- const { top: u, height: c } = a;
502
- u + c < 0 || u > i || (n.globalAlpha = 0.6, n.fillStyle = t.colours.surface, n.fillRect(0, u, o, c), n.globalAlpha = 1, _s(n, 0, u, o, c, t.colours.muted, 0.7, Is, 1));
516
+ const { top: h, height: c } = a;
517
+ h + c < 0 || h > i || (o.globalAlpha = 0.6, o.fillStyle = t.colours.surface, o.fillRect(0, h, n, c), o.globalAlpha = 1, Hs(o, 0, h, n, c, t.colours.muted, 0.7, Bs, 1));
503
518
  }
504
519
  }
505
- function bs(n, t, e, s) {
506
- const o = Math.max(e.outerFrom, Math.min(e.outerTo, s.x)), i = Math.max(e.y, Math.min(e.y + e.height, s.y));
507
- Math.hypot(s.x - o, s.y - i) < 2 || (n.strokeStyle = t.colours.text, n.lineWidth = 1, n.setLineDash([2, 3]), n.beginPath(), n.moveTo(o + 0.5, i + 0.5), n.lineTo(s.x + 0.5, s.y + 0.5), n.stroke(), n.setLineDash([]));
520
+ function Ps(o, t, e, s) {
521
+ const n = Math.max(e.outerFrom, Math.min(e.outerTo, s.x)), i = Math.max(e.y, Math.min(e.y + e.height, s.y));
522
+ Math.hypot(s.x - n, s.y - i) < 2 || (o.strokeStyle = t.colours.text, o.lineWidth = 1, o.setLineDash([2, 3]), o.beginPath(), o.moveTo(n + 0.5, i + 0.5), o.lineTo(s.x + 0.5, s.y + 0.5), o.stroke(), o.setLineDash([]));
508
523
  }
509
- function Se(n, t) {
510
- const e = Lt(n.rows, t.lane);
511
- return e === null ? null : Te(n, t, t.lane, e, 0);
524
+ function xe(o, t) {
525
+ const e = Rt(o.rows, t.lane);
526
+ return e === null ? null : Ee(o, t, t.lane, e, 0);
512
527
  }
513
- function Ms(n, t, e) {
514
- const { view: s, colours: o, bands: i } = t, { width: r, height: a } = s;
515
- n.lineWidth = 1, n.strokeStyle = o.line, n.beginPath();
528
+ function Rs(o, t, e) {
529
+ const { view: s, colours: n, bands: i } = t, { width: r, height: a } = s;
530
+ o.lineWidth = 1, o.strokeStyle = n.line, o.beginPath();
516
531
  for (const l of i.ticks)
517
- n.moveTo(l.x + 0.5, 0), n.lineTo(l.x + 0.5, a);
532
+ o.moveTo(l.x + 0.5, 0), o.lineTo(l.x + 0.5, a);
518
533
  for (const l of e.rows.rows) {
519
534
  const d = l.top + l.height - e.scrollY - 0.5;
520
- d < 0 || d > a || (n.moveTo(0, d), n.lineTo(r, d));
535
+ d < 0 || d > a || (o.moveTo(0, d), o.lineTo(r, d));
521
536
  }
522
- const u = [...e.rows.slots.values()].filter((l) => l.miniature).sort((l, d) => l.top - d.top);
523
- u.forEach((l, d) => {
524
- const p = u[d + 1];
537
+ const h = [...e.rows.slots.values()].filter((l) => l.miniature).sort((l, d) => l.top - d.top);
538
+ h.forEach((l, d) => {
539
+ const p = h[d + 1];
525
540
  if (p === void 0 || p.top !== l.top + l.height || p.group === l.group) return;
526
- const g = l.top + l.height - e.scrollY - 0.5;
527
- g < 0 || g > a || (n.moveTo(0, g), n.lineTo(r, g));
528
- }), n.stroke(), n.strokeStyle = o.lineStrong, n.beginPath();
541
+ const w = l.top + l.height - e.scrollY - 0.5;
542
+ w < 0 || w > a || (o.moveTo(0, w), o.lineTo(r, w));
543
+ }), o.stroke(), o.strokeStyle = n.lineStrong, o.beginPath();
529
544
  for (const l of i.days)
530
- n.moveTo(l.x + 0.5, 0), n.lineTo(l.x + 0.5, a);
531
- n.stroke();
532
- const c = qe(s.options.calendar);
545
+ o.moveTo(l.x + 0.5, 0), o.lineTo(l.x + 0.5, a);
546
+ o.stroke();
547
+ const c = os(s.options.calendar);
533
548
  if (c.length > 0) {
534
- n.strokeStyle = o.muted, n.setLineDash([2, 3]), n.beginPath();
549
+ o.strokeStyle = n.muted, o.setLineDash([2, 3]), o.beginPath();
535
550
  for (const l of c) {
536
551
  const d = Math.round(e.scale.toPx(l.operatingTime)) + 0.5;
537
- d < 0 || d > r || (n.moveTo(d, 0), n.lineTo(d, a));
552
+ d < 0 || d > r || (o.moveTo(d, 0), o.lineTo(d, a));
538
553
  }
539
- n.stroke(), n.setLineDash([]);
554
+ o.stroke(), o.setLineDash([]);
540
555
  }
541
556
  }
542
- function Ts(n, t) {
557
+ function xs(o, t) {
543
558
  const e = t.view.nowX();
544
- e !== null && (n.fillStyle = t.colours.accent, n.fillRect(e, 0, 2, t.view.height));
559
+ e !== null && (o.fillStyle = t.colours.now, o.fillRect(e, 0, 2, t.view.height));
545
560
  }
546
- function Cs(n, t, e, s) {
547
- const o = t.colours.tasks.get(e.subtask.task) ?? t.colours.muted;
548
- n.fillStyle = o;
561
+ function Ns(o, t, e, s) {
562
+ const n = t.colours.tasks.get(e.subtask.task) ?? t.colours.muted;
563
+ o.fillStyle = n;
549
564
  for (const [i, r] of [
550
565
  [e.outerFrom, e.mainFrom],
551
566
  [e.mainTo, e.outerTo]
552
567
  ])
553
- r <= i || (n.globalAlpha = 0.28 * s, n.fillRect(i, e.y, r - i, e.height));
554
- n.globalAlpha = s, n.fillRect(e.mainFrom, e.y, Math.max(1, e.mainTo - e.mainFrom), e.height), n.globalAlpha = 1;
555
- }
556
- function Ft(n, t, e) {
557
- if (n.dashed) return { fill: null, onDark: !1 };
558
- const s = n.muted ? Ls(t, e.surface, 0.5) : t;
559
- return { fill: s, onDark: ee(s, e.onAccent) > ee(s, e.text) };
560
- }
561
- function Ls(n, t, e) {
562
- const s = at(n), o = at(t);
563
- if (s === null || o === null) return n;
564
- const i = (r) => Math.round(s[r] + (o[r] - s[r]) * e);
568
+ r <= i || (o.globalAlpha = 0.28 * s, o.fillRect(i, e.y, r - i, e.height));
569
+ o.globalAlpha = s, o.fillRect(e.mainFrom, e.y, Math.max(1, e.mainTo - e.mainFrom), e.height), o.globalAlpha = 1;
570
+ }
571
+ function Bt(o, t, e) {
572
+ if (o.dashed) return { fill: null, onDark: !1 };
573
+ const s = o.muted ? Gs(t, e.surface, 0.5) : t;
574
+ return { fill: s, onDark: de(s, e.onAccent) > de(s, e.text) };
575
+ }
576
+ function Gs(o, t, e) {
577
+ const s = lt(o), n = lt(t);
578
+ if (s === null || n === null) return o;
579
+ const i = (r) => Math.round(s[r] + (n[r] - s[r]) * e);
565
580
  return `rgb(${i(0)}, ${i(1)}, ${i(2)})`;
566
581
  }
567
- const Ss = 2;
568
- function Ie(n, t, e, s) {
569
- const { view: o, colours: i } = t;
570
- if (!Le(e, o.width, o.height)) return;
582
+ const $s = 2;
583
+ function Ne(o, t, e, s) {
584
+ const { view: n, colours: i } = t;
585
+ if (!It(e, n.width, n.height)) return;
571
586
  if (e.miniature) {
572
- Cs(n, t, e, s);
587
+ Ns(o, t, e, s);
573
588
  return;
574
589
  }
575
- const r = ht(e.subtask.appearance), a = i.tasks.get(e.subtask.task) ?? i.muted, u = Ft(r, a, i), c = e.y, l = e.height, d = Math.max(1, e.mainTo - e.mainFrom), p = u.onDark ? i.onAccent : i.text;
576
- n.lineWidth = 1, n.fillStyle = a, n.strokeStyle = a;
577
- for (const [b, I] of [
590
+ const r = ct(e.subtask.appearance), a = i.tasks.get(e.subtask.task) ?? i.muted, h = Bt(r, a, i), c = e.y, l = e.height, d = Math.max(1, e.mainTo - e.mainFrom), p = h.onDark ? i.onAccent : i.text;
591
+ o.lineWidth = 1, o.fillStyle = a, o.strokeStyle = a;
592
+ for (const [v, A] of [
578
593
  [e.outerFrom, e.mainFrom],
579
594
  [e.mainTo, e.outerTo]
580
595
  ])
581
- I <= b || (n.globalAlpha = 0.28 * s, n.fillRect(b, c, I - b, l), n.globalAlpha = s, n.strokeRect(b + 0.5, c + 0.5, I - b - 1, l - 1));
582
- u.fill !== null && (n.globalAlpha = s, n.fillStyle = u.fill, n.fillRect(e.mainFrom, c, d, l));
583
- const g = e.subtask.progress;
584
- if (g !== void 0) {
585
- const b = Math.min(4, Math.max(2, Math.round(l / 6))), I = c + l - b - Ss, _ = Math.round(d * Math.max(0, Math.min(1, g)));
586
- n.fillStyle = u.fill === null ? a : p, n.globalAlpha = 0.3 * s, n.fillRect(e.mainFrom, I, d, b), n.globalAlpha = s, _ > 0 && n.fillRect(e.mainFrom, I, _, b);
596
+ A <= v || (o.globalAlpha = 0.28 * s, o.fillRect(v, c, A - v, l), o.globalAlpha = s, o.strokeRect(v + 0.5, c + 0.5, A - v - 1, l - 1));
597
+ h.fill !== null && (o.globalAlpha = s, o.fillStyle = h.fill, o.fillRect(e.mainFrom, c, d, l));
598
+ const w = e.subtask.progress;
599
+ if (w !== void 0) {
600
+ const v = Math.min(4, Math.max(2, Math.round(l / 6))), A = c + l - v - $s, _ = Math.round(d * Math.max(0, Math.min(1, w)));
601
+ o.fillStyle = h.fill === null ? a : p, o.globalAlpha = 0.3 * s, o.fillRect(e.mainFrom, A, d, v), o.globalAlpha = s, _ > 0 && o.fillRect(e.mainFrom, A, _, v);
587
602
  }
588
603
  if (r.hatched) {
589
- const b = Math.max(1, Math.min(Me, Math.floor((d - 2 * et) / 3))), I = d >= 4 * b ? et : 0, _ = l >= 4 * et ? et : 0;
590
- n.globalAlpha = s, n.fillStyle = p, n.fillRect(e.mainFrom + I, c + _, b, l - 2 * _), n.fillRect(e.mainTo - I - b, c + _, b, l - 2 * _);
591
- }
592
- r.open && Fs(n, e, c, l, i.surface, o.width), r.dashed && (n.globalAlpha = s, n.strokeStyle = a, n.setLineDash([4, 3]), n.strokeRect(e.mainFrom + 0.5, c + 0.5, d - 1, l - 1), n.setLineDash([])), n.globalAlpha = 1, e.depth > 0 && s === 1 && (n.strokeStyle = i.surface, n.strokeRect(e.outerFrom - 0.5, c - 0.5, e.outerTo - e.outerFrom + 1, l + 1));
593
- }
594
- const Is = 6, As = 16;
595
- function _s(n, t, e, s, o, i, r, a, u) {
596
- n.save(), n.beginPath(), n.rect(t, e, s, o), n.clip(), n.globalAlpha = 0.5 * r, n.strokeStyle = i, n.lineWidth = u, n.beginPath();
597
- for (let c = t - o; c < t + s + o; c += a)
598
- n.moveTo(c, e + o), n.lineTo(c + o, e);
599
- n.stroke(), n.restore();
600
- }
601
- function Fs(n, t, e, s, o, i) {
602
- const r = t.mainFrom < 0, a = t.mainTo > i, u = Math.max(1, Math.min(t.mainTo, i) - Math.max(t.mainFrom, 0)), c = Math.min(As, u);
603
- r && ne(n, 0, c, e, s, o, 1), a && ne(n, i, -c, e, s, o, 1);
604
- }
605
- function ne(n, t, e, s, o, i, r) {
606
- const a = n.createLinearGradient(t, 0, t + e, 0);
607
- a.addColorStop(0, oe(i, r)), a.addColorStop(1, oe(i, 0)), n.globalAlpha = 1, n.fillStyle = a, n.fillRect(Math.min(t, t + e), s, Math.abs(e), o);
608
- }
609
- function oe(n, t) {
610
- const e = at(n);
611
- return e === null ? n : `rgba(${e[0]}, ${e[1]}, ${e[2]}, ${t})`;
612
- }
613
- function Mt(n, t, e, s, o) {
614
- const { data: i, colours: r } = t, a = i.taskOfTransport(e.transport), u = o ?? i.lateById.has(e.transport.id), c = a !== null && a === t.selectedTask, l = u ? r.alarm : (a !== null ? r.tasks.get(a) : void 0) ?? r.muted;
615
- if (n.strokeStyle = l, n.fillStyle = l, n.lineWidth = s || c ? 2 : 1.25, n.setLineDash(u ? [4, 3] : []), n.beginPath(), n.moveTo(e.x1, e.y1), e.kind === "curve")
616
- n.bezierCurveTo(e.c1x, e.y1, e.c2x, e.y2, e.x2, e.y2);
604
+ const v = Math.max(1, Math.min(De, Math.floor((d - 2 * nt) / 3))), A = d >= 4 * v ? nt : 0, _ = l >= 4 * nt ? nt : 0;
605
+ o.globalAlpha = s, o.fillStyle = p, o.fillRect(e.mainFrom + A, c + _, v, l - 2 * _), o.fillRect(e.mainTo - A - v, c + _, v, l - 2 * _);
606
+ }
607
+ r.open && Ys(o, e, c, l, i.surface, n.width), r.dashed && (o.globalAlpha = s, o.strokeStyle = a, o.setLineDash([4, 3]), o.strokeRect(e.mainFrom + 0.5, c + 0.5, d - 1, l - 1), o.setLineDash([])), o.globalAlpha = 1, e.depth > 0 && s === 1 && (o.strokeStyle = i.surface, o.strokeRect(e.outerFrom - 0.5, c - 0.5, e.outerTo - e.outerFrom + 1, l + 1));
608
+ }
609
+ const Bs = 6, Os = 16;
610
+ function Hs(o, t, e, s, n, i, r, a, h) {
611
+ o.save(), o.beginPath(), o.rect(t, e, s, n), o.clip(), o.globalAlpha = 0.5 * r, o.strokeStyle = i, o.lineWidth = h, o.beginPath();
612
+ for (let c = t - n; c < t + s + n; c += a)
613
+ o.moveTo(c, e + n), o.lineTo(c + n, e);
614
+ o.stroke(), o.restore();
615
+ }
616
+ function Ys(o, t, e, s, n, i) {
617
+ const r = t.mainFrom < 0, a = t.mainTo > i, h = Math.max(1, Math.min(t.mainTo, i) - Math.max(t.mainFrom, 0)), c = Math.min(Os, h);
618
+ r && pe(o, 0, c, e, s, n, 1), a && pe(o, i, -c, e, s, n, 1);
619
+ }
620
+ function pe(o, t, e, s, n, i, r) {
621
+ const a = o.createLinearGradient(t, 0, t + e, 0);
622
+ a.addColorStop(0, me(i, r)), a.addColorStop(1, me(i, 0)), o.globalAlpha = 1, o.fillStyle = a, o.fillRect(Math.min(t, t + e), s, Math.abs(e), n);
623
+ }
624
+ function me(o, t) {
625
+ const e = lt(o);
626
+ return e === null ? o : `rgba(${e[0]}, ${e[1]}, ${e[2]}, ${t})`;
627
+ }
628
+ function _t(o, t, e, s, n) {
629
+ const { data: i, colours: r } = t, a = i.taskOfTransport(e.transport), h = n ?? i.lateById.has(e.transport.id), c = a !== null && a === t.selectedTask, l = h ? r.alarm : (a !== null ? r.tasks.get(a) : void 0) ?? r.muted;
630
+ if (o.strokeStyle = l, o.fillStyle = l, o.lineWidth = s || c ? 2 : 1.25, o.setLineDash(h ? [4, 3] : []), o.beginPath(), o.moveTo(e.x1, e.y1), e.kind === "curve")
631
+ o.bezierCurveTo(e.c1x, e.y1, e.c2x, e.y2, e.x2, e.y2);
617
632
  else
618
- for (let d = 2; d + 1 < e.points.length; d += 2) n.lineTo(e.points[d], e.points[d + 1]);
619
- if (n.stroke(), n.setLineDash([]), e.ends === "dot")
633
+ for (let d = 2; d + 1 < e.points.length; d += 2) o.lineTo(e.points[d], e.points[d + 1]);
634
+ if (o.stroke(), o.setLineDash([]), e.ends === "dot")
620
635
  for (const [d, p] of [
621
636
  [e.x1, e.y1],
622
637
  [e.x2, e.y2]
623
638
  ])
624
- n.beginPath(), n.arc(d, p, u ? 3 : 2.5, 0, Math.PI * 2), n.fill();
639
+ o.beginPath(), o.arc(d, p, h ? 3 : 2.5, 0, Math.PI * 2), o.fill();
625
640
  }
626
- function Es(n, t, e) {
641
+ function Ks(o, t, e) {
627
642
  const { data: s } = t;
628
- if (s.lateById.size !== 0) {
629
- n.fillStyle = t.colours.alarm;
630
- for (const o of s.lateById.values()) {
631
- const i = s.transports.find((d) => d.id === o.transport), r = i === void 0 ? void 0 : s.subtaskById.get(i.to);
643
+ if (s.lateById.size !== 0)
644
+ for (const n of s.lateById.values()) {
645
+ const i = s.transports.find((d) => d.id === n.transport), r = i === void 0 ? void 0 : s.subtaskById.get(i.to);
632
646
  if (r === void 0) continue;
633
- const a = ct(e, r.lane);
647
+ const a = ft(e, r.lane);
634
648
  if (a === null || !a.miniature) continue;
635
- const u = nt(e.rows, a.top + e.scrollY);
636
- if (u === null) continue;
637
- const c = N(e, o.arrival), l = Math.max(c + 2, N(e, o.arrival + o.shortBy));
638
- n.fillRect(c, u.top - e.scrollY + 1, l - c, 3);
649
+ const h = Z(e.rows, a.top + e.scrollY);
650
+ if (h === null) continue;
651
+ const c = R(e, n.arrival), l = Math.max(c + 2, R(e, n.arrival + n.shortBy));
652
+ Ft(o, t, c, l, h.top - e.scrollY + 1, 3);
639
653
  }
654
+ }
655
+ function Ft(o, t, e, s, n, i) {
656
+ if (!t.colours.forced) {
657
+ o.fillStyle = t.colours.alarm, o.fillRect(e, n, s - e, i);
658
+ return;
640
659
  }
660
+ o.strokeStyle = t.colours.alarm, o.lineWidth = i, o.setLineDash([4, 3]), o.beginPath(), o.moveTo(e, n + i / 2), o.lineTo(s, n + i / 2), o.stroke(), o.setLineDash([]);
641
661
  }
642
- function Ae(n, t, e, s) {
643
- const o = ct(e, s.lane);
644
- if (o === null) return;
645
- const i = N(e, s.from), r = Math.max(i + 2, N(e, s.to));
646
- if (n.fillStyle = t.colours.alarm, n.globalAlpha = 0.14, n.fillRect(i, o.top + 1, r - i, Math.max(1, o.height - 2)), n.globalAlpha = 1, n.fillRect(i, o.top + 1, r - i, Math.min(3, Math.max(1, o.height - 1))), o.miniature) {
647
- const a = nt(e.rows, o.top + e.scrollY);
648
- a !== null && n.fillRect(i, a.top - e.scrollY + 1, r - i, 3);
662
+ function Ge(o, t, e, s) {
663
+ const n = ft(e, s.lane);
664
+ if (n === null) return;
665
+ const i = R(e, s.from), r = Math.max(i + 2, R(e, s.to));
666
+ if (o.fillStyle = t.colours.alarm, o.globalAlpha = 0.14, o.fillRect(i, n.top + 1, r - i, Math.max(1, n.height - 2)), o.globalAlpha = 1, Ft(o, t, i, r, n.top + 1, Math.min(3, Math.max(1, n.height - 1))), n.miniature) {
667
+ const a = Z(e.rows, n.top + e.scrollY);
668
+ a !== null && Ft(o, t, i, r, a.top - e.scrollY + 1, 3);
649
669
  }
650
670
  }
651
- function Ds(n, t, e) {
652
- const { colours: s } = t, o = ht(e.subtask.appearance), i = Ft(o, s.tasks.get(e.subtask.task) ?? s.muted, s);
653
- n.globalAlpha = Ps, n.fillStyle = i.onDark ? s.onAccent : s.text, n.fillRect(e.outerFrom, e.y, Math.max(1, e.outerTo - e.outerFrom), e.height), n.globalAlpha = 1;
671
+ function Us(o, t, e) {
672
+ const { colours: s } = t, n = ct(e.subtask.appearance), i = Bt(n, s.tasks.get(e.subtask.task) ?? s.muted, s);
673
+ if (s.forced) {
674
+ o.strokeStyle = s.active, o.lineWidth = 2, o.strokeRect(e.outerFrom - 2, e.y - 2, Math.max(1, e.outerTo - e.outerFrom) + 4, e.height + 4);
675
+ return;
676
+ }
677
+ o.globalAlpha = Xs, o.fillStyle = i.onDark ? s.onAccent : s.text, o.fillRect(e.outerFrom, e.y, Math.max(1, e.outerTo - e.outerFrom), e.height), o.globalAlpha = 1;
654
678
  }
655
- const Ps = 0.2;
656
- function Ns(n, t) {
679
+ const Xs = 0.2;
680
+ function Ws(o, t) {
657
681
  const e = t.selectedTask;
658
682
  if (e !== null) {
659
- n.strokeStyle = t.colours.text;
683
+ o.strokeStyle = t.colours.text;
660
684
  for (const s of t.view.boxes) {
661
685
  if (s.subtask.task !== e) continue;
662
- const o = s.subtask.id === t.selectedSubtask;
663
- n.lineWidth = o ? 2 : 1;
664
- const i = o ? 1 : 0.5;
665
- n.strokeRect(s.outerFrom - i, s.y - i, s.outerTo - s.outerFrom + 2 * i, s.height + 2 * i);
686
+ const n = s.subtask.id === t.selectedSubtask;
687
+ o.lineWidth = n ? 2 : 1;
688
+ const i = n ? 1 : 0.5;
689
+ o.strokeRect(s.outerFrom - i, s.y - i, s.outerTo - s.outerFrom + 2 * i, s.height + 2 * i);
666
690
  }
667
691
  }
668
692
  }
669
- const rt = 32, Gs = 18;
670
- function ie(n, t) {
671
- if (!(t > 2 * rt)) return 0;
672
- const e = rt - n, s = n - (t - rt), o = Math.max(e, s);
673
- if (o <= 0) return 0;
674
- const i = Math.min(1, o / rt), r = Gs * i * i;
693
+ const at = 32, zs = 18;
694
+ function ge(o, t) {
695
+ if (!(t > 2 * at)) return 0;
696
+ const e = at - o, s = o - (t - at), n = Math.max(e, s);
697
+ if (n <= 0) return 0;
698
+ const i = Math.min(1, n / at), r = zs * i * i;
675
699
  return e > 0 ? -r : r;
676
700
  }
677
- function Rs(n, t, e, s) {
678
- const o = /* @__PURE__ */ new Set();
679
- if (s === void 0) return o;
680
- for (const i of n)
681
- i !== e && (s(t, i) || o.add(i));
682
- return o;
701
+ function js(o, t, e, s) {
702
+ const n = /* @__PURE__ */ new Set();
703
+ if (s === void 0) return n;
704
+ for (const i of o)
705
+ i !== e && (s(t, i) || n.add(i));
706
+ return n;
683
707
  }
684
- function $s(n, t) {
708
+ function qs(o, t) {
685
709
  const { step: e, offset: s } = typeof t == "number" ? { step: t, offset: 0 } : t;
686
- if (!(e > 0) || !Number.isFinite(n)) return n;
687
- const o = me(n) + s;
688
- return o + Math.round((n - o) / e) * e;
710
+ if (!(e > 0) || !Number.isFinite(o)) return o;
711
+ const n = Se(o) + s;
712
+ return n + Math.round((o - n) / e) * e;
689
713
  }
690
- const re = "\0placing", ae = /* @__PURE__ */ new Set();
691
- function le(n) {
692
- switch (n.kind) {
714
+ const ke = "\0placing", we = /* @__PURE__ */ new Set();
715
+ function Lt(o) {
716
+ switch (o.kind) {
693
717
  case "subtask":
694
- return `subtask:${n.subtask.id}:${n.part}`;
718
+ return `subtask:${o.subtask.id}:${o.part}`;
695
719
  case "transport":
696
- return `transport:${n.transport.id}`;
720
+ return `transport:${o.transport.id}`;
697
721
  case "lane":
698
- return `lane:${n.lane}`;
722
+ return `lane:${o.lane}`;
699
723
  default:
700
724
  return "nothing";
701
725
  }
702
726
  }
703
- const he = 3, Os = 10, xs = 600;
704
- class Bs {
727
+ const ye = 3, Vs = 10, Zs = 600;
728
+ class Js {
705
729
  constructor(t) {
706
730
  f(this, "gesture", { kind: "none" });
707
731
  f(this, "touches", /* @__PURE__ */ new Map());
@@ -721,8 +745,13 @@ class Bs {
721
745
  open it for this gesture. */
722
746
  f(this, "resting", null);
723
747
  f(this, "hover", { kind: "nothing" });
724
- /** Where the pointer rests on the plot while nothing is being dragged. */
748
+ /** Where the pointer rests on the plot while nothing is being dragged - or,
749
+ where the keyboard set the hover, the point its tooltip stands at. */
725
750
  f(this, "hoverPoint", { x: 0, y: 0 });
751
+ /** Whether the keyboard set the hover (ADR-0030): pointer and keys share one
752
+ **Active subtask**, and the last input wins. The keys' hover stays when
753
+ the pointer leaves, and the pointer takes it over by moving. */
754
+ f(this, "byKeyboard", !1);
726
755
  f(this, "cursor", "default");
727
756
  this.host = t;
728
757
  }
@@ -754,13 +783,13 @@ class Bs {
754
783
  ghostSummary() {
755
784
  const t = this.gesture;
756
785
  if (t.kind !== "edit" && t.kind !== "place") return null;
757
- const e = Se(this.host.view.viewport(), t.ghost);
786
+ const e = xe(this.host.view.viewport(), t.ghost);
758
787
  if (e === null) return null;
759
- const s = this.ghostFindings(t.ghost, this.ghostHome(t)), o = t.kind === "edit" && (t.mode === "setup" || t.mode === "teardown"), i = o ? ut(t.ghost) : t.ghost;
788
+ const s = this.ghostFindings(t.ghost, this.ghostHome(t)), n = t.kind === "edit" && (t.mode === "setup" || t.mode === "teardown"), i = n ? dt(t.ghost) : t.ghost;
760
789
  return {
761
790
  refused: this.refused,
762
791
  refusedLanes: [...t.refused],
763
- x: o ? e.outerFrom : e.mainFrom,
792
+ x: n ? e.outerFrom : e.mainFrom,
764
793
  y: e.y,
765
794
  height: e.height,
766
795
  from: i.from,
@@ -773,25 +802,25 @@ class Bs {
773
802
  /* Pointer */
774
803
  /* ---------------------------------------------------------------- */
775
804
  local(t, e) {
776
- var o;
777
- const s = (o = this.host.plotElement()) == null ? void 0 : o.getBoundingClientRect();
805
+ var n;
806
+ const s = (n = this.host.plotElement()) == null ? void 0 : n.getBoundingClientRect();
778
807
  return { x: t - ((s == null ? void 0 : s.left) ?? 0), y: e - ((s == null ? void 0 : s.top) ?? 0) };
779
808
  }
780
- report(t, e, s, o, i, r) {
781
- var u, c;
809
+ report(t, e, s, n, i, r) {
810
+ var h, c;
782
811
  const a = this.host.view;
783
- (c = (u = this.host.handlers()).onInteraction) == null || c.call(u, { type: t, hit: e, clientX: s, clientY: o, time: a.timeAt(i), lane: a.laneIdAt(r) });
812
+ (c = (h = this.host.handlers()).onInteraction) == null || c.call(h, { type: t, hit: e, clientX: s, clientY: n, time: a.timeAt(i), lane: a.laneIdAt(r) });
784
813
  }
785
814
  pointerDown(t) {
786
- var a, u, c, l, d;
815
+ var a, h, c, l, d;
787
816
  const { x: e, y: s } = this.local(t.clientX, t.clientY);
788
817
  if (t.pointerType === "touch" && (this.touches.set(t.pointerId, { x: e, y: s }), this.touches.size >= 2)) {
789
818
  this.gesture.kind !== "pinch" && (this.cancelEdit(), this.gesture = { kind: "pinch", distance: this.touchDistance() });
790
819
  return;
791
820
  }
792
821
  if (t.button !== 0) return;
793
- const o = (c = (u = (a = t.target) == null ? void 0 : a.closest) == null ? void 0 : u.call(a, "[data-grip]")) == null ? void 0 : c.getAttribute("data-grip"), i = this.host.selectedSubtask(), r = i !== null ? this.host.data.subtaskById.get(i) ?? null : null;
794
- t.pointerType === "touch" ? this.gesture = { kind: "pending", pointerId: t.pointerId, x0: e, y0: s, mode: "pan", subtask: null } : (o === "setup" || o === "teardown") && r !== null ? this.gesture = { kind: "pending", pointerId: t.pointerId, x0: e, y0: s, mode: o, subtask: r } : this.gesture = { kind: "pending", pointerId: t.pointerId, x0: e, y0: s, ...this.modeAt(e, s) }, (d = (l = this.host.plotElement()) == null ? void 0 : l.setPointerCapture) == null || d.call(l, t.pointerId);
822
+ const n = (c = (h = (a = t.target) == null ? void 0 : a.closest) == null ? void 0 : h.call(a, "[data-grip]")) == null ? void 0 : c.getAttribute("data-grip"), i = this.host.selectedSubtask(), r = i !== null ? this.host.data.subtaskById.get(i) ?? null : null;
823
+ t.pointerType === "touch" ? this.gesture = { kind: "pending", pointerId: t.pointerId, x0: e, y0: s, mode: "pan", subtask: null } : (n === "setup" || n === "teardown") && r !== null ? this.gesture = { kind: "pending", pointerId: t.pointerId, x0: e, y0: s, mode: n, subtask: r } : this.gesture = { kind: "pending", pointerId: t.pointerId, x0: e, y0: s, ...this.modeAt(e, s) }, (d = (l = this.host.plotElement()) == null ? void 0 : l.setPointerCapture) == null || d.call(l, t.pointerId);
795
824
  }
796
825
  /** A drag over a folded group: resting on one opens it for the GESTURE.
797
826
 
@@ -801,13 +830,13 @@ class Bs {
801
830
  never written to and no change is reported, because the application did
802
831
  not fold anything (ADR-0025). */
803
832
  restOver(t) {
804
- var o;
833
+ var n;
805
834
  const e = this.host.view, s = e.foldedGroupAt(t);
806
- s !== ((o = this.resting) == null ? void 0 : o.group) && (this.stopResting(), s !== null && (this.resting = {
835
+ s !== ((n = this.resting) == null ? void 0 : n.group) && (this.stopResting(), s !== null && (this.resting = {
807
836
  group: s,
808
837
  timer: setTimeout(() => {
809
838
  this.resting = null, e.openForGesture = /* @__PURE__ */ new Set([...e.openForGesture, s]), this.host.viewChanged();
810
- }, xs)
839
+ }, Zs)
811
840
  }));
812
841
  }
813
842
  stopResting() {
@@ -829,28 +858,28 @@ class Bs {
829
858
  lane is open. Asked at a drop, where the answer has to be current; while
830
859
  a drag runs, the held set answers instead. */
831
860
  allowed(t, e) {
832
- var s, o;
833
- return ((o = (s = this.host.handlers()).canMoveTo) == null ? void 0 : o.call(s, t, e)) ?? !0;
861
+ var s, n;
862
+ return ((n = (s = this.host.handlers()).canMoveTo) == null ? void 0 : n.call(s, t, e)) ?? !0;
834
863
  }
835
864
  /** The lanes this work may not go to, for the gesture that is beginning. A
836
865
  gesture that cannot change a lane at all asks nothing: the intents the
837
866
  caller handles decide whether the question exists. */
838
867
  askRefused(t, e) {
839
- if (!this.host.view.options.intents.includes(e === null ? "place" : "lane")) return ae;
840
- const s = this.host.data.lanes.map((o) => o.id);
841
- return Rs(s, t, e, this.host.handlers().canMoveTo);
868
+ if (!this.host.view.options.intents.includes(e === null ? "place" : "lane")) return we;
869
+ const s = this.host.data.lanes.map((n) => n.id);
870
+ return js(s, t, e, this.host.handlers().canMoveTo);
842
871
  }
843
872
  /** What a press at a point would start, given the intents the caller handles. */
844
873
  modeAt(t, e) {
845
- const s = this.host.view, o = s.options.intents;
874
+ const s = this.host.view, n = s.options.intents;
846
875
  for (let i = s.boxes.length - 1; i >= 0; i--) {
847
876
  const r = s.boxes[i];
848
- if (o.includes("stretch")) {
849
- const a = hs(r, t, e);
877
+ if (n.includes("stretch")) {
878
+ const a = ys(r, t, e);
850
879
  if (a !== null) return { mode: a === "from" ? "stretch-from" : "stretch-to", subtask: r.subtask };
851
880
  }
852
- if (Ce(r, t, e) !== null)
853
- return o.includes("move") || o.includes("lane") ? { mode: "move", subtask: r.subtask } : { mode: "pan", subtask: r.subtask };
881
+ if (Pe(r, t, e) !== null)
882
+ return n.includes("move") || n.includes("lane") ? { mode: "move", subtask: r.subtask } : { mode: "pan", subtask: r.subtask };
854
883
  }
855
884
  return { mode: "pan", subtask: null };
856
885
  }
@@ -861,24 +890,24 @@ class Bs {
861
890
  r > 0 && this.gesture.distance > 0 && this.host.view.zoomAt(this.touchCentre(), this.gesture.distance / r) && this.host.viewMoved(!0), this.gesture = { kind: "pinch", distance: r };
862
891
  return;
863
892
  }
864
- const o = this.gesture;
865
- if (o.kind === "pending" && o.pointerId === t.pointerId) {
866
- if (Math.hypot(e - o.x0, s - o.y0) < (t.pointerType === "touch" ? Os : he)) return;
867
- if (o.mode === "pan" || o.subtask === null)
868
- this.gesture = { kind: "pan", pointerId: o.pointerId, lastX: o.x0, lastY: o.y0 }, this.setCursor("grabbing");
893
+ const n = this.gesture;
894
+ if (n.kind === "pending" && n.pointerId === t.pointerId) {
895
+ if (Math.hypot(e - n.x0, s - n.y0) < (t.pointerType === "touch" ? Vs : ye)) return;
896
+ if (n.mode === "pan" || n.subtask === null)
897
+ this.gesture = { kind: "pan", pointerId: n.pointerId, lastX: n.x0, lastY: n.y0 }, this.setCursor("grabbing");
869
898
  else {
870
- const r = this.host.view.viewport().scale.fromPx(o.x0);
899
+ const r = this.host.view.viewport().scale.fromPx(n.x0);
871
900
  this.gesture = {
872
901
  kind: "edit",
873
- pointerId: o.pointerId,
874
- mode: o.mode,
875
- subtask: o.subtask,
902
+ pointerId: n.pointerId,
903
+ mode: n.mode,
904
+ subtask: n.subtask,
876
905
  t0: r,
877
- ghost: o.subtask,
906
+ ghost: n.subtask,
878
907
  /* Asked here, once, and drawn from the first frame of the drag: the
879
908
  lanes that are closed are marked before the pointer reaches one. */
880
- refused: o.mode === "move" ? this.askRefused(o.subtask, o.subtask.lane) : ae
881
- }, this.setCursor(o.mode === "move" ? "grabbing" : "ew-resize");
909
+ refused: n.mode === "move" ? this.askRefused(n.subtask, n.subtask.lane) : we
910
+ }, this.setCursor(n.mode === "move" ? "grabbing" : "ew-resize");
882
911
  }
883
912
  }
884
913
  const i = this.gesture;
@@ -891,7 +920,7 @@ class Bs {
891
920
  this.lastClient = { x: t.clientX, y: t.clientY }, this.dragPoint = { x: e, y: s }, this.restOver(s), this.gesture = { ...i, ghost: this.ghostFor(i, e, s) }, this.setCursor(this.refused ? "not-allowed" : i.mode === "move" ? "grabbing" : "ew-resize"), this.host.interactionChanged(), this.autoPan();
892
921
  return;
893
922
  }
894
- i.kind === "none" && this.hoverAt(t.clientX, t.clientY, e, s);
923
+ i.kind === "none" && (this.byKeyboard = !1, this.hoverAt(t.clientX, t.clientY, e, s));
895
924
  }
896
925
  pointerUp(t) {
897
926
  var i, r;
@@ -900,18 +929,18 @@ class Bs {
900
929
  this.touches.size === 1 && a !== void 0 ? this.gesture = { kind: "pan", pointerId: a[0], lastX: a[1].x, lastY: a[1].y } : this.touches.size === 0 && (this.gesture = { kind: "none" });
901
930
  return;
902
931
  }
903
- const e = this.gesture, { x: s, y: o } = this.local(t.clientX, t.clientY);
932
+ const e = this.gesture, { x: s, y: n } = this.local(t.clientX, t.clientY);
904
933
  if (e.kind === "pending" && e.pointerId === t.pointerId)
905
- this.gesture = { kind: "none" }, this.click(t.clientX, t.clientY, s, o);
934
+ this.gesture = { kind: "none" }, this.click(t.clientX, t.clientY, s, n);
906
935
  else if (e.kind === "pan" && e.pointerId === t.pointerId)
907
- this.gesture = { kind: "none" }, this.setCursor("default"), this.hoverAt(t.clientX, t.clientY, s, o);
936
+ this.gesture = { kind: "none" }, this.setCursor("default"), this.hoverAt(t.clientX, t.clientY, s, n);
908
937
  else if (e.kind === "edit" && e.pointerId === t.pointerId) {
909
938
  this.stopAutoPan(), this.closeGestureFolds(), this.gesture = { kind: "none" };
910
- const a = e.ghost.lane === e.subtask.lane || this.allowed(e.subtask, e.ghost.lane), u = this.intentsOf(e.subtask, e.ghost, e.mode).filter(
939
+ const a = e.ghost.lane === e.subtask.lane || this.allowed(e.subtask, e.ghost.lane), h = this.intentsOf(e.subtask, e.ghost, e.mode).filter(
911
940
  (c) => a || c.kind !== "lane"
912
941
  );
913
942
  this.refused = !1, this.cursor = "default", this.host.interactionChanged();
914
- for (const c of u) (r = (i = this.host.handlers()).onIntent) == null || r.call(i, c);
943
+ for (const c of h) (r = (i = this.host.handlers()).onIntent) == null || r.call(i, c);
915
944
  }
916
945
  }
917
946
  /** While a drag is in flight near an edge, pans along once per frame and
@@ -923,17 +952,17 @@ class Bs {
923
952
  this.panFrame = 0;
924
953
  const e = this.gesture;
925
954
  if (e.kind !== "edit" && e.kind !== "place") return;
926
- const s = this.host.view, { x: o, y: i } = this.local(this.lastClient.x, this.lastClient.y), r = ie(o, s.width), a = ie(i, s.height);
955
+ const s = this.host.view, { x: n, y: i } = this.local(this.lastClient.x, this.lastClient.y), r = ge(n, s.width), a = ge(i, s.height);
927
956
  if (r === 0 && a === 0) return;
928
- const u = s.pan(r, a);
929
- if (u.moved) {
930
- if (this.dragPoint = { x: o, y: i }, e.kind === "edit")
931
- this.gesture = { ...e, ghost: this.ghostFor(e, o, i) };
957
+ const h = s.pan(r, a);
958
+ if (h.moved) {
959
+ if (this.dragPoint = { x: n, y: i }, e.kind === "edit")
960
+ this.gesture = { ...e, ghost: this.ghostFor(e, n, i) };
932
961
  else {
933
- const c = this.placeGhost(e.item, o, i, e.refused);
962
+ const c = this.placeGhost(e.item, n, i, e.refused);
934
963
  this.refused = c.refused, this.gesture = { ...e, ghost: c.ghost ?? e.ghost };
935
964
  }
936
- this.host.viewMoved(u.time), this.panFrame = requestAnimationFrame(t);
965
+ this.host.viewMoved(h.time), this.panFrame = requestAnimationFrame(t);
937
966
  }
938
967
  };
939
968
  this.panFrame = requestAnimationFrame(t);
@@ -949,12 +978,12 @@ class Bs {
949
978
  pointer without the pointer moving, and a tooltip still naming the old
950
979
  times would be a lie. Nothing is reported: no interaction happened. */
951
980
  refreshHover() {
952
- if (!this.idle || this.hoverKey === "nothing") return;
981
+ if (!this.idle || this.hoverKey === "nothing" || this.byKeyboard) return;
953
982
  const { x: t, y: e } = this.hoverPoint, s = this.host.view.hitAt(t, e);
954
- this.hover = s, this.hoverKey = le(s);
983
+ this.hover = s, this.hoverKey = Lt(s);
955
984
  }
956
985
  pointerLeave() {
957
- this.gesture.kind === "none" && this.setHover({ kind: "nothing" }, "nothing");
986
+ this.gesture.kind !== "none" || this.byKeyboard || this.setHover({ kind: "nothing" }, "nothing");
958
987
  }
959
988
  /** Escape while a drag is in flight: the ghost goes, and nothing is reported.
960
989
  It ends a drag from outside as it ends one inside. */
@@ -972,7 +1001,7 @@ class Bs {
972
1001
  their end; Ctrl or ⌘ zooms - a trackpad pinch arrives as a wheel with
973
1002
  Ctrl -; horizontal or Shift pans through time. */
974
1003
  wheel(t) {
975
- const e = this.host.view, s = Math.max(0, Math.min(e.width, this.local(t.clientX, t.clientY).x)), o = t.deltaMode === 1 ? 16 : t.deltaMode === 2 ? e.height : 1, i = t.deltaX * o, r = t.deltaY * o;
1004
+ const e = this.host.view, s = Math.max(0, Math.min(e.width, this.local(t.clientX, t.clientY).x)), n = t.deltaMode === 1 ? 16 : t.deltaMode === 2 ? e.height : 1, i = t.deltaX * n, r = t.deltaY * n;
976
1005
  if (t.ctrlKey || t.metaKey) {
977
1006
  t.preventDefault();
978
1007
  const c = Math.abs(r) < 50 ? 0.01 : 15e-4;
@@ -988,20 +1017,26 @@ class Bs {
988
1017
  const a = r > 0 ? e.maxScroll() - e.scrollY : e.scrollY;
989
1018
  if (r === 0 || a <= 0) return;
990
1019
  t.preventDefault();
991
- const u = e.pan(0, r);
992
- u.moved && this.host.viewMoved(u.time);
1020
+ const h = e.pan(0, r);
1021
+ h.moved && this.host.viewMoved(h.time);
993
1022
  }
994
- click(t, e, s, o) {
995
- const i = this.host.view.hitAt(s, o), r = i.kind === "subtask" ? i.subtask.task : i.kind === "transport" ? this.host.data.taskOfTransport(i.transport) : null;
996
- this.host.select(r, i.kind === "subtask" ? i.subtask.id : null), this.report("click", i, t, e, s, o);
1023
+ click(t, e, s, n) {
1024
+ const i = this.host.view.hitAt(s, n), r = i.kind === "subtask" ? i.subtask.task : i.kind === "transport" ? this.host.data.taskOfTransport(i.transport) : null;
1025
+ this.host.select(r, i.kind === "subtask" ? i.subtask.id : null), this.report("click", i, t, e, s, n);
997
1026
  }
998
- hoverAt(t, e, s, o) {
999
- const i = this.host.view.hitAt(s, o), r = le(i), { mode: a } = this.modeAt(s, o);
1000
- if (this.setCursor(a === "move" ? "grab" : a === "stretch-from" || a === "stretch-to" ? "ew-resize" : "default"), this.hoverPoint = { x: s, y: o }, r === this.hoverKey) {
1027
+ hoverAt(t, e, s, n) {
1028
+ const i = this.host.view.hitAt(s, n), r = Lt(i), { mode: a } = this.modeAt(s, n);
1029
+ if (this.setCursor(a === "move" ? "grab" : a === "stretch-from" || a === "stretch-to" ? "ew-resize" : "default"), this.hoverPoint = { x: s, y: n }, r === this.hoverKey) {
1001
1030
  (i.kind === "subtask" || i.kind === "transport") && this.host.interactionChanged();
1002
1031
  return;
1003
1032
  }
1004
- this.setHover(i, r), this.report("hover", i, t, e, s, o);
1033
+ this.setHover(i, r), this.report("hover", i, t, e, s, n);
1034
+ }
1035
+ /** The keyboard sets the hover: drawn, and its tooltip shown, as the
1036
+ pointer's would be - and reported to nobody, since `onInteraction`
1037
+ speaks of pointer positions. `nothing` hands the hover back. */
1038
+ setKeyboardHover(t, e) {
1039
+ this.byKeyboard = t.kind !== "nothing", this.hoverPoint = e, this.hover = t, this.hoverKey = Lt(t), this.host.interactionChanged();
1005
1040
  }
1006
1041
  setHover(t, e) {
1007
1042
  e !== this.hoverKey && (this.hoverKey = e, this.hover = t, this.host.interactionChanged());
@@ -1026,7 +1061,7 @@ class Bs {
1026
1061
  dragOver(t, e) {
1027
1062
  const s = this.host.view;
1028
1063
  if (e === null || !s.options.intents.includes("place")) return;
1029
- const { x: o, y: i } = this.local(t.clientX, t.clientY);
1064
+ const { x: n, y: i } = this.local(t.clientX, t.clientY);
1030
1065
  if (s.laneIdAt(i) === null && s.foldedGroupAt(i) === null) {
1031
1066
  this.clearPlacing();
1032
1067
  return;
@@ -1037,30 +1072,30 @@ class Bs {
1037
1072
  pointer is not over one either, the rule is asked about an item
1038
1073
  whose own lane is empty - which is the truth of it: `canMoveTo`
1039
1074
  is asked ABOUT a lane, and the one this item is on is none. */
1040
- this.askRefused(this.askedFor(e, this.onLane(i) ?? "", o), null)
1041
- ), a = this.placeGhost(e, o, i, r);
1075
+ this.askRefused(this.askedFor(e, this.onLane(i) ?? "", n), null)
1076
+ ), a = this.placeGhost(e, n, i, r);
1042
1077
  this.refused = a.refused, this.setCursor(a.refused ? "not-allowed" : "default");
1043
- const u = this.gesture.kind === "place" ? this.gesture.ghost : null, c = a.ghost ?? (a.refused ? u : null);
1044
- t.dataTransfer !== null && (t.dataTransfer.dropEffect = c === null ? "none" : "copy"), c !== null && (this.lastClient = { x: t.clientX, y: t.clientY }, this.dragPoint = { x: o, y: i }, this.gesture = { kind: "place", ghost: c, item: e, refused: r }, this.host.interactionChanged(), this.autoPan());
1078
+ const h = this.gesture.kind === "place" ? this.gesture.ghost : null, c = a.ghost ?? (a.refused ? h : null);
1079
+ t.dataTransfer !== null && (t.dataTransfer.dropEffect = c === null ? "none" : "copy"), c !== null && (this.lastClient = { x: t.clientX, y: t.clientY }, this.dragPoint = { x: n, y: i }, this.gesture = { kind: "place", ghost: c, item: e, refused: r }, this.host.interactionChanged(), this.autoPan());
1045
1080
  }
1046
1081
  /** The ghost of a drag from outside at a point on the plot: none off the
1047
1082
  lanes, and none where the caller refuses that lane - which the answer
1048
1083
  says apart, because the two mean different things to the drag. */
1049
- placeGhost(t, e, s, o) {
1084
+ placeGhost(t, e, s, n) {
1050
1085
  const i = this.onLane(s);
1051
- return i === null ? { ghost: null, refused: !1 } : o.has(i) ? { ghost: null, refused: !0 } : { ghost: { ...this.askedFor(t, i, e), id: re }, refused: !1 };
1086
+ return i === null ? { ghost: null, refused: !1 } : n.has(i) ? { ghost: null, refused: !0 } : { ghost: { ...this.askedFor(t, i, e), id: ke }, refused: !1 };
1052
1087
  }
1053
1088
  /** The dragged item as a subtask, under the caller's key for it - not the
1054
1089
  internal sentinel: the rule is asked about the thing the application says
1055
1090
  it is dragging, and the ghost only afterwards takes the sentinel. */
1056
1091
  askedFor(t, e, s) {
1057
- const o = this.snapInside(this.host.view.timeAt(s), this.snapStep());
1092
+ const n = this.snapInside(this.host.view.timeAt(s), this.snapStep());
1058
1093
  return {
1059
1094
  id: t.item,
1060
1095
  task: t.task,
1061
1096
  lane: e,
1062
- from: o,
1063
- to: o + t.duration,
1097
+ from: n,
1098
+ to: n + t.duration,
1064
1099
  ...t.setup === void 0 ? {} : { setup: t.setup },
1065
1100
  ...t.teardown === void 0 ? {} : { teardown: t.teardown }
1066
1101
  };
@@ -1072,11 +1107,11 @@ class Bs {
1072
1107
  const e = this.gesture;
1073
1108
  if (e.kind !== "place") return;
1074
1109
  t.preventDefault();
1075
- const { ghost: s, item: o } = e;
1076
- if (this.stopAutoPan(), this.closeGestureFolds(), this.gesture = { kind: "none" }, this.refused = !1, this.cursor = "default", this.host.interactionChanged(), !this.allowed({ ...s, id: o.item }, s.lane)) return;
1110
+ const { ghost: s, item: n } = e;
1111
+ if (this.stopAutoPan(), this.closeGestureFolds(), this.gesture = { kind: "none" }, this.refused = !1, this.cursor = "default", this.host.interactionChanged(), !this.allowed({ ...s, id: n.item }, s.lane)) return;
1077
1112
  const i = {
1078
1113
  kind: "place",
1079
- item: o.item,
1114
+ item: n.item,
1080
1115
  task: s.task,
1081
1116
  lane: s.lane,
1082
1117
  from: s.from,
@@ -1101,43 +1136,47 @@ class Bs {
1101
1136
  return t === "ticks" ? { step: this.host.view.step(), offset: 0 } : t === !1 ? { step: 0, offset: 0 } : typeof t == "number" ? { step: t, offset: 0 } : t;
1102
1137
  }
1103
1138
  ghostFor(t, e, s) {
1104
- const o = this.host.view, i = t.subtask, r = this.snapStep(), a = o.options.intents, u = this.snapInside(o.timeAt(e), r);
1139
+ const n = this.host.view, i = t.subtask, r = this.snapStep(), a = n.options.intents, h = this.snapInside(n.timeAt(e), r);
1105
1140
  switch (t.mode) {
1106
1141
  case "move": {
1107
1142
  let c = i.from;
1108
- const l = o.viewport().scale, d = l.fromPx(e) - t.t0;
1109
- if (a.includes("move") && Math.abs(d * l.m) >= he) {
1110
- const g = j(o.options.calendar), b = B(i.from, g) + d, I = g.intervals.length === 0 ? b : U(Math.max(0, Math.min(g.total, b)), g);
1111
- c = this.snapInside(I, r);
1112
- }
1143
+ const l = n.viewport().scale, d = l.fromPx(e) - t.t0;
1144
+ a.includes("move") && Math.abs(d * l.m) >= ye && (c = this.shifted(i.from, d, r));
1113
1145
  let p = t.ghost.lane;
1114
1146
  if (a.includes("lane")) {
1115
- const g = this.onLane(s) ?? p;
1116
- this.refused = t.refused.has(g), this.refused || (p = g);
1147
+ const w = this.onLane(s) ?? p;
1148
+ this.refused = t.refused.has(w), this.refused || (p = w);
1117
1149
  } else
1118
1150
  this.refused = !1;
1119
1151
  return { ...i, from: c, to: c + (i.to - i.from), lane: p };
1120
1152
  }
1121
1153
  case "stretch-from":
1122
- return { ...i, from: Math.min(u, i.to - Math.max(r.step, q)) };
1154
+ return { ...i, from: Math.min(h, i.to - Math.max(r.step, X)) };
1123
1155
  case "stretch-to":
1124
- return { ...i, to: Math.max(u, i.from + Math.max(r.step, q)) };
1156
+ return { ...i, to: Math.max(h, i.from + Math.max(r.step, X)) };
1125
1157
  case "setup":
1126
- return { ...i, setup: Math.max(0, i.from - u) };
1158
+ return { ...i, setup: Math.max(0, i.from - h) };
1127
1159
  case "teardown":
1128
- return { ...i, teardown: Math.max(0, u - i.to) };
1160
+ return { ...i, teardown: Math.max(0, h - i.to) };
1129
1161
  }
1130
1162
  }
1163
+ /** A time moved by an amount of OPERATING time and snapped: a drag moves
1164
+ a start this way, and a key by one step of the raster - one arithmetic,
1165
+ so a key proposes exactly what a drag of that length would. */
1166
+ shifted(t, e, s) {
1167
+ const n = V(this.host.view.options.calendar), i = K(t, n) + e, r = n.intervals.length === 0 ? i : W(Math.max(0, Math.min(n.total, i)), n);
1168
+ return this.snapInside(r, s);
1169
+ }
1131
1170
  /** Snapped - and, where the raster lands in time the calendar removes, moved
1132
1171
  on to the seam, where time counts again. An intent never asks for a time
1133
1172
  the plant does not run. */
1134
1173
  snapInside(t, e) {
1135
- const s = $s(t, e), o = j(this.host.view.options.calendar);
1136
- return o.intervals.length === 0 ? s : U(B(s, o), o);
1174
+ const s = qs(t, e), n = V(this.host.view.options.calendar);
1175
+ return n.intervals.length === 0 ? s : W(K(s, n), n);
1137
1176
  }
1138
1177
  intentsOf(t, e, s) {
1139
- const o = [], i = this.host.view.options.intents, r = t.id;
1140
- return s === "move" ? (e.from !== t.from && i.includes("move") && o.push({ kind: "move", subtask: r, from: e.from, to: e.to }), e.lane !== t.lane && i.includes("lane") && o.push({ kind: "lane", subtask: r, lane: e.lane })) : s === "stretch-from" || s === "stretch-to" ? (e.from !== t.from || e.to !== t.to) && o.push({ kind: "stretch", subtask: r, from: e.from, to: e.to }) : s === "setup" ? (e.setup ?? 0) !== (t.setup ?? 0) && o.push({ kind: "setup", subtask: r, setup: e.setup ?? 0 }) : (e.teardown ?? 0) !== (t.teardown ?? 0) && o.push({ kind: "teardown", subtask: r, teardown: e.teardown ?? 0 }), o;
1178
+ const n = [], i = this.host.view.options.intents, r = t.id;
1179
+ return s === "move" ? (e.from !== t.from && i.includes("move") && n.push({ kind: "move", subtask: r, from: e.from, to: e.to }), e.lane !== t.lane && i.includes("lane") && n.push({ kind: "lane", subtask: r, lane: e.lane })) : s === "stretch-from" || s === "stretch-to" ? (e.from !== t.from || e.to !== t.to) && n.push({ kind: "stretch", subtask: r, from: e.from, to: e.to }) : s === "setup" ? (e.setup ?? 0) !== (t.setup ?? 0) && n.push({ kind: "setup", subtask: r, setup: e.setup ?? 0 }) : (e.teardown ?? 0) !== (t.teardown ?? 0) && n.push({ kind: "teardown", subtask: r, teardown: e.teardown ?? 0 }), n;
1141
1180
  }
1142
1181
  /** The lane the ghost came from - the only other lane a drag can touch. */
1143
1182
  ghostHome(t) {
@@ -1153,57 +1192,277 @@ class Bs {
1153
1192
  keeps a plan of hundreds of tasks fluid while a drag runs, since this is
1154
1193
  computed on every pointer movement. */
1155
1194
  ghostFindings(t, e) {
1156
- const s = this.host.data, o = (l) => l.lane === t.lane || l.lane === e, r = [...s.subtasks.filter((l) => l.id !== t.id && o(l)), t], a = (l) => l.first === t.id || l.second === t.id, u = s.transports.filter((l) => l.from === t.id || l.to === t.id), c = t.id === re ? s.subtasks : s.subtasks.map((l) => l.id === t.id ? t : l);
1157
- return { overlaps: At(r).filter(a), late: _t(c, u) };
1195
+ const s = this.host.data, n = (l) => l.lane === t.lane || l.lane === e, r = [...s.subtasks.filter((l) => l.id !== t.id && n(l)), t], a = (l) => l.first === t.id || l.second === t.id, h = s.transports.filter((l) => l.from === t.id || l.to === t.id), c = t.id === ke ? s.subtasks : s.subtasks.map((l) => l.id === t.id ? t : l);
1196
+ return { overlaps: Gt(r).filter(a), late: $t(c, h) };
1197
+ }
1198
+ }
1199
+ function Qs(o, t) {
1200
+ const e = /* @__PURE__ */ new Map();
1201
+ for (const s of t) {
1202
+ const n = o.slots.get(s.lane), i = n === void 0 ? null : Z(o, n.top);
1203
+ if (i === null) continue;
1204
+ const r = o.rows.indexOf(i);
1205
+ e.set(r, [...e.get(r) ?? [], s]);
1206
+ }
1207
+ return [...e.entries()].sort(([s], [n]) => s - n).map(([, s]) => s.sort((n, i) => n.from - i.from || n.to - i.to));
1208
+ }
1209
+ const ve = (o, t) => t < o.from ? o.from - t : t > o.to ? t - o.to : 0;
1210
+ function tn(o, t, e, s) {
1211
+ var c;
1212
+ let n = -1, i = -1;
1213
+ for (let l = 0; l < o.length && t !== null && n < 0; l++)
1214
+ i = o[l].findIndex((d) => d.id === t), i >= 0 && (n = l);
1215
+ if (n < 0) {
1216
+ for (const l of o) {
1217
+ const d = l.find((p) => p.to > s[0] && p.from < s[1]);
1218
+ if (d !== void 0) return d;
1219
+ }
1220
+ return ((c = o[0]) == null ? void 0 : c[0]) ?? null;
1221
+ }
1222
+ const r = o[n], a = r[i], h = (s[1] - s[0]) / 10;
1223
+ switch (e) {
1224
+ case "next":
1225
+ return r[i + 1] ?? a;
1226
+ case "previous":
1227
+ return r[i - 1] ?? a;
1228
+ case "first":
1229
+ return r[0];
1230
+ case "last":
1231
+ return r[r.length - 1];
1232
+ case "pageNext":
1233
+ return r.find((l, d) => d > i && l.from >= a.from + h) ?? r[r.length - 1];
1234
+ case "pagePrevious":
1235
+ for (let l = i - 1; l >= 0; l--) if (r[l].from <= a.from - h) return r[l];
1236
+ return r[0];
1237
+ case "up":
1238
+ case "down": {
1239
+ const l = o[e === "up" ? n - 1 : n + 1];
1240
+ if (l === void 0) return a;
1241
+ const d = (a.from + a.to) / 2;
1242
+ return l.reduce((p, w) => ve(w, d) < ve(p, d) ? w : p);
1243
+ }
1158
1244
  }
1159
1245
  }
1160
- const _e = [], Hs = 56;
1161
- function Ys(n, t = Hs) {
1162
- return n > 0 ? Math.min(st, Math.max(15 * q, je(n * t, 1))) : 15 * q;
1163
- }
1164
- function Xs(n, t, e = _e) {
1165
- const [s, o] = Fe(n, e);
1166
- return Ve(e, s, o, t, me(s)).filter(
1167
- (i) => i.operatingTime >= n[0] && i.operatingTime <= n[1]
1246
+ function en(o, t, e, s) {
1247
+ if (e.kind === "transport") {
1248
+ const i = o.find((a) => a.id === e.id), r = i === void 0 ? void 0 : s === "out" ? i.to : i.from;
1249
+ return r !== void 0 && t.has(r) ? { kind: "subtask", id: r } : e;
1250
+ }
1251
+ const n = o.find(
1252
+ (i) => (s === "out" ? i.from : i.to) === e.id && t.has(s === "out" ? i.to : i.from)
1253
+ );
1254
+ return n === void 0 ? e : { kind: "transport", id: n.id };
1255
+ }
1256
+ const sn = 150, nn = {
1257
+ ArrowRight: "next",
1258
+ ArrowLeft: "previous",
1259
+ ArrowUp: "up",
1260
+ ArrowDown: "down",
1261
+ Home: "first",
1262
+ End: "last",
1263
+ PageDown: "pageNext",
1264
+ PageUp: "pagePrevious"
1265
+ };
1266
+ class on {
1267
+ constructor(t) {
1268
+ f(this, "spoken", null);
1269
+ f(this, "timer", null);
1270
+ this.host = t;
1271
+ }
1272
+ /** Where the keys stand: the hover, whoever set it. */
1273
+ active() {
1274
+ const t = this.host.gestures.hover;
1275
+ return t.kind === "subtask" ? { kind: "subtask", id: t.subtask.id } : t.kind === "transport" ? { kind: "transport", id: t.transport.id } : null;
1276
+ }
1277
+ /** The focus came in by keyboard: the walk starts where the pointer
1278
+ stands, or at the first subtask in view. A click focuses the plot too,
1279
+ and must not start it. */
1280
+ focus(t) {
1281
+ !t || this.active() !== null || this.walk("first");
1282
+ }
1283
+ /** The focus left: the keys' subtask goes with it. */
1284
+ blur() {
1285
+ this.host.gestures.byKeyboard && this.host.gestures.setKeyboardHover({ kind: "nothing" }, { x: 0, y: 0 });
1286
+ }
1287
+ /** A key on the plot; true where the schedule took it. */
1288
+ key(t) {
1289
+ const e = this.host.gestures;
1290
+ if (t.metaKey || !e.idle) return !1;
1291
+ const s = t.key.toLowerCase() === "t" && !t.ctrlKey && !t.altKey;
1292
+ if (t.key === "]" || t.key === "[" || s) {
1293
+ const i = this.active();
1294
+ if (i === null) return !1;
1295
+ const r = this.host.data, a = s ? !t.shiftKey : t.key === "]";
1296
+ return this.show(en(r.transports, r.subtaskById, i, a ? "out" : "back")), !0;
1297
+ }
1298
+ if (t.ctrlKey) return !1;
1299
+ if (t.altKey) return this.edit(t);
1300
+ if (t.key === "Escape")
1301
+ return e.byKeyboard ? (this.blur(), !0) : !1;
1302
+ if (t.key === "Enter" || t.key === " ") return this.select();
1303
+ const n = t.shiftKey ? void 0 : nn[t.key];
1304
+ return n === void 0 ? !1 : (this.walk(n), !0);
1305
+ }
1306
+ walk(t) {
1307
+ var h;
1308
+ const { data: e, view: s } = this.host, n = this.active(), i = n === null ? null : n.kind === "subtask" ? n.id : ((h = e.transports.find((c) => c.id === n.id)) == null ? void 0 : h.from) ?? null;
1309
+ let r = Qs(s.rows, e.subtasks);
1310
+ if (i === null) {
1311
+ const c = r.filter((l) => {
1312
+ const d = s.boxById.get(l[0].id);
1313
+ return d !== void 0 && d.y + d.height > 0 && d.y < s.height;
1314
+ });
1315
+ c.length > 0 && (r = c);
1316
+ }
1317
+ const a = tn(r, i, t, this.host.visibleDomain());
1318
+ a !== null && this.show({ kind: "subtask", id: a.id });
1319
+ }
1320
+ /** Space and Enter select as a click does: the whole task, and the subtask. */
1321
+ select() {
1322
+ const t = this.host.gestures.hover;
1323
+ if (t.kind === "subtask") this.host.select(t.subtask.task, t.subtask.id);
1324
+ else if (t.kind === "transport") this.host.select(this.host.data.taskOfTransport(t.transport), null);
1325
+ else return !1;
1326
+ return !0;
1327
+ }
1328
+ /** Alt+←/→ proposes a move by one step of the raster, Alt+Shift+←/→ a new
1329
+ end - the intents a drag of that length reports (ADR-0023), and only
1330
+ where the caller handles them. Nothing is applied here. */
1331
+ edit(t) {
1332
+ var l, d;
1333
+ const e = this.host.gestures.hover, s = t.key === "ArrowRight" ? 1 : t.key === "ArrowLeft" ? -1 : 0;
1334
+ if (s === 0) return !1;
1335
+ if (e.kind !== "subtask") return !0;
1336
+ const n = e.subtask, i = this.host.gestures, r = this.host.view.options.intents, a = i.snapStep(), h = a.step > 0 ? a : { step: this.host.view.step(), offset: 0 };
1337
+ let c = null;
1338
+ if (!t.shiftKey && r.includes("move")) {
1339
+ const p = i.shifted(n.from, s * h.step, h);
1340
+ p !== n.from && (c = { kind: "move", subtask: n.id, from: p, to: p + (n.to - n.from) });
1341
+ } else if (t.shiftKey && r.includes("stretch")) {
1342
+ const p = Math.max(i.shifted(n.to, s * h.step, h), n.from + Math.max(h.step, X));
1343
+ p !== n.to && (c = { kind: "stretch", subtask: n.id, from: n.from, to: p });
1344
+ }
1345
+ return i.byKeyboard = !0, c !== null && ((d = (l = this.host.handlers()).onIntent) == null || d.call(l, c)), this.scheduleReadout(), !0;
1346
+ }
1347
+ /** The keys stand on this target: brought into view, drawn as the hover. */
1348
+ show(t, e = !0) {
1349
+ const s = this.hitOf(t);
1350
+ if (s === null) return;
1351
+ e && this.reveal(t);
1352
+ const n = this.bounds(t);
1353
+ if (n === null) return;
1354
+ const { view: i } = this.host, r = (a, h) => Math.max(0, Math.min(h, a));
1355
+ this.host.gestures.setKeyboardHover(s, {
1356
+ x: (r(n.x0, i.width) + r(n.x1, i.width)) / 2,
1357
+ y: (r(n.y0, i.height) + r(n.y1, i.height)) / 2
1358
+ }), e && this.scheduleReadout();
1359
+ }
1360
+ hitOf(t) {
1361
+ const e = this.host.data;
1362
+ if (t.kind === "subtask") {
1363
+ const n = e.subtaskById.get(t.id);
1364
+ return n === void 0 ? null : { kind: "subtask", subtask: n, part: "main" };
1365
+ }
1366
+ const s = e.transports.find((n) => n.id === t.id);
1367
+ return s === void 0 ? null : { kind: "transport", transport: s };
1368
+ }
1369
+ /** Where a target lies on the plot: a subtask's bar, or the span between
1370
+ the two bars a transport joins. */
1371
+ bounds(t) {
1372
+ const e = this.host.view, s = (a) => e.boxById.get(a);
1373
+ if (t.kind === "subtask") {
1374
+ const a = s(t.id);
1375
+ return a === void 0 ? null : { x0: a.outerFrom, x1: a.outerTo, y0: a.y, y1: a.y + a.height };
1376
+ }
1377
+ const n = this.host.data.transports.find((a) => a.id === t.id), i = n === void 0 ? void 0 : s(n.from), r = n === void 0 ? void 0 : s(n.to);
1378
+ return i === void 0 || r === void 0 ? null : {
1379
+ x0: Math.min(i.mainTo, r.mainFrom),
1380
+ x1: Math.max(i.mainTo, r.mainFrom),
1381
+ y0: Math.min(i.y, r.y),
1382
+ y1: Math.max(i.y + i.height, r.y + r.height)
1383
+ };
1384
+ }
1385
+ /** Pans and scrolls just enough to bring a target into view, with a margin
1386
+ at the side it came in from; a target wider than the view shows its
1387
+ start. As a drag at the edge pans along, the keys do. */
1388
+ reveal(t) {
1389
+ const e = this.bounds(t), s = this.host.view;
1390
+ if (e === null || s.width <= 0) return;
1391
+ const n = Math.min(24, s.width / 10), i = e.x0 < 0 ? e.x0 - n : e.x1 > s.width ? Math.max(0, Math.min(e.x1 - s.width + n, e.x0 - n)) : 0, r = e.y0 < 0 ? e.y0 : e.y1 > s.height ? Math.min(e.y1 - s.height, e.y0) : 0;
1392
+ if (i === 0 && r === 0) return;
1393
+ const a = s.pan(i, r);
1394
+ a.moved && this.host.viewMoved(a.time);
1395
+ }
1396
+ /** After the data or the view changed: the keys' target is read anew by its
1397
+ id - its new times, its new place -, and dropped where it is gone. */
1398
+ refresh() {
1399
+ const t = this.active();
1400
+ !this.host.gestures.byKeyboard || t === null || (this.hitOf(t) === null || this.bounds(t) === null ? this.blur() : this.show(t, !1));
1401
+ }
1402
+ /** The readout, written once the keys rest - and only while they still hold
1403
+ the hover: a pointer that took it over in the pause is not spoken for. */
1404
+ scheduleReadout() {
1405
+ this.timer !== null && clearTimeout(this.timer), this.timer = setTimeout(() => {
1406
+ var s;
1407
+ this.timer = null;
1408
+ const t = this.host.gestures.hover;
1409
+ if (!this.host.gestures.byKeyboard) return;
1410
+ const e = this.host.data.tooltipTargetFor(t);
1411
+ e !== null && (this.spoken = { target: e, lane: t.kind === "subtask" ? t.subtask.lane : null, count: (((s = this.spoken) == null ? void 0 : s.count) ?? 0) + 1 }, this.host.spokenChanged());
1412
+ }, sn);
1413
+ }
1414
+ /** Unmount: no readout after it. */
1415
+ stop() {
1416
+ this.timer !== null && clearTimeout(this.timer), this.timer = null;
1417
+ }
1418
+ }
1419
+ const $e = [], rn = 56;
1420
+ function an(o, t = rn) {
1421
+ return o > 0 ? Math.min(ot, Math.max(15 * X, is(o * t, 1))) : 15 * X;
1422
+ }
1423
+ function ln(o, t, e = $e) {
1424
+ const [s, n] = Be(o, e);
1425
+ return rs(e, s, n, t, Se(s)).filter(
1426
+ (i) => i.operatingTime >= o[0] && i.operatingTime <= o[1]
1168
1427
  );
1169
1428
  }
1170
- function Ks(n, t = _e) {
1171
- const [e, s] = Fe(n, t), o = [], i = new Date(e);
1172
- for (i.setHours(0, 0, 0, 0); i.getTime() < s && o.length < 400; ) {
1429
+ function hn(o, t = $e) {
1430
+ const [e, s] = Be(o, t), n = [], i = new Date(e);
1431
+ for (i.setHours(0, 0, 0, 0); i.getTime() < s && n.length < 400; ) {
1173
1432
  const r = i.getTime();
1174
1433
  i.setDate(i.getDate() + 1);
1175
1434
  const a = i.getTime();
1176
- o.push({
1435
+ n.push({
1177
1436
  start: r,
1178
1437
  end: a,
1179
- from: B(r, t),
1180
- to: B(a, t)
1438
+ from: K(r, t),
1439
+ to: K(a, t)
1181
1440
  });
1182
1441
  }
1183
- return o;
1442
+ return n;
1184
1443
  }
1185
- function Us(n, t, e, s) {
1186
- const o = n[1] - n[0];
1187
- if (!(o > 0)) return [n[0], n[1]];
1188
- const i = Math.min(s.max, Math.max(s.min, o * e)), r = (t - n[0]) / o, a = t - r * i;
1444
+ function un(o, t, e, s) {
1445
+ const n = o[1] - o[0];
1446
+ if (!(n > 0)) return [o[0], o[1]];
1447
+ const i = Math.min(s.max, Math.max(s.min, n * e)), r = (t - o[0]) / n, a = t - r * i;
1189
1448
  return [a, a + i];
1190
1449
  }
1191
- function zs(n, t) {
1192
- return [n[0] + t, n[1] + t];
1450
+ function cn(o, t) {
1451
+ return [o[0] + t, o[1] + t];
1193
1452
  }
1194
- function Fe(n, t) {
1195
- const e = j(t);
1196
- if (e.intervals.length === 0) return [n[0], n[1]];
1197
- const s = (o) => Math.max(0, Math.min(e.total, o));
1198
- return [U(s(n[0]), e), U(s(n[1]), e)];
1453
+ function Be(o, t) {
1454
+ const e = V(t);
1455
+ if (e.intervals.length === 0) return [o[0], o[1]];
1456
+ const s = (n) => Math.max(0, Math.min(e.total, n));
1457
+ return [W(s(o[0]), e), W(s(o[1]), e)];
1199
1458
  }
1200
- const lt = 44;
1201
- class Ws {
1459
+ const ht = 44;
1460
+ class dn {
1202
1461
  constructor(t) {
1203
1462
  f(this, "options", {
1204
- laneHeight: lt,
1463
+ laneHeight: ht,
1205
1464
  calendar: [],
1206
- zoomLimits: { min: Tt, max: 28 * st },
1465
+ zoomLimits: { min: Dt, max: 28 * ot },
1207
1466
  snap: "ticks",
1208
1467
  intents: [],
1209
1468
  now: null,
@@ -1211,14 +1470,14 @@ class Ws {
1211
1470
  attach: "centre",
1212
1471
  ends: "dot"
1213
1472
  });
1214
- f(this, "domain", [0, st]);
1473
+ f(this, "domain", [0, ot]);
1215
1474
  f(this, "scrollY", 0);
1216
1475
  f(this, "width", 0);
1217
1476
  f(this, "height", 0);
1218
1477
  /* What is laid out from top to bottom (`rows.ts`). It is derived here and
1219
1478
  not in the data, because a row's height comes from a view option; every y
1220
1479
  in the package reads it. */
1221
- f(this, "rows", qt({ lanes: [], groups: [], collapsed: /* @__PURE__ */ new Set(), laneHeight: lt }));
1480
+ f(this, "rows", ie({ lanes: [], groups: [], collapsed: /* @__PURE__ */ new Set(), laneHeight: ht }));
1222
1481
  /** The folded groups, as the scene holds them. */
1223
1482
  f(this, "collapsed", /* @__PURE__ */ new Set());
1224
1483
  /** The groups a gesture in flight holds open. Dropped when it ends; the
@@ -1232,20 +1491,20 @@ class Ws {
1232
1491
  /** Takes new options; an initial domain in wall-clock time puts the view
1233
1492
  there, and a new calendar keeps the wall-clock span in view. */
1234
1493
  setOptions(t, e) {
1235
- const s = t.calendar !== this.options.calendar, o = this.options.calendar;
1494
+ const s = t.calendar !== this.options.calendar, n = this.options.calendar;
1236
1495
  if (this.options = t, e !== null)
1237
- this.domain = [B(e[0], t.calendar), B(e[1], t.calendar)];
1496
+ this.domain = [K(e[0], t.calendar), K(e[1], t.calendar)];
1238
1497
  else if (s) {
1239
- const i = j(o), r = (a) => {
1240
- const u = i.intervals.length === 0 ? a : Math.max(0, Math.min(i.total, a));
1241
- return B(U(u, i), t.calendar) + (a - u);
1498
+ const i = V(n), r = (a) => {
1499
+ const h = i.intervals.length === 0 ? a : Math.max(0, Math.min(i.total, a));
1500
+ return K(W(h, i), t.calendar) + (a - h);
1242
1501
  };
1243
1502
  this.domain = [r(this.domain[0]), r(this.domain[1])];
1244
1503
  }
1245
1504
  }
1246
1505
  viewport() {
1247
1506
  return {
1248
- scale: new Ze(this.domain, [0, this.width]),
1507
+ scale: new as(this.domain, [0, this.width]),
1249
1508
  calendar: this.options.calendar,
1250
1509
  laneHeight: this.options.laneHeight,
1251
1510
  scrollY: this.scrollY,
@@ -1262,28 +1521,28 @@ class Ws {
1262
1521
  /** The fine band's step at the current zoom. */
1263
1522
  step() {
1264
1523
  const t = this.domain[1] - this.domain[0];
1265
- return Ys(this.width > 0 ? t / this.width : t);
1524
+ return an(this.width > 0 ? t / this.width : t);
1266
1525
  }
1267
1526
  /** Lays the rows out, clamps the scroll, and lays the data out anew. */
1268
1527
  layout() {
1269
- this.rows = qt({
1528
+ this.rows = ie({
1270
1529
  lanes: this.data.lanes,
1271
1530
  groups: this.data.groups,
1272
- collapsed: rs(this.collapsed, this.openForGesture),
1531
+ collapsed: gs(this.collapsed, this.openForGesture),
1273
1532
  laneHeight: this.options.laneHeight
1274
1533
  }), this.scrollY = Math.max(0, Math.min(this.maxScroll(), this.scrollY));
1275
1534
  const t = this.viewport();
1276
1535
  this.boxes = [], this.boxById = /* @__PURE__ */ new Map();
1277
1536
  for (const e of this.data.subtasks) {
1278
- const s = Lt(this.rows, e.lane);
1537
+ const s = Rt(this.rows, e.lane);
1279
1538
  if (s === null) continue;
1280
- const o = Te(t, e, e.lane, s, this.data.depth.get(e.id) ?? 0);
1281
- this.boxes.push(o), this.boxById.set(e.id, o);
1539
+ const n = Ee(t, e, e.lane, s, this.data.depth.get(e.id) ?? 0);
1540
+ this.boxes.push(n), this.boxById.set(e.id, n);
1282
1541
  }
1283
1542
  this.paths = [];
1284
1543
  for (const e of this.data.transports) {
1285
- const s = this.boxById.get(e.from), o = this.boxById.get(e.to);
1286
- s === void 0 || o === void 0 || this.paths.push(bt(t, e, s, o, this.options));
1544
+ const s = this.boxById.get(e.from), n = this.boxById.get(e.to);
1545
+ s === void 0 || n === void 0 || this.paths.push(At(t, e, s, n, this.options));
1287
1546
  }
1288
1547
  }
1289
1548
  /** The days of the coarse band and the ticks of the fine band, in pixels. */
@@ -1292,11 +1551,11 @@ class Ws {
1292
1551
  if (this.width <= 0) return { days: [], ticks: [], step: t };
1293
1552
  const e = this.viewport().scale, s = this.options.calendar;
1294
1553
  return {
1295
- days: Ks(this.domain, s).map((o) => {
1296
- const i = Math.round(e.toPx(o.from));
1297
- return { start: o.start, x: i, width: Math.round(e.toPx(o.to)) - i };
1554
+ days: hn(this.domain, s).map((n) => {
1555
+ const i = Math.round(e.toPx(n.from));
1556
+ return { start: n.start, x: i, width: Math.round(e.toPx(n.to)) - i };
1298
1557
  }),
1299
- ticks: Xs(this.domain, t, s).map((o) => ({ wallClock: o.wallClock, x: Math.round(e.toPx(o.operatingTime)) })),
1558
+ ticks: ln(this.domain, t, s).map((n) => ({ wallClock: n.wallClock, x: Math.round(e.toPx(n.operatingTime)) })),
1300
1559
  step: t
1301
1560
  };
1302
1561
  }
@@ -1304,27 +1563,27 @@ class Ws {
1304
1563
  nowX() {
1305
1564
  const t = this.options.now;
1306
1565
  if (t === null || this.width <= 0) return null;
1307
- const e = Math.round(this.viewport().scale.toPx(B(t, this.options.calendar)));
1566
+ const e = Math.round(this.viewport().scale.toPx(K(t, this.options.calendar)));
1308
1567
  return e >= 0 && e <= this.width ? e : null;
1309
1568
  }
1310
1569
  hitAt(t, e) {
1311
1570
  for (let r = this.boxes.length - 1; r >= 0; r--) {
1312
- const a = this.boxes[r], u = Ce(a, t, e);
1313
- if (u !== null) return { kind: "subtask", subtask: a.subtask, part: u };
1571
+ const a = this.boxes[r], h = Pe(a, t, e);
1572
+ if (h !== null) return { kind: "subtask", subtask: a.subtask, part: h };
1314
1573
  }
1315
- let s = null, o = 4;
1574
+ let s = null, n = 4;
1316
1575
  for (const r of this.paths) {
1317
- const a = fs(r, t, e);
1318
- a <= o && (o = a, s = r);
1576
+ const a = Ts(r, t, e);
1577
+ a <= n && (n = a, s = r);
1319
1578
  }
1320
1579
  if (s !== null) return { kind: "transport", transport: s.transport };
1321
- const i = Jt(this.viewport(), e);
1580
+ const i = he(this.viewport(), e);
1322
1581
  return i !== null ? { kind: "lane", lane: i } : { kind: "nothing" };
1323
1582
  }
1324
1583
  /** The wall-clock time at a plot x; within the calendar's extent. */
1325
1584
  timeAt(t) {
1326
- const e = this.viewport().scale.fromPx(t), s = j(this.options.calendar);
1327
- return s.intervals.length === 0 ? e : U(Math.max(0, Math.min(s.total, e)), s);
1585
+ const e = this.viewport().scale.fromPx(t), s = V(this.options.calendar);
1586
+ return s.intervals.length === 0 ? e : W(Math.max(0, Math.min(s.total, e)), s);
1328
1587
  }
1329
1588
  /** The lane at a y, strips included: what the pointer is ON.
1330
1589
 
@@ -1333,7 +1592,7 @@ class Ws {
1333
1592
  `foldedGroupAt` - and a caller that reached through `viewport()` for it
1334
1593
  would be depending on the layout rather than asking the view. */
1335
1594
  laneIdAt(t) {
1336
- return Jt(this.viewport(), t);
1595
+ return he(this.viewport(), t);
1337
1596
  }
1338
1597
  /** The lane a DROP at this y would land on.
1339
1598
 
@@ -1343,50 +1602,53 @@ class Ws {
1343
1602
  aim at. Hover, the tooltip and selection do read a strip - they cost
1344
1603
  nothing if they are a pixel out. */
1345
1604
  dropLaneIdAt(t) {
1346
- const e = nt(this.rows, t + this.scrollY);
1605
+ const e = Z(this.rows, t + this.scrollY);
1347
1606
  return e === null || e.kind !== "lane" ? null : e.lane ?? null;
1348
1607
  }
1349
1608
  /** The folded group a y lies over, or null. */
1350
1609
  foldedGroupAt(t) {
1351
- const e = nt(this.rows, t + this.scrollY);
1610
+ const e = Z(this.rows, t + this.scrollY);
1352
1611
  return e !== null && e.kind === "miniature" ? e.group ?? null : null;
1353
1612
  }
1354
1613
  /** Pans by pixels. Says what moved: the span through time, the lanes, or
1355
1614
  neither - a scroll through the lanes is no news about the time. */
1356
1615
  pan(t, e) {
1357
- const s = this.domain[0], o = this.scrollY, i = this.domain[1] - s;
1358
- this.width > 0 && t !== 0 && (this.domain = zs(this.domain, t / this.width * i)), this.scrollY = Math.max(0, Math.min(this.maxScroll(), this.scrollY + e));
1616
+ const s = this.domain[0], n = this.scrollY, i = this.domain[1] - s;
1617
+ this.width > 0 && t !== 0 && (this.domain = cn(this.domain, t / this.width * i)), this.scrollY = Math.max(0, Math.min(this.maxScroll(), this.scrollY + e));
1359
1618
  const r = this.domain[0] !== s;
1360
- return { moved: r || this.scrollY !== o, time: r };
1619
+ return { moved: r || this.scrollY !== n, time: r };
1361
1620
  }
1362
1621
  /** Zooms around a plot x; says whether the span changed. */
1363
1622
  zoomAt(t, e) {
1364
1623
  if (this.width <= 0 || !Number.isFinite(e)) return !1;
1365
- const s = this.domain, o = this.viewport().scale.fromPx(t);
1366
- return this.domain = Us(this.domain, o, e, this.options.zoomLimits), s[0] !== this.domain[0] || s[1] !== this.domain[1];
1624
+ const s = this.domain, n = this.viewport().scale.fromPx(t);
1625
+ return this.domain = un(this.domain, n, e, this.options.zoomLimits), s[0] !== this.domain[0] || s[1] !== this.domain[1];
1367
1626
  }
1368
1627
  }
1369
- const ue = {
1628
+ const be = {
1370
1629
  width: 0,
1371
1630
  height: 0,
1372
- laneHeight: lt,
1631
+ laneHeight: ht,
1373
1632
  scrollY: 0,
1374
1633
  headers: [],
1375
1634
  days: [],
1376
1635
  ticks: [],
1377
- step: Tt,
1636
+ step: Dt,
1378
1637
  ghost: null,
1379
1638
  grips: [],
1380
1639
  cursor: "default",
1381
1640
  tooltip: null,
1382
1641
  now: null,
1383
- bars: []
1642
+ bars: [],
1643
+ spoken: null,
1644
+ summary: { lanes: 0, subtasks: 0, from: 0, to: 0, overlaps: 0, late: 0 }
1384
1645
  };
1385
- class qs {
1646
+ class fn {
1386
1647
  constructor() {
1387
- f(this, "data", new ms(() => this.viewChanged()));
1388
- f(this, "view", new Ws(this.data));
1648
+ f(this, "data", new Ls(() => this.viewChanged()));
1649
+ f(this, "view", new dn(this.data));
1389
1650
  f(this, "gestures");
1651
+ f(this, "keys");
1390
1652
  f(this, "handlersNow", {});
1391
1653
  f(this, "placing", null);
1392
1654
  f(this, "controlledTask");
@@ -1405,7 +1667,7 @@ class qs {
1405
1667
  f(this, "frame", 0);
1406
1668
  f(this, "domainFrame", 0);
1407
1669
  f(this, "unsubscribeTheme", null);
1408
- f(this, "snapshot", ue);
1670
+ f(this, "snapshot", be);
1409
1671
  f(this, "listeners", /* @__PURE__ */ new Set());
1410
1672
  /* ---------------------------------------------------------------- */
1411
1673
  /* Registration and options */
@@ -1423,7 +1685,7 @@ class qs {
1423
1685
  this.listeners.delete(t);
1424
1686
  }));
1425
1687
  f(this, "getSnapshot", () => this.snapshot);
1426
- f(this, "getServerSnapshot", () => ue);
1688
+ f(this, "getServerSnapshot", () => be);
1427
1689
  /* ---------------------------------------------------------------- */
1428
1690
  /* Gestures, as the component hands them in */
1429
1691
  /* ---------------------------------------------------------------- */
@@ -1438,7 +1700,10 @@ class qs {
1438
1700
  f(this, "drop", (t) => this.gestures.drop(t));
1439
1701
  f(this, "dragLeave", () => this.gestures.clearPlacing());
1440
1702
  f(this, "cancelEdit", () => this.gestures.cancelEdit());
1441
- this.gestures = new Bs({
1703
+ f(this, "key", (t) => this.keys.key(t));
1704
+ f(this, "focus", (t) => this.keys.focus(t));
1705
+ f(this, "blur", () => this.keys.blur());
1706
+ this.gestures = new Js({
1442
1707
  data: this.data,
1443
1708
  view: this.view,
1444
1709
  plotElement: () => this.plot,
@@ -1450,6 +1715,17 @@ class qs {
1450
1715
  this.viewChanged(), t && this.reportDomain();
1451
1716
  },
1452
1717
  interactionChanged: () => this.interactionChanged()
1718
+ }), this.keys = new on({
1719
+ data: this.data,
1720
+ view: this.view,
1721
+ gestures: this.gestures,
1722
+ handlers: () => this.handlersNow,
1723
+ visibleDomain: () => this.visibleDomain(),
1724
+ select: (t, e) => this.select(t, e),
1725
+ viewMoved: (t) => {
1726
+ this.viewChanged(), t && this.reportDomain();
1727
+ },
1728
+ spokenChanged: () => this.publish()
1453
1729
  });
1454
1730
  }
1455
1731
  setOptions(t, e) {
@@ -1476,9 +1752,9 @@ class qs {
1476
1752
  /** Folds or unfolds one group. The caller's list is never written to: where
1477
1753
  the state is controlled, only the report goes out. */
1478
1754
  toggleGroup(t) {
1479
- var o, i;
1755
+ var n, i;
1480
1756
  const e = this.collapsedGroups, s = e.includes(t) ? e.filter((r) => r !== t) : [...e, t];
1481
- this.controlledCollapsed === void 0 && (this.ownCollapsed = s), (i = (o = this.handlersNow).onCollapsedGroupsChange) == null || i.call(o, s), this.viewChanged();
1757
+ this.controlledCollapsed === void 0 && (this.ownCollapsed = s), (i = (n = this.handlersNow).onCollapsedGroupsChange) == null || i.call(n, s), this.viewChanged();
1482
1758
  }
1483
1759
  /** `undefined`: the scene keeps the selection itself. */
1484
1760
  setControlledTask(t) {
@@ -1488,31 +1764,31 @@ class qs {
1488
1764
  return this.controlledTask !== void 0 ? this.controlledTask : this.ownTask;
1489
1765
  }
1490
1766
  select(t, e) {
1491
- var o, i;
1767
+ var n, i;
1492
1768
  const s = t !== this.selectedTask || e !== this.selected;
1493
- this.selected = e, t !== this.selectedTask && this.controlledTask === void 0 && (this.ownTask = t), s && ((i = (o = this.handlersNow).onSelectedTaskChange) == null || i.call(o, t, e)), this.interactionChanged();
1769
+ this.selected = e, t !== this.selectedTask && this.controlledTask === void 0 && (this.ownTask = t), s && ((i = (n = this.handlersNow).onSelectedTaskChange) == null || i.call(n, t, e)), this.interactionChanged();
1494
1770
  }
1495
1771
  /* ---------------------------------------------------------------- */
1496
1772
  /* DOM binding */
1497
1773
  /* ---------------------------------------------------------------- */
1498
- bind(t, e, s, o) {
1499
- this.root = t, this.plot = e, this.dataCanvas = s, this.overlayCanvas = o, this.unsubscribeTheme = Je(() => {
1774
+ bind(t, e, s, n) {
1775
+ this.root = t, this.plot = e, this.dataCanvas = s, this.overlayCanvas = n, this.unsubscribeTheme = ls(() => {
1500
1776
  this.colours = null, this.requestDraw();
1501
1777
  }), this.viewChanged();
1502
1778
  }
1503
1779
  unbind() {
1504
1780
  var t;
1505
- this.gestures.cancelEdit(), (t = this.unsubscribeTheme) == null || t.call(this), this.unsubscribeTheme = null, this.frame !== 0 && cancelAnimationFrame(this.frame), this.domainFrame !== 0 && cancelAnimationFrame(this.domainFrame), this.frame = this.domainFrame = 0, this.root = this.plot = this.dataCanvas = this.overlayCanvas = null;
1781
+ this.gestures.cancelEdit(), this.keys.stop(), (t = this.unsubscribeTheme) == null || t.call(this), this.unsubscribeTheme = null, this.frame !== 0 && cancelAnimationFrame(this.frame), this.domainFrame !== 0 && cancelAnimationFrame(this.domainFrame), this.frame = this.domainFrame = 0, this.root = this.plot = this.dataCanvas = this.overlayCanvas = null;
1506
1782
  }
1507
1783
  resize(t, e) {
1508
- const s = Math.max(0, Math.round(t)), o = Math.max(0, Math.round(e));
1509
- s === this.view.width && o === this.view.height || (this.view.width = s, this.view.height = o, this.viewChanged());
1784
+ const s = Math.max(0, Math.round(t)), n = Math.max(0, Math.round(e));
1785
+ s === this.view.width && n === this.view.height || (this.view.width = s, this.view.height = n, this.viewChanged());
1510
1786
  }
1511
1787
  /* ---------------------------------------------------------------- */
1512
1788
  /* Changes */
1513
1789
  /* ---------------------------------------------------------------- */
1514
1790
  viewChanged() {
1515
- this.view.collapsed = new Set(this.collapsedGroups), this.data.rebuild() && (this.colours = null, this.selected !== null && !this.data.subtaskById.has(this.selected) && (this.selected = null)), this.view.layout(), this.gestures.refreshHover(), this.interactionChanged();
1791
+ this.view.collapsed = new Set(this.collapsedGroups), this.data.rebuild() && (this.colours = null, this.selected !== null && !this.data.subtaskById.has(this.selected) && (this.selected = null)), this.view.layout(), this.gestures.refreshHover(), this.keys.refresh(), this.interactionChanged();
1516
1792
  }
1517
1793
  interactionChanged() {
1518
1794
  this.publish(), this.requestDraw();
@@ -1531,27 +1807,29 @@ class qs {
1531
1807
  cursor: this.gestures.cursor,
1532
1808
  tooltip: this.tooltip(),
1533
1809
  now: t.nowX(),
1534
- bars: this.bars()
1810
+ bars: this.bars(),
1811
+ spoken: this.keys.spoken,
1812
+ summary: this.summary()
1535
1813
  };
1536
- for (const o of this.listeners) o();
1814
+ for (const n of this.listeners) n();
1537
1815
  }
1538
1816
  /** One header per row, with what it says and where it sits. The scroll is
1539
1817
  not taken off here: the header column is moved as a whole, as it always
1540
1818
  was, so that a header and its row cannot drift apart by a rounding. */
1541
1819
  headers() {
1542
- const t = new Map(this.data.lanes.map((o) => [o.id, o.label])), e = new Map(this.data.groups.map((o) => [o.id, o.label])), s = new Set(this.collapsedGroups);
1543
- return this.view.rows.rows.map((o) => ({
1544
- key: o.lane ?? o.group ?? "",
1545
- kind: o.kind,
1546
- lane: o.lane,
1547
- group: o.group,
1548
- label: (o.lane !== void 0 ? t.get(o.lane) : e.get(o.group ?? "")) ?? o.lane ?? o.group ?? "",
1549
- depth: o.depth,
1550
- within: o.within,
1551
- lanes: o.lanes,
1552
- collapsed: o.group === void 0 ? void 0 : s.has(o.group),
1553
- top: o.top,
1554
- height: o.height
1820
+ const t = new Map(this.data.lanes.map((n) => [n.id, n.label])), e = new Map(this.data.groups.map((n) => [n.id, n.label])), s = new Set(this.collapsedGroups);
1821
+ return this.view.rows.rows.map((n) => ({
1822
+ key: n.lane ?? n.group ?? "",
1823
+ kind: n.kind,
1824
+ lane: n.lane,
1825
+ group: n.group,
1826
+ label: (n.lane !== void 0 ? t.get(n.lane) : e.get(n.group ?? "")) ?? n.lane ?? n.group ?? "",
1827
+ depth: n.depth,
1828
+ within: n.within,
1829
+ lanes: n.lanes,
1830
+ collapsed: n.group === void 0 ? void 0 : s.has(n.group),
1831
+ top: n.top,
1832
+ height: n.height
1555
1833
  }));
1556
1834
  }
1557
1835
  /** The bars a label could stand in: the visible part of every main time,
@@ -1562,24 +1840,37 @@ class qs {
1562
1840
  if (t.width <= 0) return [];
1563
1841
  const e = this.colours;
1564
1842
  return t.boxes.flatMap((s) => {
1565
- if (!Le(s, t.width, t.height)) return [];
1566
- const o = cs(s, t.width);
1567
- if (o === null) return [];
1568
- const i = e === null ? void 0 : e.tasks.get(s.subtask.task), r = i === void 0 || e === null ? !0 : Ft(ht(s.subtask.appearance), i, e).onDark;
1569
- return [{ subtask: s.subtask, ...o, dark: r }];
1843
+ if (!It(s, t.width, t.height)) return [];
1844
+ const n = bs(s, t.width);
1845
+ if (n === null) return [];
1846
+ const i = e === null ? void 0 : e.tasks.get(s.subtask.task), r = i === void 0 || e === null ? !0 : Bt(ct(s.subtask.appearance), i, e).onDark;
1847
+ return [{ subtask: s.subtask, ...n, dark: r }];
1570
1848
  });
1571
1849
  }
1850
+ /** The findings count the whole plan - an overlap out of view is still one
1851
+ to know of -, the subtasks only what is in view. */
1852
+ summary() {
1853
+ const t = this.view, [e, s] = this.visibleDomain();
1854
+ return {
1855
+ lanes: this.data.lanes.length,
1856
+ subtasks: t.boxes.filter((n) => It(n, t.width, t.height)).length,
1857
+ from: e,
1858
+ to: s,
1859
+ overlaps: this.data.overlaps.length,
1860
+ late: this.data.lateById.size
1861
+ };
1862
+ }
1572
1863
  tooltip() {
1573
1864
  const t = this.gestures.hover;
1574
1865
  if (!this.gestures.idle) return null;
1575
1866
  const e = this.data.tooltipTargetFor(t);
1576
1867
  if (e === null) return null;
1577
- const { x: s, y: o } = this.gestures.hoverPoint;
1578
- return { target: e, x: s, y: o };
1868
+ const { x: s, y: n } = this.gestures.hoverPoint;
1869
+ return { target: e, x: s, y: n };
1579
1870
  }
1580
1871
  /** The visible span, as two wall-clock instants. */
1581
1872
  visibleDomain() {
1582
- const t = j(this.view.options.calendar), e = (s) => t.intervals.length === 0 ? s : U(Math.max(0, Math.min(t.total, s)), t);
1873
+ const t = V(this.view.options.calendar), e = (s) => t.intervals.length === 0 ? s : W(Math.max(0, Math.min(t.total, s)), t);
1583
1874
  return [e(this.view.domain[0]), e(this.view.domain[1])];
1584
1875
  }
1585
1876
  /** Reported once per frame, however many wheel steps a planner turns - and
@@ -1593,8 +1884,8 @@ class qs {
1593
1884
  return;
1594
1885
  }
1595
1886
  this.domainFrame === 0 && (this.domainFrame = requestAnimationFrame(() => {
1596
- var s, o;
1597
- this.domainFrame = 0, (o = (s = this.handlersNow).onDomainChange) == null || o.call(s, this.visibleDomain());
1887
+ var s, n;
1888
+ this.domainFrame = 0, (n = (s = this.handlersNow).onDomainChange) == null || n.call(s, this.visibleDomain());
1598
1889
  }));
1599
1890
  }
1600
1891
  /** The time and the lane at a client point, or null outside the plot. */
@@ -1602,8 +1893,8 @@ class qs {
1602
1893
  var r;
1603
1894
  const s = (r = this.plot) == null ? void 0 : r.getBoundingClientRect();
1604
1895
  if (s === void 0) return null;
1605
- const o = t - s.left, i = e - s.top;
1606
- return o < 0 || i < 0 || o > s.width || i > s.height ? null : { time: this.view.timeAt(o), lane: this.view.laneIdAt(i) };
1896
+ const n = t - s.left, i = e - s.top;
1897
+ return n < 0 || i < 0 || n > s.width || i > s.height ? null : { time: this.view.timeAt(n), lane: this.view.laneIdAt(i) };
1607
1898
  }
1608
1899
  /** The client point of a time, on a lane's middle where one is named, or
1609
1900
  null while the schedule is not on screen. */
@@ -1611,8 +1902,8 @@ class qs {
1611
1902
  var a;
1612
1903
  const s = (a = this.plot) == null ? void 0 : a.getBoundingClientRect();
1613
1904
  if (s === void 0) return null;
1614
- const o = this.view.viewport(), i = e === void 0 ? null : ct(o, e), r = i === null ? 0 : i.top + i.height / 2;
1615
- return { x: s.left + N(o, t), y: s.top + r };
1905
+ const n = this.view.viewport(), i = e === void 0 ? null : ft(n, e), r = i === null ? 0 : i.top + i.height / 2;
1906
+ return { x: s.left + R(n, t), y: s.top + r };
1616
1907
  }
1617
1908
  requestDraw() {
1618
1909
  this.frame !== 0 || this.dataCanvas === null || typeof requestAnimationFrame != "function" || (this.frame = requestAnimationFrame(() => {
@@ -1621,9 +1912,9 @@ class qs {
1621
1912
  }
1622
1913
  draw() {
1623
1914
  if (this.root === null) return;
1624
- this.colours === null && (this.colours = ws(this.root, this.data), this.publish());
1625
- const { width: t, height: e } = this.view, s = se(this.dataCanvas, t, e), o = se(this.overlayCanvas, t, e);
1626
- if (s === null || o === null || t === 0) return;
1915
+ this.colours === null && (this.colours = _s(this.root, this.data), this.publish());
1916
+ const { width: t, height: e } = this.view, s = fe(this.dataCanvas, t, e), n = fe(this.overlayCanvas, t, e);
1917
+ if (s === null || n === null || t === 0) return;
1627
1918
  const i = {
1628
1919
  data: this.data,
1629
1920
  view: this.view,
@@ -1634,385 +1925,441 @@ class qs {
1634
1925
  hover: this.gestures.hover,
1635
1926
  ghost: this.gestures.ghostDrawing()
1636
1927
  };
1637
- ks(s, i), vs(o, i);
1638
- }
1639
- }
1640
- const js = "_root_p2o7g_4 _text_1hv7a_23", Vs = "_corner_p2o7g_18", Zs = "_dayBand_p2o7g_22", Js = "_tickBand_p2o7g_23", Qs = "_day_p2o7g_22", tn = "_dayLabel_p2o7g_46", en = "_tick_p2o7g_23", sn = "_tickLabel_p2o7g_64", nn = "_headers_p2o7g_72", on = "_header_p2o7g_72", rn = "_headerLabel_p2o7g_90", an = "_headerCount_p2o7g_103", ln = "_chevron_p2o7g_112", hn = "_plot_p2o7g_170", un = "_layer_p2o7g_176", cn = "_grip_p2o7g_185", dn = "_ghostLabel_p2o7g_195", fn = "_finding_p2o7g_208", pn = "_refusal_p2o7g_216", mn = "_tooltip_p2o7g_220", gn = "_tooltipHead_p2o7g_238", wn = "_tooltipTimes_p2o7g_243", kn = "_now_p2o7g_252", vn = "_barLabel_p2o7g_266", yn = "_barLabelText_p2o7g_279", v = {
1641
- root: js,
1642
- corner: Vs,
1643
- dayBand: Zs,
1644
- tickBand: Js,
1645
- day: Qs,
1646
- dayLabel: tn,
1647
- tick: en,
1648
- tickLabel: sn,
1649
- headers: nn,
1650
- header: on,
1651
- headerLabel: rn,
1652
- headerCount: an,
1653
- chevron: ln,
1654
- plot: hn,
1655
- layer: un,
1656
- grip: cn,
1657
- ghostLabel: dn,
1658
- finding: fn,
1659
- refusal: pn,
1660
- tooltip: mn,
1661
- tooltipHead: gn,
1662
- tooltipTimes: wn,
1663
- now: kn,
1664
- barLabel: vn,
1665
- barLabelText: yn
1928
+ Fs(s, i), Ds(n, i);
1929
+ }
1930
+ }
1931
+ const pn = "_root_19uyg_4 _text_k1tvc_23", mn = "_corner_19uyg_19", gn = "_dayBand_19uyg_23", kn = "_tickBand_19uyg_24", wn = "_day_19uyg_23", yn = "_dayLabel_19uyg_47", vn = "_tick_19uyg_24", bn = "_tickLabel_19uyg_65", Mn = "_headers_19uyg_73", Tn = "_header_19uyg_73", Cn = "_headerLabel_19uyg_91", Ln = "_headerCount_19uyg_104", Sn = "_chevron_19uyg_113", In = "_plot_19uyg_171", An = "_focusRing_19uyg_178", _n = "_layer_19uyg_196", Fn = "_grip_19uyg_205", Dn = "_ghostLabel_19uyg_215", En = "_finding_19uyg_228", Pn = "_refusal_19uyg_236", Rn = "_tooltip_19uyg_240", xn = "_tooltipHead_19uyg_259", Nn = "_tooltipTimes_19uyg_264", Gn = "_now_19uyg_273", $n = "_barLabel_19uyg_287", Bn = "_barLabelText_19uyg_300", y = {
1932
+ root: pn,
1933
+ corner: mn,
1934
+ dayBand: gn,
1935
+ tickBand: kn,
1936
+ day: wn,
1937
+ dayLabel: yn,
1938
+ tick: vn,
1939
+ tickLabel: bn,
1940
+ headers: Mn,
1941
+ header: Tn,
1942
+ headerLabel: Cn,
1943
+ headerCount: Ln,
1944
+ chevron: Sn,
1945
+ plot: In,
1946
+ focusRing: An,
1947
+ layer: _n,
1948
+ grip: Fn,
1949
+ ghostLabel: Dn,
1950
+ finding: En,
1951
+ refusal: Pn,
1952
+ tooltip: Rn,
1953
+ tooltipHead: xn,
1954
+ tooltipTimes: Nn,
1955
+ now: Gn,
1956
+ barLabel: $n,
1957
+ barLabelText: Bn
1666
1958
  };
1667
- function bn({ target: n }) {
1668
- const t = ge(), e = we(), s = (l) => t.time(new Date(l), !1), o = (l) => {
1669
- const d = Math.round(l / q), p = Math.floor(d / 60), g = d % 60;
1670
- return [p > 0 ? e.hoursShort(p) : "", g > 0 || p === 0 ? e.minutesShort(g) : ""].filter(Boolean).join(" ");
1959
+ function Oe() {
1960
+ const o = ut();
1961
+ return (t) => {
1962
+ const e = Math.round(t / X), s = Math.floor(e / 60), n = e % 60;
1963
+ return [s > 0 ? o.hoursShort(s) : "", n > 0 || s === 0 ? o.minutesShort(n) : ""].filter(Boolean).join(" ");
1671
1964
  };
1672
- if (n.kind === "subtask") {
1673
- const { subtask: l, task: d } = n;
1674
- return /* @__PURE__ */ Y(Wt, { children: [
1675
- /* @__PURE__ */ k("span", { className: v.tooltipHead, children: (d == null ? void 0 : d.name) ?? l.task }),
1965
+ }
1966
+ function On({ target: o, lane: t }) {
1967
+ const e = Et(), s = ut(), n = Oe(), i = (d) => e.time(new Date(d), !1);
1968
+ if (o.kind === "subtask") {
1969
+ const { subtask: d, task: p } = o, w = [
1970
+ (p == null ? void 0 : p.name) ?? d.task,
1971
+ d.name ?? d.id,
1972
+ `${e.dateShort(new Date(d.from))} ${s.scheduleGhostTimes(i(d.from), i(d.to))}`,
1973
+ ...o.overlapping.map((v) => s.scheduleOverlapWith(v.name ?? v.id)),
1974
+ ...o.lateTransports.map((v) => s.scheduleLateBy(n(v.shortBy)))
1975
+ ];
1976
+ return /* @__PURE__ */ Y(St, { children: [
1977
+ t,
1978
+ `, ${w.join(", ")}`
1979
+ ] });
1980
+ }
1981
+ const { transport: r, task: a, from: h, to: c, late: l } = o;
1982
+ return [
1983
+ (a == null ? void 0 : a.name) ?? (a == null ? void 0 : a.id) ?? r.id,
1984
+ `${s.scheduleTransport} ${n(r.duration)}`,
1985
+ s.scheduleRoute((h == null ? void 0 : h.name) ?? r.from, (c == null ? void 0 : c.name) ?? r.to),
1986
+ ...l === void 0 ? [] : [s.scheduleLateBy(n(l.shortBy))]
1987
+ ].join(", ");
1988
+ }
1989
+ function Hn({ target: o }) {
1990
+ const t = Et(), e = ut(), s = (l) => t.time(new Date(l), !1), n = Oe();
1991
+ if (o.kind === "subtask") {
1992
+ const { subtask: l, task: d } = o;
1993
+ return /* @__PURE__ */ Y(St, { children: [
1994
+ /* @__PURE__ */ k("span", { className: y.tooltipHead, children: (d == null ? void 0 : d.name) ?? l.task }),
1676
1995
  /* @__PURE__ */ k("span", { children: l.name ?? l.id }),
1677
- /* @__PURE__ */ k("span", { className: v.tooltipTimes, children: e.scheduleGhostTimes(s(l.from), s(l.to)) }),
1678
- (l.setup ?? 0) > 0 && /* @__PURE__ */ k("span", { children: `${e.scheduleSetup} ${o(l.setup)}` }),
1679
- (l.teardown ?? 0) > 0 && /* @__PURE__ */ k("span", { children: `${e.scheduleTeardown} ${o(l.teardown)}` }),
1680
- n.overlapping.map((p) => /* @__PURE__ */ k("span", { className: v.finding, children: e.scheduleOverlapWith(p.name ?? p.id) }, p.id)),
1681
- n.lateTransports.map((p) => /* @__PURE__ */ k("span", { className: v.finding, children: e.scheduleLateBy(o(p.shortBy)) }, p.transport))
1996
+ /* @__PURE__ */ k("span", { className: y.tooltipTimes, children: e.scheduleGhostTimes(s(l.from), s(l.to)) }),
1997
+ (l.setup ?? 0) > 0 && /* @__PURE__ */ k("span", { children: `${e.scheduleSetup} ${n(l.setup)}` }),
1998
+ (l.teardown ?? 0) > 0 && /* @__PURE__ */ k("span", { children: `${e.scheduleTeardown} ${n(l.teardown)}` }),
1999
+ o.overlapping.map((p) => /* @__PURE__ */ k("span", { className: y.finding, children: e.scheduleOverlapWith(p.name ?? p.id) }, p.id)),
2000
+ o.lateTransports.map((p) => /* @__PURE__ */ k("span", { className: y.finding, children: e.scheduleLateBy(n(p.shortBy)) }, p.transport))
1682
2001
  ] });
1683
2002
  }
1684
- const { transport: i, task: r, from: a, to: u, late: c } = n;
1685
- return /* @__PURE__ */ Y(Wt, { children: [
1686
- /* @__PURE__ */ k("span", { className: v.tooltipHead, children: (r == null ? void 0 : r.name) ?? (r == null ? void 0 : r.id) ?? i.id }),
1687
- /* @__PURE__ */ k("span", { children: e.scheduleRoute((a == null ? void 0 : a.name) ?? i.from, (u == null ? void 0 : u.name) ?? i.to) }),
1688
- /* @__PURE__ */ k("span", { children: `${e.scheduleTransport} ${o(i.duration)}` }),
1689
- c !== void 0 && /* @__PURE__ */ k("span", { className: v.finding, children: e.scheduleLateBy(o(c.shortBy)) })
2003
+ const { transport: i, task: r, from: a, to: h, late: c } = o;
2004
+ return /* @__PURE__ */ Y(St, { children: [
2005
+ /* @__PURE__ */ k("span", { className: y.tooltipHead, children: (r == null ? void 0 : r.name) ?? (r == null ? void 0 : r.id) ?? i.id }),
2006
+ /* @__PURE__ */ k("span", { children: e.scheduleRoute((a == null ? void 0 : a.name) ?? i.from, (h == null ? void 0 : h.name) ?? i.to) }),
2007
+ /* @__PURE__ */ k("span", { children: `${e.scheduleTransport} ${n(i.duration)}` }),
2008
+ c !== void 0 && /* @__PURE__ */ k("span", { className: y.finding, children: e.scheduleLateBy(n(c.shortBy)) })
1690
2009
  ] });
1691
2010
  }
1692
- const Mn = [], ce = { min: Tt, max: 28 * st }, Tn = [], de = 20, En = Xe(function(t, e) {
2011
+ const Yn = [], Me = { min: Dt, max: 28 * ot }, Kn = [], Te = 20, Jn = Qe(function(t, e) {
2012
+ var se;
1693
2013
  const {
1694
2014
  ariaLabel: s,
1695
- initialDomain: o,
2015
+ initialDomain: n,
1696
2016
  height: i = 400,
1697
- laneHeight: r = lt,
2017
+ laneHeight: r = ht,
1698
2018
  headerWidth: a = 160,
1699
- calendar: u = Tn,
2019
+ calendar: h = Kn,
1700
2020
  zoomLimits: c,
1701
2021
  snap: l = "ticks",
1702
- intents: d = Mn,
2022
+ intents: d = Yn,
1703
2023
  onIntent: p,
1704
- canMoveTo: g,
1705
- onInteraction: b,
1706
- selectedTask: I,
2024
+ canMoveTo: w,
2025
+ onInteraction: v,
2026
+ selectedTask: A,
1707
2027
  onSelectedTaskChange: _,
1708
2028
  collapsedGroups: S,
1709
2029
  defaultCollapsedGroups: m,
1710
2030
  onCollapsedGroupsChange: C,
1711
2031
  onDomainChange: L,
1712
- placing: E,
2032
+ placing: D,
1713
2033
  route: F = "curve",
1714
- attach: R = "centre",
1715
- ends: V = "dot",
1716
- label: ot,
2034
+ attach: G = "centre",
2035
+ ends: J = "dot",
2036
+ label: it,
1717
2037
  tooltip: z,
1718
- now: Z,
1719
- className: Et,
1720
- style: Ee,
1721
- children: De
1722
- } = t, [w] = it(() => new qs()), Dt = Ke(), Pt = O(null), Nt = O(null), Gt = O(null), Rt = O(null), X = ge(), K = we(), [dt, ft] = o, $t = (c == null ? void 0 : c.min) ?? ce.min, Ot = (c == null ? void 0 : c.max) ?? ce.max, xt = O(null), Bt = typeof l == "object" ? l.step : null, Ht = typeof l == "object" ? l.offset : null, Yt = typeof l == "object" ? null : l, [Pe, Ne] = it(() => Date.now());
1723
- x(() => {
1724
- if (Z !== !0) return;
1725
- const h = setInterval(() => Ne(Date.now()), q);
1726
- return () => clearInterval(h);
1727
- }, [Z]);
1728
- const Xt = Z === !0 ? Pe : typeof Z == "number" ? Z : null;
1729
- vt(() => {
1730
- const h = `${dt}|${ft}`, y = xt.current !== h;
1731
- xt.current = h;
1732
- const A = Yt ?? { step: Bt ?? 0, offset: Ht ?? 0 };
1733
- w.setOptions(
1734
- { laneHeight: r, calendar: u, zoomLimits: { min: $t, max: Ot }, snap: A, intents: d, now: Xt, route: F, attach: R, ends: V },
1735
- y ? [dt, ft] : null
2038
+ now: Q,
2039
+ className: Ot,
2040
+ style: He,
2041
+ children: Ye
2042
+ } = t, [g] = rt(() => new fn()), pt = ts(), Ht = `${pt}-summary`, Yt = O(null), Kt = O(null), Ut = O(null), Xt = O(null), $ = Et(), x = ut(), [mt, gt] = n, Wt = (c == null ? void 0 : c.min) ?? Me.min, zt = (c == null ? void 0 : c.max) ?? Me.max, jt = O(null), qt = typeof l == "object" ? l.step : null, Vt = typeof l == "object" ? l.offset : null, Zt = typeof l == "object" ? null : l, [Ke, Ue] = rt(() => Date.now());
2043
+ H(() => {
2044
+ if (Q !== !0) return;
2045
+ const u = setInterval(() => Ue(Date.now()), X);
2046
+ return () => clearInterval(u);
2047
+ }, [Q]);
2048
+ const Jt = Q === !0 ? Ke : typeof Q == "number" ? Q : null;
2049
+ Tt(() => {
2050
+ const u = `${mt}|${gt}`, b = jt.current !== u;
2051
+ jt.current = u;
2052
+ const I = Zt ?? { step: qt ?? 0, offset: Vt ?? 0 };
2053
+ g.setOptions(
2054
+ { laneHeight: r, calendar: h, zoomLimits: { min: Wt, max: zt }, snap: I, intents: d, now: Jt, route: F, attach: G, ends: J },
2055
+ b ? [mt, gt] : null
1736
2056
  );
1737
- }, [w, dt, ft, r, u, $t, Ot, Yt, Bt, Ht, d, Xt, F, R, V]), x(() => {
1738
- w.setHandlers({ onIntent: p, canMoveTo: g, onInteraction: b, onSelectedTaskChange: _, onCollapsedGroupsChange: C, onDomainChange: L });
1739
- }, [w, p, g, b, _, C, L]);
1740
- const Ge = O(m);
1741
- x(() => {
1742
- const h = Ge.current;
1743
- h !== void 0 && w.setDefaultCollapsedGroups(h);
1744
- }, [w]), x(() => {
1745
- w.setCollapsedGroups(S);
1746
- }, [w, S]), Ue(
2057
+ }, [g, mt, gt, r, h, Wt, zt, Zt, qt, Vt, d, Jt, F, G, J]), H(() => {
2058
+ g.setHandlers({ onIntent: p, canMoveTo: w, onInteraction: v, onSelectedTaskChange: _, onCollapsedGroupsChange: C, onDomainChange: L });
2059
+ }, [g, p, w, v, _, C, L]);
2060
+ const Xe = O(m);
2061
+ H(() => {
2062
+ const u = Xe.current;
2063
+ u !== void 0 && g.setDefaultCollapsedGroups(u);
2064
+ }, [g]), H(() => {
2065
+ g.setCollapsedGroups(S);
2066
+ }, [g, S]), es(
1747
2067
  e,
1748
2068
  () => ({
1749
- positionAt: (h, y) => w.positionAt(h, y),
1750
- clientPointOf: (h, y) => w.clientPointOf(h, y),
1751
- visibleDomain: () => w.visibleDomain()
2069
+ positionAt: (u, b) => g.positionAt(u, b),
2070
+ clientPointOf: (u, b) => g.clientPointOf(u, b),
2071
+ visibleDomain: () => g.visibleDomain()
1752
2072
  }),
1753
- [w]
1754
- ), x(() => {
1755
- w.setControlledTask(I);
1756
- }, [w, I]), x(() => {
1757
- w.setPlacing(E ?? null);
1758
- }, [w, E]), x(() => {
1759
- const h = Pt.current, y = Nt.current, A = Gt.current, $ = Rt.current;
1760
- if (!h || !y || !A || !$) return;
1761
- w.bind(h, y, A, $);
1762
- const D = y.getBoundingClientRect();
1763
- w.resize(D.width, D.height);
1764
- const P = new ResizeObserver((G) => {
1765
- var zt;
1766
- const tt = (zt = G[G.length - 1]) == null ? void 0 : zt.contentRect;
1767
- tt !== void 0 && w.resize(tt.width, tt.height);
2073
+ [g]
2074
+ ), H(() => {
2075
+ g.setControlledTask(A);
2076
+ }, [g, A]), H(() => {
2077
+ g.setPlacing(D ?? null);
2078
+ }, [g, D]), H(() => {
2079
+ const u = Yt.current, b = Kt.current, I = Ut.current, B = Xt.current;
2080
+ if (!u || !b || !I || !B) return;
2081
+ g.bind(u, b, I, B);
2082
+ const E = b.getBoundingClientRect();
2083
+ g.resize(E.width, E.height);
2084
+ const P = new ResizeObserver((N) => {
2085
+ var ne;
2086
+ const st = (ne = N[N.length - 1]) == null ? void 0 : ne.contentRect;
2087
+ st !== void 0 && g.resize(st.width, st.height);
1768
2088
  });
1769
- P.observe(y);
1770
- const J = (G) => w.wheel(G);
1771
- h.addEventListener("wheel", J, { passive: !1 });
1772
- const Q = (G) => {
1773
- G.key === "Escape" && w.cancelEdit() && G.preventDefault();
2089
+ P.observe(b);
2090
+ const tt = (N) => g.wheel(N);
2091
+ u.addEventListener("wheel", tt, { passive: !1 });
2092
+ const et = (N) => {
2093
+ N.key === "Escape" && g.cancelEdit() && N.preventDefault();
1774
2094
  };
1775
- return window.addEventListener("keydown", Q), () => {
1776
- window.removeEventListener("keydown", Q), h.removeEventListener("wheel", J), P.disconnect(), w.unbind();
2095
+ return window.addEventListener("keydown", et), () => {
2096
+ window.removeEventListener("keydown", et), u.removeEventListener("wheel", tt), P.disconnect(), g.unbind();
1777
2097
  };
1778
- }, [w]);
1779
- const T = ze(w.subscribe, w.getSnapshot, w.getServerSnapshot), Re = (h, y) => {
1780
- const A = new Date(h);
1781
- return y >= 200 ? X.dateLong(A) : y >= 84 ? X.date(A) : y >= 44 ? X.dateShort(A) : "";
1782
- }, M = T.ghost, pt = (h) => `${Dt}-row-${encodeURIComponent(h.key)}`, $e = W(() => {
1783
- const h = /* @__PURE__ */ new Map();
1784
- for (const y of T.headers)
1785
- for (const A of y.within)
1786
- y.kind === "groupHead" && A === y.group || h.set(A, [...h.get(A) ?? [], pt(y)]);
1787
- return h;
1788
- }, [T.headers, Dt]), Oe = W(() => new Set((M == null ? void 0 : M.refusedLanes) ?? []), [M == null ? void 0 : M.refusedLanes]), Kt = O(null), [mt, xe] = it({ x: 0, y: 0, at: "" }), gt = M === null ? "" : `${M.x}:${M.y}:${M.from}:${M.to}:${M.overlap}:${M.late}`;
1789
- vt(() => {
1790
- const h = Kt.current;
1791
- if (M === null || h === null) return;
1792
- const y = 4, A = M.y - h.offsetHeight - y, $ = M.y + M.height + y, D = {
1793
- x: Math.max(2, Math.min(M.x, T.width - h.offsetWidth - 2)),
1794
- y: A >= 2 ? A : Math.min($, T.height - h.offsetHeight - 2),
1795
- at: gt
2098
+ }, [g]);
2099
+ const M = ss(g.subscribe, g.getSnapshot, g.getServerSnapshot), We = (u, b) => {
2100
+ const I = new Date(u);
2101
+ return b >= 200 ? $.dateLong(I) : b >= 84 ? $.date(I) : b >= 44 ? $.dateShort(I) : "";
2102
+ }, T = M.ghost, j = M.spoken, kt = M.summary, Qt = (u) => `${$.dateShort(new Date(u))} ${$.time(new Date(u), !1)}`, wt = (u) => `${pt}-row-${encodeURIComponent(u.key)}`, ze = q(() => {
2103
+ const u = /* @__PURE__ */ new Map();
2104
+ for (const b of M.headers)
2105
+ for (const I of b.within)
2106
+ b.kind === "groupHead" && I === b.group || u.set(I, [...u.get(I) ?? [], wt(b)]);
2107
+ return u;
2108
+ }, [M.headers, pt]), je = q(() => new Set((T == null ? void 0 : T.refusedLanes) ?? []), [T == null ? void 0 : T.refusedLanes]), te = O(null), [yt, qe] = rt({ x: 0, y: 0, at: "" }), vt = T === null ? "" : `${T.x}:${T.y}:${T.from}:${T.to}:${T.overlap}:${T.late}`;
2109
+ Tt(() => {
2110
+ const u = te.current;
2111
+ if (T === null || u === null) return;
2112
+ const b = 4, I = T.y - u.offsetHeight - b, B = T.y + T.height + b, E = {
2113
+ x: Math.max(2, Math.min(T.x, M.width - u.offsetWidth - 2)),
2114
+ y: I >= 2 ? I : Math.min(B, M.height - u.offsetHeight - 2),
2115
+ at: vt
1796
2116
  };
1797
- xe((P) => P.x === D.x && P.y === D.y && P.at === D.at ? P : D);
1798
- }, [M, gt, T.width, T.height]);
1799
- const Ut = O(null), [wt, Be] = it({ x: 0, y: 0, at: "" }), H = T.tooltip, kt = H === null ? "" : `${H.x}:${H.y}:${H.target.kind}`;
1800
- return vt(() => {
1801
- const h = Ut.current;
1802
- if (H === null || h === null) return;
1803
- const y = 12, A = (D, P, J) => {
1804
- const Q = D + y, G = D - y - P, tt = Q + P <= J - 4 || G < 4 ? Q : G;
1805
- return Math.max(4, Math.min(tt, J - P - 4));
1806
- }, $ = {
1807
- x: A(H.x, h.offsetWidth, T.width),
1808
- y: A(H.y, h.offsetHeight, T.height),
1809
- at: kt
2117
+ qe((P) => P.x === E.x && P.y === E.y && P.at === E.at ? P : E);
2118
+ }, [T, vt, M.width, M.height]);
2119
+ const ee = O(null), [bt, Ve] = rt({ x: 0, y: 0, at: "" }), U = M.tooltip, Mt = U === null ? "" : `${U.x}:${U.y}:${U.target.kind}`;
2120
+ return Tt(() => {
2121
+ const u = ee.current;
2122
+ if (U === null || u === null) return;
2123
+ const b = 12, I = (E, P, tt) => {
2124
+ const et = E + b, N = E - b - P, st = et + P <= tt - 4 || N < 4 ? et : N;
2125
+ return Math.max(4, Math.min(st, tt - P - 4));
2126
+ }, B = {
2127
+ x: I(U.x, u.offsetWidth, M.width),
2128
+ y: I(U.y, u.offsetHeight, M.height),
2129
+ at: Mt
1810
2130
  };
1811
- Be((D) => D.x === $.x && D.y === $.y && D.at === $.at ? D : $);
1812
- }, [H, kt, T.width, T.height]), /* @__PURE__ */ Y(ke.Provider, { value: w, children: [
2131
+ Ve((E) => E.x === B.x && E.y === B.y && E.at === B.at ? E : B);
2132
+ }, [U, Mt, M.width, M.height]), /* @__PURE__ */ Y(Ie.Provider, { value: g, children: [
1813
2133
  /* @__PURE__ */ Y(
1814
2134
  "div",
1815
2135
  {
1816
- ref: Pt,
2136
+ ref: Yt,
1817
2137
  role: "figure",
1818
2138
  "aria-label": s,
1819
- className: Et ? `${v.root} ${Et}` : v.root,
1820
- style: { height: `${i}px`, gridTemplateColumns: `min(${a}px, 40%) minmax(0, 1fr)`, ...Ee },
2139
+ className: Ot ? `${y.root} ${Ot}` : y.root,
2140
+ style: { height: `${i}px`, gridTemplateColumns: `min(${a}px, 40%) minmax(0, 1fr)`, ...He },
1821
2141
  children: [
1822
- /* @__PURE__ */ k("div", { className: v.corner }),
1823
- /* @__PURE__ */ k("div", { className: v.dayBand, "aria-hidden": "true", "data-schedule-days": "", "data-schedule-clip": "day band", children: T.days.map((h) => {
1824
- const y = Math.max(0, -h.x), A = Math.min(h.x + h.width, T.width) - Math.max(h.x, 0);
1825
- return /* @__PURE__ */ k("span", { className: v.day, style: { left: `${h.x}px`, width: `${h.width}px` }, children: /* @__PURE__ */ k("span", { className: v.dayLabel, "data-schedule-overlay": "day label", style: { marginLeft: `${y}px` }, children: Re(h.start, A) }) }, h.start);
2142
+ /* @__PURE__ */ k("div", { className: y.corner }),
2143
+ /* @__PURE__ */ k("div", { className: y.dayBand, "aria-hidden": "true", "data-schedule-days": "", "data-schedule-clip": "day band", children: M.days.map((u) => {
2144
+ const b = Math.max(0, -u.x), I = Math.min(u.x + u.width, M.width) - Math.max(u.x, 0);
2145
+ return /* @__PURE__ */ k("span", { className: y.day, style: { left: `${u.x}px`, width: `${u.width}px` }, children: /* @__PURE__ */ k("span", { className: y.dayLabel, "data-schedule-overlay": "day label", style: { marginLeft: `${b}px` }, children: We(u.start, I) }) }, u.start);
1826
2146
  }) }),
1827
- /* @__PURE__ */ k("div", { className: v.headers, "data-schedule-headers": "", children: /* @__PURE__ */ k("div", { className: v.headerRun, style: { transform: `translateY(${-T.scrollY}px)` }, children: T.headers.map((h) => /* @__PURE__ */ Y(
2147
+ /* @__PURE__ */ k("div", { className: y.headers, "data-schedule-headers": "", children: /* @__PURE__ */ k("div", { className: y.headerRun, style: { transform: `translateY(${-M.scrollY}px)` }, children: M.headers.map((u) => /* @__PURE__ */ Y(
1828
2148
  "div",
1829
2149
  {
1830
- id: pt(h),
1831
- className: v.header,
1832
- style: { height: `${h.height}px`, paddingLeft: `calc(var(--u-space-3) + ${h.depth} * var(--u-space-3))` },
1833
- "data-lane": h.lane,
1834
- "data-group": h.group,
1835
- "data-row": h.kind,
1836
- "data-schedule-clip": `header ${h.kind}`,
1837
- "data-refused": h.lane !== void 0 && Oe.has(h.lane) ? "" : void 0,
2150
+ id: wt(u),
2151
+ className: y.header,
2152
+ style: { height: `${u.height}px`, paddingLeft: `calc(var(--u-space-3) + ${u.depth} * var(--u-space-3))` },
2153
+ "data-lane": u.lane,
2154
+ "data-group": u.group,
2155
+ "data-row": u.kind,
2156
+ "data-schedule-clip": `header ${u.kind}`,
2157
+ "data-refused": u.lane !== void 0 && je.has(u.lane) ? "" : void 0,
1838
2158
  children: [
1839
- h.kind !== "lane" && h.group !== void 0 && /* @__PURE__ */ k(
2159
+ u.kind !== "lane" && u.group !== void 0 && /* @__PURE__ */ k(
1840
2160
  "button",
1841
2161
  {
1842
2162
  type: "button",
1843
- className: v.chevron,
2163
+ className: y.chevron,
1844
2164
  "data-schedule-overlay": "fold control",
1845
- "aria-expanded": h.collapsed === !1,
1846
- "aria-controls": ($e.get(h.group) ?? [pt(h)]).join(" "),
1847
- "aria-label": `${h.collapsed === !0 ? K.scheduleUnfoldGroup : K.scheduleFoldGroup}: ${typeof h.label == "string" ? h.label : h.group}`,
1848
- onClick: () => w.toggleGroup(h.group),
1849
- children: /* @__PURE__ */ k(Qe, { size: 9, "data-open": h.collapsed === !1 ? "" : void 0 })
2165
+ "aria-expanded": u.collapsed === !1,
2166
+ "aria-controls": (ze.get(u.group) ?? [wt(u)]).join(" "),
2167
+ "aria-label": `${u.collapsed === !0 ? x.scheduleUnfoldGroup : x.scheduleFoldGroup}: ${typeof u.label == "string" ? u.label : u.group}`,
2168
+ onClick: () => g.toggleGroup(u.group),
2169
+ children: /* @__PURE__ */ k(hs, { size: 9, "data-open": u.collapsed === !1 ? "" : void 0 })
1850
2170
  }
1851
2171
  ),
1852
- /* @__PURE__ */ k("span", { className: v.headerLabel, "data-schedule-overlay": "header label", children: h.label }),
1853
- h.kind !== "lane" && /* @__PURE__ */ k("span", { className: v.headerCount, "data-schedule-overlay": "lane count", "data-lane-count": h.lanes, children: K.scheduleLaneCount(h.lanes) })
2172
+ /* @__PURE__ */ k("span", { className: y.headerLabel, "data-schedule-overlay": "header label", children: u.label }),
2173
+ u.kind !== "lane" && /* @__PURE__ */ k("span", { className: y.headerCount, "data-schedule-overlay": "lane count", "data-lane-count": u.lanes, children: x.scheduleLaneCount(u.lanes) })
1854
2174
  ]
1855
2175
  },
1856
- h.key
2176
+ u.key
1857
2177
  )) }) }),
1858
2178
  /* @__PURE__ */ Y(
1859
2179
  "div",
1860
2180
  {
1861
- ref: Nt,
1862
- className: v.plot,
2181
+ ref: Kt,
2182
+ className: y.plot,
1863
2183
  "data-schedule-plot": "",
1864
2184
  "data-schedule-clip": "plot",
1865
- style: { cursor: T.cursor },
1866
- onPointerDown: (h) => w.pointerDown(h.nativeEvent),
1867
- onPointerMove: (h) => w.pointerMove(h.nativeEvent),
1868
- onPointerUp: (h) => w.pointerUp(h.nativeEvent),
1869
- onPointerCancel: (h) => w.pointerCancel(h.nativeEvent),
1870
- onPointerLeave: () => w.pointerLeave(),
1871
- onContextMenu: (h) => w.contextMenu(h.nativeEvent),
1872
- onDragOver: (h) => w.dragOver(h.nativeEvent),
1873
- onDrop: (h) => w.drop(h.nativeEvent),
1874
- onDragLeave: (h) => {
1875
- const y = h.nativeEvent.relatedTarget;
1876
- (!(y instanceof Node) || !h.currentTarget.contains(y)) && w.dragLeave();
2185
+ style: { cursor: M.cursor },
2186
+ tabIndex: 0,
2187
+ role: "application",
2188
+ "aria-roledescription": x.scheduleRoleDescription,
2189
+ "aria-label": s,
2190
+ "aria-describedby": Ht,
2191
+ onKeyDown: (u) => {
2192
+ g.key(u.nativeEvent) && u.preventDefault();
2193
+ },
2194
+ onFocus: (u) => g.focus(Un(u.currentTarget)),
2195
+ onBlur: () => g.blur(),
2196
+ onPointerDown: (u) => g.pointerDown(u.nativeEvent),
2197
+ onPointerMove: (u) => g.pointerMove(u.nativeEvent),
2198
+ onPointerUp: (u) => g.pointerUp(u.nativeEvent),
2199
+ onPointerCancel: (u) => g.pointerCancel(u.nativeEvent),
2200
+ onPointerLeave: () => g.pointerLeave(),
2201
+ onContextMenu: (u) => g.contextMenu(u.nativeEvent),
2202
+ onDragOver: (u) => g.dragOver(u.nativeEvent),
2203
+ onDrop: (u) => g.drop(u.nativeEvent),
2204
+ onDragLeave: (u) => {
2205
+ const b = u.nativeEvent.relatedTarget;
2206
+ (!(b instanceof Node) || !u.currentTarget.contains(b)) && g.dragLeave();
1877
2207
  },
1878
2208
  children: [
1879
- /* @__PURE__ */ k("canvas", { ref: Gt, className: v.layer, "aria-hidden": "true" }),
1880
- /* @__PURE__ */ k("canvas", { ref: Rt, className: v.layer, "aria-hidden": "true" }),
1881
- T.grips.map((h) => /* @__PURE__ */ k(
2209
+ /* @__PURE__ */ k("canvas", { ref: Ut, className: y.layer, "aria-hidden": "true" }),
2210
+ /* @__PURE__ */ k("canvas", { ref: Xt, className: y.layer, "aria-hidden": "true" }),
2211
+ M.grips.map((u) => /* @__PURE__ */ k(
1882
2212
  "span",
1883
2213
  {
1884
- "data-grip": h.kind,
1885
- "data-schedule-overlay": `${h.kind} grip`,
2214
+ "data-grip": u.kind,
2215
+ "data-schedule-overlay": `${u.kind} grip`,
1886
2216
  "aria-hidden": "true",
1887
- className: v.grip,
1888
- style: { left: `${h.x}px`, top: `${h.y}px`, height: `${h.height}px` }
2217
+ className: y.grip,
2218
+ style: { left: `${u.x}px`, top: `${u.y}px`, height: `${u.height}px` }
1889
2219
  },
1890
- h.kind
2220
+ u.kind
1891
2221
  )),
1892
- ot !== void 0 && T.bars.map((h) => /* @__PURE__ */ k(
2222
+ it !== void 0 && M.bars.map((u) => /* @__PURE__ */ k(
1893
2223
  "span",
1894
2224
  {
1895
- className: v.barLabel,
1896
- "data-bar-label": h.subtask.id,
2225
+ className: y.barLabel,
2226
+ "data-bar-label": u.subtask.id,
1897
2227
  "data-schedule-overlay": "bar label",
1898
2228
  "data-schedule-may-cover": "",
1899
- "data-on": h.dark ? "dark" : "light",
1900
- style: { left: `${h.x}px`, top: `${h.y}px`, width: `${h.width}px`, height: `${h.height}px` },
1901
- children: /* @__PURE__ */ k("span", { className: v.barLabelText, children: ot(h.subtask) })
2229
+ "data-on": u.dark ? "dark" : "light",
2230
+ style: { left: `${u.x}px`, top: `${u.y}px`, width: `${u.width}px`, height: `${u.height}px` },
2231
+ children: /* @__PURE__ */ k("span", { className: y.barLabelText, children: it(u.subtask) })
1902
2232
  },
1903
- h.subtask.id
2233
+ u.subtask.id
1904
2234
  )),
1905
- z !== !1 && T.tooltip !== null && /* @__PURE__ */ k(
2235
+ z !== !1 && M.tooltip !== null && /* @__PURE__ */ k(
1906
2236
  "span",
1907
2237
  {
1908
- ref: Ut,
2238
+ ref: ee,
1909
2239
  role: "tooltip",
1910
- className: v.tooltip,
2240
+ className: y.tooltip,
1911
2241
  "data-schedule-tooltip": "",
1912
2242
  "data-schedule-overlay": "tooltip",
1913
2243
  style: {
1914
- left: `${wt.x}px`,
1915
- top: `${wt.y}px`,
1916
- visibility: wt.at === kt ? void 0 : "hidden"
2244
+ left: `${bt.x}px`,
2245
+ top: `${bt.y}px`,
2246
+ visibility: bt.at === Mt ? void 0 : "hidden"
1917
2247
  },
1918
- children: typeof z == "function" ? z(T.tooltip.target) : /* @__PURE__ */ k(bn, { target: T.tooltip.target })
2248
+ children: typeof z == "function" ? z(M.tooltip.target) : /* @__PURE__ */ k(Hn, { target: M.tooltip.target })
1919
2249
  }
1920
2250
  ),
1921
- M !== null && /* @__PURE__ */ Y(
2251
+ T !== null && /* @__PURE__ */ Y(
1922
2252
  "span",
1923
2253
  {
1924
- ref: Kt,
1925
- className: v.ghostLabel,
2254
+ ref: te,
2255
+ className: y.ghostLabel,
1926
2256
  "data-ghost": "",
1927
2257
  "data-schedule-overlay": "ghost label",
1928
- "data-findings": [M.overlap ? "overlap" : "", M.late ? "late-transport" : ""].filter(Boolean).join(" "),
1929
- "data-refused": M.refused ? "" : void 0,
2258
+ "data-findings": [T.overlap ? "overlap" : "", T.late ? "late-transport" : ""].filter(Boolean).join(" "),
2259
+ "data-refused": T.refused ? "" : void 0,
1930
2260
  style: {
1931
- left: `${mt.x}px`,
1932
- top: `${mt.y}px`,
1933
- visibility: mt.at === gt ? void 0 : "hidden"
2261
+ left: `${yt.x}px`,
2262
+ top: `${yt.y}px`,
2263
+ visibility: yt.at === vt ? void 0 : "hidden"
1934
2264
  },
1935
2265
  children: [
1936
- K.scheduleGhostTimes(X.time(new Date(M.from), !1), X.time(new Date(M.to), !1)),
1937
- M.refused && /* @__PURE__ */ k("span", { className: v.refusal, children: K.scheduleLaneRefused }),
1938
- M.overlap && /* @__PURE__ */ k("span", { className: v.finding, children: K.scheduleOverlap }),
1939
- M.late && /* @__PURE__ */ k("span", { className: v.finding, children: K.scheduleLateTransport })
2266
+ x.scheduleGhostTimes($.time(new Date(T.from), !1), $.time(new Date(T.to), !1)),
2267
+ T.refused && /* @__PURE__ */ k("span", { className: y.refusal, children: x.scheduleLaneRefused }),
2268
+ T.overlap && /* @__PURE__ */ k("span", { className: y.finding, children: x.scheduleOverlap }),
2269
+ T.late && /* @__PURE__ */ k("span", { className: y.finding, children: x.scheduleLateTransport })
1940
2270
  ]
1941
2271
  }
1942
- )
2272
+ ),
2273
+ /* @__PURE__ */ k("span", { className: y.focusRing, "aria-hidden": "true" })
1943
2274
  ]
1944
2275
  }
1945
2276
  ),
1946
- /* @__PURE__ */ k("div", { className: v.corner }),
1947
- /* @__PURE__ */ Y("div", { className: v.tickBand, "aria-hidden": "true", "data-schedule-ticks": "", "data-schedule-clip": "time band", children: [
1948
- T.now !== null && /* @__PURE__ */ k("span", { className: v.now, "data-now": "", "data-schedule-overlay": "now mark", style: { left: `${T.now}px` } }),
1949
- T.ticks.map((h) => /* @__PURE__ */ k("span", { className: v.tick, style: { left: `${h.x}px` }, children: h.x >= de && h.x <= T.width - de && /* @__PURE__ */ k("span", { className: v.tickLabel, "data-schedule-overlay": "time label", children: T.step >= st ? X.dateShort(new Date(h.wallClock)) : X.time(new Date(h.wallClock), !1) }) }, h.wallClock))
1950
- ] })
2277
+ /* @__PURE__ */ k("div", { className: y.corner }),
2278
+ /* @__PURE__ */ Y("div", { className: y.tickBand, "aria-hidden": "true", "data-schedule-ticks": "", "data-schedule-clip": "time band", children: [
2279
+ M.now !== null && /* @__PURE__ */ k("span", { className: y.now, "data-now": "", "data-schedule-overlay": "now mark", style: { left: `${M.now}px` } }),
2280
+ M.ticks.map((u) => /* @__PURE__ */ k("span", { className: y.tick, style: { left: `${u.x}px` }, children: u.x >= Te && u.x <= M.width - Te && /* @__PURE__ */ k("span", { className: y.tickLabel, "data-schedule-overlay": "time label", children: M.step >= ot ? $.dateShort(new Date(u.wallClock)) : $.time(new Date(u.wallClock), !1) }) }, u.wallClock))
2281
+ ] }),
2282
+ /* @__PURE__ */ k(oe, { "aria-live": "polite", children: j !== null && /* @__PURE__ */ k(
2283
+ On,
2284
+ {
2285
+ target: j.target,
2286
+ lane: j.lane === null ? null : ((se = g.data.lanes.find((u) => u.id === j.lane)) == null ? void 0 : se.label) ?? j.lane
2287
+ },
2288
+ j.count
2289
+ ) }),
2290
+ /* @__PURE__ */ k(oe, { id: Ht, children: `${x.scheduleSummary({ ...kt, from: Qt(kt.from), to: Qt(kt.to) })} ${x.scheduleKeyHelp}` })
1951
2291
  ]
1952
2292
  }
1953
2293
  ),
1954
- De
2294
+ Ye
1955
2295
  ] });
1956
2296
  });
1957
- function Dn({ id: n, label: t }) {
1958
- const e = ye(), s = W(() => ({ id: n, label: t ?? n, ...e === null ? {} : { parent: e } }), [n, t, e]);
1959
- return es(s), null;
2297
+ function Un(o) {
2298
+ try {
2299
+ return o.matches(":focus-visible");
2300
+ } catch {
2301
+ return !0;
2302
+ }
2303
+ }
2304
+ function Qn({ id: o, label: t }) {
2305
+ const e = _e(), s = q(() => ({ id: o, label: t ?? o, ...e === null ? {} : { parent: e } }), [o, t, e]);
2306
+ return cs(s), null;
1960
2307
  }
1961
- function Pn({ id: n, label: t, children: e }) {
1962
- const s = ye(), o = W(() => ({ id: n, label: t ?? n, ...s === null ? {} : { parent: s } }), [n, t, s]);
1963
- return ss(o), /* @__PURE__ */ k(ve.Provider, { value: n, children: e });
2308
+ function to({ id: o, label: t, children: e }) {
2309
+ const s = _e(), n = q(() => ({ id: o, label: t ?? o, ...s === null ? {} : { parent: s } }), [o, t, s]);
2310
+ return ds(n), /* @__PURE__ */ k(Ae.Provider, { value: o, children: e });
1964
2311
  }
1965
- function Nn({ data: n, tasks: t }) {
1966
- const e = W(() => ({ kind: "subtasks", data: n, tasks: t }), [n, t]);
1967
- return be("Subtasks", e), null;
2312
+ function eo({ data: o, tasks: t }) {
2313
+ const e = q(() => ({ kind: "subtasks", data: o, tasks: t }), [o, t]);
2314
+ return Fe("Subtasks", e), null;
1968
2315
  }
1969
- function Gn({ data: n }) {
1970
- const t = W(() => ({ kind: "transports", data: n }), [n]);
1971
- return be("Transports", t), null;
2316
+ function so({ data: o }) {
2317
+ const t = q(() => ({ kind: "transports", data: o }), [o]);
2318
+ return Fe("Transports", t), null;
1972
2319
  }
1973
- function Rn(n, t, e) {
2320
+ function no(o, t, e) {
1974
2321
  if (e.kind === "place") return [];
1975
- const s = new Map(n.map((u) => [u.id, jt(u, e)])), o = /* @__PURE__ */ new Map();
1976
- for (const u of t) {
1977
- const c = o.get(u.from) ?? [];
1978
- c.push(u), o.set(u.from, c);
2322
+ const s = new Map(o.map((h) => [h.id, re(h, e)])), n = /* @__PURE__ */ new Map();
2323
+ for (const h of t) {
2324
+ const c = n.get(h.from) ?? [];
2325
+ c.push(h), n.set(h.from, c);
1979
2326
  }
1980
2327
  const i = /* @__PURE__ */ new Map(), r = [e.subtask];
1981
- let a = (n.length + 1) * (t.length + 1);
2328
+ let a = (o.length + 1) * (t.length + 1);
1982
2329
  for (; r.length > 0 && a-- > 0; ) {
1983
- const u = r.shift(), c = s.get(u);
2330
+ const h = r.shift(), c = s.get(h);
1984
2331
  if (c !== void 0)
1985
- for (const l of o.get(u) ?? []) {
2332
+ for (const l of n.get(h) ?? []) {
1986
2333
  if (l.to === e.subtask) continue;
1987
2334
  const d = s.get(l.to);
1988
2335
  if (d === void 0) continue;
1989
- const p = St(l, c) + l.duration - It(l, d);
2336
+ const p = xt(l, c) + l.duration - Nt(l, d);
1990
2337
  if (!(p > 0)) continue;
1991
- const g = { kind: "move", subtask: d.id, from: d.from + p, to: d.to + p };
1992
- s.set(d.id, jt(d, g)), i.set(d.id, g), r.push(d.id);
2338
+ const w = { kind: "move", subtask: d.id, from: d.from + p, to: d.to + p };
2339
+ s.set(d.id, re(d, w)), i.set(d.id, w), r.push(d.id);
1993
2340
  }
1994
2341
  }
1995
2342
  return [...i.values()];
1996
2343
  }
1997
- function $n(n, t, e) {
1998
- return e === 0 || !Number.isFinite(e) ? [] : n.filter((s) => s.task === t).map((s) => ({ kind: "move", subtask: s.id, from: s.from + e, to: s.to + e }));
2344
+ function oo(o, t, e) {
2345
+ return e === 0 || !Number.isFinite(e) ? [] : o.filter((s) => s.task === t).map((s) => ({ kind: "move", subtask: s.id, from: s.from + e, to: s.to + e }));
1999
2346
  }
2000
2347
  export {
2001
- Dn as Lane,
2002
- Pn as LaneGroup,
2003
- En as Schedule,
2004
- Nn as Subtasks,
2005
- Gn as Transports,
2006
- jt as applyIntent,
2007
- It as arrival,
2008
- St as departure,
2009
- Fn as findings,
2010
- _t as lateTransports,
2011
- ut as occupied,
2012
- At as overlaps,
2013
- ht as resolveAppearance,
2014
- Rn as ripple,
2015
- $n as shiftTask,
2016
- $s as snapTime,
2017
- _n as subtaskFromPlace
2348
+ Qn as Lane,
2349
+ to as LaneGroup,
2350
+ Jn as Schedule,
2351
+ eo as Subtasks,
2352
+ so as Transports,
2353
+ re as applyIntent,
2354
+ Nt as arrival,
2355
+ xt as departure,
2356
+ Zn as findings,
2357
+ $t as lateTransports,
2358
+ dt as occupied,
2359
+ Gt as overlaps,
2360
+ ct as resolveAppearance,
2361
+ no as ripple,
2362
+ oo as shiftTask,
2363
+ qs as snapTime,
2364
+ Vn as subtaskFromPlace
2018
2365
  };