@pablo2410/shared-ui 0.18.1 → 0.19.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.
Files changed (44) hide show
  1. package/README.md +18 -15
  2. package/dist/{HealthFooter-C5K9s38i.d.ts → HealthFooter-BoOozbWG.d.ts} +4 -4
  3. package/dist/{chunk-G7XJLTNY.js → chunk-5RY3AJKI.js} +8 -9
  4. package/dist/{chunk-G7XJLTNY.js.map → chunk-5RY3AJKI.js.map} +1 -1
  5. package/dist/{chunk-3G43UG63.js → chunk-A6UTXAPS.js} +11 -3
  6. package/dist/chunk-A6UTXAPS.js.map +1 -0
  7. package/dist/{chunk-R4NOLCSI.js → chunk-BKGUIIN2.js} +1 -1
  8. package/dist/{chunk-R4NOLCSI.js.map → chunk-BKGUIIN2.js.map} +1 -1
  9. package/dist/{chunk-IEBZGU6X.js → chunk-DMUQ5WNO.js} +2 -4
  10. package/dist/chunk-DMUQ5WNO.js.map +1 -0
  11. package/dist/{chunk-PLCWXXUE.js → chunk-K6FHU4HN.js} +9 -15
  12. package/dist/chunk-K6FHU4HN.js.map +1 -0
  13. package/dist/{chunk-KXUNOSMZ.js → chunk-NLQ45OYS.js} +193 -91
  14. package/dist/chunk-NLQ45OYS.js.map +1 -0
  15. package/dist/{chunk-WTR6SNOE.js → chunk-VJEXXX2P.js} +158 -40
  16. package/dist/chunk-VJEXXX2P.js.map +1 -0
  17. package/dist/components/index.d.ts +7 -8
  18. package/dist/components/index.js +85 -63
  19. package/dist/components/index.js.map +1 -1
  20. package/dist/hierarchy/core.js +1 -1
  21. package/dist/hierarchy/index.d.ts +3 -3
  22. package/dist/hierarchy/index.js +5 -5
  23. package/dist/insights/index.d.ts +8 -8
  24. package/dist/insights/index.js +150 -61
  25. package/dist/insights/index.js.map +1 -1
  26. package/dist/layout/index.d.ts +8 -8
  27. package/dist/layout/index.js +6 -6
  28. package/dist/primitives/index.d.ts +288 -289
  29. package/dist/primitives/index.js +2 -2
  30. package/dist/rbac/index.js.map +1 -1
  31. package/dist/reporting/index.d.ts +101 -43
  32. package/dist/reporting/index.js +208 -187
  33. package/dist/reporting/index.js.map +1 -1
  34. package/dist/services/index.js +2 -2
  35. package/dist/shell/index.d.ts +2 -3
  36. package/dist/shell/index.js +7 -7
  37. package/dist/shell/oplytics-shell.css +2 -2
  38. package/dist/theme/oplytics-theme.css +4 -4
  39. package/package.json +48 -46
  40. package/dist/chunk-3G43UG63.js.map +0 -1
  41. package/dist/chunk-IEBZGU6X.js.map +0 -1
  42. package/dist/chunk-KXUNOSMZ.js.map +0 -1
  43. package/dist/chunk-PLCWXXUE.js.map +0 -1
  44. package/dist/chunk-WTR6SNOE.js.map +0 -1
@@ -2,10 +2,10 @@ import {
2
2
  readSelectionParamFromLocation,
3
3
  resolveSelectionFromIds,
4
4
  stripSelectionParamFromLocation
5
- } from "./chunk-IEBZGU6X.js";
5
+ } from "./chunk-DMUQ5WNO.js";
6
6
  import {
7
7
  ACTIVE_ENTERPRISE_COOKIE
8
- } from "./chunk-3G43UG63.js";
8
+ } from "./chunk-A6UTXAPS.js";
9
9
  import {
10
10
  ORG_HIERARCHY_EMPTY
11
11
  } from "./chunk-HLMIR5UV.js";
@@ -13,7 +13,7 @@ import {
13
13
  Tooltip,
14
14
  TooltipContent,
15
15
  TooltipTrigger
16
- } from "./chunk-PLCWXXUE.js";
16
+ } from "./chunk-K6FHU4HN.js";
17
17
  import {
18
18
  cn
19
19
  } from "./chunk-JT3XLKKD.js";
@@ -66,7 +66,9 @@ function readActiveEnterpriseCookie() {
66
66
  if (typeof document === "undefined") return null;
67
67
  const match = document.cookie.split(";").map((c) => c.trim()).find((c) => c.startsWith(`${ACTIVE_ENTERPRISE_COOKIE}=`));
68
68
  if (!match) return null;
69
- const value = decodeURIComponent(match.slice(ACTIVE_ENTERPRISE_COOKIE.length + 1));
69
+ const value = decodeURIComponent(
70
+ match.slice(ACTIVE_ENTERPRISE_COOKIE.length + 1)
71
+ );
70
72
  return value.length ? value : null;
71
73
  }
72
74
  function createOrgHierarchyContext(options) {
@@ -116,10 +118,16 @@ function createOrgHierarchyContext(options) {
116
118
  };
117
119
  if (typeof window !== "undefined") {
118
120
  window.addEventListener("focus", reloadIfEnterpriseChanged);
119
- document.addEventListener("visibilitychange", reloadIfEnterpriseChanged);
121
+ document.addEventListener(
122
+ "visibilitychange",
123
+ reloadIfEnterpriseChanged
124
+ );
120
125
  return () => {
121
126
  window.removeEventListener("focus", reloadIfEnterpriseChanged);
122
- document.removeEventListener("visibilitychange", reloadIfEnterpriseChanged);
127
+ document.removeEventListener(
128
+ "visibilitychange",
129
+ reloadIfEnterpriseChanged
130
+ );
123
131
  };
124
132
  }
125
133
  return void 0;
@@ -179,19 +187,28 @@ function createOrgHierarchyContext(options) {
179
187
  }
180
188
  }
181
189
  }
182
- }, [pendingIds, isLoading, enterprises, selection.enterprise, canSwitchEnterprise]);
183
- const selectEnterprise = useCallback((node) => {
184
- setSelection({
185
- enterprise: node,
186
- businessUnit: null,
187
- site: null,
188
- area: null,
189
- asset: null
190
- });
191
- if (canSwitchEnterprise && onEnterpriseSwitched) {
192
- onEnterpriseSwitched(node?.id ?? null);
193
- }
194
- }, [canSwitchEnterprise, onEnterpriseSwitched]);
190
+ }, [
191
+ pendingIds,
192
+ isLoading,
193
+ enterprises,
194
+ selection.enterprise,
195
+ canSwitchEnterprise
196
+ ]);
197
+ const selectEnterprise = useCallback(
198
+ (node) => {
199
+ setSelection({
200
+ enterprise: node,
201
+ businessUnit: null,
202
+ site: null,
203
+ area: null,
204
+ asset: null
205
+ });
206
+ if (canSwitchEnterprise && onEnterpriseSwitched) {
207
+ onEnterpriseSwitched(node?.id ?? null);
208
+ }
209
+ },
210
+ [canSwitchEnterprise, onEnterpriseSwitched]
211
+ );
195
212
  const selectBusinessUnit = useCallback((node) => {
196
213
  setSelection((prev) => ({
197
214
  ...prev,
@@ -228,10 +245,8 @@ function createOrgHierarchyContext(options) {
228
245
  crumbs.push({ level: "Enterprise", node: selection.enterprise });
229
246
  if (selection.businessUnit)
230
247
  crumbs.push({ level: "Business Unit", node: selection.businessUnit });
231
- if (selection.site)
232
- crumbs.push({ level: "Site", node: selection.site });
233
- if (selection.area)
234
- crumbs.push({ level: "Area", node: selection.area });
248
+ if (selection.site) crumbs.push({ level: "Site", node: selection.site });
249
+ if (selection.area) crumbs.push({ level: "Area", node: selection.area });
235
250
  if (selection.asset)
236
251
  crumbs.push({ level: "Asset", node: selection.asset });
237
252
  return crumbs;
@@ -281,7 +296,15 @@ function createOrgHierarchyContext(options) {
281
296
  }
282
297
 
283
298
  // src/hierarchy/HierarchyNavigator.tsx
284
- import { ChevronRight, ChevronDown, Building2, Network, MapPin, LayoutGrid, Box } from "lucide-react";
299
+ import {
300
+ ChevronRight,
301
+ ChevronDown,
302
+ Building2,
303
+ Network,
304
+ MapPin,
305
+ LayoutGrid,
306
+ Box
307
+ } from "lucide-react";
285
308
  import { useState as useState2 } from "react";
286
309
  import { jsx as jsx2, jsxs } from "react/jsx-runtime";
287
310
  function buildResetHandler(levels, level) {
@@ -307,11 +330,20 @@ function hierarchyCodeFor(level, selection, selectedId, tree) {
307
330
  assetId: level === "asset" ? selectedId : selection.asset?.id
308
331
  };
309
332
  const code = computeHierarchyCode(input, tree);
310
- const expectedSegments = { enterprise: 1, businessUnit: 2, site: 3, area: 4, asset: 5 }[level];
333
+ const expectedSegments = {
334
+ enterprise: 1,
335
+ businessUnit: 2,
336
+ site: 3,
337
+ area: 4,
338
+ asset: 5
339
+ }[level];
311
340
  if (code.split("-").length < expectedSegments) return null;
312
341
  return code;
313
342
  }
314
- function LevelReference({ text, compact }) {
343
+ function LevelReference({
344
+ text,
345
+ compact
346
+ }) {
315
347
  if (!text) return null;
316
348
  return /* @__PURE__ */ jsx2(
317
349
  "span",
@@ -339,7 +371,12 @@ function BreadcrumbLevel({
339
371
  const canSwitch = config.canSwitch !== false;
340
372
  const hasMultiple = nodes.length > 1;
341
373
  if (!selected) return null;
342
- const code = hierarchyCodeFor(config.key, selection, selected.id, hierarchyData);
374
+ const code = hierarchyCodeFor(
375
+ config.key,
376
+ selection,
377
+ selected.id,
378
+ hierarchyData
379
+ );
343
380
  const refText = config.key === "enterprise" ? null : `${idReference(config.key, config.label, selected.id)}${code ? ` \xB7 ${code}` : ""}`;
344
381
  if (!hasMultiple || !canSwitch) {
345
382
  const isClickable = !!onClickReset && !isLast;
@@ -359,14 +396,30 @@ function BreadcrumbLevel({
359
396
  ),
360
397
  children: [
361
398
  /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-1", children: [
362
- /* @__PURE__ */ jsx2(Icon, { className: cn("shrink-0 text-[#8890A0]", compact ? "h-2.5 w-2.5" : "h-3 w-3") }),
399
+ /* @__PURE__ */ jsx2(
400
+ Icon,
401
+ {
402
+ className: cn(
403
+ "shrink-0 text-[#8890A0]",
404
+ compact ? "h-2.5 w-2.5" : "h-3 w-3"
405
+ )
406
+ }
407
+ ),
363
408
  /* @__PURE__ */ jsx2("span", { className: "truncate max-w-[110px]", children: selected.name })
364
409
  ] }),
365
410
  /* @__PURE__ */ jsx2(LevelReference, { text: refText, compact })
366
411
  ]
367
412
  }
368
413
  ),
369
- !isLast && /* @__PURE__ */ jsx2(ChevronRight, { className: cn("shrink-0 text-[#596475]", compact ? "h-3 w-3" : "h-3.5 w-3.5") })
414
+ !isLast && /* @__PURE__ */ jsx2(
415
+ ChevronRight,
416
+ {
417
+ className: cn(
418
+ "shrink-0 text-[#596475]",
419
+ compact ? "h-3 w-3" : "h-3.5 w-3.5"
420
+ )
421
+ }
422
+ )
370
423
  ] });
371
424
  }
372
425
  const trigger = /* @__PURE__ */ jsxs(
@@ -381,9 +434,25 @@ function BreadcrumbLevel({
381
434
  ),
382
435
  children: [
383
436
  /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-1", children: [
384
- /* @__PURE__ */ jsx2(Icon, { className: cn("shrink-0 text-[#8890A0]", compact ? "h-2.5 w-2.5" : "h-3 w-3") }),
437
+ /* @__PURE__ */ jsx2(
438
+ Icon,
439
+ {
440
+ className: cn(
441
+ "shrink-0 text-[#8890A0]",
442
+ compact ? "h-2.5 w-2.5" : "h-3 w-3"
443
+ )
444
+ }
445
+ ),
385
446
  /* @__PURE__ */ jsx2("span", { className: "truncate max-w-[110px]", children: selected.name }),
386
- /* @__PURE__ */ jsx2(ChevronDown, { className: cn("shrink-0 text-[#596475]", compact ? "h-2.5 w-2.5" : "h-3 w-3") })
447
+ /* @__PURE__ */ jsx2(
448
+ ChevronDown,
449
+ {
450
+ className: cn(
451
+ "shrink-0 text-[#596475]",
452
+ compact ? "h-2.5 w-2.5" : "h-3 w-3"
453
+ )
454
+ }
455
+ )
387
456
  ] }),
388
457
  /* @__PURE__ */ jsx2(LevelReference, { text: refText, compact })
389
458
  ]
@@ -402,7 +471,15 @@ function BreadcrumbLevel({
402
471
  // Fallback: simple select-style rendering
403
472
  /* @__PURE__ */ jsx2("div", { className: "relative group", children: trigger })
404
473
  ),
405
- !isLast && /* @__PURE__ */ jsx2(ChevronRight, { className: cn("shrink-0 text-[#596475]", compact ? "h-3 w-3" : "h-3.5 w-3.5") })
474
+ !isLast && /* @__PURE__ */ jsx2(
475
+ ChevronRight,
476
+ {
477
+ className: cn(
478
+ "shrink-0 text-[#596475]",
479
+ compact ? "h-3 w-3" : "h-3.5 w-3.5"
480
+ )
481
+ }
482
+ )
406
483
  ] });
407
484
  }
408
485
  function DrillDownPrompt({
@@ -418,7 +495,15 @@ function DrillDownPrompt({
418
495
  if (nodes.length === 0) return null;
419
496
  if (!canSwitch) {
420
497
  return /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
421
- /* @__PURE__ */ jsx2(ChevronRight, { className: cn("shrink-0 text-[#596475]", compact ? "h-3 w-3" : "h-3.5 w-3.5") }),
498
+ /* @__PURE__ */ jsx2(
499
+ ChevronRight,
500
+ {
501
+ className: cn(
502
+ "shrink-0 text-[#596475]",
503
+ compact ? "h-3 w-3" : "h-3.5 w-3.5"
504
+ )
505
+ }
506
+ ),
422
507
  /* @__PURE__ */ jsxs(Tooltip, { open: showLockedHint, onOpenChange: setShowLockedHint, children: [
423
508
  /* @__PURE__ */ jsx2(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
424
509
  "button",
@@ -432,7 +517,12 @@ function DrillDownPrompt({
432
517
  compact && "px-1 py-0.5 text-[11px]"
433
518
  ),
434
519
  children: [
435
- /* @__PURE__ */ jsx2(Icon, { className: cn("shrink-0", compact ? "h-3 w-3" : "h-3.5 w-3.5") }),
520
+ /* @__PURE__ */ jsx2(
521
+ Icon,
522
+ {
523
+ className: cn("shrink-0", compact ? "h-3 w-3" : "h-3.5 w-3.5")
524
+ }
525
+ ),
436
526
  /* @__PURE__ */ jsxs("span", { className: "truncate", children: [
437
527
  "Select ",
438
528
  label
@@ -449,7 +539,15 @@ function DrillDownPrompt({
449
539
  }
450
540
  if (nodes.length === 1) {
451
541
  return /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
452
- /* @__PURE__ */ jsx2(ChevronRight, { className: cn("shrink-0 text-[#596475]", compact ? "h-3 w-3" : "h-3.5 w-3.5") }),
542
+ /* @__PURE__ */ jsx2(
543
+ ChevronRight,
544
+ {
545
+ className: cn(
546
+ "shrink-0 text-[#596475]",
547
+ compact ? "h-3 w-3" : "h-3.5 w-3.5"
548
+ )
549
+ }
550
+ ),
453
551
  /* @__PURE__ */ jsxs(
454
552
  "button",
455
553
  {
@@ -461,7 +559,12 @@ function DrillDownPrompt({
461
559
  compact && "px-1 py-0.5 text-[11px]"
462
560
  ),
463
561
  children: [
464
- /* @__PURE__ */ jsx2(Icon, { className: cn("shrink-0", compact ? "h-3 w-3" : "h-3.5 w-3.5") }),
562
+ /* @__PURE__ */ jsx2(
563
+ Icon,
564
+ {
565
+ className: cn("shrink-0", compact ? "h-3 w-3" : "h-3.5 w-3.5")
566
+ }
567
+ ),
465
568
  /* @__PURE__ */ jsx2("span", { className: "truncate", children: nodes[0].name })
466
569
  ]
467
570
  }
@@ -484,7 +587,12 @@ function DrillDownPrompt({
484
587
  "Select ",
485
588
  label
486
589
  ] }),
487
- /* @__PURE__ */ jsx2(ChevronDown, { className: cn("shrink-0", compact ? "h-2.5 w-2.5" : "h-3 w-3") })
590
+ /* @__PURE__ */ jsx2(
591
+ ChevronDown,
592
+ {
593
+ className: cn("shrink-0", compact ? "h-2.5 w-2.5" : "h-3 w-3")
594
+ }
595
+ )
488
596
  ]
489
597
  }
490
598
  );
@@ -497,7 +605,15 @@ function DrillDownPrompt({
497
605
  onClick: () => onSelect(node)
498
606
  }));
499
607
  return /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
500
- /* @__PURE__ */ jsx2(ChevronRight, { className: cn("shrink-0 text-[#596475]", compact ? "h-3 w-3" : "h-3.5 w-3.5") }),
608
+ /* @__PURE__ */ jsx2(
609
+ ChevronRight,
610
+ {
611
+ className: cn(
612
+ "shrink-0 text-[#596475]",
613
+ compact ? "h-3 w-3" : "h-3.5 w-3.5"
614
+ )
615
+ }
616
+ ),
501
617
  renderDropdown ? renderDropdown({ trigger, items, align: "start" }) : /* @__PURE__ */ jsx2("div", { className: "relative group", children: trigger })
502
618
  ] });
503
619
  }
@@ -560,7 +676,9 @@ function HierarchyNavigator({
560
676
  ];
561
677
  const levels = allLevels.slice(0, maxDepth);
562
678
  const selectedLevels = levels.filter((l) => l.getSelected() !== null);
563
- const nextLevel = levels.find((l) => l.getSelected() === null && l.getNodes().length > 0);
679
+ const nextLevel = levels.find(
680
+ (l) => l.getSelected() === null && l.getNodes().length > 0
681
+ );
564
682
  return /* @__PURE__ */ jsxs(
565
683
  "nav",
566
684
  {
@@ -607,4 +725,4 @@ export {
607
725
  hierarchyCodeFor,
608
726
  HierarchyNavigator
609
727
  };
610
- //# sourceMappingURL=chunk-WTR6SNOE.js.map
728
+ //# sourceMappingURL=chunk-VJEXXX2P.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/hierarchy/hierarchyCode.ts","../src/hierarchy/OrgHierarchyContext.tsx","../src/hierarchy/HierarchyNavigator.tsx"],"sourcesContent":["/**\n * @oplytics/shared-ui/hierarchy — Hierarchy Attribution Code\n *\n * A human-readable, computed-not-stored label identifying which hierarchy\n * node a piece of data belongs to: `E{enterpriseId}-B{ii}-S{ii}-A{ii}-X{iii}`.\n *\n * This is a *display/debug/attribution* label only — the permanent identity\n * of every node stays its Portal-issued `int` id. Re-parenting a node changes\n * its code (sibling index can shift) but never changes historical records,\n * since nothing stores this string as a join key. Mirrors Policy Deployment's\n * `generatePolicyCode` precedent: computed lineage, not stored structure.\n *\n * Sibling index is 1-based position when siblings are sorted by `id` —\n * deterministic and stable, since there's no reorder-hierarchy UI that could\n * change insertion order without changing the id.\n */\n\nimport type { OrgHierarchyData } from \"./orgHierarchy\";\n\nexport interface HierarchyCodeInput {\n enterpriseId: number;\n businessUnitId?: number | null;\n siteId?: number | null;\n areaId?: number | null;\n assetId?: number | null;\n}\n\nfunction siblingIndex(siblingIds: number[], targetId: number): number | null {\n const sorted = [...siblingIds].sort((a, b) => a - b);\n const position = sorted.indexOf(targetId);\n return position === -1 ? null : position + 1;\n}\n\nfunction pad(n: number, width: number): string {\n return String(n).padStart(width, \"0\");\n}\n\n/**\n * Computes a hierarchy attribution code for a node, given the full org tree.\n * Returns as much of the code as can be resolved — e.g. if `siteId` is set\n * but not found in `tree.sites`, the code stops at the last resolved segment\n * rather than throwing, since stale/cross-enterprise ids can occur during\n * migration/backfill windows.\n */\nexport function computeHierarchyCode(\n node: HierarchyCodeInput,\n tree: OrgHierarchyData\n): string {\n const segments: string[] = [`E${node.enterpriseId}`];\n\n if (node.businessUnitId == null) return segments.join(\"-\");\n const buSiblings = tree.businessUnits\n .filter(bu => bu.enterpriseId === node.enterpriseId)\n .map(bu => bu.id);\n const buIndex = siblingIndex(buSiblings, node.businessUnitId);\n if (buIndex == null) return segments.join(\"-\");\n segments.push(`B${pad(buIndex, 2)}`);\n\n if (node.siteId == null) return segments.join(\"-\");\n const siteSiblings = tree.sites\n .filter(s => s.businessUnitId === node.businessUnitId)\n .map(s => s.id);\n const siteIndex = siblingIndex(siteSiblings, node.siteId);\n if (siteIndex == null) return segments.join(\"-\");\n segments.push(`S${pad(siteIndex, 2)}`);\n\n if (node.areaId == null) return segments.join(\"-\");\n const areaSiblings = tree.areas\n .filter(a => a.siteId === node.siteId)\n .map(a => a.id);\n const areaIndex = siblingIndex(areaSiblings, node.areaId);\n if (areaIndex == null) return segments.join(\"-\");\n segments.push(`A${pad(areaIndex, 2)}`);\n\n if (node.assetId == null) return segments.join(\"-\");\n const assetSiblings = tree.assets\n .filter(a => a.areaId === node.areaId)\n .map(a => a.id);\n const assetIndex = siblingIndex(assetSiblings, node.assetId);\n if (assetIndex == null) return segments.join(\"-\");\n segments.push(`X${pad(assetIndex, 3)}`);\n\n return segments.join(\"-\");\n}\n","/**\n * OrgHierarchyContext — shared React context factory for the Organisational Hierarchy.\n *\n * Usage:\n * const { OrgHierarchyProvider, useOrgHierarchy } = createOrgHierarchyContext({\n * storageKey: \"oplytics-portal-org-hierarchy\",\n * useHierarchyData: () => {\n * const { data, isLoading } = trpc.hierarchy.flat.useQuery(...);\n * return { data: data ?? null, isLoading };\n * },\n * });\n *\n * All selection state, cascade setters, breadcrumbs, and session persistence\n * are handled here — no per-subdomain duplication.\n */\nimport {\n createContext,\n useContext,\n useCallback,\n useMemo,\n useState,\n useEffect,\n type ReactNode,\n} from \"react\";\nimport type {\n OrgHierarchyData,\n OrgHierarchyNode,\n OrgHierarchySelection,\n OrgHierarchyContextValue,\n} from \"./orgHierarchy\";\nimport { ORG_HIERARCHY_EMPTY } from \"./orgHierarchy\";\nimport { ACTIVE_ENTERPRISE_COOKIE } from \"./enterpriseOverride\";\nimport {\n readSelectionParamFromLocation,\n stripSelectionParamFromLocation,\n resolveSelectionFromIds,\n type OrgSelectionIds,\n} from \"./selectionParams\";\n\n/* ── Active-enterprise cookie (the single cross-subdomain channel) ── */\n\n/**\n * Read the Portal-set active-enterprise cookie on the client. This is the only\n * signal a subdomain has that the platform admin switched enterprise; the value\n * is the active enterprise id (or null if unset). Server-side, the same cookie\n * drives applyEnterpriseOverride + scopeHierarchyToEnterprise, so the fetched\n * hierarchy is already scoped to it — the client only needs to react to changes.\n */\nexport function readActiveEnterpriseCookie(): string | null {\n if (typeof document === \"undefined\") return null;\n const match = document.cookie\n .split(\";\")\n .map(c => c.trim())\n .find(c => c.startsWith(`${ACTIVE_ENTERPRISE_COOKIE}=`));\n if (!match) return null;\n const value = decodeURIComponent(\n match.slice(ACTIVE_ENTERPRISE_COOKIE.length + 1)\n );\n return value.length ? value : null;\n}\n\n/* ── Factory options ── */\n\nexport interface CreateOrgHierarchyContextOptions {\n /**\n * Unique sessionStorage key for this subdomain's selection persistence.\n * e.g. \"oplytics-portal-org-hierarchy\", \"oplytics-sqdcp-org-hierarchy\"\n */\n storageKey: string;\n\n /**\n * React hook that fetches the flat hierarchy data.\n * Must return { data, isLoading } where data is OrgHierarchyData | null.\n */\n useHierarchyData: () => {\n data: OrgHierarchyData | null;\n isLoading: boolean;\n };\n}\n\n/* ── Factory ── */\n\nexport function createOrgHierarchyContext(\n options: CreateOrgHierarchyContextOptions\n) {\n const { storageKey, useHierarchyData } = options;\n\n const OrgHierarchyCtx = createContext<OrgHierarchyContextValue>({\n selection: ORG_HIERARCHY_EMPTY,\n enterprises: [],\n businessUnits: [],\n sites: [],\n areas: [],\n assets: [],\n selectEnterprise: () => {},\n selectBusinessUnit: () => {},\n selectSite: () => {},\n selectArea: () => {},\n selectAsset: () => {},\n canSwitchEnterprise: false,\n loading: true,\n breadcrumbs: [],\n hierarchyData: null,\n });\n\n function OrgHierarchyProvider({\n children,\n canSwitchEnterprise = false,\n onEnterpriseSwitched,\n }: {\n children: ReactNode;\n canSwitchEnterprise?: boolean;\n /**\n * Callback fired when a platform_admin switches enterprise.\n * Used to persist the switch to the backend (e.g. via auth.switchEnterprise mutation).\n * Only called when canSwitchEnterprise is true and the user explicitly changes enterprise.\n */\n onEnterpriseSwitched?: (enterpriseId: number | null) => void;\n }) {\n // Single source of truth = the server-scoped hierarchy. We deliberately do\n // NOT restore a persisted selection on load — that is exactly what let one\n // tab/subdomain show a different enterprise than another. We always\n // re-derive from the server (which is scoped to the active enterprise).\n const [selection, setSelection] =\n useState<OrgHierarchySelection>(ORG_HIERARCHY_EMPTY);\n\n // Inbound cross-service deep link (?oh=ent.bu.site.area.asset). Captured\n // once with a pure lazy initializer (StrictMode-safe); applied against the\n // server-scoped hierarchy after it loads, then cleared. The URL param\n // itself is stripped in the mount effect below.\n const [pendingIds, setPendingIds] = useState<OrgSelectionIds | null>(() =>\n readSelectionParamFromLocation()\n );\n\n // On mount: drop any legacy persisted selection, and hard-reload if the\n // active enterprise changes under us (i.e. the Portal admin switched).\n // Reloading lets the server re-scope this app to the new enterprise — the\n // single, identical propagation path for every subdomain. Cookies emit no\n // change event, so we re-check whenever the tab regains focus/visibility.\n useEffect(() => {\n try {\n sessionStorage.removeItem(storageKey);\n } catch {\n // ignore storage errors\n }\n\n // Clean the address bar immediately — the captured pendingIds state\n // survives independently of the URL.\n stripSelectionParamFromLocation();\n\n const activeAtMount = readActiveEnterpriseCookie();\n const reloadIfEnterpriseChanged = () => {\n if (\n typeof window !== \"undefined\" &&\n readActiveEnterpriseCookie() !== activeAtMount\n ) {\n window.location.reload();\n }\n };\n if (typeof window !== \"undefined\") {\n window.addEventListener(\"focus\", reloadIfEnterpriseChanged);\n document.addEventListener(\n \"visibilitychange\",\n reloadIfEnterpriseChanged\n );\n return () => {\n window.removeEventListener(\"focus\", reloadIfEnterpriseChanged);\n document.removeEventListener(\n \"visibilitychange\",\n reloadIfEnterpriseChanged\n );\n };\n }\n return undefined;\n // storageKey is stable for the lifetime of a factory instance.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n // Fetch hierarchy data via the provided hook\n const { data: hierarchy, isLoading } = useHierarchyData();\n\n // ── Derive filtered lists from flat data ──\n\n const enterprises = useMemo<OrgHierarchyNode[]>(() => {\n if (!hierarchy?.enterprises) return [];\n return hierarchy.enterprises.map(e => ({\n id: e.id,\n name: e.name,\n code: e.code,\n }));\n }, [hierarchy]);\n\n const businessUnits = useMemo<OrgHierarchyNode[]>(() => {\n if (!hierarchy?.businessUnits || !selection.enterprise) return [];\n return hierarchy.businessUnits\n .filter(bu => bu.enterpriseId === selection.enterprise!.id)\n .map(bu => ({ id: bu.id, name: bu.name, code: bu.code }));\n }, [hierarchy, selection.enterprise]);\n\n const sites = useMemo<OrgHierarchyNode[]>(() => {\n if (!hierarchy?.sites || !selection.enterprise) return [];\n let filtered = hierarchy.sites.filter(\n s => s.enterpriseId === selection.enterprise!.id\n );\n if (selection.businessUnit) {\n filtered = filtered.filter(\n s => s.businessUnitId === selection.businessUnit!.id\n );\n }\n return filtered.map(s => ({ id: s.id, name: s.name, code: s.code }));\n }, [hierarchy, selection.enterprise, selection.businessUnit]);\n\n const areas = useMemo<OrgHierarchyNode[]>(() => {\n if (!hierarchy?.areas || !selection.site) return [];\n return hierarchy.areas\n .filter(a => a.siteId === selection.site!.id)\n .map(a => ({ id: a.id, name: a.name, code: a.code }));\n }, [hierarchy, selection.site]);\n\n const assets = useMemo<OrgHierarchyNode[]>(() => {\n if (!hierarchy?.assets || !selection.area) return [];\n return hierarchy.assets\n .filter(a => a.areaId === selection.area!.id)\n .map(a => ({ id: a.id, name: a.name, code: a.code }));\n }, [hierarchy, selection.area]);\n\n // Apply an inbound cross-service deep link once the scoped hierarchy is\n // available. Resolution validates ids + parent links and keeps the deepest\n // valid prefix; a selection that doesn't resolve to an enterprise falls\n // through to the auto-select default below (re-triggered by clearing\n // pendingIds). Uses setSelection directly — deliberately NOT\n // selectEnterprise — so onEnterpriseSwitched is never fired by a deep link.\n useEffect(() => {\n if (!pendingIds || isLoading || !hierarchy) return;\n const resolved = resolveSelectionFromIds(pendingIds, hierarchy);\n if (resolved.enterprise) {\n setSelection(resolved);\n }\n setPendingIds(null);\n }, [pendingIds, isLoading, hierarchy]);\n\n // Auto-select an enterprise on load.\n // - Non-platform_admin (or platform_admin with only one visible\n // enterprise): always the first/only one, matching their access.\n // - platform_admin with multiple enterprises: restore whichever\n // enterprise they last switched to, via the same\n // oplytics-active-enterprise cookie switchEnterprise already sets for\n // cross-subdomain propagation. Falls through to leaving it unselected\n // if the cookie is unset or names an enterprise no longer in the list.\n useEffect(() => {\n // A pending deep link owns the initial selection; this effect re-runs\n // as the fallback when pendingIds clears.\n if (pendingIds) return;\n if (isLoading || enterprises.length === 0) return;\n if (!selection.enterprise) {\n if (!canSwitchEnterprise || enterprises.length === 1) {\n setSelection(prev => ({ ...prev, enterprise: enterprises[0] }));\n } else {\n const cookieId = readActiveEnterpriseCookie();\n const restored = cookieId\n ? enterprises.find(e => String(e.id) === cookieId)\n : undefined;\n if (restored) {\n setSelection(prev => ({ ...prev, enterprise: restored }));\n }\n }\n }\n }, [\n pendingIds,\n isLoading,\n enterprises,\n selection.enterprise,\n canSwitchEnterprise,\n ]);\n\n // ── Cascade setters ──\n\n const selectEnterprise = useCallback(\n (node: OrgHierarchyNode | null) => {\n setSelection({\n enterprise: node,\n businessUnit: null,\n site: null,\n area: null,\n asset: null,\n });\n // Notify backend of enterprise switch (platform_admin only)\n if (canSwitchEnterprise && onEnterpriseSwitched) {\n onEnterpriseSwitched(node?.id ?? null);\n }\n },\n [canSwitchEnterprise, onEnterpriseSwitched]\n );\n\n const selectBusinessUnit = useCallback((node: OrgHierarchyNode | null) => {\n setSelection(prev => ({\n ...prev,\n businessUnit: node,\n site: null,\n area: null,\n asset: null,\n }));\n }, []);\n\n const selectSite = useCallback((node: OrgHierarchyNode | null) => {\n setSelection(prev => ({\n ...prev,\n site: node,\n area: null,\n asset: null,\n }));\n }, []);\n\n const selectArea = useCallback((node: OrgHierarchyNode | null) => {\n setSelection(prev => ({\n ...prev,\n area: node,\n asset: null,\n }));\n }, []);\n\n const selectAsset = useCallback((node: OrgHierarchyNode | null) => {\n setSelection(prev => ({\n ...prev,\n asset: node,\n }));\n }, []);\n\n // ── Breadcrumbs ──\n\n const breadcrumbs = useMemo(() => {\n const crumbs: { level: string; node: OrgHierarchyNode }[] = [];\n if (selection.enterprise)\n crumbs.push({ level: \"Enterprise\", node: selection.enterprise });\n if (selection.businessUnit)\n crumbs.push({ level: \"Business Unit\", node: selection.businessUnit });\n if (selection.site) crumbs.push({ level: \"Site\", node: selection.site });\n if (selection.area) crumbs.push({ level: \"Area\", node: selection.area });\n if (selection.asset)\n crumbs.push({ level: \"Asset\", node: selection.asset });\n return crumbs;\n }, [selection]);\n\n // ── Context value ──\n\n const value = useMemo<OrgHierarchyContextValue>(\n () => ({\n selection,\n enterprises,\n businessUnits,\n sites,\n areas,\n assets,\n selectEnterprise,\n selectBusinessUnit,\n selectSite,\n selectArea,\n selectAsset,\n canSwitchEnterprise,\n loading: isLoading,\n breadcrumbs,\n hierarchyData: hierarchy ?? null,\n }),\n [\n selection,\n enterprises,\n businessUnits,\n sites,\n areas,\n assets,\n selectEnterprise,\n selectBusinessUnit,\n selectSite,\n selectArea,\n selectAsset,\n canSwitchEnterprise,\n isLoading,\n breadcrumbs,\n hierarchy,\n ]\n );\n\n return (\n <OrgHierarchyCtx.Provider value={value}>\n {children}\n </OrgHierarchyCtx.Provider>\n );\n }\n\n function useOrgHierarchy(): OrgHierarchyContextValue {\n return useContext(OrgHierarchyCtx);\n }\n\n return { OrgHierarchyProvider, useOrgHierarchy };\n}\n\n/* ── Re-export types for convenience ── */\nexport type {\n OrgHierarchyNode,\n OrgHierarchyData,\n OrgHierarchySelection,\n OrgHierarchyContextValue,\n} from \"./orgHierarchy\";\n","/**\n * HierarchyNavigator — breadcrumb-style hierarchy switcher.\n *\n * Displays: Enterprise / BU / Site / Area / Asset\n * Each level is a clickable dropdown to switch context.\n * Platform admins can switch enterprises; others see their scoped enterprise.\n *\n * NOTE: This component requires the consuming app to provide:\n * - A hierarchy context via useHierarchy prop\n * - shadcn/ui DropdownMenu components via the renderDropdown prop\n *\n * For apps using the createOrgHierarchyContext factory, pass the useOrgHierarchy hook.\n *\n * Oplytics dark theme: #0A0E1A bg, #8C34E9 accent, #E2E8F0 text, #8890A0 muted\n */\nimport { cn } from \"../utils/cn\";\nimport type {\n OrgHierarchyNode,\n OrgHierarchyContextValue,\n OrgHierarchyData,\n OrgHierarchyLevel,\n} from \"./orgHierarchy\";\nimport { computeHierarchyCode } from \"./hierarchyCode\";\nimport {\n ChevronRight,\n ChevronDown,\n Building2,\n Network,\n MapPin,\n LayoutGrid,\n Box,\n} from \"lucide-react\";\nimport { useState, type ReactNode } from \"react\";\nimport { Tooltip, TooltipTrigger, TooltipContent } from \"../primitives\";\n\n/* ── Level config ── */\n\nexport interface LevelConfig {\n key: OrgHierarchyLevel;\n label: string;\n icon: React.ElementType;\n getNodes: () => OrgHierarchyNode[];\n getSelected: () => OrgHierarchyNode | null;\n onSelect: (node: OrgHierarchyNode | null) => void;\n canSwitch?: boolean;\n}\n\n/**\n * Builds the \"clear everything below this level\" handler for a breadcrumb\n * crumb — e.g. clicking \"Testa\" with a Site selected drops back to\n * enterprise-wide. Returns undefined when there's nothing selected below\n * `level` to clear, so callers can tell \"clickable\" from \"inert\" without\n * re-deriving the child slice themselves.\n */\nexport function buildResetHandler(\n levels: LevelConfig[],\n level: LevelConfig\n): (() => void) | undefined {\n const childLevels = levels.slice(levels.indexOf(level) + 1);\n const hasSelectedChild = childLevels.some(l => l.getSelected() !== null);\n if (!hasSelectedChild) return undefined;\n return () => {\n for (const child of childLevels) child.onSelect(null);\n };\n}\n\n/**\n * \"Site #30002\" style reference text shown in small print under a selected\n * breadcrumb level — the raw id disambiguated by level, since ids aren't\n * unique across levels (a BU and a Site can share the same numeric id).\n */\nexport function idReference(\n level: OrgHierarchyLevel,\n label: string,\n id: number\n): string {\n const short = level === \"businessUnit\" ? \"BU\" : label;\n return `${short} #${id}`;\n}\n\n/**\n * Computes the E/B/S/A/X hierarchy attribution code for a selected node,\n * given the full unfiltered tree. Returns null when the tree isn't loaded\n * yet or the node can't be resolved (e.g. stale id mid-refetch) — callers\n * should just omit the sub-text rather than show a broken code.\n */\nexport function hierarchyCodeFor(\n level: OrgHierarchyLevel,\n selection: OrgHierarchyContextValue[\"selection\"],\n selectedId: number,\n tree: OrgHierarchyData | null\n): string | null {\n if (!tree || !selection.enterprise) return null;\n const enterpriseId = selection.enterprise.id;\n const input = {\n enterpriseId,\n businessUnitId:\n level === \"businessUnit\" ? selectedId : selection.businessUnit?.id,\n siteId: level === \"site\" ? selectedId : selection.site?.id,\n areaId: level === \"area\" ? selectedId : selection.area?.id,\n assetId: level === \"asset\" ? selectedId : selection.asset?.id,\n };\n const code = computeHierarchyCode(input, tree);\n // computeHierarchyCode returns as much as it could resolve — only show it\n // when it actually reached the level being rendered (same segment count\n // check used implicitly by prefix length: E, B, S, A, X).\n const expectedSegments = {\n enterprise: 1,\n businessUnit: 2,\n site: 3,\n area: 4,\n asset: 5,\n }[level];\n if (code.split(\"-\").length < expectedSegments) return null;\n return code;\n}\n\n/* ── Dropdown render prop types ── */\n\nexport interface DropdownRenderProps {\n trigger: ReactNode;\n items: Array<{\n key: number;\n label: string;\n code?: string;\n icon: React.ElementType;\n isActive: boolean;\n onClick: () => void;\n }>;\n align?: \"start\" | \"end\";\n}\n\n/* ── Single breadcrumb level ── */\n\n/**\n * Tiny muted reference line: raw id (disambiguated by level) plus the\n * computed hierarchy code, e.g. \"BU #30002 · E90011-B01\". Sits directly\n * under a breadcrumb segment's name — small enough not to compete with it,\n * but present for cross-checking against a support ticket or log line.\n */\nfunction LevelReference({\n text,\n compact,\n}: {\n text: string | null;\n compact?: boolean;\n}) {\n if (!text) return null;\n return (\n <span\n className={cn(\n \"block leading-none text-[8px] text-[#596475] truncate max-w-[110px]\",\n compact && \"text-[7px]\"\n )}\n >\n {text}\n </span>\n );\n}\n\nfunction BreadcrumbLevel({\n config,\n isLast,\n compact,\n renderDropdown,\n selection,\n hierarchyData,\n onClickReset,\n}: {\n config: LevelConfig;\n isLast: boolean;\n compact?: boolean;\n renderDropdown?: (props: DropdownRenderProps) => ReactNode;\n selection: OrgHierarchyContextValue[\"selection\"];\n hierarchyData: OrgHierarchyData | null;\n /**\n * Clears every level below this one, re-anchoring the view here — e.g.\n * clicking \"Testa\" with a Site selected drops back to enterprise-wide.\n * Only wired up when there's something below this level to clear; `isLast`\n * (nothing below) always renders inert regardless.\n */\n onClickReset?: () => void;\n}) {\n const nodes = config.getNodes();\n const selected = config.getSelected();\n const Icon = config.icon;\n const canSwitch = config.canSwitch !== false;\n const hasMultiple = nodes.length > 1;\n\n if (!selected) return null;\n\n const code = hierarchyCodeFor(\n config.key,\n selection,\n selected.id,\n hierarchyData\n );\n const refText =\n config.key === \"enterprise\"\n ? null // enterprise id alone is never ambiguous with another level\n : `${idReference(config.key, config.label, selected.id)}${code ? ` · ${code}` : \"\"}`;\n\n // If only one option or can't switch, there's nothing to pick between —\n // but clicking still clears any selected levels below (unless this is the\n // last/deepest crumb, where there's nothing below to clear).\n if (!hasMultiple || !canSwitch) {\n const isClickable = !!onClickReset && !isLast;\n return (\n <div className=\"flex items-center gap-1\">\n <button\n type=\"button\"\n onClick={isClickable ? onClickReset : undefined}\n disabled={!isClickable}\n className={cn(\n \"flex flex-col justify-center px-1.5 py-0.5 rounded-md text-xs text-left\",\n \"text-[#E2E8F0]\",\n isClickable &&\n \"hover:bg-[#1E2738] hover:text-white transition-colors cursor-pointer\",\n !isClickable && \"cursor-default\",\n compact && \"px-1 py-0.5 text-[11px]\"\n )}\n >\n <span className=\"flex items-center gap-1\">\n <Icon\n className={cn(\n \"shrink-0 text-[#8890A0]\",\n compact ? \"h-2.5 w-2.5\" : \"h-3 w-3\"\n )}\n />\n <span className=\"truncate max-w-[110px]\">{selected.name}</span>\n </span>\n <LevelReference text={refText} compact={compact} />\n </button>\n {!isLast && (\n <ChevronRight\n className={cn(\n \"shrink-0 text-[#596475]\",\n compact ? \"h-3 w-3\" : \"h-3.5 w-3.5\"\n )}\n />\n )}\n </div>\n );\n }\n\n // Multiple options — use renderDropdown if provided, otherwise basic button\n const trigger = (\n <button\n className={cn(\n \"flex flex-col justify-center px-1.5 py-0.5 rounded-md text-xs\",\n \"text-[#E2E8F0] hover:bg-[#1E2738] hover:text-white\",\n \"transition-colors cursor-pointer outline-none\",\n \"focus-visible:ring-1 focus-visible:ring-[#8C34E9]\",\n compact && \"px-1 py-0.5 text-[11px]\"\n )}\n >\n <span className=\"flex items-center gap-1\">\n <Icon\n className={cn(\n \"shrink-0 text-[#8890A0]\",\n compact ? \"h-2.5 w-2.5\" : \"h-3 w-3\"\n )}\n />\n <span className=\"truncate max-w-[110px]\">{selected.name}</span>\n <ChevronDown\n className={cn(\n \"shrink-0 text-[#596475]\",\n compact ? \"h-2.5 w-2.5\" : \"h-3 w-3\"\n )}\n />\n </span>\n <LevelReference text={refText} compact={compact} />\n </button>\n );\n\n const items = nodes.map(node => ({\n key: node.id,\n label: node.name,\n code: node.code,\n icon: Icon,\n isActive: selected.id === node.id,\n onClick: () => config.onSelect(node),\n }));\n\n return (\n <div className=\"flex items-center gap-1\">\n {renderDropdown ? (\n renderDropdown({ trigger, items, align: \"start\" })\n ) : (\n // Fallback: simple select-style rendering\n <div className=\"relative group\">{trigger}</div>\n )}\n {!isLast && (\n <ChevronRight\n className={cn(\n \"shrink-0 text-[#596475]\",\n compact ? \"h-3 w-3\" : \"h-3.5 w-3.5\"\n )}\n />\n )}\n </div>\n );\n}\n\n/* ── Drill-down prompt ── */\n\nfunction DrillDownPrompt({\n label,\n icon: Icon,\n nodes,\n onSelect,\n compact,\n renderDropdown,\n canSwitch = true,\n}: {\n label: string;\n icon: React.ElementType;\n nodes: OrgHierarchyNode[];\n onSelect: (node: OrgHierarchyNode) => void;\n compact?: boolean;\n renderDropdown?: (props: DropdownRenderProps) => ReactNode;\n canSwitch?: boolean;\n}) {\n const [showLockedHint, setShowLockedHint] = useState(false);\n\n if (nodes.length === 0) return null;\n\n // Locked: nothing is selected yet, but this level can't be changed from\n // here. Render static prompt text — clicking surfaces a brief explanation\n // instead of opening the picker.\n if (!canSwitch) {\n return (\n <div className=\"flex items-center gap-1\">\n <ChevronRight\n className={cn(\n \"shrink-0 text-[#596475]\",\n compact ? \"h-3 w-3\" : \"h-3.5 w-3.5\"\n )}\n />\n <Tooltip open={showLockedHint} onOpenChange={setShowLockedHint}>\n <TooltipTrigger asChild>\n <button\n type=\"button\"\n onClick={() => setShowLockedHint(v => !v)}\n onBlur={() => setShowLockedHint(false)}\n className={cn(\n \"flex items-center gap-1 px-1.5 py-0.5 rounded-md text-xs\",\n \"text-[#596475] cursor-not-allowed\",\n compact && \"px-1 py-0.5 text-[11px]\"\n )}\n >\n <Icon\n className={cn(\"shrink-0\", compact ? \"h-3 w-3\" : \"h-3.5 w-3.5\")}\n />\n <span className=\"truncate\">Select {label}</span>\n </button>\n </TooltipTrigger>\n <TooltipContent>\n {label} can't be changed from this page\n </TooltipContent>\n </Tooltip>\n </div>\n );\n }\n\n // Auto-select if only one option\n if (nodes.length === 1) {\n return (\n <div className=\"flex items-center gap-1\">\n <ChevronRight\n className={cn(\n \"shrink-0 text-[#596475]\",\n compact ? \"h-3 w-3\" : \"h-3.5 w-3.5\"\n )}\n />\n <button\n onClick={() => onSelect(nodes[0])}\n className={cn(\n \"flex items-center gap-1 px-1.5 py-0.5 rounded-md text-xs\",\n \"text-[#596475] hover:bg-[#1E2738] hover:text-[#8890A0]\",\n \"transition-colors cursor-pointer\",\n compact && \"px-1 py-0.5 text-[11px]\"\n )}\n >\n <Icon\n className={cn(\"shrink-0\", compact ? \"h-3 w-3\" : \"h-3.5 w-3.5\")}\n />\n <span className=\"truncate\">{nodes[0].name}</span>\n </button>\n </div>\n );\n }\n\n const trigger = (\n <button\n className={cn(\n \"flex items-center gap-1 px-1.5 py-0.5 rounded-md text-xs\",\n \"text-[#596475] hover:bg-[#1E2738] hover:text-[#8890A0]\",\n \"transition-colors cursor-pointer outline-none\",\n \"border border-dashed border-[#2A2A3E] hover:border-[#596475]\",\n compact && \"px-1 py-0.5 text-[11px]\"\n )}\n >\n <Icon className={cn(\"shrink-0\", compact ? \"h-3 w-3\" : \"h-3.5 w-3.5\")} />\n <span className=\"truncate\">Select {label}</span>\n <ChevronDown\n className={cn(\"shrink-0\", compact ? \"h-2.5 w-2.5\" : \"h-3 w-3\")}\n />\n </button>\n );\n\n const items = nodes.map(node => ({\n key: node.id,\n label: node.name,\n code: node.code,\n icon: Icon,\n isActive: false,\n onClick: () => onSelect(node),\n }));\n\n return (\n <div className=\"flex items-center gap-1\">\n <ChevronRight\n className={cn(\n \"shrink-0 text-[#596475]\",\n compact ? \"h-3 w-3\" : \"h-3.5 w-3.5\"\n )}\n />\n {renderDropdown ? (\n renderDropdown({ trigger, items, align: \"start\" })\n ) : (\n <div className=\"relative group\">{trigger}</div>\n )}\n </div>\n );\n}\n\n/* ── Main component ── */\n\nexport interface HierarchyNavigatorProps {\n /** The hierarchy context value — pass from useOrgHierarchy() */\n hierarchy: OrgHierarchyContextValue;\n /** Show in compact mode (smaller text, tighter spacing) */\n compact?: boolean;\n /** Maximum depth to show (default: all 5 levels) */\n maxDepth?: number;\n /** CSS class for the container */\n className?: string;\n /**\n * Render prop for dropdown menus. If not provided, dropdowns won't open.\n * Consuming apps should pass a function that renders their shadcn/ui DropdownMenu.\n */\n renderDropdown?: (props: DropdownRenderProps) => ReactNode;\n}\n\nexport function HierarchyNavigator({\n hierarchy: ctx,\n compact = false,\n maxDepth = 5,\n className,\n renderDropdown,\n}: HierarchyNavigatorProps) {\n if (ctx.loading) {\n return (\n <div className={cn(\"flex items-center gap-2 animate-pulse\", className)}>\n <div className=\"h-6 w-24 rounded bg-[#1E2738]\" />\n <ChevronRight className=\"h-3.5 w-3.5 text-[#596475]\" />\n <div className=\"h-6 w-20 rounded bg-[#1E2738]\" />\n </div>\n );\n }\n\n // Build the level configs\n const allLevels: LevelConfig[] = [\n {\n key: \"enterprise\",\n label: \"Enterprise\",\n icon: Building2,\n getNodes: () => ctx.enterprises,\n getSelected: () => ctx.selection.enterprise,\n onSelect: ctx.selectEnterprise,\n canSwitch: ctx.canSwitchEnterprise,\n },\n {\n key: \"businessUnit\",\n label: \"Business Unit\",\n icon: Network,\n getNodes: () => ctx.businessUnits,\n getSelected: () => ctx.selection.businessUnit,\n onSelect: ctx.selectBusinessUnit,\n },\n {\n key: \"site\",\n label: \"Site\",\n icon: MapPin,\n getNodes: () => ctx.sites,\n getSelected: () => ctx.selection.site,\n onSelect: ctx.selectSite,\n },\n {\n key: \"area\",\n label: \"Area\",\n icon: LayoutGrid,\n getNodes: () => ctx.areas,\n getSelected: () => ctx.selection.area,\n onSelect: ctx.selectArea,\n },\n {\n key: \"asset\",\n label: \"Asset\",\n icon: Box,\n getNodes: () => ctx.assets,\n getSelected: () => ctx.selection.asset,\n onSelect: ctx.selectAsset,\n },\n ];\n const levels = allLevels.slice(0, maxDepth);\n\n // Determine which levels are selected and which is the next drill-down\n const selectedLevels = levels.filter(l => l.getSelected() !== null);\n const nextLevel = levels.find(\n l => l.getSelected() === null && l.getNodes().length > 0\n );\n\n return (\n <nav\n className={cn(\"flex items-center flex-wrap gap-0.5\", className)}\n aria-label=\"Hierarchy navigation\"\n >\n {selectedLevels.map((level, idx) => (\n <BreadcrumbLevel\n key={level.key}\n config={level}\n isLast={idx === selectedLevels.length - 1 && !nextLevel}\n compact={compact}\n renderDropdown={renderDropdown}\n selection={ctx.selection}\n hierarchyData={ctx.hierarchyData}\n onClickReset={buildResetHandler(levels, level)}\n />\n ))}\n {nextLevel && (\n <DrillDownPrompt\n label={nextLevel.label}\n icon={nextLevel.icon}\n nodes={nextLevel.getNodes()}\n onSelect={nextLevel.onSelect}\n compact={compact}\n renderDropdown={renderDropdown}\n canSwitch={nextLevel.canSwitch !== false}\n />\n )}\n {selectedLevels.length === 0 && !nextLevel && (\n <span className=\"text-sm text-[#596475] italic\">\n No hierarchy data available\n </span>\n )}\n </nav>\n );\n}\n"],"mappings":";;;;;;;;;;;;;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x_runtime from 'react/jsx-runtime';
2
1
  import * as React from 'react';
3
2
  import { Component, ReactNode, ErrorInfo } from 'react';
4
3
 
@@ -21,7 +20,7 @@ declare class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryS
21
20
  static getDerivedStateFromError(error: Error): ErrorBoundaryState;
22
21
  componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
23
22
  handleRetry: () => void;
24
- render(): string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | react_jsx_runtime.JSX.Element | null | undefined;
23
+ render(): string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | React.JSX.Element | null | undefined;
25
24
  }
26
25
 
27
26
  interface NotFoundPageProps {
@@ -38,7 +37,7 @@ interface NotFoundPageProps {
38
37
  /** CSS class for the container */
39
38
  className?: string;
40
39
  }
41
- declare function NotFoundPage({ title, description, homePath, onBack, onHome, className, }: NotFoundPageProps): react_jsx_runtime.JSX.Element;
40
+ declare function NotFoundPage({ title, description, homePath, onBack, onHome, className, }: NotFoundPageProps): React.JSX.Element;
42
41
 
43
42
  interface ManusDialogProps {
44
43
  /** Whether the dialog is open */
@@ -62,7 +61,7 @@ interface ManusDialogProps {
62
61
  /** Whether clicking the overlay closes the dialog (default: true) */
63
62
  closeOnOverlay?: boolean;
64
63
  }
65
- declare function ManusDialog({ open, onClose, title, subtitle, logo, children, footer, maxWidth, className, closeOnOverlay, }: ManusDialogProps): react_jsx_runtime.JSX.Element;
64
+ declare function ManusDialog({ open, onClose, title, subtitle, logo, children, footer, maxWidth, className, closeOnOverlay, }: ManusDialogProps): React.JSX.Element;
66
65
 
67
66
  interface ChatMessage {
68
67
  id: string;
@@ -98,7 +97,7 @@ interface AIChatBoxProps {
98
97
  /** Whether to show the header (default: true) */
99
98
  showHeader?: boolean;
100
99
  }
101
- declare function AIChatBox({ messages, onSend, isLoading, placeholder, title, floating, isOpen, onToggle, renderContent, maxHeight, className, showHeader, }: AIChatBoxProps): react_jsx_runtime.JSX.Element;
100
+ declare function AIChatBox({ messages, onSend, isLoading, placeholder, title, floating, isOpen, onToggle, renderContent, maxHeight, className, showHeader, }: AIChatBoxProps): React.JSX.Element;
102
101
 
103
102
  /**
104
103
  * MapView — Google Maps integration with Manus proxy authentication.
@@ -137,7 +136,7 @@ interface MapViewProps {
137
136
  /** CSS class for the map container */
138
137
  className?: string;
139
138
  }
140
- declare function MapView({ apiKey, forgeBaseUrl, initialCenter, initialZoom, onMapReady, mapId, className, }: MapViewProps): react_jsx_runtime.JSX.Element;
139
+ declare function MapView({ apiKey, forgeBaseUrl, initialCenter, initialZoom, onMapReady, mapId, className, }: MapViewProps): React.JSX.Element;
141
140
 
142
141
  interface ViewOnlyBadgeProps {
143
142
  /** Custom label (default: "View Only") */
@@ -147,7 +146,7 @@ interface ViewOnlyBadgeProps {
147
146
  /** CSS class */
148
147
  className?: string;
149
148
  }
150
- declare function ViewOnlyBadge({ label, size, className, }: ViewOnlyBadgeProps): react_jsx_runtime.JSX.Element;
149
+ declare function ViewOnlyBadge({ label, size, className, }: ViewOnlyBadgeProps): React.JSX.Element;
151
150
 
152
151
  type ExportFormat = "csv" | "xlsx";
153
152
  interface ExportResult {
@@ -174,6 +173,6 @@ interface ExportDialogProps {
174
173
  /** Restrict which formats are offered (default: both). */
175
174
  formats?: ExportFormat[];
176
175
  }
177
- declare function ExportDialog({ open, onOpenChange, title, description, onExport, formats, }: ExportDialogProps): react_jsx_runtime.JSX.Element;
176
+ declare function ExportDialog({ open, onOpenChange, title, description, onExport, formats, }: ExportDialogProps): React.JSX.Element;
178
177
 
179
178
  export { AIChatBox, type AIChatBoxProps, type ChatMessage, ErrorBoundary, type ErrorBoundaryProps, ExportDialog, type ExportDialogProps, type ExportFormat, type ExportResult, ManusDialog, type ManusDialogProps, MapView, type MapViewProps, NotFoundPage, type NotFoundPageProps, ViewOnlyBadge, type ViewOnlyBadgeProps };