react-semaphor 0.1.606 → 0.1.608

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 (150) hide show
  1. package/dist/analytics-protocol/index.js +1 -1
  2. package/dist/appearance-runtime/index.js +1 -1
  3. package/dist/assistant-context/index.js +1 -1
  4. package/dist/assistant-protocol/index.js +1 -1
  5. package/dist/brand-studio/index.js +2 -2
  6. package/dist/briefings/index.js +1 -1
  7. package/dist/chunks/add-to-dashboard-Bu3M9DpP.js +12 -0
  8. package/dist/chunks/appearance-provider-BBYTKSjL.js +613 -0
  9. package/dist/chunks/appearance-runtime-provider-De2VZS4F.js +1 -0
  10. package/dist/chunks/assistant-chat-x3NCrm5n.js +53 -0
  11. package/dist/chunks/attachment-filter-line-ClTS4GvQ.js +1 -0
  12. package/dist/chunks/{bookmark-impact-BW30cm5E.js → bookmark-impact-xCmo8x3V.js} +1 -1
  13. package/dist/chunks/bookmark-state-BmbBu1th.js +1 -0
  14. package/dist/chunks/{brand-CL5xDiFH.js → brand-3m_qSMyC.js} +1 -1
  15. package/dist/chunks/card-filter-builder-CM3SZ4kO.js +11 -0
  16. package/dist/chunks/check-input-C7S2sNzB.js +151 -0
  17. package/dist/chunks/{comparison-window-caption-tguyN24S.js → comparison-window-caption-WzGsqv4n.js} +1 -1
  18. package/dist/chunks/compiler-XErOfUUx.js +1 -0
  19. package/dist/chunks/context-Cwj8Axgd.js +2 -0
  20. package/dist/chunks/currency-presentation-binding-s4PlA3Wu.js +1 -0
  21. package/dist/chunks/custom-visual-inputs-CUtxCe4T.js +1 -0
  22. package/dist/chunks/custom-visual-write-CH-k-4HE.js +1 -0
  23. package/dist/chunks/{dashboard-Cyhj9EOl.js → dashboard-BwuurlUI.js} +1 -1
  24. package/dist/chunks/{dashboard-briefing-launcher-CyOFddmD.js → dashboard-briefing-launcher-CX7mCnPi.js} +5 -5
  25. package/dist/chunks/{dashboard-controls-DpADfhr0.js → dashboard-controls-Bwjy9G1i.js} +8 -8
  26. package/dist/chunks/{dashboard-json-4xMChR2q.js → dashboard-json-B9lK28i0.js} +1 -1
  27. package/dist/chunks/dashboard-temporal-snapshot-CcndP6CF.js +1 -0
  28. package/dist/chunks/edit-dashboard-visual-BF3mfrWf.js +103 -0
  29. package/dist/chunks/{filter-line-WwUV5JzN.js → filter-line-W-qQAjke.js} +1 -1
  30. package/dist/chunks/filter-reach-preview-DSH_k8AJ.js +1 -0
  31. package/dist/chunks/{filter-value-text-DqTHe_vu.js → filter-value-text-DQwYZHz0.js} +1 -1
  32. package/dist/chunks/kpi-trend-rule-DDbguInc.js +1 -0
  33. package/dist/chunks/{layout-grid-Dtsioq4h.js → layout-grid-Bx0jBVXj.js} +1 -1
  34. package/dist/chunks/matrix-analytical-definition-jn075ooo.js +1 -0
  35. package/dist/chunks/{matrix-member-presentation-vVAv-aqg.js → matrix-member-presentation-Chz6uGYz.js} +1 -1
  36. package/dist/chunks/matrix-operation-contract-DceN49RX.js +1 -0
  37. package/dist/chunks/metric-formatting-DILSVxLq.js +1 -0
  38. package/dist/chunks/{numeric-range-options-C8tr-Bls.js → numeric-range-options-Drc1EZ6H.js} +1 -1
  39. package/dist/chunks/{palette-565cA0nh.js → palette-CZJ4ZCY9.js} +1 -1
  40. package/dist/chunks/pivot-result-contract-expectations-D_ane7I2.js +1 -0
  41. package/dist/chunks/{pivot-result-identity-B0eWVMXg.js → pivot-result-identity-DRhVJMsF.js} +1 -1
  42. package/dist/chunks/{raw-temporal-value-BHQ-ldpW.js → raw-temporal-value-B4Md6Xfb.js} +1 -1
  43. package/dist/chunks/report-preferences-dialog-EQNoTych.js +1 -0
  44. package/dist/chunks/{report-runtime-context-Cd1b5pku.js → report-runtime-context-CkxgMKr6.js} +1 -1
  45. package/dist/chunks/resolve-dashboard-input-context-B5yUS9ZM.js +8 -0
  46. package/dist/chunks/sandbox-host-WJXxpvz7.js +197 -0
  47. package/dist/chunks/saved-dashboard-context-DQlA4Mg0.js +1 -0
  48. package/dist/chunks/{selection-filter-compiler-kYsRugss.js → selection-filter-compiler-BxtEEB6Z.js} +1 -1
  49. package/dist/chunks/semaphor-ready-indicator-Cq3C2SNo.js +622 -0
  50. package/dist/chunks/set-wWdhgHSh.js +1 -0
  51. package/dist/chunks/slider-C4jUvJtd.js +599 -0
  52. package/dist/chunks/stored-dashboard-1x0q2cNx.js +1 -0
  53. package/dist/chunks/table-cell-text-DFHUGeG6.js +1 -0
  54. package/dist/chunks/{table-export-sheet-xaczzWZF.js → table-export-sheet-CthBUHu4.js} +1 -1
  55. package/dist/chunks/{token-types-1vzMWjI-.js → token-types-BM0mpZce.js} +1 -1
  56. package/dist/chunks/{validators-Dg2kyF4_.js → validators-U8IL8djK.js} +1 -1
  57. package/dist/chunks/{variable-draft-CRbSYdB6.js → variable-draft-CwX-b6Fs.js} +1 -1
  58. package/dist/dashboard/index.js +1 -1
  59. package/dist/dashboard-authoring/index.js +1 -1
  60. package/dist/extensions/index.js +1 -0
  61. package/dist/format-utils/index.js +1 -1
  62. package/dist/index.js +1 -1
  63. package/dist/report-runtime-context/index.js +1 -1
  64. package/dist/style.css +1 -1
  65. package/dist/surfboard/index.js +1 -1
  66. package/dist/types/components/assistant/assistant-store.d.ts +19 -0
  67. package/dist/types/components/assistant/use-assistant.d.ts +4 -0
  68. package/dist/types/components/visual/data-table/hooks/use-data-table-logic.d.ts +2 -3
  69. package/dist/types/components/visual/data-table/table-cell-text.d.ts +93 -0
  70. package/dist/types/components/visual/data-table/types/data-table.d.ts +0 -1
  71. package/dist/types/extensions.d.ts +2 -0
  72. package/dist/types/index.js +1 -1
  73. package/dist/types/lib/charts/types.d.ts +3 -1
  74. package/dist/types/lib/dashboard/semantic-dataset-references.d.ts +0 -2
  75. package/dist/types/lib/matrix-table/matrix-card-adapter.d.ts +12 -12
  76. package/dist/types/lib/matrix-table/matrix-delivery.d.ts +25 -25
  77. package/dist/types/lib/stores/dashboard-store.d.ts +33 -2
  78. package/dist/types/lib/stores/editor-store.d.ts +8 -0
  79. package/dist/types/lib/types/common-types.d.ts +3 -0
  80. package/dist/types/lib/utils/card-definition.d.ts +12 -12
  81. package/dist/types/lib/utils/card-type-change.d.ts +9 -0
  82. package/dist/types/shared/analytics-protocol/analytics-base-schemas.d.ts +6 -6
  83. package/dist/types/shared/analytics-protocol/execution-input-schemas.d.ts +10 -10
  84. package/dist/types/shared/analytics-protocol/matrix-definition-contract.d.ts +248 -248
  85. package/dist/types/shared/analytics-protocol/matrix-operation-contract.d.ts +10 -10
  86. package/dist/types/shared/analytics-protocol/matrix-operation-request.d.ts +8 -8
  87. package/dist/types/shared/analytics-protocol/matrix-window-contract.d.ts +2 -2
  88. package/dist/types/shared/assistant-protocol/context.d.ts +26 -26
  89. package/dist/types/shared/assistant-protocol/parts.d.ts +4 -0
  90. package/dist/types/shared/assistant-protocol/request.d.ts +2 -1
  91. package/dist/types/shared/dashboard-authoring/card-data-source/card-base.d.ts +16 -6
  92. package/dist/types/shared/dashboard-authoring/card-settings/custom-visual-write.d.ts +50 -0
  93. package/dist/types/shared/dashboard-authoring/card-settings/index.d.ts +1 -0
  94. package/dist/types/shared/dashboard-authoring/changes/card-query-part.d.ts +1 -0
  95. package/dist/types/shared/dashboard-authoring/changes/card-types.d.ts +2 -2
  96. package/dist/types/shared/dashboard-authoring/changes/custom-visual-change.d.ts +57 -0
  97. package/dist/types/shared/dashboard-authoring/changes/dashboard-change.d.ts +61 -54
  98. package/dist/types/shared/dashboard-authoring/changes/diagnostics.d.ts +5 -1
  99. package/dist/types/shared/dashboard-authoring/changes/read-card-query.d.ts +5 -1
  100. package/dist/types/shared/dashboard-authoring/changes/resolve-dashboard-changes.d.ts +10 -0
  101. package/dist/types/shared/dashboard-authoring/conditional-formatting/schema.d.ts +60 -60
  102. package/dist/types/shared/dashboard-authoring/control-execution-contract.d.ts +4 -4
  103. package/dist/types/shared/dashboard-authoring/matrix-delivery.d.ts +48 -48
  104. package/dist/types/shared/dashboard-authoring/operations/operation-sentences.d.ts +8 -2
  105. package/dist/types/shared/dashboard-authoring/operations/operation-types.d.ts +11 -0
  106. package/dist/types/shared/dashboard-authoring/outline/outline-dashboard.d.ts +7 -0
  107. package/dist/types/shared/dashboard-authoring/table-sheet-shape.d.ts +8 -0
  108. package/dist/types/shared/extensions/check-audits.d.ts +30 -0
  109. package/dist/types/shared/extensions/check-findings.d.ts +46 -0
  110. package/dist/types/shared/extensions/check-input.d.ts +23 -0
  111. package/dist/types/shared/extensions/check-renders.d.ts +44 -0
  112. package/dist/types/shared/extensions/check-runner.d.ts +19 -0
  113. package/dist/types/shared/extensions/index.d.ts +17 -0
  114. package/dist/types/shared/extensions/read-document.d.ts +18 -0
  115. package/dist/types/shared/extensions/sandbox-host.d.ts +63 -0
  116. package/dist/types/shared/extensions/saved-refs.d.ts +33 -0
  117. package/dist/types/shared/extensions/script-policy.d.ts +11 -0
  118. package/dist/types/shared/extensions/types.d.ts +186 -0
  119. package/dist/types/shared/extensions/visual-contract.d.ts +38 -0
  120. package/dist/types/shared/extensions/visual-payload.d.ts +75 -0
  121. package/dist/types/shared/extensions/visual-theme.d.ts +21 -0
  122. package/dist/types/shared/format-utils/formatters/number-formatter.d.ts +13 -6
  123. package/dist/types/shared/format-utils/matrix-continuation.d.ts +2 -2
  124. package/dist/types/shared/format-utils/matrix-export-presentation.d.ts +24 -24
  125. package/dist/types/shared/usage-events/details.d.ts +4 -4
  126. package/dist/types/shared/usage-events/envelope.d.ts +2 -2
  127. package/dist/usage-events/index.js +1 -1
  128. package/package.json +7 -2
  129. package/dist/chunks/add-to-dashboard-CEmZUf9o.js +0 -12
  130. package/dist/chunks/appearance-provider-fIhJSX6y.js +0 -613
  131. package/dist/chunks/appearance-runtime-provider-Bx8H-moR.js +0 -1
  132. package/dist/chunks/assistant-chat-SBKSrrEA.js +0 -51
  133. package/dist/chunks/attachment-filter-line-C_zHMhGh.js +0 -1
  134. package/dist/chunks/bookmark-state-DScd31KT.js +0 -1
  135. package/dist/chunks/card-filter-builder-CzScSOQY.js +0 -11
  136. package/dist/chunks/context-CntvtZwC.js +0 -2
  137. package/dist/chunks/dashboard-temporal-snapshot-w3SMiPKj.js +0 -1
  138. package/dist/chunks/edit-dashboard-visual-DlvY7au4.js +0 -73
  139. package/dist/chunks/filter-reach-preview-DAEIyrEG.js +0 -1
  140. package/dist/chunks/kpi-trend-rule-N1Xkwe_u.js +0 -1
  141. package/dist/chunks/matrix-analytical-definition-5T-2euHZ.js +0 -1
  142. package/dist/chunks/matrix-operation-contract-CWvcEsQ0.js +0 -1
  143. package/dist/chunks/pivot-result-contract-expectations-BNWhS8mv.js +0 -1
  144. package/dist/chunks/report-preferences-dialog-B2ZGPS9t.js +0 -1
  145. package/dist/chunks/resolve-dashboard-input-context-SlAAe4GF.js +0 -8
  146. package/dist/chunks/saved-dashboard-context-Bc2SVDr-.js +0 -1
  147. package/dist/chunks/semaphor-ready-indicator-Bj-cjkz-.js +0 -612
  148. package/dist/chunks/set-CACXVM2A.js +0 -1
  149. package/dist/chunks/slider-CWze9OEM.js +0 -4
  150. package/dist/chunks/stored-dashboard-CcNdU-mG.js +0 -1
@@ -1,29 +1,29 @@
1
- import{jsx as e,jsxs as o,Fragment as T}from"react/jsx-runtime";import{c as we,u as D,B as $,bq as Gr,br as $r,bs as Vr,bt as tt,at as X,aq as Ne,bg as k,bh as $t,bi as Vt,bk as rt,bl as at,bu as Ht,ag as Be,af as ot,bv as Hr,X as jt,aa as te,bw as qt,ac as jr,bj as qr,aQ as zr,a4 as Kr,a5 as Qr,a6 as Wr,a7 as Jr,bx as Yr,a8 as Xr,by as A,bz as Zr,P as ea,b as ta,bA as ra,e as aa,p as na,F as At,s as sa,bB as It,bC as Mt,d as oa,bD as Lt,aI as ia,aJ as da,aK as la,bE as ca,aM as ua,bF as ma,g as zt,bG as ee,bH as be,bI as ha,bJ as pa,am as Ot,ah as fa,bK as Pt}from"./appearance-provider-fIhJSX6y.js";import{b9 as ba,ba as ga,bb as it,bc as xa,bd as va,be as ya,bf as wa,bg as Na,bh as Sa,bi as Se,bj as Da,bk as ka,bl as Ca,bm as Kt,bn as Ea,bo as Aa,aq as Ia,bp as Ma,b4 as La,bq as Oa,b5 as Pa,l as _a,u as Te,n as Ra,R as Xe,x as Ta,br as Ua,bs as Ba,Q as Fa,bt as Ga,bu as $a,r as Va,bv as Ha,bw as ja,bx as qa,by as za,b6 as Ka,T as Qa,bz as Wa,bA as Ja,bB as Ya,m as Xa,bC as Za,bD as en,bE as tn,bF as rn,bG as an,bH as nn,bI as sn,bJ as on,bK as _t,z as dn}from"./semaphor-ready-indicator-Bj-cjkz-.js";import*as E from"react";import Qt,{useMemo as H,useState as N,useEffect as ve,useRef as Rt,useLayoutEffect as ln}from"react";import{k as ye,j9 as De,ja as dt,jb as Wt,M as cn,R as un}from"./resolve-dashboard-input-context-SlAAe4GF.js";import"./validators-Dg2kyF4_.js";import"./matrix-operation-contract-CWvcEsQ0.js";import"./analytics-base-schemas-DMFrDqn_.js";import"../value-format-preferences/index.js";import{u as mn,c as hn,k as pn,D as fn,A as bn,a as gn,h as xn,l as vn,V as yn,b as wn,n as Nn,d as Sn,S as Dn,j as kn,i as Cn,m as En,U as An}from"./dashboard-briefing-launcher-CyOFddmD.js";import{I as In}from"./card-filter-builder-CzScSOQY.js";import{c as Mn,R as Ln}from"./report-preferences-dialog-B2ZGPS9t.js";import{createPortal as On}from"react-dom";import{aX as Jt}from"./pivot-result-contract-expectations-BNWhS8mv.js";import{g as nt}from"./stored-dashboard-CcNdU-mG.js";import{r as Pn}from"./export-file-format-B-wQNHIn.js";import{u as _n,s as Rn}from"./normalize-dashboard-for-dirty-check-ILKfqgL3.js";import{A as Yt}from"./bookmark-state-DScd31KT.js";import{d as Tn,a as Un}from"./bookmark-impact-BW30cm5E.js";import{P as Bn}from"./palette-565cA0nh.js";/**
1
+ import{jsx as e,jsxs as o,Fragment as T}from"react/jsx-runtime";import{c as Se,u as D,B as V,br as $r,bs as Gr,bt as Vr,bu as at,aK as Z,b9 as De,aY as k,aZ as Ht,a_ as jt,b0 as nt,b1 as st,bv as qt,ag as Fe,af as it,bw as Hr,X as zt,aa as re,bx as Kt,ac as jr,a$ as qr,av as zr,a4 as Kr,a5 as Qr,a6 as Wr,a7 as Jr,by as Yr,a8 as Xr,bz as A,bA as Zr,P as ea,b as ta,bB as ra,e as aa,p as na,F as Mt,s as sa,bC as Lt,bD as Ot,d as oa,bE as Pt,an as ia,ao as da,ap as la,bF as ca,ar as ua,bG as ma,g as Qt,bH as te,bI as xe,bJ as ha,bK as pa,am as _t,ah as fa,bL as Rt}from"./appearance-provider-BBYTKSjL.js";import{bc as ba,bd as ga,be as dt,bf as xa,bg as va,bh as ya,bi as wa,bj as Na,bk as Sa,b3 as ke,bl as Da,bm as ka,bn as Ca,bo as Wt,bp as Ea,bq as Aa,ar as Ia,br as Ma,aZ as La,bs as Oa,a_ as Pa,l as _a,u as Ue,n as Ra,R as et,x as Ta,bt as Ua,bu as Ba,W as Fa,bv as $a,bw as Ga,r as Va,I as Ha,bx as ja,by as qa,bz as za,bA as Ka,a$ as Qa,T as Wa,bB as Ja,bC as Ya,bD as Xa,m as Za,bE as en,bF as tn,bG as rn,bH as an,bI as nn,bJ as sn,bK as on,bL as dn,bM as Tt,z as ln}from"./semaphor-ready-indicator-Cq3C2SNo.js";import*as E from"react";import Jt,{useMemo as j,useState as N,useEffect as we,useRef as Ut,useLayoutEffect as cn}from"react";import{n as Ne,jw as Ce,jx as lt,jy as Yt,a5 as un,ak as mn}from"./resolve-dashboard-input-context-B5yUS9ZM.js";import"./validators-U8IL8djK.js";import"./matrix-operation-contract-DceN49RX.js";import"./analytics-base-schemas-DMFrDqn_.js";import"../value-format-preferences/index.js";import{u as hn,c as pn,k as fn,D as bn,A as gn,a as xn,h as vn,l as yn,V as wn,b as Nn,n as Sn,d as Dn,S as kn,j as Cn,i as En,m as An,U as In}from"./dashboard-briefing-launcher-CX7mCnPi.js";import{c as Mn,R as Ln}from"./report-preferences-dialog-EQNoTych.js";import{createPortal as On}from"react-dom";import{a$ as Xt}from"./pivot-result-contract-expectations-D_ane7I2.js";import{f as $e}from"./stored-dashboard-1x0q2cNx.js";import{r as Pn}from"./export-file-format-B-wQNHIn.js";import{u as _n,s as Rn}from"./normalize-dashboard-for-dirty-check-ILKfqgL3.js";import{A as Zt}from"./bookmark-state-BmbBu1th.js";import{d as Tn,a as Un}from"./bookmark-impact-xCmo8x3V.js";import{P as Bn}from"./palette-CZJ4ZCY9.js";/**
2
2
  * @license lucide-react v0.453.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
5
5
  * See the LICENSE file in the root directory of this source tree.
6
- */const Fn=we("Moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]);/**
6
+ */const Fn=Se("Moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]);/**
7
7
  * @license lucide-react v0.453.0 - ISC
8
8
  *
9
9
  * This source code is licensed under the ISC license.
10
10
  * See the LICENSE file in the root directory of this source tree.
11
- */const Gn=we("ShieldX",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m14.5 9.5-5 5",key:"17q4r4"}],["path",{d:"m9.5 9.5 5 5",key:"18nt4w"}]]);/**
11
+ */const $n=Se("ShieldX",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m14.5 9.5-5 5",key:"17q4r4"}],["path",{d:"m9.5 9.5 5 5",key:"18nt4w"}]]);/**
12
12
  * @license lucide-react v0.453.0 - ISC
13
13
  *
14
14
  * This source code is licensed under the ISC license.
15
15
  * See the LICENSE file in the root directory of this source tree.
16
- */const $n=we("Sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]);/**
16
+ */const Gn=Se("Sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]);/**
17
17
  * @license lucide-react v0.453.0 - ISC
18
18
  *
19
19
  * This source code is licensed under the ISC license.
20
20
  * See the LICENSE file in the root directory of this source tree.
21
- */const Vn=we("UserPlus",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]]);/**
21
+ */const Vn=Se("UserPlus",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]]);/**
22
22
  * @license lucide-react v0.453.0 - ISC
23
23
  *
24
24
  * This source code is licensed under the ISC license.
25
25
  * See the LICENSE file in the root directory of this source tree.
26
- */const Xt=we("UserRound",[["circle",{cx:"12",cy:"8",r:"5",key:"1hypcn"}],["path",{d:"M20 21a8 8 0 0 0-16 0",key:"rfgkzh"}]]);var st={exports:{}},Ze={};/**
26
+ */const er=Se("UserRound",[["circle",{cx:"12",cy:"8",r:"5",key:"1hypcn"}],["path",{d:"M20 21a8 8 0 0 0-16 0",key:"rfgkzh"}]]);var ot={exports:{}},tt={};/**
27
27
  * @license React
28
28
  * use-sync-external-store-shim.production.js
29
29
  *
@@ -31,7 +31,7 @@ import{jsx as e,jsxs as o,Fragment as T}from"react/jsx-runtime";import{c as we,u
31
31
  *
32
32
  * This source code is licensed under the MIT license found in the
33
33
  * LICENSE file in the root directory of this source tree.
34
- */var Tt;function Hn(){if(Tt)return Ze;Tt=1;var t=Qt;function n(i,f){return i===f&&(i!==0||1/i===1/f)||i!==i&&f!==f;}var a=typeof Object.is=="function"?Object.is:n,r=t.useState,s=t.useEffect,l=t.useLayoutEffect,u=t.useDebugValue;function m(i,f){var c=f(),x=r({inst:{value:c,getSnapshot:f}}),h=x[0].inst,w=x[1];return l(function(){h.value=c,h.getSnapshot=f,p(h)&&w({inst:h});},[i,c,f]),s(function(){return p(h)&&w({inst:h}),i(function(){p(h)&&w({inst:h});});},[i]),u(c),c;}function p(i){var f=i.getSnapshot;i=i.value;try{var c=f();return!a(i,c);}catch{return!0;}}function y(i,f){return f();}var b=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?y:m;return Ze.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:b,Ze;}var et={};/**
34
+ */var Bt;function Hn(){if(Bt)return tt;Bt=1;var t=Jt;function n(i,f){return i===f&&(i!==0||1/i===1/f)||i!==i&&f!==f;}var a=typeof Object.is=="function"?Object.is:n,r=t.useState,s=t.useEffect,l=t.useLayoutEffect,u=t.useDebugValue;function m(i,f){var c=f(),x=r({inst:{value:c,getSnapshot:f}}),h=x[0].inst,w=x[1];return l(function(){h.value=c,h.getSnapshot=f,p(h)&&w({inst:h});},[i,c,f]),s(function(){return p(h)&&w({inst:h}),i(function(){p(h)&&w({inst:h});});},[i]),u(c),c;}function p(i){var f=i.getSnapshot;i=i.value;try{var c=f();return!a(i,c);}catch{return!0;}}function y(i,f){return f();}var b=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?y:m;return tt.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:b,tt;}var rt={};/**
35
35
  * @license React
36
36
  * use-sync-external-store-shim.development.js
37
37
  *
@@ -39,4 +39,4 @@ import{jsx as e,jsxs as o,Fragment as T}from"react/jsx-runtime";import{c as we,u
39
39
  *
40
40
  * This source code is licensed under the MIT license found in the
41
41
  * LICENSE file in the root directory of this source tree.
42
- */var Ut;function jn(){return Ut||(Ut=1,process.env.NODE_ENV!=="production"&&function(){function t(c,x){return c===x&&(c!==0||1/c===1/x)||c!==c&&x!==x;}function n(c,x){b||s.startTransition===void 0||(b=!0,console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var h=x();if(!i){var w=x();l(h,w)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),i=!0);}w=u({inst:{value:h,getSnapshot:x}});var S=w[0].inst,P=w[1];return p(function(){S.value=h,S.getSnapshot=x,a(S)&&P({inst:S});},[c,h,x]),m(function(){return a(S)&&P({inst:S}),c(function(){a(S)&&P({inst:S});});},[c]),y(h),h;}function a(c){var x=c.getSnapshot;c=c.value;try{var h=x();return!l(c,h);}catch{return!0;}}function r(c,x){return x();}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var s=Qt,l=typeof Object.is=="function"?Object.is:t,u=s.useState,m=s.useEffect,p=s.useLayoutEffect,y=s.useDebugValue,b=!1,i=!1,f=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?r:n;et.useSyncExternalStore=s.useSyncExternalStore!==void 0?s.useSyncExternalStore:f,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());}()),et;}process.env.NODE_ENV==="production"?st.exports=Hn():st.exports=jn();var qn=st.exports;const Ue=["light","dark","system"];function zn(){const{theme:t,setTheme:n}=ba(),a=D(u=>u.actions.setDashboardTheme);function r(){const u=Ue.includes(t)?t:"system",m=Ue[(Ue.indexOf(u)+1)%Ue.length];n(m),a(m);}const s=t==="light"?$n:t==="dark"?Fn:ga,l=t==="light"?"Theme: light (click for dark)":t==="dark"?"Theme: dark (click for system)":"Theme: system (click for light)";return/* @__PURE__ */e($,{type:"button",variant:"ghost",size:"xs",className:"h-7 w-7 p-0",onClick:r,"aria-label":l,title:l,children:/* @__PURE__ */e(s,{className:"h-3.5 w-3.5",strokeWidth:1.5})});}function Kn(){const{displayPreferences:t,shouldShowElement:n}=Gr(),{currentUser:a,userContext:r}=it(),s=H(()=>xa(a),[a]),l=H(()=>m=>s&&s[m]!==void 0&&s[m]===!1?!1:n(m),[s,n,t]),u=H(()=>{var m,p,y,b,i;return{canEdit:((m=r==null?void 0:r.permissions)==null?void 0:m.canEdit)??Sa(a),canUseFilters:((p=r==null?void 0:r.permissions)==null?void 0:p.canEdit)??Na(a),canManageDashboards:((y=r==null?void 0:r.permissions)==null?void 0:y.canCreateDashboard)??wa(a),canCreateDashboards:((b=r==null?void 0:r.permissions)==null?void 0:b.canCreateDashboard)??ya(a),canAccessVisuals:((i=r==null?void 0:r.permissions)==null?void 0:i.canEdit)??va(a)};},[a,r]);return{displayPreferences:t,shouldShowElement:l,permissions:u,currentUser:a};}function Qn(t,n=[]){let a=[];function r(l,u){const m=E.createContext(u);m.displayName=l+"Context";const p=a.length;a=[...a,u];const y=i=>{var S;const{scope:f,children:c,...x}=i,h=((S=f==null?void 0:f[t])==null?void 0:S[p])||m,w=E.useMemo(()=>x,Object.values(x));return/* @__PURE__ */e(h.Provider,{value:w,children:c});};y.displayName=l+"Provider";function b(i,f){var h;const c=((h=f==null?void 0:f[t])==null?void 0:h[p])||m,x=E.useContext(c);if(x)return x;if(u!==void 0)return u;throw new Error(`\`${i}\` must be used within \`${l}\``);}return[y,b];}const s=()=>{const l=a.map(u=>E.createContext(u));return function(m){const p=(m==null?void 0:m[t])||l;return E.useMemo(()=>({[`__scope${t}`]:{...m,[t]:p}}),[m,p]);};};return s.scopeName=t,[r,Wn(s,...n)];}function Wn(...t){const n=t[0];if(t.length===1)return n;const a=()=>{const r=t.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(l){const u=r.reduce((m,{useScope:p,scopeName:y})=>{const i=p(l)[`__scope${y}`];return{...m,...i};},{});return E.useMemo(()=>({[`__scope${n.scopeName}`]:u}),[u]);};};return a.scopeName=n.scopeName,a;}var Jn=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],lt=Jn.reduce((t,n)=>{const a=$r(`Primitive.${n}`),r=E.forwardRef((s,l)=>{const{asChild:u,...m}=s,p=u?a:n;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),/* @__PURE__ */e(p,{...m,ref:l});});return r.displayName=`Primitive.${n}`,{...t,[n]:r};},{});function Yn(){return qn.useSyncExternalStore(Xn,()=>!0,()=>!1);}function Xn(){return()=>{};}var ct="Avatar",[Zn]=Qn(ct),[es,Zt]=Zn(ct),er=E.forwardRef((t,n)=>{const{__scopeAvatar:a,...r}=t,[s,l]=E.useState("idle");return/* @__PURE__ */e(es,{scope:a,imageLoadingStatus:s,onImageLoadingStatusChange:l,children:/* @__PURE__ */e(lt.span,{...r,ref:n})});});er.displayName=ct;var tr="AvatarImage",rr=E.forwardRef((t,n)=>{const{__scopeAvatar:a,src:r,onLoadingStatusChange:s=()=>{},...l}=t,u=Zt(tr,a),m=ts(r,l),p=Vr(y=>{s(y),u.onImageLoadingStatusChange(y);});return tt(()=>{m!=="idle"&&p(m);},[m,p]),m==="loaded"?/* @__PURE__ */e(lt.img,{...l,ref:n,src:r}):null;});rr.displayName=tr;var ar="AvatarFallback",nr=E.forwardRef((t,n)=>{const{__scopeAvatar:a,delayMs:r,...s}=t,l=Zt(ar,a),[u,m]=E.useState(r===void 0);return E.useEffect(()=>{if(r!==void 0){const p=window.setTimeout(()=>m(!0),r);return()=>window.clearTimeout(p);}},[r]),u&&l.imageLoadingStatus!=="loaded"?/* @__PURE__ */e(lt.span,{...s,ref:n}):null;});nr.displayName=ar;function Bt(t,n){return t?n?(t.src!==n&&(t.src=n),t.complete&&t.naturalWidth>0?"loaded":"loading"):"error":"idle";}function ts(t,{referrerPolicy:n,crossOrigin:a}){const r=Yn(),s=E.useRef(null),l=r?(s.current||(s.current=new window.Image()),s.current):null,[u,m]=E.useState(()=>Bt(l,t));return tt(()=>{m(Bt(l,t));},[l,t]),tt(()=>{const p=i=>()=>{m(i);};if(!l)return;const y=p("loaded"),b=p("error");return l.addEventListener("load",y),l.addEventListener("error",b),n&&(l.referrerPolicy=n),typeof a=="string"&&(l.crossOrigin=a),()=>{l.removeEventListener("load",y),l.removeEventListener("error",b);};},[l,a,n]),u;}var sr=er,or=rr,ir=nr;const dr=E.forwardRef(({className:t,...n},a)=>/* @__PURE__ */e(sr,{ref:a,className:ye("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",t),...n}));dr.displayName=sr.displayName;const rs=E.forwardRef(({className:t,...n},a)=>/* @__PURE__ */e(or,{ref:a,className:ye("aspect-square h-full w-full",t),...n}));rs.displayName=or.displayName;const lr=E.forwardRef(({className:t,...n},a)=>/* @__PURE__ */e(ir,{ref:a,className:ye("flex h-full w-full items-center justify-center rounded-full bg-muted",t),...n}));lr.displayName=ir.displayName;const as=async(t,n,a)=>{const r=`${t}/management/v1/groups`;return await Wt(r,n,a);},ns=async(t,n,a,r)=>{const s=`${t}/management/v1/groups/${a}`;return dt(s,n,"PATCH",r);},ss=async(t,n,a)=>{const r=`${t}/management/v1/groups/${a}`;await dt(r,n,"DELETE");},os=async(t,n,a,r)=>{const s=`${t}/management/v1/groups/${a}/members`;return await Wt(s,n,r);},is=async(t,n,a,r)=>{const s=`${t}/management/v1/groups/${a}/members`;await dt(s,n,"DELETE",r);};function ds(){const{authToken:t,tokenProps:n}=X(),a=Ne();return Se({mutationFn:r=>as(n.apiServiceUrl,(t==null?void 0:t.accessToken)||"",r),onSuccess:()=>{a.invalidateQueries({queryKey:["groups"]}),k.success("Group created successfully");},onError:r=>{console.error("Failed to create group:",r),k.error("Failed to create group",{description:De(r,"Failed to create group")});}});}function ls(){const{authToken:t,tokenProps:n}=X(),a=Ne();return Se({mutationFn:({groupId:r,data:s})=>ns(n.apiServiceUrl,(t==null?void 0:t.accessToken)||"",r,s),onSuccess:(r,s)=>{a.invalidateQueries({queryKey:["group",s.groupId]}),a.invalidateQueries({queryKey:["groups"]}),k.success("Group updated successfully");},onError:r=>{console.error("Failed to update group:",r),k.error("Failed to update group",{description:De(r,"Failed to update group")});}});}function cs(){const{authToken:t,tokenProps:n}=X(),a=Ne();return Se({mutationFn:r=>ss(n.apiServiceUrl,(t==null?void 0:t.accessToken)||"",r),onSuccess:(r,s)=>{a.invalidateQueries({queryKey:["groups"]}),a.removeQueries({queryKey:["group",s]}),k.success("Group deleted successfully");},onError:r=>{console.error("Failed to delete group:",r),k.error("Failed to delete group",{description:De(r,"Failed to delete group")});}});}function us(){const{authToken:t,tokenProps:n}=X(),a=Ne();return Se({mutationFn:({groupId:r,data:s})=>os(n.apiServiceUrl,(t==null?void 0:t.accessToken)||"",r,s),onSuccess:(r,s)=>{a.invalidateQueries({queryKey:["group",s.groupId]}),a.invalidateQueries({queryKey:["group-members",s.groupId]}),a.invalidateQueries({queryKey:["groups"]}),k.success("Members added successfully");},onError:r=>{console.error("Failed to add group members:",r),k.error("Failed to add members",{description:De(r,"Failed to add members")});}});}function ms(){const{authToken:t,tokenProps:n}=X(),a=Ne();return Se({mutationFn:({groupId:r,data:s})=>is(n.apiServiceUrl,(t==null?void 0:t.accessToken)||"",r,s),onSuccess:(r,s)=>{a.invalidateQueries({queryKey:["group",s.groupId]}),a.invalidateQueries({queryKey:["group-members",s.groupId]}),a.invalidateQueries({queryKey:["groups"]}),k.success("Members removed successfully");},onError:r=>{console.error("Failed to remove group members:",r),k.error("Failed to remove members",{description:De(r,"Failed to remove members")});}});}const hs=[];function ps({open:t,onOpenChange:n}){var P,g,B;const{tokenProps:a}=X(),{currentUser:r}=it(),s=(r==null?void 0:r.type)==="tenant",l=a==null?void 0:a.tenantId,{groups:u,isLoading:m,error:p,refetch:y}=Da({type:s?"TENANT_GROUP":"all",tenantId:s?l:void 0,includeMembers:!1}),b=p?cr(p,"Unable to load groups."):null,[i,f]=N({kind:"list"}),[c,x]=N(null),h=cs();ve(()=>{t||(f({kind:"list"}),x(null));},[t]);const w=i.kind==="members"&&u.find(L=>L.id===i.groupId)||null,S=async()=>{if(c)try{await h.mutateAsync(c.id),x(null),f({kind:"list"}),y();}catch{}};return/* @__PURE__ */e($t,{open:t,onOpenChange:n,children:/* @__PURE__ */o(Vt,{className:"flex max-h-[640px] w-[720px] max-w-[92vw] flex-col gap-0 overflow-hidden p-0",children:[i.kind==="list"?/* @__PURE__ */o("div",{className:"shrink-0 border-b border-border px-5 pt-4 pb-3.5",children:[/* @__PURE__ */e(rt,{className:"text-[15px] font-semibold tracking-tight",children:"Group management"}),/* @__PURE__ */e(at,{className:"mt-1 text-[12px] leading-[1.5] text-muted-foreground",children:"Organize people into groups for shared access."})]}):i.kind==="create"?/* @__PURE__ */o("div",{className:"flex h-10 shrink-0 items-center gap-1.5 border-b border-border px-5",children:[/* @__PURE__ */e("button",{type:"button",onClick:()=>f({kind:"list"}),"aria-label":"Back",className:"-ml-1 flex h-6 w-6 items-center justify-center rounded-[3px] text-muted-foreground hover:bg-accent hover:text-foreground",children:/* @__PURE__ */e(Ht,{className:"h-3.5 w-3.5"})}),/* @__PURE__ */e(rt,{className:"truncate text-[13px] font-medium",children:"New group"}),/* @__PURE__ */e(at,{className:"sr-only",children:"Create a new group to organize members."})]}):null,i.kind==="list"&&/* @__PURE__ */e(fs,{groups:u,isLoading:m,errorMessage:b,onRetry:()=>y(),currentUserId:r==null?void 0:r.id,onOpenGroup:L=>f({kind:"members",groupId:L}),onCreate:()=>f({kind:"create"}),onDeleteRequest:L=>x(L)}),i.kind==="members"&&w&&/* @__PURE__ */e(xs,{group:w,isTenantViewer:s,canEdit:((P=w.permissions)==null?void 0:P.canEdit)??w.createdBy===(r==null?void 0:r.id),canDelete:((g=w.permissions)==null?void 0:g.canDelete)??w.createdBy===(r==null?void 0:r.id),canManageMembers:((B=w.permissions)==null?void 0:B.canManageMembers)??w.createdBy===(r==null?void 0:r.id),onBack:()=>f({kind:"list"}),onMembersChanged:y,onUpdated:y,onRequestDelete:()=>x(w)},w.id),i.kind==="create"&&/* @__PURE__ */e(vs,{isTenantUser:s,tenantId:l,onCancel:()=>f({kind:"list"}),onCreated:L=>{y(),f({kind:"members",groupId:L});}}),c&&/* @__PURE__ */o("div",{className:"flex shrink-0 items-center justify-between gap-3 border-t border-border bg-muted/40 px-5 py-2.5",children:[/* @__PURE__ */o("div",{className:"min-w-0 text-[12px] text-foreground",children:["Delete ",/* @__PURE__ */e("span",{className:"font-medium",children:c.name}),"?",/* @__PURE__ */e("span",{className:"ml-2 text-muted-foreground",children:"Members lose any access granted via this group."})]}),/* @__PURE__ */o("div",{className:"flex shrink-0 items-center gap-1.5",children:[/* @__PURE__ */e("button",{type:"button",onClick:()=>x(null),disabled:h.isPending,className:"h-7 rounded-[5px] px-2.5 text-[12px] font-medium text-foreground/80 hover:bg-background",children:"Cancel"}),/* @__PURE__ */o("button",{type:"button",onClick:S,disabled:h.isPending,className:"inline-flex h-7 items-center gap-1.5 rounded-[5px] bg-rose-600 px-2.5 text-[12px] font-medium text-white hover:bg-rose-700 disabled:opacity-60",children:[h.isPending?/* @__PURE__ */e(Be,{className:"h-3 w-3 animate-spin"}):/* @__PURE__ */e(ot,{className:"h-3 w-3"}),"Delete group"]})]})]})]})});}function fs({groups:t,isLoading:n,errorMessage:a,onRetry:r,currentUserId:s,onOpenGroup:l,onCreate:u,onDeleteRequest:m}){const[p,y]=N(""),b=H(()=>t.filter(i=>!p.trim()||i.name.toLowerCase().includes(p.toLowerCase())||(i.description||"").toLowerCase().includes(p.toLowerCase())),[t,p]);return/* @__PURE__ */o("div",{className:"flex flex-1 flex-col overflow-hidden",children:[/* @__PURE__ */o("div",{className:"flex shrink-0 items-center gap-2 border-b border-border px-5 py-2.5",children:[/* @__PURE__ */o("div",{className:"flex flex-1 items-center gap-2 rounded-[5px] border border-border bg-background px-2 focus-within:border-foreground/40",children:[/* @__PURE__ */e(Hr,{className:"h-3 w-3 text-muted-foreground"}),/* @__PURE__ */e("input",{value:p,onChange:i=>y(i.target.value),placeholder:"Search groups…",className:"h-7 flex-1 bg-transparent text-[12px] text-foreground placeholder:text-muted-foreground focus:outline-none"}),p&&/* @__PURE__ */e("button",{type:"button",onClick:()=>y(""),className:"flex h-4 w-4 items-center justify-center rounded-[3px] text-muted-foreground hover:bg-accent hover:text-foreground",children:/* @__PURE__ */e(jt,{className:"h-2.5 w-2.5"})})]}),/* @__PURE__ */o("button",{type:"button",onClick:u,className:"inline-flex h-7 items-center gap-1.5 rounded-[5px] bg-foreground px-2.5 text-[12px] font-medium text-background hover:opacity-90",children:[/* @__PURE__ */e(te,{className:"h-3 w-3"}),"New group"]})]}),/* @__PURE__ */e("div",{className:"flex-1 overflow-y-auto",children:n?/* @__PURE__ */e("div",{className:"space-y-px p-3",children:[1,2,3].map(i=>/* @__PURE__ */e("div",{className:"h-12 animate-pulse rounded-[4px] bg-muted/60"},i))}):a?/* @__PURE__ */e(ur,{title:"Can't load groups",message:a,onRetry:r}):b.length===0&&t.length===0?/* @__PURE__ */e(gs,{onCreate:u}):b.length===0?/* @__PURE__ */o("div",{className:"flex h-full flex-col items-center justify-center gap-1 py-10 text-center",children:[/* @__PURE__ */o("div",{className:"text-[12px] text-foreground",children:['No groups match "',p,'"']}),/* @__PURE__ */e("div",{className:"text-[11px] text-muted-foreground",children:"Try a different search."})]}):b.map(i=>{var f;return/* @__PURE__ */e(bs,{group:i,canDelete:((f=i.permissions)==null?void 0:f.canDelete)??i.createdBy===s,onClick:()=>l(i.id),onDelete:()=>m(i)},i.id);})})]});}function bs({group:t,canDelete:n,onClick:a,onDelete:r}){let s="";try{s=Jt(new Date(t.createdAt),"MMM d, yyyy");}catch{s="";}return/* @__PURE__ */o("button",{type:"button",onClick:a,className:"group flex w-full items-center gap-3 border-b border-border/60 px-5 py-2.5 text-left hover:bg-accent/40",children:[/* @__PURE__ */e("div",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-[4px] border border-border bg-background text-muted-foreground",children:/* @__PURE__ */e(Ea,{className:"h-3.5 w-3.5"})}),/* @__PURE__ */o("div",{className:"min-w-0 flex-1",children:[/* @__PURE__ */e("div",{className:"truncate text-[13px] font-medium text-foreground",children:t.name}),/* @__PURE__ */o("div",{className:"mt-0.5 flex items-center gap-2 text-[11px] text-muted-foreground",children:[/* @__PURE__ */o("span",{className:"inline-flex items-center gap-1",children:[/* @__PURE__ */e(Xt,{className:"h-2.5 w-2.5"}),t.memberCount," member",t.memberCount===1?"":"s"]}),s&&/* @__PURE__ */o(T,{children:[/* @__PURE__ */e("span",{className:"text-border",children:"·"}),/* @__PURE__ */o("span",{className:"inline-flex items-center gap-1",children:[/* @__PURE__ */e(qt,{className:"h-2.5 w-2.5"}),s]})]}),t.description&&/* @__PURE__ */o(T,{children:[/* @__PURE__ */e("span",{className:"text-border",children:"·"}),/* @__PURE__ */e("span",{className:"truncate text-muted-foreground",children:t.description})]})]})]}),/* @__PURE__ */o("div",{className:"flex items-center gap-0.5 opacity-0 transition-opacity group-hover:opacity-100",children:[n&&/* @__PURE__ */e("span",{role:"button",tabIndex:0,onClick:l=>{l.stopPropagation(),r();},onKeyDown:l=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),l.stopPropagation(),r());},"aria-label":`Delete ${t.name}`,className:"flex h-6 w-6 items-center justify-center rounded-[3px] text-muted-foreground hover:bg-accent hover:text-foreground",children:/* @__PURE__ */e(ot,{className:"h-3 w-3"})}),/* @__PURE__ */e(jr,{className:"h-3.5 w-3.5 text-muted-foreground"})]})]});}function gs({onCreate:t}){return/* @__PURE__ */o("div",{className:"flex h-full flex-col items-center justify-center gap-2 py-12 text-center",children:[/* @__PURE__ */e("div",{className:"flex h-9 w-9 items-center justify-center rounded-full border border-border bg-muted/40 text-muted-foreground",children:/* @__PURE__ */e(Kt,{className:"h-4 w-4"})}),/* @__PURE__ */e("div",{className:"text-[13px] font-medium text-foreground",children:"No groups yet"}),/* @__PURE__ */e("div",{className:"max-w-[320px] text-[11.5px] leading-[1.55] text-muted-foreground",children:"Groups let you grant shared access to dashboards. Create one and add members."}),/* @__PURE__ */o("button",{type:"button",onClick:t,className:"mt-1 inline-flex h-7 items-center gap-1.5 rounded-[5px] bg-foreground px-2.5 text-[12px] font-medium text-background hover:opacity-90",children:[/* @__PURE__ */e(te,{className:"h-3 w-3"}),"New group"]})]});}function xs({group:t,isTenantViewer:n,canEdit:a,canDelete:r,canManageMembers:s,onBack:l,onMembersChanged:u,onUpdated:m,onRequestDelete:p}){const{data:y,isLoading:b,error:i,refetch:f}=ka(t.id),c=(y==null?void 0:y.members)??hs,x=i?cr(i,"Unable to load members for this group."):null,h=t.type==="TENANT_GROUP"?"tenant":"organization",{users:w}=Ca({type:h,tenantId:t.tenantId||void 0,active:!0,limit:200}),S=H(()=>new Set(c.map(v=>v.userId)),[c]),P=us(),g=ms(),B=ls(),[L,V]=N(!1),[ke,I]=N(t.name),[C,j]=N(!1),[re,q]=N(t.description||""),[ae,ne]=N(""),[Fe,se]=N(!1),Ge=H(()=>{const v=ae.trim().toLowerCase();return w.filter(F=>!S.has(F.id)).filter(F=>!v||(F.name||"").toLowerCase().includes(v)||(F.email||"").toLowerCase().includes(v)).slice(0,50);},[w,S,ae]),oe=async()=>{const v=ke.trim();if(V(!1),v.length>=3&&v!==t.name)try{await B.mutateAsync({groupId:t.id,data:{name:v}}),m();}catch{}},ie=async()=>{const v=re.trim();if(j(!1),v!==(t.description||""))try{await B.mutateAsync({groupId:t.id,data:{description:v}}),m();}catch{}},de=async v=>{if(s){ne(""),se(!1);try{await P.mutateAsync({groupId:t.id,data:{userIds:[v.id],userType:h==="tenant"?"tenant":"org"}}),f(),u();}catch{}}},Ce=async v=>{if(s)try{await g.mutateAsync({groupId:t.id,data:{userIds:[v]}}),f(),u();}catch{}};let z="";try{z=Jt(new Date(t.createdAt),"MMM d, yyyy");}catch{z="";}return/* @__PURE__ */o("div",{className:"flex flex-1 flex-col overflow-hidden",children:[/* @__PURE__ */o("div",{className:"flex h-10 shrink-0 items-center gap-1.5 border-b border-border px-5",children:[/* @__PURE__ */e("button",{type:"button",onClick:l,"aria-label":"Back",className:"-ml-1 flex h-6 w-6 items-center justify-center rounded-[3px] text-muted-foreground hover:bg-accent hover:text-foreground",children:/* @__PURE__ */e(Ht,{className:"h-3.5 w-3.5"})}),L?/* @__PURE__ */e("input",{autoFocus:!0,value:ke,onChange:v=>I(v.target.value),onBlur:oe,onKeyDown:v=>{v.key==="Enter"&&oe(),v.key==="Escape"&&(I(t.name),V(!1));},className:"h-6 min-w-0 flex-1 rounded-[3px] border border-border bg-background px-1.5 text-[13px] font-medium text-foreground focus:border-foreground/40 focus:outline-none"}):/* @__PURE__ */e("button",{type:"button",onClick:()=>{a&&(I(t.name),V(!0));},title:a?"Click to rename":t.name,disabled:!a,className:"truncate rounded-[3px] px-1 text-[13px] font-medium text-foreground enabled:hover:bg-accent disabled:cursor-default",children:t.name}),/* @__PURE__ */o("span",{className:"ml-1 inline-flex shrink-0 items-center gap-1 text-[10.5px] text-muted-foreground",children:[/* @__PURE__ */e(Xt,{className:"h-2.5 w-2.5"}),c.length," member",c.length===1?"":"s"]})]}),/* @__PURE__ */e("div",{className:"shrink-0 border-b border-border px-5 py-2.5",children:C?/* @__PURE__ */o("div",{children:[/* @__PURE__ */e("textarea",{autoFocus:!0,rows:2,value:re,onChange:v=>q(v.target.value),maxLength:200,onKeyDown:v=>{v.key==="Escape"&&(q(t.description||""),j(!1)),v.key==="Enter"&&(v.metaKey||v.ctrlKey)&&ie();},placeholder:"What is this group for?",className:"block w-full resize-none rounded-[5px] border border-border bg-background px-2 py-1.5 text-[12px] text-foreground placeholder:text-muted-foreground focus:border-foreground/40 focus:outline-none"}),/* @__PURE__ */o("div",{className:"mt-1.5 flex items-center justify-between",children:[/* @__PURE__ */o("span",{className:"text-[10.5px] text-muted-foreground",children:[re.length,"/200 · Esc to cancel · ⌘↩ to save"]}),/* @__PURE__ */o("div",{className:"flex items-center gap-1.5",children:[/* @__PURE__ */e("button",{type:"button",onClick:()=>{q(t.description||""),j(!1);},className:"h-6 rounded-[5px] px-2 text-[11px] font-medium text-foreground/80 hover:bg-accent",children:"Cancel"}),/* @__PURE__ */e("button",{type:"button",onClick:ie,className:"inline-flex h-6 items-center rounded-[5px] bg-foreground px-2 text-[11px] font-medium text-background hover:opacity-90",children:"Save"})]})]})]}):/* @__PURE__ */o("button",{type:"button",onClick:()=>{a&&(q(t.description||""),j(!0));},disabled:!a,title:a?"Click to edit description":void 0,className:"block w-full rounded-[3px] px-1 py-0.5 text-left enabled:hover:bg-accent/40 disabled:cursor-default",children:[t.description?/* @__PURE__ */e("p",{className:"text-[12px] leading-[1.55] text-foreground/90",children:t.description}):/* @__PURE__ */e("p",{className:"text-[12px] leading-[1.55] text-muted-foreground",children:a?"Add a description…":"No description"}),/* @__PURE__ */o("p",{className:"mt-1 text-[10.5px] text-muted-foreground",children:[z?`Created ${z}`:"Recently created",a?" · You can edit this group":""]})]})}),s&&/* @__PURE__ */e(ys,{query:ae,setQuery:ne,open:Fe,setOpen:se,candidates:Ge,showKindChip:!n,onAdd:de,busy:P.isPending}),/* @__PURE__ */e("div",{className:"flex-1 overflow-y-auto",children:b?/* @__PURE__ */e("div",{className:"space-y-px p-3",children:[1,2,3].map(v=>/* @__PURE__ */e("div",{className:"h-10 animate-pulse rounded-[4px] bg-muted/60"},v))}):x?/* @__PURE__ */e(ur,{title:"Can't load members",message:x,onRetry:()=>f()}):c.length===0?/* @__PURE__ */o("div",{className:"flex h-full flex-col items-center justify-center gap-1 py-10 text-center",children:[/* @__PURE__ */e("div",{className:"text-[12px] text-foreground",children:"No members yet"}),/* @__PURE__ */e("div",{className:"text-[11px] text-muted-foreground",children:s?"Search above to add people to this group.":"This group does not have any members."})]}):c.map(v=>{var F,le,Ee,K,Q,W;return/* @__PURE__ */o("div",{className:"group flex items-center gap-2 border-b border-border/60 px-5 py-2",children:[/* @__PURE__ */e(mr,{name:((F=v.user)==null?void 0:F.name)||((le=v.user)==null?void 0:le.email)||"?"}),/* @__PURE__ */o("div",{className:"min-w-0 flex-1",children:[/* @__PURE__ */e("div",{className:"truncate text-[12.5px] font-medium text-foreground",children:((Ee=v.user)==null?void 0:Ee.name)||((K=v.user)==null?void 0:K.email)||"Unknown"}),((Q=v.user)==null?void 0:Q.email)&&v.user.name&&/* @__PURE__ */e("div",{className:"truncate text-[10.5px] text-muted-foreground",children:v.user.email})]}),!n&&/* @__PURE__ */e("span",{className:"text-[10px] uppercase tracking-[0.06em] text-muted-foreground",children:v.userType}),/* @__PURE__ */e("button",{type:"button",onClick:()=>Ce(v.userId),disabled:!s||g.isPending,"aria-label":`Remove ${((W=v.user)==null?void 0:W.name)||"member"}`,className:"flex h-6 w-6 items-center justify-center rounded-[3px] text-muted-foreground opacity-0 transition-opacity hover:bg-accent hover:text-foreground group-hover:opacity-100 disabled:opacity-30",children:/* @__PURE__ */e(jt,{className:"h-3 w-3"})})]},v.id);})}),r&&/* @__PURE__ */e("div",{className:"flex shrink-0 items-center justify-end gap-1.5 border-t border-border bg-muted/30 px-5 py-2.5",children:/* @__PURE__ */o("button",{type:"button",onClick:p,className:"inline-flex h-7 items-center gap-1.5 rounded-[5px] border border-rose-200 bg-background px-2.5 text-[12px] font-medium text-rose-600 hover:bg-rose-50 dark:border-rose-900/60 dark:text-rose-400 dark:hover:bg-rose-950/30",children:[/* @__PURE__ */e(ot,{className:"h-3 w-3"}),"Delete group"]})})]});}function vs({isTenantUser:t,tenantId:n,onCancel:a,onCreated:r}){const[s,l]=N(""),[u,m]=N(""),[p,y]=N(null),b=ds(),i=s.trim().length>=3&&s.trim().length<=50,f=async()=>{if(!i)return;y(null);const c={name:s.trim(),description:u.trim()||void 0,type:t?"TENANT_GROUP":"ORG_GROUP",...(t&&n?{tenantId:n}:{})};try{const x=await b.mutateAsync(c),h=x==null?void 0:x.id;h?r(h):a();}catch(x){y(x instanceof Error?x.message:"Failed to create group");}};return/* @__PURE__ */o("div",{className:"flex flex-1 flex-col overflow-hidden",children:[/* @__PURE__ */o("div",{className:"flex-1 overflow-y-auto px-5 py-4",children:[/* @__PURE__ */e(Ft,{children:"Name"}),/* @__PURE__ */e("input",{autoFocus:!0,value:s,onChange:c=>l(c.target.value),placeholder:"Marketing leads, North America sales, …",maxLength:50,className:"mt-1 block h-7 w-full rounded-[5px] border border-border bg-background px-2 text-[12px] text-foreground placeholder:text-muted-foreground focus:border-foreground/40 focus:outline-none"}),/* @__PURE__ */e("div",{className:"mt-1 text-[10.5px] text-muted-foreground",children:"3–50 characters."}),/* @__PURE__ */o("div",{className:"mt-4",children:[/* @__PURE__ */e(Ft,{children:"Description (optional)"}),/* @__PURE__ */e("textarea",{rows:2,value:u,onChange:c=>m(c.target.value),maxLength:200,placeholder:"What is this group for?",className:"mt-1 block w-full resize-none rounded-[5px] border border-border bg-background px-2 py-1.5 text-[12px] text-foreground placeholder:text-muted-foreground focus:border-foreground/40 focus:outline-none"}),/* @__PURE__ */o("div",{className:"mt-1 flex justify-end text-[10.5px] text-muted-foreground",children:[u.length,"/200"]})]}),p&&/* @__PURE__ */e("div",{className:"mt-3 rounded-[5px] border border-rose-200 bg-rose-50 px-2 py-1.5 text-[11.5px] text-rose-700 dark:border-rose-900/60 dark:bg-rose-950/30 dark:text-rose-300",children:p})]}),/* @__PURE__ */o("div",{className:"flex shrink-0 items-center justify-end gap-1.5 border-t border-border bg-muted/30 px-5 py-2.5",children:[/* @__PURE__ */e("button",{type:"button",onClick:a,disabled:b.isPending,className:"h-7 rounded-[5px] px-2.5 text-[12px] font-medium text-foreground/80 hover:bg-accent",children:"Cancel"}),/* @__PURE__ */e("button",{type:"button",onClick:f,disabled:!i||b.isPending,className:"inline-flex h-7 items-center gap-1.5 rounded-[5px] bg-foreground px-2.5 text-[12px] font-medium text-background hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-60",children:b.isPending?/* @__PURE__ */o(T,{children:[/* @__PURE__ */e(Be,{className:"h-3 w-3 animate-spin"}),"Creating…"]}):/* @__PURE__ */o(T,{children:[/* @__PURE__ */e(te,{className:"h-3 w-3"}),"Create group"]})})]})]});}function ys({query:t,setQuery:n,open:a,setOpen:r,candidates:s,showKindChip:l,onAdd:u,busy:m}){const p=Rt(null),y=Rt(null),[b,i]=N(null);ln(()=>{if(!a){i(null);return;}const c=()=>{const x=p.current;if(!x)return;const h=x.getBoundingClientRect(),w=240,P=window.innerHeight-h.bottom<w+16&&h.top>w;i({left:h.left,top:P?h.top-6:h.bottom+6,width:h.width,above:P});};return c(),window.addEventListener("resize",c),window.addEventListener("scroll",c,!0),()=>{window.removeEventListener("resize",c),window.removeEventListener("scroll",c,!0);};},[a,s.length]),ve(()=>{if(!a)return;const c=x=>{var w,S;const h=x.target;(w=p.current)!=null&&w.contains(h)||(S=y.current)!=null&&S.contains(h)||r(!1);};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c);},[a,r]);const f=a&&s.length>0&&b;return/* @__PURE__ */o("div",{className:"shrink-0 border-b border-border px-5 py-2.5",children:[/* @__PURE__ */o("div",{ref:p,className:"flex items-center gap-2 rounded-[5px] border border-border bg-background px-2 focus-within:border-foreground/40",children:[/* @__PURE__ */e(Vn,{className:"h-3 w-3 text-muted-foreground"}),/* @__PURE__ */e("input",{value:t,onChange:c=>{n(c.target.value),r(!0);},onFocus:()=>r(!0),placeholder:"Add a member by name or email…",disabled:m,className:"h-7 flex-1 bg-transparent text-[12px] text-foreground placeholder:text-muted-foreground focus:outline-none disabled:cursor-not-allowed"})]}),f&&typeof document<"u"&&On(/* @__PURE__ */e("div",{ref:y,style:{position:"fixed",left:b.left,top:b.top,width:b.width,transform:b.above?"translateY(-100%)":void 0},className:"z-[60] max-h-[240px] overflow-y-auto rounded-[5px] border border-border bg-background shadow-[0_8px_24px_-12px_rgba(0,0,0,0.18)]",children:s.map(c=>/* @__PURE__ */o("button",{type:"button",onClick:()=>u(c),className:"flex w-full items-center gap-2 border-b border-border/60 px-2.5 py-2 text-left last:border-b-0 hover:bg-accent",children:[/* @__PURE__ */e(mr,{name:c.name||c.email||"?"}),/* @__PURE__ */o("div",{className:"min-w-0 flex-1",children:[/* @__PURE__ */e("div",{className:"truncate text-[12px] font-medium text-foreground",children:c.name||c.email||"Unknown"}),c.email&&c.name&&/* @__PURE__ */e("div",{className:"truncate text-[10.5px] text-muted-foreground",children:c.email})]}),l&&c.type&&/* @__PURE__ */e("span",{className:"text-[10px] uppercase tracking-[0.06em] text-muted-foreground",children:c.type==="tenant"?"tenant":"org"})]},c.id))}),document.body)]});}function cr(t,n){if(!t)return n;if(t instanceof Error){const a=t.message||"",r=a.match(/\{[\s\S]*"error"\s*:\s*"([^"]+)"[\s\S]*\}/);return r?r[1]:a||n;}return typeof t=="string"?t:n;}function ur({title:t,message:n,onRetry:a}){return/* @__PURE__ */o("div",{className:"flex h-full flex-col items-center justify-center gap-2 px-6 py-10 text-center",children:[/* @__PURE__ */e("div",{className:"text-[12.5px] font-medium text-foreground",children:t}),/* @__PURE__ */e("div",{className:"max-w-[360px] text-[11.5px] leading-[1.55] text-muted-foreground",children:n}),a&&/* @__PURE__ */e("button",{type:"button",onClick:a,className:"mt-1 inline-flex h-7 items-center rounded-[5px] border border-border bg-background px-2.5 text-[11.5px] font-medium text-foreground hover:bg-accent",children:"Try again"})]});}function Ft({children:t}){return/* @__PURE__ */e("label",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:t});}function mr({name:t}){const n=t.split(" ").map(a=>a[0]).filter(Boolean).slice(0,2).join("").toUpperCase();return/* @__PURE__ */e(dr,{className:"h-6 w-6 shrink-0",children:/* @__PURE__ */e(lr,{className:"text-[9px] font-semibold",children:n||"?"})});}const ws="text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground";function Ns({open:t,onOpenChange:n}){const a=D(s=>{var l,u;return Pn({dashboardDefault:(u=(l=s.dashboard)==null?void 0:l.exportDefaults)==null?void 0:u.csvEncoding});}),{setDashboardExportDefaults:r}=D(s=>s.actions);return/* @__PURE__ */e($t,{open:t,onOpenChange:n,children:/* @__PURE__ */o(Vt,{className:"rounded-control border-border/60 sm:max-w-[440px] sm:rounded-control",children:[/* @__PURE__ */o(qr,{children:[/* @__PURE__ */e(rt,{className:"text-[15px]",children:"Download settings"}),/* @__PURE__ */e(at,{className:"text-[13px] leading-5",children:"Applies to every CSV downloaded or delivered from this dashboard. People can still change it for a single download."})]}),/* @__PURE__ */o("div",{className:"space-y-2",children:[/* @__PURE__ */e(zr,{htmlFor:"dashboard-csv-encoding",className:ws,children:"CSV encoding"}),/* @__PURE__ */o(Kr,{value:a,onValueChange:s=>r({csvEncoding:s}),children:[/* @__PURE__ */e(Qr,{id:"dashboard-csv-encoding",size:"sm",children:/* @__PURE__ */e(Wr,{})}),/* @__PURE__ */e(Jr,{children:Yr.map(s=>/* @__PURE__ */e(Xr,{value:s.value,children:s.label},s.value))})]})]})]})});}function ge(t,n,a){var l,u;const r=(t.controls||[]).find(m=>m.id===a);if(r)return r.label;const s=(u=(l=Yt(t,n))==null?void 0:l.controls)==null?void 0:u.find(m=>m.id===a);return(s==null?void 0:s.label)||a;}function xe(t,n){var a;return((a=Yt(t,n))==null?void 0:a.title)||n;}function Ss(t){const{errors:n,dashboard:a}=t;if(!a)return n;const r=/* @__PURE__ */new Map();for(const s of n){const l=s.match(/^Card '(.+)' binding for control '(.+)' maps to missing metric '(.+)'\.$/);if(l){const[,b,i]=l,f=`${b}:${i}:missing-metric`;r.has(f)||r.set(f,`"${xe(a,b)}" has an outdated "${ge(a,b,i)}" mapping. Some choices still point to metrics that are no longer available on this card. Open the card controls and choose replacements.`);continue;}const u=s.match(/^Card '(.+)' binding for control '(.+)' maps to missing group-by field '(.+)'\.$/);if(u){const[,b,i]=u,f=`${b}:${i}:missing-group-by`;r.has(f)||r.set(f,`"${xe(a,b)}" has an outdated "${ge(a,b,i)}" mapping. Some choices still point to fields that are no longer available on this card. Open the card controls and choose replacements.`);continue;}const m=s.match(/^Card '(.+)' binding for control '(.+)' maps to an invalid metric target\.$/);if(m){const[,b,i]=m,f=`${b}:${i}:invalid-metric`;r.has(f)||r.set(f,`"${xe(a,b)}" has an invalid "${ge(a,b,i)}" metric mapping. Open the card controls and choose a valid metric for each option.`);continue;}const p=s.match(/^Card '(.+)' binding for control '(.+)' maps to an invalid group-by target\.$/);if(p){const[,b,i]=p,f=`${b}:${i}:invalid-group-by`;r.has(f)||r.set(f,`"${xe(a,b)}" has an invalid "${ge(a,b,i)}" field mapping. Open the card controls and choose a valid field for each option.`);continue;}const y=s.match(/^Card '(.+)' binding for control '(.+)' requires at least one temporal group-by field\.$/);if(y){const[,b,i]=y,f=`${b}:${i}:missing-temporal-group-by`;r.has(f)||r.set(f,`"${xe(a,b)}" can no longer use "${ge(a,b,i)}" for time grain because the card does not currently group by a date field.`);continue;}r.set(s,s);}return Array.from(r.values());}function Ds({visible:t,onSelect:n}){return t?/* @__PURE__ */o(A,{onSelect:n,children:[/* @__PURE__ */e(Aa,{className:"h-3.5 w-3.5"}),"Schedule email report"]}):null;}function ks({scheduleReportVisible:t,analyticalBriefingVisible:n,onScheduleReport:a,onCreateAnalyticalBriefing:r}){return/* @__PURE__ */o(T,{children:[/* @__PURE__ */e(Ds,{visible:t,onSelect:a}),n?/* @__PURE__ */o(A,{onSelect:r,children:[/* @__PURE__ */e(te,{className:"h-3.5 w-3.5"}),"Create analytical briefing"]}):null]});}const Cs="dashboard-bookmark-usage";function Es(t){var p;const n=D(y=>y.viewerStateClient),a=(p=t.saved)==null?void 0:p.id,s=Zr({queryKey:[Cs,(n==null?void 0:n.viewerKey)??null],queryFn:()=>n.bookmarks.usage(),enabled:t.enabled&&!!n&&!!a,staleTime:5*6e4,retry:!1}).data,{saved:l,draft:u,enabled:m}=t;return H(()=>!m||!l||!s?[]:!s.bookmarks&&!Object.keys(s.tables).length?[]:Tn({saved:l,draft:u,usage:s}),[u,m,l,s]);}function As({saved:t,draft:n,enabled:a}){const r=Es({saved:t,draft:n,enabled:a});return r.length?/* @__PURE__ */o(ea,{children:[/* @__PURE__ */e(ta,{asChild:!0,children:/* @__PURE__ */o($,{variant:"ghost",size:"xs",className:"gap-1 text-muted-foreground hover:text-foreground",children:[/* @__PURE__ */e(ra,{className:"h-3.5 w-3.5","aria-hidden":"true"}),"Affects saved views"]})}),/* @__PURE__ */o(aa,{align:"end",className:"w-[320px] p-3 text-[12px]",children:[/* @__PURE__ */e("p",{className:"text-foreground",children:"This edit removes parts of the dashboard that viewers saved. Their views still open, with a note about what no longer applies."}),/* @__PURE__ */e("ul",{"aria-label":"Affected saved views",className:"mt-2 grid gap-1 border-t border-border/60 pt-2",children:r.map(s=>{const{name:l,uses:u}=Un(s);return/* @__PURE__ */o("li",{className:"flex items-baseline justify-between gap-3",children:[/* @__PURE__ */e("span",{className:"min-w-0 truncate text-foreground",children:l}),/* @__PURE__ */e("span",{className:"shrink-0 text-[11.5px] text-muted-foreground",children:u})]},`${s.target}:${s.cardId??""}:${s.id}`);})})]})]}):null;}function Gt(t,n){return{dashboard:nt(t),semanticExecutionPayload:nt(n)};}function Ys(){var Dt,kt,Ct,Et;const{authToken:t,tokenProps:n,id:a,showBriefings:r,toolbarStatus:s}=X(),l=Ia(),{isLocalDev:u,isConsoleMode:m}=Ma(),{canEditDashboard:p,hasInspectionUser:y,inspectionMessage:b,isInspectionMode:i,isInspectionSurface:f}=La(),{openBrandStudioPreview:c}=Oa(),{permissions:x}=Kn(),h=Pa(),{isLoading:w}=_a(),S=D(d=>d.theme),P=D(d=>d.isDownloadingPdf),g=D(d=>d.dashboard),B=D(d=>d.selectedSheetId),L=(Dt=g==null?void 0:g.sheets)==null?void 0:Dt.find(d=>d.id===B),V=cn(L),ke=un(L),I=V?(kt=L==null?void 0:L.document)==null?void 0:kt.page:void 0,C=D(d=>d.isDashboardEditing),{setDashboardTitle:j}=D(d=>d.actions),[re,q]=N(!1),[ae,ne]=N(!1),[Fe,se]=N(!1),[Ge,oe]=N(!1),[ie,de]=N(null),[Ce,z]=N(null),{registerBriefingViewer:v}=na();ve(()=>v(d=>z(d)),[v]);const[F,le]=N(!1),[Ee,K]=N(!1),[Q,W]=N(null),[ut,Ae]=N([]),[mt,Ie]=N(!1),[hr,ht]=N(!1),U=D(d=>d.isVisualEditing);At(d=>d.card);const pr=Te(d=>d.selectedDashboard),fr=Te(d=>d.initialDashboard);Te(d=>d.selectedVisual),D(d=>d.selectedFrameId),At(d=>d.frame);const pt=D(d=>d.showDashboardJSON);D(d=>d.onSaveFunction);const{setIsDashboardEditing:ft,setShowDashboardJSON:bt,markDashboardSaved:br,openStyleSheet:gr}=D(d=>d.actions),{setInitialDashboard:gt,clearSelectedDashboard:$e}=Te(d=>d.actions),ce=!!n.orgUserId||!!(n.tenantId&&n.endUserId&&n.endUserEmail),{resources:Me}=Ra(Xe.DASHBOARD),M=Ta(),{currentUser:xr}=it(),vr=Ua(xr),G=pr||fr,J=Ba({config:n.config,canNavigateDashboardHub:ce,canShareDashboard:((Ct=G==null?void 0:G.permissions)==null?void 0:Ct.canShare)===!0,canManageGroups:vr}),xt=G?{id:G.id,title:(g==null?void 0:g.title)||G.title||"Dashboard"}:null,{handleAddNewFrame:yr}=Fa(),[Ve,He]=N(!1),[wr,ue]=N(!1),[je,Le]=N("close"),me=Ga(Xe.DASHBOARD),[O,he]=N(null),Nr=async(d,R)=>{if(!i){if(!(g!=null&&g.id)){console.log("No dashboard ID found");return;}console.log("Updating dashboard title:",{dashboardId:g.id,newTitle:d,previousTitle:R}),me.mutate({resourceId:g.id,data:{title:d}},{onSuccess:()=>{he(_=>(_==null?void 0:_.dashboard.id)===g.id?{..._,dashboard:{..._.dashboard,title:d}}:_),k.success("Dashboard title updated");},onError:_=>{console.error("Failed to update dashboard title:",_),k.error("Failed to update dashboard title");const Z=D.getState().dashboard;(Z==null?void 0:Z.id)===g.id&&Z.title===d&&j(R);}});}};ve(()=>{if(Me&&Me.length>0){const d=g==null?void 0:g.id;if(d){const R=Me.find(_=>_.id===d);R&&gt(R);}}},[Me,g==null?void 0:g.id,gt]);const Sr=n.orgUserId||n.tenantId,qe=H(()=>Ms({accessToken:t==null?void 0:t.accessToken,dashboardId:(g==null?void 0:g.id)||a||n.dashboard_id,selectedSheetId:V?B:void 0,pageSize:I==null?void 0:I.size,orientation:I==null?void 0:I.orientation,theme:S}),[t==null?void 0:t.accessToken,a,g==null?void 0:g.id,V,I==null?void 0:I.orientation,I==null?void 0:I.size,B,S,n.dashboard_id]),ze=C&&!U&&!i&&Sr&&p,{setDashboard:Ke}=D(d=>d.actions),Dr=D(d=>d.semanticExecutionPayload),kr=()=>{ft(!0);},Oe=()=>{ft(!1),bt(!1),he(null);};ve(()=>{if(!C){O&&he(null);return;}if(O||!g||w)return;const d=sa(D.getState());he(Gt(d.dashboard,d.semanticExecutionPayload));},[g,O,C,w,Dr]);const Qe=(O==null?void 0:O.dashboard)??null,{isDirty:We,isDirtyPending:Cr,resetDirty:pe}=_n(g,Qe,300,1e3,Rn),vt=mn(Qe,i,p),yt=We||Cr,Pe=Ve||me.isPending,Er=()=>{if(i){O&&Ke(O.dashboard,{semanticExecutionPayload:O.semanticExecutionPayload}),Oe(),pe();return;}vt()?(Le("close"),ue(!0)):(Oe(),pe());},Ar=async()=>{await Je({closeAfterSave:!0,navigateHomeAfterSave:je==="home"});},Ir=()=>{const d=je==="home"&&!!ce;O&&Ke(O.dashboard,{semanticExecutionPayload:O.semanticExecutionPayload}),Oe(),d&&$e(),Le("close"),ue(!1),pe();},Mr=()=>{O&&(Ke(O.dashboard,{semanticExecutionPayload:O.semanticExecutionPayload}),pe());},Lr=()=>{if(ce){if(C&&vt()){Le("home"),ue(!0);return;}$e();}};async function Je(d){if(i)return;const R=D.getState().dashboard;if(!R)return;const _=(d==null?void 0:d.closeAfterSave)??mt,Z=(d==null?void 0:d.navigateHomeAfterSave)??!1;Ie(_),_&&ue(!1);const Rr=nt(R);K(!0),W(null),Ae([]),He(!0);const Tr={template:R};me.mutate({resourceId:R.id,data:Tr},{onSuccess:()=>{He(!1),br(),k.success("Dashboard saved!"),he(Gt(Rr,D.getState().semanticExecutionPayload)),K(!1),Ie(!1),_&&(Oe(),pe(),Z&&ce&&$e()),Le("close");},onError:Ur=>{He(!1),W("Failed to save dashboard. Please try again.");const Re=Ur.details,Br=Array.isArray(Re==null?void 0:Re.errors)?(Re.errors||[]).filter(Fr=>typeof Fr=="string"):[];Ae(Ss({errors:Br,dashboard:R||void 0})),k.error("Failed to save dashboard");}});}const wt=g.title;me.isPending&&console.log("Title during update:",{title:wt,dashboardStateTitle:g.title,dashboardId:g==null?void 0:g.id});const Or=ce&&!!(t!=null&&t.accessToken)&&!!(n!=null&&n.apiServiceUrl),Pr=!i&&J.showDashboardHub&&Or,_r=!i&&h&&J.showDashboardHub,Y=(g==null?void 0:g.id)||null,Nt=$a((Et=n.config)==null?void 0:Et.showBriefings,r),_e=hn(Y),Ye=pn();if(!h&&!U)return null;const fe=!U&&h&&!i,St=C&&fe;return/* @__PURE__ */e(Va,{width:M.width,hasOverflowMenu:fe,children:/* @__PURE__ */o("div",{ref:M.measure,className:"flex min-h-11 shrink-0 items-center gap-2 border-b px-3 py-1.5",role:"dashboard-controls",children:[/* @__PURE__ */o("div",{className:"flex min-w-[80px] flex-1 items-center gap-2",children:[_r&&!U&&/* @__PURE__ */e(In,{"aria-label":"Dashboard Hub",tooltip:"Dashboard Hub",onClick:Lr,className:"h-7 w-7 px-0",buttonProps:{size:"xs"},children:/* @__PURE__ */e(Ha,{className:"h-3.5 w-3.5"})}),!U&&h&&(w?/* @__PURE__ */e("div",{className:"h-4 w-28 animate-pulse rounded-md bg-muted/70","aria-label":"Loading dashboard title",role:"status",children:/* @__PURE__ */e("span",{className:"sr-only",children:"Loading dashboard title"})}):/* @__PURE__ */o("div",{className:"flex min-w-0 items-center gap-1",children:[/* @__PURE__ */e(ja,{value:wt||"Untitled Dashboard",onSave:d=>{console.log("EditableText onSave called:",{newTitle:d,canEditDashboard:p,dashboardId:g==null?void 0:g.id});const R=(g==null?void 0:g.title)||"";j(d),Nr(d,R);},isEditable:qa({isDashboardEditing:C,canEditDashboard:p===!0&&!i}),displayClassName:"text-[13px] font-medium",inputClassName:"text-[13px] font-medium",placeholder:"Dashboard Title",isPending:me.isPending}),!i&&Y&&/* @__PURE__ */e(fn,{dashboardId:Y}),s?/* @__PURE__ */e("div",{className:"flex min-w-[1.25rem] shrink-[2]",children:s}):null]}))]}),/* @__PURE__ */o("div",{className:"flex min-w-0 items-center gap-1.5",children:[/* @__PURE__ */o("div",{className:"-m-1 flex min-w-0 items-center gap-1.5 overflow-x-auto p-1 [scrollbar-width:thin] [&>*]:shrink-0",children:[U&&/* @__PURE__ */o(T,{children:[/* @__PURE__ */e(bn,{}),/* @__PURE__ */e(gn,{})]}),h&&!i&&/* @__PURE__ */e(Mn,{}),!U&&C&&!i&&x.canUseFilters&&h&&/* @__PURE__ */e(xn,{}),C&&!i&&h&&/* @__PURE__ */e(vn,{}),C&&!U&&!i&&h&&ke&&/* @__PURE__ */o("div",{className:"inline-flex h-7 items-stretch overflow-hidden rounded-control border border-input bg-background",children:[/* @__PURE__ */o($,{variant:"ghost",size:"xs",disabled:!C,onClick:()=>void yr(),"aria-label":M.width==="sm"?"Add visual":void 0,title:M.width==="sm"?"Add visual":void 0,className:ye("h-full rounded-none border-0 shadow-none hover:bg-accent",M.width==="sm"&&"w-7 px-0"),children:[/* @__PURE__ */e(te,{className:"h-3.5 w-3.5"}),M.width!=="sm"&&"Visual"]}),/* @__PURE__ */o(It,{modal:!1,children:[/* @__PURE__ */e(Mt,{asChild:!0,children:/* @__PURE__ */e($,{variant:"ghost",size:"xs",className:"h-full w-7 rounded-none border-0 border-l border-border/60 px-0 shadow-none hover:bg-accent","aria-label":"Open visual options",disabled:!C,children:/* @__PURE__ */e(oa,{className:"h-3.5 w-3.5"})})}),/* @__PURE__ */e(Lt,{align:"end",className:"z-[60] w-48 rounded-control border-border/60 p-1 shadow-sm",children:/* @__PURE__ */o(A,{onClick:()=>ht(!0),children:[/* @__PURE__ */e(te,{className:"h-3.5 w-3.5"}),"From library..."]})})]}),/* @__PURE__ */e(yn,{open:hr,onOpenChange:ht})]}),!i&&h&&/* @__PURE__ */e(wn,{}),!U&&!C&&(p||i)&&(!f||!y||p!==void 0)&&h&&/* @__PURE__ */o("div",{className:"inline-flex items-center gap-1",children:[/* @__PURE__ */o($,{size:"xs",onClick:kr,"aria-label":i?"Inspect":"Edit",title:M.width==="sm"?i?"Inspect":"Edit":void 0,className:M.width==="sm"?"w-7 px-0":void 0,children:[/* @__PURE__ */e(za,{className:"h-3.5 w-3.5"}),M.width!=="sm"&&(i?"Inspect":"Edit")]}),b?/* @__PURE__ */e(ia,{children:/* @__PURE__ */o(da,{children:[/* @__PURE__ */e(la,{asChild:!0,children:/* @__PURE__ */e("button",{type:"button","aria-label":b,className:"inline-flex size-6 items-center justify-center rounded-control text-muted-foreground outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",children:/* @__PURE__ */e(ca,{"aria-hidden":"true",className:"size-3.5"})})}),/* @__PURE__ */e(ua,{children:/* @__PURE__ */e("p",{children:b})})]})}):null]}),ze&&h&&We&&/* @__PURE__ */e(As,{saved:Qe,draft:g,enabled:C&&!i}),ze&&h&&We&&/* @__PURE__ */o($,{variant:"outline",size:"xs",onClick:Mr,disabled:Pe,"aria-label":"Undo",title:M.width==="sm"?"Undo":void 0,className:M.width==="sm"?"w-7 px-0":void 0,children:[/* @__PURE__ */e(Ka,{className:"h-3.5 w-3.5"}),M.width!=="sm"&&"Undo"]}),ze&&h&&/* @__PURE__ */o($,{size:"xs",className:ye(!yt&&"opacity-60"),disabled:Pe||!yt,onClick:()=>Je(),children:[Pe?/* @__PURE__ */e(Be,{className:"h-3.5 w-3.5 animate-spin"}):/* @__PURE__ */e(Nn,{className:"h-3.5 w-3.5"}),Pe?"Saving...":"Save"]}),C&&!U&&h&&/* @__PURE__ */o($,{variant:"outline",size:"xs",onClick:Er,"aria-label":"Close",title:M.width==="sm"?"Close":void 0,className:M.width==="sm"?"w-7 px-0":void 0,children:[/* @__PURE__ */e(ma,{className:"h-3.5 w-3.5"}),M.width!=="sm"&&"Close"]})]}),!U&&h&&/* @__PURE__ */o(T,{children:[/* @__PURE__ */e(Sn,{}),m&&p===!0&&!i&&/* @__PURE__ */e(Dn,{})]}),!U&&u&&M.width==="lg"&&/* @__PURE__ */e(zn,{}),fe&&/* @__PURE__ */e(Qa,{}),fe&&St&&/* @__PURE__ */e(kn,{}),fe&&/* @__PURE__ */o(It,{children:[/* @__PURE__ */e(Mt,{asChild:!0,children:/* @__PURE__ */e($,{variant:"ghost",size:"xs",className:"w-7 px-0","aria-label":"More dashboard options",children:/* @__PURE__ */e(Wa,{className:"h-3.5 w-3.5"})})}),/* @__PURE__ */o(Lt,{align:"end",className:"w-56 rounded-control border border-border/60 p-1 shadow-sm",children:[/* @__PURE__ */e(Is,{}),_e.available&&Pr&&/* @__PURE__ */o(T,{children:[/* @__PURE__ */o(A,{disabled:_e.disabled,onSelect:_e.toggle,children:[/* @__PURE__ */e(Ja,{className:"h-3.5 w-3.5"}),/* @__PURE__ */e("span",{className:"flex-1",children:"Default dashboard"}),_e.isDefault&&/* @__PURE__ */e(zt,{className:"h-3.5 w-3.5"})]}),/* @__PURE__ */e(ee,{})]}),/* @__PURE__ */e(be,{children:"Reports & briefings"}),/* @__PURE__ */o(A,{disabled:P,onSelect:()=>le(!0),children:[/* @__PURE__ */e(ha,{className:"h-3.5 w-3.5"}),"Export"]}),/* @__PURE__ */e(ks,{scheduleReportVisible:!!(Nt&&l.surfaceVisible&&Y&&!C),analyticalBriefingVisible:!!(Nt&&l.surfaceVisible&&Y&&!C),onScheduleReport:()=>de("scheduled_report"),onCreateAnalyticalBriefing:()=>de("analytical_briefing")}),C&&/* @__PURE__ */o(A,{onSelect:()=>oe(!0),children:[/* @__PURE__ */e(pa,{className:"h-3.5 w-3.5"}),"Download settings"]}),/* @__PURE__ */e(ee,{}),(J.showDashboardSharing||J.showGroupManagement)&&/* @__PURE__ */o(T,{children:[/* @__PURE__ */e(be,{children:"Access"}),J.showDashboardSharing&&/* @__PURE__ */o(A,{onSelect:()=>q(!0),children:[/* @__PURE__ */e(Ya,{className:"h-3.5 w-3.5"}),"Share"]}),J.showGroupManagement&&/* @__PURE__ */o(A,{onClick:()=>ne(!0),children:[/* @__PURE__ */e(Kt,{className:"h-3.5 w-3.5"}),"Manage Groups"]}),/* @__PURE__ */e(ee,{})]}),St&&/* @__PURE__ */o(T,{children:[/* @__PURE__ */e(be,{children:"Dashboard"}),/* @__PURE__ */o(A,{onSelect:Ye.open,children:[/* @__PURE__ */e(Ot,{className:"h-3.5 w-3.5"}),/* @__PURE__ */e("span",{className:"flex-1",children:Ye.label}),/* @__PURE__ */e("span",{className:"pl-4 text-[11px] tabular-nums text-muted-foreground",children:Ye.count})]}),/* @__PURE__ */o(A,{onSelect:gr,children:[/* @__PURE__ */e(fa,{className:"h-3.5 w-3.5"}),"Style"]}),/* @__PURE__ */e(ee,{})]}),/* @__PURE__ */e(be,{children:"Preferences"}),/* @__PURE__ */o(A,{onClick:()=>se(!0),children:[/* @__PURE__ */e(qt,{className:"h-3.5 w-3.5"}),"Report preferences"]}),u&&h&&/* @__PURE__ */o(T,{children:[/* @__PURE__ */e(ee,{}),/* @__PURE__ */e(be,{children:"Developer"}),/* @__PURE__ */o(A,{onSelect:()=>{var d;t!=null&&t.accessToken&&((d=navigator==null?void 0:navigator.clipboard)!=null&&d.writeText?navigator.clipboard.writeText(t.accessToken).then(()=>k.success("Token copied to clipboard")).catch(()=>k.error("Unable to copy token")):k.error("Clipboard not available"));},children:[/* @__PURE__ */e(Pt,{className:"h-3.5 w-3.5"}),"Copy token"]}),V&&/* @__PURE__ */o(A,{disabled:!qe,onSelect:()=>{var d;if(!qe){k.error("Open a document sheet with a token to copy the local PDF URL");return;}(d=navigator==null?void 0:navigator.clipboard)!=null&&d.writeText?navigator.clipboard.writeText(qe).then(()=>k.success("Local document PDF URL copied to clipboard")).catch(()=>k.error("Unable to copy local document PDF URL")):k.error("Clipboard not available");},children:[/* @__PURE__ */e(Pt,{className:"h-3.5 w-3.5"}),"Copy local document PDF URL"]}),/* @__PURE__ */o(A,{onSelect:()=>Cn(n.apiServiceUrl),children:[/* @__PURE__ */e(Gn,{className:"h-3.5 w-3.5"}),"Invalidate token"]}),/* @__PURE__ */o(A,{onSelect:c,children:[/* @__PURE__ */e(Bn,{className:"h-3.5 w-3.5"}),"Brand Studio"]}),C&&/* @__PURE__ */o(A,{onSelect:()=>bt(!pt),children:[/* @__PURE__ */e(Ot,{className:"h-3.5 w-3.5"}),pt?"Hide dashboard JSON":"Show dashboard JSON"]})]})]})]}),re&&xt&&/* @__PURE__ */e(Xa,{resource:xt,resourceType:Xe.DASHBOARD,onClose:()=>q(!1)}),J.showGroupManagement&&/* @__PURE__ */e(ps,{open:ae,onOpenChange:ne}),/* @__PURE__ */e(Ln,{open:Fe,onOpenChange:se}),/* @__PURE__ */e(Ns,{open:Ge,onOpenChange:oe}),Y&&(ie||Ce)?/* @__PURE__ */e(En,{dashboardId:Y,dashboardTitle:(g==null?void 0:g.title)||(G==null?void 0:G.title),open:!0,onOpenChange:d=>{d||(de(null),z(null));},hideTrigger:!0,workflowIntent:ie??void 0,openRun:Ce??void 0}):null,h&&/* @__PURE__ */e(Za,{open:F,onOpenChange:le}),/* @__PURE__ */e(en,{open:Ee,onOpenChange:d=>{!d&&Ve&&!Q||(K(d),d||(W(null),Ae([]),Ie(!1)));},children:/* @__PURE__ */o(tn,{className:"max-w-sm",children:[/* @__PURE__ */o(rn,{children:[/* @__PURE__ */e(an,{children:Q?"Save failed":"Saving dashboard"}),/* @__PURE__ */e(nn,{className:"pt-2",children:Q?"We could not save the dashboard. Please try again.":"Please wait while we save your changes."}),ut.length>0&&/* @__PURE__ */o("div",{className:"space-y-1 rounded-md border border-destructive/20 bg-destructive/5 p-3 text-left",children:[/* @__PURE__ */e("div",{className:"text-sm font-medium text-destructive",children:"What needs attention"}),/* @__PURE__ */e("ul",{className:"list-disc space-y-1 pl-4 text-xs text-muted-foreground",children:ut.slice(0,5).map(d=>/* @__PURE__ */e("li",{children:d},d))})]})]}),/* @__PURE__ */e(sn,{className:"flex-col gap-2 sm:flex-row sm:justify-end",children:Q?/* @__PURE__ */o(T,{children:[/* @__PURE__ */e(on,{onClick:()=>{K(!1),W(null),Ae([]),Ie(!1);},className:"m-0",children:"Close"}),/* @__PURE__ */e(_t,{onClick:()=>Je({closeAfterSave:mt,navigateHomeAfterSave:je==="home"}),className:"m-0",children:"Retry"})]}):/* @__PURE__ */o(_t,{disabled:!0,className:"m-0 cursor-default",children:[/* @__PURE__ */e(Be,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]})})]})}),/* @__PURE__ */e(An,{open:wr,onOpenChange:d=>{ue(d);},onSave:Ar,onDiscard:Ir,isSaving:Ve,saveLabel:"Save",discardLabel:"Discard changes"})]})]})});}function Is(){const t=dn();return t.length===0?null:/* @__PURE__ */o(T,{children:[t.map(n=>/* @__PURE__ */o(A,{onSelect:n.onSelect,children:[n.icon,/* @__PURE__ */e("span",{className:"flex-1",children:n.label}),n.hint&&/* @__PURE__ */e("span",{className:"text-[11px] text-muted-foreground",children:n.hint}),n.checked&&/* @__PURE__ */e(zt,{className:"h-3.5 w-3.5"})]},n.id)),/* @__PURE__ */e(ee,{})]});}function Ms({accessToken:t,dashboardId:n,selectedSheetId:a,pageSize:r,orientation:s,theme:l}){if(!t||!a)return null;const u=new URL("http://localhost:5173/print-document");u.searchParams.set("token",t),n&&u.searchParams.set("dashboardId",n),u.searchParams.set("selectedSheetId",a),l&&u.searchParams.set("theme",l);const m=new URL("http://127.0.0.1:3002/");return m.searchParams.set("pdfMode","document"),m.searchParams.set("pageSize",r||"letter"),m.searchParams.set("orientation",s||"portrait"),m.searchParams.set("url",u.toString()),m.toString();}export{Ys as default};
42
+ */var Ft;function jn(){return Ft||(Ft=1,process.env.NODE_ENV!=="production"&&function(){function t(c,x){return c===x&&(c!==0||1/c===1/x)||c!==c&&x!==x;}function n(c,x){b||s.startTransition===void 0||(b=!0,console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var h=x();if(!i){var w=x();l(h,w)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),i=!0);}w=u({inst:{value:h,getSnapshot:x}});var S=w[0].inst,P=w[1];return p(function(){S.value=h,S.getSnapshot=x,a(S)&&P({inst:S});},[c,h,x]),m(function(){return a(S)&&P({inst:S}),c(function(){a(S)&&P({inst:S});});},[c]),y(h),h;}function a(c){var x=c.getSnapshot;c=c.value;try{var h=x();return!l(c,h);}catch{return!0;}}function r(c,x){return x();}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var s=Jt,l=typeof Object.is=="function"?Object.is:t,u=s.useState,m=s.useEffect,p=s.useLayoutEffect,y=s.useDebugValue,b=!1,i=!1,f=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?r:n;rt.useSyncExternalStore=s.useSyncExternalStore!==void 0?s.useSyncExternalStore:f,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());}()),rt;}process.env.NODE_ENV==="production"?ot.exports=Hn():ot.exports=jn();var qn=ot.exports;const Be=["light","dark","system"];function zn(){const{theme:t,setTheme:n}=ba(),a=D(u=>u.actions.setDashboardTheme);function r(){const u=Be.includes(t)?t:"system",m=Be[(Be.indexOf(u)+1)%Be.length];n(m),a(m);}const s=t==="light"?Gn:t==="dark"?Fn:ga,l=t==="light"?"Theme: light (click for dark)":t==="dark"?"Theme: dark (click for system)":"Theme: system (click for light)";return/* @__PURE__ */e(V,{type:"button",variant:"ghost",size:"xs",className:"h-7 w-7 p-0",onClick:r,"aria-label":l,title:l,children:/* @__PURE__ */e(s,{className:"h-3.5 w-3.5",strokeWidth:1.5})});}function Kn(){const{displayPreferences:t,shouldShowElement:n}=$r(),{currentUser:a,userContext:r}=dt(),s=j(()=>xa(a),[a]),l=j(()=>m=>s&&s[m]!==void 0&&s[m]===!1?!1:n(m),[s,n,t]),u=j(()=>{var m,p,y,b,i;return{canEdit:((m=r==null?void 0:r.permissions)==null?void 0:m.canEdit)??Sa(a),canUseFilters:((p=r==null?void 0:r.permissions)==null?void 0:p.canEdit)??Na(a),canManageDashboards:((y=r==null?void 0:r.permissions)==null?void 0:y.canCreateDashboard)??wa(a),canCreateDashboards:((b=r==null?void 0:r.permissions)==null?void 0:b.canCreateDashboard)??ya(a),canAccessVisuals:((i=r==null?void 0:r.permissions)==null?void 0:i.canEdit)??va(a)};},[a,r]);return{displayPreferences:t,shouldShowElement:l,permissions:u,currentUser:a};}function Qn(t,n=[]){let a=[];function r(l,u){const m=E.createContext(u);m.displayName=l+"Context";const p=a.length;a=[...a,u];const y=i=>{var S;const{scope:f,children:c,...x}=i,h=((S=f==null?void 0:f[t])==null?void 0:S[p])||m,w=E.useMemo(()=>x,Object.values(x));return/* @__PURE__ */e(h.Provider,{value:w,children:c});};y.displayName=l+"Provider";function b(i,f){var h;const c=((h=f==null?void 0:f[t])==null?void 0:h[p])||m,x=E.useContext(c);if(x)return x;if(u!==void 0)return u;throw new Error(`\`${i}\` must be used within \`${l}\``);}return[y,b];}const s=()=>{const l=a.map(u=>E.createContext(u));return function(m){const p=(m==null?void 0:m[t])||l;return E.useMemo(()=>({[`__scope${t}`]:{...m,[t]:p}}),[m,p]);};};return s.scopeName=t,[r,Wn(s,...n)];}function Wn(...t){const n=t[0];if(t.length===1)return n;const a=()=>{const r=t.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(l){const u=r.reduce((m,{useScope:p,scopeName:y})=>{const i=p(l)[`__scope${y}`];return{...m,...i};},{});return E.useMemo(()=>({[`__scope${n.scopeName}`]:u}),[u]);};};return a.scopeName=n.scopeName,a;}var Jn=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],ct=Jn.reduce((t,n)=>{const a=Gr(`Primitive.${n}`),r=E.forwardRef((s,l)=>{const{asChild:u,...m}=s,p=u?a:n;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),/* @__PURE__ */e(p,{...m,ref:l});});return r.displayName=`Primitive.${n}`,{...t,[n]:r};},{});function Yn(){return qn.useSyncExternalStore(Xn,()=>!0,()=>!1);}function Xn(){return()=>{};}var ut="Avatar",[Zn]=Qn(ut),[es,tr]=Zn(ut),rr=E.forwardRef((t,n)=>{const{__scopeAvatar:a,...r}=t,[s,l]=E.useState("idle");return/* @__PURE__ */e(es,{scope:a,imageLoadingStatus:s,onImageLoadingStatusChange:l,children:/* @__PURE__ */e(ct.span,{...r,ref:n})});});rr.displayName=ut;var ar="AvatarImage",nr=E.forwardRef((t,n)=>{const{__scopeAvatar:a,src:r,onLoadingStatusChange:s=()=>{},...l}=t,u=tr(ar,a),m=ts(r,l),p=Vr(y=>{s(y),u.onImageLoadingStatusChange(y);});return at(()=>{m!=="idle"&&p(m);},[m,p]),m==="loaded"?/* @__PURE__ */e(ct.img,{...l,ref:n,src:r}):null;});nr.displayName=ar;var sr="AvatarFallback",or=E.forwardRef((t,n)=>{const{__scopeAvatar:a,delayMs:r,...s}=t,l=tr(sr,a),[u,m]=E.useState(r===void 0);return E.useEffect(()=>{if(r!==void 0){const p=window.setTimeout(()=>m(!0),r);return()=>window.clearTimeout(p);}},[r]),u&&l.imageLoadingStatus!=="loaded"?/* @__PURE__ */e(ct.span,{...s,ref:n}):null;});or.displayName=sr;function $t(t,n){return t?n?(t.src!==n&&(t.src=n),t.complete&&t.naturalWidth>0?"loaded":"loading"):"error":"idle";}function ts(t,{referrerPolicy:n,crossOrigin:a}){const r=Yn(),s=E.useRef(null),l=r?(s.current||(s.current=new window.Image()),s.current):null,[u,m]=E.useState(()=>$t(l,t));return at(()=>{m($t(l,t));},[l,t]),at(()=>{const p=i=>()=>{m(i);};if(!l)return;const y=p("loaded"),b=p("error");return l.addEventListener("load",y),l.addEventListener("error",b),n&&(l.referrerPolicy=n),typeof a=="string"&&(l.crossOrigin=a),()=>{l.removeEventListener("load",y),l.removeEventListener("error",b);};},[l,a,n]),u;}var ir=rr,dr=nr,lr=or;const cr=E.forwardRef(({className:t,...n},a)=>/* @__PURE__ */e(ir,{ref:a,className:Ne("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",t),...n}));cr.displayName=ir.displayName;const rs=E.forwardRef(({className:t,...n},a)=>/* @__PURE__ */e(dr,{ref:a,className:Ne("aspect-square h-full w-full",t),...n}));rs.displayName=dr.displayName;const ur=E.forwardRef(({className:t,...n},a)=>/* @__PURE__ */e(lr,{ref:a,className:Ne("flex h-full w-full items-center justify-center rounded-full bg-muted",t),...n}));ur.displayName=lr.displayName;const as=async(t,n,a)=>{const r=`${t}/management/v1/groups`;return await Yt(r,n,a);},ns=async(t,n,a,r)=>{const s=`${t}/management/v1/groups/${a}`;return lt(s,n,"PATCH",r);},ss=async(t,n,a)=>{const r=`${t}/management/v1/groups/${a}`;await lt(r,n,"DELETE");},os=async(t,n,a,r)=>{const s=`${t}/management/v1/groups/${a}/members`;return await Yt(s,n,r);},is=async(t,n,a,r)=>{const s=`${t}/management/v1/groups/${a}/members`;await lt(s,n,"DELETE",r);};function ds(){const{authToken:t,tokenProps:n}=Z(),a=De();return ke({mutationFn:r=>as(n.apiServiceUrl,(t==null?void 0:t.accessToken)||"",r),onSuccess:()=>{a.invalidateQueries({queryKey:["groups"]}),k.success("Group created successfully");},onError:r=>{console.error("Failed to create group:",r),k.error("Failed to create group",{description:Ce(r,"Failed to create group")});}});}function ls(){const{authToken:t,tokenProps:n}=Z(),a=De();return ke({mutationFn:({groupId:r,data:s})=>ns(n.apiServiceUrl,(t==null?void 0:t.accessToken)||"",r,s),onSuccess:(r,s)=>{a.invalidateQueries({queryKey:["group",s.groupId]}),a.invalidateQueries({queryKey:["groups"]}),k.success("Group updated successfully");},onError:r=>{console.error("Failed to update group:",r),k.error("Failed to update group",{description:Ce(r,"Failed to update group")});}});}function cs(){const{authToken:t,tokenProps:n}=Z(),a=De();return ke({mutationFn:r=>ss(n.apiServiceUrl,(t==null?void 0:t.accessToken)||"",r),onSuccess:(r,s)=>{a.invalidateQueries({queryKey:["groups"]}),a.removeQueries({queryKey:["group",s]}),k.success("Group deleted successfully");},onError:r=>{console.error("Failed to delete group:",r),k.error("Failed to delete group",{description:Ce(r,"Failed to delete group")});}});}function us(){const{authToken:t,tokenProps:n}=Z(),a=De();return ke({mutationFn:({groupId:r,data:s})=>os(n.apiServiceUrl,(t==null?void 0:t.accessToken)||"",r,s),onSuccess:(r,s)=>{a.invalidateQueries({queryKey:["group",s.groupId]}),a.invalidateQueries({queryKey:["group-members",s.groupId]}),a.invalidateQueries({queryKey:["groups"]}),k.success("Members added successfully");},onError:r=>{console.error("Failed to add group members:",r),k.error("Failed to add members",{description:Ce(r,"Failed to add members")});}});}function ms(){const{authToken:t,tokenProps:n}=Z(),a=De();return ke({mutationFn:({groupId:r,data:s})=>is(n.apiServiceUrl,(t==null?void 0:t.accessToken)||"",r,s),onSuccess:(r,s)=>{a.invalidateQueries({queryKey:["group",s.groupId]}),a.invalidateQueries({queryKey:["group-members",s.groupId]}),a.invalidateQueries({queryKey:["groups"]}),k.success("Members removed successfully");},onError:r=>{console.error("Failed to remove group members:",r),k.error("Failed to remove members",{description:Ce(r,"Failed to remove members")});}});}const hs=[];function ps({open:t,onOpenChange:n}){var P,g,B;const{tokenProps:a}=Z(),{currentUser:r}=dt(),s=(r==null?void 0:r.type)==="tenant",l=a==null?void 0:a.tenantId,{groups:u,isLoading:m,error:p,refetch:y}=Da({type:s?"TENANT_GROUP":"all",tenantId:s?l:void 0,includeMembers:!1}),b=p?mr(p,"Unable to load groups."):null,[i,f]=N({kind:"list"}),[c,x]=N(null),h=cs();we(()=>{t||(f({kind:"list"}),x(null));},[t]);const w=i.kind==="members"&&u.find(L=>L.id===i.groupId)||null,S=async()=>{if(c)try{await h.mutateAsync(c.id),x(null),f({kind:"list"}),y();}catch{}};return/* @__PURE__ */e(Ht,{open:t,onOpenChange:n,children:/* @__PURE__ */o(jt,{className:"flex max-h-[640px] w-[720px] max-w-[92vw] flex-col gap-0 overflow-hidden p-0",children:[i.kind==="list"?/* @__PURE__ */o("div",{className:"shrink-0 border-b border-border px-5 pt-4 pb-3.5",children:[/* @__PURE__ */e(nt,{className:"text-[15px] font-semibold tracking-tight",children:"Group management"}),/* @__PURE__ */e(st,{className:"mt-1 text-[12px] leading-[1.5] text-muted-foreground",children:"Organize people into groups for shared access."})]}):i.kind==="create"?/* @__PURE__ */o("div",{className:"flex h-10 shrink-0 items-center gap-1.5 border-b border-border px-5",children:[/* @__PURE__ */e("button",{type:"button",onClick:()=>f({kind:"list"}),"aria-label":"Back",className:"-ml-1 flex h-6 w-6 items-center justify-center rounded-[3px] text-muted-foreground hover:bg-accent hover:text-foreground",children:/* @__PURE__ */e(qt,{className:"h-3.5 w-3.5"})}),/* @__PURE__ */e(nt,{className:"truncate text-[13px] font-medium",children:"New group"}),/* @__PURE__ */e(st,{className:"sr-only",children:"Create a new group to organize members."})]}):null,i.kind==="list"&&/* @__PURE__ */e(fs,{groups:u,isLoading:m,errorMessage:b,onRetry:()=>y(),currentUserId:r==null?void 0:r.id,onOpenGroup:L=>f({kind:"members",groupId:L}),onCreate:()=>f({kind:"create"}),onDeleteRequest:L=>x(L)}),i.kind==="members"&&w&&/* @__PURE__ */e(xs,{group:w,isTenantViewer:s,canEdit:((P=w.permissions)==null?void 0:P.canEdit)??w.createdBy===(r==null?void 0:r.id),canDelete:((g=w.permissions)==null?void 0:g.canDelete)??w.createdBy===(r==null?void 0:r.id),canManageMembers:((B=w.permissions)==null?void 0:B.canManageMembers)??w.createdBy===(r==null?void 0:r.id),onBack:()=>f({kind:"list"}),onMembersChanged:y,onUpdated:y,onRequestDelete:()=>x(w)},w.id),i.kind==="create"&&/* @__PURE__ */e(vs,{isTenantUser:s,tenantId:l,onCancel:()=>f({kind:"list"}),onCreated:L=>{y(),f({kind:"members",groupId:L});}}),c&&/* @__PURE__ */o("div",{className:"flex shrink-0 items-center justify-between gap-3 border-t border-border bg-muted/40 px-5 py-2.5",children:[/* @__PURE__ */o("div",{className:"min-w-0 text-[12px] text-foreground",children:["Delete ",/* @__PURE__ */e("span",{className:"font-medium",children:c.name}),"?",/* @__PURE__ */e("span",{className:"ml-2 text-muted-foreground",children:"Members lose any access granted via this group."})]}),/* @__PURE__ */o("div",{className:"flex shrink-0 items-center gap-1.5",children:[/* @__PURE__ */e("button",{type:"button",onClick:()=>x(null),disabled:h.isPending,className:"h-7 rounded-[5px] px-2.5 text-[12px] font-medium text-foreground/80 hover:bg-background",children:"Cancel"}),/* @__PURE__ */o("button",{type:"button",onClick:S,disabled:h.isPending,className:"inline-flex h-7 items-center gap-1.5 rounded-[5px] bg-rose-600 px-2.5 text-[12px] font-medium text-white hover:bg-rose-700 disabled:opacity-60",children:[h.isPending?/* @__PURE__ */e(Fe,{className:"h-3 w-3 animate-spin"}):/* @__PURE__ */e(it,{className:"h-3 w-3"}),"Delete group"]})]})]})]})});}function fs({groups:t,isLoading:n,errorMessage:a,onRetry:r,currentUserId:s,onOpenGroup:l,onCreate:u,onDeleteRequest:m}){const[p,y]=N(""),b=j(()=>t.filter(i=>!p.trim()||i.name.toLowerCase().includes(p.toLowerCase())||(i.description||"").toLowerCase().includes(p.toLowerCase())),[t,p]);return/* @__PURE__ */o("div",{className:"flex flex-1 flex-col overflow-hidden",children:[/* @__PURE__ */o("div",{className:"flex shrink-0 items-center gap-2 border-b border-border px-5 py-2.5",children:[/* @__PURE__ */o("div",{className:"flex flex-1 items-center gap-2 rounded-[5px] border border-border bg-background px-2 focus-within:border-foreground/40",children:[/* @__PURE__ */e(Hr,{className:"h-3 w-3 text-muted-foreground"}),/* @__PURE__ */e("input",{value:p,onChange:i=>y(i.target.value),placeholder:"Search groups…",className:"h-7 flex-1 bg-transparent text-[12px] text-foreground placeholder:text-muted-foreground focus:outline-none"}),p&&/* @__PURE__ */e("button",{type:"button",onClick:()=>y(""),className:"flex h-4 w-4 items-center justify-center rounded-[3px] text-muted-foreground hover:bg-accent hover:text-foreground",children:/* @__PURE__ */e(zt,{className:"h-2.5 w-2.5"})})]}),/* @__PURE__ */o("button",{type:"button",onClick:u,className:"inline-flex h-7 items-center gap-1.5 rounded-[5px] bg-foreground px-2.5 text-[12px] font-medium text-background hover:opacity-90",children:[/* @__PURE__ */e(re,{className:"h-3 w-3"}),"New group"]})]}),/* @__PURE__ */e("div",{className:"flex-1 overflow-y-auto",children:n?/* @__PURE__ */e("div",{className:"space-y-px p-3",children:[1,2,3].map(i=>/* @__PURE__ */e("div",{className:"h-12 animate-pulse rounded-[4px] bg-muted/60"},i))}):a?/* @__PURE__ */e(hr,{title:"Can't load groups",message:a,onRetry:r}):b.length===0&&t.length===0?/* @__PURE__ */e(gs,{onCreate:u}):b.length===0?/* @__PURE__ */o("div",{className:"flex h-full flex-col items-center justify-center gap-1 py-10 text-center",children:[/* @__PURE__ */o("div",{className:"text-[12px] text-foreground",children:['No groups match "',p,'"']}),/* @__PURE__ */e("div",{className:"text-[11px] text-muted-foreground",children:"Try a different search."})]}):b.map(i=>{var f;return/* @__PURE__ */e(bs,{group:i,canDelete:((f=i.permissions)==null?void 0:f.canDelete)??i.createdBy===s,onClick:()=>l(i.id),onDelete:()=>m(i)},i.id);})})]});}function bs({group:t,canDelete:n,onClick:a,onDelete:r}){let s="";try{s=Xt(new Date(t.createdAt),"MMM d, yyyy");}catch{s="";}return/* @__PURE__ */o("button",{type:"button",onClick:a,className:"group flex w-full items-center gap-3 border-b border-border/60 px-5 py-2.5 text-left hover:bg-accent/40",children:[/* @__PURE__ */e("div",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-[4px] border border-border bg-background text-muted-foreground",children:/* @__PURE__ */e(Ea,{className:"h-3.5 w-3.5"})}),/* @__PURE__ */o("div",{className:"min-w-0 flex-1",children:[/* @__PURE__ */e("div",{className:"truncate text-[13px] font-medium text-foreground",children:t.name}),/* @__PURE__ */o("div",{className:"mt-0.5 flex items-center gap-2 text-[11px] text-muted-foreground",children:[/* @__PURE__ */o("span",{className:"inline-flex items-center gap-1",children:[/* @__PURE__ */e(er,{className:"h-2.5 w-2.5"}),t.memberCount," member",t.memberCount===1?"":"s"]}),s&&/* @__PURE__ */o(T,{children:[/* @__PURE__ */e("span",{className:"text-border",children:"·"}),/* @__PURE__ */o("span",{className:"inline-flex items-center gap-1",children:[/* @__PURE__ */e(Kt,{className:"h-2.5 w-2.5"}),s]})]}),t.description&&/* @__PURE__ */o(T,{children:[/* @__PURE__ */e("span",{className:"text-border",children:"·"}),/* @__PURE__ */e("span",{className:"truncate text-muted-foreground",children:t.description})]})]})]}),/* @__PURE__ */o("div",{className:"flex items-center gap-0.5 opacity-0 transition-opacity group-hover:opacity-100",children:[n&&/* @__PURE__ */e("span",{role:"button",tabIndex:0,onClick:l=>{l.stopPropagation(),r();},onKeyDown:l=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),l.stopPropagation(),r());},"aria-label":`Delete ${t.name}`,className:"flex h-6 w-6 items-center justify-center rounded-[3px] text-muted-foreground hover:bg-accent hover:text-foreground",children:/* @__PURE__ */e(it,{className:"h-3 w-3"})}),/* @__PURE__ */e(jr,{className:"h-3.5 w-3.5 text-muted-foreground"})]})]});}function gs({onCreate:t}){return/* @__PURE__ */o("div",{className:"flex h-full flex-col items-center justify-center gap-2 py-12 text-center",children:[/* @__PURE__ */e("div",{className:"flex h-9 w-9 items-center justify-center rounded-full border border-border bg-muted/40 text-muted-foreground",children:/* @__PURE__ */e(Wt,{className:"h-4 w-4"})}),/* @__PURE__ */e("div",{className:"text-[13px] font-medium text-foreground",children:"No groups yet"}),/* @__PURE__ */e("div",{className:"max-w-[320px] text-[11.5px] leading-[1.55] text-muted-foreground",children:"Groups let you grant shared access to dashboards. Create one and add members."}),/* @__PURE__ */o("button",{type:"button",onClick:t,className:"mt-1 inline-flex h-7 items-center gap-1.5 rounded-[5px] bg-foreground px-2.5 text-[12px] font-medium text-background hover:opacity-90",children:[/* @__PURE__ */e(re,{className:"h-3 w-3"}),"New group"]})]});}function xs({group:t,isTenantViewer:n,canEdit:a,canDelete:r,canManageMembers:s,onBack:l,onMembersChanged:u,onUpdated:m,onRequestDelete:p}){const{data:y,isLoading:b,error:i,refetch:f}=ka(t.id),c=(y==null?void 0:y.members)??hs,x=i?mr(i,"Unable to load members for this group."):null,h=t.type==="TENANT_GROUP"?"tenant":"organization",{users:w}=Ca({type:h,tenantId:t.tenantId||void 0,active:!0,limit:200}),S=j(()=>new Set(c.map(v=>v.userId)),[c]),P=us(),g=ms(),B=ls(),[L,H]=N(!1),[Ee,I]=N(t.name),[C,q]=N(!1),[ae,z]=N(t.description||""),[ne,se]=N(""),[Ge,oe]=N(!1),Ve=j(()=>{const v=ne.trim().toLowerCase();return w.filter(F=>!S.has(F.id)).filter(F=>!v||(F.name||"").toLowerCase().includes(v)||(F.email||"").toLowerCase().includes(v)).slice(0,50);},[w,S,ne]),ie=async()=>{const v=Ee.trim();if(H(!1),v.length>=3&&v!==t.name)try{await B.mutateAsync({groupId:t.id,data:{name:v}}),m();}catch{}},de=async()=>{const v=ae.trim();if(q(!1),v!==(t.description||""))try{await B.mutateAsync({groupId:t.id,data:{description:v}}),m();}catch{}},le=async v=>{if(s){se(""),oe(!1);try{await P.mutateAsync({groupId:t.id,data:{userIds:[v.id],userType:h==="tenant"?"tenant":"org"}}),f(),u();}catch{}}},Ae=async v=>{if(s)try{await g.mutateAsync({groupId:t.id,data:{userIds:[v]}}),f(),u();}catch{}};let K="";try{K=Xt(new Date(t.createdAt),"MMM d, yyyy");}catch{K="";}return/* @__PURE__ */o("div",{className:"flex flex-1 flex-col overflow-hidden",children:[/* @__PURE__ */o("div",{className:"flex h-10 shrink-0 items-center gap-1.5 border-b border-border px-5",children:[/* @__PURE__ */e("button",{type:"button",onClick:l,"aria-label":"Back",className:"-ml-1 flex h-6 w-6 items-center justify-center rounded-[3px] text-muted-foreground hover:bg-accent hover:text-foreground",children:/* @__PURE__ */e(qt,{className:"h-3.5 w-3.5"})}),L?/* @__PURE__ */e("input",{autoFocus:!0,value:Ee,onChange:v=>I(v.target.value),onBlur:ie,onKeyDown:v=>{v.key==="Enter"&&ie(),v.key==="Escape"&&(I(t.name),H(!1));},className:"h-6 min-w-0 flex-1 rounded-[3px] border border-border bg-background px-1.5 text-[13px] font-medium text-foreground focus:border-foreground/40 focus:outline-none"}):/* @__PURE__ */e("button",{type:"button",onClick:()=>{a&&(I(t.name),H(!0));},title:a?"Click to rename":t.name,disabled:!a,className:"truncate rounded-[3px] px-1 text-[13px] font-medium text-foreground enabled:hover:bg-accent disabled:cursor-default",children:t.name}),/* @__PURE__ */o("span",{className:"ml-1 inline-flex shrink-0 items-center gap-1 text-[10.5px] text-muted-foreground",children:[/* @__PURE__ */e(er,{className:"h-2.5 w-2.5"}),c.length," member",c.length===1?"":"s"]})]}),/* @__PURE__ */e("div",{className:"shrink-0 border-b border-border px-5 py-2.5",children:C?/* @__PURE__ */o("div",{children:[/* @__PURE__ */e("textarea",{autoFocus:!0,rows:2,value:ae,onChange:v=>z(v.target.value),maxLength:200,onKeyDown:v=>{v.key==="Escape"&&(z(t.description||""),q(!1)),v.key==="Enter"&&(v.metaKey||v.ctrlKey)&&de();},placeholder:"What is this group for?",className:"block w-full resize-none rounded-[5px] border border-border bg-background px-2 py-1.5 text-[12px] text-foreground placeholder:text-muted-foreground focus:border-foreground/40 focus:outline-none"}),/* @__PURE__ */o("div",{className:"mt-1.5 flex items-center justify-between",children:[/* @__PURE__ */o("span",{className:"text-[10.5px] text-muted-foreground",children:[ae.length,"/200 · Esc to cancel · ⌘↩ to save"]}),/* @__PURE__ */o("div",{className:"flex items-center gap-1.5",children:[/* @__PURE__ */e("button",{type:"button",onClick:()=>{z(t.description||""),q(!1);},className:"h-6 rounded-[5px] px-2 text-[11px] font-medium text-foreground/80 hover:bg-accent",children:"Cancel"}),/* @__PURE__ */e("button",{type:"button",onClick:de,className:"inline-flex h-6 items-center rounded-[5px] bg-foreground px-2 text-[11px] font-medium text-background hover:opacity-90",children:"Save"})]})]})]}):/* @__PURE__ */o("button",{type:"button",onClick:()=>{a&&(z(t.description||""),q(!0));},disabled:!a,title:a?"Click to edit description":void 0,className:"block w-full rounded-[3px] px-1 py-0.5 text-left enabled:hover:bg-accent/40 disabled:cursor-default",children:[t.description?/* @__PURE__ */e("p",{className:"text-[12px] leading-[1.55] text-foreground/90",children:t.description}):/* @__PURE__ */e("p",{className:"text-[12px] leading-[1.55] text-muted-foreground",children:a?"Add a description…":"No description"}),/* @__PURE__ */o("p",{className:"mt-1 text-[10.5px] text-muted-foreground",children:[K?`Created ${K}`:"Recently created",a?" · You can edit this group":""]})]})}),s&&/* @__PURE__ */e(ys,{query:ne,setQuery:se,open:Ge,setOpen:oe,candidates:Ve,showKindChip:!n,onAdd:le,busy:P.isPending}),/* @__PURE__ */e("div",{className:"flex-1 overflow-y-auto",children:b?/* @__PURE__ */e("div",{className:"space-y-px p-3",children:[1,2,3].map(v=>/* @__PURE__ */e("div",{className:"h-10 animate-pulse rounded-[4px] bg-muted/60"},v))}):x?/* @__PURE__ */e(hr,{title:"Can't load members",message:x,onRetry:()=>f()}):c.length===0?/* @__PURE__ */o("div",{className:"flex h-full flex-col items-center justify-center gap-1 py-10 text-center",children:[/* @__PURE__ */e("div",{className:"text-[12px] text-foreground",children:"No members yet"}),/* @__PURE__ */e("div",{className:"text-[11px] text-muted-foreground",children:s?"Search above to add people to this group.":"This group does not have any members."})]}):c.map(v=>{var F,ce,Ie,Q,W,J;return/* @__PURE__ */o("div",{className:"group flex items-center gap-2 border-b border-border/60 px-5 py-2",children:[/* @__PURE__ */e(pr,{name:((F=v.user)==null?void 0:F.name)||((ce=v.user)==null?void 0:ce.email)||"?"}),/* @__PURE__ */o("div",{className:"min-w-0 flex-1",children:[/* @__PURE__ */e("div",{className:"truncate text-[12.5px] font-medium text-foreground",children:((Ie=v.user)==null?void 0:Ie.name)||((Q=v.user)==null?void 0:Q.email)||"Unknown"}),((W=v.user)==null?void 0:W.email)&&v.user.name&&/* @__PURE__ */e("div",{className:"truncate text-[10.5px] text-muted-foreground",children:v.user.email})]}),!n&&/* @__PURE__ */e("span",{className:"text-[10px] uppercase tracking-[0.06em] text-muted-foreground",children:v.userType}),/* @__PURE__ */e("button",{type:"button",onClick:()=>Ae(v.userId),disabled:!s||g.isPending,"aria-label":`Remove ${((J=v.user)==null?void 0:J.name)||"member"}`,className:"flex h-6 w-6 items-center justify-center rounded-[3px] text-muted-foreground opacity-0 transition-opacity hover:bg-accent hover:text-foreground group-hover:opacity-100 disabled:opacity-30",children:/* @__PURE__ */e(zt,{className:"h-3 w-3"})})]},v.id);})}),r&&/* @__PURE__ */e("div",{className:"flex shrink-0 items-center justify-end gap-1.5 border-t border-border bg-muted/30 px-5 py-2.5",children:/* @__PURE__ */o("button",{type:"button",onClick:p,className:"inline-flex h-7 items-center gap-1.5 rounded-[5px] border border-rose-200 bg-background px-2.5 text-[12px] font-medium text-rose-600 hover:bg-rose-50 dark:border-rose-900/60 dark:text-rose-400 dark:hover:bg-rose-950/30",children:[/* @__PURE__ */e(it,{className:"h-3 w-3"}),"Delete group"]})})]});}function vs({isTenantUser:t,tenantId:n,onCancel:a,onCreated:r}){const[s,l]=N(""),[u,m]=N(""),[p,y]=N(null),b=ds(),i=s.trim().length>=3&&s.trim().length<=50,f=async()=>{if(!i)return;y(null);const c={name:s.trim(),description:u.trim()||void 0,type:t?"TENANT_GROUP":"ORG_GROUP",...(t&&n?{tenantId:n}:{})};try{const x=await b.mutateAsync(c),h=x==null?void 0:x.id;h?r(h):a();}catch(x){y(x instanceof Error?x.message:"Failed to create group");}};return/* @__PURE__ */o("div",{className:"flex flex-1 flex-col overflow-hidden",children:[/* @__PURE__ */o("div",{className:"flex-1 overflow-y-auto px-5 py-4",children:[/* @__PURE__ */e(Gt,{children:"Name"}),/* @__PURE__ */e("input",{autoFocus:!0,value:s,onChange:c=>l(c.target.value),placeholder:"Marketing leads, North America sales, …",maxLength:50,className:"mt-1 block h-7 w-full rounded-[5px] border border-border bg-background px-2 text-[12px] text-foreground placeholder:text-muted-foreground focus:border-foreground/40 focus:outline-none"}),/* @__PURE__ */e("div",{className:"mt-1 text-[10.5px] text-muted-foreground",children:"3–50 characters."}),/* @__PURE__ */o("div",{className:"mt-4",children:[/* @__PURE__ */e(Gt,{children:"Description (optional)"}),/* @__PURE__ */e("textarea",{rows:2,value:u,onChange:c=>m(c.target.value),maxLength:200,placeholder:"What is this group for?",className:"mt-1 block w-full resize-none rounded-[5px] border border-border bg-background px-2 py-1.5 text-[12px] text-foreground placeholder:text-muted-foreground focus:border-foreground/40 focus:outline-none"}),/* @__PURE__ */o("div",{className:"mt-1 flex justify-end text-[10.5px] text-muted-foreground",children:[u.length,"/200"]})]}),p&&/* @__PURE__ */e("div",{className:"mt-3 rounded-[5px] border border-rose-200 bg-rose-50 px-2 py-1.5 text-[11.5px] text-rose-700 dark:border-rose-900/60 dark:bg-rose-950/30 dark:text-rose-300",children:p})]}),/* @__PURE__ */o("div",{className:"flex shrink-0 items-center justify-end gap-1.5 border-t border-border bg-muted/30 px-5 py-2.5",children:[/* @__PURE__ */e("button",{type:"button",onClick:a,disabled:b.isPending,className:"h-7 rounded-[5px] px-2.5 text-[12px] font-medium text-foreground/80 hover:bg-accent",children:"Cancel"}),/* @__PURE__ */e("button",{type:"button",onClick:f,disabled:!i||b.isPending,className:"inline-flex h-7 items-center gap-1.5 rounded-[5px] bg-foreground px-2.5 text-[12px] font-medium text-background hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-60",children:b.isPending?/* @__PURE__ */o(T,{children:[/* @__PURE__ */e(Fe,{className:"h-3 w-3 animate-spin"}),"Creating…"]}):/* @__PURE__ */o(T,{children:[/* @__PURE__ */e(re,{className:"h-3 w-3"}),"Create group"]})})]})]});}function ys({query:t,setQuery:n,open:a,setOpen:r,candidates:s,showKindChip:l,onAdd:u,busy:m}){const p=Ut(null),y=Ut(null),[b,i]=N(null);cn(()=>{if(!a){i(null);return;}const c=()=>{const x=p.current;if(!x)return;const h=x.getBoundingClientRect(),w=240,P=window.innerHeight-h.bottom<w+16&&h.top>w;i({left:h.left,top:P?h.top-6:h.bottom+6,width:h.width,above:P});};return c(),window.addEventListener("resize",c),window.addEventListener("scroll",c,!0),()=>{window.removeEventListener("resize",c),window.removeEventListener("scroll",c,!0);};},[a,s.length]),we(()=>{if(!a)return;const c=x=>{var w,S;const h=x.target;(w=p.current)!=null&&w.contains(h)||(S=y.current)!=null&&S.contains(h)||r(!1);};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c);},[a,r]);const f=a&&s.length>0&&b;return/* @__PURE__ */o("div",{className:"shrink-0 border-b border-border px-5 py-2.5",children:[/* @__PURE__ */o("div",{ref:p,className:"flex items-center gap-2 rounded-[5px] border border-border bg-background px-2 focus-within:border-foreground/40",children:[/* @__PURE__ */e(Vn,{className:"h-3 w-3 text-muted-foreground"}),/* @__PURE__ */e("input",{value:t,onChange:c=>{n(c.target.value),r(!0);},onFocus:()=>r(!0),placeholder:"Add a member by name or email…",disabled:m,className:"h-7 flex-1 bg-transparent text-[12px] text-foreground placeholder:text-muted-foreground focus:outline-none disabled:cursor-not-allowed"})]}),f&&typeof document<"u"&&On(/* @__PURE__ */e("div",{ref:y,style:{position:"fixed",left:b.left,top:b.top,width:b.width,transform:b.above?"translateY(-100%)":void 0},className:"z-[60] max-h-[240px] overflow-y-auto rounded-[5px] border border-border bg-background shadow-[0_8px_24px_-12px_rgba(0,0,0,0.18)]",children:s.map(c=>/* @__PURE__ */o("button",{type:"button",onClick:()=>u(c),className:"flex w-full items-center gap-2 border-b border-border/60 px-2.5 py-2 text-left last:border-b-0 hover:bg-accent",children:[/* @__PURE__ */e(pr,{name:c.name||c.email||"?"}),/* @__PURE__ */o("div",{className:"min-w-0 flex-1",children:[/* @__PURE__ */e("div",{className:"truncate text-[12px] font-medium text-foreground",children:c.name||c.email||"Unknown"}),c.email&&c.name&&/* @__PURE__ */e("div",{className:"truncate text-[10.5px] text-muted-foreground",children:c.email})]}),l&&c.type&&/* @__PURE__ */e("span",{className:"text-[10px] uppercase tracking-[0.06em] text-muted-foreground",children:c.type==="tenant"?"tenant":"org"})]},c.id))}),document.body)]});}function mr(t,n){if(!t)return n;if(t instanceof Error){const a=t.message||"",r=a.match(/\{[\s\S]*"error"\s*:\s*"([^"]+)"[\s\S]*\}/);return r?r[1]:a||n;}return typeof t=="string"?t:n;}function hr({title:t,message:n,onRetry:a}){return/* @__PURE__ */o("div",{className:"flex h-full flex-col items-center justify-center gap-2 px-6 py-10 text-center",children:[/* @__PURE__ */e("div",{className:"text-[12.5px] font-medium text-foreground",children:t}),/* @__PURE__ */e("div",{className:"max-w-[360px] text-[11.5px] leading-[1.55] text-muted-foreground",children:n}),a&&/* @__PURE__ */e("button",{type:"button",onClick:a,className:"mt-1 inline-flex h-7 items-center rounded-[5px] border border-border bg-background px-2.5 text-[11.5px] font-medium text-foreground hover:bg-accent",children:"Try again"})]});}function Gt({children:t}){return/* @__PURE__ */e("label",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:t});}function pr({name:t}){const n=t.split(" ").map(a=>a[0]).filter(Boolean).slice(0,2).join("").toUpperCase();return/* @__PURE__ */e(cr,{className:"h-6 w-6 shrink-0",children:/* @__PURE__ */e(ur,{className:"text-[9px] font-semibold",children:n||"?"})});}const ws="text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground";function Ns({open:t,onOpenChange:n}){const a=D(s=>{var l,u;return Pn({dashboardDefault:(u=(l=s.dashboard)==null?void 0:l.exportDefaults)==null?void 0:u.csvEncoding});}),{setDashboardExportDefaults:r}=D(s=>s.actions);return/* @__PURE__ */e(Ht,{open:t,onOpenChange:n,children:/* @__PURE__ */o(jt,{className:"rounded-control border-border/60 sm:max-w-[440px] sm:rounded-control",children:[/* @__PURE__ */o(qr,{children:[/* @__PURE__ */e(nt,{className:"text-[15px]",children:"Download settings"}),/* @__PURE__ */e(st,{className:"text-[13px] leading-5",children:"Applies to every CSV downloaded or delivered from this dashboard. People can still change it for a single download."})]}),/* @__PURE__ */o("div",{className:"space-y-2",children:[/* @__PURE__ */e(zr,{htmlFor:"dashboard-csv-encoding",className:ws,children:"CSV encoding"}),/* @__PURE__ */o(Kr,{value:a,onValueChange:s=>r({csvEncoding:s}),children:[/* @__PURE__ */e(Qr,{id:"dashboard-csv-encoding",size:"sm",children:/* @__PURE__ */e(Wr,{})}),/* @__PURE__ */e(Jr,{children:Yr.map(s=>/* @__PURE__ */e(Xr,{value:s.value,children:s.label},s.value))})]})]})]})});}function ve(t,n,a){var l,u;const r=(t.controls||[]).find(m=>m.id===a);if(r)return r.label;const s=(u=(l=Zt(t,n))==null?void 0:l.controls)==null?void 0:u.find(m=>m.id===a);return(s==null?void 0:s.label)||a;}function ye(t,n){var a;return((a=Zt(t,n))==null?void 0:a.title)||n;}function Ss(t){const{errors:n,dashboard:a}=t;if(!a)return n;const r=/* @__PURE__ */new Map();for(const s of n){const l=s.match(/^Card '(.+)' binding for control '(.+)' maps to missing metric '(.+)'\.$/);if(l){const[,b,i]=l,f=`${b}:${i}:missing-metric`;r.has(f)||r.set(f,`"${ye(a,b)}" has an outdated "${ve(a,b,i)}" mapping. Some choices still point to metrics that are no longer available on this card. Open the card controls and choose replacements.`);continue;}const u=s.match(/^Card '(.+)' binding for control '(.+)' maps to missing group-by field '(.+)'\.$/);if(u){const[,b,i]=u,f=`${b}:${i}:missing-group-by`;r.has(f)||r.set(f,`"${ye(a,b)}" has an outdated "${ve(a,b,i)}" mapping. Some choices still point to fields that are no longer available on this card. Open the card controls and choose replacements.`);continue;}const m=s.match(/^Card '(.+)' binding for control '(.+)' maps to an invalid metric target\.$/);if(m){const[,b,i]=m,f=`${b}:${i}:invalid-metric`;r.has(f)||r.set(f,`"${ye(a,b)}" has an invalid "${ve(a,b,i)}" metric mapping. Open the card controls and choose a valid metric for each option.`);continue;}const p=s.match(/^Card '(.+)' binding for control '(.+)' maps to an invalid group-by target\.$/);if(p){const[,b,i]=p,f=`${b}:${i}:invalid-group-by`;r.has(f)||r.set(f,`"${ye(a,b)}" has an invalid "${ve(a,b,i)}" field mapping. Open the card controls and choose a valid field for each option.`);continue;}const y=s.match(/^Card '(.+)' binding for control '(.+)' requires at least one temporal group-by field\.$/);if(y){const[,b,i]=y,f=`${b}:${i}:missing-temporal-group-by`;r.has(f)||r.set(f,`"${ye(a,b)}" can no longer use "${ve(a,b,i)}" for time grain because the card does not currently group by a date field.`);continue;}r.set(s,s);}return Array.from(r.values());}function Ds({visible:t,onSelect:n}){return t?/* @__PURE__ */o(A,{onSelect:n,children:[/* @__PURE__ */e(Aa,{className:"h-3.5 w-3.5"}),"Schedule email report"]}):null;}function ks({scheduleReportVisible:t,analyticalBriefingVisible:n,onScheduleReport:a,onCreateAnalyticalBriefing:r}){return/* @__PURE__ */o(T,{children:[/* @__PURE__ */e(Ds,{visible:t,onSelect:a}),n?/* @__PURE__ */o(A,{onSelect:r,children:[/* @__PURE__ */e(re,{className:"h-3.5 w-3.5"}),"Create analytical briefing"]}):null]});}const Cs="dashboard-bookmark-usage";function Es(t){var p;const n=D(y=>y.viewerStateClient),a=(p=t.saved)==null?void 0:p.id,s=Zr({queryKey:[Cs,(n==null?void 0:n.viewerKey)??null],queryFn:()=>n.bookmarks.usage(),enabled:t.enabled&&!!n&&!!a,staleTime:5*6e4,retry:!1}).data,{saved:l,draft:u,enabled:m}=t;return j(()=>!m||!l||!s?[]:!s.bookmarks&&!Object.keys(s.tables).length?[]:Tn({saved:l,draft:u,usage:s}),[u,m,l,s]);}function As({saved:t,draft:n,enabled:a}){const r=Es({saved:t,draft:n,enabled:a});return r.length?/* @__PURE__ */o(ea,{children:[/* @__PURE__ */e(ta,{asChild:!0,children:/* @__PURE__ */o(V,{variant:"ghost",size:"xs",className:"gap-1 text-muted-foreground hover:text-foreground",children:[/* @__PURE__ */e(ra,{className:"h-3.5 w-3.5","aria-hidden":"true"}),"Affects saved views"]})}),/* @__PURE__ */o(aa,{align:"end",className:"w-[320px] p-3 text-[12px]",children:[/* @__PURE__ */e("p",{className:"text-foreground",children:"This edit removes parts of the dashboard that viewers saved. Their views still open, with a note about what no longer applies."}),/* @__PURE__ */e("ul",{"aria-label":"Affected saved views",className:"mt-2 grid gap-1 border-t border-border/60 pt-2",children:r.map(s=>{const{name:l,uses:u}=Un(s);return/* @__PURE__ */o("li",{className:"flex items-baseline justify-between gap-3",children:[/* @__PURE__ */e("span",{className:"min-w-0 truncate text-foreground",children:l}),/* @__PURE__ */e("span",{className:"shrink-0 text-[11.5px] text-muted-foreground",children:u})]},`${s.target}:${s.cardId??""}:${s.id}`);})})]})]}):null;}function Vt(t,n){return{dashboard:$e(t),semanticExecutionPayload:$e(n)};}function Js(){var kt,Ct,Et,At;const{authToken:t,tokenProps:n,id:a,showBriefings:r,toolbarStatus:s}=Z(),l=Ia(),{isLocalDev:u,isConsoleMode:m}=Ma(),{canEditDashboard:p,hasInspectionUser:y,inspectionMessage:b,isInspectionMode:i,isInspectionSurface:f}=La(),{openBrandStudioPreview:c}=Oa(),{permissions:x}=Kn(),h=Pa(),{isLoading:w}=_a(),S=D(d=>d.theme),P=D(d=>d.isDownloadingPdf),g=D(d=>d.dashboard),B=D(d=>d.selectedSheetId),L=(kt=g==null?void 0:g.sheets)==null?void 0:kt.find(d=>d.id===B),H=un(L),Ee=mn(L),I=H?(Ct=L==null?void 0:L.document)==null?void 0:Ct.page:void 0,C=D(d=>d.isDashboardEditing),{setDashboardTitle:q}=D(d=>d.actions),[ae,z]=N(!1),[ne,se]=N(!1),[Ge,oe]=N(!1),[Ve,ie]=N(!1),[de,le]=N(null),[Ae,K]=N(null),{registerBriefingViewer:v}=na();we(()=>v(d=>K(d)),[v]);const[F,ce]=N(!1),[Ie,Q]=N(!1),[W,J]=N(null),[mt,Me]=N([]),[ht,Le]=N(!1),[fr,pt]=N(!1),U=D(d=>d.isVisualEditing);Mt(d=>d.card);const br=Ue(d=>d.selectedDashboard),gr=Ue(d=>d.initialDashboard);Ue(d=>d.selectedVisual),D(d=>d.selectedFrameId),Mt(d=>d.frame);const ft=D(d=>d.showDashboardJSON);D(d=>d.onSaveFunction);const{setIsDashboardEditing:bt,setShowDashboardJSON:gt,markDashboardSaved:xr,openStyleSheet:vr}=D(d=>d.actions),{setInitialDashboard:xt,clearSelectedDashboard:He}=Ue(d=>d.actions),ue=!!n.orgUserId||!!(n.tenantId&&n.endUserId&&n.endUserEmail),{resources:Oe}=Ra(et.DASHBOARD),M=Ta(),{currentUser:yr}=dt(),wr=Ua(yr),$=br||gr,Y=Ba({config:n.config,canNavigateDashboardHub:ue,canShareDashboard:((Et=$==null?void 0:$.permissions)==null?void 0:Et.canShare)===!0,canManageGroups:wr}),vt=$?{id:$.id,title:(g==null?void 0:g.title)||$.title||"Dashboard"}:null,{handleAddNewFrame:Nr}=Fa(),[je,qe]=N(!1),[Sr,me]=N(!1),[ze,Pe]=N("close"),he=$a(et.DASHBOARD),[O,pe]=N(null),Dr=async(d,_)=>{if(!i){if(!(g!=null&&g.id)){console.log("No dashboard ID found");return;}console.log("Updating dashboard title:",{dashboardId:g.id,newTitle:d,previousTitle:_}),he.mutate({resourceId:g.id,data:{title:d}},{onSuccess:()=>{pe(R=>(R==null?void 0:R.dashboard.id)===g.id?{...R,dashboard:{...R.dashboard,title:d}}:R),k.success("Dashboard title updated");},onError:R=>{console.error("Failed to update dashboard title:",R),k.error("Failed to update dashboard title");const ee=D.getState().dashboard;(ee==null?void 0:ee.id)===g.id&&ee.title===d&&q(_);}});}};we(()=>{if(Oe&&Oe.length>0){const d=g==null?void 0:g.id;if(d){const _=Oe.find(R=>R.id===d);_&&xt(_);}}},[Oe,g==null?void 0:g.id,xt]);const kr=n.orgUserId||n.tenantId,Ke=j(()=>Ms({accessToken:t==null?void 0:t.accessToken,dashboardId:(g==null?void 0:g.id)||a||n.dashboard_id,selectedSheetId:H?B:void 0,pageSize:I==null?void 0:I.size,orientation:I==null?void 0:I.orientation,theme:S}),[t==null?void 0:t.accessToken,a,g==null?void 0:g.id,H,I==null?void 0:I.orientation,I==null?void 0:I.size,B,S,n.dashboard_id]),Qe=C&&!U&&!i&&kr&&p,{setDashboard:We}=D(d=>d.actions),Cr=D(d=>d.semanticExecutionPayload),Er=()=>{bt(!0);},_e=()=>{bt(!1),gt(!1),pe(null);};we(()=>{if(!C){O&&pe(null);return;}if(O||!g||w)return;const d=sa(D.getState());pe(Vt(d.dashboard,d.semanticExecutionPayload));},[g,O,C,w,Cr]);const Je=(O==null?void 0:O.dashboard)??null,{isDirty:Ye,isDirtyPending:Ar,resetDirty:fe}=_n(g,Je,300,1e3,Rn),yt=hn(Je,i,p),wt=Ye||Ar,Re=je||he.isPending,Ir=()=>{if(i){O&&We(O.dashboard,{semanticExecutionPayload:O.semanticExecutionPayload}),_e(),fe();return;}yt()?(Pe("close"),me(!0)):(_e(),fe());},Mr=async()=>{await Xe({closeAfterSave:!0,navigateHomeAfterSave:ze==="home"});},Lr=()=>{const d=ze==="home"&&!!ue;O&&We(O.dashboard,{semanticExecutionPayload:O.semanticExecutionPayload}),_e(),d&&He(),Pe("close"),me(!1),fe();},Or=()=>{O&&(We(O.dashboard,{semanticExecutionPayload:O.semanticExecutionPayload}),fe());},Pr=()=>{if(ue){if(C&&yt()){Pe("home"),me(!0);return;}He();}};async function Xe(d){if(i)return;const _=D.getState().dashboard;if(!_)return;const R=(d==null?void 0:d.closeAfterSave)??ht,ee=(d==null?void 0:d.navigateHomeAfterSave)??!1;Le(R),R&&me(!1);let It=$e(_);Q(!0),J(null),Me([]),qe(!0);const Ur={template:_};he.mutate({resourceId:_.id,data:Ur},{onSuccess:ge=>{qe(!1);const G=ge==null?void 0:ge.customVisuals;G!=null&&G.length&&(It=$e(D.getState().actions.applySavedCustomVisuals(G,_))),xr(),k.success("Dashboard saved!"),pe(Vt(It,D.getState().semanticExecutionPayload)),Q(!1),Le(!1),R&&(_e(),fe(),ee&&ue&&He()),Pe("close");},onError:ge=>{qe(!1),J("Failed to save dashboard. Please try again.");const G=ge.details,Br=Array.isArray(G==null?void 0:G.errors)?(G.errors||[]).filter(Fr=>typeof Fr=="string"):[];Me(Ss({errors:Br,dashboard:_||void 0})),k.error("Failed to save dashboard");}});}const Nt=g.title;he.isPending&&console.log("Title during update:",{title:Nt,dashboardStateTitle:g.title,dashboardId:g==null?void 0:g.id});const _r=ue&&!!(t!=null&&t.accessToken)&&!!(n!=null&&n.apiServiceUrl),Rr=!i&&Y.showDashboardHub&&_r,Tr=!i&&h&&Y.showDashboardHub,X=(g==null?void 0:g.id)||null,St=Ga((At=n.config)==null?void 0:At.showBriefings,r),Te=pn(X),Ze=fn();if(!h&&!U)return null;const be=!U&&h&&!i,Dt=C&&be;return/* @__PURE__ */e(Va,{width:M.width,hasOverflowMenu:be,children:/* @__PURE__ */o("div",{ref:M.measure,className:"flex min-h-11 shrink-0 items-center gap-2 border-b px-3 py-1.5",role:"dashboard-controls",children:[/* @__PURE__ */o("div",{className:"flex min-w-[80px] flex-1 items-center gap-2",children:[Tr&&!U&&/* @__PURE__ */e(Ha,{"aria-label":"Dashboard Hub",tooltip:"Dashboard Hub",onClick:Pr,className:"h-7 w-7 px-0",buttonProps:{size:"xs"},children:/* @__PURE__ */e(ja,{className:"h-3.5 w-3.5"})}),!U&&h&&(w?/* @__PURE__ */e("div",{className:"h-4 w-28 animate-pulse rounded-md bg-muted/70","aria-label":"Loading dashboard title",role:"status",children:/* @__PURE__ */e("span",{className:"sr-only",children:"Loading dashboard title"})}):/* @__PURE__ */o("div",{className:"flex min-w-0 items-center gap-1",children:[/* @__PURE__ */e(qa,{value:Nt||"Untitled Dashboard",onSave:d=>{console.log("EditableText onSave called:",{newTitle:d,canEditDashboard:p,dashboardId:g==null?void 0:g.id});const _=(g==null?void 0:g.title)||"";q(d),Dr(d,_);},isEditable:za({isDashboardEditing:C,canEditDashboard:p===!0&&!i}),displayClassName:"text-[13px] font-medium",inputClassName:"text-[13px] font-medium",placeholder:"Dashboard Title",isPending:he.isPending}),!i&&X&&/* @__PURE__ */e(bn,{dashboardId:X}),s?/* @__PURE__ */e("div",{className:"flex min-w-[1.25rem] shrink-[2]",children:s}):null]}))]}),/* @__PURE__ */o("div",{className:"flex min-w-0 items-center gap-1.5",children:[/* @__PURE__ */o("div",{className:"-m-1 flex min-w-0 items-center gap-1.5 overflow-x-auto p-1 [scrollbar-width:thin] [&>*]:shrink-0",children:[U&&/* @__PURE__ */o(T,{children:[/* @__PURE__ */e(gn,{}),/* @__PURE__ */e(xn,{})]}),h&&!i&&/* @__PURE__ */e(Mn,{}),!U&&C&&!i&&x.canUseFilters&&h&&/* @__PURE__ */e(vn,{}),C&&!i&&h&&/* @__PURE__ */e(yn,{}),C&&!U&&!i&&h&&Ee&&/* @__PURE__ */o("div",{className:"inline-flex h-7 items-stretch overflow-hidden rounded-control border border-input bg-background",children:[/* @__PURE__ */o(V,{variant:"ghost",size:"xs",disabled:!C,onClick:()=>void Nr(),"aria-label":M.width==="sm"?"Add visual":void 0,title:M.width==="sm"?"Add visual":void 0,className:Ne("h-full rounded-none border-0 shadow-none hover:bg-accent",M.width==="sm"&&"w-7 px-0"),children:[/* @__PURE__ */e(re,{className:"h-3.5 w-3.5"}),M.width!=="sm"&&"Visual"]}),/* @__PURE__ */o(Lt,{modal:!1,children:[/* @__PURE__ */e(Ot,{asChild:!0,children:/* @__PURE__ */e(V,{variant:"ghost",size:"xs",className:"h-full w-7 rounded-none border-0 border-l border-border/60 px-0 shadow-none hover:bg-accent","aria-label":"Open visual options",disabled:!C,children:/* @__PURE__ */e(oa,{className:"h-3.5 w-3.5"})})}),/* @__PURE__ */e(Pt,{align:"end",className:"z-[60] w-48 rounded-control border-border/60 p-1 shadow-sm",children:/* @__PURE__ */o(A,{onClick:()=>pt(!0),children:[/* @__PURE__ */e(re,{className:"h-3.5 w-3.5"}),"From library..."]})})]}),/* @__PURE__ */e(wn,{open:fr,onOpenChange:pt})]}),!i&&h&&/* @__PURE__ */e(Nn,{}),!U&&!C&&(p||i)&&(!f||!y||p!==void 0)&&h&&/* @__PURE__ */o("div",{className:"inline-flex items-center gap-1",children:[/* @__PURE__ */o(V,{size:"xs",onClick:Er,"aria-label":i?"Inspect":"Edit",title:M.width==="sm"?i?"Inspect":"Edit":void 0,className:M.width==="sm"?"w-7 px-0":void 0,children:[/* @__PURE__ */e(Ka,{className:"h-3.5 w-3.5"}),M.width!=="sm"&&(i?"Inspect":"Edit")]}),b?/* @__PURE__ */e(ia,{children:/* @__PURE__ */o(da,{children:[/* @__PURE__ */e(la,{asChild:!0,children:/* @__PURE__ */e("button",{type:"button","aria-label":b,className:"inline-flex size-6 items-center justify-center rounded-control text-muted-foreground outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",children:/* @__PURE__ */e(ca,{"aria-hidden":"true",className:"size-3.5"})})}),/* @__PURE__ */e(ua,{children:/* @__PURE__ */e("p",{children:b})})]})}):null]}),Qe&&h&&Ye&&/* @__PURE__ */e(As,{saved:Je,draft:g,enabled:C&&!i}),Qe&&h&&Ye&&/* @__PURE__ */o(V,{variant:"outline",size:"xs",onClick:Or,disabled:Re,"aria-label":"Undo",title:M.width==="sm"?"Undo":void 0,className:M.width==="sm"?"w-7 px-0":void 0,children:[/* @__PURE__ */e(Qa,{className:"h-3.5 w-3.5"}),M.width!=="sm"&&"Undo"]}),Qe&&h&&/* @__PURE__ */o(V,{size:"xs",className:Ne(!wt&&"opacity-60"),disabled:Re||!wt,onClick:()=>Xe(),children:[Re?/* @__PURE__ */e(Fe,{className:"h-3.5 w-3.5 animate-spin"}):/* @__PURE__ */e(Sn,{className:"h-3.5 w-3.5"}),Re?"Saving...":"Save"]}),C&&!U&&h&&/* @__PURE__ */o(V,{variant:"outline",size:"xs",onClick:Ir,"aria-label":"Close",title:M.width==="sm"?"Close":void 0,className:M.width==="sm"?"w-7 px-0":void 0,children:[/* @__PURE__ */e(ma,{className:"h-3.5 w-3.5"}),M.width!=="sm"&&"Close"]})]}),!U&&h&&/* @__PURE__ */o(T,{children:[/* @__PURE__ */e(Dn,{}),m&&p===!0&&!i&&/* @__PURE__ */e(kn,{})]}),!U&&u&&M.width==="lg"&&/* @__PURE__ */e(zn,{}),be&&/* @__PURE__ */e(Wa,{}),be&&Dt&&/* @__PURE__ */e(Cn,{}),be&&/* @__PURE__ */o(Lt,{children:[/* @__PURE__ */e(Ot,{asChild:!0,children:/* @__PURE__ */e(V,{variant:"ghost",size:"xs",className:"w-7 px-0","aria-label":"More dashboard options",children:/* @__PURE__ */e(Ja,{className:"h-3.5 w-3.5"})})}),/* @__PURE__ */o(Pt,{align:"end",className:"w-56 rounded-control border border-border/60 p-1 shadow-sm",children:[/* @__PURE__ */e(Is,{}),Te.available&&Rr&&/* @__PURE__ */o(T,{children:[/* @__PURE__ */o(A,{disabled:Te.disabled,onSelect:Te.toggle,children:[/* @__PURE__ */e(Ya,{className:"h-3.5 w-3.5"}),/* @__PURE__ */e("span",{className:"flex-1",children:"Default dashboard"}),Te.isDefault&&/* @__PURE__ */e(Qt,{className:"h-3.5 w-3.5"})]}),/* @__PURE__ */e(te,{})]}),/* @__PURE__ */e(xe,{children:"Reports & briefings"}),/* @__PURE__ */o(A,{disabled:P,onSelect:()=>ce(!0),children:[/* @__PURE__ */e(ha,{className:"h-3.5 w-3.5"}),"Export"]}),/* @__PURE__ */e(ks,{scheduleReportVisible:!!(St&&l.surfaceVisible&&X&&!C),analyticalBriefingVisible:!!(St&&l.surfaceVisible&&X&&!C),onScheduleReport:()=>le("scheduled_report"),onCreateAnalyticalBriefing:()=>le("analytical_briefing")}),C&&/* @__PURE__ */o(A,{onSelect:()=>ie(!0),children:[/* @__PURE__ */e(pa,{className:"h-3.5 w-3.5"}),"Download settings"]}),/* @__PURE__ */e(te,{}),(Y.showDashboardSharing||Y.showGroupManagement)&&/* @__PURE__ */o(T,{children:[/* @__PURE__ */e(xe,{children:"Access"}),Y.showDashboardSharing&&/* @__PURE__ */o(A,{onSelect:()=>z(!0),children:[/* @__PURE__ */e(Xa,{className:"h-3.5 w-3.5"}),"Share"]}),Y.showGroupManagement&&/* @__PURE__ */o(A,{onClick:()=>se(!0),children:[/* @__PURE__ */e(Wt,{className:"h-3.5 w-3.5"}),"Manage Groups"]}),/* @__PURE__ */e(te,{})]}),Dt&&/* @__PURE__ */o(T,{children:[/* @__PURE__ */e(xe,{children:"Dashboard"}),/* @__PURE__ */o(A,{onSelect:Ze.open,children:[/* @__PURE__ */e(_t,{className:"h-3.5 w-3.5"}),/* @__PURE__ */e("span",{className:"flex-1",children:Ze.label}),/* @__PURE__ */e("span",{className:"pl-4 text-[11px] tabular-nums text-muted-foreground",children:Ze.count})]}),/* @__PURE__ */o(A,{onSelect:vr,children:[/* @__PURE__ */e(fa,{className:"h-3.5 w-3.5"}),"Style"]}),/* @__PURE__ */e(te,{})]}),/* @__PURE__ */e(xe,{children:"Preferences"}),/* @__PURE__ */o(A,{onClick:()=>oe(!0),children:[/* @__PURE__ */e(Kt,{className:"h-3.5 w-3.5"}),"Report preferences"]}),u&&h&&/* @__PURE__ */o(T,{children:[/* @__PURE__ */e(te,{}),/* @__PURE__ */e(xe,{children:"Developer"}),/* @__PURE__ */o(A,{onSelect:()=>{var d;t!=null&&t.accessToken&&((d=navigator==null?void 0:navigator.clipboard)!=null&&d.writeText?navigator.clipboard.writeText(t.accessToken).then(()=>k.success("Token copied to clipboard")).catch(()=>k.error("Unable to copy token")):k.error("Clipboard not available"));},children:[/* @__PURE__ */e(Rt,{className:"h-3.5 w-3.5"}),"Copy token"]}),H&&/* @__PURE__ */o(A,{disabled:!Ke,onSelect:()=>{var d;if(!Ke){k.error("Open a document sheet with a token to copy the local PDF URL");return;}(d=navigator==null?void 0:navigator.clipboard)!=null&&d.writeText?navigator.clipboard.writeText(Ke).then(()=>k.success("Local document PDF URL copied to clipboard")).catch(()=>k.error("Unable to copy local document PDF URL")):k.error("Clipboard not available");},children:[/* @__PURE__ */e(Rt,{className:"h-3.5 w-3.5"}),"Copy local document PDF URL"]}),/* @__PURE__ */o(A,{onSelect:()=>En(n.apiServiceUrl),children:[/* @__PURE__ */e($n,{className:"h-3.5 w-3.5"}),"Invalidate token"]}),/* @__PURE__ */o(A,{onSelect:c,children:[/* @__PURE__ */e(Bn,{className:"h-3.5 w-3.5"}),"Brand Studio"]}),C&&/* @__PURE__ */o(A,{onSelect:()=>gt(!ft),children:[/* @__PURE__ */e(_t,{className:"h-3.5 w-3.5"}),ft?"Hide dashboard JSON":"Show dashboard JSON"]})]})]})]}),ae&&vt&&/* @__PURE__ */e(Za,{resource:vt,resourceType:et.DASHBOARD,onClose:()=>z(!1)}),Y.showGroupManagement&&/* @__PURE__ */e(ps,{open:ne,onOpenChange:se}),/* @__PURE__ */e(Ln,{open:Ge,onOpenChange:oe}),/* @__PURE__ */e(Ns,{open:Ve,onOpenChange:ie}),X&&(de||Ae)?/* @__PURE__ */e(An,{dashboardId:X,dashboardTitle:(g==null?void 0:g.title)||($==null?void 0:$.title),open:!0,onOpenChange:d=>{d||(le(null),K(null));},hideTrigger:!0,workflowIntent:de??void 0,openRun:Ae??void 0}):null,h&&/* @__PURE__ */e(en,{open:F,onOpenChange:ce}),/* @__PURE__ */e(tn,{open:Ie,onOpenChange:d=>{!d&&je&&!W||(Q(d),d||(J(null),Me([]),Le(!1)));},children:/* @__PURE__ */o(rn,{className:"max-w-sm",children:[/* @__PURE__ */o(an,{children:[/* @__PURE__ */e(nn,{children:W?"Save failed":"Saving dashboard"}),/* @__PURE__ */e(sn,{className:"pt-2",children:W?"We could not save the dashboard. Please try again.":"Please wait while we save your changes."}),mt.length>0&&/* @__PURE__ */o("div",{className:"space-y-1 rounded-md border border-destructive/20 bg-destructive/5 p-3 text-left",children:[/* @__PURE__ */e("div",{className:"text-sm font-medium text-destructive",children:"What needs attention"}),/* @__PURE__ */e("ul",{className:"list-disc space-y-1 pl-4 text-xs text-muted-foreground",children:mt.slice(0,5).map(d=>/* @__PURE__ */e("li",{children:d},d))})]})]}),/* @__PURE__ */e(on,{className:"flex-col gap-2 sm:flex-row sm:justify-end",children:W?/* @__PURE__ */o(T,{children:[/* @__PURE__ */e(dn,{onClick:()=>{Q(!1),J(null),Me([]),Le(!1);},className:"m-0",children:"Close"}),/* @__PURE__ */e(Tt,{onClick:()=>Xe({closeAfterSave:ht,navigateHomeAfterSave:ze==="home"}),className:"m-0",children:"Retry"})]}):/* @__PURE__ */o(Tt,{disabled:!0,className:"m-0 cursor-default",children:[/* @__PURE__ */e(Fe,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]})})]})}),/* @__PURE__ */e(In,{open:Sr,onOpenChange:d=>{me(d);},onSave:Mr,onDiscard:Lr,isSaving:je,saveLabel:"Save",discardLabel:"Discard changes"})]})]})});}function Is(){const t=ln();return t.length===0?null:/* @__PURE__ */o(T,{children:[t.map(n=>/* @__PURE__ */o(A,{onSelect:n.onSelect,children:[n.icon,/* @__PURE__ */e("span",{className:"flex-1",children:n.label}),n.hint&&/* @__PURE__ */e("span",{className:"text-[11px] text-muted-foreground",children:n.hint}),n.checked&&/* @__PURE__ */e(Qt,{className:"h-3.5 w-3.5"})]},n.id)),/* @__PURE__ */e(te,{})]});}function Ms({accessToken:t,dashboardId:n,selectedSheetId:a,pageSize:r,orientation:s,theme:l}){if(!t||!a)return null;const u=new URL("http://localhost:5173/print-document");u.searchParams.set("token",t),n&&u.searchParams.set("dashboardId",n),u.searchParams.set("selectedSheetId",a),l&&u.searchParams.set("theme",l);const m=new URL("http://127.0.0.1:3002/");return m.searchParams.set("pdfMode","document"),m.searchParams.set("pageSize",r||"letter"),m.searchParams.set("orientation",s||"portrait"),m.searchParams.set("url",u.toString()),m.toString();}export{Js as default};
@@ -1 +1 @@
1
- import{jsxs as d,jsx as t}from"react/jsx-runtime";import{useMemo as m,useState as f,useRef as b,useEffect as p}from"react";import{u as o,B as S,X as N,C as D}from"./appearance-provider-fIhJSX6y.js";import{k as J}from"./resolve-dashboard-input-context-SlAAe4GF.js";import"./validators-Dg2kyF4_.js";import"./matrix-operation-contract-CWvcEsQ0.js";import"./analytics-base-schemas-DMFrDqn_.js";import"../value-format-preferences/index.js";function j(){const e=o(s=>s.dashboard),c=o(s=>s.actions.setDashboard),h=o(s=>s.showDashboardJSON),l=o(s=>s.actions.setShowDashboardJSON),a=m(()=>e?JSON.stringify(e,null,2):"",[e]),[u,n]=f(a),r=b(a);return p(()=>{a!==r.current&&(n(a),r.current=a);},[a]),/* @__PURE__ */d("div",{className:J("relative p-2",{hidden:!h}),children:[/* @__PURE__ */d(S,{variant:"secondary",size:"sm",className:"absolute right-2 top-2 z-10 h-8",onClick:()=>l(!1),children:[/* @__PURE__ */t(N,{className:"mr-2 h-4 w-4"}),"Close"]}),/* @__PURE__ */t("div",{className:"h-[550px] overflow-hidden",children:/* @__PURE__ */t(D,{value:u,onValueChange:s=>{n(s);try{const i=JSON.parse(s);r.current=JSON.stringify(i,null,2),c(i);}catch{}},language:"json"})})]});}export{j as default};
1
+ import{jsxs as d,jsx as t}from"react/jsx-runtime";import{useMemo as m,useState as f,useRef as b,useEffect as p}from"react";import{u as o,B as S,X as N,C as D}from"./appearance-provider-BBYTKSjL.js";import{n as J}from"./resolve-dashboard-input-context-B5yUS9ZM.js";import"./validators-U8IL8djK.js";import"./matrix-operation-contract-DceN49RX.js";import"./analytics-base-schemas-DMFrDqn_.js";import"../value-format-preferences/index.js";function j(){const e=o(s=>s.dashboard),c=o(s=>s.actions.setDashboard),h=o(s=>s.showDashboardJSON),l=o(s=>s.actions.setShowDashboardJSON),a=m(()=>e?JSON.stringify(e,null,2):"",[e]),[u,n]=f(a),r=b(a);return p(()=>{a!==r.current&&(n(a),r.current=a);},[a]),/* @__PURE__ */d("div",{className:J("relative p-2",{hidden:!h}),children:[/* @__PURE__ */d(S,{variant:"secondary",size:"sm",className:"absolute right-2 top-2 z-10 h-8",onClick:()=>l(!1),children:[/* @__PURE__ */t(N,{className:"mr-2 h-4 w-4"}),"Close"]}),/* @__PURE__ */t("div",{className:"h-[550px] overflow-hidden",children:/* @__PURE__ */t(D,{value:u,onValueChange:s=>{n(s);try{const i=JSON.parse(s);r.current=JSON.stringify(i,null,2),c(i);}catch{}},language:"json"})})]});}export{j as default};
@@ -0,0 +1 @@
1
+ var E=Object.defineProperty;var A=(e,t,r)=>t in e?E(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var y=(e,t,r)=>A(e,typeof t!="symbol"?t+"":t,r);import{l as D}from"./export-file-format-B-wQNHIn.js";import{r as k}from"./rendered-file-BbvwaU6z.js";import{D as S,E as B,F as _,G as P,H as R,I as q,J as M,B as j,K as O}from"./resolve-dashboard-input-context-B5yUS9ZM.js";import{z as a}from"zod";import{V as b,l as z}from"./validators-U8IL8djK.js";import{aG as L,aI as V,aj as K}from"./matrix-operation-contract-DceN49RX.js";import"./analytics-base-schemas-DMFrDqn_.js";import{aK as G,a2 as U,at as I}from"./pivot-result-contract-expectations-D_ane7I2.js";import{F as $,G as H}from"./bookmark-state-BmbBu1th.js";import"../value-format-preferences/index.js";import"./schema-O1Y3WTGF.js";import"./index-DViPGDFj.js";import{f as J,r as N,b as Y,g as Q}from"./custom-visual-inputs-CUtxCe4T.js";import"./context-Cwj8Axgd.js";const X=/* @__PURE__ */new Set(["table","detailTable"]),Z=/* @__PURE__ */new Set(["bar","horizontalBar","line","area","stackedArea","combo","pie","doughnut","radar","polarArea","bubble","scatter","stackedBar","stackedLine","table","matrixTable","detailTable","kpi","pyramid","tornado","range","funnel","bullet","heatmap","treemap","custom"]);function Ie(e){var i,n,d;const t=Z.has(e.type)&&(e.type!=="custom"||!!((i=e.customCardPreferences)!=null&&i.url));let r=!1;try{r=!!S(e);}catch{return{formats:[],defaultFormat:null};}return e.type==="text"||!t||!r&&B(e)?{formats:[],defaultFormat:null}:{formats:re({cardType:e.type,allowDownload:(n=e.preferences)==null?void 0:n.allowDownload}).filter(l=>l!=="xlsx"||e.type!=="matrixTable"||r),defaultFormat:ae({cardType:e.type,allowDownload:(d=e.preferences)==null?void 0:d.allowDownload})};}function C(e){return e==="table"||e==="detailTable";}function ve(e){let t=null;if(e.type==="matrixTable")try{t=S(e)??null;}catch{t=null;}return{cardType:e.type,matrixConfig:t};}function W(e,t){const{matrix:r,...o}=e??{},i={...o,cardType:t.cardType};return t.cardType!=="matrixTable"?i:r?{...i,matrix:r}:t.matrixConfig?{...i,matrix:{config:structuredClone(t.matrixConfig),content:"current"}}:i;}function Se(e,t){if(e.type!=="card"||!t)return e;const r=W(e.settings,t);return e.format==="xlsx"&&!r.matrix&&!C(r.cardType)?e:{...e,settings:r};}function ee(e){var r,o;if(e.type!=="card")return{kind:"rendered",format:e.format==="png"?"png":"pdf"};const t=!!((r=e.settings)!=null&&r.matrix);switch(e.format){case"png":return{kind:"rendered",format:"png"};case"pdf":return t?{kind:"matrix_pdf"}:{kind:"rendered",format:"pdf"};case"csv":case"xlsx":return t||C((o=e.settings)==null?void 0:o.cardType)?{kind:"export_job",format:e.format}:{kind:"card_query",format:"csv"};}}function Fe(e){return ee(e).kind==="export_job";}function te(e){const{label:t,extension:r,contentType:o}=e==="pdf"||e==="png"?k(e):D(e);return{label:t,extension:r,contentType:o};}function re(e){return e.allowDownload===!1?["pdf","png"]:e.cardType==="matrixTable"||C(e.cardType)?["pdf","png","csv","xlsx"]:["pdf","png","csv"];}function Ee(e){return te(e).label;}function ae(e){return X.has(e.cardType)&&e.allowDownload!==!1?"csv":"pdf";}function Ae(e){const{config:t}=e,r=G({spec:t.spec,presentation:t.presentation,defaults:t.defaultView,session:e.purpose==="manual"?e.session:void 0});return b.parse({spec:r.spec,presentation:r.presentation,...(e.content==="flat"?{mode:"flat",format:e.format==="xlsx"?"xlsx":"csv"}:{mode:"layout",format:e.format,expansion:e.content==="all"?{kind:"all"}:{kind:"current",rows:r.view.rows,columns:r.view.columns}})});}const oe=a.object({connection_id:a.string().min(1),cardType:a.literal("matrixTable"),resultOwner:a.literal("config"),sql:a.literal("").optional(),python:a.literal("").optional(),tableStructure:a.never().optional(),cardDataSource:a.object({connectionId:a.string().min(1),connectionType:a.string().min(1),mode:a.enum(["database","semanticDomain"]),selectedEntities:a.array(a.unknown()),semanticDomainId:a.string().optional()}).passthrough(),active_filters:a.array(a.unknown()).default([])}).passthrough(),De=oe.extend({dashboardId:a.string().min(1),cardId:a.string().min(1),formatOptions:a.object({matrix:b,acquisition:a.literal("continuation").optional(),presentationExecutionSnapshot:a.unknown()}).passthrough().superRefine((e,t)=>{e.matrix.format!=="pdf"!=(e.acquisition==="continuation")&&t.addIssue({code:a.ZodIssueCode.custom,path:["acquisition"],message:"CSV and Excel require continuation acquisition; PDF must not specify acquisition."});})});function ke(e){return{...e.controls,type:"card",dashboardId:e.dashboardId,cardId:e.cardId,title:e.title,cardType:"matrixTable",resultOwner:"config",sql:"",python:"",connection_id:e.dataSource.connectionId,cardDataSource:{...e.dataSource,mode:e.matrix.spec.source.kind==="semantic"?"semanticDomain":"database",semanticDomainId:e.matrix.spec.source.kind==="semantic"?e.matrix.spec.source.domainId:void 0},active_filters:e.activeFilters,formatOptions:{...(e.matrix.format!=="pdf"?{acquisition:"continuation",...(e.csvEncoding?{csvEncoding:e.csvEncoding}:{})}:{}),matrix:e.matrix,delimiter:e.delimiter,includeHeaders:e.includeHeaders,timezone:e.reportContext.calendar.tz,presentationExecutionSnapshot:U({reportContext:e.reportContext,resolvedFormats:[]})}};}const x=a.number().int().nonnegative(),Be=a.discriminatedUnion("status",[a.object({status:a.literal("ok"),request:b,layout:L,rows:a.array(V).readonly(),usage:a.object({rows:x,cells:x,bytes:x}).strict()}).strict(),a.object({status:a.literal("failed"),failure:a.object({code:a.enum(K),limit:a.enum(["rows","bytes"]).optional(),message:a.string().min(1),retryable:a.boolean()}).strict()}).strict()]);function v(e){return!e||typeof e!="object"?!1:Array.isArray(e.cards);}function ne(e){if(!e)return null;if(typeof e=="string")try{const t=JSON.parse(e);return v(t)?t:null;}catch{return null;}return v(e)?e:null;}function F(e){var t;return(t=e==null?void 0:e.cards)!=null&&t.length?e.activeCardId&&e.cards.find(r=>r.id===e.activeCardId)||e.cards[0]:null;}function _e(e){var r;const t=(e==null?void 0:e.frameObject)??((r=e==null?void 0:e.visual)==null?void 0:r.frameObject);return F(ne(t));}class h extends Error{constructor(r){const o=r.cardId?`card "${r.cardId}"`:r.sheetId?`sheet "${r.sheetId}"`:`dashboard "${r.dashboardId}"`;super(`Unable to resolve ${o} while capturing report presentation. Refresh the authoring page and select the attachment again.`);y(this,"code","temporal_snapshot_target_not_found");y(this,"selection");this.name="TemporalSnapshotSelectionError",this.selection=r;}}function se(e,t){var i;const r=[],o=/* @__PURE__ */new Map();for(const n of t){if(n.dashboardId!==e.id)throw new h(n);const d=(e.sheets||[]).filter(c=>!n.sheetId||n.sheetId===c.id);if(n.sheetId&&d.length===0)throw new h(n);let l=!n.cardId;for(const c of d){const g=(((i=c.document)==null?void 0:i.sections)||[]).flatMap(s=>H(s)),f=(c.frames||[]).flatMap(s=>ie(s,n.cardId));f.length>0&&(l=!0);const p=[...f,...(c.cards||[]).filter(s=>!n.cardId||n.cardId===s.id),...g.filter(s=>!n.cardId||n.cardId===s.id)];for(const s of p){l=!0;const m=o.get(n.attachmentIndex)??/* @__PURE__ */new Set();m.has(s.id)||(m.add(s.id),o.set(n.attachmentIndex,m),r.push({card:s,...(n.attachmentIndex!==void 0?{attachmentIndex:n.attachmentIndex}:{})}));}}if(!l)throw new h(n);}return r;}function ie(e,t){var d;const r=t?(d=e.cards)==null?void 0:d.find(l=>l.id===t):F(e);if(!r)return[];const o=J(e,r),i=(e.cards||[]).filter(l=>{var c;return typeof((c=l.customCardPreferences)==null?void 0:c.slotIndex)=="number";}).length>1,n=o!=null&&(N(o)==="multiple"||i);return!o||!n?[r]:Y(Q({frame:e,configCard:o,isMultiInputVisual:!0})).filter(l=>l!==null);}function Pe(e){return se(e.dashboard,e.selections).flatMap(({card:t,attachmentIndex:r})=>{var f,p;const o=((f=e.resolveCardConfig)==null?void 0:f.call(e,t))??t.config,i=_({card:t,cardConfig:o}),n={dashboardId:e.dashboard.id,cardId:t.id,...(r!==void 0?{attachmentIndex:r}:{})},d=i?i.fields.map(s=>({scope:n,target:{kind:"field",fieldId:s.id,role:s.role},format:P(s,{dateStyle:e.valueFormatPreferences.dateStyle,dateTime:{...e.valueFormatPreferences.dateTime}},e.valueFormatPreferences.locale)})):[],l=[],c=R(t,o),g=q(t.python||"");if(t.type==="detailTable"&&c==="config"){const s=(o==null?void 0:o.detailColumns)||[],m=$({groupByColumns:o==null?void 0:o.groupByColumns,metricColumns:o==null?void 0:o.metricColumns,pivotByColumns:o==null?void 0:o.pivotByColumns,detailColumns:s});for(const u of s){const T=z(u.dataType);if(T!=="date"&&T!=="datetime")continue;const w=m.get(u);if(!w)throw new h(n);l.push({scope:n,target:{kind:"column",columnKey:w},format:I({format:M(u),preferences:e.valueFormatPreferences,calendar:e.calendar})});}}else if(c==="freeform"&&(p=t.sql)!=null&&p.trim()&&!g.trim())for(const[s,m]of Object.entries(j(t))){if(m.type!=="date")continue;const u=O(m.dateFormat);u&&l.push({scope:n,target:{kind:"column",columnKey:s},format:I({format:u,preferences:e.valueFormatPreferences,calendar:e.calendar})});}return[...d,...l];});}export{oe as a,ke as b,Ae as c,te as d,Ee as e,Fe as f,ee as g,Se as h,C as i,W as j,Ie as k,re as l,De as m,ae as n,Pe as o,F as p,ne as q,ve as r,_e as s,Be as t};