@elevasis/ui 2.36.0 → 2.37.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/dist/api/index.js +4 -3
  2. package/dist/app/index.css +0 -384
  3. package/dist/app/index.d.ts +20 -0
  4. package/dist/app/index.js +21 -21
  5. package/dist/auth/index.d.ts +91 -28
  6. package/dist/auth/index.js +5 -1
  7. package/dist/charts/index.js +9 -3
  8. package/dist/chunk-5CTJ7TW2.js +111 -0
  9. package/dist/chunk-5EYJ2GIN.js +122 -0
  10. package/dist/{chunk-K4UZU3TU.js → chunk-6NREL3KL.js} +1 -1
  11. package/dist/chunk-6ROXVZ3L.js +9 -0
  12. package/dist/{chunk-YYX7OPZQ.js → chunk-73EWE2EW.js} +1 -1
  13. package/dist/{chunk-SIQ3P4OR.js → chunk-7GQFIWP4.js} +8 -756
  14. package/dist/chunk-A7IG36LB.js +215 -0
  15. package/dist/chunk-CLDCYJQT.js +1 -0
  16. package/dist/{chunk-AKW7KISS.js → chunk-CWYQRM5T.js} +2 -38
  17. package/dist/{chunk-LUYVRATI.js → chunk-DA6I5VEY.js} +5 -213
  18. package/dist/chunk-I53EX4VU.js +734 -0
  19. package/dist/chunk-IIMU5YAJ.js +53 -0
  20. package/dist/{chunk-VKIZUUPM.js → chunk-JPVZRZ3X.js} +31 -14
  21. package/dist/chunk-JXVNHVK7.js +79 -0
  22. package/dist/chunk-JZ2WID2G.js +337 -0
  23. package/dist/chunk-LCJQ6OWC.js +348 -0
  24. package/dist/chunk-LNC6PZAE.js +85 -0
  25. package/dist/{chunk-O2Q4VMRN.js → chunk-NWMPBG4U.js} +1 -1
  26. package/dist/chunk-NYNOMAAS.js +422 -0
  27. package/dist/chunk-S3KBYQTI.js +39 -0
  28. package/dist/chunk-S3XR4II4.js +30 -0
  29. package/dist/chunk-SHZT7ULK.js +425 -0
  30. package/dist/{chunk-F6EFC2MJ.js → chunk-T3NI7DOA.js} +291 -2044
  31. package/dist/{chunk-GX6XBRRF.js → chunk-TYRUKGGD.js} +2 -1
  32. package/dist/{chunk-R3VCBZDC.js → chunk-X4WBGKJQ.js} +3 -50
  33. package/dist/{chunk-GEFWMU26.js → chunk-X66MVMZT.js} +1 -9
  34. package/dist/{chunk-57OZ3AEG.js → chunk-Y3JQBSKQ.js} +1 -1
  35. package/dist/components/index.d.ts +29 -42
  36. package/dist/components/index.js +33 -19
  37. package/dist/components/navigation/index.js +3 -31
  38. package/dist/features/auth/index.d.ts +52 -99
  39. package/dist/features/auth/index.js +36 -99
  40. package/dist/features/clients/index.js +33 -19
  41. package/dist/features/crm/index.d.ts +20 -0
  42. package/dist/features/crm/index.js +33 -19
  43. package/dist/features/dashboard/index.js +33 -19
  44. package/dist/features/delivery/index.d.ts +20 -0
  45. package/dist/features/delivery/index.js +33 -19
  46. package/dist/features/knowledge/index.js +6 -30
  47. package/dist/features/lead-gen/index.d.ts +1088 -1
  48. package/dist/features/lead-gen/index.js +33 -19
  49. package/dist/features/monitoring/index.js +33 -19
  50. package/dist/features/monitoring/requests/index.js +33 -19
  51. package/dist/features/notes/index.d.ts +72 -0
  52. package/dist/features/notes/index.js +621 -0
  53. package/dist/features/operations/index.js +33 -19
  54. package/dist/features/right-panel-host/index.d.ts +214 -0
  55. package/dist/features/right-panel-host/index.js +640 -0
  56. package/dist/features/seo/index.js +3 -2
  57. package/dist/features/settings/index.d.ts +23 -35
  58. package/dist/features/settings/index.js +33 -19
  59. package/dist/hooks/access/index.d.ts +90 -0
  60. package/dist/hooks/access/index.js +10 -0
  61. package/dist/hooks/delivery/index.d.ts +20 -0
  62. package/dist/hooks/delivery/index.js +33 -19
  63. package/dist/hooks/index.d.ts +1599 -1651
  64. package/dist/hooks/index.js +33 -19
  65. package/dist/hooks/published.d.ts +1599 -1651
  66. package/dist/hooks/published.js +33 -19
  67. package/dist/hooks/user-notes/index.d.ts +57 -0
  68. package/dist/hooks/user-notes/index.js +3 -0
  69. package/dist/index.d.ts +239 -275
  70. package/dist/index.js +34 -20
  71. package/dist/initialization/index.d.ts +20 -19
  72. package/dist/knowledge/index.js +10 -7
  73. package/dist/layout/index.js +5 -3
  74. package/dist/organization/index.d.ts +0 -19
  75. package/dist/organization/index.js +33 -19
  76. package/dist/profile/index.d.ts +20 -0
  77. package/dist/provider/index.css +0 -384
  78. package/dist/provider/index.d.ts +20 -0
  79. package/dist/provider/index.js +15 -21
  80. package/dist/provider/published.css +0 -523
  81. package/dist/provider/published.d.ts +20 -0
  82. package/dist/provider/published.js +11 -21
  83. package/dist/supabase/index.d.ts +40 -0
  84. package/dist/test-utils/index.d.ts +2 -21
  85. package/dist/test-utils/index.js +5 -18
  86. package/dist/theme/index.js +2 -1
  87. package/dist/types/index.d.ts +70 -59
  88. package/dist/utils/index.js +2 -1
  89. package/package.json +19 -3
  90. package/src/auth/README.md +6 -6
  91. package/dist/components/navigation/index.css +0 -649
  92. package/dist/features/knowledge/index.css +0 -649
@@ -0,0 +1,53 @@
1
+ import { sidebarIconSize, sidebarIconStroke, sidebarIconInnerSize } from './chunk-DT3QYZVU.js';
2
+ import { Box, Group, ThemeIcon } from '@mantine/core';
3
+ import { jsx, jsxs } from 'react/jsx-runtime';
4
+
5
+ var SubshellSidebarSection = ({
6
+ icon: Icon,
7
+ label,
8
+ rightSection,
9
+ withTopBorder = false
10
+ }) => {
11
+ return /* @__PURE__ */ jsx(
12
+ Box,
13
+ {
14
+ p: "sm",
15
+ style: {
16
+ borderTop: withTopBorder ? "1px solid var(--color-border)" : void 0,
17
+ borderBottom: "1px solid var(--color-border)"
18
+ },
19
+ children: /* @__PURE__ */ jsxs(Group, { gap: "xs", children: [
20
+ /* @__PURE__ */ jsx(
21
+ ThemeIcon,
22
+ {
23
+ variant: "light",
24
+ size: sidebarIconSize,
25
+ style: {
26
+ backgroundColor: "var(--color-surface)",
27
+ color: "var(--color-primary)",
28
+ flexShrink: 0
29
+ },
30
+ children: /* @__PURE__ */ jsx(Icon, { size: sidebarIconInnerSize, stroke: sidebarIconStroke })
31
+ }
32
+ ),
33
+ /* @__PURE__ */ jsx(
34
+ Box,
35
+ {
36
+ c: "var(--color-text)",
37
+ style: {
38
+ fontFamily: "var(--elevasis-font-family-subtitle)",
39
+ flex: 1,
40
+ fontSize: "var(--mantine-font-size-md)",
41
+ fontWeight: 500,
42
+ lineHeight: 1.2
43
+ },
44
+ children: label
45
+ }
46
+ ),
47
+ rightSection
48
+ ] })
49
+ }
50
+ );
51
+ };
52
+
53
+ export { SubshellSidebarSection };
@@ -1,3 +1,4 @@
1
+ import { useAccess } from './chunk-LCJQ6OWC.js';
1
2
  import { useInitialization } from './chunk-533DUEQY.js';
2
3
  import { useAuthContext } from './chunk-BRJ3QZ4E.js';
3
4
  import { useRef, useCallback, useEffect } from 'react';
@@ -93,24 +94,40 @@ function ProtectedRoute({
93
94
  }
94
95
  return /* @__PURE__ */ jsx(Fragment, { children });
95
96
  }
96
- function AdminGuard({ children, redirectTo = "/", fallback = null }) {
97
- const { userReady, profile } = useInitialization();
98
- const navigate = useNavigate();
97
+ function useOptionalNavigate() {
98
+ try {
99
+ return useNavigate();
100
+ } catch {
101
+ return null;
102
+ }
103
+ }
104
+ function renderFallback(fallback, answer) {
105
+ return typeof fallback === "function" ? fallback(answer) : fallback ?? null;
106
+ }
107
+ function AccessGuard({
108
+ accessKey,
109
+ children,
110
+ fallback = null,
111
+ loadingFallback = null,
112
+ redirectTo = null
113
+ }) {
114
+ const answer = useAccess(accessKey);
115
+ const navigate = useOptionalNavigate();
116
+ const hasRedirected = useRef(false);
99
117
  useEffect(() => {
100
- if (!userReady || !profile) {
118
+ if (!answer.isReady || answer.allowed || !redirectTo || hasRedirected.current) return;
119
+ hasRedirected.current = true;
120
+ if (navigate) {
121
+ navigate({ to: redirectTo });
101
122
  return;
102
123
  }
103
- if (!profile.is_platform_admin) {
104
- navigate({ to: redirectTo });
124
+ if (typeof window !== "undefined") {
125
+ window.location.assign(redirectTo);
105
126
  }
106
- }, [userReady, profile, navigate, redirectTo]);
107
- if (!userReady) {
108
- return /* @__PURE__ */ jsx(Fragment, { children: fallback });
109
- }
110
- if (!profile?.is_platform_admin) {
111
- return null;
112
- }
127
+ }, [answer.allowed, answer.isReady, navigate, redirectTo]);
128
+ if (!answer.isReady) return /* @__PURE__ */ jsx(Fragment, { children: loadingFallback });
129
+ if (!answer.allowed) return /* @__PURE__ */ jsx(Fragment, { children: renderFallback(fallback, answer) });
113
130
  return /* @__PURE__ */ jsx(Fragment, { children });
114
131
  }
115
132
 
116
- export { AdminGuard, ProtectedRoute, useSessionCheck, useStableAccessToken };
133
+ export { AccessGuard, ProtectedRoute, useSessionCheck, useStableAccessToken };
@@ -0,0 +1,79 @@
1
+ import { useElevasisServices } from './chunk-KJ3QUBNU.js';
2
+ import { useQuery, useQueryClient, useMutation } from '@tanstack/react-query';
3
+
4
+ var PRIORITY_ORDER = {
5
+ urgent: 0,
6
+ high: 1,
7
+ normal: 2,
8
+ low: 3
9
+ };
10
+ function sortNotes(notes) {
11
+ return [...notes].sort((a, b) => {
12
+ if (a.pinned !== b.pinned) return a.pinned ? -1 : 1;
13
+ const pa = PRIORITY_ORDER[a.priority] ?? 2;
14
+ const pb = PRIORITY_ORDER[b.priority] ?? 2;
15
+ if (pa !== pb) return pa - pb;
16
+ return new Date(b.updatedAt).getTime() - new Date(a.updatedAt).getTime();
17
+ });
18
+ }
19
+ var userNotesKeys = {
20
+ all: ["user-notes"],
21
+ list: (workOSOrgId) => [...userNotesKeys.all, "list", workOSOrgId]
22
+ };
23
+ function useUserNotes() {
24
+ const { apiRequest, isReady, workOSOrganizationId } = useElevasisServices();
25
+ return useQuery({
26
+ queryKey: userNotesKeys.list(workOSOrganizationId),
27
+ queryFn: async () => {
28
+ const response = await apiRequest("/user-notes");
29
+ return sortNotes(response.notes);
30
+ },
31
+ enabled: isReady
32
+ });
33
+ }
34
+ function useCreateUserNote() {
35
+ const queryClient = useQueryClient();
36
+ const { apiRequest, workOSOrganizationId } = useElevasisServices();
37
+ return useMutation({
38
+ mutationFn: (data) => apiRequest("/user-notes", {
39
+ method: "POST",
40
+ body: JSON.stringify(data)
41
+ }),
42
+ onSuccess: () => {
43
+ queryClient.invalidateQueries({
44
+ queryKey: userNotesKeys.list(workOSOrganizationId)
45
+ });
46
+ }
47
+ });
48
+ }
49
+ function useUpdateUserNote() {
50
+ const queryClient = useQueryClient();
51
+ const { apiRequest, workOSOrganizationId } = useElevasisServices();
52
+ return useMutation({
53
+ mutationFn: ({ id, ...data }) => apiRequest(`/user-notes/${id}`, {
54
+ method: "PATCH",
55
+ body: JSON.stringify(data)
56
+ }),
57
+ onSuccess: () => {
58
+ queryClient.invalidateQueries({
59
+ queryKey: userNotesKeys.list(workOSOrganizationId)
60
+ });
61
+ }
62
+ });
63
+ }
64
+ function useDeleteUserNote() {
65
+ const queryClient = useQueryClient();
66
+ const { apiRequest, workOSOrganizationId } = useElevasisServices();
67
+ return useMutation({
68
+ mutationFn: (id) => apiRequest(`/user-notes/${id}`, {
69
+ method: "DELETE"
70
+ }),
71
+ onSuccess: () => {
72
+ queryClient.invalidateQueries({
73
+ queryKey: userNotesKeys.list(workOSOrganizationId)
74
+ });
75
+ }
76
+ });
77
+ }
78
+
79
+ export { useCreateUserNote, useDeleteUserNote, useUpdateUserNote, useUserNotes, userNotesKeys };
@@ -0,0 +1,337 @@
1
+ import { FeatureUnavailableState } from './chunk-I53EX4VU.js';
2
+ import { SubshellContainer, SubshellSidebar, SubshellRightSideContainer } from './chunk-A7IG36LB.js';
3
+ import { ApiClientProvider, useApiClient } from './chunk-Y3JQBSKQ.js';
4
+ import { useRouterContext } from './chunk-Q7DJKLEN.js';
5
+ import { getErrorInfo, getErrorTitle, formatErrorMessage } from './chunk-X66MVMZT.js';
6
+ import { useElevasisSystems } from './chunk-NYNOMAAS.js';
7
+ import { InitializationProvider } from './chunk-533DUEQY.js';
8
+ import { OrganizationContext, useOrganization } from './chunk-DD3CCMCZ.js';
9
+ import { useProfile, ProfileProvider } from './chunk-2Q2JQSQO.js';
10
+ import { ElevasisServiceProvider } from './chunk-KJ3QUBNU.js';
11
+ import { useAuthContext } from './chunk-BRJ3QZ4E.js';
12
+ import { createContext, lazy, useState, useRef, useEffect, useCallback, createElement, useContext, Suspense } from 'react';
13
+ import { useQueryClient, QueryClientProvider, QueryClient } from '@tanstack/react-query';
14
+ import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
15
+
16
+ function OrganizationProvider({ apiRequest, children }) {
17
+ const { user, organizationId: workosOrgId } = useAuthContext();
18
+ const { profile, error: profileError } = useProfile();
19
+ const queryClient = useQueryClient();
20
+ const [memberships, setMemberships] = useState([]);
21
+ const [currentWorkOSOrganizationId, setCurrentWorkOSOrganizationId] = useState(null);
22
+ const [currentSupabaseOrganizationId, setCurrentSupabaseOrganizationId] = useState(null);
23
+ const [currentMembership, setCurrentMembership] = useState(null);
24
+ const [isInitializing, setIsInitializing] = useState(true);
25
+ const [isOrgRefreshing, setIsOrgRefreshing] = useState(false);
26
+ const [error, setError] = useState(null);
27
+ const hasInitializedRef = useRef(false);
28
+ const [profileLoaded, setProfileLoaded] = useState(false);
29
+ useEffect(() => {
30
+ if (profile !== void 0 && profile !== null) {
31
+ setProfileLoaded(true);
32
+ }
33
+ }, [profile]);
34
+ useEffect(() => {
35
+ if (profileError && isInitializing && !hasInitializedRef.current) {
36
+ setIsInitializing(false);
37
+ }
38
+ }, [profileError, isInitializing]);
39
+ useEffect(() => {
40
+ if (!user) {
41
+ setMemberships([]);
42
+ setCurrentWorkOSOrganizationId(null);
43
+ setCurrentSupabaseOrganizationId(null);
44
+ setCurrentMembership(null);
45
+ setIsInitializing(false);
46
+ setIsOrgRefreshing(false);
47
+ setError(null);
48
+ hasInitializedRef.current = false;
49
+ setProfileLoaded(false);
50
+ }
51
+ }, [user]);
52
+ const applyMembership = useCallback((membership) => {
53
+ setCurrentMembership(membership);
54
+ setCurrentSupabaseOrganizationId(membership?.organization?.id ?? null);
55
+ setCurrentWorkOSOrganizationId(membership?.organization?.workos_org_id ?? null);
56
+ }, []);
57
+ const selectOrganization = useCallback(
58
+ (data) => {
59
+ let selected = null;
60
+ if (profile?.last_visited_org) {
61
+ selected = data.find((m) => m.organizationId === profile.last_visited_org) ?? null;
62
+ }
63
+ if (!selected && workosOrgId) {
64
+ selected = data.find((m) => m.organization?.workos_org_id === workosOrgId) ?? null;
65
+ }
66
+ if (!selected && data.length > 0) {
67
+ selected = data[0];
68
+ }
69
+ if (selected) {
70
+ applyMembership(selected);
71
+ }
72
+ },
73
+ [profile?.last_visited_org, workosOrgId, applyMembership]
74
+ );
75
+ const fetchAndInitialize = useCallback(async () => {
76
+ if (!user?.id || !profileLoaded) return;
77
+ setError(null);
78
+ if (memberships.length === 0) {
79
+ setIsInitializing(true);
80
+ } else {
81
+ setIsOrgRefreshing(true);
82
+ }
83
+ try {
84
+ const data = await apiRequest("/memberships/my-memberships");
85
+ if (!Array.isArray(data)) {
86
+ throw new Error("Invalid memberships response");
87
+ }
88
+ setMemberships(data);
89
+ if (data.length === 0) {
90
+ hasInitializedRef.current = true;
91
+ return;
92
+ }
93
+ if (!currentWorkOSOrganizationId) {
94
+ selectOrganization(data);
95
+ } else {
96
+ const stillPresent = data.find((m) => m.organization?.workos_org_id === currentWorkOSOrganizationId);
97
+ if (!stillPresent) {
98
+ applyMembership(data[0] ?? null);
99
+ } else {
100
+ applyMembership(stillPresent);
101
+ }
102
+ }
103
+ hasInitializedRef.current = true;
104
+ } catch (err) {
105
+ setError(err instanceof Error ? err.message : "Failed to load organizations");
106
+ } finally {
107
+ setIsInitializing(false);
108
+ setIsOrgRefreshing(false);
109
+ }
110
+ }, [
111
+ user?.id,
112
+ profileLoaded,
113
+ memberships.length,
114
+ apiRequest,
115
+ currentWorkOSOrganizationId,
116
+ selectOrganization,
117
+ applyMembership
118
+ ]);
119
+ useEffect(() => {
120
+ if (!user?.id || !profileLoaded || hasInitializedRef.current) return;
121
+ fetchAndInitialize();
122
+ }, [user?.id, profileLoaded, fetchAndInitialize]);
123
+ useEffect(() => {
124
+ if (!hasInitializedRef.current) return;
125
+ if (!workosOrgId) return;
126
+ if (workosOrgId === currentWorkOSOrganizationId) return;
127
+ const target = memberships.find((m) => m.organization?.workos_org_id === workosOrgId);
128
+ if (!target) return;
129
+ applyMembership(target);
130
+ void queryClient.invalidateQueries();
131
+ }, [workosOrgId, currentWorkOSOrganizationId, memberships, applyMembership, queryClient]);
132
+ const switchOrganization = useCallback(
133
+ (workosOrgId2) => {
134
+ const target = memberships.find((m) => m.organization?.workos_org_id === workosOrgId2);
135
+ if (!target) return;
136
+ applyMembership(target);
137
+ void queryClient.invalidateQueries();
138
+ void apiRequest("/users/me", {
139
+ method: "PATCH",
140
+ headers: { "Content-Type": "application/json" },
141
+ body: JSON.stringify({ last_visited_org: target.organizationId })
142
+ }).catch((err) => {
143
+ console.warn("Failed to persist last_visited_org preference:", err);
144
+ });
145
+ },
146
+ [memberships, applyMembership, queryClient, apiRequest]
147
+ );
148
+ const retry = useCallback(async () => {
149
+ hasInitializedRef.current = false;
150
+ setError(null);
151
+ await fetchAndInitialize();
152
+ }, [fetchAndInitialize]);
153
+ const value = {
154
+ currentWorkOSOrganizationId,
155
+ currentSupabaseOrganizationId,
156
+ currentMembership,
157
+ memberships,
158
+ isInitializing,
159
+ isOrgRefreshing,
160
+ error,
161
+ switchOrganization,
162
+ retry
163
+ };
164
+ return createElement(OrganizationContext.Provider, { value }, children);
165
+ }
166
+ var consoleAdapter = {
167
+ success(title, message) {
168
+ console.log(`[Notification][Success] ${title}: ${message}`);
169
+ },
170
+ error(title, message) {
171
+ console.warn(`[Notification][Error] ${title}: ${message}`);
172
+ },
173
+ info(title, message) {
174
+ console.log(`[Notification][Info] ${title}: ${message}`);
175
+ },
176
+ warning(title, message) {
177
+ console.warn(`[Notification][Warning] ${title}: ${message}`);
178
+ },
179
+ apiError(error) {
180
+ const { message, code, requestId, fields, retryAfter } = getErrorInfo(error);
181
+ const title = getErrorTitle(code);
182
+ const formatted = formatErrorMessage(message, requestId, fields, retryAfter);
183
+ console.warn(`[Notification][API Error] ${title}: ${formatted}`);
184
+ }
185
+ };
186
+ var NotificationContext = createContext(consoleAdapter);
187
+ function NotificationProvider({ adapter, children }) {
188
+ return /* @__PURE__ */ jsx(NotificationContext.Provider, { value: adapter, children });
189
+ }
190
+ function useNotificationAdapter() {
191
+ return useContext(NotificationContext);
192
+ }
193
+ var CrmActionsContext = createContext([]);
194
+ function CrmActionsProvider({ actions, children }) {
195
+ return /* @__PURE__ */ jsx(CrmActionsContext.Provider, { value: actions, children });
196
+ }
197
+ function useCrmActions() {
198
+ return useContext(CrmActionsContext);
199
+ }
200
+ var EMPTY_LIST_ACTIONS = Object.freeze([]);
201
+ var ListActionsContext = createContext(EMPTY_LIST_ACTIONS);
202
+ function ListActionsProvider({
203
+ registry = EMPTY_LIST_ACTIONS,
204
+ children
205
+ }) {
206
+ return /* @__PURE__ */ jsx(ListActionsContext.Provider, { value: registry, children });
207
+ }
208
+ function useListActions() {
209
+ return useContext(ListActionsContext);
210
+ }
211
+ function findListActionByAction(registry, actionKey) {
212
+ return registry.find((action) => action.actionKey === actionKey);
213
+ }
214
+ function getListActionWorkflowId(action) {
215
+ return action.workflowId ?? action.resourceId;
216
+ }
217
+ var LazyCoreAuthKitInner = lazy(() => import('./CoreAuthKitInner-QC62UHTZ.js').then((m) => ({ default: m.CoreAuthKitInner })));
218
+ var defaultQueryClient = null;
219
+ function getDefaultQueryClient() {
220
+ if (!defaultQueryClient) {
221
+ defaultQueryClient = new QueryClient({
222
+ defaultOptions: { queries: { retry: 1 } }
223
+ });
224
+ }
225
+ return defaultQueryClient;
226
+ }
227
+ var consoleNotificationAdapter = {
228
+ success(title, message) {
229
+ console.log(`[Notification][Success] ${title}: ${message}`);
230
+ },
231
+ error(title, message) {
232
+ console.warn(`[Notification][Error] ${title}: ${message}`);
233
+ },
234
+ info(title, message) {
235
+ console.log(`[Notification][Info] ${title}: ${message}`);
236
+ },
237
+ warning(title, message) {
238
+ console.warn(`[Notification][Warning] ${title}: ${message}`);
239
+ },
240
+ apiError(error) {
241
+ console.warn(`[Notification][API Error]`, error);
242
+ }
243
+ };
244
+ function ElevasisCoreProvider({
245
+ auth,
246
+ queryClient,
247
+ apiUrl,
248
+ onError,
249
+ notifications,
250
+ crmActions,
251
+ listActions,
252
+ children
253
+ }) {
254
+ if (auth.mode === "apiKey") {
255
+ throw new Error(
256
+ `ElevasisCoreProvider: auth mode 'apiKey' is not yet implemented. Only 'authkit' mode is supported.`
257
+ );
258
+ }
259
+ const resolvedQueryClient = queryClient ?? getDefaultQueryClient();
260
+ const resolvedCrmActions = crmActions ?? [];
261
+ const resolvedListActions = listActions ?? EMPTY_LIST_ACTIONS;
262
+ const content = apiUrl ? /* @__PURE__ */ jsx(ServiceStack, { apiUrl, onError, notifications, children }) : children;
263
+ const AuthInner = /* @__PURE__ */ jsx(Suspense, { fallback: null, children: /* @__PURE__ */ jsx(LazyCoreAuthKitInner, { auth, children: content }) });
264
+ return /* @__PURE__ */ jsx(QueryClientProvider, { client: resolvedQueryClient, children: /* @__PURE__ */ jsx(CrmActionsProvider, { actions: resolvedCrmActions, children: /* @__PURE__ */ jsx(ListActionsProvider, { registry: resolvedListActions, children: AuthInner }) }) });
265
+ }
266
+ function ServiceStack({
267
+ apiUrl,
268
+ onError,
269
+ notifications,
270
+ children
271
+ }) {
272
+ const { getAccessToken } = useAuthContext();
273
+ const orgIdRef = useRef(null);
274
+ const getOrganizationId = useRef(() => orgIdRef.current).current;
275
+ return /* @__PURE__ */ jsx(
276
+ ApiClientProvider,
277
+ {
278
+ getAccessToken,
279
+ getOrganizationId,
280
+ isOrganizationReady: false,
281
+ onError,
282
+ children: /* @__PURE__ */ jsx(ServiceStackInner, { apiUrl, orgIdRef, notifications, children })
283
+ }
284
+ );
285
+ }
286
+ function ServiceStackInner({
287
+ apiUrl,
288
+ orgIdRef,
289
+ notifications,
290
+ children
291
+ }) {
292
+ const { apiRequest } = useApiClient(apiUrl);
293
+ const resolvedNotifications = notifications ?? consoleNotificationAdapter;
294
+ return /* @__PURE__ */ jsx(ProfileProvider, { apiRequest, children: /* @__PURE__ */ jsx(OrganizationProvider, { apiRequest, children: /* @__PURE__ */ jsx(OrgServiceBridge, { orgIdRef, apiRequest, notifications: resolvedNotifications, children }) }) });
295
+ }
296
+ function OrgServiceBridge({
297
+ orgIdRef,
298
+ apiRequest,
299
+ notifications,
300
+ children
301
+ }) {
302
+ const { currentWorkOSOrganizationId, isInitializing, isOrgRefreshing } = useOrganization();
303
+ orgIdRef.current = currentWorkOSOrganizationId;
304
+ const isReady = !!currentWorkOSOrganizationId && !isInitializing && !isOrgRefreshing;
305
+ return /* @__PURE__ */ jsx(
306
+ ElevasisServiceProvider,
307
+ {
308
+ apiRequest,
309
+ workOSOrganizationId: currentWorkOSOrganizationId,
310
+ isReady,
311
+ children: /* @__PURE__ */ jsx(NotificationProvider, { adapter: notifications, children: /* @__PURE__ */ jsx(InitializationProvider, { children }) })
312
+ }
313
+ );
314
+ }
315
+ var defaultSystemSidebarWidth = 250;
316
+ function SystemShell({ children }) {
317
+ const { shellRuntime } = useElevasisSystems();
318
+ const { currentPath } = useRouterContext();
319
+ const routeMatch = shellRuntime.resolveRoute(currentPath);
320
+ if (routeMatch.status === "hidden") {
321
+ return /* @__PURE__ */ jsx(FeatureUnavailableState, { path: currentPath });
322
+ }
323
+ if (routeMatch.status !== "matched" || !routeMatch.system?.sidebar) {
324
+ return /* @__PURE__ */ jsx(Fragment, { children });
325
+ }
326
+ const SidebarComponent = routeMatch.system.sidebar;
327
+ const sidebarWidth = typeof routeMatch.system.sidebarWidth === "function" ? routeMatch.system.sidebarWidth({ currentPath }) : routeMatch.system.sidebarWidth ?? defaultSystemSidebarWidth;
328
+ if (sidebarWidth === 0) {
329
+ return /* @__PURE__ */ jsx(Fragment, { children });
330
+ }
331
+ return /* @__PURE__ */ jsxs(SubshellContainer, { children: [
332
+ /* @__PURE__ */ jsx(SubshellSidebar, { width: sidebarWidth, children: /* @__PURE__ */ jsx(SidebarComponent, {}) }),
333
+ /* @__PURE__ */ jsx(SubshellRightSideContainer, { children })
334
+ ] });
335
+ }
336
+
337
+ export { CrmActionsProvider, EMPTY_LIST_ACTIONS, ElevasisCoreProvider, ListActionsProvider, NotificationProvider, OrganizationProvider, SystemShell, findListActionByAction, getListActionWorkflowId, useCrmActions, useListActions, useNotificationAdapter };