react-semaphor 0.1.544 → 0.1.546

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 (179) hide show
  1. package/dist/analytics-protocol/index.js +405 -441
  2. package/dist/assistant-context/index.js +1 -1
  3. package/dist/assistant-protocol/index.js +100 -76
  4. package/dist/brand-studio/index.js +5 -5
  5. package/dist/briefings/index.js +55 -52
  6. package/dist/chunks/{class-utils-Df1OVOT1.js → _commonjsHelpers-DimLPMtv.js} +124 -98
  7. package/dist/chunks/{add-to-dashboard-BuAqfA2Y.js → add-to-dashboard-BQRAAnc3.js} +55 -33
  8. package/dist/chunks/{analytics-base-schemas-BFAoRlkU.js → analytics-base-schemas-BKs3flFS.js} +2 -2
  9. package/dist/chunks/{assistant-chat-BNLkCDml.js → assistant-chat-BPXhulAx.js} +2792 -2562
  10. package/dist/chunks/{bookmark-state-CXw7lZ50.js → bookmark-state-C4vetoa0.js} +7 -8
  11. package/dist/chunks/column-catalog-BYnochWQ.js +3363 -0
  12. package/dist/chunks/comparison-window-caption-C2xF-eWw.js +1433 -0
  13. package/dist/chunks/{context-ClREvqCZ.js → context-BerEBuFR.js} +11 -6
  14. package/dist/chunks/custom-visual-inputs-CkJW9pBS.js +295 -0
  15. package/dist/chunks/{dashboard-g5a4DKWq.js → dashboard-C3CoKbGY.js} +1 -1
  16. package/dist/chunks/dashboard-briefing-launcher-Be4h-7My.js +3734 -0
  17. package/dist/chunks/dashboard-controls-bxPrlSyp.js +2307 -0
  18. package/dist/chunks/{dashboard-json-7qT9jmfL.js → dashboard-json-BrjxIiRt.js} +6 -6
  19. package/dist/chunks/document-dashboard-inputs-CRVHpIHp.js +3010 -0
  20. package/dist/chunks/{edit-dashboard-visual-BfJwnRIZ.js → edit-dashboard-visual-DYYYDjY6.js} +5986 -6063
  21. package/dist/chunks/{filter-value-text-CYsVYPuD.js → filter-value-text-Ddf55Ku1.js} +8 -8
  22. package/dist/chunks/global-date-filter-utils-9d6m9-FE.js +11859 -0
  23. package/dist/chunks/index-CtoK1Lgu.js +586 -0
  24. package/dist/chunks/{index-DkAyQvC6.js → index-DkQkMKa1.js} +385 -339
  25. package/dist/chunks/list-filter-DsaTbM3J.js +15 -0
  26. package/dist/chunks/matrix-analytical-definition-B9vW-osb.js +717 -0
  27. package/dist/chunks/{matrix-card-DjwWcCo8.js → matrix-card-LiMEipvq.js} +3 -3
  28. package/dist/chunks/{matrix-formatter-CxJLkztA.js → matrix-formatter-DWEeC0_c.js} +55 -55
  29. package/dist/chunks/{matrix-member-presentation-CQGdVks6.js → matrix-member-presentation-DqzG-UhQ.js} +1 -1
  30. package/dist/chunks/{matrix-operation-contract-8OIO4gob.js → matrix-operation-contract-D6vYkZK4.js} +72 -72
  31. package/dist/chunks/{metric-comparison-DEwi9uc2.js → metric-comparison-zpGw4lD6.js} +2 -2
  32. package/dist/chunks/normalize-dashboard-for-dirty-check-XKgH3GFX.js +119 -0
  33. package/dist/chunks/{pivot-header-presentation-DHcx1XGQ.js → pivot-header-presentation-CQnIDtUv.js} +1 -1
  34. package/dist/chunks/{pivot-result-identity-DJhXXcns.js → pivot-result-identity-C-Q1j1Wb.js} +1 -1
  35. package/dist/chunks/{pivot-result-lifecycle-DM4CyGKs.js → pivot-result-lifecycle-pwq3b7LC.js} +571 -380
  36. package/dist/chunks/{raw-temporal-contract-C51YG48G.js → raw-temporal-contract-WuXA8jBP.js} +1 -1
  37. package/dist/chunks/{raw-temporal-presentation-CLiVi90c.js → raw-temporal-presentation-CBzrDOjM.js} +8 -8
  38. package/dist/chunks/rendered-file-D8xEuVVx.js +108 -0
  39. package/dist/chunks/{report-preferences-dialog-Df7VpRVW.js → report-preferences-dialog-4QEZWe5U.js} +637 -610
  40. package/dist/chunks/{report-runtime-context-Dq8XyODK.js → report-runtime-context-hWiTCzFV.js} +2 -2
  41. package/dist/chunks/resolve-dashboard-input-context-UpK_LBpL.js +5677 -0
  42. package/dist/chunks/{saved-dashboard-context-B-mQ--nV.js → saved-dashboard-context-D_I3Lxk0.js} +184 -212
  43. package/dist/chunks/selection-filter-compiler-BKXmyLrS.js +79 -0
  44. package/dist/chunks/{selection-reducer-Dj_8xD69.js → selection-reducer-CJzkTZio.js} +15 -15
  45. package/dist/chunks/{semaphor-ready-indicator-DDAxk8us.js → semaphor-ready-indicator-4zpRHE-X.js} +56832 -59068
  46. package/dist/chunks/{shelf-drop-preview-context-BSRPwaED.js → shelf-drop-preview-context-Cfw7TRAx.js} +890 -871
  47. package/dist/chunks/{source-entity-resolution-BYn9giz3.js → source-entity-resolution-BIGRvtbG.js} +13 -13
  48. package/dist/chunks/{switch-C3jLxlG0.js → switch-CEBOR4n7.js} +47 -48
  49. package/dist/chunks/{table-export-sheet-CPfGAQ9X.js → table-export-sheet-4X9mAG3V.js} +1 -1
  50. package/dist/chunks/table-settings-CunhoDUi.js +605 -0
  51. package/dist/chunks/{temporal-bucket-D7NBrrtL.js → temporal-bucket-CQOSbv9-.js} +26 -26
  52. package/dist/chunks/{token-types-DBbZVQsm.js → token-types-BMqRmT-C.js} +1 -1
  53. package/dist/chunks/{use-create-flow-overlay-state-BxzFviM-.js → use-create-flow-overlay-state-DZBZiiD-.js} +83 -83
  54. package/dist/chunks/{validators-DMHTpf7a.js → validators-C-aOQlTB.js} +713 -658
  55. package/dist/dashboard/index.js +2 -2
  56. package/dist/dashboard-authoring/index.js +1800 -1135
  57. package/dist/data-app-sdk/index.js +6 -6
  58. package/dist/data-app-sdk-adapters/index.js +3 -3
  59. package/dist/data-app-sdk-validation/index.js +14 -14
  60. package/dist/format-utils/index.js +198 -187
  61. package/dist/index.js +359 -325
  62. package/dist/layouts/index.js +5 -242
  63. package/dist/report-runtime-context/index.js +2 -2
  64. package/dist/shared/index.js +4 -5
  65. package/dist/style.css +1 -1
  66. package/dist/surfboard/index.js +2 -2
  67. package/dist/types/briefings/attachment-outcomes.d.ts +1 -1
  68. package/dist/types/briefings/attachments.d.ts +33 -6
  69. package/dist/types/briefings/index.d.ts +6 -5
  70. package/dist/types/components/index.d.ts +2 -0
  71. package/dist/types/components/surfboard/arrange-layout-button.d.ts +8 -0
  72. package/dist/types/components/surfboard/filter/types.d.ts +0 -14
  73. package/dist/types/components/surfboard/screen-size-preview-button.d.ts +7 -0
  74. package/dist/types/index.js +6 -6
  75. package/dist/types/lib/charts/table-chart-types.d.ts +4 -0
  76. package/dist/types/lib/charts/types.d.ts +2 -2
  77. package/dist/types/lib/dashboard-inputs/dashboard-filter-mapping-authoring.d.ts +68 -82
  78. package/dist/types/lib/dashboard-inputs/dashboard-input-target-context.d.ts +0 -8
  79. package/dist/types/lib/dashboard-inputs/dashboard-input-values.d.ts +41 -1
  80. package/dist/types/lib/dashboard-inputs/filter-settings.d.ts +201 -0
  81. package/dist/types/lib/dashboard-inputs/prepare-loaded-dashboard.d.ts +15 -0
  82. package/dist/types/lib/dashboard-inputs/resolve-dashboard-input-context.d.ts +7 -2
  83. package/dist/types/lib/dashboard-inputs/resolve-selection-input.d.ts +1 -1
  84. package/dist/types/lib/dashboard-viewer/captured-runtime-values.d.ts +40 -0
  85. package/dist/types/lib/dashboard-viewer/compatibility-input-storage.d.ts +16 -16
  86. package/dist/types/lib/dashboard-viewer/viewer-state.d.ts +11 -9
  87. package/dist/types/lib/download-pdf.d.ts +75 -1
  88. package/dist/types/lib/hooks/use-date-filter.d.ts +5 -0
  89. package/dist/types/lib/hooks/use-text-filter.d.ts +5 -0
  90. package/dist/types/lib/matrix-table/matrix-delivery-policy.d.ts +5 -4
  91. package/dist/types/lib/matrix-table/matrix-editor.d.ts +52 -0
  92. package/dist/types/lib/query-context/assemble-card-query.d.ts +158 -0
  93. package/dist/types/lib/query-context/build-card-query-context.d.ts +3 -3
  94. package/dist/types/lib/query-context/build-dashboard-card-query-contract.d.ts +15 -6
  95. package/dist/types/lib/query-context/build-dashboard-execution-snapshot.d.ts +11 -13
  96. package/dist/types/lib/query-context/compile-dashboard-card-filters.d.ts +22 -12
  97. package/dist/types/lib/query-context/dashboard-filter-mapping-resolution.d.ts +69 -0
  98. package/dist/types/lib/stores/dashboard-store.d.ts +159 -56
  99. package/dist/types/lib/stores/editor-store.d.ts +0 -3
  100. package/dist/types/lib/types/common-types.d.ts +29 -6
  101. package/dist/types/lib/types/explorer-types.d.ts +10 -0
  102. package/dist/types/lib/types/semantic-types.d.ts +84 -0
  103. package/dist/types/lib/utils/build-saved-editor-card.d.ts +20 -0
  104. package/dist/types/lib/utils/card-type-change.d.ts +16 -0
  105. package/dist/types/lib/utils/field-availability-context.d.ts +25 -0
  106. package/dist/types/lib/utils/field-placement.d.ts +96 -0
  107. package/dist/types/lib/utils/field-state-calculator.d.ts +161 -0
  108. package/dist/types/lib/utils/qualified-entity-name.d.ts +2 -0
  109. package/dist/types/shared/analytics-protocol/field-provenance.d.ts +89 -0
  110. package/dist/types/shared/analytics-protocol/index.d.ts +2 -0
  111. package/dist/types/shared/analytics-protocol/query-policies.d.ts +52 -0
  112. package/dist/types/shared/analytics-protocol/time-window-schema.d.ts +1 -1
  113. package/dist/types/shared/analytics-protocol/time-window.d.ts +40 -1
  114. package/dist/types/shared/assistant-context/saved-dashboard-context.d.ts +8 -12
  115. package/dist/types/shared/assistant-protocol/answer-text.d.ts +20 -0
  116. package/dist/types/shared/assistant-protocol/context.d.ts +21 -21
  117. package/dist/types/shared/assistant-protocol/index.d.ts +1 -0
  118. package/dist/types/shared/assistant-protocol/limits.d.ts +6 -1
  119. package/dist/types/shared/assistant-protocol/parts.d.ts +43 -3
  120. package/dist/types/shared/assistant-protocol/request.d.ts +14 -2
  121. package/dist/types/shared/dashboard-authoring/calculated-field-identity.d.ts +3 -0
  122. package/dist/types/shared/dashboard-authoring/changes/card-query-part.d.ts +487 -0
  123. package/dist/types/shared/dashboard-authoring/changes/card-types.d.ts +34 -0
  124. package/dist/types/shared/dashboard-authoring/changes/dashboard-change.d.ts +7886 -0
  125. package/dist/types/shared/dashboard-authoring/changes/diagnostics.d.ts +43 -0
  126. package/dist/types/shared/dashboard-authoring/changes/read-card-query.d.ts +54 -0
  127. package/dist/types/shared/dashboard-authoring/changes/resolve-dashboard-changes.d.ts +89 -0
  128. package/dist/types/shared/dashboard-authoring/column-catalog.d.ts +32 -0
  129. package/dist/types/shared/dashboard-authoring/contracts.d.ts +0 -55
  130. package/dist/types/shared/dashboard-authoring/control-execution-contract.d.ts +16 -6
  131. package/dist/types/shared/dashboard-authoring/dashboard-card-source-index.d.ts +9 -1
  132. package/dist/types/shared/dashboard-authoring/dashboard-filter-mapping-contract.d.ts +7 -0
  133. package/dist/types/shared/dashboard-authoring/dashboard-input-scope.d.ts +118 -0
  134. package/dist/types/shared/dashboard-authoring/filter-applicability.d.ts +75 -0
  135. package/dist/types/shared/dashboard-authoring/filter-model/ad-hoc-filter-values.d.ts +10 -0
  136. package/dist/types/shared/dashboard-authoring/filter-model/filter-definitions.d.ts +29 -0
  137. package/dist/types/shared/dashboard-authoring/filter-model/filter-values.d.ts +58 -0
  138. package/dist/types/shared/dashboard-authoring/filter-model/index.d.ts +7 -0
  139. package/dist/types/shared/dashboard-authoring/filter-model/prototype-document-inputs.d.ts +15 -0
  140. package/dist/types/shared/dashboard-authoring/filter-model/read-dashboard-filter-model.d.ts +78 -0
  141. package/dist/types/shared/dashboard-authoring/filter-model/stored-dashboard.d.ts +18 -0
  142. package/dist/types/shared/dashboard-authoring/filter-model/toolbar-filter-reach.d.ts +23 -0
  143. package/dist/types/shared/dashboard-authoring/index.d.ts +20 -2
  144. package/dist/types/shared/dashboard-authoring/operations/apply-dashboard-operations.d.ts +10 -37
  145. package/dist/types/shared/dashboard-authoring/operations/operation-types.d.ts +189 -0
  146. package/dist/types/shared/dashboard-authoring/outline/outline-dashboard.d.ts +94 -0
  147. package/dist/types/shared/dashboard-authoring/outline/outline-filters.d.ts +78 -0
  148. package/dist/types/shared/dashboard-authoring/validators.d.ts +1 -2
  149. package/dist/types/shared/format-utils/exporters/index.d.ts +2 -0
  150. package/dist/types/shared/format-utils/exporters/rendered-file.d.ts +106 -0
  151. package/dist/types/shared/layouts/engine/grid.d.ts +25 -0
  152. package/dist/types/shared/layouts/engine/index.d.ts +4 -0
  153. package/dist/types/shared/layouts/engine/sheet-layout.d.ts +7 -0
  154. package/dist/types/shared/layouts/engine/types.d.ts +125 -0
  155. package/dist/types/shared/layouts/index.d.ts +1 -2
  156. package/package.json +2 -2
  157. package/dist/chunks/_commonjsHelpers-BkfeUUK-.js +0 -28
  158. package/dist/chunks/apply-dashboard-operations-Bz4n1Lq6.js +0 -2260
  159. package/dist/chunks/calendar-day-equality-BmJAWduY.js +0 -460
  160. package/dist/chunks/comparison-window-caption-BTkrN3W4.js +0 -1623
  161. package/dist/chunks/custom-visual-inputs-DUtpYZOk.js +0 -323
  162. package/dist/chunks/dashboard-briefing-launcher-DQ_8O_e2.js +0 -3725
  163. package/dist/chunks/dashboard-controls-8RyBTQUO.js +0 -2315
  164. package/dist/chunks/dashboard-filter-value-compatibility-CwQ_iSNb.js +0 -108
  165. package/dist/chunks/document-dashboard-inputs-BC6p-ESg.js +0 -8087
  166. package/dist/chunks/document-sheet-utils-Duo9uLoH.js +0 -3619
  167. package/dist/chunks/matrix-analytical-definition-C7Gb0e12.js +0 -117
  168. package/dist/chunks/normalize-dashboard-for-dirty-check-Bk3VYv_q.js +0 -67
  169. package/dist/chunks/numeric-presentation-DESvLiu9.js +0 -5227
  170. package/dist/chunks/sort-target-MT1WK1vX.js +0 -29
  171. package/dist/chunks/stable-serialize-CfqXeiBP.js +0 -6
  172. package/dist/chunks/table-settings-CLZocegs.js +0 -501
  173. package/dist/chunks/use-debounced-dirty-check-BwAbnX_5.js +0 -59
  174. package/dist/types/lib/dashboard-inputs/dashboard-filter-mapping-storage-transition.d.ts +0 -88
  175. package/dist/types/lib/dashboard-inputs/dashboard-input-scope.d.ts +0 -10
  176. package/dist/types/shared/dashboard-authoring/change-compiler.d.ts +0 -7
  177. package/dist/types/shared/dashboard-authoring/layout-compiler.d.ts +0 -2
  178. package/dist/types/shared/layouts/create-frame-layouts.d.ts +0 -27
  179. package/dist/types/shared/layouts/frame-layouts.d.ts +0 -23
@@ -1,2315 +0,0 @@
1
- import { jsx as t, jsxs as i, Fragment as $ } from "react/jsx-runtime";
2
- import { bz as jr, u as C, bA as Hr, bB as nt, bC as qr, bD as zr, bE as Kr, bF as Qr, bG as Wr, bH as Yr, aX as K, aV as ve, bI as ye, bJ as Jr, bu as Ht, bv as qt, bx as Ze, by as et, bK as zt, aH as ot, aQ as ee, bL as Xr, bM as Zr, bN as Kt, bO as ea, bP as Qt, bw as ta, bQ as ra, bR as P, bS as aa, bT as na, bU as oa, as as sa, b6 as ia, bV as da, bW as ca, bX as la, g as ua, L as ma, Y as kt, f as Oe, m as ha, h as We, bY as pa, bZ as fa, b_ as ba, b$ as ga, J as xa, c0 as va, s as ya, c1 as wa, c2 as Na, b8 as Sa, c3 as ka, c4 as Ca, c5 as Ct, c6 as Dt, c7 as Et, c8 as Da, c9 as Ea, ca as Ia, cb as Aa, cc as _e, cd as La, ce as Ma, cf as Ye, cg as Oa, ch as It, l as _a, ci as Pa, cj as Ra, ck as Ta, cl as Ua, cm as $a, cn as Ba, co as Fa, cp as Ga, cq as At } from "./semaphor-ready-indicator-DDAxk8us.js";
3
- import { B as U, Z as Va, _ as ja, $ as tt, L as Re, l as Ha, r as qa, s as za, t as Ka, u as Qa, v as Wa, P as Ya, a as Ja, b as Xa, m as Lt, n as Mt, o as Ot, p as _t, I as Za } from "./switch-C3jLxlG0.js";
4
- import { c as te, X as Wt, C as en } from "./x-4f5U2XwU.js";
5
- import * as I from "react";
6
- import Yt, { useMemo as V, useState as S, useEffect as ge, useRef as Pt, useLayoutEffect as tn } from "react";
7
- import { ae as D } from "./numeric-presentation-DESvLiu9.js";
8
- import "./index-CuHybtft.js";
9
- import "./validators-DMHTpf7a.js";
10
- import "./matrix-operation-contract-8OIO4gob.js";
11
- import "./analytics-base-schemas-BFAoRlkU.js";
12
- import "zod";
13
- import "../value-format-preferences/index.js";
14
- import { c as xe } from "./class-utils-Df1OVOT1.js";
15
- import { u as rn, A as an, a as nn, e as on, V as sn, b as dn, i as cn, f as ln, U as un } from "./dashboard-briefing-launcher-DQ_8O_e2.js";
16
- import { I as mn } from "./use-create-flow-overlay-state-BxzFviM-.js";
17
- import { h as hn, R as pn } from "./report-preferences-dialog-Df7VpRVW.js";
18
- import { createPortal as fn } from "react-dom";
19
- import { a7 as we, a8 as st, a9 as Jt, aa as bn, ab as Rt, ac as gn } from "./document-dashboard-inputs-BC6p-ESg.js";
20
- import { S as xn, C as vn } from "./selection-reducer-Dj_8xD69.js";
21
- import { o as Xt } from "./matrix-formatter-CxJLkztA.js";
22
- import { Z as Tt, _ as yn, $ as wn, x as Nn, a as rt } from "./document-sheet-utils-Duo9uLoH.js";
23
- import { r as Sn } from "./export-file-format-C-tJsxsf.js";
24
- import { u as kn } from "./use-debounced-dirty-check-BwAbnX_5.js";
25
- import { s as Cn } from "./normalize-dashboard-for-dirty-check-Bk3VYv_q.js";
26
- import { B as Te, u as Ut } from "./table-settings-CLZocegs.js";
27
- import { S as Dn } from "./save-CfJpQQ68.js";
28
- import { P as En } from "./palette-D10o_yYX.js";
29
- import { B as In } from "./braces-o9UiRQes.js";
30
- /**
31
- * @license lucide-react v0.453.0 - ISC
32
- *
33
- * This source code is licensed under the ISC license.
34
- * See the LICENSE file in the root directory of this source tree.
35
- */
36
- const An = te("Monitor", [
37
- ["rect", { width: "20", height: "14", x: "2", y: "3", rx: "2", key: "48i651" }],
38
- ["line", { x1: "8", x2: "16", y1: "21", y2: "21", key: "1svkeh" }],
39
- ["line", { x1: "12", x2: "12", y1: "17", y2: "21", key: "vw1qmm" }]
40
- ]);
41
- /**
42
- * @license lucide-react v0.453.0 - ISC
43
- *
44
- * This source code is licensed under the ISC license.
45
- * See the LICENSE file in the root directory of this source tree.
46
- */
47
- const Ln = te("Moon", [
48
- ["path", { d: "M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z", key: "a7tn18" }]
49
- ]);
50
- /**
51
- * @license lucide-react v0.453.0 - ISC
52
- *
53
- * This source code is licensed under the ISC license.
54
- * See the LICENSE file in the root directory of this source tree.
55
- */
56
- const Mn = te("ShieldX", [
57
- [
58
- "path",
59
- {
60
- 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",
61
- key: "oel41y"
62
- }
63
- ],
64
- ["path", { d: "m14.5 9.5-5 5", key: "17q4r4" }],
65
- ["path", { d: "m9.5 9.5 5 5", key: "18nt4w" }]
66
- ]);
67
- /**
68
- * @license lucide-react v0.453.0 - ISC
69
- *
70
- * This source code is licensed under the ISC license.
71
- * See the LICENSE file in the root directory of this source tree.
72
- */
73
- const On = te("Sun", [
74
- ["circle", { cx: "12", cy: "12", r: "4", key: "4exip2" }],
75
- ["path", { d: "M12 2v2", key: "tus03m" }],
76
- ["path", { d: "M12 20v2", key: "1lh1kg" }],
77
- ["path", { d: "m4.93 4.93 1.41 1.41", key: "149t6j" }],
78
- ["path", { d: "m17.66 17.66 1.41 1.41", key: "ptbguv" }],
79
- ["path", { d: "M2 12h2", key: "1t8f8n" }],
80
- ["path", { d: "M20 12h2", key: "1q8mjw" }],
81
- ["path", { d: "m6.34 17.66-1.41 1.41", key: "1m8zz5" }],
82
- ["path", { d: "m19.07 4.93-1.41 1.41", key: "1shlcs" }]
83
- ]);
84
- /**
85
- * @license lucide-react v0.453.0 - ISC
86
- *
87
- * This source code is licensed under the ISC license.
88
- * See the LICENSE file in the root directory of this source tree.
89
- */
90
- const _n = te("UserPlus", [
91
- ["path", { d: "M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2", key: "1yyitq" }],
92
- ["circle", { cx: "9", cy: "7", r: "4", key: "nufk8" }],
93
- ["line", { x1: "19", x2: "19", y1: "8", y2: "14", key: "1bvyxn" }],
94
- ["line", { x1: "22", x2: "16", y1: "11", y2: "11", key: "1shjgl" }]
95
- ]);
96
- /**
97
- * @license lucide-react v0.453.0 - ISC
98
- *
99
- * This source code is licensed under the ISC license.
100
- * See the LICENSE file in the root directory of this source tree.
101
- */
102
- const Zt = te("UserRound", [
103
- ["circle", { cx: "12", cy: "8", r: "5", key: "1hypcn" }],
104
- ["path", { d: "M20 21a8 8 0 0 0-16 0", key: "rfgkzh" }]
105
- ]);
106
- var at = { exports: {} }, Je = {};
107
- /**
108
- * @license React
109
- * use-sync-external-store-shim.production.js
110
- *
111
- * Copyright (c) Meta Platforms, Inc. and affiliates.
112
- *
113
- * This source code is licensed under the MIT license found in the
114
- * LICENSE file in the root directory of this source tree.
115
- */
116
- var $t;
117
- function Pn() {
118
- if ($t) return Je;
119
- $t = 1;
120
- var e = Yt;
121
- function n(l, u) {
122
- return l === u && (l !== 0 || 1 / l === 1 / u) || l !== l && u !== u;
123
- }
124
- var a = typeof Object.is == "function" ? Object.is : n, r = e.useState, o = e.useEffect, c = e.useLayoutEffect, m = e.useDebugValue;
125
- function p(l, u) {
126
- var s = u(), x = r({ inst: { value: s, getSnapshot: u } }), v = x[0].inst, w = x[1];
127
- return c(
128
- function() {
129
- v.value = s, v.getSnapshot = u, b(v) && w({ inst: v });
130
- },
131
- [l, s, u]
132
- ), o(
133
- function() {
134
- return b(v) && w({ inst: v }), l(function() {
135
- b(v) && w({ inst: v });
136
- });
137
- },
138
- [l]
139
- ), m(s), s;
140
- }
141
- function b(l) {
142
- var u = l.getSnapshot;
143
- l = l.value;
144
- try {
145
- var s = u();
146
- return !a(l, s);
147
- } catch {
148
- return !0;
149
- }
150
- }
151
- function f(l, u) {
152
- return u();
153
- }
154
- var g = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? f : p;
155
- return Je.useSyncExternalStore = e.useSyncExternalStore !== void 0 ? e.useSyncExternalStore : g, Je;
156
- }
157
- var Xe = {};
158
- /**
159
- * @license React
160
- * use-sync-external-store-shim.development.js
161
- *
162
- * Copyright (c) Meta Platforms, Inc. and affiliates.
163
- *
164
- * This source code is licensed under the MIT license found in the
165
- * LICENSE file in the root directory of this source tree.
166
- */
167
- var Bt;
168
- function Rn() {
169
- return Bt || (Bt = 1, process.env.NODE_ENV !== "production" && function() {
170
- function e(s, x) {
171
- return s === x && (s !== 0 || 1 / s === 1 / x) || s !== s && x !== x;
172
- }
173
- function n(s, x) {
174
- g || o.startTransition === void 0 || (g = !0, console.error(
175
- "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."
176
- ));
177
- var v = x();
178
- if (!l) {
179
- var w = x();
180
- c(v, w) || (console.error(
181
- "The result of getSnapshot should be cached to avoid an infinite loop"
182
- ), l = !0);
183
- }
184
- w = m({
185
- inst: { value: v, getSnapshot: x }
186
- });
187
- var h = w[0].inst, E = w[1];
188
- return b(
189
- function() {
190
- h.value = v, h.getSnapshot = x, a(h) && E({ inst: h });
191
- },
192
- [s, v, x]
193
- ), p(
194
- function() {
195
- return a(h) && E({ inst: h }), s(function() {
196
- a(h) && E({ inst: h });
197
- });
198
- },
199
- [s]
200
- ), f(v), v;
201
- }
202
- function a(s) {
203
- var x = s.getSnapshot;
204
- s = s.value;
205
- try {
206
- var v = x();
207
- return !c(s, v);
208
- } catch {
209
- return !0;
210
- }
211
- }
212
- function r(s, x) {
213
- return x();
214
- }
215
- typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
216
- var o = Yt, c = typeof Object.is == "function" ? Object.is : e, m = o.useState, p = o.useEffect, b = o.useLayoutEffect, f = o.useDebugValue, g = !1, l = !1, u = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? r : n;
217
- Xe.useSyncExternalStore = o.useSyncExternalStore !== void 0 ? o.useSyncExternalStore : u, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
218
- }()), Xe;
219
- }
220
- process.env.NODE_ENV === "production" ? at.exports = Pn() : at.exports = Rn();
221
- var Tn = at.exports;
222
- const Pe = ["light", "dark", "system"];
223
- function Un() {
224
- const { theme: e, setTheme: n } = jr(), a = C(
225
- (m) => m.actions.setDashboardTheme
226
- );
227
- function r() {
228
- const m = Pe.includes(e) ? e : "system", p = Pe[(Pe.indexOf(m) + 1) % Pe.length];
229
- n(p), a(p);
230
- }
231
- const o = e === "light" ? On : e === "dark" ? Ln : An, c = e === "light" ? "Theme: light (click for dark)" : e === "dark" ? "Theme: dark (click for system)" : "Theme: system (click for light)";
232
- return /* @__PURE__ */ t(
233
- U,
234
- {
235
- type: "button",
236
- variant: "ghost",
237
- size: "xs",
238
- className: "h-7 w-7 p-0 text-muted-foreground hover:text-foreground",
239
- onClick: r,
240
- "aria-label": c,
241
- title: c,
242
- children: /* @__PURE__ */ t(o, { className: "h-3.5 w-3.5", strokeWidth: 1.5 })
243
- }
244
- );
245
- }
246
- function $n() {
247
- const { displayPreferences: e, shouldShowElement: n } = Hr(), { currentUser: a, userContext: r } = nt(), o = V(
248
- () => qr(a),
249
- [a]
250
- ), c = V(() => (p) => o && o[p] !== void 0 && o[p] === !1 ? !1 : n(p), [o, n, e]), m = V(
251
- () => {
252
- var p, b, f, g, l;
253
- return {
254
- canEdit: ((p = r == null ? void 0 : r.permissions) == null ? void 0 : p.canEdit) ?? Yr(a),
255
- canUseFilters: ((b = r == null ? void 0 : r.permissions) == null ? void 0 : b.canEdit) ?? Wr(a),
256
- canManageDashboards: ((f = r == null ? void 0 : r.permissions) == null ? void 0 : f.canCreateDashboard) ?? Qr(a),
257
- canCreateDashboards: ((g = r == null ? void 0 : r.permissions) == null ? void 0 : g.canCreateDashboard) ?? Kr(a),
258
- canAccessVisuals: ((l = r == null ? void 0 : r.permissions) == null ? void 0 : l.canEdit) ?? zr(a)
259
- };
260
- },
261
- [a, r]
262
- );
263
- return {
264
- displayPreferences: e,
265
- shouldShowElement: c,
266
- permissions: m,
267
- currentUser: a
268
- };
269
- }
270
- function Bn(e, n = []) {
271
- let a = [];
272
- function r(c, m) {
273
- const p = I.createContext(m);
274
- p.displayName = c + "Context";
275
- const b = a.length;
276
- a = [...a, m];
277
- const f = (l) => {
278
- var h;
279
- const { scope: u, children: s, ...x } = l, v = ((h = u == null ? void 0 : u[e]) == null ? void 0 : h[b]) || p, w = I.useMemo(() => x, Object.values(x));
280
- return /* @__PURE__ */ t(v.Provider, { value: w, children: s });
281
- };
282
- f.displayName = c + "Provider";
283
- function g(l, u) {
284
- var v;
285
- const s = ((v = u == null ? void 0 : u[e]) == null ? void 0 : v[b]) || p, x = I.useContext(s);
286
- if (x) return x;
287
- if (m !== void 0) return m;
288
- throw new Error(`\`${l}\` must be used within \`${c}\``);
289
- }
290
- return [f, g];
291
- }
292
- const o = () => {
293
- const c = a.map((m) => I.createContext(m));
294
- return function(p) {
295
- const b = (p == null ? void 0 : p[e]) || c;
296
- return I.useMemo(
297
- () => ({ [`__scope${e}`]: { ...p, [e]: b } }),
298
- [p, b]
299
- );
300
- };
301
- };
302
- return o.scopeName = e, [r, Fn(o, ...n)];
303
- }
304
- function Fn(...e) {
305
- const n = e[0];
306
- if (e.length === 1) return n;
307
- const a = () => {
308
- const r = e.map((o) => ({
309
- useScope: o(),
310
- scopeName: o.scopeName
311
- }));
312
- return function(c) {
313
- const m = r.reduce((p, { useScope: b, scopeName: f }) => {
314
- const l = b(c)[`__scope${f}`];
315
- return { ...p, ...l };
316
- }, {});
317
- return I.useMemo(() => ({ [`__scope${n.scopeName}`]: m }), [m]);
318
- };
319
- };
320
- return a.scopeName = n.scopeName, a;
321
- }
322
- var Gn = [
323
- "a",
324
- "button",
325
- "div",
326
- "form",
327
- "h2",
328
- "h3",
329
- "img",
330
- "input",
331
- "label",
332
- "li",
333
- "nav",
334
- "ol",
335
- "p",
336
- "select",
337
- "span",
338
- "svg",
339
- "ul"
340
- ], it = Gn.reduce((e, n) => {
341
- const a = Va(`Primitive.${n}`), r = I.forwardRef((o, c) => {
342
- const { asChild: m, ...p } = o, b = m ? a : n;
343
- return typeof window < "u" && (window[Symbol.for("radix-ui")] = !0), /* @__PURE__ */ t(b, { ...p, ref: c });
344
- });
345
- return r.displayName = `Primitive.${n}`, { ...e, [n]: r };
346
- }, {});
347
- function Vn() {
348
- return Tn.useSyncExternalStore(
349
- jn,
350
- () => !0,
351
- () => !1
352
- );
353
- }
354
- function jn() {
355
- return () => {
356
- };
357
- }
358
- var dt = "Avatar", [Hn] = Bn(dt), [qn, er] = Hn(dt), tr = I.forwardRef(
359
- (e, n) => {
360
- const { __scopeAvatar: a, ...r } = e, [o, c] = I.useState("idle");
361
- return /* @__PURE__ */ t(
362
- qn,
363
- {
364
- scope: a,
365
- imageLoadingStatus: o,
366
- onImageLoadingStatusChange: c,
367
- children: /* @__PURE__ */ t(it.span, { ...r, ref: n })
368
- }
369
- );
370
- }
371
- );
372
- tr.displayName = dt;
373
- var rr = "AvatarImage", ar = I.forwardRef(
374
- (e, n) => {
375
- const { __scopeAvatar: a, src: r, onLoadingStatusChange: o = () => {
376
- }, ...c } = e, m = er(rr, a), p = zn(r, c), b = ja((f) => {
377
- o(f), m.onImageLoadingStatusChange(f);
378
- });
379
- return tt(() => {
380
- p !== "idle" && b(p);
381
- }, [p, b]), p === "loaded" ? /* @__PURE__ */ t(it.img, { ...c, ref: n, src: r }) : null;
382
- }
383
- );
384
- ar.displayName = rr;
385
- var nr = "AvatarFallback", or = I.forwardRef(
386
- (e, n) => {
387
- const { __scopeAvatar: a, delayMs: r, ...o } = e, c = er(nr, a), [m, p] = I.useState(r === void 0);
388
- return I.useEffect(() => {
389
- if (r !== void 0) {
390
- const b = window.setTimeout(() => p(!0), r);
391
- return () => window.clearTimeout(b);
392
- }
393
- }, [r]), m && c.imageLoadingStatus !== "loaded" ? /* @__PURE__ */ t(it.span, { ...o, ref: n }) : null;
394
- }
395
- );
396
- or.displayName = nr;
397
- function Ft(e, n) {
398
- return e ? n ? (e.src !== n && (e.src = n), e.complete && e.naturalWidth > 0 ? "loaded" : "loading") : "error" : "idle";
399
- }
400
- function zn(e, { referrerPolicy: n, crossOrigin: a }) {
401
- const r = Vn(), o = I.useRef(null), c = r ? (o.current || (o.current = new window.Image()), o.current) : null, [m, p] = I.useState(
402
- () => Ft(c, e)
403
- );
404
- return tt(() => {
405
- p(Ft(c, e));
406
- }, [c, e]), tt(() => {
407
- const b = (l) => () => {
408
- p(l);
409
- };
410
- if (!c) return;
411
- const f = b("loaded"), g = b("error");
412
- return c.addEventListener("load", f), c.addEventListener("error", g), n && (c.referrerPolicy = n), typeof a == "string" && (c.crossOrigin = a), () => {
413
- c.removeEventListener("load", f), c.removeEventListener("error", g);
414
- };
415
- }, [c, a, n]), m;
416
- }
417
- var sr = tr, ir = ar, dr = or;
418
- const cr = I.forwardRef(({ className: e, ...n }, a) => /* @__PURE__ */ t(
419
- sr,
420
- {
421
- ref: a,
422
- className: xe(
423
- "relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",
424
- e
425
- ),
426
- ...n
427
- }
428
- ));
429
- cr.displayName = sr.displayName;
430
- const Kn = I.forwardRef(({ className: e, ...n }, a) => /* @__PURE__ */ t(
431
- ir,
432
- {
433
- ref: a,
434
- className: xe("aspect-square h-full w-full", e),
435
- ...n
436
- }
437
- ));
438
- Kn.displayName = ir.displayName;
439
- const lr = I.forwardRef(({ className: e, ...n }, a) => /* @__PURE__ */ t(
440
- dr,
441
- {
442
- ref: a,
443
- className: xe(
444
- "flex h-full w-full items-center justify-center rounded-full bg-muted",
445
- e
446
- ),
447
- ...n
448
- }
449
- ));
450
- lr.displayName = dr.displayName;
451
- const Qn = async (e, n, a) => {
452
- const r = `${e}/management/v1/groups`;
453
- return await Jt(r, n, a);
454
- }, Wn = async (e, n, a, r) => {
455
- const o = `${e}/management/v1/groups/${a}`;
456
- return st(o, n, "PATCH", r);
457
- }, Yn = async (e, n, a) => {
458
- const r = `${e}/management/v1/groups/${a}`;
459
- await st(r, n, "DELETE");
460
- }, Jn = async (e, n, a, r) => {
461
- const o = `${e}/management/v1/groups/${a}/members`;
462
- return await Jt(o, n, r);
463
- }, Xn = async (e, n, a, r) => {
464
- const o = `${e}/management/v1/groups/${a}/members`;
465
- await st(o, n, "DELETE", r);
466
- };
467
- function Zn() {
468
- const { authToken: e, tokenProps: n } = K(), a = ve();
469
- return ye({
470
- mutationFn: (r) => Qn(n.apiServiceUrl, (e == null ? void 0 : e.accessToken) || "", r),
471
- onSuccess: () => {
472
- a.invalidateQueries({ queryKey: ["groups"] }), D.success("Group created successfully");
473
- },
474
- onError: (r) => {
475
- console.error("Failed to create group:", r), D.error("Failed to create group", {
476
- description: we(r, "Failed to create group")
477
- });
478
- }
479
- });
480
- }
481
- function eo() {
482
- const { authToken: e, tokenProps: n } = K(), a = ve();
483
- return ye({
484
- mutationFn: ({
485
- groupId: r,
486
- data: o
487
- }) => Wn(n.apiServiceUrl, (e == null ? void 0 : e.accessToken) || "", r, o),
488
- onSuccess: (r, o) => {
489
- a.invalidateQueries({ queryKey: ["group", o.groupId] }), a.invalidateQueries({ queryKey: ["groups"] }), D.success("Group updated successfully");
490
- },
491
- onError: (r) => {
492
- console.error("Failed to update group:", r), D.error("Failed to update group", {
493
- description: we(r, "Failed to update group")
494
- });
495
- }
496
- });
497
- }
498
- function to() {
499
- const { authToken: e, tokenProps: n } = K(), a = ve();
500
- return ye({
501
- mutationFn: (r) => Yn(n.apiServiceUrl, (e == null ? void 0 : e.accessToken) || "", r),
502
- onSuccess: (r, o) => {
503
- a.invalidateQueries({ queryKey: ["groups"] }), a.removeQueries({ queryKey: ["group", o] }), D.success("Group deleted successfully");
504
- },
505
- onError: (r) => {
506
- console.error("Failed to delete group:", r), D.error("Failed to delete group", {
507
- description: we(r, "Failed to delete group")
508
- });
509
- }
510
- });
511
- }
512
- function ro() {
513
- const { authToken: e, tokenProps: n } = K(), a = ve();
514
- return ye({
515
- mutationFn: ({
516
- groupId: r,
517
- data: o
518
- }) => Jn(n.apiServiceUrl, (e == null ? void 0 : e.accessToken) || "", r, o),
519
- onSuccess: (r, o) => {
520
- a.invalidateQueries({ queryKey: ["group", o.groupId] }), a.invalidateQueries({
521
- queryKey: ["group-members", o.groupId]
522
- }), a.invalidateQueries({ queryKey: ["groups"] }), D.success("Members added successfully");
523
- },
524
- onError: (r) => {
525
- console.error("Failed to add group members:", r), D.error("Failed to add members", {
526
- description: we(r, "Failed to add members")
527
- });
528
- }
529
- });
530
- }
531
- function ao() {
532
- const { authToken: e, tokenProps: n } = K(), a = ve();
533
- return ye({
534
- mutationFn: ({
535
- groupId: r,
536
- data: o
537
- }) => Xn(n.apiServiceUrl, (e == null ? void 0 : e.accessToken) || "", r, o),
538
- onSuccess: (r, o) => {
539
- a.invalidateQueries({ queryKey: ["group", o.groupId] }), a.invalidateQueries({
540
- queryKey: ["group-members", o.groupId]
541
- }), a.invalidateQueries({ queryKey: ["groups"] }), D.success("Members removed successfully");
542
- },
543
- onError: (r) => {
544
- console.error("Failed to remove group members:", r), D.error("Failed to remove members", {
545
- description: we(r, "Failed to remove members")
546
- });
547
- }
548
- });
549
- }
550
- const no = [];
551
- function oo({
552
- open: e,
553
- onOpenChange: n
554
- }) {
555
- var E, A, L;
556
- const { tokenProps: a } = K(), { currentUser: r } = nt(), o = (r == null ? void 0 : r.type) === "tenant", c = a == null ? void 0 : a.tenantId, {
557
- groups: m,
558
- isLoading: p,
559
- error: b,
560
- refetch: f
561
- } = Jr({
562
- type: o ? "TENANT_GROUP" : "all",
563
- tenantId: o ? c : void 0,
564
- includeMembers: !1
565
- }), g = b ? ur(b, "Unable to load groups.") : null, [l, u] = S({ kind: "list" }), [s, x] = S(null), v = to();
566
- ge(() => {
567
- e || (u({ kind: "list" }), x(null));
568
- }, [e]);
569
- const w = l.kind === "members" && m.find((N) => N.id === l.groupId) || null, h = async () => {
570
- if (s)
571
- try {
572
- await v.mutateAsync(s.id), x(null), u({ kind: "list" }), f();
573
- } catch {
574
- }
575
- };
576
- return /* @__PURE__ */ t(Ht, { open: e, onOpenChange: n, children: /* @__PURE__ */ i(qt, { className: "flex max-h-[640px] w-[720px] max-w-[92vw] flex-col gap-0 overflow-hidden p-0", children: [
577
- l.kind === "list" ? /* @__PURE__ */ i("div", { className: "shrink-0 border-b border-border px-5 pt-4 pb-3.5", children: [
578
- /* @__PURE__ */ t(Ze, { className: "text-[15px] font-semibold tracking-tight", children: "Group management" }),
579
- /* @__PURE__ */ t(et, { className: "mt-1 text-[12px] leading-[1.5] text-muted-foreground", children: "Organize people into groups for shared access." })
580
- ] }) : l.kind === "create" ? /* @__PURE__ */ i("div", { className: "flex h-10 shrink-0 items-center gap-1.5 border-b border-border px-5", children: [
581
- /* @__PURE__ */ t(
582
- "button",
583
- {
584
- type: "button",
585
- onClick: () => u({ kind: "list" }),
586
- "aria-label": "Back",
587
- className: "-ml-1 flex h-6 w-6 items-center justify-center rounded-[3px] text-muted-foreground hover:bg-accent hover:text-foreground",
588
- children: /* @__PURE__ */ t(zt, { className: "h-3.5 w-3.5" })
589
- }
590
- ),
591
- /* @__PURE__ */ t(Ze, { className: "truncate text-[13px] font-medium", children: "New group" }),
592
- /* @__PURE__ */ t(et, { className: "sr-only", children: "Create a new group to organize members." })
593
- ] }) : null,
594
- l.kind === "list" && /* @__PURE__ */ t(
595
- so,
596
- {
597
- groups: m,
598
- isLoading: p,
599
- errorMessage: g,
600
- onRetry: () => f(),
601
- currentUserId: r == null ? void 0 : r.id,
602
- onOpenGroup: (N) => u({ kind: "members", groupId: N }),
603
- onCreate: () => u({ kind: "create" }),
604
- onDeleteRequest: (N) => x(N)
605
- }
606
- ),
607
- l.kind === "members" && w && /* @__PURE__ */ t(
608
- lo,
609
- {
610
- group: w,
611
- isTenantViewer: o,
612
- canEdit: ((E = w.permissions) == null ? void 0 : E.canEdit) ?? w.createdBy === (r == null ? void 0 : r.id),
613
- canDelete: ((A = w.permissions) == null ? void 0 : A.canDelete) ?? w.createdBy === (r == null ? void 0 : r.id),
614
- canManageMembers: ((L = w.permissions) == null ? void 0 : L.canManageMembers) ?? w.createdBy === (r == null ? void 0 : r.id),
615
- onBack: () => u({ kind: "list" }),
616
- onMembersChanged: f,
617
- onUpdated: f,
618
- onRequestDelete: () => x(w)
619
- },
620
- w.id
621
- ),
622
- l.kind === "create" && /* @__PURE__ */ t(
623
- uo,
624
- {
625
- isTenantUser: o,
626
- tenantId: c,
627
- onCancel: () => u({ kind: "list" }),
628
- onCreated: (N) => {
629
- f(), u({ kind: "members", groupId: N });
630
- }
631
- }
632
- ),
633
- s && /* @__PURE__ */ i("div", { className: "flex shrink-0 items-center justify-between gap-3 border-t border-border bg-muted/40 px-5 py-2.5", children: [
634
- /* @__PURE__ */ i("div", { className: "min-w-0 text-[12px] text-foreground", children: [
635
- "Delete ",
636
- /* @__PURE__ */ t("span", { className: "font-medium", children: s.name }),
637
- "?",
638
- /* @__PURE__ */ t("span", { className: "ml-2 text-muted-foreground", children: "Members lose any access granted via this group." })
639
- ] }),
640
- /* @__PURE__ */ i("div", { className: "flex shrink-0 items-center gap-1.5", children: [
641
- /* @__PURE__ */ t(
642
- "button",
643
- {
644
- type: "button",
645
- onClick: () => x(null),
646
- disabled: v.isPending,
647
- className: "h-7 rounded-[5px] px-2.5 text-[12px] font-medium text-foreground/80 hover:bg-background",
648
- children: "Cancel"
649
- }
650
- ),
651
- /* @__PURE__ */ i(
652
- "button",
653
- {
654
- type: "button",
655
- onClick: h,
656
- disabled: v.isPending,
657
- className: "inline-flex h-7 items-center gap-1.5 rounded-[5px] bg-rose-600 px-2.5 text-[12px] font-medium text-white hover:bg-rose-700 disabled:opacity-60",
658
- children: [
659
- v.isPending ? /* @__PURE__ */ t(Re, { className: "h-3 w-3 animate-spin" }) : /* @__PURE__ */ t(ot, { className: "h-3 w-3" }),
660
- "Delete group"
661
- ]
662
- }
663
- )
664
- ] })
665
- ] })
666
- ] }) });
667
- }
668
- function so({
669
- groups: e,
670
- isLoading: n,
671
- errorMessage: a,
672
- onRetry: r,
673
- currentUserId: o,
674
- onOpenGroup: c,
675
- onCreate: m,
676
- onDeleteRequest: p
677
- }) {
678
- const [b, f] = S(""), g = V(
679
- () => e.filter(
680
- (l) => !b.trim() || l.name.toLowerCase().includes(b.toLowerCase()) || (l.description || "").toLowerCase().includes(b.toLowerCase())
681
- ),
682
- [e, b]
683
- );
684
- return /* @__PURE__ */ i("div", { className: "flex flex-1 flex-col overflow-hidden", children: [
685
- /* @__PURE__ */ i("div", { className: "flex shrink-0 items-center gap-2 border-b border-border px-5 py-2.5", children: [
686
- /* @__PURE__ */ i("div", { className: "flex flex-1 items-center gap-2 rounded-[5px] border border-border bg-background px-2 focus-within:border-foreground/40", children: [
687
- /* @__PURE__ */ t(xn, { className: "h-3 w-3 text-muted-foreground" }),
688
- /* @__PURE__ */ t(
689
- "input",
690
- {
691
- value: b,
692
- onChange: (l) => f(l.target.value),
693
- placeholder: "Search groups…",
694
- className: "h-7 flex-1 bg-transparent text-[12px] text-foreground placeholder:text-muted-foreground focus:outline-none"
695
- }
696
- ),
697
- b && /* @__PURE__ */ t(
698
- "button",
699
- {
700
- type: "button",
701
- onClick: () => f(""),
702
- className: "flex h-4 w-4 items-center justify-center rounded-[3px] text-muted-foreground hover:bg-accent hover:text-foreground",
703
- children: /* @__PURE__ */ t(Wt, { className: "h-2.5 w-2.5" })
704
- }
705
- )
706
- ] }),
707
- /* @__PURE__ */ i(
708
- "button",
709
- {
710
- type: "button",
711
- onClick: m,
712
- className: "inline-flex h-7 items-center gap-1.5 rounded-[5px] bg-foreground px-2.5 text-[12px] font-medium text-background hover:opacity-90",
713
- children: [
714
- /* @__PURE__ */ t(ee, { className: "h-3 w-3" }),
715
- "New group"
716
- ]
717
- }
718
- )
719
- ] }),
720
- /* @__PURE__ */ t("div", { className: "flex-1 overflow-y-auto", children: n ? /* @__PURE__ */ t("div", { className: "space-y-px p-3", children: [1, 2, 3].map((l) => /* @__PURE__ */ t(
721
- "div",
722
- {
723
- className: "h-12 animate-pulse rounded-[4px] bg-muted/60"
724
- },
725
- l
726
- )) }) : a ? /* @__PURE__ */ t(
727
- mr,
728
- {
729
- title: "Can't load groups",
730
- message: a,
731
- onRetry: r
732
- }
733
- ) : g.length === 0 && e.length === 0 ? /* @__PURE__ */ t(co, { onCreate: m }) : g.length === 0 ? /* @__PURE__ */ i("div", { className: "flex h-full flex-col items-center justify-center gap-1 py-10 text-center", children: [
734
- /* @__PURE__ */ i("div", { className: "text-[12px] text-foreground", children: [
735
- 'No groups match "',
736
- b,
737
- '"'
738
- ] }),
739
- /* @__PURE__ */ t("div", { className: "text-[11px] text-muted-foreground", children: "Try a different search." })
740
- ] }) : g.map((l) => {
741
- var u;
742
- return /* @__PURE__ */ t(
743
- io,
744
- {
745
- group: l,
746
- canDelete: ((u = l.permissions) == null ? void 0 : u.canDelete) ?? l.createdBy === o,
747
- onClick: () => c(l.id),
748
- onDelete: () => p(l)
749
- },
750
- l.id
751
- );
752
- }) })
753
- ] });
754
- }
755
- function io({
756
- group: e,
757
- canDelete: n,
758
- onClick: a,
759
- onDelete: r
760
- }) {
761
- let o = "";
762
- try {
763
- o = Xt(new Date(e.createdAt), "MMM d, yyyy");
764
- } catch {
765
- o = "";
766
- }
767
- return /* @__PURE__ */ i(
768
- "button",
769
- {
770
- type: "button",
771
- onClick: a,
772
- className: "group flex w-full items-center gap-3 border-b border-border/60 px-5 py-2.5 text-left hover:bg-accent/40",
773
- children: [
774
- /* @__PURE__ */ t("div", { className: "flex h-7 w-7 shrink-0 items-center justify-center rounded-[4px] border border-border bg-background text-muted-foreground", children: /* @__PURE__ */ t(ea, { className: "h-3.5 w-3.5" }) }),
775
- /* @__PURE__ */ i("div", { className: "min-w-0 flex-1", children: [
776
- /* @__PURE__ */ t("div", { className: "truncate text-[13px] font-medium text-foreground", children: e.name }),
777
- /* @__PURE__ */ i("div", { className: "mt-0.5 flex items-center gap-2 text-[11px] text-muted-foreground", children: [
778
- /* @__PURE__ */ i("span", { className: "inline-flex items-center gap-1", children: [
779
- /* @__PURE__ */ t(Zt, { className: "h-2.5 w-2.5" }),
780
- e.memberCount,
781
- " member",
782
- e.memberCount === 1 ? "" : "s"
783
- ] }),
784
- o && /* @__PURE__ */ i($, { children: [
785
- /* @__PURE__ */ t("span", { className: "text-border", children: "·" }),
786
- /* @__PURE__ */ i("span", { className: "inline-flex items-center gap-1", children: [
787
- /* @__PURE__ */ t(Qt, { className: "h-2.5 w-2.5" }),
788
- o
789
- ] })
790
- ] }),
791
- e.description && /* @__PURE__ */ i($, { children: [
792
- /* @__PURE__ */ t("span", { className: "text-border", children: "·" }),
793
- /* @__PURE__ */ t("span", { className: "truncate text-muted-foreground", children: e.description })
794
- ] })
795
- ] })
796
- ] }),
797
- /* @__PURE__ */ i("div", { className: "flex items-center gap-0.5 opacity-0 transition-opacity group-hover:opacity-100", children: [
798
- n && /* @__PURE__ */ t(
799
- "span",
800
- {
801
- role: "button",
802
- tabIndex: 0,
803
- onClick: (c) => {
804
- c.stopPropagation(), r();
805
- },
806
- onKeyDown: (c) => {
807
- (c.key === "Enter" || c.key === " ") && (c.preventDefault(), c.stopPropagation(), r());
808
- },
809
- "aria-label": `Delete ${e.name}`,
810
- className: "flex h-6 w-6 items-center justify-center rounded-[3px] text-muted-foreground hover:bg-accent hover:text-foreground",
811
- children: /* @__PURE__ */ t(ot, { className: "h-3 w-3" })
812
- }
813
- ),
814
- /* @__PURE__ */ t(vn, { className: "h-3.5 w-3.5 text-muted-foreground" })
815
- ] })
816
- ]
817
- }
818
- );
819
- }
820
- function co({ onCreate: e }) {
821
- return /* @__PURE__ */ i("div", { className: "flex h-full flex-col items-center justify-center gap-2 py-12 text-center", children: [
822
- /* @__PURE__ */ t("div", { className: "flex h-9 w-9 items-center justify-center rounded-full border border-border bg-muted/40 text-muted-foreground", children: /* @__PURE__ */ t(Kt, { className: "h-4 w-4" }) }),
823
- /* @__PURE__ */ t("div", { className: "text-[13px] font-medium text-foreground", children: "No groups yet" }),
824
- /* @__PURE__ */ t("div", { className: "max-w-[320px] text-[11.5px] leading-[1.55] text-muted-foreground", children: "Groups let you grant shared access to dashboards. Create one and add members." }),
825
- /* @__PURE__ */ i(
826
- "button",
827
- {
828
- type: "button",
829
- onClick: e,
830
- className: "mt-1 inline-flex h-7 items-center gap-1.5 rounded-[5px] bg-foreground px-2.5 text-[12px] font-medium text-background hover:opacity-90",
831
- children: [
832
- /* @__PURE__ */ t(ee, { className: "h-3 w-3" }),
833
- "New group"
834
- ]
835
- }
836
- )
837
- ] });
838
- }
839
- function lo({
840
- group: e,
841
- isTenantViewer: n,
842
- canEdit: a,
843
- canDelete: r,
844
- canManageMembers: o,
845
- onBack: c,
846
- onMembersChanged: m,
847
- onUpdated: p,
848
- onRequestDelete: b
849
- }) {
850
- const {
851
- data: f,
852
- isLoading: g,
853
- error: l,
854
- refetch: u
855
- } = Xr(e.id), s = (f == null ? void 0 : f.members) ?? no, x = l ? ur(l, "Unable to load members for this group.") : null, v = e.type === "TENANT_GROUP" ? "tenant" : "organization", { users: w } = Zr({
856
- type: v,
857
- tenantId: e.tenantId || void 0,
858
- active: !0,
859
- limit: 200
860
- }), h = V(
861
- () => new Set(s.map((y) => y.userId)),
862
- [s]
863
- ), E = ro(), A = ao(), L = eo(), [N, k] = S(!1), [re, ae] = S(e.name), [Ne, Q] = S(!1), [W, Y] = S(e.description || ""), [J, Se] = S(""), [ke, ne] = S(!1), oe = V(() => {
864
- const y = J.trim().toLowerCase();
865
- return w.filter((R) => !h.has(R.id)).filter(
866
- (R) => !y || (R.name || "").toLowerCase().includes(y) || (R.email || "").toLowerCase().includes(y)
867
- ).slice(0, 50);
868
- }, [w, h, J]), se = async () => {
869
- const y = re.trim();
870
- if (k(!1), y.length >= 3 && y !== e.name)
871
- try {
872
- await L.mutateAsync({
873
- groupId: e.id,
874
- data: { name: y }
875
- }), p();
876
- } catch {
877
- }
878
- }, ie = async () => {
879
- const y = W.trim();
880
- if (Q(!1), y !== (e.description || ""))
881
- try {
882
- await L.mutateAsync({
883
- groupId: e.id,
884
- data: { description: y }
885
- }), p();
886
- } catch {
887
- }
888
- }, Ce = async (y) => {
889
- if (o) {
890
- Se(""), ne(!1);
891
- try {
892
- await E.mutateAsync({
893
- groupId: e.id,
894
- data: {
895
- userIds: [y.id],
896
- userType: v === "tenant" ? "tenant" : "org"
897
- }
898
- }), u(), m();
899
- } catch {
900
- }
901
- }
902
- }, Ue = async (y) => {
903
- if (o)
904
- try {
905
- await A.mutateAsync({
906
- groupId: e.id,
907
- data: { userIds: [y] }
908
- }), u(), m();
909
- } catch {
910
- }
911
- };
912
- let j = "";
913
- try {
914
- j = Xt(new Date(e.createdAt), "MMM d, yyyy");
915
- } catch {
916
- j = "";
917
- }
918
- return /* @__PURE__ */ i("div", { className: "flex flex-1 flex-col overflow-hidden", children: [
919
- /* @__PURE__ */ i("div", { className: "flex h-10 shrink-0 items-center gap-1.5 border-b border-border px-5", children: [
920
- /* @__PURE__ */ t(
921
- "button",
922
- {
923
- type: "button",
924
- onClick: c,
925
- "aria-label": "Back",
926
- className: "-ml-1 flex h-6 w-6 items-center justify-center rounded-[3px] text-muted-foreground hover:bg-accent hover:text-foreground",
927
- children: /* @__PURE__ */ t(zt, { className: "h-3.5 w-3.5" })
928
- }
929
- ),
930
- N ? /* @__PURE__ */ t(
931
- "input",
932
- {
933
- autoFocus: !0,
934
- value: re,
935
- onChange: (y) => ae(y.target.value),
936
- onBlur: se,
937
- onKeyDown: (y) => {
938
- y.key === "Enter" && se(), y.key === "Escape" && (ae(e.name), k(!1));
939
- },
940
- className: "h-6 min-w-0 flex-1 rounded-[3px] border border-border bg-background px-1.5 text-[13px] font-medium text-foreground focus:border-foreground/40 focus:outline-none"
941
- }
942
- ) : /* @__PURE__ */ t(
943
- "button",
944
- {
945
- type: "button",
946
- onClick: () => {
947
- a && (ae(e.name), k(!0));
948
- },
949
- title: a ? "Click to rename" : e.name,
950
- disabled: !a,
951
- className: "truncate rounded-[3px] px-1 text-[13px] font-medium text-foreground enabled:hover:bg-accent disabled:cursor-default",
952
- children: e.name
953
- }
954
- ),
955
- /* @__PURE__ */ i("span", { className: "ml-1 inline-flex shrink-0 items-center gap-1 text-[10.5px] text-muted-foreground", children: [
956
- /* @__PURE__ */ t(Zt, { className: "h-2.5 w-2.5" }),
957
- s.length,
958
- " member",
959
- s.length === 1 ? "" : "s"
960
- ] })
961
- ] }),
962
- /* @__PURE__ */ t("div", { className: "shrink-0 border-b border-border px-5 py-2.5", children: Ne ? /* @__PURE__ */ i("div", { children: [
963
- /* @__PURE__ */ t(
964
- "textarea",
965
- {
966
- autoFocus: !0,
967
- rows: 2,
968
- value: W,
969
- onChange: (y) => Y(y.target.value),
970
- maxLength: 200,
971
- onKeyDown: (y) => {
972
- y.key === "Escape" && (Y(e.description || ""), Q(!1)), y.key === "Enter" && (y.metaKey || y.ctrlKey) && ie();
973
- },
974
- placeholder: "What is this group for?",
975
- className: "block w-full resize-none rounded-[5px] border border-border bg-background px-2 py-1.5 text-[12px] text-foreground placeholder:text-muted-foreground focus:border-foreground/40 focus:outline-none"
976
- }
977
- ),
978
- /* @__PURE__ */ i("div", { className: "mt-1.5 flex items-center justify-between", children: [
979
- /* @__PURE__ */ i("span", { className: "text-[10.5px] text-muted-foreground", children: [
980
- W.length,
981
- "/200 · Esc to cancel · ⌘↩ to save"
982
- ] }),
983
- /* @__PURE__ */ i("div", { className: "flex items-center gap-1.5", children: [
984
- /* @__PURE__ */ t(
985
- "button",
986
- {
987
- type: "button",
988
- onClick: () => {
989
- Y(e.description || ""), Q(!1);
990
- },
991
- className: "h-6 rounded-[5px] px-2 text-[11px] font-medium text-foreground/80 hover:bg-accent",
992
- children: "Cancel"
993
- }
994
- ),
995
- /* @__PURE__ */ t(
996
- "button",
997
- {
998
- type: "button",
999
- onClick: ie,
1000
- className: "inline-flex h-6 items-center rounded-[5px] bg-foreground px-2 text-[11px] font-medium text-background hover:opacity-90",
1001
- children: "Save"
1002
- }
1003
- )
1004
- ] })
1005
- ] })
1006
- ] }) : /* @__PURE__ */ i(
1007
- "button",
1008
- {
1009
- type: "button",
1010
- onClick: () => {
1011
- a && (Y(e.description || ""), Q(!0));
1012
- },
1013
- disabled: !a,
1014
- title: a ? "Click to edit description" : void 0,
1015
- className: "block w-full rounded-[3px] px-1 py-0.5 text-left enabled:hover:bg-accent/40 disabled:cursor-default",
1016
- children: [
1017
- e.description ? /* @__PURE__ */ t("p", { className: "text-[12px] leading-[1.55] text-foreground/90", children: e.description }) : /* @__PURE__ */ t("p", { className: "text-[12px] leading-[1.55] text-muted-foreground", children: a ? "Add a description…" : "No description" }),
1018
- /* @__PURE__ */ i("p", { className: "mt-1 text-[10.5px] text-muted-foreground", children: [
1019
- j ? `Created ${j}` : "Recently created",
1020
- a ? " · You can edit this group" : ""
1021
- ] })
1022
- ]
1023
- }
1024
- ) }),
1025
- o && /* @__PURE__ */ t(
1026
- mo,
1027
- {
1028
- query: J,
1029
- setQuery: Se,
1030
- open: ke,
1031
- setOpen: ne,
1032
- candidates: oe,
1033
- showKindChip: !n,
1034
- onAdd: Ce,
1035
- busy: E.isPending
1036
- }
1037
- ),
1038
- /* @__PURE__ */ t("div", { className: "flex-1 overflow-y-auto", children: g ? /* @__PURE__ */ t("div", { className: "space-y-px p-3", children: [1, 2, 3].map((y) => /* @__PURE__ */ t(
1039
- "div",
1040
- {
1041
- className: "h-10 animate-pulse rounded-[4px] bg-muted/60"
1042
- },
1043
- y
1044
- )) }) : x ? /* @__PURE__ */ t(
1045
- mr,
1046
- {
1047
- title: "Can't load members",
1048
- message: x,
1049
- onRetry: () => u()
1050
- }
1051
- ) : s.length === 0 ? /* @__PURE__ */ i("div", { className: "flex h-full flex-col items-center justify-center gap-1 py-10 text-center", children: [
1052
- /* @__PURE__ */ t("div", { className: "text-[12px] text-foreground", children: "No members yet" }),
1053
- /* @__PURE__ */ t("div", { className: "text-[11px] text-muted-foreground", children: o ? "Search above to add people to this group." : "This group does not have any members." })
1054
- ] }) : s.map((y) => {
1055
- var R, H, q, de, z, ce;
1056
- return /* @__PURE__ */ i(
1057
- "div",
1058
- {
1059
- className: "group flex items-center gap-2 border-b border-border/60 px-5 py-2",
1060
- children: [
1061
- /* @__PURE__ */ t(hr, { name: ((R = y.user) == null ? void 0 : R.name) || ((H = y.user) == null ? void 0 : H.email) || "?" }),
1062
- /* @__PURE__ */ i("div", { className: "min-w-0 flex-1", children: [
1063
- /* @__PURE__ */ t("div", { className: "truncate text-[12.5px] font-medium text-foreground", children: ((q = y.user) == null ? void 0 : q.name) || ((de = y.user) == null ? void 0 : de.email) || "Unknown" }),
1064
- ((z = y.user) == null ? void 0 : z.email) && y.user.name && /* @__PURE__ */ t("div", { className: "truncate text-[10.5px] text-muted-foreground", children: y.user.email })
1065
- ] }),
1066
- !n && /* @__PURE__ */ t("span", { className: "text-[10px] uppercase tracking-[0.06em] text-muted-foreground", children: y.userType }),
1067
- /* @__PURE__ */ t(
1068
- "button",
1069
- {
1070
- type: "button",
1071
- onClick: () => Ue(y.userId),
1072
- disabled: !o || A.isPending,
1073
- "aria-label": `Remove ${((ce = y.user) == null ? void 0 : ce.name) || "member"}`,
1074
- className: "flex h-6 w-6 items-center justify-center rounded-[3px] text-muted-foreground opacity-0 transition-opacity hover:bg-accent hover:text-foreground group-hover:opacity-100 disabled:opacity-30",
1075
- children: /* @__PURE__ */ t(Wt, { className: "h-3 w-3" })
1076
- }
1077
- )
1078
- ]
1079
- },
1080
- y.id
1081
- );
1082
- }) }),
1083
- r && /* @__PURE__ */ t("div", { className: "flex shrink-0 items-center justify-end gap-1.5 border-t border-border bg-muted/30 px-5 py-2.5", children: /* @__PURE__ */ i(
1084
- "button",
1085
- {
1086
- type: "button",
1087
- onClick: b,
1088
- className: "inline-flex h-7 items-center gap-1.5 rounded-[5px] border border-rose-200 bg-background px-2.5 text-[12px] font-medium text-rose-600 hover:bg-rose-50 dark:border-rose-900/60 dark:text-rose-400 dark:hover:bg-rose-950/30",
1089
- children: [
1090
- /* @__PURE__ */ t(ot, { className: "h-3 w-3" }),
1091
- "Delete group"
1092
- ]
1093
- }
1094
- ) })
1095
- ] });
1096
- }
1097
- function uo({
1098
- isTenantUser: e,
1099
- tenantId: n,
1100
- onCancel: a,
1101
- onCreated: r
1102
- }) {
1103
- const [o, c] = S(""), [m, p] = S(""), [b, f] = S(null), g = Zn(), l = o.trim().length >= 3 && o.trim().length <= 50, u = async () => {
1104
- if (!l) return;
1105
- f(null);
1106
- const s = {
1107
- name: o.trim(),
1108
- description: m.trim() || void 0,
1109
- type: e ? "TENANT_GROUP" : "ORG_GROUP",
1110
- ...e && n ? { tenantId: n } : {}
1111
- };
1112
- try {
1113
- const x = await g.mutateAsync(s), v = x == null ? void 0 : x.id;
1114
- v ? r(v) : a();
1115
- } catch (x) {
1116
- f(x instanceof Error ? x.message : "Failed to create group");
1117
- }
1118
- };
1119
- return /* @__PURE__ */ i("div", { className: "flex flex-1 flex-col overflow-hidden", children: [
1120
- /* @__PURE__ */ i("div", { className: "flex-1 overflow-y-auto px-5 py-4", children: [
1121
- /* @__PURE__ */ t(Gt, { children: "Name" }),
1122
- /* @__PURE__ */ t(
1123
- "input",
1124
- {
1125
- autoFocus: !0,
1126
- value: o,
1127
- onChange: (s) => c(s.target.value),
1128
- placeholder: "Marketing leads, North America sales, …",
1129
- maxLength: 50,
1130
- className: "mt-1 block h-7 w-full rounded-[5px] border border-border bg-background px-2 text-[12px] text-foreground placeholder:text-muted-foreground focus:border-foreground/40 focus:outline-none"
1131
- }
1132
- ),
1133
- /* @__PURE__ */ t("div", { className: "mt-1 text-[10.5px] text-muted-foreground", children: "3–50 characters." }),
1134
- /* @__PURE__ */ i("div", { className: "mt-4", children: [
1135
- /* @__PURE__ */ t(Gt, { children: "Description (optional)" }),
1136
- /* @__PURE__ */ t(
1137
- "textarea",
1138
- {
1139
- rows: 2,
1140
- value: m,
1141
- onChange: (s) => p(s.target.value),
1142
- maxLength: 200,
1143
- placeholder: "What is this group for?",
1144
- className: "mt-1 block w-full resize-none rounded-[5px] border border-border bg-background px-2 py-1.5 text-[12px] text-foreground placeholder:text-muted-foreground focus:border-foreground/40 focus:outline-none"
1145
- }
1146
- ),
1147
- /* @__PURE__ */ i("div", { className: "mt-1 flex justify-end text-[10.5px] text-muted-foreground", children: [
1148
- m.length,
1149
- "/200"
1150
- ] })
1151
- ] }),
1152
- b && /* @__PURE__ */ t("div", { className: "mt-3 rounded-[5px] border border-rose-200 bg-rose-50 px-2 py-1.5 text-[11.5px] text-rose-700 dark:border-rose-900/60 dark:bg-rose-950/30 dark:text-rose-300", children: b })
1153
- ] }),
1154
- /* @__PURE__ */ i("div", { className: "flex shrink-0 items-center justify-end gap-1.5 border-t border-border bg-muted/30 px-5 py-2.5", children: [
1155
- /* @__PURE__ */ t(
1156
- "button",
1157
- {
1158
- type: "button",
1159
- onClick: a,
1160
- disabled: g.isPending,
1161
- className: "h-7 rounded-[5px] px-2.5 text-[12px] font-medium text-foreground/80 hover:bg-accent",
1162
- children: "Cancel"
1163
- }
1164
- ),
1165
- /* @__PURE__ */ t(
1166
- "button",
1167
- {
1168
- type: "button",
1169
- onClick: u,
1170
- disabled: !l || g.isPending,
1171
- className: "inline-flex h-7 items-center gap-1.5 rounded-[5px] bg-foreground px-2.5 text-[12px] font-medium text-background hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-60",
1172
- children: g.isPending ? /* @__PURE__ */ i($, { children: [
1173
- /* @__PURE__ */ t(Re, { className: "h-3 w-3 animate-spin" }),
1174
- "Creating…"
1175
- ] }) : /* @__PURE__ */ i($, { children: [
1176
- /* @__PURE__ */ t(ee, { className: "h-3 w-3" }),
1177
- "Create group"
1178
- ] })
1179
- }
1180
- )
1181
- ] })
1182
- ] });
1183
- }
1184
- function mo({
1185
- query: e,
1186
- setQuery: n,
1187
- open: a,
1188
- setOpen: r,
1189
- candidates: o,
1190
- showKindChip: c,
1191
- onAdd: m,
1192
- busy: p
1193
- }) {
1194
- const b = Pt(null), f = Pt(null), [g, l] = S(null);
1195
- tn(() => {
1196
- if (!a) {
1197
- l(null);
1198
- return;
1199
- }
1200
- const s = () => {
1201
- const x = b.current;
1202
- if (!x) return;
1203
- const v = x.getBoundingClientRect(), w = 240, E = window.innerHeight - v.bottom < w + 16 && v.top > w;
1204
- l({
1205
- left: v.left,
1206
- top: E ? v.top - 6 : v.bottom + 6,
1207
- width: v.width,
1208
- above: E
1209
- });
1210
- };
1211
- return s(), window.addEventListener("resize", s), window.addEventListener("scroll", s, !0), () => {
1212
- window.removeEventListener("resize", s), window.removeEventListener("scroll", s, !0);
1213
- };
1214
- }, [a, o.length]), ge(() => {
1215
- if (!a) return;
1216
- const s = (x) => {
1217
- var w, h;
1218
- const v = x.target;
1219
- (w = b.current) != null && w.contains(v) || (h = f.current) != null && h.contains(v) || r(!1);
1220
- };
1221
- return document.addEventListener("mousedown", s), () => document.removeEventListener("mousedown", s);
1222
- }, [a, r]);
1223
- const u = a && o.length > 0 && g;
1224
- return /* @__PURE__ */ i("div", { className: "shrink-0 border-b border-border px-5 py-2.5", children: [
1225
- /* @__PURE__ */ i(
1226
- "div",
1227
- {
1228
- ref: b,
1229
- className: "flex items-center gap-2 rounded-[5px] border border-border bg-background px-2 focus-within:border-foreground/40",
1230
- children: [
1231
- /* @__PURE__ */ t(_n, { className: "h-3 w-3 text-muted-foreground" }),
1232
- /* @__PURE__ */ t(
1233
- "input",
1234
- {
1235
- value: e,
1236
- onChange: (s) => {
1237
- n(s.target.value), r(!0);
1238
- },
1239
- onFocus: () => r(!0),
1240
- placeholder: "Add a member by name or email…",
1241
- disabled: p,
1242
- className: "h-7 flex-1 bg-transparent text-[12px] text-foreground placeholder:text-muted-foreground focus:outline-none disabled:cursor-not-allowed"
1243
- }
1244
- )
1245
- ]
1246
- }
1247
- ),
1248
- u && typeof document < "u" && fn(
1249
- /* @__PURE__ */ t(
1250
- "div",
1251
- {
1252
- ref: f,
1253
- style: {
1254
- position: "fixed",
1255
- left: g.left,
1256
- top: g.top,
1257
- width: g.width,
1258
- transform: g.above ? "translateY(-100%)" : void 0
1259
- },
1260
- className: "z-[60] max-h-[240px] overflow-y-auto rounded-[5px] border border-border bg-background shadow-[0_8px_24px_-12px_rgba(0,0,0,0.18)]",
1261
- children: o.map((s) => /* @__PURE__ */ i(
1262
- "button",
1263
- {
1264
- type: "button",
1265
- onClick: () => m(s),
1266
- className: "flex w-full items-center gap-2 border-b border-border/60 px-2.5 py-2 text-left last:border-b-0 hover:bg-accent",
1267
- children: [
1268
- /* @__PURE__ */ t(hr, { name: s.name || s.email || "?" }),
1269
- /* @__PURE__ */ i("div", { className: "min-w-0 flex-1", children: [
1270
- /* @__PURE__ */ t("div", { className: "truncate text-[12px] font-medium text-foreground", children: s.name || s.email || "Unknown" }),
1271
- s.email && s.name && /* @__PURE__ */ t("div", { className: "truncate text-[10.5px] text-muted-foreground", children: s.email })
1272
- ] }),
1273
- c && s.type && /* @__PURE__ */ t("span", { className: "text-[10px] uppercase tracking-[0.06em] text-muted-foreground", children: s.type === "tenant" ? "tenant" : "org" })
1274
- ]
1275
- },
1276
- s.id
1277
- ))
1278
- }
1279
- ),
1280
- document.body
1281
- )
1282
- ] });
1283
- }
1284
- function ur(e, n) {
1285
- if (!e) return n;
1286
- if (e instanceof Error) {
1287
- const a = e.message || "", r = a.match(/\{[\s\S]*"error"\s*:\s*"([^"]+)"[\s\S]*\}/);
1288
- return r ? r[1] : a || n;
1289
- }
1290
- return typeof e == "string" ? e : n;
1291
- }
1292
- function mr({
1293
- title: e,
1294
- message: n,
1295
- onRetry: a
1296
- }) {
1297
- return /* @__PURE__ */ i("div", { className: "flex h-full flex-col items-center justify-center gap-2 px-6 py-10 text-center", children: [
1298
- /* @__PURE__ */ t("div", { className: "text-[12.5px] font-medium text-foreground", children: e }),
1299
- /* @__PURE__ */ t("div", { className: "max-w-[360px] text-[11.5px] leading-[1.55] text-muted-foreground", children: n }),
1300
- a && /* @__PURE__ */ t(
1301
- "button",
1302
- {
1303
- type: "button",
1304
- onClick: a,
1305
- className: "mt-1 inline-flex h-7 items-center rounded-[5px] border border-border bg-background px-2.5 text-[11.5px] font-medium text-foreground hover:bg-accent",
1306
- children: "Try again"
1307
- }
1308
- )
1309
- ] });
1310
- }
1311
- function Gt({ children: e }) {
1312
- return /* @__PURE__ */ t("label", { className: "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground", children: e });
1313
- }
1314
- function hr({ name: e }) {
1315
- const n = e.split(" ").map((a) => a[0]).filter(Boolean).slice(0, 2).join("").toUpperCase();
1316
- return /* @__PURE__ */ t(cr, { className: "h-6 w-6 shrink-0", children: /* @__PURE__ */ t(lr, { className: "text-[9px] font-semibold", children: n || "?" }) });
1317
- }
1318
- const ho = "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground";
1319
- function po({
1320
- open: e,
1321
- onOpenChange: n
1322
- }) {
1323
- const a = C(
1324
- (o) => {
1325
- var c, m;
1326
- return Sn({
1327
- dashboardDefault: (m = (c = o.dashboard) == null ? void 0 : c.exportDefaults) == null ? void 0 : m.csvEncoding
1328
- });
1329
- }
1330
- ), { setDashboardExportDefaults: r } = C(
1331
- (o) => o.actions
1332
- );
1333
- return /* @__PURE__ */ t(Ht, { open: e, onOpenChange: n, children: /* @__PURE__ */ i(qt, { className: "rounded-control border-border/60 sm:max-w-[440px] sm:rounded-control", children: [
1334
- /* @__PURE__ */ i(ta, { children: [
1335
- /* @__PURE__ */ t(Ze, { className: "text-[15px]", children: "Download settings" }),
1336
- /* @__PURE__ */ t(et, { className: "text-[13px] leading-5", children: "Applies to every CSV downloaded or delivered from this dashboard. People can still change it for a single download." })
1337
- ] }),
1338
- /* @__PURE__ */ i("div", { className: "space-y-2", children: [
1339
- /* @__PURE__ */ t(Ha, { htmlFor: "dashboard-csv-encoding", className: ho, children: "CSV encoding" }),
1340
- /* @__PURE__ */ i(
1341
- qa,
1342
- {
1343
- value: a,
1344
- onValueChange: (o) => r({ csvEncoding: o }),
1345
- children: [
1346
- /* @__PURE__ */ t(za, { id: "dashboard-csv-encoding", size: "sm", children: /* @__PURE__ */ t(Ka, {}) }),
1347
- /* @__PURE__ */ t(Qa, { children: ra.map((o) => /* @__PURE__ */ t(Wa, { value: o.value, children: o.label }, o.value)) })
1348
- ]
1349
- }
1350
- )
1351
- ] })
1352
- ] }) });
1353
- }
1354
- function fe(e, n, a) {
1355
- var c, m;
1356
- const r = (e.controls || []).find(
1357
- (p) => p.id === a
1358
- );
1359
- if (r)
1360
- return r.label;
1361
- const o = (m = (c = Te(e, n)) == null ? void 0 : c.controls) == null ? void 0 : m.find(
1362
- (p) => p.id === a
1363
- );
1364
- return (o == null ? void 0 : o.label) || a;
1365
- }
1366
- function be(e, n) {
1367
- var a;
1368
- return ((a = Te(e, n)) == null ? void 0 : a.title) || n;
1369
- }
1370
- function fo(e) {
1371
- const { errors: n, dashboard: a } = e;
1372
- if (!a)
1373
- return n;
1374
- const r = /* @__PURE__ */ new Map();
1375
- for (const o of n) {
1376
- const c = o.match(
1377
- /^Card '(.+)' binding for control '(.+)' maps to missing metric '(.+)'\.$/
1378
- );
1379
- if (c) {
1380
- const [, g, l] = c, u = `${g}:${l}:missing-metric`;
1381
- r.has(u) || r.set(
1382
- u,
1383
- `"${be(a, g)}" has an outdated "${fe(
1384
- a,
1385
- g,
1386
- l
1387
- )}" mapping. Some choices still point to metrics that are no longer available on this card. Open the card controls and choose replacements.`
1388
- );
1389
- continue;
1390
- }
1391
- const m = o.match(
1392
- /^Card '(.+)' binding for control '(.+)' maps to missing group-by field '(.+)'\.$/
1393
- );
1394
- if (m) {
1395
- const [, g, l] = m, u = `${g}:${l}:missing-group-by`;
1396
- r.has(u) || r.set(
1397
- u,
1398
- `"${be(a, g)}" has an outdated "${fe(
1399
- a,
1400
- g,
1401
- l
1402
- )}" mapping. Some choices still point to fields that are no longer available on this card. Open the card controls and choose replacements.`
1403
- );
1404
- continue;
1405
- }
1406
- const p = o.match(
1407
- /^Card '(.+)' binding for control '(.+)' maps to an invalid metric target\.$/
1408
- );
1409
- if (p) {
1410
- const [, g, l] = p, u = `${g}:${l}:invalid-metric`;
1411
- r.has(u) || r.set(
1412
- u,
1413
- `"${be(a, g)}" has an invalid "${fe(
1414
- a,
1415
- g,
1416
- l
1417
- )}" metric mapping. Open the card controls and choose a valid metric for each option.`
1418
- );
1419
- continue;
1420
- }
1421
- const b = o.match(
1422
- /^Card '(.+)' binding for control '(.+)' maps to an invalid group-by target\.$/
1423
- );
1424
- if (b) {
1425
- const [, g, l] = b, u = `${g}:${l}:invalid-group-by`;
1426
- r.has(u) || r.set(
1427
- u,
1428
- `"${be(a, g)}" has an invalid "${fe(
1429
- a,
1430
- g,
1431
- l
1432
- )}" field mapping. Open the card controls and choose a valid field for each option.`
1433
- );
1434
- continue;
1435
- }
1436
- const f = o.match(
1437
- /^Card '(.+)' binding for control '(.+)' requires at least one temporal group-by field\.$/
1438
- );
1439
- if (f) {
1440
- const [, g, l] = f, u = `${g}:${l}:missing-temporal-group-by`;
1441
- r.has(u) || r.set(
1442
- u,
1443
- `"${be(a, g)}" can no longer use "${fe(
1444
- a,
1445
- g,
1446
- l
1447
- )}" for time grain because the card does not currently group by a date field.`
1448
- );
1449
- continue;
1450
- }
1451
- r.set(o, o);
1452
- }
1453
- return Array.from(r.values());
1454
- }
1455
- function bo({
1456
- visible: e,
1457
- onSelect: n
1458
- }) {
1459
- return e ? /* @__PURE__ */ i(P, { onSelect: n, children: [
1460
- /* @__PURE__ */ t(aa, { className: "h-3.5 w-3.5" }),
1461
- "Schedule email report"
1462
- ] }) : null;
1463
- }
1464
- function go({
1465
- scheduleReportVisible: e,
1466
- analyticalBriefingVisible: n,
1467
- onScheduleReport: a,
1468
- onCreateAnalyticalBriefing: r
1469
- }) {
1470
- return /* @__PURE__ */ i($, { children: [
1471
- /* @__PURE__ */ t(
1472
- bo,
1473
- {
1474
- visible: e,
1475
- onSelect: a
1476
- }
1477
- ),
1478
- n ? /* @__PURE__ */ i(P, { onSelect: r, children: [
1479
- /* @__PURE__ */ t(ee, { className: "h-3.5 w-3.5" }),
1480
- "Create analytical briefing"
1481
- ] }) : null
1482
- ] });
1483
- }
1484
- function xo(e) {
1485
- var f, g, l;
1486
- const { saved: n, draft: a, usage: r } = e, o = [], c = bn(n);
1487
- for (const [u, s] of Object.entries(r.inputs))
1488
- !s || !Rt(n, u) || Rt(a, u) || o.push({
1489
- target: "input",
1490
- id: u,
1491
- label: gn(n, c, u),
1492
- bookmarks: s,
1493
- remembered: 0
1494
- });
1495
- const m = new Set((a.sheets ?? []).map((u) => u.id));
1496
- for (const u of n.sheets ?? []) {
1497
- const s = r.sheets[u.id] ?? 0;
1498
- !s || m.has(u.id) || o.push({
1499
- target: "sheet",
1500
- id: u.id,
1501
- label: ((f = u.title) == null ? void 0 : f.trim()) || "Untitled sheet",
1502
- bookmarks: s,
1503
- remembered: 0
1504
- });
1505
- }
1506
- const p = Ut(n), b = Ut(a);
1507
- for (const [u, s] of Object.entries(r.tables)) {
1508
- if (!p.has(u)) continue;
1509
- const x = Te(n, u), v = ((g = x == null ? void 0 : x.title) == null ? void 0 : g.trim()) || "Untitled table";
1510
- if (!b.has(u)) {
1511
- o.push({
1512
- target: "table",
1513
- id: u,
1514
- label: v,
1515
- bookmarks: s.bookmarks,
1516
- remembered: s.remembered
1517
- });
1518
- continue;
1519
- }
1520
- const w = x ? Tt(x) : void 0, h = Te(a, u), E = h ? Tt(h) : void 0;
1521
- if (!(!x || !w || !E))
1522
- for (const [A, L] of Object.entries(s.columns)) {
1523
- if (!(L.bookmarks || L.remembered) || yn(A) || !w.has(A) || E.has(A))
1524
- continue;
1525
- const N = wn(x, A), k = ((l = N == null ? void 0 : N.label) == null ? void 0 : l.trim()) || (N == null ? void 0 : N.name);
1526
- o.push({
1527
- target: "column",
1528
- id: A,
1529
- cardId: u,
1530
- label: k ? `${k} in ${v}` : `A column in ${v}`,
1531
- bookmarks: L.bookmarks,
1532
- remembered: L.remembered
1533
- });
1534
- }
1535
- }
1536
- return o;
1537
- }
1538
- const vo = "dashboard-bookmark-usage";
1539
- function yo(e) {
1540
- var b;
1541
- const n = C((f) => f.viewerStateClient), a = (b = e.saved) == null ? void 0 : b.id, o = na({
1542
- // Keyed by the viewer, never by the client object (TanStack drops functions when hashing).
1543
- queryKey: [vo, (n == null ? void 0 : n.viewerKey) ?? null],
1544
- queryFn: () => n.bookmarks.usage(),
1545
- enabled: e.enabled && !!n && !!a,
1546
- staleTime: 5 * 6e4,
1547
- retry: !1
1548
- }).data, { saved: c, draft: m, enabled: p } = e;
1549
- return V(() => !p || !c || !o ? [] : !o.bookmarks && !Object.keys(o.tables).length ? [] : xo({ saved: c, draft: m, usage: o }), [m, p, c, o]);
1550
- }
1551
- function Vt(e, n, a) {
1552
- return `${e} ${e === 1 ? n : a}`;
1553
- }
1554
- function wo(e) {
1555
- const n = [
1556
- e.bookmarks ? Vt(e.bookmarks, "bookmark", "bookmarks") : null,
1557
- e.remembered ? Vt(e.remembered, "remembered layout", "remembered layouts") : null
1558
- ].filter(Boolean).join(", ");
1559
- return e.target === "sheet" ? { name: `${e.label} sheet`, uses: n } : e.target === "table" ? { name: `${e.label} table`, uses: n } : { name: e.label, uses: n };
1560
- }
1561
- function No({
1562
- saved: e,
1563
- draft: n,
1564
- enabled: a
1565
- }) {
1566
- const r = yo({ saved: e, draft: n, enabled: a });
1567
- return r.length ? /* @__PURE__ */ i(Ya, { children: [
1568
- /* @__PURE__ */ t(Ja, { asChild: !0, children: /* @__PURE__ */ i(
1569
- U,
1570
- {
1571
- variant: "ghost",
1572
- size: "xs",
1573
- className: "gap-1 text-muted-foreground hover:text-foreground",
1574
- children: [
1575
- /* @__PURE__ */ t(oa, { className: "h-3.5 w-3.5", "aria-hidden": "true" }),
1576
- "Affects saved views"
1577
- ]
1578
- }
1579
- ) }),
1580
- /* @__PURE__ */ i(Xa, { align: "end", className: "w-[320px] p-3 text-[12px]", children: [
1581
- /* @__PURE__ */ t("p", { className: "text-foreground", children: "This edit removes parts of the dashboard that viewers saved. Their views still open, with a note about what no longer applies." }),
1582
- /* @__PURE__ */ t(
1583
- "ul",
1584
- {
1585
- "aria-label": "Affected saved views",
1586
- className: "mt-2 grid gap-1 border-t border-border/60 pt-2",
1587
- children: r.map((o) => {
1588
- const { name: c, uses: m } = wo(o);
1589
- return /* @__PURE__ */ i(
1590
- "li",
1591
- {
1592
- className: "flex items-baseline justify-between gap-3",
1593
- children: [
1594
- /* @__PURE__ */ t("span", { className: "min-w-0 truncate text-foreground", children: c }),
1595
- /* @__PURE__ */ t("span", { className: "shrink-0 text-[11.5px] text-muted-foreground", children: m })
1596
- ]
1597
- },
1598
- `${o.target}:${o.cardId ?? ""}:${o.id}`
1599
- );
1600
- })
1601
- }
1602
- )
1603
- ] })
1604
- ] }) : null;
1605
- }
1606
- function jt(e, n) {
1607
- return {
1608
- dashboard: rt(e),
1609
- semanticExecutionPayload: rt(n)
1610
- };
1611
- }
1612
- function Xo() {
1613
- var vt, yt, wt, Nt, St;
1614
- const {
1615
- authToken: e,
1616
- tokenProps: n,
1617
- id: a,
1618
- showBriefings: r
1619
- } = K(), o = sa(), { isLocalDev: c } = ia(), {
1620
- canEditDashboard: m,
1621
- hasInspectionUser: p,
1622
- inspectionMessage: b,
1623
- isInspectionMode: f,
1624
- isInspectionSurface: g
1625
- } = da(), { openBrandStudioPreview: l } = ca(), { permissions: u } = $n(), s = la(), { isLoading: x } = ua(), v = C((d) => d.theme), w = C((d) => d.isDownloadingPdf), h = C((d) => d.dashboard), E = C((d) => d.selectedSheetId), A = (vt = h == null ? void 0 : h.sheets) == null ? void 0 : vt.find(
1626
- (d) => d.id === E
1627
- ), L = Nn(A), N = L ? (yt = A == null ? void 0 : A.document) == null ? void 0 : yt.page : void 0, k = C(
1628
- (d) => d.isDashboardEditing
1629
- ), { setDashboardTitle: re } = C((d) => d.actions), [ae, Ne] = S(!1), [Q, W] = S(!1), [Y, J] = S(!1), [Se, ke] = S(!1), [ne, oe] = S(null), [se, ie] = S(null), { registerBriefingViewer: Ce } = ma();
1630
- ge(
1631
- () => Ce((d) => ie(d)),
1632
- [Ce]
1633
- );
1634
- const [Ue, j] = S(!1), [y, R] = S(!1), [H, q] = S(null), [de, z] = S([]), [ce, De] = S(!1), [pr, ct] = S(!1), T = C((d) => d.isVisualEditing);
1635
- kt((d) => d.card);
1636
- const fr = Oe(
1637
- (d) => d.selectedDashboard
1638
- ), br = Oe(
1639
- (d) => d.initialDashboard
1640
- );
1641
- Oe((d) => d.selectedVisual), C((d) => d.selectedFrameId), kt((d) => d.frame);
1642
- const lt = C(
1643
- (d) => d.showDashboardJSON
1644
- );
1645
- C((d) => d.onSaveFunction);
1646
- const { setIsDashboardEditing: ut, setShowDashboardJSON: mt } = C(
1647
- (d) => d.actions
1648
- ), { setInitialDashboard: ht, clearSelectedDashboard: $e } = Oe(
1649
- (d) => d.actions
1650
- ), le = !!n.orgUserId || !!(n.tenantId && n.endUserId && n.endUserEmail), { resources: Ee } = ha(We.DASHBOARD), { data: Be } = pa(), gr = ((wt = Be == null ? void 0 : Be.preference) == null ? void 0 : wt.defaultDashboardId) || null, { mutate: xr, isPending: vr } = fa(), { currentUser: yr } = nt(), wr = ba(yr), B = fr || br, G = ga({
1651
- config: n.config,
1652
- canNavigateDashboardHub: le,
1653
- canShareDashboard: ((Nt = B == null ? void 0 : B.permissions) == null ? void 0 : Nt.canShare) === !0,
1654
- canManageGroups: wr
1655
- }), pt = B ? {
1656
- id: B.id,
1657
- title: (h == null ? void 0 : h.title) || B.title || "Dashboard"
1658
- } : null, { handleAddNewFrame: Nr } = xa(), [Fe, Ge] = S(!1), [Sr, ue] = S(!1), [Ve, Ie] = S("close"), me = va(We.DASHBOARD), [M, he] = S(null), kr = async (d, _) => {
1659
- if (!f) {
1660
- if (!(h != null && h.id)) {
1661
- console.log("No dashboard ID found");
1662
- return;
1663
- }
1664
- console.log("Updating dashboard title:", {
1665
- dashboardId: h.id,
1666
- newTitle: d,
1667
- previousTitle: _
1668
- }), me.mutate(
1669
- {
1670
- resourceId: h.id,
1671
- data: { title: d }
1672
- },
1673
- {
1674
- onSuccess: () => {
1675
- he(
1676
- (O) => (O == null ? void 0 : O.dashboard.id) === h.id ? {
1677
- ...O,
1678
- dashboard: { ...O.dashboard, title: d }
1679
- } : O
1680
- ), D.success("Dashboard title updated");
1681
- },
1682
- onError: (O) => {
1683
- console.error("Failed to update dashboard title:", O), D.error("Failed to update dashboard title");
1684
- const Z = C.getState().dashboard;
1685
- (Z == null ? void 0 : Z.id) === h.id && Z.title === d && re(_);
1686
- }
1687
- }
1688
- );
1689
- }
1690
- };
1691
- ge(() => {
1692
- if (Ee && Ee.length > 0) {
1693
- const d = h == null ? void 0 : h.id;
1694
- if (d) {
1695
- const _ = Ee.find(
1696
- (O) => O.id === d
1697
- );
1698
- _ && ht(_);
1699
- }
1700
- }
1701
- }, [Ee, h == null ? void 0 : h.id, ht]);
1702
- const Cr = n.orgUserId || n.tenantId, je = V(
1703
- () => So({
1704
- accessToken: e == null ? void 0 : e.accessToken,
1705
- dashboardId: (h == null ? void 0 : h.id) || a || n.dashboard_id,
1706
- selectedSheetId: L ? E : void 0,
1707
- pageSize: N == null ? void 0 : N.size,
1708
- orientation: N == null ? void 0 : N.orientation,
1709
- theme: v
1710
- }),
1711
- [
1712
- e == null ? void 0 : e.accessToken,
1713
- a,
1714
- h == null ? void 0 : h.id,
1715
- L,
1716
- N == null ? void 0 : N.orientation,
1717
- N == null ? void 0 : N.size,
1718
- E,
1719
- v,
1720
- n.dashboard_id
1721
- ]
1722
- ), He = k && !T && !f && Cr && m, { setDashboard: qe } = C((d) => d.actions), Dr = C(
1723
- (d) => d.semanticExecutionPayload
1724
- ), Er = () => {
1725
- ut(!0);
1726
- }, Ae = () => {
1727
- ut(!1), mt(!1), he(null);
1728
- };
1729
- ge(() => {
1730
- if (!k) {
1731
- M && he(null);
1732
- return;
1733
- }
1734
- if (M || !h || x)
1735
- return;
1736
- const d = ya(C.getState());
1737
- he(
1738
- jt(d.dashboard, d.semanticExecutionPayload)
1739
- );
1740
- }, [
1741
- h,
1742
- M,
1743
- k,
1744
- x,
1745
- Dr
1746
- ]);
1747
- const ze = (M == null ? void 0 : M.dashboard) ?? null, { isDirty: Ke, isDirtyPending: Ir, resetDirty: pe } = kn(
1748
- h,
1749
- ze,
1750
- 300,
1751
- 1e3,
1752
- Cn
1753
- ), ft = rn(
1754
- ze,
1755
- f,
1756
- m
1757
- ), bt = Ke || Ir, Le = Fe || me.isPending, Ar = () => {
1758
- if (f) {
1759
- M && qe(M.dashboard, {
1760
- semanticExecutionPayload: M.semanticExecutionPayload
1761
- }), Ae(), pe();
1762
- return;
1763
- }
1764
- ft() ? (Ie("close"), ue(!0)) : (Ae(), pe());
1765
- }, Lr = async () => {
1766
- await Qe({
1767
- closeAfterSave: !0,
1768
- navigateHomeAfterSave: Ve === "home"
1769
- });
1770
- }, Mr = () => {
1771
- const d = Ve === "home" && !!le;
1772
- M && qe(M.dashboard, {
1773
- semanticExecutionPayload: M.semanticExecutionPayload
1774
- }), Ae(), d && $e(), Ie("close"), ue(!1), pe();
1775
- }, Or = () => {
1776
- M && (qe(M.dashboard, {
1777
- semanticExecutionPayload: M.semanticExecutionPayload
1778
- }), pe());
1779
- }, _r = () => {
1780
- if (le) {
1781
- if (k && ft()) {
1782
- Ie("home"), ue(!0);
1783
- return;
1784
- }
1785
- $e();
1786
- }
1787
- };
1788
- async function Qe(d) {
1789
- if (f)
1790
- return;
1791
- const _ = C.getState().dashboard;
1792
- if (!_)
1793
- return;
1794
- const O = (d == null ? void 0 : d.closeAfterSave) ?? ce, Z = (d == null ? void 0 : d.navigateHomeAfterSave) ?? !1;
1795
- De(O), O && ue(!1);
1796
- const $r = rt(_);
1797
- R(!0), q(null), z([]), Ge(!0);
1798
- const Br = {
1799
- template: _
1800
- };
1801
- me.mutate(
1802
- {
1803
- resourceId: _.id,
1804
- data: Br
1805
- },
1806
- {
1807
- onSuccess: () => {
1808
- Ge(!1), D.success("Dashboard saved!"), he(
1809
- jt(
1810
- $r,
1811
- C.getState().semanticExecutionPayload
1812
- )
1813
- ), R(!1), De(!1), O && (Ae(), pe(), Z && le && $e()), Ie("close");
1814
- },
1815
- onError: (Fr) => {
1816
- Ge(!1), q("Failed to save dashboard. Please try again.");
1817
- const Me = Fr.details, Gr = Array.isArray(
1818
- Me == null ? void 0 : Me.errors
1819
- ) ? (Me.errors || []).filter(
1820
- (Vr) => typeof Vr == "string"
1821
- ) : [];
1822
- z(
1823
- fo({
1824
- errors: Gr,
1825
- dashboard: _ || void 0
1826
- })
1827
- ), D.error("Failed to save dashboard");
1828
- }
1829
- }
1830
- );
1831
- }
1832
- const gt = h.title;
1833
- me.isPending && console.log("Title during update:", {
1834
- title: gt,
1835
- dashboardStateTitle: h.title,
1836
- dashboardId: h == null ? void 0 : h.id
1837
- });
1838
- const Pr = le && !!(e != null && e.accessToken) && !!(n != null && n.apiServiceUrl), Rr = !f && G.showDashboardHub && Pr, Tr = !f && s && G.showDashboardHub, F = (h == null ? void 0 : h.id) || null, xt = wa(
1839
- (St = n.config) == null ? void 0 : St.showBriefings,
1840
- r
1841
- ), X = !!F && gr === F, Ur = () => {
1842
- !F || f || xr({
1843
- dashboardId: X ? null : F
1844
- });
1845
- };
1846
- return !s && !T ? null : /* @__PURE__ */ i(
1847
- "div",
1848
- {
1849
- className: "flex min-h-11 shrink-0 items-center justify-between gap-2 overflow-x-auto border-b px-4 py-1.5",
1850
- role: "dashboard-controls",
1851
- children: [
1852
- /* @__PURE__ */ i("div", { className: "flex items-center gap-2", children: [
1853
- Tr && !T && /* @__PURE__ */ t(
1854
- mn,
1855
- {
1856
- "aria-label": "Dashboard Hub",
1857
- tooltip: "Dashboard Hub",
1858
- onClick: _r,
1859
- className: "h-7 w-7 px-0",
1860
- buttonProps: { size: "xs" },
1861
- children: /* @__PURE__ */ t(Na, { className: "h-3.5 w-3.5" })
1862
- }
1863
- ),
1864
- !T && s && (x ? /* @__PURE__ */ t(
1865
- "div",
1866
- {
1867
- className: "h-4 w-28 animate-pulse rounded-md bg-muted/70",
1868
- "aria-label": "Loading dashboard title",
1869
- role: "status",
1870
- children: /* @__PURE__ */ t("span", { className: "sr-only", children: "Loading dashboard title" })
1871
- }
1872
- ) : /* @__PURE__ */ i($, { children: [
1873
- /* @__PURE__ */ t(
1874
- Sa,
1875
- {
1876
- value: gt || "Untitled Dashboard",
1877
- onSave: (d) => {
1878
- console.log("EditableText onSave called:", {
1879
- newTitle: d,
1880
- canEditDashboard: m,
1881
- dashboardId: h == null ? void 0 : h.id
1882
- });
1883
- const _ = (h == null ? void 0 : h.title) || "";
1884
- re(d), kr(d, _);
1885
- },
1886
- isEditable: ka({
1887
- isDashboardEditing: k,
1888
- canEditDashboard: m === !0 && !f
1889
- }),
1890
- displayClassName: "text-[13px] font-medium",
1891
- inputClassName: "text-[13px] font-medium",
1892
- placeholder: "Dashboard Title",
1893
- isPending: me.isPending
1894
- }
1895
- ),
1896
- G.showDashboardHub && X && /* @__PURE__ */ t(
1897
- "span",
1898
- {
1899
- className: "shrink-0 rounded-[4px] border border-border/60 px-1.5 py-px text-[10px] font-medium uppercase tracking-[0.06em] text-muted-foreground",
1900
- title: "Default dashboard",
1901
- children: "Default"
1902
- }
1903
- ),
1904
- Rr && F && /* @__PURE__ */ t(Lt, { children: /* @__PURE__ */ i(Mt, { children: [
1905
- /* @__PURE__ */ t(Ot, { asChild: !0, children: /* @__PURE__ */ t(
1906
- U,
1907
- {
1908
- variant: "ghost",
1909
- size: "xs",
1910
- onClick: Ur,
1911
- disabled: vr || !(e != null && e.accessToken) || !(n != null && n.apiServiceUrl),
1912
- className: xe(
1913
- "w-7 px-0",
1914
- X ? "bg-primary/10 text-primary hover:bg-primary/15 hover:text-primary focus-visible:bg-primary/15" : "text-muted-foreground hover:text-foreground"
1915
- ),
1916
- "aria-pressed": X,
1917
- "aria-label": X ? "Remove as default dashboard" : "Set as default dashboard",
1918
- children: /* @__PURE__ */ t(Ca, { className: "h-3.5 w-3.5" })
1919
- }
1920
- ) }),
1921
- /* @__PURE__ */ t(_t, { children: /* @__PURE__ */ t("p", { children: X ? "Remove as default dashboard" : "Set as default dashboard" }) })
1922
- ] }) })
1923
- ] }))
1924
- ] }),
1925
- /* @__PURE__ */ i("div", { className: "flex items-center gap-2", children: [
1926
- T && /* @__PURE__ */ i($, { children: [
1927
- /* @__PURE__ */ t(an, {}),
1928
- /* @__PURE__ */ t(nn, {})
1929
- ] }),
1930
- s && !f && /* @__PURE__ */ t(hn, {}),
1931
- !T && k && !f && u.canUseFilters && s && /* @__PURE__ */ t(on, {}),
1932
- k && !T && !f && s && !L && /* @__PURE__ */ i("div", { className: "inline-flex h-7 items-stretch overflow-hidden rounded-control border border-input bg-background", children: [
1933
- /* @__PURE__ */ i(
1934
- U,
1935
- {
1936
- variant: "ghost",
1937
- size: "xs",
1938
- disabled: !k,
1939
- onClick: () => void Nr(),
1940
- className: "h-full rounded-none border-0 shadow-none hover:bg-accent",
1941
- children: [
1942
- /* @__PURE__ */ t(ee, { className: "h-3.5 w-3.5" }),
1943
- "Visual"
1944
- ]
1945
- }
1946
- ),
1947
- /* @__PURE__ */ i(Ct, { modal: !1, children: [
1948
- /* @__PURE__ */ t(Dt, { asChild: !0, children: /* @__PURE__ */ t(
1949
- U,
1950
- {
1951
- variant: "ghost",
1952
- size: "xs",
1953
- className: "h-full w-7 rounded-none border-0 border-l border-border/60 px-0 shadow-none hover:bg-accent",
1954
- "aria-label": "Open visual options",
1955
- disabled: !k,
1956
- children: /* @__PURE__ */ t(en, { className: "h-3.5 w-3.5" })
1957
- }
1958
- ) }),
1959
- /* @__PURE__ */ t(
1960
- Et,
1961
- {
1962
- align: "end",
1963
- className: "z-[60] w-48 rounded-[6px] border-border/60 p-1 shadow-sm",
1964
- children: /* @__PURE__ */ i(P, { onClick: () => ct(!0), children: [
1965
- /* @__PURE__ */ t(ee, { className: "h-3.5 w-3.5" }),
1966
- "From library..."
1967
- ] })
1968
- }
1969
- )
1970
- ] }),
1971
- /* @__PURE__ */ t(
1972
- sn,
1973
- {
1974
- open: pr,
1975
- onOpenChange: ct
1976
- }
1977
- )
1978
- ] }),
1979
- !T && !k && (m || f) && (!g || !p || m !== void 0) && s && /* @__PURE__ */ i("div", { className: "inline-flex items-center gap-1", children: [
1980
- /* @__PURE__ */ i(U, { size: "xs", onClick: Er, children: [
1981
- /* @__PURE__ */ t(Da, { className: "h-3.5 w-3.5" }),
1982
- f ? "Inspect" : "Edit"
1983
- ] }),
1984
- b ? /* @__PURE__ */ t(Lt, { children: /* @__PURE__ */ i(Mt, { children: [
1985
- /* @__PURE__ */ t(Ot, { asChild: !0, children: /* @__PURE__ */ t(
1986
- "button",
1987
- {
1988
- type: "button",
1989
- "aria-label": b,
1990
- className: "inline-flex size-6 items-center justify-center rounded-control text-muted-foreground outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
1991
- children: /* @__PURE__ */ t(Za, { "aria-hidden": "true", className: "size-3.5" })
1992
- }
1993
- ) }),
1994
- /* @__PURE__ */ t(_t, { children: /* @__PURE__ */ t("p", { children: b }) })
1995
- ] }) }) : null
1996
- ] }),
1997
- He && s && Ke && /* @__PURE__ */ t(
1998
- No,
1999
- {
2000
- saved: ze,
2001
- draft: h,
2002
- enabled: k && !f
2003
- }
2004
- ),
2005
- He && s && Ke && /* @__PURE__ */ i(
2006
- U,
2007
- {
2008
- variant: "outline",
2009
- size: "xs",
2010
- onClick: Or,
2011
- disabled: Le,
2012
- children: [
2013
- /* @__PURE__ */ t(Ea, { className: "h-3.5 w-3.5" }),
2014
- "Undo"
2015
- ]
2016
- }
2017
- ),
2018
- He && s && /* @__PURE__ */ i(
2019
- U,
2020
- {
2021
- size: "xs",
2022
- className: xe(!bt && "opacity-60"),
2023
- disabled: Le || !bt,
2024
- onClick: () => Qe(),
2025
- children: [
2026
- Le ? /* @__PURE__ */ t(Re, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ t(Dn, { className: "h-3.5 w-3.5" }),
2027
- Le ? "Saving..." : "Save"
2028
- ]
2029
- }
2030
- ),
2031
- k && !T && s && /* @__PURE__ */ i(U, { variant: "outline", size: "xs", onClick: Ar, children: [
2032
- /* @__PURE__ */ t(Ia, { className: "h-3.5 w-3.5" }),
2033
- "Close"
2034
- ] }),
2035
- !T && s && /* @__PURE__ */ t("div", { className: "ml-2 flex items-center", children: /* @__PURE__ */ t(dn, {}) }),
2036
- !T && c && /* @__PURE__ */ t(Un, {}),
2037
- !T && s && !f && /* @__PURE__ */ i(Ct, { children: [
2038
- /* @__PURE__ */ t(Dt, { asChild: !0, children: /* @__PURE__ */ t(
2039
- U,
2040
- {
2041
- variant: "ghost",
2042
- size: "xs",
2043
- className: "w-7 px-0 text-muted-foreground hover:text-foreground",
2044
- "aria-label": "More dashboard options",
2045
- children: /* @__PURE__ */ t(Aa, { className: "h-3.5 w-3.5" })
2046
- }
2047
- ) }),
2048
- /* @__PURE__ */ i(
2049
- Et,
2050
- {
2051
- align: "end",
2052
- className: "w-56 rounded-control border border-border/60 p-1 shadow-sm",
2053
- children: [
2054
- /* @__PURE__ */ t(_e, { children: "Reports & briefings" }),
2055
- /* @__PURE__ */ i(
2056
- P,
2057
- {
2058
- disabled: w,
2059
- onSelect: () => j(!0),
2060
- children: [
2061
- /* @__PURE__ */ t(La, { className: "h-3.5 w-3.5" }),
2062
- "Export"
2063
- ]
2064
- }
2065
- ),
2066
- /* @__PURE__ */ t(
2067
- go,
2068
- {
2069
- scheduleReportVisible: !!(xt && o.surfaceVisible && F && !k),
2070
- analyticalBriefingVisible: !!(xt && o.surfaceVisible && F && !k),
2071
- onScheduleReport: () => oe("scheduled_report"),
2072
- onCreateAnalyticalBriefing: () => oe("analytical_briefing")
2073
- }
2074
- ),
2075
- k && /* @__PURE__ */ i(
2076
- P,
2077
- {
2078
- onSelect: () => ke(!0),
2079
- children: [
2080
- /* @__PURE__ */ t(Ma, { className: "h-3.5 w-3.5" }),
2081
- "Download settings"
2082
- ]
2083
- }
2084
- ),
2085
- /* @__PURE__ */ t(Ye, {}),
2086
- (G.showDashboardSharing || G.showGroupManagement) && /* @__PURE__ */ i($, { children: [
2087
- /* @__PURE__ */ t(_e, { children: "Access" }),
2088
- G.showDashboardSharing && /* @__PURE__ */ i(P, { onSelect: () => Ne(!0), children: [
2089
- /* @__PURE__ */ t(Oa, { className: "h-3.5 w-3.5" }),
2090
- "Share"
2091
- ] }),
2092
- G.showGroupManagement && /* @__PURE__ */ i(
2093
- P,
2094
- {
2095
- onClick: () => W(!0),
2096
- children: [
2097
- /* @__PURE__ */ t(Kt, { className: "h-3.5 w-3.5" }),
2098
- "Manage Groups"
2099
- ]
2100
- }
2101
- ),
2102
- /* @__PURE__ */ t(Ye, {})
2103
- ] }),
2104
- /* @__PURE__ */ t(_e, { children: "Preferences" }),
2105
- /* @__PURE__ */ i(P, { onClick: () => J(!0), children: [
2106
- /* @__PURE__ */ t(Qt, { className: "h-3.5 w-3.5" }),
2107
- "Report preferences"
2108
- ] }),
2109
- c && s && /* @__PURE__ */ i($, { children: [
2110
- /* @__PURE__ */ t(Ye, {}),
2111
- /* @__PURE__ */ t(_e, { children: "Developer" }),
2112
- /* @__PURE__ */ i(
2113
- P,
2114
- {
2115
- onSelect: () => {
2116
- var d;
2117
- e != null && e.accessToken && ((d = navigator == null ? void 0 : navigator.clipboard) != null && d.writeText ? navigator.clipboard.writeText(e.accessToken).then(
2118
- () => D.success("Token copied to clipboard")
2119
- ).catch(() => D.error("Unable to copy token")) : D.error("Clipboard not available"));
2120
- },
2121
- children: [
2122
- /* @__PURE__ */ t(It, { className: "h-3.5 w-3.5" }),
2123
- "Copy token"
2124
- ]
2125
- }
2126
- ),
2127
- L && /* @__PURE__ */ i(
2128
- P,
2129
- {
2130
- disabled: !je,
2131
- onSelect: () => {
2132
- var d;
2133
- if (!je) {
2134
- D.error(
2135
- "Open a document sheet with a token to copy the local PDF URL"
2136
- );
2137
- return;
2138
- }
2139
- (d = navigator == null ? void 0 : navigator.clipboard) != null && d.writeText ? navigator.clipboard.writeText(je).then(
2140
- () => D.success(
2141
- "Local document PDF URL copied to clipboard"
2142
- )
2143
- ).catch(
2144
- () => D.error(
2145
- "Unable to copy local document PDF URL"
2146
- )
2147
- ) : D.error("Clipboard not available");
2148
- },
2149
- children: [
2150
- /* @__PURE__ */ t(It, { className: "h-3.5 w-3.5" }),
2151
- "Copy local document PDF URL"
2152
- ]
2153
- }
2154
- ),
2155
- /* @__PURE__ */ i(
2156
- P,
2157
- {
2158
- onSelect: () => cn(n.apiServiceUrl),
2159
- children: [
2160
- /* @__PURE__ */ t(Mn, { className: "h-3.5 w-3.5" }),
2161
- "Invalidate token"
2162
- ]
2163
- }
2164
- ),
2165
- /* @__PURE__ */ i(P, { onSelect: l, children: [
2166
- /* @__PURE__ */ t(En, { className: "h-3.5 w-3.5" }),
2167
- "Brand Studio"
2168
- ] }),
2169
- k && /* @__PURE__ */ i(
2170
- P,
2171
- {
2172
- onSelect: () => mt(!lt),
2173
- children: [
2174
- /* @__PURE__ */ t(In, { className: "h-3.5 w-3.5" }),
2175
- lt ? "Hide dashboard JSON" : "Show dashboard JSON"
2176
- ]
2177
- }
2178
- )
2179
- ] })
2180
- ]
2181
- }
2182
- )
2183
- ] }),
2184
- ae && pt && /* @__PURE__ */ t(
2185
- _a,
2186
- {
2187
- resource: pt,
2188
- resourceType: We.DASHBOARD,
2189
- onClose: () => Ne(!1)
2190
- }
2191
- ),
2192
- G.showGroupManagement && /* @__PURE__ */ t(
2193
- oo,
2194
- {
2195
- open: Q,
2196
- onOpenChange: W
2197
- }
2198
- ),
2199
- /* @__PURE__ */ t(
2200
- pn,
2201
- {
2202
- open: Y,
2203
- onOpenChange: J
2204
- }
2205
- ),
2206
- /* @__PURE__ */ t(
2207
- po,
2208
- {
2209
- open: Se,
2210
- onOpenChange: ke
2211
- }
2212
- ),
2213
- F && (ne || se) ? /* @__PURE__ */ t(
2214
- ln,
2215
- {
2216
- dashboardId: F,
2217
- dashboardTitle: (h == null ? void 0 : h.title) || (B == null ? void 0 : B.title),
2218
- open: !0,
2219
- onOpenChange: (d) => {
2220
- d || (oe(null), ie(null));
2221
- },
2222
- hideTrigger: !0,
2223
- workflowIntent: ne ?? void 0,
2224
- openRun: se ?? void 0
2225
- }
2226
- ) : null,
2227
- s && /* @__PURE__ */ t(
2228
- Pa,
2229
- {
2230
- open: Ue,
2231
- onOpenChange: j
2232
- }
2233
- ),
2234
- /* @__PURE__ */ t(
2235
- Ra,
2236
- {
2237
- open: y,
2238
- onOpenChange: (d) => {
2239
- !d && Fe && !H || (R(d), d || (q(null), z([]), De(!1)));
2240
- },
2241
- children: /* @__PURE__ */ i(Ta, { className: "max-w-sm", children: [
2242
- /* @__PURE__ */ i(Ua, { children: [
2243
- /* @__PURE__ */ t($a, { children: H ? "Save failed" : "Saving dashboard" }),
2244
- /* @__PURE__ */ t(Ba, { className: "pt-2", children: H ? "We could not save the dashboard. Please try again." : "Please wait while we save your changes." }),
2245
- de.length > 0 && /* @__PURE__ */ i("div", { className: "space-y-1 rounded-md border border-destructive/20 bg-destructive/5 p-3 text-left", children: [
2246
- /* @__PURE__ */ t("div", { className: "text-sm font-medium text-destructive", children: "What needs attention" }),
2247
- /* @__PURE__ */ t("ul", { className: "list-disc space-y-1 pl-4 text-xs text-muted-foreground", children: de.slice(0, 5).map((d) => /* @__PURE__ */ t("li", { children: d }, d)) })
2248
- ] })
2249
- ] }),
2250
- /* @__PURE__ */ t(Fa, { className: "flex-col gap-2 sm:flex-row sm:justify-end", children: H ? /* @__PURE__ */ i($, { children: [
2251
- /* @__PURE__ */ t(
2252
- Ga,
2253
- {
2254
- onClick: () => {
2255
- R(!1), q(null), z([]), De(!1);
2256
- },
2257
- className: "m-0",
2258
- children: "Close"
2259
- }
2260
- ),
2261
- /* @__PURE__ */ t(
2262
- At,
2263
- {
2264
- onClick: () => Qe({
2265
- closeAfterSave: ce,
2266
- navigateHomeAfterSave: Ve === "home"
2267
- }),
2268
- className: "m-0",
2269
- children: "Retry"
2270
- }
2271
- )
2272
- ] }) : /* @__PURE__ */ i(At, { disabled: !0, className: "m-0 cursor-default", children: [
2273
- /* @__PURE__ */ t(Re, { className: "mr-2 h-4 w-4 animate-spin" }),
2274
- "Saving..."
2275
- ] }) })
2276
- ] })
2277
- }
2278
- ),
2279
- /* @__PURE__ */ t(
2280
- un,
2281
- {
2282
- open: Sr,
2283
- onOpenChange: (d) => {
2284
- ue(d);
2285
- },
2286
- onSave: Lr,
2287
- onDiscard: Mr,
2288
- isSaving: Fe,
2289
- saveLabel: "Save",
2290
- discardLabel: "Discard changes"
2291
- }
2292
- )
2293
- ] })
2294
- ]
2295
- }
2296
- );
2297
- }
2298
- function So({
2299
- accessToken: e,
2300
- dashboardId: n,
2301
- selectedSheetId: a,
2302
- pageSize: r,
2303
- orientation: o,
2304
- theme: c
2305
- }) {
2306
- if (!e || !a)
2307
- return null;
2308
- const m = new URL("http://localhost:5173/print-document");
2309
- m.searchParams.set("token", e), n && m.searchParams.set("dashboardId", n), m.searchParams.set("selectedSheetId", a), c && m.searchParams.set("theme", c);
2310
- const p = new URL("http://127.0.0.1:3002/");
2311
- return p.searchParams.set("pdfMode", "document"), p.searchParams.set("pageSize", r || "letter"), p.searchParams.set("orientation", o || "portrait"), p.searchParams.set("url", m.toString()), p.toString();
2312
- }
2313
- export {
2314
- Xo as default
2315
- };