@elevasis/ui 2.40.1 → 2.41.1

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 (92) hide show
  1. package/dist/api/index.js +4 -6
  2. package/dist/app/index.css +384 -0
  3. package/dist/app/index.d.ts +108 -0
  4. package/dist/app/index.js +17 -27
  5. package/dist/auth/index.css +659 -0
  6. package/dist/auth/index.js +19 -6
  7. package/dist/charts/index.css +533 -0
  8. package/dist/charts/index.js +18 -15
  9. package/dist/{chunk-RXH4D6TY.js → chunk-5M4HSHQ5.js} +631 -2
  10. package/dist/{chunk-TE4P6OSJ.js → chunk-7FJI76OH.js} +1 -1
  11. package/dist/chunk-GMXGDO3I.js +244 -0
  12. package/dist/{chunk-CXY7FMUM.js → chunk-GUKY77FJ.js} +50 -4
  13. package/dist/{chunk-5JYKCULK.js → chunk-NZ2F5RQ4.js} +44 -2
  14. package/dist/{chunk-WF7CONXF.js → chunk-OJJK27GC.js} +658 -6
  15. package/dist/{chunk-RX6RSKWC.js → chunk-QDXTIQT4.js} +29255 -18312
  16. package/dist/{chunk-73EWE2EW.js → chunk-V5HWC5EW.js} +1 -1
  17. package/dist/components/chat/index.js +1 -2
  18. package/dist/components/index.css +149 -149
  19. package/dist/components/index.js +13 -37
  20. package/dist/components/navigation/index.css +659 -0
  21. package/dist/components/navigation/index.js +25 -4
  22. package/dist/features/auth/index.js +14 -38
  23. package/dist/features/clients/index.css +149 -149
  24. package/dist/features/clients/index.js +13 -37
  25. package/dist/features/crm/index.js +13 -37
  26. package/dist/features/dashboard/index.js +13 -37
  27. package/dist/features/delivery/index.js +13 -37
  28. package/dist/features/knowledge/index.css +659 -0
  29. package/dist/features/knowledge/index.js +25 -248
  30. package/dist/features/lead-gen/index.d.ts +81 -0
  31. package/dist/features/lead-gen/index.js +13 -37
  32. package/dist/features/monitoring/index.js +13 -37
  33. package/dist/features/monitoring/requests/index.d.ts +69 -7
  34. package/dist/features/monitoring/requests/index.js +32 -41
  35. package/dist/features/operations/index.d.ts +79 -0
  36. package/dist/features/operations/index.js +13 -37
  37. package/dist/features/seo/index.js +1 -4
  38. package/dist/features/settings/index.js +13 -37
  39. package/dist/hooks/access/index.css +659 -0
  40. package/dist/hooks/access/index.js +19 -5
  41. package/dist/hooks/delivery/index.js +13 -37
  42. package/dist/hooks/index.d.ts +18 -6
  43. package/dist/hooks/index.js +13 -37
  44. package/dist/hooks/published.d.ts +18 -6
  45. package/dist/hooks/published.js +13 -37
  46. package/dist/index.d.ts +151 -7
  47. package/dist/index.js +14 -38
  48. package/dist/initialization/index.js +1 -1
  49. package/dist/knowledge/index.css +659 -0
  50. package/dist/knowledge/index.d.ts +81 -0
  51. package/dist/knowledge/index.js +25 -15
  52. package/dist/layout/index.css +659 -0
  53. package/dist/layout/index.d.ts +18 -2
  54. package/dist/layout/index.js +24 -7
  55. package/dist/organization/index.js +13 -37
  56. package/dist/provider/index.css +384 -0
  57. package/dist/provider/index.d.ts +120 -1
  58. package/dist/provider/index.js +18 -22
  59. package/dist/provider/published.css +533 -0
  60. package/dist/provider/published.d.ts +121 -2
  61. package/dist/provider/published.js +18 -17
  62. package/dist/test-utils/index.js +4 -6
  63. package/dist/theme/index.js +2 -5
  64. package/dist/theme/presets/index.js +1 -2
  65. package/dist/utils/index.js +1 -3
  66. package/package.json +3 -3
  67. package/dist/chunk-3KMDHCAR.js +0 -52
  68. package/dist/chunk-4DRI3G36.js +0 -1016
  69. package/dist/chunk-5EYJ2GIN.js +0 -122
  70. package/dist/chunk-66U7JOWV.js +0 -425
  71. package/dist/chunk-6D4LCJ52.js +0 -10
  72. package/dist/chunk-6EV47QQW.js +0 -340
  73. package/dist/chunk-6ROXVZ3L.js +0 -9
  74. package/dist/chunk-7MTWRSUZ.js +0 -357
  75. package/dist/chunk-7PHY5ONQ.js +0 -85
  76. package/dist/chunk-B2DZLPDL.js +0 -39
  77. package/dist/chunk-CLDCYJQT.js +0 -1
  78. package/dist/chunk-CTJBPF3Z.js +0 -734
  79. package/dist/chunk-DT3QYZVU.js +0 -23
  80. package/dist/chunk-IIMU5YAJ.js +0 -53
  81. package/dist/chunk-IUQAP4IO.js +0 -2131
  82. package/dist/chunk-J3FLIZY4.js +0 -423
  83. package/dist/chunk-K7GKKETO.js +0 -3157
  84. package/dist/chunk-L7GXUSCV.js +0 -215
  85. package/dist/chunk-LJDYY3XB.js +0 -133
  86. package/dist/chunk-NYBEU5TE.js +0 -118
  87. package/dist/chunk-RH5VWWSC.js +0 -624
  88. package/dist/chunk-SJNIOGVX.js +0 -112
  89. package/dist/chunk-TYRUKGGD.js +0 -46
  90. package/dist/chunk-WLOQ4IBG.js +0 -654
  91. package/dist/chunk-X4WBGKJQ.js +0 -138
  92. package/dist/chunk-X7D6SUKR.js +0 -1234
@@ -1,357 +0,0 @@
1
- import { useOptionalElevasisSystems } from './chunk-J3FLIZY4.js';
2
- import { InitializationContext } from './chunk-6DO4PE3O.js';
3
- import { DEFAULT_ORGANIZATION_MODEL } from './chunk-K7GKKETO.js';
4
- import { OrganizationContext } from './chunk-DD3CCMCZ.js';
5
- import { STALE_TIME_DEFAULT } from './chunk-6ROXVZ3L.js';
6
- import { listAllSystems, getSystem } from './chunk-RH5VWWSC.js';
7
- import { ElevasisServiceContext } from './chunk-2FTX4WO2.js';
8
- import { useContext, useMemo } from 'react';
9
- import { useQuery } from '@tanstack/react-query';
10
- import { z } from 'zod';
11
-
12
- // ../core/src/auth/multi-tenancy/permissions.ts
13
- var PERMISSIONS = {
14
- ORG_READ: "org.read",
15
- ORG_MANAGE: "org.manage",
16
- ORG_DELETE: "org.delete",
17
- MEMBERS_MANAGE: "members.manage",
18
- ROLES_MANAGE: "roles.manage",
19
- SECRETS_MANAGE: "secrets.manage",
20
- OPERATIONS_READ: "operations.read",
21
- OPERATIONS_MANAGE: "operations.manage",
22
- SALES_LEAD_GEN_MANAGE: "sales.lead-gen.manage",
23
- ACQUISITION_MANAGE: "acquisition.manage",
24
- PROJECTS_MANAGE: "projects.manage",
25
- CLIENTS_MANAGE: "clients.manage"
26
- };
27
- var PERMISSION_CATALOG = [
28
- {
29
- key: "org.read",
30
- description: "Read organization profile and listings",
31
- isOrgGrantable: true
32
- },
33
- {
34
- key: "org.manage",
35
- description: "Update organization settings",
36
- isOrgGrantable: false
37
- },
38
- {
39
- key: "org.delete",
40
- description: "Delete the organization (owner-only)",
41
- isOrgGrantable: false
42
- },
43
- {
44
- key: "members.manage",
45
- description: "Invite, remove, and reassign roles for members",
46
- isOrgGrantable: false
47
- },
48
- {
49
- key: "roles.manage",
50
- description: "Grant or revoke privileged system roles (owner, admin) within the organization",
51
- isOrgGrantable: false
52
- },
53
- {
54
- key: "secrets.manage",
55
- description: "Create, update, and delete API keys and credentials",
56
- isOrgGrantable: false
57
- },
58
- {
59
- key: "operations.read",
60
- description: "View executions, sessions, schedules, and command queue",
61
- isOrgGrantable: true
62
- },
63
- {
64
- key: "operations.manage",
65
- description: "Run and modify executions, sessions, schedules, queue",
66
- isOrgGrantable: true
67
- },
68
- {
69
- key: "sales.lead-gen.manage",
70
- description: "Operate Lead Gen lists and list-builder workflows",
71
- isOrgGrantable: true
72
- },
73
- {
74
- key: "acquisition.manage",
75
- description: "Create, update, and delete acquisition records (acq_companies, acq_contacts, acq_deals, acq_lists*, acq_content*, acquisition storage files)",
76
- isOrgGrantable: false
77
- },
78
- {
79
- key: "projects.manage",
80
- description: "Create, update, and delete project records (prj_projects, prj_milestones, prj_tasks, prj_notes)",
81
- isOrgGrantable: false
82
- },
83
- {
84
- key: "clients.manage",
85
- description: "Create, update, and delete client hub records (clients, clt_* satellites)",
86
- isOrgGrantable: false
87
- }
88
- ];
89
- new Set(PERMISSION_CATALOG.map((p) => p.key));
90
- var DEFAULT_ACCESS_ACTION = "view";
91
- var PLATFORM_ADMIN_ACCESS_KEY = "platform.admin";
92
- var PLATFORM_ADMIN_ACCESS_KEY_SHORTHAND = "platformAdmin";
93
- var AccessActionSchema = z.enum(["view", "manage"]);
94
- var AccessKeyObjectSchema = z.object({
95
- systemPath: z.string().trim().min(1),
96
- action: AccessActionSchema.default(DEFAULT_ACCESS_ACTION)
97
- }).strict();
98
- var AccessKeyInputSchema = z.union([z.string().trim().min(1), AccessKeyObjectSchema]);
99
- var NormalizedAccessKeySchema = AccessKeyObjectSchema;
100
- var DIAGNOSTIC_VIEW_ACCESS_KEYS = [
101
- "diagnostic.operations.overview",
102
- "diagnostic.operations.recent-executions",
103
- "diagnostic.monitoring.execution-logs",
104
- "diagnostic.monitoring.notifications"
105
- ];
106
- var AccessKeys = {
107
- platformAdmin: { systemPath: PLATFORM_ADMIN_ACCESS_KEY, action: DEFAULT_ACCESS_ACTION },
108
- organizationManage: { systemPath: "permission.org", action: "manage" },
109
- membersManage: { systemPath: "permission.members", action: "manage" },
110
- rolesManage: { systemPath: "permission.roles", action: "manage" },
111
- secretsManage: { systemPath: "permission.secrets", action: "manage" },
112
- operationsRead: { systemPath: "permission.operations", action: DEFAULT_ACCESS_ACTION },
113
- operationsManage: { systemPath: "permission.operations", action: "manage" },
114
- leadGenManage: { systemPath: "sales.lead-gen", action: "manage" },
115
- acquisitionManage: { systemPath: "permission.acquisition", action: "manage" },
116
- projectsManage: { systemPath: "permission.projects", action: "manage" },
117
- clientsManage: { systemPath: "permission.clients", action: "manage" },
118
- operationsOverview: { systemPath: "diagnostic.operations.overview", action: DEFAULT_ACCESS_ACTION },
119
- operationsRecentExecutions: { systemPath: "diagnostic.operations.recent-executions", action: DEFAULT_ACCESS_ACTION },
120
- monitoringExecutionLogs: { systemPath: "diagnostic.monitoring.execution-logs", action: DEFAULT_ACCESS_ACTION },
121
- monitoringNotifications: { systemPath: "diagnostic.monitoring.notifications", action: DEFAULT_ACCESS_ACTION }
122
- };
123
- var PERMISSION_ACCESS_KEY_DEFINITIONS = [
124
- { key: AccessKeys.organizationManage, rolePermission: PERMISSIONS.ORG_MANAGE },
125
- { key: AccessKeys.membersManage, rolePermission: PERMISSIONS.MEMBERS_MANAGE },
126
- { key: AccessKeys.rolesManage, rolePermission: PERMISSIONS.ROLES_MANAGE },
127
- { key: AccessKeys.secretsManage, rolePermission: PERMISSIONS.SECRETS_MANAGE },
128
- { key: AccessKeys.operationsRead, rolePermission: PERMISSIONS.OPERATIONS_READ },
129
- { key: AccessKeys.operationsManage, rolePermission: PERMISSIONS.OPERATIONS_MANAGE },
130
- { key: AccessKeys.acquisitionManage, rolePermission: PERMISSIONS.ACQUISITION_MANAGE },
131
- { key: AccessKeys.projectsManage, rolePermission: PERMISSIONS.PROJECTS_MANAGE },
132
- { key: AccessKeys.clientsManage, rolePermission: PERMISSIONS.CLIENTS_MANAGE }
133
- ];
134
- function normalizeAccessKey(input) {
135
- const parsed = AccessKeyInputSchema.parse(input);
136
- const normalized = typeof parsed === "string" ? {
137
- systemPath: parsed === PLATFORM_ADMIN_ACCESS_KEY_SHORTHAND ? PLATFORM_ADMIN_ACCESS_KEY : parsed,
138
- action: DEFAULT_ACCESS_ACTION
139
- } : parsed;
140
- return NormalizedAccessKeySchema.parse(normalized);
141
- }
142
- function rolePermissionForAccessKey(key) {
143
- if (key.action === DEFAULT_ACCESS_ACTION) return void 0;
144
- return `${key.systemPath}.${key.action}`;
145
- }
146
- function groupCatalogEntries(entries) {
147
- const grouped = /* @__PURE__ */ new Map();
148
- for (const entry of entries) {
149
- const existing = grouped.get(entry.key.systemPath) ?? [];
150
- existing.push(entry);
151
- grouped.set(entry.key.systemPath, existing);
152
- }
153
- return grouped;
154
- }
155
- function buildCatalogEntry(systemPath, action, source) {
156
- const key = normalizeAccessKey({ systemPath, action });
157
- return {
158
- key,
159
- source,
160
- rolePermission: rolePermissionForAccessKey(key)
161
- };
162
- }
163
- function deriveAccessKeyCatalog(organizationModel, options = {}) {
164
- const { diagnosticKeys = DIAGNOSTIC_VIEW_ACCESS_KEYS, includeManageActions = true } = options;
165
- const entries = [
166
- buildCatalogEntry(PLATFORM_ADMIN_ACCESS_KEY, DEFAULT_ACCESS_ACTION, "platform")
167
- ];
168
- for (const { path } of listAllSystems(organizationModel)) {
169
- entries.push(buildCatalogEntry(path, DEFAULT_ACCESS_ACTION, "om-system"));
170
- if (includeManageActions) {
171
- entries.push(buildCatalogEntry(path, "manage", "om-system"));
172
- }
173
- }
174
- for (const { key, rolePermission } of PERMISSION_ACCESS_KEY_DEFINITIONS) {
175
- entries.push({
176
- key,
177
- source: "permission",
178
- rolePermission
179
- });
180
- }
181
- for (const systemPath of diagnosticKeys) {
182
- entries.push(buildCatalogEntry(systemPath, DEFAULT_ACCESS_ACTION, "diagnostic"));
183
- }
184
- return {
185
- bySystemPath: groupCatalogEntries(entries),
186
- entries
187
- };
188
- }
189
- function findAccessCatalogEntry(catalog, key) {
190
- return catalog.bySystemPath.get(key.systemPath)?.find((entry) => entry.key.action === key.action);
191
- }
192
-
193
- // ../core/src/auth/access-model.ts
194
- var ALLOWED = { allowed: true, restrictedBy: null, reason: "allowed" };
195
- var PLATFORM_ADMIN_BYPASS = {
196
- allowed: true,
197
- restrictedBy: null,
198
- reason: "platform-admin-bypass"
199
- };
200
- function deny(restrictedBy, reason) {
201
- return { allowed: false, restrictedBy, reason };
202
- }
203
- function isPlatformAdmin(profile) {
204
- return profile?.isPlatformAdmin === true || profile?.is_platform_admin === true;
205
- }
206
- function diagnosticAllowlistHas(allowlist, systemPath) {
207
- if (allowlist === void 0) return false;
208
- return "has" in allowlist ? allowlist.has(systemPath) : allowlist.includes(systemPath);
209
- }
210
- function lifecycleAllowsAccess(lifecycle, ctx) {
211
- if (lifecycle === "active") return true;
212
- if (lifecycle === "beta") return ctx.betaAccessEnabled === true || ctx.isDevelopment === true;
213
- return false;
214
- }
215
- function getPermissionSource(ctx) {
216
- return ctx.permissions ?? ctx.membership?.effectivePermissions;
217
- }
218
- function hasRequiredPermission(key, rolePermission, ctx) {
219
- const permissionSource = getPermissionSource(ctx);
220
- if (permissionSource === void 0 || permissionSource === null) return true;
221
- const requiredPermission = rolePermission ?? `${key.systemPath}.${key.action}`;
222
- return permissionSource.includes(requiredPermission);
223
- }
224
- function hasExplicitRequiredPermission(rolePermission, ctx) {
225
- const permissionSource = getPermissionSource(ctx);
226
- return rolePermission !== void 0 && permissionSource !== void 0 && permissionSource !== null ? permissionSource.includes(rolePermission) : false;
227
- }
228
- function checkAccess(input, ctx) {
229
- if (isPlatformAdmin(ctx.profile)) return PLATFORM_ADMIN_BYPASS;
230
- const parsed = (() => {
231
- try {
232
- return normalizeAccessKey(input);
233
- } catch {
234
- return null;
235
- }
236
- })();
237
- if (parsed === null) return deny("catalog", "invalid-access-key");
238
- const catalog = ctx.accessCatalog ?? deriveAccessKeyCatalog(ctx.organizationModel);
239
- const catalogEntry = findAccessCatalogEntry(catalog, parsed);
240
- if (catalogEntry === void 0) return deny("catalog", "unknown-access-key");
241
- const membership = ctx.membership;
242
- if (membership === void 0 || membership === null) return deny("membership", "missing-membership");
243
- if (membership.organizationId !== ctx.organizationId) return deny("membership", "organization-mismatch");
244
- if (parsed.systemPath === PLATFORM_ADMIN_ACCESS_KEY) {
245
- return deny("role-permission", "role-permission-denied");
246
- }
247
- if (catalogEntry.source === "diagnostic") {
248
- if (!diagnosticAllowlistHas(ctx.diagnosticAllowlist, parsed.systemPath)) {
249
- return deny("diagnostic-allowlist", "diagnostic-key-not-allowed");
250
- }
251
- if (parsed.action !== DEFAULT_ACCESS_ACTION && !hasRequiredPermission(parsed, catalogEntry.rolePermission, ctx)) {
252
- return deny("role-permission", "role-permission-denied");
253
- }
254
- return ALLOWED;
255
- }
256
- if (catalogEntry.source === "permission") {
257
- if (!hasExplicitRequiredPermission(catalogEntry.rolePermission, ctx)) {
258
- return deny("role-permission", "role-permission-denied");
259
- }
260
- return ALLOWED;
261
- }
262
- const system = getSystem(ctx.organizationModel, parsed.systemPath);
263
- if (system === void 0 || !lifecycleAllowsAccess(system.lifecycle, ctx)) {
264
- return deny("system-lifecycle", "system-not-active");
265
- }
266
- if (parsed.action !== DEFAULT_ACCESS_ACTION && !hasRequiredPermission(parsed, catalogEntry.rolePermission, ctx)) {
267
- return deny("role-permission", "role-permission-denied");
268
- }
269
- return ALLOWED;
270
- }
271
- function createAccessModel(organizationModel) {
272
- const catalog = deriveAccessKeyCatalog(organizationModel);
273
- return {
274
- catalog,
275
- checkAccess: (key, ctx) => checkAccess(key, { ...ctx, organizationModel, accessCatalog: catalog })
276
- };
277
- }
278
-
279
- // src/hooks/access/useAccess.ts
280
- var MISSING_CONTEXT_ANSWER = {
281
- allowed: false,
282
- restrictedBy: "membership",
283
- reason: "missing-membership"
284
- };
285
- function readStringArray(value) {
286
- return Array.isArray(value) && value.every((item) => typeof item === "string") ? value : void 0;
287
- }
288
- function membershipPermissions(membership) {
289
- if (!membership || typeof membership !== "object") return void 0;
290
- const record = membership;
291
- return readStringArray(record.effectivePermissions) ?? readStringArray(record.effective_permissions);
292
- }
293
- function resolveOrganizationId(organization) {
294
- const membership = organization?.currentMembership;
295
- return organization?.currentSupabaseOrganizationId ?? membership?.organizationId ?? membership?.organization?.id ?? null;
296
- }
297
- function toAccessMembership(membership, organizationId, permissions) {
298
- if (!membership || !organizationId) return null;
299
- return {
300
- id: membership.id,
301
- organizationId: membership.organizationId ?? organizationId,
302
- role: membership.role?.slug ?? null,
303
- effectivePermissions: permissions
304
- };
305
- }
306
- function useAccess(key) {
307
- const initialization = useContext(InitializationContext);
308
- const organization = useContext(OrganizationContext);
309
- const services = useContext(ElevasisServiceContext);
310
- const systems = useOptionalElevasisSystems();
311
- const profile = initialization?.profile ?? null;
312
- const isPlatformAdmin2 = profile?.is_platform_admin === true;
313
- const organizationId = resolveOrganizationId(organization);
314
- const membership = organization?.currentMembership ?? null;
315
- const organizationModel = systems?.organizationModel ?? DEFAULT_ORGANIZATION_MODEL;
316
- const permissionsFromMembership = useMemo(() => membershipPermissions(membership), [membership]);
317
- const shouldFetchPermissions = Boolean(services?.isReady && organizationId && !isPlatformAdmin2);
318
- const permissionsQuery = useQuery({
319
- // eslint-disable-next-line @tanstack/query/exhaustive-deps -- services.apiRequest is a stable context fn, not cache-relevant; query is keyed by organizationId
320
- queryKey: ["access-permissions", organizationId],
321
- queryFn: () => services.apiRequest(`/memberships/my-permissions/${organizationId}`),
322
- enabled: shouldFetchPermissions,
323
- staleTime: STALE_TIME_DEFAULT
324
- });
325
- const permissions = useMemo(
326
- () => isPlatformAdmin2 ? Object.values(PERMISSIONS) : permissionsQuery.data?.permissions ?? permissionsFromMembership ?? [],
327
- [isPlatformAdmin2, permissionsFromMembership, permissionsQuery.data?.permissions]
328
- );
329
- const accessMembership = useMemo(
330
- () => toAccessMembership(membership, organizationId, permissions),
331
- [membership, organizationId, permissions]
332
- );
333
- const accessModel = useMemo(() => createAccessModel(organizationModel), [organizationModel]);
334
- const answer = useMemo(() => {
335
- if (!organizationId && !isPlatformAdmin2) return MISSING_CONTEXT_ANSWER;
336
- return accessModel.checkAccess(key, {
337
- organizationId: organizationId ?? "",
338
- organizationModel,
339
- membership: accessMembership,
340
- profile,
341
- permissions,
342
- diagnosticAllowlist: DIAGNOSTIC_VIEW_ACCESS_KEYS,
343
- isDevelopment: import.meta.env?.DEV ?? false
344
- });
345
- }, [accessMembership, accessModel, isPlatformAdmin2, key, organizationId, organizationModel, permissions, profile]);
346
- const providerReady = initialization?.organizationReady ?? Boolean(organizationId && accessMembership && systems?.organizationModel);
347
- const permissionsReady = !shouldFetchPermissions || !permissionsQuery.isPending;
348
- const isReady = isPlatformAdmin2 ? initialization?.userReady ?? true : providerReady && permissionsReady;
349
- return {
350
- ...answer,
351
- isReady,
352
- isPlatformAdmin: isPlatformAdmin2,
353
- permissions
354
- };
355
- }
356
-
357
- export { AccessKeys, useAccess };
@@ -1,85 +0,0 @@
1
- import { useRouterContext } from './chunk-Q7DJKLEN.js';
2
- import { useOptionalElevasisSystems } from './chunk-J3FLIZY4.js';
3
- import { useMemo } from 'react';
4
-
5
- var useBreadcrumbs = (options = {}) => {
6
- const { currentPath } = useRouterContext();
7
- const systemContext = useOptionalElevasisSystems();
8
- const { labelsByPath = {} } = options;
9
- return useMemo(() => {
10
- const shellModel = systemContext?.shellModel;
11
- const overriddenLabel = labelsByPath[currentPath];
12
- if (overriddenLabel) {
13
- return [{ label: overriddenLabel, isActive: true }];
14
- }
15
- if (shellModel) {
16
- const matchedNode = shellModel.findByPath(currentPath);
17
- if (matchedNode) {
18
- return shellModel.ancestorsOf(matchedNode.id).map((node, index, items) => ({
19
- label: labelsByPath[node.path ?? ""] ?? node.label,
20
- path: index === items.length - 1 ? void 0 : node.path,
21
- isActive: index === items.length - 1
22
- }));
23
- }
24
- }
25
- const segments = currentPath.split("/").filter(Boolean);
26
- if (segments.length === 0) {
27
- return [{ label: "Dashboard", isActive: true }];
28
- }
29
- const breadcrumbs = [{ label: "Dashboard", path: "/" }];
30
- let currentSegmentPath = "";
31
- for (let i = 0; i < segments.length; i++) {
32
- currentSegmentPath += `/${segments[i]}`;
33
- const isLast = i === segments.length - 1;
34
- const label = labelsByPath[currentSegmentPath] ?? formatSegmentLabel(segments[i]);
35
- breadcrumbs.push({
36
- label,
37
- path: isLast ? void 0 : currentSegmentPath,
38
- isActive: isLast
39
- });
40
- }
41
- return breadcrumbs;
42
- }, [currentPath, systemContext, labelsByPath]);
43
- };
44
- function formatSegmentLabel(segment) {
45
- const decodedSegment = safeDecodeURIComponent(segment);
46
- const routeLabel = formatRouteIdLabel(decodedSegment);
47
- if (routeLabel) return routeLabel;
48
- return titleCaseSegment(decodedSegment);
49
- }
50
- function safeDecodeURIComponent(value) {
51
- try {
52
- return decodeURIComponent(value);
53
- } catch {
54
- return value;
55
- }
56
- }
57
- function formatRouteIdLabel(segment) {
58
- if (segment.startsWith("group:")) {
59
- const groupKey = segment.slice("group:".length);
60
- return groupKey === "graph" ? "Ontology" : titleCaseSegment(groupKey);
61
- }
62
- if (segment.startsWith("domain:")) {
63
- return titleCaseSegment(segment.slice("domain:".length));
64
- }
65
- if (segment.startsWith("item:")) {
66
- const rest = segment.slice("item:".length);
67
- const separatorIndex = rest.indexOf(":");
68
- const itemId = separatorIndex === -1 ? rest : rest.slice(separatorIndex + 1);
69
- return formatOntologyOrIdLabel(itemId);
70
- }
71
- if (segment.startsWith("ontology:")) {
72
- return formatOntologyOrIdLabel(segment);
73
- }
74
- return void 0;
75
- }
76
- function formatOntologyOrIdLabel(value) {
77
- const localId = value.includes("/") ? value.slice(value.lastIndexOf("/") + 1) : value;
78
- const suffix = localId.includes(":") ? localId.slice(localId.lastIndexOf(":") + 1) : localId;
79
- return titleCaseSegment(suffix);
80
- }
81
- function titleCaseSegment(segment) {
82
- return segment.split("-").flatMap((part) => part.split("_")).flatMap((part) => part.split(".")).map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" ");
83
- }
84
-
85
- export { useBreadcrumbs };
@@ -1,39 +0,0 @@
1
- import { usePresetsContext } from './chunk-6D4LCJ52.js';
2
- import { useMemo } from 'react';
3
-
4
- var BUILT_IN_NAMES = /* @__PURE__ */ new Set([
5
- "default",
6
- "tactical",
7
- "regal",
8
- "cyber-volt",
9
- "aurora",
10
- "rose-gold",
11
- "midnight",
12
- "titanium",
13
- "obsidian",
14
- "honey",
15
- "abyss",
16
- "canopy",
17
- "slate",
18
- "cyber-strike",
19
- "cyber-chrome",
20
- "cyber-void",
21
- "quarry"
22
- ]);
23
- function titleCase(str) {
24
- return str.replace(/(^|-)(\w)/g, (_, sep, char) => (sep ? " " : "") + char.toUpperCase());
25
- }
26
- function useAvailablePresets() {
27
- const presetsMap = usePresetsContext();
28
- return useMemo(() => {
29
- return Object.entries(presetsMap).map(([key, preset]) => ({
30
- value: key,
31
- label: preset.label ?? titleCase(key),
32
- description: preset.description ?? "",
33
- colors: preset.colors ?? [preset.dark.primary, preset.dark.background, preset.light.background],
34
- isCustom: !BUILT_IN_NAMES.has(key)
35
- }));
36
- }, [presetsMap]);
37
- }
38
-
39
- export { useAvailablePresets };
@@ -1 +0,0 @@
1
-