nish-ui 1.6.0 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1160,6 +1160,16 @@ var SettingsIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
1160
1160
  /* @__PURE__ */ jsx("path", { d: "M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z" }),
1161
1161
  /* @__PURE__ */ jsx("circle", { cx: "12", cy: "12", r: "3" })
1162
1162
  ] });
1163
+ var PanelLeftCloseIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
1164
+ /* @__PURE__ */ jsx("rect", { width: "18", height: "18", x: "3", y: "3", rx: "2" }),
1165
+ /* @__PURE__ */ jsx("path", { d: "M9 3v18" }),
1166
+ /* @__PURE__ */ jsx("path", { d: "m16 15-3-3 3-3" })
1167
+ ] });
1168
+ var PanelLeftOpenIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
1169
+ /* @__PURE__ */ jsx("rect", { width: "18", height: "18", x: "3", y: "3", rx: "2" }),
1170
+ /* @__PURE__ */ jsx("path", { d: "M9 3v18" }),
1171
+ /* @__PURE__ */ jsx("path", { d: "m14 9 3 3-3 3" })
1172
+ ] });
1163
1173
 
1164
1174
  // src/components/primitives.tsx
1165
1175
  import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
@@ -1870,7 +1880,7 @@ function ChipGroup({ label, scroll = false, className, children, ...rest }) {
1870
1880
  }
1871
1881
 
1872
1882
  // src/components/tabs.tsx
1873
- import { createContext as createContext2, useContext as useContext2, useEffect as useEffect8, useId as useId6, useRef as useRef6, useSyncExternalStore as useSyncExternalStore2 } from "react";
1883
+ import { createContext as createContext2, useContext as useContext2, useEffect as useEffect9, useId as useId6, useRef as useRef7, useSyncExternalStore as useSyncExternalStore2 } from "react";
1874
1884
 
1875
1885
  // src/components/layout-vars.ts
1876
1886
  import { useEffect as useEffect2, useState } from "react";
@@ -1964,19 +1974,18 @@ function useScrollEdges(ref) {
1964
1974
  // src/components/nav.tsx
1965
1975
  import {
1966
1976
  Fragment as Fragment4,
1967
- createElement,
1968
- useEffect as useEffect7,
1969
- useRef as useRef5,
1977
+ useEffect as useEffect8,
1978
+ useRef as useRef6,
1970
1979
  useState as useState6,
1971
1980
  useSyncExternalStore
1972
1981
  } from "react";
1973
1982
 
1974
1983
  // src/components/command.tsx
1975
1984
  import {
1976
- useEffect as useEffect4,
1985
+ useEffect as useEffect5,
1977
1986
  useId as useId4,
1978
1987
  useMemo,
1979
- useRef as useRef3,
1988
+ useRef as useRef4,
1980
1989
  useState as useState3
1981
1990
  } from "react";
1982
1991
 
@@ -1986,13 +1995,26 @@ import {
1986
1995
  createContext,
1987
1996
  useCallback as useCallback2,
1988
1997
  useContext,
1989
- useEffect as useEffect3,
1998
+ useEffect as useEffect4,
1990
1999
  useId as useId3,
1991
- useLayoutEffect as useLayoutEffect2,
1992
- useRef as useRef2,
2000
+ useLayoutEffect as useLayoutEffect3,
2001
+ useRef as useRef3,
1993
2002
  useState as useState2
1994
2003
  } from "react";
1995
2004
  import { createPortal } from "react-dom";
2005
+
2006
+ // src/components/latest.ts
2007
+ import { useEffect as useEffect3, useLayoutEffect as useLayoutEffect2, useRef as useRef2 } from "react";
2008
+ var useIsoLayoutEffect2 = typeof window === "undefined" ? useEffect3 : useLayoutEffect2;
2009
+ function useLatest(value) {
2010
+ const ref = useRef2(value);
2011
+ useIsoLayoutEffect2(() => {
2012
+ ref.current = value;
2013
+ });
2014
+ return ref;
2015
+ }
2016
+
2017
+ // src/components/overlay.tsx
1996
2018
  import { Fragment, jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
1997
2019
  var layerStack = [];
1998
2020
  var isTop = (self) => layerStack[layerStack.length - 1] === self;
@@ -2103,9 +2125,8 @@ if (typeof window !== "undefined") {
2103
2125
  }
2104
2126
  function useDialog(panelRef, onClose, closeOnBackProp = false) {
2105
2127
  const closeOnBack = closeOnBackProp && (typeof window === "undefined" || window.self === window.top);
2106
- const onCloseRef = useRef2(onClose);
2107
- onCloseRef.current = onClose;
2108
- useEffect3(() => {
2128
+ const onCloseRef = useLatest(onClose);
2129
+ useEffect4(() => {
2109
2130
  const opener = document.activeElement;
2110
2131
  const panel = panelRef.current;
2111
2132
  const self = {};
@@ -2191,17 +2212,15 @@ function useDialog(panelRef, onClose, closeOnBackProp = false) {
2191
2212
  history.back();
2192
2213
  }
2193
2214
  };
2194
- }, [panelRef, closeOnBack]);
2215
+ }, [panelRef, closeOnBack, onCloseRef]);
2195
2216
  }
2196
2217
  function useSheetExit(onClose, canClose) {
2197
2218
  const [closing, setClosing] = useState2(false);
2198
- const closingRef = useRef2(false);
2199
- const timer = useRef2(0);
2200
- const onCloseRef = useRef2(onClose);
2201
- onCloseRef.current = onClose;
2202
- const canCloseRef = useRef2(canClose);
2203
- canCloseRef.current = canClose;
2204
- useEffect3(() => () => window.clearTimeout(timer.current), []);
2219
+ const closingRef = useRef3(false);
2220
+ const timer = useRef3(0);
2221
+ const onCloseRef = useLatest(onClose);
2222
+ const canCloseRef = useLatest(canClose);
2223
+ useEffect4(() => () => window.clearTimeout(timer.current), []);
2205
2224
  const requestClose = useCallback2(() => {
2206
2225
  if (closingRef.current) return;
2207
2226
  if (closeVetoes.get(onCloseRef.current)?.()) return;
@@ -2217,24 +2236,21 @@ function useSheetExit(onClose, canClose) {
2217
2236
  closingRef.current = false;
2218
2237
  setClosing(false);
2219
2238
  }, SHEET_EXIT_MS);
2220
- }, []);
2239
+ }, [canCloseRef, onCloseRef]);
2221
2240
  const closeNow = useCallback2(() => {
2222
2241
  onCloseRef.current();
2223
- }, []);
2242
+ }, [onCloseRef]);
2224
2243
  const isClosing = useCallback2(() => closingRef.current, []);
2225
- const allowClose = useCallback2(() => !canCloseRef.current || canCloseRef.current(), []);
2244
+ const allowClose = useCallback2(() => !canCloseRef.current || canCloseRef.current(), [canCloseRef]);
2226
2245
  return { closing, requestClose, closeNow, isClosing, allowClose };
2227
2246
  }
2228
2247
  function useSheetSwipe(panelRef, scrimRef, enabled, onDismiss, allow = () => true) {
2229
- const drag = useRef2(null);
2230
- const timer = useRef2(0);
2231
- const enabledRef = useRef2(enabled);
2232
- enabledRef.current = enabled;
2233
- const dismissRef = useRef2(onDismiss);
2234
- dismissRef.current = onDismiss;
2235
- const allowRef = useRef2(allow);
2236
- allowRef.current = allow;
2237
- useEffect3(() => () => window.clearTimeout(timer.current), []);
2248
+ const drag = useRef3(null);
2249
+ const timer = useRef3(0);
2250
+ const enabledRef = useLatest(enabled);
2251
+ const dismissRef = useLatest(onDismiss);
2252
+ const allowRef = useLatest(allow);
2253
+ useEffect4(() => () => window.clearTimeout(timer.current), []);
2238
2254
  const onPointerDown = useCallback2(
2239
2255
  (e) => {
2240
2256
  if (drag.current || !enabledRef.current()) return;
@@ -2249,7 +2265,7 @@ function useSheetSwipe(panelRef, scrimRef, enabled, onDismiss, allow = () => tru
2249
2265
  if (scrimRef.current) scrimRef.current.style.transition = "none";
2250
2266
  drag.current = { startY: e.clientY, dy: 0, lastY: e.clientY, lastT: e.timeStamp, v: 0 };
2251
2267
  },
2252
- [panelRef, scrimRef]
2268
+ [enabledRef, panelRef, scrimRef]
2253
2269
  );
2254
2270
  const onPointerMove = useCallback2(
2255
2271
  (e) => {
@@ -2298,7 +2314,7 @@ function useSheetSwipe(panelRef, scrimRef, enabled, onDismiss, allow = () => tru
2298
2314
  }, ms);
2299
2315
  }
2300
2316
  },
2301
- [panelRef, scrimRef]
2317
+ [allowRef, dismissRef, panelRef, scrimRef]
2302
2318
  );
2303
2319
  return {
2304
2320
  onPointerDown,
@@ -2360,8 +2376,8 @@ function Modal({
2360
2376
  className
2361
2377
  }) {
2362
2378
  const titleId = useId3();
2363
- const panelRef = useRef2(null);
2364
- const scrimRef = useRef2(null);
2379
+ const panelRef = useRef3(null);
2380
+ const scrimRef = useRef3(null);
2365
2381
  const { closing, requestClose, closeNow, isClosing, allowClose } = useSheetExit(onClose, canClose);
2366
2382
  useDialog(panelRef, requestClose, closeOnBack);
2367
2383
  const swipe = useSheetSwipe(panelRef, scrimRef, () => dismissible && !isClosing() && isPhoneViewport(), closeNow, allowClose);
@@ -2451,8 +2467,8 @@ function Drawer({
2451
2467
  className
2452
2468
  }) {
2453
2469
  const titleId = useId3();
2454
- const panelRef = useRef2(null);
2455
- const scrimRef = useRef2(null);
2470
+ const panelRef = useRef3(null);
2471
+ const scrimRef = useRef3(null);
2456
2472
  const { closing, requestClose, closeNow, isClosing, allowClose } = useSheetExit(onClose, canClose);
2457
2473
  useDialog(panelRef, requestClose, closeOnBack);
2458
2474
  const bottom = side === "bottom";
@@ -2540,12 +2556,16 @@ function ConfirmDialog({
2540
2556
  onConfirm,
2541
2557
  onCancel
2542
2558
  }) {
2543
- const pendingRef = useRef2(pending);
2544
- pendingRef.current = pending;
2559
+ const pendingRef = useLatest(pending);
2545
2560
  const cancel = useCallback2(() => {
2546
2561
  if (!pendingRef.current) onCancel();
2547
- }, [onCancel]);
2548
- closeVetoes.set(cancel, () => pendingRef.current);
2562
+ }, [onCancel, pendingRef]);
2563
+ useEffect4(() => {
2564
+ closeVetoes.set(cancel, () => pendingRef.current);
2565
+ return () => {
2566
+ closeVetoes.delete(cancel);
2567
+ };
2568
+ }, [cancel, pendingRef]);
2549
2569
  const danger = tone === "danger";
2550
2570
  return /* @__PURE__ */ jsx4(
2551
2571
  Modal,
@@ -2603,7 +2623,7 @@ function place(r, w, h, side, align, gap) {
2603
2623
  }
2604
2624
  function useAnchoredPosition(anchor, floating, open, side, align, gap = GAP) {
2605
2625
  const [pos, setPos] = useState2(null);
2606
- useLayoutEffect2(() => {
2626
+ useLayoutEffect3(() => {
2607
2627
  if (!open) {
2608
2628
  setPos(null);
2609
2629
  return;
@@ -2660,10 +2680,10 @@ function touchTracker() {
2660
2680
  };
2661
2681
  }
2662
2682
  function Tooltip({ tip, children, className, side = "top", as = "span", focusable = true, variant = "default" }) {
2663
- const triggerRef = useRef2(null);
2683
+ const triggerRef = useRef3(null);
2664
2684
  const [open, setOpen] = useState2(false);
2665
2685
  const id = useId3();
2666
- useEffect3(() => {
2686
+ useEffect4(() => {
2667
2687
  const el = triggerRef.current;
2668
2688
  if (!el) return;
2669
2689
  const touch = touchTracker();
@@ -2721,7 +2741,7 @@ function FloatingTip({
2721
2741
  tip,
2722
2742
  side = "top"
2723
2743
  }) {
2724
- const tipRef = useRef2(null);
2744
+ const tipRef = useRef3(null);
2725
2745
  const pos = useAnchoredPosition(anchor, tipRef, true, side, "center");
2726
2746
  return createPortal(
2727
2747
  /* @__PURE__ */ jsx4(
@@ -2743,9 +2763,8 @@ function FloatingTip({
2743
2763
  );
2744
2764
  }
2745
2765
  function useDismiss(open, panel, anchor, close) {
2746
- const closeRef = useRef2(close);
2747
- closeRef.current = close;
2748
- useEffect3(() => {
2766
+ const closeRef = useLatest(close);
2767
+ useEffect4(() => {
2749
2768
  if (!open) return;
2750
2769
  const self = {};
2751
2770
  layerStack.push(self);
@@ -2768,12 +2787,12 @@ function useDismiss(open, panel, anchor, close) {
2768
2787
  document.removeEventListener("keydown", onKey);
2769
2788
  document.removeEventListener("pointerdown", onDown, true);
2770
2789
  };
2771
- }, [open, panel, anchor]);
2790
+ }, [open, panel, anchor, closeRef]);
2772
2791
  }
2773
2792
  function useReturnFocus(open, panel, anchor) {
2774
- const wasOpen = useRef2(false);
2775
- const focusWasInside = useRef2(false);
2776
- useEffect3(() => {
2793
+ const wasOpen = useRef3(false);
2794
+ const focusWasInside = useRef3(false);
2795
+ useEffect4(() => {
2777
2796
  if (!open) return;
2778
2797
  const p = panel.current;
2779
2798
  const track = () => {
@@ -2786,7 +2805,7 @@ function useReturnFocus(open, panel, anchor) {
2786
2805
  p?.removeEventListener("focusout", track);
2787
2806
  };
2788
2807
  }, [open, panel]);
2789
- useLayoutEffect2(() => {
2808
+ useLayoutEffect3(() => {
2790
2809
  if (open) {
2791
2810
  wasOpen.current = true;
2792
2811
  return;
@@ -2810,18 +2829,16 @@ function Popover({
2810
2829
  className,
2811
2830
  children
2812
2831
  }) {
2813
- const panelRef = useRef2(null);
2832
+ const panelRef = useRef3(null);
2814
2833
  const pos = useAnchoredPosition(anchor, panelRef, open, side, align);
2815
- const onOpenChangeRef = useRef2(onOpenChange);
2816
- onOpenChangeRef.current = onOpenChange;
2817
- const outsideRef = useRef2(dismissOnOutside);
2818
- outsideRef.current = dismissOnOutside;
2834
+ const onOpenChangeRef = useLatest(onOpenChange);
2835
+ const outsideRef = useLatest(dismissOnOutside);
2819
2836
  useDismiss(open, panelRef, anchor, (reason) => {
2820
2837
  if (reason === "outside" && !outsideRef.current) return;
2821
2838
  onOpenChangeRef.current(false, reason);
2822
2839
  });
2823
2840
  useReturnFocus(open, panelRef, anchor);
2824
- useEffect3(() => {
2841
+ useEffect4(() => {
2825
2842
  if (!open) return;
2826
2843
  const t = window.setTimeout(() => {
2827
2844
  const p = panelRef.current;
@@ -2874,7 +2891,7 @@ function setRef2(ref, value) {
2874
2891
  }
2875
2892
  function usePhoneViewport(enabled) {
2876
2893
  const [phone, setPhone] = useState2(() => enabled && isPhoneViewport());
2877
- useEffect3(() => {
2894
+ useEffect4(() => {
2878
2895
  if (!enabled || typeof window.matchMedia !== "function") {
2879
2896
  setPhone(false);
2880
2897
  return;
@@ -2887,6 +2904,9 @@ function usePhoneViewport(enabled) {
2887
2904
  }, [enabled]);
2888
2905
  return phone;
2889
2906
  }
2907
+ function Cloned({ element, ...props }) {
2908
+ return cloneElement2(element, props);
2909
+ }
2890
2910
  function DropdownMenu({
2891
2911
  trigger,
2892
2912
  align = "start",
@@ -2902,28 +2922,38 @@ function DropdownMenu({
2902
2922
  }) {
2903
2923
  const [openState, setOpenState] = useState2(defaultOpen);
2904
2924
  const open = openProp ?? openState;
2905
- const triggerRef = useRef2(null);
2906
- const menuRef = useRef2(null);
2925
+ const triggerRef = useRef3(null);
2926
+ const [triggerNode, setTriggerNode] = useState2(null);
2927
+ const triggerPropRef = trigger.props.ref;
2928
+ const attachTrigger = useCallback2(
2929
+ (node) => {
2930
+ triggerRef.current = node;
2931
+ setTriggerNode(node);
2932
+ setRef2(triggerPropRef, node);
2933
+ },
2934
+ [triggerPropRef]
2935
+ );
2936
+ const shown = open && triggerNode != null;
2937
+ const menuRef = useRef3(null);
2907
2938
  const menuId = useId3();
2908
2939
  const triggerId = useId3();
2909
- const initial = useRef2("first");
2940
+ const initial = useRef3("first");
2910
2941
  const asSheet = usePhoneViewport(sheetBelow === "sm");
2911
- const pos = useAnchoredPosition(triggerRef, menuRef, open && !asSheet, side, align, 4);
2912
- const onOpenChangeRef = useRef2(onOpenChange);
2913
- onOpenChangeRef.current = onOpenChange;
2942
+ const pos = useAnchoredPosition(triggerRef, menuRef, shown && !asSheet, side, align, 4);
2943
+ const onOpenChangeRef = useLatest(onOpenChange);
2914
2944
  const setOpen = useCallback2(
2915
2945
  (next, reason) => {
2916
2946
  if (openProp === void 0) setOpenState(next);
2917
2947
  onOpenChangeRef.current?.(next, reason);
2918
2948
  },
2919
- [openProp]
2949
+ [onOpenChangeRef, openProp]
2920
2950
  );
2921
2951
  const close = useCallback2(() => setOpen(false), [setOpen]);
2922
2952
  const dismiss = useCallback2((reason) => setOpen(false, reason), [setOpen]);
2923
- useDismiss(open && !asSheet, menuRef, triggerRef, dismiss);
2924
- useReturnFocus(open, menuRef, triggerRef);
2925
- useEffect3(() => {
2926
- if (!open) return;
2953
+ useDismiss(shown && !asSheet, menuRef, triggerRef, dismiss);
2954
+ useReturnFocus(shown, menuRef, triggerRef);
2955
+ useEffect4(() => {
2956
+ if (!shown) return;
2927
2957
  const menu = menuRef.current;
2928
2958
  if (!menu) return;
2929
2959
  const focusInitial = () => {
@@ -2943,7 +2973,7 @@ function DropdownMenu({
2943
2973
  window.clearTimeout(t);
2944
2974
  mo.disconnect();
2945
2975
  };
2946
- }, [open, asSheet]);
2976
+ }, [shown, asSheet]);
2947
2977
  function openWith(where) {
2948
2978
  initial.current = where;
2949
2979
  setOpen(true);
@@ -2981,30 +3011,31 @@ function DropdownMenu({
2981
3011
  }
2982
3012
  }
2983
3013
  const tp = trigger.props;
2984
- const triggerEl = cloneElement2(trigger, {
2985
- ref: (node) => {
2986
- triggerRef.current = node;
2987
- setRef2(tp.ref, node);
2988
- },
2989
- id: tp.id ?? triggerId,
2990
- "aria-haspopup": "menu",
2991
- "aria-expanded": open,
2992
- "aria-controls": open ? menuId : void 0,
2993
- onClick: (e) => {
2994
- tp.onClick?.(e);
2995
- if (e.defaultPrevented) return;
2996
- if (open) close();
2997
- else openWith(e.detail === 0 ? "first" : "menu");
2998
- },
2999
- onKeyDown: (e) => {
3000
- tp.onKeyDown?.(e);
3001
- if (e.defaultPrevented) return;
3002
- if (e.key === "ArrowDown" || e.key === "ArrowUp") {
3003
- e.preventDefault();
3004
- openWith(e.key === "ArrowDown" ? "first" : "last");
3014
+ const triggerEl = /* @__PURE__ */ jsx4(
3015
+ Cloned,
3016
+ {
3017
+ element: trigger,
3018
+ ref: attachTrigger,
3019
+ id: tp.id ?? triggerId,
3020
+ "aria-haspopup": "menu",
3021
+ "aria-expanded": open,
3022
+ "aria-controls": open ? menuId : void 0,
3023
+ onClick: (e) => {
3024
+ tp.onClick?.(e);
3025
+ if (e.defaultPrevented) return;
3026
+ if (open) close();
3027
+ else openWith(e.detail === 0 ? "first" : "menu");
3028
+ },
3029
+ onKeyDown: (e) => {
3030
+ tp.onKeyDown?.(e);
3031
+ if (e.defaultPrevented) return;
3032
+ if (e.key === "ArrowDown" || e.key === "ArrowUp") {
3033
+ e.preventDefault();
3034
+ openWith(e.key === "ArrowDown" ? "first" : "last");
3035
+ }
3005
3036
  }
3006
3037
  }
3007
- });
3038
+ );
3008
3039
  const menuProps = {
3009
3040
  ref: menuRef,
3010
3041
  id: menuId,
@@ -3027,7 +3058,7 @@ function DropdownMenu({
3027
3058
  ),
3028
3059
  children
3029
3060
  }
3030
- ) }) }) : open ? createPortal(
3061
+ ) }) }) : shown ? createPortal(
3031
3062
  /* @__PURE__ */ jsx4(MenuContext.Provider, { value: { close }, children: /* @__PURE__ */ jsx4(
3032
3063
  "div",
3033
3064
  {
@@ -3045,7 +3076,7 @@ function DropdownMenu({
3045
3076
  children
3046
3077
  }
3047
3078
  ) }),
3048
- layerHost(triggerRef.current)
3079
+ layerHost(triggerNode)
3049
3080
  ) : null
3050
3081
  ] });
3051
3082
  }
@@ -3253,9 +3284,8 @@ function isTypingTarget(t) {
3253
3284
  return tag === "INPUT" || tag === "TEXTAREA" || tag === "SELECT" || t.isContentEditable;
3254
3285
  }
3255
3286
  function useCommandHotkey(open, enabled = true) {
3256
- const ref = useRef3(open);
3257
- ref.current = open;
3258
- useEffect4(() => {
3287
+ const ref = useLatest(open);
3288
+ useEffect5(() => {
3259
3289
  if (!enabled) return;
3260
3290
  const onKey = (e) => {
3261
3291
  if (e.defaultPrevented || e.isComposing) return;
@@ -3269,7 +3299,7 @@ function useCommandHotkey(open, enabled = true) {
3269
3299
  };
3270
3300
  document.addEventListener("keydown", onKey);
3271
3301
  return () => document.removeEventListener("keydown", onKey);
3272
- }, [enabled]);
3302
+ }, [enabled, ref]);
3273
3303
  }
3274
3304
  function CommandPalette({
3275
3305
  open,
@@ -3303,16 +3333,15 @@ function PaletteDialog({ onClose, items: items2, placeholder, emptyText, onQuery
3303
3333
  const uid = useId4();
3304
3334
  const listId = `${uid}-list`;
3305
3335
  const optionId = (i) => `${uid}-opt-${i}`;
3306
- const inputRef = useRef3(null);
3307
- const listRef = useRef3(null);
3336
+ const inputRef = useRef4(null);
3337
+ const listRef = useRef4(null);
3308
3338
  const [query, setQuery] = useState3("");
3309
3339
  const [active, setActive] = useState3(0);
3310
3340
  const isFn = typeof items2 === "function";
3311
- const itemsRef = useRef3(items2);
3312
- itemsRef.current = items2;
3341
+ const itemsRef = useLatest(items2);
3313
3342
  const [dynamic, setDynamic] = useState3([]);
3314
3343
  const [pending, setPending] = useState3(isFn);
3315
- useEffect4(() => {
3344
+ useEffect5(() => {
3316
3345
  const fn = itemsRef.current;
3317
3346
  if (typeof fn !== "function") return;
3318
3347
  let stale = false;
@@ -3343,20 +3372,20 @@ function PaletteDialog({ onClose, items: items2, placeholder, emptyText, onQuery
3343
3372
  return () => {
3344
3373
  stale = true;
3345
3374
  };
3346
- }, [query, isFn]);
3375
+ }, [query, isFn, itemsRef]);
3347
3376
  const rows = useMemo(() => {
3348
3377
  if (isFn) return dynamic.map((item) => ({ item, marks: matchText(item.label.toLowerCase(), query.trim().toLowerCase())?.idx ?? [] }));
3349
3378
  return rankItems(items2, query);
3350
3379
  }, [isFn, dynamic, items2, query]);
3351
3380
  const groups = useMemo(() => groupRows(rows), [rows]);
3352
3381
  const flat = useMemo(() => groups.flatMap((g) => g.rows.map((x) => x.r.item)), [groups]);
3353
- useEffect4(() => {
3382
+ useEffect5(() => {
3354
3383
  inputRef.current?.focus();
3355
3384
  }, []);
3356
- useEffect4(() => {
3385
+ useEffect5(() => {
3357
3386
  setActive(0);
3358
3387
  }, [query, flat.length]);
3359
- useEffect4(() => {
3388
+ useEffect5(() => {
3360
3389
  document.getElementById(optionId(active))?.scrollIntoView({ block: "nearest" });
3361
3390
  }, [active]);
3362
3391
  const select = (item) => {
@@ -3489,10 +3518,10 @@ function PaletteDialog({ onClose, items: items2, placeholder, emptyText, onQuery
3489
3518
  }
3490
3519
 
3491
3520
  // src/components/theme-toggle.tsx
3492
- import { useEffect as useEffect6, useState as useState5 } from "react";
3521
+ import { useEffect as useEffect7, useState as useState5 } from "react";
3493
3522
 
3494
3523
  // src/components/segmented.tsx
3495
- import { useEffect as useEffect5, useId as useId5, useRef as useRef4, useState as useState4 } from "react";
3524
+ import { useEffect as useEffect6, useId as useId5, useRef as useRef5, useState as useState4 } from "react";
3496
3525
  import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
3497
3526
  var SELECTED = {
3498
3527
  accent: "bg-th-accent-soft text-th-accent ring-1 ring-th-accent/40",
@@ -3507,13 +3536,13 @@ var SIZE2 = {
3507
3536
  function Segmented({ label, options, value, onChange, size = "sm", block = false, overflow = "scroll", fullWidth = false, className }) {
3508
3537
  const fill = block || fullWidth;
3509
3538
  const scroll = overflow === "scroll";
3510
- const groupRef = useRef4(null);
3539
+ const groupRef = useRef5(null);
3511
3540
  useScrollEdges(groupRef);
3512
- const refs = useRef4([]);
3513
- const tipAnchor = useRef4(null);
3541
+ const refs = useRef5([]);
3542
+ const tipAnchor = useRef5(null);
3514
3543
  const [tipAt, setTipAt] = useState4(null);
3515
3544
  const tipId = useId5();
3516
- const touch = useRef4(touchTracker()).current;
3545
+ const [touch] = useState4(touchTracker);
3517
3546
  const showTip = (i) => {
3518
3547
  if (options[i]?.tip == null) return;
3519
3548
  tipAnchor.current = refs.current[i];
@@ -3522,7 +3551,7 @@ function Segmented({ label, options, value, onChange, size = "sm", block = false
3522
3551
  const hideTip = (i) => setTipAt((cur) => cur === i ? null : cur);
3523
3552
  const enabled = options.map((o, i) => o.disabled ? -1 : i).filter((i) => i >= 0);
3524
3553
  const selected = options.findIndex((o) => o.value === value);
3525
- useEffect5(() => {
3554
+ useEffect6(() => {
3526
3555
  const el = selected >= 0 ? refs.current[selected] : null;
3527
3556
  if (scroll && el && groupRef.current) revealInRow(groupRef.current, el);
3528
3557
  }, [selected, scroll, options.length]);
@@ -3626,7 +3655,7 @@ function useTheme() {
3626
3655
  const choice = typeof document === "undefined" ? "system" : getThemeChoice();
3627
3656
  return { choice, theme: typeof document === "undefined" ? "dark" : resolveTheme(choice) };
3628
3657
  });
3629
- useEffect6(() => onThemeChange((choice, theme) => setState({ choice, theme })), []);
3658
+ useEffect7(() => onThemeChange((choice, theme) => setState({ choice, theme })), []);
3630
3659
  return { ...state, scheme: schemeOf(state.theme), setChoice: setThemeChoice };
3631
3660
  }
3632
3661
  var MODES = [
@@ -3849,7 +3878,7 @@ function MoreDots() {
3849
3878
  ] });
3850
3879
  }
3851
3880
  function BottomNav({ items: items2, more, trailing, hideFrom = "md", label = "Sections", renderLink, className }) {
3852
- const ref = useRef5(null);
3881
+ const ref = useRef6(null);
3853
3882
  const visible = useMatches(MAX_QUERY[hideFrom]);
3854
3883
  useHeightVar(ref, "--nish-bottom-nav-h", visible);
3855
3884
  const pill = (active) => cn(
@@ -3974,6 +4003,47 @@ function NavRail({ items: items2, tools, footer, showFrom = "md", hideFrom = "lg
3974
4003
  }
3975
4004
  );
3976
4005
  }
4006
+ function NavSidebar({ items: items2, collapsed, onCollapsedChange, tools, footer, label = "Sections", renderLink, className }) {
4007
+ return /* @__PURE__ */ jsxs8(
4008
+ "aside",
4009
+ {
4010
+ "aria-label": "Sidebar",
4011
+ className: cn(
4012
+ "flex h-full shrink-0 flex-col border-r border-th-line bg-th-surface py-3 pl-[env(safe-area-inset-left)] transition-[width] duration-200 motion-reduce:transition-none",
4013
+ collapsed ? "w-16" : "w-56",
4014
+ className
4015
+ ),
4016
+ children: [
4017
+ tools ? /* @__PURE__ */ jsx8("div", { className: cn("mb-2 flex gap-1 border-b border-th-line pb-2", collapsed ? "flex-col items-center" : "flex-wrap px-3"), children: tools }) : null,
4018
+ /* @__PURE__ */ jsx8("nav", { "aria-label": label, className: cn("flex min-h-0 flex-1 flex-col gap-1 overflow-y-auto", collapsed ? "items-center px-2" : "px-3"), children: items2.map((item) => {
4019
+ const node = renderItem(
4020
+ item,
4021
+ cn(
4022
+ "flex min-h-11 items-center gap-3 rounded-lg border-l-2 text-sm transition-colors",
4023
+ FOCUS,
4024
+ collapsed ? "w-11 justify-center" : "w-full px-3",
4025
+ item.active ? "border-th-accent bg-th-accent-soft font-medium text-th-accent" : "border-transparent text-th-hi2 hover:bg-th-elevated hover:text-th-hi"
4026
+ ),
4027
+ /* @__PURE__ */ jsxs8(Fragment5, { children: [
4028
+ /* @__PURE__ */ jsxs8("span", { className: "relative inline-flex size-5 shrink-0 items-center justify-center [&>svg]:size-5", children: [
4029
+ item.icon,
4030
+ /* @__PURE__ */ jsx8(CountBadge, { value: item.badge })
4031
+ ] }),
4032
+ /* @__PURE__ */ jsx8("span", { className: collapsed ? "sr-only" : "min-w-0 truncate", children: item.label })
4033
+ ] }),
4034
+ renderLink
4035
+ );
4036
+ const tip = collapsed ? item.label : item.hint;
4037
+ return tip ? /* @__PURE__ */ jsx8(Tooltip, { tip, side: "right", focusable: false, className: collapsed ? "block" : "block w-full", children: node }, item.key) : /* @__PURE__ */ jsx8("span", { className: "block w-full", children: node }, item.key);
4038
+ }) }),
4039
+ /* @__PURE__ */ jsxs8("div", { className: cn("mt-3 flex gap-2 border-t border-th-line pt-3", collapsed ? "flex-col items-center" : "items-center justify-between px-3"), children: [
4040
+ footer,
4041
+ /* @__PURE__ */ jsx8(IconButton, { label: collapsed ? "Expand sidebar" : "Collapse sidebar", onClick: () => onCollapsedChange(!collapsed), children: collapsed ? /* @__PURE__ */ jsx8(PanelLeftOpenIcon, { size: 18 }) : /* @__PURE__ */ jsx8(PanelLeftCloseIcon, { size: 18 }) })
4042
+ ] })
4043
+ ]
4044
+ }
4045
+ );
4046
+ }
3977
4047
  function revealInRow(scroller, child) {
3978
4048
  const s = scroller.getBoundingClientRect();
3979
4049
  const c = child.getBoundingClientRect();
@@ -3983,18 +4053,19 @@ function revealInRow(scroller, child) {
3983
4053
  }
3984
4054
  var ACTIVE_SELECTOR = '[aria-pressed="true"],[aria-selected="true"],[aria-current]:not([aria-current="false"]),[aria-checked="true"]';
3985
4055
  function ScrollRow({ children, bleed = false, fade = true, snap = false, as = "div", label, className }) {
3986
- const ref = useRef5(null);
4056
+ const ref = useRef6(null);
3987
4057
  useScrollEdges(ref);
3988
- const lastActive = useRef5(null);
3989
- useEffect7(() => {
4058
+ const lastActive = useRef6(null);
4059
+ useEffect8(() => {
3990
4060
  const active = ref.current?.querySelector(ACTIVE_SELECTOR) ?? null;
3991
4061
  if (active && active !== lastActive.current) {
3992
4062
  revealInRow(ref.current, active);
3993
4063
  }
3994
4064
  lastActive.current = active;
3995
4065
  });
3996
- return createElement(
3997
- as,
4066
+ const Tag = as;
4067
+ return /* @__PURE__ */ jsx8(
4068
+ Tag,
3998
4069
  {
3999
4070
  ref,
4000
4071
  "aria-label": label,
@@ -4004,15 +4075,15 @@ function ScrollRow({ children, bleed = false, fade = true, snap = false, as = "d
4004
4075
  bleed && "-mx-[var(--nish-page-gutter)] px-[var(--nish-page-gutter)]",
4005
4076
  snap && "snap-x snap-mandatory [&>*]:snap-start",
4006
4077
  className
4007
- )
4008
- },
4009
- children
4078
+ ),
4079
+ children
4080
+ }
4010
4081
  );
4011
4082
  }
4012
4083
  function useScrollSpy(ids, { rootMargin = "-45% 0px -50% 0px" } = {}) {
4013
4084
  const [active, setActive] = useState6(ids[0] ?? null);
4014
4085
  const key = ids.join("\0");
4015
- useEffect7(() => {
4086
+ useEffect8(() => {
4016
4087
  const list = key ? key.split("\0") : [];
4017
4088
  setActive((cur) => cur != null && list.includes(cur) ? cur : list[0] ?? null);
4018
4089
  if (!list.length || typeof IntersectionObserver === "undefined") return;
@@ -4075,11 +4146,11 @@ function useScrollSpy(ids, { rootMargin = "-45% 0px -50% 0px" } = {}) {
4075
4146
  return active;
4076
4147
  }
4077
4148
  function SectionNav({ items: items2, sticky = true, onSelect, updateHash = true, label = "Sections", className }) {
4078
- const ref = useRef5(null);
4149
+ const ref = useRef6(null);
4079
4150
  const spy = useScrollSpy(items2.map((i) => i.id));
4080
4151
  const [locked, setLocked] = useState6(null);
4081
4152
  const active = locked ?? spy;
4082
- useEffect7(() => {
4153
+ useEffect8(() => {
4083
4154
  if (locked == null) return;
4084
4155
  const release = () => setLocked(null);
4085
4156
  const onKey = (e) => {
@@ -4181,9 +4252,9 @@ function useBreakpoint(bp) {
4181
4252
  );
4182
4253
  }
4183
4254
  function ScrollingList({ selected, children, ...rest }) {
4184
- const ref = useRef6(null);
4255
+ const ref = useRef7(null);
4185
4256
  useScrollEdges(ref);
4186
- useEffect8(() => {
4257
+ useEffect9(() => {
4187
4258
  const el = selected >= 0 ? ref.current?.children[selected] : null;
4188
4259
  if (el && ref.current) revealInRow(ref.current, el);
4189
4260
  }, [selected]);
@@ -4223,7 +4294,7 @@ function Tabs({
4223
4294
  const auto = useId6();
4224
4295
  const wide = useBreakpoint(hideFrom);
4225
4296
  const base = idBase ?? auto.replace(/:/g, "");
4226
- const refs = useRef6([]);
4297
+ const refs = useRef7([]);
4227
4298
  const enabled = items2.map((t, i) => t.disabled ? -1 : i).filter((i) => i >= 0);
4228
4299
  const selected = items2.findIndex((t) => t.value === value);
4229
4300
  const tabStop = selected >= 0 && !items2[selected].disabled ? selected : enabled[0] ?? -1;
@@ -4425,7 +4496,7 @@ function ErrorState({
4425
4496
  }
4426
4497
 
4427
4498
  // src/components/toast.tsx
4428
- import { useEffect as useEffect9, useRef as useRef7, useState as useState7, useSyncExternalStore as useSyncExternalStore3 } from "react";
4499
+ import { useEffect as useEffect10, useRef as useRef8, useState as useState7, useSyncExternalStore as useSyncExternalStore3 } from "react";
4429
4500
  import { createPortal as createPortal2 } from "react-dom";
4430
4501
  import { jsx as jsx11, jsxs as jsxs11 } from "react/jsx-runtime";
4431
4502
  var items = [];
@@ -4521,13 +4592,13 @@ function Toaster({ className, offset, offsetUntil = "md" }) {
4521
4592
  const list = useToasts();
4522
4593
  const [polite, setPolite] = useState7({ text: "", seq: 0 });
4523
4594
  const [assertive, setAssertive] = useState7({ text: "", seq: 0 });
4524
- const announced = useRef7(/* @__PURE__ */ new Set());
4525
- const timers2 = useRef7({
4595
+ const announced = useRef8(/* @__PURE__ */ new Set());
4596
+ const timers2 = useRef8({
4526
4597
  queue: { polite: [], assertive: [] },
4527
4598
  flush: {},
4528
4599
  clear: {}
4529
4600
  });
4530
- useEffect9(() => {
4601
+ useEffect10(() => {
4531
4602
  const t = timers2.current;
4532
4603
  for (const item of list) {
4533
4604
  if (announced.current.has(item.id)) continue;
@@ -4552,7 +4623,7 @@ function Toaster({ className, offset, offsetUntil = "md" }) {
4552
4623
  if (!live.has(id)) announced.current.delete(id);
4553
4624
  });
4554
4625
  }, [list]);
4555
- useEffect9(() => {
4626
+ useEffect10(() => {
4556
4627
  const t = timers2.current;
4557
4628
  return () => {
4558
4629
  clearTimeout(t.flush.polite);
@@ -4593,8 +4664,8 @@ var SWIPE_DISMISS_FRACTION = 0.35;
4593
4664
  var SWIPE_DISMISS_VELOCITY = 0.5;
4594
4665
  var SWIPE_SLOP = 8;
4595
4666
  function ToastCard({ t }) {
4596
- const ref = useRef7(null);
4597
- const drag = useRef7(null);
4667
+ const ref = useRef8(null);
4668
+ const drag = useRef8(null);
4598
4669
  const setOffset = (dx, width) => {
4599
4670
  const el = ref.current;
4600
4671
  if (!el) return;
@@ -4709,8 +4780,8 @@ function ToastCard({ t }) {
4709
4780
  import {
4710
4781
  createContext as createContext3,
4711
4782
  useContext as useContext3,
4712
- useEffect as useEffect10,
4713
- useRef as useRef8,
4783
+ useEffect as useEffect11,
4784
+ useRef as useRef9,
4714
4785
  useState as useState8
4715
4786
  } from "react";
4716
4787
  import { Fragment as Fragment6, jsx as jsx12, jsxs as jsxs12 } from "react/jsx-runtime";
@@ -5185,8 +5256,8 @@ function CopyButton({
5185
5256
  className
5186
5257
  }) {
5187
5258
  const [copied, setCopied] = useState8(false);
5188
- const timer = useRef8(null);
5189
- useEffect10(() => () => {
5259
+ const timer = useRef9(null);
5260
+ useEffect11(() => () => {
5190
5261
  if (timer.current) clearTimeout(timer.current);
5191
5262
  }, []);
5192
5263
  const onClick = async () => {
@@ -5215,7 +5286,7 @@ function PageHeader({
5215
5286
  collapseWhenStuck = true,
5216
5287
  className
5217
5288
  }) {
5218
- const ref = useRef8(null);
5289
+ const ref = useRef9(null);
5219
5290
  const stuck = useStuck(ref) && sticky;
5220
5291
  const collapsed = stuck && collapseWhenStuck;
5221
5292
  return /* @__PURE__ */ jsxs12(
@@ -5263,6 +5334,7 @@ function MoreVerticalIcon({ size = 18 }) {
5263
5334
  function AppHeader({
5264
5335
  name,
5265
5336
  icon,
5337
+ brand,
5266
5338
  hubHref = "https://nish.software",
5267
5339
  actions,
5268
5340
  nav,
@@ -5277,11 +5349,11 @@ function AppHeader({
5277
5349
  overflowActions,
5278
5350
  className
5279
5351
  }) {
5280
- const ref = useRef8(null);
5352
+ const ref = useRef9(null);
5281
5353
  useHeightVar(ref, "--nish-header-h", sticky);
5282
5354
  const stuck = useStuck(ref) && sticky;
5283
- const inlineActionsRef = useRef8(null);
5284
- useEffect10(() => {
5355
+ const inlineActionsRef = useRef9(null);
5356
+ useEffect11(() => {
5285
5357
  inlineActionsRef.current?.querySelectorAll('[role="menuitem"]').forEach((el) => {
5286
5358
  el.removeAttribute("role");
5287
5359
  el.tabIndex = el.getAttribute("aria-disabled") === "true" ? -1 : 0;
@@ -5329,7 +5401,10 @@ function AppHeader({
5329
5401
  ]
5330
5402
  }
5331
5403
  ),
5332
- homeHref != null ? /* @__PURE__ */ jsx12("a", { href: homeHref, className: cn(markClass, "min-h-11 min-w-11 rounded-lg", hideName && "max-sm:justify-center"), children: mark }) : /* @__PURE__ */ jsx12("span", { className: markClass, children: mark }),
5404
+ brand != null ? /* @__PURE__ */ jsxs12("div", { className: "flex min-w-0 items-center", children: [
5405
+ /* @__PURE__ */ jsx12("span", { className: "sr-only", children: name }),
5406
+ brand
5407
+ ] }) : homeHref != null ? /* @__PURE__ */ jsx12("a", { href: homeHref, className: cn(markClass, "min-h-11 min-w-11 rounded-lg", hideName && "max-sm:justify-center"), children: mark }) : /* @__PURE__ */ jsx12("span", { className: markClass, children: mark }),
5333
5408
  /* @__PURE__ */ jsxs12("div", { className: "ml-auto flex shrink-0 items-center gap-2", children: [
5334
5409
  actions,
5335
5410
  overflowActions ? /* @__PURE__ */ jsxs12(Fragment6, { children: [
@@ -5420,7 +5495,7 @@ function ChartLegend({ items: items2, marker = "line", label = "Legend", classNa
5420
5495
  import {
5421
5496
  createContext as createContext4,
5422
5497
  useContext as useContext4,
5423
- useRef as useRef9
5498
+ useRef as useRef10
5424
5499
  } from "react";
5425
5500
  import { jsx as jsx13, jsxs as jsxs13 } from "react/jsx-runtime";
5426
5501
  var ALIGN = { left: "text-left", center: "text-center", right: "text-right" };
@@ -5476,7 +5551,7 @@ function TableWrap({
5476
5551
  children,
5477
5552
  ...rest
5478
5553
  }) {
5479
- const ref = useRef9(null);
5554
+ const ref = useRef10(null);
5480
5555
  useScrollEdges(ref);
5481
5556
  const css = {
5482
5557
  // With a pinned first column the left fade would wash it out, so only the right edge fades.
@@ -5567,14 +5642,14 @@ function Tr({ tone, interactive = false, muted = false, className, ...rest }) {
5567
5642
  // src/components/layout.tsx
5568
5643
  import {
5569
5644
  useCallback as useCallback3,
5570
- useEffect as useEffect11,
5571
- useRef as useRef10,
5645
+ useEffect as useEffect12,
5646
+ useRef as useRef11,
5572
5647
  useState as useState9,
5573
5648
  useSyncExternalStore as useSyncExternalStore4
5574
5649
  } from "react";
5575
5650
  import { jsx as jsx14, jsxs as jsxs14 } from "react/jsx-runtime";
5576
5651
  function StickyBar({ children, top = "var(--nish-header-h, 0px)", elevate = true, as = "div", className }) {
5577
- const ref = useRef10(null);
5652
+ const ref = useRef11(null);
5578
5653
  const stuck = useStuck(ref);
5579
5654
  useHeightVar(ref, "--nish-sticky-extra");
5580
5655
  const Tag = as;
@@ -5593,7 +5668,7 @@ function StickyBar({ children, top = "var(--nish-header-h, 0px)", elevate = true
5593
5668
  );
5594
5669
  }
5595
5670
  function StickyActionBar({ open, message, primary, secondary, label = "Actions", className }) {
5596
- const ref = useRef10(null);
5671
+ const ref = useRef11(null);
5597
5672
  useHeightVar(ref, "--nish-bottom-bar-h", open);
5598
5673
  if (!open) return null;
5599
5674
  return /* @__PURE__ */ jsxs14(
@@ -5622,7 +5697,7 @@ function StickyActionBar({ open, message, primary, secondary, label = "Actions",
5622
5697
  }
5623
5698
  function LoadingBar({ active, delayMs = 200, top = "var(--nish-header-h, 0px)", className }) {
5624
5699
  const [shown, setShown] = useState9(false);
5625
- useEffect11(() => {
5700
+ useEffect12(() => {
5626
5701
  if (!active) {
5627
5702
  setShown(false);
5628
5703
  return;
@@ -5678,8 +5753,8 @@ function ConnectionBanner({
5678
5753
  const online = useOnline();
5679
5754
  const [reachable, setReachable] = useState9(true);
5680
5755
  const [retrying, setRetrying] = useState9(false);
5681
- const probeRef = useRef10(null);
5682
- useEffect11(() => {
5756
+ const probeRef = useRef11(null);
5757
+ useEffect12(() => {
5683
5758
  if (!healthUrl) {
5684
5759
  probeRef.current = null;
5685
5760
  setReachable(true);
@@ -5760,16 +5835,16 @@ function ConnectionBanner({
5760
5835
 
5761
5836
  // src/components/data.tsx
5762
5837
  import {
5763
- useEffect as useEffect13,
5838
+ useEffect as useEffect14,
5764
5839
  useId as useId7,
5765
- useLayoutEffect as useLayoutEffect3,
5840
+ useLayoutEffect as useLayoutEffect4,
5766
5841
  useMemo as useMemo2,
5767
- useRef as useRef12,
5842
+ useRef as useRef13,
5768
5843
  useState as useState11
5769
5844
  } from "react";
5770
5845
 
5771
5846
  // src/components/hooks.tsx
5772
- import { useCallback as useCallback4, useEffect as useEffect12, useRef as useRef11, useState as useState10, useSyncExternalStore as useSyncExternalStore5 } from "react";
5847
+ import { useCallback as useCallback4, useEffect as useEffect13, useRef as useRef12, useState as useState10, useSyncExternalStore as useSyncExternalStore5 } from "react";
5773
5848
 
5774
5849
  // src/format.ts
5775
5850
  var DASH = "\u2013";
@@ -5881,7 +5956,7 @@ function useBreakpoint2() {
5881
5956
  }
5882
5957
  function useDocumentTitle(title, o = {}) {
5883
5958
  const app = o.app;
5884
- useEffect12(() => {
5959
+ useEffect13(() => {
5885
5960
  if (typeof document === "undefined") return;
5886
5961
  const next = title && app ? `${title} \xB7 ${app}` : title || app;
5887
5962
  if (!next) return;
@@ -5894,7 +5969,7 @@ function useDocumentTitle(title, o = {}) {
5894
5969
  }
5895
5970
  function useNow(intervalMs = 3e4) {
5896
5971
  const [now, setNow] = useState10(() => Date.now());
5897
- useEffect12(() => {
5972
+ useEffect13(() => {
5898
5973
  if (typeof document === "undefined") return;
5899
5974
  let id;
5900
5975
  const start = () => {
@@ -5931,15 +6006,13 @@ function readStored(key, initial, raw) {
5931
6006
  }
5932
6007
  function useLocalStorage(key, initial, o = {}) {
5933
6008
  const raw = !!o.raw;
5934
- const initialRef = useRef11(initial);
5935
- initialRef.current = initial;
6009
+ const initialRef = useLatest(initial);
5936
6010
  const [value, setValueState] = useState10(
5937
6011
  () => typeof window === "undefined" ? initial : readStored(key, initial, raw)
5938
6012
  );
5939
- const valueRef = useRef11(value);
5940
- valueRef.current = value;
5941
- const instanceRef = useRef11({});
5942
- useEffect12(() => {
6013
+ const valueRef = useLatest(value);
6014
+ const instanceRef = useRef12({});
6015
+ useEffect13(() => {
5943
6016
  const sync = () => setValueState(readStored(key, initialRef.current, raw));
5944
6017
  sync();
5945
6018
  const onStorage = (e) => {
@@ -5955,7 +6028,7 @@ function useLocalStorage(key, initial, o = {}) {
5955
6028
  window.removeEventListener("storage", onStorage);
5956
6029
  window.removeEventListener(LOCAL_EVENT, onLocal);
5957
6030
  };
5958
- }, [key, raw]);
6031
+ }, [initialRef, key, raw]);
5959
6032
  const setValue = useCallback4(
5960
6033
  (next) => {
5961
6034
  const resolved = typeof next === "function" ? next(valueRef.current) : next;
@@ -5970,7 +6043,7 @@ function useLocalStorage(key, initial, o = {}) {
5970
6043
  } catch {
5971
6044
  }
5972
6045
  },
5973
- [key, raw]
6046
+ [key, raw, valueRef]
5974
6047
  );
5975
6048
  return [value, setValue];
5976
6049
  }
@@ -6263,7 +6336,7 @@ function Favicon({ url, size = 16, label, className }) {
6263
6336
  const host = hostnameOf(url);
6264
6337
  const [failed, setFailed] = useState11(false);
6265
6338
  const [loaded, setLoaded] = useState11(false);
6266
- useEffect13(() => {
6339
+ useEffect14(() => {
6267
6340
  setFailed(false);
6268
6341
  setLoaded(false);
6269
6342
  }, [host]);
@@ -6345,9 +6418,9 @@ function LinkCard({
6345
6418
  external = false,
6346
6419
  className
6347
6420
  }) {
6348
- const ref = useRef12(null);
6421
+ const ref = useRef13(null);
6349
6422
  const [wide, setWide] = useState11(false);
6350
- useLayoutEffect3(() => {
6423
+ useLayoutEffect4(() => {
6351
6424
  if (layout !== "auto") return;
6352
6425
  const parent = ref.current?.parentElement;
6353
6426
  if (!parent) return;
@@ -6435,10 +6508,10 @@ function AsyncPanel({ status, skeleton, error, empty, children, className }) {
6435
6508
  }
6436
6509
 
6437
6510
  // src/components/charts.tsx
6438
- import { useCallback as useCallback5, useEffect as useEffect15, useId as useId8, useMemo as useMemo3, useRef as useRef13, useState as useState13 } from "react";
6511
+ import { useCallback as useCallback5, useEffect as useEffect16, useId as useId8, useMemo as useMemo3, useRef as useRef14, useState as useState13 } from "react";
6439
6512
 
6440
6513
  // src/chart.ts
6441
- import { useEffect as useEffect14, useState as useState12 } from "react";
6514
+ import { useEffect as useEffect15, useState as useState12 } from "react";
6442
6515
  function seriesColor(i) {
6443
6516
  const n = (Math.trunc(i) % 8 + 8) % 8;
6444
6517
  return `var(--nish-chart-${n + 1})`;
@@ -6470,7 +6543,7 @@ function toneColor(tone, index) {
6470
6543
  function useWidth() {
6471
6544
  const [el, setEl] = useState13(null);
6472
6545
  const [width, setWidth] = useState13(0);
6473
- useEffect15(() => {
6546
+ useEffect16(() => {
6474
6547
  if (!el) {
6475
6548
  setWidth(0);
6476
6549
  return;
@@ -6485,7 +6558,7 @@ function useWidth() {
6485
6558
  }
6486
6559
  function useCoarsePointer() {
6487
6560
  const [coarse, setCoarse] = useState13(false);
6488
- useEffect15(() => {
6561
+ useEffect16(() => {
6489
6562
  if (typeof window === "undefined" || !window.matchMedia) return;
6490
6563
  const mq = window.matchMedia("(pointer: coarse)");
6491
6564
  const update = () => setCoarse(mq.matches);
@@ -6522,7 +6595,7 @@ function LineChart({
6522
6595
  const [wrapRef, width, wrapEl] = useWidth();
6523
6596
  const gradId = `nish-area-${useId8().replace(/[^a-zA-Z0-9]/g, "")}`;
6524
6597
  const [active, setActive] = useState13(null);
6525
- const fromKey = useRef13(false);
6598
+ const fromKey = useRef14(false);
6526
6599
  const lines = useMemo3(() => series ?? (data ? [{ label, tone, points: data }] : []), [series, data, label, tone]);
6527
6600
  const xs = useMemo3(() => {
6528
6601
  const set = /* @__PURE__ */ new Set();
@@ -6558,7 +6631,7 @@ function LineChart({
6558
6631
  const xMax = xs[xs.length - 1];
6559
6632
  return { xMin, xMax: xMax === xMin ? xMin + 1 : xMax, yMin, yMax };
6560
6633
  }, [lines, xs, baseline]);
6561
- useEffect15(() => {
6634
+ useEffect16(() => {
6562
6635
  if (active == null) return;
6563
6636
  const onDown = (e) => {
6564
6637
  if (wrapEl && !wrapEl.contains(e.target)) setActive(null);
@@ -6823,10 +6896,10 @@ function RangeBar({ min, max, low, high, current, className }) {
6823
6896
 
6824
6897
  // src/components/flow.tsx
6825
6898
  import {
6826
- useEffect as useEffect16,
6827
- useLayoutEffect as useLayoutEffect4,
6899
+ useEffect as useEffect17,
6900
+ useLayoutEffect as useLayoutEffect5,
6828
6901
  useMemo as useMemo4,
6829
- useRef as useRef14,
6902
+ useRef as useRef15,
6830
6903
  useState as useState14
6831
6904
  } from "react";
6832
6905
  import { Fragment as Fragment8, jsx as jsx18, jsxs as jsxs17 } from "react/jsx-runtime";
@@ -6846,8 +6919,8 @@ function warnDev(message) {
6846
6919
  }
6847
6920
  }
6848
6921
  function useTransitionFx(value, ref, pick) {
6849
- const prev = useRef14(value);
6850
- useLayoutEffect4(() => {
6922
+ const prev = useRef15(value);
6923
+ useLayoutEffect5(() => {
6851
6924
  const from = prev.current;
6852
6925
  prev.current = value;
6853
6926
  if (from === value) return;
@@ -6866,17 +6939,17 @@ function useTransitionFx(value, ref, pick) {
6866
6939
  }, [value, ref, pick]);
6867
6940
  }
6868
6941
  function useFreshIds(ids, skipFirst) {
6869
- const known = useRef14(skipFirst ? null : /* @__PURE__ */ new Set());
6870
- const fresh = useRef14(/* @__PURE__ */ new Set());
6871
- if (known.current) {
6872
- for (const id of ids) if (!known.current.has(id)) fresh.current.add(id);
6873
- }
6874
- useEffect16(() => {
6875
- const current = new Set(ids);
6876
- known.current = current;
6877
- for (const id of fresh.current) if (!current.has(id)) fresh.current.delete(id);
6878
- });
6879
- return fresh.current;
6942
+ const key = ids.join("\n");
6943
+ const [seen, setSeen] = useState14(() => ({
6944
+ key,
6945
+ known: new Set(ids),
6946
+ fresh: new Set(skipFirst ? [] : ids)
6947
+ }));
6948
+ if (seen.key === key) return seen.fresh;
6949
+ const fresh = new Set([...seen.fresh].filter((id) => ids.includes(id)));
6950
+ for (const id of ids) if (!seen.known.has(id)) fresh.add(id);
6951
+ setSeen({ key, known: new Set(ids), fresh });
6952
+ return fresh;
6880
6953
  }
6881
6954
  function CheckSvg({ size, className }) {
6882
6955
  return /* @__PURE__ */ jsx18(
@@ -6936,7 +7009,7 @@ function StepRow({
6936
7009
  last,
6937
7010
  sweeping
6938
7011
  }) {
6939
- const nodeRef = useRef14(null);
7012
+ const nodeRef = useRef15(null);
6940
7013
  useTransitionFx(step.status, nodeRef, pickStepFx);
6941
7014
  const { status } = step;
6942
7015
  return /* @__PURE__ */ jsxs17(
@@ -7004,9 +7077,9 @@ function StepRow({
7004
7077
  }
7005
7078
  function FlowSteps({ steps, orientation = "auto", label = "Progress", className }) {
7006
7079
  const allDone = steps.length > 0 && steps.every((s) => s.status === "done");
7007
- const prevAll = useRef14(null);
7080
+ const prevAll = useRef15(null);
7008
7081
  const [sweeping, setSweeping] = useState14(false);
7009
- useLayoutEffect4(() => {
7082
+ useLayoutEffect5(() => {
7010
7083
  const was = prevAll.current;
7011
7084
  prevAll.current = allDone;
7012
7085
  if (!allDone) {
@@ -7072,7 +7145,7 @@ function TickerText({ text, as = "span", className }) {
7072
7145
  setState(cur);
7073
7146
  }
7074
7147
  const animating = cur.prev !== null;
7075
- useEffect16(() => {
7148
+ useEffect17(() => {
7076
7149
  if (!animating) return;
7077
7150
  const timer = setTimeout(() => setState((s) => s.prev === null ? s : { ...s, prev: null }), 300);
7078
7151
  return () => clearTimeout(timer);
@@ -7131,7 +7204,7 @@ function AgentIcon({ state }) {
7131
7204
  return /* @__PURE__ */ jsx18("span", { className: "nish-flow-agent-icon grid size-5 shrink-0 place-items-center", children: /* @__PURE__ */ jsx18("span", { className: "size-4 rounded-full border-2 border-dashed border-th-ghost" }) });
7132
7205
  }
7133
7206
  function AgentNode({ label, state, model, activity, meta, onClick, className }) {
7134
- const ref = useRef14(null);
7207
+ const ref = useRef15(null);
7135
7208
  useTransitionFx(state, ref, pickAgentFx);
7136
7209
  const aria = `${label}: ${STATE_WORD[state]}`;
7137
7210
  const classes = cn(
@@ -7348,13 +7421,12 @@ function AnimatedList({
7348
7421
  setState(current);
7349
7422
  }
7350
7423
  const entries = current.entries;
7351
- const els = useRef14(/* @__PURE__ */ new Map());
7352
- const rects = useRef14(/* @__PURE__ */ new Map());
7353
- const anims = useRef14(/* @__PURE__ */ new Map());
7354
- const refCbs = useRef14(/* @__PURE__ */ new Map());
7355
- const lastKeys = useRef14(null);
7356
- const timers2 = useRef14(/* @__PURE__ */ new Map());
7357
- useEffect16(() => {
7424
+ const els = useRef15(/* @__PURE__ */ new Map());
7425
+ const rects = useRef15(/* @__PURE__ */ new Map());
7426
+ const anims = useRef15(/* @__PURE__ */ new Map());
7427
+ const lastKeys = useRef15(null);
7428
+ const timers2 = useRef15(/* @__PURE__ */ new Map());
7429
+ useEffect17(() => {
7358
7430
  const wanted = /* @__PURE__ */ new Set();
7359
7431
  for (const e of entries) {
7360
7432
  if (e.phase === "idle") continue;
@@ -7387,14 +7459,14 @@ function AnimatedList({
7387
7459
  }
7388
7460
  });
7389
7461
  }, [entries, exitMs]);
7390
- useEffect16(
7462
+ useEffect17(
7391
7463
  () => () => {
7392
7464
  timers2.current.forEach((timer) => clearTimeout(timer));
7393
7465
  timers2.current.clear();
7394
7466
  },
7395
7467
  []
7396
7468
  );
7397
- useLayoutEffect4(() => {
7469
+ useLayoutEffect5(() => {
7398
7470
  const next = /* @__PURE__ */ new Map();
7399
7471
  els.current.forEach((el, k) => next.set(k, { x: el.offsetLeft, y: el.offsetTop }));
7400
7472
  const keyList = entries.map((e) => e.key).join("\n");
@@ -7407,9 +7479,6 @@ function AnimatedList({
7407
7479
  anims.current.delete(k);
7408
7480
  }
7409
7481
  });
7410
- refCbs.current.forEach((_, k) => {
7411
- if (!live.has(k)) refCbs.current.delete(k);
7412
- });
7413
7482
  const active = typeof document !== "undefined" ? document.activeElement : null;
7414
7483
  if (active) {
7415
7484
  const ei = entries.findIndex((e) => e.phase === "exit" && els.current.get(e.key)?.contains(active));
@@ -7450,23 +7519,18 @@ function AnimatedList({
7450
7519
  }
7451
7520
  rects.current = next;
7452
7521
  }, [entries, reduced]);
7453
- const refFor = (key) => {
7454
- let cb = refCbs.current.get(key);
7455
- if (!cb) {
7456
- cb = (el) => {
7457
- if (el) els.current.set(key, el);
7458
- else els.current.delete(key);
7459
- };
7460
- refCbs.current.set(key, cb);
7461
- }
7462
- return cb;
7463
- };
7464
7522
  const Root = as;
7465
7523
  const Item = as === "div" ? "div" : "li";
7466
7524
  return /* @__PURE__ */ jsx18(Root, { className, children: entries.map((e) => /* @__PURE__ */ jsx18(
7467
7525
  Item,
7468
7526
  {
7469
- ref: refFor(e.key),
7527
+ ref: (el) => {
7528
+ if (!el) return;
7529
+ els.current.set(e.key, el);
7530
+ return () => {
7531
+ if (els.current.get(e.key) === el) els.current.delete(e.key);
7532
+ };
7533
+ },
7470
7534
  className: cn("nish-flow-item", itemClassName),
7471
7535
  "data-phase": e.phase,
7472
7536
  "aria-hidden": e.phase === "exit" || void 0,
@@ -7482,7 +7546,7 @@ function AnimatedList({
7482
7546
  import { SystemCanvas, layoutSystem, pickLayout, routeEdges } from "./system-canvas.js";
7483
7547
 
7484
7548
  // src/components/inbox.tsx
7485
- import { useEffect as useEffect17, useId as useId9, useRef as useRef15, useState as useState15 } from "react";
7549
+ import { useEffect as useEffect18, useId as useId9, useRef as useRef16, useState as useState15 } from "react";
7486
7550
 
7487
7551
  // src/server/inbox/types.ts
7488
7552
  var INBOX_ACTION_HEADER = "X-Inbox-Action";
@@ -7634,10 +7698,10 @@ function Inbox({
7634
7698
  const [expanded, setExpanded] = useState15(() => /* @__PURE__ */ new Set());
7635
7699
  const [confirmAll, setConfirmAll] = useState15(false);
7636
7700
  const [running, setRunning] = useState15(() => /* @__PURE__ */ new Map());
7637
- const scrolled = useRef15(null);
7701
+ const scrolled = useRef16(null);
7638
7702
  const labelOf = (id) => sourceLabels[id] ?? id;
7639
7703
  const rowId = (id) => `${idBase}-item-${id}`;
7640
- useEffect17(() => {
7704
+ useEffect18(() => {
7641
7705
  if (selectedId == null || scrolled.current === selectedId) return;
7642
7706
  const el = document.getElementById(rowId(selectedId));
7643
7707
  if (!el) return;
@@ -7735,7 +7799,7 @@ function Inbox({
7735
7799
  }
7736
7800
 
7737
7801
  // src/components/app-shell.tsx
7738
- import { Fragment as Fragment10, useEffect as useEffect18, useRef as useRef16, useState as useState16 } from "react";
7802
+ import { Fragment as Fragment10, useEffect as useEffect19, useRef as useRef17, useState as useState16 } from "react";
7739
7803
 
7740
7804
  // src/components/error-boundary.tsx
7741
7805
  import { Component } from "react";
@@ -7788,9 +7852,10 @@ var MAIN_ID = "nish-main";
7788
7852
  function AppShell({
7789
7853
  name,
7790
7854
  icon,
7855
+ brand,
7791
7856
  homeHref = "/",
7792
7857
  hubHref,
7793
- nav,
7858
+ nav = [],
7794
7859
  primary = 4,
7795
7860
  moreItems = [],
7796
7861
  renderLink,
@@ -7799,6 +7864,8 @@ function AppShell({
7799
7864
  railFooter,
7800
7865
  loading = false,
7801
7866
  connection = {},
7867
+ banner,
7868
+ sidebar = false,
7802
7869
  container = "default",
7803
7870
  toaster = {},
7804
7871
  errorBoundary = true,
@@ -7806,20 +7873,33 @@ function AppShell({
7806
7873
  children
7807
7874
  }) {
7808
7875
  const [sheet, setSheet] = useState16(false);
7809
- const firstKey = useRef16(true);
7810
- useEffect18(() => {
7876
+ const firstKey = useRef17(true);
7877
+ useEffect19(() => {
7811
7878
  if (firstKey.current) {
7812
7879
  firstKey.current = false;
7813
7880
  return;
7814
7881
  }
7815
7882
  setSheet(false);
7816
7883
  }, [resetKey]);
7884
+ const side = sidebar === false ? null : sidebar === true ? {} : sidebar;
7885
+ const storageKey = side?.storageKey === false ? null : side?.storageKey ?? "nish-sidebar-collapsed";
7886
+ const [storedCollapsed, setStoredCollapsed] = useLocalStorage(storageKey ?? "nish-sidebar-collapsed", side?.defaultCollapsed ?? false);
7887
+ const [memoryCollapsed, setMemoryCollapsed] = useState16(side?.defaultCollapsed ?? false);
7888
+ const collapsed = side?.collapsed ?? (storageKey ? storedCollapsed : memoryCollapsed);
7889
+ const setCollapsed = (next) => {
7890
+ if (side?.collapsed === void 0) (storageKey ? setStoredCollapsed : setMemoryCollapsed)(next);
7891
+ side?.onCollapsedChange?.(next);
7892
+ };
7893
+ const bannersRef = useRef17(null);
7894
+ useHeightVar(bannersRef, "--nish-banners-h");
7895
+ const hasNav = nav.length > 0;
7817
7896
  const n = nav.length <= 5 ? nav.length : Math.max(0, primary);
7818
7897
  const bottomItems = nav.slice(0, n);
7819
7898
  const overflow = nav.slice(n);
7820
- const sheetItems = [...overflow, ...moreItems];
7899
+ const sheetItems = hasNav ? [...overflow, ...moreItems] : [];
7821
7900
  const hasSheet = sheetItems.length > 0;
7822
7901
  const moreActive = sheetItems.some((i) => i.active);
7902
+ const stickTop = "sticky top-[calc(var(--nish-header-h,0px)+var(--nish-banners-h,0px))] h-[calc(100dvh-var(--nish-header-h,0px)-var(--nish-banners-h,0px))] self-start";
7823
7903
  const toggle = themeToggle === false ? false : hasSheet ? /* @__PURE__ */ jsx21("span", { className: "max-md:hidden", children: themeToggle ?? /* @__PURE__ */ jsx21(ThemeToggle, {}) }) : themeToggle;
7824
7904
  const desktopNav = /* @__PURE__ */ jsx21(Fragment11, { children: nav.map((item) => {
7825
7905
  const className = cn(tabClass({ active: !!item.active }), "inline-flex");
@@ -7829,26 +7909,29 @@ function AppShell({
7829
7909
  }
7830
7910
  return item.href != null ? /* @__PURE__ */ jsx21("a", { href: item.href, className, "aria-current": current, onClick: item.onSelect, children: item.label }, item.key) : /* @__PURE__ */ jsx21("button", { type: "button", className, "aria-current": current, onClick: item.onSelect, children: item.label }, item.key);
7831
7911
  }) });
7832
- const moreMenu = moreItems.length > 0 ? /* @__PURE__ */ jsx21("div", { className: "hidden md:inline-flex", children: /* @__PURE__ */ jsx21(
7833
- DropdownMenu,
7834
- {
7835
- align: "end",
7836
- trigger: /* @__PURE__ */ jsx21(IconButton, { label: "More", children: /* @__PURE__ */ jsx21(MoreIcon, { size: 20 }) }),
7837
- children: moreItems.map((item) => /* @__PURE__ */ jsx21(
7838
- MenuItem,
7839
- {
7840
- icon: item.icon,
7841
- active: item.active,
7842
- onSelect: () => {
7843
- if (item.onSelect) item.onSelect();
7844
- else if (item.href != null) window.location.assign(item.href);
7912
+ const moreMenu = moreItems.length > 0 ? (
7913
+ // With nav, under 768px these items live in the MoreSheet; signed out there is no sheet.
7914
+ /* @__PURE__ */ jsx21("div", { className: hasNav ? "hidden md:inline-flex" : "inline-flex", children: /* @__PURE__ */ jsx21(
7915
+ DropdownMenu,
7916
+ {
7917
+ align: "end",
7918
+ trigger: /* @__PURE__ */ jsx21(IconButton, { label: "More", children: /* @__PURE__ */ jsx21(MoreIcon, { size: 20 }) }),
7919
+ children: moreItems.map((item) => /* @__PURE__ */ jsx21(
7920
+ MenuItem,
7921
+ {
7922
+ icon: item.icon,
7923
+ active: item.active,
7924
+ onSelect: () => {
7925
+ if (item.onSelect) item.onSelect();
7926
+ else if (item.href != null) window.location.assign(item.href);
7927
+ },
7928
+ children: item.label
7845
7929
  },
7846
- children: item.label
7847
- },
7848
- item.key
7849
- ))
7850
- }
7851
- ) }) : null;
7930
+ item.key
7931
+ ))
7932
+ }
7933
+ ) })
7934
+ ) : null;
7852
7935
  const page = errorBoundary ? /* @__PURE__ */ jsx21(AppErrorBoundary, { resetKeys: [resetKey], children }) : children;
7853
7936
  return /* @__PURE__ */ jsxs20(Fragment11, { children: [
7854
7937
  /* @__PURE__ */ jsx21(
@@ -7871,41 +7954,59 @@ function AppShell({
7871
7954
  {
7872
7955
  name,
7873
7956
  icon,
7957
+ brand,
7874
7958
  homeHref,
7875
7959
  hubHref,
7876
7960
  hideNameBelow: icon != null ? "sm" : void 0,
7877
7961
  compactPill: true,
7878
7962
  actions: /* @__PURE__ */ jsxs20(Fragment11, { children: [
7963
+ hasNav && side?.tools != null ? /* @__PURE__ */ jsx21("span", { className: "flex items-center gap-2 lg:hidden", children: side.tools }) : null,
7879
7964
  actions,
7880
7965
  moreMenu
7881
7966
  ] }),
7882
7967
  themeToggle: toggle,
7883
7968
  className: "max-lg:[&>nav]:hidden",
7884
- nav: desktopNav,
7969
+ nav: hasNav && !side ? desktopNav : void 0,
7885
7970
  navLabel: "Sections"
7886
7971
  }
7887
7972
  ),
7888
7973
  /* @__PURE__ */ jsx21(LoadingBar, { active: loading }),
7889
- connection !== false ? /* @__PURE__ */ jsx21(ConnectionBanner, { ...connection }) : null,
7974
+ /* @__PURE__ */ jsxs20("div", { ref: bannersRef, className: "sticky top-[var(--nish-header-h,0px)] z-20 empty:hidden", children: [
7975
+ connection !== false ? /* @__PURE__ */ jsx21(ConnectionBanner, { ...connection }) : null,
7976
+ banner
7977
+ ] }),
7890
7978
  /* @__PURE__ */ jsxs20("div", { className: "md:flex", children: [
7891
- /* @__PURE__ */ jsx21("div", { className: "sticky top-[var(--nish-header-h,0px)] hidden h-[calc(100dvh-var(--nish-header-h,0px))] self-start md:block lg:hidden", children: /* @__PURE__ */ jsx21(NavRail, { items: nav, showFrom: "md", hideFrom: "lg", footer: railFooter, renderLink, className: "h-full" }) }),
7979
+ hasNav ? /* @__PURE__ */ jsx21("div", { className: cn(stickTop, "hidden md:block lg:hidden"), children: /* @__PURE__ */ jsx21(NavRail, { items: nav, showFrom: "md", hideFrom: "lg", footer: railFooter, renderLink, className: "h-full" }) }) : null,
7980
+ hasNav && side ? /* @__PURE__ */ jsx21("div", { className: cn(stickTop, "hidden lg:block"), children: /* @__PURE__ */ jsx21(
7981
+ NavSidebar,
7982
+ {
7983
+ items: nav,
7984
+ collapsed,
7985
+ onCollapsedChange: setCollapsed,
7986
+ tools: side.tools,
7987
+ footer: side.footer,
7988
+ renderLink
7989
+ }
7990
+ ) }) : null,
7892
7991
  /* @__PURE__ */ jsx21("div", { className: "min-w-0 flex-1", children: /* @__PURE__ */ jsx21("main", { id: MAIN_ID, tabIndex: -1, className: "focus:outline-none", children: container === false ? page : /* @__PURE__ */ jsx21(PageContainer, { as: "div", size: container, children: page }) }) })
7893
7992
  ] }),
7894
- /* @__PURE__ */ jsx21(
7895
- BottomNav,
7896
- {
7897
- items: bottomItems,
7898
- more: hasSheet ? { active: moreActive, expanded: sheet, onToggle: () => setSheet((s) => !s) } : void 0,
7899
- renderLink
7900
- }
7901
- ),
7902
- /* @__PURE__ */ jsx21(MoreSheet, { open: sheet, onClose: () => setSheet(false), items: sheetItems, renderLink }),
7993
+ hasNav ? /* @__PURE__ */ jsxs20(Fragment11, { children: [
7994
+ /* @__PURE__ */ jsx21(
7995
+ BottomNav,
7996
+ {
7997
+ items: bottomItems,
7998
+ more: hasSheet ? { active: moreActive, expanded: sheet, onToggle: () => setSheet((s) => !s) } : void 0,
7999
+ renderLink
8000
+ }
8001
+ ),
8002
+ /* @__PURE__ */ jsx21(MoreSheet, { open: sheet, onClose: () => setSheet(false), items: sheetItems, renderLink })
8003
+ ] }) : null,
7903
8004
  toaster !== false ? /* @__PURE__ */ jsx21(Toaster, { ...toaster }) : null
7904
8005
  ] });
7905
8006
  }
7906
8007
 
7907
8008
  // src/components/resource.ts
7908
- import { useCallback as useCallback6, useEffect as useEffect19, useRef as useRef17, useState as useState17 } from "react";
8009
+ import { useCallback as useCallback6, useEffect as useEffect20, useRef as useRef18, useState as useState17 } from "react";
7909
8010
  var ApiError = class extends Error {
7910
8011
  /** HTTP status; 0 = network failure or abort-by-timeout. */
7911
8012
  status;
@@ -7931,14 +8032,19 @@ function configureApi(c) {
7931
8032
  function isRawBody(b) {
7932
8033
  return typeof b === "string" || typeof FormData !== "undefined" && b instanceof FormData || typeof Blob !== "undefined" && b instanceof Blob || typeof URLSearchParams !== "undefined" && b instanceof URLSearchParams || b instanceof ArrayBuffer || ArrayBuffer.isView(b);
7933
8034
  }
7934
- function errorMessage(body, res) {
8035
+ var ERROR_CODE = /^[a-z0-9_]+$/;
8036
+ function errorMessage(body, status) {
8037
+ let raw = "";
7935
8038
  if (body && typeof body === "object") {
7936
8039
  const o = body;
7937
- if (typeof o.error === "string" && o.error) return o.error;
7938
- if (typeof o.message === "string" && o.message) return o.message;
8040
+ if (typeof o.error === "string" && o.error) raw = o.error;
8041
+ else if (typeof o.message === "string" && o.message) raw = o.message;
7939
8042
  }
7940
- const line = `${res.status} ${res.statusText}`.trim();
7941
- return line || "Request failed";
8043
+ if (raw && !ERROR_CODE.test(raw)) return raw;
8044
+ if (status === 401) return "Log in to continue.";
8045
+ if (raw && status === 404) return "That was not found.";
8046
+ if (raw) return "The server had a problem. Try again.";
8047
+ return `The server answered ${status}.`;
7942
8048
  }
7943
8049
  async function apiFetch(path, o = {}) {
7944
8050
  const { body, timeoutMs = 15e3, nullOn404, signal: callerSignal, headers: extraHeaders, ...init } = o;
@@ -7972,9 +8078,9 @@ async function apiFetch(path, o = {}) {
7972
8078
  res = await fetch(url, { credentials: "same-origin", ...init, headers, body: payload, signal: ctl.signal });
7973
8079
  text = await res.text();
7974
8080
  } catch (e) {
7975
- if (timedOut) throw new ApiError("Request timed out", { status: 0, url });
8081
+ if (timedOut) throw new ApiError("The server took too long to answer.", { status: 0, url });
7976
8082
  if (e instanceof Error && e.name === "AbortError") throw e;
7977
- throw new ApiError("Can't reach the server", { status: 0, url });
8083
+ throw new ApiError("Could not reach the server.", { status: 0, url });
7978
8084
  }
7979
8085
  const type = res.headers.get("content-type") ?? "";
7980
8086
  let parsed = text === "" ? null : text;
@@ -7987,7 +8093,7 @@ async function apiFetch(path, o = {}) {
7987
8093
  }
7988
8094
  if (!res.ok) {
7989
8095
  if (res.status === 404 && nullOn404) return null;
7990
- const err = new ApiError(errorMessage(parsed, res), { status: res.status, body: parsed, url });
8096
+ const err = new ApiError(errorMessage(parsed, res.status), { status: res.status, body: parsed, url });
7991
8097
  if (res.status === 401) config.onUnauthorized?.(err);
7992
8098
  throw err;
7993
8099
  }
@@ -8008,17 +8114,13 @@ function useResource(key, fetcher, o = {}) {
8008
8114
  updatedAt: void 0,
8009
8115
  fetching: false
8010
8116
  }));
8011
- const fetcherRef = useRef17(fetcher);
8012
- fetcherRef.current = fetcher;
8013
- const keyRef = useRef17(key);
8014
- keyRef.current = key;
8015
- const keepPrevRef = useRef17(keepPrevious);
8016
- keepPrevRef.current = keepPrevious;
8017
- const initialRef = useRef17(o.initialData);
8018
- initialRef.current = o.initialData;
8019
- const ctlRef = useRef17(null);
8020
- const runRef = useRef17(0);
8021
- const pollSkippedRef = useRef17(false);
8117
+ const fetcherRef = useLatest(fetcher);
8118
+ const keyRef = useLatest(key);
8119
+ const keepPrevRef = useLatest(keepPrevious);
8120
+ const initialRef = useLatest(o.initialData);
8121
+ const ctlRef = useRef18(null);
8122
+ const runRef = useRef18(0);
8123
+ const pollSkippedRef = useRef18(false);
8022
8124
  const [now, setNow] = useState17(() => Date.now());
8023
8125
  const load = useCallback6(async () => {
8024
8126
  const k = keyRef.current;
@@ -8047,8 +8149,8 @@ function useResource(key, fetcher, o = {}) {
8047
8149
  const error2 = e instanceof Error ? e : new Error(String(e));
8048
8150
  setState((s) => ({ ...s, key: k, error: error2, fetching: false }));
8049
8151
  }
8050
- }, []);
8051
- useEffect19(() => {
8152
+ }, [fetcherRef, initialRef, keepPrevRef, keyRef]);
8153
+ useEffect20(() => {
8052
8154
  if (!active) return;
8053
8155
  void load();
8054
8156
  return () => {
@@ -8060,7 +8162,7 @@ function useResource(key, fetcher, o = {}) {
8060
8162
  }, [active, key, load]);
8061
8163
  const fetching = state.fetching;
8062
8164
  const updatedAt = state.updatedAt;
8063
- useEffect19(() => {
8165
+ useEffect20(() => {
8064
8166
  if (!active || !intervalMs || fetching) return;
8065
8167
  const id = setTimeout(() => {
8066
8168
  if (typeof document !== "undefined" && document.hidden) {
@@ -8071,7 +8173,7 @@ function useResource(key, fetcher, o = {}) {
8071
8173
  }, intervalMs);
8072
8174
  return () => clearTimeout(id);
8073
8175
  }, [active, intervalMs, fetching, load]);
8074
- useEffect19(() => {
8176
+ useEffect20(() => {
8075
8177
  if (!active || typeof document === "undefined") return;
8076
8178
  let hiddenAt = document.hidden ? Date.now() : null;
8077
8179
  const onVisibility = () => {
@@ -8095,7 +8197,7 @@ function useResource(key, fetcher, o = {}) {
8095
8197
  window.removeEventListener("online", onOnline);
8096
8198
  };
8097
8199
  }, [active, refetchOnVisible, refetchOnReconnect, load]);
8098
- useEffect19(() => {
8200
+ useEffect20(() => {
8099
8201
  if (!intervalMs || updatedAt === void 0) return;
8100
8202
  const id = setInterval(() => setNow(Date.now()), intervalMs);
8101
8203
  return () => clearInterval(id);
@@ -8209,7 +8311,7 @@ function FilterBar({
8209
8311
  }
8210
8312
 
8211
8313
  // src/components/url-state.ts
8212
- import { useCallback as useCallback7, useMemo as useMemo5, useRef as useRef18, useSyncExternalStore as useSyncExternalStore6 } from "react";
8314
+ import { useCallback as useCallback7, useMemo as useMemo5, useSyncExternalStore as useSyncExternalStore6 } from "react";
8213
8315
  var EVENT = "nish:urlstate";
8214
8316
  var locationAdapter = {
8215
8317
  get() {
@@ -8233,11 +8335,11 @@ var locationAdapter = {
8233
8335
  };
8234
8336
  }
8235
8337
  };
8236
- function parseValue(params, key, fallback) {
8338
+ function parseValue(params, key, fallback, comma) {
8237
8339
  if (!params.has(key)) return fallback;
8238
8340
  if (Array.isArray(fallback)) {
8239
8341
  const all = params.getAll(key);
8240
- return (all.length === 1 ? all[0].split(",") : all).filter(Boolean);
8342
+ return (comma && all.length === 1 ? all[0].split(",") : all).filter(Boolean);
8241
8343
  }
8242
8344
  const raw = params.get(key) ?? "";
8243
8345
  if (typeof fallback === "number") {
@@ -8256,26 +8358,28 @@ function same(a, b) {
8256
8358
  if (Array.isArray(a) && Array.isArray(b)) return a.length === b.length && a.every((v, i) => v === b[i]);
8257
8359
  return a === b;
8258
8360
  }
8259
- function parse(params, defaults, prefix) {
8361
+ function parse(params, defaults, prefix, comma) {
8260
8362
  const out = {};
8261
- for (const key of Object.keys(defaults)) out[key] = parseValue(params, prefix + key, defaults[key]);
8363
+ for (const key of Object.keys(defaults)) out[key] = parseValue(params, prefix + key, defaults[key], isComma(comma, key));
8262
8364
  return out;
8263
8365
  }
8366
+ var isComma = (comma, key) => Array.isArray(comma) ? comma.includes(key) : comma === true;
8264
8367
  function useUrlState(defaults, o = {}) {
8265
8368
  const adapter = o.adapter ?? locationAdapter;
8266
8369
  const prefix = o.prefix ? `${o.prefix}.` : "";
8267
- const defaultsRef = useRef18(defaults);
8268
- defaultsRef.current = defaults;
8370
+ const commaKey = JSON.stringify(o.comma ?? false);
8371
+ const comma = useMemo5(() => JSON.parse(commaKey), [commaKey]);
8269
8372
  const defaultsKey = JSON.stringify(defaults);
8373
+ const stableDefaults = useMemo5(() => JSON.parse(defaultsKey), [defaultsKey]);
8270
8374
  const search = useSyncExternalStore6(
8271
8375
  adapter.subscribe,
8272
8376
  () => adapter.get().toString(),
8273
8377
  () => ""
8274
8378
  );
8275
- const state = useMemo5(() => parse(new URLSearchParams(search), defaultsRef.current, prefix), [search, prefix, defaultsKey]);
8379
+ const state = useMemo5(() => parse(new URLSearchParams(search), stableDefaults, prefix, comma), [search, prefix, stableDefaults, comma]);
8276
8380
  const write = useCallback7(
8277
8381
  (next) => {
8278
- const d = defaultsRef.current;
8382
+ const d = stableDefaults;
8279
8383
  const params = adapter.get();
8280
8384
  for (const key of Object.keys(next)) {
8281
8385
  if (!(key in d)) continue;
@@ -8287,52 +8391,55 @@ function useUrlState(defaults, o = {}) {
8287
8391
  if (value.length === 0) params.append(name, "");
8288
8392
  else {
8289
8393
  for (const v of value) params.append(name, v);
8290
- if (value.length === 1 && value[0].includes(",")) params.append(name, "");
8394
+ if (isComma(comma, key) && value.length === 1 && value[0].includes(",")) params.append(name, "");
8291
8395
  }
8292
8396
  } else if (typeof value === "boolean") params.set(name, value ? "1" : "0");
8293
8397
  else params.set(name, String(value));
8294
8398
  }
8295
8399
  adapter.set(params);
8296
8400
  },
8297
- [adapter, prefix]
8401
+ [adapter, stableDefaults, prefix, comma]
8298
8402
  );
8299
8403
  const patch = useCallback7(
8300
8404
  (p) => {
8301
- const prev = parse(adapter.get(), defaultsRef.current, prefix);
8405
+ const prev = parse(adapter.get(), stableDefaults, prefix, comma);
8302
8406
  write(typeof p === "function" ? p(prev) : p);
8303
8407
  },
8304
- [adapter, prefix, write]
8408
+ [adapter, stableDefaults, prefix, comma, write]
8305
8409
  );
8306
8410
  const reset = useCallback7(() => {
8307
8411
  const params = adapter.get();
8308
- for (const key of Object.keys(defaultsRef.current)) params.delete(prefix + key);
8412
+ for (const key of Object.keys(stableDefaults)) params.delete(prefix + key);
8309
8413
  adapter.set(params);
8310
- }, [adapter, prefix]);
8414
+ }, [adapter, stableDefaults, prefix]);
8311
8415
  return [state, patch, reset];
8312
8416
  }
8313
8417
 
8314
8418
  // src/components/settings.tsx
8315
8419
  import {
8420
+ createContext as createContext5,
8316
8421
  forwardRef as forwardRef3,
8317
8422
  useCallback as useCallback8,
8318
- useEffect as useEffect20,
8423
+ useContext as useContext5,
8424
+ useEffect as useEffect21,
8319
8425
  useId as useId10,
8320
8426
  useRef as useRef19,
8321
8427
  useState as useState19
8322
8428
  } from "react";
8323
8429
  import { jsx as jsx23, jsxs as jsxs22 } from "react/jsx-runtime";
8324
- function SettingsSection({ title, description, id, actions, children, className }) {
8430
+ var CompactSettings = createContext5(false);
8431
+ function SettingsSection({ title, description, id, actions, compact = false, children, className }) {
8325
8432
  const auto = useId10();
8326
8433
  const headingId = `${id ?? auto}-heading`;
8327
8434
  return /* @__PURE__ */ jsxs22("section", { id, "aria-labelledby": headingId, className: cn("min-w-0", className), children: [
8328
- /* @__PURE__ */ jsxs22("div", { className: "mb-3 flex flex-wrap items-end justify-between gap-x-4 gap-y-2", children: [
8435
+ /* @__PURE__ */ jsxs22("div", { className: cn("flex flex-wrap items-end justify-between gap-x-4 gap-y-2", compact ? "mb-1" : "mb-3"), children: [
8329
8436
  /* @__PURE__ */ jsxs22("div", { className: "min-w-0", children: [
8330
- /* @__PURE__ */ jsx23("h2", { id: headingId, className: "text-base font-semibold text-th-hi", children: title }),
8331
- description != null ? /* @__PURE__ */ jsx23("p", { className: "mt-0.5 text-sm text-th-hi3", children: description }) : null
8437
+ /* @__PURE__ */ jsx23("h2", { id: headingId, className: compact ? "text-sm font-semibold text-th-hi2" : "text-base font-semibold text-th-hi", children: title }),
8438
+ description != null ? /* @__PURE__ */ jsx23("p", { className: cn("mt-0.5 text-th-hi3", compact ? "text-xs" : "text-sm"), children: description }) : null
8332
8439
  ] }),
8333
8440
  actions != null ? /* @__PURE__ */ jsx23("div", { className: "flex shrink-0 items-center gap-2", children: actions }) : null
8334
8441
  ] }),
8335
- /* @__PURE__ */ jsx23(Card, { padding: "none", className: "divide-y divide-th-line", children })
8442
+ /* @__PURE__ */ jsx23(CompactSettings.Provider, { value: compact, children: compact ? /* @__PURE__ */ jsx23("div", { className: "divide-y divide-th-line", children }) : /* @__PURE__ */ jsx23(Card, { padding: "none", className: "divide-y divide-th-line", children }) })
8336
8443
  ] });
8337
8444
  }
8338
8445
  var STATUS_TONE = { muted: "text-th-hi3", error: "text-th-loss", ok: "text-th-ok" };
@@ -8343,25 +8450,29 @@ function SettingRow({
8343
8450
  htmlFor,
8344
8451
  stacked = false,
8345
8452
  inline = false,
8453
+ compact: compactProp,
8346
8454
  status,
8347
8455
  statusTone = "muted",
8348
8456
  className
8349
8457
  }) {
8458
+ const inCompactSection = useContext5(CompactSettings);
8459
+ const compact = compactProp ?? inCompactSection;
8350
8460
  const labelClass = "block text-sm font-medium text-th-hi";
8351
8461
  const auto = useId10();
8352
8462
  const labelId = `${auto}-label`;
8353
8463
  const descId = `${auto}-desc`;
8354
- const layout = stacked ? "flex flex-col gap-2" : inline ? "grid grid-cols-[1fr_auto] items-center gap-4" : "flex flex-col gap-2 sm:grid sm:grid-cols-[1fr_auto] sm:items-center sm:gap-4";
8355
- return /* @__PURE__ */ jsxs22("div", { className: cn("min-h-[56px] px-4 py-3", layout, className), children: [
8464
+ const side = inline || compact && !stacked;
8465
+ const layout = stacked ? "flex flex-col gap-2" : side ? "grid grid-cols-[1fr_auto] items-center gap-4" : "flex flex-col gap-2 sm:grid sm:grid-cols-[1fr_auto] sm:items-center sm:gap-4";
8466
+ return /* @__PURE__ */ jsxs22("div", { className: cn(compact ? cn("min-h-11 py-2", !inCompactSection && "px-4") : "min-h-[56px] px-4 py-3", layout, className), children: [
8356
8467
  /* @__PURE__ */ jsxs22("div", { className: "min-w-0", children: [
8357
8468
  htmlFor ? /* @__PURE__ */ jsx23("label", { htmlFor, className: labelClass, children: label }) : /* @__PURE__ */ jsx23("span", { id: labelId, className: labelClass, children: label }),
8358
- description != null ? /* @__PURE__ */ jsx23("p", { id: descId, className: "mt-0.5 text-sm text-th-hi3", children: description }) : null
8469
+ description != null ? /* @__PURE__ */ jsx23("p", { id: descId, className: cn("mt-0.5 text-th-hi3", compact ? "text-xs" : "text-sm"), children: description }) : null
8359
8470
  ] }),
8360
8471
  /* @__PURE__ */ jsxs22(
8361
8472
  "div",
8362
8473
  {
8363
8474
  ...htmlFor ? {} : { role: "group", "aria-labelledby": labelId, "aria-describedby": description != null ? descId : void 0 },
8364
- className: cn("flex min-w-0 items-center gap-2", stacked ? "w-full" : inline ? "justify-end" : "w-full sm:w-auto sm:justify-end"),
8475
+ className: cn("flex min-w-0 items-center gap-2", stacked ? "w-full" : side ? "justify-end" : "w-full sm:w-auto sm:justify-end"),
8365
8476
  children: [
8366
8477
  children,
8367
8478
  /* @__PURE__ */ jsx23("span", { role: "status", "aria-live": "polite", className: cn("shrink-0 text-sm empty:hidden", STATUS_TONE[statusTone]), children: status })
@@ -8378,7 +8489,7 @@ function useSaveStatus() {
8378
8489
  const timer = useRef19(void 0);
8379
8490
  const token = useRef19(0);
8380
8491
  const mounted = useRef19(true);
8381
- useEffect20(() => {
8492
+ useEffect21(() => {
8382
8493
  mounted.current = true;
8383
8494
  return () => {
8384
8495
  mounted.current = false;
@@ -8413,6 +8524,7 @@ function useSaveStatus() {
8413
8524
  const tone = status === "saved" ? "ok" : status === "error" ? "error" : "muted";
8414
8525
  return { status, error, label, tone, run };
8415
8526
  }
8527
+ var parseDraft = (text) => Number(text.trim().replace(/,/g, "").replace(/\u2212/g, "-"));
8416
8528
  var fmt = (v) => v == null ? "" : String(v);
8417
8529
  var decimals = (n) => String(n).split(".")[1]?.length ?? 0;
8418
8530
  var NumberField = forwardRef3(function NumberField2({ value, onCommit, min, max, step = 1, nullable = false, suffix, precision, className, onBlur, onKeyDown, id, invalid, "aria-describedby": describedBy, ...rest }, ref) {
@@ -8429,13 +8541,13 @@ var NumberField = forwardRef3(function NumberField2({ value, onCommit, min, max,
8429
8541
  draftRef.current = next;
8430
8542
  setDraftState(next);
8431
8543
  };
8432
- useEffect20(() => {
8544
+ useEffect21(() => {
8433
8545
  mounted.current = true;
8434
8546
  return () => {
8435
8547
  mounted.current = false;
8436
8548
  };
8437
8549
  }, []);
8438
- useEffect20(() => {
8550
+ useEffect21(() => {
8439
8551
  lastSent.current = null;
8440
8552
  setDraft(fmt(value));
8441
8553
  }, [value]);
@@ -8460,7 +8572,7 @@ var NumberField = forwardRef3(function NumberField2({ value, onCommit, min, max,
8460
8572
  }
8461
8573
  next = null;
8462
8574
  } else {
8463
- const n = Number(text.replace(/,/g, ""));
8575
+ const n = parseDraft(text);
8464
8576
  if (Number.isNaN(n)) {
8465
8577
  setDraft(fmt(value));
8466
8578
  setError("Enter a number");
@@ -8497,7 +8609,7 @@ var NumberField = forwardRef3(function NumberField2({ value, onCommit, min, max,
8497
8609
  }
8498
8610
  };
8499
8611
  const nudge = (dir) => {
8500
- const base = Number(draftRef.current.replace(/,/g, ""));
8612
+ const base = parseDraft(draftRef.current);
8501
8613
  const from = Number.isNaN(base) || draftRef.current.trim() === "" ? value ?? min ?? 0 : base;
8502
8614
  const n = Number(clamp2(from + dir * step).toFixed(Math.max(precision ?? 0, decimals(step), decimals(from))));
8503
8615
  setDraft(String(n));
@@ -8521,16 +8633,24 @@ var NumberField = forwardRef3(function NumberField2({ value, onCommit, min, max,
8521
8633
  nudge(e.key === "ArrowUp" ? 1 : -1);
8522
8634
  }
8523
8635
  };
8636
+ const shown = parseDraft(draft);
8637
+ const now = draft.trim() !== "" && !Number.isNaN(shown) ? shown : value ?? void 0;
8638
+ const negatives = min != null && min < 0;
8524
8639
  return /* @__PURE__ */ jsxs22("div", { className: "flex min-w-0 flex-col gap-1", children: [
8525
8640
  /* @__PURE__ */ jsxs22("div", { className: "flex items-center gap-2", children: [
8526
8641
  /* @__PURE__ */ jsx23(
8527
8642
  Input,
8528
8643
  {
8644
+ inputMode: negatives ? "text" : "decimal",
8529
8645
  ...rest,
8530
8646
  ref,
8531
8647
  id,
8532
8648
  type: "text",
8533
- inputMode: "decimal",
8649
+ role: "spinbutton",
8650
+ "aria-valuemin": min,
8651
+ "aria-valuemax": max,
8652
+ "aria-valuenow": now,
8653
+ "aria-valuetext": now != null && typeof suffix === "string" ? `${now} ${suffix}` : void 0,
8534
8654
  autoComplete: "off",
8535
8655
  value: draft,
8536
8656
  invalid: invalid || error != null,
@@ -8560,7 +8680,7 @@ var NumberField = forwardRef3(function NumberField2({ value, onCommit, min, max,
8560
8680
  // src/components/service-tokens.tsx
8561
8681
  import {
8562
8682
  useCallback as useCallback9,
8563
- useEffect as useEffect21,
8683
+ useEffect as useEffect22,
8564
8684
  useMemo as useMemo6,
8565
8685
  useRef as useRef20,
8566
8686
  useState as useState20
@@ -8574,7 +8694,7 @@ function useServiceTokens(url = "/api/service-tokens") {
8574
8694
  const [error, setError] = useState20(null);
8575
8695
  const [nonce, setNonce] = useState20(0);
8576
8696
  const seq = useRef20(0);
8577
- useEffect21(() => {
8697
+ useEffect22(() => {
8578
8698
  const mine = ++seq.current;
8579
8699
  const ctl = new AbortController();
8580
8700
  apiFetch(url, { signal: ctl.signal }).then((r) => {
@@ -8636,7 +8756,7 @@ function ServiceTokensSection({
8636
8756
  const [pending, setPending] = useState20(false);
8637
8757
  const [failure, setFailure] = useState20(null);
8638
8758
  const mounted = useRef20(true);
8639
- useEffect21(() => {
8759
+ useEffect22(() => {
8640
8760
  mounted.current = true;
8641
8761
  return () => {
8642
8762
  mounted.current = false;
@@ -8757,7 +8877,7 @@ function ServiceTokensSection({
8757
8877
  }
8758
8878
 
8759
8879
  // src/components/combobox.tsx
8760
- import { useCallback as useCallback10, useEffect as useEffect22, useId as useId11, useMemo as useMemo7, useRef as useRef21, useState as useState21 } from "react";
8880
+ import { useCallback as useCallback10, useEffect as useEffect23, useId as useId11, useMemo as useMemo7, useRef as useRef21, useState as useState21 } from "react";
8761
8881
  import { jsx as jsx25, jsxs as jsxs24 } from "react/jsx-runtime";
8762
8882
  var MAX_SHOWN = 50;
8763
8883
  var DEBOUNCE_MS = 200;
@@ -8802,13 +8922,13 @@ function Combobox({
8802
8922
  const list = !dirty || serverFiltered ? options : options.filter((o) => test(o, text));
8803
8923
  return list.slice(0, MAX_SHOWN);
8804
8924
  }, [options, dirty, text, filter, onQueryChange]);
8805
- useEffect22(() => () => window.clearTimeout(debounceRef.current), []);
8806
- useEffect22(() => {
8925
+ useEffect23(() => () => window.clearTimeout(debounceRef.current), []);
8926
+ useEffect23(() => {
8807
8927
  if (!open || active < 0) return;
8808
8928
  const el = listRef.current?.querySelector(`[data-index="${active}"]`);
8809
8929
  el?.scrollIntoView?.({ block: "nearest" });
8810
8930
  }, [open, active]);
8811
- useEffect22(() => {
8931
+ useEffect23(() => {
8812
8932
  if (open) listRef.current?.scrollIntoView?.({ block: "nearest" });
8813
8933
  }, [open]);
8814
8934
  const reset = useCallback10(() => {
@@ -9027,8 +9147,8 @@ function Combobox({
9027
9147
 
9028
9148
  // src/components/split.tsx
9029
9149
  import {
9030
- useEffect as useEffect23,
9031
- useLayoutEffect as useLayoutEffect5,
9150
+ useEffect as useEffect24,
9151
+ useLayoutEffect as useLayoutEffect6,
9032
9152
  useRef as useRef22,
9033
9153
  useState as useState22
9034
9154
  } from "react";
@@ -9467,10 +9587,10 @@ function SplitDividers({ layout, w, h, gap, onResize, onDragChange, minPane, bar
9467
9587
  const hit = coarse ? 44 : 24;
9468
9588
  const baseMin = minPane ?? { w: 160, h: 90 };
9469
9589
  const onDragChangeRef = useRef22(onDragChange);
9470
- useEffect23(() => {
9590
+ useEffect24(() => {
9471
9591
  onDragChangeRef.current = onDragChange;
9472
9592
  });
9473
- useEffect23(
9593
+ useEffect24(
9474
9594
  () => () => {
9475
9595
  if (drag.current) {
9476
9596
  drag.current = null;
@@ -9598,10 +9718,10 @@ function SplitStage({
9598
9718
  const showDividers = resizable && !!layout && slots.length > 1;
9599
9719
  if (!showDividers && resizing) setResizing(false);
9600
9720
  const onSizeRef = useRef22(onSize);
9601
- useEffect23(() => {
9721
+ useEffect24(() => {
9602
9722
  onSizeRef.current = onSize;
9603
9723
  });
9604
- useLayoutEffect5(() => {
9724
+ useLayoutEffect6(() => {
9605
9725
  const el = ref.current;
9606
9726
  if (!el) return;
9607
9727
  const measure = () => {
@@ -9615,7 +9735,7 @@ function SplitStage({
9615
9735
  ro.observe(el);
9616
9736
  return () => ro.disconnect();
9617
9737
  }, []);
9618
- useEffect23(() => {
9738
+ useEffect24(() => {
9619
9739
  onSizeRef.current?.(size);
9620
9740
  }, [size]);
9621
9741
  const measured = size.w > 0 && size.h > 0;