@pablo2410/shared-ui 0.14.0 → 0.15.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.
@@ -1,6 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import React__default, { ReactNode, CSSProperties } from 'react';
3
- import { C as CrossServiceLink } from './crossNav-Bd8-0qoi.js';
3
+ import { C as CrossServiceLink } from './crossNav-BwdA3B2h.js';
4
4
 
5
5
  /**
6
6
  * SharedSidebar — Config-driven sidebar component for all Oplytics subdomains.
@@ -4,7 +4,7 @@ import {
4
4
  } from "./chunk-4QJMLQSH.js";
5
5
  import {
6
6
  readActiveEnterpriseCookie
7
- } from "./chunk-CYIMXOQW.js";
7
+ } from "./chunk-MZVMN77F.js";
8
8
  import {
9
9
  Avatar,
10
10
  AvatarFallback,
@@ -1097,4 +1097,4 @@ export {
1097
1097
  policyDeploymentConfig,
1098
1098
  SERVICE_CONFIGS
1099
1099
  };
1100
- //# sourceMappingURL=chunk-7I4ADEJY.js.map
1100
+ //# sourceMappingURL=chunk-EGGUAREC.js.map
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-4QJMLQSH.js";
4
4
  import {
5
5
  appendSelectionParam
6
- } from "./chunk-3E3GLIQV.js";
6
+ } from "./chunk-IEBZGU6X.js";
7
7
 
8
8
  // src/services/catalog.ts
9
9
  var SERVICE_CATALOG = [
@@ -159,4 +159,4 @@ export {
159
159
  normalizeServiceSlug,
160
160
  buildCrossServiceLinks
161
161
  };
162
- //# sourceMappingURL=chunk-PLS7NDDR.js.map
162
+ //# sourceMappingURL=chunk-G7XJLTNY.js.map
@@ -34,4 +34,4 @@ export {
34
34
  ORG_HIERARCHY_LEVELS,
35
35
  ORG_HIERARCHY_LABELS
36
36
  };
37
- //# sourceMappingURL=chunk-PS4K7FKB.js.map
37
+ //# sourceMappingURL=chunk-HLMIR5UV.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/hierarchy/orgHierarchy.ts"],"sourcesContent":["/**\n * @oplytics/shared-ui/hierarchy — Org Hierarchy Types & Utilities\n *\n * Hierarchy: Enterprise > Business Unit > Site > Area > Asset\n *\n * Single source of truth for org-hierarchy types used by:\n * - Portal (direct DB via tRPC)\n * - All subdomains (via Portal Service API)\n *\n * The canonical data shape matches the Portal Service API response:\n * GET /api/service/hierarchy\n */\n\n/* ── Base Node ── */\n\nexport interface OrgHierarchyNode {\n id: number;\n name: string;\n code?: string;\n}\n\n/* ── Flat hierarchy data — matches Portal Service API /api/service/hierarchy ── */\n\nexport interface OrgHierarchyEnterprise extends OrgHierarchyNode {}\n\nexport interface OrgHierarchyBusinessUnit extends OrgHierarchyNode {\n enterpriseId: number;\n}\n\nexport interface OrgHierarchySite extends OrgHierarchyNode {\n enterpriseId: number;\n businessUnitId: number;\n location?: string | null;\n}\n\nexport interface OrgHierarchyArea extends OrgHierarchyNode {\n siteId: number;\n}\n\nexport interface OrgHierarchyAsset extends OrgHierarchyNode {\n siteId: number;\n areaId: number;\n assetType?: string;\n}\n\n/**\n * Canonical flat hierarchy payload.\n * Every consumer (Portal tRPC, Service API REST) must return this shape.\n */\nexport interface OrgHierarchyData {\n enterprises: OrgHierarchyEnterprise[];\n businessUnits: OrgHierarchyBusinessUnit[];\n sites: OrgHierarchySite[];\n areas: OrgHierarchyArea[];\n assets: OrgHierarchyAsset[];\n}\n\n/* ── Selection state ── */\n\nexport interface OrgHierarchySelection {\n enterprise: OrgHierarchyNode | null;\n businessUnit: OrgHierarchyNode | null;\n site: OrgHierarchyNode | null;\n area: OrgHierarchyNode | null;\n asset: OrgHierarchyNode | null;\n}\n\nexport const ORG_HIERARCHY_EMPTY: OrgHierarchySelection = {\n enterprise: null,\n businessUnit: null,\n site: null,\n area: null,\n asset: null,\n};\n\n/**\n * An empty hierarchy payload. Use as the canonical \"no data\" value so every\n * consumer returns the same shape (never null/undefined for a missing tree).\n */\nexport const ORG_HIERARCHY_DATA_EMPTY: OrgHierarchyData = {\n enterprises: [],\n businessUnits: [],\n sites: [],\n areas: [],\n assets: [],\n};\n\n/* ── Context value ── */\n\nexport interface OrgHierarchyContextValue {\n /** Current selection at each level */\n selection: OrgHierarchySelection;\n\n /** Flat lists filtered by current selection */\n enterprises: OrgHierarchyNode[];\n businessUnits: OrgHierarchyNode[];\n sites: OrgHierarchyNode[];\n areas: OrgHierarchyNode[];\n assets: OrgHierarchyNode[];\n\n /** Setters — selecting a level clears all levels below it */\n selectEnterprise: (node: OrgHierarchyNode | null) => void;\n selectBusinessUnit: (node: OrgHierarchyNode | null) => void;\n selectSite: (node: OrgHierarchyNode | null) => void;\n selectArea: (node: OrgHierarchyNode | null) => void;\n selectAsset: (node: OrgHierarchyNode | null) => void;\n\n /** Whether the user can switch enterprises (platform_admin only) */\n canSwitchEnterprise: boolean;\n\n /** Loading state */\n loading: boolean;\n\n /** Breadcrumb trail as an array of { level, node } */\n breadcrumbs: { level: string; node: OrgHierarchyNode }[];\n}\n\n/* ── Hierarchy levels (for iteration) ── */\n\nexport const ORG_HIERARCHY_LEVELS = [\n \"enterprise\",\n \"businessUnit\",\n \"site\",\n \"area\",\n \"asset\",\n] as const;\n\nexport type OrgHierarchyLevel = (typeof ORG_HIERARCHY_LEVELS)[number];\n\n/** Human-readable labels for each level */\nexport const ORG_HIERARCHY_LABELS: Record<OrgHierarchyLevel, string> = {\n enterprise: \"Enterprise\",\n businessUnit: \"Business Unit\",\n site: \"Site\",\n area: \"Area\",\n asset: \"Asset\",\n};\n"],"mappings":";AAmEO,IAAM,sBAA6C;AAAA,EACxD,YAAY;AAAA,EACZ,cAAc;AAAA,EACd,MAAM;AAAA,EACN,MAAM;AAAA,EACN,OAAO;AACT;AAMO,IAAM,2BAA6C;AAAA,EACxD,aAAa,CAAC;AAAA,EACd,eAAe,CAAC;AAAA,EAChB,OAAO,CAAC;AAAA,EACR,OAAO,CAAC;AAAA,EACR,QAAQ,CAAC;AACX;AAkCO,IAAM,uBAAuB;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAKO,IAAM,uBAA0D;AAAA,EACrE,YAAY;AAAA,EACZ,cAAc;AAAA,EACd,MAAM;AAAA,EACN,MAAM;AAAA,EACN,OAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../src/hierarchy/orgHierarchy.ts"],"sourcesContent":["/**\n * @oplytics/shared-ui/hierarchy — Org Hierarchy Types & Utilities\n *\n * Hierarchy: Enterprise > Business Unit > Site > Area > Asset\n *\n * Single source of truth for org-hierarchy types used by:\n * - Portal (direct DB via tRPC)\n * - All subdomains (via Portal Service API)\n *\n * The canonical data shape matches the Portal Service API response:\n * GET /api/service/hierarchy\n */\n\n/* ── Base Node ── */\n\nexport interface OrgHierarchyNode {\n id: number;\n name: string;\n code?: string;\n}\n\n/* ── Flat hierarchy data — matches Portal Service API /api/service/hierarchy ── */\n\nexport interface OrgHierarchyEnterprise extends OrgHierarchyNode {}\n\nexport interface OrgHierarchyBusinessUnit extends OrgHierarchyNode {\n enterpriseId: number;\n}\n\nexport interface OrgHierarchySite extends OrgHierarchyNode {\n enterpriseId: number;\n businessUnitId: number;\n location?: string | null;\n}\n\nexport interface OrgHierarchyArea extends OrgHierarchyNode {\n siteId: number;\n}\n\nexport interface OrgHierarchyAsset extends OrgHierarchyNode {\n siteId: number;\n areaId: number;\n assetType?: string;\n}\n\n/**\n * Canonical flat hierarchy payload.\n * Every consumer (Portal tRPC, Service API REST) must return this shape.\n */\nexport interface OrgHierarchyData {\n enterprises: OrgHierarchyEnterprise[];\n businessUnits: OrgHierarchyBusinessUnit[];\n sites: OrgHierarchySite[];\n areas: OrgHierarchyArea[];\n assets: OrgHierarchyAsset[];\n}\n\n/* ── Selection state ── */\n\nexport interface OrgHierarchySelection {\n enterprise: OrgHierarchyNode | null;\n businessUnit: OrgHierarchyNode | null;\n site: OrgHierarchyNode | null;\n area: OrgHierarchyNode | null;\n asset: OrgHierarchyNode | null;\n}\n\nexport const ORG_HIERARCHY_EMPTY: OrgHierarchySelection = {\n enterprise: null,\n businessUnit: null,\n site: null,\n area: null,\n asset: null,\n};\n\n/**\n * An empty hierarchy payload. Use as the canonical \"no data\" value so every\n * consumer returns the same shape (never null/undefined for a missing tree).\n */\nexport const ORG_HIERARCHY_DATA_EMPTY: OrgHierarchyData = {\n enterprises: [],\n businessUnits: [],\n sites: [],\n areas: [],\n assets: [],\n};\n\n/* ── Context value ── */\n\nexport interface OrgHierarchyContextValue {\n /** Current selection at each level */\n selection: OrgHierarchySelection;\n\n /** Flat lists filtered by current selection */\n enterprises: OrgHierarchyNode[];\n businessUnits: OrgHierarchyNode[];\n sites: OrgHierarchyNode[];\n areas: OrgHierarchyNode[];\n assets: OrgHierarchyNode[];\n\n /**\n * The unfiltered server-scoped tree, as fetched — the same payload the\n * filtered lists above are derived from. Exposed (rather than only the\n * per-level filtered lists) because computing a hierarchy attribution code\n * (see hierarchyCode.ts) needs full sibling sets at every level, not just\n * the ones matching the current selection. `null` while loading.\n */\n hierarchyData: OrgHierarchyData | null;\n\n /** Setters — selecting a level clears all levels below it */\n selectEnterprise: (node: OrgHierarchyNode | null) => void;\n selectBusinessUnit: (node: OrgHierarchyNode | null) => void;\n selectSite: (node: OrgHierarchyNode | null) => void;\n selectArea: (node: OrgHierarchyNode | null) => void;\n selectAsset: (node: OrgHierarchyNode | null) => void;\n\n /** Whether the user can switch enterprises (platform_admin only) */\n canSwitchEnterprise: boolean;\n\n /** Loading state */\n loading: boolean;\n\n /** Breadcrumb trail as an array of { level, node } */\n breadcrumbs: { level: string; node: OrgHierarchyNode }[];\n}\n\n/* ── Hierarchy levels (for iteration) ── */\n\nexport const ORG_HIERARCHY_LEVELS = [\n \"enterprise\",\n \"businessUnit\",\n \"site\",\n \"area\",\n \"asset\",\n] as const;\n\nexport type OrgHierarchyLevel = (typeof ORG_HIERARCHY_LEVELS)[number];\n\n/** Human-readable labels for each level */\nexport const ORG_HIERARCHY_LABELS: Record<OrgHierarchyLevel, string> = {\n enterprise: \"Enterprise\",\n businessUnit: \"Business Unit\",\n site: \"Site\",\n area: \"Area\",\n asset: \"Asset\",\n};\n"],"mappings":";AAmEO,IAAM,sBAA6C;AAAA,EACxD,YAAY;AAAA,EACZ,cAAc;AAAA,EACd,MAAM;AAAA,EACN,MAAM;AAAA,EACN,OAAO;AACT;AAMO,IAAM,2BAA6C;AAAA,EACxD,aAAa,CAAC;AAAA,EACd,eAAe,CAAC;AAAA,EAChB,OAAO,CAAC;AAAA,EACR,OAAO,CAAC;AAAA,EACR,QAAQ,CAAC;AACX;AA2CO,IAAM,uBAAuB;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAKO,IAAM,uBAA0D;AAAA,EACrE,YAAY;AAAA,EACZ,cAAc;AAAA,EACd,MAAM;AAAA,EACN,MAAM;AAAA,EACN,OAAO;AACT;","names":[]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  ORG_HIERARCHY_EMPTY
3
- } from "./chunk-PS4K7FKB.js";
3
+ } from "./chunk-HLMIR5UV.js";
4
4
 
5
5
  // src/hierarchy/selectionParams.ts
6
6
  var ORG_HIERARCHY_PARAM = "oh";
@@ -109,4 +109,4 @@ export {
109
109
  stripSelectionParamFromLocation,
110
110
  resolveSelectionFromIds
111
111
  };
112
- //# sourceMappingURL=chunk-3E3GLIQV.js.map
112
+ //# sourceMappingURL=chunk-IEBZGU6X.js.map
@@ -2,13 +2,13 @@ import {
2
2
  readSelectionParamFromLocation,
3
3
  resolveSelectionFromIds,
4
4
  stripSelectionParamFromLocation
5
- } from "./chunk-3E3GLIQV.js";
5
+ } from "./chunk-IEBZGU6X.js";
6
6
  import {
7
7
  ACTIVE_ENTERPRISE_COOKIE
8
8
  } from "./chunk-3G43UG63.js";
9
9
  import {
10
10
  ORG_HIERARCHY_EMPTY
11
- } from "./chunk-PS4K7FKB.js";
11
+ } from "./chunk-HLMIR5UV.js";
12
12
  import {
13
13
  Tooltip,
14
14
  TooltipContent,
@@ -90,7 +90,8 @@ function createOrgHierarchyContext(options) {
90
90
  },
91
91
  canSwitchEnterprise: false,
92
92
  loading: true,
93
- breadcrumbs: []
93
+ breadcrumbs: [],
94
+ hierarchyData: null
94
95
  });
95
96
  function OrgHierarchyProvider({
96
97
  children,
@@ -250,7 +251,8 @@ function createOrgHierarchyContext(options) {
250
251
  selectAsset,
251
252
  canSwitchEnterprise,
252
253
  loading: isLoading,
253
- breadcrumbs
254
+ breadcrumbs,
255
+ hierarchyData: hierarchy ?? null
254
256
  }),
255
257
  [
256
258
  selection,
@@ -266,7 +268,8 @@ function createOrgHierarchyContext(options) {
266
268
  selectAsset,
267
269
  canSwitchEnterprise,
268
270
  isLoading,
269
- breadcrumbs
271
+ breadcrumbs,
272
+ hierarchy
270
273
  ]
271
274
  );
272
275
  return /* @__PURE__ */ jsx(OrgHierarchyCtx.Provider, { value, children });
@@ -281,11 +284,45 @@ function createOrgHierarchyContext(options) {
281
284
  import { ChevronRight, ChevronDown, Building2, Network, MapPin, LayoutGrid, Box } from "lucide-react";
282
285
  import { useState as useState2 } from "react";
283
286
  import { jsx as jsx2, jsxs } from "react/jsx-runtime";
287
+ function idReference(level, label, id) {
288
+ const short = level === "businessUnit" ? "BU" : label;
289
+ return `${short} #${id}`;
290
+ }
291
+ function hierarchyCodeFor(level, selection, selectedId, tree) {
292
+ if (!tree || !selection.enterprise) return null;
293
+ const enterpriseId = selection.enterprise.id;
294
+ const input = {
295
+ enterpriseId,
296
+ businessUnitId: level === "businessUnit" ? selectedId : selection.businessUnit?.id,
297
+ siteId: level === "site" ? selectedId : selection.site?.id,
298
+ areaId: level === "area" ? selectedId : selection.area?.id,
299
+ assetId: level === "asset" ? selectedId : selection.asset?.id
300
+ };
301
+ const code = computeHierarchyCode(input, tree);
302
+ const expectedSegments = { enterprise: 1, businessUnit: 2, site: 3, area: 4, asset: 5 }[level];
303
+ if (code.split("-").length < expectedSegments) return null;
304
+ return code;
305
+ }
306
+ function LevelReference({ text, compact }) {
307
+ if (!text) return null;
308
+ return /* @__PURE__ */ jsx2(
309
+ "span",
310
+ {
311
+ className: cn(
312
+ "block leading-none text-[9px] text-[#596475] truncate max-w-[120px]",
313
+ compact && "text-[8px]"
314
+ ),
315
+ children: text
316
+ }
317
+ );
318
+ }
284
319
  function BreadcrumbLevel({
285
320
  config,
286
321
  isLast,
287
322
  compact,
288
- renderDropdown
323
+ renderDropdown,
324
+ selection,
325
+ hierarchyData
289
326
  }) {
290
327
  const nodes = config.getNodes();
291
328
  const selected = config.getSelected();
@@ -293,19 +330,24 @@ function BreadcrumbLevel({
293
330
  const canSwitch = config.canSwitch !== false;
294
331
  const hasMultiple = nodes.length > 1;
295
332
  if (!selected) return null;
333
+ const code = hierarchyCodeFor(config.key, selection, selected.id, hierarchyData);
334
+ const refText = config.key === "enterprise" ? null : `${idReference(config.key, config.label, selected.id)}${code ? ` \xB7 ${code}` : ""}`;
296
335
  if (!hasMultiple || !canSwitch) {
297
336
  return /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
298
337
  /* @__PURE__ */ jsxs(
299
338
  "div",
300
339
  {
301
340
  className: cn(
302
- "flex items-center gap-1.5 px-2 py-1 rounded-md text-sm",
341
+ "flex flex-col justify-center px-2 py-1 rounded-md text-sm",
303
342
  "text-[#E2E8F0]",
304
343
  compact && "px-1.5 py-0.5 text-xs"
305
344
  ),
306
345
  children: [
307
- /* @__PURE__ */ jsx2(Icon, { className: cn("shrink-0 text-[#8890A0]", compact ? "h-3 w-3" : "h-3.5 w-3.5") }),
308
- /* @__PURE__ */ jsx2("span", { className: "truncate max-w-[120px]", children: selected.name })
346
+ /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-1.5", children: [
347
+ /* @__PURE__ */ jsx2(Icon, { className: cn("shrink-0 text-[#8890A0]", compact ? "h-3 w-3" : "h-3.5 w-3.5") }),
348
+ /* @__PURE__ */ jsx2("span", { className: "truncate max-w-[120px]", children: selected.name })
349
+ ] }),
350
+ /* @__PURE__ */ jsx2(LevelReference, { text: refText, compact })
309
351
  ]
310
352
  }
311
353
  ),
@@ -316,16 +358,19 @@ function BreadcrumbLevel({
316
358
  "button",
317
359
  {
318
360
  className: cn(
319
- "flex items-center gap-1.5 px-2 py-1 rounded-md text-sm",
361
+ "flex flex-col justify-center px-2 py-1 rounded-md text-sm",
320
362
  "text-[#E2E8F0] hover:bg-[#1E2738] hover:text-white",
321
363
  "transition-colors cursor-pointer outline-none",
322
364
  "focus-visible:ring-1 focus-visible:ring-[#8C34E9]",
323
365
  compact && "px-1.5 py-0.5 text-xs"
324
366
  ),
325
367
  children: [
326
- /* @__PURE__ */ jsx2(Icon, { className: cn("shrink-0 text-[#8890A0]", compact ? "h-3 w-3" : "h-3.5 w-3.5") }),
327
- /* @__PURE__ */ jsx2("span", { className: "truncate max-w-[120px]", children: selected.name }),
328
- /* @__PURE__ */ jsx2(ChevronDown, { className: cn("shrink-0 text-[#596475]", compact ? "h-2.5 w-2.5" : "h-3 w-3") })
368
+ /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-1.5", children: [
369
+ /* @__PURE__ */ jsx2(Icon, { className: cn("shrink-0 text-[#8890A0]", compact ? "h-3 w-3" : "h-3.5 w-3.5") }),
370
+ /* @__PURE__ */ jsx2("span", { className: "truncate max-w-[120px]", children: selected.name }),
371
+ /* @__PURE__ */ jsx2(ChevronDown, { className: cn("shrink-0 text-[#596475]", compact ? "h-2.5 w-2.5" : "h-3 w-3") })
372
+ ] }),
373
+ /* @__PURE__ */ jsx2(LevelReference, { text: refText, compact })
329
374
  ]
330
375
  }
331
376
  );
@@ -455,7 +500,7 @@ function HierarchyNavigator({
455
500
  /* @__PURE__ */ jsx2("div", { className: "h-6 w-20 rounded bg-[#1E2738]" })
456
501
  ] });
457
502
  }
458
- const levels = [
503
+ const allLevels = [
459
504
  {
460
505
  key: "enterprise",
461
506
  label: "Enterprise",
@@ -497,7 +542,8 @@ function HierarchyNavigator({
497
542
  getSelected: () => ctx.selection.asset,
498
543
  onSelect: ctx.selectAsset
499
544
  }
500
- ].slice(0, maxDepth);
545
+ ];
546
+ const levels = allLevels.slice(0, maxDepth);
501
547
  const selectedLevels = levels.filter((l) => l.getSelected() !== null);
502
548
  const nextLevel = levels.find((l) => l.getSelected() === null && l.getNodes().length > 0);
503
549
  return /* @__PURE__ */ jsxs(
@@ -512,7 +558,9 @@ function HierarchyNavigator({
512
558
  config: level,
513
559
  isLast: idx === selectedLevels.length - 1 && !nextLevel,
514
560
  compact,
515
- renderDropdown
561
+ renderDropdown,
562
+ selection: ctx.selection,
563
+ hierarchyData: ctx.hierarchyData
516
564
  },
517
565
  level.key
518
566
  )),
@@ -538,6 +586,8 @@ export {
538
586
  computeHierarchyCode,
539
587
  readActiveEnterpriseCookie,
540
588
  createOrgHierarchyContext,
589
+ idReference,
590
+ hierarchyCodeFor,
541
591
  HierarchyNavigator
542
592
  };
543
- //# sourceMappingURL=chunk-CYIMXOQW.js.map
593
+ //# sourceMappingURL=chunk-MZVMN77F.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(match.slice(ACTIVE_ENTERPRISE_COOKIE.length + 1));\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(options: CreateOrgHierarchyContextOptions) {\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] = 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 (typeof window !== \"undefined\" && readActiveEnterpriseCookie() !== activeAtMount) {\n window.location.reload();\n }\n };\n if (typeof window !== \"undefined\") {\n window.addEventListener(\"focus\", reloadIfEnterpriseChanged);\n document.addEventListener(\"visibilitychange\", reloadIfEnterpriseChanged);\n return () => {\n window.removeEventListener(\"focus\", reloadIfEnterpriseChanged);\n document.removeEventListener(\"visibilitychange\", reloadIfEnterpriseChanged);\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 }, [pendingIds, isLoading, enterprises, selection.enterprise, canSwitchEnterprise]);\n\n // ── Cascade setters ──\n\n const selectEnterprise = useCallback((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 }, [canSwitchEnterprise, onEnterpriseSwitched]);\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)\n crumbs.push({ level: \"Site\", node: selection.site });\n if (selection.area)\n 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 { OrgHierarchyNode, OrgHierarchyContextValue, OrgHierarchyData, OrgHierarchyLevel } from \"./orgHierarchy\";\nimport { computeHierarchyCode } from \"./hierarchyCode\";\nimport { ChevronRight, ChevronDown, Building2, Network, MapPin, LayoutGrid, Box } from \"lucide-react\";\nimport { useState, type ReactNode } from \"react\";\nimport { Tooltip, TooltipTrigger, TooltipContent } from \"../primitives\";\n\n/* ── Level config ── */\n\ninterface 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 * \"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(level: OrgHierarchyLevel, label: string, id: number): 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: 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 = { enterprise: 1, businessUnit: 2, site: 3, area: 4, asset: 5 }[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({ text, compact }: { text: string | null; compact?: boolean }) {\n if (!text) return null;\n return (\n <span\n className={cn(\n \"block leading-none text-[9px] text-[#596475] truncate max-w-[120px]\",\n compact && \"text-[8px]\"\n )}\n >\n {text}\n </span>\n );\n}\n\nfunction BreadcrumbLevel({\n config,\n isLast,\n compact,\n renderDropdown,\n selection,\n hierarchyData,\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 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(config.key, selection, selected.id, hierarchyData);\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, show as static text\n if (!hasMultiple || !canSwitch) {\n return (\n <div className=\"flex items-center gap-1\">\n <div\n className={cn(\n \"flex flex-col justify-center px-2 py-1 rounded-md text-sm\",\n \"text-[#E2E8F0]\",\n compact && \"px-1.5 py-0.5 text-xs\"\n )}\n >\n <span className=\"flex items-center gap-1.5\">\n <Icon className={cn(\"shrink-0 text-[#8890A0]\", compact ? \"h-3 w-3\" : \"h-3.5 w-3.5\")} />\n <span className=\"truncate max-w-[120px]\">{selected.name}</span>\n </span>\n <LevelReference text={refText} compact={compact} />\n </div>\n {!isLast && (\n <ChevronRight className={cn(\"shrink-0 text-[#596475]\", compact ? \"h-3 w-3\" : \"h-3.5 w-3.5\")} />\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-2 py-1 rounded-md text-sm\",\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.5 py-0.5 text-xs\"\n )}\n >\n <span className=\"flex items-center gap-1.5\">\n <Icon className={cn(\"shrink-0 text-[#8890A0]\", compact ? \"h-3 w-3\" : \"h-3.5 w-3.5\")} />\n <span className=\"truncate max-w-[120px]\">{selected.name}</span>\n <ChevronDown className={cn(\"shrink-0 text-[#596475]\", compact ? \"h-2.5 w-2.5\" : \"h-3 w-3\")} />\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\">\n {trigger}\n </div>\n )}\n {!isLast && (\n <ChevronRight className={cn(\"shrink-0 text-[#596475]\", compact ? \"h-3 w-3\" : \"h-3.5 w-3.5\")} />\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 className={cn(\"shrink-0 text-[#596475]\", compact ? \"h-3 w-3\" : \"h-3.5 w-3.5\")} />\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.5 px-2 py-1 rounded-md text-sm\",\n \"text-[#596475] cursor-not-allowed\",\n compact && \"px-1.5 py-0.5 text-xs\"\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 </button>\n </TooltipTrigger>\n <TooltipContent>{label} can't be changed from this page</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 className={cn(\"shrink-0 text-[#596475]\", compact ? \"h-3 w-3\" : \"h-3.5 w-3.5\")} />\n <button\n onClick={() => onSelect(nodes[0])}\n className={cn(\n \"flex items-center gap-1.5 px-2 py-1 rounded-md text-sm\",\n \"text-[#596475] hover:bg-[#1E2738] hover:text-[#8890A0]\",\n \"transition-colors cursor-pointer\",\n compact && \"px-1.5 py-0.5 text-xs\"\n )}\n >\n <Icon className={cn(\"shrink-0\", compact ? \"h-3 w-3\" : \"h-3.5 w-3.5\")} />\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.5 px-2 py-1 rounded-md text-sm\",\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.5 py-0.5 text-xs\"\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 className={cn(\"shrink-0\", compact ? \"h-2.5 w-2.5\" : \"h-3 w-3\")} />\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 className={cn(\"shrink-0 text-[#596475]\", compact ? \"h-3 w-3\" : \"h-3.5 w-3.5\")} />\n {renderDropdown ? (\n renderDropdown({ trigger, items, align: \"start\" })\n ) : (\n <div className=\"relative group\">\n {trigger}\n </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((l) => l.getSelected() === null && l.getNodes().length > 0);\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 />\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\">No hierarchy data available</span>\n )}\n </nav>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA2BA,SAAS,aAAa,YAAsB,UAAiC;AAC3E,QAAM,SAAS,CAAC,GAAG,UAAU,EAAE,KAAK,CAAC,GAAG,MAAM,IAAI,CAAC;AACnD,QAAM,WAAW,OAAO,QAAQ,QAAQ;AACxC,SAAO,aAAa,KAAK,OAAO,WAAW;AAC7C;AAEA,SAAS,IAAI,GAAW,OAAuB;AAC7C,SAAO,OAAO,CAAC,EAAE,SAAS,OAAO,GAAG;AACtC;AASO,SAAS,qBACd,MACA,MACQ;AACR,QAAM,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AAEJ;","names":["useState","jsx","useState"]}
@@ -1,4 +1,4 @@
1
- import { O as OrgHierarchySelection } from './orgHierarchy-BLW4dt8Q.js';
1
+ import { O as OrgHierarchySelection } from './orgHierarchy-BVpunsrZ.js';
2
2
 
3
3
  /**
4
4
  * crossNav — build the sidebar cross-service links (service → service jump
@@ -1,5 +1,5 @@
1
- import { a as OrgHierarchyData } from '../orgHierarchy-BLW4dt8Q.js';
2
- export { c as ORG_HIERARCHY_DATA_EMPTY, d as ORG_HIERARCHY_EMPTY, e as ORG_HIERARCHY_LABELS, f as ORG_HIERARCHY_LEVELS, g as OrgHierarchyArea, h as OrgHierarchyAsset, i as OrgHierarchyBusinessUnit, b as OrgHierarchyContextValue, j as OrgHierarchyEnterprise, k as OrgHierarchyLevel, l as OrgHierarchyNode, O as OrgHierarchySelection, m as OrgHierarchySite } from '../orgHierarchy-BLW4dt8Q.js';
1
+ import { a as OrgHierarchyData } from '../orgHierarchy-BVpunsrZ.js';
2
+ export { d as ORG_HIERARCHY_DATA_EMPTY, e as ORG_HIERARCHY_EMPTY, f as ORG_HIERARCHY_LABELS, g as ORG_HIERARCHY_LEVELS, h as OrgHierarchyArea, i as OrgHierarchyAsset, j as OrgHierarchyBusinessUnit, b as OrgHierarchyContextValue, k as OrgHierarchyEnterprise, c as OrgHierarchyLevel, l as OrgHierarchyNode, O as OrgHierarchySelection, m as OrgHierarchySite } from '../orgHierarchy-BVpunsrZ.js';
3
3
 
4
4
  /**
5
5
  * Enterprise Override — shared helper for platform_admin enterprise switching.
@@ -8,7 +8,7 @@ import {
8
8
  ORG_HIERARCHY_EMPTY,
9
9
  ORG_HIERARCHY_LABELS,
10
10
  ORG_HIERARCHY_LEVELS
11
- } from "../chunk-PS4K7FKB.js";
11
+ } from "../chunk-HLMIR5UV.js";
12
12
  export {
13
13
  ACTIVE_ENTERPRISE_COOKIE,
14
14
  ORG_HIERARCHY_DATA_EMPTY,
@@ -1,5 +1,5 @@
1
- import { a as OrgHierarchyData, O as OrgHierarchySelection, b as OrgHierarchyContextValue } from '../orgHierarchy-BLW4dt8Q.js';
2
- export { c as ORG_HIERARCHY_DATA_EMPTY, d as ORG_HIERARCHY_EMPTY, e as ORG_HIERARCHY_LABELS, f as ORG_HIERARCHY_LEVELS, g as OrgHierarchyArea, h as OrgHierarchyAsset, i as OrgHierarchyBusinessUnit, j as OrgHierarchyEnterprise, k as OrgHierarchyLevel, l as OrgHierarchyNode, m as OrgHierarchySite } from '../orgHierarchy-BLW4dt8Q.js';
1
+ import { a as OrgHierarchyData, O as OrgHierarchySelection, b as OrgHierarchyContextValue, c as OrgHierarchyLevel } from '../orgHierarchy-BVpunsrZ.js';
2
+ export { d as ORG_HIERARCHY_DATA_EMPTY, e as ORG_HIERARCHY_EMPTY, f as ORG_HIERARCHY_LABELS, g as ORG_HIERARCHY_LEVELS, h as OrgHierarchyArea, i as OrgHierarchyAsset, j as OrgHierarchyBusinessUnit, k as OrgHierarchyEnterprise, l as OrgHierarchyNode, m as OrgHierarchySite } from '../orgHierarchy-BVpunsrZ.js';
3
3
  export { ACTIVE_ENTERPRISE_COOKIE, applyEnterpriseOverride, scopeHierarchyToEnterprise } from './core.js';
4
4
  import * as react_jsx_runtime from 'react/jsx-runtime';
5
5
  import { ReactNode } from 'react';
@@ -128,6 +128,19 @@ declare function createOrgHierarchyContext(options: CreateOrgHierarchyContextOpt
128
128
  useOrgHierarchy: () => OrgHierarchyContextValue;
129
129
  };
130
130
 
131
+ /**
132
+ * "Site #30002" style reference text shown in small print under a selected
133
+ * breadcrumb level — the raw id disambiguated by level, since ids aren't
134
+ * unique across levels (a BU and a Site can share the same numeric id).
135
+ */
136
+ declare function idReference(level: OrgHierarchyLevel, label: string, id: number): string;
137
+ /**
138
+ * Computes the E/B/S/A/X hierarchy attribution code for a selected node,
139
+ * given the full unfiltered tree. Returns null when the tree isn't loaded
140
+ * yet or the node can't be resolved (e.g. stale id mid-refetch) — callers
141
+ * should just omit the sub-text rather than show a broken code.
142
+ */
143
+ declare function hierarchyCodeFor(level: OrgHierarchyLevel, selection: OrgHierarchyContextValue["selection"], selectedId: number, tree: OrgHierarchyData | null): string | null;
131
144
  interface DropdownRenderProps {
132
145
  trigger: ReactNode;
133
146
  items: Array<{
@@ -157,4 +170,4 @@ interface HierarchyNavigatorProps {
157
170
  }
158
171
  declare function HierarchyNavigator({ hierarchy: ctx, compact, maxDepth, className, renderDropdown, }: HierarchyNavigatorProps): react_jsx_runtime.JSX.Element;
159
172
 
160
- export { type CreateOrgHierarchyContextOptions, type DropdownRenderProps, type HierarchyCodeInput, HierarchyNavigator, type HierarchyNavigatorProps, ORG_HIERARCHY_PARAM, OrgHierarchyContextValue, OrgHierarchyData, OrgHierarchySelection, type OrgSelectionIds, appendSelectionParam, computeHierarchyCode, createOrgHierarchyContext, parseSelectionParam, readActiveEnterpriseCookie, readSelectionParamFromLocation, resolveSelectionFromIds, serializeSelectionParam, stripSelectionParamFromLocation };
173
+ export { type CreateOrgHierarchyContextOptions, type DropdownRenderProps, type HierarchyCodeInput, HierarchyNavigator, type HierarchyNavigatorProps, ORG_HIERARCHY_PARAM, OrgHierarchyContextValue, OrgHierarchyData, OrgHierarchyLevel, OrgHierarchySelection, type OrgSelectionIds, appendSelectionParam, computeHierarchyCode, createOrgHierarchyContext, hierarchyCodeFor, idReference, parseSelectionParam, readActiveEnterpriseCookie, readSelectionParamFromLocation, resolveSelectionFromIds, serializeSelectionParam, stripSelectionParamFromLocation };
@@ -2,8 +2,10 @@ import {
2
2
  HierarchyNavigator,
3
3
  computeHierarchyCode,
4
4
  createOrgHierarchyContext,
5
+ hierarchyCodeFor,
6
+ idReference,
5
7
  readActiveEnterpriseCookie
6
- } from "../chunk-CYIMXOQW.js";
8
+ } from "../chunk-MZVMN77F.js";
7
9
  import {
8
10
  ORG_HIERARCHY_PARAM,
9
11
  appendSelectionParam,
@@ -12,7 +14,7 @@ import {
12
14
  resolveSelectionFromIds,
13
15
  serializeSelectionParam,
14
16
  stripSelectionParamFromLocation
15
- } from "../chunk-3E3GLIQV.js";
17
+ } from "../chunk-IEBZGU6X.js";
16
18
  import {
17
19
  ACTIVE_ENTERPRISE_COOKIE,
18
20
  applyEnterpriseOverride,
@@ -23,7 +25,7 @@ import {
23
25
  ORG_HIERARCHY_EMPTY,
24
26
  ORG_HIERARCHY_LABELS,
25
27
  ORG_HIERARCHY_LEVELS
26
- } from "../chunk-PS4K7FKB.js";
28
+ } from "../chunk-HLMIR5UV.js";
27
29
  import "../chunk-NTFR5ZIF.js";
28
30
  import "../chunk-JT3XLKKD.js";
29
31
  import "../chunk-R4NOLCSI.js";
@@ -39,6 +41,8 @@ export {
39
41
  applyEnterpriseOverride,
40
42
  computeHierarchyCode,
41
43
  createOrgHierarchyContext,
44
+ hierarchyCodeFor,
45
+ idReference,
42
46
  parseSelectionParam,
43
47
  readActiveEnterpriseCookie,
44
48
  readSelectionParamFromLocation,
@@ -1,9 +1,9 @@
1
- import { S as SharedSidebarConfig } from '../HealthFooter-9rZjMmqc.js';
2
- export { C as CrossServiceNav, d as CrossServiceNavProps, D as DashboardLayout, a as DashboardLayoutEnterprise, b as DashboardLayoutProps, c as DashboardLayoutUser, H as HealthFooter, e as HealthFooterEnterprise, f as HealthFooterProps, g as HealthFooterUser, M as MenuItem, h as MenuSection, i as SharedSidebarProps, j as getInitials, k as isAdminRole, l as isMenuItemActive, u as useSidebarResize } from '../HealthFooter-9rZjMmqc.js';
1
+ import { S as SharedSidebarConfig } from '../HealthFooter-BIG3oto5.js';
2
+ export { C as CrossServiceNav, d as CrossServiceNavProps, D as DashboardLayout, a as DashboardLayoutEnterprise, b as DashboardLayoutProps, c as DashboardLayoutUser, H as HealthFooter, e as HealthFooterEnterprise, f as HealthFooterProps, g as HealthFooterUser, M as MenuItem, h as MenuSection, i as SharedSidebarProps, j as getInitials, k as isAdminRole, l as isMenuItemActive, u as useSidebarResize } from '../HealthFooter-BIG3oto5.js';
3
3
  import * as react_jsx_runtime from 'react/jsx-runtime';
4
4
  import { ReactNode } from 'react';
5
- import '../crossNav-Bd8-0qoi.js';
6
- import '../orgHierarchy-BLW4dt8Q.js';
5
+ import '../crossNav-BwdA3B2h.js';
6
+ import '../orgHierarchy-BVpunsrZ.js';
7
7
 
8
8
  interface DashboardLayoutSkeletonProps {
9
9
  className?: string;
@@ -19,12 +19,12 @@ import {
19
19
  policyDeploymentConfig,
20
20
  sqdcpConfig,
21
21
  useSidebarResize
22
- } from "../chunk-7I4ADEJY.js";
22
+ } from "../chunk-EGGUAREC.js";
23
23
  import "../chunk-4QJMLQSH.js";
24
- import "../chunk-CYIMXOQW.js";
25
- import "../chunk-3E3GLIQV.js";
24
+ import "../chunk-MZVMN77F.js";
25
+ import "../chunk-IEBZGU6X.js";
26
26
  import "../chunk-3G43UG63.js";
27
- import "../chunk-PS4K7FKB.js";
27
+ import "../chunk-HLMIR5UV.js";
28
28
  import "../chunk-NTFR5ZIF.js";
29
29
  import "../chunk-JT3XLKKD.js";
30
30
  import "../chunk-R4NOLCSI.js";
@@ -66,6 +66,14 @@ interface OrgHierarchyContextValue {
66
66
  sites: OrgHierarchyNode[];
67
67
  areas: OrgHierarchyNode[];
68
68
  assets: OrgHierarchyNode[];
69
+ /**
70
+ * The unfiltered server-scoped tree, as fetched — the same payload the
71
+ * filtered lists above are derived from. Exposed (rather than only the
72
+ * per-level filtered lists) because computing a hierarchy attribution code
73
+ * (see hierarchyCode.ts) needs full sibling sets at every level, not just
74
+ * the ones matching the current selection. `null` while loading.
75
+ */
76
+ hierarchyData: OrgHierarchyData | null;
69
77
  /** Setters — selecting a level clears all levels below it */
70
78
  selectEnterprise: (node: OrgHierarchyNode | null) => void;
71
79
  selectBusinessUnit: (node: OrgHierarchyNode | null) => void;
@@ -87,4 +95,4 @@ type OrgHierarchyLevel = (typeof ORG_HIERARCHY_LEVELS)[number];
87
95
  /** Human-readable labels for each level */
88
96
  declare const ORG_HIERARCHY_LABELS: Record<OrgHierarchyLevel, string>;
89
97
 
90
- export { type OrgHierarchySelection as O, type OrgHierarchyData as a, type OrgHierarchyContextValue as b, ORG_HIERARCHY_DATA_EMPTY as c, ORG_HIERARCHY_EMPTY as d, ORG_HIERARCHY_LABELS as e, ORG_HIERARCHY_LEVELS as f, type OrgHierarchyArea as g, type OrgHierarchyAsset as h, type OrgHierarchyBusinessUnit as i, type OrgHierarchyEnterprise as j, type OrgHierarchyLevel as k, type OrgHierarchyNode as l, type OrgHierarchySite as m };
98
+ export { type OrgHierarchySelection as O, type OrgHierarchyData as a, type OrgHierarchyContextValue as b, type OrgHierarchyLevel as c, ORG_HIERARCHY_DATA_EMPTY as d, ORG_HIERARCHY_EMPTY as e, ORG_HIERARCHY_LABELS as f, ORG_HIERARCHY_LEVELS as g, type OrgHierarchyArea as h, type OrgHierarchyAsset as i, type OrgHierarchyBusinessUnit as j, type OrgHierarchyEnterprise as k, type OrgHierarchyNode as l, type OrgHierarchySite as m };
@@ -1,5 +1,5 @@
1
- export { A as ADMIN_SEE_ALL_ROLES, B as BuildCrossServiceLinksOptions, C as CrossServiceLink, S as SLUG_ALIASES, b as buildCrossServiceLinks, n as normalizeServiceSlug } from '../crossNav-Bd8-0qoi.js';
2
- import '../orgHierarchy-BLW4dt8Q.js';
1
+ export { A as ADMIN_SEE_ALL_ROLES, B as BuildCrossServiceLinksOptions, C as CrossServiceLink, S as SLUG_ALIASES, b as buildCrossServiceLinks, n as normalizeServiceSlug } from '../crossNav-BwdA3B2h.js';
2
+ import '../orgHierarchy-BVpunsrZ.js';
3
3
 
4
4
  /**
5
5
  * Platform domain resolution — single source of truth for building
@@ -11,15 +11,15 @@ import {
11
11
  inDevServices,
12
12
  liveServices,
13
13
  normalizeServiceSlug
14
- } from "../chunk-PLS7NDDR.js";
14
+ } from "../chunk-G7XJLTNY.js";
15
15
  import {
16
16
  DEFAULT_PLATFORM_DOMAIN,
17
17
  getPlatformDomain,
18
18
  platformUrl,
19
19
  portalUrl
20
20
  } from "../chunk-4QJMLQSH.js";
21
- import "../chunk-3E3GLIQV.js";
22
- import "../chunk-PS4K7FKB.js";
21
+ import "../chunk-IEBZGU6X.js";
22
+ import "../chunk-HLMIR5UV.js";
23
23
  export {
24
24
  ADMIN_SEE_ALL_ROLES,
25
25
  DEFAULT_PLATFORM_DOMAIN,
@@ -1,9 +1,9 @@
1
- import { D as DashboardLayout, a as DashboardLayoutEnterprise, b as DashboardLayoutProps, c as DashboardLayoutUser } from '../HealthFooter-9rZjMmqc.js';
2
- export { C as CrossServiceNav, d as CrossServiceNavProps, H as HealthFooter, e as HealthFooterEnterprise, f as HealthFooterProps, g as HealthFooterUser, M as MenuItem, h as MenuSection } from '../HealthFooter-9rZjMmqc.js';
3
- export { C as CrossServiceLink, b as buildCrossServiceLinks } from '../crossNav-Bd8-0qoi.js';
1
+ import { D as DashboardLayout, a as DashboardLayoutEnterprise, b as DashboardLayoutProps, c as DashboardLayoutUser } from '../HealthFooter-BIG3oto5.js';
2
+ export { C as CrossServiceNav, d as CrossServiceNavProps, H as HealthFooter, e as HealthFooterEnterprise, f as HealthFooterProps, g as HealthFooterUser, M as MenuItem, h as MenuSection } from '../HealthFooter-BIG3oto5.js';
3
+ export { C as CrossServiceLink, b as buildCrossServiceLinks } from '../crossNav-BwdA3B2h.js';
4
4
  import 'react/jsx-runtime';
5
5
  import 'react';
6
- import '../orgHierarchy-BLW4dt8Q.js';
6
+ import '../orgHierarchy-BVpunsrZ.js';
7
7
 
8
8
  /**
9
9
  * @pablo2410/shared-ui/shell — Oplytics Service Shell
@@ -1,16 +1,16 @@
1
1
  import {
2
2
  buildCrossServiceLinks
3
- } from "../chunk-PLS7NDDR.js";
3
+ } from "../chunk-G7XJLTNY.js";
4
4
  import {
5
5
  CrossServiceNav,
6
6
  DashboardLayout,
7
7
  HealthFooter
8
- } from "../chunk-7I4ADEJY.js";
8
+ } from "../chunk-EGGUAREC.js";
9
9
  import "../chunk-4QJMLQSH.js";
10
- import "../chunk-CYIMXOQW.js";
11
- import "../chunk-3E3GLIQV.js";
10
+ import "../chunk-MZVMN77F.js";
11
+ import "../chunk-IEBZGU6X.js";
12
12
  import "../chunk-3G43UG63.js";
13
- import "../chunk-PS4K7FKB.js";
13
+ import "../chunk-HLMIR5UV.js";
14
14
  import "../chunk-NTFR5ZIF.js";
15
15
  import "../chunk-JT3XLKKD.js";
16
16
  import "../chunk-R4NOLCSI.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pablo2410/shared-ui",
3
- "version": "0.14.0",
3
+ "version": "0.15.0",
4
4
  "description": "Shared UI component library for all Oplytics.digital subdomains",
5
5
  "type": "module",
6
6
  "exports": {
@@ -1 +0,0 @@
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(match.slice(ACTIVE_ENTERPRISE_COOKIE.length + 1));\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(options: CreateOrgHierarchyContextOptions) {\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 });\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] = 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 (typeof window !== \"undefined\" && readActiveEnterpriseCookie() !== activeAtMount) {\n window.location.reload();\n }\n };\n if (typeof window !== \"undefined\") {\n window.addEventListener(\"focus\", reloadIfEnterpriseChanged);\n document.addEventListener(\"visibilitychange\", reloadIfEnterpriseChanged);\n return () => {\n window.removeEventListener(\"focus\", reloadIfEnterpriseChanged);\n document.removeEventListener(\"visibilitychange\", reloadIfEnterpriseChanged);\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 }, [pendingIds, isLoading, enterprises, selection.enterprise, canSwitchEnterprise]);\n\n // ── Cascade setters ──\n\n const selectEnterprise = useCallback((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 }, [canSwitchEnterprise, onEnterpriseSwitched]);\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)\n crumbs.push({ level: \"Site\", node: selection.site });\n if (selection.area)\n 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 }),\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 ]\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 { OrgHierarchyNode, OrgHierarchyContextValue } from \"./orgHierarchy\";\nimport { ChevronRight, ChevronDown, Building2, Network, MapPin, LayoutGrid, Box } from \"lucide-react\";\nimport { useState, type ReactNode } from \"react\";\nimport { Tooltip, TooltipTrigger, TooltipContent } from \"../primitives\";\n\n/* ── Level config ── */\n\ninterface LevelConfig {\n key: string;\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/* ── 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\nfunction BreadcrumbLevel({\n config,\n isLast,\n compact,\n renderDropdown,\n}: {\n config: LevelConfig;\n isLast: boolean;\n compact?: boolean;\n renderDropdown?: (props: DropdownRenderProps) => ReactNode;\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 // If only one option or can't switch, show as static text\n if (!hasMultiple || !canSwitch) {\n return (\n <div className=\"flex items-center gap-1\">\n <div\n className={cn(\n \"flex items-center gap-1.5 px-2 py-1 rounded-md text-sm\",\n \"text-[#E2E8F0]\",\n compact && \"px-1.5 py-0.5 text-xs\"\n )}\n >\n <Icon className={cn(\"shrink-0 text-[#8890A0]\", compact ? \"h-3 w-3\" : \"h-3.5 w-3.5\")} />\n <span className=\"truncate max-w-[120px]\">{selected.name}</span>\n </div>\n {!isLast && (\n <ChevronRight className={cn(\"shrink-0 text-[#596475]\", compact ? \"h-3 w-3\" : \"h-3.5 w-3.5\")} />\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 items-center gap-1.5 px-2 py-1 rounded-md text-sm\",\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.5 py-0.5 text-xs\"\n )}\n >\n <Icon className={cn(\"shrink-0 text-[#8890A0]\", compact ? \"h-3 w-3\" : \"h-3.5 w-3.5\")} />\n <span className=\"truncate max-w-[120px]\">{selected.name}</span>\n <ChevronDown className={cn(\"shrink-0 text-[#596475]\", compact ? \"h-2.5 w-2.5\" : \"h-3 w-3\")} />\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\">\n {trigger}\n </div>\n )}\n {!isLast && (\n <ChevronRight className={cn(\"shrink-0 text-[#596475]\", compact ? \"h-3 w-3\" : \"h-3.5 w-3.5\")} />\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 className={cn(\"shrink-0 text-[#596475]\", compact ? \"h-3 w-3\" : \"h-3.5 w-3.5\")} />\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.5 px-2 py-1 rounded-md text-sm\",\n \"text-[#596475] cursor-not-allowed\",\n compact && \"px-1.5 py-0.5 text-xs\"\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 </button>\n </TooltipTrigger>\n <TooltipContent>{label} can't be changed from this page</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 className={cn(\"shrink-0 text-[#596475]\", compact ? \"h-3 w-3\" : \"h-3.5 w-3.5\")} />\n <button\n onClick={() => onSelect(nodes[0])}\n className={cn(\n \"flex items-center gap-1.5 px-2 py-1 rounded-md text-sm\",\n \"text-[#596475] hover:bg-[#1E2738] hover:text-[#8890A0]\",\n \"transition-colors cursor-pointer\",\n compact && \"px-1.5 py-0.5 text-xs\"\n )}\n >\n <Icon className={cn(\"shrink-0\", compact ? \"h-3 w-3\" : \"h-3.5 w-3.5\")} />\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.5 px-2 py-1 rounded-md text-sm\",\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.5 py-0.5 text-xs\"\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 className={cn(\"shrink-0\", compact ? \"h-2.5 w-2.5\" : \"h-3 w-3\")} />\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 className={cn(\"shrink-0 text-[#596475]\", compact ? \"h-3 w-3\" : \"h-3.5 w-3.5\")} />\n {renderDropdown ? (\n renderDropdown({ trigger, items, align: \"start\" })\n ) : (\n <div className=\"relative group\">\n {trigger}\n </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 levels: 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 ].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((l) => l.getSelected() === null && l.getNodes().length > 0);\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 />\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\">No hierarchy data available</span>\n )}\n </nav>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA2BA,SAAS,aAAa,YAAsB,UAAiC;AAC3E,QAAM,SAAS,CAAC,GAAG,UAAU,EAAE,KAAK,CAAC,GAAG,MAAM,IAAI,CAAC;AACnD,QAAM,WAAW,OAAO,QAAQ,QAAQ;AACxC,SAAO,aAAa,KAAK,OAAO,WAAW;AAC7C;AAEA,SAAS,IAAI,GAAW,OAAuB;AAC7C,SAAO,OAAO,CAAC,EAAE,SAAS,OAAO,GAAG;AACtC;AASO,SAAS,qBACd,MACA,MACQ;AACR,QAAM,WAAqB,CAAC,IAAI,KAAK,YAAY,EAAE;AAEnD,MAAI,KAAK,kBAAkB,KAAM,QAAO,SAAS,KAAK,GAAG;AACzD,QAAM,aAAa,KAAK,cACrB,OAAO,CAAC,OAAO,GAAG,iBAAiB,KAAK,YAAY,EACpD,IAAI,CAAC,OAAO,GAAG,EAAE;AACpB,QAAM,UAAU,aAAa,YAAY,KAAK,cAAc;AAC5D,MAAI,WAAW,KAAM,QAAO,SAAS,KAAK,GAAG;AAC7C,WAAS,KAAK,IAAI,IAAI,SAAS,CAAC,CAAC,EAAE;AAEnC,MAAI,KAAK,UAAU,KAAM,QAAO,SAAS,KAAK,GAAG;AACjD,QAAM,eAAe,KAAK,MACvB,OAAO,CAAC,MAAM,EAAE,mBAAmB,KAAK,cAAc,EACtD,IAAI,CAAC,MAAM,EAAE,EAAE;AAClB,QAAM,YAAY,aAAa,cAAc,KAAK,MAAM;AACxD,MAAI,aAAa,KAAM,QAAO,SAAS,KAAK,GAAG;AAC/C,WAAS,KAAK,IAAI,IAAI,WAAW,CAAC,CAAC,EAAE;AAErC,MAAI,KAAK,UAAU,KAAM,QA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