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,3725 +0,0 @@
1
- import { jsx as t, jsxs as r, Fragment as z } from "react/jsx-runtime";
2
- import Ft, { useState as k, useEffect as ge, useCallback as ae, useMemo as re, useLayoutEffect as Nt, useRef as rt, useContext as Kt } from "react";
3
- import { ae as I, ap as Yt } from "./numeric-presentation-DESvLiu9.js";
4
- import { B as T, l as De, q as nt, L as ne, j as It, c as st, i as Xt, P as Ue, a as Re, b as Oe, S as Et } from "./switch-C3jLxlG0.js";
5
- import { cr as ot, bu as Ae, bv as Fe, bx as Ie, cs as Zt, ct as Jt, aX as Vt, aV as $e, cu as ea, cv as We, cw as it, Z as qe, W as ue, u as D, cx as ta, cy as aa, cz as ra, Y as J, b6 as na, cA as sa, cB as oa, aQ as be, cg as Tt, aH as _e, l as ia, h as la, cC as da, cj as lt, ck as dt, cl as ct, cm as ut, cn as ht, co as mt, cp as pt, cq as Lt, aF as ft, cD as ca, cE as ua, c8 as Je, c5 as Qe, c6 as He, cF as Bt, c7 as Ge, bR as Y, ch as ha, cf as ze, cG as ma, bP as pa, bw as gt, by as bt, cH as fa, bt as ga, cI as Pt, cJ as xt, cK as ba, bV as xa, f as va, cL as ya, cM as Ca, cN as G, cO as wa, R as Mt, cP as Na, cQ as Sa, cR as ka, cS as Da, aC as Aa, cT as pe, cU as Fa, L as vt, cV as Ia, cW as Ea, cX as Va, cY as Ta, cZ as La, c_ as Ba, c$ as Pa, d0 as Ut, d1 as Ma, d2 as Ua, d3 as Ra, d4 as Rt, d5 as Oa, d6 as Be, d7 as _a, d8 as za, d9 as ja, A as $a, ar as Wa, as as qa, a7 as Qa, a6 as Ha, a5 as Ga, a4 as Ka, a1 as Ya, $ as Xa, da as Za, db as Ja, dc as er, dd as tr, de as ar, ap as rr } from "./semaphor-ready-indicator-DDAxk8us.js";
6
- import { L as yt } from "./layout-grid-Bgzth8vd.js";
7
- import { c as xe, X as Ke, C as Ot } from "./x-4f5U2XwU.js";
8
- import "./index-CuHybtft.js";
9
- import { t as nr } from "./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 Z } from "./class-utils-Df1OVOT1.js";
15
- import { S as sr } from "./selection-reducer-Dj_8xD69.js";
16
- import { s as Pe } from "./normalize-dashboard-for-dirty-check-Bk3VYv_q.js";
17
- import { f as or } from "./editor-draft-sync-BN5qYHPF.js";
18
- import { ad as je, ae as ir, m as lr, af as dr, ag as cr, ah as ur, ai as hr, aj as mr } from "./document-dashboard-inputs-BC6p-ESg.js";
19
- import "react-dom";
20
- import "./pivot-result-lifecycle-DM4CyGKs.js";
21
- import { F as pr } from "./table-settings-CLZocegs.js";
22
- import { S as _t } from "./save-CfJpQQ68.js";
23
- import { V as fr, L as gr, a as br, u as zt, C as jt, F as xr, b as vr } from "./use-create-flow-overlay-state-BxzFviM-.js";
24
- import { v as St } from "./custom-visual-inputs-DUtpYZOk.js";
25
- import { w as kt } from "./matrix-formatter-CxJLkztA.js";
26
- import { x as yr } from "./document-sheet-utils-Duo9uLoH.js";
27
- import { g as ce, d as Cr, a as wr } from "./index-DkAyQvC6.js";
28
- /**
29
- * @license lucide-react v0.453.0 - ISC
30
- *
31
- * This source code is licensed under the ISC license.
32
- * See the LICENSE file in the root directory of this source tree.
33
- */
34
- const Nr = xe("ArrowUpRight", [
35
- ["path", { d: "M7 7h10v10", key: "1tivn9" }],
36
- ["path", { d: "M7 17 17 7", key: "1vkiza" }]
37
- ]);
38
- /**
39
- * @license lucide-react v0.453.0 - ISC
40
- *
41
- * This source code is licensed under the ISC license.
42
- * See the LICENSE file in the root directory of this source tree.
43
- */
44
- const Sr = xe("Bell", [
45
- ["path", { d: "M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9", key: "1qo2s2" }],
46
- ["path", { d: "M10.3 21a1.94 1.94 0 0 0 3.4 0", key: "qgo35s" }]
47
- ]);
48
- /**
49
- * @license lucide-react v0.453.0 - ISC
50
- *
51
- * This source code is licensed under the ISC license.
52
- * See the LICENSE file in the root directory of this source tree.
53
- */
54
- const kr = xe("CalendarRange", [
55
- ["rect", { width: "18", height: "18", x: "3", y: "4", rx: "2", key: "1hopcy" }],
56
- ["path", { d: "M16 2v4", key: "4m81vk" }],
57
- ["path", { d: "M3 10h18", key: "8toen8" }],
58
- ["path", { d: "M8 2v4", key: "1cmpym" }],
59
- ["path", { d: "M17 14h-6", key: "bkmgh3" }],
60
- ["path", { d: "M13 18H7", key: "bb0bb7" }],
61
- ["path", { d: "M7 14h.01", key: "1qa3f1" }],
62
- ["path", { d: "M17 18h.01", key: "1bdyru" }]
63
- ]);
64
- /**
65
- * @license lucide-react v0.453.0 - ISC
66
- *
67
- * This source code is licensed under the ISC license.
68
- * See the LICENSE file in the root directory of this source tree.
69
- */
70
- const Dr = xe("CodeXml", [
71
- ["path", { d: "m18 16 4-4-4-4", key: "1inbqp" }],
72
- ["path", { d: "m6 8-4 4 4 4", key: "15zrgr" }],
73
- ["path", { d: "m14.5 4-5 16", key: "e7oirm" }]
74
- ]);
75
- /**
76
- * @license lucide-react v0.453.0 - ISC
77
- *
78
- * This source code is licensed under the ISC license.
79
- * See the LICENSE file in the root directory of this source tree.
80
- */
81
- const Ar = xe("MousePointer2", [
82
- [
83
- "path",
84
- {
85
- d: "M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z",
86
- key: "edeuup"
87
- }
88
- ]
89
- ]);
90
- /**
91
- * @license lucide-react v0.453.0 - ISC
92
- *
93
- * This source code is licensed under the ISC license.
94
- * See the LICENSE file in the root directory of this source tree.
95
- */
96
- const Fr = xe("Newspaper", [
97
- [
98
- "path",
99
- {
100
- d: "M4 22h16a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v16a2 2 0 0 1-2 2Zm0 0a2 2 0 0 1-2-2v-9c0-1.1.9-2 2-2h2",
101
- key: "7pis2x"
102
- }
103
- ],
104
- ["path", { d: "M18 14h-8", key: "sponae" }],
105
- ["path", { d: "M15 18h-5", key: "95g1m2" }],
106
- ["path", { d: "M10 6h8v4h-8V6Z", key: "smlsk5" }]
107
- ]);
108
- function Ir() {
109
- return /* @__PURE__ */ t("div", { className: "space-y-1.5 py-1", children: [...Array(5)].map((e, a) => /* @__PURE__ */ r(
110
- "div",
111
- {
112
- className: "flex animate-pulse items-start gap-3 rounded-xl border border-transparent px-2.5 py-2.5",
113
- children: [
114
- /* @__PURE__ */ t("div", { className: "mt-0.5 h-4 w-4 flex-shrink-0 rounded bg-muted/60" }),
115
- /* @__PURE__ */ r("div", { className: "flex-1 space-y-1.5", children: [
116
- /* @__PURE__ */ t("div", { className: "h-4 w-3/5 rounded bg-muted/60" }),
117
- /* @__PURE__ */ t("div", { className: "h-3 w-4/5 rounded bg-muted/40" })
118
- ] })
119
- ]
120
- },
121
- a
122
- )) });
123
- }
124
- function Er({
125
- open: e,
126
- onOpenChange: a,
127
- onSubmit: o,
128
- isCreating: s
129
- }) {
130
- const i = ot("interactive"), [n, d] = k(""), [c, l] = k("");
131
- ge(() => {
132
- e || (d(""), l(""));
133
- }, [e]);
134
- const h = () => {
135
- n.trim() && o({ title: n, description: c });
136
- }, u = (m) => {
137
- a(m);
138
- };
139
- return /* @__PURE__ */ t(Ae, { open: e, onOpenChange: u, children: /* @__PURE__ */ r(
140
- Fe,
141
- {
142
- showCloseButton: !1,
143
- className: "flex max-w-lg grid-cols-none flex-col gap-0 overflow-hidden rounded-card border-border/60 p-0 shadow-lg sm:rounded-card",
144
- style: i.dialogStyle,
145
- children: [
146
- /* @__PURE__ */ r("div", { className: "flex h-10 shrink-0 items-center justify-between gap-2 border-b border-border/60 px-3", children: [
147
- /* @__PURE__ */ r("div", { className: "flex min-w-0 items-center gap-2", children: [
148
- /* @__PURE__ */ t(yt, { className: "h-3.5 w-3.5 shrink-0 text-muted-foreground" }),
149
- /* @__PURE__ */ r("div", { className: "flex min-w-0 items-baseline gap-2", children: [
150
- /* @__PURE__ */ t(Ie, { className: "truncate text-[13px] font-medium leading-none tracking-normal", children: "New library visual" }),
151
- /* @__PURE__ */ t("span", { className: "shrink-0 text-[10px] font-medium uppercase leading-none tracking-[0.08em] text-muted-foreground", children: "Visual" })
152
- ] })
153
- ] }),
154
- /* @__PURE__ */ t(
155
- T,
156
- {
157
- size: "xs",
158
- variant: "ghost",
159
- className: "w-7 px-0 text-muted-foreground hover:text-foreground",
160
- onClick: () => u(!1),
161
- "aria-label": "Close",
162
- disabled: s,
163
- children: /* @__PURE__ */ t(Ke, { className: "h-3.5 w-3.5" })
164
- }
165
- )
166
- ] }),
167
- /* @__PURE__ */ r("div", { className: "space-y-3 px-4 py-3", children: [
168
- /* @__PURE__ */ t("p", { className: "text-[12px] text-muted-foreground", children: "Create a saved visual that can be reused across dashboards." }),
169
- /* @__PURE__ */ r("div", { className: "space-y-1.5", children: [
170
- /* @__PURE__ */ t(De, { htmlFor: "visual-title", className: "text-[12px]", children: "Name" }),
171
- /* @__PURE__ */ t(
172
- nt,
173
- {
174
- id: "visual-title",
175
- size: "sm",
176
- placeholder: "Untitled visual",
177
- value: n,
178
- onChange: (m) => d(m.target.value),
179
- disabled: s,
180
- onKeyDown: (m) => {
181
- m.key === "Enter" && !m.shiftKey && (m.preventDefault(), h());
182
- }
183
- }
184
- )
185
- ] }),
186
- /* @__PURE__ */ r("div", { className: "space-y-1.5", children: [
187
- /* @__PURE__ */ t(De, { htmlFor: "visual-description", className: "text-[12px]", children: "Description" }),
188
- /* @__PURE__ */ t(
189
- nt,
190
- {
191
- id: "visual-description",
192
- size: "sm",
193
- placeholder: "Optional",
194
- value: c,
195
- onChange: (m) => l(m.target.value),
196
- disabled: s
197
- }
198
- )
199
- ] })
200
- ] }),
201
- /* @__PURE__ */ r("div", { className: "flex shrink-0 justify-end gap-2 border-t border-border/60 px-4 py-2.5", children: [
202
- /* @__PURE__ */ t(
203
- T,
204
- {
205
- size: "xs",
206
- variant: "outline",
207
- onClick: () => u(!1),
208
- disabled: s,
209
- children: "Cancel"
210
- }
211
- ),
212
- /* @__PURE__ */ t(
213
- T,
214
- {
215
- size: "xs",
216
- onClick: h,
217
- disabled: !n.trim() || s,
218
- children: s ? /* @__PURE__ */ r(z, { children: [
219
- /* @__PURE__ */ t(ne, { className: "h-3.5 w-3.5 animate-spin" }),
220
- "Creating..."
221
- ] }) : "Create library visual"
222
- }
223
- )
224
- ] })
225
- ]
226
- }
227
- ) });
228
- }
229
- function Vr(e) {
230
- const [a, o] = k(null), [s, i] = k(null), n = Zt();
231
- return ge(() => {
232
- if (!e || e.trim() === "") {
233
- o(null), i(null);
234
- return;
235
- }
236
- if (!n)
237
- return;
238
- (async () => {
239
- try {
240
- if (!e.startsWith("http://") && !e.startsWith("https://"))
241
- throw new Error(`Invalid URL format: ${e}`);
242
- try {
243
- new URL(e);
244
- } catch {
245
- throw new Error(`Invalid URL: ${e}`);
246
- }
247
- const l = `${e.endsWith("/") ? e : `${e}/`}index.js`;
248
- try {
249
- if (!(await fetch(l, { method: "HEAD" })).ok)
250
- throw new Error(`Module not found at ${l}`);
251
- } catch {
252
- }
253
- const h = await import(
254
- /* @vite-ignore */
255
- /* webpackIgnore: true */
256
- l
257
- );
258
- if (typeof h.useChartStore != "function")
259
- throw new Error("useChartStore is not a function");
260
- o(() => h.useChartStore), i(null);
261
- } catch (c) {
262
- const l = c instanceof Error ? c.message : "Unknown error";
263
- console.error("Failed to load remote chart store:", l), i(l), o(null);
264
- }
265
- })();
266
- }, [e, n]), a;
267
- }
268
- function Tr(e, a) {
269
- if (e.length === 0)
270
- return "";
271
- const o = e.find(
272
- (s) => {
273
- var i, n;
274
- return ((i = s.customCardPreferences) == null ? void 0 : i.visualType) === "multiple" || !!((n = s.customCardPreferences) != null && n.dataInputCardIds);
275
- }
276
- );
277
- if (o)
278
- return o.id;
279
- if (a) {
280
- const s = e.find((i) => i.id === a);
281
- if (s) {
282
- const i = s.tabTitle;
283
- if (i == "All__Header")
284
- return e[0].id;
285
- if (i && i.endsWith("__Header")) {
286
- const d = i.split("__")[0], c = e.find(
287
- (l) => l.tabTitle === d
288
- );
289
- return c ? c.id : e[0].id;
290
- }
291
- return a;
292
- }
293
- }
294
- return e[0].id;
295
- }
296
- function Lr(e, a) {
297
- return a ? {
298
- ...e,
299
- settings: a
300
- } : e;
301
- }
302
- function Br(e, a) {
303
- const o = a.selectedConnectionId || e.connectionId || "";
304
- if (!e.dataSource) {
305
- if (!o)
306
- return;
307
- const s = a.selectedDatabaseName || e.lastSelectedDatabase, i = a.selectedSchemaName || e.lastSelectedSchema, n = a.selectedTableName || e.lastSelectedTable;
308
- return {
309
- connectionId: o,
310
- connectionType: "",
311
- mode: "database",
312
- selectedEntities: [],
313
- ...s && i && n ? {
314
- dbSelection: {
315
- database: s,
316
- schema: i,
317
- entityType: "table"
318
- }
319
- } : {}
320
- };
321
- }
322
- return {
323
- ...e.dataSource,
324
- connectionId: a.selectedConnectionId || e.dataSource.connectionId || e.connectionId || ""
325
- };
326
- }
327
- function Pr(e, {
328
- isDevMode: a,
329
- cardSql: o,
330
- selectedSchemaName: s,
331
- selectedDatamodelId: i,
332
- selectedDatabaseName: n,
333
- selectedTableName: d,
334
- selectedConnectionId: c,
335
- remoteChartSettings: l,
336
- stripConfig: h
337
- }) {
338
- const u = a || Jt(e);
339
- return {
340
- ...e,
341
- dataSource: Br(e, {
342
- selectedConnectionId: c,
343
- selectedDatabaseName: n,
344
- selectedSchemaName: s,
345
- selectedTableName: d
346
- }),
347
- lastSelectedSchema: s,
348
- lastSelectedDatamodelId: i,
349
- lastSelectedDatabase: n,
350
- lastSelectedTable: d,
351
- connectionId: c || e.connectionId,
352
- sql: u ? o || e.sql : void 0,
353
- python: u ? e.python : void 0,
354
- config: a || !e.config ? void 0 : h(e.config),
355
- customCfg: e.customCfg,
356
- preferences: e.preferences,
357
- customCardPreferences: Lr(
358
- e.customCardPreferences,
359
- l
360
- )
361
- };
362
- }
363
- const Mr = (e) => {
364
- if (!e || !("detailTableBackup" in e))
365
- return e;
366
- const { detailTableBackup: a, ...o } = e;
367
- return o;
368
- };
369
- async function Dt(e, a, o, s, i = "Opening library visual...") {
370
- if (!a || !o)
371
- throw new Error("Missing auth token or visual ID");
372
- const n = ["resource-by-id", "visual", o], d = s.getQueryData(n);
373
- if (d)
374
- return console.log("Using cached visual data for:", o), { data: d, fromCache: !0 };
375
- console.log("Fetching visual data from network for:", o);
376
- const c = I.loading(i, {
377
- position: "top-center"
378
- });
379
- try {
380
- const l = await fetch(
381
- `${e}/management/v1/visuals/${o}`,
382
- {
383
- headers: {
384
- Authorization: `Bearer ${a}`
385
- }
386
- }
387
- );
388
- if (!l.ok)
389
- throw new Error("Failed to load visual");
390
- const h = await l.json();
391
- return s.setQueryData(n, h), I.dismiss(c), { data: h, fromCache: !1 };
392
- } catch (l) {
393
- throw I.dismiss(c), l;
394
- }
395
- }
396
- function $t(e) {
397
- if (typeof e == "string")
398
- return JSON.parse(e);
399
- if (typeof e == "object")
400
- return e;
401
- throw new Error("Invalid frame object format");
402
- }
403
- function Ur(e, a) {
404
- var n, d;
405
- const o = (e == null ? void 0 : e.frameObject) ?? ((n = e == null ? void 0 : e.visual) == null ? void 0 : n.frameObject);
406
- if (!o)
407
- return !1;
408
- const s = $t(o);
409
- if (!(s != null && s.cards) || s.cards.length === 0)
410
- return !1;
411
- const i = (d = s.cards) == null ? void 0 : d.find(
412
- (c) => c.id === s.activeCardId
413
- );
414
- return i ? (ra({
415
- ...a,
416
- frame: s,
417
- card: i,
418
- visualId: (e == null ? void 0 : e.id) || s.visualId
419
- }), !0) : !1;
420
- }
421
- function Rr() {
422
- const e = J(
423
- (s) => {
424
- var i;
425
- return ((i = s.card.customCardPreferences) == null ? void 0 : i.url) || "";
426
- }
427
- ), a = Vr(e);
428
- return { getUpdatedFrame: ae(() => {
429
- var v;
430
- or();
431
- const {
432
- frame: s,
433
- card: i,
434
- isDevMode: n,
435
- selectedSchemaName: d,
436
- selectedDatamodelId: c,
437
- selectedDatabaseName: l,
438
- selectedTableName: h,
439
- selectedConnectionId: u
440
- } = J.getState(), m = i.sql, p = (v = a == null ? void 0 : a.getState()) == null ? void 0 : v.settings, g = Pr(i, {
441
- isDevMode: n,
442
- cardSql: m,
443
- selectedSchemaName: d,
444
- selectedDatamodelId: c,
445
- selectedDatabaseName: l,
446
- selectedTableName: h,
447
- selectedConnectionId: u,
448
- remoteChartSettings: p,
449
- stripConfig: Mr
450
- }), f = s.cards.map(
451
- (S) => S.id === i.id ? g : S
452
- );
453
- return {
454
- ...s,
455
- cards: f,
456
- activeCardId: Tr(f, s.activeCardId)
457
- };
458
- }, [a]) };
459
- }
460
- function ve() {
461
- const { authToken: e, tokenProps: a } = Vt(), o = $e(), s = ea(), i = We(), { selectVisual: n } = it(), {
462
- setFrame: d,
463
- setCard: c,
464
- setIsDevMode: l,
465
- initializeModeDrafts: h,
466
- setActiveTabCardId: u,
467
- updateDataSource: m,
468
- setQueryResultColumns: p,
469
- setSelectedConnectionId: g,
470
- setSelectedDatabaseName: f,
471
- setSelectedSchemaName: v,
472
- setSelectedTableName: S,
473
- setSelectedDatamodelId: E,
474
- setFilterValues: M,
475
- setInlineFilterValuesMap: U,
476
- setApplyFilters: A,
477
- clearEditorContext: O
478
- } = qe(), {
479
- setIsDashboardEditing: C,
480
- setIsVisualEditing: N,
481
- setSelectedFrameId: x,
482
- clearSelectedFrameId: V
483
- } = ue(), w = D((j) => j.selectedSheetId), W = D((j) => j.selectedFrameId), F = D((j) => j.dashboard), R = D((j) => j.filterValues), K = D(
484
- (j) => j.inlineFilterValuesMap
485
- ), _ = ta((i == null ? void 0 : i.id) || "", {
486
- enabled: !!(i != null && i.id) && !!(e != null && e.accessToken)
487
- }), ye = ae(
488
- async (j) => {
489
- try {
490
- n(j), V(), O();
491
- const { data: X, fromCache: he } = await Dt(
492
- a.apiServiceUrl,
493
- (e == null ? void 0 : e.accessToken) || "",
494
- j.id,
495
- o,
496
- "Opening library visual..."
497
- );
498
- if (!Ur(X, {
499
- setFrame: d,
500
- setCard: c,
501
- setIsDevMode: l,
502
- initializeModeDrafts: h,
503
- setActiveTabCardId: u,
504
- updateDataSource: m,
505
- setQueryResultColumns: p,
506
- setSelectedConnectionId: g,
507
- setSelectedDatabaseName: f,
508
- setSelectedSchemaName: v,
509
- setSelectedTableName: S,
510
- setSelectedDatamodelId: E,
511
- setFilterValues: M,
512
- setInlineFilterValuesMap: U,
513
- setApplyFilters: A,
514
- setIsDashboardEditing: C,
515
- setIsVisualEditing: N,
516
- dashboard: F,
517
- selectedSheetId: w,
518
- selectedFrameId: W,
519
- filterValues: R,
520
- inlineFilterValuesMap: K
521
- }))
522
- throw new Error("Failed to setup editor with visual data");
523
- return { success: !0, fromCache: he };
524
- } catch (X) {
525
- return console.error("Error editing visual:", X), { success: !1, error: "Failed to load visual for editing" };
526
- }
527
- },
528
- [
529
- e == null ? void 0 : e.accessToken,
530
- a.apiServiceUrl,
531
- o,
532
- n,
533
- d,
534
- c,
535
- C,
536
- N,
537
- l,
538
- h,
539
- u,
540
- m,
541
- p,
542
- g,
543
- f,
544
- v,
545
- S,
546
- E,
547
- M,
548
- U,
549
- A,
550
- O,
551
- V,
552
- F,
553
- w,
554
- W,
555
- R,
556
- K
557
- ]
558
- ), se = ae(
559
- async (j) => {
560
- var he;
561
- const X = (L) => (I.error(L), { success: !1, error: L });
562
- try {
563
- if (n(j), !w)
564
- return X("No sheet selected. Please select a sheet first.");
565
- const { data: L, fromCache: $ } = await Dt(
566
- a.apiServiceUrl,
567
- (e == null ? void 0 : e.accessToken) || "",
568
- j.id,
569
- o,
570
- "Adding visual to dashboard..."
571
- ), ee = (L == null ? void 0 : L.frameObject) ?? ((he = L == null ? void 0 : L.visual) == null ? void 0 : he.frameObject);
572
- if (!ee)
573
- return X("Visual has no frame data");
574
- const te = $t(ee);
575
- if (!(te != null && te.cards) || te.cards.length === 0)
576
- return X("Visual frame is malformed");
577
- const le = {
578
- ...aa(te),
579
- visualId: j.id
580
- // Link this frame to the library visual
581
- };
582
- return await s(
583
- w,
584
- le,
585
- "end"
586
- ), C(!0), x(le.id), { success: !0, fromCache: $ };
587
- } catch (L) {
588
- return console.error("Error adding visual:", L), X(
589
- L instanceof Error ? L.message : "Failed to add visual to dashboard"
590
- );
591
- }
592
- },
593
- [
594
- e == null ? void 0 : e.accessToken,
595
- a.apiServiceUrl,
596
- o,
597
- n,
598
- w,
599
- C,
600
- x,
601
- s
602
- ]
603
- );
604
- return {
605
- visual: _.data,
606
- isLoading: _.isLoading,
607
- isError: _.isError,
608
- error: _.error,
609
- handleEditLibraryVisual: ye,
610
- handleAddLibraryVisual: se,
611
- getUpdatedFrame: Rr().getUpdatedFrame,
612
- refetch: _.refetch
613
- };
614
- }
615
- function Wt(e) {
616
- return e ? new Date(e).toLocaleDateString("en-US", {
617
- month: "short",
618
- day: "numeric",
619
- year: "numeric"
620
- }) : "Unknown";
621
- }
622
- function qt(e, a) {
623
- var s;
624
- const o = (s = e.ownership.createdBy) == null ? void 0 : s.type;
625
- return o === "tenant" || o === "organization" && a;
626
- }
627
- function Ct(e, a) {
628
- var o, s;
629
- return qt(e, a) ? ((o = e.ownership.createdBy) == null ? void 0 : o.name) || ((s = e.createdByTenantUserRel) == null ? void 0 : s.name) || e.lastModifiedBy || "Unknown" : "Organization";
630
- }
631
- function Or(e, a) {
632
- return Ct(e, a).split(/\s+/).filter(Boolean).slice(0, 2).map((s) => s.charAt(0).toUpperCase()).join("") || "?";
633
- }
634
- function _r(e) {
635
- const a = (e || "").toLowerCase();
636
- return a.includes("table") ? It : a.includes("pie") || a.includes("donut") ? ca : a.includes("line") ? ua : a.includes("bar") ? Xt : yt;
637
- }
638
- function zr({ visual: e }) {
639
- const a = e.ownership.status === "public" ? "Public" : e.ownership.status === "shared" || e.ownership.sharedCount > 0 ? "Shared" : "Private";
640
- return /* @__PURE__ */ t("span", { className: "inline-flex items-center rounded-[4px] border border-border/60 px-1.5 py-px text-[11px] text-muted-foreground", children: a });
641
- }
642
- function ss({
643
- open: e,
644
- onOpenChange: a
645
- }) {
646
- const o = ot("interactive"), [s, i] = k(""), [n, d] = k(/* @__PURE__ */ new Set()), [c, l] = k(!1), [h, u] = k(
647
- null
648
- ), [m, p] = k(
649
- null
650
- ), [g, f] = k(!1), [v, S] = k(null), [E, M] = k(null), U = () => {
651
- d(/* @__PURE__ */ new Set()), u(null), p(null), f(!1), S(null);
652
- }, A = () => {
653
- a(!1), U();
654
- }, { selectVisual: O } = it(), { handleAddLibraryVisual: C, handleEditLibraryVisual: N } = ve(), { isConsoleMode: x } = na(), {
655
- resources: V,
656
- isLoading: w,
657
- isError: W,
658
- createResource: F,
659
- updateResource: R,
660
- deleteResourceAsync: K,
661
- duplicateResource: _,
662
- isCreating: ye,
663
- isDeleting: se
664
- } = sa(
665
- void 0,
666
- (b) => {
667
- l(!1), b && (O(b), N(b), A());
668
- }
669
- ), {
670
- startUpdating: j,
671
- stopUpdating: X,
672
- isUpdating: he
673
- } = oa(), L = V, $ = re(() => {
674
- const b = s.trim().toLowerCase();
675
- return b ? L.filter(
676
- (B) => {
677
- var H, de, me;
678
- return ((H = B.title) == null ? void 0 : H.toLowerCase().includes(b)) || ((de = B.description) == null ? void 0 : de.toLowerCase().includes(b)) || ((me = B.kind) == null ? void 0 : me.toLowerCase().includes(b));
679
- }
680
- ) : L;
681
- }, [s, L]), ee = re(
682
- () => L.filter(
683
- (b) => n.has(b.id)
684
- ),
685
- [n, L]
686
- ), te = ee.filter(
687
- (b) => b.permissions.canDelete
688
- ), le = ee.filter(
689
- (b) => b.permissions.canShare
690
- ), Ce = $.length > 0 && $.every(
691
- (b) => n.has(b.id)
692
- ), Ee = $.some(
693
- (b) => n.has(b.id)
694
- ), Ye = (b) => {
695
- const B = new Set(n);
696
- b(B), d(B);
697
- }, q = (b) => {
698
- Ye((B) => {
699
- B.has(b) ? B.delete(b) : B.add(b);
700
- });
701
- }, Q = () => {
702
- d((b) => {
703
- const B = new Set(b);
704
- return Ce ? $.forEach(
705
- (H) => B.delete(H.id)
706
- ) : $.forEach(
707
- (H) => B.add(H.id)
708
- ), B;
709
- });
710
- }, oe = async (b) => {
711
- (await C(b)).success && A();
712
- }, we = async () => {
713
- const b = ee;
714
- if (b.length === 0) return;
715
- let B = !1;
716
- for (const H of b)
717
- if (!(await C(H)).success) {
718
- B = !0;
719
- break;
720
- }
721
- B || A();
722
- }, Xe = (b) => {
723
- N(b), A();
724
- }, fe = (b) => {
725
- M(b), _(b, {
726
- onSettled: () => M(null)
727
- });
728
- }, Ve = () => {
729
- if (te.length === 0) {
730
- I.error("Select a visual you can delete");
731
- return;
732
- }
733
- S(null), f(!0);
734
- }, Ze = async () => {
735
- const b = v ? [v] : te;
736
- try {
737
- for (const B of b)
738
- await K(B.id);
739
- d((B) => {
740
- const H = new Set(B);
741
- return b.forEach(
742
- (de) => H.delete(de.id)
743
- ), H;
744
- }), f(!1), S(null);
745
- } catch {
746
- }
747
- }, Ne = () => {
748
- if (ee.length !== 1) {
749
- I.error("Select one visual to share");
750
- return;
751
- }
752
- const [b] = ee;
753
- if (!b.permissions.canShare) {
754
- I.error("You do not have permission to share this visual");
755
- return;
756
- }
757
- u(b);
758
- }, Se = ({
759
- title: b,
760
- description: B
761
- }) => {
762
- if (!m) return;
763
- const H = {};
764
- if (b !== m.title && (H.title = b), (m.description || "") !== B && (H.description = B), Object.keys(H).length === 0) {
765
- p(null);
766
- return;
767
- }
768
- const de = Object.keys(H), me = de.length === 1 ? de[0] : void 0;
769
- j(m.id, me), R(
770
- {
771
- resourceId: m.id,
772
- data: H
773
- },
774
- {
775
- onSuccess: () => {
776
- X(m.id, me), p(null);
777
- },
778
- onError: () => {
779
- X(m.id, me);
780
- }
781
- }
782
- );
783
- }, ie = (b) => {
784
- a(b), b || U();
785
- }, ke = v ? 1 : te.length;
786
- return /* @__PURE__ */ r(z, { children: [
787
- /* @__PURE__ */ t(Ae, { open: e, onOpenChange: ie, children: /* @__PURE__ */ r(
788
- Fe,
789
- {
790
- showCloseButton: !1,
791
- className: "flex max-h-[80vh] w-[min(72rem,calc(100vw-2rem))] max-w-none grid-cols-none flex-col gap-0 overflow-hidden rounded-card border-border/60 p-0 shadow-lg sm:rounded-card",
792
- style: o.dialogStyle,
793
- children: [
794
- /* @__PURE__ */ r("div", { className: "flex h-10 shrink-0 items-center justify-between gap-2 border-b border-border/60 px-3", children: [
795
- /* @__PURE__ */ r("div", { className: "flex min-w-0 items-center gap-2", children: [
796
- /* @__PURE__ */ t(It, { className: "h-3.5 w-3.5 shrink-0 text-muted-foreground" }),
797
- /* @__PURE__ */ r("div", { className: "flex min-w-0 items-baseline gap-2", children: [
798
- /* @__PURE__ */ t(Ie, { className: "truncate text-[13px] font-medium leading-none tracking-normal", children: "Visuals library" }),
799
- /* @__PURE__ */ t("span", { className: "shrink-0 text-[10px] font-medium uppercase leading-none tracking-[0.08em] text-muted-foreground", children: "Add to dashboard" })
800
- ] })
801
- ] }),
802
- /* @__PURE__ */ t(
803
- T,
804
- {
805
- size: "xs",
806
- variant: "ghost",
807
- className: "w-7 px-0 text-muted-foreground hover:text-foreground",
808
- onClick: () => ie(!1),
809
- "aria-label": "Close visuals library",
810
- children: "×"
811
- }
812
- )
813
- ] }),
814
- /* @__PURE__ */ r("div", { className: "flex shrink-0 items-center gap-2 border-b border-border/60 px-3 py-2", children: [
815
- /* @__PURE__ */ r("div", { className: "relative min-w-[12rem] flex-1 md:max-w-md", children: [
816
- /* @__PURE__ */ t(sr, { className: "pointer-events-none absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground" }),
817
- /* @__PURE__ */ t(
818
- "input",
819
- {
820
- autoFocus: !0,
821
- value: s,
822
- onChange: (b) => i(b.target.value),
823
- placeholder: "Search visuals...",
824
- className: "h-7 w-full rounded-control border border-input bg-background pl-7 pr-2 text-[12px] text-foreground placeholder:text-muted-foreground focus:border-ring focus:outline-none",
825
- "aria-label": "Search visuals"
826
- }
827
- )
828
- ] }),
829
- /* @__PURE__ */ r(
830
- T,
831
- {
832
- size: "xs",
833
- variant: "outline",
834
- className: "ml-auto",
835
- onClick: () => l(!0),
836
- children: [
837
- /* @__PURE__ */ t(be, { className: "h-3.5 w-3.5" }),
838
- "New library visual"
839
- ]
840
- }
841
- )
842
- ] }),
843
- /* @__PURE__ */ t("div", { className: "min-h-0 flex-1 overflow-auto", children: w ? /* @__PURE__ */ t("div", { className: "p-3", children: /* @__PURE__ */ t(Ir, {}) }) : W ? /* @__PURE__ */ t("div", { className: "flex flex-col items-center gap-2 px-4 py-12 text-center", children: /* @__PURE__ */ t("p", { className: "text-[13px] text-destructive", children: "Failed to load visuals" }) }) : $.length === 0 ? /* @__PURE__ */ r("div", { className: "flex flex-col items-center gap-2 px-4 py-12 text-center", children: [
844
- /* @__PURE__ */ t(yt, { className: "h-5 w-5 text-muted-foreground/60" }),
845
- /* @__PURE__ */ t("p", { className: "text-[13px] font-medium", children: s ? "No visuals found" : "No visuals yet" }),
846
- /* @__PURE__ */ t("p", { className: "text-[12px] text-muted-foreground", children: s ? "Try a different search." : "Create a saved visual to add it here." })
847
- ] }) : /* @__PURE__ */ t(
848
- jr,
849
- {
850
- visuals: $,
851
- selectedIds: n,
852
- allFilteredSelected: Ce,
853
- someFilteredSelected: Ee,
854
- onSelectAll: Q,
855
- onToggleSelection: q,
856
- onAddVisual: oe,
857
- onOpenVisual: Xe,
858
- onEditDetails: p,
859
- onShareVisual: u,
860
- onDeleteVisual: (b) => {
861
- S(b), f(!0);
862
- },
863
- onDuplicateVisual: fe,
864
- duplicatingId: E,
865
- isDeleting: se,
866
- isConsoleMode: x
867
- }
868
- ) }),
869
- /* @__PURE__ */ r("div", { className: "flex shrink-0 items-center justify-between gap-2 border-t border-border/60 px-3 py-2", children: [
870
- /* @__PURE__ */ t("div", { className: "flex min-w-0 items-center gap-1.5", children: n.size > 0 && /* @__PURE__ */ r(z, { children: [
871
- /* @__PURE__ */ r("span", { className: "text-[12px] text-muted-foreground", children: [
872
- /* @__PURE__ */ t("span", { className: "font-medium tabular-nums text-foreground", children: n.size }),
873
- " ",
874
- "selected"
875
- ] }),
876
- /* @__PURE__ */ t(
877
- T,
878
- {
879
- size: "xs",
880
- variant: "ghost",
881
- onClick: () => d(/* @__PURE__ */ new Set()),
882
- children: "Clear"
883
- }
884
- ),
885
- /* @__PURE__ */ r(
886
- T,
887
- {
888
- size: "xs",
889
- variant: "outline",
890
- onClick: Ne,
891
- disabled: ee.length !== 1 || le.length !== 1,
892
- children: [
893
- /* @__PURE__ */ t(Tt, { className: "h-3.5 w-3.5" }),
894
- "Share"
895
- ]
896
- }
897
- ),
898
- /* @__PURE__ */ r(
899
- T,
900
- {
901
- size: "xs",
902
- variant: "outline",
903
- className: "text-destructive hover:text-destructive",
904
- onClick: Ve,
905
- disabled: te.length === 0,
906
- children: [
907
- /* @__PURE__ */ t(_e, { className: "h-3.5 w-3.5" }),
908
- "Delete ",
909
- te.length || n.size
910
- ]
911
- }
912
- )
913
- ] }) }),
914
- /* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
915
- /* @__PURE__ */ t(
916
- T,
917
- {
918
- size: "xs",
919
- variant: "outline",
920
- onClick: () => ie(!1),
921
- children: "Close"
922
- }
923
- ),
924
- /* @__PURE__ */ r(
925
- T,
926
- {
927
- size: "xs",
928
- onClick: we,
929
- disabled: n.size === 0,
930
- children: [
931
- /* @__PURE__ */ t(st, { className: "h-3.5 w-3.5" }),
932
- n.size === 0 ? "Add to dashboard" : `Add ${n.size} visual${n.size === 1 ? "" : "s"}`
933
- ]
934
- }
935
- )
936
- ] })
937
- ] })
938
- ]
939
- }
940
- ) }),
941
- /* @__PURE__ */ t(
942
- Er,
943
- {
944
- open: c,
945
- onOpenChange: l,
946
- onSubmit: F,
947
- isCreating: ye
948
- }
949
- ),
950
- h && /* @__PURE__ */ t(
951
- ia,
952
- {
953
- resource: h,
954
- resourceType: la.VISUAL,
955
- onClose: () => u(null)
956
- }
957
- ),
958
- m && /* @__PURE__ */ t(
959
- da,
960
- {
961
- open: !!m,
962
- resourceLabel: "Visual",
963
- initialTitle: m.title || "",
964
- initialDescription: m.description || "",
965
- onClose: () => p(null),
966
- onSave: Se,
967
- isSaving: he(m.id)
968
- }
969
- ),
970
- /* @__PURE__ */ t(
971
- lt,
972
- {
973
- open: g,
974
- onOpenChange: (b) => {
975
- !b && se || (f(b), b || S(null));
976
- },
977
- children: /* @__PURE__ */ r(dt, { children: [
978
- /* @__PURE__ */ r(ct, { children: [
979
- /* @__PURE__ */ r(ut, { children: [
980
- "Delete ",
981
- ke,
982
- " visual",
983
- ke === 1 ? "" : "s",
984
- "?"
985
- ] }),
986
- /* @__PURE__ */ t(ht, { children: "This cannot be undone. Visuals already added to dashboards may need to be removed from those dashboards separately." })
987
- ] }),
988
- /* @__PURE__ */ r(mt, { children: [
989
- /* @__PURE__ */ t(pt, { disabled: se, children: "Cancel" }),
990
- /* @__PURE__ */ r(
991
- Lt,
992
- {
993
- onClick: (b) => {
994
- b.preventDefault(), Ze();
995
- },
996
- disabled: se || ke === 0,
997
- children: [
998
- se ? /* @__PURE__ */ t(ne, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ t(_e, { className: "h-3.5 w-3.5" }),
999
- se ? "Deleting..." : "Delete"
1000
- ]
1001
- }
1002
- )
1003
- ] })
1004
- ] })
1005
- }
1006
- )
1007
- ] });
1008
- }
1009
- function jr({
1010
- visuals: e,
1011
- selectedIds: a,
1012
- allFilteredSelected: o,
1013
- someFilteredSelected: s,
1014
- onSelectAll: i,
1015
- onToggleSelection: n,
1016
- onAddVisual: d,
1017
- onOpenVisual: c,
1018
- onEditDetails: l,
1019
- onShareVisual: h,
1020
- onDeleteVisual: u,
1021
- onDuplicateVisual: m,
1022
- duplicatingId: p,
1023
- isDeleting: g,
1024
- isConsoleMode: f
1025
- }) {
1026
- return /* @__PURE__ */ r("div", { className: "min-w-[48rem]", children: [
1027
- /* @__PURE__ */ r("div", { className: "grid h-9 grid-cols-[2.5rem_minmax(14rem,1.8fr)_minmax(10rem,1fr)_8rem_7rem_5rem_5.5rem] items-center border-b border-border/60 px-3 text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground", children: [
1028
- /* @__PURE__ */ t(
1029
- ft,
1030
- {
1031
- checked: o ? !0 : s ? "indeterminate" : !1,
1032
- onCheckedChange: i,
1033
- "aria-label": "Select all visuals"
1034
- }
1035
- ),
1036
- /* @__PURE__ */ t("span", { children: "Name" }),
1037
- /* @__PURE__ */ t("span", { children: "Created by" }),
1038
- /* @__PURE__ */ t("span", { children: "Updated" }),
1039
- /* @__PURE__ */ t("span", { children: "Visibility" }),
1040
- /* @__PURE__ */ t("span", { className: "text-right", children: "Shared" }),
1041
- /* @__PURE__ */ t("span", { className: "text-right", children: "Actions" })
1042
- ] }),
1043
- e.map((v) => /* @__PURE__ */ t(
1044
- $r,
1045
- {
1046
- visual: v,
1047
- selected: a.has(v.id),
1048
- onToggleSelection: n,
1049
- onAddVisual: d,
1050
- onOpenVisual: c,
1051
- onEditDetails: l,
1052
- onShareVisual: h,
1053
- onDeleteVisual: u,
1054
- onDuplicateVisual: m,
1055
- duplicatingId: p,
1056
- isDeleting: g,
1057
- isConsoleMode: f
1058
- },
1059
- v.id
1060
- ))
1061
- ] });
1062
- }
1063
- function $r({
1064
- visual: e,
1065
- selected: a,
1066
- onToggleSelection: o,
1067
- onAddVisual: s,
1068
- onOpenVisual: i,
1069
- onEditDetails: n,
1070
- onShareVisual: d,
1071
- onDeleteVisual: c,
1072
- onDuplicateVisual: l,
1073
- duplicatingId: h,
1074
- isDeleting: u,
1075
- isConsoleMode: m
1076
- }) {
1077
- var f;
1078
- const p = _r(e.kind), g = () => {
1079
- s(e);
1080
- };
1081
- return /* @__PURE__ */ r(
1082
- "div",
1083
- {
1084
- className: Z(
1085
- "group grid min-h-12 grid-cols-[2.5rem_minmax(14rem,1.8fr)_minmax(10rem,1fr)_8rem_7rem_5rem_5.5rem] items-center border-b border-border/50 px-3 text-[13px] hover:bg-muted/50",
1086
- a && "bg-muted/70"
1087
- ),
1088
- children: [
1089
- /* @__PURE__ */ t("div", { children: /* @__PURE__ */ t(
1090
- ft,
1091
- {
1092
- checked: a,
1093
- onCheckedChange: () => o(e.id),
1094
- "aria-label": `Select ${e.title || "visual"}`
1095
- }
1096
- ) }),
1097
- /* @__PURE__ */ r(
1098
- "button",
1099
- {
1100
- type: "button",
1101
- className: "flex min-w-0 items-center gap-2 rounded-[4px] text-left outline-none focus-visible:ring-1 focus-visible:ring-ring",
1102
- onClick: g,
1103
- "aria-label": `Add ${e.title || "visual"} to dashboard`,
1104
- children: [
1105
- /* @__PURE__ */ t(p, { className: "h-3.5 w-3.5 shrink-0 text-muted-foreground" }),
1106
- /* @__PURE__ */ r("div", { className: "min-w-0", children: [
1107
- /* @__PURE__ */ t(
1108
- "div",
1109
- {
1110
- className: "truncate font-medium text-foreground",
1111
- title: e.title || "Untitled Visual",
1112
- children: e.title || "Untitled Visual"
1113
- }
1114
- ),
1115
- ((f = e.description) == null ? void 0 : f.trim()) && /* @__PURE__ */ t(
1116
- "div",
1117
- {
1118
- className: "truncate text-[11px] text-muted-foreground",
1119
- title: e.description,
1120
- children: e.description
1121
- }
1122
- )
1123
- ] })
1124
- ]
1125
- }
1126
- ),
1127
- /* @__PURE__ */ r("div", { className: "flex min-w-0 items-center gap-2", children: [
1128
- /* @__PURE__ */ t("div", { className: "flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-muted text-[9px] font-medium text-muted-foreground", children: Or(e, m) }),
1129
- /* @__PURE__ */ t("span", { className: "truncate text-muted-foreground", children: Ct(e, m) })
1130
- ] }),
1131
- /* @__PURE__ */ t("span", { className: "text-muted-foreground", children: Wt(e.updatedAt) }),
1132
- /* @__PURE__ */ t(zr, { visual: e }),
1133
- /* @__PURE__ */ t("span", { className: "text-right tabular-nums text-muted-foreground", children: e.ownership.sharedCount > 0 ? e.ownership.sharedCount : "—" }),
1134
- /* @__PURE__ */ t(
1135
- Wr,
1136
- {
1137
- visual: e,
1138
- onOpenVisual: i,
1139
- onEditDetails: n,
1140
- onShareVisual: d,
1141
- onDeleteVisual: c,
1142
- onDuplicateVisual: l,
1143
- duplicatingId: h,
1144
- isDeleting: u,
1145
- isConsoleMode: m
1146
- }
1147
- )
1148
- ]
1149
- }
1150
- );
1151
- }
1152
- function Wr({
1153
- visual: e,
1154
- onOpenVisual: a,
1155
- onEditDetails: o,
1156
- onShareVisual: s,
1157
- onDeleteVisual: i,
1158
- onDuplicateVisual: n,
1159
- duplicatingId: d,
1160
- isDeleting: c,
1161
- isConsoleMode: l
1162
- }) {
1163
- return /* @__PURE__ */ r(
1164
- "div",
1165
- {
1166
- className: "flex items-center justify-end gap-0.5 opacity-0 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100",
1167
- onClick: (h) => h.stopPropagation(),
1168
- children: [
1169
- /* @__PURE__ */ t(
1170
- T,
1171
- {
1172
- size: "xs",
1173
- variant: "ghost",
1174
- className: "w-7 px-0",
1175
- onClick: () => a(e),
1176
- "aria-label": "Edit visual",
1177
- children: /* @__PURE__ */ t(Je, { className: "h-3.5 w-3.5" })
1178
- }
1179
- ),
1180
- /* @__PURE__ */ r(Qe, { modal: !1, children: [
1181
- /* @__PURE__ */ t(He, { asChild: !0, children: /* @__PURE__ */ t(
1182
- T,
1183
- {
1184
- size: "xs",
1185
- variant: "ghost",
1186
- className: "w-7 px-0",
1187
- "aria-label": "More actions",
1188
- children: /* @__PURE__ */ t(Bt, { className: "h-3.5 w-3.5" })
1189
- }
1190
- ) }),
1191
- /* @__PURE__ */ r(
1192
- Ge,
1193
- {
1194
- align: "end",
1195
- className: "z-[60] w-44 rounded-[6px] border-border/60 p-1 shadow-sm",
1196
- children: [
1197
- /* @__PURE__ */ r(Y, { onClick: () => a(e), children: [
1198
- /* @__PURE__ */ t(Je, { className: "h-3.5 w-3.5" }),
1199
- "Edit visual"
1200
- ] }),
1201
- /* @__PURE__ */ r(
1202
- Y,
1203
- {
1204
- onClick: () => n(e.id),
1205
- disabled: d === e.id,
1206
- children: [
1207
- d === e.id ? /* @__PURE__ */ t(ne, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ t(ha, { className: "h-3.5 w-3.5" }),
1208
- d === e.id ? "Duplicating..." : "Duplicate"
1209
- ]
1210
- }
1211
- ),
1212
- e.permissions.canEdit && /* @__PURE__ */ r(Y, { onClick: () => o(e), children: [
1213
- /* @__PURE__ */ t(Je, { className: "h-3.5 w-3.5" }),
1214
- "Edit details"
1215
- ] }),
1216
- e.permissions.canShare && /* @__PURE__ */ r(Y, { onClick: () => s(e), children: [
1217
- /* @__PURE__ */ t(Tt, { className: "h-3.5 w-3.5" }),
1218
- "Share"
1219
- ] }),
1220
- e.permissions.canDelete && /* @__PURE__ */ r(z, { children: [
1221
- /* @__PURE__ */ t(ze, {}),
1222
- /* @__PURE__ */ r(
1223
- Y,
1224
- {
1225
- className: "text-destructive focus:bg-destructive/10 focus:text-destructive",
1226
- onClick: () => i(e),
1227
- disabled: c,
1228
- children: [
1229
- /* @__PURE__ */ t(_e, { className: "h-3.5 w-3.5" }),
1230
- c ? "Deleting..." : "Delete"
1231
- ]
1232
- }
1233
- )
1234
- ] }),
1235
- /* @__PURE__ */ t(ze, {}),
1236
- /* @__PURE__ */ r("div", { className: "space-y-1 px-2 py-1.5 text-[11px] text-muted-foreground", children: [
1237
- qt(e, l) && /* @__PURE__ */ r("div", { className: "flex items-center gap-1.5", children: [
1238
- /* @__PURE__ */ t(ma, { className: "h-3 w-3" }),
1239
- /* @__PURE__ */ t("span", { className: "truncate", children: Ct(e, l) })
1240
- ] }),
1241
- /* @__PURE__ */ r("div", { className: "flex items-center gap-1.5", children: [
1242
- /* @__PURE__ */ t(pa, { className: "h-3 w-3" }),
1243
- /* @__PURE__ */ t("span", { children: Wt(e.updatedAt) })
1244
- ] })
1245
- ] })
1246
- ]
1247
- }
1248
- )
1249
- ] })
1250
- ]
1251
- }
1252
- );
1253
- }
1254
- function os(e, a, o = !1) {
1255
- const s = D((h) => h.dashboard), i = D(
1256
- (h) => h.isDashboardEditing
1257
- ), n = D(
1258
- (h) => h.onDashboardLifecycleEvent
1259
- ), d = ae(() => {
1260
- const h = D.getState().dashboard;
1261
- return a || !e || !h || h.id !== e.id ? !1 : Pe(h) !== Pe(e);
1262
- }, [e, a]);
1263
- Nt(() => (D.setState({ checkUnsavedDashboardChanges: d }), () => {
1264
- D.getState().checkUnsavedDashboardChanges === d && D.setState({ checkUnsavedDashboardChanges: null });
1265
- }), [d]);
1266
- const c = re(() => !o || a || !s || i && (!e || s.id !== e.id) ? null : {
1267
- dashboardId: s.id,
1268
- dirty: i && e ? Pe(s) !== Pe(e) : !1
1269
- }, [
1270
- i,
1271
- a,
1272
- o,
1273
- e,
1274
- s
1275
- ]), l = rt(null);
1276
- return Nt(() => {
1277
- if (!n || !c) {
1278
- l.current = null;
1279
- return;
1280
- }
1281
- const h = l.current;
1282
- (h == null ? void 0 : h.callback) === n && h.dashboardId === c.dashboardId && h.dirty === c.dirty || (l.current = {
1283
- callback: n,
1284
- dashboardId: c.dashboardId,
1285
- dirty: c.dirty
1286
- }, n({
1287
- type: "dashboard:dirty-state",
1288
- dashboardId: c.dashboardId,
1289
- payload: { dirty: c.dirty }
1290
- }));
1291
- }, [c, n]), d;
1292
- }
1293
- function qr({
1294
- open: e,
1295
- onOpenChange: a,
1296
- isLibraryVisual: o,
1297
- currentVisualName: s,
1298
- isSaving: i = !1,
1299
- destinationMode: n = "both",
1300
- onConfirm: d
1301
- }) {
1302
- const [c, l] = k(
1303
- o && s ? `Copy of ${s}` : s || ""
1304
- ), [h, u] = k("");
1305
- Ft.useEffect(() => {
1306
- e && (l(
1307
- o && s ? `Copy of ${s}` : s || ""
1308
- ), u(""));
1309
- }, [e, o, s]);
1310
- const m = !!c.trim(), p = n === "local" ? {
1311
- saveToLibrary: !1,
1312
- saveToCurrentDashboard: !0,
1313
- badgeType: "local",
1314
- description: "Creates a local copy on the current dashboard.",
1315
- actionLabel: "Add to Dashboard (Local)"
1316
- } : n === "library" ? {
1317
- saveToLibrary: !0,
1318
- saveToCurrentDashboard: !1,
1319
- badgeType: "library",
1320
- description: "Creates a reusable visual in Visual Library.",
1321
- actionLabel: "Save as Library Visual"
1322
- } : {
1323
- saveToLibrary: !0,
1324
- saveToCurrentDashboard: !0,
1325
- badgeType: "linked",
1326
- description: "Creates a new library visual and adds a linked copy to this dashboard.",
1327
- actionLabel: "Save Copy as Linked Visual"
1328
- }, g = () => {
1329
- !m || i || d({
1330
- name: c.trim(),
1331
- description: h.trim() || void 0,
1332
- saveToLibrary: p.saveToLibrary,
1333
- saveToCurrentDashboard: p.saveToCurrentDashboard
1334
- });
1335
- };
1336
- return /* @__PURE__ */ t(Ae, { open: e, onOpenChange: a, children: /* @__PURE__ */ r(Fe, { className: "sm:max-w-[500px]", children: [
1337
- /* @__PURE__ */ r(gt, { children: [
1338
- /* @__PURE__ */ r(Ie, { className: "flex items-center gap-2", children: [
1339
- /* @__PURE__ */ t("span", { children: "Save Visual As" }),
1340
- p.badgeType !== "local" && /* @__PURE__ */ t(
1341
- fr,
1342
- {
1343
- type: p.badgeType,
1344
- showLabel: !0,
1345
- className: "px-2 py-0.5"
1346
- }
1347
- )
1348
- ] }),
1349
- /* @__PURE__ */ t(bt, { children: p.description })
1350
- ] }),
1351
- /* @__PURE__ */ r("div", { className: "grid gap-4 py-4", children: [
1352
- /* @__PURE__ */ r("div", { className: "grid gap-2", children: [
1353
- /* @__PURE__ */ t(De, { htmlFor: "name", children: "Name" }),
1354
- /* @__PURE__ */ t(
1355
- nt,
1356
- {
1357
- id: "name",
1358
- value: c,
1359
- onChange: (f) => l(f.target.value),
1360
- placeholder: "Enter visual name",
1361
- disabled: i
1362
- }
1363
- )
1364
- ] }),
1365
- /* @__PURE__ */ r("div", { className: "grid gap-2", children: [
1366
- /* @__PURE__ */ t(De, { htmlFor: "description", children: "Description (optional)" }),
1367
- /* @__PURE__ */ t(
1368
- fa,
1369
- {
1370
- id: "description",
1371
- value: h,
1372
- onChange: (f) => u(f.target.value),
1373
- placeholder: "Enter visual description",
1374
- rows: 3,
1375
- disabled: i
1376
- }
1377
- )
1378
- ] })
1379
- ] }),
1380
- /* @__PURE__ */ r(ga, { children: [
1381
- /* @__PURE__ */ t(
1382
- T,
1383
- {
1384
- variant: "outline",
1385
- onClick: () => a(!1),
1386
- disabled: i,
1387
- children: "Cancel"
1388
- }
1389
- ),
1390
- /* @__PURE__ */ r(T, { onClick: g, disabled: !m || i, children: [
1391
- i && /* @__PURE__ */ t(ne, { className: "mr-2 h-4 w-4 animate-spin" }),
1392
- p.actionLabel
1393
- ] })
1394
- ] })
1395
- ] }) });
1396
- }
1397
- function wt(e) {
1398
- var a;
1399
- for (const o of e.cards)
1400
- if (o.type === "matrixTable" && !nr.safeParse((a = o.config) == null ? void 0 : a.matrix).success)
1401
- return I.error("Matrix requires at least one row field, one metric, and valid settings."), !1;
1402
- return !0;
1403
- }
1404
- function et({
1405
- className: e,
1406
- variant: a = "outline"
1407
- }) {
1408
- const o = J((n) => n.onSave), { getUpdatedFrame: s } = ve();
1409
- function i() {
1410
- const n = s();
1411
- wt(n) && (o == null || o(n));
1412
- }
1413
- return /* @__PURE__ */ r(
1414
- T,
1415
- {
1416
- onClick: i,
1417
- className: e,
1418
- size: "xs",
1419
- variant: a,
1420
- children: [
1421
- /* @__PURE__ */ t(st, { className: "h-3.5 w-3.5" }),
1422
- "Done"
1423
- ]
1424
- }
1425
- );
1426
- }
1427
- function Qr({
1428
- className: e,
1429
- variant: a = "default"
1430
- }) {
1431
- const o = $e(), [s, i] = k(!1), { setIsVisualEditing: n } = ue(), { getUpdatedFrame: d } = ve(), c = We(), l = J((m) => m.frame), h = Pt();
1432
- return /* @__PURE__ */ t(
1433
- T,
1434
- {
1435
- onClick: () => {
1436
- const m = d();
1437
- if (!wt(m))
1438
- return;
1439
- const p = (l == null ? void 0 : l.visualId) || (c == null ? void 0 : c.id);
1440
- if (!p) {
1441
- I.error("No visual to save");
1442
- return;
1443
- }
1444
- i(!0), h.mutate(
1445
- {
1446
- visualId: p,
1447
- data: {
1448
- frameObject: m
1449
- }
1450
- },
1451
- {
1452
- onSuccess: () => {
1453
- i(!1), I.success("Visual updated successfully"), o.invalidateQueries({
1454
- queryKey: ["resource-by-id", "visual", p],
1455
- exact: !0
1456
- });
1457
- },
1458
- onError: () => {
1459
- i(!1), I.error("Failed to update visual");
1460
- }
1461
- }
1462
- );
1463
- },
1464
- className: e,
1465
- size: "xs",
1466
- variant: a,
1467
- children: s ? /* @__PURE__ */ r(z, { children: [
1468
- /* @__PURE__ */ t(ne, { className: "h-3.5 w-3.5 animate-spin" }),
1469
- "Saving"
1470
- ] }) : /* @__PURE__ */ r(z, { children: [
1471
- /* @__PURE__ */ t(_t, { className: "h-3.5 w-3.5" }),
1472
- "Save to Library"
1473
- ] })
1474
- }
1475
- );
1476
- }
1477
- function Hr({
1478
- className: e
1479
- }) {
1480
- const a = $e(), [o, s] = k(!1), i = We(), n = J((f) => f.frame), d = D((f) => f.selectedSheetId), c = D((f) => f.dashboard), { updateFrame: l, setIsVisualEditing: h } = ue(), { getUpdatedFrame: u } = ve(), m = Pt(), p = xt();
1481
- return /* @__PURE__ */ t(
1482
- T,
1483
- {
1484
- onClick: async () => {
1485
- if (!d) {
1486
- I.error("No sheet selected");
1487
- return;
1488
- }
1489
- const f = (n == null ? void 0 : n.visualId) || (i == null ? void 0 : i.id);
1490
- if (!f) {
1491
- I.error("No visual to update");
1492
- return;
1493
- }
1494
- s(!0);
1495
- try {
1496
- const v = u();
1497
- if (!wt(v)) {
1498
- s(!1);
1499
- return;
1500
- }
1501
- const S = {
1502
- ...v,
1503
- visualId: f
1504
- // Keep the link to library visual
1505
- }, E = je(c, S.id), M = await p(S, {
1506
- previousFrame: E
1507
- });
1508
- await m.mutateAsync({
1509
- visualId: f,
1510
- data: {
1511
- frameObject: v
1512
- }
1513
- }), l(d, S, {
1514
- semanticExecutionPayload: M
1515
- }), a.invalidateQueries({ queryKey: ["visuals"] }), a.invalidateQueries({ queryKey: ["visual", f] }), I.success("Saved to library and applied locally"), setTimeout(() => {
1516
- h(!1);
1517
- }, 300);
1518
- } catch (v) {
1519
- console.error("Failed to save and apply:", v), I.error(
1520
- v instanceof Error ? v.message : "Failed to save and apply changes"
1521
- );
1522
- } finally {
1523
- s(!1);
1524
- }
1525
- },
1526
- className: e,
1527
- size: "xs",
1528
- variant: "default",
1529
- disabled: o,
1530
- children: o ? /* @__PURE__ */ r(z, { children: [
1531
- /* @__PURE__ */ t(ne, { className: "h-3.5 w-3.5 animate-spin" }),
1532
- "Saving..."
1533
- ] }) : /* @__PURE__ */ r(z, { children: [
1534
- /* @__PURE__ */ t(_t, { className: "h-3.5 w-3.5" }),
1535
- "Save & Apply"
1536
- ] })
1537
- }
1538
- );
1539
- }
1540
- function tt({ className: e }) {
1541
- const { setTempQueryData: a, setSqlGen: o } = qe(), s = $e(), i = J((c) => c.tempQueryData), n = J((c) => c.onClose);
1542
- function d() {
1543
- if (i) {
1544
- const { queryKey: c, queryData: l } = i;
1545
- c && l && s.setQueryData(c, l);
1546
- }
1547
- o({}), n == null || n();
1548
- }
1549
- return /* @__PURE__ */ r(
1550
- T,
1551
- {
1552
- onClick: d,
1553
- className: e,
1554
- size: "xs",
1555
- variant: "outline",
1556
- children: [
1557
- /* @__PURE__ */ t(Ke, { className: "h-3.5 w-3.5" }),
1558
- "Close"
1559
- ]
1560
- }
1561
- );
1562
- }
1563
- function Gr() {
1564
- const [e, a] = k(!1), [o, s] = k(!1), [i, n] = k(null), [d, c] = k(null), l = J((N) => N.frame), h = J((N) => N.card), u = We(), m = D((N) => N.selectedSheetId), p = D((N) => N.dashboard), { getUpdatedFrame: g } = ve(), { selectVisual: f } = it(), { addFrame: v, setSelectedFrameId: S, setIsVisualEditing: E } = ue(), M = xt(), U = !!(l != null && l.visualId), A = (() => {
1565
- var N, x;
1566
- return ((N = l == null ? void 0 : l.cards) == null ? void 0 : N.length) === 1 && ((x = l.cards[0]) != null && x.title) ? l.cards[0].title : u != null && u.title ? u.title : (h == null ? void 0 : h.title) || "Untitled Visual";
1567
- })(), O = ba((N) => {
1568
- N != null && N.id && (f(N), o && i && d && m && (async () => {
1569
- try {
1570
- const x = {
1571
- ...i,
1572
- id: St(),
1573
- visualId: N.id
1574
- // Link to the newly created library visual
1575
- };
1576
- v(m, x, {
1577
- placement: "end",
1578
- semanticExecutionPayload: d
1579
- }), S(x.id), s(!1), n(null), c(null), E(!1);
1580
- } catch (x) {
1581
- console.error(
1582
- "Failed to promote semantic metadata for saved visual:",
1583
- x
1584
- ), I.error(
1585
- x instanceof Error ? x.message : "Failed to prepare semantic metadata for the saved visual"
1586
- );
1587
- }
1588
- })(), a(!1));
1589
- });
1590
- return {
1591
- saveAsDialogOpen: e,
1592
- setSaveAsDialogOpen: a,
1593
- handleSaveAs: async (N) => {
1594
- if (!m) {
1595
- I.error("No sheet selected");
1596
- return;
1597
- }
1598
- const x = g(), w = x.cards.length === 1 ? {
1599
- ...x,
1600
- cards: x.cards.map((W) => ({
1601
- ...W,
1602
- title: N.name
1603
- // Use visual name as card title
1604
- }))
1605
- } : x;
1606
- if (N.saveToLibrary) {
1607
- let W = null;
1608
- if (N.saveToCurrentDashboard)
1609
- try {
1610
- W = await M(w, {
1611
- previousFrame: je(p, w.id)
1612
- });
1613
- } catch (R) {
1614
- console.error(
1615
- "Failed to prepare semantic metadata before saving visual:",
1616
- R
1617
- ), I.error(
1618
- R instanceof Error ? R.message : "Failed to prepare semantic metadata for the saved visual"
1619
- );
1620
- return;
1621
- }
1622
- s(N.saveToCurrentDashboard), n(w), c(W);
1623
- const F = {
1624
- title: N.name,
1625
- description: N.description,
1626
- frameObject: w,
1627
- // Card title synced for single-card frames
1628
- isPrivate: !1
1629
- };
1630
- O.mutate(F);
1631
- } else if (N.saveToCurrentDashboard) {
1632
- const W = {
1633
- ...w,
1634
- // Card title already synced
1635
- id: St(),
1636
- visualId: void 0
1637
- // Explicitly no visualId for local visuals
1638
- };
1639
- try {
1640
- const F = await M(w, {
1641
- previousFrame: je(p, w.id)
1642
- });
1643
- v(m, W, {
1644
- placement: "end",
1645
- semanticExecutionPayload: F
1646
- }), S(W.id), I.success("Visual saved to dashboard"), a(!1), E(!1);
1647
- } catch (F) {
1648
- console.error("Failed to save visual to dashboard:", F), I.error(
1649
- F instanceof Error ? F.message : "Failed to prepare semantic metadata for the visual"
1650
- );
1651
- }
1652
- }
1653
- },
1654
- isLibraryVisual: U,
1655
- currentVisualName: A,
1656
- isSaving: O.isPending
1657
- };
1658
- }
1659
- function is(e = {}) {
1660
- const { isInspectionMode: a } = xa(), o = J((F) => F.frame), s = J((F) => F.editorContext), i = va((F) => F.selectedVisual), n = D((F) => F.selectedFrameId), d = D((F) => F.selectedSheetId), c = D((F) => F.dashboard), { setIsVisualEditing: l, updateFrame: h } = ue(), [u, m] = k(!1), [p, g] = k("both"), f = xt(), v = (s == null ? void 0 : s.type) === "documentSection", S = !!(o != null && o.visualId || i != null && i.id), E = !!(o != null && o.visualId && n), M = S && !E, {
1661
- saveAsDialogOpen: U,
1662
- setSaveAsDialogOpen: A,
1663
- handleSaveAs: O,
1664
- isLibraryVisual: C,
1665
- currentVisualName: N,
1666
- isSaving: x
1667
- } = Gr(), { getUpdatedFrame: V } = ve();
1668
- if (a)
1669
- return /* @__PURE__ */ r(z, { children: [
1670
- /* @__PURE__ */ t(
1671
- et,
1672
- {
1673
- className: "rounded-control",
1674
- variant: "default"
1675
- }
1676
- ),
1677
- /* @__PURE__ */ t(tt, {})
1678
- ] });
1679
- if (v)
1680
- return /* @__PURE__ */ r(z, { children: [
1681
- /* @__PURE__ */ t(et, { className: "rounded-control", variant: "default" }),
1682
- /* @__PURE__ */ t(tt, {})
1683
- ] });
1684
- const w = async () => {
1685
- if (!d) {
1686
- I.error("No sheet selected");
1687
- return;
1688
- }
1689
- if (u) return;
1690
- m(!0);
1691
- const R = {
1692
- ...V(),
1693
- visualId: void 0
1694
- }, K = je(c, R.id);
1695
- try {
1696
- const _ = await f(R, {
1697
- previousFrame: K
1698
- });
1699
- h(d, R, {
1700
- semanticExecutionPayload: _
1701
- });
1702
- } catch (_) {
1703
- console.error("Failed to apply local semantic metadata:", _), m(!1), I.error(
1704
- _ instanceof Error ? _.message : "Failed to prepare semantic metadata for this visual"
1705
- );
1706
- return;
1707
- }
1708
- setTimeout(() => {
1709
- m(!1), I.success("Changes applied. Visual is now local to this dashboard"), l(!1);
1710
- }, 300);
1711
- }, W = (F) => {
1712
- g(F), A(!0);
1713
- };
1714
- return /* @__PURE__ */ r(z, { children: [
1715
- /* @__PURE__ */ r("div", { className: "inline-flex items-center overflow-hidden rounded-control", children: [
1716
- !S && /* @__PURE__ */ t(et, { className: "!rounded-none", variant: "default" }),
1717
- S && M && /* @__PURE__ */ t(Qr, { className: "!rounded-none", variant: "default" }),
1718
- S && E && /* @__PURE__ */ t(Hr, { className: "!rounded-none" }),
1719
- /* @__PURE__ */ r(Qe, { modal: !1, children: [
1720
- /* @__PURE__ */ t(He, { asChild: !0, children: /* @__PURE__ */ t(
1721
- T,
1722
- {
1723
- variant: "default",
1724
- size: "xs",
1725
- className: "w-7 !rounded-none border-l border-primary-foreground/20 px-0",
1726
- "aria-label": "Open visual save options",
1727
- disabled: x || u,
1728
- children: /* @__PURE__ */ t(Ot, { className: "h-3.5 w-3.5" })
1729
- }
1730
- ) }),
1731
- /* @__PURE__ */ r(
1732
- Ge,
1733
- {
1734
- align: "end",
1735
- className: "min-w-[220px] rounded-control border border-border/60 p-1 shadow-sm",
1736
- children: [
1737
- E && /* @__PURE__ */ r(z, { children: [
1738
- /* @__PURE__ */ r(
1739
- Y,
1740
- {
1741
- onClick: w,
1742
- disabled: u,
1743
- children: [
1744
- /* @__PURE__ */ t(st, { className: "h-3.5 w-3.5" }),
1745
- u ? "Applying..." : "Apply Locally"
1746
- ]
1747
- }
1748
- ),
1749
- /* @__PURE__ */ t(ze, {})
1750
- ] }),
1751
- /* @__PURE__ */ r(
1752
- Y,
1753
- {
1754
- onClick: () => W("local"),
1755
- disabled: x,
1756
- children: [
1757
- /* @__PURE__ */ t(be, { className: "h-3.5 w-3.5" }),
1758
- "Add to Dashboard (Local)"
1759
- ]
1760
- }
1761
- ),
1762
- /* @__PURE__ */ r(
1763
- Y,
1764
- {
1765
- onClick: () => W("library"),
1766
- disabled: x,
1767
- children: [
1768
- /* @__PURE__ */ t(gr, { className: "h-3.5 w-3.5" }),
1769
- "Save as Library Visual"
1770
- ]
1771
- }
1772
- ),
1773
- /* @__PURE__ */ r(
1774
- Y,
1775
- {
1776
- onClick: () => W("both"),
1777
- disabled: x,
1778
- children: [
1779
- /* @__PURE__ */ t(br, { className: "h-3.5 w-3.5" }),
1780
- "Save Copy as Linked Visual"
1781
- ]
1782
- }
1783
- )
1784
- ]
1785
- }
1786
- )
1787
- ] })
1788
- ] }),
1789
- /* @__PURE__ */ t(tt, {}),
1790
- /* @__PURE__ */ t(
1791
- qr,
1792
- {
1793
- open: U,
1794
- onOpenChange: (F) => {
1795
- x || A(F);
1796
- },
1797
- isLibraryVisual: C,
1798
- currentVisualName: N,
1799
- isSaving: x,
1800
- destinationMode: p,
1801
- onConfirm: O
1802
- }
1803
- )
1804
- ] });
1805
- }
1806
- function ls({ className: e }) {
1807
- const a = J((u) => u.isDevMode), o = J((u) => u.card.type), s = D((u) => u.isVisualEditing), { setIsDevMode: i } = qe(), { config: n } = Kt(ya).tokenProps, d = (n == null ? void 0 : n.showAdvancedMode) !== !1;
1808
- if (!s || !d || !Yt(o))
1809
- return null;
1810
- const c = a ? Ar : Dr, l = a ? "Visual editor" : "SQL editor", h = a ? "Switch to visual editor" : "Switch to SQL editor";
1811
- return /* @__PURE__ */ r(
1812
- "button",
1813
- {
1814
- type: "button",
1815
- "aria-label": h,
1816
- title: h,
1817
- onClick: () => i(!a),
1818
- className: Z(
1819
- "inline-flex h-7 items-center gap-1.5 rounded-control border border-input bg-background px-2 text-[12px] font-medium text-foreground transition-colors hover:bg-muted/40 focus-visible:border-ring focus-visible:outline-none",
1820
- e
1821
- ),
1822
- children: [
1823
- /* @__PURE__ */ t(c, { className: "h-3 w-3 text-muted-foreground" }),
1824
- l
1825
- ]
1826
- }
1827
- );
1828
- }
1829
- function ds({
1830
- open: e,
1831
- onOpenChange: a,
1832
- onSave: o,
1833
- onDiscard: s,
1834
- isSaving: i,
1835
- title: n = "Unsaved changes",
1836
- description: d = "You have unsaved changes to this dashboard. What would you like to do?",
1837
- cancelLabel: c = "Cancel",
1838
- discardLabel: l = "Discard changes",
1839
- saveLabel: h = "Save"
1840
- }) {
1841
- return /* @__PURE__ */ t(lt, { open: e, onOpenChange: (m) => {
1842
- !m && i || a(m);
1843
- }, children: /* @__PURE__ */ r(dt, { children: [
1844
- /* @__PURE__ */ r(ct, { children: [
1845
- /* @__PURE__ */ t(ut, { children: n }),
1846
- /* @__PURE__ */ t(ht, { children: d })
1847
- ] }),
1848
- /* @__PURE__ */ r(mt, { children: [
1849
- /* @__PURE__ */ t(
1850
- T,
1851
- {
1852
- type: "button",
1853
- size: "xs",
1854
- onClick: s,
1855
- disabled: i,
1856
- variant: "outline",
1857
- className: "mr-auto text-destructive hover:border-destructive/40 hover:bg-destructive/10 hover:text-destructive focus-visible:bg-destructive/10 focus-visible:text-destructive",
1858
- children: l
1859
- }
1860
- ),
1861
- /* @__PURE__ */ t(pt, { disabled: i, children: c }),
1862
- /* @__PURE__ */ t(T, { type: "button", size: "xs", onClick: o, disabled: i, children: i ? /* @__PURE__ */ r(z, { children: [
1863
- /* @__PURE__ */ t(ne, { className: "mr-2 h-3.5 w-3.5 animate-spin" }),
1864
- "Saving..."
1865
- ] }) : h })
1866
- ] })
1867
- ] }) });
1868
- }
1869
- async function cs(e) {
1870
- var n, d;
1871
- const a = (d = (n = D.getState()) == null ? void 0 : n.authToken) == null ? void 0 : d.accessToken;
1872
- if (!a)
1873
- return;
1874
- const o = `${e}/v1/invalidate-token`, s = await fetch(o, {
1875
- method: "POST",
1876
- headers: {
1877
- Authorization: `Bearer ${a}`
1878
- }
1879
- });
1880
- if (!s.ok)
1881
- throw new Error("Failed to invalidate token");
1882
- const i = await s.json();
1883
- return console.log("invalidateToken", i), i;
1884
- }
1885
- function Kr(e) {
1886
- switch (e == null ? void 0 : e.kind) {
1887
- case "queued":
1888
- return { text: G.queued };
1889
- case "preparing":
1890
- return { text: G.preparing };
1891
- case "fetching":
1892
- return { text: G.fetchingRows(e.rowsProcessed) };
1893
- case "finalizing":
1894
- return { text: G.finalizing };
1895
- case "processing":
1896
- return e.percent === null ? { text: G.processing } : { text: G.processing, detail: G.percentComplete(e.percent), bar: e.percent };
1897
- default:
1898
- return { text: G.inProgress };
1899
- }
1900
- }
1901
- function Yr(e) {
1902
- var o;
1903
- const a = e.item;
1904
- return a.kind === "export" ? {
1905
- title: a.title,
1906
- status: a.status,
1907
- startedAt: a.startedAt,
1908
- finishedAt: a.finishedAt,
1909
- running: Kr(a.stage),
1910
- finishedDetail: [
1911
- a.totalRows !== null ? `${a.totalRows.toLocaleString("en-US")} rows` : null,
1912
- a.fileSize ? Aa(a.fileSize) : null
1913
- ].filter((s) => !!s),
1914
- failure: ((o = a.failure) == null ? void 0 : o.kind) === "export" ? a.failure.message : a.status === "failed" ? G.failedFallback : null,
1915
- note: null
1916
- } : {
1917
- title: a.title,
1918
- status: a.status,
1919
- startedAt: a.startedAt,
1920
- finishedAt: a.finishedAt,
1921
- running: { text: a.stageLabel ?? G.inProgress },
1922
- finishedDetail: [],
1923
- failure: null,
1924
- note: a.omittedAttachmentCount > 0 ? pe.attachmentsLeftOut(a.omittedAttachmentCount) : null
1925
- };
1926
- }
1927
- function Xr({ row: e, now: a, api: o }) {
1928
- const [s, i] = k("idle"), n = Yr(e), d = Ca(e, o), c = async () => {
1929
- if (!d) return;
1930
- i("working");
1931
- const f = await Fa(o, e, d);
1932
- i(f === "done" ? "idle" : f);
1933
- }, l = n.status === "ready" ? "bg-emerald-500" : n.status === "failed" ? "bg-destructive" : n.status === "cancelled" ? "bg-muted-foreground/40" : "animate-pulse bg-muted-foreground/60", h = n.status === "ready" ? G.ready : n.status === "failed" ? G.failed : n.status === "cancelled" ? G.cancelled : G.inProgress, u = Date.parse(n.startedAt), m = kt(Date.parse(n.finishedAt ?? n.startedAt), a, { addSuffix: !0 }), p = n.status === "running" && e.item.kind === "export" && a - u >= wa, g = /* @__PURE__ */ t("span", { className: "text-muted-foreground/50", children: "·" });
1934
- return /* @__PURE__ */ r("div", { className: "group flex items-start gap-2.5 px-3 py-2 transition-colors hover:bg-muted/40 focus-within:bg-muted/40", children: [
1935
- /* @__PURE__ */ t("span", { className: "flex h-5 shrink-0 items-center", "aria-hidden": "true", children: /* @__PURE__ */ t("span", { className: `h-1.5 w-1.5 rounded-full ${l}` }) }),
1936
- /* @__PURE__ */ t("span", { className: "sr-only", children: h }),
1937
- /* @__PURE__ */ r("div", { className: "min-w-0 flex-1", children: [
1938
- /* @__PURE__ */ r("div", { className: "flex h-5 items-center gap-2", children: [
1939
- /* @__PURE__ */ t("span", { className: "min-w-0 flex-1 truncate text-[13px] font-medium leading-5", children: n.title }),
1940
- d && s === "working" && /* @__PURE__ */ t("span", { role: "status", className: "inline-flex shrink-0 items-center gap-1.5 text-[12px] text-muted-foreground", children: /* @__PURE__ */ t(Mt, { className: "h-3 w-3 animate-spin", strokeWidth: 1.75 }) }),
1941
- d && s !== "working" && /* @__PURE__ */ t(
1942
- "button",
1943
- {
1944
- type: "button",
1945
- onClick: () => void c(),
1946
- className: "shrink-0 text-[12px] font-medium text-foreground/80 underline-offset-2 hover:text-foreground hover:underline focus-visible:underline focus-visible:outline-none",
1947
- children: Na[d]
1948
- }
1949
- )
1950
- ] }),
1951
- n.status === "running" && n.running && /* @__PURE__ */ r("div", { className: "text-[12px] leading-4 text-muted-foreground", children: [
1952
- /* @__PURE__ */ t("span", { className: "tabular-nums", children: n.running.text }),
1953
- n.running.detail && /* @__PURE__ */ r(z, { children: [
1954
- " ",
1955
- g,
1956
- " ",
1957
- /* @__PURE__ */ t("span", { className: "tabular-nums", children: n.running.detail })
1958
- ] }),
1959
- " ",
1960
- g,
1961
- " ",
1962
- /* @__PURE__ */ t("span", { children: G.started(kt(u, a)) }),
1963
- n.running.bar !== void 0 && /* @__PURE__ */ t(Sa, { value: n.running.bar, className: "mt-1.5 h-1" }),
1964
- p && /* @__PURE__ */ t("div", { className: "mt-1", children: G.longRunning })
1965
- ] }),
1966
- n.status !== "running" && /* @__PURE__ */ r("div", { className: "flex items-center gap-1.5 text-[12px] leading-4 text-muted-foreground", children: [
1967
- n.status === "ready" && n.finishedDetail.length > 0 ? (
1968
- // Disclosed on hover or focus only; the time is what a reader scans.
1969
- /* @__PURE__ */ r("span", { className: "hidden group-hover:contents group-focus-within:contents", children: [
1970
- n.finishedDetail.map((f, v) => /* @__PURE__ */ r(Ft.Fragment, { children: [
1971
- v > 0 && g,
1972
- /* @__PURE__ */ t("span", { children: f })
1973
- ] }, v)),
1974
- g
1975
- ] })
1976
- ) : n.status !== "ready" ? /* @__PURE__ */ r(z, { children: [
1977
- /* @__PURE__ */ t("span", { children: h }),
1978
- g
1979
- ] }) : null,
1980
- /* @__PURE__ */ t("span", { children: m })
1981
- ] }),
1982
- n.note && /* @__PURE__ */ t("div", { className: "text-[12px] leading-4 text-muted-foreground", children: n.note }),
1983
- n.status === "failed" && n.failure && /* @__PURE__ */ t("div", { className: "mt-1 whitespace-pre-wrap break-words text-[12px] leading-4 text-destructive", children: n.failure }),
1984
- (s === "denied" || s === "blocked") && /* @__PURE__ */ r("div", { role: "alert", className: "mt-1 flex items-start gap-1.5 text-[12px] leading-4 text-foreground", children: [
1985
- /* @__PURE__ */ t(ka, { className: "mt-0.5 h-3 w-3 shrink-0 text-destructive", strokeWidth: 1.75 }),
1986
- /* @__PURE__ */ t("span", { children: Da(s) })
1987
- ] })
1988
- ] })
1989
- ] });
1990
- }
1991
- function us({ variant: e }) {
1992
- const { snapshot: a, markSeen: o } = vt(), s = a.runningCount > 0 ? a.runningCount > 9 ? "9+" : String(a.runningCount) : a.hasUnseenFinished ? "" : null;
1993
- return /* @__PURE__ */ r(Ue, { onOpenChange: (i) => {
1994
- i && o();
1995
- }, children: [
1996
- /* @__PURE__ */ t(Re, { asChild: !0, children: /* @__PURE__ */ r(
1997
- T,
1998
- {
1999
- variant: e ?? "ghost",
2000
- size: "xs",
2001
- className: "relative w-7 px-0 text-muted-foreground hover:text-foreground",
2002
- "aria-label": pe.title,
2003
- title: pe.title,
2004
- children: [
2005
- /* @__PURE__ */ t(Sr, { className: "h-3.5 w-3.5" }),
2006
- s !== null && /* @__PURE__ */ t(
2007
- "span",
2008
- {
2009
- className: `absolute flex items-center justify-center rounded-full bg-primary text-primary-foreground ${s ? "-right-0.5 -top-0.5 h-3.5 min-w-3.5 px-0.5 text-[9px] font-semibold" : "right-1 top-1 h-1.5 w-1.5"}`,
2010
- children: s
2011
- }
2012
- )
2013
- ]
2014
- }
2015
- ) }),
2016
- /* @__PURE__ */ t(Oe, { className: "w-80 p-0", align: "end", sideOffset: 8, children: /* @__PURE__ */ t(Zr, {}) })
2017
- ] });
2018
- }
2019
- function Zr() {
2020
- const e = vt(), a = Ia(), { rows: o, activeTruncated: s } = e.snapshot, i = o.some((n) => Ea(n.item.status));
2021
- return o.length === 0 ? /* @__PURE__ */ r("div", { className: "flex flex-col items-center gap-1.5 px-6 py-8 text-center", children: [
2022
- /* @__PURE__ */ t("span", { className: "flex h-8 w-8 items-center justify-center rounded-[6px] border border-border text-muted-foreground", children: /* @__PURE__ */ t(Va, { className: "h-3.5 w-3.5", strokeWidth: 1.75 }) }),
2023
- /* @__PURE__ */ t("p", { className: "text-[13px] font-medium", children: pe.title }),
2024
- /* @__PURE__ */ t("p", { className: "text-[12px] text-muted-foreground", children: pe.empty })
2025
- ] }) : /* @__PURE__ */ r("div", { className: "flex flex-col", children: [
2026
- /* @__PURE__ */ r("div", { className: "flex h-8 items-center gap-2 border-b border-border px-3", children: [
2027
- /* @__PURE__ */ t("span", { className: "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground", children: pe.title }),
2028
- /* @__PURE__ */ t("span", { className: "text-[10px] tabular-nums text-muted-foreground/70", children: o.length }),
2029
- /* @__PURE__ */ r("div", { className: "ml-auto flex items-center gap-0.5", children: [
2030
- i && /* @__PURE__ */ t(
2031
- T,
2032
- {
2033
- variant: "ghost",
2034
- size: "xs",
2035
- className: "h-6 px-1.5 text-[12px] text-muted-foreground hover:text-foreground",
2036
- onClick: e.clearFinished,
2037
- children: pe.clear
2038
- }
2039
- ),
2040
- /* @__PURE__ */ t(
2041
- T,
2042
- {
2043
- variant: "ghost",
2044
- size: "xs",
2045
- className: "h-6 w-6 px-0 text-muted-foreground hover:text-foreground",
2046
- onClick: e.refresh,
2047
- title: "Refresh status",
2048
- "aria-label": "Refresh status",
2049
- children: /* @__PURE__ */ t(Mt, { strokeWidth: 1.75, className: "h-3.5 w-3.5" })
2050
- }
2051
- )
2052
- ] })
2053
- ] }),
2054
- s && /* @__PURE__ */ t("p", { className: "border-b border-border px-3 py-2 text-[12px] leading-4 text-muted-foreground", children: pe.truncated }),
2055
- /* @__PURE__ */ t("div", { className: "max-h-[320px] overflow-y-auto", children: /* @__PURE__ */ t("div", { className: "divide-y divide-border/70", children: o.map((n) => /* @__PURE__ */ t(Xr, { row: n, now: a, api: e }, Ta(n))) }) })
2056
- ] });
2057
- }
2058
- function Jr(e) {
2059
- if (e)
2060
- return {
2061
- renamed: e.type === "rename" ? { oldId: e.oldId, newId: e.newId } : void 0,
2062
- removedControlId: e.type === "remove" ? e.controlId : void 0,
2063
- cardBindingsById: e.type === "add" || e.type === "update" ? e.cardBindingsById : void 0,
2064
- affectedBindingControlIds: e.type === "add" || e.type === "update" ? e.affectedBindingControlIds : void 0
2065
- };
2066
- }
2067
- function en({
2068
- open: e,
2069
- onOpenChange: a,
2070
- trigger: o,
2071
- showTrigger: s = !0,
2072
- initialMode: i = "manage"
2073
- }) {
2074
- const n = i === "create", {
2075
- forceClose: d,
2076
- handleOpenChange: c,
2077
- isCreateFlowActive: l,
2078
- preventPassiveDismissDuringCreate: h,
2079
- resolvedOpen: u,
2080
- setIsCreateFlowActive: m
2081
- } = zt({
2082
- open: e,
2083
- onOpenChange: a,
2084
- initialCreateFlowActive: i === "create",
2085
- // Dialog mode renders a built-in X close button — allow explicit
2086
- // closes through `handleOpenChange`. Popover mode has no X; its
2087
- // only close-via-trigger path is a re-click that would silently
2088
- // wipe the in-progress create flow, so block everything during
2089
- // create and make consumers use `forceClose()` from a dedicated
2090
- // button.
2091
- dismissMode: s ? "passive" : "explicit-only"
2092
- }), p = D((x) => x.dashboard), { setDashboardControlsModel: g } = ue(), { participants: f } = La(pr(p)), v = Array.from(
2093
- new Map(
2094
- f.flatMap(
2095
- (x) => x.fieldChoices.map((V) => {
2096
- var w;
2097
- return [
2098
- V.value,
2099
- {
2100
- option: V,
2101
- target: (w = x.fieldTargetMap) == null ? void 0 : w[V.value]
2102
- }
2103
- ];
2104
- })
2105
- )
2106
- ).values()
2107
- ), S = Array.from(
2108
- new Map(
2109
- f.flatMap(
2110
- (x) => x.metricChoices.map((V) => {
2111
- var w;
2112
- return [
2113
- V.value,
2114
- {
2115
- option: V,
2116
- target: (w = x.metricTargetMap) == null ? void 0 : w[V.value]
2117
- }
2118
- ];
2119
- })
2120
- )
2121
- ).values()
2122
- ), E = ir({
2123
- ...p || {},
2124
- controls: []
2125
- }), M = Ba(p), U = (x, V, w) => {
2126
- g(
2127
- x,
2128
- V,
2129
- Jr(w)
2130
- );
2131
- }, A = ae(() => {
2132
- if (n) {
2133
- d();
2134
- return;
2135
- }
2136
- m(!1);
2137
- }, [n, d, m]), O = /* @__PURE__ */ t(
2138
- jt,
2139
- {
2140
- scope: "dashboard",
2141
- controls: p.controls || [],
2142
- reservedControlIds: E,
2143
- defaultValues: p.defaultControlValues || {},
2144
- usageByControlId: Pa(p),
2145
- availableFieldChoices: v,
2146
- availableMetricChoices: S,
2147
- structuralParticipants: f,
2148
- structuralParticipantIdsByControlId: M,
2149
- initialCreateFlow: i === "create",
2150
- onCreateFlowActiveChange: m,
2151
- onCreateFlowComplete: A,
2152
- onChange: U,
2153
- emptyMessage: "No dashboard controls yet."
2154
- }
2155
- ), C = l ? "Add dashboard control" : "Dashboard Controls", N = /* @__PURE__ */ r(z, { children: [
2156
- /* @__PURE__ */ r("div", { className: "space-y-1", children: [
2157
- /* @__PURE__ */ t("h4", { className: "text-sm font-medium", children: "Dashboard Controls" }),
2158
- /* @__PURE__ */ t("p", { className: "text-xs text-muted-foreground", children: "Add shared controls viewers can use across the dashboard. Each card can decide how to respond to the same control." })
2159
- ] }),
2160
- O
2161
- ] });
2162
- return s ? /* @__PURE__ */ r(Ue, { open: u, onOpenChange: c, children: [
2163
- /* @__PURE__ */ t(Re, { asChild: !0, children: o || /* @__PURE__ */ r(T, { variant: "outline", className: "h-7 px-2", size: "sm", children: [
2164
- /* @__PURE__ */ t(Et, { className: "mr-2 h-4 w-4" }),
2165
- "Controls"
2166
- ] }) }),
2167
- /* @__PURE__ */ t(
2168
- Oe,
2169
- {
2170
- className: "w-[620px] max-w-[95vw] space-y-4",
2171
- align: "end",
2172
- onEscapeKeyDown: h,
2173
- onPointerDownOutside: h,
2174
- children: N
2175
- }
2176
- )
2177
- ] }) : /* @__PURE__ */ t(Ae, { open: u, onOpenChange: c, children: /* @__PURE__ */ r(
2178
- Fe,
2179
- {
2180
- className: "flex max-h-[88vh] flex-col overflow-hidden sm:max-w-[600px]",
2181
- onEscapeKeyDown: h,
2182
- onPointerDownOutside: h,
2183
- children: [
2184
- /* @__PURE__ */ r(
2185
- gt,
2186
- {
2187
- className: l ? "space-y-0" : void 0,
2188
- children: [
2189
- /* @__PURE__ */ t(Ie, { className: "text-[15px]", children: C }),
2190
- /* @__PURE__ */ t(
2191
- bt,
2192
- {
2193
- className: l ? "sr-only" : "text-[13px]",
2194
- children: l ? "Configure and add a shared dashboard control." : "Add shared controls viewers can use across the dashboard. Each card can decide how to respond to the same control."
2195
- }
2196
- )
2197
- ]
2198
- }
2199
- ),
2200
- /* @__PURE__ */ t("div", { className: "min-h-0 overflow-y-auto pr-1", children: O })
2201
- ]
2202
- }
2203
- ) });
2204
- }
2205
- const tn = [
2206
- "enum",
2207
- "multi_enum",
2208
- "text",
2209
- "number",
2210
- "boolean",
2211
- "date"
2212
- ];
2213
- function an({
2214
- open: e,
2215
- onOpenChange: a,
2216
- initialMode: o = "manage"
2217
- }) {
2218
- var N;
2219
- const s = o === "create", {
2220
- forceClose: i,
2221
- handleOpenChange: n,
2222
- isCreateFlowActive: d,
2223
- preventPassiveDismissDuringCreate: c,
2224
- resolvedOpen: l,
2225
- setIsCreateFlowActive: h
2226
- } = zt({
2227
- open: e,
2228
- onOpenChange: a,
2229
- initialCreateFlowActive: o === "create",
2230
- dismissMode: "explicit-only"
2231
- }), u = D((x) => x.dashboard), m = D((x) => x.selectedSheetId), { setDashboardInputs: p } = ue(), g = (N = u.sheets) == null ? void 0 : N.find(
2232
- (x) => x.id === m
2233
- ), f = (g == null ? void 0 : g.kind) === "document" && !!g.document, v = re(
2234
- () => f && (g != null && g.document) ? lr(u, g.id) : [],
2235
- [u, f, g == null ? void 0 : g.document, g == null ? void 0 : g.id]
2236
- ), S = re(
2237
- () => v.filter(
2238
- (x) => x.kind === "control"
2239
- ),
2240
- [v]
2241
- ), E = re(
2242
- () => S.map((x) => x.control),
2243
- [S]
2244
- ), M = re(
2245
- () => nn(E),
2246
- [E]
2247
- ), U = re(
2248
- () => rn(u),
2249
- [u]
2250
- ), A = ae(() => {
2251
- if (s) {
2252
- i();
2253
- return;
2254
- }
2255
- h(!1);
2256
- }, [s, i, h]), O = ae(
2257
- (x, V, w) => {
2258
- !f || !(g != null && g.document) || p(
2259
- on({
2260
- allInputs: u.inputs || [],
2261
- documentSheetId: g.id,
2262
- currentDocumentInputs: v,
2263
- nextControls: x,
2264
- nextDefaultValues: V,
2265
- change: w
2266
- })
2267
- );
2268
- },
2269
- [
2270
- u.inputs,
2271
- v,
2272
- f,
2273
- g,
2274
- p
2275
- ]
2276
- );
2277
- return !f || !(g != null && g.document) ? null : /* @__PURE__ */ t(Ae, { open: l, onOpenChange: n, children: /* @__PURE__ */ r(
2278
- Fe,
2279
- {
2280
- className: "flex max-h-[88vh] flex-col overflow-hidden sm:max-w-[600px]",
2281
- onEscapeKeyDown: c,
2282
- onPointerDownOutside: c,
2283
- children: [
2284
- /* @__PURE__ */ r(gt, { className: d ? "space-y-0" : void 0, children: [
2285
- /* @__PURE__ */ t(Ie, { className: "text-[15px]", children: d ? "Add document control" : "Document Controls" }),
2286
- /* @__PURE__ */ t(
2287
- bt,
2288
- {
2289
- className: d ? "sr-only" : "text-[13px]",
2290
- children: d ? "Configure and add a document-local control input." : "Add document-local control inputs. They are stored on this document sheet and are not dashboard controls."
2291
- }
2292
- )
2293
- ] }),
2294
- /* @__PURE__ */ t("div", { className: "min-h-0 overflow-y-auto pr-1", children: /* @__PURE__ */ t(
2295
- jt,
2296
- {
2297
- scope: "dashboard",
2298
- controls: E,
2299
- reservedControlIds: U,
2300
- defaultValues: M,
2301
- usageByControlId: {},
2302
- availableFieldChoices: [],
2303
- availableMetricChoices: [],
2304
- structuralParticipants: [],
2305
- structuralParticipantIdsByControlId: {},
2306
- allowedControlTypes: tn,
2307
- initialCreateFlow: o === "create",
2308
- onCreateFlowActiveChange: h,
2309
- onCreateFlowComplete: A,
2310
- onChange: O,
2311
- emptyMessage: "No document controls yet."
2312
- }
2313
- ) })
2314
- ]
2315
- }
2316
- ) });
2317
- }
2318
- function rn(e) {
2319
- return (e.controls || []).map((a) => a.id);
2320
- }
2321
- function nn(e) {
2322
- const a = {};
2323
- for (const o of e)
2324
- o.defaultValue !== void 0 && (a[o.id] = o.defaultValue);
2325
- return a;
2326
- }
2327
- function sn(e, a) {
2328
- return a ? Object.prototype.hasOwnProperty.call(a, e.id) ? {
2329
- ...e,
2330
- defaultValue: a[e.id]
2331
- } : e.defaultValue === void 0 ? e : { ...e, defaultValue: void 0 } : e.defaultValue === void 0 ? e : { ...e, defaultValue: void 0 };
2332
- }
2333
- function on({
2334
- allInputs: e,
2335
- documentSheetId: a,
2336
- currentDocumentInputs: o,
2337
- nextControls: s,
2338
- nextDefaultValues: i,
2339
- change: n
2340
- }) {
2341
- const d = new Map(
2342
- s.map((p) => [
2343
- p.id,
2344
- sn(p, i)
2345
- ])
2346
- ), c = (n == null ? void 0 : n.type) === "rename" ? { oldId: n.oldId, newId: n.newId } : null, l = /* @__PURE__ */ new Set(), h = [];
2347
- for (const p of o) {
2348
- if (p.kind !== "control") {
2349
- h.push(p);
2350
- continue;
2351
- }
2352
- const g = d.get(p.control.id) || ((c == null ? void 0 : c.oldId) === p.control.id ? d.get(c.newId) : void 0);
2353
- if (!g)
2354
- continue;
2355
- l.add(g.id);
2356
- const f = dr(
2357
- g.id,
2358
- [...e, ...h].filter(
2359
- (S) => S.id !== p.id
2360
- )
2361
- ), v = g.id === f ? g : { ...g, id: f };
2362
- h.push({
2363
- ...p,
2364
- label: v.label,
2365
- variableName: f,
2366
- requiredAtExecution: v.requiredAtExecution,
2367
- control: v
2368
- });
2369
- }
2370
- for (const p of d.values())
2371
- l.has(p.id) || h.push(
2372
- cr({
2373
- control: p,
2374
- existingInputs: [...e, ...h],
2375
- sheetId: a
2376
- })
2377
- );
2378
- const u = new Set(
2379
- o.map((p) => p.id)
2380
- );
2381
- return [...e.filter(
2382
- (p) => !u.has(p.id)
2383
- ), ...h];
2384
- }
2385
- function ln({
2386
- showFilters: e,
2387
- onShowFiltersChange: a,
2388
- pickerContent: o,
2389
- settingsContent: s,
2390
- size: i = "default",
2391
- className: n,
2392
- primaryButtonClassName: d,
2393
- secondaryButtonClassName: c,
2394
- pickerContentClassName: l,
2395
- settingsContentClassName: h
2396
- }) {
2397
- const u = i === "toolbar", [m, p] = k(!1), g = ot("interactive");
2398
- return /* @__PURE__ */ r(
2399
- "div",
2400
- {
2401
- className: Z(
2402
- // Height lives on the shell so the outer border is part of the
2403
- // h-7 box (matches regular `size="xs"` buttons). Inner triggers
2404
- // stretch to fill via `h-full`.
2405
- "relative inline-flex items-stretch overflow-hidden rounded-control border border-input bg-background",
2406
- u ? "h-8" : "h-7",
2407
- n
2408
- ),
2409
- children: [
2410
- /* @__PURE__ */ r(Ue, { open: e, onOpenChange: a, children: [
2411
- /* @__PURE__ */ t(Re, { asChild: !0, children: /* @__PURE__ */ r(
2412
- T,
2413
- {
2414
- variant: "ghost",
2415
- size: "xs",
2416
- className: Z(
2417
- "h-full rounded-none border-0 bg-transparent pl-2.5 pr-2 shadow-none hover:bg-accent/50 data-[state=open]:bg-accent/60",
2418
- d
2419
- ),
2420
- children: [
2421
- e ? /* @__PURE__ */ t(xr, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ t(Ut, { className: "h-3.5 w-3.5" }),
2422
- "Filter"
2423
- ]
2424
- }
2425
- ) }),
2426
- /* @__PURE__ */ t(
2427
- Oe,
2428
- {
2429
- align: "end",
2430
- sideOffset: 6,
2431
- className: Z(
2432
- "w-auto rounded-card border border-border/60 p-0 shadow-[0_10px_28px_rgba(0,0,0,0.14)] dark:shadow-[0_10px_28px_rgba(0,0,0,0.5)]",
2433
- l
2434
- ),
2435
- style: g.contentStyle,
2436
- children: o
2437
- }
2438
- )
2439
- ] }),
2440
- /* @__PURE__ */ r(Ue, { open: m, onOpenChange: p, children: [
2441
- /* @__PURE__ */ t(Re, { asChild: !0, children: /* @__PURE__ */ t(
2442
- T,
2443
- {
2444
- variant: "ghost",
2445
- size: "xs",
2446
- className: Z(
2447
- "h-full w-7 rounded-none border-0 border-l border-border/60 bg-transparent px-0 shadow-none hover:bg-accent/50 data-[state=open]:bg-accent/60",
2448
- c
2449
- ),
2450
- "aria-label": "Filter and control actions",
2451
- children: /* @__PURE__ */ t(Ot, { className: "h-3.5 w-3.5" })
2452
- }
2453
- ) }),
2454
- /* @__PURE__ */ t(
2455
- Oe,
2456
- {
2457
- align: "end",
2458
- sideOffset: 6,
2459
- className: Z(
2460
- "w-auto rounded-card border border-border/60 p-0 shadow-[0_10px_28px_rgba(0,0,0,0.14)] dark:shadow-[0_10px_28px_rgba(0,0,0,0.5)]",
2461
- h
2462
- ),
2463
- style: g.contentStyle,
2464
- children: s(() => p(!1))
2465
- }
2466
- )
2467
- ] })
2468
- ]
2469
- }
2470
- );
2471
- }
2472
- function dn() {
2473
- vr();
2474
- const e = D((l) => l.selectedSheetId), a = D((l) => l.selectedFrameId), o = D((l) => l.dashboard), s = D((l) => l.actions.getSelectedFrame), { setSelectedFrameId: i } = ue(), { setCard: n } = qe(), d = J((l) => l.card.dataSource);
2475
- return ge(() => {
2476
- var h, u;
2477
- let l = s();
2478
- if (!l) {
2479
- const m = (h = o == null ? void 0 : o.sheets) == null ? void 0 : h.find((g) => g.id === e), p = (u = m == null ? void 0 : m.frames) == null ? void 0 : u[0];
2480
- p && (i(p.id), l = p);
2481
- }
2482
- if (l) {
2483
- const m = l.cards.find((p) => p.id === l.activeCardId);
2484
- m && n(m);
2485
- }
2486
- }, [s, e, a, o, i, n]), {
2487
- hasEntities: !!(d != null && d.selectedEntities && d.selectedEntities.length > 0)
2488
- };
2489
- }
2490
- function cn() {
2491
- const e = D((l) => l.dashboard), a = D(
2492
- (l) => l.semanticExecutionPayload
2493
- ), o = D((l) => l.actions.addFilter), { hasEntities: s } = dn(), { isLoading: i } = Ma(), n = re(
2494
- () => ur(e, a),
2495
- [e, a]
2496
- ), c = !hr(e.filters) && n.hasEligibleCards && !i;
2497
- return /* @__PURE__ */ r("div", { className: "flex h-[520px] w-[400px] flex-col", children: [
2498
- c && /* @__PURE__ */ t("div", { className: "border-b border-border/60 p-2", children: /* @__PURE__ */ r(
2499
- "button",
2500
- {
2501
- type: "button",
2502
- onClick: () => o(mr()),
2503
- title: `Applies to ${n.eligibleCardCount} of ${n.totalCardCount} date-aware cards`,
2504
- className: "flex w-full items-start gap-2 rounded-control px-2 py-1.5 text-left outline-none transition-colors hover:bg-muted/40 focus-visible:bg-muted/40 focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-border",
2505
- children: [
2506
- /* @__PURE__ */ t(kr, { className: "mt-0.5 h-3.5 w-3.5 shrink-0 text-muted-foreground" }),
2507
- /* @__PURE__ */ r("span", { className: "flex min-w-0 flex-col", children: [
2508
- /* @__PURE__ */ t("span", { className: "text-[12px] font-medium text-foreground", children: "Add global date filter" }),
2509
- /* @__PURE__ */ t("span", { className: "text-[11px] leading-[1.4] text-muted-foreground", children: "One date range across all date-aware cards." })
2510
- ] })
2511
- ]
2512
- }
2513
- ) }),
2514
- !s && /* @__PURE__ */ r("div", { className: "flex flex-1 flex-col items-center justify-center px-6 py-8 text-center", children: [
2515
- /* @__PURE__ */ t(Ua, { className: "mb-3 h-10 w-10 text-muted-foreground/50" }),
2516
- /* @__PURE__ */ t("h3", { className: "mb-1 text-[13px] font-medium text-foreground", children: "No fields configured" }),
2517
- /* @__PURE__ */ t("p", { className: "text-[11px] text-muted-foreground", children: "Configure a data source for this card to enable filtering." })
2518
- ] }),
2519
- s && /* @__PURE__ */ t("div", { className: "flex flex-1 overflow-hidden", children: /* @__PURE__ */ t(Ra, { context: "filter" }) })
2520
- ] });
2521
- }
2522
- const At = !1;
2523
- function un({
2524
- onAddFilter: e,
2525
- onAddControl: a,
2526
- onManageControls: o,
2527
- onDismiss: s
2528
- }) {
2529
- const i = D(
2530
- (c) => c.dashboard.filterLayout
2531
- ), { setFilterLayout: n } = ue();
2532
- i != null && i.displayMode;
2533
- const d = (i == null ? void 0 : i.toolbarWrap) ?? !1;
2534
- return i == null || i.showDownloadButton, /* @__PURE__ */ r("div", { className: "w-[300px]", children: [
2535
- /* @__PURE__ */ r("div", { className: "p-1", children: [
2536
- /* @__PURE__ */ t(
2537
- at,
2538
- {
2539
- icon: Ut,
2540
- label: "Add filter",
2541
- onClick: () => {
2542
- e(), s();
2543
- }
2544
- }
2545
- ),
2546
- /* @__PURE__ */ t(
2547
- at,
2548
- {
2549
- icon: Et,
2550
- label: "Add control",
2551
- onClick: () => {
2552
- a(), s();
2553
- }
2554
- }
2555
- ),
2556
- /* @__PURE__ */ t(
2557
- at,
2558
- {
2559
- icon: Rt,
2560
- label: "Manage controls",
2561
- onClick: () => {
2562
- o(), s();
2563
- }
2564
- }
2565
- )
2566
- ] }),
2567
- /* @__PURE__ */ t("div", { className: "border-t border-border/60" }),
2568
- /* @__PURE__ */ r("div", { className: "space-y-1 p-2", children: [
2569
- /* @__PURE__ */ t("p", { className: "px-1 text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground", children: "Display" }),
2570
- At,
2571
- /* @__PURE__ */ t(
2572
- hn,
2573
- {
2574
- id: "filter-display-wrap",
2575
- label: "Wrap to multiple lines",
2576
- checked: d,
2577
- onCheckedChange: (c) => n({ toolbarWrap: c === !0 })
2578
- }
2579
- ),
2580
- At
2581
- ] })
2582
- ] });
2583
- }
2584
- function at({
2585
- icon: e,
2586
- label: a,
2587
- onClick: o
2588
- }) {
2589
- return /* @__PURE__ */ r(
2590
- "button",
2591
- {
2592
- type: "button",
2593
- onClick: o,
2594
- className: "flex w-full items-center gap-2 rounded-control px-2 py-1.5 text-left text-[13px] text-foreground outline-none transition-colors hover:bg-muted/40 focus-visible:bg-muted/40",
2595
- children: [
2596
- /* @__PURE__ */ t(e, { className: "h-3.5 w-3.5 text-muted-foreground" }),
2597
- a
2598
- ]
2599
- }
2600
- );
2601
- }
2602
- function hn({
2603
- id: e,
2604
- label: a,
2605
- checked: o,
2606
- onCheckedChange: s
2607
- }) {
2608
- return /* @__PURE__ */ r("div", { className: "flex items-center gap-2 rounded-control px-1 py-1 transition-colors hover:bg-muted/40 focus-within:bg-muted/40", children: [
2609
- /* @__PURE__ */ t(ft, { id: e, checked: o, onCheckedChange: s }),
2610
- /* @__PURE__ */ t(
2611
- De,
2612
- {
2613
- htmlFor: e,
2614
- className: "cursor-pointer text-[12px] font-normal leading-[1.3]",
2615
- children: a
2616
- }
2617
- )
2618
- ] });
2619
- }
2620
- function hs({
2621
- size: e,
2622
- className: a,
2623
- primaryButtonClassName: o,
2624
- secondaryButtonClassName: s,
2625
- pickerContentClassName: i,
2626
- settingsContentClassName: n
2627
- }) {
2628
- var O;
2629
- const [d, c] = k(null), l = D((C) => C.dashboard), h = D((C) => C.selectedSheetId), u = D((C) => C.showFilters), m = D((C) => C.actions), { setDocumentPanelTarget: p, setShowFilters: g } = m, f = (O = l.sheets) == null ? void 0 : O.find(
2630
- (C) => C.id === h
2631
- ), v = yr(f), S = ae((C) => {
2632
- window.setTimeout(() => {
2633
- c(C);
2634
- }, 0);
2635
- }, []), E = ae(
2636
- (C) => {
2637
- if (v && h) {
2638
- C && p(h, {
2639
- kind: "document",
2640
- group: "inputs"
2641
- });
2642
- return;
2643
- }
2644
- g(C);
2645
- },
2646
- [
2647
- v,
2648
- h,
2649
- p,
2650
- g
2651
- ]
2652
- ), M = ae(() => {
2653
- E(!0);
2654
- }, [E]), U = ae(() => {
2655
- S("create");
2656
- }, [S]), A = ae(() => {
2657
- S("manage");
2658
- }, [S]);
2659
- return /* @__PURE__ */ r(z, { children: [
2660
- /* @__PURE__ */ t(
2661
- ln,
2662
- {
2663
- showFilters: v ? !1 : u,
2664
- onShowFiltersChange: E,
2665
- pickerContent: /* @__PURE__ */ t(cn, {}),
2666
- settingsContent: (C) => /* @__PURE__ */ t(
2667
- un,
2668
- {
2669
- onAddFilter: M,
2670
- onAddControl: U,
2671
- onManageControls: A,
2672
- onDismiss: C
2673
- }
2674
- ),
2675
- size: e,
2676
- className: a,
2677
- primaryButtonClassName: o,
2678
- secondaryButtonClassName: s,
2679
- pickerContentClassName: i,
2680
- settingsContentClassName: n
2681
- }
2682
- ),
2683
- d ? v ? /* @__PURE__ */ t(
2684
- an,
2685
- {
2686
- open: !0,
2687
- onOpenChange: (C) => {
2688
- C || c(null);
2689
- },
2690
- initialMode: d
2691
- }
2692
- ) : /* @__PURE__ */ t(
2693
- en,
2694
- {
2695
- open: !0,
2696
- onOpenChange: (C) => {
2697
- C || c(null);
2698
- },
2699
- showTrigger: !1,
2700
- initialMode: d
2701
- }
2702
- ) : null
2703
- ] });
2704
- }
2705
- function mn({
2706
- disabled: e,
2707
- briefingCount: a,
2708
- className: o,
2709
- onClick: s
2710
- }) {
2711
- const i = typeof a == "number" && a > 0;
2712
- return /* @__PURE__ */ r(
2713
- T,
2714
- {
2715
- type: "button",
2716
- size: "xs",
2717
- variant: "outline",
2718
- disabled: e,
2719
- className: Z("gap-1.5", o),
2720
- onClick: s,
2721
- "aria-label": "Reports & briefings",
2722
- children: [
2723
- /* @__PURE__ */ t(Fr, { className: "h-3.5 w-3.5" }),
2724
- "Reports & briefings",
2725
- i ? /* @__PURE__ */ t("span", { className: "ml-0.5 rounded-control bg-muted px-1 text-[10px] tabular-nums text-foreground/70", children: a }) : null
2726
- ]
2727
- }
2728
- );
2729
- }
2730
- const pn = "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground", Qt = "inline-flex h-7 items-center gap-1.5 rounded-control px-2 text-[12px] text-muted-foreground hover:bg-muted hover:text-foreground disabled:opacity-50", Me = "inline-flex h-7 items-center gap-1.5 rounded-control bg-primary px-3 text-[12px] font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50";
2731
- function fn(e) {
2732
- return e === "dashboard" ? "This dashboard" : "Project";
2733
- }
2734
- function gn(e) {
2735
- if (!e) return "Never";
2736
- const a = new Date(e);
2737
- if (Number.isNaN(a.getTime())) return "Unknown";
2738
- const o = Date.now() - a.getTime(), s = Math.round(o / 6e4);
2739
- if (s < 1) return "now";
2740
- if (s < 60) return `${s}m ago`;
2741
- const i = Math.round(s / 60);
2742
- if (i < 24) return `${i}h ago`;
2743
- const n = Math.round(i / 24);
2744
- if (n < 7) return `${n}d ago`;
2745
- const d = Math.round(n / 7);
2746
- return d < 5 ? `${d}w ago` : `${Math.round(n / 30)}mo ago`;
2747
- }
2748
- function bn(e) {
2749
- return e.scheduleExpr ? Cr(
2750
- e.scheduleExpr,
2751
- e.timezone || "UTC"
2752
- ) ?? "Invalid schedule" : "On demand";
2753
- }
2754
- function xn(e) {
2755
- if (e.lastRunStatus) {
2756
- const a = e.lastRunStatus.toString().toUpperCase();
2757
- return a === "SUCCESS" ? "Last run completed." : a === "FAILED" ? "Last run failed." : `Last run ${e.lastRunStatus.toString().toLowerCase()}`;
2758
- }
2759
- return null;
2760
- }
2761
- function Ht(e) {
2762
- return e.hasActiveRun ? "Running" : e.lastRunStatus ? `Last run ${e.lastRunStatus.toString().toLowerCase()}` : "Idle";
2763
- }
2764
- function vn(e) {
2765
- return e.source.type === "dashboard" ? "This dashboard" : "Project";
2766
- }
2767
- function yn({
2768
- activeView: e,
2769
- onChange: a
2770
- }) {
2771
- return /* @__PURE__ */ t(
2772
- "div",
2773
- {
2774
- className: "flex shrink-0 items-center gap-1 rounded-control bg-muted p-0.5",
2775
- role: "tablist",
2776
- "aria-label": "Briefing source view",
2777
- children: ["dashboard", "project"].map((o) => {
2778
- const s = e === o;
2779
- return /* @__PURE__ */ t(
2780
- "button",
2781
- {
2782
- type: "button",
2783
- role: "tab",
2784
- "aria-selected": s,
2785
- onClick: () => a(o),
2786
- className: Z(
2787
- "h-6 rounded-[3px] px-2 text-[11px] transition-colors",
2788
- s ? "bg-background font-medium text-foreground shadow-sm" : "text-muted-foreground hover:text-foreground"
2789
- ),
2790
- children: fn(o)
2791
- },
2792
- o
2793
- );
2794
- })
2795
- }
2796
- );
2797
- }
2798
- function Cn({
2799
- briefings: e,
2800
- dashboardLabel: a,
2801
- sourceView: o,
2802
- error: s,
2803
- loading: i,
2804
- onSourceViewChange: n,
2805
- onClose: d,
2806
- onEdit: c,
2807
- onNew: l,
2808
- canCreate: h,
2809
- canCreateScheduledReport: u,
2810
- analyticalBriefingsEnabled: m,
2811
- onRunNow: p,
2812
- onTogglePause: g,
2813
- onDelete: f,
2814
- selectingId: v,
2815
- busyId: S,
2816
- manageBriefingsHref: E,
2817
- contentKind: M,
2818
- hideHeader: U = !1
2819
- }) {
2820
- const A = e.length, O = e.filter((w) => w.status === "ACTIVE").length, C = M === "reports" ? A === 1 ? "report" : "reports" : M === "briefings" ? A === 1 ? "briefing" : "briefings" : A === 1 ? "item" : "items", N = e.find((w) => w.hasActiveRun) ?? null, x = M ?? "reports & briefings", V = o === "dashboard" ? a : `Project ${x}`;
2821
- return /* @__PURE__ */ r(
2822
- "section",
2823
- {
2824
- "aria-label": `Dashboard ${x.replace("&", "and")}`,
2825
- className: "flex h-full min-h-0 flex-col bg-background text-foreground",
2826
- children: [
2827
- U ? null : /* @__PURE__ */ r("header", { className: "flex items-start justify-between gap-3 border-b border-border px-4 py-3", children: [
2828
- /* @__PURE__ */ r("div", { className: "min-w-0", children: [
2829
- /* @__PURE__ */ t("div", { className: pn, children: x }),
2830
- /* @__PURE__ */ t("h2", { className: "mt-0.5 truncate text-[14px] font-semibold leading-5", children: V })
2831
- ] }),
2832
- /* @__PURE__ */ t(
2833
- "button",
2834
- {
2835
- type: "button",
2836
- onClick: d,
2837
- className: "rounded-control p-1 text-muted-foreground hover:bg-muted hover:text-foreground",
2838
- "aria-label": `Close ${x.replace("&", "and")} panel`,
2839
- children: /* @__PURE__ */ t(Ke, { className: "h-3.5 w-3.5" })
2840
- }
2841
- )
2842
- ] }),
2843
- /* @__PURE__ */ r("div", { className: "flex items-center justify-between gap-3 border-b border-border px-4 py-2", children: [
2844
- /* @__PURE__ */ r("div", { className: "flex min-w-0 items-center gap-3", children: [
2845
- /* @__PURE__ */ t(
2846
- yn,
2847
- {
2848
- activeView: o,
2849
- onChange: n
2850
- }
2851
- ),
2852
- /* @__PURE__ */ t("div", { className: "flex min-w-0 items-center gap-1.5 text-[11px] text-muted-foreground", children: i && A === 0 ? /* @__PURE__ */ r("span", { children: [
2853
- "Loading ",
2854
- x,
2855
- "…"
2856
- ] }) : A === 0 ? /* @__PURE__ */ r("span", { children: [
2857
- "No ",
2858
- x,
2859
- " yet"
2860
- ] }) : /* @__PURE__ */ r(z, { children: [
2861
- /* @__PURE__ */ r("span", { className: "font-medium text-foreground/80", children: [
2862
- A,
2863
- " ",
2864
- C
2865
- ] }),
2866
- /* @__PURE__ */ t("span", { className: "text-border", children: "·" }),
2867
- /* @__PURE__ */ r("span", { children: [
2868
- O,
2869
- " active"
2870
- ] })
2871
- ] }) })
2872
- ] }),
2873
- /* @__PURE__ */ r("div", { className: "flex items-center gap-1.5", children: [
2874
- i ? (
2875
- // Auto-refresh on open; surface a quiet spinner near the count
2876
- // when a manual reload is in flight, but don't show a separate
2877
- // refresh button — close+reopen handles the rare "stale list"
2878
- // case without crowding the toolbar.
2879
- /* @__PURE__ */ t(ne, { className: "h-3.5 w-3.5 animate-spin text-muted-foreground" })
2880
- ) : null,
2881
- A > 0 && h ? m && u ? /* @__PURE__ */ r(Qe, { children: [
2882
- /* @__PURE__ */ t(He, { asChild: !0, children: /* @__PURE__ */ r("button", { className: Me, children: [
2883
- /* @__PURE__ */ t(be, { className: "h-3 w-3" }),
2884
- " New"
2885
- ] }) }),
2886
- /* @__PURE__ */ r(Ge, { align: "end", children: [
2887
- /* @__PURE__ */ t(Y, { onClick: () => l("scheduled_report"), children: "Schedule a report" }),
2888
- /* @__PURE__ */ t(
2889
- Y,
2890
- {
2891
- onClick: () => l("analytical_briefing"),
2892
- children: "Create analytical briefing"
2893
- }
2894
- )
2895
- ] })
2896
- ] }) : u ? /* @__PURE__ */ r(
2897
- "button",
2898
- {
2899
- onClick: () => l("scheduled_report"),
2900
- className: Me,
2901
- children: [
2902
- /* @__PURE__ */ t(be, { className: "h-3 w-3" }),
2903
- " Schedule report"
2904
- ]
2905
- }
2906
- ) : m ? /* @__PURE__ */ r(
2907
- "button",
2908
- {
2909
- onClick: () => l("analytical_briefing"),
2910
- className: Me,
2911
- children: [
2912
- /* @__PURE__ */ t(be, { className: "h-3 w-3" }),
2913
- " New briefing"
2914
- ]
2915
- }
2916
- ) : null : null
2917
- ] })
2918
- ] }),
2919
- N ? /* @__PURE__ */ r("div", { className: "flex items-center gap-2 border-b border-border bg-muted/60 px-4 py-2 text-[12px]", children: [
2920
- /* @__PURE__ */ t(ne, { className: "h-3 w-3 shrink-0 animate-spin text-muted-foreground" }),
2921
- /* @__PURE__ */ t("span", { className: "font-medium text-foreground", children: N.name }),
2922
- /* @__PURE__ */ t("span", { className: "text-border", children: "·" }),
2923
- /* @__PURE__ */ t("span", { className: "truncate text-muted-foreground", children: Ht(N) })
2924
- ] }) : null,
2925
- /* @__PURE__ */ r("div", { className: "flex-1 overflow-y-auto", children: [
2926
- s ? /* @__PURE__ */ t("div", { className: "m-4 rounded-card border border-destructive/30 bg-destructive/10 px-3 py-2 text-[12px] text-destructive", children: s }) : null,
2927
- !i && e.length === 0 && !s ? /* @__PURE__ */ t(
2928
- wn,
2929
- {
2930
- onNew: l,
2931
- canCreate: h,
2932
- canCreateScheduledReport: u,
2933
- analyticalBriefingsEnabled: m,
2934
- contentKind: M
2935
- }
2936
- ) : null,
2937
- e.map((w) => /* @__PURE__ */ t(
2938
- Sn,
2939
- {
2940
- briefing: w,
2941
- isOpening: v === w.id,
2942
- isBusy: S === w.id,
2943
- onOpen: () => c(w.id),
2944
- onRunNow: () => p(w),
2945
- onTogglePause: () => g(w),
2946
- onDelete: () => f(w)
2947
- },
2948
- w.id
2949
- ))
2950
- ] }),
2951
- E ? /* @__PURE__ */ t("div", { className: "border-t border-border px-4 py-2.5", children: /* @__PURE__ */ r(
2952
- "a",
2953
- {
2954
- href: E,
2955
- className: Z(Qt, "h-6 px-1 text-[11px]"),
2956
- children: [
2957
- "Manage all reports & briefings",
2958
- /* @__PURE__ */ t(Nr, { className: "h-3 w-3" })
2959
- ]
2960
- }
2961
- ) }) : null
2962
- ]
2963
- }
2964
- );
2965
- }
2966
- function wn({
2967
- onNew: e,
2968
- canCreate: a,
2969
- canCreateScheduledReport: o,
2970
- analyticalBriefingsEnabled: s,
2971
- contentKind: i
2972
- }) {
2973
- const n = i === "reports" ? {
2974
- title: "No reports yet",
2975
- description: "Schedule an emailed dashboard or visual report to see it here."
2976
- } : i === "briefings" ? {
2977
- title: "No briefings yet",
2978
- description: "Create an analytical briefing to monitor this dashboard and brief your team."
2979
- } : null;
2980
- return /* @__PURE__ */ r("div", { className: "flex h-full flex-col items-center justify-center px-8 py-12 text-center", children: [
2981
- /* @__PURE__ */ t(Nn, { className: "mb-5 h-[88px] w-[112px] text-border" }),
2982
- /* @__PURE__ */ t("div", { className: "text-[13px] font-medium text-foreground", children: (n == null ? void 0 : n.title) ?? "Have an analyst brief your team" }),
2983
- /* @__PURE__ */ t("p", { className: "mt-1.5 max-w-[320px] text-[12px] leading-5 text-muted-foreground", children: (n == null ? void 0 : n.description) ?? "Describe what to watch. An analyst digs into this dashboard and the data behind it, then briefs your team on the cadence you choose." }),
2984
- a ? /* @__PURE__ */ r("div", { className: "mt-4 flex flex-wrap justify-center gap-2", children: [
2985
- o ? /* @__PURE__ */ r(
2986
- "button",
2987
- {
2988
- onClick: () => e("scheduled_report"),
2989
- className: Me,
2990
- children: [
2991
- /* @__PURE__ */ t(be, { className: "h-3 w-3" }),
2992
- " Schedule a report"
2993
- ]
2994
- }
2995
- ) : null,
2996
- s ? /* @__PURE__ */ t(
2997
- "button",
2998
- {
2999
- onClick: () => e("analytical_briefing"),
3000
- className: Qt,
3001
- children: "Create analytical briefing"
3002
- }
3003
- ) : null
3004
- ] }) : null
3005
- ] });
3006
- }
3007
- function Nn({ className: e }) {
3008
- return /* @__PURE__ */ r(
3009
- "svg",
3010
- {
3011
- viewBox: "0 0 112 88",
3012
- fill: "none",
3013
- xmlns: "http://www.w3.org/2000/svg",
3014
- role: "presentation",
3015
- "aria-hidden": "true",
3016
- className: e,
3017
- children: [
3018
- /* @__PURE__ */ t(
3019
- "rect",
3020
- {
3021
- x: "22",
3022
- y: "6",
3023
- width: "60",
3024
- height: "72",
3025
- rx: "3",
3026
- stroke: "currentColor",
3027
- strokeWidth: "1.25"
3028
- }
3029
- ),
3030
- /* @__PURE__ */ t(
3031
- "line",
3032
- {
3033
- x1: "30",
3034
- y1: "16",
3035
- x2: "64",
3036
- y2: "16",
3037
- stroke: "currentColor",
3038
- strokeWidth: "1.5",
3039
- strokeLinecap: "round"
3040
- }
3041
- ),
3042
- /* @__PURE__ */ t(
3043
- "line",
3044
- {
3045
- x1: "30",
3046
- y1: "21",
3047
- x2: "52",
3048
- y2: "21",
3049
- stroke: "currentColor",
3050
- strokeWidth: "1",
3051
- strokeLinecap: "round",
3052
- opacity: "0.5"
3053
- }
3054
- ),
3055
- /* @__PURE__ */ t("circle", { cx: "31", cy: "32", r: "1", fill: "currentColor", opacity: "0.6" }),
3056
- /* @__PURE__ */ t(
3057
- "line",
3058
- {
3059
- x1: "35",
3060
- y1: "32",
3061
- x2: "72",
3062
- y2: "32",
3063
- stroke: "currentColor",
3064
- strokeWidth: "1",
3065
- opacity: "0.4",
3066
- strokeLinecap: "round"
3067
- }
3068
- ),
3069
- /* @__PURE__ */ t("circle", { cx: "31", cy: "38", r: "1", fill: "currentColor", opacity: "0.6" }),
3070
- /* @__PURE__ */ t(
3071
- "line",
3072
- {
3073
- x1: "35",
3074
- y1: "38",
3075
- x2: "68",
3076
- y2: "38",
3077
- stroke: "currentColor",
3078
- strokeWidth: "1",
3079
- opacity: "0.4",
3080
- strokeLinecap: "round"
3081
- }
3082
- ),
3083
- /* @__PURE__ */ t("circle", { cx: "31", cy: "44", r: "1", fill: "currentColor", opacity: "0.6" }),
3084
- /* @__PURE__ */ t(
3085
- "line",
3086
- {
3087
- x1: "35",
3088
- y1: "44",
3089
- x2: "74",
3090
- y2: "44",
3091
- stroke: "currentColor",
3092
- strokeWidth: "1",
3093
- opacity: "0.4",
3094
- strokeLinecap: "round"
3095
- }
3096
- ),
3097
- /* @__PURE__ */ t(
3098
- "rect",
3099
- {
3100
- x: "30",
3101
- y: "64",
3102
- width: "5",
3103
- height: "8",
3104
- rx: "0.5",
3105
- fill: "currentColor",
3106
- opacity: "0.55"
3107
- }
3108
- ),
3109
- /* @__PURE__ */ t(
3110
- "rect",
3111
- {
3112
- x: "38",
3113
- y: "60",
3114
- width: "5",
3115
- height: "12",
3116
- rx: "0.5",
3117
- fill: "currentColor",
3118
- opacity: "0.7"
3119
- }
3120
- ),
3121
- /* @__PURE__ */ t(
3122
- "rect",
3123
- {
3124
- x: "46",
3125
- y: "56",
3126
- width: "5",
3127
- height: "16",
3128
- rx: "0.5",
3129
- fill: "currentColor",
3130
- opacity: "0.85"
3131
- }
3132
- ),
3133
- /* @__PURE__ */ t(
3134
- "rect",
3135
- {
3136
- x: "54",
3137
- y: "62",
3138
- width: "5",
3139
- height: "10",
3140
- rx: "0.5",
3141
- fill: "currentColor",
3142
- opacity: "0.6"
3143
- }
3144
- ),
3145
- /* @__PURE__ */ t(
3146
- "rect",
3147
- {
3148
- x: "62",
3149
- y: "58",
3150
- width: "5",
3151
- height: "14",
3152
- rx: "0.5",
3153
- fill: "currentColor",
3154
- opacity: "0.75"
3155
- }
3156
- ),
3157
- /* @__PURE__ */ t(
3158
- "circle",
3159
- {
3160
- cx: "86",
3161
- cy: "62",
3162
- r: "10",
3163
- fill: "var(--background, white)",
3164
- stroke: "currentColor",
3165
- strokeWidth: "1.25"
3166
- }
3167
- ),
3168
- /* @__PURE__ */ t(
3169
- "line",
3170
- {
3171
- x1: "93.5",
3172
- y1: "69.5",
3173
- x2: "100",
3174
- y2: "76",
3175
- stroke: "currentColor",
3176
- strokeWidth: "1.5",
3177
- strokeLinecap: "round"
3178
- }
3179
- )
3180
- ]
3181
- }
3182
- );
3183
- }
3184
- function Sn({
3185
- briefing: e,
3186
- isOpening: a,
3187
- isBusy: o,
3188
- onOpen: s,
3189
- onRunNow: i,
3190
- onTogglePause: n,
3191
- onDelete: d
3192
- }) {
3193
- const c = e.status === "PAUSED", l = e.hasActiveRun, h = xn(e), u = gn(e.lastRunAt), m = e.lastRunStatus, p = ce(e), g = m === "SUCCESS" ? Be.success.dot : m === "FAILED" ? Be.danger.dot : m ? Be.warning.dot : Be.neutral.dot;
3194
- return /* @__PURE__ */ r(
3195
- "div",
3196
- {
3197
- className: Z(
3198
- "group relative border-b border-border/60 px-4 py-3 transition-colors hover:bg-muted/60",
3199
- c && "opacity-70"
3200
- ),
3201
- children: [
3202
- /* @__PURE__ */ r(
3203
- "div",
3204
- {
3205
- role: "button",
3206
- tabIndex: 0,
3207
- onClick: s,
3208
- onKeyDown: (f) => {
3209
- (f.key === "Enter" || f.key === " ") && (f.preventDefault(), s());
3210
- },
3211
- className: "cursor-pointer pr-8",
3212
- children: [
3213
- /* @__PURE__ */ r("div", { className: "flex min-w-0 items-center gap-2", children: [
3214
- /* @__PURE__ */ t("span", { className: "truncate text-[13px] font-medium text-foreground", children: e.name }),
3215
- c ? /* @__PURE__ */ t("span", { className: "shrink-0 text-[11px] text-muted-foreground", children: "· Paused" }) : null
3216
- ] }),
3217
- /* @__PURE__ */ r("div", { className: "mt-1 flex flex-wrap items-center gap-x-1.5 text-[11px] text-muted-foreground", children: [
3218
- /* @__PURE__ */ t("span", { children: p.typeLabel }),
3219
- /* @__PURE__ */ t("span", { className: "text-border", children: "·" }),
3220
- /* @__PURE__ */ t("span", { children: vn(e) }),
3221
- /* @__PURE__ */ t("span", { className: "text-border", children: "·" }),
3222
- /* @__PURE__ */ t(Oa, { className: "h-3 w-3" }),
3223
- /* @__PURE__ */ t("span", { className: "truncate", children: bn(e) }),
3224
- e.lastRunAt ? /* @__PURE__ */ r(z, { children: [
3225
- /* @__PURE__ */ t("span", { className: "text-border", children: "·" }),
3226
- /* @__PURE__ */ r("span", { children: [
3227
- "Last run ",
3228
- u
3229
- ] })
3230
- ] }) : null
3231
- ] }),
3232
- h || l ? /* @__PURE__ */ r("div", { className: "mt-1.5 flex items-center gap-1.5 text-[12px] leading-[1.5] text-foreground/80", children: [
3233
- l ? /* @__PURE__ */ t(ne, { className: "h-3 w-3 shrink-0 animate-spin text-muted-foreground/70" }) : /* @__PURE__ */ t(
3234
- "span",
3235
- {
3236
- className: Z(
3237
- "inline-block h-1.5 w-1.5 shrink-0 rounded-full",
3238
- g
3239
- )
3240
- }
3241
- ),
3242
- /* @__PURE__ */ t("span", { className: "truncate", children: l ? Ht(e) : h })
3243
- ] }) : null
3244
- ]
3245
- }
3246
- ),
3247
- /* @__PURE__ */ t("div", { className: "absolute right-3 top-3", children: o ? /* @__PURE__ */ t(ne, { className: "h-3.5 w-3.5 animate-spin text-muted-foreground/70" }) : a ? /* @__PURE__ */ t(ne, { className: "h-3.5 w-3.5 animate-spin text-muted-foreground/70" }) : /* @__PURE__ */ r(Qe, { children: [
3248
- /* @__PURE__ */ t(He, { asChild: !0, children: /* @__PURE__ */ t(
3249
- "button",
3250
- {
3251
- type: "button",
3252
- onClick: (f) => f.stopPropagation(),
3253
- className: "inline-flex h-6 w-6 items-center justify-center rounded-control text-muted-foreground/70 opacity-60 hover:bg-muted hover:text-foreground/80 focus-visible:opacity-100 group-hover:opacity-100",
3254
- "aria-label": `${p.noun === "report" ? "Report" : "Briefing"} actions`,
3255
- children: /* @__PURE__ */ t(Bt, { className: "h-3.5 w-3.5" })
3256
- }
3257
- ) }),
3258
- /* @__PURE__ */ r(Ge, { align: "end", className: "w-44", children: [
3259
- /* @__PURE__ */ r(Y, { onClick: s, children: [
3260
- /* @__PURE__ */ t(Rt, { className: "h-3.5 w-3.5" }),
3261
- "Edit ",
3262
- p.noun
3263
- ] }),
3264
- /* @__PURE__ */ r(
3265
- Y,
3266
- {
3267
- onClick: (f) => {
3268
- f.preventDefault(), i();
3269
- },
3270
- children: [
3271
- /* @__PURE__ */ t(_a, { className: "h-3.5 w-3.5" }),
3272
- "Run now"
3273
- ]
3274
- }
3275
- ),
3276
- e.scheduleExpr ? /* @__PURE__ */ t(
3277
- Y,
3278
- {
3279
- onClick: (f) => {
3280
- f.preventDefault(), n();
3281
- },
3282
- children: c ? /* @__PURE__ */ r(z, { children: [
3283
- /* @__PURE__ */ t(za, { className: "h-3.5 w-3.5" }),
3284
- "Resume"
3285
- ] }) : /* @__PURE__ */ r(z, { children: [
3286
- /* @__PURE__ */ t(ja, { className: "h-3.5 w-3.5" }),
3287
- "Pause"
3288
- ] })
3289
- }
3290
- ) : null,
3291
- /* @__PURE__ */ t(ze, {}),
3292
- /* @__PURE__ */ r(
3293
- Y,
3294
- {
3295
- onClick: (f) => {
3296
- f.preventDefault(), d();
3297
- },
3298
- className: "text-destructive focus:bg-destructive/10 focus:text-destructive",
3299
- children: [
3300
- /* @__PURE__ */ t(_e, { className: "h-3.5 w-3.5" }),
3301
- "Delete ",
3302
- p.noun
3303
- ]
3304
- }
3305
- )
3306
- ] })
3307
- ] }) })
3308
- ]
3309
- }
3310
- );
3311
- }
3312
- function kn(e) {
3313
- return (e == null ? void 0 : e.trim()) || "This dashboard";
3314
- }
3315
- function Dn(e) {
3316
- return e === "This dashboard" ? "Watch this dashboard" : `Watch ${e}`;
3317
- }
3318
- function An(e, a, o) {
3319
- return a !== "dashboard" ? e : e.filter(
3320
- (s) => s.source.type === "dashboard" && s.source.dashboardId === o
3321
- );
3322
- }
3323
- async function Fn(e) {
3324
- const o = [];
3325
- let s = 1, i = 0, n = Number.POSITIVE_INFINITY;
3326
- for (; i < n; ) {
3327
- const d = await e.apiClient.listBriefings(
3328
- e.apiServiceUrl,
3329
- e.token,
3330
- { scope: "organization", page: s, pageSize: 100 }
3331
- );
3332
- if (o.push(...d.briefings), i += d.briefings.length, n = d.total, d.briefings.length === 0 || i >= n) break;
3333
- s += 1;
3334
- }
3335
- return o;
3336
- }
3337
- const In = {
3338
- listBriefings: Xa,
3339
- getBriefing: Ya,
3340
- pauseBriefing: Ka,
3341
- resumeBriefing: Ga,
3342
- deleteBriefing: Ha,
3343
- runBriefingNow: Qa
3344
- };
3345
- function ms(e) {
3346
- return /* @__PURE__ */ t($a, { authToken: e.token ? { accessToken: e.token } : void 0, children: /* @__PURE__ */ t(Wa, { children: /* @__PURE__ */ t(En, { ...e }) }) });
3347
- }
3348
- function En({
3349
- dashboardId: e,
3350
- dashboardTitle: a,
3351
- apiServiceUrl: o,
3352
- token: s,
3353
- disabled: i,
3354
- className: n,
3355
- manageBriefingsHref: d,
3356
- open: c,
3357
- onOpenChange: l,
3358
- hideTrigger: h = !1,
3359
- workflowIntent: u,
3360
- openRun: m,
3361
- client: p
3362
- }) {
3363
- const { authToken: g, tokenProps: f } = Vt(), v = qa(), S = !u || v.canCreate && (u === "scheduled_report" || v.analyticalBriefingsEnabled), [E, M] = k(!1), U = c ?? E, A = (y) => {
3364
- c === void 0 && M(y), l == null || l(y);
3365
- }, [O, C] = k(
3366
- u ? "author" : "list"
3367
- ), [N, x] = k(
3368
- u ?? "analytical_briefing"
3369
- ), [V, w] = k("dashboard"), [W, F] = k(
3370
- []
3371
- ), [R, K] = k(null), _ = u && !S && !R ? "list" : O, [ye, se] = k(!1), [j, X] = k(null), [he, L] = k(null), [$, ee] = k(
3372
- null
3373
- ), [te, le] = k(null), Ce = rt(null), Ee = rt(U);
3374
- ge(() => {
3375
- const y = U && !Ee.current;
3376
- Ee.current = U, !(!y || !u) && (K(null), w("dashboard"), x(u), C("author"), le(null));
3377
- }, [U, u]);
3378
- const Ye = vt(), q = o ?? (f == null ? void 0 : f.apiServiceUrl), Q = s ?? (g == null ? void 0 : g.accessToken), oe = re(() => ({ ...In, ...p }), [p]), [we, Xe] = k(null);
3379
- ge(() => {
3380
- if (!m || !q || !Q) return;
3381
- let y = !0;
3382
- return oe.getBriefing(q, Q, m.briefingId).then(({ briefing: P }) => {
3383
- y && (K(P), Xe(m), C("author"));
3384
- }, (P) => {
3385
- y && I.error(P instanceof Error ? P.message : "Could not open the run.");
3386
- }), () => {
3387
- y = !1;
3388
- };
3389
- }, [m, q, Q, oe]);
3390
- const fe = kn(a), Ve = re(() => {
3391
- const y = An(
3392
- W,
3393
- V,
3394
- e
3395
- );
3396
- if (!u)
3397
- return y;
3398
- const P = u === "scheduled_report" ? "report" : "briefing";
3399
- return y.filter(
3400
- (Te) => ce(Te).noun === P
3401
- );
3402
- }, [e, W, V, u]), Ze = re(() => V === "dashboard" ? {
3403
- source: { type: "dashboard", dashboardId: e },
3404
- label: fe,
3405
- detail: Dn(fe)
3406
- } : {
3407
- source: { type: "project" },
3408
- label: "This project",
3409
- detail: "Use any data in this project."
3410
- }, [e, fe, V]), Ne = !!(q && Q), Se = wr({
3411
- canCreate: v.canCreate,
3412
- analyticalBriefingsEnabled: v.analyticalBriefingsEnabled,
3413
- scheduledReportAvailable: V === "dashboard"
3414
- }), ie = ae(async () => {
3415
- if (!(!q || !Q)) {
3416
- se(!0), le(null);
3417
- try {
3418
- F(
3419
- await Fn({
3420
- apiClient: oe,
3421
- apiServiceUrl: q,
3422
- token: Q
3423
- })
3424
- );
3425
- } catch (y) {
3426
- le(
3427
- y instanceof Error ? y.message : "Could not load briefings."
3428
- );
3429
- } finally {
3430
- se(!1);
3431
- }
3432
- }
3433
- }, [oe, q, Q]);
3434
- ge(() => {
3435
- !U || _ !== "list" || !Ne || ie();
3436
- }, [Ne, _, ie, U]);
3437
- const ke = () => {
3438
- K(null), w("dashboard"), C("list"), A(!0);
3439
- }, b = (y) => {
3440
- K(null), x(y), C("author");
3441
- }, B = async (y) => {
3442
- if (!(!q || !Q)) {
3443
- X(y), le(null);
3444
- try {
3445
- const P = await oe.getBriefing(
3446
- q,
3447
- Q,
3448
- y
3449
- );
3450
- K(P.briefing), C("author");
3451
- } catch (P) {
3452
- le(
3453
- P instanceof Error ? P.message : "Could not open briefing."
3454
- );
3455
- } finally {
3456
- X(null);
3457
- }
3458
- }
3459
- }, H = async (y) => {
3460
- if (!(!q || !Q)) {
3461
- L(y.id);
3462
- try {
3463
- const P = await oe.runBriefingNow(
3464
- q,
3465
- Q,
3466
- y.id,
3467
- { requestId: Vn() }
3468
- );
3469
- Ye.track({ kind: "briefing", id: P.run.id, title: y.name, briefingId: y.id }), ie();
3470
- } catch (P) {
3471
- I.error(
3472
- P instanceof Error ? P.message : "Could not start the run."
3473
- );
3474
- } finally {
3475
- L(null);
3476
- }
3477
- }
3478
- }, de = async (y) => {
3479
- if (!q || !Q) return;
3480
- const { noun: P } = ce(y), Te = P === "report" ? "Report" : "Briefing";
3481
- L(y.id);
3482
- try {
3483
- const Le = y.status === "PAUSED" ? await oe.resumeBriefing(
3484
- q,
3485
- Q,
3486
- y.id
3487
- ) : await oe.pauseBriefing(
3488
- q,
3489
- Q,
3490
- y.id
3491
- );
3492
- I.success(
3493
- Le.briefing.status === "PAUSED" ? `${Te} paused` : `${Te} resumed`
3494
- ), ie();
3495
- } catch (Le) {
3496
- I.error(
3497
- Le instanceof Error ? Le.message : `Could not update the ${P} status.`
3498
- );
3499
- } finally {
3500
- L(null);
3501
- }
3502
- }, me = async () => {
3503
- if (!$ || !q || !Q) return;
3504
- const y = $;
3505
- L(y.id);
3506
- try {
3507
- await oe.deleteBriefing(
3508
- q,
3509
- Q,
3510
- y.id
3511
- );
3512
- const { noun: P } = ce(y);
3513
- I.success(`${P === "report" ? "Report" : "Briefing"} deleted`), ee(null), ie();
3514
- } catch (P) {
3515
- I.error(
3516
- P instanceof Error ? P.message : "Could not delete the briefing."
3517
- );
3518
- } finally {
3519
- L(null);
3520
- }
3521
- }, Gt = Ve.length;
3522
- return v.surfaceVisible ? /* @__PURE__ */ r(Za, { open: U, onOpenChange: A, children: [
3523
- h ? null : /* @__PURE__ */ t(
3524
- mn,
3525
- {
3526
- disabled: i || !Ne,
3527
- briefingCount: Gt,
3528
- className: n,
3529
- onClick: ke
3530
- }
3531
- ),
3532
- /* @__PURE__ */ r(
3533
- Ja,
3534
- {
3535
- ref: Ce,
3536
- side: "right",
3537
- hideClose: !0,
3538
- className: "flex h-full w-full flex-col overflow-hidden p-0 outline-none sm:max-w-[560px]",
3539
- onOpenAutoFocus: (y) => {
3540
- var P;
3541
- y.preventDefault(), (P = Ce.current) == null || P.focus({ preventScroll: !0 });
3542
- },
3543
- children: [
3544
- /* @__PURE__ */ r(er, { className: "sr-only", children: [
3545
- /* @__PURE__ */ t(tr, { children: "Reports & briefings" }),
3546
- /* @__PURE__ */ t(ar, { children: "Manage reports and briefings for this dashboard." })
3547
- ] }),
3548
- u ? /* @__PURE__ */ r("div", { className: "flex shrink-0 items-start justify-between gap-3 border-b border-border pl-4 pr-3 pt-2", children: [
3549
- /* @__PURE__ */ r(
3550
- "div",
3551
- {
3552
- className: "flex items-center gap-5",
3553
- role: "tablist",
3554
- "aria-label": u === "scheduled_report" ? "Email report workflow" : "Analytical briefing workflow",
3555
- children: [
3556
- /* @__PURE__ */ t(
3557
- "button",
3558
- {
3559
- type: "button",
3560
- role: "tab",
3561
- "aria-selected": _ === "author",
3562
- disabled: !S,
3563
- className: Z(
3564
- "-mb-px border-b-2 px-0.5 pb-2 text-[12px] transition-colors",
3565
- _ === "author" ? "border-foreground font-medium text-foreground" : "border-transparent text-muted-foreground hover:text-foreground",
3566
- !S && "cursor-not-allowed opacity-50"
3567
- ),
3568
- onClick: () => {
3569
- S && (K(null), x(u), w("dashboard"), C("author"));
3570
- },
3571
- children: R ? `Edit ${ce(R).noun}` : u === "scheduled_report" ? "Schedule report" : "Create briefing"
3572
- }
3573
- ),
3574
- /* @__PURE__ */ t(
3575
- "button",
3576
- {
3577
- type: "button",
3578
- role: "tab",
3579
- "aria-selected": _ === "list",
3580
- className: Z(
3581
- "-mb-px border-b-2 px-0.5 pb-2 text-[12px] transition-colors",
3582
- _ === "list" ? "border-foreground font-medium text-foreground" : "border-transparent text-muted-foreground hover:text-foreground"
3583
- ),
3584
- onClick: () => C("list"),
3585
- children: u === "scheduled_report" ? "Manage reports" : "Manage briefings"
3586
- }
3587
- )
3588
- ]
3589
- }
3590
- ),
3591
- /* @__PURE__ */ t(
3592
- "button",
3593
- {
3594
- type: "button",
3595
- onClick: () => A(!1),
3596
- className: "rounded-control p-1 text-muted-foreground hover:bg-muted hover:text-foreground",
3597
- "aria-label": u === "scheduled_report" ? "Close email report workflow" : "Close analytical briefing workflow",
3598
- children: /* @__PURE__ */ t(Ke, { className: "h-3.5 w-3.5" })
3599
- }
3600
- )
3601
- ] }) : null,
3602
- _ === "list" ? /* @__PURE__ */ t(
3603
- Cn,
3604
- {
3605
- briefings: Ve,
3606
- dashboardLabel: fe,
3607
- sourceView: V,
3608
- error: te,
3609
- loading: ye,
3610
- onSourceViewChange: w,
3611
- onClose: () => A(!1),
3612
- onEdit: (y) => {
3613
- B(y);
3614
- },
3615
- onNew: b,
3616
- canCreate: !u && Se.length > 0,
3617
- canCreateScheduledReport: Se.includes(
3618
- "scheduled_report"
3619
- ),
3620
- analyticalBriefingsEnabled: Se.includes(
3621
- "analytical_briefing"
3622
- ),
3623
- onRunNow: (y) => {
3624
- H(y);
3625
- },
3626
- onTogglePause: (y) => {
3627
- de(y);
3628
- },
3629
- onDelete: (y) => ee(y),
3630
- selectingId: j,
3631
- busyId: he,
3632
- manageBriefingsHref: d,
3633
- contentKind: u === "scheduled_report" ? "reports" : u === "analytical_briefing" ? "briefings" : void 0,
3634
- hideHeader: !!u
3635
- }
3636
- ) : /* @__PURE__ */ t(
3637
- rr,
3638
- {
3639
- apiServiceUrl: q,
3640
- token: Q,
3641
- briefing: R,
3642
- initialRunId: we && (R == null ? void 0 : R.id) === we.briefingId ? we.runId : void 0,
3643
- intent: N,
3644
- sourceContext: R ? void 0 : Ze,
3645
- title: R ? `Edit ${ce(R).noun}` : N === "scheduled_report" ? "Schedule report" : "Create analytical briefing",
3646
- hideHeader: !!u,
3647
- className: "h-full min-h-0 max-w-none border-0 shadow-none",
3648
- onBack: u ? void 0 : () => C("list"),
3649
- onCancel: () => A(!1),
3650
- onDeleted: () => {
3651
- const y = R ? ce(R).noun : "briefing";
3652
- I.success(`${y === "report" ? "Report" : "Briefing"} deleted`), K(null), C("list"), ie();
3653
- },
3654
- onRunStarted: () => {
3655
- },
3656
- onSaved: (y) => {
3657
- K(y), ie();
3658
- },
3659
- onMinimizeRun: () => {
3660
- A(!1);
3661
- }
3662
- }
3663
- )
3664
- ]
3665
- }
3666
- ),
3667
- /* @__PURE__ */ t(
3668
- lt,
3669
- {
3670
- open: !!$,
3671
- onOpenChange: (y) => {
3672
- y || ee(null);
3673
- },
3674
- children: /* @__PURE__ */ r(dt, { children: [
3675
- /* @__PURE__ */ r(ct, { children: [
3676
- /* @__PURE__ */ r(ut, { children: [
3677
- "Delete",
3678
- " ",
3679
- $ ? ce($).noun : "briefing",
3680
- "?"
3681
- ] }),
3682
- /* @__PURE__ */ r(ht, { children: [
3683
- "This permanently deletes ",
3684
- /* @__PURE__ */ t("strong", { children: $ == null ? void 0 : $.name }),
3685
- ". Recipients will stop receiving it."
3686
- ] })
3687
- ] }),
3688
- /* @__PURE__ */ r(mt, { children: [
3689
- /* @__PURE__ */ t(pt, { children: "Cancel" }),
3690
- /* @__PURE__ */ r(
3691
- Lt,
3692
- {
3693
- className: "bg-destructive/90 hover:bg-destructive",
3694
- onClick: me,
3695
- children: [
3696
- "Delete",
3697
- " ",
3698
- $ ? ce($).noun : "briefing"
3699
- ]
3700
- }
3701
- )
3702
- ] })
3703
- ] })
3704
- }
3705
- )
3706
- ] }) : null;
3707
- }
3708
- function Vn() {
3709
- return typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : `briefing-run-now-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
3710
- }
3711
- export {
3712
- ls as A,
3713
- en as D,
3714
- ds as U,
3715
- ss as V,
3716
- mn as W,
3717
- is as a,
3718
- us as b,
3719
- an as c,
3720
- ln as d,
3721
- hs as e,
3722
- ms as f,
3723
- cs as i,
3724
- os as u
3725
- };