@soffits/dsh-card-board 0.7.1 → 0.9.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/client.js CHANGED
@@ -1,4 +1,4 @@
1
- /* @soffits/dsh-card-board 0.7.1: built by scripts/build.mjs from src/client/. Do not edit. */
1
+ /* @soffits/dsh-card-board 0.9.0: built by scripts/build.mjs from src/client/. Do not edit. */
2
2
  window.__ModuleLoader__.load({
3
3
  id: "@soffits/dsh-card-board",
4
4
  factory: (require) => {
@@ -29,7 +29,7 @@ __export(index_exports, {
29
29
  inject: () => inject
30
30
  });
31
31
  module.exports = __toCommonJS(index_exports);
32
- var import_react9 = require("react");
32
+ var import_react12 = require("react");
33
33
 
34
34
  // src/client/look.js
35
35
  var STYLE_ID = "dsh-card-board-style";
@@ -41,7 +41,8 @@ var CSS = `
41
41
  .cb-heading h1{margin:0;font-size:20px;font-weight:500;line-height:28px}
42
42
  .cb-sub{margin-top:4px;color:var(--dsw-alias-label-tertiary);font-size:13px;line-height:20px}
43
43
  .cb-tabs{display:flex;flex-wrap:wrap;gap:6px 8px;margin:0 0 18px}
44
- .cb-grid{display:grid;gap:14px;grid-auto-flow:row dense;align-items:stretch}
44
+ .cb-grid{display:grid;row-gap:0;grid-auto-flow:row dense;align-items:start}
45
+ .cb-more{align-self:flex-start;margin-top:2px}
45
46
  .cb-card{container-type:inline-size;box-sizing:border-box;min-width:0;display:flex;flex-direction:column;gap:12px;padding:16px 18px 18px;border-radius:16px;background:var(--dsw-alias-bg-base);box-shadow:inset 0 0 0 .5px var(--dsw-alias-border-l2)}
46
47
  .cb-cardHead{display:flex;align-items:center;gap:10px;min-height:28px}
47
48
  .cb-cardHead h3{flex:1;min-width:0;margin:0;font-size:15px;font-weight:600;line-height:22px}
@@ -101,9 +102,12 @@ h3.cb-truncOpen{overflow:visible}
101
102
  .cb-strip li{display:flex;flex-direction:column;align-items:center;gap:3px;min-width:0;color:var(--dsw-alias-label-tertiary);font-size:11px;font-variant-numeric:tabular-nums}
102
103
  .cb-strip b{color:var(--dsw-alias-label-primary);font-size:13px;font-weight:500}
103
104
  .cb-strip li[data-on=true],.cb-strip li[data-on=true] b{color:var(--dsw-alias-state-business-primary)}
105
+ /* a narrow card shows the first hours that fit: 6 under 360 px, 8 under 480 px */
106
+ @container (width<480px){.cb-strip li:nth-child(n+9){display:none}}
107
+ @container (width<360px){.cb-strip li:nth-child(n+7){display:none}}
104
108
  /* a chart card with headline numbers: side by side when there is room */
105
109
  .cb-split{display:flex;flex-direction:column;gap:12px}
106
- @container (width>=640px){.cb-split{display:grid;grid-template-columns:minmax(0,max-content) minmax(0,1fr);align-items:center;gap:28px}.cb-split .cb-stats{display:grid;grid-template-columns:repeat(2,max-content);gap:14px 40px}}
110
+ @container (width>=640px){.cb-split{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);align-items:center;gap:28px}.cb-split .cb-stats{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px 24px}}
107
111
 
108
112
  /* rows of lists and status cards */
109
113
  .cb-list{display:flex;flex-direction:column;gap:10px}
@@ -123,8 +127,8 @@ h3.cb-truncOpen{overflow:visible}
123
127
  .cb-when{flex:none;color:var(--dsw-alias-label-tertiary);font-size:12px;font-variant-numeric:tabular-nums}
124
128
  .cb-rowActions{display:inline-flex;flex-wrap:wrap;justify-content:flex-end;min-width:0}
125
129
  .cb-rowSteps{flex-basis:100%;min-width:0;padding-left:41px}
126
- .cb-check{flex:none;display:inline-grid;place-items:center;width:18px;height:18px;border-radius:5px;color:#fff;box-shadow:inset 0 0 0 1.5px var(--dsw-alias-border-l4,var(--dsw-alias-border-l3))}
127
- .cb-check[data-checked=true]{background:var(--dsw-alias-state-success-primary);box-shadow:none}
130
+ .cb-doneBox{flex:none;display:inline-flex;align-items:center;min-width:28px;min-height:28px;justify-content:center}
131
+ .cb-visuallyHidden{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
128
132
  .cb-dotSlot{flex:none;display:inline-grid;place-items:center;width:28px}
129
133
  .cb-statusSpark{flex:0 1 90px;min-width:48px}
130
134
  .cb-statusValue{flex:none;color:var(--dsw-alias-label-secondary);font-variant-numeric:tabular-nums}
@@ -171,7 +175,7 @@ h3.cb-truncOpen{overflow:visible}
171
175
  .cb-row>.cb-statusValue{grid-column:3;grid-row:1}
172
176
  .cb-statusRow>.cb-rowActions{grid-row:2}
173
177
  .cb-row>.cb-rowSteps{grid-column:2/-1;padding-left:0}
174
- .cb-row>.cb-check+.uk-tile{display:none}
178
+ .cb-row>.cb-doneBox+.uk-tile{display:none}
175
179
  }
176
180
  @container (width<520px){
177
181
  .cb-track{grid-auto-flow:row;grid-auto-columns:auto;gap:10px}
@@ -189,6 +193,56 @@ h3.cb-truncOpen{overflow:visible}
189
193
  .cb-summaryText{font-size:16px;line-height:24px}
190
194
  .cb-statValue{font-size:24px;line-height:30px}
191
195
  }
196
+ /* Touch and pointer: cards and rows answer a hover and a press, in DSH's own interactive colours and motion. */
197
+ .cb-card{transition:box-shadow var(--ds-transition-duration,.2s) var(--ds-ease-in-out,ease),transform var(--ds-transition-duration,.2s) var(--ds-ease-in-out,ease)}
198
+ .cb-cardOpenable{cursor:pointer}
199
+ button.cb-cardOpen{border:0;background:transparent;padding:0;font:inherit;cursor:pointer}
200
+ @media (hover:hover) and (pointer:fine){.cb-cardOpen{opacity:0;transition:opacity var(--ds-transition-duration,.2s) var(--ds-ease-in-out,ease)}.cb-card:hover .cb-cardOpen,.cb-cardOpen:focus-visible{opacity:1}}
201
+ .cb-cardOpenable:active{transform:scale(.995)}
202
+ .cb-rowOpens{cursor:pointer}
203
+ .cb-row{transition:background-color var(--ds-transition-duration,.2s) var(--ds-ease-in-out,ease)}
204
+ .cb-rowOpens:active{background:var(--dsw-alias-interactive-bg-active,var(--dsw-alias-interactive-bg-hover))}
205
+ .cb-rowOpens:focus-visible,.cb-cardOpen:focus-visible{outline:2px solid var(--dsw-alias-state-business-primary);outline-offset:1px}
206
+ .cb-statLink{color:inherit;text-decoration:none;border-radius:10px;margin:-4px -6px;padding:4px 6px;transition:background-color var(--ds-transition-duration,.2s) var(--ds-ease-in-out,ease)}
207
+ .cb-statLink:active{background:var(--dsw-alias-interactive-bg-active,var(--dsw-alias-interactive-bg-hover))}
208
+ @media (hover:hover) and (pointer:fine){
209
+ .cb-cardOpenable:hover{box-shadow:inset 0 0 0 .5px var(--dsw-alias-border-l3),0 2px 10px color-mix(in srgb,var(--dsw-alias-label-primary) 6%,transparent)}
210
+ .cb-row:hover,.cb-statLink:hover{background:var(--dsw-alias-interactive-bg-hover)}
211
+ /* a row's buttons show on hover or focus; on touch they are always there */
212
+ .cb-row .cb-rowActions{opacity:0;transition:opacity var(--ds-transition-duration,.2s) var(--ds-ease-in-out,ease)}
213
+ .cb-row:hover .cb-rowActions,.cb-row:focus-within .cb-rowActions{opacity:1}
214
+ }
215
+ /* Motion: a changed card settles, rows that open in a list fade in, numbers ease (motion.js). */
216
+ @keyframes cb-settle{from{transform:translateY(3px);opacity:.55}to{transform:none;opacity:1}}
217
+ @keyframes cb-in{from{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:none}}
218
+ .cb-card.uk-wash .cb-cardBody,.cb-card.uk-wash .cb-stats{animation:cb-settle var(--ds-transition-duration,.2s) var(--ds-ease-in-out,ease) both}
219
+ .cb-rowLate{animation:cb-in var(--ds-transition-duration,.2s) var(--ds-ease-in-out,ease) both}
220
+ @media (prefers-reduced-motion:reduce){.cb-card,.cb-row,.cb-statLink{transition:none}.cb-card.uk-wash .cb-cardBody,.cb-card.uk-wash .cb-stats,.cb-rowLate{animation:none}.cb-cardOpenable:active{transform:none}}
221
+ /* What is chrome is not selectable (heads, tags, axes, legends, strips, buttons, times); titles, notes and numbers are. */
222
+ .cb-cardHead,.cb-tabs,.cb-heading .cb-sub,.cb-rowMeta,.cb-rowActions,.cb-statLabel,.cb-strip,.cb-chart svg,.cb-legend,.cb-track b,.cb-more,.cb-doneBox,.cb-delta,.cb-when,.cb-progress small,.cb-bubble{-webkit-user-select:none;user-select:none}
223
+ .cb-cardHead h3{-webkit-user-select:text;user-select:text}
224
+ .cb-card svg,.cb-card img{-webkit-user-drag:none}
225
+ /* The point under the pointer on a chart */
226
+ .cb-chart{position:relative}
227
+ .cb-plot{touch-action:pan-y}
228
+ .cb-hoverRule{stroke:var(--dsw-alias-border-l3);stroke-width:1}
229
+ .cb-bubble{position:absolute;top:4px;z-index:1;pointer-events:none;padding:5px 8px;border-radius:8px;background:var(--dsw-alias-bg-base);box-shadow:0 2px 10px color-mix(in srgb,var(--dsw-alias-label-primary) 14%,transparent),inset 0 0 0 .5px var(--dsw-alias-border-l2);color:var(--dsw-alias-label-primary);font-size:12px;line-height:17px;white-space:nowrap;font-variant-numeric:tabular-nums}
230
+ .cb-bubbleHead{color:var(--dsw-alias-label-tertiary)}
231
+ /* The opened card */
232
+ .cb-sheetModal.cb-sheetModal{width:min(720px,calc(100vw - 32px));max-width:none}
233
+ .cb-sheet{min-width:0}
234
+ .cb-cardInSheet{padding:0;box-shadow:none;background:transparent;border-radius:0}
235
+ .cb-detail{display:flex;flex-direction:column;gap:14px;margin-top:4px}
236
+ .cb-detailText{margin:0;color:var(--dsw-alias-label-secondary);font-size:14px;line-height:21px;white-space:pre-wrap}
237
+ .cb-facts{display:grid;grid-template-columns:max-content minmax(0,1fr);gap:6px 18px;margin:0;font-size:13px;line-height:19px}
238
+ .cb-facts dt{color:var(--dsw-alias-label-tertiary);-webkit-user-select:none;user-select:none}
239
+ .cb-facts dd{margin:0;color:var(--dsw-alias-label-primary);overflow-wrap:anywhere}
240
+ .cb-detailHistory h4{margin:0 0 6px;font-size:12px;font-weight:500;color:var(--dsw-alias-label-tertiary);-webkit-user-select:none;user-select:none}
241
+ .cb-sheetChat{display:flex;justify-content:flex-end}
242
+ .cb-rowSheet{display:flex;flex-direction:column;gap:12px}
243
+ /* the opened view shows every word: nothing is cut to a line or two */
244
+ .cb-sheet .cb-trunc{white-space:normal;display:block;-webkit-line-clamp:unset;overflow:visible;text-overflow:clip}
245
+ @media (width<=640px){.cb-sheetModal.cb-sheetModal{width:calc(100vw - 16px)}}
192
246
  @media (width<=768px),(pointer:coarse){
193
247
  .cb-cardLink{width:40px;height:40px;margin:-9px 0}
194
248
  .cb-cardChat{margin:-9px -10px -9px 0}
@@ -196,19 +250,18 @@ h3.cb-truncOpen{overflow:visible}
196
250
  `;
197
251
 
198
252
  // src/client/page.js
199
- var import_react8 = require("react");
253
+ var import_react11 = require("react");
200
254
  var import_dsh_client_ui_primitives4 = require("@deepseek-ai/dsh-client-ui-primitives");
201
255
 
202
256
  // src/client/card.js
203
- var import_react7 = require("react");
204
- var import_dsh_client_ui_primitives3 = require("@deepseek-ai/dsh-client-ui-primitives");
257
+ var import_react9 = require("react");
258
+ var import_dsh_client_ui_primitives2 = require("@deepseek-ai/dsh-client-ui-primitives");
205
259
 
206
260
  // src/client/charts.js
207
261
  var import_react4 = require("react");
208
262
 
209
263
  // src/client/pieces.js
210
264
  var import_react = require("react");
211
- var import_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
212
265
  function Trunc({ text, as = "div", className = "", lines = 1 }) {
213
266
  const [open, setOpen] = (0, import_react.useState)(false);
214
267
  return (0, import_react.createElement)(as, {
@@ -217,13 +270,6 @@ function Trunc({ text, as = "div", className = "", lines = 1 }) {
217
270
  onClick: () => setOpen((value) => !value)
218
271
  }, text);
219
272
  }
220
- function CheckBox({ checked, label }) {
221
- return (0, import_react.createElement)(
222
- "span",
223
- { className: "cb-check", "data-checked": checked ? "true" : "false", role: "img", "aria-label": label },
224
- checked && (0, import_react.createElement)(import_dsh_client_ui_primitives.IconCheckOutlineMedium, { size: 12 })
225
- );
226
- }
227
273
 
228
274
  // src/client/format.js
229
275
  var import_react2 = require("react");
@@ -323,6 +369,28 @@ var useButtons = () => (0, import_react3.useSyncExternalStore)(buttonsStore.subs
323
369
  // src/client/charts.js
324
370
  var PALETTE = ["accent", "ok", "warn", "violet", "bad", "muted"];
325
371
  var toneColor = (tone, index = 0) => kitStore.get().toneColor(tone ?? PALETTE[index % PALETTE.length]);
372
+ function usePointer(pick) {
373
+ const [at, setAt] = (0, import_react4.useState)(null);
374
+ const fromEvent = (event) => {
375
+ const box = event.currentTarget.getBoundingClientRect();
376
+ return pick(event.clientX - box.left);
377
+ };
378
+ return [at, {
379
+ onPointerMove: (event) => setAt(fromEvent(event)),
380
+ onPointerDown: (event) => setAt(fromEvent(event)),
381
+ onPointerLeave: (event) => {
382
+ if (event.pointerType === "mouse") setAt(null);
383
+ }
384
+ }, () => setAt(null)];
385
+ }
386
+ function Bubble({ x, width, lines }) {
387
+ const flip = x > width * 0.6;
388
+ return (0, import_react4.createElement)(
389
+ "div",
390
+ { className: "cb-bubble", role: "status", style: flip ? { right: Math.max(0, width - x + 10) } : { left: x + 10 } },
391
+ lines.map((line, i) => (0, import_react4.createElement)("div", { key: i, className: i === 0 ? "cb-bubbleHead" : void 0 }, line))
392
+ );
393
+ }
326
394
  function Legend({ items, locale }) {
327
395
  return (0, import_react4.createElement)("ul", { className: "cb-legend" }, items.map((item, i) => (0, import_react4.createElement)(
328
396
  "li",
@@ -398,9 +466,20 @@ function LineChart({ data, locale, height }) {
398
466
  return d;
399
467
  };
400
468
  const gradientId = (0, import_react4.useMemo)(() => `cb-g-${Math.random().toString(36).slice(2, 9)}`, []);
401
- return (0, import_react4.createElement)("div", { ref, className: "cb-chart", style: { height } }, width > 0 && (0, import_react4.createElement)(
469
+ const xsAll = (0, import_react4.useMemo)(() => [...new Set(data.series.flatMap((s) => s.points.filter((p) => typeof p.y === "number").map((p) => p.x)))], [data]);
470
+ const [hover, pointer] = usePointer((px) => {
471
+ let best = null;
472
+ for (const x of xsAll) if (best === null || Math.abs(sx(x) - px) < Math.abs(sx(best) - px)) best = x;
473
+ return best;
474
+ });
475
+ const hoverX = hover === null ? null : sx(hover);
476
+ const hoverLines = hover === null ? [] : [model.timeAxis ? formatDay(toTime(hover), locale, 0) : xLabel(hover), ...data.series.flatMap((s) => {
477
+ const p = s.points.find((q) => q.x === hover && typeof q.y === "number");
478
+ return p ? [`${s.name ? `${s.name}: ` : ""}${formatNumber(p.y, locale)}${data.unit ? ` ${data.unit}` : ""}`] : [];
479
+ })];
480
+ return (0, import_react4.createElement)("div", { ref, className: "cb-chart", style: { height } }, width > 0 && hover !== null && (0, import_react4.createElement)(Bubble, { x: hoverX, width, lines: hoverLines }), width > 0 && (0, import_react4.createElement)(
402
481
  "svg",
403
- { width, height, role: "img" },
482
+ { width, height, role: "img", className: "cb-plot", ...pointer },
404
483
  (0, import_react4.createElement)("defs", null, data.series.map((s, i) => (0, import_react4.createElement)(
405
484
  "linearGradient",
406
485
  { key: i, id: `${gradientId}-${i}`, x1: 0, y1: 0, x2: 0, y2: 1 },
@@ -445,7 +524,16 @@ function LineChart({ data, locale, height }) {
445
524
  )),
446
525
  valid.length > 16 && last && (0, import_react4.createElement)("circle", { cx: sx(last.x), cy: sy(last.y), r: 3, fill: color })
447
526
  );
448
- })
527
+ }),
528
+ hover !== null && (0, import_react4.createElement)(
529
+ "g",
530
+ { className: "cb-hover" },
531
+ (0, import_react4.createElement)("line", { x1: hoverX, x2: hoverX, y1: top, y2: top + plotH, className: "cb-hoverRule" }),
532
+ data.series.map((s, i) => {
533
+ const p = s.points.find((q) => q.x === hover && typeof q.y === "number");
534
+ return p && (0, import_react4.createElement)("circle", { key: i, cx: hoverX, cy: sy(p.y), r: 4, fill: toneColor(s.tone, i), stroke: "var(--dsw-alias-bg-base)", strokeWidth: 2 });
535
+ })
536
+ )
449
537
  ));
450
538
  }
451
539
  function BarChart({ data, locale, height }) {
@@ -472,51 +560,58 @@ function BarChart({ data, locale, height }) {
472
560
  const time = toTime(x);
473
561
  return Number.isFinite(time) ? formatDay(time, locale, 0) : String(x);
474
562
  };
563
+ const [hover, pointer] = usePointer((px) => Math.max(0, Math.min(data.bars.length - 1, Math.floor(px / slot))));
564
+ const tipOf = (bar) => multi ? [label(bar.x), ...keys.filter((k) => bar.values?.[k] !== void 0).map((k) => `${k}: ${formatNumber(bar.values[k], locale)}${data.unit ? ` ${data.unit}` : ""}`)] : [label(bar.x), `${formatNumber(bar.value, locale)}${data.unit ? ` ${data.unit}` : ""}`];
475
565
  return (0, import_react4.createElement)(
476
566
  "div",
477
567
  null,
478
- (0, import_react4.createElement)("div", { ref, className: "cb-chart", style: { height } }, width > 0 && (0, import_react4.createElement)(
479
- "svg",
480
- { width, height, role: "img" },
481
- (0, import_react4.createElement)("line", { x1: 0, x2: width, y1: top + plotH + 0.5, y2: top + plotH + 0.5, className: "cb-rule" }),
482
- data.goal && (0, import_react4.createElement)("line", { x1: 0, x2: width, y1: sy(data.goal.y), y2: sy(data.goal.y), className: "cb-goal" }),
483
- data.goal?.label && (0, import_react4.createElement)("text", { x: width, y: sy(data.goal.y) - 4, className: "cb-goalLabel", textAnchor: "end" }, (0, import_react4.createElement)("title", null, data.goal.label), fit(data.goal.label, width)),
484
- data.bars.map((bar, i) => {
485
- const cx = slot * i + slot / 2;
486
- const tip = multi ? `${label(bar.x)}: ${keys.filter((k) => bar.values?.[k] !== void 0).map((k) => `${k} ${formatNumber(bar.values[k], locale)}`).join(", ")}` : `${label(bar.x)}: ${formatNumber(bar.value, locale)}${data.unit ? ` ${data.unit}` : ""}`;
487
- let parts;
488
- if (!multi) parts = [{ y0: 0, y1: Math.max(0, bar.value), color: toneColor(void 0, 1), x: cx - barW / 2, w: barW }];
489
- else if (stacked) {
490
- let base = 0;
491
- parts = keys.map((key, k) => {
492
- const v = Math.max(0, bar.values?.[key] ?? 0);
493
- const part2 = { y0: base, y1: base + v, color: toneColor(void 0, k), x: cx - barW / 2, w: barW };
494
- base += v;
495
- return part2;
496
- });
497
- } else {
498
- const each = barW / keys.length;
499
- parts = keys.map((key, k) => ({ y0: 0, y1: Math.max(0, bar.values?.[key] ?? 0), color: toneColor(void 0, k), x: cx - barW / 2 + k * each, w: Math.max(1, each - 1) }));
500
- }
501
- return (0, import_react4.createElement)(
502
- "g",
503
- { key: i },
504
- (0, import_react4.createElement)("title", null, tip),
505
- parts.filter((p) => p.y1 > p.y0).map((p, k) => (0, import_react4.createElement)("rect", {
506
- key: k,
507
- x: p.x,
508
- width: p.w,
509
- y: sy(p.y1),
510
- height: Math.max(0.5, sy(p.y0) - sy(p.y1)),
511
- rx: Math.min(4, p.w / 3),
512
- fill: p.color,
513
- fillOpacity: multi ? 0.85 : 0.55
514
- })),
515
- showValues && (0, import_react4.createElement)("text", { x: cx, y: sy(peaks[i]) - 4, className: "cb-barValue", textAnchor: "middle" }, formatNumber(multi && !stacked ? peaks[i] : totals[i], locale, 1)),
516
- i % labelEvery === 0 && (0, import_react4.createElement)("text", { x: Math.min(Math.max(cx, textWidth(label(bar.x)) / 2), width - textWidth(label(bar.x)) / 2), y: height - 4, className: "cb-axis", textAnchor: "middle" }, label(bar.x))
517
- );
518
- })
519
- )),
568
+ (0, import_react4.createElement)(
569
+ "div",
570
+ { ref, className: "cb-chart", style: { height } },
571
+ width > 0 && hover !== null && data.bars[hover] && (0, import_react4.createElement)(Bubble, { x: slot * hover + slot / 2, width, lines: tipOf(data.bars[hover]) }),
572
+ width > 0 && (0, import_react4.createElement)(
573
+ "svg",
574
+ { width, height, role: "img", className: "cb-plot", ...pointer },
575
+ (0, import_react4.createElement)("line", { x1: 0, x2: width, y1: top + plotH + 0.5, y2: top + plotH + 0.5, className: "cb-rule" }),
576
+ data.goal && (0, import_react4.createElement)("line", { x1: 0, x2: width, y1: sy(data.goal.y), y2: sy(data.goal.y), className: "cb-goal" }),
577
+ data.goal?.label && (0, import_react4.createElement)("text", { x: width, y: sy(data.goal.y) - 4, className: "cb-goalLabel", textAnchor: "end" }, (0, import_react4.createElement)("title", null, data.goal.label), fit(data.goal.label, width)),
578
+ data.bars.map((bar, i) => {
579
+ const cx = slot * i + slot / 2;
580
+ const tip = multi ? `${label(bar.x)}: ${keys.filter((k) => bar.values?.[k] !== void 0).map((k) => `${k} ${formatNumber(bar.values[k], locale)}`).join(", ")}` : `${label(bar.x)}: ${formatNumber(bar.value, locale)}${data.unit ? ` ${data.unit}` : ""}`;
581
+ let parts;
582
+ if (!multi) parts = [{ y0: 0, y1: Math.max(0, bar.value), color: toneColor(void 0, 1), x: cx - barW / 2, w: barW }];
583
+ else if (stacked) {
584
+ let base = 0;
585
+ parts = keys.map((key, k) => {
586
+ const v = Math.max(0, bar.values?.[key] ?? 0);
587
+ const part2 = { y0: base, y1: base + v, color: toneColor(void 0, k), x: cx - barW / 2, w: barW };
588
+ base += v;
589
+ return part2;
590
+ });
591
+ } else {
592
+ const each = barW / keys.length;
593
+ parts = keys.map((key, k) => ({ y0: 0, y1: Math.max(0, bar.values?.[key] ?? 0), color: toneColor(void 0, k), x: cx - barW / 2 + k * each, w: Math.max(1, each - 1) }));
594
+ }
595
+ return (0, import_react4.createElement)(
596
+ "g",
597
+ { key: i },
598
+ (0, import_react4.createElement)("title", null, tip),
599
+ parts.filter((p) => p.y1 > p.y0).map((p, k) => (0, import_react4.createElement)("rect", {
600
+ key: k,
601
+ x: p.x,
602
+ width: p.w,
603
+ y: sy(p.y1),
604
+ height: Math.max(0.5, sy(p.y0) - sy(p.y1)),
605
+ rx: Math.min(4, p.w / 3),
606
+ fill: p.color,
607
+ fillOpacity: hover === i ? 1 : multi ? 0.85 : 0.55
608
+ })),
609
+ showValues && (0, import_react4.createElement)("text", { x: cx, y: sy(peaks[i]) - 4, className: "cb-barValue", textAnchor: "middle" }, formatNumber(multi && !stacked ? peaks[i] : totals[i], locale, 1)),
610
+ i % labelEvery === 0 && (0, import_react4.createElement)("text", { x: Math.min(Math.max(cx, textWidth(label(bar.x)) / 2), width - textWidth(label(bar.x)) / 2), y: height - 4, className: "cb-axis", textAnchor: "middle" }, label(bar.x))
611
+ );
612
+ })
613
+ )
614
+ ),
520
615
  multi && (0, import_react4.createElement)(Legend, { items: keys.map((key, k) => ({ label: key, color: toneColor(void 0, k) })), locale })
521
616
  );
522
617
  }
@@ -650,8 +745,50 @@ function Timeline({ data, locale }) {
650
745
  }
651
746
 
652
747
  // src/client/cards.js
748
+ var import_react6 = require("react");
749
+ var import_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
750
+
751
+ // src/client/motion.js
653
752
  var import_react5 = require("react");
654
- var import_dsh_client_ui_primitives2 = require("@deepseek-ai/dsh-client-ui-primitives");
753
+ var reduced = () => typeof matchMedia === "function" && matchMedia("(prefers-reduced-motion: reduce)").matches;
754
+ function useEased(value, ms = 500) {
755
+ const [shown, setShown] = (0, import_react5.useState)(value);
756
+ const from = (0, import_react5.useRef)(value);
757
+ (0, import_react5.useEffect)(() => {
758
+ const start = from.current;
759
+ from.current = value;
760
+ if (typeof value !== "number" || typeof start !== "number" || start === value || reduced() || typeof requestAnimationFrame !== "function") {
761
+ setShown(value);
762
+ return void 0;
763
+ }
764
+ const begin = performance.now();
765
+ let frame = 0;
766
+ const step = (now) => {
767
+ const k = Math.min(1, (now - begin) / ms);
768
+ const eased = 1 - (1 - k) ** 3;
769
+ setShown(k >= 1 ? value : start + (value - start) * eased);
770
+ if (k < 1) frame = requestAnimationFrame(step);
771
+ };
772
+ frame = requestAnimationFrame(step);
773
+ return () => cancelAnimationFrame(frame);
774
+ }, [value, ms]);
775
+ return shown;
776
+ }
777
+
778
+ // src/client/links.js
779
+ function openLink(link) {
780
+ if (/^https?:/i.test(link)) {
781
+ window.open(link, "_blank", "noopener,noreferrer");
782
+ return;
783
+ }
784
+ const url = new URL(link, window.location.origin);
785
+ if (url.origin !== window.location.origin) return;
786
+ window.history.pushState(null, "", url.pathname + url.search + url.hash);
787
+ window.dispatchEvent(new PopStateEvent("popstate"));
788
+ }
789
+ function onControl(event) {
790
+ return Boolean(event.target?.closest?.("button,a,input,select,textarea,label,[role=button],[role=checkbox],[role=menuitem]"));
791
+ }
655
792
 
656
793
  // src/client/steps.js
657
794
  function ownOffset(at) {
@@ -690,134 +827,213 @@ function stepTimes(steps, locale, here = Intl.DateTimeFormat().resolvedOptions()
690
827
  });
691
828
  }
692
829
 
830
+ // src/client/layout.js
831
+ var DEFAULT_SIZE = { summary: "wide", countdown: "large", timeline: "wide", stat: "small" };
832
+ var SPAN = { 6: { small: 2, medium: 3, large: 4, wide: 6 }, 2: { small: 1, medium: 1, large: 2, wide: 2 }, 1: {} };
833
+ var ROW = 4;
834
+ var GAP = 14;
835
+ function spanOf(type, size, tracks) {
836
+ const chosen = type === "summary" ? "wide" : size ?? DEFAULT_SIZE[type] ?? "medium";
837
+ return SPAN[tracks]?.[chosen] ?? 1;
838
+ }
839
+ var LIST_ROWS = 6;
840
+ function shownRows(rows, open, limit, live) {
841
+ if (open || rows.length <= limit + 1) return rows;
842
+ return rows.filter((row, i) => i < limit || row.key !== void 0 && (live?.freshRows?.has(row.key) || live?.rows?.[row.key] > 0));
843
+ }
844
+
693
845
  // src/client/cards.js
694
846
  var STATE_OF_TONE = { ok: "done", warn: "warning", bad: "error" };
695
847
  var DIRECTION_ICON = { up: "trending-up", down: "trending-down" };
848
+ function EasedNumber({ value, locale }) {
849
+ const shown = useEased(value);
850
+ if (typeof value !== "number") return formatNumber(value, locale);
851
+ const decimals = Math.min(3, (String(value).split(".")[1] ?? "").length);
852
+ return formatNumber(shown === value ? value : Number(shown.toFixed(decimals)), locale);
853
+ }
696
854
  function StatBlock({ data, locale, compact, wash }) {
697
855
  const kit = useKit();
698
- return (0, import_react5.createElement)("div", { className: `cb-stats${compact ? " cb-statsCompact" : ""}` }, data.items.map((item, i) => (0, import_react5.createElement)(
699
- "div",
700
- { key: i, className: `cb-stat${item.strip ? " cb-statWide" : ""}` },
701
- (0, import_react5.createElement)("div", { className: "cb-statLabel" }, (0, import_react5.createElement)(Trunc, { as: "span", text: item.label }), i === 0 && wash && (0, import_react5.createElement)(kit.JustNow)),
702
- (0, import_react5.createElement)(
856
+ return (0, import_react6.createElement)("div", { className: `cb-stats${compact ? " cb-statsCompact" : ""}` }, data.items.map((item, i) => (0, import_react6.createElement)(
857
+ item.link ? "a" : "div",
858
+ { key: i, className: `cb-stat${item.strip ? " cb-statWide" : ""}${item.link ? " cb-statLink" : ""}`, ...item.link ? linkProps(item.link) : {} },
859
+ (0, import_react6.createElement)("div", { className: "cb-statLabel" }, (0, import_react6.createElement)(Trunc, { as: "span", text: item.label }), i === 0 && wash && (0, import_react6.createElement)(kit.JustNow)),
860
+ (0, import_react6.createElement)(
703
861
  "div",
704
862
  { className: "cb-statValue", style: item.tone ? { color: kit.toneColor(item.tone) } : void 0 },
705
- (0, import_react5.createElement)("span", null, formatNumber(item.value, locale)),
706
- item.unit && (0, import_react5.createElement)("small", null, item.unit)
863
+ (0, import_react6.createElement)("span", null, (0, import_react6.createElement)(EasedNumber, { value: item.value, locale })),
864
+ item.unit && (0, import_react6.createElement)("small", null, item.unit)
707
865
  ),
708
- item.delta && (0, import_react5.createElement)(
866
+ item.delta && (0, import_react6.createElement)(
709
867
  "div",
710
868
  { className: "cb-delta", style: { color: kit.toneColor(item.delta.tone ?? "muted") } },
711
- DIRECTION_ICON[item.delta.dir] && (0, import_react5.createElement)(kit.Icon, { name: DIRECTION_ICON[item.delta.dir], size: 13 }),
712
- (0, import_react5.createElement)("span", null, item.delta.text)
869
+ DIRECTION_ICON[item.delta.dir] && (0, import_react6.createElement)(kit.Icon, { name: DIRECTION_ICON[item.delta.dir], size: 13 }),
870
+ (0, import_react6.createElement)("span", null, item.delta.text)
713
871
  ),
714
- item.progress && (0, import_react5.createElement)(
872
+ item.progress && (0, import_react6.createElement)(
715
873
  "div",
716
874
  { className: "cb-statProgress" },
717
- (0, import_react5.createElement)(kit.Progress, { value: item.progress.value, max: item.progress.max, tone: item.tone ?? (item.progress.value > item.progress.max ? "warn" : "ok") }),
718
- item.progress.text && (0, import_react5.createElement)("div", { className: "cb-statSub" }, item.progress.text)
875
+ (0, import_react6.createElement)(kit.Progress, { value: item.progress.value, max: item.progress.max, tone: item.tone ?? (item.progress.value > item.progress.max ? "warn" : "ok") }),
876
+ item.progress.text && (0, import_react6.createElement)("div", { className: "cb-statSub" }, item.progress.text)
719
877
  ),
720
- item.spark && (0, import_react5.createElement)(kit.Spark, { values: item.spark, tone: item.tone ?? "accent", height: 28, area: true }),
721
- item.sub && (0, import_react5.createElement)(Trunc, { className: "cb-statSub", lines: 2, text: item.sub }),
722
- item.strip && (0, import_react5.createElement)("ol", { className: "cb-strip" }, item.strip.map((cell, j) => (0, import_react5.createElement)(
878
+ item.spark && (0, import_react6.createElement)(kit.Spark, { values: item.spark, tone: item.tone ?? "accent", height: 28, area: true }),
879
+ item.sub && (0, import_react6.createElement)(Trunc, { className: "cb-statSub", lines: 2, text: item.sub }),
880
+ item.strip && (0, import_react6.createElement)("ol", { className: "cb-strip" }, item.strip.map((cell, j) => (0, import_react6.createElement)(
723
881
  "li",
724
882
  { key: j, "data-on": cell.on ? "true" : void 0 },
725
- (0, import_react5.createElement)("b", null, formatNumber(cell.value, locale, 1)),
726
- cell.icon && (0, import_react5.createElement)(kit.Icon, { name: cell.icon, size: 14 }),
727
- (0, import_react5.createElement)("span", null, cell.label)
883
+ (0, import_react6.createElement)("b", null, formatNumber(cell.value, locale, 1)),
884
+ cell.icon && (0, import_react6.createElement)(kit.Icon, { name: cell.icon, size: 14 }),
885
+ (0, import_react6.createElement)("span", null, cell.label)
728
886
  )))
729
887
  )));
730
888
  }
889
+ function linkProps(link) {
890
+ const external = /^https?:/i.test(link);
891
+ return { href: link, ...external ? { target: "_blank", rel: "noopener noreferrer" } : { onClick: (event) => {
892
+ event.preventDefault();
893
+ openLink(link);
894
+ } } };
895
+ }
731
896
  function RowWhen({ row, locale, t }) {
732
897
  const kit = useKit();
733
898
  const now = kit.useNow();
734
899
  if (row.active) {
735
- if (isActive(row.active, now)) return (0, import_react5.createElement)(import_dsh_client_ui_primitives2.Tag, { tone: "info" }, t("now"));
900
+ if (isActive(row.active, now)) return (0, import_react6.createElement)(import_dsh_client_ui_primitives.Tag, { tone: "info" }, t("now"));
736
901
  const from = Date.parse(row.active.from);
737
- if (from > now && new Date(from).toDateString() === new Date(now).toDateString()) return (0, import_react5.createElement)("span", { className: "cb-when" }, t("fromTime", { time: formatClock(from, locale) }));
902
+ if (from > now && new Date(from).toDateString() === new Date(now).toDateString()) return (0, import_react6.createElement)("span", { className: "cb-when" }, t("fromTime", { time: formatClock(from, locale) }));
738
903
  }
739
- return row.date ? (0, import_react5.createElement)("span", { className: "cb-when" }, (0, import_react5.createElement)(kit.RelativeDay, { date: row.date })) : null;
904
+ return row.date ? (0, import_react6.createElement)("span", { className: "cb-when" }, (0, import_react6.createElement)(kit.RelativeDay, { date: row.date })) : null;
740
905
  }
741
- function Row({ lead, title, sub, meta, value, spark, row, index, washCount, fresh, rowActions, className }) {
906
+ function Row({ lead, title, sub, meta, value, spark, row, index, washCount, fresh, rowActions, className, onOpenRow }) {
742
907
  const kit = useKit();
743
908
  const now = kit.useNow();
744
909
  const wash = kit.useWash(washCount, row.key);
745
- return (0, import_react5.createElement)(
910
+ const go = row.link ? () => openLink(row.link) : row.detail && row.key !== void 0 && onOpenRow ? () => onOpenRow(row.key) : null;
911
+ const opens = go && {
912
+ "data-opens": "true",
913
+ role: row.link ? "link" : "button",
914
+ tabIndex: 0,
915
+ onClick: (event) => {
916
+ if (!onControl(event)) {
917
+ event.stopPropagation();
918
+ go();
919
+ }
920
+ },
921
+ onKeyDown: (event) => {
922
+ if ((event.key === "Enter" || event.key === " ") && event.target === event.currentTarget) {
923
+ event.preventDefault();
924
+ go();
925
+ }
926
+ }
927
+ };
928
+ return (0, import_react6.createElement)(
746
929
  "li",
747
- { className: ["cb-row", className, row.checked && "cb-done", isActive(row.active, now) && "cb-rowNow", wash].filter(Boolean).join(" ") },
930
+ { className: ["cb-row", className, row.checked && "cb-done", isActive(row.active, now) && "cb-rowNow", go && "cb-rowOpens", wash].filter(Boolean).join(" "), ...opens },
748
931
  lead,
749
- (0, import_react5.createElement)(
932
+ (0, import_react6.createElement)(
750
933
  "div",
751
934
  { className: "cb-rowText" },
752
- (0, import_react5.createElement)("div", { className: "cb-rowTitle" }, fresh && (0, import_react5.createElement)(kit.NewDot), (0, import_react5.createElement)(Trunc, { as: "span", lines: 2, text: title })),
753
- sub && (0, import_react5.createElement)(Trunc, { className: "cb-rowSub", lines: 2, text: sub })
935
+ (0, import_react6.createElement)("div", { className: "cb-rowTitle" }, fresh && (0, import_react6.createElement)(kit.NewDot), (0, import_react6.createElement)(Trunc, { as: "span", lines: 2, text: title })),
936
+ sub && (0, import_react6.createElement)(Trunc, { className: "cb-rowSub", lines: 2, text: sub })
754
937
  ),
755
938
  spark,
756
939
  meta,
757
940
  value,
758
- row.actions && rowActions && (0, import_react5.createElement)("span", { className: "cb-rowActions" }, rowActions(index, row.actions, "buttons")),
759
- row.actions?.some((action) => action.kind === "step") && rowActions && (0, import_react5.createElement)("div", { className: "cb-rowSteps" }, rowActions(index, row.actions, "steps"))
941
+ // The row's own buttons on the right: its steps first (a step starts the work on one tap), then the others.
942
+ row.actions && rowActions && (0, import_react6.createElement)(
943
+ "span",
944
+ { className: "cb-rowActions" },
945
+ row.actions.some((action) => action.kind === "step") && rowActions(index, row.actions, "steps"),
946
+ rowActions(index, row.actions, "buttons")
947
+ )
948
+ );
949
+ }
950
+ function DoneBox({ row, index, done, rowControls, t }) {
951
+ const state = rowControls.state(index, done.id);
952
+ const checked = row.checked === true || state === "done" || state === "pending";
953
+ return (0, import_react6.createElement)(
954
+ "span",
955
+ { className: "cb-doneBox", onClick: (event) => event.stopPropagation() },
956
+ (0, import_react6.createElement)(import_dsh_client_ui_primitives.Checkbox, {
957
+ checked,
958
+ disabled: checked,
959
+ title: t(checked ? "checked" : "markDone"),
960
+ label: (0, import_react6.createElement)("span", { className: "cb-visuallyHidden" }, t(checked ? "checked" : "markDone")),
961
+ onChange: (value) => {
962
+ if (value) rowControls.press(index, done);
963
+ }
964
+ })
760
965
  );
761
966
  }
762
967
  var rowLive = (live, row) => ({ washCount: live.rows?.[row.key] ?? 0, fresh: row.key !== void 0 && live.freshRows.has(row.key) });
763
- function ListCard({ data, live, locale, t, rowActions }) {
968
+ function ListCard({ data, live, locale, t, rowActions, all = false, onOpenRow, rowControls }) {
764
969
  const kit = useKit();
765
- const checkable = data.rows.some((row) => "checked" in row);
970
+ const [open, setOpen] = (0, import_react6.useState)(false);
971
+ const rows = shownRows(data.rows, open || all, LIST_ROWS, live);
972
+ const hidden = data.rows.length - rows.length;
973
+ const doneOf = (row) => row.actions?.find((action) => action.kind === "done");
766
974
  const progress = data.progress;
767
- return (0, import_react5.createElement)(
975
+ return (0, import_react6.createElement)(
768
976
  "div",
769
977
  { className: "cb-list" },
770
- progress && (0, import_react5.createElement)(
978
+ progress && (0, import_react6.createElement)(
771
979
  "div",
772
980
  { className: "cb-progress" },
773
- (0, import_react5.createElement)(
981
+ (0, import_react6.createElement)(
774
982
  kit.Ring,
775
983
  { value: progress.done, max: progress.total, size: 54, tone: progress.done >= progress.total ? "ok" : "accent", label: `${progress.done}/${progress.total}` },
776
- (0, import_react5.createElement)("span", null, String(progress.done)),
777
- (0, import_react5.createElement)("small", null, t("ofTotal", { total: progress.total }))
984
+ (0, import_react6.createElement)("span", null, String(progress.done)),
985
+ (0, import_react6.createElement)("small", null, t("ofTotal", { total: progress.total }))
778
986
  ),
779
- (0, import_react5.createElement)(
987
+ (0, import_react6.createElement)(
780
988
  "div",
781
989
  { className: "cb-progressText" },
782
- progress.label && (0, import_react5.createElement)("div", { className: "cb-progressLabel" }, progress.label),
783
- progress.sub && (0, import_react5.createElement)("div", { className: "cb-rowSub" }, progress.sub)
990
+ progress.label && (0, import_react6.createElement)("div", { className: "cb-progressLabel" }, progress.label),
991
+ progress.sub && (0, import_react6.createElement)("div", { className: "cb-rowSub" }, progress.sub)
784
992
  )
785
993
  ),
786
- data.rows.length === 0 ? (0, import_react5.createElement)("p", { className: "cb-muted" }, data.empty ?? t("listEmpty")) : (0, import_react5.createElement)("ul", { className: "cb-rows" }, data.rows.map((row, i) => (0, import_react5.createElement)(Row, {
994
+ data.rows.length === 0 ? (0, import_react6.createElement)("p", { className: "cb-muted" }, data.empty ?? t("listEmpty")) : (0, import_react6.createElement)("ul", { className: "cb-rows" }, rows.map((row, i) => (0, import_react6.createElement)(Row, {
787
995
  key: row.key ?? i,
788
- index: i,
789
- row,
996
+ index: data.rows.indexOf(row),
997
+ row: doneOf(row) && rowControls ? { ...row, actions: row.actions.filter((a) => a.kind !== "done") } : row,
790
998
  rowActions,
999
+ onOpenRow,
1000
+ className: i >= LIST_ROWS ? "cb-rowLate" : void 0,
791
1001
  ...rowLive(live, row),
792
1002
  lead: [
793
- checkable && (0, import_react5.createElement)(CheckBox, { key: "check", checked: row.checked === true, label: t(row.checked ? "checked" : "unchecked") }),
794
- row.icon && (0, import_react5.createElement)(kit.Tile, { key: "tile", icon: row.icon, tone: row.tone ?? "muted", size: 30 })
1003
+ doneOf(row) && rowControls && (0, import_react6.createElement)(DoneBox, { key: "check", row, index: data.rows.indexOf(row), done: doneOf(row), rowControls, t }),
1004
+ row.icon && (0, import_react6.createElement)(kit.Tile, { key: "tile", icon: row.icon, tone: row.tone ?? "muted", size: 30 })
795
1005
  ],
796
1006
  title: row.title,
797
1007
  sub: row.sub,
798
- meta: (0, import_react5.createElement)(
1008
+ meta: (0, import_react6.createElement)(
799
1009
  "span",
800
1010
  { className: "cb-rowMeta" },
801
- row.chip && (0, import_react5.createElement)(import_dsh_client_ui_primitives2.Tag, { tone: kit.tagTone(row.chip.tone ?? "muted") }, row.chip.text),
802
- (0, import_react5.createElement)(RowWhen, { row, locale, t })
1011
+ row.chip && (0, import_react6.createElement)(import_dsh_client_ui_primitives.Tag, { tone: kit.tagTone(row.chip.tone ?? "muted") }, row.chip.text),
1012
+ (0, import_react6.createElement)(RowWhen, { row, locale, t })
803
1013
  )
804
- })))
1014
+ }))),
1015
+ !all && (hidden > 0 || open) && data.rows.length > LIST_ROWS + 1 && (0, import_react6.createElement)(
1016
+ import_dsh_client_ui_primitives.Button,
1017
+ { variant: "ghost", size: "sm", className: "cb-more", onClick: () => setOpen((value) => !value) },
1018
+ open ? t("showFewer") : t("showMore", { n: hidden })
1019
+ )
805
1020
  );
806
1021
  }
807
- function StatusCard({ data, live, locale, rowActions }) {
1022
+ function StatusCard({ data, live, locale, rowActions, onOpenRow }) {
808
1023
  const kit = useKit();
809
- return (0, import_react5.createElement)("ul", { className: "cb-rows" }, data.rows.map((row, i) => (0, import_react5.createElement)(Row, {
1024
+ return (0, import_react6.createElement)("ul", { className: "cb-rows" }, data.rows.map((row, i) => (0, import_react6.createElement)(Row, {
810
1025
  key: row.key ?? i,
811
1026
  index: i,
812
1027
  row,
813
1028
  rowActions,
1029
+ onOpenRow,
814
1030
  ...rowLive(live, row),
815
1031
  className: "cb-statusRow",
816
- lead: row.icon ? (0, import_react5.createElement)(kit.Tile, { icon: row.icon, tone: row.tone, size: 28 }) : (0, import_react5.createElement)("span", { className: "cb-dotSlot" }, (0, import_react5.createElement)(import_dsh_client_ui_primitives2.StateDot, { state: STATE_OF_TONE[row.tone] ?? "idle" })),
1032
+ lead: row.icon ? (0, import_react6.createElement)(kit.Tile, { icon: row.icon, tone: row.tone, size: 28 }) : (0, import_react6.createElement)("span", { className: "cb-dotSlot" }, (0, import_react6.createElement)(import_dsh_client_ui_primitives.StateDot, { state: STATE_OF_TONE[row.tone] ?? "idle" })),
817
1033
  title: row.label,
818
1034
  sub: row.sub,
819
- spark: row.spark && (0, import_react5.createElement)("span", { className: "cb-statusSpark" }, (0, import_react5.createElement)(kit.Spark, { values: row.spark, tone: row.tone === "ok" ? "ok" : row.tone, height: 22 })),
820
- value: (0, import_react5.createElement)("span", { className: "cb-statusValue", style: row.tone === "bad" || row.tone === "warn" ? { color: kit.toneColor(row.tone) } : void 0 }, formatNumber(row.value, locale))
1035
+ spark: row.spark && (0, import_react6.createElement)("span", { className: "cb-statusSpark" }, (0, import_react6.createElement)(kit.Spark, { values: row.spark, tone: row.tone === "ok" ? "ok" : row.tone, height: 22 })),
1036
+ value: (0, import_react6.createElement)("span", { className: "cb-statusValue", style: row.tone === "bad" || row.tone === "warn" ? { color: kit.toneColor(row.tone) } : void 0 }, formatNumber(row.value, locale))
821
1037
  })));
822
1038
  }
823
1039
  var PARTS = [[5, "dayPart.morning"], [12, "dayPart.afternoon"], [18, "dayPart.evening"], [22, "dayPart.night"]];
@@ -830,12 +1046,12 @@ function SummaryBody({ card, locale, t, wash }) {
830
1046
  const kit = useKit();
831
1047
  const now = kit.useNow();
832
1048
  const day = dayLine(now, locale, t);
833
- return (0, import_react5.createElement)(
1049
+ return (0, import_react6.createElement)(
834
1050
  "div",
835
1051
  { className: "cb-summary" },
836
- (0, import_react5.createElement)("div", { className: "cb-summaryLine" }, (0, import_react5.createElement)(kit.Icon, { name: day.dark ? "moon" : "sun-medium", size: 14 }), (0, import_react5.createElement)("span", null, `${day.text} \xB7 ${card.title}`), wash && (0, import_react5.createElement)(kit.JustNow)),
837
- (0, import_react5.createElement)("p", { className: "cb-summaryText" }, card.data.text),
838
- card.data.chips?.length > 0 && (0, import_react5.createElement)("div", { className: "cb-chips" }, card.data.chips.map((chip, i) => (0, import_react5.createElement)(kit.Chip, { key: i, icon: chip.icon, tone: chip.tone ?? "muted", to: chip.to }, chip.text)))
1052
+ (0, import_react6.createElement)("div", { className: "cb-summaryLine" }, (0, import_react6.createElement)(kit.Icon, { name: day.dark ? "moon" : "sun-medium", size: 14 }), (0, import_react6.createElement)("span", null, `${day.text} \xB7 ${card.title}`), wash && (0, import_react6.createElement)(kit.JustNow)),
1053
+ (0, import_react6.createElement)("p", { className: "cb-summaryText" }, card.data.text),
1054
+ card.data.chips?.length > 0 && (0, import_react6.createElement)("div", { className: "cb-chips" }, card.data.chips.map((chip, i) => (0, import_react6.createElement)(kit.Chip, { key: i, icon: chip.icon, tone: chip.tone ?? "muted", to: chip.to }, chip.text)))
839
1055
  );
840
1056
  }
841
1057
  function CountdownBody({ card, locale }) {
@@ -844,26 +1060,26 @@ function CountdownBody({ card, locale }) {
844
1060
  const data = card.data;
845
1061
  const times = data.steps ? stepTimes(data.steps, locale) : [];
846
1062
  const next = times.findIndex((step) => step.time > now);
847
- return (0, import_react5.createElement)(
1063
+ return (0, import_react6.createElement)(
848
1064
  "div",
849
1065
  { className: "cb-countdown" },
850
- (0, import_react5.createElement)(
1066
+ (0, import_react6.createElement)(
851
1067
  "div",
852
1068
  { className: "cb-countdownHead" },
853
- (0, import_react5.createElement)(kit.Countdown, { to: data.to }),
854
- (0, import_react5.createElement)(
1069
+ (0, import_react6.createElement)(kit.Countdown, { to: data.to }),
1070
+ (0, import_react6.createElement)(
855
1071
  "div",
856
1072
  { className: "cb-countdownText" },
857
- (0, import_react5.createElement)("div", null, data.label),
858
- data.sub && (0, import_react5.createElement)("div", { className: "cb-rowSub" }, data.sub)
1073
+ (0, import_react6.createElement)("div", null, data.label),
1074
+ data.sub && (0, import_react6.createElement)("div", { className: "cb-rowSub" }, data.sub)
859
1075
  )
860
1076
  ),
861
- times.length > 0 && (0, import_react5.createElement)("ol", { className: "cb-track" }, data.steps.map((step, i) => (0, import_react5.createElement)(
1077
+ times.length > 0 && (0, import_react6.createElement)("ol", { className: "cb-track" }, data.steps.map((step, i) => (0, import_react6.createElement)(
862
1078
  "li",
863
1079
  { key: i, "data-state": i === next ? "next" : times[i].time <= now ? "past" : "later" },
864
- (0, import_react5.createElement)("i", { "aria-hidden": true }),
865
- (0, import_react5.createElement)("b", null, times[i].text),
866
- (0, import_react5.createElement)("span", null, step.sub ? `${step.label} \xB7 ${step.sub}` : step.label)
1080
+ (0, import_react6.createElement)("i", { "aria-hidden": true }),
1081
+ (0, import_react6.createElement)("b", null, times[i].text),
1082
+ (0, import_react6.createElement)("span", null, step.sub ? `${step.label} \xB7 ${step.sub}` : step.label)
867
1083
  )))
868
1084
  );
869
1085
  }
@@ -917,7 +1133,7 @@ function summaryLines(card, locale, t) {
917
1133
  }
918
1134
 
919
1135
  // src/client/words.js
920
- var import_react6 = require("react");
1136
+ var import_react7 = require("react");
921
1137
  var messageRequests = /* @__PURE__ */ new Map();
922
1138
  function fetchMessages(tag) {
923
1139
  if (!messageRequests.has(tag)) {
@@ -963,11 +1179,11 @@ var setClientContext = (ctx) => {
963
1179
  clientCtx = ctx;
964
1180
  };
965
1181
  function useActiveLocale() {
966
- const subscribe = (0, import_react6.useCallback)((listener) => clientCtx.locale.subscribe(listener), []);
967
- const active = (0, import_react6.useSyncExternalStore)(subscribe, () => clientCtx.locale.getSnapshot().active);
968
- const [loaded, setLoaded] = (0, import_react6.useState)(null);
969
- const [attempt, setAttempt] = (0, import_react6.useState)(0);
970
- (0, import_react6.useEffect)(() => {
1182
+ const subscribe = (0, import_react7.useCallback)((listener) => clientCtx.locale.subscribe(listener), []);
1183
+ const active = (0, import_react7.useSyncExternalStore)(subscribe, () => clientCtx.locale.getSnapshot().active);
1184
+ const [loaded, setLoaded] = (0, import_react7.useState)(null);
1185
+ const [attempt, setAttempt] = (0, import_react7.useState)(0);
1186
+ (0, import_react7.useEffect)(() => {
971
1187
  let live = true;
972
1188
  let timer;
973
1189
  fetchMessages(active).then(
@@ -983,52 +1199,88 @@ function useActiveLocale() {
983
1199
  clearTimeout(timer);
984
1200
  };
985
1201
  }, [active, attempt]);
986
- return (0, import_react6.useMemo)(() => ({ active: loaded?.active ?? active, ready: loaded !== null, intl: intlTag(loaded?.active ?? active), t: translator(loaded?.messages ?? {}) }), [loaded, active]);
1202
+ return (0, import_react7.useMemo)(() => ({ active: loaded?.active ?? active, ready: loaded !== null, intl: intlTag(loaded?.active ?? active), t: translator(loaded?.messages ?? {}) }), [loaded, active]);
1203
+ }
1204
+
1205
+ // src/client/detail.js
1206
+ var import_react8 = require("react");
1207
+ var CHARTS = { line: LineChart, bar: BarChart };
1208
+ function DetailParts({ detail, locale, t }) {
1209
+ const kit = useKit();
1210
+ if (!detail) return null;
1211
+ const Chart = detail.chart && CHARTS[detail.chart.type];
1212
+ return (0, import_react8.createElement)(
1213
+ "div",
1214
+ { className: "cb-detail" },
1215
+ detail.text && (0, import_react8.createElement)("p", { className: "cb-detailText" }, detail.text),
1216
+ detail.facts?.length > 0 && (0, import_react8.createElement)("dl", { className: "cb-facts" }, detail.facts.map((fact, i) => [
1217
+ (0, import_react8.createElement)("dt", { key: `t${i}` }, fact.label),
1218
+ (0, import_react8.createElement)("dd", { key: `d${i}` }, typeof fact.value === "number" ? formatNumber(fact.value, locale) : fact.value)
1219
+ ])),
1220
+ Chart && (0, import_react8.createElement)("div", { className: "cb-detailChart" }, (0, import_react8.createElement)(Chart, { data: detail.chart.data, locale, height: 240 })),
1221
+ detail.history?.length > 0 && (0, import_react8.createElement)(
1222
+ "section",
1223
+ { className: "cb-detailHistory" },
1224
+ (0, import_react8.createElement)("h4", null, t("history")),
1225
+ (0, import_react8.createElement)(kit.History, { items: detail.history, max: 8, moreLabel: t("showMore", { n: "{n}" }) })
1226
+ )
1227
+ );
987
1228
  }
988
1229
 
989
1230
  // src/client/card.js
990
- var CHART_HEIGHT = { 1: 150, 2: 360, 3: 560 };
991
- var CHART_HEIGHT_NARROW = { 1: 150, 2: 220, 3: 260 };
992
- var CHARTS = { line: LineChart, bar: BarChart, donut: Donut, timeline: Timeline };
1231
+ var CHART_HEIGHT = 150;
1232
+ function useRowSpan() {
1233
+ const ref = (0, import_react9.useRef)(null);
1234
+ const [rows, setRows] = (0, import_react9.useState)(0);
1235
+ (0, import_react9.useLayoutEffect)(() => {
1236
+ const el = ref.current;
1237
+ if (!el || typeof ResizeObserver === "undefined") return void 0;
1238
+ const measure = () => setRows(Math.ceil((el.getBoundingClientRect().height + GAP) / ROW));
1239
+ measure();
1240
+ const observer = new ResizeObserver(measure);
1241
+ observer.observe(el);
1242
+ return () => observer.disconnect();
1243
+ }, []);
1244
+ return [ref, rows];
1245
+ }
1246
+ var CHARTS2 = { line: LineChart, bar: BarChart, donut: Donut, timeline: Timeline };
993
1247
  function statesOf(presses, row) {
994
1248
  const states = {};
995
1249
  for (const press of presses ?? []) if (press.row === row) states[press.id] = press.state;
996
1250
  return states;
997
1251
  }
998
- function Body({ card, size, narrow, live, wash, locale, t, rowActions }) {
1252
+ function Body({ card, live, wash, locale, t, rowActions, all, onOpenRow, rowControls }) {
999
1253
  const data = card.data;
1000
1254
  switch (card.type) {
1001
1255
  case "stat":
1002
- return (0, import_react7.createElement)(StatBlock, { data, locale, wash });
1256
+ return (0, import_react9.createElement)(StatBlock, { data, locale, wash });
1003
1257
  case "list":
1004
- return (0, import_react7.createElement)(ListCard, { data, live, locale, t, rowActions });
1258
+ return (0, import_react9.createElement)(ListCard, { data, live, locale, t, rowActions, all, onOpenRow, rowControls });
1005
1259
  case "status":
1006
- return (0, import_react7.createElement)(StatusCard, { data, live, locale, rowActions });
1260
+ return (0, import_react9.createElement)(StatusCard, { data, live, locale, rowActions, onOpenRow });
1007
1261
  case "countdown":
1008
- return (0, import_react7.createElement)(CountdownBody, { card, locale });
1262
+ return (0, import_react9.createElement)(CountdownBody, { card, locale });
1009
1263
  default: {
1010
- const Chart = CHARTS[card.type];
1264
+ const Chart = CHARTS2[card.type];
1011
1265
  if (Chart === void 0) return null;
1012
- const height = (narrow ? CHART_HEIGHT_NARROW : CHART_HEIGHT)[size.h];
1013
- return (0, import_react7.createElement)(Chart, { data, locale, height: card.type === "bar" ? Math.min(height, 130 + (size.h - 1) * 200) : card.type === "donut" ? Math.max(height, 160) : height });
1266
+ return (0, import_react9.createElement)(Chart, { data, locale, height: all ? card.type === "donut" ? 200 : 240 : card.type === "bar" ? 130 : card.type === "donut" ? 160 : CHART_HEIGHT });
1014
1267
  }
1015
1268
  }
1016
1269
  }
1017
- function Card({ entry, live, boardId, assistant, columns, active, locale, t, press }) {
1270
+ function Card({ entry, live, boardId, assistant, tracks, active, locale, t, press, onOpen, sheet = false, row: openRow }) {
1018
1271
  const kit = useKit();
1019
1272
  const actions = useButtons();
1020
1273
  const now = kit.useNow();
1021
1274
  const wash = kit.useWash(live.wash, entry.id);
1022
- const full = entry.card?.type === "summary";
1023
- const size = { w: full ? columns : Math.min(entry.w ?? 1, columns), h: entry.h ?? 1 };
1024
- const style = { gridColumn: `span ${size.w}`, gridRow: size.h > 1 && columns > 1 && !full ? `span ${size.h}` : void 0 };
1275
+ const [ref, rows] = useRowSpan();
1276
+ const style = sheet ? void 0 : { gridColumn: `span ${spanOf(entry.card?.type, entry.size, tracks)}`, gridRowEnd: rows > 0 ? `span ${rows}` : void 0 };
1025
1277
  if (!entry.card) {
1026
- return (0, import_react7.createElement)(
1278
+ return (0, import_react9.createElement)(
1027
1279
  "section",
1028
- { className: "cb-card cb-cardError", style },
1029
- (0, import_react7.createElement)("header", { className: "cb-cardHead" }, (0, import_react7.createElement)("h3", { title: entry.id }, entry.id)),
1030
- (0, import_react7.createElement)("p", { className: "cb-errorText" }, t("cardError")),
1031
- (0, import_react7.createElement)("ul", { className: "cb-problems" }, (entry.problems ?? []).map((p, i) => (0, import_react7.createElement)("li", { key: i }, p)))
1280
+ { ref, className: "cb-card cb-cardError", style },
1281
+ (0, import_react9.createElement)("header", { className: "cb-cardHead" }, (0, import_react9.createElement)("h3", { title: entry.id }, entry.id)),
1282
+ (0, import_react9.createElement)("p", { className: "cb-errorText" }, t("cardError")),
1283
+ (0, import_react9.createElement)("ul", { className: "cb-problems" }, (entry.problems ?? []).map((p, i) => (0, import_react9.createElement)("li", { key: i }, p)))
1032
1284
  );
1033
1285
  }
1034
1286
  const card = pickCard(entry.card, active);
@@ -1047,7 +1299,7 @@ function Card({ entry, live, boardId, assistant, columns, active, locale, t, pre
1047
1299
  const askName = assistant ? t("action.chatNamed", { name: assistant }) : void 0;
1048
1300
  const named = (list) => assistant ? list?.map((action) => action.kind === "chat" && action.label === void 0 ? { ...action, label: askName } : action) : list;
1049
1301
  const onPress = (target) => (action, extra) => press(action, extra, { card: entry.id, ...target });
1050
- const rowActions = actions && ((row, list, part2) => (0, import_react7.createElement)(actions.ActionBar, {
1302
+ const rowActions = actions && ((row, list, part2) => (0, import_react9.createElement)(actions.ActionBar, {
1051
1303
  actions: named(list),
1052
1304
  part: part2,
1053
1305
  states: statesOf(entry.presses, row),
@@ -1055,48 +1307,80 @@ function Card({ entry, live, boardId, assistant, columns, active, locale, t, pre
1055
1307
  about: about(row, rowLine(row)),
1056
1308
  onPress: onPress({ row })
1057
1309
  }));
1058
- const chat = actions && (0, import_react7.createElement)("span", { className: "cb-cardChat" }, (0, import_react7.createElement)(actions.ActionButton, { action: { kind: "chat", id: "_chat", label: askName }, compact: true, about: about() }));
1310
+ const rowControls = {
1311
+ press: (row, action) => onPress({ row })(action),
1312
+ state: (row, id) => statesOf(entry.presses, row)[id]
1313
+ };
1314
+ const chat = actions && (0, import_react9.createElement)("span", { className: "cb-cardChat" }, (0, import_react9.createElement)(actions.ActionButton, { action: { kind: "chat", id: "_chat", label: askName }, compact: true, about: about() }));
1059
1315
  const others = card.actions?.filter((action) => action.kind !== "step") ?? [];
1060
- const steps = card.actions?.some((action) => action.kind === "step") && (0, import_react7.createElement)(kit.Suggested, { actions: card.actions, about: about(), states: statesOf(entry.presses, void 0), onPress: onPress({}) });
1061
- const footer = actions && others.length > 0 && (0, import_react7.createElement)("footer", { className: "cb-cardActions" }, (0, import_react7.createElement)(actions.ActionBar, {
1316
+ const steps = card.actions?.some((action) => action.kind === "step") && (0, import_react9.createElement)(kit.Suggested, { actions: card.actions, about: about(), states: statesOf(entry.presses, void 0), onPress: onPress({}) });
1317
+ const footer = actions && others.length > 0 && (0, import_react9.createElement)("footer", { className: "cb-cardActions" }, (0, import_react9.createElement)(actions.ActionBar, {
1062
1318
  actions: named(others),
1063
1319
  part: "buttons",
1064
1320
  states: statesOf(entry.presses, void 0),
1065
1321
  about: about(),
1066
1322
  onPress: onPress({})
1067
1323
  }));
1068
- const className = ["cb-card", `cb-card-${card.type}`, stale && "cb-cardStale", wash].filter(Boolean).join(" ");
1324
+ const openable = !sheet && onOpen && card.type !== "summary";
1325
+ const className = ["cb-card", `cb-card-${card.type}`, stale && "cb-cardStale", openable && "cb-cardOpenable", sheet && "cb-cardInSheet", wash].filter(Boolean).join(" ");
1326
+ const openOnTap = openable ? { onClick: (event) => {
1327
+ if (!onControl(event) && !event.target.closest?.("[data-opens]") && !window.getSelection?.()?.toString()) onOpen();
1328
+ } } : {};
1329
+ const onOpenRow = onOpen && ((key) => onOpen(key));
1330
+ if (sheet && openRow !== void 0) {
1331
+ const index = card.data.rows?.findIndex((r) => r.key === openRow) ?? -1;
1332
+ const target = index >= 0 ? card.data.rows[index] : null;
1333
+ if (!target) return (0, import_react9.createElement)("p", { className: "cb-muted" }, t("rowGone"));
1334
+ return (0, import_react9.createElement)(
1335
+ "div",
1336
+ { className: "cb-rowSheet" },
1337
+ (0, import_react9.createElement)(Body, {
1338
+ card: { ...card, data: { ...card.data, rows: [target], progress: void 0 } },
1339
+ live,
1340
+ wash: false,
1341
+ locale,
1342
+ t,
1343
+ rowActions: rowActions && ((_, list, part2) => rowActions(index, list, part2)),
1344
+ all: true,
1345
+ rowControls: { press: (_, action) => rowControls.press(index, action), state: (_, id) => rowControls.state(index, id) }
1346
+ }),
1347
+ (0, import_react9.createElement)(DetailParts, { detail: target.detail, locale, t })
1348
+ );
1349
+ }
1069
1350
  if (card.type === "summary") {
1070
- return (0, import_react7.createElement)(
1351
+ return (0, import_react9.createElement)(
1071
1352
  "section",
1072
- { className, style, "data-type": card.type },
1073
- (0, import_react7.createElement)("div", { className: "cb-summaryMain" }, (0, import_react7.createElement)(SummaryBody, { card, locale, t, wash: wash !== "" }), steps, footer),
1074
- (0, import_react7.createElement)("div", { className: "cb-summaryAside" }, live.fresh && (0, import_react7.createElement)(kit.NewDot), chat)
1353
+ { ref, className, style, "data-type": card.type },
1354
+ (0, import_react9.createElement)("div", { className: "cb-summaryMain" }, (0, import_react9.createElement)(SummaryBody, { card, locale, t, wash: wash !== "" }), steps, footer),
1355
+ (0, import_react9.createElement)("div", { className: "cb-summaryAside" }, live.fresh && (0, import_react9.createElement)(kit.NewDot), chat)
1075
1356
  );
1076
1357
  }
1077
- const statBlock = card.stat && (0, import_react7.createElement)(StatBlock, { data: card.stat, locale, compact: true, wash: wash !== "" });
1078
- const body = (0, import_react7.createElement)(Body, { card, size, narrow: columns === 1, live, wash: wash !== "", locale, t, rowActions });
1079
- return (0, import_react7.createElement)(
1358
+ const statBlock = card.stat && (0, import_react9.createElement)(StatBlock, { data: card.stat, locale, compact: true, wash: wash !== "" });
1359
+ const body = (0, import_react9.createElement)(Body, { card, live, wash: wash !== "", locale, t, rowActions, all: sheet, onOpenRow, rowControls });
1360
+ return (0, import_react9.createElement)(
1080
1361
  "section",
1081
- { className, style, "data-type": card.type },
1082
- (0, import_react7.createElement)(
1362
+ { ref, className, style, "data-type": card.type, ...openOnTap },
1363
+ !sheet && (0, import_react9.createElement)(
1083
1364
  "header",
1084
1365
  { className: "cb-cardHead" },
1085
- card.icon && (0, import_react7.createElement)(kit.Tile, { icon: card.icon, tone: card.tone ?? "muted", size: 30 }),
1086
- (0, import_react7.createElement)(Trunc, { as: "h3", text: card.title }),
1087
- live.fresh && (0, import_react7.createElement)(kit.NewDot),
1088
- wash !== "" && card.type !== "stat" && !card.stat && (0, import_react7.createElement)(kit.JustNow),
1089
- stale && (0, import_react7.createElement)(
1366
+ card.icon && (0, import_react9.createElement)(kit.Tile, { icon: card.icon, tone: card.tone ?? "muted", size: 30 }),
1367
+ (0, import_react9.createElement)(Trunc, { as: "h3", text: card.title }),
1368
+ live.fresh && (0, import_react9.createElement)(kit.NewDot),
1369
+ wash !== "" && card.type !== "stat" && !card.stat && (0, import_react9.createElement)(kit.JustNow),
1370
+ stale && (0, import_react9.createElement)(
1090
1371
  "span",
1091
1372
  { className: "cb-stale", title: new Intl.DateTimeFormat(locale, { dateStyle: "medium", timeStyle: "short" }).format(updated) },
1092
- (0, import_react7.createElement)(import_dsh_client_ui_primitives3.Tag, { tone: "warning" }, t("stale", { age: formatAge(age, locale) }))
1373
+ (0, import_react9.createElement)(import_dsh_client_ui_primitives2.Tag, { tone: "warning" }, t("stale", { age: formatAge(age, locale) }))
1093
1374
  ),
1094
- card.link && (0, import_react7.createElement)("a", { className: "cb-cardLink", href: card.link, title: t("open"), "aria-label": t("open"), ...external ? { target: "_blank", rel: "noopener noreferrer" } : {} }, (0, import_react7.createElement)(import_dsh_client_ui_primitives3.IconRightUpOutlineRegular, { size: 14 })),
1375
+ card.link && (0, import_react9.createElement)("a", { className: "cb-cardLink", href: card.link, title: t("open"), "aria-label": t("open"), ...external ? { target: "_blank", rel: "noopener noreferrer" } : {} }, (0, import_react9.createElement)(import_dsh_client_ui_primitives2.IconRightUpOutlineRegular, { size: 14 })),
1376
+ openable && (0, import_react9.createElement)("button", { type: "button", className: "cb-cardLink cb-cardOpen", title: t("details"), "aria-label": t("details"), onClick: () => onOpen() }, (0, import_react9.createElement)(import_dsh_client_ui_primitives2.IconFullscreenOutlineRegular, { size: 14 })),
1095
1377
  chat
1096
1378
  ),
1097
- statBlock && ["line", "bar", "donut"].includes(card.type) ? (0, import_react7.createElement)("div", { className: "cb-split" }, statBlock, (0, import_react7.createElement)("div", { className: "cb-cardBody" }, body)) : [statBlock && (0, import_react7.createElement)("div", { key: "stat" }, statBlock), (0, import_react7.createElement)("div", { key: "body", className: "cb-cardBody" }, body)],
1379
+ statBlock && ["line", "bar", "donut"].includes(card.type) ? (0, import_react9.createElement)("div", { className: "cb-split" }, statBlock, (0, import_react9.createElement)("div", { className: "cb-cardBody" }, body)) : [statBlock && (0, import_react9.createElement)("div", { key: "stat" }, statBlock), (0, import_react9.createElement)("div", { key: "body", className: "cb-cardBody" }, body)],
1380
+ sheet && (0, import_react9.createElement)(DetailParts, { detail: card.detail, locale, t }),
1098
1381
  steps,
1099
- footer
1382
+ footer,
1383
+ sheet && chat && (0, import_react9.createElement)("div", { className: "cb-sheetChat" }, chat)
1100
1384
  );
1101
1385
  }
1102
1386
 
@@ -1131,6 +1415,33 @@ function seenReport(board) {
1131
1415
  return { board: board.id, cards };
1132
1416
  }
1133
1417
 
1418
+ // src/client/nav.js
1419
+ var NAMES = ["board", "card", "row"];
1420
+ function readNav(search) {
1421
+ const params = new URLSearchParams(search);
1422
+ const nav = {};
1423
+ for (const name of NAMES) {
1424
+ const value = params.get(name);
1425
+ if (value) nav[name] = value;
1426
+ }
1427
+ return nav;
1428
+ }
1429
+ function writeNav(search, nav) {
1430
+ const params = new URLSearchParams(search);
1431
+ for (const name of NAMES) params.delete(name);
1432
+ for (const name of NAMES) if (nav?.[name]) params.set(name, nav[name]);
1433
+ const query = params.toString();
1434
+ return query ? `?${query}` : "";
1435
+ }
1436
+ var hasNav = (search) => Boolean(readNav(search).card);
1437
+
1438
+ // src/client/sheet.js
1439
+ var import_react10 = require("react");
1440
+ var import_dsh_client_ui_primitives3 = require("@deepseek-ai/dsh-client-ui-primitives");
1441
+ function Sheet({ open, onClose, title, closeLabel, children }) {
1442
+ return (0, import_react10.createElement)(import_dsh_client_ui_primitives3.Modal, { open, onClose, title, closeLabel, className: "cb-sheetModal", contentClassName: "cb-sheet" }, children);
1443
+ }
1444
+
1134
1445
  // src/client/page.js
1135
1446
  var STORE_KEY = "dsh-card-board:board";
1136
1447
  var SEEN_AFTER_MS = 2500;
@@ -1152,39 +1463,42 @@ async function getJson(path, etag) {
1152
1463
  }
1153
1464
  var ERROR_KEYS = { 403: "error.forbidden", 404: "error.notFound", 409: "error.gone", 503: "error.noProvider" };
1154
1465
  var errorText = (error, t) => error.status === void 0 ? error.message : t(ERROR_KEYS[error.status] ?? "error.http", { status: error.status });
1155
- function useColumns() {
1466
+ function useTracks() {
1156
1467
  const [ref, width] = useWidth();
1157
- return [ref, width >= 1400 ? 4 : width >= 980 ? 3 : width >= 620 ? 2 : 1];
1468
+ return [ref, width >= 900 ? 6 : width >= 560 ? 2 : 1];
1158
1469
  }
1159
1470
  var visible = () => document.visibilityState === "visible";
1160
1471
  function BoardsPage() {
1161
1472
  const kit = useKit();
1162
1473
  const { active, intl: locale, ready, t } = useActiveLocale();
1163
- const [boards, setBoards] = (0, import_react8.useState)(null);
1164
- const [listError, setListError] = (0, import_react8.useState)(null);
1165
- const [selected, setSelected] = (0, import_react8.useState)(() => {
1474
+ const [boards, setBoards] = (0, import_react11.useState)(null);
1475
+ const [listError, setListError] = (0, import_react11.useState)(null);
1476
+ const [opened, setOpened] = (0, import_react11.useState)(() => typeof location === "undefined" ? {} : readNav(location.search));
1477
+ const pushed = (0, import_react11.useRef)(false);
1478
+ const [selected, setSelected] = (0, import_react11.useState)(() => {
1479
+ if (opened.board) return opened.board;
1166
1480
  try {
1167
1481
  return localStorage.getItem(STORE_KEY);
1168
1482
  } catch {
1169
1483
  return null;
1170
1484
  }
1171
1485
  });
1172
- const [view, setView] = (0, import_react8.useState)({ board: null, live: {} });
1173
- const [boardError, setBoardError] = (0, import_react8.useState)(null);
1174
- const [pollSeconds, setPollSeconds] = (0, import_react8.useState)(30);
1175
- const etag = (0, import_react8.useRef)(null);
1176
- const [gridRef, columns] = useColumns();
1177
- const currentRef = (0, import_react8.useRef)(null);
1178
- const translateRef = (0, import_react8.useRef)(t);
1486
+ const [view, setView] = (0, import_react11.useState)({ board: null, live: {} });
1487
+ const [boardError, setBoardError] = (0, import_react11.useState)(null);
1488
+ const [pollSeconds, setPollSeconds] = (0, import_react11.useState)(30);
1489
+ const etag = (0, import_react11.useRef)(null);
1490
+ const [gridRef, tracks] = useTracks();
1491
+ const currentRef = (0, import_react11.useRef)(null);
1492
+ const translateRef = (0, import_react11.useRef)(t);
1179
1493
  translateRef.current = t;
1180
1494
  const board = view.board;
1181
- const boardRef = (0, import_react8.useRef)(null);
1495
+ const boardRef = (0, import_react11.useRef)(null);
1182
1496
  boardRef.current = board;
1183
- const show = (0, import_react8.useCallback)((next) => setView((prev) => ({
1497
+ const show = (0, import_react11.useCallback)((next) => setView((prev) => ({
1184
1498
  board: next,
1185
1499
  live: next === null ? {} : nextLive(prev.board?.id === next.id ? prev.board : null, next, prev.board?.id === next.id ? prev.live : {})
1186
1500
  })), []);
1187
- const loadList = (0, import_react8.useCallback)(async () => {
1501
+ const loadList = (0, import_react11.useCallback)(async () => {
1188
1502
  try {
1189
1503
  const { body } = await getJson("boards");
1190
1504
  setBoards(body.boards);
@@ -1195,7 +1509,7 @@ function BoardsPage() {
1195
1509
  }
1196
1510
  }, []);
1197
1511
  const current = boards?.some((b) => b.id === selected) ? selected : boards?.[0]?.id ?? null;
1198
- const loadBoard = (0, import_react8.useCallback)(async (id, fresh) => {
1512
+ const loadBoard = (0, import_react11.useCallback)(async (id, fresh) => {
1199
1513
  if (!id) return;
1200
1514
  try {
1201
1515
  const result = await getJson(`board?id=${encodeURIComponent(id)}`, fresh ? null : etag.current);
@@ -1211,7 +1525,7 @@ function BoardsPage() {
1211
1525
  }
1212
1526
  }
1213
1527
  }, [loadList, show]);
1214
- const loadCard = (0, import_react8.useCallback)(async (boardId, id) => {
1528
+ const loadCard = (0, import_react11.useCallback)(async (boardId, id) => {
1215
1529
  try {
1216
1530
  if (boardRef.current?.id !== boardId || !boardRef.current.cards.some((card) => card.id === id)) return loadBoard(boardId, false);
1217
1531
  const { body } = await getJson(`card?board=${encodeURIComponent(boardId)}&id=${encodeURIComponent(id)}`);
@@ -1225,7 +1539,7 @@ function BoardsPage() {
1225
1539
  else loadBoard(boardId, false);
1226
1540
  }
1227
1541
  }, [loadBoard]);
1228
- const onEvent = (0, import_react8.useCallback)((message) => {
1542
+ const onEvent = (0, import_react11.useCallback)((message) => {
1229
1543
  const id = currentRef.current;
1230
1544
  if (!id) return;
1231
1545
  if (message.type === "card") loadCard(id, message.id);
@@ -1237,7 +1551,7 @@ function BoardsPage() {
1237
1551
  }
1238
1552
  }, [loadBoard, loadCard, loadList, show]);
1239
1553
  const status = kit.useEventStream(current ? `api/card-board/events?board=${encodeURIComponent(current)}` : null, onEvent);
1240
- const press = (0, import_react8.useCallback)(async (action, extra, target) => {
1554
+ const press = (0, import_react11.useCallback)(async (action, extra, target) => {
1241
1555
  const response = await fetch(api("action"), {
1242
1556
  method: "POST",
1243
1557
  credentials: "same-origin",
@@ -1249,10 +1563,10 @@ function BoardsPage() {
1249
1563
  loadBoard(currentRef.current, false);
1250
1564
  return body;
1251
1565
  }, [loadBoard]);
1252
- (0, import_react8.useEffect)(() => {
1566
+ (0, import_react11.useEffect)(() => {
1253
1567
  loadList();
1254
1568
  }, [loadList]);
1255
- (0, import_react8.useEffect)(() => {
1569
+ (0, import_react11.useEffect)(() => {
1256
1570
  currentRef.current = current;
1257
1571
  if (!current) return;
1258
1572
  etag.current = null;
@@ -1260,7 +1574,7 @@ function BoardsPage() {
1260
1574
  loadBoard(current, true);
1261
1575
  }, [current, loadBoard]);
1262
1576
  const waiting = board?.cards.some((entry) => entry.presses?.some((p) => p.state === "pending")) === true;
1263
- (0, import_react8.useEffect)(() => {
1577
+ (0, import_react11.useEffect)(() => {
1264
1578
  if (!current || status === "live" && !waiting) return void 0;
1265
1579
  let ticks = 0;
1266
1580
  const timer = setInterval(() => {
@@ -1280,8 +1594,8 @@ function BoardsPage() {
1280
1594
  document.removeEventListener("visibilitychange", onVisible);
1281
1595
  };
1282
1596
  }, [current, status, waiting, pollSeconds, loadBoard, loadList]);
1283
- const reported = (0, import_react8.useRef)("");
1284
- (0, import_react8.useEffect)(() => {
1597
+ const reported = (0, import_react11.useRef)("");
1598
+ (0, import_react11.useEffect)(() => {
1285
1599
  if (!board) return void 0;
1286
1600
  const report = seenReport(board);
1287
1601
  const text = JSON.stringify(report);
@@ -1295,6 +1609,27 @@ function BoardsPage() {
1295
1609
  }, SEEN_AFTER_MS);
1296
1610
  return () => clearTimeout(timer);
1297
1611
  }, [board]);
1612
+ (0, import_react11.useEffect)(() => {
1613
+ const onPop = () => {
1614
+ pushed.current = false;
1615
+ setOpened(readNav(location.search));
1616
+ };
1617
+ window.addEventListener("popstate", onPop);
1618
+ return () => window.removeEventListener("popstate", onPop);
1619
+ }, []);
1620
+ const openCard = (0, import_react11.useCallback)((boardId, card, row) => {
1621
+ const nav = { board: boardId, card, ...row === void 0 ? {} : { row } };
1622
+ window.history[pushed.current ? "replaceState" : "pushState"](window.history.state, "", `${location.pathname}${writeNav(location.search, nav)}${location.hash}`);
1623
+ pushed.current = true;
1624
+ setOpened(nav);
1625
+ }, []);
1626
+ const closeCard = (0, import_react11.useCallback)(() => {
1627
+ setOpened({});
1628
+ if (pushed.current) {
1629
+ pushed.current = false;
1630
+ window.history.back();
1631
+ } else window.history.replaceState(window.history.state, "", `${location.pathname}${writeNav(location.search, {})}${location.hash}`);
1632
+ }, []);
1298
1633
  const choose = (id) => {
1299
1634
  setSelected(id);
1300
1635
  try {
@@ -1307,39 +1642,49 @@ function BoardsPage() {
1307
1642
  return Number.isFinite(time) && time > max ? time : max;
1308
1643
  }, 0);
1309
1644
  const titleOf = (entry) => pickText(entry.title, active);
1310
- if (!ready) return (0, import_react8.createElement)("div", { className: "cb-page" });
1645
+ if (!ready) return (0, import_react11.createElement)("div", { className: "cb-page" });
1311
1646
  let content;
1312
- if (listError) content = (0, import_react8.createElement)("p", { className: "cb-notice" }, errorText(listError, t));
1313
- else if (boards === null) content = (0, import_react8.createElement)("p", { className: "cb-muted" }, t("loading"));
1314
- else if (boards.length === 0) content = (0, import_react8.createElement)("div", { className: "cb-empty" }, (0, import_react8.createElement)("p", { className: "cb-emptyTitle" }, t("emptyTitle")), (0, import_react8.createElement)("p", { className: "cb-muted" }, t("emptyHint")));
1315
- else if (boardError) content = (0, import_react8.createElement)("p", { className: "cb-notice" }, errorText(boardError, t));
1316
- else if (!board) content = (0, import_react8.createElement)("p", { className: "cb-muted" }, t("loading"));
1317
- else content = (0, import_react8.createElement)(
1318
- import_react8.Fragment,
1647
+ if (listError) content = (0, import_react11.createElement)("p", { className: "cb-notice" }, errorText(listError, t));
1648
+ else if (boards === null) content = (0, import_react11.createElement)("p", { className: "cb-muted" }, t("loading"));
1649
+ else if (boards.length === 0) content = (0, import_react11.createElement)("div", { className: "cb-empty" }, (0, import_react11.createElement)("p", { className: "cb-emptyTitle" }, t("emptyTitle")), (0, import_react11.createElement)("p", { className: "cb-muted" }, t("emptyHint")));
1650
+ else if (boardError) content = (0, import_react11.createElement)("p", { className: "cb-notice" }, errorText(boardError, t));
1651
+ else if (!board) content = (0, import_react11.createElement)("p", { className: "cb-muted" }, t("loading"));
1652
+ else content = (0, import_react11.createElement)(
1653
+ import_react11.Fragment,
1319
1654
  null,
1320
- board.problems?.length > 0 && (0, import_react8.createElement)("div", { className: "cb-notice" }, t("boardProblems"), (0, import_react8.createElement)("ul", { className: "cb-problems" }, board.problems.map((p, i) => (0, import_react8.createElement)("li", { key: i }, p)))),
1321
- board.cards.length === 0 && (0, import_react8.createElement)("p", { className: "cb-muted" }, t("noCards")),
1322
- (0, import_react8.createElement)(
1655
+ board.problems?.length > 0 && (0, import_react11.createElement)("div", { className: "cb-notice" }, t("boardProblems"), (0, import_react11.createElement)("ul", { className: "cb-problems" }, board.problems.map((p, i) => (0, import_react11.createElement)("li", { key: i }, p)))),
1656
+ board.cards.length === 0 && (0, import_react11.createElement)("p", { className: "cb-muted" }, t("noCards")),
1657
+ (0, import_react11.createElement)(
1323
1658
  "div",
1324
- { className: "cb-grid", style: { gridTemplateColumns: `repeat(${columns}, minmax(0, 1fr))` } },
1325
- board.cards.map((entry) => (0, import_react8.createElement)(Card, { key: entry.id, entry, live: liveOf(view.live, entry.id), boardId: board.id, assistant: board.assistant, columns, active, locale, t, press }))
1659
+ { className: "cb-grid", style: { gridTemplateColumns: `repeat(${tracks}, minmax(0, 1fr))`, gridAutoRows: `${ROW}px`, columnGap: GAP } },
1660
+ board.cards.map((entry) => (0, import_react11.createElement)(Card, { key: entry.id, entry, live: liveOf(view.live, entry.id), boardId: board.id, assistant: board.assistant, tracks, active, locale, t, press, onOpen: (row) => openCard(board.id, entry.id, row) }))
1326
1661
  )
1327
1662
  );
1328
- return (0, import_react8.createElement)(
1663
+ const openEntry = opened.card && board && (!opened.board || opened.board === board.id) ? board.cards.find((entry) => entry.id === opened.card && entry.card) : void 0;
1664
+ const openCardData = openEntry && pickCard(openEntry.card, active);
1665
+ const openRow = openCardData && opened.row !== void 0 ? openCardData.data.rows?.find((r) => r.key === opened.row) : void 0;
1666
+ const sheet = (0, import_react11.createElement)(Sheet, {
1667
+ open: Boolean(openEntry),
1668
+ onClose: closeCard,
1669
+ title: openRow ? openRow.title ?? openRow.label : openCardData?.title,
1670
+ closeLabel: t("close")
1671
+ }, openEntry && (0, import_react11.createElement)(Card, { entry: openEntry, live: liveOf(view.live, openEntry.id), boardId: board.id, assistant: board.assistant, tracks: 1, active, locale, t, press, sheet: true, row: opened.row }));
1672
+ return (0, import_react11.createElement)(
1329
1673
  "div",
1330
1674
  { className: "cb-page" },
1331
- (0, import_react8.createElement)(
1675
+ (0, import_react11.createElement)(
1332
1676
  "div",
1333
1677
  { className: "cb-content", ref: gridRef },
1334
- (0, import_react8.createElement)(
1678
+ (0, import_react11.createElement)(
1335
1679
  "div",
1336
1680
  { className: "cb-heading" },
1337
- (0, import_react8.createElement)("h1", null, boards?.length === 1 ? titleOf(boards[0]) : t("title")),
1338
- board && (0, import_react8.createElement)("div", { className: "cb-sub" }, (0, import_react8.createElement)(kit.LiveStatus, { status, updatedAt: newest || void 0 }))
1681
+ (0, import_react11.createElement)("h1", null, boards?.length === 1 ? titleOf(boards[0]) : t("title")),
1682
+ board && (0, import_react11.createElement)("div", { className: "cb-sub" }, (0, import_react11.createElement)(kit.LiveStatus, { status, updatedAt: newest || void 0 }))
1339
1683
  ),
1340
- boards && boards.length > 1 && (0, import_react8.createElement)("div", { className: "cb-tabs", role: "tablist" }, boards.map((b) => (0, import_react8.createElement)(import_dsh_client_ui_primitives4.Pill, { key: b.id, active: b.id === current, role: "tab", "aria-selected": b.id === current, title: titleOf(b), onClick: () => choose(b.id) }, titleOf(b)))),
1684
+ boards && boards.length > 1 && (0, import_react11.createElement)("div", { className: "cb-tabs", role: "tablist" }, boards.map((b) => (0, import_react11.createElement)(import_dsh_client_ui_primitives4.Pill, { key: b.id, active: b.id === current, role: "tab", "aria-selected": b.id === current, title: titleOf(b), onClick: () => choose(b.id) }, titleOf(b)))),
1341
1685
  content
1342
- )
1686
+ ),
1687
+ board && sheet
1343
1688
  );
1344
1689
  }
1345
1690
 
@@ -1348,17 +1693,17 @@ var NS = "dsh-card-board";
1348
1693
  var PANEL = "dsh-card-board";
1349
1694
  function SidebarIcon({ size }) {
1350
1695
  const stroke = { stroke: "currentColor", strokeWidth: 1.2, strokeLinecap: "round", strokeLinejoin: "round", fill: "none" };
1351
- return (0, import_react9.createElement)(
1696
+ return (0, import_react12.createElement)(
1352
1697
  "svg",
1353
1698
  { width: size, height: size, viewBox: "0 0 16 16", "aria-hidden": true, focusable: "false" },
1354
- (0, import_react9.createElement)("rect", { x: 1.75, y: 1.75, width: 5.5, height: 5.5, rx: 1.4, ...stroke }),
1355
- (0, import_react9.createElement)("rect", { x: 8.75, y: 1.75, width: 5.5, height: 5.5, rx: 1.4, ...stroke }),
1356
- (0, import_react9.createElement)("rect", { x: 1.75, y: 8.75, width: 5.5, height: 5.5, rx: 1.4, ...stroke }),
1357
- (0, import_react9.createElement)("path", { d: "M9 13.5l1.6-2 1.4 1 2-2.8", ...stroke })
1699
+ (0, import_react12.createElement)("rect", { x: 1.75, y: 1.75, width: 5.5, height: 5.5, rx: 1.4, ...stroke }),
1700
+ (0, import_react12.createElement)("rect", { x: 8.75, y: 1.75, width: 5.5, height: 5.5, rx: 1.4, ...stroke }),
1701
+ (0, import_react12.createElement)("rect", { x: 1.75, y: 8.75, width: 5.5, height: 5.5, rx: 1.4, ...stroke }),
1702
+ (0, import_react12.createElement)("path", { d: "M9 13.5l1.6-2 1.4 1 2-2.8", ...stroke })
1358
1703
  );
1359
1704
  }
1360
1705
  function Page() {
1361
- return useKit() === null ? (0, import_react9.createElement)("div", { className: "cb-page" }) : (0, import_react9.createElement)(BoardsPage);
1706
+ return useKit() === null ? (0, import_react12.createElement)("div", { className: "cb-page" }) : (0, import_react12.createElement)(BoardsPage);
1362
1707
  }
1363
1708
  var inject = ["slots", "locale"];
1364
1709
  function apply(ctx) {
@@ -1422,6 +1767,21 @@ function apply(ctx) {
1422
1767
  document.head.appendChild(tag);
1423
1768
  return () => tag.remove();
1424
1769
  }, "card-board: styles");
1770
+ ctx.effect(() => {
1771
+ if (typeof location === "undefined" || !hasNav(location.search)) return () => {
1772
+ };
1773
+ let tries = 0;
1774
+ const timer = setInterval(() => {
1775
+ const layout = ctx.get("layout");
1776
+ try {
1777
+ layout?.selectPanel(PANEL);
1778
+ if (layout) clearInterval(timer);
1779
+ } catch {
1780
+ }
1781
+ if (++tries > 50) clearInterval(timer);
1782
+ }, 100);
1783
+ return () => clearInterval(timer);
1784
+ }, "card-board: card link");
1425
1785
  ctx.slots.inject("main", () => ctx.slots.register({ name: "main", key: PANEL, locale: NS }, Page));
1426
1786
  ctx.slots.inject("sidebar.panellist", () => ctx.slots.register({
1427
1787
  name: "sidebar.panellist",