react-semaphor 0.1.292 → 0.1.294

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/dist/chunks/{braces-hczcJsV8.js → braces-DR-GdaLC.js} +1 -1
  2. package/dist/chunks/{braces-0bzwctGp.js → braces-DfDQiR3J.js} +1 -1
  3. package/dist/chunks/dashboard-controls-C3Z9bpYE.js +2014 -0
  4. package/dist/chunks/dashboard-controls-DGEVXgP5.js +47 -0
  5. package/dist/chunks/dashboard-filter-controls-button-BIYT1ucX.js +11 -0
  6. package/dist/chunks/dashboard-filter-controls-button-DxgGUl00.js +1152 -0
  7. package/dist/chunks/{dashboard-json-COXiPm3N.js → dashboard-json-BvTeHePu.js} +1 -1
  8. package/dist/chunks/{dashboard-json-BDyKcoGT.js → dashboard-json-DQW8TN0I.js} +1 -1
  9. package/dist/chunks/dashboard-summary-settings-dialog-BsmKiGud.js +1 -0
  10. package/dist/chunks/dashboard-summary-settings-dialog-q7fx3YAK.js +543 -0
  11. package/dist/chunks/edit-dashboard-visual-ChKj-Lzr.js +183 -0
  12. package/dist/chunks/{edit-dashboard-visual-DLyimx6x.js → edit-dashboard-visual-RVl9nbDZ.js} +3018 -2989
  13. package/dist/chunks/index-BlspGR07.js +1435 -0
  14. package/dist/chunks/{index-72yod5pb.js → index-DerPpfv0.js} +40703 -39330
  15. package/dist/chunks/{resource-management-panel-DwPION_M.js → resource-management-panel-DnZ1rw1A.js} +64 -64
  16. package/dist/chunks/{resource-management-panel-CSLGSJjC.js → resource-management-panel-epydPwyM.js} +1 -1
  17. package/dist/chunks/use-create-flow-overlay-state-Bcg4EgoD.js +21 -0
  18. package/dist/chunks/{use-create-flow-overlay-state-UruHbtfS.js → use-create-flow-overlay-state-C5vdfXhM.js} +430 -425
  19. package/dist/chunks/use-visual-utils-D9Kknvjl.js +337 -0
  20. package/dist/chunks/use-visual-utils-Dw_yw9zU.js +1 -0
  21. package/dist/dashboard/index.cjs +1 -1
  22. package/dist/dashboard/index.js +1 -1
  23. package/dist/index.cjs +1 -1
  24. package/dist/index.js +258 -253
  25. package/dist/style.css +1 -1
  26. package/dist/surfboard/index.cjs +1 -1
  27. package/dist/surfboard/index.js +2 -2
  28. package/dist/types/dashboard.d.ts +28 -0
  29. package/dist/types/main.d.ts +45 -5
  30. package/dist/types/shared.d.ts +3 -0
  31. package/dist/types/surfboard.d.ts +28 -0
  32. package/dist/types/types.d.ts +28 -0
  33. package/package.json +1 -1
  34. package/dist/chunks/dashboard-controls-Db0F38eK.js +0 -47
  35. package/dist/chunks/dashboard-controls-DeUHM4uL.js +0 -1970
  36. package/dist/chunks/dashboard-filter-controls-button-DDqEus_E.js +0 -1109
  37. package/dist/chunks/dashboard-filter-controls-button-DSQHVjjX.js +0 -11
  38. package/dist/chunks/dashboard-summary-settings-dialog-CryMC_4x.js +0 -1
  39. package/dist/chunks/dashboard-summary-settings-dialog-DbcWMZsr.js +0 -536
  40. package/dist/chunks/edit-dashboard-visual-BqfzqW4i.js +0 -183
  41. package/dist/chunks/index-BQ6qu8FI.js +0 -1435
  42. package/dist/chunks/use-create-flow-overlay-state-zz9TYhdC.js +0 -21
  43. package/dist/chunks/use-visual-utils-Bm-ZnkON.js +0 -1
  44. package/dist/chunks/use-visual-utils-DPBqTRUC.js +0 -334
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../chunks/index-BQ6qu8FI.js"),e=require("../types/index.cjs"),r=require("../chunks/dashboard-summary-settings-dialog-CryMC_4x.js");exports.Surfboard=a.DashboardPlus;exports.CONTROL_CARD_DEFAULT_VALUE=e.CONTROL_CARD_DEFAULT_VALUE;exports.EMPTY_SELECTION=e.EMPTY_SELECTION;exports.CalendarPreferencesDialog=r.CalendarPreferencesDialog;exports.DashboardSummarySettingsDialog=r.DashboardSummarySettingsDialog;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../chunks/index-BlspGR07.js"),e=require("../types/index.cjs"),r=require("../chunks/dashboard-summary-settings-dialog-BsmKiGud.js");exports.Surfboard=a.DashboardPlus;exports.CONTROL_CARD_DEFAULT_VALUE=e.CONTROL_CARD_DEFAULT_VALUE;exports.EMPTY_SELECTION=e.EMPTY_SELECTION;exports.CalendarPreferencesDialog=r.CalendarPreferencesDialog;exports.DashboardSummarySettingsDialog=r.DashboardSummarySettingsDialog;
@@ -1,6 +1,6 @@
1
- import { a as o } from "../chunks/index-72yod5pb.js";
1
+ import { a as o } from "../chunks/index-DerPpfv0.js";
2
2
  import { CONTROL_CARD_DEFAULT_VALUE as s, EMPTY_SELECTION as D } from "../types/index.js";
3
- import { C as m, D as t } from "../chunks/dashboard-summary-settings-dialog-DbcWMZsr.js";
3
+ import { C as m, D as t } from "../chunks/dashboard-summary-settings-dialog-q7fx3YAK.js";
4
4
  export {
5
5
  s as CONTROL_CARD_DEFAULT_VALUE,
6
6
  m as CalendarPreferencesDialog,
@@ -875,6 +875,8 @@ declare interface FilterGroup {
875
875
  groups: FilterGroup[];
876
876
  }
877
877
 
878
+ declare type FilterKind = 'field' | 'global-date';
879
+
878
880
  /**
879
881
  * Filter layout settings for controlling how dashboard filters are displayed
880
882
  */
@@ -964,6 +966,7 @@ export declare type GetDashboardResponse = {
964
966
  filterValues?: TFilterValue[];
965
967
  defaultLensId?: string;
966
968
  assistantProfileId?: string;
969
+ semanticExecutionPayload: SemanticExecutionPayload;
967
970
  };
968
971
 
969
972
  export declare type GetPluginsResponse = {
@@ -1286,10 +1289,34 @@ declare type RelativeDateFilter = {
1286
1289
  to: number;
1287
1290
  };
1288
1291
 
1292
+ declare type ResolvedPrimaryDateField = {
1293
+ sourceDataset: string;
1294
+ sourceField: string;
1295
+ name: string;
1296
+ qualifiedFieldName: string;
1297
+ qualifiedEntityName?: string;
1298
+ entityId: string;
1299
+ entityName: string;
1300
+ entityType: string;
1301
+ dataType: string;
1302
+ dateFormat?: string;
1303
+ customFormat?: string;
1304
+ defaultGranularity?: TimeGranularity;
1305
+ supportedGranularities?: TimeGranularity[];
1306
+ } | null;
1307
+
1289
1308
  declare type SelectedEntities = Array<DatabaseEntityReference | DataModelEntityReference | DatasetEntityReference | FileEntityReference>;
1290
1309
 
1291
1310
  export declare type SelectionState = Record<Level, string | null>;
1292
1311
 
1312
+ declare type SemanticExecutionPayload = {
1313
+ domainsById: Record<string, {
1314
+ datasetsByName: Record<string, {
1315
+ primaryDateField: ResolvedPrimaryDateField;
1316
+ }>;
1317
+ }>;
1318
+ };
1319
+
1293
1320
  declare interface SortByField extends Field {
1294
1321
  role: 'sortby';
1295
1322
  direction: 'asc' | 'desc';
@@ -1896,6 +1923,7 @@ export declare type TEvent = {
1896
1923
  };
1897
1924
 
1898
1925
  declare type TFilter = {
1926
+ kind?: FilterKind;
1899
1927
  type?: 'single' | 'multiple';
1900
1928
  uiType?: 'radio' | 'dropdown' | 'tabs';
1901
1929
  dateSelectionMode?: DateSelectionMode;
@@ -60,9 +60,15 @@ declare type Actions_2 = {
60
60
  setCustomCards: (customCards: CustomCard[]) => void;
61
61
  setAuthToken: (authToken: AuthToken) => void;
62
62
  setThemeStyle: (themeStyle: StyleProps) => void;
63
- setDashboard: (dashboard: TDashboard) => void;
64
- setDashboardWithFilterValues: (dashboard: TDashboard, filterValues: TFilterValue[], runtimeOverrides?: Record<string, unknown>) => void;
63
+ setDashboard: (dashboard: TDashboard, options?: {
64
+ semanticExecutionPayload?: SemanticExecutionPayload;
65
+ }) => void;
66
+ setDashboardWithFilterValues: (dashboard: TDashboard, filterValues: TFilterValue[], runtimeOverrides?: Record<string, unknown>, options?: {
67
+ selectedSheetId?: string | null;
68
+ semanticExecutionPayload?: SemanticExecutionPayload;
69
+ }) => void;
65
70
  hydrateRuntimeControlValues: (dashboard: TDashboard, runtimeOverrides?: Record<string, unknown>) => void;
71
+ mergeSemanticExecutionPayload: (semanticExecutionPayload: SemanticExecutionPayload) => void;
66
72
  setDashboardTheme: (theme: 'light' | 'dark' | 'system') => void;
67
73
  setDashboardTitle: (title: string) => void;
68
74
  setDashboardDescription: (description: string) => void;
@@ -102,7 +108,9 @@ declare type Actions_2 = {
102
108
  setCardInlineFilterMode: (sheetId: string, cardId: string, filterId: string, filterMode: 'include' | 'exclude') => void;
103
109
  setCardInlineFilterDefaultValues: (sheetId: string, cardId: string, filterId: string, defaultValues: (string | number)[] | undefined) => void;
104
110
  addFrame: (sheetId: string, frame: TFrame, positionOrOptions?: 'start' | 'end' | AddFrameOptions) => void;
105
- updateFrame: (sheetId: string, frame: TFrame) => void;
111
+ updateFrame: (sheetId: string, frame: TFrame, options?: {
112
+ semanticExecutionPayload?: SemanticExecutionPayload;
113
+ }) => void;
106
114
  updateSheetCalculatedFields: (sheetId: string, calculatedFields: Field[]) => void;
107
115
  setVisualEditPendingFrameRewrites: (sheetId: string, frames: TFrame[]) => void;
108
116
  setVisualEditPendingFilterRewrites: (sheetId: string, filters: TFilter[]) => void;
@@ -302,6 +310,7 @@ declare type AddFrameOptions = {
302
310
  position?: 'start' | 'end';
303
311
  insertAfterFrameId?: string;
304
312
  copyLayoutFromFrameId?: string;
313
+ semanticExecutionPayload?: SemanticExecutionPayload;
305
314
  };
306
315
 
307
316
  /**
@@ -1286,6 +1295,7 @@ export declare interface CreateExportRequest {
1286
1295
  controlDefinitions?: ControlDefinition[];
1287
1296
  cardControlDefinitions?: ControlDefinition[];
1288
1297
  controlBindings?: ControlBinding[];
1298
+ resolvedPrimaryDateField?: ResolvedPrimaryDateField;
1289
1299
  timezone?: string;
1290
1300
  totalRows: number;
1291
1301
  format: ExportFormat;
@@ -1491,6 +1501,7 @@ export declare type DashboardStore = {
1491
1501
  controlValues: Record<string, unknown>;
1492
1502
  /** Runtime-only card-scoped control values, keyed by cardId then controlId. */
1493
1503
  cardControlValuesMap: Record<string, Record<string, unknown>>;
1504
+ semanticExecutionPayload: SemanticExecutionPayload;
1494
1505
  isDashboardPanelOpen: boolean;
1495
1506
  drillHistory: Array<{
1496
1507
  sourceDashboardId: string;
@@ -2044,7 +2055,7 @@ export declare type EditorStore = {
2044
2055
  onDatabaseChange?: (databaseName: string) => void;
2045
2056
  onTableChange?: (tableName: string) => void;
2046
2057
  onSchemaChange?: (schemaName: string) => void;
2047
- onSave?: (card: TFrame) => void;
2058
+ onSave?: (card: TFrame) => void | Promise<void>;
2048
2059
  onClose?: () => void;
2049
2060
  /** Draft slots for mode switching - preserves work when toggling between dev/standard */
2050
2061
  modeDrafts: ModeDrafts;
@@ -2395,6 +2406,8 @@ export declare interface FilterGroup {
2395
2406
  groups: FilterGroup[];
2396
2407
  }
2397
2408
 
2409
+ declare type FilterKind = 'field' | 'global-date';
2410
+
2398
2411
  /**
2399
2412
  * Filter layout settings for controlling how dashboard filters are displayed
2400
2413
  */
@@ -2535,6 +2548,7 @@ export declare type GetDashboardResponse = {
2535
2548
  filterValues?: TFilterValue[];
2536
2549
  defaultLensId?: string;
2537
2550
  assistantProfileId?: string;
2551
+ semanticExecutionPayload: SemanticExecutionPayload;
2538
2552
  };
2539
2553
 
2540
2554
  /**
@@ -3188,6 +3202,22 @@ export declare function resolveDatamodelName(datamodelName: string): string;
3188
3202
 
3189
3203
  export declare const resolveDataType: (value: any) => string;
3190
3204
 
3205
+ declare type ResolvedPrimaryDateField = {
3206
+ sourceDataset: string;
3207
+ sourceField: string;
3208
+ name: string;
3209
+ qualifiedFieldName: string;
3210
+ qualifiedEntityName?: string;
3211
+ entityId: string;
3212
+ entityName: string;
3213
+ entityType: string;
3214
+ dataType: string;
3215
+ dateFormat?: string;
3216
+ customFormat?: string;
3217
+ defaultGranularity?: TimeGranularity;
3218
+ supportedGranularities?: TimeGranularity[];
3219
+ } | null;
3220
+
3191
3221
  /**
3192
3222
  * Parameters in JWT payload (after backend resolution).
3193
3223
  * The backend ALWAYS includes calendarContext, even if customer didn't provide it.
@@ -3288,6 +3318,14 @@ export declare type SemanticDomainAccessRequest = {
3288
3318
  domains?: string[];
3289
3319
  };
3290
3320
 
3321
+ declare type SemanticExecutionPayload = {
3322
+ domainsById: Record<string, {
3323
+ datasetsByName: Record<string, {
3324
+ primaryDateField: ResolvedPrimaryDateField;
3325
+ }>;
3326
+ }>;
3327
+ };
3328
+
3291
3329
  export declare const SemaphorContextProvider: ({ children, dashboardProps, }: {
3292
3330
  children: React.ReactNode;
3293
3331
  dashboardProps: DashboardProps;
@@ -4049,6 +4087,7 @@ export declare type TEvent = {
4049
4087
  };
4050
4088
 
4051
4089
  export declare type TFilter = {
4090
+ kind?: FilterKind;
4052
4091
  type?: 'single' | 'multiple';
4053
4092
  uiType?: 'radio' | 'dropdown' | 'tabs';
4054
4093
  dateSelectionMode?: DateSelectionMode;
@@ -4652,7 +4691,7 @@ export declare function useAddNewFrame(): {
4652
4691
  handleAddNewFrame: (options?: {
4653
4692
  openVisualEditor?: boolean;
4654
4693
  sheetId?: string;
4655
- }) => TFrame | undefined;
4694
+ }) => Promise<TFrame | undefined>;
4656
4695
  canAddFrame: boolean;
4657
4696
  };
4658
4697
 
@@ -5098,6 +5137,7 @@ export declare function useCard(cardId: string): {
5098
5137
  queryKey: string[];
5099
5138
  pagination: PaginationMetadata | undefined;
5100
5139
  comparisonMetadata: ComparisonMetadataMap | undefined;
5140
+ resolvedPrimaryDateField: ResolvedPrimaryDateField | undefined;
5101
5141
  };
5102
5142
 
5103
5143
  export declare const useCardAlertMap: () => Map<string, string[]>;
@@ -755,6 +755,8 @@ declare interface FilterGroup {
755
755
  groups: FilterGroup[];
756
756
  }
757
757
 
758
+ declare type FilterKind = 'field' | 'global-date';
759
+
758
760
  /**
759
761
  * Filter layout settings for controlling how dashboard filters are displayed
760
762
  */
@@ -1704,6 +1706,7 @@ declare type TDynamicVisualIntent = {
1704
1706
  };
1705
1707
 
1706
1708
  declare type TFilter = {
1709
+ kind?: FilterKind;
1707
1710
  type?: 'single' | 'multiple';
1708
1711
  uiType?: 'radio' | 'dropdown' | 'tabs';
1709
1712
  dateSelectionMode?: DateSelectionMode;
@@ -895,6 +895,8 @@ declare interface FilterGroup {
895
895
  groups: FilterGroup[];
896
896
  }
897
897
 
898
+ declare type FilterKind = 'field' | 'global-date';
899
+
898
900
  /**
899
901
  * Filter layout settings for controlling how dashboard filters are displayed
900
902
  */
@@ -984,6 +986,7 @@ export declare type GetDashboardResponse = {
984
986
  filterValues?: TFilterValue[];
985
987
  defaultLensId?: string;
986
988
  assistantProfileId?: string;
989
+ semanticExecutionPayload: SemanticExecutionPayload;
987
990
  };
988
991
 
989
992
  export declare type GetPluginsResponse = {
@@ -1306,10 +1309,34 @@ declare type RelativeDateFilter = {
1306
1309
  to: number;
1307
1310
  };
1308
1311
 
1312
+ declare type ResolvedPrimaryDateField = {
1313
+ sourceDataset: string;
1314
+ sourceField: string;
1315
+ name: string;
1316
+ qualifiedFieldName: string;
1317
+ qualifiedEntityName?: string;
1318
+ entityId: string;
1319
+ entityName: string;
1320
+ entityType: string;
1321
+ dataType: string;
1322
+ dateFormat?: string;
1323
+ customFormat?: string;
1324
+ defaultGranularity?: TimeGranularity;
1325
+ supportedGranularities?: TimeGranularity[];
1326
+ } | null;
1327
+
1309
1328
  declare type SelectedEntities = Array<DatabaseEntityReference | DataModelEntityReference | DatasetEntityReference | FileEntityReference>;
1310
1329
 
1311
1330
  export declare type SelectionState = Record<Level, string | null>;
1312
1331
 
1332
+ declare type SemanticExecutionPayload = {
1333
+ domainsById: Record<string, {
1334
+ datasetsByName: Record<string, {
1335
+ primaryDateField: ResolvedPrimaryDateField;
1336
+ }>;
1337
+ }>;
1338
+ };
1339
+
1313
1340
  declare interface SortByField extends Field {
1314
1341
  role: 'sortby';
1315
1342
  direction: 'asc' | 'desc';
@@ -1918,6 +1945,7 @@ export declare type TEvent = {
1918
1945
  };
1919
1946
 
1920
1947
  declare type TFilter = {
1948
+ kind?: FilterKind;
1921
1949
  type?: 'single' | 'multiple';
1922
1950
  uiType?: 'radio' | 'dropdown' | 'tabs';
1923
1951
  dateSelectionMode?: DateSelectionMode;
@@ -1164,6 +1164,8 @@ declare interface FilterGroup {
1164
1164
  groups: FilterGroup[];
1165
1165
  }
1166
1166
 
1167
+ declare type FilterKind = 'field' | 'global-date';
1168
+
1167
1169
  /**
1168
1170
  * Filter layout settings for controlling how dashboard filters are displayed
1169
1171
  */
@@ -1255,6 +1257,7 @@ export declare type GetDashboardResponse = {
1255
1257
  filterValues?: TFilterValue[];
1256
1258
  defaultLensId?: string;
1257
1259
  assistantProfileId?: string;
1260
+ semanticExecutionPayload: SemanticExecutionPayload;
1258
1261
  };
1259
1262
 
1260
1263
  export declare type GetPluginsResponse = {
@@ -1592,6 +1595,22 @@ declare type RelativeDateFilter = {
1592
1595
  to: number;
1593
1596
  };
1594
1597
 
1598
+ declare type ResolvedPrimaryDateField = {
1599
+ sourceDataset: string;
1600
+ sourceField: string;
1601
+ name: string;
1602
+ qualifiedFieldName: string;
1603
+ qualifiedEntityName?: string;
1604
+ entityId: string;
1605
+ entityName: string;
1606
+ entityType: string;
1607
+ dataType: string;
1608
+ dateFormat?: string;
1609
+ customFormat?: string;
1610
+ defaultGranularity?: TimeGranularity;
1611
+ supportedGranularities?: TimeGranularity[];
1612
+ } | null;
1613
+
1595
1614
  /**
1596
1615
  * Parameters in JWT payload (after backend resolution).
1597
1616
  * The backend ALWAYS includes calendarContext, even if customer didn't provide it.
@@ -1632,6 +1651,14 @@ export declare type SemanticDomainAccessRequest = {
1632
1651
  domains?: string[];
1633
1652
  };
1634
1653
 
1654
+ declare type SemanticExecutionPayload = {
1655
+ domainsById: Record<string, {
1656
+ datasetsByName: Record<string, {
1657
+ primaryDateField: ResolvedPrimaryDateField;
1658
+ }>;
1659
+ }>;
1660
+ };
1661
+
1635
1662
  export declare type SensitivityPreset = 'low_noise' | 'standard' | 'early_warning';
1636
1663
 
1637
1664
  declare interface SortByField extends Field {
@@ -2246,6 +2273,7 @@ export declare type TEvent = {
2246
2273
  };
2247
2274
 
2248
2275
  declare type TFilter = {
2276
+ kind?: FilterKind;
2249
2277
  type?: 'single' | 'multiple';
2250
2278
  uiType?: 'radio' | 'dropdown' | 'tabs';
2251
2279
  dateSelectionMode?: DateSelectionMode;
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "email": "support@semaphor.cloud"
6
6
  },
7
7
  "license": "MIT",
8
- "version": "0.1.292",
8
+ "version": "0.1.294",
9
9
  "description": "Fully interactive and customizable dashboards for your apps.",
10
10
  "keywords": [
11
11
  "react",
@@ -1,47 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("./index-BQ6qu8FI.js"),g=require("react");require("react-dom");const U=require("./dashboard-filter-controls-button-DSQHVjjX.js"),Hs=require("./date-formatter-CqXdM6JO.js"),ns=require("./dashboard-summary-settings-dialog-CryMC_4x.js"),zs=require("./use-debounced-dirty-check-XHSwAefL.js"),Ee=require("./normalize-dashboard-for-dirty-check-BXRUMVb2.js"),os=require("./use-create-flow-overlay-state-zz9TYhdC.js"),Vs=require("./braces-hczcJsV8.js");function Ks(t){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const r in t)if(r!=="default"){const a=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(n,r,a.get?a:{enumerable:!0,get:()=>t[r]})}}return n.default=t,Object.freeze(n)}const w=Ks(g);/**
2
- * @license lucide-react v0.453.0 - ISC
3
- *
4
- * This source code is licensed under the ISC license.
5
- * See the LICENSE file in the root directory of this source tree.
6
- */const Qs=s.createLucideIcon("Glasses",[["circle",{cx:"6",cy:"15",r:"4",key:"vux9w4"}],["circle",{cx:"18",cy:"15",r:"4",key:"18o8ve"}],["path",{d:"M14 15a2 2 0 0 0-2-2 2 2 0 0 0-2 2",key:"1ag4bs"}],["path",{d:"M2.5 13 5 7c.7-1.3 1.4-2 3-2",key:"1hm1gs"}],["path",{d:"M21.5 13 19 7c-.7-1.3-1.5-2-3-2",key:"1r31ai"}]]);/**
7
- * @license lucide-react v0.453.0 - ISC
8
- *
9
- * This source code is licensed under the ISC license.
10
- * See the LICENSE file in the root directory of this source tree.
11
- */const Js=s.createLucideIcon("Menu",[["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}],["line",{x1:"4",x2:"20",y1:"6",y2:"6",key:"1owob3"}],["line",{x1:"4",x2:"20",y1:"18",y2:"18",key:"yk5zj1"}]]);/**
12
- * @license lucide-react v0.453.0 - ISC
13
- *
14
- * This source code is licensed under the ISC license.
15
- * See the LICENSE file in the root directory of this source tree.
16
- */const Ws=s.createLucideIcon("Monitor",[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]]);/**
17
- * @license lucide-react v0.453.0 - ISC
18
- *
19
- * This source code is licensed under the ISC license.
20
- * See the LICENSE file in the root directory of this source tree.
21
- */const Ys=s.createLucideIcon("Moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]);/**
22
- * @license lucide-react v0.453.0 - ISC
23
- *
24
- * This source code is licensed under the ISC license.
25
- * See the LICENSE file in the root directory of this source tree.
26
- */const Xs=s.createLucideIcon("ShieldX",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m14.5 9.5-5 5",key:"17q4r4"}],["path",{d:"m9.5 9.5 5 5",key:"18nt4w"}]]);/**
27
- * @license lucide-react v0.453.0 - ISC
28
- *
29
- * This source code is licensed under the ISC license.
30
- * See the LICENSE file in the root directory of this source tree.
31
- */const Zs=s.createLucideIcon("Sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]);var ke={exports:{}},Ae={};/**
32
- * @license React
33
- * use-sync-external-store-shim.production.js
34
- *
35
- * Copyright (c) Meta Platforms, Inc. and affiliates.
36
- *
37
- * This source code is licensed under the MIT license found in the
38
- * LICENSE file in the root directory of this source tree.
39
- */var is;function et(){if(is)return Ae;is=1;var t=g;function n(u,o){return u===o&&(u!==0||1/u===1/o)||u!==u&&o!==o}var r=typeof Object.is=="function"?Object.is:n,a=t.useState,l=t.useEffect,c=t.useLayoutEffect,h=t.useDebugValue;function m(u,o){var p=o(),x=a({inst:{value:p,getSnapshot:o}}),j=x[0].inst,S=x[1];return c(function(){j.value=p,j.getSnapshot=o,f(j)&&S({inst:j})},[u,p,o]),l(function(){return f(j)&&S({inst:j}),u(function(){f(j)&&S({inst:j})})},[u]),h(p),p}function f(u){var o=u.getSnapshot;u=u.value;try{var p=o();return!r(u,p)}catch{return!0}}function b(u,o){return o()}var d=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?b:m;return Ae.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:d,Ae}var Ie={};/**
40
- * @license React
41
- * use-sync-external-store-shim.development.js
42
- *
43
- * Copyright (c) Meta Platforms, Inc. and affiliates.
44
- *
45
- * This source code is licensed under the MIT license found in the
46
- * LICENSE file in the root directory of this source tree.
47
- */var ls;function st(){return ls||(ls=1,process.env.NODE_ENV!=="production"&&function(){function t(p,x){return p===x&&(p!==0||1/p===1/x)||p!==p&&x!==x}function n(p,x){d||l.startTransition===void 0||(d=!0,console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var j=x();if(!u){var S=x();c(j,S)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),u=!0)}S=h({inst:{value:j,getSnapshot:x}});var N=S[0].inst,C=S[1];return f(function(){N.value=j,N.getSnapshot=x,r(N)&&C({inst:N})},[p,j,x]),m(function(){return r(N)&&C({inst:N}),p(function(){r(N)&&C({inst:N})})},[p]),b(j),j}function r(p){var x=p.getSnapshot;p=p.value;try{var j=x();return!c(p,j)}catch{return!0}}function a(p,x){return x()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var l=g,c=typeof Object.is=="function"?Object.is:t,h=l.useState,m=l.useEffect,f=l.useLayoutEffect,b=l.useDebugValue,d=!1,u=!1,o=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?a:n;Ie.useSyncExternalStore=l.useSyncExternalStore!==void 0?l.useSyncExternalStore:o,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()),Ie}process.env.NODE_ENV==="production"?ke.exports=et():ke.exports=st();var tt=ke.exports;const ge=["light","dark","system"];function at(){const{theme:t,setTheme:n}=s.useTheme(),r=s.useDashboardStore(h=>h.actions.setDashboardTheme);function a(){const h=ge.includes(t)?t:"system",m=ge[(ge.indexOf(h)+1)%ge.length];n(m),r(m)}const l=t==="light"?Zs:t==="dark"?Ys:Ws,c=t==="light"?"Theme: light (click for dark)":t==="dark"?"Theme: dark (click for system)":"Theme: system (click for light)";return e.jsx(s.Button,{type:"button",variant:"ghost",size:"xs",className:"h-7 w-7 p-0 text-muted-foreground hover:text-foreground",onClick:a,"aria-label":c,title:c,children:e.jsx(l,{className:"h-3.5 w-3.5",strokeWidth:1.5})})}async function rt(t,n,r,a,l){if(!l)return null;const c=JSON.stringify(r),h=`${t}/v1/lens`;return await s.postRequest(h,l,{name:n,template:c,filterValues:a,operation:"create"})}async function Oe(t,n,r){if(!r)return null;const{id:a,template:l,filterValues:c,isDefault:h,shared:m}=n,f=`${t}/v1/lens`;return await s.postRequest(f,r,{lensId:a,template:l,filterValues:c,isDefault:h,shared:m,operation:"update"})}async function nt(t,n,r){if(!r)return null;const a=`${t}/v1/lens`;return await s.postRequest(a,r,{operation:"delete",lensId:n})}function ot({open:t,onOpenChange:n}={}){const[r,a]=g.useState(""),[l,c]=g.useState(!1),h=s.useDashboardStore(y=>y.lenses),{setLenses:m,setSelectedLensId:f}=s.useDashboardActions(),[b,d]=g.useState(!1),[u,o]=g.useState(!1),p=t!==void 0,x=p?t:u,j=y=>{p||o(y),n==null||n(y)},S=s.useDashboardStore(y=>y.dashboard),N=s.useDashboardStore(y=>y.filterValues),{authToken:C,tokenProps:O}=s.useSemaphorContext();async function E(){d(!0);const y=await rt(O.apiServiceUrl,r,S,N,C==null?void 0:C.accessToken);y&&(m([...h||[],y]),f(y.id),j(!1)),d(!1)}return e.jsxs(s.Dialog,{open:x,onOpenChange:j,children:[p?null:e.jsx(s.DialogTrigger,{asChild:!0,children:e.jsxs(s.Button,{variant:"secondary",className:"h-7 p-2",size:"sm",children:[e.jsx(s.Plus,{className:"mr-2 h-4 w-4"}),"Lens"]})}),e.jsxs(s.DialogContent,{className:"sm:max-w-[425px]",children:[e.jsxs(s.DialogHeader,{children:[e.jsx(s.DialogTitle,{children:"Create Lens"}),e.jsx(s.DialogDescription,{children:"Lenses are private by default and are only visible to you."})]}),e.jsx("div",{className:"grid gap-4 py-4",children:e.jsxs("div",{className:"grid grid-cols-8 items-center gap-4",children:[e.jsx(s.Label,{className:"text-right",children:"Name"}),e.jsx(s.Input,{value:r,onChange:y=>{a(y.target.value)},id:"name",className:"col-span-7 focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0"})]})}),l&&e.jsx("p",{className:"text-sm",children:"The lens name already exists. Use a differnet name."}),e.jsx(s.DialogFooter,{children:e.jsx(s.Button,{size:"sm",variant:"outline",type:"submit",onClick:E,disabled:b,children:b?"Creating...":"Add"})})]})]})}function it({includeLabel:t=!1}={}){const n=s.useDashboardStore(d=>d.lenses),r=s.useDashboardStore(d=>d.selectedLensId),{setLenses:a,setSelectedLensId:l}=s.useDashboardActions(),{authToken:c,tokenProps:h}=s.useSemaphorContext();async function m(d){l(d)}async function f(d){if(await nt(h.apiServiceUrl,d,c==null?void 0:c.accessToken)){const o=n==null?void 0:n.filter(p=>p.id!==d);a(o||[]),l("original")}}async function b(d){const u=n==null?void 0:n.map(x=>x.id===d.id?{...x,isDefault:!d.isDefault}:{...x,isDefault:!1});a(u||[]);const o={...d,isDefault:!d.isDefault};await Oe(h.apiServiceUrl,o,c==null?void 0:c.accessToken);const p=n==null?void 0:n.find(x=>x.isDefault);if(p&&p.id!==d.id){const x={...p,isDefault:!1};await Oe(h.apiServiceUrl,x,c==null?void 0:c.accessToken)}}return e.jsxs(e.Fragment,{children:[t?e.jsxs(e.Fragment,{children:[e.jsx(s.DropdownMenuLabel,{className:"px-3",children:"Lenses"}),e.jsx(s.DropdownMenuSeparator,{})]}):null,e.jsxs(s.DropdownMenuRadioGroup,{value:r,onValueChange:m,children:[e.jsx(s.DropdownMenuRadioItem,{value:"original",children:"Original"}),n==null?void 0:n.map(d=>e.jsxs(s.DropdownMenuRadioItem,{className:"group flex justify-between gap-2",value:d.id,children:[e.jsx("p",{children:d.name}),e.jsxs("span",{className:"flex items-center gap-3",children:[e.jsx(s.House,{onClick:u=>{u.preventDefault(),b(d)},className:s.cn("size-3.5 text-muted-foreground hover:cursor-pointer hover:text-foreground group-hover:visible",{invisible:!d.isDefault,"text-green-500":d.isDefault}),strokeWidth:1.5}),e.jsx(s.Cross2Icon,{onClick:u=>{u.preventDefault(),f(d.id)},className:"invisible size-3.5 text-muted-foreground hover:cursor-pointer hover:text-foreground group-hover:visible",strokeWidth:1.5})]})]},d.id))]})]})}function lt(){const{displayPreferences:t,shouldShowElement:n}=s.useDisplayPreferences(),{currentUser:r,userContext:a}=s.useCurrentUserInfo(),l=g.useMemo(()=>s.getRoleBasedDisplayOverrides(r),[r]),c=g.useMemo(()=>m=>l&&l[m]!==void 0&&l[m]===!1?!1:n(m),[l,n,t]),h=g.useMemo(()=>{var m,f,b,d,u;return{canEdit:((m=a==null?void 0:a.permissions)==null?void 0:m.canEdit)??s.canUserEdit(r),canUseFilters:((f=a==null?void 0:a.permissions)==null?void 0:f.canEdit)??s.canUserUseFilters(r),canManageDashboards:((b=a==null?void 0:a.permissions)==null?void 0:b.canCreateDashboard)??s.canUserManageDashboards(r),canCreateDashboards:((d=a==null?void 0:a.permissions)==null?void 0:d.canCreateDashboard)??s.canUserCreateDashboards(r),canAccessVisuals:((u=a==null?void 0:a.permissions)==null?void 0:u.canEdit)??s.canUserAccessVisuals(r)}},[r,a]);return{displayPreferences:t,shouldShowElement:c,permissions:h,currentUser:r}}const ct=async(t,n,r)=>{const a=`${t}/management/v1/groups`;return await s.postRequestRegular(a,n,r)},dt=async(t,n,r)=>{const a=`${t}/management/v1/groups/${r}`;await s.requestJsonRegular(a,n,"DELETE")},ut=async(t,n,r,a)=>{const l=`${t}/management/v1/groups/${r}/members`;return await s.postRequestRegular(l,n,a)},mt=async(t,n,r,a)=>{const l=`${t}/management/v1/groups/${r}/members`;await s.requestJsonRegular(l,n,"DELETE",a)};function ht(){const{authToken:t,tokenProps:n}=s.useSemaphorContext(),r=s.useQueryClient();return s.useMutation({mutationFn:a=>ct(n.apiServiceUrl,(t==null?void 0:t.accessToken)||"",a),onSuccess:()=>{r.invalidateQueries({queryKey:["groups"]}),s.ue.success("Group created successfully")},onError:a=>{console.error("Failed to create group:",a),s.ue.error("Failed to create group",{description:s.getRequestErrorMessage(a,"Failed to create group")})}})}function pt(){const{authToken:t,tokenProps:n}=s.useSemaphorContext(),r=s.useQueryClient();return s.useMutation({mutationFn:a=>dt(n.apiServiceUrl,(t==null?void 0:t.accessToken)||"",a),onSuccess:(a,l)=>{r.invalidateQueries({queryKey:["groups"]}),r.removeQueries({queryKey:["group",l]}),s.ue.success("Group deleted successfully")},onError:a=>{console.error("Failed to delete group:",a),s.ue.error("Failed to delete group",{description:s.getRequestErrorMessage(a,"Failed to delete group")})}})}function ft(){const{authToken:t,tokenProps:n}=s.useSemaphorContext(),r=s.useQueryClient();return s.useMutation({mutationFn:({groupId:a,data:l})=>ut(n.apiServiceUrl,(t==null?void 0:t.accessToken)||"",a,l),onSuccess:(a,l)=>{r.invalidateQueries({queryKey:["group",l.groupId]}),r.invalidateQueries({queryKey:["group-members",l.groupId]}),r.invalidateQueries({queryKey:["groups"]}),s.ue.success("Members added successfully")},onError:a=>{console.error("Failed to add group members:",a),s.ue.error("Failed to add members",{description:s.getRequestErrorMessage(a,"Failed to add members")})}})}function gt(){const{authToken:t,tokenProps:n}=s.useSemaphorContext(),r=s.useQueryClient();return s.useMutation({mutationFn:({groupId:a,data:l})=>mt(n.apiServiceUrl,(t==null?void 0:t.accessToken)||"",a,l),onSuccess:(a,l)=>{r.invalidateQueries({queryKey:["group",l.groupId]}),r.invalidateQueries({queryKey:["group-members",l.groupId]}),r.invalidateQueries({queryKey:["groups"]}),s.ue.success("Members removed successfully")},onError:a=>{console.error("Failed to remove group members:",a),s.ue.error("Failed to remove members",{description:s.getRequestErrorMessage(a,"Failed to remove members")})}})}function xt({onSuccess:t,tenantId:n,isTenantUser:r}){const[a,l]=g.useState(""),[c,h]=g.useState(""),[m,f]=g.useState({}),b=ht(),d=()=>{const o={};return a.trim()?a.length<3?o.name="Group name must be at least 3 characters":a.length>50&&(o.name="Group name must be less than 50 characters"):o.name="Group name is required",c&&c.length>200&&(o.description="Description must be less than 200 characters"),f(o),Object.keys(o).length===0},u=async o=>{if(o.preventDefault(),!d())return;const p={name:a.trim(),description:c.trim()||void 0,type:r?"TENANT_GROUP":"ORG_GROUP",...r&&n?{tenantId:n}:{}};try{await b.mutateAsync(p),l(""),h(""),f({}),t()}catch(x){console.error("Failed to create group:",x)}};return e.jsxs("form",{onSubmit:u,className:"space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(s.Label,{htmlFor:"group-name",children:["Group Name ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(s.Input,{id:"group-name",placeholder:"e.g., Marketing Team, Engineering Squad",value:a,onChange:o=>{l(o.target.value),m.name&&f(p=>({...p,name:""}))},className:m.name?"border-destructive":"",disabled:b.isPending}),m.name&&e.jsx("p",{className:"text-sm text-destructive",children:m.name})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(s.Label,{htmlFor:"group-description",children:["Description",e.jsx("span",{className:"ml-2 text-xs text-muted-foreground",children:"(optional)"})]}),e.jsx(s.Textarea,{id:"group-description",placeholder:"Describe the purpose of this group...",value:c,onChange:o=>{h(o.target.value),m.description&&f(p=>({...p,description:""}))},className:m.description?"border-destructive":"",disabled:b.isPending,rows:3}),m.description&&e.jsx("p",{className:"text-sm text-destructive",children:m.description}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[c.length,"/200 characters"]})]}),e.jsx("div",{className:"rounded-lg border bg-muted/50 p-4",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(s.CircleAlert,{className:"h-4 w-4 mt-0.5 text-muted-foreground"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"This group will be accessible to users in your workspace. You can add members after creating the group."})]})})]}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx(s.Button,{type:"button",variant:"outline",onClick:()=>{l(""),h(""),f({})},disabled:b.isPending,children:"Clear"}),e.jsx(s.Button,{type:"submit",disabled:b.isPending||!a.trim(),children:b.isPending?e.jsxs(e.Fragment,{children:[e.jsx(s.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Creating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(s.Users,{className:"mr-2 h-4 w-4"}),"Create Group"]})})]})]})}function bt(t,n=[]){let r=[];function a(c,h){const m=w.createContext(h);m.displayName=c+"Context";const f=r.length;r=[...r,h];const b=u=>{var N;const{scope:o,children:p,...x}=u,j=((N=o==null?void 0:o[t])==null?void 0:N[f])||m,S=w.useMemo(()=>x,Object.values(x));return e.jsx(j.Provider,{value:S,children:p})};b.displayName=c+"Provider";function d(u,o){var j;const p=((j=o==null?void 0:o[t])==null?void 0:j[f])||m,x=w.useContext(p);if(x)return x;if(h!==void 0)return h;throw new Error(`\`${u}\` must be used within \`${c}\``)}return[b,d]}const l=()=>{const c=r.map(h=>w.createContext(h));return function(m){const f=(m==null?void 0:m[t])||c;return w.useMemo(()=>({[`__scope${t}`]:{...m,[t]:f}}),[m,f])}};return l.scopeName=t,[a,vt(l,...n)]}function vt(...t){const n=t[0];if(t.length===1)return n;const r=()=>{const a=t.map(l=>({useScope:l(),scopeName:l.scopeName}));return function(c){const h=a.reduce((m,{useScope:f,scopeName:b})=>{const u=f(c)[`__scope${b}`];return{...m,...u}},{});return w.useMemo(()=>({[`__scope${n.scopeName}`]:h}),[h])}};return r.scopeName=n.scopeName,r}var jt=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Te=jt.reduce((t,n)=>{const r=s.createSlot(`Primitive.${n}`),a=w.forwardRef((l,c)=>{const{asChild:h,...m}=l,f=h?r:n;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(f,{...m,ref:c})});return a.displayName=`Primitive.${n}`,{...t,[n]:a}},{});function St(){return tt.useSyncExternalStore(yt,()=>!0,()=>!1)}function yt(){return()=>{}}var Pe="Avatar",[Dt]=bt(Pe),[Nt,ds]=Dt(Pe),us=w.forwardRef((t,n)=>{const{__scopeAvatar:r,...a}=t,[l,c]=w.useState("idle");return e.jsx(Nt,{scope:r,imageLoadingStatus:l,onImageLoadingStatusChange:c,children:e.jsx(Te.span,{...a,ref:n})})});us.displayName=Pe;var ms="AvatarImage",hs=w.forwardRef((t,n)=>{const{__scopeAvatar:r,src:a,onLoadingStatusChange:l=()=>{},...c}=t,h=ds(ms,r),m=wt(a,c),f=s.useCallbackRef(b=>{l(b),h.onImageLoadingStatusChange(b)});return s.useLayoutEffect2(()=>{m!=="idle"&&f(m)},[m,f]),m==="loaded"?e.jsx(Te.img,{...c,ref:n,src:a}):null});hs.displayName=ms;var ps="AvatarFallback",fs=w.forwardRef((t,n)=>{const{__scopeAvatar:r,delayMs:a,...l}=t,c=ds(ps,r),[h,m]=w.useState(a===void 0);return w.useEffect(()=>{if(a!==void 0){const f=window.setTimeout(()=>m(!0),a);return()=>window.clearTimeout(f)}},[a]),h&&c.imageLoadingStatus!=="loaded"?e.jsx(Te.span,{...l,ref:n}):null});fs.displayName=ps;function cs(t,n){return t?n?(t.src!==n&&(t.src=n),t.complete&&t.naturalWidth>0?"loaded":"loading"):"error":"idle"}function wt(t,{referrerPolicy:n,crossOrigin:r}){const a=St(),l=w.useRef(null),c=a?(l.current||(l.current=new window.Image),l.current):null,[h,m]=w.useState(()=>cs(c,t));return s.useLayoutEffect2(()=>{m(cs(c,t))},[c,t]),s.useLayoutEffect2(()=>{const f=u=>()=>{m(u)};if(!c)return;const b=f("loaded"),d=f("error");return c.addEventListener("load",b),c.addEventListener("error",d),n&&(c.referrerPolicy=n),typeof r=="string"&&(c.crossOrigin=r),()=>{c.removeEventListener("load",b),c.removeEventListener("error",d)}},[c,r,n]),h}var gs=us,xs=hs,bs=fs;const Fe=w.forwardRef(({className:t,...n},r)=>e.jsx(gs,{ref:r,className:s.cn("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",t),...n}));Fe.displayName=gs.displayName;const Ct=w.forwardRef(({className:t,...n},r)=>e.jsx(xs,{ref:r,className:s.cn("aspect-square h-full w-full",t),...n}));Ct.displayName=xs.displayName;const _e=w.forwardRef(({className:t,...n},r)=>e.jsx(bs,{ref:r,className:s.cn("flex h-full w-full items-center justify-center rounded-full bg-muted",t),...n}));_e.displayName=bs.displayName;function Mt({open:t,onOpenChange:n,group:r,onUpdate:a}){const[l,c]=g.useState("members"),[h,m]=g.useState(""),[f,b]=g.useState([]),[d,u]=g.useState([]),{data:o,isLoading:p,refetch:x}=s.useGroupMembers(r.id),j=r.type==="TENANT_GROUP"?"tenant":"organization",{users:S,isLoading:N}=s.useUnifiedUsers({type:j,tenantId:r.tenantId||void 0,active:!0,limit:100}),C=ft(),O=gt(),E=(o==null?void 0:o.members)||[],y=g.useMemo(()=>new Set(E.map(v=>v.userId)),[E]),T=g.useMemo(()=>S.filter(v=>!y.has(v.id)),[S,y]),$=g.useMemo(()=>{if(!h)return T;const v=h.toLowerCase();return T.filter(M=>{var k,P;return((k=M.name)==null?void 0:k.toLowerCase().includes(v))||((P=M.email)==null?void 0:P.toLowerCase().includes(v))})},[T,h]),D=g.useMemo(()=>{if(!h)return E;const v=h.toLowerCase();return E.filter(M=>{var k,P,ee,R;return((P=(k=M.user)==null?void 0:k.name)==null?void 0:P.toLowerCase().includes(v))||((R=(ee=M.user)==null?void 0:ee.email)==null?void 0:R.toLowerCase().includes(v))})},[E,h]),q=async()=>{if(f.length!==0)try{await C.mutateAsync({groupId:r.id,data:{userIds:f,userType:j==="tenant"?"tenant":"org"}}),b([]),c("members"),x(),a==null||a()}catch(v){console.error("Failed to add members:",v)}},X=async()=>{if(d.length!==0)try{await O.mutateAsync({groupId:r.id,data:{userIds:d}}),u([]),x(),a==null||a()}catch(v){console.error("Failed to remove members:",v)}},xe=v=>{b(M=>M.includes(v)?M.filter(k=>k!==v):[...M,v])},Z=v=>{u(M=>M.includes(v)?M.filter(k=>k!==v):[...M,v])};return e.jsx(e.Fragment,{children:e.jsx(s.Dialog,{open:t,onOpenChange:n,children:e.jsxs(s.DialogContent,{className:"max-w-3xl max-h-[80vh]","aria-describedby":"group-members-description",children:[e.jsxs(s.DialogHeader,{children:[e.jsx(s.DialogTitle,{children:r.name}),e.jsx("div",{className:"flex items-center gap-2 mt-1",children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:[E.length," ",E.length===1?"member":"members"]})}),e.jsxs("p",{id:"group-members-description",className:"sr-only",children:["Add or remove members from the ",r.name," group"]})]}),e.jsxs(s.Tabs,{value:l,onValueChange:v=>{c(v),m(""),u([])},className:"mt-4",children:[e.jsxs(s.TabsList,{className:"grid w-full grid-cols-2",children:[e.jsx(s.TabsTrigger,{value:"members",children:"Current Members"}),e.jsx(s.TabsTrigger,{value:"add",children:"Add Members"})]}),e.jsxs(s.TabsContent,{value:"members",className:"mt-4 space-y-4",children:[e.jsxs("div",{className:"relative",children:[e.jsx(s.Search,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(s.Input,{placeholder:"Search members...",value:h,onChange:v=>m(v.target.value),className:"pl-10"})]}),e.jsx(s.ScrollArea,{className:d.length>0?"h-[300px]":"h-[350px]",children:p?e.jsx("div",{className:"space-y-2",children:[1,2,3].map(v=>e.jsx(s.Skeleton,{className:"h-16 w-full"},v))}):D.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[e.jsx(s.Users,{className:"h-12 w-12 mb-3 opacity-50"}),e.jsx("p",{className:"text-sm font-medium",children:h?"No members found":"No members yet"}),e.jsx("p",{className:"text-xs mt-1",children:h?"Try a different search":'Switch to the "Add Members" tab to add people to this group'})]}):e.jsx("div",{className:"space-y-2",children:D.map(v=>e.jsx(Lt,{member:v,selected:d.includes(v.userId),onToggle:()=>Z(v.userId)},v.id))})}),d.length>0&&e.jsxs("div",{className:"flex items-center justify-between pt-4 border-t",children:[e.jsxs("span",{className:"text-sm text-muted-foreground",children:[d.length," member",d.length!==1?"s":""," selected"]}),e.jsx(s.Button,{variant:"destructive",size:"sm",onClick:X,disabled:O.isPending,children:O.isPending?e.jsxs(e.Fragment,{children:[e.jsx(s.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Removing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(s.Trash2,{className:"mr-2 h-4 w-4"}),"Remove Selected"]})})]})]}),e.jsxs(s.TabsContent,{value:"add",className:"mt-4 space-y-4",children:[e.jsxs("div",{className:"relative",children:[e.jsx(s.Search,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(s.Input,{placeholder:"Search users to add...",value:h,onChange:v=>m(v.target.value),className:"pl-10"})]}),e.jsx(s.ScrollArea,{className:"h-[300px]",children:N?e.jsx("div",{className:"space-y-2",children:[1,2,3].map(v=>e.jsx(s.Skeleton,{className:"h-16 w-full"},v))}):$.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[e.jsx(s.UserPlus,{className:"h-12 w-12 mb-3 opacity-50"}),e.jsx("p",{className:"text-sm font-medium",children:"No available users"}),e.jsx("p",{className:"text-xs mt-1",children:h?"Try a different search":"All eligible users are already members"})]}):e.jsx("div",{className:"space-y-2",children:$.map(v=>e.jsx(Et,{user:v,selected:f.includes(v.id),onToggle:()=>xe(v.id)},v.id))})}),f.length>0&&e.jsxs("div",{className:"flex items-center justify-between pt-4 border-t",children:[e.jsxs("span",{className:"text-sm text-muted-foreground",children:[f.length," user",f.length!==1?"s":""," selected"]}),e.jsx(s.Button,{onClick:q,disabled:C.isPending,children:C.isPending?e.jsxs(e.Fragment,{children:[e.jsx(s.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Adding..."]}):e.jsxs(e.Fragment,{children:[e.jsx(s.UserPlus,{className:"mr-2 h-4 w-4"}),"Add Members"]})})]})]})]})]})})})}function Lt({member:t,selected:n,onToggle:r}){var l,c,h,m;const a=((c=(l=t.user)==null?void 0:l.name)==null?void 0:c.split(" ").map(f=>f[0]).join("").toUpperCase())||"?";return e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg border bg-card hover:bg-muted/50 cursor-pointer",onClick:r,children:[e.jsx(s.Checkbox,{checked:n}),e.jsx(Fe,{className:"h-8 w-8",children:e.jsx(_e,{className:"text-xs",children:a})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium",children:((h=t.user)==null?void 0:h.name)||"Unknown User"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(m=t.user)==null?void 0:m.email})]})]})}function Et({user:t,selected:n,onToggle:r}){var l;const a=((l=t.name)==null?void 0:l.split(" ").map(c=>c[0]).join("").toUpperCase())||"?";return e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg border bg-card hover:bg-muted/50 cursor-pointer",onClick:r,children:[e.jsx(s.Checkbox,{checked:n}),e.jsx(Fe,{className:"h-8 w-8",children:e.jsx(_e,{className:"text-xs",children:a})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium",children:t.name}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t.email})]})]})}function At({open:t,onOpenChange:n}){const[r,a]=g.useState("groups"),[l,c]=g.useState(""),[h,m]=g.useState(null),[f,b]=g.useState(!1),[d,u]=g.useState(null),{tokenProps:o}=s.useSemaphorContext(),{currentUser:p}=s.useCurrentUserInfo(),x=pt(),j=(p==null?void 0:p.type)==="tenant",S=o==null?void 0:o.tenantId,{groups:N,isLoading:C,refetch:O}=s.useGroups({type:j?"TENANT_GROUP":"all",tenantId:j?S:void 0,includeMembers:!1}),E=N.filter(D=>{var q;return D.name.toLowerCase().includes(l.toLowerCase())||((q=D.description)==null?void 0:q.toLowerCase().includes(l.toLowerCase()))}),y=async()=>{if(d)try{await x.mutateAsync(d.id),u(null),O()}catch(D){console.error("Failed to delete group:",D)}},T=D=>{m(D),b(!0)},$=()=>{a("groups"),O()};return e.jsxs(e.Fragment,{children:[e.jsx(s.Dialog,{open:t,onOpenChange:n,children:e.jsxs(s.DialogContent,{className:"max-w-4xl max-h-[80vh]",children:[e.jsxs(s.DialogHeader,{children:[e.jsxs(s.DialogTitle,{className:"flex items-center gap-2",children:[e.jsx(s.Users,{className:"h-5 w-5"}),"Group Management"]}),e.jsx(s.DialogDescription,{children:"Manage your groups, create new groups, and control group membership"})]}),e.jsxs(s.Tabs,{value:r,onValueChange:a,className:"mt-4",children:[e.jsxs(s.TabsList,{className:"grid w-full grid-cols-2",children:[e.jsxs(s.TabsTrigger,{value:"groups",className:"flex items-center gap-2",children:[e.jsx(s.Users,{className:"h-4 w-4"}),"Groups"]}),e.jsxs(s.TabsTrigger,{value:"create",className:"flex items-center gap-2",children:[e.jsx(s.Plus,{className:"h-4 w-4"}),"Create Group"]})]}),e.jsx(s.TabsContent,{value:"groups",className:"mt-4",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"relative",children:[e.jsx(s.Search,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(s.Input,{placeholder:"Search groups...",value:l,onChange:D=>c(D.target.value),className:"pl-10"})]}),e.jsx(s.ScrollArea,{className:"h-[400px]",children:C?e.jsx("div",{className:"space-y-3",children:[1,2,3].map(D=>e.jsx(s.Skeleton,{className:"h-24 w-full"},D))}):E.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[e.jsx(s.Users,{className:"h-12 w-12 mb-3 opacity-50"}),e.jsx("p",{className:"text-sm font-medium",children:"No groups found"}),e.jsx("p",{className:"text-xs mt-1",children:l?"Try a different search":"Create your first group to get started"})]}):e.jsx("div",{className:"space-y-3",children:E.map(D=>e.jsx(It,{group:D,onManageMembers:()=>T(D),onDelete:()=>u(D),currentUserId:p==null?void 0:p.id},D.id))})})]})}),e.jsx(s.TabsContent,{value:"create",className:"mt-4",children:e.jsx(xt,{onSuccess:$,tenantId:S,isTenantUser:j})})]})]})}),h&&e.jsx(Mt,{open:f,onOpenChange:b,group:h,onUpdate:()=>O()}),e.jsx(s.AlertDialog,{open:!!d,onOpenChange:()=>u(null),children:e.jsxs(s.AlertDialogContent,{children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsx(s.AlertDialogTitle,{children:"Delete Group"}),e.jsxs(s.AlertDialogDescription,{children:['Are you sure you want to delete "',d==null?void 0:d.name,'"? This action cannot be undone and will remove all members from the group.']})]}),e.jsxs(s.AlertDialogFooter,{children:[e.jsx(s.AlertDialogCancel,{children:"Cancel"}),e.jsx(s.AlertDialogAction,{onClick:y,disabled:x.isPending,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:x.isPending?e.jsxs(e.Fragment,{children:[e.jsx(s.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Deleting..."]}):"Delete Group"})]})]})})]})}function It({group:t,onManageMembers:n,onDelete:r,currentUserId:a}){const l=t.createdBy===a;return e.jsx("div",{className:"rounded-lg border bg-card p-4 transition-colors hover:bg-muted/50",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium",children:t.name}),t.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:t.description})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(s.Users,{className:"h-3 w-3"}),t.memberCount," ",t.memberCount===1?"member":"members"]}),e.jsxs("span",{children:["Created ",Hs.format(new Date(t.createdAt),"MMM d, yyyy")]})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(s.Button,{variant:"ghost",size:"sm",onClick:n,title:"Manage members",children:e.jsx(s.UserPlus,{className:"h-4 w-4"})}),l&&e.jsx(s.Button,{variant:"ghost",size:"sm",onClick:r,title:"Delete group",className:"text-destructive hover:text-destructive",children:e.jsx(s.Trash2,{className:"h-4 w-4"})})]})]})})}function W(t,n,r){var c,h;const a=(t.controls||[]).find(m=>m.id===r);if(a)return a.label;const l=(h=(c=s.findCardById(t,n))==null?void 0:c.controls)==null?void 0:h.find(m=>m.id===r);return(l==null?void 0:l.label)||r}function Y(t,n){var r;return((r=s.findCardById(t,n))==null?void 0:r.title)||n}function kt(t){const{errors:n,dashboard:r}=t;if(!r)return n;const a=new Map;for(const l of n){const c=l.match(/^Card '(.+)' binding for control '(.+)' maps to missing metric '(.+)'\.$/);if(c){const[,d,u]=c,o=`${d}:${u}:missing-metric`;a.has(o)||a.set(o,`"${Y(r,d)}" has an outdated "${W(r,d,u)}" mapping. Some choices still point to metrics that are no longer available on this card. Open the card controls and choose replacements.`);continue}const h=l.match(/^Card '(.+)' binding for control '(.+)' maps to missing group-by field '(.+)'\.$/);if(h){const[,d,u]=h,o=`${d}:${u}:missing-group-by`;a.has(o)||a.set(o,`"${Y(r,d)}" has an outdated "${W(r,d,u)}" mapping. Some choices still point to fields that are no longer available on this card. Open the card controls and choose replacements.`);continue}const m=l.match(/^Card '(.+)' binding for control '(.+)' maps to an invalid metric target\.$/);if(m){const[,d,u]=m,o=`${d}:${u}:invalid-metric`;a.has(o)||a.set(o,`"${Y(r,d)}" has an invalid "${W(r,d,u)}" metric mapping. Open the card controls and choose a valid metric for each option.`);continue}const f=l.match(/^Card '(.+)' binding for control '(.+)' maps to an invalid group-by target\.$/);if(f){const[,d,u]=f,o=`${d}:${u}:invalid-group-by`;a.has(o)||a.set(o,`"${Y(r,d)}" has an invalid "${W(r,d,u)}" field mapping. Open the card controls and choose a valid field for each option.`);continue}const b=l.match(/^Card '(.+)' binding for control '(.+)' requires at least one temporal group-by field\.$/);if(b){const[,d,u]=b,o=`${d}:${u}:missing-temporal-group-by`;a.has(o)||a.set(o,`"${Y(r,d)}" can no longer use "${W(r,d,u)}" for time grain because the card does not currently group by a date field.`);continue}a.set(l,l)}return Array.from(a.values())}function Ot(){var es,ss,ts,as;U.useExportRecovery(),U.useExportPolling();const{authToken:t,tokenProps:n,id:r}=s.useSemaphorContext(),{isLocalDev:a}=s.useDashboardPreferences(),{permissions:l}=lt(),c=s.useHasDashboardId(),{isLoading:h}=s.useDashboardQuery();s.useDashboardStore(i=>i.theme);const m=s.useDashboardStore(i=>i.isDownloadingPdf),f=s.useDashboardStore(i=>i.dashboardAssistantDraftScopeKey),b=s.useDashboardStore(i=>i.lenses),d=s.useDashboardStore(i=>i.selectedLensId),u=b==null?void 0:b.find(i=>i.id===d),o=s.useDashboardStore(i=>i.dashboard);s.useDashboardStore(i=>i.selectedSheetId);const p=s.useDashboardStore(i=>i.isDashboardEditing),{setDashboardTitle:x}=s.useDashboardStore(i=>i.actions),[j,S]=g.useState(!1),[N,C]=g.useState(!1),[O,E]=g.useState(!1),[y,T]=g.useState(!1),[$,D]=g.useState(!1),[q,X]=g.useState(!1),[xe,Z]=g.useState(!1),[v,M]=g.useState(!1),[k,P]=g.useState(null),[ee,R]=g.useState(!1),[se,te]=g.useState(null),[Ue,ae]=g.useState([]),[Re,re]=g.useState(!1),vs=s.useDashboardStore(i=>i.isDashboardPanelOpen),js=s.useDashboardStore(i=>i.actions.setIsDashboardPanelOpen),Ss=s.useDashboardStore(i=>i.filterValues),A=s.useDashboardStore(i=>i.isVisualEditing);s.useEditorStore(i=>i.card);const H=s.useManagementStore(i=>i.selectedDashboard),ne=s.useManagementStore(i=>i.initialDashboard);s.useManagementStore(i=>i.selectedVisual),s.useDashboardStore(i=>i.selectedFrameId),s.useEditorStore(i=>i.frame);const oe=H?(ss=H==null?void 0:H.permissions)==null?void 0:ss.canEdit:(es=ne==null?void 0:ne.permissions)==null?void 0:es.canEdit,ie=s.useDashboardStore(i=>i.showFilters),Ge=s.useAssistantLayoutStore(i=>i.setPanelOpen),$e=s.useDashboardStore(i=>i.showDashboardJSON),be=s.useDashboardStore(i=>i.onSaveFunction),qe=s.useDashboardStore(i=>i.actions.setShowFilters),{setIsDashboardEditing:Be,setShowDashboardJSON:He}=s.useDashboardStore(i=>i.actions),{setInitialDashboard:ze,clearSelectedDashboard:ve}=s.useManagementStore(i=>i.actions),{resources:le}=s.useResourceManagement(s.ResourceType.DASHBOARD),{data:je}=s.useUserPreferences(),ys=((ts=je==null?void 0:je.preference)==null?void 0:ts.defaultDashboardId)||null,{mutate:Ds,isPending:Ns}=s.useDefaultDashboardMutation(),{currentUser:ws}=s.useCurrentUserInfo(),Cs=s.canUserManageGroups(ws),B=H||ne,Ve=B?{id:B.id,title:(o==null?void 0:o.title)||B.title||"Dashboard"}:null,{handleAddNewFrame:Ms}=s.useAddNewFrame(),[Se,ye]=g.useState(!1),[Ls,z]=g.useState(!1),[De,ce]=g.useState("close"),V=s.useUpdateResource(s.ResourceType.DASHBOARD),[F,Ne]=g.useState(null),Ke=g.useCallback(i=>{window.setTimeout(()=>{P(i)},0)},[]),Es=async(i,L)=>{if(!(o!=null&&o.id)){console.log("No dashboard ID found");return}console.log("Updating dashboard title:",{dashboardId:o.id,newTitle:i,previousTitle:L}),V.mutate({resourceId:o.id,data:{title:i}},{onSuccess:()=>{console.log("Dashboard title updated successfully"),s.ue.success("Dashboard title updated")},onError:_=>{console.error("Failed to update dashboard title:",_),s.ue.error("Failed to update dashboard title"),x(L)}})};g.useEffect(()=>{if(le&&le.length>0){const i=o==null?void 0:o.id;if(i){const L=le.find(_=>_.id===i);L&&ze(L)}}},[le,o==null?void 0:o.id,ze]);const K=n.orgUserId||n.tenantId,Qe=p&&!A&&K&&oe,{setDashboard:we}=s.useDashboardStore(i=>i.actions),As=()=>{Be(!0)},Ce=()=>{Be(!1),He(!1),Ne(null),P(null)};U.usePristineSnapshotInitializer(p,o,F,i=>Ne(i));const{isDirty:Je,isDirtyPending:Is,resetDirty:de}=zs.useDebouncedDirtyCheck(o,F,300,1e3,Ee.serializeDashboardForDirtyCheck),We=g.useCallback(()=>F?Ee.serializeDashboardForDirtyCheck(o)!==Ee.serializeDashboardForDirtyCheck(F):!1,[o,F]),Ye=Je||Is,ue=Se||V.isPending,ks=()=>{We()?(ce("close"),z(!0)):(Ce(),de())},Os=async()=>{await Me({closeAfterSave:!0,navigateHomeAfterSave:De==="home"})},Ts=()=>{F&&we(F),Ce(),De==="home"&&ve(),ce("close"),z(!1),de()},Ps=()=>{F&&(we(F),de())},Fs=()=>{if(p&&We()){ce("home"),z(!0);return}ve()};async function Me(i){const L=s.useDashboardStore.getState().dashboard;if(!L)return;const _=(i==null?void 0:i.closeAfterSave)??Re,$s=(i==null?void 0:i.navigateHomeAfterSave)??!1;re(_),_&&z(!1);const qs=s.cloneDeep(L);R(!0),te(null),ae([]),ye(!0);const Bs={template:L};V.mutate({resourceId:L.id,data:Bs},{onSuccess:I=>{var he,pe,rs;const G=(I==null?void 0:I.id)||((he=I==null?void 0:I.dashboard)==null?void 0:he.id)||((pe=I==null?void 0:I.resource)==null?void 0:pe.id)||((rs=I==null?void 0:I.template)==null?void 0:rs.id)||null;if(!L.id&&G){const Le=s.useAIInteractionStore.getState(),fe=Le.pendingDashboardDraftMigration;(fe==null?void 0:fe.scopeKey)===f?Le.actions.setPendingDashboardDraftMigrationExpectedDashboardId(G):fe&&Le.actions.clearPendingDashboardDraftMigration()}ye(!1),s.ue.success("Dashboard saved!"),Ne(qs),R(!1),re(!1),_&&(Ce(),de(),$s&&ve()),ce("close")},onError:I=>{ye(!1),te("Failed to save dashboard. Please try again.");const G=I.details,he=Array.isArray(G==null?void 0:G.errors)?(G.errors||[]).filter(pe=>typeof pe=="string"):[];ae(kt({errors:he,dashboard:L||void 0})),s.ue.error("Failed to save dashboard")}})}async function _s(){if(S(!0),!d||!u)return;const i=s.useDashboardStore.getState().dashboard;if(!i){S(!1);return}const L=JSON.stringify(i),_={...u,template:L,filterValues:Ss};await Oe(n.apiServiceUrl,_,t==null?void 0:t.accessToken),s.ue.success("Lens saved"),be==null||be(i),S(!1)}const Xe=(u==null?void 0:u.name)||o.title,Q=!!(o!=null&&o.id);V.isPending&&console.log("Title during update:",{title:Xe,dashboardStateTitle:o.title,dashboardId:o==null?void 0:o.id,currentLensName:u==null?void 0:u.name});const Ze=n.orgUserId||n.tenantId&&n.endUserId&&n.endUserEmail,Us=!!Ze&&!!(t!=null&&t.accessToken)&&!!(n!=null&&n.apiServiceUrl);g.useEffect(()=>{!Q&&y&&T(!1)},[Q,y]);const Rs=c,J=(o==null?void 0:o.id)||null,me=!!J&&ys===J,Gs=()=>{J&&Ds({dashboardId:me?null:J})};return e.jsxs("div",{className:"flex h-11 shrink-0 items-center justify-between gap-2 overflow-x-auto border-b px-4 py-2",role:"dashboard-controls",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[Ze&&e.jsxs(e.Fragment,{children:[e.jsx(s.IconButton,{"aria-label":"Manage Dashboards",tooltip:"Manage Dashboards",onClick:()=>{js(!vs)},className:"h-7 w-7 px-0",buttonProps:{size:"xs"},children:e.jsx(Js,{className:"h-3.5 w-3.5"})}),Rs&&!A&&e.jsx(s.IconButton,{"aria-label":"Dashboard Hub",tooltip:"Dashboard Hub",onClick:Fs,className:"h-7 w-7 px-0",buttonProps:{size:"xs"},children:e.jsx(s.House,{className:"h-3.5 w-3.5"})})]}),!A&&c&&(h?e.jsx("div",{className:"h-4 w-28 rounded-md bg-muted/70 animate-pulse","aria-label":"Loading dashboard title",role:"status",children:e.jsx("span",{className:"sr-only",children:"Loading dashboard title"})}):e.jsxs(e.Fragment,{children:[e.jsx(s.EditableText,{value:Xe||"Untitled Dashboard",onSave:i=>{console.log("EditableText onSave called:",{newTitle:i,canEditDashboard:oe,dashboardId:o==null?void 0:o.id});const L=(o==null?void 0:o.title)||"";x(i),Es(i,L)},isEditable:oe&&!u,displayClassName:"text-[13px] font-medium",inputClassName:"text-[13px] font-medium",placeholder:"Dashboard Title",isPending:V.isPending}),Us&&J&&e.jsx(s.TooltipProvider,{children:e.jsxs(s.Tooltip,{children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx(s.Button,{variant:"ghost",size:"xs",onClick:Gs,disabled:Ns||!(t!=null&&t.accessToken)||!(n!=null&&n.apiServiceUrl),className:"w-7 px-0","aria-label":me?"Remove as default dashboard":"Make this a default dashboard",children:e.jsx(s.Star,{className:s.cn("h-3.5 w-3.5 transition-colors",me?"fill-foreground text-foreground":"text-muted-foreground hover:text-foreground")})})}),e.jsx(s.TooltipContent,{children:e.jsx("p",{children:me?"Remove as default dashboard":"Make this a default dashboard"})})]})})]}))]}),e.jsxs("div",{className:"flex items-center gap-2",children:[A&&e.jsxs(e.Fragment,{children:[e.jsx(U.AdvancedModeToggle,{}),e.jsx(U.VisualEditingControls,{})]}),!A&&c&&((as=B==null?void 0:B.permissions)==null?void 0:as.canShare)&&e.jsxs(s.Button,{variant:"outline",size:"xs",onClick:()=>C(!0),children:[e.jsx(s.Share2,{className:"h-3.5 w-3.5"}),"Share"]}),!A&&p&&l.canUseFilters&&c&&e.jsx(U.DashboardFilterControlsButton,{showFilters:ie,onToggleFilters:()=>{ie||Ge("dashboard",!1),qe(!ie)},onAddFilter:()=>{ie||(Ge("dashboard",!1),qe(!0))},onAddControl:()=>{Ke("create")},onManageControls:()=>Ke("manage")}),p&&!A&&c&&k?e.jsx(U.DashboardControlsSettings,{open:!0,onOpenChange:i=>{i||P(null)},showTrigger:!1,initialMode:k}):null,p&&!A&&K&&u&&a&&c&&e.jsxs(s.Button,{variant:"secondary",size:"xs",disabled:j,onClick:_s,children:[e.jsx(os.Save,{className:"h-3.5 w-3.5"}),"Save Lens"]}),p&&!A&&c&&e.jsxs(s.Button,{variant:"outline",size:"xs",disabled:!p,onClick:()=>Ms(),children:[e.jsx(s.Plus,{className:"h-3.5 w-3.5"}),"Visual"]}),!A&&!p&&oe&&c&&e.jsxs(s.Button,{size:"xs",onClick:As,children:[e.jsx(s.Pencil,{className:"h-3.5 w-3.5"}),"Edit"]}),Qe&&c&&Je&&e.jsxs(s.Button,{variant:"outline",size:"xs",onClick:Ps,disabled:ue,children:[e.jsx(s.Undo2,{className:"h-3.5 w-3.5"}),"Undo"]}),Qe&&c&&e.jsxs(s.Button,{size:"xs",className:s.cn(!Ye&&"opacity-60"),disabled:ue||!Ye,onClick:()=>Me(),children:[ue?e.jsx(s.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(os.Save,{className:"h-3.5 w-3.5"}),ue?"Saving...":"Save"]}),p&&!A&&c&&e.jsxs(s.Button,{variant:"outline",size:"xs",onClick:ks,children:[e.jsx(s.Cross2Icon,{className:"h-3.5 w-3.5"}),"Close"]}),!A&&c&&e.jsx("div",{className:"ml-2",children:e.jsx(U.NotificationBell,{})}),!A&&a&&e.jsx(at,{}),!A&&c&&e.jsxs(s.DropdownMenu,{children:[e.jsx(s.DropdownMenuTrigger,{asChild:!0,children:e.jsx(s.IconButton,{tooltip:"More Options",className:"w-7 px-0 text-muted-foreground hover:text-foreground",buttonProps:{size:"xs",variant:"ghost","aria-label":"More dashboard options"},children:e.jsx(s.EllipsisVertical,{className:"h-3.5 w-3.5"})})}),e.jsxs(s.DropdownMenuContent,{align:"end",className:"w-56 rounded-[6px] border border-border/60 p-1 shadow-sm",children:[e.jsx(s.DropdownMenuLabel,{children:"Reports"}),e.jsxs(s.DropdownMenuItem,{disabled:m,onSelect:()=>M(!0),children:[e.jsx(s.Download,{className:"h-3.5 w-3.5"}),"Export"]}),e.jsxs(s.DropdownMenuItem,{disabled:!Q,onSelect:()=>{Q&&T(!0)},children:[e.jsx(s.Clock,{className:"h-3.5 w-3.5"}),"Schedule"]}),e.jsx(s.DropdownMenuSeparator,{}),Cs&&e.jsxs(e.Fragment,{children:[e.jsx(s.DropdownMenuLabel,{children:"Access"}),e.jsxs(s.DropdownMenuItem,{onClick:()=>E(!0),children:[e.jsx(s.Users,{className:"h-3.5 w-3.5"}),"Manage Groups"]}),e.jsx(s.DropdownMenuSeparator,{})]}),e.jsx(s.DropdownMenuLabel,{children:"Preferences"}),e.jsxs(s.DropdownMenuItem,{onClick:()=>D(!0),children:[e.jsx(s.Calendar,{className:"h-3.5 w-3.5"}),"Calendar Preferences"]}),e.jsxs(s.DropdownMenuItem,{onClick:()=>X(!0),children:[e.jsx(s.FileText,{className:"h-3.5 w-3.5"}),"Summary Settings"]}),a&&c&&e.jsxs(e.Fragment,{children:[e.jsx(s.DropdownMenuSeparator,{}),e.jsx(s.DropdownMenuLabel,{children:"Developer"}),e.jsxs(s.DropdownMenuItem,{onSelect:()=>{var i;t!=null&&t.accessToken&&((i=navigator==null?void 0:navigator.clipboard)!=null&&i.writeText?navigator.clipboard.writeText(t.accessToken).then(()=>s.ue.success("Token copied to clipboard")).catch(()=>s.ue.error("Unable to copy token")):s.ue.error("Clipboard not available"))},children:[e.jsx(s.Copy,{className:"h-3.5 w-3.5"}),"Copy token"]}),e.jsxs(s.DropdownMenuItem,{onSelect:()=>s.invalidateToken(n.apiServiceUrl),children:[e.jsx(Xs,{className:"h-3.5 w-3.5"}),"Invalidate token"]}),p&&e.jsxs(s.DropdownMenuItem,{onSelect:()=>He(!$e),children:[e.jsx(Vs.Braces,{className:"h-3.5 w-3.5"}),$e?"Hide dashboard JSON":"Show dashboard JSON"]}),K&&p&&e.jsxs(s.DropdownMenuItem,{onSelect:()=>Z(!0),children:[e.jsx(s.Plus,{className:"h-3.5 w-3.5"}),"Add lens"]}),K&&e.jsxs(s.DropdownMenuSub,{children:[e.jsxs(s.DropdownMenuSubTrigger,{children:[e.jsx(Qs,{className:"h-3.5 w-3.5"}),"Lenses"]}),e.jsx(s.DropdownMenuSubContent,{className:"w-60",children:e.jsx(it,{})})]})]})]})]}),N&&Ve&&e.jsx(s.ShareDialog,{resource:Ve,resourceType:s.ResourceType.DASHBOARD,onClose:()=>C(!1)}),e.jsx(At,{open:O,onOpenChange:E}),Q&&(o==null?void 0:o.id)&&e.jsx(s.EmailScheduleDialog,{open:y,onOpenChange:T,dashboardId:o.id,dashboardName:o==null?void 0:o.title}),e.jsx(ns.CalendarPreferencesDialog,{open:$,onOpenChange:D}),e.jsx(ns.DashboardSummarySettingsDialog,{open:q,onOpenChange:X,dashboard:o,disabled:!p,onApply:i=>we({...o,summary:i})}),a&&K&&c&&e.jsx(ot,{open:xe,onOpenChange:Z}),c&&e.jsx(s.DownloadPdf,{open:v,onOpenChange:M}),e.jsx(s.AlertDialog,{open:ee,onOpenChange:i=>{!i&&Se&&!se||(R(i),i||(te(null),ae([]),re(!1)))},children:e.jsxs(s.AlertDialogContent,{className:"max-w-sm",children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsx(s.AlertDialogTitle,{children:se?"Save failed":"Saving dashboard"}),e.jsx(s.AlertDialogDescription,{className:"pt-2",children:se?"We could not save the dashboard. Please try again.":"Please wait while we save your changes."}),Ue.length>0&&e.jsxs("div",{className:"space-y-1 rounded-md border border-destructive/20 bg-destructive/5 p-3 text-left",children:[e.jsx("div",{className:"text-sm font-medium text-destructive",children:"What needs attention"}),e.jsx("ul",{className:"list-disc space-y-1 pl-4 text-xs text-muted-foreground",children:Ue.slice(0,5).map(i=>e.jsx("li",{children:i},i))})]})]}),e.jsx(s.AlertDialogFooter,{className:"flex-col gap-2 sm:flex-row sm:justify-end",children:se?e.jsxs(e.Fragment,{children:[e.jsx(s.AlertDialogCancel,{onClick:()=>{R(!1),te(null),ae([]),re(!1)},className:"m-0",children:"Close"}),e.jsx(s.AlertDialogAction,{onClick:()=>Me({closeAfterSave:Re,navigateHomeAfterSave:De==="home"}),className:"m-0",children:"Retry"})]}):e.jsxs(s.AlertDialogAction,{disabled:!0,className:"m-0 cursor-default",children:[e.jsx(s.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]})})]})}),e.jsx(U.UnsavedChangesAlert,{open:Ls,onOpenChange:i=>{z(i)},onSave:Os,onDiscard:Ts,isSaving:Se,saveLabel:"Save",discardLabel:"Discard"})]})]})}exports.default=Ot;