react-semaphor 0.1.305 → 0.1.307
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.
- package/dist/brand-studio/index.cjs +2 -2
- package/dist/brand-studio/index.js +14 -14
- package/dist/chunks/braces-CkL8POe0.js +6 -0
- package/dist/chunks/braces-e5qkN-I_.js +23 -0
- package/dist/chunks/{dashboard-controls-DjOO0fkG.js → dashboard-controls-5bibC_5a.js} +141 -128
- package/dist/chunks/dashboard-controls-Dwet_9h0.js +52 -0
- package/dist/chunks/{dashboard-filter-controls-button-YvRfoUuN.js → dashboard-filter-controls-button-D0k9NDci.js} +4 -4
- package/dist/chunks/{dashboard-filter-controls-button-CR0_duPw.js → dashboard-filter-controls-button-ZeYO5jux.js} +1 -1
- package/dist/chunks/{dashboard-json-tOsNVccY.js → dashboard-json-Bi5XdgG5.js} +1 -1
- package/dist/chunks/{dashboard-json-BYLaWi0-.js → dashboard-json-CfRKLL7C.js} +2 -2
- package/dist/chunks/{dashboard-summary-settings-dialog-CMxi2arh.js → dashboard-summary-settings-dialog-Bj4_wBW9.js} +2 -2
- package/dist/chunks/{dashboard-summary-settings-dialog-DioOegLQ.js → dashboard-summary-settings-dialog-DD9Aj2XH.js} +1 -1
- package/dist/chunks/{edit-dashboard-visual-ClLcFLD_.js → edit-dashboard-visual-DIuzuJfj.js} +8796 -8713
- package/dist/chunks/edit-dashboard-visual-Wfs53Kbn.js +183 -0
- package/dist/chunks/{index-DJFckbGE.js → index-DMFCfjgD.js} +52348 -49752
- package/dist/chunks/index-DQCMUspd.js +1350 -0
- package/dist/chunks/{palette-BqJlrRto.js → palette-D5Lorzf2.js} +2 -7
- package/dist/chunks/{palette-DD-i7bNS.js → palette-Oa4O9jWG.js} +3 -23
- package/dist/chunks/{resource-management-panel-CoHy6cOi.js → resource-management-panel-CNr6uMMf.js} +1 -1
- package/dist/chunks/{resource-management-panel-BS9nfJbb.js → resource-management-panel-Dqc3gfYn.js} +3 -3
- package/dist/chunks/{save-j-clxFtx.js → save-CDX2p4v1.js} +1 -1
- package/dist/chunks/{save-CFBIhbHD.js → save-zEdICevW.js} +1 -1
- package/dist/chunks/{switch-BH17qlxH.js → switch-BPFzGTzF.js} +34 -29
- package/dist/chunks/{switch-BFhVVwh9.js → switch-CKiXRRoh.js} +432 -390
- package/dist/chunks/{use-create-flow-overlay-state-Lmk-mIkA.js → use-create-flow-overlay-state-CLyv5c2m.js} +4 -4
- package/dist/chunks/{use-create-flow-overlay-state-BSUi4chy.js → use-create-flow-overlay-state-CSMe5Ls6.js} +1 -1
- package/dist/chunks/{use-visual-utils-CR9nLyEz.js → use-visual-utils-DDAs4dCz.js} +1 -1
- package/dist/chunks/{use-visual-utils-CikIkKb2.js → use-visual-utils-Det6M3Wd.js} +2 -2
- package/dist/dashboard/index.cjs +1 -1
- package/dist/dashboard/index.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +7 -7
- package/dist/style.css +1 -1
- package/dist/surfboard/index.cjs +1 -1
- package/dist/surfboard/index.js +2 -2
- package/dist/types/dashboard.d.ts +142 -44
- package/dist/types/main.d.ts +144 -46
- package/dist/types/shared.d.ts +142 -44
- package/dist/types/surfboard.d.ts +142 -44
- package/dist/types/types.d.ts +142 -44
- package/package.json +4 -4
- package/dist/chunks/dashboard-controls-BcwXajYv.js +0 -47
- package/dist/chunks/edit-dashboard-visual-331vOmKT.js +0 -183
- package/dist/chunks/index-BOGpMmRo.js +0 -1360
- package/dist/chunks/rotate-ccw-CdGW8Rxm.js +0 -6
- package/dist/chunks/rotate-ccw-X8MbX_hF.js +0 -14
package/dist/types/types.d.ts
CHANGED
|
@@ -590,10 +590,7 @@ declare interface ColumnSettings {
|
|
|
590
590
|
maxWidth?: number;
|
|
591
591
|
textOverflow?: 'ellipsis' | 'wrap' | 'clip';
|
|
592
592
|
textWrap: 'wrap' | 'nowrap';
|
|
593
|
-
/**
|
|
594
|
-
* Totals-row behavior for this column. Undefined = 'none'. The footer
|
|
595
|
-
* renders only when at least one visible column has a non-'none' behavior.
|
|
596
|
-
*/
|
|
593
|
+
/** Deprecated/inert. Totals are controlled by tablePrefs.tableStyle.totals. */
|
|
597
594
|
totalsBehavior?: TotalsBehavior;
|
|
598
595
|
totalsLabel?: string;
|
|
599
596
|
numberFormat: {
|
|
@@ -633,6 +630,90 @@ declare type ColumnSettingsMap = Record<string, ColumnSettings>;
|
|
|
633
630
|
|
|
634
631
|
declare type ColumnType = 'string' | 'number' | 'date';
|
|
635
632
|
|
|
633
|
+
declare type ComparisonOperator = 'eq' | 'neq' | 'gt' | 'gte' | 'lt' | 'lte';
|
|
634
|
+
|
|
635
|
+
declare type ConditionalFormatCondition = {
|
|
636
|
+
kind: 'comparison';
|
|
637
|
+
columnId: string;
|
|
638
|
+
operator: ComparisonOperator;
|
|
639
|
+
value: unknown;
|
|
640
|
+
} | {
|
|
641
|
+
kind: 'between';
|
|
642
|
+
columnId: string;
|
|
643
|
+
min: unknown;
|
|
644
|
+
max: unknown;
|
|
645
|
+
inclusive?: boolean;
|
|
646
|
+
} | {
|
|
647
|
+
kind: 'blank';
|
|
648
|
+
columnId: string;
|
|
649
|
+
isBlank: boolean;
|
|
650
|
+
} | {
|
|
651
|
+
kind: 'contains';
|
|
652
|
+
columnId: string;
|
|
653
|
+
value: string;
|
|
654
|
+
caseSensitive?: boolean;
|
|
655
|
+
exact?: boolean;
|
|
656
|
+
} | {
|
|
657
|
+
kind: 'topBottom';
|
|
658
|
+
columnId: string;
|
|
659
|
+
direction: 'top' | 'bottom';
|
|
660
|
+
count: number;
|
|
661
|
+
} | {
|
|
662
|
+
kind: 'colorScale';
|
|
663
|
+
columnId: string;
|
|
664
|
+
range: 'auto' | 'manual';
|
|
665
|
+
min?: number;
|
|
666
|
+
mid?: number;
|
|
667
|
+
max?: number;
|
|
668
|
+
colors: {
|
|
669
|
+
min: string;
|
|
670
|
+
mid?: string;
|
|
671
|
+
max: string;
|
|
672
|
+
};
|
|
673
|
+
} | {
|
|
674
|
+
kind: 'dataBar';
|
|
675
|
+
columnId: string;
|
|
676
|
+
range: 'auto' | 'manual';
|
|
677
|
+
min?: number;
|
|
678
|
+
max?: number;
|
|
679
|
+
color: string;
|
|
680
|
+
showValue?: boolean;
|
|
681
|
+
};
|
|
682
|
+
|
|
683
|
+
declare type ConditionalFormatRule = {
|
|
684
|
+
id: string;
|
|
685
|
+
name?: string;
|
|
686
|
+
enabled?: boolean;
|
|
687
|
+
target: ConditionalFormatTarget;
|
|
688
|
+
condition: ConditionalFormatCondition;
|
|
689
|
+
style?: ConditionalFormatStyle;
|
|
690
|
+
};
|
|
691
|
+
|
|
692
|
+
declare type ConditionalFormatStyle = {
|
|
693
|
+
backgroundColor?: string;
|
|
694
|
+
textColor?: string;
|
|
695
|
+
fontWeight?: 'normal' | 'medium' | 'semibold' | 'bold';
|
|
696
|
+
italic?: boolean;
|
|
697
|
+
textDecoration?: 'none' | 'underline' | 'line-through';
|
|
698
|
+
icon?: 'arrowUp' | 'arrowDown' | 'warning' | 'check' | 'x';
|
|
699
|
+
dataBar?: {
|
|
700
|
+
color: string;
|
|
701
|
+
showValue: boolean;
|
|
702
|
+
};
|
|
703
|
+
};
|
|
704
|
+
|
|
705
|
+
declare type ConditionalFormatTarget = {
|
|
706
|
+
level: 'cell' | 'row';
|
|
707
|
+
columnIds?: string[];
|
|
708
|
+
conditionColumnId?: string;
|
|
709
|
+
applyToColumnIds?: string[];
|
|
710
|
+
tableParts?: TablePart[];
|
|
711
|
+
rowRoles?: string[];
|
|
712
|
+
depth?: number;
|
|
713
|
+
includeTotals?: boolean;
|
|
714
|
+
includeSubtotals?: boolean;
|
|
715
|
+
};
|
|
716
|
+
|
|
636
717
|
export declare type ConnectionPolicy = {
|
|
637
718
|
connectionId?: string;
|
|
638
719
|
name: string;
|
|
@@ -1222,12 +1303,6 @@ export declare type DocumentSpacerSection = {
|
|
|
1222
1303
|
heightPx: number;
|
|
1223
1304
|
};
|
|
1224
1305
|
|
|
1225
|
-
export declare type DocumentTableDensity = 'comfortable' | 'standard' | 'compact' | 'dense';
|
|
1226
|
-
|
|
1227
|
-
export declare type DocumentTableGridLines = 'none' | 'outer' | 'inner' | 'horizontal' | 'vertical' | 'top' | 'right' | 'bottom' | 'left' | 'full';
|
|
1228
|
-
|
|
1229
|
-
export declare type DocumentTableHeaderStyle = 'plain' | 'filled' | 'accent';
|
|
1230
|
-
|
|
1231
1306
|
export declare type DocumentTableSection = {
|
|
1232
1307
|
id: string;
|
|
1233
1308
|
type: 'table';
|
|
@@ -1238,30 +1313,9 @@ export declare type DocumentTableSection = {
|
|
|
1238
1313
|
columnFormatting?: Record<string, unknown>;
|
|
1239
1314
|
repeatHeaderOnPageBreak?: boolean;
|
|
1240
1315
|
rowHeightPx?: number;
|
|
1241
|
-
style?: DocumentTableStyle;
|
|
1242
|
-
totalsStyle?: DocumentTableTotalsStyle;
|
|
1243
1316
|
};
|
|
1244
1317
|
};
|
|
1245
1318
|
|
|
1246
|
-
export declare type DocumentTableStyle = {
|
|
1247
|
-
density?: DocumentTableDensity;
|
|
1248
|
-
headerStyle?: DocumentTableHeaderStyle;
|
|
1249
|
-
headerBackgroundColor?: string;
|
|
1250
|
-
headerTextColor?: string;
|
|
1251
|
-
stripedRows?: boolean;
|
|
1252
|
-
gridLines?: DocumentTableGridLines;
|
|
1253
|
-
wrapText?: boolean;
|
|
1254
|
-
};
|
|
1255
|
-
|
|
1256
|
-
export declare type DocumentTableTotalsFontWeight = 'normal' | 'medium' | 'semibold' | 'bold';
|
|
1257
|
-
|
|
1258
|
-
export declare type DocumentTableTotalsStyle = {
|
|
1259
|
-
backgroundColor?: string;
|
|
1260
|
-
textColor?: string;
|
|
1261
|
-
fontWeight?: DocumentTableTotalsFontWeight;
|
|
1262
|
-
borderTop?: boolean;
|
|
1263
|
-
};
|
|
1264
|
-
|
|
1265
1319
|
export declare type DocumentTextContent = DocumentTextNode[];
|
|
1266
1320
|
|
|
1267
1321
|
export declare type DocumentTextInlineFormat = {
|
|
@@ -2287,6 +2341,29 @@ declare type TableAppearance = {
|
|
|
2287
2341
|
};
|
|
2288
2342
|
};
|
|
2289
2343
|
|
|
2344
|
+
declare type TableBaseFormatting = {
|
|
2345
|
+
version: TableFormattingVersion;
|
|
2346
|
+
tableParts?: Partial<Record<TablePart, TableBaseStyle>>;
|
|
2347
|
+
columns?: Record<string, {
|
|
2348
|
+
body?: TableBaseStyle;
|
|
2349
|
+
header?: TableBaseStyle;
|
|
2350
|
+
footer?: TableBaseStyle;
|
|
2351
|
+
}>;
|
|
2352
|
+
};
|
|
2353
|
+
|
|
2354
|
+
declare type TableBaseStyle = {
|
|
2355
|
+
fontWeight?: 'normal' | 'medium' | 'semibold' | 'bold';
|
|
2356
|
+
italic?: boolean;
|
|
2357
|
+
textColor?: string;
|
|
2358
|
+
backgroundColor?: string;
|
|
2359
|
+
textDecoration?: 'none' | 'underline' | 'line-through';
|
|
2360
|
+
};
|
|
2361
|
+
|
|
2362
|
+
declare type TableConditionalFormatting = {
|
|
2363
|
+
version: TableFormattingVersion;
|
|
2364
|
+
rules: ConditionalFormatRule[];
|
|
2365
|
+
};
|
|
2366
|
+
|
|
2290
2367
|
/**
|
|
2291
2368
|
* Row rhythm for the whole table. Authors pick one per card; undefined
|
|
2292
2369
|
* falls back to 'compact' (the canonical default — dense scanning, matches
|
|
@@ -2295,8 +2372,18 @@ declare type TableAppearance = {
|
|
|
2295
2372
|
*/
|
|
2296
2373
|
declare type TableDensity = 'dense' | 'compact' | 'standard' | 'comfortable' | 'spacious';
|
|
2297
2374
|
|
|
2375
|
+
declare type TableFormattingVersion = 1;
|
|
2376
|
+
|
|
2377
|
+
declare type TableGridLines = 'none' | 'outer' | 'inner' | 'horizontal' | 'vertical' | 'top' | 'right' | 'bottom' | 'left' | 'full';
|
|
2378
|
+
|
|
2379
|
+
declare type TableHeaderStyle = 'plain' | 'filled' | 'accent';
|
|
2380
|
+
|
|
2381
|
+
declare type TablePart = 'body' | 'header' | 'footer' | 'subtotal' | 'grandTotal';
|
|
2382
|
+
|
|
2298
2383
|
declare type TablePreferences = {
|
|
2299
2384
|
columnSettingsMap?: ColumnSettingsMap;
|
|
2385
|
+
baseFormatting?: TableBaseFormatting;
|
|
2386
|
+
conditionalFormatting?: TableConditionalFormatting;
|
|
2300
2387
|
selectColumnVisible?: boolean;
|
|
2301
2388
|
columnVisibility?: Record<string, boolean>;
|
|
2302
2389
|
columnSizing?: ColumnSizingState;
|
|
@@ -2304,7 +2391,29 @@ declare type TablePreferences = {
|
|
|
2304
2391
|
enableDevModePagination?: boolean;
|
|
2305
2392
|
forceClientPagination?: boolean;
|
|
2306
2393
|
density?: TableDensity;
|
|
2307
|
-
|
|
2394
|
+
tableStyle?: TableStylePreferences;
|
|
2395
|
+
};
|
|
2396
|
+
|
|
2397
|
+
declare type TableStylePreferences = {
|
|
2398
|
+
headerStyle?: TableHeaderStyle;
|
|
2399
|
+
headerBackgroundColor?: string;
|
|
2400
|
+
headerTextColor?: string;
|
|
2401
|
+
stripedRows?: boolean;
|
|
2402
|
+
gridLines?: TableGridLines;
|
|
2403
|
+
wrapText?: boolean;
|
|
2404
|
+
totals?: TableTotalsStylePreferences;
|
|
2405
|
+
};
|
|
2406
|
+
|
|
2407
|
+
declare type TableTotalsFontWeight = 'normal' | 'medium' | 'semibold' | 'bold';
|
|
2408
|
+
|
|
2409
|
+
declare type TableTotalsStylePreferences = {
|
|
2410
|
+
enabled?: boolean;
|
|
2411
|
+
backgroundColor?: string;
|
|
2412
|
+
textColor?: string;
|
|
2413
|
+
fontWeight?: TableTotalsFontWeight;
|
|
2414
|
+
borderTop?: boolean;
|
|
2415
|
+
borderTopStyle?: 'solid' | 'dashed' | 'dotted' | 'double';
|
|
2416
|
+
borderTopColor?: string;
|
|
2308
2417
|
};
|
|
2309
2418
|
|
|
2310
2419
|
/**
|
|
@@ -3265,18 +3374,7 @@ export declare type TokenSecurityPolicy = {
|
|
|
3265
3374
|
};
|
|
3266
3375
|
};
|
|
3267
3376
|
|
|
3268
|
-
/**
|
|
3269
|
-
* Per-column contribution to the table-level totals row (`<tfoot>`).
|
|
3270
|
-
* Additive and optional — omitting it keeps the cell empty in the footer,
|
|
3271
|
-
* matching existing behavior when a totals row is not needed.
|
|
3272
|
-
*
|
|
3273
|
-
* - 'sum' → aggregate the column across the full dataset
|
|
3274
|
-
* - 'avg' → arithmetic mean across the full dataset
|
|
3275
|
-
* - 'count' → non-null count across the full dataset
|
|
3276
|
-
* - 'label' → render `totalsLabel` (or 'Total') as static text — typically
|
|
3277
|
-
* on the first column so the footer reads as a labeled row
|
|
3278
|
-
* - 'none' → blank cell in the footer
|
|
3279
|
-
*/
|
|
3377
|
+
/** Historical per-column totals shape. Runtime totals are table-level now. */
|
|
3280
3378
|
declare type TotalsBehavior = 'sum' | 'avg' | 'count' | 'label' | 'none';
|
|
3281
3379
|
|
|
3282
3380
|
/** Point style options supported by Chart.js */
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"email": "support@semaphor.cloud"
|
|
6
6
|
},
|
|
7
7
|
"license": "MIT",
|
|
8
|
-
"version": "0.1.
|
|
8
|
+
"version": "0.1.307",
|
|
9
9
|
"description": "Fully interactive and customizable dashboards for your apps.",
|
|
10
10
|
"keywords": [
|
|
11
11
|
"react",
|
|
@@ -140,7 +140,7 @@
|
|
|
140
140
|
"culori": "^4.0.2",
|
|
141
141
|
"date-fns": "^3.6.0",
|
|
142
142
|
"date-fns-tz": "^3.2.0",
|
|
143
|
-
"dompurify": "^3.
|
|
143
|
+
"dompurify": "^3.4.2",
|
|
144
144
|
"fast-deep-equal": "^3.1.3",
|
|
145
145
|
"immer": "^10.0.3",
|
|
146
146
|
"jwt-decode": "^4.0.0",
|
|
@@ -183,7 +183,7 @@
|
|
|
183
183
|
"react-dom": "$react-dom"
|
|
184
184
|
},
|
|
185
185
|
"devDependencies": {
|
|
186
|
-
"@microsoft/api-extractor": "^7.
|
|
186
|
+
"@microsoft/api-extractor": "^7.58.7",
|
|
187
187
|
"@tanstack/react-query-devtools": "^5.62.15",
|
|
188
188
|
"@testing-library/jest-dom": "^6.9.1",
|
|
189
189
|
"@testing-library/react": "^16.3.0",
|
|
@@ -214,7 +214,7 @@
|
|
|
214
214
|
"eslint-plugin-react-refresh": "^0.4.5",
|
|
215
215
|
"jsdom": "^26.1.0",
|
|
216
216
|
"path": "^0.12.7",
|
|
217
|
-
"postcss": "^8.
|
|
217
|
+
"postcss": "^8.5.13",
|
|
218
218
|
"postcss-prefix-selector": "^2.1.0",
|
|
219
219
|
"postcss-preset-env": "^10.0.9",
|
|
220
220
|
"prettier-plugin-tailwindcss": "^0.6.1",
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),o=require("./switch-BH17qlxH.js"),s=require("./index-BOGpMmRo.js"),b=require("react");require("./index-DRlMUglg.js");require("react-dom");const G=require("./dashboard-filter-controls-button-CR0_duPw.js"),it=require("./index-D7KJindZ.js"),xs=require("./dashboard-summary-settings-dialog-DioOegLQ.js"),lt=require("./use-debounced-dirty-check-XHSwAefL.js"),Fe=require("./normalize-dashboard-for-dirty-check-BXRUMVb2.js"),gs=require("./use-create-flow-overlay-state-BSUi4chy.js"),bs=require("./save-CFBIhbHD.js"),vs=require("./palette-BqJlrRto.js");function ct(t){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(a,n,r.get?r:{enumerable:!0,get:()=>t[n]})}}return a.default=t,Object.freeze(a)}const I=ct(b);/**
|
|
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 dt=o.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 ut=o.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 mt=o.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 ht=o.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 pt=o.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 ft=o.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 Re={exports:{}},_e={};/**
|
|
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 ys;function xt(){if(ys)return _e;ys=1;var t=b;function a(x,p){return x===p&&(x!==0||1/x===1/p)||x!==x&&p!==p}var n=typeof Object.is=="function"?Object.is:a,r=t.useState,c=t.useEffect,m=t.useLayoutEffect,d=t.useDebugValue;function f(x,p){var u=p(),i=r({inst:{value:u,getSnapshot:p}}),y=i[0].inst,w=i[1];return m(function(){y.value=u,y.getSnapshot=p,g(y)&&w({inst:y})},[x,u,p]),c(function(){return g(y)&&w({inst:y}),x(function(){g(y)&&w({inst:y})})},[x]),d(u),u}function g(x){var p=x.getSnapshot;x=x.value;try{var u=p();return!n(x,u)}catch{return!0}}function v(x,p){return p()}var h=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?v:f;return _e.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:h,_e}var Ue={};/**
|
|
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 Ss;function gt(){return Ss||(Ss=1,process.env.NODE_ENV!=="production"&&function(){function t(u,i){return u===i&&(u!==0||1/u===1/i)||u!==u&&i!==i}function a(u,i){h||c.startTransition===void 0||(h=!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 y=i();if(!x){var w=i();m(y,w)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),x=!0)}w=d({inst:{value:y,getSnapshot:i}});var D=w[0].inst,C=w[1];return g(function(){D.value=y,D.getSnapshot=i,n(D)&&C({inst:D})},[u,y,i]),f(function(){return n(D)&&C({inst:D}),u(function(){n(D)&&C({inst:D})})},[u]),v(y),y}function n(u){var i=u.getSnapshot;u=u.value;try{var y=i();return!m(u,y)}catch{return!0}}function r(u,i){return i()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var c=b,m=typeof Object.is=="function"?Object.is:t,d=c.useState,f=c.useEffect,g=c.useLayoutEffect,v=c.useDebugValue,h=!1,x=!1,p=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?r:a;Ue.useSyncExternalStore=c.useSyncExternalStore!==void 0?c.useSyncExternalStore:p,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()),Ue}process.env.NODE_ENV==="production"?Re.exports=xt():Re.exports=gt();var bt=Re.exports;const je=["light","dark","system"];function vt(){const{theme:t,setTheme:a}=s.useTheme(),n=o.useDashboardStore(d=>d.actions.setDashboardTheme);function r(){const d=je.includes(t)?t:"system",f=je[(je.indexOf(d)+1)%je.length];a(f),n(f)}const c=t==="light"?ft:t==="dark"?ht:mt,m=t==="light"?"Theme: light (click for dark)":t==="dark"?"Theme: dark (click for system)":"Theme: system (click for light)";return e.jsx(o.Button,{type:"button",variant:"ghost",size:"xs",className:"h-7 w-7 p-0 text-muted-foreground hover:text-foreground",onClick:r,"aria-label":m,title:m,children:e.jsx(c,{className:"h-3.5 w-3.5",strokeWidth:1.5})})}async function yt(t,a,n,r,c){if(!c)return null;const m=JSON.stringify(n),d=`${t}/v1/lens`;return await o.postRequest(d,c,{name:a,template:m,filterValues:r,operation:"create"})}async function qe(t,a,n){if(!n)return null;const{id:r,template:c,filterValues:m,isDefault:d,shared:f}=a,g=`${t}/v1/lens`;return await o.postRequest(g,n,{lensId:r,template:c,filterValues:m,isDefault:d,shared:f,operation:"update"})}async function St(t,a,n){if(!n)return null;const r=`${t}/v1/lens`;return await o.postRequest(r,n,{operation:"delete",lensId:a})}const jt="text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground";function Dt({open:t,onOpenChange:a}={}){const[n,r]=b.useState(""),[c,m]=b.useState(!1),d=o.useDashboardStore(M=>M.lenses),{setLenses:f,setSelectedLensId:g}=o.useDashboardActions(),[v,h]=b.useState(!1),[x,p]=b.useState(!1),u=t!==void 0,i=u?t:x,y=M=>{u||p(M),a==null||a(M)},w=o.useDashboardStore(M=>M.dashboard),D=o.useDashboardStore(M=>M.filterValues),{authToken:C,tokenProps:N}=s.useSemaphorContext();async function E(){h(!0);const M=await yt(N.apiServiceUrl,n,w,D,C==null?void 0:C.accessToken);M&&(f([...d||[],M]),g(M.id),y(!1)),h(!1)}return e.jsxs(s.Dialog,{open:i,onOpenChange:y,children:[u?null:e.jsx(s.DialogTrigger,{asChild:!0,children:e.jsxs(o.Button,{variant:"secondary",size:"xs",children:[e.jsx(s.Plus,{className:"h-3.5 w-3.5"}),"Lens"]})}),e.jsxs(s.DialogContent,{className:"rounded-control border-border/60 sm:max-w-[420px] sm:rounded-control",children:[e.jsxs(s.DialogHeader,{children:[e.jsx(s.DialogTitle,{className:"text-[15px]",children:"Create lens"}),e.jsx(s.DialogDescription,{className:"text-[13px] leading-5",children:"Lenses are private by default and are only visible to you."})]}),e.jsxs("div",{className:"space-y-1.5 py-1",children:[e.jsx(o.Label,{htmlFor:"lens-name",className:jt,children:"Name"}),e.jsx(o.Input,{id:"lens-name",size:"xs",value:n,placeholder:"Monthly review, West region, …",onChange:M=>r(M.target.value)}),c&&e.jsx("p",{className:"text-[12px] text-destructive",children:"A lens with this name already exists. Pick a different one."})]}),e.jsxs(s.DialogFooter,{children:[e.jsx(o.Button,{variant:"outline",size:"xs",onClick:()=>y(!1),children:"Cancel"}),e.jsx(o.Button,{size:"xs",type:"submit",onClick:E,disabled:v||!n.trim(),children:v?"Creating…":"Create"})]})]})]})}function wt({includeLabel:t=!1}={}){const a=o.useDashboardStore(h=>h.lenses),n=o.useDashboardStore(h=>h.selectedLensId),{setLenses:r,setSelectedLensId:c}=o.useDashboardActions(),{authToken:m,tokenProps:d}=s.useSemaphorContext();async function f(h){c(h)}async function g(h){if(await St(d.apiServiceUrl,h,m==null?void 0:m.accessToken)){const p=a==null?void 0:a.filter(u=>u.id!==h);r(p||[]),c("original")}}async function v(h){const x=a==null?void 0:a.map(i=>i.id===h.id?{...i,isDefault:!h.isDefault}:{...i,isDefault:!1});r(x||[]);const p={...h,isDefault:!h.isDefault};await qe(d.apiServiceUrl,p,m==null?void 0:m.accessToken);const u=a==null?void 0:a.find(i=>i.isDefault);if(u&&u.id!==h.id){const i={...u,isDefault:!1};await qe(d.apiServiceUrl,i,m==null?void 0:m.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:n,onValueChange:f,children:[e.jsx(s.DropdownMenuRadioItem,{value:"original",children:"Original"}),a==null?void 0:a.map(h=>e.jsxs(s.DropdownMenuRadioItem,{className:"group flex justify-between gap-2",value:h.id,children:[e.jsx("p",{children:h.name}),e.jsxs("span",{className:"flex items-center gap-3",children:[e.jsx(s.House,{onClick:x=>{x.preventDefault(),v(h)},className:o.cn("size-3.5 text-muted-foreground hover:cursor-pointer hover:text-foreground group-hover:visible",{invisible:!h.isDefault,"text-green-500":h.isDefault}),strokeWidth:1.5}),e.jsx(s.Cross2Icon,{onClick:x=>{x.preventDefault(),g(h.id)},className:"invisible size-3.5 text-muted-foreground hover:cursor-pointer hover:text-foreground group-hover:visible",strokeWidth:1.5})]})]},h.id))]})]})}function Ct(){const{displayPreferences:t,shouldShowElement:a}=s.useDisplayPreferences(),{currentUser:n,userContext:r}=s.useCurrentUserInfo(),c=b.useMemo(()=>s.getRoleBasedDisplayOverrides(n),[n]),m=b.useMemo(()=>f=>c&&c[f]!==void 0&&c[f]===!1?!1:a(f),[c,a,t]),d=b.useMemo(()=>{var f,g,v,h,x;return{canEdit:((f=r==null?void 0:r.permissions)==null?void 0:f.canEdit)??s.canUserEdit(n),canUseFilters:((g=r==null?void 0:r.permissions)==null?void 0:g.canEdit)??s.canUserUseFilters(n),canManageDashboards:((v=r==null?void 0:r.permissions)==null?void 0:v.canCreateDashboard)??s.canUserManageDashboards(n),canCreateDashboards:((h=r==null?void 0:r.permissions)==null?void 0:h.canCreateDashboard)??s.canUserCreateDashboards(n),canAccessVisuals:((x=r==null?void 0:r.permissions)==null?void 0:x.canEdit)??s.canUserAccessVisuals(n)}},[n,r]);return{displayPreferences:t,shouldShowElement:m,permissions:d,currentUser:n}}const Nt=async(t,a,n)=>{const r=`${t}/management/v1/groups`;return await o.postRequestRegular(r,a,n)},Mt=async(t,a,n)=>{const r=`${t}/management/v1/groups/${n}`;await o.requestJsonRegular(r,a,"DELETE")},It=async(t,a,n,r)=>{const c=`${t}/management/v1/groups/${n}/members`;return await o.postRequestRegular(c,a,r)},Et=async(t,a,n,r)=>{const c=`${t}/management/v1/groups/${n}/members`;await o.requestJsonRegular(c,a,"DELETE",r)};function Lt(){const{authToken:t,tokenProps:a}=s.useSemaphorContext(),n=s.useQueryClient();return s.useMutation({mutationFn:r=>Nt(a.apiServiceUrl,(t==null?void 0:t.accessToken)||"",r),onSuccess:()=>{n.invalidateQueries({queryKey:["groups"]}),s.ue.success("Group created successfully")},onError:r=>{console.error("Failed to create group:",r),s.ue.error("Failed to create group",{description:o.getRequestErrorMessage(r,"Failed to create group")})}})}function At(){const{authToken:t,tokenProps:a}=s.useSemaphorContext(),n=s.useQueryClient();return s.useMutation({mutationFn:r=>Mt(a.apiServiceUrl,(t==null?void 0:t.accessToken)||"",r),onSuccess:(r,c)=>{n.invalidateQueries({queryKey:["groups"]}),n.removeQueries({queryKey:["group",c]}),s.ue.success("Group deleted successfully")},onError:r=>{console.error("Failed to delete group:",r),s.ue.error("Failed to delete group",{description:o.getRequestErrorMessage(r,"Failed to delete group")})}})}function Ot(){const{authToken:t,tokenProps:a}=s.useSemaphorContext(),n=s.useQueryClient();return s.useMutation({mutationFn:({groupId:r,data:c})=>It(a.apiServiceUrl,(t==null?void 0:t.accessToken)||"",r,c),onSuccess:(r,c)=>{n.invalidateQueries({queryKey:["group",c.groupId]}),n.invalidateQueries({queryKey:["group-members",c.groupId]}),n.invalidateQueries({queryKey:["groups"]}),s.ue.success("Members added successfully")},onError:r=>{console.error("Failed to add group members:",r),s.ue.error("Failed to add members",{description:o.getRequestErrorMessage(r,"Failed to add members")})}})}function kt(){const{authToken:t,tokenProps:a}=s.useSemaphorContext(),n=s.useQueryClient();return s.useMutation({mutationFn:({groupId:r,data:c})=>Et(a.apiServiceUrl,(t==null?void 0:t.accessToken)||"",r,c),onSuccess:(r,c)=>{n.invalidateQueries({queryKey:["group",c.groupId]}),n.invalidateQueries({queryKey:["group-members",c.groupId]}),n.invalidateQueries({queryKey:["groups"]}),s.ue.success("Members removed successfully")},onError:r=>{console.error("Failed to remove group members:",r),s.ue.error("Failed to remove members",{description:o.getRequestErrorMessage(r,"Failed to remove members")})}})}const js="text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground";function Tt({onSuccess:t,tenantId:a,isTenantUser:n}){const[r,c]=b.useState(""),[m,d]=b.useState(""),[f,g]=b.useState({}),v=Lt(),h=()=>{const p={};return r.trim()?r.length<3?p.name="Group name must be at least 3 characters":r.length>50&&(p.name="Group name must be less than 50 characters"):p.name="Group name is required",m&&m.length>200&&(p.description="Description must be less than 200 characters"),g(p),Object.keys(p).length===0},x=async p=>{if(p.preventDefault(),!h())return;const u={name:r.trim(),description:m.trim()||void 0,type:n?"TENANT_GROUP":"ORG_GROUP",...n&&a?{tenantId:a}:{}};try{await v.mutateAsync(u),c(""),d(""),g({}),t()}catch(i){console.error("Failed to create group:",i)}};return e.jsxs("form",{onSubmit:x,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(o.Label,{htmlFor:"group-name",className:js,children:["Group name ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(o.Input,{id:"group-name",size:"xs",placeholder:"e.g., Marketing Team, Engineering Squad",value:r,onChange:p=>{c(p.target.value),f.name&&g(u=>({...u,name:""}))},className:f.name?"border-destructive":"",disabled:v.isPending}),f.name&&e.jsx("p",{className:"text-[12px] text-destructive",children:f.name})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(o.Label,{htmlFor:"group-description",className:js,children:"Description (optional)"}),e.jsx(s.Textarea,{id:"group-description",placeholder:"Describe the purpose of this group…",value:m,onChange:p=>{d(p.target.value),f.description&&g(u=>({...u,description:""}))},className:`text-[13px] ${f.description?"border-destructive":""}`,disabled:v.isPending,rows:3}),f.description?e.jsx("p",{className:"text-[12px] text-destructive",children:f.description}):e.jsxs("p",{className:"text-[11px] text-muted-foreground",children:[m.length,"/200"]})]}),e.jsxs("div",{className:"flex gap-2 text-[12px] text-muted-foreground",children:[e.jsx(o.Info,{className:"h-3.5 w-3.5 shrink-0 mt-0.5"}),e.jsx("p",{children:"This group will be accessible to users in your workspace. You can add members after creating it."})]}),e.jsxs("div",{className:"flex justify-end gap-1.5 pt-1",children:[e.jsx(o.Button,{type:"button",variant:"outline",size:"xs",onClick:()=>{c(""),d(""),g({})},disabled:v.isPending,children:"Clear"}),e.jsx(o.Button,{type:"submit",size:"xs",disabled:v.isPending||!r.trim(),children:v.isPending?e.jsxs(e.Fragment,{children:[e.jsx(o.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}),"Creating…"]}):"Create group"})]})]})}function Pt(t,a=[]){let n=[];function r(m,d){const f=I.createContext(d);f.displayName=m+"Context";const g=n.length;n=[...n,d];const v=x=>{var D;const{scope:p,children:u,...i}=x,y=((D=p==null?void 0:p[t])==null?void 0:D[g])||f,w=I.useMemo(()=>i,Object.values(i));return e.jsx(y.Provider,{value:w,children:u})};v.displayName=m+"Provider";function h(x,p){var y;const u=((y=p==null?void 0:p[t])==null?void 0:y[g])||f,i=I.useContext(u);if(i)return i;if(d!==void 0)return d;throw new Error(`\`${x}\` must be used within \`${m}\``)}return[v,h]}const c=()=>{const m=n.map(d=>I.createContext(d));return function(f){const g=(f==null?void 0:f[t])||m;return I.useMemo(()=>({[`__scope${t}`]:{...f,[t]:g}}),[f,g])}};return c.scopeName=t,[r,Ft(c,...a)]}function Ft(...t){const a=t[0];if(t.length===1)return a;const n=()=>{const r=t.map(c=>({useScope:c(),scopeName:c.scopeName}));return function(m){const d=r.reduce((f,{useScope:g,scopeName:v})=>{const x=g(m)[`__scope${v}`];return{...f,...x}},{});return I.useMemo(()=>({[`__scope${a.scopeName}`]:d}),[d])}};return n.scopeName=a.scopeName,n}var _t=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ge=_t.reduce((t,a)=>{const n=o.createSlot(`Primitive.${a}`),r=I.forwardRef((c,m)=>{const{asChild:d,...f}=c,g=d?n:a;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(g,{...f,ref:m})});return r.displayName=`Primitive.${a}`,{...t,[a]:r}},{});function Ut(){return bt.useSyncExternalStore(Rt,()=>!0,()=>!1)}function Rt(){return()=>{}}var $e="Avatar",[qt]=Pt($e),[Gt,Cs]=qt($e),Ns=I.forwardRef((t,a)=>{const{__scopeAvatar:n,...r}=t,[c,m]=I.useState("idle");return e.jsx(Gt,{scope:n,imageLoadingStatus:c,onImageLoadingStatusChange:m,children:e.jsx(Ge.span,{...r,ref:a})})});Ns.displayName=$e;var Ms="AvatarImage",Is=I.forwardRef((t,a)=>{const{__scopeAvatar:n,src:r,onLoadingStatusChange:c=()=>{},...m}=t,d=Cs(Ms,n),f=$t(r,m),g=o.useCallbackRef(v=>{c(v),d.onImageLoadingStatusChange(v)});return o.useLayoutEffect2(()=>{f!=="idle"&&g(f)},[f,g]),f==="loaded"?e.jsx(Ge.img,{...m,ref:a,src:r}):null});Is.displayName=Ms;var Es="AvatarFallback",Ls=I.forwardRef((t,a)=>{const{__scopeAvatar:n,delayMs:r,...c}=t,m=Cs(Es,n),[d,f]=I.useState(r===void 0);return I.useEffect(()=>{if(r!==void 0){const g=window.setTimeout(()=>f(!0),r);return()=>window.clearTimeout(g)}},[r]),d&&m.imageLoadingStatus!=="loaded"?e.jsx(Ge.span,{...c,ref:a}):null});Ls.displayName=Es;function Ds(t,a){return t?a?(t.src!==a&&(t.src=a),t.complete&&t.naturalWidth>0?"loaded":"loading"):"error":"idle"}function $t(t,{referrerPolicy:a,crossOrigin:n}){const r=Ut(),c=I.useRef(null),m=r?(c.current||(c.current=new window.Image),c.current):null,[d,f]=I.useState(()=>Ds(m,t));return o.useLayoutEffect2(()=>{f(Ds(m,t))},[m,t]),o.useLayoutEffect2(()=>{const g=x=>()=>{f(x)};if(!m)return;const v=g("loaded"),h=g("error");return m.addEventListener("load",v),m.addEventListener("error",h),a&&(m.referrerPolicy=a),typeof n=="string"&&(m.crossOrigin=n),()=>{m.removeEventListener("load",v),m.removeEventListener("error",h)}},[m,n,a]),d}var As=Ns,Os=Is,ks=Ls;const Be=I.forwardRef(({className:t,...a},n)=>e.jsx(As,{ref:n,className:o.cn("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",t),...a}));Be.displayName=As.displayName;const Bt=I.forwardRef(({className:t,...a},n)=>e.jsx(Os,{ref:n,className:o.cn("aspect-square h-full w-full",t),...a}));Bt.displayName=Os.displayName;const ze=I.forwardRef(({className:t,...a},n)=>e.jsx(ks,{ref:n,className:o.cn("flex h-full w-full items-center justify-center rounded-full bg-muted",t),...a}));ze.displayName=ks.displayName;function zt({open:t,onOpenChange:a,group:n,onUpdate:r}){const[c,m]=b.useState("members"),[d,f]=b.useState(""),[g,v]=b.useState([]),[h,x]=b.useState([]),{data:p,isLoading:u,refetch:i}=s.useGroupMembers(n.id),y=n.type==="TENANT_GROUP"?"tenant":"organization",{users:w,isLoading:D}=s.useUnifiedUsers({type:y,tenantId:n.tenantId||void 0,active:!0,limit:100}),C=Ot(),N=kt(),E=(p==null?void 0:p.members)||[],M=b.useMemo(()=>new Set(E.map(S=>S.userId)),[E]),P=b.useMemo(()=>w.filter(S=>!M.has(S.id)),[w,M]),_=b.useMemo(()=>{if(!d)return P;const S=d.toLowerCase();return P.filter(L=>{var F,q;return((F=L.name)==null?void 0:F.toLowerCase().includes(S))||((q=L.email)==null?void 0:q.toLowerCase().includes(S))})},[P,d]),j=b.useMemo(()=>{if(!d)return E;const S=d.toLowerCase();return E.filter(L=>{var F,q,te,K;return((q=(F=L.user)==null?void 0:F.name)==null?void 0:q.toLowerCase().includes(S))||((K=(te=L.user)==null?void 0:te.email)==null?void 0:K.toLowerCase().includes(S))})},[E,d]),R=async()=>{if(g.length!==0)try{await C.mutateAsync({groupId:n.id,data:{userIds:g,userType:y==="tenant"?"tenant":"org"}}),v([]),m("members"),i(),r==null||r()}catch(S){console.error("Failed to add members:",S)}},B=async()=>{if(h.length!==0)try{await N.mutateAsync({groupId:n.id,data:{userIds:h}}),x([]),i(),r==null||r()}catch(S){console.error("Failed to remove members:",S)}},V=S=>{v(L=>L.includes(S)?L.filter(F=>F!==S):[...L,S])},H=S=>{x(L=>L.includes(S)?L.filter(F=>F!==S):[...L,S])};return e.jsx(e.Fragment,{children:e.jsx(s.Dialog,{open:t,onOpenChange:a,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:n.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 ",n.name," group"]})]}),e.jsxs(o.Tabs,{value:c,onValueChange:S=>{m(S),f(""),x([])},className:"mt-4",children:[e.jsxs(o.TabsList,{className:"grid w-full grid-cols-2",children:[e.jsx(o.TabsTrigger,{value:"members",children:"Current Members"}),e.jsx(o.TabsTrigger,{value:"add",children:"Add Members"})]}),e.jsxs(o.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(o.Input,{placeholder:"Search members...",value:d,onChange:S=>f(S.target.value),className:"pl-10"})]}),e.jsx(o.ScrollArea,{className:h.length>0?"h-[300px]":"h-[350px]",children:u?e.jsx("div",{className:"space-y-2",children:[1,2,3].map(S=>e.jsx(s.Skeleton,{className:"h-16 w-full"},S))}):j.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:d?"No members found":"No members yet"}),e.jsx("p",{className:"text-xs mt-1",children:d?"Try a different search":'Switch to the "Add Members" tab to add people to this group'})]}):e.jsx("div",{className:"space-y-2",children:j.map(S=>e.jsx(Vt,{member:S,selected:h.includes(S.userId),onToggle:()=>H(S.userId)},S.id))})}),h.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:[h.length," member",h.length!==1?"s":""," selected"]}),e.jsx(o.Button,{variant:"destructive",size:"sm",onClick:B,disabled:N.isPending,children:N.isPending?e.jsxs(e.Fragment,{children:[e.jsx(o.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(o.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(o.Input,{placeholder:"Search users to add...",value:d,onChange:S=>f(S.target.value),className:"pl-10"})]}),e.jsx(o.ScrollArea,{className:"h-[300px]",children:D?e.jsx("div",{className:"space-y-2",children:[1,2,3].map(S=>e.jsx(s.Skeleton,{className:"h-16 w-full"},S))}):_.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:d?"Try a different search":"All eligible users are already members"})]}):e.jsx("div",{className:"space-y-2",children:_.map(S=>e.jsx(Ht,{user:S,selected:g.includes(S.id),onToggle:()=>V(S.id)},S.id))})}),g.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:[g.length," user",g.length!==1?"s":""," selected"]}),e.jsx(o.Button,{onClick:R,disabled:C.isPending,children:C.isPending?e.jsxs(e.Fragment,{children:[e.jsx(o.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 Vt({member:t,selected:a,onToggle:n}){var c,m,d,f;const r=((m=(c=t.user)==null?void 0:c.name)==null?void 0:m.split(" ").map(g=>g[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:n,children:[e.jsx(s.Checkbox,{checked:a}),e.jsx(Be,{className:"h-8 w-8",children:e.jsx(ze,{className:"text-xs",children:r})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium",children:((d=t.user)==null?void 0:d.name)||"Unknown User"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(f=t.user)==null?void 0:f.email})]})]})}function Ht({user:t,selected:a,onToggle:n}){var c;const r=((c=t.name)==null?void 0:c.split(" ").map(m=>m[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:n,children:[e.jsx(s.Checkbox,{checked:a}),e.jsx(Be,{className:"h-8 w-8",children:e.jsx(ze,{className:"text-xs",children:r})}),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 Kt({open:t,onOpenChange:a}){const[n,r]=b.useState("groups"),[c,m]=b.useState(""),[d,f]=b.useState(null),[g,v]=b.useState(!1),[h,x]=b.useState(null),{tokenProps:p}=s.useSemaphorContext(),{currentUser:u}=s.useCurrentUserInfo(),i=At(),y=(u==null?void 0:u.type)==="tenant",w=p==null?void 0:p.tenantId,{groups:D,isLoading:C,refetch:N}=s.useGroups({type:y?"TENANT_GROUP":"all",tenantId:y?w:void 0,includeMembers:!1}),E=D.filter(j=>{var R;return j.name.toLowerCase().includes(c.toLowerCase())||((R=j.description)==null?void 0:R.toLowerCase().includes(c.toLowerCase()))}),M=async()=>{if(h)try{await i.mutateAsync(h.id),x(null),N()}catch(j){console.error("Failed to delete group:",j)}},P=j=>{f(j),v(!0)},_=()=>{r("groups"),N()};return e.jsxs(e.Fragment,{children:[e.jsx(s.Dialog,{open:t,onOpenChange:a,children:e.jsxs(s.DialogContent,{className:"max-h-[80vh] max-w-3xl rounded-[6px] border-border/60 sm:rounded-[6px]",children:[e.jsxs(s.DialogHeader,{children:[e.jsx(s.DialogTitle,{className:"text-[15px]",children:"Group management"}),e.jsx(s.DialogDescription,{className:"text-[13px] leading-5",children:"Manage groups, create new ones, and control membership."})]}),e.jsxs(o.Tabs,{value:n,onValueChange:r,className:"mt-2",children:[e.jsxs(o.TabsList,{className:"h-8 w-full justify-start gap-1 bg-transparent p-0 border-b border-border/60 rounded-none",children:[e.jsx(o.TabsTrigger,{value:"groups",className:"h-8 rounded-none border-b-2 border-transparent bg-transparent px-3 text-[13px] data-[state=active]:border-foreground data-[state=active]:bg-transparent data-[state=active]:shadow-none",children:"Groups"}),e.jsx(o.TabsTrigger,{value:"create",className:"h-8 rounded-none border-b-2 border-transparent bg-transparent px-3 text-[13px] data-[state=active]:border-foreground data-[state=active]:bg-transparent data-[state=active]:shadow-none",children:"Create group"})]}),e.jsx(o.TabsContent,{value:"groups",className:"mt-4",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(s.Search,{className:"absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground"}),e.jsx(o.Input,{size:"xs",placeholder:"Search groups…",value:c,onChange:j=>m(j.target.value),className:"pl-7"})]}),e.jsx(o.ScrollArea,{className:"h-[400px]",children:C?e.jsx("div",{className:"space-y-2",children:[1,2,3].map(j=>e.jsx(s.Skeleton,{className:"h-16 w-full rounded-[6px]"},j))}):E.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[e.jsx("p",{className:"text-[13px]",children:"No groups found."}),e.jsx("p",{className:"mt-1 text-[12px]",children:c?"Try a different search.":"Create your first group to get started."})]}):e.jsx("div",{className:"space-y-2 pr-2",children:E.map(j=>e.jsx(Qt,{group:j,onManageMembers:()=>P(j),onDelete:()=>x(j),currentUserId:u==null?void 0:u.id},j.id))})})]})}),e.jsx(o.TabsContent,{value:"create",className:"mt-4",children:e.jsx(Tt,{onSuccess:_,tenantId:w,isTenantUser:y})})]})]})}),d&&e.jsx(zt,{open:g,onOpenChange:v,group:d,onUpdate:()=>N()}),e.jsx(s.AlertDialog,{open:!!h,onOpenChange:()=>x(null),children:e.jsxs(s.AlertDialogContent,{children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsx(s.AlertDialogTitle,{children:"Delete group"}),e.jsxs(s.AlertDialogDescription,{children:['Delete "',h==null?void 0:h.name,`"? This removes all members and can't be undone.`]})]}),e.jsxs(s.AlertDialogFooter,{children:[e.jsx(s.AlertDialogCancel,{children:"Cancel"}),e.jsx(s.AlertDialogAction,{onClick:M,disabled:i.isPending,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:i.isPending?e.jsxs(e.Fragment,{children:[e.jsx(o.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}),"Deleting…"]}):"Delete group"})]})]})})]})}function Qt({group:t,onManageMembers:a,onDelete:n,currentUserId:r}){const c=t.createdBy===r;return e.jsx("div",{className:"rounded-[6px] border border-border/60 bg-card px-3 py-2.5 transition-colors hover:bg-muted/30",children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[e.jsx("h4",{className:"text-[13px] font-medium text-foreground",children:t.name}),t.description&&e.jsx("p",{className:"text-[12px] text-muted-foreground",children:t.description}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3 text-[11px] text-muted-foreground",children:[e.jsxs("span",{className:"inline-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 ",it.format(new Date(t.createdAt),"MMM d, yyyy")]})]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[e.jsx(o.Button,{variant:"ghost",size:"xs",className:"h-7 w-7 p-0 text-muted-foreground hover:text-foreground",onClick:a,title:"Manage members","aria-label":"Manage members",children:e.jsx(s.UserPlus,{className:"h-3.5 w-3.5"})}),c&&e.jsx(o.Button,{variant:"ghost",size:"xs",className:"h-7 w-7 p-0 text-muted-foreground hover:bg-destructive/10 hover:text-destructive",onClick:n,title:"Delete group","aria-label":"Delete group",children:e.jsx(s.Trash2,{className:"h-3.5 w-3.5"})})]})]})})}function ee(t,a,n){var m,d;const r=(t.controls||[]).find(f=>f.id===n);if(r)return r.label;const c=(d=(m=o.findCardById(t,a))==null?void 0:m.controls)==null?void 0:d.find(f=>f.id===n);return(c==null?void 0:c.label)||n}function se(t,a){var n;return((n=o.findCardById(t,a))==null?void 0:n.title)||a}function Wt(t){const{errors:a,dashboard:n}=t;if(!n)return a;const r=new Map;for(const c of a){const m=c.match(/^Card '(.+)' binding for control '(.+)' maps to missing metric '(.+)'\.$/);if(m){const[,h,x]=m,p=`${h}:${x}:missing-metric`;r.has(p)||r.set(p,`"${se(n,h)}" has an outdated "${ee(n,h,x)}" mapping. Some choices still point to metrics that are no longer available on this card. Open the card controls and choose replacements.`);continue}const d=c.match(/^Card '(.+)' binding for control '(.+)' maps to missing group-by field '(.+)'\.$/);if(d){const[,h,x]=d,p=`${h}:${x}:missing-group-by`;r.has(p)||r.set(p,`"${se(n,h)}" has an outdated "${ee(n,h,x)}" mapping. Some choices still point to fields that are no longer available on this card. Open the card controls and choose replacements.`);continue}const f=c.match(/^Card '(.+)' binding for control '(.+)' maps to an invalid metric target\.$/);if(f){const[,h,x]=f,p=`${h}:${x}:invalid-metric`;r.has(p)||r.set(p,`"${se(n,h)}" has an invalid "${ee(n,h,x)}" metric mapping. Open the card controls and choose a valid metric for each option.`);continue}const g=c.match(/^Card '(.+)' binding for control '(.+)' maps to an invalid group-by target\.$/);if(g){const[,h,x]=g,p=`${h}:${x}:invalid-group-by`;r.has(p)||r.set(p,`"${se(n,h)}" has an invalid "${ee(n,h,x)}" field mapping. Open the card controls and choose a valid field for each option.`);continue}const v=c.match(/^Card '(.+)' binding for control '(.+)' requires at least one temporal group-by field\.$/);if(v){const[,h,x]=v,p=`${h}:${x}:missing-temporal-group-by`;r.has(p)||r.set(p,`"${se(n,h)}" can no longer use "${ee(n,h,x)}" for time grain because the card does not currently group by a date field.`);continue}r.set(c,c)}return Array.from(r.values())}const Jt=["enum","multi_enum","text","number","boolean","date"];function Yt({open:t,onOpenChange:a,initialMode:n="manage"}){var _;const r=n==="create",{forceClose:c,handleOpenChange:m,isCreateFlowActive:d,preventPassiveDismissDuringCreate:f,resolvedOpen:g,setIsCreateFlowActive:v}=gs.useCreateFlowOverlayState({open:t,onOpenChange:a,initialCreateFlowActive:n==="create",dismissMode:"explicit-only"}),h=o.useDashboardStore(j=>j.dashboard),x=o.useDashboardStore(j=>j.selectedSheetId),{setDashboardInputs:p}=o.useDashboardActions(),u=(_=h.sheets)==null?void 0:_.find(j=>j.id===x),i=(u==null?void 0:u.kind)==="document"&&!!u.document,y=b.useMemo(()=>i&&(u!=null&&u.document)?s.getDocumentSheetDashboardInputs(h,u.id):[],[h,i,u==null?void 0:u.document,u==null?void 0:u.id]),w=b.useMemo(()=>y.filter(j=>j.kind==="control"),[y]),D=b.useMemo(()=>w.map(j=>j.control),[w]),C=b.useMemo(()=>Zt(D),[D]),N=b.useMemo(()=>Xt(h),[h]),E=b.useCallback(()=>{if(r){c();return}v(!1)},[r,c,v]),M=b.useCallback((j,R,B)=>{!i||!(u!=null&&u.document)||p(sa({allInputs:h.inputs||[],documentSheetId:u.id,currentDocumentInputs:y,nextControls:j,nextDefaultValues:R,change:B}))},[h.inputs,y,i,u,p]);if(!i||!(u!=null&&u.document))return null;const P=d?"Add document control":"Document Controls";return e.jsx(s.Dialog,{open:g,onOpenChange:m,children:e.jsxs(s.DialogContent,{className:"flex max-h-[88vh] flex-col overflow-hidden sm:max-w-[600px]",onEscapeKeyDown:f,onPointerDownOutside:f,children:[e.jsxs(s.DialogHeader,{className:d?"space-y-0":void 0,children:[e.jsx(s.DialogTitle,{className:"text-[15px]",children:P}),e.jsx(s.DialogDescription,{className:d?"sr-only":"text-[13px]",children:d?"Configure and add a document-local control input.":"Add document-local control inputs. They are stored on this document sheet and are not dashboard controls."})]}),e.jsx("div",{className:"min-h-0 overflow-y-auto pr-1",children:e.jsx(gs.ControlDefinitionListEditor,{scope:"dashboard",controls:D,reservedControlIds:N,defaultValues:C,usageByControlId:{},availableFieldChoices:[],availableMetricChoices:[],structuralParticipants:[],structuralParticipantIdsByControlId:{},allowedControlTypes:Jt,initialCreateFlow:n==="create",onCreateFlowActiveChange:v,onCreateFlowComplete:E,onChange:M,emptyMessage:"No document controls yet."})})]})})}function Xt(t){return(t.controls||[]).map(a=>a.id)}function Zt(t){const a={};for(const n of t)n.defaultValue!==void 0&&(a[n.id]=n.defaultValue);return a}function ea(t,a){return a?Object.prototype.hasOwnProperty.call(a,t.id)?{...t,defaultValue:a[t.id]}:t.defaultValue===void 0?t:{...t,defaultValue:void 0}:t.defaultValue===void 0?t:{...t,defaultValue:void 0}}function sa({allInputs:t,documentSheetId:a,currentDocumentInputs:n,nextControls:r,nextDefaultValues:c,change:m}){const d=new Map(r.map(p=>[p.id,ea(p,c)])),f=(m==null?void 0:m.type)==="rename"?{oldId:m.oldId,newId:m.newId}:null,g=new Set,v=[];for(const p of n){if(p.kind!=="control"){v.push(p);continue}const u=d.get(p.control.id)||((f==null?void 0:f.oldId)===p.control.id?d.get(f.newId):void 0);if(!u)continue;g.add(u.id);const i=s.createUniqueDashboardInputVariableNameFromName(u.id,[...t,...v].filter(w=>w.id!==p.id)),y=u.id===i?u:{...u,id:i};v.push({...p,label:y.label,variableName:i,requiredAtExecution:y.requiredAtExecution,control:y})}for(const p of d.values())g.has(p.id)||v.push(s.createDashboardControlInputFromControl({control:p,existingInputs:[...t,...v],sheetId:a}));const h=new Set(n.map(p=>p.id));return[...t.filter(p=>!h.has(p.id)),...v]}function ws(t,a){return{dashboard:s.cloneDeep(t),semanticExecutionPayload:s.cloneDeep(a)}}function ta(){var cs,ds,us,ms,hs,ps;G.useExportRecovery(),G.useExportPolling();const{authToken:t,tokenProps:a,id:n}=s.useSemaphorContext(),{isLocalDev:r}=s.useDashboardPreferences(),{openBrandStudioPreview:c}=s.useBrandStudioPreview(),{permissions:m}=Ct(),d=s.useHasDashboardId(),{isLoading:f}=s.useDashboardQuery(),g=o.useDashboardStore(l=>l.theme),v=o.useDashboardStore(l=>l.isDownloadingPdf),h=o.useDashboardStore(l=>l.dashboardAssistantDraftScopeKey),x=o.useDashboardStore(l=>l.lenses),p=o.useDashboardStore(l=>l.selectedLensId),u=x==null?void 0:x.find(l=>l.id===p),i=o.useDashboardStore(l=>l.dashboard),y=o.useDashboardStore(l=>l.selectedSheetId),w=(cs=i==null?void 0:i.sheets)==null?void 0:cs.find(l=>l.id===y),D=o.isDocumentSheet(w),C=D?(ds=w==null?void 0:w.document)==null?void 0:ds.page:void 0,N=o.useDashboardStore(l=>l.isDashboardEditing),{setDashboardTitle:E}=o.useDashboardStore(l=>l.actions),[M,P]=b.useState(!1),[_,j]=b.useState(!1),[R,B]=b.useState(!1),[V,H]=b.useState(!1),[S,L]=b.useState(!1),[F,q]=b.useState(!1),[te,K]=b.useState(!1),[Ts,Ve]=b.useState(!1),[De,ae]=b.useState(null),[Ps,ne]=b.useState(!1),[re,oe]=b.useState(null),[He,ie]=b.useState([]),[Ke,le]=b.useState(!1),Fs=o.useDashboardStore(l=>l.isDashboardPanelOpen),_s=o.useDashboardStore(l=>l.actions.setIsDashboardPanelOpen),Us=o.useDashboardStore(l=>l.filterValues),O=o.useDashboardStore(l=>l.isVisualEditing);o.useEditorStore(l=>l.card);const Q=s.useManagementStore(l=>l.selectedDashboard),ce=s.useManagementStore(l=>l.initialDashboard);s.useManagementStore(l=>l.selectedVisual),o.useDashboardStore(l=>l.selectedFrameId),o.useEditorStore(l=>l.frame);const de=Q?(ms=Q==null?void 0:Q.permissions)==null?void 0:ms.canEdit:(us=ce==null?void 0:ce.permissions)==null?void 0:us.canEdit,ue=o.useDashboardStore(l=>l.showFilters),Qe=s.useAssistantLayoutStore(l=>l.setPanelOpen),We=o.useDashboardStore(l=>l.showDashboardJSON),we=o.useDashboardStore(l=>l.onSaveFunction),Je=o.useDashboardStore(l=>l.actions.setShowFilters),{setDocumentInspectorTab:Ye,setIsDashboardEditing:Xe,setShowDashboardJSON:Ze}=o.useDashboardStore(l=>l.actions),{setInitialDashboard:es,clearSelectedDashboard:Ce}=s.useManagementStore(l=>l.actions),{resources:me}=s.useResourceManagement(s.ResourceType.DASHBOARD),{data:Ne}=s.useUserPreferences(),Rs=((hs=Ne==null?void 0:Ne.preference)==null?void 0:hs.defaultDashboardId)||null,{mutate:qs,isPending:Gs}=s.useDefaultDashboardMutation(),{currentUser:$s}=s.useCurrentUserInfo(),Bs=s.canUserManageGroups($s),z=Q||ce,ss=z?{id:z.id,title:(i==null?void 0:i.title)||z.title||"Dashboard"}:null,{handleAddNewFrame:zs}=s.useAddNewFrame(),[Me,Ie]=b.useState(!1),[Vs,W]=b.useState(!1),[Ee,he]=b.useState("close"),J=s.useUpdateResource(s.ResourceType.DASHBOARD),[T,pe]=b.useState(null),ts=b.useCallback(l=>{window.setTimeout(()=>{ae(l)},0)},[]),Hs=async(l,A)=>{if(!(i!=null&&i.id)){console.log("No dashboard ID found");return}console.log("Updating dashboard title:",{dashboardId:i.id,newTitle:l,previousTitle:A}),J.mutate({resourceId:i.id,data:{title:l}},{onSuccess:()=>{console.log("Dashboard title updated successfully"),s.ue.success("Dashboard title updated")},onError:U=>{console.error("Failed to update dashboard title:",U),s.ue.error("Failed to update dashboard title"),E(A)}})};b.useEffect(()=>{if(me&&me.length>0){const l=i==null?void 0:i.id;if(l){const A=me.find(U=>U.id===l);A&&es(A)}}},[me,i==null?void 0:i.id,es]);const Y=a.orgUserId||a.tenantId,Le=b.useMemo(()=>aa({accessToken:t==null?void 0:t.accessToken,dashboardId:(i==null?void 0:i.id)||n||a.dashboard_id,selectedSheetId:D?y:void 0,pageSize:C==null?void 0:C.size,orientation:C==null?void 0:C.orientation,theme:g}),[t==null?void 0:t.accessToken,n,i==null?void 0:i.id,D,C==null?void 0:C.orientation,C==null?void 0:C.size,y,g,a.dashboard_id]),as=N&&!O&&Y&&de,{setDashboard:Ae}=o.useDashboardStore(l=>l.actions),Oe=o.useDashboardStore(l=>l.semanticExecutionPayload),Ks=()=>{Xe(!0)},ke=()=>{Xe(!1),Ze(!1),pe(null),ae(null)};b.useEffect(()=>{if(!N){T&&pe(null);return}T||!i||f||pe(ws(i,Oe))},[i,T,N,f,Oe]);const fe=(T==null?void 0:T.dashboard)??null,{isDirty:ns,isDirtyPending:Qs,resetDirty:xe}=lt.useDebouncedDirtyCheck(i,fe,300,1e3,Fe.serializeDashboardForDirtyCheck),rs=b.useCallback(()=>fe?Fe.serializeDashboardForDirtyCheck(i)!==Fe.serializeDashboardForDirtyCheck(fe):!1,[i,fe]),os=ns||Qs,ge=Me||J.isPending,Ws=()=>{rs()?(he("close"),W(!0)):(ke(),xe())},Js=async()=>{await Te({closeAfterSave:!0,navigateHomeAfterSave:Ee==="home"})},Ys=()=>{T&&Ae(T.dashboard,{semanticExecutionPayload:T.semanticExecutionPayload}),ke(),Ee==="home"&&Ce(),he("close"),W(!1),xe()},Xs=()=>{T&&(Ae(T.dashboard,{semanticExecutionPayload:T.semanticExecutionPayload}),xe())},Zs=()=>{if(N&&rs()){he("home"),W(!0);return}Ce()};async function Te(l){const A=o.useDashboardStore.getState().dashboard;if(!A)return;const U=(l==null?void 0:l.closeAfterSave)??Ke,nt=(l==null?void 0:l.navigateHomeAfterSave)??!1;le(U),U&&W(!1);const rt=s.cloneDeep(A);ne(!0),oe(null),ie([]),Ie(!0);const ot={template:A};J.mutate({resourceId:A.id,data:ot},{onSuccess:k=>{var ve,ye,fs;const $=(k==null?void 0:k.id)||((ve=k==null?void 0:k.dashboard)==null?void 0:ve.id)||((ye=k==null?void 0:k.resource)==null?void 0:ye.id)||((fs=k==null?void 0:k.template)==null?void 0:fs.id)||null;if(!A.id&&$){const Pe=o.useAIInteractionStore.getState(),Se=Pe.pendingDashboardDraftMigration;(Se==null?void 0:Se.scopeKey)===h?Pe.actions.setPendingDashboardDraftMigrationExpectedDashboardId($):Se&&Pe.actions.clearPendingDashboardDraftMigration()}Ie(!1),s.ue.success("Dashboard saved!"),pe(ws(rt,o.useDashboardStore.getState().semanticExecutionPayload)),ne(!1),le(!1),U&&(ke(),xe(),nt&&Ce()),he("close")},onError:k=>{Ie(!1),oe("Failed to save dashboard. Please try again.");const $=k.details,ve=Array.isArray($==null?void 0:$.errors)?($.errors||[]).filter(ye=>typeof ye=="string"):[];ie(Wt({errors:ve,dashboard:A||void 0})),s.ue.error("Failed to save dashboard")}})}async function et(){if(P(!0),!p||!u)return;const l=o.useDashboardStore.getState().dashboard;if(!l){P(!1);return}const A=JSON.stringify(l),U={...u,template:A,filterValues:Us};await qe(a.apiServiceUrl,U,t==null?void 0:t.accessToken),s.ue.success("Lens saved"),we==null||we(l),P(!1)}const is=(u==null?void 0:u.name)||i.title,X=!!(i!=null&&i.id);J.isPending&&console.log("Title during update:",{title:is,dashboardStateTitle:i.title,dashboardId:i==null?void 0:i.id,currentLensName:u==null?void 0:u.name});const ls=a.orgUserId||a.tenantId&&a.endUserId&&a.endUserEmail,st=!!ls&&!!(t!=null&&t.accessToken)&&!!(a!=null&&a.apiServiceUrl);b.useEffect(()=>{!X&&V&&H(!1)},[X,V]);const tt=d,Z=(i==null?void 0:i.id)||null,be=!!Z&&Rs===Z,at=()=>{Z&&qs({dashboardId:be?null:Z})};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:[ls&&e.jsxs(e.Fragment,{children:[e.jsx(s.IconButton,{"aria-label":"Manage Dashboards",tooltip:"Manage Dashboards",onClick:()=>{_s(!Fs)},className:"h-7 w-7 px-0",buttonProps:{size:"xs"},children:e.jsx(ut,{className:"h-3.5 w-3.5"})}),tt&&!O&&e.jsx(s.IconButton,{"aria-label":"Dashboard Hub",tooltip:"Dashboard Hub",onClick:Zs,className:"h-7 w-7 px-0",buttonProps:{size:"xs"},children:e.jsx(s.House,{className:"h-3.5 w-3.5"})})]}),!O&&d&&(f?e.jsx("div",{className:"h-4 w-28 animate-pulse rounded-md bg-muted/70","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:is||"Untitled Dashboard",onSave:l=>{console.log("EditableText onSave called:",{newTitle:l,canEditDashboard:de,dashboardId:i==null?void 0:i.id});const A=(i==null?void 0:i.title)||"";E(l),Hs(l,A)},isEditable:de&&!u,displayClassName:"text-[13px] font-medium",inputClassName:"text-[13px] font-medium",placeholder:"Dashboard Title",isPending:J.isPending}),st&&Z&&e.jsx(o.TooltipProvider,{children:e.jsxs(o.Tooltip,{children:[e.jsx(o.TooltipTrigger,{asChild:!0,children:e.jsx(o.Button,{variant:"ghost",size:"xs",onClick:at,disabled:Gs||!(t!=null&&t.accessToken)||!(a!=null&&a.apiServiceUrl),className:"w-7 px-0","aria-label":be?"Remove as default dashboard":"Make this a default dashboard",children:e.jsx(s.Star,{className:o.cn("h-3.5 w-3.5 transition-colors",be?"fill-foreground text-foreground":"text-muted-foreground hover:text-foreground")})})}),e.jsx(o.TooltipContent,{children:e.jsx("p",{children:be?"Remove as default dashboard":"Make this a default dashboard"})})]})})]}))]}),e.jsxs("div",{className:"flex items-center gap-2",children:[O&&e.jsxs(e.Fragment,{children:[e.jsx(G.AdvancedModeToggle,{}),e.jsx(G.VisualEditingControls,{})]}),!O&&d&&((ps=z==null?void 0:z.permissions)==null?void 0:ps.canShare)&&e.jsxs(o.Button,{variant:"outline",size:"xs",onClick:()=>j(!0),children:[e.jsx(s.Share2,{className:"h-3.5 w-3.5"}),"Share"]}),!O&&N&&m.canUseFilters&&d&&e.jsx(G.DashboardFilterControlsButton,{showFilters:D?!1:ue,onToggleFilters:()=>{if(D&&y){Ye(y,"inputs");return}ue||Qe("dashboard",!1),Je(!ue)},onAddFilter:()=>{if(D&&y){Ye(y,"inputs");return}ue||(Qe("dashboard",!1),Je(!0))},onAddControl:()=>{ts("create")},onManageControls:()=>ts("manage")}),N&&!O&&d&&De?D?e.jsx(Yt,{open:!0,onOpenChange:l=>{l||ae(null)},initialMode:De}):e.jsx(G.DashboardControlsSettings,{open:!0,onOpenChange:l=>{l||ae(null)},showTrigger:!1,initialMode:De}):null,N&&!O&&Y&&u&&r&&d&&e.jsxs(o.Button,{variant:"secondary",size:"xs",disabled:M,onClick:et,children:[e.jsx(bs.Save,{className:"h-3.5 w-3.5"}),"Save Lens"]}),N&&!O&&d&&!D&&e.jsxs(o.Button,{variant:"outline",size:"xs",disabled:!N,onClick:()=>zs(),children:[e.jsx(s.Plus,{className:"h-3.5 w-3.5"}),"Visual"]}),!O&&!N&&de&&d&&e.jsxs(o.Button,{size:"xs",onClick:Ks,children:[e.jsx(s.Pencil,{className:"h-3.5 w-3.5"}),"Edit"]}),as&&d&&ns&&e.jsxs(o.Button,{variant:"outline",size:"xs",onClick:Xs,disabled:ge,children:[e.jsx(s.Undo2,{className:"h-3.5 w-3.5"}),"Undo"]}),as&&d&&e.jsxs(o.Button,{size:"xs",className:o.cn(!os&&"opacity-60"),disabled:ge||!os,onClick:()=>Te(),children:[ge?e.jsx(o.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(bs.Save,{className:"h-3.5 w-3.5"}),ge?"Saving...":"Save"]}),N&&!O&&d&&e.jsxs(o.Button,{variant:"outline",size:"xs",onClick:Ws,children:[e.jsx(s.Cross2Icon,{className:"h-3.5 w-3.5"}),"Close"]}),!O&&d&&e.jsx("div",{className:"ml-2",children:e.jsx(G.NotificationBell,{})}),!O&&r&&e.jsx(vt,{}),!O&&d&&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-control border border-border/60 p-1 shadow-sm",children:[e.jsx(s.DropdownMenuLabel,{children:"Reports"}),e.jsxs(s.DropdownMenuItem,{disabled:v,onSelect:()=>Ve(!0),children:[e.jsx(s.Download,{className:"h-3.5 w-3.5"}),"Export"]}),e.jsxs(s.DropdownMenuItem,{disabled:!X,onSelect:()=>{X&&H(!0)},children:[e.jsx(s.Clock,{className:"h-3.5 w-3.5"}),"Schedule"]}),e.jsx(s.DropdownMenuSeparator,{}),Bs&&e.jsxs(e.Fragment,{children:[e.jsx(s.DropdownMenuLabel,{children:"Access"}),e.jsxs(s.DropdownMenuItem,{onClick:()=>B(!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:()=>L(!0),children:[e.jsx(s.Calendar,{className:"h-3.5 w-3.5"}),"Calendar Preferences"]}),e.jsxs(s.DropdownMenuItem,{onClick:()=>q(!0),children:[e.jsx(s.FileText,{className:"h-3.5 w-3.5"}),"Summary Settings"]}),r&&d&&e.jsxs(e.Fragment,{children:[e.jsx(s.DropdownMenuSeparator,{}),e.jsx(s.DropdownMenuLabel,{children:"Developer"}),e.jsxs(s.DropdownMenuItem,{onSelect:()=>{var l;t!=null&&t.accessToken&&((l=navigator==null?void 0:navigator.clipboard)!=null&&l.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"]}),D&&e.jsxs(s.DropdownMenuItem,{disabled:!Le,onSelect:()=>{var l;if(!Le){s.ue.error("Open a document sheet with a token to copy the local PDF URL");return}(l=navigator==null?void 0:navigator.clipboard)!=null&&l.writeText?navigator.clipboard.writeText(Le).then(()=>s.ue.success("Local document PDF URL copied to clipboard")).catch(()=>s.ue.error("Unable to copy local document PDF URL")):s.ue.error("Clipboard not available")},children:[e.jsx(s.Copy,{className:"h-3.5 w-3.5"}),"Copy local document PDF URL"]}),e.jsxs(s.DropdownMenuItem,{onSelect:()=>o.invalidateToken(a.apiServiceUrl),children:[e.jsx(pt,{className:"h-3.5 w-3.5"}),"Invalidate token"]}),e.jsxs(s.DropdownMenuItem,{onSelect:c,children:[e.jsx(vs.Palette,{className:"h-3.5 w-3.5"}),"Brand Studio"]}),N&&e.jsxs(s.DropdownMenuItem,{onSelect:()=>Ze(!We),children:[e.jsx(vs.Braces,{className:"h-3.5 w-3.5"}),We?"Hide dashboard JSON":"Show dashboard JSON"]}),Y&&N&&e.jsxs(s.DropdownMenuItem,{onSelect:()=>K(!0),children:[e.jsx(s.Plus,{className:"h-3.5 w-3.5"}),"Add lens"]}),Y&&e.jsxs(s.DropdownMenuSub,{children:[e.jsxs(s.DropdownMenuSubTrigger,{children:[e.jsx(dt,{className:"h-3.5 w-3.5"}),"Lenses"]}),e.jsx(s.DropdownMenuSubContent,{className:"w-60",children:e.jsx(wt,{})})]})]})]})]}),_&&ss&&e.jsx(s.ShareDialog,{resource:ss,resourceType:s.ResourceType.DASHBOARD,onClose:()=>j(!1)}),e.jsx(Kt,{open:R,onOpenChange:B}),X&&(i==null?void 0:i.id)&&e.jsx(s.EmailScheduleDialog,{open:V,onOpenChange:H,dashboardId:i.id,dashboardName:i==null?void 0:i.title}),e.jsx(xs.CalendarPreferencesDialog,{open:S,onOpenChange:L}),e.jsx(xs.DashboardSummarySettingsDialog,{open:F,onOpenChange:q,dashboard:i,disabled:!N,onApply:l=>Ae({...i,summary:l},{semanticExecutionPayload:Oe})}),r&&Y&&d&&e.jsx(Dt,{open:te,onOpenChange:K}),d&&e.jsx(s.DownloadPdf,{open:Ts,onOpenChange:Ve}),e.jsx(s.AlertDialog,{open:Ps,onOpenChange:l=>{!l&&Me&&!re||(ne(l),l||(oe(null),ie([]),le(!1)))},children:e.jsxs(s.AlertDialogContent,{className:"max-w-sm",children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsx(s.AlertDialogTitle,{children:re?"Save failed":"Saving dashboard"}),e.jsx(s.AlertDialogDescription,{className:"pt-2",children:re?"We could not save the dashboard. Please try again.":"Please wait while we save your changes."}),He.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:He.slice(0,5).map(l=>e.jsx("li",{children:l},l))})]})]}),e.jsx(s.AlertDialogFooter,{className:"flex-col gap-2 sm:flex-row sm:justify-end",children:re?e.jsxs(e.Fragment,{children:[e.jsx(s.AlertDialogCancel,{onClick:()=>{ne(!1),oe(null),ie([]),le(!1)},className:"m-0",children:"Close"}),e.jsx(s.AlertDialogAction,{onClick:()=>Te({closeAfterSave:Ke,navigateHomeAfterSave:Ee==="home"}),className:"m-0",children:"Retry"})]}):e.jsxs(s.AlertDialogAction,{disabled:!0,className:"m-0 cursor-default",children:[e.jsx(o.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]})})]})}),e.jsx(G.UnsavedChangesAlert,{open:Vs,onOpenChange:l=>{W(l)},onSave:Js,onDiscard:Ys,isSaving:Me,saveLabel:"Save",discardLabel:"Discard"})]})]})}function aa({accessToken:t,dashboardId:a,selectedSheetId:n,pageSize:r,orientation:c,theme:m}){if(!t||!n)return null;const d=new URL("http://localhost:5173/print-document");d.searchParams.set("token",t),a&&d.searchParams.set("dashboardId",a),d.searchParams.set("selectedSheetId",n),m&&d.searchParams.set("theme",m);const f=new URL("http://127.0.0.1:3002/");return f.searchParams.set("pdfMode","document"),f.searchParams.set("pageSize",r||"letter"),f.searchParams.set("orientation",c||"portrait"),f.searchParams.set("url",d.toString()),f.toString()}exports.default=ta;
|