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