@luxfi/ui 7.4.0 → 7.4.3

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.
Files changed (131) hide show
  1. package/dist/avatar.cjs +7 -6
  2. package/dist/avatar.js +7 -5
  3. package/dist/badge.cjs +33 -35
  4. package/dist/badge.js +33 -35
  5. package/dist/bank.d.cts +3 -3
  6. package/dist/bank.d.ts +3 -3
  7. package/dist/checkbox.cjs +4 -4
  8. package/dist/checkbox.d.cts +3 -2
  9. package/dist/checkbox.d.ts +3 -2
  10. package/dist/checkbox.js +5 -4
  11. package/dist/chrome.cjs +960 -0
  12. package/dist/chrome.d.cts +93 -0
  13. package/dist/chrome.d.ts +93 -0
  14. package/dist/chrome.js +931 -0
  15. package/dist/drawer.cjs +86 -20
  16. package/dist/drawer.js +85 -19
  17. package/dist/expiration-selector.cjs +3 -2
  18. package/dist/expiration-selector.js +3 -2
  19. package/dist/greeks-display.cjs +6 -6
  20. package/dist/greeks-display.js +6 -6
  21. package/dist/gui.cjs +13 -0
  22. package/dist/gui.d.cts +2 -0
  23. package/dist/gui.d.ts +2 -0
  24. package/dist/gui.js +2 -0
  25. package/dist/heading.cjs +4 -2
  26. package/dist/heading.js +4 -2
  27. package/dist/iam.cjs +216 -0
  28. package/dist/iam.d.cts +65 -0
  29. package/dist/iam.d.ts +65 -0
  30. package/dist/iam.js +211 -0
  31. package/dist/icons.cjs +13 -0
  32. package/dist/icons.d.cts +1 -0
  33. package/dist/icons.d.ts +1 -0
  34. package/dist/icons.js +2 -0
  35. package/dist/identity.cjs +430 -0
  36. package/dist/identity.d.cts +64 -0
  37. package/dist/identity.d.ts +64 -0
  38. package/dist/identity.js +408 -0
  39. package/dist/index.cjs +1610 -836
  40. package/dist/index.d.cts +7 -3
  41. package/dist/index.d.ts +7 -3
  42. package/dist/index.js +1587 -831
  43. package/dist/input.cjs +3 -1
  44. package/dist/input.d.cts +3 -5
  45. package/dist/input.d.ts +3 -5
  46. package/dist/input.js +3 -1
  47. package/dist/lux.config.cjs +23 -2
  48. package/dist/lux.config.d.cts +28 -10
  49. package/dist/lux.config.d.ts +28 -10
  50. package/dist/lux.config.js +23 -2
  51. package/dist/menu.cjs +4 -4
  52. package/dist/menu.js +4 -4
  53. package/dist/next.cjs +132 -0
  54. package/dist/next.d.cts +32 -0
  55. package/dist/next.d.ts +32 -0
  56. package/dist/next.js +129 -0
  57. package/dist/option-chain.cjs +1 -1
  58. package/dist/option-chain.js +1 -1
  59. package/dist/option-position.cjs +2 -1
  60. package/dist/option-position.js +2 -1
  61. package/dist/pnl-diagram.cjs +8 -6
  62. package/dist/pnl-diagram.js +8 -6
  63. package/dist/progress.cjs +7 -6
  64. package/dist/progress.js +7 -5
  65. package/dist/provider.cjs +146 -4
  66. package/dist/provider.d.cts +15 -3
  67. package/dist/provider.d.ts +15 -3
  68. package/dist/provider.js +146 -5
  69. package/dist/radio.cjs +9 -7
  70. package/dist/radio.js +10 -7
  71. package/dist/separator.cjs +3 -1
  72. package/dist/separator.js +3 -1
  73. package/dist/slider.cjs +28 -16
  74. package/dist/slider.js +28 -15
  75. package/dist/strategy-builder.cjs +2 -1
  76. package/dist/strategy-builder.js +2 -1
  77. package/dist/switch.cjs +11 -12
  78. package/dist/switch.js +12 -12
  79. package/dist/tag.cjs +34 -36
  80. package/dist/tag.js +33 -35
  81. package/dist/textarea.cjs +3 -1
  82. package/dist/textarea.js +3 -1
  83. package/dist/tooltip.cjs +28 -30
  84. package/dist/tooltip.js +27 -29
  85. package/dist/use-narrow.cjs +46 -0
  86. package/dist/use-narrow.d.cts +12 -0
  87. package/dist/use-narrow.d.ts +12 -0
  88. package/dist/use-narrow.js +20 -0
  89. package/dist/vite.cjs +109 -0
  90. package/dist/vite.d.cts +29 -0
  91. package/dist/vite.d.ts +29 -0
  92. package/dist/vite.js +107 -0
  93. package/dist/white-label.cjs +142 -0
  94. package/dist/white-label.d.cts +59 -0
  95. package/dist/white-label.d.ts +59 -0
  96. package/dist/white-label.js +134 -0
  97. package/package.json +85 -19
  98. package/src/avatar.tsx +22 -16
  99. package/src/checkbox.tsx +15 -10
  100. package/src/chrome.tsx +459 -0
  101. package/src/drawer.tsx +83 -10
  102. package/src/engine.ts +130 -0
  103. package/src/expiration-selector.tsx +3 -2
  104. package/src/greeks-display.tsx +9 -6
  105. package/src/gui.ts +17 -0
  106. package/src/heading.tsx +12 -8
  107. package/src/iam.ts +170 -0
  108. package/src/icons.ts +18 -0
  109. package/src/identity.tsx +318 -0
  110. package/src/index.ts +44 -1
  111. package/src/input.tsx +13 -9
  112. package/src/lux.config.ts +16 -15
  113. package/src/menu.tsx +4 -4
  114. package/src/next.ts +89 -0
  115. package/src/option-chain.tsx +1 -1
  116. package/src/option-position.tsx +2 -1
  117. package/src/pnl-diagram.tsx +11 -6
  118. package/src/progress.tsx +15 -8
  119. package/src/provider.tsx +48 -7
  120. package/src/radio.tsx +15 -11
  121. package/src/separator.tsx +8 -3
  122. package/src/slider.tsx +35 -19
  123. package/src/strategy-builder.tsx +3 -2
  124. package/src/switch.tsx +17 -16
  125. package/src/textarea.tsx +8 -4
  126. package/src/tooltip.tsx +15 -24
  127. package/src/use-narrow.ts +40 -0
  128. package/src/vite.ts +80 -0
  129. package/src/white-label.ts +254 -0
  130. package/tokens.css +613 -319
  131. package/src/tokens.css +0 -438
@@ -0,0 +1,960 @@
1
+ "use client";
2
+ 'use strict';
3
+
4
+ var React6 = require('react');
5
+ var lucideReact = require('lucide-react');
6
+ var gui = require('@hanzo/gui');
7
+ var RadixDialog = require('@radix-ui/react-dialog');
8
+ var clsx = require('clsx');
9
+ var tailwindMerge = require('tailwind-merge');
10
+ var jsxRuntime = require('react/jsx-runtime');
11
+ var reactQuery = require('@tanstack/react-query');
12
+ var DropdownMenu = require('@radix-ui/react-dropdown-menu');
13
+
14
+ function _interopNamespace(e) {
15
+ if (e && e.__esModule) return e;
16
+ var n = Object.create(null);
17
+ if (e) {
18
+ Object.keys(e).forEach(function (k) {
19
+ if (k !== 'default') {
20
+ var d = Object.getOwnPropertyDescriptor(e, k);
21
+ Object.defineProperty(n, k, d.get ? d : {
22
+ enumerable: true,
23
+ get: function () { return e[k]; }
24
+ });
25
+ }
26
+ });
27
+ }
28
+ n.default = e;
29
+ return Object.freeze(n);
30
+ }
31
+
32
+ var React6__namespace = /*#__PURE__*/_interopNamespace(React6);
33
+ var RadixDialog__namespace = /*#__PURE__*/_interopNamespace(RadixDialog);
34
+ var DropdownMenu__namespace = /*#__PURE__*/_interopNamespace(DropdownMenu);
35
+
36
+ var NARROW_PX = 640;
37
+ function useBelow(px) {
38
+ const [below, setBelow] = React6__namespace.useState(false);
39
+ React6__namespace.useEffect(() => {
40
+ const mql = window.matchMedia(`(max-width: ${px - 1}px)`);
41
+ const apply = () => setBelow(mql.matches);
42
+ apply();
43
+ mql.addEventListener("change", apply);
44
+ return () => mql.removeEventListener("change", apply);
45
+ }, [px]);
46
+ return below;
47
+ }
48
+ var useIsNarrow = () => useBelow(NARROW_PX);
49
+ function cn(...inputs) {
50
+ return tailwindMerge.twMerge(clsx.clsx(inputs));
51
+ }
52
+ var CLOSE_ICON_PATH = "M9.44 8.035a.791.791 0 0 0 1.12 0l3.802-3.803a.791.791 0 0 1 1.119 0l.287.287a.79.79 0 0 1 0 1.119L11.965 9.44a.79.79 0 0 0 0 1.118l3.803 3.803a.791.791 0 0 1 0 1.119l-.287.287a.791.791 0 0 1-1.119 0l-3.803-3.803a.79.79 0 0 0-1.118 0l-3.803 3.803a.79.79 0 0 1-1.119 0l-.287-.287a.791.791 0 0 1 0-1.119l3.803-3.803a.791.791 0 0 0 0-1.118L4.232 5.638a.791.791 0 0 1 0-1.119l.287-.287a.791.791 0 0 1 1.119 0L9.44 8.035Z";
53
+ var CloseButtonFrame = gui.styled(gui.View, {
54
+ name: "LuxCloseButton",
55
+ render: /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", "aria-label": "Close" }),
56
+ role: "button",
57
+ cursor: "pointer",
58
+ display: "inline-flex",
59
+ alignItems: "center",
60
+ justifyContent: "center",
61
+ width: 20,
62
+ height: 20,
63
+ minWidth: 0,
64
+ flexShrink: 1,
65
+ padding: 0,
66
+ borderRadius: 4,
67
+ borderWidth: 0,
68
+ overflow: "hidden",
69
+ backgroundColor: "transparent",
70
+ hoverStyle: {
71
+ backgroundColor: "transparent"
72
+ },
73
+ variants: {
74
+ disabled: {
75
+ true: {
76
+ opacity: 0.4,
77
+ pointerEvents: "none"
78
+ }
79
+ }
80
+ }
81
+ });
82
+ var CLOSE_BUTTON_CLASSES = [
83
+ "text-[var(--closeButton-fg,currentColor)]",
84
+ "hover:text-[var(--hover-color,currentColor)]",
85
+ "disabled:opacity-40"
86
+ ].join(" ");
87
+ var CloseButton = React6__namespace.forwardRef(function CloseButton2(props, ref) {
88
+ const { variant: _variant, size: _size, className, children, ...rest } = props;
89
+ return /* @__PURE__ */ jsxRuntime.jsx(
90
+ CloseButtonFrame,
91
+ {
92
+ ref,
93
+ className: [CLOSE_BUTTON_CLASSES, className].filter(Boolean).join(" "),
94
+ ...rest,
95
+ children: children ?? /* @__PURE__ */ jsxRuntime.jsx(
96
+ "svg",
97
+ {
98
+ className: "size-5",
99
+ viewBox: "0 0 20 20",
100
+ fill: "none",
101
+ "aria-hidden": "true",
102
+ children: /* @__PURE__ */ jsxRuntime.jsx(
103
+ "path",
104
+ {
105
+ d: CLOSE_ICON_PATH,
106
+ fill: "currentColor"
107
+ }
108
+ )
109
+ }
110
+ )
111
+ }
112
+ );
113
+ });
114
+ var DrawerPlacementContext = React6__namespace.createContext("right");
115
+ var DrawerSizeContext = React6__namespace.createContext("md");
116
+ var DrawerStateContext = React6__namespace.createContext({
117
+ open: false,
118
+ setOpen: () => {
119
+ },
120
+ modal: true
121
+ });
122
+ var DrawerRoot = (props) => {
123
+ const {
124
+ children,
125
+ open,
126
+ defaultOpen,
127
+ onOpenChange,
128
+ placement = "right",
129
+ modal = true,
130
+ size = "md"
131
+ } = props;
132
+ const [uncontrolled, setUncontrolled] = React6__namespace.useState(defaultOpen ?? false);
133
+ const isControlled = open !== void 0;
134
+ const isOpen = isControlled ? open : uncontrolled;
135
+ const setOpen = React6__namespace.useCallback((nextOpen) => {
136
+ if (!isControlled) setUncontrolled(nextOpen);
137
+ onOpenChange?.({ open: nextOpen });
138
+ }, [isControlled, onOpenChange]);
139
+ const state = React6__namespace.useMemo(
140
+ () => ({ open: isOpen, setOpen, modal }),
141
+ [isOpen, setOpen, modal]
142
+ );
143
+ return /* @__PURE__ */ jsxRuntime.jsx(DrawerPlacementContext.Provider, { value: placement, children: /* @__PURE__ */ jsxRuntime.jsx(DrawerSizeContext.Provider, { value: size, children: /* @__PURE__ */ jsxRuntime.jsx(DrawerStateContext.Provider, { value: state, children: /* @__PURE__ */ jsxRuntime.jsx(
144
+ RadixDialog__namespace.Root,
145
+ {
146
+ open: isOpen,
147
+ onOpenChange: setOpen,
148
+ modal,
149
+ children
150
+ }
151
+ ) }) }) });
152
+ };
153
+ var PLACEMENT_CLASSES = {
154
+ right: [
155
+ "inset-y-0 right-0",
156
+ "data-[state=open]:animate-in data-[state=open]:slide-in-from-right",
157
+ "data-[state=closed]:animate-out data-[state=closed]:slide-out-to-right"
158
+ ].join(" "),
159
+ left: [
160
+ "inset-y-0 left-0",
161
+ "data-[state=open]:animate-in data-[state=open]:slide-in-from-left",
162
+ "data-[state=closed]:animate-out data-[state=closed]:slide-out-to-left"
163
+ ].join(" "),
164
+ top: [
165
+ "inset-x-0 top-0",
166
+ "data-[state=open]:animate-in data-[state=open]:slide-in-from-top",
167
+ "data-[state=closed]:animate-out data-[state=closed]:slide-out-to-top"
168
+ ].join(" "),
169
+ bottom: [
170
+ "inset-x-0 bottom-0",
171
+ "data-[state=open]:animate-in data-[state=open]:slide-in-from-bottom",
172
+ "data-[state=closed]:animate-out data-[state=closed]:slide-out-to-bottom"
173
+ ].join(" ")
174
+ };
175
+ var SIZE_CLASSES = {
176
+ right: { xs: "w-60", sm: "w-80", md: "w-96", lg: "w-[480px]", xl: "w-[640px]", full: "w-screen" },
177
+ left: { xs: "w-60", sm: "w-80", md: "w-96", lg: "w-[480px]", xl: "w-[640px]", full: "w-screen" },
178
+ top: { xs: "h-40", sm: "h-60", md: "h-80", lg: "h-96", xl: "h-[480px]", full: "h-screen" },
179
+ bottom: { xs: "h-40", sm: "h-60", md: "h-80", lg: "h-96", xl: "h-[480px]", full: "h-screen" }
180
+ };
181
+ var DrawerContent = React6__namespace.forwardRef(
182
+ function DrawerContent2(props, ref) {
183
+ const { children, portalled = true, portalRef, offset: _offset, backdrop = true, className, ...rest } = props;
184
+ const placement = React6__namespace.useContext(DrawerPlacementContext);
185
+ const size = React6__namespace.useContext(DrawerSizeContext);
186
+ const { open, setOpen, modal } = React6__namespace.useContext(DrawerStateContext);
187
+ const isNarrow = useIsNarrow();
188
+ if (isNarrow) {
189
+ return /* @__PURE__ */ jsxRuntime.jsxs(
190
+ gui.Sheet,
191
+ {
192
+ open,
193
+ onOpenChange: setOpen,
194
+ modal,
195
+ dismissOnSnapToBottom: true,
196
+ snapPointsMode: "percent",
197
+ snapPoints: [88],
198
+ transition: "medium",
199
+ children: [
200
+ backdrop && /* @__PURE__ */ jsxRuntime.jsx(
201
+ gui.Sheet.Overlay,
202
+ {
203
+ transition: "lazy",
204
+ enterStyle: { opacity: 0 },
205
+ exitStyle: { opacity: 0 },
206
+ className: "bg-black/50"
207
+ }
208
+ ),
209
+ /* @__PURE__ */ jsxRuntime.jsx(gui.Sheet.Handle, {}),
210
+ /* @__PURE__ */ jsxRuntime.jsx(
211
+ gui.Sheet.Frame,
212
+ {
213
+ unstyled: true,
214
+ className: cn(
215
+ "flex flex-col rounded-t-2xl bg-[var(--color-drawer-bg)] shadow-[var(--shadow-drawer)]",
216
+ className
217
+ ),
218
+ ...rest,
219
+ children
220
+ }
221
+ )
222
+ ]
223
+ }
224
+ );
225
+ }
226
+ const content = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
227
+ backdrop && /* @__PURE__ */ jsxRuntime.jsx(
228
+ RadixDialog__namespace.Overlay,
229
+ {
230
+ className: cn(
231
+ "fixed inset-0 z-50 bg-black/50",
232
+ "data-[state=open]:animate-in data-[state=open]:fade-in-0",
233
+ "data-[state=closed]:animate-out data-[state=closed]:fade-out-0"
234
+ )
235
+ }
236
+ ),
237
+ /* @__PURE__ */ jsxRuntime.jsx(
238
+ RadixDialog__namespace.Content,
239
+ {
240
+ ref,
241
+ className: cn(
242
+ "fixed z-50 flex flex-col bg-[var(--color-drawer-bg)] shadow-[var(--shadow-drawer)] duration-300",
243
+ PLACEMENT_CLASSES[placement] ?? PLACEMENT_CLASSES.right,
244
+ SIZE_CLASSES[placement]?.[size] ?? SIZE_CLASSES.right?.md,
245
+ className
246
+ ),
247
+ ...rest,
248
+ children
249
+ }
250
+ )
251
+ ] });
252
+ if (portalled) {
253
+ return /* @__PURE__ */ jsxRuntime.jsx(RadixDialog__namespace.Portal, { container: portalRef?.current ?? void 0, children: content });
254
+ }
255
+ return content;
256
+ }
257
+ );
258
+ React6__namespace.forwardRef(function DrawerCloseTrigger2(props, ref) {
259
+ return /* @__PURE__ */ jsxRuntime.jsx(RadixDialog__namespace.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
260
+ CloseButton,
261
+ {
262
+ ref,
263
+ className: cn("absolute top-7 right-5", props.className),
264
+ ...props
265
+ }
266
+ ) });
267
+ });
268
+ var DrawerHeader = React6__namespace.forwardRef(
269
+ function DrawerHeader2({ className, ...props }, ref) {
270
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: cn("flex flex-col gap-1.5 p-6 pb-0", className), ...props });
271
+ }
272
+ );
273
+ var DrawerBody = React6__namespace.forwardRef(
274
+ function DrawerBody2({ className, ...props }, ref) {
275
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: cn("flex-1 overflow-auto p-6", className), ...props });
276
+ }
277
+ );
278
+ React6__namespace.forwardRef(
279
+ function DrawerFooter2({ className, ...props }, ref) {
280
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: cn("flex items-center justify-end gap-2 p-6 pt-0", className), ...props });
281
+ }
282
+ );
283
+ var DrawerTitle = RadixDialog__namespace.Title;
284
+
285
+ // src/white-label.ts
286
+ var LUX_BRAND = {
287
+ lux: "#7000FF",
288
+ zoo: "#6C5EFB",
289
+ hanzo: "#EA580C",
290
+ pars: "#1C3879"};
291
+ var PARS_GOLD = "#C8A45C";
292
+ var ORGS = {
293
+ lux: {
294
+ org: "lux",
295
+ name: "Lux",
296
+ domain: "lux.network",
297
+ iamDomain: "lux.id",
298
+ accent: LUX_BRAND.lux,
299
+ accentForeground: "#FFFFFF"
300
+ },
301
+ zoo: {
302
+ org: "zoo",
303
+ name: "Zoo",
304
+ domain: "zoo.ngo",
305
+ // Zoo's issuer is `zoolabs.id` — the one row where it is not `<org>.id`,
306
+ // and the one every hand-rolled branding map gets wrong. `id.zoo.network`
307
+ // ANSWERS, which is why it keeps being copied around, but it is an alias:
308
+ // its own discovery document advertises
309
+ // issuer https://zoolabs.id
310
+ // authorization_endpoint https://zoolabs.id/v1/iam/oauth/authorize
311
+ // jwks_uri https://zoolabs.id/v1/iam/.well-known/jwks
312
+ // so a client configured on the alias validates `iss` against a string the
313
+ // IdP never emits and rejects every token it is given — the exact shape of
314
+ // the lux.id outage. `zoo.id` is not an IdP at all (no discovery document).
315
+ iamDomain: "zoolabs.id",
316
+ accent: LUX_BRAND.zoo,
317
+ accentForeground: "#FFFFFF"
318
+ },
319
+ bootnode: {
320
+ org: "bootnode",
321
+ name: "Bootnode",
322
+ domain: "bootno.de",
323
+ iamDomain: "id.bootno.de",
324
+ accent: LUX_BRAND.lux,
325
+ accentForeground: "#FFFFFF"
326
+ },
327
+ hanzo: {
328
+ org: "hanzo",
329
+ name: "Hanzo",
330
+ domain: "hanzo.ai",
331
+ iamDomain: "hanzo.id",
332
+ accent: LUX_BRAND.hanzo,
333
+ accentForeground: "#FFFFFF"
334
+ },
335
+ pars: {
336
+ org: "pars",
337
+ name: "Pars",
338
+ domain: "pars.id",
339
+ iamDomain: "pars.id",
340
+ accent: LUX_BRAND.pars,
341
+ accentForeground: PARS_GOLD
342
+ }
343
+ };
344
+ var DOMAIN_ORG = [
345
+ ["lux.network", "lux"],
346
+ ["lux.cloud", "lux"],
347
+ ["lux.id", "lux"],
348
+ ["lux.finance", "lux"],
349
+ ["lux.market", "lux"],
350
+ ["lux.exchange", "lux"],
351
+ ["zoo.ngo", "zoo"],
352
+ ["zoo.network", "zoo"],
353
+ ["zoo.cloud", "zoo"],
354
+ ["zoolabs.id", "zoo"],
355
+ ["hanzo.ai", "hanzo"],
356
+ ["hanzo.cloud", "hanzo"],
357
+ ["hanzo.id", "hanzo"],
358
+ ["pars.id", "pars", "app"],
359
+ ["pars.network", "pars", "app"],
360
+ ["parsdao.org", "pars", "app"],
361
+ ["bootno.de", "bootnode", "platform"]
362
+ ];
363
+ var DEFAULT_ORG = "lux";
364
+ function normalizeHost(host) {
365
+ const noPort = host.trim().toLowerCase().split(":")[0] ?? "";
366
+ return noPort.replace(/\.$/, "");
367
+ }
368
+ function isUnder(host, domain) {
369
+ return host === domain || host.endsWith(`.${domain}`);
370
+ }
371
+ function matchDomain(host) {
372
+ let best;
373
+ for (const entry of DOMAIN_ORG) {
374
+ if (isUnder(host, entry[0]) && (!best || entry[0].length > best[0].length)) {
375
+ best = entry;
376
+ }
377
+ }
378
+ return best;
379
+ }
380
+ function appSlug(host, domain, pinned) {
381
+ if (pinned) return pinned;
382
+ const sub = host === domain ? "" : host.slice(0, -(domain.length + 1));
383
+ const leftmost = sub.split(".")[0] ?? "";
384
+ if (leftmost && leftmost !== "www") return leftmost;
385
+ const label = domain.split(".")[0] ?? "";
386
+ const tld = domain.split(".").slice(1).join(".");
387
+ return tld.split(".")[0] || label;
388
+ }
389
+ function isLocal(host) {
390
+ return host === "localhost" || host.endsWith(".localhost") || host === "127.0.0.1" || host === "0.0.0.0" || host === "[::1]" || host.endsWith(".local");
391
+ }
392
+ function resolveWhiteLabel(host) {
393
+ const h = normalizeHost(host);
394
+ const match = h ? matchDomain(h) : void 0;
395
+ const org = match ? match[1] : DEFAULT_ORG;
396
+ const identity = ORGS[org];
397
+ const app = match ? appSlug(h, match[0], match[2]) : h && isLocal(h) ? "local" : "app";
398
+ return {
399
+ ...identity,
400
+ host: h,
401
+ app,
402
+ theme: `dark_${org}`,
403
+ issuer: `https://${identity.iamDomain}`,
404
+ clientId: `${org}-${app}`
405
+ };
406
+ }
407
+ new reactQuery.QueryClient({
408
+ defaultOptions: { queries: { refetchOnWindowFocus: false, retry: 1, staleTime: 3e4 } }
409
+ });
410
+ var WhiteLabelContext = React6__namespace.default.createContext(resolveWhiteLabel(""));
411
+ var useWhiteLabel = () => React6__namespace.default.useContext(WhiteLabelContext);
412
+ var IdentityContext = React6__namespace.createContext(null);
413
+ function useIdentity() {
414
+ const ctx = React6__namespace.useContext(IdentityContext);
415
+ const whiteLabel = useWhiteLabel();
416
+ const fallback = React6__namespace.useMemo(() => ({
417
+ status: "anonymous",
418
+ account: null,
419
+ orgs: [],
420
+ org: null,
421
+ projects: [],
422
+ project: null,
423
+ error: null,
424
+ whiteLabel,
425
+ setOrg: () => void 0,
426
+ setProject: () => void 0,
427
+ signIn: () => {
428
+ if (typeof window !== "undefined") window.location.assign("/login");
429
+ },
430
+ signOut: () => void 0,
431
+ reload: () => void 0
432
+ }), [whiteLabel]);
433
+ return ctx ?? fallback;
434
+ }
435
+ function parsePlacement(placement) {
436
+ if (!placement) {
437
+ return { side: "bottom", align: "start" };
438
+ }
439
+ const parts = placement.split("-");
440
+ const side = parts[0] ?? "bottom";
441
+ const alignPart = parts[1];
442
+ let align = "center";
443
+ if (alignPart === "start") {
444
+ align = "start";
445
+ } else if (alignPart === "end") {
446
+ align = "end";
447
+ }
448
+ return { side, align };
449
+ }
450
+ var PositioningContext = React6__namespace.createContext({
451
+ side: "bottom",
452
+ align: "start",
453
+ sideOffset: 4,
454
+ alignOffset: 0
455
+ });
456
+ var MenuRoot = (props) => {
457
+ const {
458
+ children,
459
+ open,
460
+ defaultOpen,
461
+ onOpenChange,
462
+ positioning,
463
+ modal = true,
464
+ // lazyMount / unmountOnExit have no direct Radix equivalent; Radix handles
465
+ // mount/unmount automatically.
466
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
467
+ lazyMount: _lazyMount,
468
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
469
+ unmountOnExit: _unmountOnExit
470
+ } = props;
471
+ const mergedPositioning = {
472
+ placement: "bottom-start",
473
+ ...positioning,
474
+ offset: {
475
+ mainAxis: 4,
476
+ ...positioning?.offset
477
+ }
478
+ };
479
+ const { side, align } = parsePlacement(mergedPositioning.placement);
480
+ const positioningValue = React6__namespace.useMemo(() => ({
481
+ side,
482
+ align,
483
+ sideOffset: mergedPositioning.offset?.mainAxis ?? 4,
484
+ alignOffset: mergedPositioning.offset?.crossAxis ?? 0
485
+ }), [side, align, mergedPositioning.offset?.mainAxis, mergedPositioning.offset?.crossAxis]);
486
+ const handleOpenChange = React6__namespace.useCallback((isOpen) => {
487
+ onOpenChange?.({ open: isOpen });
488
+ }, [onOpenChange]);
489
+ return /* @__PURE__ */ jsxRuntime.jsx(PositioningContext.Provider, { value: positioningValue, children: /* @__PURE__ */ jsxRuntime.jsx(
490
+ DropdownMenu__namespace.Root,
491
+ {
492
+ open,
493
+ defaultOpen,
494
+ onOpenChange: handleOpenChange,
495
+ modal,
496
+ children
497
+ }
498
+ ) });
499
+ };
500
+ var MenuTrigger = React6__namespace.forwardRef(function MenuTrigger2(props, ref) {
501
+ const { asChild = false, ...rest } = props;
502
+ return /* @__PURE__ */ jsxRuntime.jsx(DropdownMenu__namespace.Trigger, { asChild, ref, ...rest });
503
+ });
504
+ var MenuContent = React6__namespace.forwardRef(function MenuContent2(props, ref) {
505
+ const { portalled = true, portalRef, className, zIndex, minW, style, ...rest } = props;
506
+ const positioning = React6__namespace.useContext(PositioningContext);
507
+ const mergedStyle = {
508
+ ...style,
509
+ ...zIndex !== void 0 ? { zIndex: typeof zIndex === "string" ? `var(--z-index-${zIndex}, ${zIndex})` : zIndex } : {},
510
+ ...minW !== void 0 ? { minWidth: minW } : {}
511
+ };
512
+ const content = /* @__PURE__ */ jsxRuntime.jsx(
513
+ DropdownMenu__namespace.Content,
514
+ {
515
+ ref,
516
+ side: positioning.side,
517
+ align: positioning.align,
518
+ sideOffset: positioning.sideOffset,
519
+ alignOffset: positioning.alignOffset,
520
+ className: cn(
521
+ "z-50 min-w-[8rem] overflow-hidden rounded-lg p-1",
522
+ "border border-[var(--color-popover-border,var(--color-border-divider))]",
523
+ "bg-[var(--color-popover-bg,var(--color-dialog-bg))]",
524
+ "shadow-[0_4px_12px_var(--color-popover-shadow)]",
525
+ "outline-none",
526
+ "data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95",
527
+ "data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95",
528
+ "data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2",
529
+ "data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
530
+ className
531
+ ),
532
+ style: Object.keys(mergedStyle).length > 0 ? mergedStyle : void 0,
533
+ ...rest
534
+ }
535
+ );
536
+ if (!portalled) {
537
+ return content;
538
+ }
539
+ return /* @__PURE__ */ jsxRuntime.jsx(DropdownMenu__namespace.Portal, { container: portalRef?.current ?? void 0, children: content });
540
+ });
541
+ var MenuItem = React6__namespace.forwardRef(function MenuItem2(props, ref) {
542
+ const { className, value: _value, asChild, closeOnSelect: _closeOnSelect, disabled, children, onClick, ...rest } = props;
543
+ return /* @__PURE__ */ jsxRuntime.jsx(
544
+ DropdownMenu__namespace.Item,
545
+ {
546
+ ref,
547
+ asChild,
548
+ disabled,
549
+ onClick,
550
+ className: cn(
551
+ "relative flex cursor-pointer select-none items-center gap-2 rounded-md px-2 py-1.5 text-sm",
552
+ "outline-none transition-colors",
553
+ "text-[var(--color-text-primary,inherit)]",
554
+ "data-[highlighted]:bg-[var(--color-popover-item-hover,rgba(0,0,0,0.04))]",
555
+ "data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
556
+ className
557
+ ),
558
+ ...rest,
559
+ children
560
+ }
561
+ );
562
+ });
563
+ React6__namespace.forwardRef(function MenuItemText2(props, ref) {
564
+ const { className, ...rest } = props;
565
+ return /* @__PURE__ */ jsxRuntime.jsx("span", { ref, className: cn("flex-1", className), ...rest });
566
+ });
567
+ React6__namespace.forwardRef(function MenuItemCommand2(props, ref) {
568
+ const { className, ...rest } = props;
569
+ return /* @__PURE__ */ jsxRuntime.jsx(
570
+ "span",
571
+ {
572
+ ref,
573
+ className: cn("ml-auto text-xs tracking-widest opacity-60", className),
574
+ ...rest
575
+ }
576
+ );
577
+ });
578
+ var MenuSeparator = React6__namespace.forwardRef(function MenuSeparator2(props, ref) {
579
+ const { className, ...rest } = props;
580
+ return /* @__PURE__ */ jsxRuntime.jsx(
581
+ DropdownMenu__namespace.Separator,
582
+ {
583
+ ref,
584
+ className: cn("-mx-1 my-1 h-px bg-[var(--color-border-divider)]", className),
585
+ ...rest
586
+ }
587
+ );
588
+ });
589
+ React6__namespace.forwardRef(function MenuItemGroup2(props, ref) {
590
+ const { title, children, className, ...rest } = props;
591
+ return /* @__PURE__ */ jsxRuntime.jsxs(DropdownMenu__namespace.Group, { ref, className, ...rest, children: [
592
+ title && /* @__PURE__ */ jsxRuntime.jsx(DropdownMenu__namespace.Label, { className: "px-2 py-1.5 text-xs font-semibold select-none opacity-60", children: title }),
593
+ children
594
+ ] });
595
+ });
596
+ React6__namespace.forwardRef(function MenuArrow2(props, ref) {
597
+ const { className, ...rest } = props;
598
+ return /* @__PURE__ */ jsxRuntime.jsx(
599
+ DropdownMenu__namespace.Arrow,
600
+ {
601
+ ref,
602
+ className: cn("fill-[var(--color-popover-bg,var(--color-dialog-bg))]", className),
603
+ ...rest
604
+ }
605
+ );
606
+ });
607
+ React6__namespace.forwardRef(function MenuCheckboxItem2(props, ref) {
608
+ const { className, children, checked, onCheckedChange, onClick, ...rest } = props;
609
+ return /* @__PURE__ */ jsxRuntime.jsxs(
610
+ DropdownMenu__namespace.CheckboxItem,
611
+ {
612
+ ref,
613
+ checked,
614
+ onCheckedChange,
615
+ onClick,
616
+ className: cn(
617
+ "relative flex cursor-pointer select-none items-center rounded-md py-1.5 pr-2 pl-8 text-sm",
618
+ "outline-none transition-colors",
619
+ "data-[highlighted]:bg-[var(--color-popover-item-hover,rgba(0,0,0,0.04))]",
620
+ "data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
621
+ className
622
+ ),
623
+ ...rest,
624
+ children: [
625
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "absolute left-2 flex h-3.5 w-3.5 items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(DropdownMenu__namespace.ItemIndicator, { children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { className: "h-4 w-4" }) }) }),
626
+ children
627
+ ]
628
+ }
629
+ );
630
+ });
631
+ React6__namespace.forwardRef(function MenuRadioItemGroup2(props, ref) {
632
+ const { value, onValueChange, ...rest } = props;
633
+ return /* @__PURE__ */ jsxRuntime.jsx(
634
+ DropdownMenu__namespace.RadioGroup,
635
+ {
636
+ ref,
637
+ value,
638
+ onValueChange,
639
+ ...rest
640
+ }
641
+ );
642
+ });
643
+ React6__namespace.forwardRef(function MenuRadioItem2(props, ref) {
644
+ const { className, children, value, onClick, ...rest } = props;
645
+ const { value: _v, ...radixRest } = rest;
646
+ return /* @__PURE__ */ jsxRuntime.jsxs(
647
+ DropdownMenu__namespace.RadioItem,
648
+ {
649
+ ref,
650
+ value,
651
+ onClick,
652
+ className: cn(
653
+ "relative flex cursor-pointer select-none items-center rounded-md py-1.5 pr-2 pl-8 text-sm",
654
+ "outline-none transition-colors",
655
+ "data-[highlighted]:bg-[var(--color-popover-item-hover,rgba(0,0,0,0.04))]",
656
+ "data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
657
+ className
658
+ ),
659
+ children: [
660
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "absolute left-2 flex h-3.5 w-3.5 items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(DropdownMenu__namespace.ItemIndicator, { children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { className: "h-4 w-4" }) }) }),
661
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children })
662
+ ]
663
+ }
664
+ );
665
+ });
666
+ React6__namespace.forwardRef(function MenuContextTrigger2(props, ref) {
667
+ const { asChild: _asChild, ...rest } = props;
668
+ return /* @__PURE__ */ jsxRuntime.jsx("span", { ref, ...rest });
669
+ });
670
+ React6__namespace.forwardRef(function MenuTriggerItem2(props, ref) {
671
+ const { startIcon, children, className, ...rest } = props;
672
+ return /* @__PURE__ */ jsxRuntime.jsx(DropdownMenu__namespace.Sub, { children: /* @__PURE__ */ jsxRuntime.jsxs(
673
+ DropdownMenu__namespace.SubTrigger,
674
+ {
675
+ ref,
676
+ className: cn(
677
+ "relative flex cursor-pointer select-none items-center gap-2 rounded-md px-2 py-1.5 text-sm",
678
+ "outline-none transition-colors",
679
+ "data-[highlighted]:bg-[var(--color-popover-item-hover,rgba(0,0,0,0.04))]",
680
+ className
681
+ ),
682
+ ...rest,
683
+ children: [
684
+ startIcon,
685
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex-1", children }),
686
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronRight, { className: "h-4 w-4" })
687
+ ]
688
+ }
689
+ ) });
690
+ });
691
+ function initials(label) {
692
+ return label.split(/[\s._-]+/).filter(Boolean).map((w) => w[0]).join("").slice(0, 2).toUpperCase();
693
+ }
694
+ var Monogram = ({ label, logo }) => logo ? /* @__PURE__ */ jsxRuntime.jsx("img", { src: logo, alt: "", className: "h-5 w-5 shrink-0 rounded object-contain" }) : /* @__PURE__ */ jsxRuntime.jsx(
695
+ "span",
696
+ {
697
+ "aria-hidden": "true",
698
+ className: "flex h-5 w-5 shrink-0 items-center justify-center rounded bg-[rgba(127,127,127,0.22)] text-[10px] font-bold",
699
+ children: initials(label)
700
+ }
701
+ );
702
+ var Row = ({ item, onDone, menu }) => {
703
+ const body = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
704
+ item.icon,
705
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex-1 truncate", children: item.label }),
706
+ item.hint ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs opacity-60", children: item.hint }) : null,
707
+ item.selected ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { "aria-hidden": "true", className: "h-4 w-4 shrink-0" }) : null
708
+ ] });
709
+ const className = cn(
710
+ "flex w-full cursor-pointer select-none items-center gap-2.5 rounded-md px-2 py-2 text-left text-sm",
711
+ "hover:bg-[rgba(127,127,127,0.14)]",
712
+ item.danger && "text-[var(--color-text-error,#e5484d)]"
713
+ );
714
+ const activate = () => {
715
+ onDone();
716
+ item.onSelect?.();
717
+ };
718
+ const shared = {
719
+ "data-testid": `chrome-item-${item.id}`,
720
+ "aria-current": item.selected ? "true" : void 0,
721
+ className
722
+ };
723
+ const control = item.href ? /* @__PURE__ */ jsxRuntime.jsx("a", { href: item.href, ...shared, onClick: onDone, children: body }) : /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", ...shared, onClick: activate, children: body });
724
+ return menu ? /* @__PURE__ */ jsxRuntime.jsx(MenuItem, { value: item.id, asChild: true, children: control }) : control;
725
+ };
726
+ var Switcher = ({
727
+ title,
728
+ label,
729
+ icon,
730
+ items,
731
+ footer = [],
732
+ status = "ready",
733
+ empty = "Nothing here yet.",
734
+ onSignIn,
735
+ signInLabel = "Sign in",
736
+ error,
737
+ align = "start",
738
+ testId
739
+ }) => {
740
+ const [open, setOpen] = React6__namespace.useState(false);
741
+ const narrow = useIsNarrow();
742
+ const close = React6__namespace.useCallback(() => setOpen(false), []);
743
+ const message = status === "loading" ? "Loading\u2026" : status === "error" ? error ?? "Could not reach IAM." : status === "anonymous" ? null : items.length === 0 ? empty : null;
744
+ const rows = status === "anonymous" && onSignIn ? [{ id: "sign-in", label: signInLabel, icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.User, { "aria-hidden": "true", className: "h-4 w-4" }), onSelect: onSignIn }] : status === "ready" ? items : [];
745
+ const panel = (menu) => /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
746
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-2 pb-1 pt-1 text-[11px] font-semibold uppercase tracking-wide opacity-55", children: title }),
747
+ message ? /* @__PURE__ */ jsxRuntime.jsx("div", { "data-testid": "chrome-message", className: "px-2 py-2 text-sm opacity-70", children: message }) : null,
748
+ rows.map((item) => /* @__PURE__ */ jsxRuntime.jsx(Row, { item, onDone: close, menu }, item.id)),
749
+ footer.length > 0 ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
750
+ menu ? /* @__PURE__ */ jsxRuntime.jsx(MenuSeparator, { className: "my-1 h-px bg-[var(--color-border-divider,rgba(127,127,127,0.25))]" }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "my-1 h-px bg-[var(--color-border-divider,rgba(127,127,127,0.25))]" }),
751
+ footer.map((item) => /* @__PURE__ */ jsxRuntime.jsx(Row, { item, onDone: close, menu }, item.id))
752
+ ] }) : null
753
+ ] });
754
+ const trigger = /* @__PURE__ */ jsxRuntime.jsxs(
755
+ "button",
756
+ {
757
+ type: "button",
758
+ "data-testid": testId,
759
+ "aria-label": title,
760
+ "aria-haspopup": "menu",
761
+ "aria-expanded": open,
762
+ className: cn(
763
+ "flex max-w-[14rem] items-center gap-2 rounded-md px-2 py-1.5 text-sm font-medium",
764
+ "hover:bg-[rgba(127,127,127,0.14)]"
765
+ ),
766
+ children: [
767
+ icon,
768
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate", children: label }),
769
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronsUpDown, { "aria-hidden": "true", className: "h-3.5 w-3.5 shrink-0 opacity-60" })
770
+ ]
771
+ }
772
+ );
773
+ if (narrow) {
774
+ return /* @__PURE__ */ jsxRuntime.jsxs(DrawerRoot, { open, onOpenChange: (d) => setOpen(d.open), placement: "bottom", size: "md", children: [
775
+ React6__namespace.cloneElement(trigger, { onClick: () => setOpen(true) }),
776
+ /* @__PURE__ */ jsxRuntime.jsxs(DrawerContent, { "data-testid": testId ? `${testId}-panel` : void 0, children: [
777
+ /* @__PURE__ */ jsxRuntime.jsx(DrawerHeader, { children: /* @__PURE__ */ jsxRuntime.jsx(DrawerTitle, { children: title }) }),
778
+ /* @__PURE__ */ jsxRuntime.jsx(DrawerBody, { children: panel(false) })
779
+ ] })
780
+ ] });
781
+ }
782
+ return /* @__PURE__ */ jsxRuntime.jsxs(
783
+ MenuRoot,
784
+ {
785
+ open,
786
+ onOpenChange: (d) => setOpen(d.open),
787
+ positioning: { placement: align === "end" ? "bottom-end" : "bottom-start" },
788
+ children: [
789
+ /* @__PURE__ */ jsxRuntime.jsx(MenuTrigger, { asChild: true, children: trigger }),
790
+ /* @__PURE__ */ jsxRuntime.jsx(MenuContent, { minW: "16rem", "data-testid": testId ? `${testId}-panel` : void 0, children: panel(true) })
791
+ ]
792
+ }
793
+ );
794
+ };
795
+ var OrgSwitcher = () => {
796
+ const id = useIdentity();
797
+ return /* @__PURE__ */ jsxRuntime.jsx(
798
+ Switcher,
799
+ {
800
+ testId: "org-switcher",
801
+ title: "Organization",
802
+ label: id.org?.displayName || id.org?.name || id.whiteLabel.name,
803
+ icon: /* @__PURE__ */ jsxRuntime.jsx(Monogram, { label: id.org?.displayName || id.org?.name || id.whiteLabel.name, logo: id.org?.logo }),
804
+ status: id.status,
805
+ error: id.error,
806
+ empty: "No organizations for this account.",
807
+ onSignIn: id.signIn,
808
+ signInLabel: `Sign in with ${id.whiteLabel.iamDomain}`,
809
+ items: id.orgs.map((o) => ({
810
+ id: o.name,
811
+ label: o.displayName || o.name,
812
+ icon: /* @__PURE__ */ jsxRuntime.jsx(Monogram, { label: o.displayName || o.name, logo: o.logo }),
813
+ selected: o.name === id.org?.name,
814
+ onSelect: () => id.setOrg(o.name)
815
+ }))
816
+ }
817
+ );
818
+ };
819
+ var ProjectSwitcher = () => {
820
+ const id = useIdentity();
821
+ if (id.status === "ready" && id.projects.length === 0) return null;
822
+ return /* @__PURE__ */ jsxRuntime.jsx(
823
+ Switcher,
824
+ {
825
+ testId: "project-switcher",
826
+ title: "Project",
827
+ label: id.project?.displayName || id.project?.name || "Project",
828
+ icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Folder, { "aria-hidden": "true", className: "h-4 w-4 opacity-70" }),
829
+ status: id.status,
830
+ error: id.error,
831
+ empty: "No projects in this organization.",
832
+ onSignIn: id.signIn,
833
+ items: id.projects.map((p) => ({
834
+ id: p.name,
835
+ label: p.displayName || p.name,
836
+ icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Folder, { "aria-hidden": "true", className: "h-4 w-4 opacity-70" }),
837
+ selected: p.name === id.project?.name,
838
+ onSelect: () => id.setProject(p.name)
839
+ }))
840
+ }
841
+ );
842
+ };
843
+ var UserMenu = ({ items = [] }) => {
844
+ const id = useIdentity();
845
+ const who = id.account?.displayName || id.account?.email || id.account?.name || "Account";
846
+ return /* @__PURE__ */ jsxRuntime.jsx(
847
+ Switcher,
848
+ {
849
+ testId: "user-menu",
850
+ align: "end",
851
+ title: id.status === "ready" ? who : "Account",
852
+ label: id.status === "ready" ? who : "Sign in",
853
+ icon: id.status === "ready" ? /* @__PURE__ */ jsxRuntime.jsx(Monogram, { label: who, logo: id.account?.avatar }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.User, { "aria-hidden": "true", className: "h-4 w-4 opacity-70" }),
854
+ status: id.status,
855
+ error: id.error,
856
+ onSignIn: id.signIn,
857
+ signInLabel: `Sign in with ${id.whiteLabel.iamDomain}`,
858
+ items: [
859
+ { id: "account", label: id.account?.email || who, icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.User, { "aria-hidden": "true", className: "h-4 w-4 opacity-70" }) },
860
+ ...items
861
+ ],
862
+ footer: id.status === "ready" ? [{ id: "sign-out", label: "Sign out", danger: true, icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.LogOut, { "aria-hidden": "true", className: "h-4 w-4" }), onSelect: id.signOut }] : []
863
+ }
864
+ );
865
+ };
866
+ var SettingsMenu = ({ items = [], href = "/settings" }) => /* @__PURE__ */ jsxRuntime.jsx(
867
+ Switcher,
868
+ {
869
+ testId: "settings-menu",
870
+ align: "end",
871
+ title: "Settings",
872
+ label: "Settings",
873
+ icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Settings, { "aria-hidden": "true", className: "h-4 w-4 opacity-70" }),
874
+ items,
875
+ empty: "No settings on this surface.",
876
+ footer: [{ id: "all-settings", label: "All settings", href, icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Settings, { "aria-hidden": "true", className: "h-4 w-4 opacity-70" }) }]
877
+ }
878
+ );
879
+ var AppNav = ({
880
+ brand,
881
+ home = "/",
882
+ links = [],
883
+ org = true,
884
+ project = false,
885
+ settings,
886
+ userItems,
887
+ children
888
+ }) => {
889
+ const id = useIdentity();
890
+ const narrow = useIsNarrow();
891
+ const [menu, setMenu] = React6__namespace.useState(false);
892
+ return /* @__PURE__ */ jsxRuntime.jsx(
893
+ "header",
894
+ {
895
+ "data-testid": "app-nav",
896
+ className: "sticky top-0 z-50 border-b border-[var(--color-border-divider,rgba(127,127,127,0.25))] bg-[var(--color-bg-body,inherit)]",
897
+ children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mx-auto flex h-14 max-w-7xl items-center gap-2 px-4", children: [
898
+ narrow && links.length > 0 ? /* @__PURE__ */ jsxRuntime.jsxs(DrawerRoot, { open: menu, onOpenChange: (d) => setMenu(d.open), placement: "bottom", size: "md", children: [
899
+ /* @__PURE__ */ jsxRuntime.jsx(
900
+ "button",
901
+ {
902
+ type: "button",
903
+ "aria-label": "Menu",
904
+ "data-testid": "nav-menu",
905
+ className: "rounded-md p-2 hover:bg-[rgba(127,127,127,0.14)]",
906
+ onClick: () => setMenu(true),
907
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Menu, { "aria-hidden": "true", className: "h-5 w-5" })
908
+ }
909
+ ),
910
+ /* @__PURE__ */ jsxRuntime.jsxs(DrawerContent, { "data-testid": "nav-menu-panel", children: [
911
+ /* @__PURE__ */ jsxRuntime.jsx(DrawerHeader, { children: /* @__PURE__ */ jsxRuntime.jsx(DrawerTitle, { children: "Menu" }) }),
912
+ /* @__PURE__ */ jsxRuntime.jsx(DrawerBody, { children: links.map((l) => /* @__PURE__ */ jsxRuntime.jsx(
913
+ "a",
914
+ {
915
+ href: l.href,
916
+ onClick: () => setMenu(false),
917
+ "aria-current": l.active ? "page" : void 0,
918
+ className: "block rounded-md px-2 py-2.5 text-sm hover:bg-[rgba(127,127,127,0.14)]",
919
+ children: l.label
920
+ },
921
+ l.href
922
+ )) })
923
+ ] })
924
+ ] }) : null,
925
+ /* @__PURE__ */ jsxRuntime.jsx("a", { href: home, className: "flex items-center gap-2 font-semibold tracking-tight", children: brand ?? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
926
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Building2, { "aria-hidden": "true", className: "h-4 w-4 opacity-70" }),
927
+ id.whiteLabel.name
928
+ ] }) }),
929
+ org ? /* @__PURE__ */ jsxRuntime.jsx(OrgSwitcher, {}) : null,
930
+ project ? /* @__PURE__ */ jsxRuntime.jsx(ProjectSwitcher, {}) : null,
931
+ !narrow && links.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("nav", { className: "flex items-center gap-1", children: links.map((l) => /* @__PURE__ */ jsxRuntime.jsx(
932
+ "a",
933
+ {
934
+ href: l.href,
935
+ "aria-current": l.active ? "page" : void 0,
936
+ className: cn(
937
+ "rounded-md px-3 py-1.5 text-sm font-medium",
938
+ l.active ? "bg-[rgba(127,127,127,0.14)]" : "opacity-75 hover:opacity-100"
939
+ ),
940
+ children: l.label
941
+ },
942
+ l.href
943
+ )) }) : null,
944
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-1 items-center justify-end gap-1", children: [
945
+ children,
946
+ settings ? /* @__PURE__ */ jsxRuntime.jsx(SettingsMenu, { items: settings }) : null,
947
+ /* @__PURE__ */ jsxRuntime.jsx(UserMenu, { items: userItems })
948
+ ] })
949
+ ] })
950
+ }
951
+ );
952
+ };
953
+
954
+ exports.AppNav = AppNav;
955
+ exports.OrgSwitcher = OrgSwitcher;
956
+ exports.ProjectSwitcher = ProjectSwitcher;
957
+ exports.SettingsMenu = SettingsMenu;
958
+ exports.Switcher = Switcher;
959
+ exports.UserMenu = UserMenu;
960
+ exports.initials = initials;