@nimblebrain/synapse 0.8.0 → 0.10.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.
@@ -0,0 +1,1420 @@
1
+ import { createContext, useRef, useId, useState, useEffect, useMemo, useContext, useLayoutEffect } from 'react';
2
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
3
+
4
+ // src/ui/components/Avatar.tsx
5
+
6
+ // src/ui/tokens.ts
7
+ var tokens = {
8
+ // ── Surfaces ──
9
+ bg: "var(--color-background-primary, #ffffff)",
10
+ bgRaised: "var(--color-background-secondary, #fafafa)",
11
+ bgSubtle: "var(--color-background-tertiary, #f3f4f6)",
12
+ // ── Text ──
13
+ fg: "var(--color-text-primary, #111827)",
14
+ fgMuted: "var(--color-text-secondary, #6b7280)",
15
+ fgFaint: "var(--color-text-tertiary, #9ca3af)",
16
+ accent: "var(--color-text-accent, #2563eb)",
17
+ accentFg: "var(--nb-color-accent-foreground, #ffffff)",
18
+ // ── Border / ring ──
19
+ border: "var(--color-border-primary, #e5e7eb)",
20
+ borderStrong: "var(--color-border-secondary, #d1d5db)",
21
+ ring: "var(--color-ring-primary, #2563eb)",
22
+ // ── Status / brand semantics ──
23
+ danger: "var(--nb-color-danger, #dc2626)",
24
+ success: "var(--nb-color-success, #059669)",
25
+ warning: "var(--nb-color-warning, #f59e0b)",
26
+ warm: "var(--nb-color-warm, #d4620a)",
27
+ warmLight: "var(--nb-color-warm-light, #fef5ee)",
28
+ processing: "var(--nb-color-processing, #7c3aed)",
29
+ processingLight: "var(--nb-color-processing-light, #f3eeff)",
30
+ infoLight: "var(--nb-color-info-light, #eef4ff)",
31
+ // ── Typography ──
32
+ fontSans: "var(--font-sans, system-ui, -apple-system, BlinkMacSystemFont, sans-serif)",
33
+ fontMono: "var(--font-mono, ui-monospace, SFMono-Regular, Menlo, monospace)",
34
+ fontHeading: "var(--nb-font-heading, Georgia, 'Times New Roman', serif)",
35
+ weightNormal: "var(--font-weight-normal, 400)",
36
+ weightMedium: "var(--font-weight-medium, 500)",
37
+ weightSemibold: "var(--font-weight-semibold, 600)",
38
+ weightBold: "var(--font-weight-bold, 700)",
39
+ // ── Type scale (size + line-height pairs) ──
40
+ textXsSize: "var(--font-text-xs-size, 0.75rem)",
41
+ textXsLine: "var(--font-text-xs-line-height, 1rem)",
42
+ textSmSize: "var(--font-text-sm-size, 0.875rem)",
43
+ textSmLine: "var(--font-text-sm-line-height, 1.25rem)",
44
+ textBaseSize: "var(--font-text-base-size, 1rem)",
45
+ textBaseLine: "var(--font-text-base-line-height, 1.5rem)",
46
+ textLgSize: "var(--font-text-lg-size, 1.125rem)",
47
+ textLgLine: "var(--font-text-lg-line-height, 1.75rem)",
48
+ headingSmSize: "var(--font-heading-sm-size, 1.25rem)",
49
+ headingSmLine: "var(--font-heading-sm-line-height, 1.75rem)",
50
+ headingMdSize: "var(--font-heading-md-size, 1.5rem)",
51
+ headingMdLine: "var(--font-heading-md-line-height, 2rem)",
52
+ headingLgSize: "var(--font-heading-lg-size, 2rem)",
53
+ headingLgLine: "var(--font-heading-lg-line-height, 2.5rem)",
54
+ // ── Radius / border width ──
55
+ radiusXs: "var(--border-radius-xs, 0.25rem)",
56
+ radiusSm: "var(--border-radius-sm, 0.5rem)",
57
+ radiusMd: "var(--border-radius-md, 0.75rem)",
58
+ radiusLg: "var(--border-radius-lg, 1rem)",
59
+ radiusXl: "var(--border-radius-xl, 1.5rem)",
60
+ borderWidth: "var(--border-width-regular, 1px)",
61
+ // ── Shadows ──
62
+ shadowHairline: "var(--shadow-hairline, 0 0 0 1px rgba(0,0,0,0.06))",
63
+ shadowSm: "var(--shadow-sm, 0 1px 2px rgba(0,0,0,0.05))",
64
+ shadowMd: "var(--shadow-md, 0 4px 6px -1px rgba(0,0,0,0.1))",
65
+ shadowLg: "var(--shadow-lg, 0 10px 15px -3px rgba(0,0,0,0.1))"
66
+ };
67
+ var TEXT_SCALE = {
68
+ xs: { fontSize: tokens.textXsSize, lineHeight: tokens.textXsLine },
69
+ sm: { fontSize: tokens.textSmSize, lineHeight: tokens.textSmLine },
70
+ base: { fontSize: tokens.textBaseSize, lineHeight: tokens.textBaseLine },
71
+ lg: { fontSize: tokens.textLgSize, lineHeight: tokens.textLgLine }
72
+ };
73
+ var HEADING_SCALE = {
74
+ sm: { fontSize: tokens.headingSmSize, lineHeight: tokens.headingSmLine },
75
+ md: { fontSize: tokens.headingMdSize, lineHeight: tokens.headingMdLine },
76
+ lg: { fontSize: tokens.headingLgSize, lineHeight: tokens.headingLgLine }
77
+ };
78
+ function textStyle(size) {
79
+ return TEXT_SCALE[size];
80
+ }
81
+ function headingStyle(size) {
82
+ return HEADING_SCALE[size];
83
+ }
84
+ function initialsOf(name) {
85
+ const parts = name.trim().split(/\s+/).filter(Boolean);
86
+ if (parts.length === 0) return "?";
87
+ const first = parts[0] ?? "";
88
+ if (parts.length === 1) return first.charAt(0).toUpperCase();
89
+ const last = parts[parts.length - 1] ?? "";
90
+ return (first.charAt(0) + last.charAt(0)).toUpperCase();
91
+ }
92
+ function Avatar({ name, src, size = 28, style, ...rest }) {
93
+ const [failed, setFailed] = useState(false);
94
+ useEffect(() => setFailed(false), [src]);
95
+ const showImage = Boolean(src) && !failed;
96
+ return /* @__PURE__ */ jsx(
97
+ "span",
98
+ {
99
+ style: {
100
+ display: "inline-flex",
101
+ alignItems: "center",
102
+ justifyContent: "center",
103
+ flexShrink: 0,
104
+ width: size,
105
+ height: size,
106
+ borderRadius: "50%",
107
+ overflow: "hidden",
108
+ background: tokens.bgSubtle,
109
+ color: tokens.fgMuted,
110
+ fontFamily: tokens.fontSans,
111
+ fontSize: Math.round(size * 0.4),
112
+ fontWeight: tokens.weightSemibold,
113
+ userSelect: "none",
114
+ ...style
115
+ },
116
+ ...rest,
117
+ children: showImage ? /* @__PURE__ */ jsx(
118
+ "img",
119
+ {
120
+ src,
121
+ alt: name,
122
+ width: size,
123
+ height: size,
124
+ onError: () => setFailed(true),
125
+ style: { width: "100%", height: "100%", objectFit: "cover" }
126
+ }
127
+ ) : initialsOf(name)
128
+ }
129
+ );
130
+ }
131
+ var TONE = {
132
+ neutral: { bg: tokens.bgSubtle, fg: tokens.fgMuted },
133
+ accent: { bg: tokens.infoLight, fg: tokens.accent },
134
+ success: { bg: `color-mix(in oklab, ${tokens.success} 14%, transparent)`, fg: tokens.success },
135
+ warning: { bg: `color-mix(in oklab, ${tokens.warning} 14%, transparent)`, fg: tokens.warning },
136
+ danger: { bg: `color-mix(in oklab, ${tokens.danger} 14%, transparent)`, fg: tokens.danger },
137
+ processing: { bg: tokens.processingLight, fg: tokens.processing },
138
+ warm: { bg: tokens.warmLight, fg: tokens.warm }
139
+ };
140
+ function Badge({ tone = "neutral", style, children, ...rest }) {
141
+ const { bg, fg } = TONE[tone];
142
+ return /* @__PURE__ */ jsx(
143
+ "span",
144
+ {
145
+ style: {
146
+ display: "inline-flex",
147
+ alignItems: "center",
148
+ gap: "0.25rem",
149
+ padding: "0.1rem 0.45rem",
150
+ borderRadius: tokens.radiusXs,
151
+ background: bg,
152
+ color: fg,
153
+ fontFamily: tokens.fontSans,
154
+ fontSize: tokens.textXsSize,
155
+ lineHeight: tokens.textXsLine,
156
+ fontWeight: tokens.weightSemibold,
157
+ letterSpacing: "0.02em",
158
+ textTransform: "uppercase",
159
+ whiteSpace: "nowrap",
160
+ ...style
161
+ },
162
+ ...rest,
163
+ children
164
+ }
165
+ );
166
+ }
167
+
168
+ // src/ui/internal/inject-style.ts
169
+ function ensureStyle(id, css) {
170
+ if (typeof document === "undefined") return;
171
+ if (document.getElementById(id)) return;
172
+ const style = document.createElement("style");
173
+ style.id = id;
174
+ style.textContent = css;
175
+ document.head.appendChild(style);
176
+ }
177
+ var STYLE_ID = "nb-synapse-button";
178
+ var RULES = `
179
+ .nb-btn {
180
+ --nb-btn-bg: transparent;
181
+ --nb-btn-bg-hover: transparent;
182
+ display: inline-flex;
183
+ align-items: center;
184
+ justify-content: center;
185
+ gap: 0.4rem;
186
+ border: var(--nb-btn-border, none);
187
+ border-radius: var(--nb-btn-radius);
188
+ background: var(--nb-btn-bg);
189
+ color: var(--nb-btn-fg);
190
+ font-family: var(--nb-btn-font);
191
+ font-weight: var(--nb-btn-weight);
192
+ cursor: pointer;
193
+ transition: background 130ms ease, color 130ms ease, opacity 130ms ease;
194
+ white-space: nowrap;
195
+ }
196
+ .nb-btn:hover { background: var(--nb-btn-bg-hover); }
197
+ .nb-btn:active { transform: translateY(0.5px); }
198
+ .nb-btn:disabled { opacity: 0.5; cursor: default; }
199
+ .nb-btn:disabled:hover { background: var(--nb-btn-bg); }
200
+ .nb-textlink {
201
+ border: none;
202
+ background: none;
203
+ padding: 0;
204
+ cursor: pointer;
205
+ font-family: var(--nb-tl-font);
206
+ color: var(--nb-tl-fg);
207
+ transition: color 130ms ease, opacity 130ms ease;
208
+ }
209
+ .nb-textlink:hover { color: var(--nb-tl-fg-hover); }
210
+ .nb-textlink:disabled { opacity: 0.45; cursor: default; }
211
+ `;
212
+ var SIZE_PAD = {
213
+ sm: "0.3rem 0.6rem",
214
+ md: "0.45rem 0.85rem"
215
+ };
216
+ function Button({
217
+ variant = "primary",
218
+ size = "md",
219
+ style,
220
+ className,
221
+ children,
222
+ ...rest
223
+ }) {
224
+ ensureStyle(STYLE_ID, RULES);
225
+ const vars = {
226
+ "--nb-btn-radius": tokens.radiusSm,
227
+ "--nb-btn-font": tokens.fontSans,
228
+ "--nb-btn-weight": tokens.weightMedium
229
+ };
230
+ if (variant === "primary") {
231
+ vars["--nb-btn-bg"] = tokens.accent;
232
+ vars["--nb-btn-bg-hover"] = `color-mix(in oklab, ${tokens.accent} 88%, black)`;
233
+ vars["--nb-btn-fg"] = tokens.accentFg;
234
+ } else if (variant === "secondary") {
235
+ vars["--nb-btn-bg"] = tokens.bgSubtle;
236
+ vars["--nb-btn-bg-hover"] = tokens.bgRaised;
237
+ vars["--nb-btn-fg"] = tokens.fg;
238
+ vars["--nb-btn-border"] = `${tokens.borderWidth} solid ${tokens.border}`;
239
+ } else {
240
+ vars["--nb-btn-bg"] = "transparent";
241
+ vars["--nb-btn-bg-hover"] = tokens.bgSubtle;
242
+ vars["--nb-btn-fg"] = tokens.fg;
243
+ }
244
+ const btnStyle = {
245
+ ...vars,
246
+ padding: SIZE_PAD[size],
247
+ fontSize: size === "sm" ? tokens.textSmSize : tokens.textBaseSize,
248
+ lineHeight: size === "sm" ? tokens.textSmLine : tokens.textBaseLine,
249
+ ...style
250
+ };
251
+ return /* @__PURE__ */ jsx("button", { type: "button", className: `nb-btn ${className ?? ""}`.trim(), style: btnStyle, ...rest, children });
252
+ }
253
+ function TextLink({ tone = "muted", style, className, children, ...rest }) {
254
+ ensureStyle(STYLE_ID, RULES);
255
+ const resting = tone === "danger" ? tokens.danger : tone === "default" ? tokens.fg : tokens.fgMuted;
256
+ const hover = tone === "danger" ? tokens.danger : tokens.accent;
257
+ const linkStyle = {
258
+ "--nb-tl-font": tokens.fontSans,
259
+ "--nb-tl-fg": resting,
260
+ "--nb-tl-fg-hover": hover,
261
+ fontSize: tokens.textXsSize,
262
+ lineHeight: tokens.textXsLine,
263
+ letterSpacing: "0.02em",
264
+ ...style
265
+ };
266
+ return /* @__PURE__ */ jsx(
267
+ "button",
268
+ {
269
+ type: "button",
270
+ className: `nb-textlink ${className ?? ""}`.trim(),
271
+ style: linkStyle,
272
+ ...rest,
273
+ children
274
+ }
275
+ );
276
+ }
277
+ var STYLE_ID2 = "nb-synapse-card";
278
+ var RULES2 = `
279
+ .nb-card--interactive {
280
+ cursor: pointer;
281
+ transition: box-shadow 140ms ease, border-color 140ms ease;
282
+ }
283
+ .nb-card--interactive:hover {
284
+ box-shadow: var(--nb-card-shadow-hover);
285
+ border-color: var(--nb-card-border-hover);
286
+ }
287
+ `;
288
+ function Card({
289
+ padding = "0.875rem",
290
+ interactive = false,
291
+ style,
292
+ className,
293
+ children,
294
+ ...rest
295
+ }) {
296
+ if (interactive) ensureStyle(STYLE_ID2, RULES2);
297
+ const cardStyle = {
298
+ background: tokens.bgRaised,
299
+ border: `${tokens.borderWidth} solid ${tokens.border}`,
300
+ borderRadius: tokens.radiusMd,
301
+ padding,
302
+ boxShadow: tokens.shadowSm,
303
+ "--nb-card-shadow-hover": tokens.shadowMd,
304
+ "--nb-card-border-hover": tokens.borderStrong,
305
+ ...style
306
+ };
307
+ return /* @__PURE__ */ jsx(
308
+ "div",
309
+ {
310
+ className: interactive ? `nb-card--interactive ${className ?? ""}`.trim() : className,
311
+ style: cardStyle,
312
+ ...rest,
313
+ children
314
+ }
315
+ );
316
+ }
317
+ var STYLE_ID3 = "nb-synapse-drawer";
318
+ var RULES3 = `
319
+ .nb-drawer {
320
+ margin: 0; padding: 0; border: none; max-width: 92%;
321
+ height: 100%; max-height: 100%; display: flex; flex-direction: column;
322
+ }
323
+ .nb-drawer--right { margin-left: auto; }
324
+ .nb-drawer--left { margin-right: auto; }
325
+ .nb-drawer--bottom {
326
+ margin-top: auto; width: 100%; max-width: 100%;
327
+ height: auto; max-height: 92%;
328
+ }
329
+ .nb-drawer--right[open] { animation: nb-drawer-in-right 240ms cubic-bezier(0.2, 0, 0, 1); }
330
+ .nb-drawer--left[open] { animation: nb-drawer-in-left 240ms cubic-bezier(0.2, 0, 0, 1); }
331
+ .nb-drawer--bottom[open] { animation: nb-drawer-in-bottom 240ms cubic-bezier(0.2, 0, 0, 1); }
332
+ .nb-drawer::backdrop { background: rgba(0, 0, 0, 0.32); }
333
+ .nb-drawer[open]::backdrop { animation: nb-drawer-fade 200ms ease; }
334
+ @keyframes nb-drawer-in-right { from { transform: translateX(100%); } }
335
+ @keyframes nb-drawer-in-left { from { transform: translateX(-100%); } }
336
+ @keyframes nb-drawer-in-bottom { from { transform: translateY(100%); } }
337
+ @keyframes nb-drawer-fade { from { opacity: 0; } }
338
+ .nb-drawer-iconbtn { width: 28px; height: 28px; }
339
+ @media (pointer: coarse) {
340
+ .nb-drawer-iconbtn { min-width: 44px; min-height: 44px; }
341
+ }
342
+ `;
343
+ var DrawerContext = createContext(null);
344
+ function DrawerRoot({
345
+ open,
346
+ onClose,
347
+ onEscape,
348
+ side = "right",
349
+ width = 480,
350
+ style,
351
+ children,
352
+ ...rest
353
+ }) {
354
+ ensureStyle(STYLE_ID3, RULES3);
355
+ const dialogRef = useRef(null);
356
+ const labelId = useId();
357
+ const [hasTitle, setHasTitle] = useState(false);
358
+ useEffect(() => {
359
+ const dialog = dialogRef.current;
360
+ if (!dialog || typeof dialog.showModal !== "function") return;
361
+ if (open && !dialog.open) dialog.showModal();
362
+ else if (!open && dialog.open) dialog.close();
363
+ }, [open]);
364
+ const isBottom = side === "bottom";
365
+ const panelStyle = {
366
+ ...isBottom ? { width: "100%", maxWidth: "100%" } : { width },
367
+ background: tokens.bg,
368
+ color: tokens.fg,
369
+ boxShadow: tokens.shadowLg,
370
+ ...side === "right" ? { borderLeft: `${tokens.borderWidth} solid ${tokens.border}` } : side === "left" ? { borderRight: `${tokens.borderWidth} solid ${tokens.border}` } : { borderTop: `${tokens.borderWidth} solid ${tokens.border}` },
371
+ ...style
372
+ };
373
+ const ctxValue = useMemo(() => ({ labelId, setHasTitle }), [labelId]);
374
+ return /* @__PURE__ */ jsx(DrawerContext.Provider, { value: ctxValue, children: /* @__PURE__ */ jsx(
375
+ "dialog",
376
+ {
377
+ ref: dialogRef,
378
+ className: `nb-drawer nb-drawer--${side}`,
379
+ style: panelStyle,
380
+ "aria-labelledby": hasTitle ? labelId : void 0,
381
+ onCancel: (e) => {
382
+ e.preventDefault();
383
+ (onEscape ?? onClose)();
384
+ },
385
+ onClick: (e) => {
386
+ if (e.target === dialogRef.current) onClose();
387
+ },
388
+ ...rest,
389
+ children
390
+ }
391
+ ) });
392
+ }
393
+ function Header({ title, onBack, actions, onClose, style, children, ...rest }) {
394
+ const ctx = useContext(DrawerContext);
395
+ const hasTitle = title != null;
396
+ useEffect(() => {
397
+ if (!ctx || !hasTitle) return;
398
+ ctx.setHasTitle(true);
399
+ return () => ctx.setHasTitle(false);
400
+ }, [ctx, hasTitle]);
401
+ return /* @__PURE__ */ jsxs(
402
+ "header",
403
+ {
404
+ style: {
405
+ flexShrink: 0,
406
+ display: "flex",
407
+ alignItems: "center",
408
+ gap: "0.75rem",
409
+ padding: "0.875rem 1rem",
410
+ borderBottom: `${tokens.borderWidth} solid ${tokens.border}`,
411
+ fontFamily: tokens.fontSans,
412
+ fontWeight: tokens.weightSemibold,
413
+ color: tokens.fg,
414
+ ...style
415
+ },
416
+ ...rest,
417
+ children: [
418
+ onBack ? /* @__PURE__ */ jsx(IconButton, { label: "Back", onClick: onBack, children: /* @__PURE__ */ jsx(
419
+ "path",
420
+ {
421
+ d: "M10 3L5 8l5 5",
422
+ stroke: "currentColor",
423
+ strokeWidth: "1.5",
424
+ fill: "none",
425
+ strokeLinecap: "round",
426
+ strokeLinejoin: "round"
427
+ }
428
+ ) }) : null,
429
+ hasTitle ? /* @__PURE__ */ jsx(
430
+ "h2",
431
+ {
432
+ id: ctx?.labelId,
433
+ style: {
434
+ flex: 1,
435
+ minWidth: 0,
436
+ margin: 0,
437
+ fontFamily: tokens.fontSans,
438
+ fontSize: tokens.textBaseSize,
439
+ lineHeight: tokens.textBaseLine,
440
+ fontWeight: tokens.weightSemibold,
441
+ color: tokens.fg,
442
+ whiteSpace: "nowrap",
443
+ overflow: "hidden",
444
+ textOverflow: "ellipsis"
445
+ },
446
+ children: title
447
+ }
448
+ ) : /* @__PURE__ */ jsx("div", { style: { flex: 1, minWidth: 0 }, children }),
449
+ actions ? /* @__PURE__ */ jsx("div", { style: { display: "flex", alignItems: "center", gap: "0.4rem", flexShrink: 0 }, children: actions }) : null,
450
+ onClose ? /* @__PURE__ */ jsx(IconButton, { label: "Close", onClick: onClose, children: /* @__PURE__ */ jsx(
451
+ "path",
452
+ {
453
+ d: "M4 4l8 8M12 4l-8 8",
454
+ stroke: "currentColor",
455
+ strokeWidth: "1.5",
456
+ strokeLinecap: "round"
457
+ }
458
+ ) }) : null
459
+ ]
460
+ }
461
+ );
462
+ }
463
+ function IconButton({
464
+ label,
465
+ onClick,
466
+ children
467
+ }) {
468
+ return /* @__PURE__ */ jsx(
469
+ "button",
470
+ {
471
+ type: "button",
472
+ "aria-label": label,
473
+ onClick,
474
+ className: "nb-drawer-iconbtn",
475
+ style: {
476
+ flexShrink: 0,
477
+ display: "inline-flex",
478
+ alignItems: "center",
479
+ justifyContent: "center",
480
+ border: "none",
481
+ background: "transparent",
482
+ color: tokens.fgMuted,
483
+ cursor: "pointer",
484
+ borderRadius: tokens.radiusSm
485
+ },
486
+ children: /* @__PURE__ */ jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", "aria-hidden": "true", children })
487
+ }
488
+ );
489
+ }
490
+ function Body({ style, children, ...rest }) {
491
+ return /* @__PURE__ */ jsx("div", { style: { flex: 1, minHeight: 0, overflowY: "auto", padding: "1rem", ...style }, ...rest, children });
492
+ }
493
+ function Footer({ style, children, ...rest }) {
494
+ return /* @__PURE__ */ jsx(
495
+ "footer",
496
+ {
497
+ style: {
498
+ flexShrink: 0,
499
+ padding: "0.75rem 1rem",
500
+ borderTop: `${tokens.borderWidth} solid ${tokens.border}`,
501
+ ...style
502
+ },
503
+ ...rest,
504
+ children
505
+ }
506
+ );
507
+ }
508
+ var Drawer = Object.assign(DrawerRoot, { Header, Body, Footer });
509
+ var ALIGN = {
510
+ start: "flex-start",
511
+ center: "center",
512
+ end: "flex-end",
513
+ stretch: "stretch",
514
+ baseline: "baseline"
515
+ };
516
+ var JUSTIFY = {
517
+ start: "flex-start",
518
+ center: "center",
519
+ end: "flex-end",
520
+ between: "space-between",
521
+ around: "space-around"
522
+ };
523
+ function flexStyle(direction, { gap, align, justify, wrap }) {
524
+ return {
525
+ display: "flex",
526
+ flexDirection: direction,
527
+ gap,
528
+ alignItems: align ? ALIGN[align] : void 0,
529
+ justifyContent: justify ? JUSTIFY[justify] : void 0,
530
+ flexWrap: wrap ? "wrap" : void 0
531
+ };
532
+ }
533
+ function Stack({ gap, align, justify, wrap, style, children, ...rest }) {
534
+ return /* @__PURE__ */ jsx("div", { style: { ...flexStyle("column", { gap, align, justify, wrap }), ...style }, ...rest, children });
535
+ }
536
+ function Inline({
537
+ gap,
538
+ align = "center",
539
+ justify,
540
+ wrap,
541
+ style,
542
+ children,
543
+ ...rest
544
+ }) {
545
+ return /* @__PURE__ */ jsx("div", { style: { ...flexStyle("row", { gap, align, justify, wrap }), ...style }, ...rest, children });
546
+ }
547
+ function Spacer({ style, ...rest }) {
548
+ return /* @__PURE__ */ jsx("div", { style: { flex: 1, ...style }, ...rest });
549
+ }
550
+ function Divider({ orientation = "horizontal", style, ...rest }) {
551
+ const isVertical = orientation === "vertical";
552
+ return /* @__PURE__ */ jsx(
553
+ "div",
554
+ {
555
+ "aria-hidden": "true",
556
+ style: {
557
+ flexShrink: 0,
558
+ background: tokens.border,
559
+ ...isVertical ? { width: tokens.borderWidth, alignSelf: "stretch" } : { height: tokens.borderWidth, width: "100%" },
560
+ ...style
561
+ },
562
+ ...rest
563
+ }
564
+ );
565
+ }
566
+ var TONE2 = {
567
+ default: tokens.fg,
568
+ muted: tokens.fgMuted,
569
+ faint: tokens.fgFaint,
570
+ accent: tokens.accent,
571
+ danger: tokens.danger,
572
+ success: tokens.success
573
+ };
574
+ var WEIGHT = {
575
+ normal: tokens.weightNormal,
576
+ medium: tokens.weightMedium,
577
+ semibold: tokens.weightSemibold,
578
+ bold: tokens.weightBold
579
+ };
580
+ function Text({
581
+ size = "base",
582
+ weight = "normal",
583
+ tone = "default",
584
+ mono = false,
585
+ truncate = false,
586
+ as: As = "span",
587
+ style,
588
+ children,
589
+ ...rest
590
+ }) {
591
+ const truncation = truncate ? { overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" } : {};
592
+ return /* @__PURE__ */ jsx(
593
+ As,
594
+ {
595
+ style: {
596
+ margin: 0,
597
+ fontFamily: mono ? tokens.fontMono : tokens.fontSans,
598
+ fontWeight: WEIGHT[weight],
599
+ color: TONE2[tone],
600
+ ...textStyle(size),
601
+ ...truncation,
602
+ ...style
603
+ },
604
+ ...rest,
605
+ children
606
+ }
607
+ );
608
+ }
609
+ function Heading({
610
+ size = "md",
611
+ weight = "semibold",
612
+ tone = "default",
613
+ as: As = "h2",
614
+ style,
615
+ children,
616
+ ...rest
617
+ }) {
618
+ return /* @__PURE__ */ jsx(
619
+ As,
620
+ {
621
+ style: {
622
+ margin: 0,
623
+ fontFamily: tokens.fontHeading,
624
+ fontWeight: WEIGHT[weight],
625
+ color: TONE2[tone],
626
+ letterSpacing: "-0.015em",
627
+ ...headingStyle(size),
628
+ ...style
629
+ },
630
+ ...rest,
631
+ children
632
+ }
633
+ );
634
+ }
635
+ function EmptyState({ icon, title, description, action, style, ...rest }) {
636
+ return /* @__PURE__ */ jsxs(
637
+ Stack,
638
+ {
639
+ align: "center",
640
+ gap: "0.5rem",
641
+ style: {
642
+ textAlign: "center",
643
+ padding: "4rem 1.5rem",
644
+ color: tokens.fgMuted,
645
+ ...style
646
+ },
647
+ ...rest,
648
+ children: [
649
+ icon ? /* @__PURE__ */ jsx("div", { style: { color: tokens.fgFaint, marginBottom: "0.25rem" }, children: icon }) : null,
650
+ title ? /* @__PURE__ */ jsx(Heading, { size: "sm", children: title }) : null,
651
+ description ? /* @__PURE__ */ jsx(Text, { size: "sm", tone: "muted", style: { maxWidth: 360 }, children: description }) : null,
652
+ action ? /* @__PURE__ */ jsx("div", { style: { marginTop: "0.75rem" }, children: action }) : null
653
+ ]
654
+ }
655
+ );
656
+ }
657
+ var STYLE_ID4 = "nb-synapse-listrow";
658
+ var RULES4 = `
659
+ .nb-listrow { transition: background 140ms ease; }
660
+ .nb-listrow--interactive { cursor: pointer; }
661
+ .nb-listrow--interactive:hover { background: var(--nb-listrow-hover); }
662
+ `;
663
+ function ListRow({
664
+ title,
665
+ meta,
666
+ leading,
667
+ trailing,
668
+ interactive = false,
669
+ style,
670
+ className,
671
+ ...rest
672
+ }) {
673
+ ensureStyle(STYLE_ID4, RULES4);
674
+ const rowStyle = {
675
+ "--nb-listrow-hover": tokens.bgSubtle,
676
+ display: "grid",
677
+ gridTemplateColumns: `${leading ? "auto " : ""}minmax(0, 1fr)${trailing ? " auto" : ""}`,
678
+ columnGap: "0.75rem",
679
+ alignItems: "baseline",
680
+ padding: "0.65rem 0.75rem",
681
+ borderRadius: tokens.radiusSm,
682
+ ...style
683
+ };
684
+ const interactiveProps = interactive ? {
685
+ role: "button",
686
+ tabIndex: 0,
687
+ onKeyDown: (e) => {
688
+ if (e.key === "Enter" || e.key === " ") {
689
+ e.preventDefault();
690
+ e.currentTarget.click();
691
+ }
692
+ }
693
+ } : {};
694
+ return /* @__PURE__ */ jsxs(
695
+ "div",
696
+ {
697
+ className: `nb-listrow ${interactive ? "nb-listrow--interactive" : ""} ${className ?? ""}`.trim(),
698
+ style: rowStyle,
699
+ ...interactiveProps,
700
+ ...rest,
701
+ children: [
702
+ leading ? /* @__PURE__ */ jsx("div", { style: { alignSelf: "center", display: "flex" }, children: leading }) : null,
703
+ /* @__PURE__ */ jsxs("div", { style: { minWidth: 0 }, children: [
704
+ /* @__PURE__ */ jsx(
705
+ "div",
706
+ {
707
+ style: {
708
+ fontFamily: tokens.fontSans,
709
+ fontSize: tokens.textBaseSize,
710
+ lineHeight: tokens.textBaseLine,
711
+ fontWeight: tokens.weightMedium,
712
+ color: tokens.fg,
713
+ overflow: "hidden",
714
+ textOverflow: "ellipsis",
715
+ whiteSpace: "nowrap"
716
+ },
717
+ children: title
718
+ }
719
+ ),
720
+ meta ? /* @__PURE__ */ jsx(
721
+ "div",
722
+ {
723
+ style: {
724
+ marginTop: "0.15rem",
725
+ fontFamily: tokens.fontSans,
726
+ fontSize: tokens.textXsSize,
727
+ lineHeight: tokens.textXsLine,
728
+ color: tokens.fgMuted,
729
+ overflow: "hidden",
730
+ textOverflow: "ellipsis",
731
+ whiteSpace: "nowrap"
732
+ },
733
+ children: meta
734
+ }
735
+ ) : null
736
+ ] }),
737
+ trailing ? /* @__PURE__ */ jsx(
738
+ "div",
739
+ {
740
+ style: {
741
+ alignSelf: "center",
742
+ display: "inline-flex",
743
+ alignItems: "center",
744
+ gap: "0.5rem",
745
+ fontSize: tokens.textXsSize,
746
+ color: tokens.fgMuted,
747
+ whiteSpace: "nowrap"
748
+ },
749
+ children: trailing
750
+ }
751
+ ) : null
752
+ ]
753
+ }
754
+ );
755
+ }
756
+ function Pagination({ page, pageCount, onChange, style, ...rest }) {
757
+ const total = Math.max(1, pageCount);
758
+ const atStart = page <= 1;
759
+ const atEnd = page >= total;
760
+ return /* @__PURE__ */ jsxs(
761
+ Inline,
762
+ {
763
+ justify: "between",
764
+ style: {
765
+ fontFamily: tokens.fontSans,
766
+ fontSize: tokens.textXsSize,
767
+ color: tokens.fgMuted,
768
+ letterSpacing: "0.02em",
769
+ ...style
770
+ },
771
+ ...rest,
772
+ children: [
773
+ /* @__PURE__ */ jsxs("span", { style: { fontVariantNumeric: "tabular-nums" }, children: [
774
+ "Page ",
775
+ page,
776
+ " of ",
777
+ total
778
+ ] }),
779
+ /* @__PURE__ */ jsxs(Inline, { gap: "1rem", children: [
780
+ /* @__PURE__ */ jsx(TextLink, { disabled: atStart, onClick: () => onChange(page - 1), children: "\u2190 Prev" }),
781
+ /* @__PURE__ */ jsx(TextLink, { disabled: atEnd, onClick: () => onChange(page + 1), children: "Next \u2192" })
782
+ ] })
783
+ ]
784
+ }
785
+ );
786
+ }
787
+ var STYLE_ID5 = "nb-synapse-prose";
788
+ var RULES5 = `
789
+ .nb-prose {
790
+ font-family: ${tokens.fontSans};
791
+ font-size: ${tokens.textBaseSize};
792
+ line-height: 1.7;
793
+ color: ${tokens.fg};
794
+ }
795
+ .nb-prose > :first-child { margin-top: 0; }
796
+ .nb-prose > :last-child { margin-bottom: 0; }
797
+ .nb-prose h1, .nb-prose h2 { font-family: ${tokens.fontHeading}; letter-spacing: -0.015em; color: ${tokens.fg}; }
798
+ .nb-prose h1 { font-size: ${tokens.headingMdSize}; line-height: ${tokens.headingMdLine}; margin: 2rem 0 0.75rem; }
799
+ .nb-prose h2 { font-size: ${tokens.headingSmSize}; line-height: ${tokens.headingSmLine}; margin: 1.75rem 0 0.5rem; }
800
+ .nb-prose h3 { font-size: ${tokens.textBaseSize}; font-weight: ${tokens.weightSemibold}; margin: 1.5rem 0 0.35rem; color: ${tokens.fg}; }
801
+ .nb-prose p { margin: 0 0 1rem; }
802
+ .nb-prose ul, .nb-prose ol { margin: 0 0 1rem; padding-left: 1.25rem; }
803
+ .nb-prose li { margin: 0.25rem 0; }
804
+ .nb-prose a { color: ${tokens.accent}; text-decoration: underline; text-underline-offset: 2px; }
805
+ .nb-prose blockquote { margin: 0 0 1rem; padding-left: 1rem; border-left: 2px solid ${tokens.accent}; color: ${tokens.fgMuted}; font-style: italic; }
806
+ .nb-prose code { font-family: ${tokens.fontMono}; font-size: 0.88em; padding: 0.08rem 0.32rem; border-radius: ${tokens.radiusXs}; background: ${tokens.bgSubtle}; }
807
+ .nb-prose pre { font-family: ${tokens.fontMono}; font-size: ${tokens.textSmSize}; line-height: 1.55; margin: 0 0 1.25rem; padding: 0.875rem 1rem; background: ${tokens.bgSubtle}; border-radius: ${tokens.radiusSm}; overflow-x: auto; }
808
+ .nb-prose pre code { padding: 0; background: none; }
809
+ .nb-prose hr { border: none; border-top: 1px solid ${tokens.border}; margin: 2rem 0; }
810
+ .nb-prose strong { font-weight: ${tokens.weightSemibold}; }
811
+ `;
812
+ function Prose({ html, children, className, ...rest }) {
813
+ ensureStyle(STYLE_ID5, RULES5);
814
+ const cls = `nb-prose ${className ?? ""}`.trim();
815
+ if (html !== void 0) {
816
+ return /* @__PURE__ */ jsx("div", { className: cls, dangerouslySetInnerHTML: { __html: html }, ...rest });
817
+ }
818
+ return /* @__PURE__ */ jsx("div", { className: cls, ...rest, children });
819
+ }
820
+ var STYLE_ID6 = "nb-synapse-searchfield";
821
+ var RULES6 = `
822
+ .nb-search { font-family: var(--nb-search-font); color: var(--nb-search-fg); outline: none; }
823
+ .nb-search::placeholder { color: var(--nb-search-placeholder); }
824
+ .nb-search--underline {
825
+ border: none;
826
+ border-bottom: 1px solid transparent;
827
+ background: transparent;
828
+ padding: 0.3rem 0.1rem;
829
+ transition: border-color 160ms ease;
830
+ }
831
+ .nb-search--underline:focus { border-bottom-color: var(--nb-search-accent); }
832
+ .nb-search--boxed {
833
+ border: 1px solid var(--nb-search-border);
834
+ border-radius: var(--nb-search-radius);
835
+ background: var(--nb-search-bg);
836
+ padding: 0.4rem 0.6rem;
837
+ transition: border-color 160ms ease, box-shadow 160ms ease;
838
+ }
839
+ .nb-search--boxed:focus {
840
+ border-color: var(--nb-search-accent);
841
+ box-shadow: 0 0 0 3px color-mix(in oklab, var(--nb-search-accent) 18%, transparent);
842
+ }
843
+ `;
844
+ function SearchField({
845
+ variant = "underline",
846
+ style,
847
+ className,
848
+ type = "search",
849
+ ...rest
850
+ }) {
851
+ ensureStyle(STYLE_ID6, RULES6);
852
+ const fieldStyle = {
853
+ "--nb-search-font": tokens.fontSans,
854
+ "--nb-search-fg": tokens.fg,
855
+ "--nb-search-placeholder": tokens.fgFaint,
856
+ "--nb-search-accent": tokens.accent,
857
+ "--nb-search-border": tokens.border,
858
+ "--nb-search-bg": tokens.bgSubtle,
859
+ "--nb-search-radius": tokens.radiusSm,
860
+ fontSize: tokens.textSmSize,
861
+ lineHeight: tokens.textSmLine,
862
+ ...style
863
+ };
864
+ return /* @__PURE__ */ jsx(
865
+ "input",
866
+ {
867
+ type,
868
+ className: `nb-search nb-search--${variant} ${className ?? ""}`.trim(),
869
+ style: fieldStyle,
870
+ ...rest
871
+ }
872
+ );
873
+ }
874
+ var STYLE_ID7 = "nb-synapse-segmented";
875
+ var RULES7 = `
876
+ .nb-seg {
877
+ display: inline-flex;
878
+ gap: 2px;
879
+ padding: 2px;
880
+ border-radius: var(--nb-seg-radius);
881
+ background: var(--nb-seg-track);
882
+ }
883
+ .nb-seg__btn {
884
+ border: none;
885
+ background: transparent;
886
+ color: var(--nb-seg-fg);
887
+ font-family: var(--nb-seg-font);
888
+ font-weight: var(--nb-seg-weight);
889
+ padding: 0.25rem 0.7rem;
890
+ border-radius: calc(var(--nb-seg-radius) - 2px);
891
+ cursor: pointer;
892
+ transition: color 130ms ease, background 130ms ease;
893
+ white-space: nowrap;
894
+ }
895
+ .nb-seg__btn:hover:not([aria-pressed="true"]) { color: var(--nb-seg-fg-strong); }
896
+ .nb-seg__btn[aria-pressed="true"] {
897
+ background: var(--nb-seg-active-bg);
898
+ color: var(--nb-seg-fg-strong);
899
+ box-shadow: var(--nb-seg-active-shadow);
900
+ }
901
+ `;
902
+ function SegmentedControl({
903
+ options,
904
+ value,
905
+ onChange,
906
+ style,
907
+ className,
908
+ ...rest
909
+ }) {
910
+ ensureStyle(STYLE_ID7, RULES7);
911
+ const trackStyle = {
912
+ "--nb-seg-radius": tokens.radiusSm,
913
+ "--nb-seg-track": tokens.bgSubtle,
914
+ "--nb-seg-fg": tokens.fgMuted,
915
+ "--nb-seg-fg-strong": tokens.fg,
916
+ "--nb-seg-font": tokens.fontSans,
917
+ "--nb-seg-weight": tokens.weightMedium,
918
+ "--nb-seg-active-bg": tokens.bgRaised,
919
+ "--nb-seg-active-shadow": tokens.shadowSm,
920
+ fontSize: tokens.textSmSize,
921
+ lineHeight: tokens.textSmLine,
922
+ ...style
923
+ };
924
+ return (
925
+ // biome-ignore lint/a11y/useSemanticElements: role="group" with aria-label is the correct grouping for a set of toggle buttons; <fieldset> would impose form semantics this control doesn't have.
926
+ /* @__PURE__ */ jsx("div", { className: `nb-seg ${className ?? ""}`.trim(), role: "group", style: trackStyle, ...rest, children: options.map((opt) => /* @__PURE__ */ jsx(
927
+ "button",
928
+ {
929
+ type: "button",
930
+ className: "nb-seg__btn",
931
+ "aria-pressed": opt.value === value,
932
+ onClick: () => onChange(opt.value),
933
+ children: opt.label
934
+ },
935
+ opt.value
936
+ )) })
937
+ );
938
+ }
939
+ var STYLE_ID8 = "nb-synapse-spinner";
940
+ var RULES8 = `
941
+ @keyframes nb-spin { to { transform: rotate(360deg); } }
942
+ .nb-spinner { animation: nb-spin 0.7s linear infinite; }
943
+ @media (prefers-reduced-motion: reduce) { .nb-spinner { animation-duration: 1.6s; } }
944
+ `;
945
+ function Spinner({ size = 16, color, style, className, ...rest }) {
946
+ ensureStyle(STYLE_ID8, RULES8);
947
+ const spinnerStyle = {
948
+ display: "inline-block",
949
+ flexShrink: 0,
950
+ width: size,
951
+ height: size,
952
+ borderRadius: "50%",
953
+ border: `2px solid ${tokens.border}`,
954
+ borderTopColor: color ?? tokens.accent,
955
+ boxSizing: "border-box",
956
+ ...style
957
+ };
958
+ return /* @__PURE__ */ jsx(
959
+ "span",
960
+ {
961
+ className: `nb-spinner ${className ?? ""}`.trim(),
962
+ role: "status",
963
+ "aria-label": "Loading",
964
+ style: spinnerStyle,
965
+ ...rest
966
+ }
967
+ );
968
+ }
969
+ var COLOR = {
970
+ working: tokens.accent,
971
+ completed: tokens.success,
972
+ failed: tokens.danger,
973
+ idle: tokens.fgFaint
974
+ };
975
+ var STYLE_ID9 = "nb-synapse-statusdot";
976
+ var KEYFRAMES = `
977
+ @keyframes nb-statusdot-pulse {
978
+ 0% { box-shadow: 0 0 0 0 var(--nb-statusdot-ring); transform: scale(1); }
979
+ 70% { box-shadow: 0 0 0 7px transparent; transform: scale(1.15); }
980
+ 100% { box-shadow: 0 0 0 0 transparent; transform: scale(1); }
981
+ }
982
+ .nb-statusdot--working {
983
+ animation: nb-statusdot-pulse 1.6s cubic-bezier(0.4, 0, 0.6, 1) infinite;
984
+ }
985
+ @media (prefers-reduced-motion: reduce) {
986
+ .nb-statusdot--working { animation: none; box-shadow: 0 0 0 2px var(--nb-statusdot-ring); }
987
+ }
988
+ `;
989
+ function StatusDot({
990
+ status = "idle",
991
+ color,
992
+ size = 8,
993
+ style,
994
+ className,
995
+ ...rest
996
+ }) {
997
+ ensureStyle(STYLE_ID9, KEYFRAMES);
998
+ const dotColor = color ?? COLOR[status];
999
+ const working = status === "working";
1000
+ const dotStyle = {
1001
+ display: "inline-block",
1002
+ flexShrink: 0,
1003
+ width: size,
1004
+ height: size,
1005
+ borderRadius: "50%",
1006
+ background: dotColor,
1007
+ // Ring color for the pulse keyframe — a faded copy of the dot color.
1008
+ "--nb-statusdot-ring": `color-mix(in oklab, ${dotColor} 45%, transparent)`,
1009
+ ...style
1010
+ };
1011
+ return /* @__PURE__ */ jsx(
1012
+ "span",
1013
+ {
1014
+ className: working ? `nb-statusdot--working ${className ?? ""}`.trim() : className,
1015
+ style: dotStyle,
1016
+ ...rest
1017
+ }
1018
+ );
1019
+ }
1020
+ var STYLE_ID10 = "nb-synapse-table";
1021
+ var RULES9 = `
1022
+ .nb-table { width: 100%; border-collapse: collapse; font-family: var(--nb-table-font); }
1023
+ .nb-table th, .nb-table td {
1024
+ padding: 0.55rem 0.75rem;
1025
+ border-bottom: var(--nb-table-border);
1026
+ font-size: var(--nb-table-size); line-height: var(--nb-table-line);
1027
+ }
1028
+ .nb-table thead th {
1029
+ position: sticky; top: 0; z-index: 1;
1030
+ background: var(--nb-table-head-bg);
1031
+ color: var(--nb-table-muted);
1032
+ font-weight: var(--nb-table-semibold);
1033
+ font-size: var(--nb-table-xs); text-align: left;
1034
+ text-transform: uppercase; letter-spacing: 0.04em;
1035
+ }
1036
+ .nb-table tbody td { color: var(--nb-table-fg); }
1037
+ .nb-table tbody tr.nb-table__row--clickable { cursor: pointer; }
1038
+ .nb-table tbody tr.nb-table__row--clickable:hover { background: var(--nb-table-hover); }
1039
+ `;
1040
+ function Table({
1041
+ data,
1042
+ columns,
1043
+ rowKey,
1044
+ onRowClick,
1045
+ empty,
1046
+ style,
1047
+ className,
1048
+ ...rest
1049
+ }) {
1050
+ ensureStyle(STYLE_ID10, RULES9);
1051
+ const vars = {
1052
+ "--nb-table-font": tokens.fontSans,
1053
+ "--nb-table-fg": tokens.fg,
1054
+ "--nb-table-muted": tokens.fgMuted,
1055
+ "--nb-table-head-bg": tokens.bg,
1056
+ "--nb-table-hover": tokens.bgSubtle,
1057
+ "--nb-table-border": `${tokens.borderWidth} solid ${tokens.border}`,
1058
+ "--nb-table-size": tokens.textSmSize,
1059
+ "--nb-table-line": tokens.textSmLine,
1060
+ "--nb-table-xs": tokens.textXsSize,
1061
+ "--nb-table-semibold": tokens.weightSemibold
1062
+ };
1063
+ if (data.length === 0 && empty !== void 0) {
1064
+ return /* @__PURE__ */ jsx(Fragment, { children: empty });
1065
+ }
1066
+ const tableStyle = { ...vars, ...style };
1067
+ return /* @__PURE__ */ jsxs("table", { className: `nb-table ${className ?? ""}`.trim(), style: tableStyle, ...rest, children: [
1068
+ /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsx("tr", { children: columns.map((col) => /* @__PURE__ */ jsx(
1069
+ "th",
1070
+ {
1071
+ scope: "col",
1072
+ style: { width: col.width, textAlign: col.align ?? "left" },
1073
+ children: col.header
1074
+ },
1075
+ col.key
1076
+ )) }) }),
1077
+ /* @__PURE__ */ jsx("tbody", { children: data.map((row, i) => {
1078
+ const clickable = Boolean(onRowClick);
1079
+ return /* @__PURE__ */ jsx(
1080
+ "tr",
1081
+ {
1082
+ className: clickable ? "nb-table__row--clickable" : void 0,
1083
+ tabIndex: clickable ? 0 : void 0,
1084
+ onClick: clickable ? () => onRowClick?.(row, i) : void 0,
1085
+ onKeyDown: clickable ? (e) => {
1086
+ if (e.key === "Enter" || e.key === " ") {
1087
+ e.preventDefault();
1088
+ onRowClick?.(row, i);
1089
+ }
1090
+ } : void 0,
1091
+ children: columns.map((col) => /* @__PURE__ */ jsx("td", { style: { textAlign: col.align ?? "left" }, children: col.render(row, i) }, col.key))
1092
+ },
1093
+ rowKey(row, i)
1094
+ );
1095
+ }) })
1096
+ ] });
1097
+ }
1098
+ var READING_MAX = 760;
1099
+ var ContentWidthCtx = createContext("full");
1100
+ function columnStyle(width) {
1101
+ return width === "reading" ? { maxWidth: READING_MAX, marginInline: "auto", width: "100%" } : {};
1102
+ }
1103
+ function AppFrameRoot({ contentWidth = "full", style, children, ...rest }) {
1104
+ return /* @__PURE__ */ jsx(ContentWidthCtx.Provider, { value: contentWidth, children: /* @__PURE__ */ jsx(
1105
+ "div",
1106
+ {
1107
+ style: {
1108
+ display: "flex",
1109
+ flexDirection: "column",
1110
+ height: "100%",
1111
+ minHeight: 0,
1112
+ background: tokens.bg,
1113
+ color: tokens.fg,
1114
+ fontFamily: tokens.fontSans,
1115
+ ...style
1116
+ },
1117
+ ...rest,
1118
+ children
1119
+ }
1120
+ ) });
1121
+ }
1122
+ function Header2({ style, children, ...rest }) {
1123
+ const width = useContext(ContentWidthCtx);
1124
+ return /* @__PURE__ */ jsx("header", { style: { flexShrink: 0, padding: "1.25rem 1.5rem 0.75rem", ...style }, ...rest, children: /* @__PURE__ */ jsx("div", { style: columnStyle(width), children }) });
1125
+ }
1126
+ function Body2({ bleed = false, style, children, ...rest }) {
1127
+ const width = useContext(ContentWidthCtx);
1128
+ if (bleed) {
1129
+ return /* @__PURE__ */ jsx(
1130
+ "div",
1131
+ {
1132
+ style: {
1133
+ flex: 1,
1134
+ minHeight: 0,
1135
+ display: "flex",
1136
+ flexDirection: "column",
1137
+ overflow: "hidden",
1138
+ ...style
1139
+ },
1140
+ ...rest,
1141
+ children
1142
+ }
1143
+ );
1144
+ }
1145
+ return /* @__PURE__ */ jsx("div", { style: { flex: 1, minHeight: 0, overflowY: "auto", ...style }, ...rest, children: /* @__PURE__ */ jsx("div", { style: { ...columnStyle(width), padding: "0.75rem 1.5rem 1.5rem" }, children }) });
1146
+ }
1147
+ function Footer2({ style, children, ...rest }) {
1148
+ const width = useContext(ContentWidthCtx);
1149
+ return /* @__PURE__ */ jsx(
1150
+ "footer",
1151
+ {
1152
+ style: {
1153
+ flexShrink: 0,
1154
+ padding: "0.75rem 1.5rem",
1155
+ borderTop: `${tokens.borderWidth} solid ${tokens.border}`,
1156
+ ...style
1157
+ },
1158
+ ...rest,
1159
+ children: /* @__PURE__ */ jsx("div", { style: columnStyle(width), children })
1160
+ }
1161
+ );
1162
+ }
1163
+ var AppFrame = Object.assign(AppFrameRoot, { Header: Header2, Body: Body2, Footer: Footer2 });
1164
+ function useBreakpoint(breakpoint) {
1165
+ const ref = useRef(null);
1166
+ const [width, setWidth] = useState(null);
1167
+ useLayoutEffect(() => {
1168
+ const el = ref.current;
1169
+ if (!el) return;
1170
+ setWidth(el.getBoundingClientRect().width);
1171
+ if (typeof ResizeObserver === "undefined") return;
1172
+ const ro = new ResizeObserver((entries) => {
1173
+ const entry = entries[0];
1174
+ const w = entry?.borderBoxSize?.[0]?.inlineSize ?? entry?.contentRect.width;
1175
+ if (typeof w === "number") setWidth(w);
1176
+ });
1177
+ ro.observe(el);
1178
+ return () => ro.disconnect();
1179
+ }, []);
1180
+ return { ref, isNarrow: width !== null && width < breakpoint };
1181
+ }
1182
+ var ListDetailCtx = createContext(null);
1183
+ function useListDetail() {
1184
+ const ctx = useContext(ListDetailCtx);
1185
+ if (!ctx) throw new Error("useListDetail must be used within <ListDetailLayout>");
1186
+ return ctx;
1187
+ }
1188
+ function ListDetailLayoutRoot({
1189
+ selected = false,
1190
+ onBack,
1191
+ listWidth = 320,
1192
+ breakpoint = 720,
1193
+ style,
1194
+ children,
1195
+ ...rest
1196
+ }) {
1197
+ const { ref, isNarrow } = useBreakpoint(breakpoint);
1198
+ return /* @__PURE__ */ jsx(ListDetailCtx.Provider, { value: { collapsed: isNarrow, selected, listWidth, onBack }, children: /* @__PURE__ */ jsx(
1199
+ "div",
1200
+ {
1201
+ ref,
1202
+ style: { display: "flex", flexDirection: "row", height: "100%", minHeight: 0, ...style },
1203
+ ...rest,
1204
+ children
1205
+ }
1206
+ ) });
1207
+ }
1208
+ function List({ style, children, ...rest }) {
1209
+ const { collapsed, selected, listWidth } = useListDetail();
1210
+ if (collapsed && selected) return null;
1211
+ const border = `${tokens.borderWidth} solid ${tokens.border}`;
1212
+ return /* @__PURE__ */ jsx(
1213
+ "section",
1214
+ {
1215
+ style: {
1216
+ overflowY: "auto",
1217
+ ...collapsed ? { flex: 1, minWidth: 0 } : { width: listWidth, flexShrink: 0, borderRight: border },
1218
+ ...style
1219
+ },
1220
+ ...rest,
1221
+ children
1222
+ }
1223
+ );
1224
+ }
1225
+ function Detail({ style, children, ...rest }) {
1226
+ const { collapsed, selected } = useListDetail();
1227
+ if (collapsed && !selected) return null;
1228
+ return /* @__PURE__ */ jsx("div", { style: { flex: 1, minWidth: 0, minHeight: 0, overflowY: "auto", ...style }, ...rest, children });
1229
+ }
1230
+ function Back({ children, style }) {
1231
+ const { collapsed, selected, onBack } = useListDetail();
1232
+ if (!collapsed || !selected) return null;
1233
+ return /* @__PURE__ */ jsx(TextLink, { onClick: () => onBack?.(), style: { marginBottom: "0.5rem", ...style }, children: children ?? "\u2190 Back" });
1234
+ }
1235
+ var ListDetailLayout = Object.assign(ListDetailLayoutRoot, { List, Detail, Back });
1236
+ var SidebarCtx = createContext(null);
1237
+ function useSidebar() {
1238
+ const ctx = useContext(SidebarCtx);
1239
+ if (!ctx) throw new Error("useSidebar must be used within <SidebarLayout>");
1240
+ return ctx;
1241
+ }
1242
+ var STYLE_ID11 = "nb-synapse-sidebarlayout";
1243
+ var RULES10 = `
1244
+ .nb-sidebar-drawer { transition: transform 220ms cubic-bezier(0.2, 0, 0, 1); }
1245
+ .nb-sidebar-scrim { animation: nb-sidebar-fade 180ms ease; }
1246
+ @keyframes nb-sidebar-fade { from { opacity: 0; } to { opacity: 1; } }
1247
+ @media (prefers-reduced-motion: reduce) {
1248
+ .nb-sidebar-drawer { transition: none; }
1249
+ .nb-sidebar-scrim { animation: none; }
1250
+ }
1251
+ `;
1252
+ function SidebarLayoutRoot({
1253
+ side = "left",
1254
+ width = 240,
1255
+ breakpoint = 640,
1256
+ collapseMode = "reflow",
1257
+ style,
1258
+ children,
1259
+ ...rest
1260
+ }) {
1261
+ const { ref, isNarrow } = useBreakpoint(breakpoint);
1262
+ const [open, setOpen] = useState(false);
1263
+ useEffect(() => {
1264
+ if (!open) return;
1265
+ const onKey = (e) => {
1266
+ if (e.key === "Escape") setOpen(false);
1267
+ };
1268
+ window.addEventListener("keydown", onKey);
1269
+ return () => window.removeEventListener("keydown", onKey);
1270
+ }, [open]);
1271
+ useEffect(() => {
1272
+ if (!isNarrow && open) setOpen(false);
1273
+ }, [isNarrow, open]);
1274
+ const reflowed = isNarrow && collapseMode === "reflow";
1275
+ const rootStyle = {
1276
+ position: "relative",
1277
+ display: "flex",
1278
+ flexDirection: reflowed ? "column" : side === "right" ? "row-reverse" : "row",
1279
+ height: "100%",
1280
+ minHeight: 0,
1281
+ ...style
1282
+ };
1283
+ return /* @__PURE__ */ jsx(
1284
+ SidebarCtx.Provider,
1285
+ {
1286
+ value: { collapsed: isNarrow, mode: collapseMode, side, width, open, setOpen },
1287
+ children: /* @__PURE__ */ jsx("div", { ref, style: rootStyle, ...rest, children })
1288
+ }
1289
+ );
1290
+ }
1291
+ function Sidebar({ style, children, ...rest }) {
1292
+ const { collapsed, mode, side, width, open, setOpen } = useSidebar();
1293
+ ensureStyle(STYLE_ID11, RULES10);
1294
+ if (!collapsed) {
1295
+ const border = `${tokens.borderWidth} solid ${tokens.border}`;
1296
+ return /* @__PURE__ */ jsx(
1297
+ "aside",
1298
+ {
1299
+ style: {
1300
+ width,
1301
+ flexShrink: 0,
1302
+ overflowY: "auto",
1303
+ display: "flex",
1304
+ flexDirection: "column",
1305
+ gap: "0.125rem",
1306
+ padding: "0.5rem 0.5rem",
1307
+ ...side === "right" ? { borderLeft: border } : { borderRight: border },
1308
+ ...style
1309
+ },
1310
+ ...rest,
1311
+ children
1312
+ }
1313
+ );
1314
+ }
1315
+ if (mode === "reflow") {
1316
+ return /* @__PURE__ */ jsx(
1317
+ "aside",
1318
+ {
1319
+ style: {
1320
+ display: "flex",
1321
+ flexDirection: "row",
1322
+ alignItems: "center",
1323
+ gap: "0.25rem",
1324
+ width: "100%",
1325
+ overflowX: "auto",
1326
+ padding: "0.5rem 0.75rem",
1327
+ borderBottom: `${tokens.borderWidth} solid ${tokens.border}`,
1328
+ ...style
1329
+ },
1330
+ ...rest,
1331
+ children
1332
+ }
1333
+ );
1334
+ }
1335
+ const closed = side === "right" ? "translateX(100%)" : "translateX(-100%)";
1336
+ const drawerStyle = {
1337
+ position: "absolute",
1338
+ top: 0,
1339
+ bottom: 0,
1340
+ [side]: 0,
1341
+ width,
1342
+ maxWidth: "85%",
1343
+ overflowY: "auto",
1344
+ background: tokens.bgRaised,
1345
+ boxShadow: tokens.shadowLg,
1346
+ transform: open ? "translateX(0)" : closed,
1347
+ zIndex: 11,
1348
+ ...side === "right" ? { borderLeft: `${tokens.borderWidth} solid ${tokens.border}` } : { borderRight: `${tokens.borderWidth} solid ${tokens.border}` },
1349
+ ...style
1350
+ };
1351
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
1352
+ open ? /* @__PURE__ */ jsx(
1353
+ "button",
1354
+ {
1355
+ type: "button",
1356
+ "aria-label": "Close sidebar",
1357
+ className: "nb-sidebar-scrim",
1358
+ onClick: () => setOpen(false),
1359
+ style: {
1360
+ position: "absolute",
1361
+ inset: 0,
1362
+ border: "none",
1363
+ padding: 0,
1364
+ cursor: "pointer",
1365
+ background: "rgba(0,0,0,0.32)",
1366
+ zIndex: 10
1367
+ }
1368
+ }
1369
+ ) : null,
1370
+ /* @__PURE__ */ jsx("aside", { className: "nb-sidebar-drawer", inert: !open, style: drawerStyle, ...rest, children })
1371
+ ] });
1372
+ }
1373
+ function Main({ style, children, ...rest }) {
1374
+ return /* @__PURE__ */ jsx("div", { style: { flex: 1, minWidth: 0, minHeight: 0, overflowY: "auto", ...style }, ...rest, children });
1375
+ }
1376
+ function Trigger({ children, style, onClick, ...rest }) {
1377
+ const ctx = useContext(SidebarCtx);
1378
+ if (!ctx?.collapsed || ctx.mode !== "drawer") return null;
1379
+ const { open, setOpen } = ctx;
1380
+ return /* @__PURE__ */ jsx(
1381
+ "button",
1382
+ {
1383
+ type: "button",
1384
+ "aria-label": "Toggle sidebar",
1385
+ "aria-expanded": open,
1386
+ onClick: (e) => {
1387
+ setOpen(!open);
1388
+ onClick?.(e);
1389
+ },
1390
+ style: {
1391
+ display: "inline-flex",
1392
+ alignItems: "center",
1393
+ justifyContent: "center",
1394
+ width: 32,
1395
+ height: 32,
1396
+ border: "none",
1397
+ background: "transparent",
1398
+ color: tokens.fg,
1399
+ cursor: "pointer",
1400
+ borderRadius: tokens.radiusSm,
1401
+ ...style
1402
+ },
1403
+ ...rest,
1404
+ children: children ?? /* @__PURE__ */ jsx("svg", { width: "18", height: "18", viewBox: "0 0 18 18", "aria-hidden": "true", children: /* @__PURE__ */ jsx(
1405
+ "path",
1406
+ {
1407
+ d: "M2 4.5h14M2 9h14M2 13.5h14",
1408
+ stroke: "currentColor",
1409
+ strokeWidth: "1.5",
1410
+ strokeLinecap: "round"
1411
+ }
1412
+ ) })
1413
+ }
1414
+ );
1415
+ }
1416
+ var SidebarLayout = Object.assign(SidebarLayoutRoot, { Sidebar, Main, Trigger });
1417
+
1418
+ export { AppFrame, Avatar, Badge, Button, Card, Divider, Drawer, EmptyState, Heading, Inline, ListDetailLayout, ListRow, Pagination, Prose, SearchField, SegmentedControl, SidebarLayout, Spacer, Spinner, Stack, StatusDot, Table, Text, TextLink, headingStyle, textStyle, tokens, useBreakpoint, useListDetail, useSidebar };
1419
+ //# sourceMappingURL=index.js.map
1420
+ //# sourceMappingURL=index.js.map