react-semaphor 0.1.607 → 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 (73) hide show
  1. package/dist/analytics-protocol/index.js +1 -1
  2. package/dist/assistant-context/index.js +1 -1
  3. package/dist/brand-studio/index.js +1 -1
  4. package/dist/briefings/index.js +1 -1
  5. package/dist/chunks/{appearance-provider-C4lPZcaN.js → appearance-provider-BBYTKSjL.js} +59 -59
  6. package/dist/chunks/{assistant-chat-B7Fngg8U.js → assistant-chat-x3NCrm5n.js} +8 -8
  7. package/dist/chunks/attachment-filter-line-ClTS4GvQ.js +1 -0
  8. package/dist/chunks/{bookmark-impact-DjrrJomS.js → bookmark-impact-xCmo8x3V.js} +1 -1
  9. package/dist/chunks/{bookmark-state-x9hJS83D.js → bookmark-state-BmbBu1th.js} +1 -1
  10. package/dist/chunks/{brand-DgFcvKJI.js → brand-3m_qSMyC.js} +1 -1
  11. package/dist/chunks/card-filter-builder-CM3SZ4kO.js +11 -0
  12. package/dist/chunks/{visual-contract-DQPKg5QW.js → check-input-C7S2sNzB.js} +13 -5
  13. package/dist/chunks/{comparison-window-caption-zUZDe4tL.js → comparison-window-caption-WzGsqv4n.js} +1 -1
  14. package/dist/chunks/{currency-presentation-binding-w9WDUk3b.js → currency-presentation-binding-s4PlA3Wu.js} +1 -1
  15. package/dist/chunks/{custom-visual-inputs-D8U98aBz.js → custom-visual-inputs-CUtxCe4T.js} +1 -1
  16. package/dist/chunks/custom-visual-write-CH-k-4HE.js +1 -0
  17. package/dist/chunks/{dashboard-BEd6i29E.js → dashboard-BwuurlUI.js} +1 -1
  18. package/dist/chunks/{dashboard-briefing-launcher-DMDYM9IA.js → dashboard-briefing-launcher-CX7mCnPi.js} +14 -9
  19. package/dist/chunks/{dashboard-controls-5B2vCIjJ.js → dashboard-controls-Bwjy9G1i.js} +3 -3
  20. package/dist/chunks/{dashboard-json-C6r30x-5.js → dashboard-json-B9lK28i0.js} +1 -1
  21. package/dist/chunks/{dashboard-temporal-snapshot-Wki-YACw.js → dashboard-temporal-snapshot-CcndP6CF.js} +1 -1
  22. package/dist/chunks/edit-dashboard-visual-BF3mfrWf.js +103 -0
  23. package/dist/chunks/{filter-line-COFQaF4_.js → filter-line-W-qQAjke.js} +1 -1
  24. package/dist/chunks/{filter-reach-preview-BWRGfSmb.js → filter-reach-preview-DSH_k8AJ.js} +1 -1
  25. package/dist/chunks/filter-value-text-DQwYZHz0.js +1 -0
  26. package/dist/chunks/kpi-trend-rule-DDbguInc.js +1 -0
  27. package/dist/chunks/{layout-grid-DahW4ClC.js → layout-grid-Bx0jBVXj.js} +1 -1
  28. package/dist/chunks/{matrix-analytical-definition-Bd-dXB8q.js → matrix-analytical-definition-jn075ooo.js} +1 -1
  29. package/dist/chunks/{matrix-member-presentation-CfvxPV-i.js → matrix-member-presentation-Chz6uGYz.js} +1 -1
  30. package/dist/chunks/{matrix-operation-contract-Cw7U53Ao.js → matrix-operation-contract-DceN49RX.js} +1 -1
  31. package/dist/chunks/{metric-formatting-QDqXfQGY.js → metric-formatting-DILSVxLq.js} +1 -1
  32. package/dist/chunks/{numeric-range-options-s6i_nDXg.js → numeric-range-options-Drc1EZ6H.js} +1 -1
  33. package/dist/chunks/{palette-CYvJHSqP.js → palette-CZJ4ZCY9.js} +1 -1
  34. package/dist/chunks/{pivot-result-contract-expectations-BX5gLcze.js → pivot-result-contract-expectations-D_ane7I2.js} +1 -1
  35. package/dist/chunks/{pivot-result-identity-DOISzHU4.js → pivot-result-identity-DRhVJMsF.js} +1 -1
  36. package/dist/chunks/{raw-temporal-value-Cssny3RJ.js → raw-temporal-value-B4Md6Xfb.js} +1 -1
  37. package/dist/chunks/{report-preferences-dialog-BNpB9byP.js → report-preferences-dialog-EQNoTych.js} +1 -1
  38. package/dist/chunks/{report-runtime-context-B8HuY0bu.js → report-runtime-context-CkxgMKr6.js} +1 -1
  39. package/dist/chunks/{resolve-dashboard-input-context-B-0tONJg.js → resolve-dashboard-input-context-B5yUS9ZM.js} +2 -2
  40. package/dist/chunks/{sandbox-host-Drf58_oU.js → sandbox-host-WJXxpvz7.js} +1 -1
  41. package/dist/chunks/{saved-dashboard-context-dbdbQ5bB.js → saved-dashboard-context-DQlA4Mg0.js} +1 -1
  42. package/dist/chunks/{selection-filter-compiler-DK8KkS9g.js → selection-filter-compiler-BxtEEB6Z.js} +1 -1
  43. package/dist/chunks/semaphor-ready-indicator-Cq3C2SNo.js +622 -0
  44. package/dist/chunks/{set-oJDaJdtI.js → set-wWdhgHSh.js} +1 -1
  45. package/dist/chunks/slider-C4jUvJtd.js +599 -0
  46. package/dist/chunks/stored-dashboard-1x0q2cNx.js +1 -0
  47. package/dist/chunks/{table-cell-text-2x6r_oHO.js → table-cell-text-DFHUGeG6.js} +1 -1
  48. package/dist/chunks/{table-export-sheet-CWqKiQu4.js → table-export-sheet-CthBUHu4.js} +1 -1
  49. package/dist/chunks/{token-types-BSyWn2pb.js → token-types-BM0mpZce.js} +1 -1
  50. package/dist/chunks/{validators-BPGmPz8-.js → validators-U8IL8djK.js} +1 -1
  51. package/dist/chunks/{variable-draft-DGA22H2g.js → variable-draft-CwX-b6Fs.js} +1 -1
  52. package/dist/dashboard/index.js +1 -1
  53. package/dist/dashboard-authoring/index.js +1 -1
  54. package/dist/extensions/index.js +1 -1
  55. package/dist/format-utils/index.js +1 -1
  56. package/dist/index.js +1 -1
  57. package/dist/report-runtime-context/index.js +1 -1
  58. package/dist/style.css +1 -1
  59. package/dist/surfboard/index.js +1 -1
  60. package/dist/types/index.js +1 -1
  61. package/dist/types/shared/dashboard-authoring/card-settings/custom-visual-write.d.ts +6 -0
  62. package/dist/types/shared/dashboard-authoring/table-sheet-shape.d.ts +8 -0
  63. package/dist/types/shared/extensions/visual-contract.d.ts +3 -1
  64. package/package.json +1 -1
  65. package/dist/chunks/attachment-filter-line-wJRB0GSP.js +0 -1
  66. package/dist/chunks/card-filter-builder-CvxygmsE.js +0 -16
  67. package/dist/chunks/check-input-7DVPUuco.js +0 -1
  68. package/dist/chunks/edit-dashboard-visual-F2w7v4iB.js +0 -83
  69. package/dist/chunks/filter-value-text-BSAMEgve.js +0 -1
  70. package/dist/chunks/kpi-trend-rule-BcnKbY7d.js +0 -1
  71. package/dist/chunks/semaphor-ready-indicator-BSFsqsBJ.js +0 -617
  72. package/dist/chunks/slider-DAvAdfMC.js +0 -599
  73. package/dist/chunks/stored-dashboard-DmgJQcyZ.js +0 -1
@@ -1,83 +0,0 @@
1
- import{jsxs as n,jsx as e,Fragment as be}from"react/jsx-runtime";import{F as js,P as Hs,a as Us,b as yr,u as Be,S as Rn,c as Ln,r as Nr,E as Gs,T as Qs,A as Ws,d as Ys,e as Xs,C as Js,G as Zs,W as el,f as tl,g as al,h as Yt}from"./slider-DAvAdfMC.js";import{Q as nl,m as W,lb as Pn,f6 as Cr,eO as rl,dV as nn,hP as sl,jB as jt,dD as ll,kr as rn,jz as il,I as ol,lc as cl,ld as dl,aS as ul,d2 as ml,bK as hl,v as qa,ka as pl,c1 as fl,le as gl,lf as wr,bq as xl,fB as bl,lg as vl,ks as yl,fY as Nl,A as ya,lh as Cl,li as wl,lj as Sl,lk as Tl,bV as kl,al as Il,ll as El,lm as sn,bh as Fl,r as Sr,T as Ml,hw as Tr,u as Ol,c8 as Al,ih as Rl,hK as kr,dy as Ll,iy as Pl,ln as Dl,ij as _l,kX as Vl,lo as Bl,jL as zl,lp as Kl,lq as ql,lr as Dn,ls as $l,lt as jl,bR as We,lu as Hl,lv as Ul,lw as Gl,lx as Ql,ly as Wl,lz as Yl,lA as _n,lB as Vn,e as Xl,ck as Jl,eb as Zl,e9 as ei,lC as ti,lD as ai,lE as ni,hQ as ri,aK as si,aH as $a,aI as Ir,lF as Er,lG as ln,bd as Xt,l5 as li,a0 as ii,kq as oi}from"./resolve-dashboard-input-context-B-0tONJg.js";import{j as ci}from"./validators-BPGmPz8-.js";import{D as di,t as Fr,u as Mr}from"./matrix-operation-contract-Cw7U53Ao.js";import"./analytics-base-schemas-DMFrDqn_.js";import{DEFAULT_RESOLVED_VALUE_FORMAT_PREFERENCES as Bn}from"../value-format-preferences/index.js";import{cr as ui,cs as mi,bX as Or,cp as Ar,ct as hi,bD as pi,bE as fi,bF as gi,bG as xi,bH as bi,bI as vi,bJ as yi,bK as Ni,bw as Jt,cu as Rr,cv as Ci,bb as on,bi as Lr,c6 as Pr,av as Mt,aw as Ot,ax as At,cw as wi,cx as Si,cy as tt,cz as Ti,cA as ki,cB as Na,cC as Ii,cD as Ei,cE as Fi,cF as Dr,L as _r,cG as cn,cH as Mi,M as Oi,cI as dn,cJ as Ai,cb as Ri,cK as Li,cL as Pi,cM as Zt,cN as Di,bO as _i,c as un,cO as Vr,cP as zn,cQ as Br,cR as Vi,cS as Bi,cT as zi,cU as Ki,cV as qi,cW as $i,cX as ea,cY as ji,cZ as Hi,c_ as zr,c$ as Kr,d0 as Ui,d1 as Gi,c2 as Qi,d2 as Wi,d3 as qr,d4 as Yi,bN as Xi,bM as mn,d5 as hn,aA as $r,aC as Ji,aD as Kn,aE as Zi,aF as eo,aG as to,cg as ao,aI as no,aJ as ro,aK as so,aL as lo,aM as io,aN as oo,d6 as co,d7 as uo,b4 as mo,b5 as ho,b2 as po,d8 as fo,d9 as go,da as xo,db as bo,b7 as vo,b8 as yo,dc as No,dd as Co,de as wo,df as So,dg as To,dh as jr,bz as Hr,di as ra,dj as Se,dk as Te,dl as ke,bS as ko,bT as Io,dm as Eo,H as Fo,aS as qn,dn as Mo,dp as sa,dq as Ur,dr as Gr,ds as Qr,dt as pn,du as ja,dv as Oo,dw as Ao,dx as Ro,dy as Lo,dz as Ha,dA as Po,dB as et,dC as Do,ch as la,dD as _o,dE as Wr,dF as Vo,dG as Bo,dH as Yr,dI as zo,dJ as Ko,dK as $n,dL as qo,dM as $o,dN as jo,dO as Ho,dP as Uo,dQ as Go,dR as Qo,dS as Wo,dT as Yo,dU as Xo,ci as Jo,dV as Zo,dW as ec,dX as tc,dY as ac,dZ as nc,u as rc,d_ as sc,aH as lc,d$ as ic,e0 as jn,e1 as oc,e2 as cc,F as dc,e3 as uc,aX as mc}from"./semaphor-ready-indicator-BSFsqsBJ.js";import{c as De,F as E,b8 as je,co as Xr,cp as hc,cq as pc,aK as Rt,a2 as dt,P as it,c8 as fc,B as ce,X as ia,e as ot,an as Lt,ao as mt,ap as ht,ar as pt,ag as oa,C as qt,aZ as Ht,a_ as Ut,b2 as ft,a$ as ca,b0 as Gt,b3 as gt,b4 as qe,b1 as Et,b5 as Ye,b as xt,g as fn,bK as wt,aY as $e,bW as gc,bE as ut,cr as xc,G as me,b9 as gn,u as fe,b6 as bt,b7 as Ca,cs as bc,av as D,ct as Ua,d as Ft,ac as nt,cu as Jr,cv as xn,aX as ta,aw as vc,bZ as bn,$ as vn,cw as da,cx as Zr,bP as yn,bO as es,E as ua,cy as yc,cz as Nc,cA as Cc,bv as wc,ak as ts,bB as ma,bC as ha,cB as Ga,cc as aa,bD as pa,cC as Sc,cD as Tc,ax as Nn,bS as Hn,aJ as as,cE as kc,cF as fa,aq as ns,af as rs,a4 as ne,a5 as re,a6 as se,a7 as le,a8 as U,aa as ga,cG as Ic,cH as Un,cI as Ec,cJ as ss,cK as ls,bb as Fc,bc as Mc,bd as Oc,be as Ac,cL as Gn,cM as Rc,cN as St,cO as Tt,cP as kt,al as xa,by as Ge,bG as Qn,bH as Wn,bI as Qa,ah as Lc,cQ as is,cR as Pc,cS as Dc,cT as _c,cU as Vc,cV as Bc,a3 as Wa,ab as we,cW as zc,cX as Kc,au as Kt,cY as qc,cZ as $c,c_ as jc,c$ as Hc,V as Uc,d0 as Gc,d1 as Qc,d2 as Yn,d3 as Wc,d4 as wa,d5 as Xn,d6 as Yc,d7 as Xc,aV as Cn,aW as $t,d8 as Sa,d9 as os,da as Jc,aj as cs,bU as Zc,db as ed,dc as td,bQ as ad,bR as nd,dd as rd,bA as sd,bT as ld,de as id,cj as od,df as cd,ck as dd,cm as ud,cn as md,dg as hd,dh as pd,cd as fd,A as gd,bX as xd}from"./appearance-provider-C4lPZcaN.js";import Ya,{useState as Y,useRef as Ee,useEffect as ve,useCallback as rt,useMemo as X,useContext as wn,Suspense as bd}from"react";import{aY as vd,aJ as yd,aQ as Nd,k as Cd}from"./pivot-result-contract-expectations-BX5gLcze.js";import"zod";import{aK as ds,aL as us,A as wd}from"./bookmark-state-x9hJS83D.js";import"./schema-O1Y3WTGF.js";import{i as ms}from"./index-DViPGDFj.js";import{f as vt,r as yt,g as Qt,a as at,c as It,i as Sd,d as Td,e as kd,b as hs,n as Id,h as Xa,j as Ed,k as Fd,l as Md}from"./custom-visual-inputs-D8U98aBz.js";import"./context-Cwj8Axgd.js";import{F as Od,V as ps,I as Ve,u as Ad,a as Rd,C as Ld,b as Pd}from"./card-filter-builder-CvxygmsE.js";import{N as Sn,I as Dd,b as _d,Q as Vd,R as Bd,U as zd}from"./filter-reach-preview-BWRGfSmb.js";import{H as Kd,k as qd,I as $d,J as jd,w as Hd}from"./stored-dashboard-DmgJQcyZ.js";import"react-dom";import{c as Ud,b as Gd,m as Qd,w as Wd,K as Yd,d as Xd}from"./kpi-trend-rule-BcnKbY7d.js";import{e as Jd,m as Zd,d as fs,n as eu,f as gs,o as tu,b as au}from"./currency-presentation-binding-w9WDUk3b.js";import{d as nu,e as ru,s as su,h as Tn,i as kn}from"./metric-formatting-QDqXfQGY.js";import{r as lu}from"./export-file-format-B-wQNHIn.js";import{u as iu}from"./appearance-runtime-provider-De2VZS4F.js";import{v as ou}from"./visual-contract-DQPKg5QW.js";import{r as xs,b as bs}from"./sandbox-host-Drf58_oU.js";import{a as Jn,e as Zn}from"./check-input-7DVPUuco.js";import{M as cu,K as er,L as Ta}from"./set-oJDaJdtI.js";import{b as tr}from"./raw-temporal-value-Cssny3RJ.js";import{P as du}from"./palette-CYvJHSqP.js";import{u as uu}from"./table-cell-text-2x6r_oHO.js";/**
2
- * @license lucide-react v0.453.0 - ISC
3
- *
4
- * This source code is licensed under the ISC license.
5
- * See the LICENSE file in the root directory of this source tree.
6
- */const vs=De("ArrowUpDown",[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]]);/**
7
- * @license lucide-react v0.453.0 - ISC
8
- *
9
- * This source code is licensed under the ISC license.
10
- * See the LICENSE file in the root directory of this source tree.
11
- */const ys=De("Blocks",[["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["path",{d:"M10 21V8a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-5a1 1 0 0 0-1-1H3",key:"1fpvtg"}]]);/**
12
- * @license lucide-react v0.453.0 - ISC
13
- *
14
- * This source code is licensed under the ISC license.
15
- * See the LICENSE file in the root directory of this source tree.
16
- */const mu=De("CircleHelp",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/**
17
- * @license lucide-react v0.453.0 - ISC
18
- *
19
- * This source code is licensed under the ISC license.
20
- * See the LICENSE file in the root directory of this source tree.
21
- */const hu=De("ClipboardPaste",[["path",{d:"M15 2H9a1 1 0 0 0-1 1v2c0 .6.4 1 1 1h6c.6 0 1-.4 1-1V3c0-.6-.4-1-1-1Z",key:"1pp7kr"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2M16 4h2a2 2 0 0 1 2 2v2M11 14h10",key:"2ik1ml"}],["path",{d:"m17 10 4 4-4 4",key:"vp2hj1"}]]);/**
22
- * @license lucide-react v0.453.0 - ISC
23
- *
24
- * This source code is licensed under the ISC license.
25
- * See the LICENSE file in the root directory of this source tree.
26
- */const pu=De("Component",[["path",{d:"M15.536 11.293a1 1 0 0 0 0 1.414l2.376 2.377a1 1 0 0 0 1.414 0l2.377-2.377a1 1 0 0 0 0-1.414l-2.377-2.377a1 1 0 0 0-1.414 0z",key:"1uwlt4"}],["path",{d:"M2.297 11.293a1 1 0 0 0 0 1.414l2.377 2.377a1 1 0 0 0 1.414 0l2.377-2.377a1 1 0 0 0 0-1.414L6.088 8.916a1 1 0 0 0-1.414 0z",key:"10291m"}],["path",{d:"M8.916 17.912a1 1 0 0 0 0 1.415l2.377 2.376a1 1 0 0 0 1.414 0l2.377-2.376a1 1 0 0 0 0-1.415l-2.377-2.376a1 1 0 0 0-1.414 0z",key:"1tqoq1"}],["path",{d:"M8.916 4.674a1 1 0 0 0 0 1.414l2.377 2.376a1 1 0 0 0 1.414 0l2.377-2.376a1 1 0 0 0 0-1.414l-2.377-2.377a1 1 0 0 0-1.414 0z",key:"1x6lto"}]]);/**
27
- * @license lucide-react v0.453.0 - ISC
28
- *
29
- * This source code is licensed under the ISC license.
30
- * See the LICENSE file in the root directory of this source tree.
31
- */const fu=De("FileJson2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M4 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1",key:"fq0c9t"}],["path",{d:"M8 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1",key:"4gibmv"}]]);/**
32
- * @license lucide-react v0.453.0 - ISC
33
- *
34
- * This source code is licensed under the ISC license.
35
- * See the LICENSE file in the root directory of this source tree.
36
- */const gu=De("Fullscreen",[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["rect",{width:"10",height:"8",x:"7",y:"8",rx:"1",key:"vys8me"}]]);/**
37
- * @license lucide-react v0.453.0 - ISC
38
- *
39
- * This source code is licensed under the ISC license.
40
- * See the LICENSE file in the root directory of this source tree.
41
- */const xu=De("LayoutTemplate",[["rect",{width:"18",height:"7",x:"3",y:"3",rx:"1",key:"f1a2em"}],["rect",{width:"9",height:"7",x:"3",y:"14",rx:"1",key:"jqznyg"}],["rect",{width:"5",height:"7",x:"16",y:"14",rx:"1",key:"q5h2i8"}]]);/**
42
- * @license lucide-react v0.453.0 - ISC
43
- *
44
- * This source code is licensed under the ISC license.
45
- * See the LICENSE file in the root directory of this source tree.
46
- */const ka=De("MoveHorizontal",[["path",{d:"m18 8 4 4-4 4",key:"1ak13k"}],["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}]]);/**
47
- * @license lucide-react v0.453.0 - ISC
48
- *
49
- * This source code is licensed under the ISC license.
50
- * See the LICENSE file in the root directory of this source tree.
51
- */const Ia=De("MoveVertical",[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"m8 18 4 4 4-4",key:"bh5tu3"}],["path",{d:"m8 6 4-4 4 4",key:"ybng9g"}]]);/**
52
- * @license lucide-react v0.453.0 - ISC
53
- *
54
- * This source code is licensed under the ISC license.
55
- * See the LICENSE file in the root directory of this source tree.
56
- */const Ja=De("RefreshCcw",[["path",{d:"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"14sxne"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16",key:"1hlbsb"}],["path",{d:"M16 16h5v5",key:"ccwih5"}]]);/**
57
- * @license lucide-react v0.453.0 - ISC
58
- *
59
- * This source code is licensed under the ISC license.
60
- * See the LICENSE file in the root directory of this source tree.
61
- */const bu=De("SendHorizontal",[["path",{d:"M3.714 3.048a.498.498 0 0 0-.683.627l2.843 7.627a2 2 0 0 1 0 1.396l-2.842 7.627a.498.498 0 0 0 .682.627l18-8.5a.5.5 0 0 0 0-.904z",key:"117uat"}],["path",{d:"M6 12h16",key:"s4cdu5"}]]);/**
62
- * @license lucide-react v0.453.0 - ISC
63
- *
64
- * This source code is licensed under the ISC license.
65
- * See the LICENSE file in the root directory of this source tree.
66
- */const vu=De("Spline",[["circle",{cx:"19",cy:"5",r:"2",key:"mhkx31"}],["circle",{cx:"5",cy:"19",r:"2",key:"v8kfzx"}],["path",{d:"M5 17A12 12 0 0 1 17 5",key:"1okkup"}]]);/**
67
- * @license lucide-react v0.453.0 - ISC
68
- *
69
- * This source code is licensed under the ISC license.
70
- * See the LICENSE file in the root directory of this source tree.
71
- */const yu=De("SquareSplitVertical",[["path",{d:"M5 8V5c0-1 1-2 2-2h10c1 0 2 1 2 2v3",key:"1pi83i"}],["path",{d:"M19 16v3c0 1-1 2-2 2H7c-1 0-2-1-2-2v-3",key:"ido5k7"}],["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}]]);/**
72
- * @license lucide-react v0.453.0 - ISC
73
- *
74
- * This source code is licensed under the ISC license.
75
- * See the LICENSE file in the root directory of this source tree.
76
- */const Nu=De("Tags",[["path",{d:"m15 5 6.3 6.3a2.4 2.4 0 0 1 0 3.4L17 19",key:"1cbfv1"}],["path",{d:"M9.586 5.586A2 2 0 0 0 8.172 5H3a1 1 0 0 0-1 1v5.172a2 2 0 0 0 .586 1.414L8.29 18.29a2.426 2.426 0 0 0 3.42 0l3.58-3.58a2.426 2.426 0 0 0 0-3.42z",key:"135mg7"}],["circle",{cx:"6.5",cy:"9.5",r:".5",fill:"currentColor",key:"5pm5xn"}]]);/**
77
- * @license lucide-react v0.453.0 - ISC
78
- *
79
- * This source code is licensed under the ISC license.
80
- * See the LICENSE file in the root directory of this source tree.
81
- */const Ns=De("TrendingUp",[["polyline",{points:"22 7 13.5 15.5 8.5 10.5 2 17",key:"126l90"}],["polyline",{points:"16 7 22 7 22 13",key:"kwv8wd"}]]);function ba(){var d,l;const t=E(o=>o.card),{data:a,comparisonMetadata:s}=je(t),r=(a==null?void 0:a.records)||[],{keys:i}=Xr(r,s),c=i.slice(1).filter(o=>!nl.includes(o));if(uu(t.type)){const o=t.config,x=(d=o==null?void 0:o.pivotByColumns)!=null&&d.length&&(l=o==null?void 0:o.groupByColumns)!=null&&l.length?hc(r,o.metricColumns||[]):r,u=pc({card:t,cardType:t.type,records:x,columnKeyMap:a==null?void 0:a.columnKeyMap,comparisonMetadata:s});return{transformedMetricKeys:u.valueKeys,dimensionKeys:u.axisKeys,keys:i,defaultMetricKeys:c};}return{transformedMetricKeys:c,dimensionKeys:i.slice(0,1),keys:i,defaultMetricKeys:c};}function Cs({isVisible:t}){return ui(),/* @__PURE__ */n("div",{className:W("flex shrink-0 flex-col overflow-hidden border-r border-border bg-background transition-all duration-300 ease-in-out",{"w-[290px]":t,"min-w-[290px]":t,"w-0 border-r-0":!t,"min-w-0":!t}),children:[/* @__PURE__ */e("div",{className:"px-4 pt-4",children:/* @__PURE__ */e(mi,{})}),/* @__PURE__ */e("div",{className:"min-h-0 flex-1",children:/* @__PURE__ */e(js,{})})]});}const Za=({className:t,...a})=>/* @__PURE__ */e(Us,{className:W("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",t),...a}),Ct=Hs,ws=({withHandle:t,className:a,...s})=>/* @__PURE__ */e(yr,{className:W("group relative flex w-px items-center justify-center bg-border after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:-translate-y-1/2 data-[panel-group-direction=vertical]:after:translate-x-0 [&[data-panel-group-direction=vertical]>div]:rotate-90",a),...s,children:t&&/* @__PURE__ */e(Ss,{className:"top-1/2 -translate-y-1/2 group-data-[panel-group-direction=horizontal]:h-8 group-data-[panel-group-direction=horizontal]:w-[3px]"})}),Ss=({className:t})=>/* @__PURE__ */e("span",{"aria-hidden":!0,className:W("pointer-events-none absolute left-1/2 z-10 h-[3px] w-8 -translate-x-1/2 rounded-[2px] bg-transparent transition-colors group-data-[resize-handle-state=drag]:bg-foreground/50 group-data-[resize-handle-state=hover]:bg-foreground/20",t)}),Cu=3,en="Self-heal",Ea={grounding:"Analyzing context",drafting:"Drafting SQL",validating:"Validating SQL",repairing:en},Pt="Unable to generate a SQL draft right now. Try again.",wu="Choose a data source for this card before describing a query.",Su="Validation service unavailable. You can still replace and run.";function Dt(t,a){typeof window>"u"||window.dispatchEvent(new CustomEvent("semaphor:inline-query-writer",{detail:{event:t,...a,timestamp:Date.now()}}));}const _t={runId:0,status:"idle",prompt:"",mode:"draft",baselineSql:"",timelineSteps:[],activeStep:"",attempt:0,sql:"",validation:null,errorMessage:""};function Tu(t,a){return t===en&&a>0?`${en} ${a}/${Cu}`:t;}async function ku(t,a){try{const s=await t.json();if(typeof(s==null?void 0:s.error)=="string"&&s.error.trim())return s.error;}catch{}return a;}async function Iu(t,a){const s=d=>{const l=d.trim();l&&a(JSON.parse(l));};if(!t.body){(await t.text()).split(`
82
- `).forEach(s);return;}const r=t.body.getReader(),i=new TextDecoder();let c="";for(;;){const{done:d,value:l}=await r.read();if(d)break;c+=i.decode(l,{stream:!0});const o=c.split(`
83
- `);c=o.pop()??"",o.forEach(s);}s(c+i.decode());}function Eu({currentSql:t,selectedDatabaseName:a,selectedSchemaName:s,selectedTableName:r,onApplySql:i,autoFocus:c,onDismiss:d}){var Xe,Je;const{authToken:l,tokenProps:o}=Rt(),x=E(ee=>ee.card.id),u=E(ee=>{var ye;return ee.card.connectionId||((ye=ee.card.dataSource)==null?void 0:ye.connectionId)||"";}),[p,h]=Y(""),[m,C]=Y("draft"),[S,w]=Y(!1),[v,y]=Y(!1),[A,b]=Y(_t),[z,B]=Y(x),j=Ee(null),$=Ee(0),I=Ee(null),O=(Xe=o.apiServiceUrl)==null?void 0:Xe.replace(/\/$/,""),L=O?`${O}/v1/sql/draft`:"/v1/sql/draft";function k(){var ee;$.current+=1,(ee=I.current)==null||ee.abort(),I.current=null;}ve(()=>()=>{var ee;$.current+=1,(ee=I.current)==null||ee.abort(),I.current=null;},[x]),z!==x&&(B(x),b(ee=>({..._t,runId:ee.runId})),h(""),w(!1));const K=A.status==="running";function M(){A.status==="running"&&(k(),b(ee=>({...ee,status:"idle",activeStep:"",sql:"",validation:null})),Dt("inline_self_heal_stopped",{runId:A.runId,attemptCount:A.attempt,finalOutcome:"cancelled"}));}async function f(ee,ye,Ae){const _e=()=>$.current===ee,Le=xe=>{_e()&&b(oe=>oe.runId===ee?xe(oe):oe);},Pe=xe=>Le(oe=>({...oe,status:"failed",activeStep:"",errorMessage:xe}));let He=!1;const Ze=xe=>{var Oe;if(!_e()||He)return;if(xe.type==="stage"){const H=Ea[xe.stage];if(!H)return;const Ie=xe.stage==="repairing"?xe.attempt??0:0;Le(te=>({...te,timelineSteps:te.timelineSteps.includes(H)?te.timelineSteps:[...te.timelineSteps,H],activeStep:H,attempt:xe.stage==="repairing"?Ie:te.attempt})),xe.stage==="repairing"&&Dt("inline_self_heal_attempt",{runId:ee,attemptCount:Ie});return;}if(He=!0,xe.type==="error"){Pe(xe.message||Pt);return;}const oe=((Oe=xe.sql)==null?void 0:Oe.trim())||"";if(!oe){Pe(Pt);return;}Le(H=>({...H,status:"done",activeStep:"",sql:oe,validation:xe.validation})),xe.validation.status==="invalid"?Dt("inline_validation_failed",{runId:ee,attemptCount:xe.repairs,errorCode:xe.validation.code,finalOutcome:"validation_failed"}):Dt("inline_draft_validated",{runId:ee,attemptCount:xe.repairs,finalOutcome:xe.validation.status});};try{const xe=await fetch(L,{method:"POST",headers:{Authorization:`Bearer ${l==null?void 0:l.accessToken}`,"Content-Type":"application/json"},credentials:"omit",body:JSON.stringify(ye),signal:Ae});if(!_e())return;if(!xe.ok){Pe(await ku(xe,Pt));return;}await Iu(xe,Ze),He||Pe(Pt);}catch{Pe(Pt);}finally{_e()&&(I.current=null);}}const F=(t==null?void 0:t.trim())||"";function g(ee="draft"){if(K)return;const ye=p.trim();if(!ye)return;const Ae=ee==="refine"&&F?"refine":"draft",_e=Ae==="refine"?F:"";k();const Le=$.current;if(w(!1),y(!0),!u){b({..._t,runId:Le,status:"failed",prompt:ye,errorMessage:wu});return;}b({..._t,runId:Le,status:"running",prompt:ye,mode:Ae,baselineSql:_e}),Dt("inline_draft_started",{runId:Le,attemptCount:0,finalOutcome:"drafting"});const Pe=new AbortController();I.current=Pe,f(Le,{request:ye,mode:Ae,...(F?{currentSql:F}:{}),connectionId:u,...(a?{database:a}:{}),...(s?{schema:s}:{}),...(r?{table:r}:{})},Pe.signal);}const N=A.status==="done"?A.sql:"",T=A.prompt,_=A.mode,P=A.baselineSql;function R(ee){const ye=N.trim();ye&&(i(ye,ee),ee||y(!1));}const V=N.length>0,Q=((Je=A.validation)==null?void 0:Je.status)==="invalid",J=V&&T.length>0&&T===p.trim(),Z=F.length>0,G=p.trim().length>0,q=!!d&&!G&&!V&&!K,ae=J&&_==="draft",de=J&&_==="refine"&&P===F,he=m==="refine"&&!Z?"draft":m,pe=(he==="refine"?de:ae)?"Open composer preview":"Generate composer SQL",ge=p.trim().length>0||T.trim().length>0||V||A.status!=="idle"||A.timelineSteps.length>0;function Fe(ee="draft"){if(K)return;if((ee==="refine"?de:ae)&&!v){y(!0);return;}g(ee);}function Re(){y(!0);}function Ue(ee){M(),h(ee);}function ue(){K||(k(),h(""),C("draft"),w(!1),b({..._t,runId:$.current}));}function Ce(ee){ee||M(),y(ee);}const Me=A.timelineSteps.findIndex(ee=>ee===A.activeStep),st=A.activeStep===Ea.repairing?"Fixing validation issue":A.activeStep||Ea.drafting,ze=!V||!A.validation?null:A.validation.status==="valid"?{label:"Validation passed",className:"border-emerald-500/30 bg-emerald-500/10 text-emerald-700",detail:"SQL validation passed."}:A.validation.status==="invalid"?{label:"Validation failed",className:"border-destructive/40 bg-destructive/10 text-destructive",detail:A.validation.message}:{label:"Validation unavailable",className:"border-border/60 bg-muted/20 text-muted-foreground",detail:Su};return/* @__PURE__ */n("div",{ref:j,className:"relative flex h-7 min-w-0 flex-1 items-center",children:[/* @__PURE__ */e(dt,{value:p,onChange:ee=>Ue(ee.target.value),autoFocus:c,onFocus:Re,onClick:Re,onKeyDown:ee=>{ee.key==="Enter"?(ee.preventDefault(),Fe(he)):ee.key==="Escape"&&q&&(d==null||d());},placeholder:"Describe the query you want, or a change to this one…","aria-label":"Describe a query",className:["h-7 rounded-[5px] border border-border/60 bg-background pl-3 text-[12px] shadow-none placeholder:text-muted-foreground/70 focus-visible:border-ring focus-visible:ring-0",G?"pr-[56px]":d?"pr-9":"pr-3"].join(" ")}),/* @__PURE__ */n(it,{open:v,onOpenChange:Ce,children:[/* @__PURE__ */e(fc,{asChild:!0,children:/* @__PURE__ */e("div",{className:"pointer-events-none absolute inset-0"})}),/* @__PURE__ */n("div",{className:"absolute right-1 flex items-center gap-1",children:[(G||d)&&/* @__PURE__ */e(ce,{type:"button",variant:"ghost",size:"sm",className:"size-6 p-0",onClick:ee=>{ee.preventDefault(),G?(M(),h("")):q?d==null||d():ue();},disabled:K,"aria-label":G?"Clear input":q?"Close":"Clear draft",title:G?"Clear input":q?"Close":"Clear draft",children:/* @__PURE__ */e(ia,{className:"size-3.5"})}),G&&/* @__PURE__ */e(ce,{type:"button",variant:"ghost",size:"sm",className:"size-6 p-0",onClick:ee=>{if(ee.preventDefault(),K){M();return;}Fe(he);},"aria-label":K?"Stop AI generation":pe,title:K?"Stop AI generation":pe,children:K?/* @__PURE__ */e(Or,{className:"size-3 fill-current"}):/* @__PURE__ */e(bu,{className:"size-3.5"})})]}),/* @__PURE__ */e(ot,{align:"start",alignOffset:0,side:"top",sideOffset:8,className:"w-[min(92vw,var(--radix-popover-trigger-width))] max-w-[760px] p-2.5",onOpenAutoFocus:ee=>{ee.preventDefault();},onInteractOutside:ee=>{var Ae;const ye=ee.target;if(ye&&(Ae=j.current)!=null&&Ae.contains(ye)){ee.preventDefault();return;}q&&(d==null||d());},children:/* @__PURE__ */n("div",{className:"space-y-2",children:[/* @__PURE__ */n("div",{className:"flex items-center justify-between gap-3",children:[/* @__PURE__ */e("div",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-2",children:/* @__PURE__ */n("div",{className:"inline-flex h-7 items-center rounded-[5px] border border-border/60 bg-background p-0.5",children:[/* @__PURE__ */e(ce,{type:"button",variant:"ghost",className:["h-6 rounded-[4px] px-2 text-[12px]",he==="draft"?"bg-accent text-foreground":"text-muted-foreground hover:text-foreground"].join(" "),onClick:()=>{C("draft"),w(!1);},children:"Draft New"}),/* @__PURE__ */e(ce,{type:"button",variant:"ghost",className:["h-6 rounded-[4px] px-2 text-[12px]",he==="refine"?"bg-accent text-foreground":"text-muted-foreground hover:text-foreground"].join(" "),onClick:()=>C("refine"),disabled:!Z,children:"Refine"})]})}),/* @__PURE__ */n("div",{className:"flex shrink-0 items-center",children:[K&&/* @__PURE__ */e(ce,{variant:"ghost",size:"xs",onClick:M,children:"Stop"}),!K&&/* @__PURE__ */e(ce,{variant:"ghost",size:"xs",onClick:ue,disabled:!ge,children:"Clear"})]})]}),(A.timelineSteps.length>0||ze)&&/* @__PURE__ */n("div",{className:"flex flex-wrap items-center gap-1",children:[A.timelineSteps.map((ee,ye)=>{const Ae=K&&ee===A.activeStep,_e=!Ae&&Me>=0&&ye<Me;return/* @__PURE__ */e("span",{className:["rounded-full border px-2 py-0.5 text-[11px]",Ae?"border-foreground/30 bg-foreground/10 text-foreground":_e?"border-border/60 bg-muted/20 text-muted-foreground":"border-border/50 bg-background text-muted-foreground/80"].join(" "),children:Tu(ee,A.attempt)},`${ee}-${ye}`);}),ze&&/* @__PURE__ */e(Lt,{delayDuration:150,children:/* @__PURE__ */n(mt,{children:[/* @__PURE__ */e(ht,{asChild:!0,children:/* @__PURE__ */e("span",{className:["rounded-full border px-2 py-0.5 text-[11px]",ze.className].join(" "),children:ze.label})}),/* @__PURE__ */e(pt,{side:"top",align:"start",className:"max-w-[680px] whitespace-pre-wrap break-words text-xs",children:ze.detail})]})})]}),K&&/* @__PURE__ */n("div",{className:"flex items-center gap-2 rounded-md border border-border/60 bg-muted/20 px-3 py-2 text-xs text-muted-foreground",children:[/* @__PURE__ */e(oa,{className:"size-3.5 animate-spin"}),st]}),A.status==="failed"&&/* @__PURE__ */e("div",{className:"rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-xs text-destructive",children:A.errorMessage}),_==="refine"&&P&&/* @__PURE__ */n("div",{className:"space-y-1",children:[/* @__PURE__ */n("div",{className:"flex items-center justify-between rounded-[5px] border border-border/60 bg-muted/20 px-2.5 py-1.5 text-[11px]",children:[/* @__PURE__ */e("span",{className:"text-muted-foreground",children:"Refining editor SQL"}),/* @__PURE__ */e(ce,{type:"button",variant:"ghost",size:"xs",onClick:()=>w(ee=>!ee),children:S?"Hide base SQL":"View base SQL"})]}),S&&/* @__PURE__ */e("div",{className:"max-h-[120px] overflow-auto rounded-[5px] border border-border/60",children:/* @__PURE__ */e(qt,{value:P,onValueChange:()=>{},language:"sql",readOnly:!0,embedded:!0,wrapLines:!0,dense:!0,hideLineNumbers:!0,ariaLabel:"Base SQL"})})]}),V?/* @__PURE__ */n("div",{className:"space-y-1",children:[_==="refine"&&/* @__PURE__ */e("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Refined SQL"}),/* @__PURE__ */e("div",{className:"max-h-[200px] overflow-auto rounded-[5px] border border-border/60",children:/* @__PURE__ */e(qt,{value:N,onValueChange:()=>{},language:"sql",readOnly:!0,embedded:!0,wrapLines:!0,dense:!0,hideLineNumbers:!0,ariaLabel:"Drafted SQL"})})]}):!K&&/* @__PURE__ */e("div",{className:"rounded-[5px] border border-dashed border-border/70 px-3 py-2 text-[11px] text-muted-foreground",children:Z?"Choose Draft New or Refine Current, then press Enter or click send.":"Describe what you want to query, then press Enter or click send to generate a SQL preview."}),/* @__PURE__ */n("div",{className:"flex flex-wrap items-center justify-end gap-1.5",children:[/* @__PURE__ */e(ce,{variant:"secondary",size:"xs",disabled:K||!V,onClick:()=>R(!1),children:"Replace SQL"}),/* @__PURE__ */e(ce,{size:"xs",disabled:K||!V||Q,onClick:()=>R(!0),children:"Replace & Run"})]})]})})]})]});}function Fu({activeEditor:t,isRunning:a,sqlEditor:s,pythonEditor:r,onActiveEditorChange:i,onOpenChange:c,onRun:d}){return/* @__PURE__ */e(Ht,{open:t!==null,onOpenChange:c,children:/* @__PURE__ */e(Ut,{showCloseButton:!1,className:"flex h-[min(88vh,860px)] w-[min(1280px,calc(100vw-2rem))] max-w-none flex-col gap-0 overflow-hidden p-0",children:/* @__PURE__ */n(ft,{value:t??"sql",onValueChange:o=>i(o),className:"flex min-h-0 flex-1 flex-col",children:[/* @__PURE__ */n(ca,{className:"h-11 flex-row items-center justify-between space-y-0 border-b border-border/60 px-4 py-0 text-left",children:[/* @__PURE__ */n("div",{className:"flex min-w-0 items-center gap-4 self-stretch",children:[/* @__PURE__ */e(Gt,{className:"shrink-0 text-sm",children:"Query editor"}),/* @__PURE__ */n(gt,{variant:"underline",className:"h-full items-end gap-5 self-stretch border-b-0",children:[/* @__PURE__ */e(qe,{value:"sql",className:"px-0",children:"SQL"}),/* @__PURE__ */e(qe,{value:"python",className:"px-0",children:"Python"})]}),/* @__PURE__ */e(Et,{className:"sr-only",children:"Expanded SQL and Python query editor"})]}),/* @__PURE__ */n("div",{className:"flex shrink-0 items-center gap-1.5",children:[/* @__PURE__ */n(ce,{type:"button",size:"xs",onClick:d,disabled:a,children:[a?/* @__PURE__ */e(oa,{className:"h-3.5 w-3.5 animate-spin"}):/* @__PURE__ */e(Ar,{className:"h-3.5 w-3.5"}),"Run"]}),/* @__PURE__ */e(ce,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>c(!1),"aria-label":"Collapse query editor",title:"Collapse editor",children:/* @__PURE__ */e(hi,{className:"h-3.5 w-3.5"})})]})]}),/* @__PURE__ */e(Ye,{value:"sql",forceMount:!0,className:"mt-0 min-h-0 flex-1 data-[state=inactive]:hidden",children:s}),/* @__PURE__ */e(Ye,{value:"python",forceMount:!0,className:"mt-0 min-h-0 flex-1 data-[state=inactive]:hidden",children:r})]})})});}function ar(t,a){return t.current.cardId!==a&&(t.current={cardId:a,snapshots:{}}),t.current;}function Mu({cardId:t,expandedEditor:a}){const s=Ee(null),r=Ee(null),i=Ee(null),c=Ee(null),d=Ee({cardId:t,snapshots:{}}),l=rt(o=>{var C,S;const x=o==="inline"?s:i,u=o==="inline"?r:c,p=(C=x.current)==null?void 0:C.captureSession(),h=(S=u.current)==null?void 0:S.captureSession(),m=ar(d,t);p&&(m.snapshots.sql=p),h&&(m.snapshots.python=h);},[t]);return ve(()=>{var m,C;const o=ar(d,t),x=a===null?s:i,u=a===null?r:c,{sql:p,python:h}=o.snapshots;p&&((m=x.current)==null||m.restoreSession(p)),h&&((C=u.current)==null||C.restoreSession(h));},[t,a]),{inlineSqlEditorRef:s,inlinePythonEditorRef:r,expandedSqlEditorRef:i,expandedPythonEditorRef:c,captureEditorSessions:l};}function Ts({openDelay:t=200,closeDelay:a=150}={}){const[s,r]=Y(!1),i=Ee(null),c=Ee(null),d=Ee(!1),l=()=>{i.current&&(clearTimeout(i.current),i.current=null);},o=()=>{c.current&&(clearTimeout(c.current),c.current=null);};ve(()=>()=>{i.current&&clearTimeout(i.current),c.current&&clearTimeout(c.current);},[]);const x=p=>{p.pointerType!=="touch"&&(o(),!s&&(l(),i.current=setTimeout(()=>r(!0),t)));},u=p=>{p.pointerType!=="touch"&&(l(),o(),c.current=setTimeout(()=>r(!1),a));};return{popoverProps:{open:s,onOpenChange:r},triggerProps:{onPointerEnter:x,onPointerLeave:u,onFocus:()=>{l(),o(),d.current||r(!0);},onClick:p=>{p.preventDefault(),l(),o(),r(!0);}},contentProps:{onCloseAutoFocus:()=>{d.current=!0,queueMicrotask(()=>{d.current=!1;});},onPointerEnter:p=>{p.pointerType!=="touch"&&o();},onPointerLeave:u}};}function Ou({value:t}){const[a,s]=Y(!1),r=Ee(null);ve(()=>()=>{r.current&&clearTimeout(r.current);},[]);const i=async()=>{var c;try{if(!((c=navigator.clipboard)!=null&&c.writeText))throw new Error("Clipboard API unavailable");await navigator.clipboard.writeText(t),s(!0),r.current&&clearTimeout(r.current),r.current=setTimeout(()=>s(!1),1200);}catch{$e.error("Failed to copy");}};return/* @__PURE__ */n("button",{type:"button","aria-label":`Copy ${t}`,onClick:i,className:"group inline-flex w-full cursor-pointer items-center justify-start rounded-[3px] bg-muted/35 px-2 py-1.5 text-left font-mono text-[11px] text-foreground transition-colors hover:bg-muted/60 focus-visible:bg-muted/60 focus-visible:outline-none",children:[/* @__PURE__ */e("code",{children:t}),a?/* @__PURE__ */e(fn,{"aria-hidden":"true",className:"ml-auto size-3.5 shrink-0 text-emerald-600/80 dark:text-emerald-400/80",strokeWidth:1.75}):/* @__PURE__ */e(wt,{"aria-hidden":"true",className:"ml-auto size-3.5 shrink-0 text-muted-foreground/60 transition-colors group-hover:text-muted-foreground group-focus-visible:text-muted-foreground",strokeWidth:1.75}),/* @__PURE__ */e("span",{className:"sr-only","aria-live":"polite",children:a?"Copied to clipboard":""})]});}function Au({hint:t}){const{popoverProps:a,triggerProps:s,contentProps:r}=Ts();return/* @__PURE__ */n(it,{...a,children:[/* @__PURE__ */e(xt,{asChild:!0,children:/* @__PURE__ */n(ce,{type:"button",variant:"ghost",size:"xs","aria-label":"Dashboard filters off",...s,className:"h-7 w-7 shrink-0 gap-1.5 border border-amber-300/60 bg-amber-50/60 px-0 text-amber-800 hover:bg-amber-100/70 hover:text-amber-900 @[1550px]:w-auto @[1550px]:px-2 dark:border-amber-500/30 dark:bg-amber-500/10 dark:text-amber-300 dark:hover:bg-amber-500/15 dark:hover:text-amber-200",children:[/* @__PURE__ */e(Od,{className:"h-3.5 w-3.5",strokeWidth:1.75}),/* @__PURE__ */e("span",{className:"hidden @[1550px]:inline",children:"Dashboard filters off"})]})}),/* @__PURE__ */n(ot,{align:"start",collisionPadding:8,...r,onOpenAutoFocus:i=>i.preventDefault(),className:"w-72 space-y-2.5 p-3",children:[/* @__PURE__ */n("div",{className:"space-y-1",children:[/* @__PURE__ */e("p",{className:"text-[13px] font-medium",children:"Dashboard filters aren’t applied"}),/* @__PURE__ */e("p",{className:"text-[12px] leading-relaxed text-muted-foreground",children:t.description})]}),/* @__PURE__ */e(Ou,{value:t.helper}),/* @__PURE__ */e("a",{href:"https://docs.semaphor.cloud/docs/concepts/filters",target:"_blank",rel:"noreferrer",className:"inline-flex text-[12px] font-medium text-foreground underline-offset-4 hover:underline",children:"Learn more ↗"})]})]});}function Ru({activeEditor:t,onExpand:a,trailing:s}){const r=`Expand ${t==="sql"?"SQL":"Python"} editor`;return(/* @__PURE__ */n("div",{className:"flex h-10 shrink-0 items-center gap-4 border-b border-border/60 px-4",children:[/* @__PURE__ */n(gt,{variant:"underline",className:"h-full items-end gap-5 self-stretch border-b-0",children:[/* @__PURE__ */e(qe,{value:"sql",className:"px-0 text-[13px]",children:"SQL"}),/* @__PURE__ */e(qe,{value:"python",className:"px-0 text-[13px]",children:"Python"})]}),/* @__PURE__ */n("div",{className:"ml-auto flex min-w-0 shrink-0 items-center gap-1.5",children:[s,/* @__PURE__ */e(ce,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-foreground",onClick:a,"aria-label":r,title:r,children:/* @__PURE__ */e(gc,{className:"h-3.5 w-3.5",strokeWidth:1.75})})]})]}));}function Lu({value:t}){const[a,s]=Y(!1),r=Ee(null);return ve(()=>()=>{r.current&&clearTimeout(r.current);},[]),/* @__PURE__ */n(ce,{type:"button",variant:"ghost",size:"xs",className:"h-6 gap-1 px-1.5 text-[11px] text-muted-foreground","aria-label":"Copy example",onClick:async()=>{var c;try{if(!((c=navigator.clipboard)!=null&&c.writeText))throw new Error("Clipboard API unavailable");await navigator.clipboard.writeText(t),s(!0),r.current&&clearTimeout(r.current),r.current=setTimeout(()=>s(!1),1200);}catch{$e.error("Failed to copy");}},children:[a?/* @__PURE__ */e(fn,{className:"h-3 w-3",strokeWidth:1.75}):/* @__PURE__ */e(wt,{className:"h-3 w-3",strokeWidth:1.75}),a?"Copied":"Copy"]});}function Pu(){const{popoverProps:t,triggerProps:a,contentProps:s}=Ts();return/* @__PURE__ */n(it,{...t,children:[/* @__PURE__ */e(xt,{asChild:!0,children:/* @__PURE__ */n(ce,{type:"button",variant:"ghost",size:"xs",className:"h-7 gap-1.5 px-2 text-[12px] font-normal text-muted-foreground hover:text-foreground","aria-label":"How the Python step works",...a,children:[/* @__PURE__ */e(ut,{className:"h-3.5 w-3.5",strokeWidth:1.75}),"How it works"]})}),/* @__PURE__ */n(ot,{align:"end",collisionPadding:8,...s,onOpenAutoFocus:r=>r.preventDefault(),className:"w-[min(92vw,380px)] space-y-3 p-3",children:[/* @__PURE__ */n("div",{className:"space-y-1",children:[/* @__PURE__ */e("p",{className:"text-[13px] font-medium",children:"Python step"}),/* @__PURE__ */e("p",{className:"text-[12px] leading-relaxed text-muted-foreground",children:"Runs after the SQL and can reshape its result. Until you add code here, only the SQL runs."})]}),/* @__PURE__ */n("dl",{className:"space-y-1.5 text-[12px] leading-relaxed",children:[/* @__PURE__ */n("div",{className:"flex gap-2",children:[/* @__PURE__ */e("dt",{children:/* @__PURE__ */e("code",{className:"rounded-[3px] bg-muted px-1 font-mono text-[11px]",children:"data"})}),/* @__PURE__ */e("dd",{className:"text-muted-foreground",children:"The SQL result, as a list of records."})]}),/* @__PURE__ */n("div",{className:"flex gap-2",children:[/* @__PURE__ */e("dt",{children:/* @__PURE__ */e("code",{className:"rounded-[3px] bg-muted px-1 font-mono text-[11px]",children:"result"})}),/* @__PURE__ */e("dd",{className:"text-muted-foreground",children:"Set it to a list of dicts to replace the result. Leave it unset to keep the SQL result as is."})]})]}),/* @__PURE__ */n("div",{className:"overflow-hidden rounded-[5px] border border-border/60",children:[/* @__PURE__ */n("div",{className:"flex items-center justify-between border-b border-border/60 bg-muted/30 px-2 py-0.5",children:[/* @__PURE__ */e("span",{className:"text-[11px] text-muted-foreground",children:"Example"}),/* @__PURE__ */e(Lu,{value:Pn})]}),/* @__PURE__ */e("div",{className:"max-h-40 overflow-auto",children:/* @__PURE__ */e(qt,{value:Pn,language:"python",readOnly:!0,embedded:!0,dense:!0,hideLineNumbers:!0,wrapLines:!0,ariaLabel:"Python example"})})]})]})]});}function Du({open:t,onOpenChange:a,onConfirm:s}){return/* @__PURE__ */e(pi,{open:t,onOpenChange:a,children:/* @__PURE__ */n(fi,{children:[/* @__PURE__ */n(gi,{children:[/* @__PURE__ */e(xi,{children:"Clear the editor?"}),/* @__PURE__ */e(bi,{children:"This clears the SQL, the Python step and the chart settings in this editor. Nothing changes on the dashboard until you click Done."})]}),/* @__PURE__ */n(vi,{children:[/* @__PURE__ */e(yi,{children:"Cancel"}),/* @__PURE__ */e(Ni,{className:W(xc({variant:"destructive",size:"xs"})),onClick:s,children:"Clear"})]})]})});}function _u(t,a){return{...t,sql:"",python:"",config:void 0,customCfg:"",preferences:{},interactionConfig:void 0,linkedInteractionTargetOverrides:void 0,customCardPreferences:a?t.customCardPreferences:void 0,type:a?t.type:Sn};}function Vu(){const{setTempQueryData:t}=me(),a=gn(),s=E(A=>A.tempQueryData),r=E(A=>A.card),i=Be(),c=X(()=>i!==r.type?{...r,type:i}:r,[r,i]),{queryKey:d}=je(c),{setCardSql:l,setSqlGen:o,setCardPython:x,setCardCustomCfg:u,setCardPreferences:p,clearQueryConfig:h,setCardConfig:m,setCardType:C,setFrame:S,setCard:w,setActiveTabCardId:v}=me();function y(){var I,O,L,k;const A=a.getQueryData(d);s!=null&&s.queryData||t({queryKey:d,queryData:A}),a.setQueryData(d,null),a.removeQueries({queryKey:d,exact:!0}),l(""),o({}),h(),m(void 0),x(""),u(""),p({});const b=E.getState().frame,z=E.getState().card,B=vt(b,z),j=((I=B==null?void 0:B.customCardPreferences)==null?void 0:I.visualType)==="multiple"||!!((O=B==null?void 0:B.customCardPreferences)!=null&&O.dataInputCardIds)||(((L=B==null?void 0:B.customCardPreferences)==null?void 0:L.minInputs)||0)>1||(((k=B==null?void 0:B.customCardPreferences)==null?void 0:k.maxInputs)||0)>1,$=_u(z,j);S({...b,cards:b.cards.map(K=>K.id===$.id?$:K)}),v($.id),w($),j||C(Sn);}return y;}const nr="[&_.code-editor-pre]:!pb-14 [&_.code-editor-textarea]:!pb-14";function Bu(){var Ze,xe,oe,Oe;const t=gn(),{tokenProps:a}=Rt(),s=((xe=(Ze=a.config)==null?void 0:Ze.projectFeatures)==null?void 0:xe.features.aiWritingHelpers)!==!1,[r,i]=Y("sql"),[c,d]=Y(!1),[l,o]=Y(!1),x=Vu(),[u,p]=Y(!1),[h,m]=Y(null),C=E(H=>H.frame),S=E(H=>H.card),{inlineSqlEditorRef:w,inlinePythonEditorRef:v,expandedSqlEditorRef:y,expandedPythonEditorRef:A,captureEditorSessions:b}=Mu({cardId:S.id,expandedEditor:h});E(H=>H.selectedConnectionId),E(H=>H.tempQueryData);const z=E(H=>H.selectedDatabaseName);E(H=>H.selectedDatamodelId);const B=E(H=>H.selectedSchemaName),j=E(H=>H.selectedTableName),$=fe(H=>H.dashboard?Cr(H.dashboard).length:0),I=E(H=>H.inlineFilterValuesMap[(S==null?void 0:S.id)??""]),O=X(()=>vt(C,S),[C,S]),{manifest:L}=bt(((oe=O==null?void 0:O.customCardPreferences)==null?void 0:oe.url)||""),k=X(()=>{var H;return(H=L==null?void 0:L.visuals)==null?void 0:H.find(Ie=>{var te;return Ie.name===((te=O==null?void 0:O.customCardPreferences)==null?void 0:te.componentName);});},[L,(Oe=O==null?void 0:O.customCardPreferences)==null?void 0:Oe.componentName]),K=yt(O,k),M=X(()=>Qt({frame:C,configCard:O,isMultiInputVisual:K==="multiple"}),[C,O,K]),f=X(()=>{const H=M.findIndex(Ie=>(Ie==null?void 0:Ie.id)===(S==null?void 0:S.id));return H<0?-1:at(S,H);},[M,S]),F=X(()=>!O||K!=="multiple"||f<0?S.type:It(S,f,k==null?void 0:k.slots)??S.type,[O,K,f,S,k==null?void 0:k.slots]),g=X(()=>F!==S.type?{...S,type:F}:S,[S,F]),N=X(()=>$===0?null:rl(S==null?void 0:S.sql),[S==null?void 0:S.sql,$]),T=Ee(!0),{setCardCustomCfg:_,setQueryResultColumns:P,setCardSql:R,setTempQueryData:V,setCardPreferences:Q,setCardType:J,setCardPython:Z,setCard:G,updateCardInFrame:q}=me();E(H=>H.onSave),E(H=>H.onClose),E(H=>H.actions.setSqlGen);const ae=E(H=>H.runSql),de=E(H=>H.actions.setRunSql),he=E(H=>H.actions.setIsSqlRunning),{data:ie,isLoading:pe,isFetching:ge,isSuccess:Fe,isError:Re,error:Ue,errorSql:ue,queryKey:Ce,refetch:Me,errorMessage:st}=je(g),ze=Ee(Ce);ze.current=Ce;const Xe=S.type==="kpi"&&nn(S);ve(()=>{if(ie)if(ie.rowLimitExceeded&&$e.error("Row limit (10,000) exceeded. Refine your query.",{position:"top-center",richColors:!0}),ie.records.length>0){const{keys:H}=Xr(ie.records),Ie=Xe?sl(ie.records).value:void 0;P(S.type==="kpi"?Ie?[Ie]:[]:H,ie.columnKeyMap,ie.columns);}else P([]);},[S.type,ie,P,Xe]),ve(()=>{(pe||ge)&&(he(!0),P([])),(Re||Fe)&&he(!1),Re&&P([]);},[pe,ge,ie,Re,Fe,he,P,Ue]),ve(()=>{ae&&(t.getQueryData(Ce)||Me(),de(!1));},[ae,Me,de,Ce,t]);const Je=Ee(Me);Je.current=Me,ve(()=>{if(T.current){T.current=!1;return;}Je.current();},[I]);function ee(H,Ie){R(H),Ie&&de(!0);}function ye(){Nr({queryClient:t,readQueryKey:()=>ze.current,setRunSql:de});}function Ae(H){Ca(),b("inline"),m(H);}function _e(H){Ca(),b("expanded"),m(H);}function Le(H){H||(Ca(),b("expanded"),m(null));}function Pe(H){s&&(H.metaKey||H.ctrlKey)&&!H.altKey&&!H.shiftKey&&H.key.toLowerCase()==="k"&&(H.preventDefault(),d(!0));}const He=pe||ge;return(/* @__PURE__ */n("section",{role:"editor-section",className:"flex grow flex-col justify-end",onKeyDown:Pe,children:[/* @__PURE__ */n("div",{className:"flex shrink-0 flex-col gap-1.5 px-4 pb-1 pt-3",children:[/* @__PURE__ */n("div",{className:"flex items-center gap-2",children:[/* @__PURE__ */e("div",{className:W("min-w-0",u&&"flex-1"),children:/* @__PURE__ */e(Jt,{value:S.title,onSave:H=>G({...S,title:H}),onEditingChange:p,isEditable:!0,placeholder:"Add title",displayClassName:"text-[17px] font-semibold leading-tight tracking-[-0.005em]",inputClassName:"text-[17px] font-semibold leading-tight tracking-[-0.005em]"})}),/* @__PURE__ */e(Rr,{card:S})]}),/* @__PURE__ */e(Jt,{value:(S.description||"").trim(),onSave:H=>G({...S,description:H.trim()}),isEditable:!0,placeholder:"Add description",displayClassName:"text-[12px] leading-snug text-muted-foreground",inputClassName:"text-[12px] leading-snug"})]}),/* @__PURE__ */n(ft,{value:r,onValueChange:H=>i(H),className:"flex min-h-0 grow flex-col",children:[/* @__PURE__ */e(Ru,{activeEditor:r,onExpand:()=>Ae(r),trailing:/* @__PURE__ */n(be,{children:[N?/* @__PURE__ */e(Au,{hint:N}):null,r==="python"?/* @__PURE__ */e(Pu,{}):null]})}),/* @__PURE__ */n("div",{className:"relative min-h-0 grow",children:[/* @__PURE__ */e(Ye,{value:"sql",forceMount:!0,className:"absolute inset-0 mt-0 data-[state=inactive]:hidden",children:/* @__PURE__ */e("div",{id:"sql-container",className:"relative h-full w-full overflow-hidden bg-background",children:h===null?/* @__PURE__ */e(Rn,{ref:w,className:nr},`inline-sql-${S.id}`):null})}),/* @__PURE__ */e(Ye,{value:"python",forceMount:!0,className:"absolute inset-0 mt-0 data-[state=inactive]:hidden",children:/* @__PURE__ */e("div",{id:"python-container",className:"relative h-full w-full overflow-hidden bg-background",children:h===null?/* @__PURE__ */e(Ln,{ref:v,className:nr},`inline-python-${S.id}`):null})}),/* @__PURE__ */n("div",{role:"editor-controls",className:"pointer-events-none absolute inset-x-4 bottom-3 z-10 flex items-end justify-end gap-2",children:[s?c?/* @__PURE__ */e("div",{className:"pointer-events-auto flex min-w-0 max-w-[560px] flex-1",children:/* @__PURE__ */e(Eu,{currentSql:S==null?void 0:S.sql,selectedDatabaseName:z,selectedSchemaName:B,selectedTableName:j,onApplySql:ee,autoFocus:!0,onDismiss:()=>d(!1)})}):/* @__PURE__ */e(ce,{type:"button",variant:"outline",size:"xs",className:"pointer-events-auto h-7 shrink-0 bg-background px-2.5 text-[12px] font-normal text-muted-foreground hover:text-foreground",onClick:()=>d(!0),children:"Describe a query"}):null,/* @__PURE__ */e(ce,{type:"button",variant:"outline",size:"xs",className:"pointer-events-auto h-7 shrink-0 bg-background px-2.5 text-[12px] font-normal text-muted-foreground hover:text-foreground",title:"Clear the SQL, the Python step and the chart settings",onClick:()=>o(!0),children:"Clear"}),/* @__PURE__ */n(ce,{title:"Shift + Enter",disabled:He,onClick:ye,className:"pointer-events-auto shrink-0",size:"xs",children:[He?/* @__PURE__ */e(oa,{className:"h-3.5 w-3.5 animate-spin"}):/* @__PURE__ */e(Ar,{className:"h-3.5 w-3.5"}),"Run"]})]})]})]}),/* @__PURE__ */e(Du,{open:l,onOpenChange:o,onConfirm:x}),/* @__PURE__ */e(Fu,{activeEditor:h,isRunning:He,sqlEditor:/* @__PURE__ */e(Rn,{ref:y},`expanded-sql-${S.id}`),pythonEditor:/* @__PURE__ */e(Ln,{ref:A},`expanded-python-${S.id}`),onActiveEditorChange:_e,onOpenChange:Le,onRun:ye})]}));}function In(){const t=E(r=>r.actions.setCardType),{columns:a,isLoading:s}=Ci();return rt((r,i)=>{const c=t(r,{...i,catalog:a,catalogLoading:s});return c.status==="refused"?$e.info("Fields are still loading",{description:"Try switching again in a moment."}):c.status==="changed"&&c.leftOut.length&&$e.info("Some fields did not carry over to this visual",{description:c.leftOut.join(", ")}),c;},[t,a,s]);}const Fa=[{value:"table",label:"Table"},{value:"detailTable",label:"Detail"}];function zu({className:t}){const a=E(m=>m.card),s=E(m=>m.frame),r=E(m=>m.editorContext),i=Be(),{setCard:c,updateCardInFrame:d}=me(),l=(r==null?void 0:r.type)==="documentSection"&&!!r.lockedKind,o=(r==null?void 0:r.type)==="documentSection"?Fa.filter(m=>m.value==="table"):Fa,x=Fa.some(m=>m.value===i),u=jt(a.config,a.type),p=Sd(a,s.cards);if(!x||!u||p||l||o.length<2)return/* @__PURE__ */e("div",{"aria-hidden":"true",className:W("invisible flex items-center gap-5",t),children:/* @__PURE__ */e("span",{className:"-mb-px flex h-9 items-center border-b-2 border-transparent text-[12px]",children:"Placeholder"})});const h=m=>{if(m===i||p)return;const C=m,S=a.config??{},w=ll(i,C,S),v={...a,type:C,config:w};c(v),d(v);};return/* @__PURE__ */e("div",{role:"tablist",className:W("flex items-center gap-5",t),children:o.map(m=>{const C=i===m.value;return/* @__PURE__ */e("button",{type:"button",role:"tab","aria-selected":C,onClick:()=>h(m.value),className:W("-mb-px flex h-9 items-center border-b-2 text-[12px] transition-colors",C?"border-foreground font-medium text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),children:m.label},m.value);})});}function ks(t){const a=E(d=>d.card),s=E(d=>d.isDevMode),{switchEditorMode:r,setRunSql:i}=me(),c=()=>{const d=t||a.sql||a.python||"";r("dev",{sqlToLoad:d}),setTimeout(()=>{i(!0);},100);};return{isDevMode:s,handleOpenInEditor:!s&&rn(a.type)?c:void 0};}function Ku(){const{authToken:t,tokenProps:a}=Rt(),{currentUser:s}=on(),r=Lr({mutationFn:async i=>{if(!(t!=null&&t.accessToken))throw new Error("No authentication token available");const d=`${a.apiServiceUrl||""}/v1/feedback`,l={...i,user:s,tokenContext:a},o=await il(d,t.accessToken,l,"POST");if(!o||!o.success)throw new Error((o==null?void 0:o.error)||"Failed to send feedback");return o;},onSuccess:i=>{$e.success(`Feedback sent successfully! Issue: ${i.issueNumber}`,{duration:5e3});},onError:i=>{console.error("Feedback submission error:",i),$e.error("Failed to send feedback. Please try again later.",{duration:5e3});}});return{sendFeedback:r.mutate,sendFeedbackAsync:r.mutateAsync,isLoading:r.isPending,isSuccess:r.isSuccess,isError:r.isError,error:r.error,data:r.data,reset:r.reset};}function qu(t,a,s){return{category:t,userMessage:s,systemState:a,metadata:{url:window.location.href,userAgent:navigator.userAgent,timestamp:(/* @__PURE__ */new Date()).toISOString(),viewport:`${window.innerWidth}x${window.innerHeight}`}};}function $u({code:t,language:a,wrapLongLines:s=!1,className:r,ariaLabel:i}){const c=X(()=>bc(t,a),[t,a]);return(/* @__PURE__ */e("div",{className:W("code-editor",r),children:/* @__PURE__ */e("pre",{"aria-label":i,className:W("w-full min-w-0 max-w-full bg-transparent px-3 py-2.5 font-mono text-[12px] leading-[1.55] [font-variant-numeric:tabular-nums]",s?"overflow-x-hidden whitespace-pre-wrap break-words":"overflow-x-auto whitespace-pre"),children:c===null?/* @__PURE__ */e("code",{className:"text-foreground",children:t}):/* @__PURE__ */e("code",{dangerouslySetInnerHTML:{__html:c}})})}));}function En({open:t,onOpenChange:a,feedbackData:s,onSuccess:r,showDebugInfo:i=!1}){var z,B,j,$,I,O;const[c,d]=Y(""),[l,o]=Y(!1),{sendFeedback:x,isLoading:u,isSuccess:p,isError:h,data:m,reset:C}=Ku(),S=p?"Feedback Sent":"Report a Query Issue",w=p?"Your feedback was sent to the support team.":"Tell us what happened. We’ll include technical details to help support investigate.",v=()=>{const L={...s,userMessage:c.trim()||void 0};x(L,{onSuccess:()=>r==null?void 0:r()});},y=()=>{d(""),o(!1),C(),a(!1);},A=L=>{L||y();},b={category:s.category,error:{message:(z=s.systemState)==null?void 0:z.errorMessage,sql:(B=s.systemState)==null?void 0:B.generatedSql,errorSql:(j=s.systemState)==null?void 0:j.errorSql},cardConfig:($=s.systemState)==null?void 0:$.cardConfig,dataSource:(I=s.systemState)==null?void 0:I.dataSource,filters:(O=s.systemState)==null?void 0:O.dashboardFilters,metadata:s.metadata};return/* @__PURE__ */e(Ht,{open:t,onOpenChange:A,children:/* @__PURE__ */n(Ut,{"aria-busy":u,className:"max-h-[calc(100vh-2rem)] w-[calc(100%-2rem)] max-w-[520px] gap-0 overflow-y-auto overscroll-contain rounded-card border-border/60 p-0 sm:rounded-card [&>button]:right-3 [&>button]:top-3",children:[/* @__PURE__ */n(ca,{className:"flex h-10 flex-row items-center space-y-0 border-b border-border px-3 pr-10 text-left",children:[/* @__PURE__ */e(Gt,{className:"truncate text-[13px] font-medium",children:S}),p&&/* @__PURE__ */e(Et,{className:"sr-only",children:w})]}),!p&&/* @__PURE__ */n(be,{children:[/* @__PURE__ */n("div",{className:"min-w-0 space-y-4 px-3 py-4",children:[/* @__PURE__ */e(Et,{className:"text-[12px] leading-[1.5] text-muted-foreground",children:w}),/* @__PURE__ */n("div",{className:"space-y-2",children:[/* @__PURE__ */n(D,{htmlFor:"feedback-message",className:"text-[12px] font-medium",children:["What Happened?"," ",/* @__PURE__ */e("span",{className:"font-normal text-muted-foreground",children:"(Optional)"})]}),/* @__PURE__ */e(Pr,{id:"feedback-message",name:"feedback-message",autoComplete:"off",placeholder:"Describe what you were doing when the issue occurred…",value:c,onChange:L=>d(L.target.value),size:"sm",className:"min-h-[112px] resize-none",disabled:u})]}),h&&/* @__PURE__ */n("div",{role:"alert",className:"flex items-start gap-2 text-[12px] leading-[1.5] text-destructive",children:[/* @__PURE__ */e(Ua,{"aria-hidden":"true",className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),/* @__PURE__ */e("p",{children:"We couldn’t send your feedback. Check your connection and try again."})]}),i&&/* @__PURE__ */n(Mt,{open:l,onOpenChange:o,children:[/* @__PURE__ */n("div",{className:"flex items-center gap-1",children:[/* @__PURE__ */e(Ot,{asChild:!0,children:/* @__PURE__ */n(ce,{type:"button",variant:"ghost",size:"xs",className:"flex flex-1 items-center justify-between p-2 hover:bg-muted",children:[/* @__PURE__ */e("span",{className:"text-[12px] font-medium",children:"View data to be sent"}),l?/* @__PURE__ */e(Ft,{"aria-hidden":"true",className:"h-3.5 w-3.5"}):/* @__PURE__ */e(nt,{"aria-hidden":"true",className:"h-3.5 w-3.5"})]})}),/* @__PURE__ */e(Jr,{text:JSON.stringify(b,null,2),className:"h-8 w-8 shrink-0"})]}),/* @__PURE__ */e(At,{className:"mt-2 min-w-0",children:/* @__PURE__ */e(xn,{className:"h-[300px] w-full rounded-card border bg-muted/50 p-4",children:/* @__PURE__ */e("div",{className:"min-w-0 max-w-full overflow-x-hidden text-xs",children:/* @__PURE__ */e($u,{code:JSON.stringify(b,null,2),language:"json",wrapLongLines:!0})})})})]})]}),/* @__PURE__ */n(ta,{className:"gap-2 border-t border-border px-3 py-3 sm:space-x-0",children:[/* @__PURE__ */e(ce,{type:"button",variant:"outline",size:"xs",onClick:y,disabled:u,children:"Cancel"}),/* @__PURE__ */e(ce,{type:"button",size:"xs",onClick:v,disabled:u,"aria-busy":u,className:"min-w-[100px]",children:u?/* @__PURE__ */n(be,{children:[/* @__PURE__ */e(oa,{"aria-hidden":"true",className:"h-3.5 w-3.5 animate-spin motion-reduce:animate-none"}),"Sending…"]}):"Send Feedback"})]})]}),p&&/* @__PURE__ */n(be,{children:[/* @__PURE__ */n("div",{role:"status","aria-live":"polite",className:"flex items-start gap-3 px-3 py-4",children:[/* @__PURE__ */e(vc,{"aria-hidden":"true",className:"mt-0.5 h-5 w-5 shrink-0 text-emerald-500"}),/* @__PURE__ */n("div",{className:"min-w-0",children:[/* @__PURE__ */e("p",{className:"text-[13px] font-medium",children:"Thanks—your feedback was sent."}),/* @__PURE__ */n("p",{className:"mt-1 text-[12px] leading-[1.5] text-muted-foreground",children:["Issue number:"," ",/* @__PURE__ */e("span",{className:"font-mono font-medium tabular-nums text-foreground",children:m==null?void 0:m.issueNumber}),". Our support team will review the report."]})]})]}),/* @__PURE__ */e(ta,{className:"border-t border-border px-3 py-3",children:/* @__PURE__ */e(ce,{type:"button",size:"xs",onClick:y,children:"Close"})})]})]})});}var Fn=/* @__PURE__ */(t=>(t.QUERY_GENERATION="query-generation",t))(Fn||{});function Is(t,a){const[s,r]=Y(!1),i=E(u=>u.card),c=fe(u=>Cr(u.dashboard)),{currentUser:d}=on(),{tokenProps:l}=wn(bn),o=rt(()=>{r(!0);},[]),x=X(()=>{const u=typeof window<"u"?window.location.href:"",p=typeof navigator<"u"?navigator.userAgent:"",h=typeof window<"u"?`${window.innerWidth}x${window.innerHeight}`:"";return{category:Fn.QUERY_GENERATION,user:d,tokenContext:l,systemState:{cardConfig:i.config,dataSource:i.dataSource,dashboardFilters:[...c],errorMessage:t||void 0,errorSql:a||i.sql||i.python,generatedSql:a||i.sql},metadata:{url:u,userAgent:p,timestamp:(/* @__PURE__ */new Date()).toISOString(),viewport:h}};},[d,l,i,c,t,a]);return{feedbackDialogOpen:s,setFeedbackDialogOpen:r,handleSendFeedback:o,feedbackPayload:x};}const ju="__editor_sql__",Hu="__editor_python__";function Uu(t){var s;const a=ol(t.python||"");return{sql:(s=t.sql)!=null&&s.trim()?ju:"",python:a.trim()?Hu:""};}function Es({className:t,style:a,...s}){var _e,Le,Pe,He,Ze,xe;const r=E(oe=>oe.card),i=vn(),d=E(oe=>oe.isDevMode)?!1:((_e=r.customCardPreferences)==null?void 0:_e.showCardHeader)??!0,l=((Pe=(Le=r.preferences)==null?void 0:Le.displayOptions)==null?void 0:Pe.showInlineFilterBar)??!0,o=E(oe=>oe.frame),x=E(oe=>oe.inlineFilterValuesMap[r.id]),u=fe(oe=>oe.selectedSheetId),p=E(oe=>oe.actions.setRunSql),h=E(oe=>oe.actions.setCardInlineFilterValue),m=E(oe=>oe.actions.removeCardInlineFilterValue),C=rt(oe=>h(r.id,oe),[r.id,h]),S=rt(oe=>m(r.id,oe),[r.id,m]),w=cl(r,x,{savedFilters:l}).length>0,v=X(()=>vt(o,r),[o,r]),{manifest:y}=bt(((He=v==null?void 0:v.customCardPreferences)==null?void 0:He.url)||""),A=X(()=>{var oe;return(oe=y==null?void 0:y.visuals)==null?void 0:oe.find(Oe=>{var H;return Oe.name===((H=v==null?void 0:v.customCardPreferences)==null?void 0:H.componentName);});},[y,(Ze=v==null?void 0:v.customCardPreferences)==null?void 0:Ze.componentName]),b=yt(v,A),z=X(()=>Qt({frame:o,configCard:v,isMultiInputVisual:b==="multiple"}),[o,v,b]),B=X(()=>{const oe=z.findIndex(Oe=>(Oe==null?void 0:Oe.id)===(r==null?void 0:r.id));return oe<0?-1:at(r,oe);},[z,r]),j=X(()=>!v||b!=="multiple"||B<0?r.type:It(r,B,A==null?void 0:A.slots)??r.type,[v,b,B,r,A==null?void 0:A.slots]),$=j??r.type,I=X(()=>$===r.type?r:{...r,type:$},[r,$]),O=I.type==="table"||I.type==="matrixTable"||I.type==="detailTable",L=X(()=>j!==r.type?{...r,type:j}:r,[r,j]),{data:k,isLoading:K,isFetching:M,errorMessage:f,errorSql:F,pagination:g}=je(L),N=da(I,k),T=!!f,{handleOpenInEditor:_}=ks(F||r.sql||r.python),{feedbackDialogOpen:P,setFeedbackDialogOpen:R,handleSendFeedback:V,feedbackPayload:Q}=Is(f,F||r.sql||r.python),J=X(()=>(k==null?void 0:k.records)||[],[k==null?void 0:k.records]),{setCard:Z,updateCardInFrame:G}=me(),q=N.id,ae=N.config,de=N.interactionConfig,he=N.controls,ie=N.controlBindings,pe=N.customCfg,ge=N.preferences,Fe=N.queryConfig,Re=Uu({sql:N.sql,python:N.python}),Ue=Re.sql,ue=Re.python,Ce=k==null?void 0:k.records,Me=X(()=>({id:q,type:$,config:ae,interactionConfig:de,preferences:ge,controls:he,controlBindings:ie,sql:Ue,python:ue}),[q,$,ae,de,ge,he,ie,Ue,ue]),st=(oe,Oe)=>{var Ie,te;const H={...r,paginationConfig:{page:oe+1,pageSize:Oe}};Z(H),G(H),r.sql&&(te=(Ie=r.preferences)==null?void 0:Ie.tablePrefs)!=null&&te.enableDevModePagination&&p(!0);},ze=oe=>{var Ie,te,Ne,lt,Qe;const Oe=Vr(oe,(Ie=r.config)==null?void 0:Ie.metricColumns,(te=r.config)==null?void 0:te.groupByColumns,(Ne=r.config)==null?void 0:Ne.detailColumns),H={...r,config:{...(r.config||{}),sortByColumns:Oe}};Z(H),G(H),r.sql&&(Qe=(lt=r.preferences)==null?void 0:lt.tablePrefs)!=null&&Qe.enableDevModePagination&&p(!0);},Xe=Zr(Me,Ce||void 0),Je=yn(),ee=X(()=>{var oe;return!q||!Ce?null:es({chartTheme:Je,card:Me,data:Ce,cardType:$,queryConfig:Fe,customCfg:pe,preferences:ge,comparisonMetadata:(oe=k==null?void 0:k.metadata)==null?void 0:oe.comparisonMetadata,numericPresentation:Xe,resultColumns:k==null?void 0:k.columns,columnKeyMap:k==null?void 0:k.columnKeyMap});},[Me,q,pe,ge,Fe,Ce,Je,k==null?void 0:k.columns,k==null?void 0:k.columnKeyMap,(xe=k==null?void 0:k.metadata)==null?void 0:xe.comparisonMetadata,$,Xe]);function ye(oe){return/* @__PURE__ */e(ua,{FallbackComponent:un,children:/* @__PURE__ */e(Gs,{card:oe})});}function Ae(){var oe,Oe;if(N.type==="matrixTable")return/* @__PURE__ */e(Oi,{card:N,frame:o,mode:"editor"});if(k!=null&&k.records&&(k==null?void 0:k.records.length)===0&&!K&&!M)return f?/* @__PURE__ */e("div",{className:"flex h-full flex-col items-start justify-start overflow-auto",children:/* @__PURE__ */e(dn,{error:f,errorSql:F||r.sql||r.python,onOpenInEditor:_,onSendFeedback:V,showFeedbackButton:!0})}):/* @__PURE__ */e(Ai,{fallback:/* @__PURE__ */n("div",{className:"flex h-full flex-col items-center justify-center gap-2",children:[/* @__PURE__ */e(Ri,{className:"h-8 w-8 text-muted-foreground/40"}),/* @__PURE__ */e("p",{className:"text-[12px] text-muted-foreground",children:"No results to display"})]})});if((K||M)&&(!(k!=null&&k.records)||k.records.length===0))return $==="table"||$==="detailTable"?/* @__PURE__ */e("div",{className:"relative mb-2 flex h-full min-h-0 w-full flex-1 grow basis-0",children:/* @__PURE__ */e(Li,{})}):/* @__PURE__ */e("div",{className:"z-50 flex h-full items-center justify-center",children:/* @__PURE__ */e(tt,{size:"md",color:"muted","aria-label":"Loading data"})});if(!N.id)return null;if($==="custom")return ye(r);if($==="customVisual")return/* @__PURE__ */e(Pi,{card:N,result:{records:(k==null?void 0:k.records)??[],columns:k==null?void 0:k.columns,columnKeyMap:k==null?void 0:k.columnKeyMap,totals:k==null?void 0:k.tableTotalsByColumnId,truncated:!!(g!=null&&g.hasNextPage),comparisonMetadata:(oe=k==null?void 0:k.metadata)==null?void 0:oe.comparisonMetadata},isLoading:K||M,printing:!1,showReason:!0,renderFallback:()=>{var H;return/* @__PURE__ */e(Zt,{card:Di(N),data:J,resultColumns:k==null?void 0:k.columns,columnKeyMap:k==null?void 0:k.columnKeyMap,comparisonMetadata:(H=k==null?void 0:k.metadata)==null?void 0:H.comparisonMetadata,paginationMetadata:g,onPaginationChange:st,onSortChange:ze,isLoading:K||M});}});if(!["table","matrixTable","detailTable","custom","customVisual"].includes($)&&ee)return/* @__PURE__ */e("div",{className:"relative h-full min-h-0 w-full flex-1 grow basis-0",children:K||M?/* @__PURE__ */e(be,{}):/* @__PURE__ */e(_i,{cfg:ee})});if($==="table"||$==="detailTable")return/* @__PURE__ */e("div",{className:"relative mb-2 flex h-full min-h-0 w-full flex-1 grow basis-0",children:/* @__PURE__ */e(Zt,{card:N,data:J,resultColumns:k==null?void 0:k.columns,columnKeyMap:k==null?void 0:k.columnKeyMap,totalsByColumnId:k==null?void 0:k.tableTotalsByColumnId,columnTotals:k==null?void 0:k.tableColumnTotals,comparisonMetadata:(Oe=k==null?void 0:k.metadata)==null?void 0:Oe.comparisonMetadata,paginationMetadata:g,onPaginationChange:st,onSortChange:ze,isLoading:K||M})});}return/* @__PURE__ */n(wi,{role:"editor-visual-card",className:W("relative flex h-full flex-col rounded-none bg-card text-card-foreground",t),style:{...i.cardFrameStyle,...a},...s,children:[(K||M)&&!Si({type:$})&&(k==null?void 0:k.records)&&k.records.length>0&&/* @__PURE__ */e("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-background/50",children:/* @__PURE__ */e(tt,{size:"md",color:"muted","aria-label":"Loading data"})}),d&&/* @__PURE__ */e(Ti,{className:W("flex flex-row items-start justify-between gap-4 px-4 pb-3 pt-3"),style:i.cardGutterStyle,children:/* @__PURE__ */n("div",{className:"min-w-0 flex-1 space-y-1",children:[/* @__PURE__ */n("div",{className:"flex items-center gap-2",children:[/* @__PURE__ */e(ki,{className:W("min-w-0",Na),children:/* @__PURE__ */e(Jt,{value:r.title,onSave:oe=>Z({...r,title:oe}),isEditable:!0,placeholder:"Add title",displayClassName:Na,inputClassName:Na})}),/* @__PURE__ */e(Rr,{card:r}),/* @__PURE__ */e(ps,{}),/* @__PURE__ */e("div",{className:"ml-auto",children:/* @__PURE__ */e(zu,{})})]}),/* @__PURE__ */e("div",{className:"min-w-0",children:/* @__PURE__ */e(Jt,{value:(r.description||"").trim(),onSave:oe=>Z({...r,description:oe.trim()}),isEditable:!0,placeholder:"Add description",displayClassName:"text-[12px] leading-snug text-muted-foreground",inputClassName:"text-[12px] leading-snug"})})]})}),/* @__PURE__ */n(Ii,{card:r,sheetId:u||"",inlineFilterValues:x,setInlineFilterValue:C,removeInlineFilterValue:S,children:[w&&/* @__PURE__ */e("div",{className:"px-4 pb-2",style:i.cardGutterStyle,children:/* @__PURE__ */e(Ei,{card:r,sheetId:u||"",inlineFilterValues:x,setInlineFilterValue:C,removeInlineFilterValue:S,showSavedFilters:l})}),/* @__PURE__ */n(Fi,{className:W("flex min-h-0 grow flex-col",O?T?"px-4 pb-0 pt-2":W("p-0",cn):T?"px-4 py-0":W("px-4",Mi)),style:O&&!T?void 0:i.cardGutterStyle,children:[/* @__PURE__ */e("div",{className:"min-h-0 flex-1 grow basis-0",children:Ae()}),Dr(N)&&/* @__PURE__ */e("div",{className:W("pt-3",O&&"px-4"),children:/* @__PURE__ */e(_r,{card:N,mode:"editor",records:k==null?void 0:k.records})})]})]}),/* @__PURE__ */e(En,{open:P,onOpenChange:R,feedbackData:Q,showDebugInfo:!0})]});}function rr(t){var a,s;return JSON.stringify({...t,data:{...t.data,datasets:(s=(a=t.data)==null?void 0:a.datasets)==null?void 0:s.map(r=>{const i={...r};return Object.keys(i).forEach(c=>{c.startsWith("semaphor")&&delete i[c];}),{...i,data:[]};})}},null,2);}const Ma=({language:t,value:a,onChange:s,readonly:r})=>/* @__PURE__ */e(qt,{className:"h-full w-full text-xs",language:t,value:a,onValueChange:s,readOnly:r,embedded:!0}),Gu=()=>/* @__PURE__ */n(ca,{children:[/* @__PURE__ */e("div",{className:"flex items-center gap-2",children:/* @__PURE__ */e(Gt,{children:"Customize Card"})}),/* @__PURE__ */n(Et,{children:["See the configuration options and documentation",/* @__PURE__ */e("a",{target:"_blank",className:"ml-1 text-blue-500 underline",href:"https://www.chartjs.org/docs/latest/samples/bar/vertical.html",children:"here."})]})]}),Qu=({customCode:t,cardCustomCfgString:a,mergedConfig:s,onConfigChange:r,onCodeChange:i})=>/* @__PURE__ */n(ft,{defaultValue:"final-config",className:"flex w-1/2 flex-col",children:[/* @__PURE__ */n(gt,{variant:"underline",className:"justify-start gap-5",children:[/* @__PURE__ */e(qe,{value:"final-config",className:"px-0",children:"Config"}),/* @__PURE__ */e(qe,{value:"custom-config",className:"px-0",children:"Changes"}),/* @__PURE__ */e(qe,{value:"custom-code",className:"px-0",children:"Custom Code"})]}),/* @__PURE__ */e(Ye,{value:"final-config",className:"mt-2 grow rounded border",children:/* @__PURE__ */e(Ma,{language:"json",value:s,onChange:r})}),/* @__PURE__ */e(Ye,{value:"custom-config",className:"mt-2 grow rounded border",children:/* @__PURE__ */e(Ma,{readonly:!0,language:"json",value:a,onChange:()=>{}})}),/* @__PURE__ */e(Ye,{value:"custom-code",className:"mt-2 grow rounded border",children:/* @__PURE__ */e(Ma,{language:"javascript",value:t,onChange:i})})]}),Wu=({error:t,hasCardCustomConfig:a,onReset:s,onApply:r,onClose:i})=>/* @__PURE__ */n(ta,{className:"flex items-center",children:[/* @__PURE__ */e(D,{className:"mr-2 text-red-500",children:t}),/* @__PURE__ */e(ce,{disabled:!a,onClick:s,variant:"outline",children:"Reset"}),/* @__PURE__ */e(ce,{onClick:r,variant:"outline",children:"Apply"}),/* @__PURE__ */e(ce,{onClick:i,variant:"outline",children:"Close"})]});function Yu({triggerVariant:t="icon",className:a,label:s="Customize Visual"}={}){const[r,i]=Y(!1),[c,d]=Y(""),[l,o]=Y(""),[x,u]=Y(""),[p,h]=Y(""),m=E(O=>O.card),C=Be(),S=E(O=>O.card.customCfg),w=S?JSON.stringify(S,null,2):"",v=X(()=>C!==m.type?{...m,type:C}:m,[m,C]),{data:y}=je(v),A=Zr(da(m,y),y==null?void 0:y.records),b=yn(),{setCardCustomCfg:z,setCustomVisualCode:B}=me(),j=()=>{var L,k,K;if(!((L=y==null?void 0:y.records)!=null&&L.length))return;const O=es({chartTheme:b,card:m,data:y.records,cardType:m.type,queryConfig:m.queryConfig,preferences:m.preferences,comparisonMetadata:(k=y==null?void 0:y.metadata)==null?void 0:k.comparisonMetadata,numericPresentation:A,resultColumns:y==null?void 0:y.columns,columnKeyMap:y==null?void 0:y.columnKeyMap});if(O){d(rr(O)),u(((K=m.preferences)==null?void 0:K.customVisualCode)||"");const M=Nc(O,S);o(rr(M));}},$=()=>{try{if(x&&B(x),l){const O=JSON.parse(l),L=Kd(JSON.parse(c),O);z(L),h("");}}catch{h("Invalid JSON configuration");}},I=Object.keys(S||{}).length===0;return/* @__PURE__ */n(Ht,{open:r,onOpenChange:i,children:[/* @__PURE__ */e(yc,{asChild:!0,children:t==="menu"?/* @__PURE__ */n(ce,{variant:"ghost",onClick:j,className:W("h-7 w-full justify-start gap-2 px-2 text-[13px] font-normal",I?"":"text-green-600 hover:text-green-700",a),children:[/* @__PURE__ */e(zn,{className:"h-3.5 w-3.5"}),/* @__PURE__ */e("span",{children:s})]}):/* @__PURE__ */e(Ve,{tooltip:"Customize Visual",onClick:j,className:W(I?"":"text-green-600 hover:text-green-700",a),children:/* @__PURE__ */e(zn,{className:"h-4 w-4"})})}),/* @__PURE__ */n(Ut,{className:"flex h-[600px] grow flex-col overflow-auto sm:min-w-[900px] lg:min-w-[1200px]",children:[/* @__PURE__ */e(Gu,{}),/* @__PURE__ */n("div",{className:"flex grow gap-2",children:[/* @__PURE__ */e(ua,{FallbackComponent:un,children:/* @__PURE__ */e(Es,{className:"w-1/2 rounded shadow-none"})}),/* @__PURE__ */e(Qu,{customCode:x,cardCustomCfgString:w,mergedConfig:l,onConfigChange:O=>o(O??""),onCodeChange:O=>u(O??"")})]}),/* @__PURE__ */e(Wu,{error:p,hasCardCustomConfig:!!S,onReset:()=>{o(c),z(null);},onApply:$,onClose:()=>i(!1)})]})]});}function Xu(t){let a=0;for(let r=0;r<t.length;r++)a=t.charCodeAt(r)+((a<<5)-a);return`hsl(${Math.abs(a%360)}, 65%, 45%)`;}function Ju(t){const a=t.trim().split(/\s+/);return a.length>1?(a[0][0]+a[1][0]).toUpperCase():t.slice(0,2).toUpperCase();}function Fs({chartType:t,chartName:a,isCustom:s=!1,className:r="h-6 w-6"}){if(!s&&t)return Br(t,r);const i=Vi(a);if(i)return Ya.cloneElement(i,{className:r});const c=Ju(a),d=Xu(a);return/* @__PURE__ */e("div",{className:W("flex items-center justify-center rounded text-white font-semibold text-xs",r),style:{backgroundColor:d},children:c});}function sr({chartType:t,chartName:a,description:s,isCustom:r=!1,pluginName:i,isSelected:c=!1,isActive:d=!1,onSelect:l,onHover:o}){return/* @__PURE__ */n("button",{type:"button",onClick:l,onMouseMove:o,"aria-pressed":c,title:i?`${a} · ${i}`:a,className:W("flex w-full min-w-0 gap-2 rounded-[4px] px-2 text-left text-[12px] transition-colors",s?"items-start py-1.5":"h-7 items-center",d&&"bg-muted"),children:[/* @__PURE__ */e(Fs,{chartType:t,chartName:a,isCustom:r,className:W("h-3.5 w-3.5 shrink-0",s&&"mt-px",r?"text-[7px]":c?"text-foreground":"text-muted-foreground")}),/* @__PURE__ */n("span",{className:"min-w-0",children:[/* @__PURE__ */e("span",{className:W("block truncate",c?"font-medium text-foreground":"text-foreground/80"),children:a}),s?/* @__PURE__ */e("span",{className:"block text-[11px] leading-snug text-muted-foreground",children:s}):null]}),c&&/* @__PURE__ */e(fn,{className:"ml-auto h-3 w-3 shrink-0"})]});}const lr=[{id:"tables",label:"Tables"},{id:"other",label:"Single value and text"},{id:"comparison",label:"Comparison"},{id:"trend",label:"Trend"},{id:"part",label:"Part of a whole"},{id:"relationship",label:"Relationship"},{id:"custom-visual",label:"Custom"}],Zu=[{id:"table",name:"Table",group:"tables"},{id:"matrixTable",name:"Matrix Table",group:"tables"},{id:"bar",name:"Bar Chart",group:"comparison"},{id:"stackedBar",name:"Stacked Bar",group:"comparison"},{id:"combo",name:"Combo Chart",group:"comparison"},{id:"bullet",name:"Bullet Chart",group:"comparison"},{id:"tornado",name:"Tornado",group:"comparison"},{id:"range",name:"Range",group:"comparison"},{id:"line",name:"Line Chart",group:"trend"},{id:"area",name:"Area Chart",group:"trend"},{id:"stackedLine",name:"Stacked Line",group:"trend"},{id:"stackedArea",name:"Stacked Area",group:"trend"},{id:"pie",name:"Pie Chart",group:"part"},{id:"doughnut",name:"Doughnut",group:"part"},{id:"treemap",name:"Treemap",group:"part"},{id:"funnel",name:"Funnel",group:"part"},{id:"polarArea",name:"Polar Area",group:"part"},{id:"scatter",name:"Scatter",group:"relationship"},{id:"bubble",name:"Bubble",group:"relationship"},{id:"heatmap",name:"Heatmap",group:"relationship"},{id:"radar",name:"Radar",group:"relationship"},{id:"kpi",name:"KPI",group:"other"},{id:"text",name:"Text",group:"other"},{id:"customVisual",name:"Custom visual",group:"custom-visual",description:"A chart this list doesn't have: describe it, or start from a template"}],Oa=2;function Ms(t){return Zu.filter(a=>dl(a.id,t));}function em({selectedChart:t,onChartSelect:a,onClose:s}){var F;const[r,i]=Y(""),[c,d]=Y(0),l=Ee(null),{data:o=[],isLoading:x}=Cc(),u=In(),{setCardPreferences:p}=E(g=>g.actions),h=E(g=>g.card),m=E(g=>g.isDevMode),C=t??h.type,S=C==="custom"?(F=h.customCardPreferences)==null?void 0:F.componentName:void 0,{setCardCustomCfg:w,setQueryConfig:v,replaceFrameCards:y,clearModeDrafts:A,initializeModeDrafts:b}=me(),z=X(()=>{const g=Ms({isDevMode:m});if(!r)return g;const N=r.toLowerCase(),T=new Set(lr.filter(_=>_.label.toLowerCase().includes(N)).map(_=>_.id));return g.filter(_=>_.name.toLowerCase().includes(N)||T.has(_.group));},[m,r]),B=X(()=>{const g=o.filter(T=>T.componentType==="chart"&&T.pluginType!=="standard");if(!r)return g;const N=r.toLowerCase();return g.filter(T=>T.name.toLowerCase().includes(N));},[o,r]),j=g=>{u(g).status!=="refused"&&(a==null||a(g),s==null||s());},$=g=>{const N=Td(g);if(N==="multiple"&&g.slots&&g.slots.length>0){w(null),p({}),v(void 0),A();const _=kd(g.slots,g,h);y(_),_[0]&&b(_[0]),s==null||s();return;}else if(u("custom",{customVisual:{type:"component",visualType:N,url:g.url,componentName:g.name,icon:g.icon,pluginChartType:g.chartType,minInputs:g.minInputs,maxInputs:g.maxInputs}}).status==="refused")return;a==null||a("custom",g),s==null||s();},I=X(()=>{const g=lr.map(N=>({key:N.id,label:N.label,entries:z.filter(T=>T.group===N.id).map(T=>({kind:"default",id:T.id,name:T.name,...(T.description?{description:T.description}:{})}))})).filter(N=>N.entries.length>0);return B.length===0?g:[...g,{key:"custom",label:"Custom charts",entries:B.map(N=>({kind:"custom",visual:N}))}];},[z,B]),O=X(()=>I.flatMap(g=>g.entries),[I]),L=Math.min(c,Math.max(O.length-1,0)),k=g=>{g.kind==="default"?j(g.id):$(g.visual);},K=g=>{var T,_;const N=Math.max(0,Math.min(g,O.length-1));d(N),(_=(T=l.current)==null?void 0:T.querySelector(`[data-index="${N}"]`))==null||_.scrollIntoView({block:"nearest"});},M=g=>{if(O.length===0)return;const N=g.key==="ArrowDown"?Oa:g.key==="ArrowUp"?-Oa:g.key==="ArrowRight"?1:g.key==="ArrowLeft"?-1:0;if(N!==0&&(Math.abs(N)===Oa||!r))g.preventDefault(),K(L+N);else if(g.key==="Enter"){g.preventDefault();const T=O[L];T&&k(T);}};let f=0;return/* @__PURE__ */n("div",{className:"flex flex-col",children:[/* @__PURE__ */n("div",{className:"flex h-9 items-center gap-2 border-b border-border px-3",children:[/* @__PURE__ */e(wc,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),/* @__PURE__ */e("input",{type:"text",placeholder:"Search charts",value:r,onChange:g=>{i(g.target.value),d(0);},onKeyDown:M,"aria-label":"Search charts",className:"h-full w-full bg-transparent text-[12px] text-foreground placeholder:text-muted-foreground focus:outline-none"})]}),/* @__PURE__ */n("div",{ref:l,className:"max-h-[360px] overflow-y-auto px-1.5 pb-1.5",children:[I.map(g=>/* @__PURE__ */n("section",{className:"pt-2",children:[/* @__PURE__ */e("div",{className:"px-2 pb-0.5 text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:g.label}),/* @__PURE__ */e("div",{className:"grid grid-cols-2 gap-x-0.5",children:g.entries.map(N=>{const T=f++,_=T===L;if(N.kind==="default")return/* @__PURE__ */e("div",{"data-index":T,className:N.description?"col-span-2":void 0,children:/* @__PURE__ */e(sr,{chartType:N.id,chartName:N.name,description:N.description,isSelected:C===N.id,isActive:_,onSelect:()=>k(N),onHover:()=>d(T)})},N.id);const{visual:P}=N;return/* @__PURE__ */e("div",{"data-index":T,children:/* @__PURE__ */e(sr,{chartName:P.name,isCustom:!0,pluginName:P.pluginName,isSelected:S===P.name,isActive:_,onSelect:()=>k(N),onHover:()=>d(T)})},`${P.url}-${P.name}`);})})]},g.key)),x&&/* @__PURE__ */e("div",{className:"py-3 text-center text-[11px] text-muted-foreground",children:"Loading custom charts…"}),O.length===0&&!x&&/* @__PURE__ */e("div",{className:"py-8 text-center text-[11px] text-muted-foreground",children:"No charts found"})]})]});}const Aa={table:ts,matrixTable:ea,bar:hn,line:mn,stackedBar:Xi,stackedLine:Yi,scatter:qr,bubble:Wi,pie:Qi,doughnut:Gi,kpi:Ui,treemap:Kr,bullet:zr,funnel:Hi,tornado:ji,heatmap:ea,range:$i,radar:qi,polarArea:Ki,text:zi,customVisual:Bi},Ra={table:"Table",matrixTable:"Matrix Table",bar:"Bar Chart",line:"Line Chart",stackedBar:"Stacked Bar",stackedLine:"Stacked Line",scatter:"Scatter",bubble:"Bubble",pie:"Pie Chart",doughnut:"Donut",kpi:"KPI",treemap:"Treemap",bullet:"Bullet",funnel:"Funnel",tornado:"Tornado",heatmap:"Heatmap",range:"Range",radar:"Radar",polarArea:"Polar Area",text:"Text",customVisual:"Custom visual"},tm=[{id:"table"},{id:"bar"},{id:"line"},{id:"pie"},{id:"kpi"},{id:"matrixTable"}],am=6;function nm({selectedChart:t,onChartChange:a}){return/* @__PURE__ */n("div",{className:"px-4 pb-3 pt-4",children:[/* @__PURE__ */e("p",{className:"pb-1.5 text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Chart type"}),/* @__PURE__ */e(tn,{selectedChart:t,onChartChange:a,compactMore:!0})]});}function tn({selectedChart:t,onChartChange:a,compactMore:s=!1,responsiveCompact:r=!1}){const[i,c]=Y(!1),d=E(m=>m.isDevMode),l=E(m=>{var C,S;return((S=(C=m.card)==null?void 0:C.customCardPreferences)==null?void 0:S.componentName)??null;}),o=X(()=>{const m=new Set(Ms({isDevMode:d}).map(S=>S.id)),C=tm.filter(S=>m.has(S.id)).map(S=>({id:S.id,label:Ra[S.id]??S.id,icon:Aa[S.id],isCustom:!1}));return t==="custom"&&l?C.unshift({id:l,label:l,isCustom:!0}):!C.some(S=>S.id===t)&&Aa[t]&&m.has(t)&&C.unshift({id:t,label:Ra[t]??t,icon:Aa[t],isCustom:!1}),C.slice(0,am);},[t,l,d]),x=m=>m.isCustom?t==="custom"&&l===m.id:t===m.id,u=m=>{m.isCustom||a(m.id);},p=o.some(x),h=p?"More":t==="custom"?l||"Custom":Ra[t]||"More";return/* @__PURE__ */e("div",{className:"flex items-center",children:/* @__PURE__ */n("div",{className:"inline-flex h-7 items-center overflow-hidden rounded-control border border-input bg-background",children:[o.map(m=>{const C=m.icon,S=x(m);return/* @__PURE__ */n(mt,{children:[/* @__PURE__ */e(ht,{asChild:!0,children:/* @__PURE__ */n("button",{type:"button",onClick:()=>u(m),"aria-label":m.label,"aria-pressed":!!S,className:W("flex h-full w-7 items-center justify-center text-foreground/65 transition-colors hover:bg-muted/50 hover:text-foreground",r&&!S&&"hidden @[800px]:flex",S&&"bg-foreground/[0.08] font-medium text-foreground"),children:[C?/* @__PURE__ */e(C,{className:"h-3.5 w-3.5"}):/* @__PURE__ */e(Fs,{chartName:m.label,isCustom:!0,className:"h-3.5 w-3.5"}),/* @__PURE__ */e("span",{className:"sr-only",children:m.label})]})}),/* @__PURE__ */e(pt,{side:"bottom",children:m.label})]},`${m.isCustom?"custom":"default"}-${m.id}`);}),/* @__PURE__ */n(it,{open:i,onOpenChange:c,children:[/* @__PURE__ */e(xt,{asChild:!0,children:/* @__PURE__ */n("button",{type:"button","aria-label":s?"More chart types":h,className:W("inline-flex h-full items-center gap-1 border-l border-input transition-colors hover:bg-muted/50",s?"w-7 justify-center":"px-2 text-[12px]",!s&&(p?"text-muted-foreground":"text-foreground")),children:[!s&&/* @__PURE__ */e("span",{className:"truncate",children:h}),/* @__PURE__ */e(Ft,{className:W("h-3 w-3 shrink-0 text-muted-foreground transition-transform",i&&"rotate-180"),strokeWidth:1.75})]})}),/* @__PURE__ */e(ot,{className:"w-[360px] overflow-hidden p-0",align:"end",onOpenAutoFocus:m=>m.preventDefault(),children:/* @__PURE__ */e(em,{selectedChart:t,onChartSelect:m=>{a(m),c(!1);},onClose:()=>c(!1)})})]})]})});}function rm(){const t=E(o=>{var x,u;return(u=(x=o.card.preferences)==null?void 0:x.chartOptions)==null?void 0:u.indexAxis;}),a=E(o=>o.card.type),{setChartOrientation:s,setCardPreferences:r}=E(o=>o.actions),i=o=>{if(s(o),a!=="bullet")return;const x=o==="y"?"horizontal":"vertical",u=E.getState().card.preferences,p={...(u||{}),bulletConfig:{...((u==null?void 0:u.bulletConfig)||{}),orientation:x}};r(p);};function c(){const o=t??"x";return/* @__PURE__ */e(Ve,{onClick:()=>{i(o==="x"?"y":"x");},tooltip:"Chart Orientation",className:"h-7 w-7 px-0",children:o==="x"?/* @__PURE__ */e(Ia,{className:"h-3.5 w-3.5"}):/* @__PURE__ */e(ka,{className:"h-3.5 w-3.5"})});}function d(){return/* @__PURE__ */e(Ve,{onClick:()=>{i(t==="y"||t===void 0?"x":"y");},tooltip:"Chart Orientation",className:"h-7 w-7 px-0",children:t==="y"||t===void 0?/* @__PURE__ */e(Ia,{className:"h-3.5 w-3.5"}):/* @__PURE__ */e(ka,{className:"h-3.5 w-3.5"})});}function l(){const o=t??"y";return/* @__PURE__ */e(Ve,{onClick:()=>{i(o==="y"?"x":"y");},tooltip:"Chart Orientation",className:"h-7 w-7 px-0",children:o==="y"?/* @__PURE__ */e(ka,{className:"h-3.5 w-3.5"}):/* @__PURE__ */e(Ia,{className:"h-3.5 w-3.5"})});}return/* @__PURE__ */e(be,{children:a==="funnel"?d():a==="bullet"?l():c()});}function Mn({className:t,triggerVariant:a="icon",label:s="Display options"}){var w,v,y,A,b,z,B,j,$,I;const r=E(O=>O.card),{setCardPreferences:i,updateCardInFrame:c,setCard:d}=me(),[l,o]=Y(!1),x=((v=(w=r.preferences)==null?void 0:w.displayOptions)==null?void 0:v.showFilterInfo)??!0,u=((A=(y=r.preferences)==null?void 0:y.displayOptions)==null?void 0:A.showCardToolbar)??!0,p=((z=(b=r.preferences)==null?void 0:b.displayOptions)==null?void 0:z.showChrome)??!0,h=((j=(B=r.preferences)==null?void 0:B.displayOptions)==null?void 0:j.allowScroll)??!0,m=((I=($=r.preferences)==null?void 0:$.displayOptions)==null?void 0:I.showInlineFilterBar)??!0,C=(O,L)=>{var M;const k={...r.preferences,displayOptions:{...((M=r.preferences)==null?void 0:M.displayOptions),[O]:L}};i(k);const K={...r,preferences:k};d(K),c(K);},S=[{option:"showFilterInfo",label:"Filter info",hint:"Badge",checked:x},{option:"showCardToolbar",label:"Card tools",hint:"Expand, hover actions",checked:u},{option:"showChrome",label:"Card chrome",hint:"Frame and padding",checked:p},{option:"allowScroll",label:"Allow scroll",hint:"Content scroll",checked:h},{option:"showInlineFilterBar",label:"Inline filter bar",hint:"On-card filters",checked:m}];return/* @__PURE__ */e("div",{className:W("flex items-center",t),children:/* @__PURE__ */n(ma,{modal:!1,open:l,onOpenChange:o,children:[/* @__PURE__ */e(ha,{asChild:!0,children:a==="menu"?/* @__PURE__ */n(ce,{variant:"ghost",className:"h-auto w-full justify-start gap-2 rounded-sm px-2 py-1.5 text-[13px] font-normal",children:[/* @__PURE__ */e(Ga,{className:"h-3.5 w-3.5 text-muted-foreground"}),/* @__PURE__ */e("span",{children:s})]}):/* @__PURE__ */e(Ve,{className:"h-7 w-7 p-0",tooltip:"Display Options",children:/* @__PURE__ */e(aa,{className:"h-3.5 w-3.5"})})}),/* @__PURE__ */n(pa,{align:"end",className:"w-64",children:[/* @__PURE__ */e("p",{className:"px-2 pb-1.5 pt-1 text-[11px] text-muted-foreground",children:"Changes apply to dashboard view only"}),S.map(O=>/* @__PURE__ */n(Sc,{checked:O.checked,onCheckedChange:L=>C(O.option,L),onSelect:L=>L.preventDefault(),className:"[&_svg]:h-3.5 [&_svg]:w-3.5",children:[/* @__PURE__ */e("span",{className:"min-w-0 flex-1 truncate",children:O.label}),/* @__PURE__ */e("span",{className:"ml-3 shrink-0 text-[11px] text-muted-foreground",children:O.hint})]},O.option))]})]})});}function On({className:t,triggerVariant:a="icon",label:s="Pinned filters"}){const[r,i]=Y(!1),c=E(I=>I.card),d=E(I=>I.selectedConnectionId),{tokenProps:l}=Rt(),{setCard:o}=me(),x=fe(I=>I.actions.removeCardInlineFilterValue),u=fe(I=>I.actions.setCardInlineFilterValue),p=E(I=>I.actions.removeCardInlineFilterValue),h=E(I=>I.actions.setCardInlineFilterValue),m=Tc(),C=(c==null?void 0:c.inlineFilters)||[],S=Ya.useMemo(()=>c?[c]:[],[c]),{inlineCalculatedFields:w}=$r(),v=Ya.useMemo(()=>({fields:w.filter(I=>I.fieldScope==="card"),domainId:ul(c==null?void 0:c.dataSource)}),[w,c==null?void 0:c.dataSource]),y=Nn()??void 0,A=Ji(Kn(to,{activationConstraint:{distance:5}}),Kn(eo,{coordinateGetter:Zi}));function b({active:I,over:O}){if(!O||I.id===O.id)return;const L=C.findIndex(K=>K.id===O.id);if(L===-1)return;const k=Qd(C,String(I.id),L);k!==C&&o({...c,inlineFilters:[...k]});}function z(I){if(C.find(k=>ml(k,I)))return;const L=Gd({id:qa(),field:I,...hl(c??{},d)});o({...c,inlineFilters:[...C,L]});}function B(I){const O=C.filter(L=>L.id!==I);o({...c,inlineFilters:O}),m?p(c.id,I):x(c.id,I);}function j(I,O){const L=C.find(f=>f.id===I),k=C.map(f=>f.id===I?{...f,...O}:f);o({...c,inlineFilters:k});const K=k.find(f=>f.id===I);if(!K||!pl(L,K))return;const M=fl(K,y);M?m?h(c.id,M):u(c.id,M):m?p(c.id,I):x(c.id,I);}if(!Ud(c==null?void 0:c.type))return null;const $=a==="menu";return/* @__PURE__ */e("div",{className:W("flex items-center gap-1",$&&"w-full",t),children:/* @__PURE__ */n(it,{open:r,onOpenChange:i,children:[/* @__PURE__ */e(xt,{asChild:!0,children:$?/* @__PURE__ */n(ce,{variant:"ghost",className:"h-auto w-full justify-start gap-2 rounded-sm px-2 py-1.5 text-[13px] font-normal",children:[/* @__PURE__ */e(Hn,{className:"h-3.5 w-3.5 text-muted-foreground"}),/* @__PURE__ */e("span",{children:s}),C.length>0&&/* @__PURE__ */e("span",{className:"ml-auto text-[11px] tabular-nums text-muted-foreground",children:C.length})]}):/* @__PURE__ */n(Ve,{tooltip:"Pin a filter",className:W("relative h-7 w-7 px-0",{"text-primary":C.length>0}),children:[/* @__PURE__ */e(Hn,{className:"h-3.5 w-3.5"}),C.length>0&&/* @__PURE__ */e("span",{className:"absolute -right-1 -top-1 flex h-4 w-4 items-center justify-center rounded-full bg-primary text-[10px] font-medium text-primary-foreground",children:C.length})]})}),/* @__PURE__ */e(ot,{align:"end",className:W("w-80 p-0",$&&"z-[60]"),children:/* @__PURE__ */n("div",{className:"flex flex-col",children:[/* @__PURE__ */n("div",{className:"border-b px-4 py-3",children:[/* @__PURE__ */e("h4",{className:"text-sm font-medium",children:"Pinned filters"}),/* @__PURE__ */e("p",{className:"text-xs text-muted-foreground",children:"Pick a field to pin a filter on the card."})]}),/* @__PURE__ */e("div",{className:"flex h-[320px] min-h-0 flex-col overflow-hidden",children:/* @__PURE__ */e(ao,{cards:S,context:"inline-filter",onFieldSelect:z,inlineFilters:C,cardCalculated:v})}),C.length>0&&/* @__PURE__ */n("div",{className:"border-t px-4 py-3",children:[/* @__PURE__ */e("p",{className:"mb-2 text-xs font-medium text-muted-foreground",children:"Pinned, in the order the card shows them"}),/* @__PURE__ */e(no,{sensors:A,collisionDetection:ro,onDragEnd:b,children:/* @__PURE__ */e(so,{items:C.map(I=>I.id),strategy:lo,children:/* @__PURE__ */e("div",{className:"space-y-1",children:C.map(I=>/* @__PURE__ */e(sm,{filter:I,onUpdate:O=>j(I.id,O),onRemove:()=>B(I.id)},I.id))})})})]})]})})]})});}function sm({filter:t,onUpdate:a,onRemove:s}){const{attributes:r,listeners:i,setNodeRef:c,transform:d,transition:l,isDragging:o}=io({id:t.id});return/* @__PURE__ */n("div",{ref:c,style:{transform:oo.Transform.toString(d),transition:l},className:W("flex items-center justify-between gap-1 rounded-md bg-muted px-1 py-1.5 text-sm",o&&"relative z-10 shadow-sm"),children:[/* @__PURE__ */e("button",{type:"button","aria-label":`Move ${t.title}`,className:"flex h-5 w-4 shrink-0 cursor-grab items-center justify-center text-muted-foreground hover:text-foreground active:cursor-grabbing",...r,...i,children:/* @__PURE__ */e(as,{className:"h-3 w-3"})}),/* @__PURE__ */e("span",{className:"min-w-0 flex-1 truncate",title:t.column,children:t.title}),/* @__PURE__ */n("div",{className:"flex items-center gap-0.5",children:[/* @__PURE__ */e(kc,{filter:t,variant:"inline",onAccept:x=>a(x),trigger:/* @__PURE__ */e(ce,{variant:"ghost",size:"icon",className:"h-5 w-5 shrink-0",title:"Configure filter",children:/* @__PURE__ */e(fa,{className:"h-3 w-3"})})}),/* @__PURE__ */e(ce,{variant:"ghost",size:"icon",className:"h-5 w-5 shrink-0 hover:bg-destructive/10 hover:text-destructive",onClick:s,children:/* @__PURE__ */e(ia,{className:"h-3 w-3"})})]})]});}const lm={metric_selector:"Displayed metric",field_selector:"Group by field",aggregation_selector:"Aggregation",grain_selector:"Time grain"};function im(t,a){return t&&typeof t=="object"&&"label"in t&&typeof t.label=="string"&&t.label.trim().length>0?t.label:a||null;}const om={metric_selector:"config_metric_selector",field_selector:"config_field_selector",aggregation_selector:"config_aggregation",grain_selector:"config_grain"};function na(t,a){return`${t}:${a}`;}function cm(t,a,s,r,i){const c=new Set(s.filter(l=>l.target!=="sql_param"&&l.target!=="presentation_currency").map(l=>na(l.controlId,l.target))),d=a.map(l=>{const o=wr({card:t,control:l,matrixSpec:r,resolveDataType:i}).map(h=>h.value),x=om[l.type],p=[...(x&&o.includes(x)?[x]:[]),...o.filter(h=>h!==x)].find(h=>!c.has(na(l.id,h)));return p?{controlId:l.id,target:p}:null;}).find(Boolean);return d?{controlId:d.controlId,target:d.target,mapping:{}}:null;}function dm({card:t,dashboardControls:a,bindings:s,onChange:r,availableFieldChoices:i,matrixFieldCatalog:c=[],availableMetricChoices:d,suppressTransientStaleState:l=!1,matrixSpec:o,matrixPresentation:x}){const u=X(()=>x??(o?vd(o).presentation:void 0),[o,x]);function p(I){return!o||!u?[]:bl(o,I,w).map(O=>({id:O.id,label:O.kind==="measure"?`${yd(O.measure,u)} (${O.measure.aggregate})`:`${O.axis==="rows"?"Rows":"Columns"}: ${Nd(O.level,u)}`}));}const h=[...a,...(t.controls||[])],[m,C]=Y({}),S=Jd({sql:t.sql,controlBindings:t.controlBindings});function w(I){return o?vl(I,o.source,c):I.dataType;}const v=gl(t,o,w),y=new Set(s.map(I=>na(I.controlId,I.target))),A=h.some(I=>wr({card:t,control:I,matrixSpec:o,resolveDataType:w}).some(O=>!y.has(na(I.id,O.value)))),b=l?0:s.reduce((I,O)=>{const L=z(O.target),k=Object.values(O.mapping).filter(K=>{const M=O.target==="config_metric_selector"||O.target==="config_field_selector"?typeof K=="string"?K:K==null?void 0:K.id:typeof K=="string"?K:void 0;return typeof M=="string"&&!L.some(f=>f.value===M);}).length;return I+k;},0);function z(I){var O,L,k,K;switch(I){case"config_metric_selector":return d?d.filter(M=>!!M.target).map(M=>({value:M.target.id,label:M.target.label||M.option.label,target:M.target})):o&&u?p(I).map(M=>({value:M.id,label:M.label,target:{kind:"matrix_instance",id:M.id}})):((L=(O=t.config)==null?void 0:O.metricColumns)==null?void 0:L.map(M=>({value:M.id,label:M.label||M.id,target:M})))||[];case"config_field_selector":return i?i.filter(M=>!!M.target).map(M=>({value:M.target.id,label:M.target.label||M.option.label,target:M.target})):o&&u?p(I).map(M=>({value:M.id,label:M.label,target:{kind:"matrix_instance",id:M.id}})):((K=(k=t.config)==null?void 0:k.groupByColumns)==null?void 0:K.map(M=>({value:M.id,label:M.label||M.id,target:M})))||[];case"config_aggregation":return(v.config_aggregation||[]).map(M=>({value:M,label:M}));case"config_grain":return(v.config_grain||[]).map(M=>({value:M,label:M.charAt(0).toUpperCase()+M.slice(1)}));default:return[];}}const B=(I,O)=>{r(s.map((L,k)=>k!==I?L:O(L)));},j=I=>{r(s.filter((O,L)=>L!==I));},$=()=>{const I=cm(t,h,s,o,w);I&&r([...s,I]);};if(typeof t.sql=="string"&&t.sql.trim().length>0){const I=S.map(({controlId:O,paramId:L})=>{const k=h.find(K=>K.id===O);return k?{id:O,paramId:L,label:k.label,reference:`[[param.${L}]]`}:{id:O,paramId:L,label:O,reference:`[[param.${L}]]`};});return/* @__PURE__ */e("div",{className:"space-y-2",children:I.length===0?/* @__PURE__ */e("div",{className:"rounded-md border border-dashed p-3 text-sm text-muted-foreground",children:"This card is currently using raw SQL. Reference a control directly in the SQL editor with syntax like `[[param.metric]]`."}):I.map(O=>/* @__PURE__ */e("div",{className:"rounded-md border p-3",children:/* @__PURE__ */n("div",{className:"flex items-start justify-between gap-3",children:[/* @__PURE__ */n("div",{children:[/* @__PURE__ */e("div",{className:"text-sm font-medium",children:O.label}),/* @__PURE__ */e("p",{className:"text-xs text-muted-foreground",children:"Referenced in SQL"})]}),/* @__PURE__ */n("div",{className:"flex items-center gap-2 rounded-md bg-muted/40 px-2 py-1",children:[/* @__PURE__ */e("code",{className:"text-xs",children:O.reference}),/* @__PURE__ */e(Jr,{text:O.reference,ariaLabel:`Copy ${O.reference}`})]})]})},`${O.id}:${O.paramId}`))});}return/* @__PURE__ */n("div",{className:"space-y-4",children:[b>0?/* @__PURE__ */n("div",{className:"flex items-start gap-2 rounded-md border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-950",children:[/* @__PURE__ */e(Ua,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),/* @__PURE__ */n("span",{children:[b," ",b===1?"mapping needs":"mappings need"," attention before save. Replace each missing target or choose Not mapped."]})]}):null,s.length===0?/* @__PURE__ */e("div",{className:"rounded-md border border-dashed p-3 text-sm text-muted-foreground",children:"This card is not using any controls yet."}):s.map((I,O)=>{const L=v[I.target]||[],k=h.find(V=>V.id===I.controlId),K=k?xl(k):null,M=(K==null?void 0:K.source.kind)==="manual"?K.source.options:[],f=z(I.target),F=p(I.target),g=I.matrixTargetId!==void 0&&!F.some(V=>V.id===I.matrixTargetId),N=Array.from(/* @__PURE__ */new Set([...M.map(V=>V.value),...Object.keys(I.mapping)])).map(V=>{const Q=M.find(J=>J.value===V);return{value:V,label:(Q==null?void 0:Q.label)||V};}),T=`${I.controlId}-${I.target}-${O}`,_=m[T]??O===0,P=Object.keys(I.mapping).length,R=k!=null&&k.type?lm[k.type]||k.type:null;return/* @__PURE__ */n(Mt,{open:_,onOpenChange:V=>C(Q=>({...Q,[T]:V})),className:"rounded-md border",children:[/* @__PURE__ */n("div",{className:"flex items-start justify-between gap-2 p-3",children:[/* @__PURE__ */e(Ot,{asChild:!0,children:/* @__PURE__ */n("button",{type:"button",className:"flex min-w-0 flex-1 items-start gap-2 text-left",children:[_?/* @__PURE__ */e(Ft,{className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"}):/* @__PURE__ */e(nt,{className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"}),/* @__PURE__ */n("div",{className:"min-w-0",children:[/* @__PURE__ */n("div",{className:"flex min-w-0 items-center gap-2",children:[/* @__PURE__ */e("div",{className:"truncate text-sm font-medium",children:(k==null?void 0:k.label)||"Control"}),R?/* @__PURE__ */e(ns,{variant:"secondary",className:"shrink-0 text-[11px] font-normal text-muted-foreground",children:R}):null]}),/* @__PURE__ */e("div",{className:"text-xs text-muted-foreground",children:P>0?`${P} mapped`:"No mappings yet"})]})]})}),/* @__PURE__ */e(ce,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>j(O),children:/* @__PURE__ */e(rs,{className:"h-4 w-4"})})]}),/* @__PURE__ */n(At,{className:"space-y-3 border-t px-3 pb-3 pt-2",children:[o?/* @__PURE__ */n("div",{className:"space-y-1",children:[/* @__PURE__ */e(D,{className:"text-xs",htmlFor:`matrix-target-${T}`,children:"Matrix target"}),/* @__PURE__ */n(ne,{value:I.matrixTargetId??"__none__",onValueChange:V=>B(O,Q=>{const{matrixTargetId:J,...Z}=Q;return V==="__none__"?Z:{...Z,matrixTargetId:V};}),children:[/* @__PURE__ */e(re,{id:`matrix-target-${T}`,"aria-label":"Matrix target",children:/* @__PURE__ */e(se,{placeholder:"Choose target"})}),/* @__PURE__ */n(le,{children:[/* @__PURE__ */e(U,{value:"__none__",children:F.length===1?`Automatic: ${F[0].label}`:"Choose target"}),g?/* @__PURE__ */e(U,{value:I.matrixTargetId,disabled:!0,children:"Missing target"}):null,F.map(V=>/* @__PURE__ */e(U,{value:V.id,children:V.label},V.id))]})]}),g?/* @__PURE__ */e("p",{role:"alert",className:"text-xs text-amber-700",children:"The saved Matrix target is no longer available."}):F.length===0?/* @__PURE__ */e("p",{role:"alert",className:"text-xs text-muted-foreground",children:"No eligible Matrix target."}):!I.matrixTargetId&&F.length>1?/* @__PURE__ */e("p",{role:"alert",className:"text-xs text-amber-700",children:"Select a Matrix target."}):null]}):null,N.length===0?/* @__PURE__ */e("div",{className:"rounded-md border border-dashed p-3 text-sm text-muted-foreground",children:"Add choices to this control first so you can decide what each choice changes in the card."}):f.length===0?/* @__PURE__ */e("div",{className:"rounded-md border border-dashed p-3 text-sm text-muted-foreground",children:"No matching targets are available for this binding yet."}):/* @__PURE__ */n("div",{className:"space-y-2",children:[/* @__PURE__ */e(D,{className:"text-xs",children:"Map each choice"}),/* @__PURE__ */e("div",{className:"space-y-2",children:N.map(V=>{const Q=I.mapping[V.value],J=I.target==="config_metric_selector"||I.target==="config_field_selector"?typeof Q=="string"?Q:Q==null?void 0:Q.id:typeof Q=="string"?Q:void 0,Z=!l&&typeof J=="string"&&!f.some(ae=>ae.value===J),G=im(Q,J),q=J&&Z?[...f,{value:J,label:"Needs remap",target:Q}]:f;return/* @__PURE__ */n("div",{className:"grid gap-2 rounded-md border p-2 md:grid-cols-[minmax(0,1fr)_minmax(0,1fr)]",children:[/* @__PURE__ */n("div",{className:"space-y-1",children:[/* @__PURE__ */e(D,{className:"text-[11px] text-muted-foreground",children:"Viewer picks"}),/* @__PURE__ */e("div",{className:"rounded-md bg-muted/50 px-3 py-2 text-sm",children:V.label})]}),/* @__PURE__ */n("div",{className:"space-y-1",children:[/* @__PURE__ */e(D,{className:"text-[11px] text-muted-foreground",children:"Switch to"}),/* @__PURE__ */n(ne,{value:J||"__none__",onValueChange:ae=>B(O,de=>{if(de.target==="config_metric_selector"){const ie={...de.mapping};if(ae==="__none__")delete ie[V.value];else{const pe=q.find(ge=>ge.value===ae);pe!=null&&pe.target?ie[V.value]=pe.target:delete ie[V.value];}return{...de,mapping:ie};}if(de.target==="config_field_selector"){const ie={...de.mapping};if(ae==="__none__")delete ie[V.value];else{const pe=q.find(ge=>ge.value===ae);pe!=null&&pe.target?ie[V.value]=pe.target:delete ie[V.value];}return{...de,mapping:ie};}const he={...de.mapping};return ae==="__none__"?delete he[V.value]:he[V.value]=ae,{...de,mapping:he};}),children:[/* @__PURE__ */e(re,{children:/* @__PURE__ */e(se,{placeholder:"Choose what this should use"})}),/* @__PURE__ */n(le,{children:[/* @__PURE__ */e(U,{value:"__none__",children:"Not mapped"}),q.map(ae=>/* @__PURE__ */e(U,{value:ae.value,children:ae.label},ae.value))]})]}),Z?/* @__PURE__ */n("div",{className:"flex items-center gap-1.5 text-[11px] text-amber-700",children:[/* @__PURE__ */e(Ua,{className:"h-3 w-3 shrink-0"}),/* @__PURE__ */n("span",{children:["Needs remap",G?` · Previously: ${G}`:""]})]}):null]})]},`${I.controlId}-${I.target}-${V.value}`);})}),L.length>0&&/* @__PURE__ */n("p",{className:"text-[11px] text-muted-foreground",children:["Available choices for this card: ",L.join(", ")]})]})]})]},T);}),A?/* @__PURE__ */n(ce,{type:"button",variant:"outline",size:"sm",onClick:$,children:[/* @__PURE__ */e(ga,{className:"mr-2 h-4 w-4"}),"Add another control response"]}):null]});}function um(t,a,s){const{eligibleTargets:r}=fs(t,a,s),i=tu(t),c=new Map(i.map(l=>[l.id,l])),d=new Map(au(t,s).map(l=>[l.measureId,l.label]));return r.map(l=>{var o;return{key:gs(l),label:l.kind==="metric"?((o=c.get(l.metricId))==null?void 0:o.label)||l.metricId:l.kind==="column"?l.columnKey:d.get(l.measureId)||l.measureId,target:l};});}function mm(t){return t?t.kind==="metric"?t.metricId:t.kind==="column"?t.columnKey:t.measureId:"invalid target";}function hm({matrixCatalog:t,card:a,dashboardControls:s,resultColumnKeys:r=[],bindings:i,onChange:c}){const d=[...s,...(a.controls||[])],l=d.filter(Zd),o=X(()=>um(a,r,t),[a,r,t]),x=X(()=>fs(a,r,t),[a,r,t]),u=eu({bindings:i,controls:d,...x}),{preferences:p,resolveBoundCurrency:h}=Ic(a,r,t),[m,C]=Y(""),[S,w]=Y(""),v=o.find(b=>b.key===S),y=!!(m&&v)&&!i.some(b=>b.presentationTarget&&v&&gs(b.presentationTarget)===v.key),A=b=>{if(!p)return;const z=nu({card:a,target:b,resultColumnKeys:r,valueFormatPreferences:p,boundCurrency:h(b),matrixCatalog:t});if(z)return Cd(1e3,z);};return l.length===0&&i.length===0?/* @__PURE__ */e("p",{className:"text-xs text-muted-foreground",children:"Add a manual enum whose options are ISO currency codes to enable presentation currency bindings."}):/* @__PURE__ */n("div",{className:"space-y-3",children:[/* @__PURE__ */n("div",{className:"space-y-1",children:[/* @__PURE__ */e("h5",{className:"text-xs font-medium",children:"Currency presentation"}),/* @__PURE__ */e("p",{className:"text-xs text-muted-foreground",children:"Change only the display currency for an explicit metric or column."})]}),i.map((b,z)=>/* @__PURE__ */n("div",{className:"flex items-center gap-2 rounded-control border border-border/60 px-2 py-1.5 text-xs",children:[/* @__PURE__ */n("span",{className:"min-w-0 flex-1 truncate",children:[b.controlId," →"," ",mm(b.presentationTarget),b.presentationTarget?` · ${A(b.presentationTarget)??"unavailable"}`:null]}),/* @__PURE__ */e(ce,{variant:"ghost",size:"xs",onClick:()=>c(i.filter((B,j)=>j!==z)),children:/* @__PURE__ */e(rs,{className:"h-3.5 w-3.5"})})]},`${b.controlId}:${JSON.stringify(b.presentationTarget)}`)),u.length>0?/* @__PURE__ */e("div",{className:"space-y-1 text-xs text-destructive",children:u.map((b,z)=>/* @__PURE__ */n("p",{children:[b.controlId?`${b.controlId}: `:"",b.code.split("_").join(" ")]},`${b.controlId||"binding"}:${b.code}:${z}`))}):null,/* @__PURE__ */n("div",{className:"grid grid-cols-[1fr_1fr_auto] gap-2",children:[/* @__PURE__ */n(ne,{value:m,onValueChange:C,children:[/* @__PURE__ */e(re,{size:"xs",children:/* @__PURE__ */e(se,{placeholder:"Currency control"})}),/* @__PURE__ */e(le,{children:l.map(b=>/* @__PURE__ */e(U,{value:b.id,children:b.label},b.id))})]}),/* @__PURE__ */n(ne,{value:S,onValueChange:w,children:[/* @__PURE__ */e(re,{size:"xs",children:/* @__PURE__ */e(se,{placeholder:"Target"})}),/* @__PURE__ */e(le,{children:o.map(b=>/* @__PURE__ */e(U,{value:b.key,children:b.label},b.key))})]}),/* @__PURE__ */e(ce,{variant:"outline",size:"xs",disabled:!y,onClick:()=>{v&&(c([...i,{controlId:m,target:"presentation_currency",presentationTarget:v.target}]),w(""));},children:/* @__PURE__ */e(ga,{className:"h-3.5 w-3.5"})})]})]});}const pm=[];function An({className:t,triggerVariant:a="icon",label:s="Controls"}){var T,_,P;const{handleOpenChange:r,preventPassiveDismissDuringCreate:i,resolvedOpen:c,setIsCreateFlowActive:d}=Ad({}),l=E(R=>R.card),o=E(R=>R.frame),x=E(R=>R.queryResultColumns),u=fe(R=>R.dashboard),h=fe(R=>R.dashboard.controls)||pm,{setCard:m,updateCardInFrame:C}=me(),[S,w]=Y(null);ve(()=>{c&&!S&&l!=null&&l.id&&w(l.id);},[l==null?void 0:l.id,c,S]),ve(()=>{!c&&S!==null&&w(null);},[c,S]);const v=X(()=>S?(o==null?void 0:o.cards.find(R=>R.id===S))||((l==null?void 0:l.id)===S?l:void 0):l,[l,o==null?void 0:o.cards,S]),y=(v==null?void 0:v.type)==="matrixTable"?(T=v.config)==null?void 0:T.matrix:void 0,A=X(()=>c&&y?qd(y.spec,v==null?void 0:v.controlBindings):[],[c,y,v==null?void 0:v.controlBindings]),b=co(A),z=X(()=>b.catalog.map(R=>({...R.field,dataType:ci(R.resolvedField.dataType)})),[b.catalog]),B=(v==null?void 0:v.controls)||[],j=v?yl(u,{excludeCardId:v.id}):h.map(R=>R.id),$=((v==null?void 0:v.controlBindings)||[]).filter(Nl),I=((v==null?void 0:v.controlBindings)||[]).filter(ya),O=uo({card:v,controls:B}),L={choices:Cl(v),targetMap:Object.fromEntries((((_=v==null?void 0:v.config)==null?void 0:_.groupByColumns)||[]).map(R=>[R.id,R]))},k={choices:wl(v),targetMap:Object.fromEntries((((P=v==null?void 0:v.config)==null?void 0:P.metricColumns)||[]).map(R=>[R.id,R]))},K=L.choices.map(R=>({option:R,target:L.targetMap[R.value]})),M=k.choices.map(R=>({option:R,target:k.targetMap[R.value]})),f=(R,V)=>{if(!v)return;const Q=(V==null?void 0:V.type)==="rename"?Un(v,{type:"rename",oldId:V.oldId,newId:V.newId}):(V==null?void 0:V.type)==="remove"?Un(v,{type:"remove",controlId:V.controlId}):v,J={...Q,controls:R,controlBindings:Sl(Q.controlBindings,R)};C(J),(l==null?void 0:l.id)===J.id&&m(J);},F=R=>{if(!v)return;const V={...v,controlBindings:[...Tl(R,(v.controlBindings||[]).filter(Q=>!ya(Q))),...I]};C(V),(l==null?void 0:l.id)===V.id&&m(V);},g=R=>{if(!v)return;const V={...v,controlBindings:[...(v.controlBindings||[]).filter(Q=>!ya(Q)),...R]};C(V),(l==null?void 0:l.id)===V.id&&m(V);},N=a==="menu";return/* @__PURE__ */e("div",{className:W("flex items-center gap-1",N&&"w-full",t),children:/* @__PURE__ */n(it,{modal:!0,open:c,onOpenChange:r,children:[/* @__PURE__ */e(xt,{asChild:!0,children:N?/* @__PURE__ */n(ce,{variant:"ghost",className:"h-auto w-full justify-start gap-2 rounded-sm px-2 py-1.5 text-[13px] font-normal",children:[/* @__PURE__ */e(aa,{className:"h-3.5 w-3.5 text-muted-foreground"}),/* @__PURE__ */e("span",{children:s}),B.length+$.length>0&&/* @__PURE__ */e("span",{className:"ml-auto text-[11px] tabular-nums text-muted-foreground",children:B.length+$.length})]}):/* @__PURE__ */n(Ve,{tooltip:"Configure Controls",className:W("relative h-7 w-7 px-0",{"text-primary":B.length>0||$.length>0}),children:[/* @__PURE__ */e(aa,{className:"h-3.5 w-3.5"}),B.length+$.length>0&&/* @__PURE__ */e("span",{className:"absolute -right-1 -top-1 inline-flex h-4 min-w-4 items-center justify-center rounded-full bg-primary px-1 text-[10px] font-medium text-primary-foreground",children:B.length+$.length})]})}),/* @__PURE__ */n(ot,{className:W("flex max-h-[85vh] w-[560px] max-w-[95vw] flex-col",N&&"z-[60]"),align:"end",onEscapeKeyDown:i,onPointerDownOutside:i,children:[/* @__PURE__ */n("div",{className:"space-y-1 border-b pb-4",children:[/* @__PURE__ */e("h4",{className:"text-sm font-medium",children:"Card-only controls"}),/* @__PURE__ */e("p",{className:"text-xs text-muted-foreground",children:"Add controls that belong only to this card, or decide how this card should respond to shared dashboard controls."}),v!=null&&v.sql?/* @__PURE__ */e("p",{className:"text-xs text-muted-foreground",children:"SQL cards reference controls explicitly with syntax like `[[param.wac_type]]`."}):null]}),/* @__PURE__ */e("div",{className:"flex-1 overflow-y-auto pt-5",children:/* @__PURE__ */n("div",{className:"space-y-5 pr-1",children:[/* @__PURE__ */e(Rd,{scope:"card",card:v,controls:B,reservedControlIds:j,usageByControlId:O,availableFieldChoices:K,availableMetricChoices:M,onCreateFlowActiveChange:d,onChange:(R,V,Q)=>f(R,Q),emptyMessage:"No card-scoped controls yet."}),/* @__PURE__ */n("div",{className:"space-y-1 border-t pt-4",children:[/* @__PURE__ */e("h4",{className:"text-sm font-medium",children:"How this card uses controls"}),/* @__PURE__ */e("p",{className:"text-xs text-muted-foreground",children:"Choose what each control changes in this card."})]}),v?/* @__PURE__ */n(be,{children:[/* @__PURE__ */e(dm,{card:v,dashboardControls:h,bindings:$,onChange:F,availableFieldChoices:y?void 0:K,availableMetricChoices:y?void 0:M,matrixSpec:y==null?void 0:y.spec,matrixPresentation:y==null?void 0:y.presentation,matrixFieldCatalog:z,suppressTransientStaleState:!!(y&&b.pending)}),/* @__PURE__ */e("div",{className:"border-t pt-4",children:/* @__PURE__ */e(hm,{matrixCatalog:b.catalog,card:v,dashboardControls:h,resultColumnKeys:x,bindings:I,onChange:g})})]}):null]})})]})]})});}function Os({showOrientation:t=!0,showGridStyle:a=!0,showInlineFilters:s=!0,showControls:r=!0,showDisplayOptions:i=!0}={}){const c=E(m=>m.card),d=E(m=>{var C,S;return(S=(C=m.card)==null?void 0:C.preferences)==null?void 0:S.chartOptions;}),l=Ec(d),{setChartGrid:o}=me();function x(){const m=["xy","none","x","y"],S=(m.indexOf(l)+1)%m.length;o(m[S]);}const u=t&&["line","bar","range","stackedBar","stackedLine","horizontalBar","funnel","bullet"].includes(c.type),p=a&&!["pie","doughnut","funnel","radar","polarArea","table","detailTable","custom","kpi","text"].includes(c.type);return u||p||s||r||i?/* @__PURE__ */n("div",{"data-info":"visual-settings",className:"flex items-center gap-2",children:[u&&/* @__PURE__ */e(be,{children:/* @__PURE__ */e(rm,{})}),p&&/* @__PURE__ */n(Ve,{tooltip:"Grid Style",onClick:x,className:"h-7 w-7 px-0",children:[(l==="xy"||!l)&&/* @__PURE__ */e(ea,{className:"h-3.5 w-3.5"}),l==="x"&&/* @__PURE__ */e(ss,{className:"h-3.5 w-3.5"}),l==="y"&&/* @__PURE__ */e(ls,{className:"h-3.5 w-3.5"}),l==="none"&&/* @__PURE__ */e(Or,{className:"h-3.5 w-3.5"})]}),s&&/* @__PURE__ */e(On,{}),r&&/* @__PURE__ */e(An,{}),i&&/* @__PURE__ */e(Mn,{})]}):null;}function fm({errorMessage:t,errorSql:a,onOpenInEditor:s}){const{feedbackDialogOpen:r,setFeedbackDialogOpen:i,handleSendFeedback:c,feedbackPayload:d}=Is(t,a);return/* @__PURE__ */n(be,{children:[/* @__PURE__ */e("div",{className:"flex h-full min-h-0 flex-col overflow-auto px-4 py-0",children:/* @__PURE__ */e(dn,{error:t,errorSql:a,errorMessageClassName:"max-h-40",fillAvailableSqlHeight:!0,className:"max-h-none",onOpenInEditor:s,onSendFeedback:c,showFeedbackButton:!0})}),/* @__PURE__ */e(En,{open:r,onOpenChange:i,feedbackData:d,showDebugInfo:!0})]});}function gm({isPreviewMode:t,onPreviewToggle:a,configCard:s}){var F,g,N,T,_;const r=E(P=>P.frame),i=E(P=>P.card),c=E(P=>P.editorContext),d=(c==null?void 0:c.type)==="documentSection",l=fe(P=>{var R,V;return Il((V=(R=P.dashboard)==null?void 0:R.sheets)==null?void 0:V.find(Q=>{var J;return(J=Q.frames)==null?void 0:J.some(Z=>Z.id===r.id);}));}),{setFrame:o,setActiveTabCardId:x,setCard:u,updateCardInFrame:p,closeCardTab:h}=me(),{manifest:m}=bt(((F=s==null?void 0:s.customCardPreferences)==null?void 0:F.url)||""),C=(g=m==null?void 0:m.visuals)==null?void 0:g.find(P=>{var R;return P.name===((R=s==null?void 0:s.customCardPreferences)==null?void 0:R.componentName);}),w=yt(s,C)==="multiple",v=(C==null?void 0:C.minInputs)??((N=s==null?void 0:s.customCardPreferences)==null?void 0:N.minInputs)??1,y=(C==null?void 0:C.maxInputs)??((T=s==null?void 0:s.customCardPreferences)==null?void 0:T.maxInputs),A=X(()=>Qt({frame:r,configCard:s,isMultiInputVisual:w}),[r,s,w]),b=w?A.filter(Boolean).length:r.cards.length,z=d?!1:y?b<y:!0,B=b>Math.max(v||1,1),j=!!((_=s==null?void 0:s.customCardPreferences)!=null&&_.dataInputCardIds),$=(P,R)=>{P.dataTransfer.setData("tabIndex",R.toString());},I=P=>{P.preventDefault();},O=(P,R)=>{const V=P.dataTransfer.getData("tabIndex");if(V===R.toString())return;const Q=Array.from(r.cards),[J]=Q.splice(parseInt(V),1);Q.splice(R,0,J),o({...r,cards:Q});};function L(P){const R=(s==null?void 0:s.id)===P;(j&&R?r.cards.length>1:B)&&h(P,{renumber:w&&!j?Ed:void 0});}function k(P,R){if(!z)return;const V={...r,cards:[...r.cards,R],activeCardId:P.id};o(V),x(R.id);}function K(){if(d)return;if(w&&(s==null?void 0:s.id)===i.id){M(i);return;}const P={...i,id:qa(),title:`${i.title} Copy`,tabTitle:`${i.tabTitle||i.title} Copy`,customCardPreferences:i.customCardPreferences?{...i.customCardPreferences,slotIndex:w?Math.max(-1,...A.map((R,V)=>at(R,V)))+1:i.customCardPreferences.slotIndex}:void 0};k(i,P);}function M(P){var G;if(d||!z)return;let R=w?"table":Sn,V="Title",Q="";const J=w?Math.max(-1,...A.map((q,ae)=>at(q,ae)))+1:b;if(w&&(G=C==null?void 0:C.slots)!=null&&G.length){const q=Xa(C.slots,J);q&&(R=Fd(q),V=q.label||`Tab ${J+1}`,Q=q.description||"");}const Z={dataSource:P.dataSource,connectionId:P.connectionId,id:qa(),title:V,tabTitle:V,description:Q,preferences:{onClickFilter:[{columnIndex:0,expression:""}],...(R==="text"?{textVisualOptions:{richContent:El()}}:{})},type:R,sql:"",data:[],mode:"explorer",...(w&&{customCardPreferences:{slotIndex:J}})};k(P,Z);}function f(P,R){return P.cards.length===1&&(R.displayTab===!0||R.displayTab===void 0)||P.activeCardId!==R.id&&(R.displayTab===!0||R.displayTab===void 0)?null:/* @__PURE__ */e("div",{onClick:()=>{const V=R.displayTab===void 0?!1:!R.displayTab;u({...R,displayTab:V}),p({...R,displayTab:V});},children:R.displayTab===!0||R.displayTab===void 0?/* @__PURE__ */e(Ga,{className:"h-3 w-3 text-muted-foreground hover:text-foreground"}):/* @__PURE__ */e(Gn,{className:"h-3 w-3 text-muted-foreground hover:text-foreground"})});}return/* @__PURE__ */e(gt,{variant:"underline",className:"group flex h-9 shrink-0 items-center justify-start gap-1 overflow-x-auto rounded-none border-b-0 border-t border-border bg-background px-4",children:/* @__PURE__ */n("div",{className:"flex items-center gap-1",children:[r.cards.map((P,R)=>{var G,q;const V=w?at(P,R):-1,Q=w&&(G=C==null?void 0:C.slots)!=null&&G.length&&V>=0?Xa(C.slots,V):null,J=Q?(Array.isArray(Q.expectedType)?Q.expectedType[0]:Q.expectedType)||"table":P.type,Z=w&&((q=C==null?void 0:C.slots)==null?void 0:q.length)&&C.slots.every(ae=>typeof ae.position=="number"||typeof ae.position=="string"&&!ae.position.includes("+"));return/* @__PURE__ */n(qe,{draggable:!w&&!d,onDragStart:w||d?void 0:ae=>$(ae,R),onDragOver:w||d?void 0:I,onDrop:w||d?void 0:ae=>O(ae,R),className:W("inline-flex h-6 shrink-0 items-center gap-1.5 rounded-[5px] border px-2 text-[12px] font-normal text-muted-foreground transition-colors","mb-0 border-transparent pb-0","hover:bg-muted/40 hover:text-foreground","data-[state=active]:border-border data-[state=active]:bg-card data-[state=active]:text-foreground"),value:P.id,children:[w&&Q?/* @__PURE__ */e(Lt,{delayDuration:0,children:/* @__PURE__ */n(mt,{children:[/* @__PURE__ */e(ht,{asChild:!0,children:/* @__PURE__ */n("div",{className:"flex items-center gap-2",children:[/* @__PURE__ */e("span",{className:"text-muted-foreground",children:Br(J,"size-3.5")}),/* @__PURE__ */e("span",{children:Q.label||`Tab ${V+1}`})]})}),/* @__PURE__ */e(pt,{side:"bottom",className:"w-64 p-3 text-left",children:/* @__PURE__ */n("div",{className:"space-y-2",children:[/* @__PURE__ */e("p",{className:"text-xs font-medium",children:Q.label}),Q.description&&/* @__PURE__ */e("p",{className:"whitespace-normal break-words text-xs text-muted-foreground",children:Q.description}),/* @__PURE__ */n("div",{className:"flex items-center gap-2 pt-1",children:[Q.expectedType&&/* @__PURE__ */e("span",{className:"inline-flex items-center rounded bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground",children:Array.isArray(Q.expectedType)?Q.expectedType.join(" / "):Q.expectedType}),Q.required&&/* @__PURE__ */e("span",{className:"inline-flex items-center rounded bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground",children:"Required"})]})]})})]})}):/* @__PURE__ */n(be,{children:[f(r,P),/* @__PURE__ */e(xo,{enabled:r.activeCardId===P.id,text:P.tabTitle||P.title,onSave:ae=>{u({...i,tabTitle:ae}),p({...i,tabTitle:ae});},children:P.tabTitle||P.title},P.id)]}),!d&&!l&&r.activeCardId===P.id&&!Z&&/* @__PURE__ */e(bo,{className:"h-3 w-3 text-muted-foreground hover:text-foreground",onClick:ae=>{ae.stopPropagation(),K();}}),!d&&r.activeCardId===P.id&&(j&&(s==null?void 0:s.id)===P.id?r.cards.length>1:B)&&/* @__PURE__ */e(ia,{className:"h-3 w-3 text-muted-foreground hover:text-foreground",onClick:()=>L(P.id)})]},P.id);}),!d&&!l&&/* @__PURE__ */e(Ve,{tooltip:"Add Card",className:"h-6 w-6 rounded-[5px] p-0 text-muted-foreground hover:bg-muted hover:text-foreground",onClick:()=>M(i),disabled:!z,children:/* @__PURE__ */e(ga,{className:"h-3 w-3"})}),w&&/* @__PURE__ */n(Qs,{pressed:t,onPressedChange:a,size:"sm",className:"ml-1 h-6 gap-1 rounded-[5px] px-2 text-[11px] data-[state=on]:bg-muted data-[state=on]:text-foreground","aria-label":"Toggle preview",children:[t?/* @__PURE__ */e(Gn,{className:"h-3 w-3"}):/* @__PURE__ */e(Ga,{className:"h-3 w-3"}),/* @__PURE__ */e("span",{children:"Preview"})]})]})});}function an({renderCardOverride:t,alwaysRenderOverride:a=!1}={}){var Pe,He,Ze,xe,oe,Oe,H,Ie;const s=Fc(),r=E(te=>te.frame),i=E(te=>te.card),[c,d]=Y(!1),l=X(()=>vt(r,i),[r,i]),o=E(te=>te.isSqlRunning);E(te=>te.isDevMode);const{switchCardTab:x,resetAllColumnSettings:u}=me(),p=Object.keys(((He=(Pe=i.preferences)==null?void 0:Pe.tablePrefs)==null?void 0:He.columnSettingsMap)??{}).length>0||Object.keys(((Ze=i.preferences)==null?void 0:Ze.sqlColumns)??{}).length>0,[h,m]=Y({}),[C,S]=Y(()=>/* @__PURE__ */new Set()),{authToken:w}=Rt(),v=kl(w==null?void 0:w.accessToken),{compiledAppearance:y}=iu(),A=X(()=>Mc(y),[y]),{getCard:b,manifest:z,isLoading:B}=bt(((xe=l==null?void 0:l.customCardPreferences)==null?void 0:xe.url)||""),j=(oe=l==null?void 0:l.customCardPreferences)==null?void 0:oe.componentName,$=j?b(j):null,I=(Oe=z==null?void 0:z.visuals)==null?void 0:Oe.find(te=>te.name===j),O=yt(l,I),L=c&&O==="multiple"&&!!l,k=X(()=>Qt({frame:r,configCard:l,isMultiInputVisual:!0}).map(Ne=>(Ne==null?void 0:Ne.id)===i.id?i:Ne),[r,l,i]),K=X(()=>hs(k),[k]),M=X(()=>{const te=k.findIndex(Ne=>(Ne==null?void 0:Ne.id)===i.id);return te<0?-1:at(i,te);},[k,i]),f=X(()=>!l||O!=="multiple"||M<0?i.type:It(i,M,I==null?void 0:I.slots)??i.type,[l,O,M,i,I==null?void 0:I.slots]),F=X(()=>L?{...i,connectionId:void 0,dataSource:void 0,sql:"",python:"",config:void 0,queryConfig:void 0}:f!==i.type?{...i,type:f}:i,[i,f,L]),{data:g,dataUpdatedAt:N,isLoading:T,isFetching:_,isError:P,errorMessage:R,errorSql:V,queryKey:Q}=je(F),J=da(i,g),Z=JSON.stringify(Q),{handleOpenInEditor:G}=ks(V||i.sql||i.python),q=i.type==="text"&&((Ie=(H=i.preferences)==null?void 0:H.textVisualOptions)==null?void 0:Ie.isDynamicText)===!0&&!!R,ae=rt((te,Ne)=>{const lt=Id(Ne);m(Qe=>({...Qe,[te]:lt}));},[]),de=rt((te,Ne)=>{S(lt=>{const Qe=new Set(lt);return Ne?Qe.add(te):Qe.delete(te),Qe;});},[]),he=C.size>0,ie=X(()=>K.map((te,Ne)=>It(te,Ne,I==null?void 0:I.slots)),[K,I==null?void 0:I.slots]),pe=X(()=>mo(ho({slotOrderedCards:K,multiInputData:h,valueFormatPreferences:s})),[h,K,s]),ge=Oc(),Fe=fe(te=>te.dashboard),Re=fe(te=>te.dashboardInputValues),Ue=fe(te=>te.adHocFilterValues),ue=fe(te=>{var Ne;return((Ne=te.reportContext)==null?void 0:Ne.calendar)??null;}),Ce=fe(te=>te.selectedSheetId),Me=E(te=>te.inlineFilterValuesMap[(l==null?void 0:l.id)||""]),st=E(te=>te.actions.setCardInlineFilterValue),ze=E(te=>te.actions.removeCardInlineFilterValue),Xe=X(()=>l?po({card:l,sheetId:Ce||"",inlineFilterValues:Me,setInlineFilterValue:te=>st(l.id,te),removeInlineFilterValue:te=>ze(l.id,te)}):[],[l,Ce,Me,st,ze]),{filterInputs:Je,filters:ee,filterValues:ye}=X(()=>l?Ac({dashboard:Fe,card:l,sheetId:Ce,dashboardInputValues:Re,adHocFilterValues:Ue,transientContexts:ge,calendar:ue}):{filterInputs:[],filters:[],filterValues:[]},[Ue,l,Re,ue,Fe,Ce,ge]);function Ae(te){x(te);}function _e(){return B?/* @__PURE__ */e("div",{className:"flex h-full items-center justify-center",children:/* @__PURE__ */e(tt,{size:"md",color:"muted","aria-label":"Loading manifest"})}):$?/* @__PURE__ */n("div",{className:"relative flex h-full flex-col pl-2 pr-4",children:[k.map((Ne,lt)=>{if(!Ne)return null;const Qe=at(Ne,lt),$s=It(Ne,Qe,I==null?void 0:I.slots);return/* @__PURE__ */e(vo,{onLoadingStatus:de,onDataChange:ae,card:Ne,effectiveCardType:$s},`${Ne.id}-${Qe}`);}),he&&/* @__PURE__ */e("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-background/50",children:/* @__PURE__ */e(tt,{size:"md",color:"muted","aria-label":"Loading preview"})}),/* @__PURE__ */e("div",{className:W("flex h-full min-h-0 flex-1 flex-col gap-2",he&&"opacity-50"),children:/* @__PURE__ */e(bd,{fallback:/* @__PURE__ */e("div",{className:"flex h-full items-center justify-center",children:/* @__PURE__ */e(tt,{size:"md",color:"muted"})}),children:/* @__PURE__ */e($,{editing:!0,...yo({configCard:l,slotOrderedCards:K,slotTypes:ie,multiInputData:h,params:v,theme:A,filterInputs:Je,filters:ee,filterValues:[...(ye||[]),...(Me||[])],inlineFilters:Xe,formatTemporalBucketValue:pe})})})})]}):/* @__PURE__ */e("div",{className:"flex h-full items-center justify-center text-sm text-muted-foreground",children:"Select a component to preview the multi-input visual."});}function Le(){return L?_e():t&&(a||!T&&!_&&!P&&!R)?t({card:i,data:g,isLoading:T,isFetching:_,isError:P}):i.type==="kpi"?T||_?/* @__PURE__ */e("div",{className:"z-50 flex h-full items-center justify-center",children:/* @__PURE__ */e(tt,{size:"md",color:"muted","aria-label":"Loading data"})}):R?/* @__PURE__ */e(fm,{errorMessage:R,errorSql:V||i.sql||i.python,onOpenInEditor:G}):/* @__PURE__ */e("div",{className:"flex h-full items-center justify-center",children:/* @__PURE__ */n("div",{className:"w-1/2 space-y-3",children:[/* @__PURE__ */e("div",{className:"flex h-44 rounded-md border border-border",children:/* @__PURE__ */e(fo,{card:J,data:g==null?void 0:g.records,isPending:T||_,isError:P,metadata:g==null?void 0:g.metadata})}),Dr(i)&&/* @__PURE__ */e(_r,{card:J,mode:"editor",records:g==null?void 0:g.records})]})}):i.type==="text"?T||_?/* @__PURE__ */e("div",{className:"z-50 flex h-full items-center justify-center",children:/* @__PURE__ */e(tt,{size:"md",color:"muted","aria-label":"Loading data"})}):q?/* @__PURE__ */e("div",{className:"flex h-full min-h-0 flex-col overflow-auto px-4 py-0",children:/* @__PURE__ */e(dn,{error:R,errorSql:V||i.sql||i.python,onOpenInEditor:G,showFeedbackButton:!1})}):/* @__PURE__ */e("div",{className:"flex h-full min-h-0 flex-col px-4 py-4",children:/* @__PURE__ */e(go,{isLoading:o,card:i,data:g==null?void 0:g.records})}):/* @__PURE__ */e(ua,{fallbackRender:te=>/* @__PURE__ */e(un,{...te,onResetColumnSettings:p?u:void 0}),resetKeys:[Z,N,_],children:/* @__PURE__ */e(Es,{className:"grow border-none shadow-none"})});}return/* @__PURE__ */n(ft,{onValueChange:Ae,value:r.activeCardId,className:"flex min-h-0 flex-1 flex-col",children:[L?/* @__PURE__ */e("div",{className:"mt-0 min-h-0 flex-1 overflow-hidden",children:Le()}):r.cards.map(te=>/* @__PURE__ */e(Ye,{className:"mt-0 min-h-0 flex-1 overflow-hidden focus-visible:ring-0 focus-visible:ring-offset-0",value:te.id,children:Le()},te.id)),/* @__PURE__ */e(gm,{isPreviewMode:L,onPreviewToggle:d,configCard:l})]});}function As({sql:t,debugPayloads:a,variant:s="panel",className:r}){const[i,c]=Y(!1),d=s==="popover",l=E(C=>C.isDevMode),o=E(C=>C.card.type),{switchEditorMode:x,setRunSql:u}=me(),p=!d&&!l&&!!a,h=p&&i,m=()=>{x("dev",{sqlToLoad:t}),setTimeout(()=>{u(!0);},100);};return/* @__PURE__ */n(No,{className:W("overflow-hidden",d&&"pt-0",r),children:[/* @__PURE__ */e(Co,{sql:t,label:d?"Executed SQL":"Governed query",headerClassName:d?"border-b border-border/60 py-2":void 0,labelClassName:d?"font-medium text-foreground":void 0,ariaLabel:"Executed SQL",copyAriaLabel:"Copy governed query",headerActions:l?void 0:/* @__PURE__ */n(be,{children:[rn(o)&&/* @__PURE__ */e(ce,{onClick:m,variant:"outline",size:"xs",className:wo,children:"Open in SQL editor"}),p&&/* @__PURE__ */e(So,{isOpen:i,onClick:()=>c(C=>!C)})]}),className:W("min-h-0",!d&&(h?"max-h-[40%] shrink-0":"flex-1")),bodyClassName:d?"max-h-[min(420px,calc(var(--radix-hover-card-content-available-height,100vh)-3rem))]":"flex-1"}),h&&a&&/* @__PURE__ */e(To,{payloads:a,onClose:()=>c(!1),className:"mt-3 flex-1"})]});}function La({children:t,visualAsideControl:a,mode:s="both"}){const r=gn(),i=E(ie=>ie.frame),c=E(ie=>ie.card),d=E(ie=>ie.isDevMode),l=E(ie=>ie.editorContext),o=(l==null?void 0:l.type)==="documentSection",x=fe(ie=>ie.isVisualEditing),u=fe(ie=>{var pe,ge;return(ge=(pe=ie.dashboard)==null?void 0:pe.exportDefaults)==null?void 0:ge.csvEncoding;}),p=E(ie=>ie.actions.setRunSql),h=Be(),m=h==="table"||h==="detailTable"||h==="matrixTable",S=sn(h)&&!!(a!=null&&a.onOpen),w=In(),v=X(()=>h!==c.type?{...c,type:h}:c,[c,h]),{data:y,isLoading:A,isFetching:b,errorMessage:z,refetch:B,queryKey:j,pagination:$,isCurrentQueryResult:I}=je(v),O=Ee(j);O.current=j;const L=X(()=>(y==null?void 0:y.records)||[],[y==null?void 0:y.records]),{cardFilterValues:k}=Rc((c==null?void 0:c.id)??""),[K,M]=Y(!1),f=jr(c),[F,g]=Y();ve(()=>{b||M(!1);},[b]);const N=()=>{var ie;if(f){(ie=f.refresh)==null||ie.call(f);return;}if(M(!0),d){Nr({queryClient:r,readQueryKey:()=>O.current,setRunSql:p});return;}B();},T=Array.isArray(y==null?void 0:y.records)?y.records:[],_=T.length>0;function P(){var pe;if(!_)return;const ie=JSON.stringify(T,null,2);typeof navigator>"u"||!((pe=navigator.clipboard)!=null&&pe.writeText)||navigator.clipboard.writeText(ie).catch(ge=>{console.error("Failed to copy JSON",ge);});}function R(){if(!_)return;const ie=JSON.stringify(T,null,2),pe=new Blob([ie],{type:"application/json"}),ge=URL.createObjectURL(pe),Fe=document.createElement("a");Fe.href=ge,Fe.download=`${c.title}.json`,Fe.click();}function V(){_&&Pc(Dc(Dd({records:T,encoding:lu({dashboardDefault:u})}),c.title||"export"));}if(!c)return/* @__PURE__ */e(be,{children:"No Active Card"});const Q=s==="both"||s==="toolbar",J=s==="both"||s==="canvas",Z=s==="toolbar",G=!A&&!b&&!z&&y!=null&&y.sql?/* @__PURE__ */e("div",{className:"inline-flex shrink-0 items-center text-[11px] text-muted-foreground",children:/* @__PURE__ */n(St,{openDelay:200,children:[/* @__PURE__ */e(Tt,{asChild:!0,children:/* @__PURE__ */e("button",{type:"button",className:"cursor-pointer text-[11px] transition-colors hover:text-foreground",children:"Executed SQL"})}),/* @__PURE__ */e(kt,{align:"end",collisionPadding:16,className:"w-[500px] overflow-hidden p-0",children:/* @__PURE__ */e(As,{sql:y.sql,variant:"popover"})})]})}):null,q=typeof(y==null?void 0:y.output)=="string"?y.output.trim():"",ae=Z&&!A&&!b&&!z&&q?/* @__PURE__ */n(St,{openDelay:200,children:[/* @__PURE__ */e(Tt,{asChild:!0,children:/* @__PURE__ */e("button",{type:"button",className:"cursor-pointer text-[11px] transition-colors hover:text-foreground",children:"Python output"})}),/* @__PURE__ */n(kt,{align:"end",collisionPadding:16,className:"w-[480px] overflow-hidden p-0",children:[/* @__PURE__ */e("div",{className:"border-b border-border/60 px-3 py-2 text-[12px] font-medium",children:"Python output"}),/* @__PURE__ */e("pre",{className:"max-h-80 overflow-auto whitespace-pre-wrap break-words px-3 py-2 font-mono text-[11px] leading-relaxed text-foreground/90",children:q})]})]}):null,de=($==null?void 0:$.totalCount)??L.length,he=Z&&!A&&!b&&!z&&Array.isArray(y==null?void 0:y.records)?/* @__PURE__ */n("div",{className:"flex min-w-0 items-center gap-1.5 whitespace-nowrap text-[11px] tabular-nums text-muted-foreground",children:[/* @__PURE__ */n("span",{children:[I?null:"Last run: ",de.toLocaleString()," ",de===1?"row":"rows"]}),G?/* @__PURE__ */n(be,{children:[/* @__PURE__ */e("span",{"aria-hidden":!0,className:"text-border",children:"·"}),G]}):null,ae?/* @__PURE__ */n(be,{children:[/* @__PURE__ */e("span",{"aria-hidden":!0,className:"text-border",children:"·"}),ae]}):null]}):null;return/* @__PURE__ */n("div",{className:W("relative isolate flex flex-col",Z?"pointer-events-none w-full min-w-0":W("h-full",!m&&"pt-2")),children:[Q&&/* @__PURE__ */n("div",{className:W("z-10 mb-0 flex items-center",Z?"pointer-events-none relative h-10 min-w-0 gap-3 px-4":"min-h-10 gap-2 px-4"),children:[Z?/* @__PURE__ */n("div",{className:"pointer-events-auto flex min-w-0 items-center gap-3",children:[!o&&/* @__PURE__ */e(tn,{selectedChart:c.type,onChartChange:w,compactMore:!0,responsiveCompact:!0}),he]}):/* @__PURE__ */e("div",{className:"flex grow items-center gap-4",children:/* @__PURE__ */e("div",{className:"flex items-center gap-3",children:!o&&/* @__PURE__ */e(tn,{selectedChart:c.type,onChartChange:w,compactMore:!0})})}),/* @__PURE__ */n("div",{className:W("flex items-center text-muted-foreground",Z?"pointer-events-auto ml-auto gap-1.5":"gap-2"),children:[t,Z?null:G,k&&k.length>0&&/* @__PURE__ */n(St,{openDelay:200,children:[/* @__PURE__ */e(Tt,{asChild:!0,children:/* @__PURE__ */n(ce,{variant:"outline",size:"xs",className:"h-7 gap-1.5 px-2",children:[/* @__PURE__ */e(xa,{className:"h-3.5 w-3.5",strokeWidth:1.75}),/* @__PURE__ */e(ns,{variant:"secondary",className:"h-4 min-w-4 rounded-[4px] px-1 text-[10px] font-medium",children:k.length})]})}),/* @__PURE__ */n(kt,{align:"end",className:"flex max-h-[400px] w-[500px] flex-col overflow-hidden p-0",children:[/* @__PURE__ */e("div",{className:"shrink-0 border-b border-border px-3 py-2 text-[13px] font-medium",children:"Active Dashboard Filters"}),/* @__PURE__ */e("div",{className:"min-h-0 flex-1 overflow-auto",children:/* @__PURE__ */e(qt,{value:JSON.stringify(k,null,2),onValueChange:()=>{},language:"json",readOnly:!0,embedded:!0,wrapLines:!0,dense:!0,hideLineNumbers:!0,ariaLabel:"Active dashboard filters JSON"})})]})]}),/* @__PURE__ */e("div",{className:Z?"hidden @[820px]:flex":"",children:/* @__PURE__ */e(Os,{showInlineFilters:!1,showControls:!1,showDisplayOptions:!1})}),(a==null?void 0:a.show)&&/* @__PURE__ */n(ce,{type:"button",variant:"ghost",size:"xs","aria-pressed":a.isOpen,onClick:a.onToggle,className:W("h-7 shrink-0 gap-1.5 text-[12px]",Z?"w-7 px-0 @[760px]:w-auto @[760px]:px-2":"px-2",a.isOpen&&"bg-accent text-accent-foreground"),children:[/* @__PURE__ */e(fa,{className:"h-3.5 w-3.5",strokeWidth:1.75}),/* @__PURE__ */e("span",{className:Z?"hidden @[760px]:inline":"",children:"Settings"})]}),!Z&&/* @__PURE__ */e(Ve,{tooltip:"Refresh",disabled:A||b,className:"h-7 w-7 px-0",onClick:N,children:/* @__PURE__ */e(Ja,{className:W("h-3.5 w-3.5",{"animate-spin":(f==null?void 0:f.isFetching)??K})})}),/* @__PURE__ */n(ma,{modal:!1,children:[/* @__PURE__ */e(ha,{asChild:!0,children:/* @__PURE__ */e(Ve,{tooltip:"More Options",className:"h-7 w-7 px-0","aria-label":"More options",children:/* @__PURE__ */e(Hr,{className:"h-3.5 w-3.5"})})}),/* @__PURE__ */n(pa,{align:"end",collisionPadding:8,className:"max-h-[var(--radix-dropdown-menu-content-available-height)] w-56 overflow-y-auto overscroll-contain",children:[Z&&/* @__PURE__ */n(be,{children:[/* @__PURE__ */n(Ge,{disabled:A||b,onSelect:N,children:[/* @__PURE__ */e(Ja,{className:"h-3.5 w-3.5"}),"Refresh result"]}),/* @__PURE__ */e(Qn,{})]}),/* @__PURE__ */e(Wn,{children:"Export"}),f?/* @__PURE__ */n(Ge,{disabled:A||b||!f.hasDelivery,title:f.hasDelivery?void 0:"Available once the preview has loaded.",onSelect:()=>g(f.readDelivery()),className:"gap-2 text-[13px]",children:[/* @__PURE__ */e(Qa,{className:"h-3.5 w-3.5"}),"Download"]}):/* @__PURE__ */n(be,{children:[/* @__PURE__ */n(Ge,{disabled:!_,onSelect:V,className:"gap-2 text-[13px]",children:[/* @__PURE__ */e(Qa,{className:"h-3.5 w-3.5"}),"Download CSV"]}),/* @__PURE__ */n(Ge,{disabled:!_,onSelect:R,className:"gap-2 text-[13px]",children:[/* @__PURE__ */e(fu,{className:"h-3.5 w-3.5"}),"Download JSON"]}),/* @__PURE__ */n(Ge,{disabled:!_,onSelect:P,className:"gap-2 text-[13px]",children:[/* @__PURE__ */e(wt,{className:"h-3.5 w-3.5"}),"Copy JSON"]})]}),/* @__PURE__ */e(Qn,{}),/* @__PURE__ */e(Wn,{children:"Customize"}),!["table","detailTable","custom"].includes(c.type)&&x&&/* @__PURE__ */e(Yu,{triggerVariant:"menu",className:"w-full"}),/* @__PURE__ */e(On,{triggerVariant:"menu",className:"w-full"}),/* @__PURE__ */e(An,{triggerVariant:"menu",className:"w-full"}),/* @__PURE__ */e(Mn,{triggerVariant:"menu",className:"w-full"}),S&&/* @__PURE__ */n(Ge,{onSelect:()=>{var ie;return(ie=a==null?void 0:a.onOpen)==null?void 0:ie.call(a,"style");},className:"gap-2 text-[13px]",children:[/* @__PURE__ */e(Lc,{className:"h-3.5 w-3.5"}),"Table settings"]})]})]}),F&&/* @__PURE__ */e(is,{isOpen:!0,onClose:()=>g(void 0),card:c,frame:i,matrix:F})]})]}),J&&/* @__PURE__ */e(an,{})]});}function xm({onToggleEditor:t,children:a}){return/* @__PURE__ */n("div",{className:"relative isolate shrink-0 border-t border-border bg-muted/30 @container",children:[/* @__PURE__ */e(yr,{title:"Drag to resize. Double-click to collapse the editor.",onDoubleClick:t,className:"group absolute inset-0 cursor-row-resize outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-ring",children:/* @__PURE__ */e(Ss,{className:"top-1"})}),a]});}function Ke({value:t,onCommit:a,type:s="text",placeholder:r,className:i}){const[c,d]=Y(t),l=Ee(!1);return ve(()=>{d(t);},[t]),/* @__PURE__ */e(dt,{type:s,placeholder:r,value:c,onChange:u=>d(u.target.value),onBlur:()=>{if(l.current){l.current=!1;return;}c!==t&&a(c);},onKeyDown:u=>{if(u.key==="Enter"){u.currentTarget.blur();return;}u.key==="Escape"&&(l.current=!0,d(t),u.currentTarget.blur());},className:i});}function Wt({defaultValue:t,label:a,options:s,value:r,onValueChange:i,className:c,icon:d,showPlaceholderLabel:l=!0}){return/* @__PURE__ */n(ne,{defaultValue:t,value:r,onValueChange:i,children:[/* @__PURE__ */e(re,{className:W("w-full focus:ring-0 focus:ring-offset-0",c),children:/* @__PURE__ */n("div",{className:"flex items-center gap-2",children:[d&&/* @__PURE__ */e("span",{children:d}),l&&/* @__PURE__ */e(se,{placeholder:a})]})}),/* @__PURE__ */e(le,{children:/* @__PURE__ */n(_c,{children:[/* @__PURE__ */e(Vc,{children:a}),s.map(o=>/* @__PURE__ */e(U,{value:o.value,children:o.label},o.value))]})})]});}function bm(t,a){return Xa(t,a)||null;}function Vt(t){if(typeof t=="number")return`Tab ${t+1}`;const a=t.match(/^(\d+)-(\d+)$/);if(a){const[,r,i]=a;return`Tabs ${Number(r)+1}-${Number(i)+1}`;}const s=t.match(/^(\d+)\+$/);return s?`Tabs ${Number(s[1])+1}+`:`Tab ${t}`;}function vm(t){return t?Array.isArray(t)?t:[t]:[];}function Pa(t){var r,i;if(!t)return!1;if(t.type==="text")return!!((r=t.description)!=null&&r.trim());const a=!!((i=t.sql)!=null&&i.trim()),s=jt(t.config);return a||s;}function ym({slots:t,cards:a,minInputs:s}){const r=[],i=a.filter(Boolean).length;return s&&i<s&&r.push({type:"too-few-inputs",message:`This visual requires at least ${s} tab${s===1?"":"s"}.`}),!t||t.length===0||(t.forEach(c=>{if(!c.required)return;if(typeof c.position=="number"){const o=a[c.position];Pa(o)||r.push({type:"missing-required",message:`${Vt(c.position)} ("${c.label}") is required but has no data configured.`});return;}const d=c.position.match(/^(\d+)-(\d+)$/);if(d){const[,o,x]=d.map(Number);for(let u=o;u<=x;u+=1){const p=a[u];if(!Pa(p)){r.push({type:"missing-required",message:`${Vt(u)} ("${c.label}") is required but has no data configured.`});break;}}return;}const l=c.position.match(/^(\d+)\+$/);if(l){const o=Number(l[1]);if(a.length<=o){r.push({type:"missing-required",message:`${Vt(o)} ("${c.label}") is required but has no data configured.`});return;}for(let x=o;x<a.length;x+=1){const u=a[x];if(!Pa(u)){r.push({type:"missing-required",message:`${Vt(x)} ("${c.label}") is required but has no data configured.`});break;}}}}),a.forEach((c,d)=>{if(!c)return;const l=bm(t,d);if(!l||!l.expectedType)return;const o=vm(l.expectedType);o.length!==0&&(o.includes(c.type)||r.push({type:"wrong-type",message:`${Vt(d)} ("${l.label}") expects ${o.join(", ")}, but is configured as ${c.type}.`}));})),r;}const Nm={table:({children:t})=>/* @__PURE__ */e("table",{className:"my-3 w-full border-collapse overflow-hidden rounded-md border border-border text-sm",children:t}),thead:({children:t})=>/* @__PURE__ */e("thead",{className:"bg-muted",children:t}),th:({children:t})=>/* @__PURE__ */e("th",{className:"border border-border px-3 py-2 text-left font-medium",children:t}),td:({children:t})=>/* @__PURE__ */e("td",{className:"border border-border px-3 py-2",children:t}),code:({children:t,className:a})=>(a==null?void 0:a.includes("language-"))?/* @__PURE__ */e("pre",{className:"my-3 overflow-x-auto rounded-md bg-muted p-3 text-xs",children:/* @__PURE__ */e("code",{children:t})}):/* @__PURE__ */e("code",{className:"rounded bg-muted px-1 py-0.5 text-xs",children:t}),pre:({children:t})=>/* @__PURE__ */e(be,{children:t})};function Rs(){var k,K,M;const t=E(f=>f.card.customCardPreferences),{data:a}=Bc(),s=(a==null?void 0:a.plugins)||[],r=E(f=>f.card),i=E(f=>f.frame),{setCustomCardPreferences:c}=me(),d=X(()=>vt(i,r),[i,r]),l=d==null?void 0:d.customCardPreferences,{components:o,manifest:x}=bt((l==null?void 0:l.url)||(t==null?void 0:t.url)||""),u=(k=x==null?void 0:x.visuals)==null?void 0:k.find(f=>f.name===((l==null?void 0:l.componentName)||(t==null?void 0:t.componentName))),h=yt(d||r,u)==="multiple",m=!!d&&d.id===r.id,C=(u==null?void 0:u.minInputs)??((K=d==null?void 0:d.customCardPreferences)==null?void 0:K.minInputs),S=(u==null?void 0:u.maxInputs)??((M=d==null?void 0:d.customCardPreferences)==null?void 0:M.maxInputs),w=X(()=>Qt({frame:i,configCard:d||r,isMultiInputVisual:h}),[i,d,r,h]),v=X(()=>hs(w),[w]),y=X(()=>v.map((f,F)=>{if(!f)return null;const g=at(f,F),N=It(f,g,u==null?void 0:u.slots);return{...f,type:N??f.type};}),[v,u==null?void 0:u.slots]),A=X(()=>ym({slots:u==null?void 0:u.slots,cards:y,minInputs:C}),[u==null?void 0:u.slots,y,C]),b=X(()=>{const f=w.findIndex(F=>(F==null?void 0:F.id)===r.id);return f<0?-1:at(r,f);},[w,r]);function z(f){if(typeof f=="number")return`Tab ${f+1}`;const F=f.match(/^(\d+)-(\d+)$/);if(F){const[,N,T]=F;return`Tabs ${Number(N)+1}-${Number(T)+1}`;}const g=f.match(/^(\d+)\+$/);return g?`Tabs ${Number(g[1])+1}+`:`Tab ${f}`;}function B(f){return f?(Array.isArray(f)?f:[f]).join(", "):null;}function j(f,F,g=[],N="",T,_,P){const R=$({key:F,defaultValue:N,settingsValue:_,sourceCard:P});return f==="input"?/* @__PURE__ */e(Ke,{className:`h-8 w-full ${Fl}`,value:String(R??""),onCommit:V=>{I({key:F,value:V,settingsField:T,settingsValue:_,sourceCard:P});}},F):f==="select"?/* @__PURE__ */e(Wt,{className:"h-8 w-full",label:"",options:g,value:String(R!==void 0?R:N??""),onValueChange:V=>{I({key:F,value:V,settingsField:T,settingsValue:_,sourceCard:P});}}):null;}function $({key:f,defaultValue:F,settingsValue:g,sourceCard:N}){const T=g==null?void 0:g[f];return T!==void 0?T:f==="title"&&(N==null?void 0:N.title)!==void 0?N.title:f==="description"&&(N==null?void 0:N.description)!==void 0?N.description:F;}function I({key:f,value:F,settingsField:g,settingsValue:N,sourceCard:T}){const _={...(N||{})},P=f==="title"&&(T==null?void 0:T.title)!==void 0,R=f==="description"&&(T==null?void 0:T.description)!==void 0;P&&F===String((T==null?void 0:T.title)??"")||R&&F===String((T==null?void 0:T.description)??"")?delete _[f]:_[f]=F,c({...(t||{}),[g]:_});}function O({settingsSchema:f,settingsField:F,settingsValue:g,sourceCard:N,headerLabel:T}){const _=Object.entries(f||{});return/* @__PURE__ */n("div",{className:"space-y-3",children:[T&&/* @__PURE__ */e(D,{children:T}),_.map(([P,R])=>{var V;return/* @__PURE__ */n("div",{className:"space-y-2",children:[/* @__PURE__ */n("div",{className:"flex items-center gap-2",children:[/* @__PURE__ */e(D,{children:R.title}),((V=R.docs)==null?void 0:V.description)&&/* @__PURE__ */e(Lt,{delayDuration:0,children:/* @__PURE__ */n(mt,{children:[/* @__PURE__ */e(ht,{asChild:!0,children:/* @__PURE__ */e(ut,{className:"h-3.5 w-3.5 cursor-help text-muted-foreground"})}),/* @__PURE__ */e(pt,{side:"right",className:"max-w-xs",children:/* @__PURE__ */e("p",{className:"text-xs",children:R.docs.description})})]})})]}),j(R.ui,P,R.options,R.defaultValue,F,g,N)]},P);})]});}function L(){return/* @__PURE__ */n(be,{children:[h&&/* @__PURE__ */n("div",{className:"space-y-3",children:[/* @__PURE__ */e(D,{children:"Slot Guide"}),/* @__PURE__ */e("div",{className:"space-y-3 rounded-md border border-border bg-muted/40 px-3 py-2 text-xs",children:u!=null&&u.slots&&u.slots.length>0?/* @__PURE__ */e("div",{className:"space-y-3",children:u.slots.map((f,F)=>/* @__PURE__ */n("div",{className:"space-y-1",children:[/* @__PURE__ */n("div",{className:"flex items-center gap-2 text-foreground",children:[/* @__PURE__ */e("span",{className:"font-medium",children:z(f.position)}),/* @__PURE__ */e("span",{className:"text-muted-foreground",children:"•"}),/* @__PURE__ */e("span",{className:"font-medium",children:f.label})]}),f.description&&/* @__PURE__ */e("p",{className:"text-muted-foreground",children:f.description}),/* @__PURE__ */n("div",{className:"flex flex-wrap gap-2 text-muted-foreground",children:[B(f.expectedType)&&/* @__PURE__ */n("span",{children:["Expected: ",B(f.expectedType)]}),f.required&&/* @__PURE__ */e("span",{children:"Required"})]})]},`${f.label}-${F}`))}):/* @__PURE__ */n("div",{className:"space-y-1 text-muted-foreground",children:[/* @__PURE__ */e("p",{children:"This visual renders all tabs in a flexible layout. Add as many tabs as needed."}),(C||S)&&/* @__PURE__ */n("p",{children:[C?`Min ${C} tabs`:"",C&&S?" • ":"",S?`Max ${S} tabs`:""]})]})})]}),h&&A.length>0&&/* @__PURE__ */e(Ws,{className:"mt-3 border-yellow-500/40 bg-yellow-500/10 text-yellow-900 dark:text-yellow-100",children:/* @__PURE__ */e(Ys,{children:/* @__PURE__ */e("ul",{className:"list-disc space-y-1 pl-4 text-xs",children:A.map((f,F)=>/* @__PURE__ */e("li",{children:f.message},`${f.type}-${F}`))})})}),u&&!h&&u.settings&&/* @__PURE__ */e("div",{className:"space-y-3",children:/* @__PURE__ */e("div",{className:"px-2",children:O({settingsSchema:u.settings,settingsField:"settings",settingsValue:t==null?void 0:t.settings,sourceCard:r})})}),u&&h&&(u.settings||u.slotSettings)&&/* @__PURE__ */n("div",{className:"mt-4 space-y-4",children:[m&&u.settings&&/* @__PURE__ */e("div",{className:"px-2",children:O({settingsSchema:u.settings,settingsField:"settings",settingsValue:t==null?void 0:t.settings,sourceCard:d||r,headerLabel:"Global Settings"})}),u.slotSettings&&/* @__PURE__ */e("div",{className:"px-2",children:O({settingsSchema:u.slotSettings,settingsField:"slotSettings",settingsValue:t==null?void 0:t.slotSettings,sourceCard:r,headerLabel:(()=>{const f=r.tabTitle||r.title,F=b>=0?b:0,g=m?"Slot 0":`Slot ${F}`;return f?`${g}: ${f} Settings`:`${g} Settings`;})()})})]})]});}return/* @__PURE__ */n(ra,{type:"multiple",defaultValue:["component-settings"],className:"",children:[/* @__PURE__ */n(Se,{value:"plugin-settings",children:[/* @__PURE__ */e(Te,{children:"Plugin"}),/* @__PURE__ */e(ke,{children:/* @__PURE__ */n("div",{className:"space-y-4 text-sm",children:[/* @__PURE__ */e("div",{className:"space-y-2",children:/* @__PURE__ */n("div",{className:"space-y-4",children:[(!h||m)&&/* @__PURE__ */e(Wt,{icon:/* @__PURE__ */e(ys,{className:"h-3.5 w-3.5"}),className:"h-9 w-full",label:"Select Plugin",options:s,value:(l==null?void 0:l.url)||"",onValueChange:f=>c({...(t||{url:"",componentName:""}),url:f})}),h&&!m&&/* @__PURE__ */e("p",{className:"text-xs text-muted-foreground",children:"Switch to the config tab to change the plugin or component."})]})}),((t==null?void 0:t.type)==="component"||(t==null?void 0:t.type)===void 0)&&t&&(!h||m)&&/* @__PURE__ */e(be,{children:o&&/* @__PURE__ */e(Wt,{icon:/* @__PURE__ */e(pu,{className:"h-3.5 w-3.5"}),className:"h-9 w-full",label:"Select Component",options:(o==null?void 0:o.map(f=>({value:f.name,label:f.name})))||[],value:t.componentName||"",onValueChange:f=>{var N;const F=(N=x==null?void 0:x.visuals)==null?void 0:N.find(T=>T.name===f),g=o==null?void 0:o.find(T=>T.name===f);c({...t,componentName:f,visualType:(F==null?void 0:F.visualType)||(g==null?void 0:g.type)||"single",minInputs:F==null?void 0:F.minInputs,maxInputs:F==null?void 0:F.maxInputs,pluginChartType:F==null?void 0:F.chartType});}})})]})})]}),((l==null?void 0:l.componentName)||(t==null?void 0:t.componentName))&&/* @__PURE__ */n(Se,{className:"border-none",value:"component-settings",children:[/* @__PURE__ */e(Te,{children:/* @__PURE__ */n("div",{className:"flex items-center gap-2",children:[/* @__PURE__ */e("span",{children:(u==null?void 0:u.name)||"Settings"}),(u==null?void 0:u.docs)&&/* @__PURE__ */n(St,{openDelay:0,closeDelay:100,children:[/* @__PURE__ */e(Tt,{asChild:!0,onClick:f=>f.stopPropagation(),children:/* @__PURE__ */e(ut,{className:"h-3.5 w-3.5 cursor-help text-muted-foreground transition-colors hover:text-foreground"})}),/* @__PURE__ */e(kt,{side:"right",align:"start",className:"max-h-[40vh] w-[500px] overflow-y-auto text-left",children:/* @__PURE__ */n("div",{className:"space-y-4 text-left",children:[u.docs.description&&/* @__PURE__ */e("p",{className:"text-sm text-muted-foreground",children:u.docs.description}),u.docs.dataSchema&&/* @__PURE__ */n("div",{className:"space-y-2",children:[/* @__PURE__ */e("h4",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Data Schema"}),/* @__PURE__ */e("div",{className:"prose prose-sm dark:prose-invert prose-pre:bg-muted prose-pre:text-xs max-w-none",children:/* @__PURE__ */e(ko,{remarkPlugins:[Io],components:Nm,children:u.docs.dataSchema})})]}),(()=>{var F;const f=(F=u.docs)==null?void 0:F.useCases;return!f||f.length===0?null:/* @__PURE__ */n("div",{className:"space-y-2",children:[/* @__PURE__ */e("h4",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Use Cases"}),/* @__PURE__ */e("ul",{className:"space-y-1 text-sm",children:f.map((g,N)=>/* @__PURE__ */n("li",{className:"flex items-start gap-2",children:[/* @__PURE__ */e("span",{className:"mt-1 text-primary",children:"•"}),/* @__PURE__ */e("span",{children:g})]},N))})]});})()]})})]})]})}),/* @__PURE__ */e(ke,{children:L()})]})]});}const zt=[{id:"sankey",name:"Sankey",needs:"2 or more dimensions, 1 measure",html:Xs},{id:"calendar-heatmap",name:"Calendar heatmap",needs:"a date by day, 1 measure",html:Js},{id:"gauge",name:"Gauge",needs:"1 measure, and a target",html:Zs},{id:"waterfall",name:"Waterfall",needs:"1 dimension, 1 measure",html:el},{id:"small-multiples",name:"Small multiples",needs:"2 dimensions, 1 measure",html:tl},{id:"progress-list",name:"Progress list",needs:"1 dimension, 1 measure, and a target",html:al}];function Cm(){const t=fe(d=>{var l;return(l=d.authToken)==null?void 0:l.accessToken;})||"",a=fe(d=>{var l;return(l=d.dashboard)==null?void 0:l.id;}),{tokenProps:s}=Rt(),r=s==null?void 0:s.apiServiceUrl,i=!!(t&&r&&a);return{...Lr({mutationFn:async d=>{const l=await fetch(`${r}/v1/dashboard/${encodeURIComponent(a)}/extensions/check`,{method:"POST",headers:{Authorization:`Bearer ${t}`,"Content-Type":"application/json"},body:JSON.stringify(d)});if(!l.ok)throw new Error(`The visual couldn't be checked (${l.status}).`);const o=await l.json();if(!Array.isArray(o==null?void 0:o.findings))throw new Error("The visual couldn't be checked.");return{findings:o.findings,ranRender:!!o.ranRender};}}),available:i};}function wm(t,a){return[...t.filter(s=>s.kind===a),...t.filter(s=>s.kind!==a&&"column"in s.ref)];}const ir=t=>t.length>1?`${t.slice(0,-1).join(", ")} and ${t[t.length-1]}`:t[0]??"";function Sm(t,a,s){const r=Sr(t.html,{kind:"visual"});if(!r.ok)return"";const i=r.manifest,{assigned:c,unfilled:d}=xs({card:a,result:s,manifest:i}),l=new Map(bs(a,s).map(h=>[h.key,h.label])),o=i.slots.filter(h=>{var m;return(m=c.get(h.id))==null?void 0:m.length;}).map(h=>`${ir(c.get(h.id).map(m=>l.get(m)??m))} as ${h.label}`),x=i.slots.filter(h=>d.includes(h.id)).map(h=>h.label),u=o.length?`${t.name} uses ${o.length>1?`${o.slice(0,-1).join(", ")}, and ${o[o.length-1]}`:o[0]}.`:"",p=x.length?`${o.length?"It":t.name} needs a field for ${ir(x)}.`:"";return[u,p].filter(Boolean).join(" ")||`Add fields to this card for ${t.name}.`;}function Tm({open:t,onOpenChange:a,onPick:s,card:r,result:i}){const[c,d]=Y(zt[0].id),l=zt.find(x=>x.id===c)??zt[0],o=X(()=>Sm(l,r,i),[l,r,i]);return/* @__PURE__ */e(Ht,{open:t,onOpenChange:a,children:/* @__PURE__ */n(Ut,{className:"max-w-[640px] gap-0 p-0",children:[/* @__PURE__ */n(ca,{className:"border-b border-border px-4 py-3",children:[/* @__PURE__ */e(Gt,{className:"text-[14px]",children:"Start from a template"}),/* @__PURE__ */e(Et,{className:"text-[12px]",children:"It fills from this card's fields."})]}),/* @__PURE__ */e("div",{className:"grid grid-cols-2 gap-2 p-4 sm:grid-cols-3",role:"listbox","aria-label":"Templates",children:zt.map(x=>/* @__PURE__ */n("button",{type:"button",role:"option","aria-selected":x.id===l.id,className:W("rounded-md border p-2 text-left transition-colors hover:bg-muted/60",x.id===l.id?"border-foreground":"border-border"),onClick:()=>d(x.id),onDoubleClick:()=>s(x),children:[/* @__PURE__ */e(km,{id:x.id}),/* @__PURE__ */e("div",{className:"mt-2 text-[12px] font-medium",children:x.name}),/* @__PURE__ */n("div",{className:"text-[11px] text-muted-foreground",children:["Needs ",x.needs]})]},x.id))}),/* @__PURE__ */n(ta,{className:"items-center gap-3 border-t border-border px-4 py-3 sm:justify-between",children:[/* @__PURE__ */e("p",{className:"min-w-0 text-[11px] text-muted-foreground","data-testid":"template-fit",children:o}),/* @__PURE__ */n("div",{className:"flex shrink-0 gap-2",children:[/* @__PURE__ */e(ce,{type:"button",variant:"ghost",size:"xs",onClick:()=>a(!1),children:"Cancel"}),/* @__PURE__ */n(ce,{type:"button",size:"xs",onClick:()=>s(l),children:["Use ",l.name]})]})]})]})});}function km({id:t}){const a="h-14 w-full rounded bg-muted/60",s="fill-primary",r="fill-primary/40",i="stroke-muted-foreground/50";switch(t){case"sankey":return/* @__PURE__ */n("svg",{viewBox:"0 0 120 50",className:a,"aria-hidden":"true",children:[/* @__PURE__ */e("path",{d:"M14 10 C60 10, 60 24, 106 24 L106 30 C60 30, 60 18, 14 18 Z",className:r}),/* @__PURE__ */e("path",{d:"M14 26 C60 26, 60 34, 106 34 L106 40 C60 40, 60 34, 14 34 Z",className:"fill-primary/25"}),/* @__PURE__ */e("rect",{x:"8",y:"8",width:"6",height:"28",rx:"1",className:s}),/* @__PURE__ */e("rect",{x:"106",y:"20",width:"6",height:"22",rx:"1",className:s})]});case"calendar-heatmap":return/* @__PURE__ */e("svg",{viewBox:"0 0 120 50",className:a,"aria-hidden":"true",children:Array.from({length:4},(c,d)=>Array.from({length:12},(l,o)=>/* @__PURE__ */e("rect",{x:12+o*8,y:8+d*9,width:"6",height:"7",rx:"1",className:"fill-primary",opacity:0.15+(d*7+o*3)%5/5*0.8},`${d}-${o}`)))});case"gauge":return/* @__PURE__ */n("svg",{viewBox:"0 0 120 50",className:a,"aria-hidden":"true",children:[/* @__PURE__ */e("path",{d:"M36 42 A24 24 0 0 1 84 42",fill:"none",strokeWidth:"7",className:"stroke-muted-foreground/25"}),/* @__PURE__ */e("path",{d:"M36 42 A24 24 0 0 1 74 23",fill:"none",strokeWidth:"7",className:"stroke-primary"})]});case"waterfall":return/* @__PURE__ */n("svg",{viewBox:"0 0 120 50",className:a,"aria-hidden":"true",children:[/* @__PURE__ */e("line",{x1:"10",x2:"110",y1:"42",y2:"42",strokeWidth:"1",className:i}),/* @__PURE__ */e("rect",{x:"16",y:"20",width:"12",height:"22",className:s}),/* @__PURE__ */e("rect",{x:"36",y:"12",width:"12",height:"8",className:"fill-emerald-500/70"}),/* @__PURE__ */e("rect",{x:"56",y:"12",width:"12",height:"14",className:"fill-rose-500/70"}),/* @__PURE__ */e("rect",{x:"76",y:"18",width:"12",height:"8",className:"fill-emerald-500/70"}),/* @__PURE__ */e("rect",{x:"96",y:"18",width:"12",height:"24",className:s})]});case"small-multiples":return/* @__PURE__ */e("svg",{viewBox:"0 0 120 50",className:a,"aria-hidden":"true",children:[0,1,2].map(c=>/* @__PURE__ */n("g",{transform:`translate(${10+c*36} 8)`,children:[/* @__PURE__ */e("rect",{width:"30",height:"34",rx:"2",fill:"none",strokeWidth:"1",className:i}),[0,1,2,3].map(d=>/* @__PURE__ */e("rect",{x:4+d*6,y:34-(8+(d+c)%4*6),width:"4",height:8+(d+c)%4*6,className:r},d))]},c))});case"progress-list":return/* @__PURE__ */e("svg",{viewBox:"0 0 120 50",className:a,"aria-hidden":"true",children:[0.85,0.6,0.4].map((c,d)=>/* @__PURE__ */n("g",{transform:`translate(12 ${10+d*12})`,children:[/* @__PURE__ */e("rect",{width:"96",height:"5",rx:"2.5",className:"fill-muted-foreground/20"}),/* @__PURE__ */e("rect",{width:96*c,height:"5",rx:"2.5",className:s})]},d))});default:return/* @__PURE__ */e("div",{className:a});}}const or="__position__",Im="Build a custom visual for the card I'm editing: ";function Ls(){var g,N;const t=E(T=>T.card),{setCard:a}=me(),s=fe(T=>{var _;return(_=T.dashboard)==null?void 0:_.id;}),r=t.customVisual,i=Eo({dashboardId:s,extensionId:r!=null&&r.draft||r==null?void 0:r.extensionId,version:r!=null&&r.draft||r==null?void 0:r.version}),c=((g=r==null?void 0:r.draft)==null?void 0:g.html)??i.data??"",d=X(()=>c?Sr(c,{kind:"visual"}):void 0,[c]),l=d!=null&&d.ok?d.manifest:void 0,o=je(t).data,x=X(()=>{var T;return{records:(o==null?void 0:o.records)??[],columns:o==null?void 0:o.columns,columnKeyMap:o==null?void 0:o.columnKeyMap,comparisonMetadata:(T=o==null?void 0:o.metadata)==null?void 0:T.comparisonMetadata};},[o==null?void 0:o.records,o==null?void 0:o.columns,o==null?void 0:o.columnKeyMap,(N=o==null?void 0:o.metadata)==null?void 0:N.comparisonMetadata]),u=X(()=>bs(t,x),[t,x]),p=X(()=>l?xs({card:t,result:x,manifest:l}):void 0,[t,x,l]),h=Cm(),m=Ee(void 0),C=T=>{var V,Q;const _=(Q=(V=T.customVisual)==null?void 0:V.draft)==null?void 0:Q.html;if(!h.available||!_)return;const P=Zn(T,_),R=Jn(P);R!==m.current&&(m.current=R,h.mutate(P));},S=c?Jn(Zn(t,c)):void 0,[w,v]=Y(),y=T=>{var P;const _=Wd(t,T,{manifest:l});if(!_.ok){if(T.html!==void 0){const R=((P=_.problem.details)==null?void 0:P.findings)??[];v({html:T.html,findings:R,message:_.problem.message});}else $e.error(_.problem.message);return;}T.html!==void 0&&v(void 0),(T.html!==void 0||m.current!==void 0)&&C(_.card),_.card!==t&&a(_.card);},A=async()=>{const T=ou({fields:u.map(_=>({name:_.label,kind:_.kind,type:_.type}))});try{await navigator.clipboard.writeText(T),$e.success("Prompt copied",{description:"Paste it into your assistant, then paste the HTML it writes here."});}catch{$e.error("The prompt couldn't be copied");}},b=Fo(),[z,B]=Y(!1),[j,$]=Y(!1),[I,O]=Y(!1),L=i.isLoading&&!(r!=null&&r.draft),k=!!c||L,K=T=>{y({html:T.html}),O(!1);},M=()=>{y({clear:!0}),v(void 0),B(!1),$(!1),m.current=void 0;},f=/* @__PURE__ */e(Mm,{html:c,loading:L,onCommit:T=>y({html:T})}),F=w?/* @__PURE__ */n("div",{className:"space-y-1",children:[/* @__PURE__ */n("p",{className:"text-destructive",children:["This HTML can't be used yet",l?`, so ${l.name} keeps drawing`:"",":"]}),/* @__PURE__ */e(cr,{findings:w.findings.length?w.findings:[{code:"manifest_invalid",severity:"error",message:w.message}],manifest:void 0})]}):null;return/* @__PURE__ */n("div",{className:"space-y-5 py-4 text-[12px]","data-testid":"custom-visual-panel",children:[k?/* @__PURE__ */n("section",{className:"space-y-2",children:[/* @__PURE__ */e(Nt,{children:"Custom visual"}),!w&&d?/* @__PURE__ */e(cr,{findings:d.findings,manifest:l}):null,!w&&h.isPending?/* @__PURE__ */e("p",{className:"text-muted-foreground",children:"Checking the visual at several sizes, light and dark…"}):null,!w&&h.data&&m.current===S?/* @__PURE__ */e(Fm,{findings:h.data.findings}):null,!w&&h.isError&&m.current===S?/* @__PURE__ */e("p",{className:"text-muted-foreground",children:"The visual couldn't be checked here. Saving checks it again and refuses it only if it doesn't work."}):null,i.isError&&!(r!=null&&r.draft)?/* @__PURE__ */e("p",{className:"text-destructive",children:"This visual can't be loaded."}):null,/* @__PURE__ */n("div",{className:"flex flex-wrap gap-1.5",children:[b.available?/* @__PURE__ */n(ce,{type:"button",variant:"outline",size:"xs",onClick:()=>!b.isOpen&&b.toggle(),children:[/* @__PURE__ */e(qn,{className:"mr-1 h-3 w-3"})," Ask for a change"]}):null,/* @__PURE__ */n(ce,{type:"button",variant:"outline",size:"xs",onClick:()=>O(!0),children:[/* @__PURE__ */e(xu,{className:"mr-1 h-3 w-3"})," Change template"]}),/* @__PURE__ */n(ce,{type:"button",variant:"ghost",size:"xs",onClick:M,children:[/* @__PURE__ */e(Wa,{className:"mr-1 h-3 w-3"})," Start over"]})]})]}):/* @__PURE__ */n(be,{children:[b.available?/* @__PURE__ */n("section",{className:"space-y-2",children:[/* @__PURE__ */e(Nt,{children:"Custom visual"}),/* @__PURE__ */n(ce,{type:"button",variant:"outline",size:"xs",className:"w-full justify-start",onClick:()=>b.startWith(Im),children:[/* @__PURE__ */e(qn,{className:"mr-1.5 h-3 w-3"})," Describe it to the assistant"]})]}):null,/* @__PURE__ */n("section",{className:"space-y-2",children:[/* @__PURE__ */e(Nt,{children:b.available?"Or start from":"Start from"}),/* @__PURE__ */e("div",{className:"grid grid-cols-2 gap-1",children:zt.slice(0,4).map(T=>/* @__PURE__ */e(ce,{type:"button",variant:"outline",size:"xs",className:"justify-start",onClick:()=>K(T),children:T.name},T.id))}),/* @__PURE__ */n(ce,{type:"button",variant:"ghost",size:"xs",className:"px-1 text-muted-foreground",onClick:()=>O(!0),children:["All templates ",/* @__PURE__ */e(nt,{className:"ml-0.5 h-3 w-3"})]})]}),/* @__PURE__ */n("section",{className:"space-y-2",children:[/* @__PURE__ */e(Nt,{children:"Your own assistant"}),/* @__PURE__ */e("p",{className:"leading-[1.55] text-muted-foreground",children:"For Claude, ChatGPT or any assistant: copy the prompt, then paste the HTML it writes."}),/* @__PURE__ */n("div",{className:"flex gap-1.5",children:[/* @__PURE__ */n(ce,{type:"button",variant:"outline",size:"xs",onClick:A,children:[/* @__PURE__ */e(wt,{className:"mr-1 h-3 w-3"})," Copy prompt"]}),/* @__PURE__ */n(ce,{type:"button",variant:"ghost",size:"xs",onClick:()=>B(!0),children:[/* @__PURE__ */e(hu,{className:"mr-1 h-3 w-3"})," Paste code"]})]}),z||w?f:null,F]})]}),l&&l.slots.length?/* @__PURE__ */n("section",{className:"space-y-2",children:[/* @__PURE__ */e(Nt,{children:"Fields"}),l.slots.map(T=>{var Q,J;const _=wm(u,T.kind),P=(Q=r==null?void 0:r.slots)==null?void 0:Q[T.id],R=P?(J=_.find(Z=>Am(Z,P)))==null?void 0:J.key:void 0,V=((p==null?void 0:p.assigned.get(T.id))??[]).map(Z=>{var G;return((G=u.find(q=>q.key===Z))==null?void 0:G.label)??Z;});return/* @__PURE__ */n("label",{className:"block space-y-1",children:[/* @__PURE__ */n("span",{className:"text-foreground",children:[T.label,T.optional?/* @__PURE__ */e("span",{className:"text-muted-foreground",children:" (optional)"}):null]}),/* @__PURE__ */n(ne,{value:R??or,onValueChange:Z=>{const G=_.find(q=>q.key===Z);y({slots:{[T.id]:G?G.ref:null}});},children:[/* @__PURE__ */e(re,{size:"xs",className:"w-full","aria-label":T.label,children:/* @__PURE__ */e(se,{})}),/* @__PURE__ */n(le,{children:[/* @__PURE__ */e(U,{value:or,children:V.length&&!R?`In order: ${V.join(", ")}`:"In order"}),_.map(Z=>/* @__PURE__ */e(U,{value:Z.key,children:Z.label},Z.key))]})]})]},T.id);})]}):null,l!=null&&l.settings&&Object.keys(l.settings).length?/* @__PURE__ */n("section",{className:"space-y-2",children:[/* @__PURE__ */e(Nt,{children:"Settings"}),Object.entries(l.settings).map(([T,_])=>{var P;return/* @__PURE__ */e(Om,{definition:_,value:(P=r==null?void 0:r.settings)==null?void 0:P[T],onChange:R=>y({settings:{[T]:R===void 0||R===_.default?null:R}})},T);})]}):null,k?/* @__PURE__ */n("section",{className:"space-y-2 border-t border-border/60 pt-3",children:[/* @__PURE__ */n("button",{type:"button",className:"flex w-full items-center justify-between text-muted-foreground hover:text-foreground","aria-expanded":j||!!w,onClick:()=>$(T=>!T),children:[/* @__PURE__ */n("span",{className:"flex items-center gap-1.5",children:[/* @__PURE__ */e(Ld,{className:"h-3.5 w-3.5"})," Code"]}),/* @__PURE__ */e(nt,{className:W("h-3 w-3 transition-transform",(j||w)&&"rotate-90")})]}),j||w?/* @__PURE__ */n("div",{className:"space-y-2",children:[f,F,/* @__PURE__ */n("div",{className:"flex gap-1.5",children:[/* @__PURE__ */n(ce,{type:"button",variant:"outline",size:"xs",onClick:()=>void Em(c,"Code copied"),children:[/* @__PURE__ */e(wt,{className:"mr-1 h-3 w-3"})," Copy code"]}),/* @__PURE__ */n(ce,{type:"button",variant:"ghost",size:"xs",onClick:A,children:[/* @__PURE__ */e(wt,{className:"mr-1 h-3 w-3"})," Copy prompt"]})]}),/* @__PURE__ */e("p",{className:"text-muted-foreground",children:"Paste new code here to replace it; it's checked before it replaces the visual."})]}):null]}):null,/* @__PURE__ */e(Tm,{open:I,onOpenChange:O,onPick:K,card:t,result:x})]});}async function Em(t,a){try{await navigator.clipboard.writeText(t),$e.success(a);}catch{$e.error("It couldn't be copied");}}function Fm({findings:t}){const a=t.filter(r=>r.severity==="error"),s=t.filter(r=>r.severity==="warning");return!a.length&&!s.length?/* @__PURE__ */e("p",{className:"text-muted-foreground",children:"Checked at four sizes, light and dark: no problems."}):/* @__PURE__ */n("div",{className:"space-y-1",children:[a.length?/* @__PURE__ */e("p",{className:"text-destructive",children:"Fix this before saving; the dashboard won't save it as it is:"}):null,/* @__PURE__ */e("ul",{className:"space-y-1","aria-label":"Check results",children:[...a,...s].map((r,i)=>/* @__PURE__ */n("li",{className:r.severity==="error"?"text-destructive":"text-muted-foreground",children:[r.message,r.fix?/* @__PURE__ */e("span",{className:"block text-muted-foreground",children:r.fix}):null]},`${r.code}-${i}`))})]});}function Nt({children:t}){return/* @__PURE__ */e("div",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:t});}function Mm({html:t,loading:a,onCommit:s}){const[r,i]=Y(t),[c,d]=Y(t);t!==c&&(d(t),i(t));const l=Ee(null),o=x=>{x!==t&&s(x);};return/* @__PURE__ */e(Pr,{ref:l,"aria-label":"Visual HTML",placeholder:a?"Loading the visual…":"Paste the HTML here",value:r,spellCheck:!1,className:"h-40 resize-y font-mono text-[11px] leading-[1.45]",onChange:x=>i(x.target.value),onPaste:()=>{requestAnimationFrame(()=>{l.current&&o(l.current.value);});},onBlur:x=>o(x.target.value)});}function cr({findings:t,manifest:a}){return t.length?/* @__PURE__ */e("ul",{className:"space-y-1","aria-label":"What to fix",children:t.map((s,r)=>/* @__PURE__ */e("li",{className:s.severity==="error"?"text-destructive":"text-muted-foreground",children:s.message},`${s.code}-${r}`))}):a?/* @__PURE__ */n("p",{className:"text-muted-foreground",children:[a.name," is ready to draw."]}):null;}function Om({definition:t,value:a,onChange:s}){const r=a!==void 0&&typeof a==typeof t.default?a:t.default;if(t.type==="boolean")return/* @__PURE__ */n("label",{className:"flex items-center justify-between gap-3",children:[/* @__PURE__ */e("span",{className:"text-foreground",children:t.label}),/* @__PURE__ */e(we,{size:"xs",checked:!!r,onCheckedChange:i=>s(i),"aria-label":t.label})]});if(t.type==="select"||t.type==="color"){const i=t.type==="select"?t.options:[.../* @__PURE__ */new Set([...Ml,String(r)])].map(c=>({value:c,label:c}));return/* @__PURE__ */n("label",{className:"block space-y-1",children:[/* @__PURE__ */e("span",{className:"text-foreground",children:t.label}),/* @__PURE__ */n(ne,{value:String(r),onValueChange:c=>s(c),children:[/* @__PURE__ */e(re,{size:"xs",className:"w-full","aria-label":t.label,children:/* @__PURE__ */e(se,{})}),/* @__PURE__ */e(le,{children:i.map(c=>/* @__PURE__ */e(U,{value:c.value,children:c.label},c.value))})]})]});}return/* @__PURE__ */n("label",{className:"block space-y-1",children:[/* @__PURE__ */e("span",{className:"text-foreground",children:t.label}),/* @__PURE__ */e(dt,{size:"xs",type:t.type==="number"?"number":"text",defaultValue:String(r),...(t.type==="number"?{min:t.min,max:t.max,step:t.step}:{maxLength:t.maxLength}),onBlur:i=>{const c=i.target.value;if(t.type==="number"){const d=Number(c);c.trim()&&Number.isFinite(d)&&s(d);}else s(c);}},String(r))]});}function Am(t,a){return a?"fieldId"in a?"fieldId"in t.ref&&t.ref.fieldId===a.fieldId:"column"in t.ref&&t.ref.column===a.column:!1;}const Rm={type:"number",minimumFractionDigits:0,maximumFractionDigits:0};function Lm(t){var a;return ru((a=t==null?void 0:t.sqlKpiValue)==null?void 0:a.format)||Rm;}function dr(t,a){const s=a?su(a):void 0,{format:r,...i}=t.sqlKpiValue??{},c=s?{...i,format:s}:i,{sqlKpiValue:d,...l}=t;return Object.keys(c).length?{...l,sqlKpiValue:c}:l;}function Pm(){var x,u;const t=E(p=>p.card),a=E(p=>p.actions.setCardPreferences),s=zc()??Bn.locale,r=Kc()??Bn.defaultCurrency,i=Mo(t)==="config",c=Lm(t.preferences),d=!!((u=(x=t.preferences)==null?void 0:x.sqlKpiValue)!=null&&u.format),l=p=>{const h=E.getState().card.preferences??{};a(dr(h,p));},o=p=>{const h=E.getState().card.preferences??{};a(dr(h,p?c:void 0));};return i?/* @__PURE__ */e(ur,{card:t}):/* @__PURE__ */n("div",{children:[/* @__PURE__ */n("div",{className:"mb-3 flex items-center gap-2",children:[/* @__PURE__ */e(Kt,{id:"query-kpi-format-number",checked:d,onCheckedChange:p=>o(p===!0)}),/* @__PURE__ */e(D,{htmlFor:"query-kpi-format-number",className:"text-xs",children:"Format number"})]}),d&&/* @__PURE__ */n("div",{className:"flex flex-col gap-2",children:[/* @__PURE__ */e(sa,{formatOptions:c,onFormatOptionsChange:l,showTitle:!1,showAutoFormat:!1,reportDefaults:{currency:r,locale:s}}),/* @__PURE__ */e(qc,{className:"my-3"})]}),/* @__PURE__ */e(ur,{card:t})]});}function ur({card:t}){const a=E(o=>o.actions.updateConditionalRules),{rules:s,onChange:r}=Ur(t.id,Tr(t),a),i=Ol(t),c=i==null?void 0:i.value,d=(i==null?void 0:i.source)==="config"?i.measure:void 0,l=c?[{value:Al(c),label:d?d.label||d.alias||d.name:"Value"}]:[];return l.length?/* @__PURE__ */n("div",{className:"space-y-2",children:[/* @__PURE__ */e(Gr,{cardId:t.id}),/* @__PURE__ */e(Qr,{columnId:l[0].value,availableColumns:l,conditionalRules:s,onConditionalRulesChange:r,capabilities:{ruleKinds:["comparison"],automaticRanges:!1}})]}):null;}const Dm={combo:{label:"Combo Chart",query:"SELECT x-axis, metric-1, metric-2, ... FROM table",fields:[{name:"x-axis",type:"category",description:"dimension"},{name:"metric-1, metric-2",type:"number",description:"can be bar, line, or area"}],description:"Combo charts allow mixing bar and line series with optional dual Y-axis for metrics with different scales.",docsUrl:"https://docs.semaphor.cloud/docs/charts/combo"},area:{label:"Area Chart",query:"SELECT x-axis, y-axis-1, y-axis-2, ... FROM table",fields:[{name:"X-axis",type:"category",description:"e.g., date, city"},{name:"Y-axis",type:"number",description:"e.g., sales, population"}],description:"Area charts display quantitative data with filled areas under the line.",docsUrl:"https://docs.semaphor.cloud/docs/charts/bar-line-area"},stackedArea:{label:"Stacked Area Chart",query:"SELECT x-axis, y-axis-1, y-axis-2, ... FROM table",fields:[{name:"X-axis",type:"category",description:"e.g., date, city"},{name:"Y-axis",type:"number",description:"e.g., sales, population"}],description:"Stacked area charts show how multiple series contribute to a total over time.",docsUrl:"https://docs.semaphor.cloud/docs/charts/stacked"},bar:{label:"Bar Chart",query:"SELECT x-axis, y-axis-1, y-axis-2, ... FROM table",fields:[{name:"X-axis",type:"category",description:"e.g., city, product"},{name:"Y-axis",type:"number",description:"e.g., sales, count"}],description:"Bar charts compare values across categories using horizontal or vertical bars.",docsUrl:"https://docs.semaphor.cloud/docs/charts/bar-line-area"},line:{label:"Line Chart",query:"SELECT x-axis, y-axis-1, y-axis-2, ... FROM table",fields:[{name:"X-axis",type:"category",description:"e.g., date, month"},{name:"Y-axis",type:"number",description:"e.g., revenue, count"}],description:"Line charts show trends over time or continuous data.",docsUrl:"https://docs.semaphor.cloud/docs/charts/bar-line-area"},stackedBar:{label:"Stacked Bar Chart",query:"SELECT x-axis, stack-by, y-axis FROM table",fields:[{name:"X-axis",type:"category",description:"e.g., month"},{name:"Stack-by",type:"category",description:"e.g., product type"},{name:"Y-axis",type:"number",description:"e.g., sales"}],description:"Stacked bar charts show how parts contribute to a whole across categories.",docsUrl:"https://docs.semaphor.cloud/docs/charts/stacked"},stackedLine:{label:"Stacked Line Chart",query:"SELECT x-axis, stack-by, y-axis FROM table",fields:[{name:"X-axis",type:"category",description:"e.g., date"},{name:"Stack-by",type:"category",description:"e.g., region"},{name:"Y-axis",type:"number",description:"e.g., revenue"}],description:"Stacked line charts show cumulative trends over time.",docsUrl:"https://docs.semaphor.cloud/docs/charts/stacked"},pie:{label:"Pie Chart",query:"SELECT label, measure FROM table",fields:[{name:"Label",type:"category",description:"e.g., product, region"},{name:"Measure",type:"number",description:"e.g., sales, count"}],description:"Pie charts show proportions of a whole.",docsUrl:"https://docs.semaphor.cloud/docs/charts/pie-donut-polar"},doughnut:{label:"Doughnut Chart",query:"SELECT label, measure FROM table",fields:[{name:"Label",type:"category",description:"e.g., product, region"},{name:"Measure",type:"number",description:"e.g., sales, count"}],description:"Doughnut charts show proportions with a hollow center.",docsUrl:"https://docs.semaphor.cloud/docs/charts/pie-donut-polar"},polarArea:{label:"Polar Area Chart",query:"SELECT label, measure FROM table",fields:[{name:"Label",type:"category",description:"e.g., skill, metric"},{name:"Measure",type:"number",description:"e.g., score, value"}],description:"Polar area charts compare values using sectors of equal angle but varying radius.",docsUrl:"https://docs.semaphor.cloud/docs/charts/pie-donut-polar"},radar:{label:"Radar Chart",query:"SELECT label, measure FROM table",fields:[{name:"Label",type:"category",description:"e.g., attribute, skill"},{name:"Measure",type:"number",description:"e.g., score, rating"}],description:"Radar charts display multivariate data on axes starting from the same point.",docsUrl:"https://docs.semaphor.cloud/docs/charts/pie-donut-polar"},funnel:{label:"Funnel Chart",query:"SELECT label, measure FROM table",fields:[{name:"Label",type:"category",description:"e.g., stage name"},{name:"Measure",type:"number",description:"e.g., count, value"}],description:"Funnel charts visualize progressive reduction of data through stages.",docsUrl:"https://docs.semaphor.cloud/docs/charts/funnel"},bubble:{label:"Bubble Chart",query:"SELECT label, [group], x-axis, y-axis, radius FROM table",fields:[{name:"Label",type:"category",description:"e.g., city"},{name:"Group",type:"category",description:"e.g., region",optional:!0},{name:"X-axis",type:"number",description:"e.g., population"},{name:"Y-axis",type:"number",description:"e.g., income"},{name:"Radius",type:"number",description:"e.g., area"}],description:"Bubble charts display three dimensions of data using position and size.",docsUrl:"https://docs.semaphor.cloud/docs/charts/bubble"},scatter:{label:"Scatter Chart",query:"SELECT label, [group], x-axis, y-axis FROM table",fields:[{name:"Label",type:"category",description:"e.g., item name"},{name:"Group",type:"category",description:"e.g., type",optional:!0},{name:"X-axis",type:"number",description:"e.g., price"},{name:"Y-axis",type:"number",description:"e.g., quantity"}],description:"Scatter charts show relationships between two numeric variables.",docsUrl:"https://docs.semaphor.cloud/docs/charts/bubble"},tornado:{label:"Tornado Chart",query:"SELECT dimension, cohort, metric FROM table",fields:[{name:"Dimension",type:"category",description:"e.g., age group"},{name:"Cohort",type:"category",description:"e.g., gender"},{name:"Metric",type:"number",description:"e.g., population"}],description:"Tornado charts compare two groups across categories using back-to-back bars.",docsUrl:"https://docs.semaphor.cloud/docs/charts/tornado"},pyramid:{label:"Pyramid Chart",query:"SELECT dimension, cohort, metric FROM table",fields:[{name:"Dimension",type:"category",description:"e.g., age group"},{name:"Cohort",type:"category",description:"e.g., gender"},{name:"Metric",type:"number",description:"e.g., population"}],description:"Population pyramids show age and gender distribution.",docsUrl:"https://docs.semaphor.cloud/docs/charts/tornado"},range:{label:"Range Chart",query:"SELECT y-axis, label, range-from, range-to, range-value FROM table",fields:[{name:"Y-axis",type:"category",description:"e.g., category"},{name:"Label",type:"category",description:"e.g., range name"},{name:"Range-from",type:"number",description:"start value"},{name:"Range-to",type:"number",description:"end value"},{name:"Range-value",type:"number",description:"e.g., midpoint"}],description:"Range charts display data ranges with start and end values.",docsUrl:"https://docs.semaphor.cloud/docs/charts/range"},heatmap:{label:"Heatmap",query:"SELECT x-axis, y-axis, value FROM table",fields:[{name:"X-axis",type:"category",description:"e.g., day"},{name:"Y-axis",type:"category",description:"e.g., hour"},{name:"Value",type:"number",description:"e.g., count, intensity"}],description:"Heatmaps visualize data density using color intensity.",docsUrl:"https://docs.semaphor.cloud/docs/charts/heatmap"},bullet:{label:"Bullet Chart",query:"SELECT label, actual, target, [ranges] FROM table",fields:[{name:"Label",type:"category",description:"e.g., metric name"},{name:"Actual",type:"number",description:"current value"},{name:"Target",type:"number",description:"goal value"},{name:"Ranges",type:"number",description:"threshold values",optional:!0}],description:"Bullet charts compare actual performance against targets.",docsUrl:"https://docs.semaphor.cloud/docs/charts/bullet"},text:{label:"Text Visual",query:"SELECT text FROM table LIMIT 1",fields:[{name:"Text",type:"string",description:"content to display"}],description:"Text visuals display dynamic text content from your data.",docsUrl:"https://docs.semaphor.cloud/docs/charts/text"},kpi:{label:"KPI",query:"SELECT current, previous FROM table",fields:[{name:"Current",type:"number",description:"current value"},{name:"Previous",type:"number",description:"comparison value"}],description:"KPI visuals display key performance indicators with comparison values.",docsUrl:"https://docs.semaphor.cloud/docs/charts/kpi"},table:{label:"Table",query:"SELECT column1, column2, ... FROM table",fields:[{name:"Columns",type:"category",description:"any data columns"}],description:"Tables display data in rows and columns.",docsUrl:"https://docs.semaphor.cloud/docs/charts/table"},detailTable:{label:"Detail Table",query:"SELECT column1, column2, ... FROM table ORDER BY column1 DESC",fields:[{name:"Columns",type:"category",description:"columns to display (no aggregation)"}],description:"Detail tables display raw records without aggregation. Ideal for event logs, transaction history, and audit trails.",docsUrl:"https://docs.semaphor.cloud/docs/charts/detail-table"}};function Ps(t){return Dm[t];}function _m({chartType:t,showDocsLink:a=!0}){const s=Ps(t);return s?/* @__PURE__ */n("div",{className:"space-y-4",children:[/* @__PURE__ */n("div",{className:"space-y-2",children:[/* @__PURE__ */e("h4",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Query Format"}),/* @__PURE__ */e("code",{className:"block rounded-md bg-muted/50 px-3 py-2 font-mono text-xs text-foreground",children:s.query})]}),/* @__PURE__ */n("div",{className:"space-y-2",children:[/* @__PURE__ */e("h4",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Fields"}),/* @__PURE__ */e("div",{className:"rounded-md border",children:/* @__PURE__ */n("table",{className:"w-full text-xs",children:[/* @__PURE__ */e("thead",{children:/* @__PURE__ */n("tr",{className:"border-b bg-muted/50",children:[/* @__PURE__ */e("th",{className:"px-2.5 py-1.5 text-left font-medium text-muted-foreground",children:"Field"}),/* @__PURE__ */e("th",{className:"px-2.5 py-1.5 text-left font-medium text-muted-foreground",children:"Type"}),/* @__PURE__ */e("th",{className:"px-2.5 py-1.5 text-left font-medium text-muted-foreground",children:"Description"})]})}),/* @__PURE__ */e("tbody",{children:s.fields.map((r,i)=>/* @__PURE__ */n("tr",{className:i<s.fields.length-1?"border-b":"",children:[/* @__PURE__ */n("td",{className:"px-2.5 py-1.5 font-medium text-foreground",children:[r.name,r.optional&&/* @__PURE__ */e("span",{className:"ml-1 text-muted-foreground",children:"?"})]}),/* @__PURE__ */e("td",{className:"px-2.5 py-1.5 font-mono text-muted-foreground",children:r.type}),/* @__PURE__ */e("td",{className:"px-2.5 py-1.5 text-muted-foreground",children:r.description||"—"})]},r.name))})]})})]}),/* @__PURE__ */e("p",{className:"text-xs leading-relaxed text-muted-foreground",children:s.description}),a&&s.docsUrl&&/* @__PURE__ */n("a",{href:s.docsUrl,target:"_blank",rel:"noopener noreferrer",onClick:r=>r.stopPropagation(),className:"inline-flex items-center gap-1.5 text-xs font-medium text-primary hover:underline",children:["View documentation",/* @__PURE__ */e($c,{className:"h-3 w-3"})]})]}):null;}function Vm({chartType:t}){return Ps(t)?/* @__PURE__ */n(St,{openDelay:200,children:[/* @__PURE__ */e(Tt,{asChild:!0,children:/* @__PURE__ */e("button",{type:"button",className:"rounded bg-muted px-2 py-0.5 font-mono text-[10px] font-semibold uppercase tracking-wider text-muted-foreground transition-colors hover:bg-muted/80 hover:text-foreground",children:"SQL"})}),/* @__PURE__ */e(kt,{className:"w-80 p-4",side:"left",align:"start",sideOffset:8,children:/* @__PURE__ */e(_m,{chartType:t})})]}):null;}function Ds({chartType:t,suffix:a="Configuration"}){return/* @__PURE__ */n("div",{className:"flex items-center justify-between",children:[/* @__PURE__ */e("h3",{className:"text-xs font-medium",children:a}),/* @__PURE__ */e(Vm,{chartType:t})]});}function Bm(){const t=E(i=>!jt(i.card.config)),a=E(i=>{var c,d;return((d=(c=i.card.preferences)==null?void 0:c.sqlKpiValue)==null?void 0:d.comparisonPolarity)??di;}),s=E(i=>i.actions.setCardPreferences),r=i=>{const c=E.getState().card;s(Rl(c,{kind:"sqlKpiValue"},i).preferences??{});};return/* @__PURE__ */n("div",{className:"space-y-6 px-6 py-4",children:[/* @__PURE__ */e(Ds,{chartType:"kpi"}),/* @__PURE__ */e("section",{children:/* @__PURE__ */e(Pm,{})}),t&&/* @__PURE__ */n("section",{className:"space-y-1.5",children:[/* @__PURE__ */e(D,{htmlFor:"query-kpi-favorable-direction",className:"text-xs",children:"Favorable direction"}),/* @__PURE__ */n(ne,{value:a,onValueChange:i=>r(i),children:[/* @__PURE__ */e(re,{id:"query-kpi-favorable-direction",size:"xs",className:"w-full",children:/* @__PURE__ */e(se,{})}),/* @__PURE__ */n(le,{children:[/* @__PURE__ */e(U,{value:"higher_is_better",children:"Higher is better"}),/* @__PURE__ */e(U,{value:"lower_is_better",children:"Lower is better"}),/* @__PURE__ */e(U,{value:"neutral",children:"Neutral"})]})]}),/* @__PURE__ */e("p",{className:"text-[11px] leading-4 text-muted-foreground",children:"Applies when the query returns current and comparison values."})]})]});}function zm(t){return t.kind==="dashboard"?{kind:"inherit"}:t;}function _s(t,a){var s,r;return kr(t)&&((r=(s=t.config)==null?void 0:s.metricColumns)==null?void 0:r[0])===a;}function Vs(t,a){var r,i;const s=Fr({metricComparison:a.comparison,inheritGlobalComparison:(r=t.preferences)==null?void 0:r.inheritGlobalComparison,hidden:Mr((i=t.preferences)==null?void 0:i.comparisonPresentation)});return s.state==="follow"?{kind:"dashboard"}:s.state==="off"?{kind:"off"}:s.spec;}function Km({card:t,metric:a,options:s,dates:r,otherMetric:i,onChange:c}){var S,w;const{data:d}=je(t),l=d==null?void 0:d.metadata,o=(S=ds(l==null?void 0:l.comparisonMetadata,a))==null?void 0:S.output,x=Nn(),u=qm(l==null?void 0:l.dateContext,o==null?void 0:o.windowShape,x),p=(o==null?void 0:o.availability.status)==="available"&&o.comparisonWindow?_d(o.comparisonWindow):void 0,h=_s(t,a)?{kind:"metric"}:Vs(t,a),m=v=>v.offered?void 0:v.reason,C=Object.values(s.comparison).some(v=>v.offered&&v.replaces==="transform");return/* @__PURE__ */n("div",{className:"space-y-1",children:[/* @__PURE__ */e(jc,{value:h,shape:u,dashboard:{offered:!0},target:{offered:s.comparison.target.offered,reason:m(s.comparison.target)},...(i?{otherMetric:i}:{}),shiftRefusal:m(s.comparison.shift),dates:h.kind==="shift"||h.kind==="dashboard"?p:void 0,onChange:v=>c(zm(v))}),C?/* @__PURE__ */e("p",{className:"text-[11px] leading-4 text-muted-foreground",children:"A comparison replaces this metric's transform."}):null,h.kind==="shift"&&r.dateWindow==="none"?/* @__PURE__ */n("p",{className:"text-[11px] leading-4 text-muted-foreground",children:["Shows only while a date range applies to ",((w=r.comparisonDate)==null?void 0:w.label)??"its date","; none does yet."]}):null]});}function qm(t,a,s){const r=(t==null?void 0:t.windows.filter(i=>!i.replaced))??[];return r.length===1?(r[0].relative?tr({kind:"relative",window:r[0].relative}):void 0)??(r[0].window?tr({kind:"resolved",window:r[0].window,calendar:s}):a):a;}function $m({card:t}){var x;const a=Nn(),s=Hc(t),r=fe(u=>u.dashboard),i=fe(u=>u.semanticExecutionPayload),{handleMetricComparisonChange:c}=pn(t),d=X(()=>cu(t,$d(s,jd(r,i,a)),a),[t,s,r,i,a]),l=((x=t.config)==null?void 0:x.metricColumns)??[],o=Ll("metric",l);return/* @__PURE__ */e("div",{className:"space-y-4",children:l.map((u,p)=>{const h=o[p]?Pl(t,o[p],d):void 0;if(!h||!Object.values(h.comparison).some(C=>C.offered))return null;const m=h.comparison.metric.offered?l[1]:void 0;return/* @__PURE__ */n("div",{className:"space-y-2","data-role":"measure-comparison",children:[/* @__PURE__ */e("div",{className:"text-[12px] font-medium",children:u.label||u.name}),/* @__PURE__ */e(Km,{card:t,metric:u,options:h,dates:d,...(m?{otherMetric:{name:m.label||m.name}}:{}),onChange:C=>c(p,C,d)})]},u.id??p);})});}function mr({card:t}){var i;const{handleMetricComparisonPolarityChange:a}=pn(t),r=(((i=t.config)==null?void 0:i.metricColumns)??[]).map((c,d)=>({metric:c,index:d})).filter(({metric:c})=>_s(t,c)||Vs(t,c).kind!=="off");return r.length?/* @__PURE__ */e("div",{className:"space-y-2",children:r.map(({metric:c,index:d})=>/* @__PURE__ */n("div",{className:"space-y-1",children:[/* @__PURE__ */e(D,{className:"text-xs font-medium text-muted-foreground",children:r.length===1?"Higher is":`Higher is · ${c.label||c.name}`}),/* @__PURE__ */n(ne,{value:us(c),disabled:!!c.semanticComparisonPolarity,onValueChange:l=>a(d,l),children:[/* @__PURE__ */e(re,{size:"xs",className:"w-full",children:/* @__PURE__ */e(se,{})}),/* @__PURE__ */n(le,{children:[/* @__PURE__ */e(U,{value:"higher_is_better",children:"Better"}),/* @__PURE__ */e(U,{value:"lower_is_better",children:"Worse"}),/* @__PURE__ */e(U,{value:"neutral",children:"Neither"})]})]}),c.semanticComparisonPolarity?/* @__PURE__ */e("p",{className:"text-[11px] leading-4 text-muted-foreground",children:"Governed by this metric's semantic definition."}):null]},c.id??d))}):null;}const jm={green:"#16a34a",red:"#dc2626",neutral:"#6b7280"};function Hm(t){return t&&(jm[t]??t);}function Um({value:t,onChange:a,showPosition:s=!1,polarity:r,direction:i}){const c=t.colors||{},d=l=>r==="higher_is_better"?l?" (good)":" (bad)":r==="lower_is_better"?l?" (bad)":" (good)":"";return/* @__PURE__ */n("div",{className:"space-y-3",children:[/* @__PURE__ */n("div",{className:"space-y-1.5",children:[/* @__PURE__ */e(D,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Shown as"}),/* @__PURE__ */e(Uc,{fill:!0,label:"Shown as",value:t.displayMode||"difference",options:[{value:"percent_change",label:"Change %"},{value:"difference",label:"Change"},{value:"both",label:"Both"},{value:"ratio",label:"Ratio",title:"Current ÷ comparison"}],onChange:l=>a({displayMode:l})})]}),(t.displayMode||"difference")!=="difference"?/* @__PURE__ */n("div",{className:"flex items-center justify-between gap-3",children:[/* @__PURE__ */e("div",{children:/* @__PURE__ */e(D,{htmlFor:"comparison-precision",className:"text-xs",children:"Decimals"})}),/* @__PURE__ */e(dt,{id:"comparison-precision",type:"number",min:0,max:6,step:1,value:t.precision??"",placeholder:"Auto",onChange:l=>{if(l.target.value===""){a({precision:void 0});return;}const o=Number(l.target.value);Number.isInteger(o)&&o>=0&&o<=6&&a({precision:o});},size:"xs",className:"w-16"})]}):null,/* @__PURE__ */n("div",{className:"space-y-1.5",children:[/* @__PURE__ */e(D,{className:"text-xs font-medium text-muted-foreground",children:"Indicator"}),/* @__PURE__ */n(ne,{value:t.indicatorStyle||"arrow_badge",onValueChange:l=>a({indicatorStyle:l}),children:[/* @__PURE__ */e(re,{size:"xs",children:/* @__PURE__ */e(se,{})}),/* @__PURE__ */n(le,{children:[/* @__PURE__ */e(U,{value:"arrow_badge",children:"Arrow + badge"}),/* @__PURE__ */e(U,{value:"arrow",children:"Arrow"}),/* @__PURE__ */e(U,{value:"badge",children:"Badge"}),/* @__PURE__ */e(U,{value:"none",children:"None"})]})]})]}),s&&/* @__PURE__ */n("div",{className:"flex items-center justify-between",children:[/* @__PURE__ */e(D,{className:"text-xs",children:"Position"}),/* @__PURE__ */n(ne,{value:t.position||"right",onValueChange:l=>a({position:l}),children:[/* @__PURE__ */e(re,{size:"xs",className:"w-24",children:/* @__PURE__ */e(se,{})}),/* @__PURE__ */n(le,{children:[/* @__PURE__ */e(U,{value:"right",children:"Right"}),/* @__PURE__ */e(U,{value:"left",children:"Left"}),/* @__PURE__ */e(U,{value:"top",children:"Top"})]})]})]}),i,/* @__PURE__ */n("div",{className:"flex items-center justify-between",children:[/* @__PURE__ */e(D,{htmlFor:"comparison-color",className:"text-xs",children:"Colors"}),/* @__PURE__ */e(we,{id:"comparison-color",size:"xs",checked:t.showColor!==!1,onCheckedChange:l=>a({showColor:l})})]}),t.showColor!==!1&&/* @__PURE__ */e("div",{className:"space-y-1.5",children:[["increase",`Up${d(!0)}`,"#16a34a"],["decrease",`Down${d(!1)}`,"#dc2626"],["neutral","No change","#6b7280"]].map(([l,o,x])=>/* @__PURE__ */n("div",{className:"flex items-center gap-2",children:[/* @__PURE__ */e("span",{className:"w-24 shrink-0 text-xs text-muted-foreground",children:o}),/* @__PURE__ */e(ja,{value:Hm(c[l]||x),onChange:u=>a({colors:{...c,[l]:u||x}}),defaultValue:x,ariaLabel:`${o} color`,allowEmpty:!1})]},l))}),/* @__PURE__ */n("div",{className:"space-y-1.5",children:[/* @__PURE__ */e(D,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Label"}),t.conditionalLabel?/* @__PURE__ */e("div",{className:"space-y-1.5",children:[["increase","Increase"],["decrease","Decrease"],["neutral","No change"]].map(([l,o])=>{var x;return/* @__PURE__ */e(dt,{"aria-label":`${o} label`,value:((x=t.conditionalLabels)==null?void 0:x[l])||o,onChange:u=>a({conditionalLabels:{...t.conditionalLabels,[l]:u.target.value}}),size:"xs"},l);})}):/* @__PURE__ */n("div",{className:"space-y-1",children:[/* @__PURE__ */e(dt,{"aria-label":"Comparison label",value:t.labelName&&t.labelName!=="Previous"?t.labelName:"",onChange:l=>a({labelName:l.target.value}),placeholder:"The comparison's own words",size:"xs"}),/* @__PURE__ */e("p",{className:"text-[11px] leading-4 text-muted-foreground",children:"Empty: the comparison's own words, which follow the Date filter."})]}),/* @__PURE__ */n("div",{className:"flex items-center justify-between pt-1",children:[/* @__PURE__ */e(D,{htmlFor:"comparison-conditional-label",className:"text-xs",children:"Different label per direction"}),/* @__PURE__ */e(we,{id:"comparison-conditional-label",size:"xs",checked:t.conditionalLabel===!0,onCheckedChange:l=>a({conditionalLabel:l})})]})]})]});}function Bs({cardType:t}){var p,h;const a=E(m=>m.card),{setCardPreferences:s}=me(),r=((p=a.config)==null?void 0:p.metricColumns)||[],i=((h=a.preferences)==null?void 0:h.comparisonPresentation)||{},c=m=>s(_l(a.preferences,m)),d=Mr(i),l=kr({...a,type:t}),o=r.filter(m=>{var C;return Fr({metricComparison:m.comparison,inheritGlobalComparison:(C=a.preferences)==null?void 0:C.inheritGlobalComparison,hidden:d}).state!=="off";}),x=o.length>0||l,u=Dl.includes(t);return/* @__PURE__ */n("div",{className:"space-y-4",children:[/* @__PURE__ */e($m,{card:a}),x&&u?/* @__PURE__ */e(Um,{value:i,onChange:c,showPosition:l,direction:/* @__PURE__ */e(mr,{card:a}),polarity:us((l?r[0]:o[0])??r[0])}):x?/* @__PURE__ */e(mr,{card:a}):null]});}function Gm(){const t=Be();return Vl.includes(t)?/* @__PURE__ */n(Se,{value:"comparison",className:"border-none",children:[/* @__PURE__ */e(Te,{className:"flex items-center gap-2 py-2 text-[12px] hover:no-underline [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground",children:/* @__PURE__ */n("div",{className:"flex items-center gap-2",children:[/* @__PURE__ */e(Gc,{className:"h-3.5 w-3.5 text-foreground/60"}),/* @__PURE__ */e("span",{children:"Comparison"})]})}),/* @__PURE__ */e(ke,{className:"pb-4 pt-2",children:/* @__PURE__ */e(Bs,{cardType:t})})]}):null;}const Qm={surface:"dashboard",kind:"table"};function zs({cardType:t,queryOutput:a,focusSection:s,focusRequestId:r}){var Z,G;const i=E(q=>q.card),c=E(q=>q.queryResultColumns),d=E(q=>q.queryResultColumnKeyMap),l=E(q=>{var ae;return(ae=q.card)==null?void 0:ae.preferences;}),o=l==null?void 0:l.tablePrefs,x=E(q=>q.actions.setCardPreferences),u=E(q=>q.queryResultColumnMeta),p=t??i.type,h=a?[...(a.keys??[])]:c,m=a?a.columnKeyMap:d,C=a?a.resultColumns:u,S=i.type===p?i:{...i,type:p},w=Oo(S,h,m,C),v=Ao(S,h),y=p==="matrixTable"||Ro(p),A=p==="table",b=p==="table",z=i?er(i):[],B=!!i&&er({...i,type:p}).includes("columns"),j=z.includes("columnFilters"),$=z.includes("search"),I=b||B||j,O=((Z=w[0])==null?void 0:Z.value)||"",L=Bl(S),k=zl(S),[K,M]=Y("style");ve(()=>{if(s==="style"){M("style");return;}if(s==="columns"&&I){M("columns");return;}s==="conditional-formatting"&&y&&M("conditional-formatting");},[I,y,r,s]);const f=i?Kl(i):!1,F=q=>{x({...l,tablePrefs:{...o,tableStyle:{...(o==null?void 0:o.tableStyle),wrapText:q}}});},{style:g}=Qc(Qm),N=(q,ae)=>{x(Dn(l,{measures:{[q]:ae}}));},T=q=>{x(Dn(l,{row:q}));},_=(q,ae)=>{x($l({preferences:l},q,{hidden:!ae}).preferences??{});},P=q=>{x(Ta(l,"columns",q));},R=q=>{x(Ta(l,"columnFilters",q));},V=q=>{x(Ta(l,"search",q));},Q=()=>{x(jl({preferences:l}).preferences??{});},J=f?/* @__PURE__ */n("div",{className:"space-y-2",children:[/* @__PURE__ */e("div",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Comparison"}),/* @__PURE__ */e(Bs,{cardType:"table"})]}):null;return/* @__PURE__ */e("div",{className:"px-4 py-3",children:/* @__PURE__ */n(ft,{value:K,onValueChange:q=>M(q),className:"space-y-4",children:[/* @__PURE__ */n(gt,{variant:"underline",children:[/* @__PURE__ */e(qe,{value:"style",children:"Appearance"}),I?/* @__PURE__ */e(qe,{value:"columns",children:"Columns"}):null,/* @__PURE__ */e(qe,{value:"conditional-formatting",disabled:!y,children:"Conditional formatting"})]}),/* @__PURE__ */n(Ye,{value:"style",className:"mt-0",children:[A?/* @__PURE__ */e(Lo,{wrapText:((G=o==null?void 0:o.tableStyle)==null?void 0:G.wrapText)??g.cell.wrap,onWrapTextChange:F,totals:L?{enabled:k,onEnabledChange:T,measures:ql(S),onMeasureTotalChange:N}:void 0,extraSection:J}):J,p==="matrixTable"&&/* @__PURE__ */e(Ha,{section:"table"})]}),/* @__PURE__ */n(Ye,{value:"columns",className:"mt-0 space-y-4",children:[B?/* @__PURE__ */n("div",{className:"flex items-start justify-between gap-3",children:[/* @__PURE__ */n("div",{className:"min-w-0",children:[/* @__PURE__ */e(D,{htmlFor:"allow-viewer-column-customization",className:"text-xs",children:"Let viewers customize columns"}),/* @__PURE__ */e("p",{className:"mt-0.5 text-[12px] leading-5 text-muted-foreground",children:"Viewers can hide, reorder and rename columns for themselves, and their changes are remembered. Sorting works either way. Their changes never affect anyone else."})]}),/* @__PURE__ */e(we,{id:"allow-viewer-column-customization",size:"xs",checked:(o==null?void 0:o.allowViewerColumnCustomization)!==!1,onCheckedChange:P})]}):null,j?/* @__PURE__ */n("div",{className:"flex items-start justify-between gap-3",children:[/* @__PURE__ */n("div",{className:"min-w-0",children:[/* @__PURE__ */e(D,{htmlFor:"allow-viewer-column-filters",className:"text-xs",children:"Let viewers filter columns"}),/* @__PURE__ */n("p",{className:"mt-0.5 text-[12px] leading-5 text-muted-foreground",children:[p==="matrixTable"?"Viewers can filter any row or column level from its menu, for this card only.":"Viewers can filter any column from its header, for this card only."," ","Their filters never affect anyone else, and a saved view keeps them."]})]}),/* @__PURE__ */e(we,{id:"allow-viewer-column-filters",size:"xs",checked:(o==null?void 0:o.allowViewerColumnFilters)!==!1,onCheckedChange:R})]}):null,$?/* @__PURE__ */n("div",{className:"flex items-start justify-between gap-3",children:[/* @__PURE__ */n("div",{className:"min-w-0",children:[/* @__PURE__ */e(D,{htmlFor:"allow-viewer-search",className:"text-xs",children:"Let viewers search"}),/* @__PURE__ */e("p",{className:"mt-0.5 text-[12px] leading-5 text-muted-foreground",children:"Viewers can search the table's text columns, for this card only and for their visit."})]}),/* @__PURE__ */e(we,{id:"allow-viewer-search",size:"xs",checked:(o==null?void 0:o.allowViewerSearch)!==!1,onCheckedChange:V})]}):null,b?/* @__PURE__ */e(Po,{columns:v,columnVisibility:o==null?void 0:o.columnVisibility,onColumnVisibilityChange:_,onShowAllColumns:Q}):null]}),/* @__PURE__ */e(Ye,{value:"conditional-formatting",className:"mt-0",children:p==="matrixTable"?/* @__PURE__ */e(Ha,{section:"conditional-formatting"}):y?O?/* @__PURE__ */e(Wm,{columnId:O,availableColumns:w}):/* @__PURE__ */e("p",{className:"py-6 text-center text-[12px] text-muted-foreground",children:"Run the query to configure conditional formatting."}):/* @__PURE__ */e("p",{className:"py-6 text-center text-[12px] text-muted-foreground",children:"Conditional formatting is available for table and detail table cards."})})]})});}function Wm({columnId:t,availableColumns:a}){const s=E(d=>d.card),r=E(d=>d.actions.updateConditionalRules),{rules:i,onChange:c}=Ur(s.id,Tr(s),r);return/* @__PURE__ */n("div",{className:"space-y-2",children:[/* @__PURE__ */e(Gr,{cardId:s.id}),/* @__PURE__ */e(Qr,{columnId:t,availableColumns:a,conditionalRules:i,onConditionalRulesChange:c,startRulesWithNoTrigger:!0})]});}function Ym(){var i;const t=E(c=>c.card.preferences),{setCardPreferences:a}=E(c=>c.actions),s=(i=t==null?void 0:t.textVisualOptions)!=null&&i.isDynamicText?"dynamic":"static";function r(c){a({...t,textVisualOptions:{...(t==null?void 0:t.textVisualOptions),isDynamicText:c==="dynamic"}});}return/* @__PURE__ */e(ft,{value:s,onValueChange:r,children:/* @__PURE__ */n(gt,{variant:"underline",children:[/* @__PURE__ */e(qe,{value:"static",children:"Static"}),/* @__PURE__ */e(qe,{value:"dynamic",children:"Dynamic"})]})});}function Xm(){return/* @__PURE__ */n("div",{className:"space-y-2 px-6 py-4",children:[/* @__PURE__ */e("div",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Text mode"}),/* @__PURE__ */e(Ym,{}),/* @__PURE__ */e("p",{className:"pt-1 text-[12px] leading-[1.55] text-muted-foreground",children:"Static text is authored inline. Dynamic text reads from the first cell of the card's query."})]});}function Jm({color:t,onColorChange:a,onClose:s}){const[r,i]=Y(0),[c,d]=Y(100),[l,o]=Y(50),[x,u]=Y(t);ve(()=>{const w=hr(t);if(w){const v=pr(w.r,w.g,w.b);i(v.h),d(v.s),o(v.l),u(t);}},[t]);const p=w=>{i(w),m(w,c,l);},h=w=>{const v=w.currentTarget.getBoundingClientRect(),y=Math.max(0,Math.min(1,(w.clientX-v.left)/v.width)),A=Math.max(0,Math.min(1,(w.clientY-v.top)/v.height)),b=y*100,z=(1-A)*100;d(b),o(z),m(r,b,z);},m=(w,v,y)=>{const A=eh(w,v,y),b=Zm(A.r,A.g,A.b);u(b);},C=w=>{if(u(w),/^#[0-9A-Fa-f]{6}$/.test(w)){const v=hr(w);if(v){const y=pr(v.r,v.g,v.b);i(y.h),d(y.s),o(y.l);}}},S=()=>{/^#[0-9A-Fa-f]{6}$/.test(x)&&(a(x),s());};return/* @__PURE__ */n("div",{className:"p-4 space-y-4 w-[320px]",children:[/* @__PURE__ */n("div",{className:"relative h-[200px] rounded cursor-crosshair",style:{background:`hsl(${r}, 100%, 50%)`},onClick:h,onMouseMove:w=>{w.buttons===1&&h(w);},children:[/* @__PURE__ */e("div",{className:"absolute inset-0 rounded",style:{background:"linear-gradient(to right, white, transparent)"}}),/* @__PURE__ */e("div",{className:"absolute inset-0 rounded",style:{background:"linear-gradient(to bottom, transparent, black)"}}),/* @__PURE__ */e("div",{className:"absolute w-4 h-4 -ml-2 -mt-2 rounded-full border-2 border-white shadow-md",style:{left:`${c}%`,top:`${100-l}%`,backgroundColor:x}})]}),/* @__PURE__ */e("div",{className:"space-y-2",children:/* @__PURE__ */e("input",{type:"range",min:"0",max:"360",value:r,onChange:w=>p(Number(w.target.value)),className:"w-full h-4 rounded-lg appearance-none cursor-pointer",style:{background:"linear-gradient(to right, #ff0000, #ffff00, #00ff00, #00ffff, #0000ff, #ff00ff, #ff0000)"}})}),/* @__PURE__ */n("div",{className:"space-y-2",children:[/* @__PURE__ */e(D,{children:"HEX"}),/* @__PURE__ */e(dt,{value:x,onChange:w=>C(w.target.value),placeholder:"#000000",size:"xs",className:"font-mono"})]}),/* @__PURE__ */n("div",{className:"flex items-center gap-4",children:[/* @__PURE__ */n("div",{className:"text-center",children:[/* @__PURE__ */e("div",{className:"w-12 h-12 rounded-full border shadow-sm",style:{backgroundColor:t}}),/* @__PURE__ */e("span",{className:"text-xs text-muted-foreground mt-1",children:"CURRENT"})]}),/* @__PURE__ */n("div",{className:"text-center",children:[/* @__PURE__ */e("div",{className:"w-12 h-12 rounded-full border shadow-sm",style:{backgroundColor:x}}),/* @__PURE__ */e("span",{className:"text-xs text-muted-foreground mt-1",children:"NEW"})]})]}),/* @__PURE__ */n("div",{className:"flex gap-2 justify-end",children:[/* @__PURE__ */e(ce,{variant:"outline",onClick:s,children:"Cancel"}),/* @__PURE__ */e(ce,{onClick:S,children:"OK"})]})]});}function hr(t){const a=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return a?{r:parseInt(a[1],16),g:parseInt(a[2],16),b:parseInt(a[3],16)}:null;}function Zm(t,a,s){return"#"+((1<<24)+(t<<16)+(a<<8)+s).toString(16).slice(1);}function pr(t,a,s){t/=255,a/=255,s/=255;const r=Math.max(t,a,s),i=Math.min(t,a,s);let c=0,d=0;const l=(r+i)/2;if(r!==i){const o=r-i;switch(d=l>0.5?o/(2-r-i):o/(r+i),r){case t:c=((a-s)/o+(a<s?6:0))/6;break;case a:c=((s-t)/o+2)/6;break;case s:c=((t-a)/o+4)/6;break;}}return{h:Math.round(c*360),s:Math.round(d*100),l:Math.round(l*100)};}function eh(t,a,s){t/=360,a/=100,s/=100;let r,i,c;if(a===0)r=i=c=s;else{const d=(x,u,p)=>(p<0&&(p+=1),p>1&&(p-=1),p<0.16666666666666666?x+(u-x)*6*p:p<0.5?u:p<0.6666666666666666?x+(u-x)*(0.6666666666666666-p)*6:x),l=s<0.5?s*(1+a):s+a-s*a,o=2*s-l;r=d(o,l,t+1/3),i=d(o,l,t),c=d(o,l,t-1/3);}return{r:Math.round(r*255),g:Math.round(i*255),b:Math.round(c*255)};}const th=["#000000","#ffffff","#6b7280","#dc2626","#ea580c","#ca8a04","#16a34a","#0891b2","#2563eb","#7c3aed","#c026d3","#e11d48","#0f172a","#f3f4f6","#fbbf24"];function ah(){var z,B,j,$,I,O,L,k,K,M;const t=E(f=>f.card),a=E(f=>{var F;return(F=f.card)==null?void 0:F.preferences;}),s=Be(),{setCardPreferences:r,updateCardInFrame:i}=me(),c=X(()=>s!==t.type?{...t,type:s}:t,[t,s]),{data:d}=je(c),[l,o]=Y({}),[x,u]=Y(null),[p,h]=Y(null),m=X(()=>{var N,T,_,P,R,V,Q;if(!(d!=null&&d.records)||d.records.length===0)return[];const f=s==="stackedBar"||s==="stackedLine",F=s==="bar"||s==="line"||s==="horizontalBar"||s==="bullet"||s==="combo"||s==="area"||s==="stackedArea",g=((N=t==null?void 0:t.config)==null?void 0:N.pivotByColumns)&&t.config.pivotByColumns.length>0;if((f||F)&&g){if(d.pivotSchema&&Array.isArray(d.pivotSchema)){const J=/* @__PURE__ */new Set();return d.pivotSchema.forEach(Z=>{Z.alias&&J.add(Z.alias);}),Array.from(J);}if(d.records.length>0){const J=d.records[0],Z=Object.keys(J),G=/* @__PURE__ */new Set();(T=t==null?void 0:t.config)!=null&&T.groupByColumns&&t.config.groupByColumns.forEach(de=>{G.add(de.label||de.name),G.add(de.alias||de.name);});const q=/* @__PURE__ */new Set();return(_=t==null?void 0:t.config)!=null&&_.metricColumns&&t.config.metricColumns.forEach(de=>{const he=de.alias||de.name;q.add(he),q.add(`${he}_count`),q.add(`${he}_sum`),q.add(`${he}_avg`),q.add(`${he}_min`),q.add(`${he}_max`);const ie=de.entityName||de.qualifiedEntityName;ie&&(q.add(`${ie}_${he}`),q.add(`${ie}_${he}_count`));}),Z.filter(de=>!G.has(de)&&!q.has(de));}}if((F||f)&&!g&&(R=(P=t==null?void 0:t.config)==null?void 0:P.metricColumns)!=null&&R.length)return t.config.metricColumns.map(J=>J.alias||J.label||J.name);if((Q=(V=t==null?void 0:t.config)==null?void 0:V.groupByColumns)!=null&&Q.length){const J=t.config.groupByColumns[0],Z=J.label||J.name,G=/* @__PURE__ */new Set();return d.records.forEach(q=>{const ae=q[Z];ae!=null&&G.add(String(ae));}),Array.from(G);}return[];},[d,(z=t==null?void 0:t.config)==null?void 0:z.groupByColumns,(B=t==null?void 0:t.config)==null?void 0:B.pivotByColumns,(j=t==null?void 0:t.config)==null?void 0:j.metricColumns,s]),C=yn().palette;ve(()=>{const f={};m.forEach((F,g)=>{f[F]=Yn(F,g,C,a==null?void 0:a.colorConfig);}),o(f);},[m,a==null?void 0:a.colorConfig,C]);const S=(f,F)=>{var _;const g={...l,[f]:F};o(g);const N={...(a||{}),colorConfig:{...(a==null?void 0:a.colorConfig),segments:{...((_=a==null?void 0:a.colorConfig)==null?void 0:_.segments),[f]:F}}};r(N);const T={...t,preferences:N};i(T);},w=(f,F)=>{var R;const g=C[F%C.length],{[f]:N,...T}=((R=a==null?void 0:a.colorConfig)==null?void 0:R.segments)||{},_={...(a||{}),colorConfig:{segments:T}};r(_);const P={...t,preferences:_};i(P),o(V=>({...V,[f]:g}));};if(!m.length||!((t==null?void 0:t.type)==="stackedBar"||(t==null?void 0:t.type)==="stackedLine"?((I=($=t==null?void 0:t.config)==null?void 0:$.groupByColumns)==null?void 0:I.length)||((L=(O=t==null?void 0:t.config)==null?void 0:O.pivotByColumns)==null?void 0:L.length):(K=(k=t==null?void 0:t.config)==null?void 0:k.groupByColumns)==null?void 0:K.length)||["table","kpi","text","custom","heatmap"].includes(s))return null;const A=()=>{const f={...(a||{}),colorConfig:{segments:{}}};r(f);const F={...t,preferences:f};i(F);const g={};m.forEach((N,T)=>{g[N]=Yn(N,T,C);}),o(g);},b=Object.keys(((M=a==null?void 0:a.colorConfig)==null?void 0:M.segments)||{}).length>0;return/* @__PURE__ */n(Se,{value:"colors",className:"border-b-0",children:[/* @__PURE__ */e(Te,{className:"flex w-full items-center gap-2 py-2 text-[12px] font-medium hover:no-underline",children:/* @__PURE__ */n("div",{className:"flex items-center gap-2",children:[/* @__PURE__ */e(du,{className:"h-4 w-4 text-muted-foreground"}),/* @__PURE__ */e("span",{children:"Colors"})]})}),/* @__PURE__ */e(ke,{className:"",children:/* @__PURE__ */n("div",{className:"space-y-3",children:[/* @__PURE__ */e("div",{className:"space-y-2",children:/* @__PURE__ */e("div",{className:"flex items-center justify-between",children:b&&/* @__PURE__ */n("button",{className:"ml-auto flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground",onClick:A,children:[/* @__PURE__ */e(Wa,{className:"h-3 w-3"}),"Reset All"]})})}),/* @__PURE__ */e("div",{className:"max-h-[200px] space-y-2 overflow-y-auto pr-1",children:m.map((f,F)=>{const g=l[f]===C[F%C.length],N=!g;return/* @__PURE__ */n("div",{className:"flex items-center gap-2",children:[/* @__PURE__ */n(it,{open:x===f,onOpenChange:T=>u(T?f:null),children:[/* @__PURE__ */e(xt,{asChild:!0,children:/* @__PURE__ */e("button",{className:"h-5 w-5 shrink-0 rounded border border-input shadow-sm transition-colors hover:border-gray-400 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",style:{backgroundColor:l[f]}})}),/* @__PURE__ */e(ot,{align:"start",className:"w-auto p-3",children:/* @__PURE__ */n("div",{className:"space-y-2.5",children:[/* @__PURE__ */n("div",{className:"space-y-1",children:[/* @__PURE__ */e("p",{className:"text-xs font-medium text-muted-foreground",children:"Theme Colors"}),/* @__PURE__ */e("div",{className:"grid grid-cols-5 gap-1.5",children:C.slice(0,10).map((T,_)=>/* @__PURE__ */n("button",{className:W("relative h-5 w-5 rounded border-2 transition-all hover:scale-110",l[f]===T?"border-gray-900":"border-transparent"),style:{backgroundColor:T},onClick:()=>{S(f,T),u(null);},children:[_===F%C.length&&/* @__PURE__ */e("div",{className:"absolute inset-0 flex items-center justify-center",children:/* @__PURE__ */e("div",{className:"rounded-full bg-white/90 px-0.5 text-[8px] font-bold text-gray-900 shadow-sm",children:"D"})}),/* @__PURE__ */e("span",{className:"sr-only",children:T})]},`default-${_}`))})]}),/* @__PURE__ */n("div",{className:"space-y-1",children:[/* @__PURE__ */e("p",{className:"text-xs font-medium text-muted-foreground",children:"Popular Colors"}),/* @__PURE__ */e("div",{className:"grid grid-cols-5 gap-1.5",children:th.map((T,_)=>/* @__PURE__ */e("button",{className:W("h-5 w-5 rounded border transition-all hover:scale-110",l[f]===T?"border-2 border-gray-900":T==="#ffffff"?"border border-gray-300":"border border-transparent"),style:{backgroundColor:T},onClick:()=>{S(f,T),u(null);},children:/* @__PURE__ */e("span",{className:"sr-only",children:T})},`preset-${_}`))})]}),/* @__PURE__ */n("div",{className:"flex items-center justify-between gap-2 pt-1",children:[/* @__PURE__ */e("button",{className:"text-sm font-medium text-blue-600 hover:text-blue-700",onClick:()=>{h({value:f,color:l[f]}),u(null);},children:"Custom color"}),!g&&/* @__PURE__ */n("button",{className:"flex items-center gap-1 text-sm text-muted-foreground hover:text-foreground",onClick:()=>{w(f,F),u(null);},children:[/* @__PURE__ */e(Wa,{className:"h-3 w-3"}),"Reset"]})]})]})})]}),/* @__PURE__ */e("span",{className:"flex-1 truncate text-sm",children:f}),N&&/* @__PURE__ */e("span",{className:"text-xs text-muted-foreground",children:"(custom)"})]},f);})}),p&&/* @__PURE__ */n("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[/* @__PURE__ */e("div",{className:"absolute inset-0 bg-black/50",onClick:()=>h(null)}),/* @__PURE__ */e("div",{className:"relative rounded-lg bg-white shadow-lg",children:/* @__PURE__ */e(Jm,{color:p.color,onColorChange:f=>{S(p.value,f),h(null);},onClose:()=>h(null)})})]})]})})]});}function Da({axis:t,label:a,type:s,config:r,onChange:i,defaultTitle:c,hidePosition:d}){var w,v,y,A,b,z,B,j,$,I,O,L,k,K;const[l,o]=Y(!!(r!=null&&r.valueFormat)),x=l||!!(r!=null&&r.valueFormat),u=(M,f)=>{i({...(r??{}),[M]:f});},p=(M,f)=>{var N;const g=M==="enabled"&&f===!0&&!((N=r==null?void 0:r.name)!=null&&N.text)&&c;i(Ul(r,{[M]:f,...(g?{text:c}:{})}));},h=(M,f)=>{var F,g;i({...(r??{}),labels:{enabled:M==="enabled"?f:((F=r==null?void 0:r.labels)==null?void 0:F.enabled)??!0,rotation:M==="rotation"?f:(g=r==null?void 0:r.labels)==null?void 0:g.rotation}});},m=(M,f)=>{i(Gl(r,{[M]:f===""?null:Number(f)}));},C=t==="x"?["auto","top","bottom"]:["auto","left","right"],S=["auto","0","45","90","-45","-90"];return/* @__PURE__ */n(Se,{value:`${t}-axis`,className:"border-b-0",children:[/* @__PURE__ */n("div",{className:"flex w-full items-center justify-between gap-2",children:[/* @__PURE__ */e(Te,{className:"flex grow items-center justify-between gap-3 py-2 text-[12px] font-medium hover:no-underline",children:/* @__PURE__ */e("div",{className:"flex grow items-center justify-between gap-2",children:/* @__PURE__ */e("span",{children:a})})}),/* @__PURE__ */e(we,{size:"sm",checked:(r==null?void 0:r.enabled)!==!1,onCheckedChange:M=>u("enabled",M),onClick:M=>M.stopPropagation()})]}),/* @__PURE__ */n(ke,{className:"space-y-4 pt-2",children:[/* @__PURE__ */n("div",{className:"space-y-2",children:[/* @__PURE__ */n("div",{className:"flex items-center gap-2",children:[/* @__PURE__ */e(Kt,{id:`${t}-title-enabled`,checked:((w=r==null?void 0:r.name)==null?void 0:w.enabled)??!1,onCheckedChange:M=>p("enabled",M===!0)}),/* @__PURE__ */e(D,{htmlFor:`${t}-title-enabled`,className:"text-xs font-medium cursor-pointer",children:"TITLE"})]}),((v=r==null?void 0:r.name)==null?void 0:v.enabled)&&/* @__PURE__ */n("div",{className:"space-y-2 pl-6",children:[/* @__PURE__ */e(et,{placeholder:`${a} title`,value:((y=r==null?void 0:r.name)==null?void 0:y.text)||"",onSave:M=>p("text",M),className:""}),/* @__PURE__ */n("div",{className:"flex items-center gap-3",children:[/* @__PURE__ */n("div",{className:"flex items-center gap-2",children:[/* @__PURE__ */e(D,{className:"text-xs text-muted-foreground",children:"Size"}),/* @__PURE__ */e("div",{className:"w-14",children:/* @__PURE__ */e(et,{type:"number",placeholder:"12",value:String(((A=r==null?void 0:r.name)==null?void 0:A.fontSize)||12),onSave:M=>p("fontSize",Number(M)||12),className:""})})]}),/* @__PURE__ */n("div",{className:"flex items-center gap-2",children:[/* @__PURE__ */e(D,{className:"text-xs text-muted-foreground",children:"Weight"}),/* @__PURE__ */n(ne,{value:((b=r==null?void 0:r.name)==null?void 0:b.fontWeight)||"normal",onValueChange:M=>p("fontWeight",M),children:[/* @__PURE__ */e(re,{size:"xs",className:"w-20",children:/* @__PURE__ */e(se,{})}),/* @__PURE__ */n(le,{children:[/* @__PURE__ */e(U,{value:"normal",className:"text-xs",children:"Normal"}),/* @__PURE__ */e(U,{value:"bold",className:"text-xs",children:"Bold"})]})]})]})]})]})]}),!d&&/* @__PURE__ */n("div",{className:"space-y-2",children:[/* @__PURE__ */e(D,{className:"text-xs font-medium",children:"POSITION"}),/* @__PURE__ */n(ne,{value:(r==null?void 0:r.position)||"auto",onValueChange:M=>u("position",M),children:[/* @__PURE__ */e(re,{size:"xs",children:/* @__PURE__ */e(se,{})}),/* @__PURE__ */e(le,{children:C.map(M=>/* @__PURE__ */e(U,{value:M,className:"text-xs",children:M==="auto"?"Auto (Default)":We(M)},M))})]})]}),/* @__PURE__ */n("div",{className:"space-y-2",children:[/* @__PURE__ */n("div",{className:"flex items-center justify-between",children:[/* @__PURE__ */e(D,{className:"text-xs font-medium",children:"LABELS"}),/* @__PURE__ */e(we,{size:"sm",checked:((z=r==null?void 0:r.labels)==null?void 0:z.enabled)!==!1,onCheckedChange:M=>h("enabled",M)})]}),((B=r==null?void 0:r.labels)==null?void 0:B.enabled)!==!1&&/* @__PURE__ */n("div",{className:"space-y-2",children:[/* @__PURE__ */e(D,{className:"text-xs text-muted-foreground",children:"Rotation"}),/* @__PURE__ */n(ne,{value:String(((j=r==null?void 0:r.labels)==null?void 0:j.rotation)||"auto"),onValueChange:M=>h("rotation",M==="auto"?"auto":Number(M)),children:[/* @__PURE__ */e(re,{size:"xs",children:/* @__PURE__ */e(se,{})}),/* @__PURE__ */e(le,{children:S.map(M=>/* @__PURE__ */e(U,{value:M,className:"text-xs",children:M==="auto"?"Auto (Default)":`${M}°`},M))})]})]})]}),s==="value"&&/* @__PURE__ */n("div",{className:"space-y-3",children:[/* @__PURE__ */n("div",{className:"flex items-center justify-between",children:[/* @__PURE__ */n("div",{className:"space-y-1",children:[/* @__PURE__ */e(D,{className:"text-xs font-medium",children:"FORMAT"}),/* @__PURE__ */e("div",{className:"text-xs text-muted-foreground",children:"Inherit from the bound metric by default."})]}),/* @__PURE__ */e(we,{size:"sm",checked:x,onCheckedChange:M=>{if(o(M),!M){const{valueFormat:f,...F}=r??{};i(F);}}})]}),x&&/* @__PURE__ */e(sa,{formatOptions:Tn(r==null?void 0:r.valueFormat)||{},onFormatOptionsChange:M=>i({...r,valueFormat:kn(M)}),showTitle:!1})]}),s==="value"&&/* @__PURE__ */n("div",{className:"space-y-2",children:[/* @__PURE__ */e(D,{className:"text-xs font-medium",children:"SCALE"}),/* @__PURE__ */n("div",{className:"space-y-2",children:[/* @__PURE__ */n("div",{className:"flex items-center gap-2",children:[/* @__PURE__ */e(D,{className:"w-8 text-xs text-muted-foreground",children:"Min"}),/* @__PURE__ */e("div",{className:"flex-1",children:/* @__PURE__ */e(et,{type:"number",placeholder:"auto",value:(($=r==null?void 0:r.scale)==null?void 0:$.min)==="auto"||((I=r==null?void 0:r.scale)==null?void 0:I.min)===void 0?"":String(r.scale.min),onSave:M=>m("min",M),className:""})})]}),/* @__PURE__ */n("div",{className:"flex items-center gap-2",children:[/* @__PURE__ */e(D,{className:"w-8 text-xs text-muted-foreground",children:"Max"}),/* @__PURE__ */e("div",{className:"flex-1",children:/* @__PURE__ */e(et,{type:"number",placeholder:"auto",value:((O=r==null?void 0:r.scale)==null?void 0:O.max)==="auto"||((L=r==null?void 0:r.scale)==null?void 0:L.max)===void 0?"":String(r.scale.max),onSave:M=>m("max",M),className:""})})]}),/* @__PURE__ */n("div",{className:"flex items-center gap-2",children:[/* @__PURE__ */e(D,{className:"w-8 text-xs text-muted-foreground",children:"Step"}),/* @__PURE__ */e("div",{className:"flex-1",children:/* @__PURE__ */e(et,{type:"number",placeholder:"auto",value:((k=r==null?void 0:r.scale)==null?void 0:k.stepSize)==="auto"||((K=r==null?void 0:r.scale)==null?void 0:K.stepSize)===void 0?"":String(r.scale.stepSize),onSave:M=>m("stepSize",M),className:""})})]})]})]})]})]});}function _a(t,a,s){var c,d,l;if(t==="x"){const o=(d=(c=a==null?void 0:a.config)==null?void 0:c.groupByColumns)==null?void 0:d[0];return(o==null?void 0:o.label)||(o==null?void 0:o.name)||"";}const r=((l=a==null?void 0:a.config)==null?void 0:l.metricColumns)||[],i=(s==null?void 0:s.datasetOptions)||[];if(t==="y"){const o=r.filter((x,u)=>{const p=i.find(h=>h.idx===u);return!p||p.yAxisId!=="y2";});return o.length===1&&(o[0].label||o[0].name)||"";}if(t==="y2"){const o=r.filter((x,u)=>{const p=i.find(h=>h.idx===u);return(p==null?void 0:p.yAxisId)==="y2";});return o.length===1&&(o[0].label||o[0].name)||"";}return"";}function nh(){const t=E(o=>o.card),a=E(o=>{var x;return(x=o.card)==null?void 0:x.preferences;}),{setCardPreferences:s,updateCardInFrame:r}=me(),i=Be();if(!t||["tornado","pyramid","kpi","treemap"].includes(i))return null;const c=Wc.getAxisInfo(i,a);if(!c.hasXAxis&&!c.hasYAxis)return null;const d=(o,x)=>{let u;o==="x"?u="xAxisConfig":o==="y"?u="yAxisConfig":u="secondaryYAxisConfig";const p=Hl(a,u,x);s(p);const h={...t,preferences:p};r(h);},l=c.hasY2Axis&&i==="combo";return/* @__PURE__ */n(Se,{value:"axes",className:"border-b-0",children:[/* @__PURE__ */e(Te,{className:"flex w-full items-center gap-2 py-2 text-[12px] font-medium hover:no-underline",children:/* @__PURE__ */n("div",{className:"flex items-center gap-2",children:[/* @__PURE__ */e(aa,{className:"h-4 w-4 text-muted-foreground"}),/* @__PURE__ */e("span",{children:"Axes"})]})}),/* @__PURE__ */e(ke,{className:"pt-2",children:/* @__PURE__ */n(ra,{type:"single",collapsible:!0,className:"w-full",children:[c.hasXAxis&&/* @__PURE__ */e(Da,{axis:"x",label:"X-Axis",type:c.xAxisType,config:wa(Xn(i,"x"),a==null?void 0:a.xAxisConfig),onChange:o=>d("x",o),defaultTitle:_a("x",t,a)}),c.hasYAxis&&/* @__PURE__ */e(Da,{axis:"y",label:l?"Y-Axis (Left)":"Y-Axis",type:c.yAxisType,config:wa(Xn(i,"y"),a==null?void 0:a.yAxisConfig),onChange:o=>d("y",o),defaultTitle:_a("y",t,a)}),l&&/* @__PURE__ */e(Da,{axis:"y2",label:"Y2-Axis (Right)",type:"value",config:wa({enabled:!0,position:"right"},a==null?void 0:a.secondaryYAxisConfig),onChange:o=>d("y2",o),defaultTitle:_a("y2",t,a),hidePosition:!0})]})})]});}function rh(){const t=E(p=>p.card),a=Be(),s=E(p=>{var h,m,C,S;return(S=(C=(m=(h=p.card)==null?void 0:h.preferences)==null?void 0:m.chartOptions)==null?void 0:C.plugins)==null?void 0:S.legend;}),{setLegendOptions:r}=me();if(!t||!Yc(a))return null;const i=Xc(a),c=(i==null?void 0:i.display)??!0,d=(i==null?void 0:i.position)??"top",l=(i==null?void 0:i.align)??"center",o=(p,h)=>{const m={...s,[p]:h};r(m);},x=["top","bottom","left","right"],u=["start","center","end"];return/* @__PURE__ */n(Se,{value:"legend",className:"border-b-0",children:[/* @__PURE__ */e(Te,{className:"flex w-full items-center gap-2 py-2 text-[12px] font-medium hover:no-underline",children:/* @__PURE__ */n("div",{className:"flex items-center gap-2",children:[/* @__PURE__ */e(Do,{className:"h-4 w-4 text-muted-foreground"}),/* @__PURE__ */e("span",{children:"Legend"})]})}),/* @__PURE__ */e(ke,{className:"pt-2",children:/* @__PURE__ */n("div",{className:"space-y-3",children:[/* @__PURE__ */n("div",{className:"flex items-center justify-between",children:[/* @__PURE__ */e(D,{className:"text-xs font-medium",children:"Display"}),/* @__PURE__ */e(we,{size:"sm",checked:(s==null?void 0:s.display)??c,onCheckedChange:p=>o("display",p)})]}),((s==null?void 0:s.display)??c)&&/* @__PURE__ */n(be,{children:[/* @__PURE__ */n("div",{className:"space-y-2",children:[/* @__PURE__ */e(D,{className:"text-xs font-medium",children:"Position"}),/* @__PURE__ */n(ne,{value:(s==null?void 0:s.position)||d,onValueChange:p=>o("position",p),children:[/* @__PURE__ */e(re,{size:"xs",children:/* @__PURE__ */e(se,{})}),/* @__PURE__ */e(le,{children:x.map(p=>/* @__PURE__ */e(U,{value:p,className:"text-xs",children:We(p)},p))})]})]}),/* @__PURE__ */n("div",{className:"space-y-2",children:[/* @__PURE__ */e(D,{className:"text-xs font-medium",children:"Alignment"}),/* @__PURE__ */n(ne,{value:(s==null?void 0:s.align)||l,onValueChange:p=>o("align",p),children:[/* @__PURE__ */e(re,{size:"xs",children:/* @__PURE__ */e(se,{})}),/* @__PURE__ */e(le,{children:u.map(p=>/* @__PURE__ */e(U,{value:p,className:"text-xs",children:We(p)},p))})]})]})]})]})})]});}function sh(){var K,M,f,F,g;const t=E(N=>N.card),a=Be(),s=E(N=>{var T,_;return(_=(T=N.card)==null?void 0:T.preferences)==null?void 0:_.dataLabelsConfig;}),r=E(N=>{var T;return(T=N.card)==null?void 0:T.preferences;}),{setCardPreferences:i,updateCardInFrame:c}=me(),[d,l]=Y(!!(s!=null&&s.valueFormat));if(!t||!Ql(a))return null;const o=a==="bullet"?((K=r==null?void 0:r.bulletConfig)==null?void 0:K.orientation)??(((M=r==null?void 0:r.chartOptions)==null?void 0:M.indexAxis)==="x"?"vertical":"horizontal"):void 0,x=o!=null?o==="horizontal":((f=r==null?void 0:r.chartOptions)==null?void 0:f.indexAxis)==="y",u=a==="stackedBar"||a==="stackedLine",p=a==="pie"||a==="doughnut"||a==="polarArea"||a==="funnel",h=a==="bubble"||a==="scatter",m=Wl(a,t.preferences),C=s??m,S=Yl(a,t.preferences),w=(s==null?void 0:s.enabled)!==void 0?s.enabled:S,v=(N,T)=>{const P=(N==="enabled"?_n({type:a,preferences:t.preferences},{show:T}).dataLabelsConfig:void 0)??{...Vn(s,m),[N]:T};N==="enabled"&&T&&h&&!P.position&&(P.position="bottom"),N==="position"&&h&&(P.position="bottom");const R={...(t.preferences||{}),dataLabelsConfig:P};i(R);const V={...t,preferences:R};c(V);},y=(N,T)=>{const _={...Vn(s,m),font:{...((s==null?void 0:s.font)||{}),[N]:T}},P={...(t.preferences||{}),dataLabelsConfig:_};i(P);const R={...t,preferences:P};c(R);},A=()=>{const N=a;return N==="stackedBar"||N==="stackedLine"||N==="pie"||N==="doughnut"?"center":x?"right":"top";},b=a!=="treemap"&&a!=="heatmap",z=a!=="treemap",B=A();let j=[];if(b)if(h)j=["bottom"];else if(u||p)j=["center"];else{const N=x?["center","left","right"]:["center","top","bottom"];j=["auto",...(a==="bullet"?N:N.filter(_=>_!==B)),"custom"];}const $=()=>We(B),I=["center","start","end"],O=["center","start","end","top","bottom"],L=d||!!(C!=null&&C.valueFormat),k=N=>{const T=_n({type:a,preferences:t.preferences},{format:N??null});i(T),c({...t,preferences:T});};return/* @__PURE__ */n(Se,{value:"data-labels",className:"border-b-0",children:[/* @__PURE__ */e(Te,{className:"flex w-full items-center gap-2 py-2 text-[12px] font-medium hover:no-underline",children:/* @__PURE__ */n("div",{className:"flex items-center gap-2",children:[/* @__PURE__ */e(Nu,{className:"h-4 w-4 text-muted-foreground"}),/* @__PURE__ */e("span",{children:"Data Labels"})]})}),/* @__PURE__ */e(ke,{className:"pt-2",children:/* @__PURE__ */n("div",{className:"space-y-3",children:[/* @__PURE__ */n("div",{className:"flex items-center justify-between",children:[/* @__PURE__ */e(D,{className:"text-xs font-medium",children:"Display"}),/* @__PURE__ */e(we,{size:"sm",checked:w,onCheckedChange:N=>v("enabled",N)})]}),w&&/* @__PURE__ */n(be,{children:[b&&!u&&!p&&/* @__PURE__ */n("div",{className:"space-y-2",children:[/* @__PURE__ */e(D,{className:"text-xs font-medium",children:"Position"}),/* @__PURE__ */n(ne,{value:h?(C==null?void 0:C.position)||"bottom":(C==null?void 0:C.position)||"auto",onValueChange:N=>v("position",N),children:[/* @__PURE__ */e(re,{size:"xs",children:/* @__PURE__ */e(se,{})}),/* @__PURE__ */e(le,{children:j.map(N=>/* @__PURE__ */e(U,{value:N,className:"text-xs",children:N==="auto"?$():N==="custom"?"Custom (Advanced)":We(N)},N))})]})]}),u&&/* @__PURE__ */n("div",{className:"flex items-center justify-between",children:[/* @__PURE__ */e(D,{className:"text-xs font-medium",children:"Show Total"}),/* @__PURE__ */e(we,{size:"sm",checked:(s==null?void 0:s.showTotal)??!1,onCheckedChange:N=>v("showTotal",N)})]}),(C==null?void 0:C.position)==="custom"&&/* @__PURE__ */n("div",{className:"space-y-2 pl-4 border-l-2 border-muted",children:[/* @__PURE__ */n("div",{className:"flex items-center gap-2",children:[/* @__PURE__ */e(D,{className:"text-xs text-muted-foreground w-16",children:"Anchor"}),/* @__PURE__ */n(ne,{value:(C==null?void 0:C.anchor)||"center",onValueChange:N=>v("anchor",N),children:[/* @__PURE__ */e(re,{size:"xs",className:"flex-1",children:/* @__PURE__ */e(se,{})}),/* @__PURE__ */e(le,{children:I.map(N=>/* @__PURE__ */e(U,{value:N,className:"text-xs",children:We(N)},N))})]})]}),/* @__PURE__ */n("div",{className:"flex items-center gap-2",children:[/* @__PURE__ */e(D,{className:"text-xs text-muted-foreground w-16",children:"Align"}),/* @__PURE__ */n(ne,{value:String((C==null?void 0:C.align)||"center"),onValueChange:N=>v("align",N),children:[/* @__PURE__ */e(re,{size:"xs",className:"flex-1",children:/* @__PURE__ */e(se,{})}),/* @__PURE__ */e(le,{children:O.map(N=>/* @__PURE__ */e(U,{value:N,className:"text-xs",children:We(N)},N))})]})]})]}),/* @__PURE__ */n("div",{className:"space-y-3",children:[/* @__PURE__ */n("div",{className:"flex items-center justify-between",children:[/* @__PURE__ */n("div",{className:"space-y-1",children:[/* @__PURE__ */e(D,{className:"text-xs font-medium",children:"Format"}),/* @__PURE__ */e("div",{className:"text-xs text-muted-foreground",children:"Keep this off to inherit from the bound metric."})]}),/* @__PURE__ */e(we,{size:"sm",checked:L,onCheckedChange:N=>{l(N),N||k(void 0);}})]}),L&&/* @__PURE__ */e(sa,{formatOptions:Tn(C==null?void 0:C.valueFormat)||{},onFormatOptionsChange:N=>k(kn(N)),showTitle:!1})]}),z&&/* @__PURE__ */n("div",{className:"space-y-2",children:[/* @__PURE__ */e(D,{className:"text-xs font-medium",children:"Appearance"}),/* @__PURE__ */n("div",{className:"flex items-center gap-2",children:[/* @__PURE__ */e(D,{className:"text-xs text-muted-foreground w-20",children:"Size"}),/* @__PURE__ */e("div",{className:"flex-1",children:/* @__PURE__ */e(et,{type:"number",placeholder:"12",value:String(((F=C==null?void 0:C.font)==null?void 0:F.size)||12),onSave:N=>y("size",Number(N)),className:""})})]}),/* @__PURE__ */n("div",{className:"flex items-center gap-2",children:[/* @__PURE__ */e(D,{className:"text-xs text-muted-foreground w-20",children:"Weight"}),/* @__PURE__ */n(ne,{value:((g=C==null?void 0:C.font)==null?void 0:g.weight)||"normal",onValueChange:N=>y("weight",N),children:[/* @__PURE__ */e(re,{size:"xs",className:"flex-1",children:/* @__PURE__ */e(se,{})}),/* @__PURE__ */n(le,{children:[/* @__PURE__ */e(U,{value:"normal",className:"text-xs",children:"Normal"}),/* @__PURE__ */e(U,{value:"bold",className:"text-xs",children:"Bold"})]})]})]}),/* @__PURE__ */n("div",{className:"flex items-center gap-2",children:[/* @__PURE__ */e(D,{className:"text-xs text-muted-foreground w-20",children:"Color"}),/* @__PURE__ */n(ne,{value:(C==null?void 0:C.color)==="auto"||!(C!=null&&C.color)?"auto":"custom",onValueChange:N=>{N==="auto"&&v("color","auto");},children:[/* @__PURE__ */e(re,{size:"xs",className:"flex-1",children:/* @__PURE__ */e(se,{})}),/* @__PURE__ */n(le,{children:[/* @__PURE__ */e(U,{value:"auto",className:"text-xs",children:"Auto (Smart Contrast)"}),/* @__PURE__ */e(U,{value:"custom",disabled:!0,className:"text-xs",children:"Custom (Coming Soon)"})]})]})]}),/* @__PURE__ */n("div",{className:"flex items-center gap-2",children:[/* @__PURE__ */e(D,{className:"text-xs text-muted-foreground w-20",children:"Rotation"}),/* @__PURE__ */e("div",{className:"flex-1",children:/* @__PURE__ */e(et,{type:"number",placeholder:"0",value:String((C==null?void 0:C.rotation)||0),onSave:N=>v("rotation",Number(N)),className:""})}),/* @__PURE__ */e("span",{className:"text-xs text-muted-foreground",children:"degrees"})]})]})]})]})})]});}function lh(){var c;const t=E(d=>{var l;return(l=d.card)==null?void 0:l.type;}),a=E(d=>{var l;return(l=d.card)==null?void 0:l.preferences;}),{setCardPreferences:s}=me();if(t!=="treemap")return null;const r=((c=a==null?void 0:a.chartOptions)==null?void 0:c.treemapColorMode)??"branch",i=d=>{const l={...(a||{}),chartOptions:{...(a==null?void 0:a.chartOptions),treemapColorMode:d}};s(l);};return/* @__PURE__ */n(Se,{value:"treemap-color-mode",className:"border-none",children:[/* @__PURE__ */e(Te,{className:"flex w-full items-center gap-2 py-3 text-[12px] font-medium hover:no-underline",children:/* @__PURE__ */n("div",{className:"flex items-center gap-2",children:[/* @__PURE__ */e(Kr,{className:"h-4 w-4 text-muted-foreground"}),/* @__PURE__ */e("span",{children:"Treemap Colors"})]})}),/* @__PURE__ */e(ke,{className:"space-y-4 border-t border-border bg-background/50 px-3 py-4 text-sm",children:/* @__PURE__ */n(Cn,{value:r,onValueChange:d=>i(d??"branch"),className:"space-y-3",children:[/* @__PURE__ */n("div",{className:"flex items-start gap-2 rounded-md border border-border px-3 py-2",children:[/* @__PURE__ */e($t,{id:"treemap-color-branch",value:"branch"}),/* @__PURE__ */n(D,{htmlFor:"treemap-color-branch",className:"flex flex-col text-sm font-normal leading-tight",children:[/* @__PURE__ */e("span",{className:"font-medium",children:"Shade by value (default)"}),/* @__PURE__ */e("span",{className:"text-xs text-muted-foreground",children:"Keeps parent hue and adjusts lightness based on the node's share within the branch."})]})]}),/* @__PURE__ */n("div",{className:"flex items-start gap-2 rounded-md border border-border px-3 py-2",children:[/* @__PURE__ */e($t,{id:"treemap-color-category",value:"category"}),/* @__PURE__ */n(D,{htmlFor:"treemap-color-category",className:"flex flex-col text-sm font-normal leading-tight",children:[/* @__PURE__ */e("span",{className:"font-medium",children:"Single color per category"}),/* @__PURE__ */e("span",{className:"text-xs text-muted-foreground",children:"Applies the top-level color to all descendants without lightening/darkening."})]})]})]})})]});}const ih=Object.keys(os);function oh(){const t=E(h=>h.card),a=E(h=>{var m;return(m=h.card)==null?void 0:m.preferences;}),{setCardPreferences:s}=me(),r=(t==null?void 0:t.type)==="heatmap",i=(a==null?void 0:a.heatmapConfig)||{},c=i.colorPalette??"green",d=i.legendPosition??"bottom",l=X(()=>i.colorRange&&i.colorRange[0]&&i.colorRange[1]?[i.colorRange[0],i.colorRange[1]]:[...Sa],[i.colorRange]),o=h=>{const m={...i,...h};m.colorPalette!=="custom"?delete m.colorRange:(!m.colorRange||!m.colorRange[0]||!m.colorRange[1])&&(m.colorRange=[...Sa]),s({...(a||{}),heatmapConfig:m});},x=h=>{o({colorPalette:h,colorRange:h==="custom"?i.colorRange??[...Sa]:void 0});},u=(h,m)=>{const C=[...l];C[h]=m,o({colorPalette:"custom",colorRange:C});},p=h=>{o({legendPosition:h});};return r?/* @__PURE__ */n(Se,{value:"heatmap-color-config",className:"border-none",children:[/* @__PURE__ */e(Te,{className:"flex w-full items-center gap-2 py-3 text-[12px] font-medium hover:no-underline",children:/* @__PURE__ */n("div",{className:"flex items-center gap-2",children:[/* @__PURE__ */e(ea,{className:"h-4 w-4 text-muted-foreground"}),/* @__PURE__ */e("span",{children:"Heatmap Settings"})]})}),/* @__PURE__ */n(ke,{className:"space-y-4 border-t border-border bg-background/50 px-3 py-4 text-sm",children:[/* @__PURE__ */n(Cn,{value:c,onValueChange:h=>x(h??"blue"),className:"space-y-3",children:[ih.map(h=>{const m=os[h];return/* @__PURE__ */n("div",{className:"flex items-center gap-2 rounded-md border border-border px-3 py-2",children:[/* @__PURE__ */e($t,{id:`heatmap-${h}`,value:h}),/* @__PURE__ */n(D,{htmlFor:`heatmap-${h}`,className:"flex w-full flex-col gap-1 text-sm font-normal",children:[/* @__PURE__ */e("span",{className:"font-medium",children:m.label}),/* @__PURE__ */e("span",{className:"h-2 rounded-full",style:{background:`linear-gradient(90deg, ${m.start}, ${m.end})`}})]})]},h);}),/* @__PURE__ */n("div",{className:"flex flex-col gap-2 rounded-md border border-border px-3 py-2",children:[/* @__PURE__ */n("div",{className:"flex items-center gap-2",children:[/* @__PURE__ */e($t,{id:"heatmap-custom",value:"custom"}),/* @__PURE__ */e(D,{htmlFor:"heatmap-custom",className:"text-sm font-medium",children:"Custom colors"})]}),c==="custom"&&/* @__PURE__ */n("div",{className:"flex flex-col gap-2 pl-6",children:[/* @__PURE__ */n("div",{className:"flex items-center gap-2",children:[/* @__PURE__ */e(ja,{value:l[0],onChange:h=>u(0,h??"#000000"),ariaLabel:"Start color",allowEmpty:!1}),/* @__PURE__ */e("span",{className:"text-[11px] text-muted-foreground",children:"Start color"})]}),/* @__PURE__ */n("div",{className:"flex items-center gap-2",children:[/* @__PURE__ */e(ja,{value:l[1],onChange:h=>u(1,h??"#000000"),ariaLabel:"End color",allowEmpty:!1}),/* @__PURE__ */e("span",{className:"text-[11px] text-muted-foreground",children:"End color"})]})]})]})]}),/* @__PURE__ */n("div",{className:"space-y-2",children:[/* @__PURE__ */e(D,{className:"text-xs font-medium",children:"Color scale position"}),/* @__PURE__ */n(ne,{value:d,onValueChange:h=>p(h??"bottom"),children:[/* @__PURE__ */e(re,{size:"xs",children:/* @__PURE__ */e(se,{})}),/* @__PURE__ */e(le,{children:["top","bottom","left","right"].map(h=>/* @__PURE__ */e(U,{value:h,className:"text-xs",children:h[0].toUpperCase()+h.slice(1)},h))})]})]})]})]}):null;}const fr=["poor","satisfactory","good"];function gr(t){if(!t)return;const a={...t};return a.targetMetricKey||delete a.targetMetricKey,a.comparativeMetricKey||delete a.comparativeMetricKey,!a.targetValue&&a.targetValue!==0&&delete a.targetValue,(!a.rangeKeys||Object.keys(a.rangeKeys).length===0)&&delete a.rangeKeys,(!a.ranges||Object.keys(a.ranges).length===0)&&delete a.ranges,(!a.rangeLabels||Object.keys(a.rangeLabels).length===0)&&delete a.rangeLabels,a;}function ch(){var K,M;const t=E(f=>f.card.preferences),a=E(f=>f.card),s=E(f=>f.isDevMode),{setCardPreferences:r,setChartOrientation:i}=me(),c=X(()=>(t==null?void 0:t.bulletConfig)||{},[t==null?void 0:t.bulletConfig]),l=jt(a==null?void 0:a.config)&&!s,[o,x]=Y(c.showRanges??!1),[u,p]=Y(c.rangesArePercentages??!1),h=c.disableAutoComparative?!1:c.comparativeMetricKey!==void 0||!l,[m,C]=Y(h);ve(()=>{x(c.showRanges??!1);},[c.showRanges]),ve(()=>{p(c.rangesArePercentages??!1);},[c.rangesArePercentages]);const S=c.targetValue===void 0?"":String(c.targetValue);ve(()=>{const f=c.disableAutoComparative?!1:c.comparativeMetricKey!==void 0||!l;C(f);},[c.disableAutoComparative,c.comparativeMetricKey,l]);const w=X(()=>{var f,F;return((F=(f=a==null?void 0:a.config)==null?void 0:f.metricColumns)==null?void 0:F.map(g=>{const N=g.label||g.name||g.alias||"";return{value:N,label:N};}))||[];},[(K=a==null?void 0:a.config)==null?void 0:K.metricColumns]);ve(()=>{var R,V;if(!t||w.length===0)return;const f={};let F=!1;const g=(R=w[1])==null?void 0:R.value;!c.targetMetricKey&&g&&(f.targetMetricKey=g,F=!0);const N=(V=w[2])==null?void 0:V.value;!c.comparativeMetricKey&&!c.disableAutoComparative&&N&&(f.comparativeMetricKey=N,F=!0);const T=w.slice(3),_={...(c.rangeKeys||{})};let P=!1;if(fr.forEach((Q,J)=>{!_[Q]&&T[J]&&(_[Q]=T[J].value,P=!0);}),P&&(f.rangeKeys=_,F=!0,c.showRanges===void 0&&(f.showRanges=!0)),F){const Q=gr({...c,...f});r({...t,bulletConfig:Q});}},[w,c,t,r]);const v=f=>{const F=gr({...c,...f});r({...t,bulletConfig:F});},y=(f,F)=>{const g={...(c.rangeKeys||{}),[f]:F.trim()};F.trim()||delete g[f],v({rangeKeys:Object.keys(g).length>0?g:void 0});},A=(f,F)=>{const g=F===""?void 0:Number(F),N={...(c.ranges||{})};g===void 0||Number.isNaN(g)?delete N[f]:N[f]=g,v({ranges:Object.keys(N).length?N:void 0});},b=f=>{if(f===""){v({targetValue:void 0});return;}const F=Number(f);v({targetValue:Number.isNaN(F)?void 0:F});},z=(f,F)=>{const g=F.trim(),N={...(c.rangeLabels||{})};g?N[f]=g:delete N[f],v({rangeLabels:Object.keys(N).length>0?N:void 0});},B=f=>{x(f),v({showRanges:f});},j=f=>{p(f),v({rangesArePercentages:f});},$=c.orientation||(((M=t==null?void 0:t.chartOptions)==null?void 0:M.indexAxis)==="y"?"horizontal":"vertical"),I=f=>{v({orientation:f}),i(f==="horizontal"?"y":"x");},O=[{value:"__none",label:"None"},...w.map(f=>({value:f.value,label:f.label}))],L=O,k=f=>{if(C(f),!f){v({comparativeMetricKey:void 0,disableAutoComparative:!0});return;}if(!l){v({disableAutoComparative:!1});return;}if(c.comparativeMetricKey)v({disableAutoComparative:!1});else{const F=w.find(g=>g.value!==c.targetMetricKey);v({comparativeMetricKey:F==null?void 0:F.value,disableAutoComparative:!1});}};return/* @__PURE__ */n(Se,{value:"bullet-config",className:"border-b-0",children:[/* @__PURE__ */e(Te,{className:"flex w-full items-center gap-2 py-2 text-[12px] font-medium hover:no-underline",children:/* @__PURE__ */n("div",{className:"flex items-center gap-2",children:[/* @__PURE__ */e(zr,{className:"h-4 w-4 text-muted-foreground"}),/* @__PURE__ */e("span",{children:"Bullet Chart"})]})}),/* @__PURE__ */n(ke,{className:"space-y-6 border-t border-border/50 py-4",children:[/* @__PURE__ */n("section",{className:"space-y-4",children:[/* @__PURE__ */n("div",{className:"space-y-1.5",children:[/* @__PURE__ */e(D,{className:"text-xs font-medium",children:"ORIENTATION"}),/* @__PURE__ */n(ne,{value:$,onValueChange:f=>I(f),children:[/* @__PURE__ */e(re,{size:"xs",children:/* @__PURE__ */e(se,{})}),/* @__PURE__ */n(le,{children:[/* @__PURE__ */e(U,{value:"horizontal",className:"text-xs",children:"Horizontal"}),/* @__PURE__ */e(U,{value:"vertical",className:"text-xs",children:"Vertical"})]})]})]}),l&&/* @__PURE__ */n("div",{className:"space-y-1.5",children:[/* @__PURE__ */e(D,{className:"text-xs font-medium",children:"TARGET METRIC"}),/* @__PURE__ */n(ne,{value:c.targetMetricKey||"__none",onValueChange:f=>v({targetMetricKey:f==="__none"?void 0:f}),children:[/* @__PURE__ */e(re,{size:"xs",children:/* @__PURE__ */e(se,{placeholder:"Select metric"})}),/* @__PURE__ */n(le,{children:[/* @__PURE__ */e(U,{value:"__none",className:"text-xs",children:"None"}),w.map(f=>/* @__PURE__ */e(U,{value:f.value,className:"text-xs",children:f.label},f.value))]})]})]}),/* @__PURE__ */n("div",{className:"space-y-1.5",children:[/* @__PURE__ */e(D,{className:"text-xs font-medium",children:"COMPARATIVE METRIC"}),l?/* @__PURE__ */n(ne,{value:c.comparativeMetricKey||"__none",onValueChange:f=>v({comparativeMetricKey:f==="__none"?void 0:f,disableAutoComparative:f==="__none"}),children:[/* @__PURE__ */e(re,{size:"xs",children:/* @__PURE__ */e(se,{placeholder:"Select metric"})}),/* @__PURE__ */e(le,{children:O.map(f=>/* @__PURE__ */e(U,{value:f.value,className:"text-xs",children:f.label},f.value))})]}):/* @__PURE__ */n("div",{className:"space-y-2 rounded-md border border-border/50 p-3 text-xs",children:[/* @__PURE__ */n("div",{className:"flex items-center justify-between font-medium",children:[/* @__PURE__ */e("span",{children:"Show comparative"}),/* @__PURE__ */e(we,{size:"sm",checked:m,onCheckedChange:f=>k(f)})]}),/* @__PURE__ */e("p",{className:"text-[11px] text-muted-foreground",children:"Comparative values are auto-detected from the third metric in your results."})]})]}),/* @__PURE__ */n("div",{className:"space-y-1.5",children:[/* @__PURE__ */e(D,{className:"text-xs font-medium",children:"TARGET VALUE (FALLBACK)"}),/* @__PURE__ */e(Ke,{type:"number",className:"h-8 text-xs",value:S,onCommit:b,placeholder:"Optional numeric fallback"})]})]}),/* @__PURE__ */n("section",{className:"space-y-4 rounded-md border border-border/60 p-3",children:[/* @__PURE__ */n("div",{className:"space-y-3",children:[/* @__PURE__ */n("div",{className:"flex items-center justify-between gap-2",children:[/* @__PURE__ */n("div",{className:"flex items-center gap-2",children:[/* @__PURE__ */e(D,{className:"text-xs font-medium",children:"QUALITATIVE RANGES"}),/* @__PURE__ */e(Lt,{children:/* @__PURE__ */n(mt,{delayDuration:200,children:[/* @__PURE__ */e(ht,{asChild:!0,children:/* @__PURE__ */e("button",{type:"button",className:"text-muted-foreground transition-colors hover:text-foreground",children:/* @__PURE__ */e(ut,{className:"h-3.5 w-3.5"})})}),/* @__PURE__ */e(pt,{side:"top",children:"Use columns or static values for Poor / Average / Good."})]})})]}),/* @__PURE__ */e("div",{className:"flex items-center gap-2 text-xs font-medium",children:/* @__PURE__ */e(we,{size:"sm",checked:o,onCheckedChange:B})})]}),/* @__PURE__ */n("div",{className:"flex items-center gap-2 text-xs font-medium",children:[/* @__PURE__ */e("input",{type:"checkbox",checked:u,disabled:!o,onChange:f=>j(f.target.checked),className:"h-3.5 w-3.5 accent-primary disabled:opacity-50"}),/* @__PURE__ */e("span",{children:"Use % of value"})]})]}),o&&/* @__PURE__ */e("div",{className:"space-y-3",children:fr.map(f=>{var F,g,N,T,_;return/* @__PURE__ */n("div",{className:"space-y-2 rounded-md border border-border/60 bg-muted/40 p-3",children:[/* @__PURE__ */n("div",{className:"space-y-1.5",children:[/* @__PURE__ */n(D,{className:"text-[11px] font-medium uppercase tracking-wide",children:[f," LABEL"]}),/* @__PURE__ */e(Ke,{placeholder:`Display label (${f})`,value:((F=c.rangeLabels)==null?void 0:F[f])||"",onCommit:P=>z(f,P),className:"h-8 text-xs"})]}),l?/* @__PURE__ */n("div",{className:"space-y-1.5",children:[/* @__PURE__ */n(D,{className:"text-[11px] font-medium uppercase tracking-wide",children:[f," COLUMN"]}),/* @__PURE__ */n(ne,{value:((g=c.rangeKeys)==null?void 0:g[f])||"__none",onValueChange:P=>{P==="__none"?y(f,""):y(f,P);},children:[/* @__PURE__ */e(re,{size:"xs",children:/* @__PURE__ */e(se,{placeholder:"Select column"})}),/* @__PURE__ */e(le,{children:L.map(P=>/* @__PURE__ */e(U,{value:P.value,className:"text-xs",children:P.label},P.value))})]})]}):/* @__PURE__ */n("div",{className:"space-y-1.5",children:[/* @__PURE__ */n(D,{className:"text-[11px] font-medium uppercase tracking-wide",children:[f," COLUMN KEY"]}),/* @__PURE__ */e(Ke,{placeholder:"Column key",value:((N=c.rangeKeys)==null?void 0:N[f])||"",onCommit:P=>y(f,P),className:"h-8 text-xs"})]}),/* @__PURE__ */n("div",{className:"space-y-1.5",children:[/* @__PURE__ */n(D,{className:"text-[11px] font-medium uppercase tracking-wide",children:[f," VALUE"]}),/* @__PURE__ */e(Ke,{type:"number",placeholder:u?"0.80":"Static value",value:((T=c.ranges)==null?void 0:T[f])===void 0?"":String((_=c.ranges)==null?void 0:_[f]),onCommit:P=>A(f,P),className:"h-8 text-xs"})]})]},f);})})]})]})]});}function xr(t){if(!t)return;const a={...t};if(a.xMetricKey||delete a.xMetricKey,a.yMetricKey||delete a.yMetricKey,a.radiusMetricKey||delete a.radiusMetricKey,a.labelKey||delete a.labelKey,a.groupKey||delete a.groupKey,a.enableGrouping===void 0&&delete a.enableGrouping,a.radiusScale||delete a.radiusScale,a.fixedRadius===void 0&&delete a.fixedRadius,a.minRadius===void 0&&delete a.minRadius,a.maxRadius===void 0&&delete a.maxRadius,Object.keys(a).length!==0)return a;}function dh(){var z,B,j,$,I,O,L,k,K,M,f,F;const t=E(g=>g.card.preferences),a=E(g=>g.card),s=Be(),r=E(g=>g.isDevMode),{setCardPreferences:i,updateCardInFrame:c}=me(),d=s==="bubble",l=s==="scatter",o=X(()=>(t==null?void 0:t.bubbleScatterConfig)||{},[t==null?void 0:t.bubbleScatterConfig]),u=jt(a==null?void 0:a.config)&&!r,p=X(()=>{var g,N;return((N=(g=a==null?void 0:a.config)==null?void 0:g.metricColumns)==null?void 0:N.map(T=>{const _=T.label||T.name||T.alias||"";return{value:_,label:_};}))||[];},[(z=a==null?void 0:a.config)==null?void 0:z.metricColumns]),h=X(()=>{var g,N;return((N=(g=a==null?void 0:a.config)==null?void 0:g.groupByColumns)==null?void 0:N.map(T=>{const _=T.label||T.name||T.alias||"";return{value:_,label:_};}))||[];},[(B=a==null?void 0:a.config)==null?void 0:B.groupByColumns]),m=X(()=>o.enableGrouping!==void 0?o.enableGrouping:!r&&h.length>=2,[o.enableGrouping,r,h.length]),[C,S]=Y(m);ve(()=>{S(m);},[m]);const w=g=>{const N={...(t||{}),bubbleScatterConfig:g};i(N),a&&c({...a,preferences:N});},v=g=>{i(g),a&&c({...a,preferences:g});};ve(()=>{if(!t||p.length===0)return;const g={};let N=!1;if(!o.xMetricKey&&p[0]&&(g.xMetricKey=p[0].value,N=!0),!o.yMetricKey&&p[1]&&(g.yMetricKey=p[1].value,N=!0),d&&!o.radiusMetricKey&&p[2]&&(g.radiusMetricKey=p[2].value,N=!0),!o.labelKey&&h[0]&&(g.labelKey=h[0].value,N=!0),m&&!o.groupKey&&h[1]&&(g.groupKey=h[1].value,g.enableGrouping=!0,N=!0),N){const T=xr({...o,...g});w(T);}},[p,h,o,t,i,d,m]);const y=g=>{const N=xr({...o,...g});w(N);},A=g=>{S(g),y({enableGrouping:g,groupKey:g?o.groupKey:void 0});};return!d&&!l?null:/* @__PURE__ */n(Se,{value:"bubble-scatter-config",children:[/* @__PURE__ */e(Te,{className:"flex w-full items-center gap-2 py-2 text-[12px] font-medium hover:no-underline",children:/* @__PURE__ */n("div",{className:"flex items-center gap-2",children:[/* @__PURE__ */e(d?Jc:qr,{className:"h-3.5 w-3.5 text-foreground/60"}),/* @__PURE__ */n("span",{children:[d?"Bubble":"Scatter"," Configuration"]})]})}),/* @__PURE__ */n(ke,{className:"space-y-4 px-1 pb-4",children:[/* @__PURE__ */n("div",{className:"space-y-3",children:[/* @__PURE__ */n("div",{className:"flex items-center gap-1 text-xs font-medium text-muted-foreground",children:["Dimensions",/* @__PURE__ */e(Lt,{children:/* @__PURE__ */n(mt,{children:[/* @__PURE__ */e(ht,{children:/* @__PURE__ */e(ut,{className:"h-3 w-3"})}),/* @__PURE__ */e(pt,{side:"right",className:"max-w-xs",children:/* @__PURE__ */e("p",{children:"Label identifies each point. Group creates separate series in the legend."})})]})})]}),/* @__PURE__ */n("div",{className:"space-y-1",children:[/* @__PURE__ */e(D,{className:"text-xs",children:"Label Column"}),u?/* @__PURE__ */n(ne,{value:o.labelKey||"",onValueChange:g=>y({labelKey:g}),children:[/* @__PURE__ */e(re,{size:"xs",children:/* @__PURE__ */e(se,{placeholder:"Select label column"})}),/* @__PURE__ */e(le,{children:h.map(g=>/* @__PURE__ */e(U,{value:g.value,children:g.label},g.value))})]}):/* @__PURE__ */e(Ke,{className:"h-8 text-xs",placeholder:"Column name for labels",value:o.labelKey||"",onCommit:g=>y({labelKey:g})})]}),/* @__PURE__ */n("div",{className:"flex items-center justify-between",children:[/* @__PURE__ */e(D,{className:"text-xs",children:"Group points into series"}),/* @__PURE__ */e(we,{size:"sm",checked:C,onCheckedChange:A})]}),C&&/* @__PURE__ */n("div",{className:"space-y-1",children:[/* @__PURE__ */e(D,{className:"text-xs",children:"Group By"}),u?/* @__PURE__ */n(ne,{value:o.groupKey||"",onValueChange:g=>y({groupKey:g}),children:[/* @__PURE__ */e(re,{size:"xs",children:/* @__PURE__ */e(se,{placeholder:"Select group column"})}),/* @__PURE__ */e(le,{children:h.map(g=>/* @__PURE__ */e(U,{value:g.value,children:g.label},g.value))})]}):/* @__PURE__ */e(Ke,{className:"h-8 text-xs",placeholder:"Column name for grouping",value:o.groupKey||"",onCommit:g=>y({groupKey:g})})]})]}),/* @__PURE__ */n("div",{className:"space-y-3",children:[/* @__PURE__ */e("div",{className:"text-xs font-medium text-muted-foreground",children:"Metrics"}),/* @__PURE__ */n("div",{className:"space-y-1",children:[/* @__PURE__ */e(D,{className:"text-xs",children:"X Axis"}),u?/* @__PURE__ */n(ne,{value:o.xMetricKey||"",onValueChange:g=>y({xMetricKey:g}),children:[/* @__PURE__ */e(re,{size:"xs",children:/* @__PURE__ */e(se,{placeholder:"Select X metric"})}),/* @__PURE__ */e(le,{children:p.map(g=>/* @__PURE__ */e(U,{value:g.value,children:g.label},g.value))})]}):/* @__PURE__ */e(Ke,{className:"h-8 text-xs",placeholder:"Column name for X axis",value:o.xMetricKey||"",onCommit:g=>y({xMetricKey:g})})]}),/* @__PURE__ */n("div",{className:"space-y-1",children:[/* @__PURE__ */e(D,{className:"text-xs",children:"Y Axis"}),u?/* @__PURE__ */n(ne,{value:o.yMetricKey||"",onValueChange:g=>y({yMetricKey:g}),children:[/* @__PURE__ */e(re,{size:"xs",children:/* @__PURE__ */e(se,{placeholder:"Select Y metric"})}),/* @__PURE__ */e(le,{children:p.map(g=>/* @__PURE__ */e(U,{value:g.value,children:g.label},g.value))})]}):/* @__PURE__ */e(Ke,{className:"h-8 text-xs",placeholder:"Column name for Y axis",value:o.yMetricKey||"",onCommit:g=>y({yMetricKey:g})})]}),d&&/* @__PURE__ */n("div",{className:"space-y-1",children:[/* @__PURE__ */e(D,{className:"text-xs",children:"Radius"}),u?/* @__PURE__ */n(ne,{value:o.radiusMetricKey||"",onValueChange:g=>y({radiusMetricKey:g}),children:[/* @__PURE__ */e(re,{size:"xs",children:/* @__PURE__ */e(se,{placeholder:"Select radius metric"})}),/* @__PURE__ */e(le,{children:p.map(g=>/* @__PURE__ */e(U,{value:g.value,children:g.label},g.value))})]}):/* @__PURE__ */e(Ke,{className:"h-8 text-xs",placeholder:"Column name for radius",value:o.radiusMetricKey||"",onCommit:g=>y({radiusMetricKey:g})})]})]}),d&&/* @__PURE__ */n("div",{className:"space-y-3",children:[/* @__PURE__ */e("div",{className:"text-xs font-medium text-muted-foreground",children:"Radius Settings"}),/* @__PURE__ */n("div",{className:"space-y-1",children:[/* @__PURE__ */e(D,{className:"text-xs",children:"Scale Mode"}),/* @__PURE__ */n(ne,{value:o.radiusScale||"sqrt",onValueChange:g=>y({radiusScale:g}),children:[/* @__PURE__ */e(re,{size:"xs",children:/* @__PURE__ */e(se,{})}),/* @__PURE__ */n(le,{children:[/* @__PURE__ */e(U,{value:"sqrt",children:"Square Root (area-proportional)"}),/* @__PURE__ */e(U,{value:"linear",children:"Linear"}),/* @__PURE__ */e(U,{value:"fixed",children:"Fixed Size"})]})]})]}),o.radiusScale!=="fixed"&&/* @__PURE__ */n("div",{className:"grid grid-cols-2 gap-2",children:[/* @__PURE__ */n("div",{className:"space-y-1",children:[/* @__PURE__ */e(D,{className:"text-xs",children:"Min Radius"}),/* @__PURE__ */e(Ke,{className:"h-8 text-xs",type:"number",placeholder:"5",value:((j=o.minRadius)==null?void 0:j.toString())||"",onCommit:g=>y({minRadius:g?Number(g):void 0})})]}),/* @__PURE__ */n("div",{className:"space-y-1",children:[/* @__PURE__ */e(D,{className:"text-xs",children:"Max Radius"}),/* @__PURE__ */e(Ke,{className:"h-8 text-xs",type:"number",placeholder:"30",value:(($=o.maxRadius)==null?void 0:$.toString())||"",onCommit:g=>y({maxRadius:g?Number(g):void 0})})]})]}),o.radiusScale==="fixed"&&/* @__PURE__ */n("div",{className:"space-y-1",children:[/* @__PURE__ */n(D,{className:"text-xs",children:["Fixed Radius: ",o.fixedRadius||10]}),/* @__PURE__ */e(Yt,{value:[o.fixedRadius||10],onValueChange:([g])=>y({fixedRadius:g}),min:3,max:30,step:1,className:"py-2"})]})]}),l&&/* @__PURE__ */n("div",{className:"space-y-3",children:[/* @__PURE__ */e("div",{className:"text-xs font-medium text-muted-foreground",children:"Point Settings"}),/* @__PURE__ */n("div",{className:"space-y-1",children:[/* @__PURE__ */n(D,{className:"text-xs",children:["Point Size: ",o.fixedRadius||5]}),/* @__PURE__ */e(Yt,{value:[o.fixedRadius||5],onValueChange:([g])=>y({fixedRadius:g}),min:2,max:15,step:1,className:"py-2"})]})]}),/* @__PURE__ */n("div",{className:"space-y-3",children:[/* @__PURE__ */n("div",{className:"flex items-center justify-between",children:[/* @__PURE__ */e("span",{className:"text-xs font-medium text-muted-foreground",children:"Axis Titles"}),/* @__PURE__ */e(we,{size:"sm",checked:((O=(I=t==null?void 0:t.xAxisConfig)==null?void 0:I.name)==null?void 0:O.enabled)??!1,onCheckedChange:g=>{var _,P,R,V;const N=o.xMetricKey||"X Axis",T=o.yMetricKey||"Y Axis";v({...(t??{}),xAxisConfig:{...(t==null?void 0:t.xAxisConfig),name:{enabled:g,text:((P=(_=t==null?void 0:t.xAxisConfig)==null?void 0:_.name)==null?void 0:P.text)||N}},yAxisConfig:{...(t==null?void 0:t.yAxisConfig),name:{enabled:g,text:((V=(R=t==null?void 0:t.yAxisConfig)==null?void 0:R.name)==null?void 0:V.text)||T}}});}})]}),((k=(L=t==null?void 0:t.xAxisConfig)==null?void 0:L.name)==null?void 0:k.enabled)&&/* @__PURE__ */n("div",{className:"grid grid-cols-2 gap-2",children:[/* @__PURE__ */n("div",{className:"space-y-1",children:[/* @__PURE__ */e(D,{className:"text-xs",children:"X Title"}),/* @__PURE__ */e(Ke,{className:"h-8 text-xs",placeholder:o.xMetricKey||"X Axis",value:((M=(K=t==null?void 0:t.xAxisConfig)==null?void 0:K.name)==null?void 0:M.text)||"",onCommit:g=>{var N;v({...(t??{}),xAxisConfig:{...(t==null?void 0:t.xAxisConfig),name:{...((N=t==null?void 0:t.xAxisConfig)==null?void 0:N.name),enabled:!0,text:g||o.xMetricKey||"X Axis"}}});}})]}),/* @__PURE__ */n("div",{className:"space-y-1",children:[/* @__PURE__ */e(D,{className:"text-xs",children:"Y Title"}),/* @__PURE__ */e(Ke,{className:"h-8 text-xs",placeholder:o.yMetricKey||"Y Axis",value:((F=(f=t==null?void 0:t.yAxisConfig)==null?void 0:f.name)==null?void 0:F.text)||"",onCommit:g=>{var N;v({...(t??{}),yAxisConfig:{...(t==null?void 0:t.yAxisConfig),name:{...((N=t==null?void 0:t.yAxisConfig)==null?void 0:N.name),enabled:!0,text:g||o.yMetricKey||"Y Axis"}}});}})]})]})]})]})]});}const uh=[{value:"percentOfTotal",label:"% of Total",description:"Each stage shows percentage of the sum of all values"},{value:"percentOfFirst",label:"% of Stage 1",description:"First stage = 100%, others relative to first stage"}];function mh(){const t=E(h=>h.card),a=E(h=>{var m;return(m=h.card)==null?void 0:m.preferences;}),{setCardPreferences:s}=me(),r=(t==null?void 0:t.type)==="funnel",i=(a==null?void 0:a.funnelConfig)||{},c=i.percentMode??"percentOfTotal",d=i.shrinkFraction??1,l=i.labelThreshold??0,o=h=>{const m={...i,...h};s({...(a||{}),funnelConfig:m});},x=h=>{o({percentMode:h});},u=h=>{o({shrinkFraction:h[0]});},p=h=>{o({labelThreshold:h[0]});};return r?/* @__PURE__ */n(Se,{value:"funnel-config",className:"border-none",children:[/* @__PURE__ */e(Te,{className:"flex w-full items-center gap-2 py-3 text-[12px] font-medium hover:no-underline",children:/* @__PURE__ */n("div",{className:"flex items-center gap-2",children:[/* @__PURE__ */e(xa,{className:"h-4 w-4 text-muted-foreground"}),/* @__PURE__ */e("span",{children:"Funnel Settings"})]})}),/* @__PURE__ */n(ke,{className:"space-y-4 border-t border-border bg-background/50 px-3 py-4 text-sm",children:[/* @__PURE__ */n("div",{className:"space-y-2",children:[/* @__PURE__ */e(D,{className:"text-xs font-medium",children:"PERCENTAGE MODE"}),/* @__PURE__ */e(Cn,{value:c,onValueChange:h=>x(h),className:"space-y-2",children:uh.map(h=>/* @__PURE__ */n("div",{className:"flex items-start gap-2 rounded-md border border-border px-3 py-2",children:[/* @__PURE__ */e($t,{id:`funnel-${h.value}`,value:h.value,className:"mt-0.5"}),/* @__PURE__ */n(D,{htmlFor:`funnel-${h.value}`,className:"flex flex-col gap-0.5 text-sm font-normal",children:[/* @__PURE__ */e("span",{className:"font-medium",children:h.label}),/* @__PURE__ */e("span",{className:"text-xs text-muted-foreground",children:h.description})]})]},h.value))})]}),/* @__PURE__ */n("div",{className:"space-y-2",children:[/* @__PURE__ */e(D,{className:"text-xs font-medium",children:"SEGMENT SHRINK"}),/* @__PURE__ */n("div",{className:"flex items-center gap-3 pt-1",children:[/* @__PURE__ */e("span",{className:"whitespace-nowrap text-xs text-muted-foreground",children:"Same Width"}),/* @__PURE__ */e(Yt,{value:[d],onValueChange:u,min:0,max:1,step:0.1,className:"flex-1"}),/* @__PURE__ */e("span",{className:"whitespace-nowrap text-xs text-muted-foreground",children:"Full Shrink"})]}),/* @__PURE__ */n("p",{className:"text-center text-xs text-muted-foreground",children:["Current: ",Math.round(d*100),"%"]})]}),/* @__PURE__ */n("div",{className:"space-y-2",children:[/* @__PURE__ */e(D,{className:"text-xs font-medium",children:"LABEL VISIBILITY THRESHOLD"}),/* @__PURE__ */n("div",{className:"flex items-center gap-3 pt-1",children:[/* @__PURE__ */e("span",{className:"whitespace-nowrap text-xs text-muted-foreground",children:"Show All"}),/* @__PURE__ */e(Yt,{value:[l],onValueChange:p,min:0,max:25,step:1,className:"flex-1"}),/* @__PURE__ */e("span",{className:"whitespace-nowrap text-xs text-muted-foreground",children:"Hide Small"})]}),/* @__PURE__ */e("p",{className:"text-center text-xs text-muted-foreground",children:l===0?"Showing all labels":`Hide labels below ${l}%`})]})]})]}):null;}const hh=[{value:"USD",label:"USD - US Dollar"},{value:"EUR",label:"EUR - Euro"},{value:"GBP",label:"GBP - British Pound"},{value:"JPY",label:"JPY - Japanese Yen"},{value:"CNY",label:"CNY - Chinese Yuan"},{value:"INR",label:"INR - Indian Rupee"},{value:"CAD",label:"CAD - Canadian Dollar"},{value:"AUD",label:"AUD - Australian Dollar"}],ph=[{value:"en-US",label:"English (US)"},{value:"en-GB",label:"English (UK)"},{value:"de-DE",label:"German"},{value:"fr-FR",label:"French"},{value:"es-ES",label:"Spanish"},{value:"it-IT",label:"Italian"},{value:"pt-BR",label:"Portuguese (Brazil)"},{value:"zh-CN",label:"Chinese (Simplified)"}],fh=["center","start","end"],gh=["center","start","end","top","bottom"];function va({config:t,onChange:a,isHorizontal:s=!1,showAutoFormat:r=!0,positionOptions:i,showAppearance:c=!0}){var C,S,w,v,y,A;const d=i??(s?["auto","center","left","right","custom"]:["auto","center","top","bottom","custom"]),l=r?["auto","number","currency","percent","none"]:["number","currency","percent","none"],o=(b,z)=>{const B={...t,[b]:z};a(B);},x=(b,z)=>{const B={...t,font:{...((t==null?void 0:t.font)||{}),[b]:z}};a(B);},u=(b,z)=>{const B={...t,formatOptions:{...((t==null?void 0:t.formatOptions)||{}),[b]:z}};a(B);},p=()=>s?"Right":"Top",h=t||{},m=h.format||(r?"auto":"number");return/* @__PURE__ */n("div",{className:"space-y-3",children:[/* @__PURE__ */n("div",{className:"space-y-1.5",children:[/* @__PURE__ */e(D,{className:"text-xs text-muted-foreground",children:"Position"}),/* @__PURE__ */n(ne,{value:h.position||"auto",onValueChange:b=>o("position",b),children:[/* @__PURE__ */e(re,{size:"xs",children:/* @__PURE__ */e(se,{})}),/* @__PURE__ */e(le,{children:d.map(b=>/* @__PURE__ */e(U,{value:b,className:"text-xs",children:b==="auto"?p():b==="custom"?"Custom (Advanced)":We(b)},b))})]})]}),h.position==="custom"&&/* @__PURE__ */n("div",{className:"space-y-2 rounded-md border border-border bg-background p-2",children:[/* @__PURE__ */n("div",{className:"flex items-center justify-between",children:[/* @__PURE__ */e(D,{className:"text-xs",children:"Anchor"}),/* @__PURE__ */n(ne,{value:h.anchor||"center",onValueChange:b=>o("anchor",b),children:[/* @__PURE__ */e(re,{size:"xs",className:"w-24",children:/* @__PURE__ */e(se,{})}),/* @__PURE__ */e(le,{children:fh.map(b=>/* @__PURE__ */e(U,{value:b,className:"text-xs",children:We(b)},b))})]})]}),/* @__PURE__ */n("div",{className:"flex items-center justify-between",children:[/* @__PURE__ */e(D,{className:"text-xs",children:"Align"}),/* @__PURE__ */n(ne,{value:String(h.align||"center"),onValueChange:b=>o("align",b),children:[/* @__PURE__ */e(re,{size:"xs",className:"w-24",children:/* @__PURE__ */e(se,{})}),/* @__PURE__ */e(le,{children:gh.map(b=>/* @__PURE__ */e(U,{value:b,className:"text-xs",children:We(b)},b))})]})]})]}),/* @__PURE__ */n("div",{className:"space-y-1.5",children:[/* @__PURE__ */e(D,{className:"text-xs text-muted-foreground",children:"Format"}),/* @__PURE__ */n(ne,{value:m,onValueChange:b=>o("format",b),children:[/* @__PURE__ */e(re,{size:"xs",children:/* @__PURE__ */e(se,{})}),/* @__PURE__ */e(le,{children:l.map(b=>/* @__PURE__ */e(U,{value:b,className:"text-xs",children:b==="auto"&&r?"Auto (Use Axis)":b==="none"?"None (Raw Value)":We(b)},b))})]})]}),!["auto","none"].includes(m)&&/* @__PURE__ */n("div",{className:"space-y-2 rounded-md border border-border bg-background p-2",children:[["number","currency","percent"].includes(m)&&/* @__PURE__ */n("div",{className:"flex items-center justify-between",children:[/* @__PURE__ */e(D,{className:"text-xs",children:"Decimals"}),/* @__PURE__ */e("div",{className:"w-16",children:/* @__PURE__ */e(et,{type:"number",placeholder:"0",value:String(((C=h.formatOptions)==null?void 0:C.decimalPlaces)??(m==="currency"?2:m==="percent"?1:0)),onSave:b=>u("decimalPlaces",Number(b)),className:""})})]}),m==="currency"&&/* @__PURE__ */n("div",{className:"flex items-center justify-between",children:[/* @__PURE__ */e(D,{className:"text-xs",children:"Currency"}),/* @__PURE__ */n(ne,{value:((S=h.formatOptions)==null?void 0:S.currency)||"USD",onValueChange:b=>u("currency",b),children:[/* @__PURE__ */e(re,{size:"xs",className:"w-28",children:/* @__PURE__ */e(se,{})}),/* @__PURE__ */e(le,{children:hh.map(b=>/* @__PURE__ */e(U,{value:b.value,className:"text-xs",children:b.label},b.value))})]})]}),["number","currency"].includes(m)&&/* @__PURE__ */n("div",{className:"flex items-center justify-between",children:[/* @__PURE__ */e(D,{className:"text-xs",children:"Abbreviate (K, M, B)"}),/* @__PURE__ */e(we,{size:"sm",checked:((w=h.formatOptions)==null?void 0:w.useSuffix)??!1,onCheckedChange:b=>u("useSuffix",b)})]}),/* @__PURE__ */n("div",{className:"flex items-center justify-between",children:[/* @__PURE__ */e(D,{className:"text-xs",children:"Locale"}),/* @__PURE__ */n(ne,{value:((v=h.formatOptions)==null?void 0:v.locale)||"en-US",onValueChange:b=>u("locale",b),children:[/* @__PURE__ */e(re,{size:"xs",className:"w-28",children:/* @__PURE__ */e(se,{})}),/* @__PURE__ */e(le,{children:ph.map(b=>/* @__PURE__ */e(U,{value:b.value,className:"text-xs",children:b.label},b.value))})]})]})]}),c&&/* @__PURE__ */n("div",{className:"space-y-2",children:[/* @__PURE__ */e(D,{className:"text-xs text-muted-foreground",children:"Appearance"}),/* @__PURE__ */n("div",{className:"space-y-2 rounded-md border border-border bg-background p-2",children:[/* @__PURE__ */n("div",{className:"flex items-center justify-between",children:[/* @__PURE__ */e(D,{className:"text-xs",children:"Size"}),/* @__PURE__ */e("div",{className:"w-16",children:/* @__PURE__ */e(et,{type:"number",placeholder:"12",value:String(((y=h.font)==null?void 0:y.size)||12),onSave:b=>x("size",Number(b)),className:""})})]}),/* @__PURE__ */n("div",{className:"flex items-center justify-between",children:[/* @__PURE__ */e(D,{className:"text-xs",children:"Weight"}),/* @__PURE__ */n(ne,{value:((A=h.font)==null?void 0:A.weight)||"normal",onValueChange:b=>x("weight",b),children:[/* @__PURE__ */e(re,{size:"xs",className:"w-24",children:/* @__PURE__ */e(se,{})}),/* @__PURE__ */n(le,{children:[/* @__PURE__ */e(U,{value:"normal",className:"text-xs",children:"Normal"}),/* @__PURE__ */e(U,{value:"bold",className:"text-xs",children:"Bold"})]})]})]}),/* @__PURE__ */n("div",{className:"flex items-center justify-between",children:[/* @__PURE__ */e(D,{className:"text-xs",children:"Color"}),/* @__PURE__ */n(ne,{value:h.color==="auto"||!h.color?"auto":"custom",onValueChange:b=>{b==="auto"&&o("color","auto");},children:[/* @__PURE__ */e(re,{size:"xs",className:"w-28",children:/* @__PURE__ */e(se,{})}),/* @__PURE__ */n(le,{children:[/* @__PURE__ */e(U,{value:"auto",className:"text-xs",children:"Auto (Contrast)"}),/* @__PURE__ */e(U,{value:"custom",disabled:!0,className:"text-xs",children:"Custom"})]})]})]}),/* @__PURE__ */n("div",{className:"flex items-center justify-between",children:[/* @__PURE__ */e(D,{className:"text-xs",children:"Rotation"}),/* @__PURE__ */n("div",{className:"flex items-center gap-1",children:[/* @__PURE__ */e("div",{className:"w-12",children:/* @__PURE__ */e(et,{type:"number",placeholder:"0",value:String(h.rotation||0),onSave:b=>o("rotation",Number(b)),className:""})}),/* @__PURE__ */e("span",{className:"text-xs text-muted-foreground",children:"°"})]})]})]})]})]});}const xh=[{type:"bar",icon:hn,label:"Bar"},{type:"line",icon:mn,label:"Line"}],bh=[0,1,2,3,4,5,6,8,10],vh=[{value:"circle",label:"Circle ●"},{value:"rect",label:"Square ■"},{value:"rectRounded",label:"Rounded ▢"},{value:"rectRot",label:"Diamond ◆"},{value:"triangle",label:"Triangle ▲"},{value:"cross",label:"Cross +"},{value:"crossRot",label:"X ×"},{value:"star",label:"Star ★"},{value:"dash",label:"Dash —"},{value:"line",label:"Line │"}],yh=[{value:"solid",label:"Solid ───"},{value:"dashed",label:"Dashed - - -"},{value:"dotted",label:"Dotted ···"},{value:"dash-dot",label:"Dash-Dot -·-·"}];function Nh(){return E(a=>{var s;return(s=a.card)==null?void 0:s.type;})!=="combo"?null:/* @__PURE__ */n(Se,{value:"combo-series",className:"border-b-0",children:[/* @__PURE__ */e(Te,{className:"flex w-full items-center gap-2 py-2 text-[12px] font-medium hover:no-underline",children:/* @__PURE__ */n("div",{className:"flex items-center gap-2",children:[/* @__PURE__ */e(la,{className:"h-4 w-4 text-muted-foreground"}),/* @__PURE__ */e("span",{children:"Series"})]})}),/* @__PURE__ */e(ke,{className:"pt-2",children:/* @__PURE__ */e(Ch,{})})]});}function Ch(){const{transformedMetricKeys:t}=ba();return t.length===0?/* @__PURE__ */e("div",{className:"rounded-lg border border-dashed border-border p-4 text-center text-xs text-muted-foreground",children:"Add metrics to configure series"}):/* @__PURE__ */e("div",{className:"space-y-3",children:t.map((a,s)=>/* @__PURE__ */e(wh,{metricKey:a,idx:s},a))});}function wh({metricKey:t,idx:a}){var v;const[s,r]=Y(!1),i=E(y=>{var A;return(A=y.card)==null?void 0:A.preferences;}),c=E(y=>{var A,b;return(b=(A=y.card)==null?void 0:A.preferences)==null?void 0:b.datasetOptions;}),d=c==null?void 0:c.find(y=>y.idx===a),{setCardPreferences:l}=E(y=>y.actions),o=(d==null?void 0:d.type)||"bar",x=(d==null?void 0:d.yAxisId)||"y",u=((v=d==null?void 0:d.dataLabels)==null?void 0:v.enabled)??!1,p=o==="line"?mn:hn;function h(y){const A={idx:a,type:o,yAxisId:x,dataLabels:d==null?void 0:d.dataLabels,...y};if(!d)l({...(i||{}),datasetOptions:[...(c||[]),A]});else{const b=c==null?void 0:c.map(z=>z.idx===a?{...z,...A}:z);l({...(i||{}),datasetOptions:b});}}function m(y){h({type:y});}function C(y){h({yAxisId:y});}function S(y){h({dataLabels:{...(d==null?void 0:d.dataLabels),enabled:y}});}function w(y){h({dataLabels:y});}return/* @__PURE__ */e(Mt,{open:s,onOpenChange:r,children:/* @__PURE__ */n("div",{className:"rounded-lg border border-border bg-muted/30",children:[/* @__PURE__ */e(Ot,{asChild:!0,children:/* @__PURE__ */n("button",{className:"flex w-full items-center justify-between gap-3 overflow-hidden px-3 py-2 text-left hover:bg-muted/50",children:[/* @__PURE__ */n("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[/* @__PURE__ */e(nt,{className:W("h-4 w-4 shrink-0 text-muted-foreground transition-transform",s&&"rotate-90")}),/* @__PURE__ */e("span",{className:"max-w-[100px] truncate text-xs font-medium",title:t,children:t})]}),/* @__PURE__ */n("div",{className:"flex shrink-0 items-center gap-1.5",children:[/* @__PURE__ */n("span",{className:W("flex items-center gap-1 rounded px-1.5 py-0.5 text-xs","border border-border bg-background text-muted-foreground"),children:[/* @__PURE__ */e(p,{className:"h-3 w-3"}),o==="line"?"Line":"Bar"]}),/* @__PURE__ */e("span",{className:W("rounded px-1.5 py-0.5 text-xs","border border-border bg-background text-muted-foreground"),children:x==="y2"?"Y2":"Y1"})]})]})}),/* @__PURE__ */e(At,{children:/* @__PURE__ */e("div",{className:"border-t border-border",children:/* @__PURE__ */n("div",{className:"space-y-4 p-3",children:[/* @__PURE__ */n("div",{className:"flex items-end gap-4",children:[/* @__PURE__ */n("div",{className:"flex-1 space-y-1.5",children:[/* @__PURE__ */e(D,{className:"text-xs text-muted-foreground",children:"Chart Type"}),/* @__PURE__ */e("div",{className:"flex gap-2",children:xh.map(({type:y,icon:A,label:b})=>/* @__PURE__ */n("button",{onClick:()=>m(y),className:W("flex items-center gap-2 rounded-md border px-3 py-1.5 text-xs transition-colors",o===y?"border-primary bg-primary/10 text-primary":"border-border bg-background text-muted-foreground hover:bg-muted"),children:[/* @__PURE__ */e(A,{className:"h-3.5 w-3.5 text-foreground/60"}),/* @__PURE__ */e("span",{children:b})]},y))})]}),/* @__PURE__ */n("div",{className:"space-y-1.5",children:[/* @__PURE__ */e(D,{className:"text-xs text-muted-foreground",children:"Axis"}),/* @__PURE__ */n(ne,{value:x,onValueChange:y=>C(y),children:[/* @__PURE__ */e(re,{size:"xs",className:"w-20",children:/* @__PURE__ */e(se,{})}),/* @__PURE__ */n(le,{children:[/* @__PURE__ */e(U,{value:"y",className:"text-xs",children:"Y1 (Left)"}),/* @__PURE__ */e(U,{value:"y2",className:"text-xs",children:"Y2 (Right)"})]})]})]})]}),o==="line"&&/* @__PURE__ */n("div",{className:"space-y-3",children:[/* @__PURE__ */e(D,{className:"text-xs font-medium",children:"Line Style"}),/* @__PURE__ */n("div",{className:"grid grid-cols-3 gap-3",children:[/* @__PURE__ */n("div",{className:"space-y-1.5",children:[/* @__PURE__ */e(D,{className:"text-xs text-muted-foreground",children:"Pattern"}),/* @__PURE__ */n(ne,{value:(d==null?void 0:d.lineStyle)||"solid",onValueChange:y=>h({lineStyle:y}),children:[/* @__PURE__ */e(re,{size:"xs",className:"w-full",children:/* @__PURE__ */e(se,{})}),/* @__PURE__ */e(le,{children:yh.map(({value:y,label:A})=>/* @__PURE__ */e(U,{value:y,className:"text-xs",children:A},y))})]})]}),/* @__PURE__ */n("div",{className:"space-y-1.5",children:[/* @__PURE__ */e(D,{className:"text-xs text-muted-foreground",children:"Point Size"}),/* @__PURE__ */n(ne,{value:String((d==null?void 0:d.pointRadius)??3),onValueChange:y=>h({pointRadius:Number(y)}),children:[/* @__PURE__ */e(re,{size:"xs",className:"w-full",children:/* @__PURE__ */e(se,{})}),/* @__PURE__ */e(le,{children:bh.map(y=>/* @__PURE__ */e(U,{value:String(y),className:"text-xs",children:y===0?"None":y},y))})]})]}),/* @__PURE__ */n("div",{className:"space-y-1.5",children:[/* @__PURE__ */e(D,{className:"text-xs text-muted-foreground",children:"Point Shape"}),/* @__PURE__ */n(ne,{value:(d==null?void 0:d.pointStyle)||"circle",onValueChange:y=>h({pointStyle:y}),children:[/* @__PURE__ */e(re,{size:"xs",className:"w-full",children:/* @__PURE__ */e(se,{})}),/* @__PURE__ */e(le,{children:vh.map(({value:y,label:A})=>/* @__PURE__ */e(U,{value:y,className:"text-xs",children:A},y))})]})]})]})]}),/* @__PURE__ */n("div",{className:"space-y-2",children:[/* @__PURE__ */n("div",{className:"flex items-center justify-between",children:[/* @__PURE__ */e(D,{className:"text-xs text-muted-foreground",children:"Data Labels"}),/* @__PURE__ */e(we,{size:"sm",checked:u,onCheckedChange:S})]}),u&&/* @__PURE__ */e("div",{className:"rounded-md border border-border bg-background p-2",children:/* @__PURE__ */e(va,{config:d==null?void 0:d.dataLabels,onChange:w,isHorizontal:!1,showAutoFormat:!0,showAppearance:!0})})]})]})})})]})});}const Va=[{value:"origin",label:"Origin (X-axis)",description:"Fill to the X-axis (y=0)"},{value:"start",label:"Start (Top)",description:"Fill to the top of chart area"},{value:"end",label:"End (Bottom)",description:"Fill to the bottom of chart area"},{value:"-1",label:"Previous Series",description:"Fill to the series below"},{value:"+1",label:"Next Series",description:"Fill to the series above"},{value:"false",label:"No Fill (Line)",description:"Show as line without fill"}],Sh=[0,1,2,3,4,5,6,8,10],Th=[{value:"circle",label:"Circle ●"},{value:"rect",label:"Square ■"},{value:"rectRounded",label:"Rounded ▢"},{value:"rectRot",label:"Diamond ◆"},{value:"triangle",label:"Triangle ▲"},{value:"cross",label:"Cross +"},{value:"crossRot",label:"X ×"},{value:"star",label:"Star ★"},{value:"dash",label:"Dash —"},{value:"line",label:"Line │"}],kh=[{value:"solid",label:"Solid ───"},{value:"dashed",label:"Dashed - - -"},{value:"dotted",label:"Dotted ···"},{value:"dash-dot",label:"Dash-Dot -·-·"}];function Ih(t){return t==null?"origin":t===!1?"false":t;}function Eh(){const t=E(a=>{var s;return(s=a.card)==null?void 0:s.type;});return t!=="area"&&t!=="stackedArea"?null:/* @__PURE__ */n(Se,{value:"area-series",className:"border-b-0",children:[/* @__PURE__ */e(Te,{className:"flex w-full items-center gap-2 py-2 text-[12px] font-medium hover:no-underline",children:/* @__PURE__ */n("div",{className:"flex items-center gap-2",children:[/* @__PURE__ */e(la,{className:"h-4 w-4 text-muted-foreground"}),/* @__PURE__ */e("span",{children:"Series"})]})}),/* @__PURE__ */e(ke,{className:"pt-2",children:/* @__PURE__ */e(Fh,{})})]});}function Fh(){const{transformedMetricKeys:t}=ba();return t.length===0?/* @__PURE__ */e("div",{className:"rounded-lg border border-dashed border-border p-4 text-center text-xs text-muted-foreground",children:"Add metrics to configure series"}):/* @__PURE__ */e("div",{className:"space-y-3",children:t.map((a,s)=>/* @__PURE__ */e(Mh,{metricKey:a,idx:s},a))});}function Mh({metricKey:t,idx:a}){var S;const[s,r]=Y(!1),i=E(w=>{var v;return(v=w.card)==null?void 0:v.preferences;}),c=E(w=>{var v,y;return(y=(v=w.card)==null?void 0:v.preferences)==null?void 0:y.datasetOptions;}),d=c==null?void 0:c.find(w=>w.idx===a),{setCardPreferences:l}=E(w=>w.actions),o=Ih(d==null?void 0:d.fill),x=((S=d==null?void 0:d.dataLabels)==null?void 0:S.enabled)??!1,u=Va.find(w=>w.value===o)||Va[0];function p(w){const v={idx:a,fill:o,dataLabels:d==null?void 0:d.dataLabels,...w};if(!d)l({...(i||{}),datasetOptions:[...(c||[]),v]});else{const y=c==null?void 0:c.map(A=>A.idx===a?{...A,...v}:A);l({...(i||{}),datasetOptions:y});}}function h(w){p({fill:w==="false"?!1:w});}function m(w){p({dataLabels:{...(d==null?void 0:d.dataLabels),enabled:w}});}function C(w){p({dataLabels:w});}return/* @__PURE__ */e(Mt,{open:s,onOpenChange:r,children:/* @__PURE__ */n("div",{className:"rounded-lg border border-border bg-muted/30",children:[/* @__PURE__ */e(Ot,{asChild:!0,children:/* @__PURE__ */n("button",{className:"flex w-full items-center justify-between gap-3 overflow-hidden px-3 py-2 text-left hover:bg-muted/50",children:[/* @__PURE__ */n("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[/* @__PURE__ */e(nt,{className:W("h-4 w-4 shrink-0 text-muted-foreground transition-transform",s&&"rotate-90")}),/* @__PURE__ */e("span",{className:"max-w-[100px] truncate text-xs font-medium",title:t,children:t})]}),/* @__PURE__ */e("div",{className:"flex shrink-0 items-center gap-1.5",children:/* @__PURE__ */n("span",{className:W("flex items-center gap-1 rounded px-1.5 py-0.5 text-xs","border border-border bg-background text-muted-foreground"),children:[/* @__PURE__ */e(_o,{className:"h-3 w-3"}),u.label.split(" ")[0]]})})]})}),/* @__PURE__ */e(At,{children:/* @__PURE__ */e("div",{className:"border-t border-border",children:/* @__PURE__ */n("div",{className:"space-y-4 p-3",children:[/* @__PURE__ */n("div",{className:"space-y-1.5",children:[/* @__PURE__ */e(D,{className:"text-xs text-muted-foreground",children:"Fill Target"}),/* @__PURE__ */n(ne,{value:o,onValueChange:w=>h(w),children:[/* @__PURE__ */e(re,{size:"xs",children:/* @__PURE__ */e(se,{})}),/* @__PURE__ */e(le,{children:Va.map(w=>/* @__PURE__ */e(U,{value:w.value,className:"text-xs",children:/* @__PURE__ */e("div",{className:"flex flex-col",children:/* @__PURE__ */e("span",{children:w.label})})},w.value))})]})]}),/* @__PURE__ */n("div",{className:"space-y-3",children:[/* @__PURE__ */e(D,{className:"text-xs font-medium",children:"Line Style"}),/* @__PURE__ */n("div",{className:"grid grid-cols-3 gap-3",children:[/* @__PURE__ */n("div",{className:"space-y-1.5",children:[/* @__PURE__ */e(D,{className:"text-xs text-muted-foreground",children:"Pattern"}),/* @__PURE__ */n(ne,{value:(d==null?void 0:d.lineStyle)||"solid",onValueChange:w=>p({lineStyle:w}),children:[/* @__PURE__ */e(re,{size:"xs",className:"w-full",children:/* @__PURE__ */e(se,{})}),/* @__PURE__ */e(le,{children:kh.map(({value:w,label:v})=>/* @__PURE__ */e(U,{value:w,className:"text-xs",children:v},w))})]})]}),/* @__PURE__ */n("div",{className:"space-y-1.5",children:[/* @__PURE__ */e(D,{className:"text-xs text-muted-foreground",children:"Point Size"}),/* @__PURE__ */n(ne,{value:String((d==null?void 0:d.pointRadius)??3),onValueChange:w=>p({pointRadius:Number(w)}),children:[/* @__PURE__ */e(re,{size:"xs",className:"w-full",children:/* @__PURE__ */e(se,{})}),/* @__PURE__ */e(le,{children:Sh.map(w=>/* @__PURE__ */e(U,{value:String(w),className:"text-xs",children:w===0?"None":w},w))})]})]}),/* @__PURE__ */n("div",{className:"space-y-1.5",children:[/* @__PURE__ */e(D,{className:"text-xs text-muted-foreground",children:"Point Shape"}),/* @__PURE__ */n(ne,{value:(d==null?void 0:d.pointStyle)||"circle",onValueChange:w=>p({pointStyle:w}),children:[/* @__PURE__ */e(re,{size:"xs",className:"w-full",children:/* @__PURE__ */e(se,{})}),/* @__PURE__ */e(le,{children:Th.map(({value:w,label:v})=>/* @__PURE__ */e(U,{value:w,className:"text-xs",children:v},w))})]})]})]})]}),/* @__PURE__ */n("div",{className:"space-y-2",children:[/* @__PURE__ */n("div",{className:"flex items-center justify-between",children:[/* @__PURE__ */e(D,{className:"text-xs text-muted-foreground",children:"Data Labels"}),/* @__PURE__ */e(we,{size:"sm",checked:x,onCheckedChange:m})]}),x&&/* @__PURE__ */e("div",{className:"rounded-md border border-border bg-background p-2",children:/* @__PURE__ */e(va,{config:d==null?void 0:d.dataLabels,onChange:C,isHorizontal:!1,showAutoFormat:!0,showAppearance:!0})})]})]})})})]})});}const Oh=[0,1,2,3,4,5,6,8,10],Ah=[{value:"circle",label:"Circle ●"},{value:"rect",label:"Square ■"},{value:"rectRounded",label:"Rounded ▢"},{value:"rectRot",label:"Diamond ◆"},{value:"triangle",label:"Triangle ▲"},{value:"cross",label:"Cross +"},{value:"crossRot",label:"X ×"},{value:"star",label:"Star ★"},{value:"dash",label:"Dash —"},{value:"line",label:"Line │"}],Ba=[{value:"solid",label:"Solid ───"},{value:"dashed",label:"Dashed - - -"},{value:"dotted",label:"Dotted ···"},{value:"dash-dot",label:"Dash-Dot -·-·"}];function Rh(){return E(a=>{var s;return(s=a.card)==null?void 0:s.type;})!=="line"?null:/* @__PURE__ */n(Se,{value:"line-series",className:"border-b-0",children:[/* @__PURE__ */e(Te,{className:"flex w-full items-center gap-2 py-2 text-[12px] font-medium hover:no-underline",children:/* @__PURE__ */n("div",{className:"flex items-center gap-2",children:[/* @__PURE__ */e(la,{className:"h-4 w-4 text-muted-foreground"}),/* @__PURE__ */e("span",{children:"Series"})]})}),/* @__PURE__ */e(ke,{className:"pt-2",children:/* @__PURE__ */e(Lh,{})})]});}function Lh(){const{transformedMetricKeys:t}=ba();return t.length===0?/* @__PURE__ */e("div",{className:"rounded-lg border border-dashed border-border p-4 text-center text-xs text-muted-foreground",children:"Add metrics to configure series"}):/* @__PURE__ */e("div",{className:"space-y-3",children:t.map((a,s)=>/* @__PURE__ */e(Ph,{metricKey:a,idx:s},a))});}function Ph({metricKey:t,idx:a}){var w;const[s,r]=Y(!1),i=E(v=>{var y;return(y=v.card)==null?void 0:y.preferences;}),c=E(v=>{var y,A;return(A=(y=v.card)==null?void 0:y.preferences)==null?void 0:A.datasetOptions;}),d=c==null?void 0:c.find(v=>v.idx===a),{setCardPreferences:l}=E(v=>v.actions),o=(d==null?void 0:d.lineStyle)||"solid",x=(d==null?void 0:d.pointRadius)??3,u=(d==null?void 0:d.pointStyle)||"circle",p=((w=d==null?void 0:d.dataLabels)==null?void 0:w.enabled)??!1,h=Ba.find(v=>v.value===o)||Ba[0];function m(v){const y={idx:a,lineStyle:o,pointRadius:x,pointStyle:u,dataLabels:d==null?void 0:d.dataLabels,...v};if(!d)l({...(i||{}),datasetOptions:[...(c||[]),y]});else{const A=c==null?void 0:c.map(b=>b.idx===a?{...b,...y}:b);l({...(i||{}),datasetOptions:A});}}function C(v){m({dataLabels:{...(d==null?void 0:d.dataLabels),enabled:v}});}function S(v){m({dataLabels:v});}return/* @__PURE__ */e(Mt,{open:s,onOpenChange:r,children:/* @__PURE__ */n("div",{className:"rounded-lg border border-border bg-muted/30",children:[/* @__PURE__ */e(Ot,{asChild:!0,children:/* @__PURE__ */n("button",{className:"flex w-full items-center justify-between gap-3 overflow-hidden px-3 py-2 text-left hover:bg-muted/50",children:[/* @__PURE__ */n("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[/* @__PURE__ */e(nt,{className:W("h-4 w-4 shrink-0 text-muted-foreground transition-transform",s&&"rotate-90")}),/* @__PURE__ */e("span",{className:"max-w-[100px] truncate text-xs font-medium",title:t,children:t})]}),/* @__PURE__ */e("div",{className:"flex shrink-0 items-center gap-1.5",children:/* @__PURE__ */n("span",{className:W("flex items-center gap-1 rounded px-1.5 py-0.5 text-xs","border border-border bg-background text-muted-foreground"),children:[/* @__PURE__ */e(Ns,{className:"h-3 w-3"}),h.label.split(" ")[0]]})})]})}),/* @__PURE__ */e(At,{children:/* @__PURE__ */e("div",{className:"border-t border-border",children:/* @__PURE__ */n("div",{className:"space-y-4 p-3",children:[/* @__PURE__ */n("div",{className:"space-y-3",children:[/* @__PURE__ */e(D,{className:"text-xs font-medium",children:"Line Style"}),/* @__PURE__ */n("div",{className:"grid grid-cols-3 gap-3",children:[/* @__PURE__ */n("div",{className:"space-y-1.5",children:[/* @__PURE__ */e(D,{className:"text-xs text-muted-foreground",children:"Pattern"}),/* @__PURE__ */n(ne,{value:o,onValueChange:v=>m({lineStyle:v}),children:[/* @__PURE__ */e(re,{size:"xs",className:"w-full",children:/* @__PURE__ */e(se,{})}),/* @__PURE__ */e(le,{children:Ba.map(({value:v,label:y})=>/* @__PURE__ */e(U,{value:v,className:"text-xs",children:y},v))})]})]}),/* @__PURE__ */n("div",{className:"space-y-1.5",children:[/* @__PURE__ */e(D,{className:"text-xs text-muted-foreground",children:"Point Size"}),/* @__PURE__ */n(ne,{value:String(x),onValueChange:v=>m({pointRadius:Number(v)}),children:[/* @__PURE__ */e(re,{size:"xs",className:"w-full",children:/* @__PURE__ */e(se,{})}),/* @__PURE__ */e(le,{children:Oh.map(v=>/* @__PURE__ */e(U,{value:String(v),className:"text-xs",children:v===0?"None":v},v))})]})]}),/* @__PURE__ */n("div",{className:"space-y-1.5",children:[/* @__PURE__ */e(D,{className:"text-xs text-muted-foreground",children:"Point Shape"}),/* @__PURE__ */n(ne,{value:u,onValueChange:v=>m({pointStyle:v}),children:[/* @__PURE__ */e(re,{size:"xs",className:"w-full",children:/* @__PURE__ */e(se,{})}),/* @__PURE__ */e(le,{children:Ah.map(({value:v,label:y})=>/* @__PURE__ */e(U,{value:v,className:"text-xs",children:y},v))})]})]})]})]}),/* @__PURE__ */n("div",{className:"space-y-2",children:[/* @__PURE__ */n("div",{className:"flex items-center justify-between",children:[/* @__PURE__ */e(D,{className:"text-xs text-muted-foreground",children:"Data Labels"}),/* @__PURE__ */e(we,{size:"sm",checked:p,onCheckedChange:C})]}),p&&/* @__PURE__ */e("div",{className:"rounded-md border border-border bg-background p-2",children:/* @__PURE__ */e(va,{config:d==null?void 0:d.dataLabels,onChange:S,isHorizontal:!1,showAutoFormat:!0,showAppearance:!0})})]})]})})})]})});}const Dh=[0,2,4,6,8,10,12,16,20];function _h(){const t=E(a=>{var s;return(s=a.card)==null?void 0:s.type;});return!t||!["bar","horizontalBar","stackedBar"].includes(t)?null:/* @__PURE__ */n(Se,{value:"bar-series",className:"border-b-0",children:[/* @__PURE__ */e(Te,{className:"flex w-full items-center gap-2 py-2 text-[12px] font-medium hover:no-underline",children:/* @__PURE__ */n("div",{className:"flex items-center gap-2",children:[/* @__PURE__ */e(la,{className:"h-4 w-4 text-muted-foreground"}),/* @__PURE__ */e("span",{children:"Series"})]})}),/* @__PURE__ */e(ke,{className:"pt-2",children:/* @__PURE__ */e(Vh,{})})]});}function Vh(){const{transformedMetricKeys:t}=ba();return t.length===0?/* @__PURE__ */e("div",{className:"rounded-lg border border-dashed border-border p-4 text-center text-xs text-muted-foreground",children:"Add metrics to configure series"}):/* @__PURE__ */e("div",{className:"space-y-3",children:t.map((a,s)=>/* @__PURE__ */e(Bh,{metricKey:a,idx:s},a))});}function Bh({metricKey:t,idx:a}){var C;const[s,r]=Y(!1),i=E(S=>{var w;return(w=S.card)==null?void 0:w.type;}),c=E(S=>{var w;return(w=S.card)==null?void 0:w.preferences;}),d=E(S=>{var w,v;return(v=(w=S.card)==null?void 0:w.preferences)==null?void 0:v.datasetOptions;}),l=d==null?void 0:d.find(S=>S.idx===a),{setCardPreferences:o}=E(S=>S.actions),x=(l==null?void 0:l.borderRadius)??0,u=((C=l==null?void 0:l.dataLabels)==null?void 0:C.enabled)??!1;function p(S){const w={idx:a,borderRadius:x,dataLabels:l==null?void 0:l.dataLabels,...S};if(!l)o({...(c||{}),datasetOptions:[...(d||[]),w]});else{const v=d==null?void 0:d.map(y=>y.idx===a?{...y,...w}:y);o({...(c||{}),datasetOptions:v});}}function h(S){p({dataLabels:{...(l==null?void 0:l.dataLabels),enabled:S}});}function m(S){p({dataLabels:S});}return/* @__PURE__ */e(Mt,{open:s,onOpenChange:r,children:/* @__PURE__ */n("div",{className:"rounded-lg border border-border bg-muted/30",children:[/* @__PURE__ */e(Ot,{asChild:!0,children:/* @__PURE__ */n("button",{className:"flex w-full items-center justify-between gap-3 overflow-hidden px-3 py-2 text-left hover:bg-muted/50",children:[/* @__PURE__ */n("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[/* @__PURE__ */e(nt,{className:W("h-4 w-4 shrink-0 text-muted-foreground transition-transform",s&&"rotate-90")}),/* @__PURE__ */e("span",{className:"max-w-[100px] truncate text-xs font-medium",title:t,children:t})]}),/* @__PURE__ */e("div",{className:"flex shrink-0 items-center gap-1.5",children:x>0&&/* @__PURE__ */n("span",{className:W("flex items-center gap-1 rounded px-1.5 py-0.5 text-xs","border border-border bg-background text-muted-foreground"),children:[/* @__PURE__ */e(cs,{className:"h-3 w-3"}),"r:",x]})})]})}),/* @__PURE__ */e(At,{children:/* @__PURE__ */e("div",{className:"border-t border-border",children:/* @__PURE__ */n("div",{className:"space-y-4 p-3",children:[/* @__PURE__ */n("div",{className:"space-y-3",children:[/* @__PURE__ */e(D,{className:"text-xs font-medium",children:"Bar Style"}),/* @__PURE__ */e("div",{className:"space-y-3",children:/* @__PURE__ */n("div",{className:"space-y-1.5",children:[/* @__PURE__ */e(D,{className:"text-xs text-muted-foreground",children:"Corner Radius"}),/* @__PURE__ */n(ne,{value:String(x),onValueChange:S=>p({borderRadius:Number(S)}),children:[/* @__PURE__ */e(re,{size:"xs",className:"w-full",children:/* @__PURE__ */e(se,{})}),/* @__PURE__ */e(le,{children:Dh.map(S=>/* @__PURE__ */e(U,{value:String(S),className:"text-xs",children:S===0?"None":`${S}px`},S))})]})]})})]}),/* @__PURE__ */n("div",{className:"space-y-2",children:[/* @__PURE__ */n("div",{className:"flex items-center justify-between",children:[/* @__PURE__ */e(D,{className:"text-xs text-muted-foreground",children:"Data Labels"}),/* @__PURE__ */e(we,{size:"sm",checked:u,onCheckedChange:h})]}),u&&/* @__PURE__ */e("div",{className:"rounded-md border border-border bg-background p-2",children:/* @__PURE__ */e(va,{config:l==null?void 0:l.dataLabels,onChange:m,isHorizontal:i==="horizontalBar",showAutoFormat:!0,showAppearance:!0})})]})]})})})]})});}const zh=[0,1,2,3,4,5,6,8,10],Kh=[{value:"circle",label:"Circle ●"},{value:"rect",label:"Square ■"},{value:"rectRounded",label:"Rounded ▢"},{value:"rectRot",label:"Diamond ◆"},{value:"triangle",label:"Triangle ▲"},{value:"cross",label:"Cross +"},{value:"crossRot",label:"X ×"},{value:"star",label:"Star ★"},{value:"dash",label:"Dash —"},{value:"line",label:"Line │"}],qh=[{value:"solid",label:"Solid ───"},{value:"dashed",label:"Dashed - - -"},{value:"dotted",label:"Dotted ···"},{value:"dash-dot",label:"Dash-Dot -·-·"}];function $h(){const t=E(l=>l.card),a=E(l=>{var o;return(o=l.card)==null?void 0:o.preferences;}),s=Be(),r=a==null?void 0:a.lineStyleConfig,{setCardPreferences:i,updateCardInFrame:c}=me();if(!t||!["line","area","stackedArea"].includes(s))return null;const d=(l,o)=>{const x={...(a||{}),lineStyleConfig:{...r,[l]:o}};i(x),c({...t,preferences:x});};return/* @__PURE__ */n(Se,{value:"line-style",className:"border-b-0",children:[/* @__PURE__ */e(Te,{className:"flex w-full items-center gap-2 py-2 text-[12px] font-medium hover:no-underline",children:/* @__PURE__ */n("div",{className:"flex items-center gap-2",children:[/* @__PURE__ */e(vu,{className:"h-4 w-4 text-muted-foreground"}),/* @__PURE__ */e("span",{children:"Line Style"})]})}),/* @__PURE__ */e(ke,{className:"pt-2",children:/* @__PURE__ */n("div",{className:"space-y-3",children:[/* @__PURE__ */e("p",{className:"text-xs text-muted-foreground",children:"Default styles for all series. Override per-series in the Series section."}),/* @__PURE__ */n("div",{className:"space-y-1.5",children:[/* @__PURE__ */e(D,{className:"text-xs font-medium",children:"Line Pattern"}),/* @__PURE__ */n(ne,{value:(r==null?void 0:r.lineStyle)||"solid",onValueChange:l=>d("lineStyle",l),children:[/* @__PURE__ */e(re,{size:"xs",children:/* @__PURE__ */e(se,{})}),/* @__PURE__ */e(le,{children:qh.map(({value:l,label:o})=>/* @__PURE__ */e(U,{value:l,className:"text-xs",children:o},l))})]})]}),/* @__PURE__ */n("div",{className:"space-y-1.5",children:[/* @__PURE__ */e(D,{className:"text-xs font-medium",children:"Point Size"}),/* @__PURE__ */n(ne,{value:String((r==null?void 0:r.pointRadius)??3),onValueChange:l=>d("pointRadius",Number(l)),children:[/* @__PURE__ */e(re,{size:"xs",children:/* @__PURE__ */e(se,{})}),/* @__PURE__ */e(le,{children:zh.map(l=>/* @__PURE__ */e(U,{value:String(l),className:"text-xs",children:l===0?"None":l},l))})]})]}),/* @__PURE__ */n("div",{className:"space-y-1.5",children:[/* @__PURE__ */e(D,{className:"text-xs font-medium",children:"Point Shape"}),/* @__PURE__ */n(ne,{value:(r==null?void 0:r.pointStyle)||"circle",onValueChange:l=>d("pointStyle",l),children:[/* @__PURE__ */e(re,{size:"xs",children:/* @__PURE__ */e(se,{})}),/* @__PURE__ */e(le,{children:Kh.map(({value:l,label:o})=>/* @__PURE__ */e(U,{value:l,className:"text-xs",children:o},l))})]})]})]})})]});}const jh=[0,2,4,6,8,10,12,16,20],Hh=[{value:"0.5",label:"50%"},{value:"0.6",label:"60%"},{value:"0.7",label:"70%"},{value:"0.8",label:"80%"},{value:"0.9",label:"90%"},{value:"1",label:"100%"}],Uh=[{value:"0.5",label:"50%"},{value:"0.6",label:"60%"},{value:"0.7",label:"70%"},{value:"0.8",label:"80%"},{value:"0.9",label:"90%"},{value:"1",label:"100%"}];function Gh(){const t=E(l=>l.card),a=E(l=>{var o;return(o=l.card)==null?void 0:o.preferences;}),s=Be(),r=a==null?void 0:a.barStyleConfig,{setCardPreferences:i,updateCardInFrame:c}=me();if(!t||!["bar","horizontalBar","stackedBar"].includes(s))return null;const d=(l,o)=>{const x={...(a||{}),barStyleConfig:{...r,[l]:o}};i(x),c({...t,preferences:x});};return/* @__PURE__ */n(Se,{value:"bar-style",className:"border-b-0",children:[/* @__PURE__ */e(Te,{className:"flex w-full items-center gap-2 py-2 text-[12px] font-medium hover:no-underline",children:/* @__PURE__ */n("div",{className:"flex items-center gap-2",children:[/* @__PURE__ */e(cs,{className:"h-4 w-4 text-muted-foreground"}),/* @__PURE__ */e("span",{children:"Bar Style"})]})}),/* @__PURE__ */e(ke,{className:"pt-2",children:/* @__PURE__ */n("div",{className:"space-y-3",children:[/* @__PURE__ */e("p",{className:"text-xs text-muted-foreground",children:"Default styles for all bars. Override per-series in the Series section."}),/* @__PURE__ */n("div",{className:"space-y-1.5",children:[/* @__PURE__ */e(D,{className:"text-xs font-medium",children:"Corner Radius"}),/* @__PURE__ */n(ne,{value:String((r==null?void 0:r.borderRadius)??0),onValueChange:l=>d("borderRadius",Number(l)),children:[/* @__PURE__ */e(re,{size:"xs",children:/* @__PURE__ */e(se,{})}),/* @__PURE__ */e(le,{children:jh.map(l=>/* @__PURE__ */e(U,{value:String(l),className:"text-xs",children:l===0?"None":`${l}px`},l))})]})]}),/* @__PURE__ */n("div",{className:"space-y-1.5",children:[/* @__PURE__ */e(D,{className:"text-xs font-medium",children:"Bar Width"}),/* @__PURE__ */n(ne,{value:String((r==null?void 0:r.barPercentage)??0.9),onValueChange:l=>d("barPercentage",Number(l)),children:[/* @__PURE__ */e(re,{size:"xs",children:/* @__PURE__ */e(se,{})}),/* @__PURE__ */e(le,{children:Hh.map(({value:l,label:o})=>/* @__PURE__ */e(U,{value:l,className:"text-xs",children:o},l))})]})]}),/* @__PURE__ */n("div",{className:"space-y-1.5",children:[/* @__PURE__ */e(D,{className:"text-xs font-medium",children:"Category Width"}),/* @__PURE__ */n(ne,{value:String((r==null?void 0:r.categoryPercentage)??0.8),onValueChange:l=>d("categoryPercentage",Number(l)),children:[/* @__PURE__ */e(re,{size:"xs",children:/* @__PURE__ */e(se,{})}),/* @__PURE__ */e(le,{children:Uh.map(({value:l,label:o})=>/* @__PURE__ */e(U,{value:l,className:"text-xs",children:o},l))})]})]})]})})]});}function Qh(){const t=E(s=>{var r,i;return(i=(r=s==null?void 0:s.card)==null?void 0:r.preferences)==null?void 0:i.sortChart;}),{setSortChart:a}=me();return/* @__PURE__ */n(Se,{value:"stacked-sort",children:[/* @__PURE__ */e(Te,{children:/* @__PURE__ */n("div",{className:"flex items-center gap-2",children:[/* @__PURE__ */e(vs,{className:"h-3.5 w-3.5 text-foreground/60"}),"Sort"]})}),/* @__PURE__ */e(ke,{className:"space-y-4 px-1",children:/* @__PURE__ */n("div",{className:"space-y-2",children:[/* @__PURE__ */e(D,{children:"Sort Order"}),/* @__PURE__ */e(Wt,{className:"h-8",label:"Sort Chart",options:[{label:"None",value:"none"},{label:"Ascending",value:"asc"},{label:"Descending",value:"desc"}],value:t||"none",onValueChange:s=>{a(s);}})]})})]});}const Wh=["kpi"],za=2;function ct(t){return typeof t=="string"?t.trim().toLowerCase():((t==null?void 0:t.id)||(t==null?void 0:t.qualifiedFieldName)||(t==null?void 0:t.name)||(t==null?void 0:t.label)||"").trim().toLowerCase();}function Yh(t){if(!(t!=null&&t.name)||!(t!=null&&t.dataType)||t.role==="metric")return!1;const a=Xl(t.dataType);return["date","string","boolean"].includes(a);}function Xh(t){return{...t,role:"groupby"};}function Jh(){var y,A;const t=E(b=>b.card),a=E(b=>b.actions.updateCardConfig),s=Be(),{scopedFields:r}=Wr(),i=((y=t.config)==null?void 0:y.metricColumns)||[],c=((A=t.config)==null?void 0:A.summary)||{},d=c.breakdownDimensions||[],l=d.length>0,o=Wh.includes(s),x=i.length>0,u=c.enabled===!0,p=o&&x,h=Array.from(new Map(r.filter(Yh).map(b=>[ct(b),Xh(b)])).values()),m=new Set(h.map(b=>ct(b))),C=new Set(d.map(b=>ct(b)).filter(b=>b&&m.has(b)));if(!o)return null;const S=b=>{a(t.id,{summary:{...c,...b}});},w=(b,z)=>{const B=ct(b),j=h.filter(I=>C.has(ct(I))),$=z?C.has(B)?j:[...j,b].slice(0,za):j.filter(I=>ct(I)!==B);S({breakdownDimensions:$,...($.length>0?{showOnCard:!0}:{})});};return/* @__PURE__ */n(Se,{value:"summary",className:"border-none",children:[/* @__PURE__ */e(Te,{className:"flex items-center gap-2 py-2 text-[12px] hover:no-underline [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground",children:/* @__PURE__ */n("div",{className:"flex flex-1 items-center gap-2",children:[/* @__PURE__ */e(Zc,{className:"h-3.5 w-3.5 text-foreground/60"}),/* @__PURE__ */e("span",{children:"Summary"})]})}),/* @__PURE__ */n(ke,{className:"space-y-3 pb-4 pt-2",children:[/* @__PURE__ */n("div",{className:"flex items-center justify-between",children:[/* @__PURE__ */e(D,{htmlFor:"summary-enabled",className:"text-xs",children:"Show summary"}),/* @__PURE__ */e(we,{id:"summary-enabled",size:"xs",checked:u,disabled:!p,onCheckedChange:b=>{if(!b){S({enabled:!1,showOnCard:!1,includeInDashboardSummary:!1});return;}S({enabled:!0,showOnCard:c.showOnCard??!0,includeInDashboardSummary:c.includeInDashboardSummary??!0});}})]}),/* @__PURE__ */n("div",{className:W("space-y-3 transition-opacity",!u&&"opacity-60"),children:[!p&&/* @__PURE__ */e("p",{className:"text-[11px] text-muted-foreground",children:x?"Summary is not supported for this card type.":"Add at least one metric to enable summary."}),!l&&/* @__PURE__ */n("div",{className:"flex items-center gap-2",children:[/* @__PURE__ */e(Kt,{id:"summary-show-on-card",checked:c.showOnCard===!0,disabled:!u,onCheckedChange:b=>S({showOnCard:b===!0})}),/* @__PURE__ */e(D,{htmlFor:"summary-show-on-card",className:"cursor-pointer text-xs",children:"Show summary on card"})]}),/* @__PURE__ */n("div",{className:"flex items-center gap-2",children:[/* @__PURE__ */e(Kt,{id:"summary-include-rollup",checked:c.includeInDashboardSummary===!0,disabled:!u,onCheckedChange:b=>S({includeInDashboardSummary:b===!0})}),/* @__PURE__ */e(D,{htmlFor:"summary-include-rollup",className:"cursor-pointer text-xs",children:"Include in dashboard summary"})]}),/* @__PURE__ */n("div",{className:"space-y-1.5",children:[/* @__PURE__ */n("div",{className:"flex items-center justify-between",children:[/* @__PURE__ */e(D,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Breakdown Dimensions"}),/* @__PURE__ */n("span",{className:"text-[11px] tabular-nums text-muted-foreground",children:[d.length,"/",za]})]}),h.length===0?/* @__PURE__ */e("p",{className:"text-[11px] text-muted-foreground",children:"No dimension fields available for breakdown."}):/* @__PURE__ */e("ul",{className:"max-h-40 space-y-1 overflow-y-auto",children:h.map(b=>{const z=ct(b),B=C.has(z),j=C.size>=za,$=!u||!B&&j;return/* @__PURE__ */n("li",{className:"flex items-center gap-2 text-xs",children:[/* @__PURE__ */e(Kt,{id:`summary-breakdown-${z}`,checked:B,disabled:$,onCheckedChange:I=>w(b,I===!0)}),/* @__PURE__ */e(D,{htmlFor:`summary-breakdown-${z}`,className:"cursor-pointer text-xs",children:b.label||b.name})]},z);})})]})]})]})]});}const Zh={hour:"Hour",minute:"Minute",second:"Second",day:"Day",week:"Week",month:"Month",quarter:"Quarter",year:"Year"},Ka=t=>Zh[t??"day"]??"Day";function ep(){const t=E(a=>a.card);return!t||t.type!=="kpi"||nn(t)?null:/* @__PURE__ */e(tp,{card:t});}function tp({card:t}){var m,C,S,w,v;const{setCardConfig:a}=me(),{data:s}=je(t),r=s==null?void 0:s.metadata,i=Jl(t.config),c=!!(r!=null&&r.dateContext&&!r.dateContext.field&&!i),d=((m=t.config)==null?void 0:m.kpiBand)==="trend",l=((C=t.config)==null?void 0:C.kpiTrendGrain)??"automatic",o=((w=(S=r==null?void 0:r.dateContext)==null?void 0:S.counted)==null?void 0:w.status)==="window"?r.dateContext.counted.window:void 0,x=((v=r==null?void 0:r.trend)==null?void 0:v.grainSource)==="automatic"?r.trend.granularity:void 0,u=y=>a(ti(t,y).config),p=y=>a(ai(t,y==="automatic"?null:y).config),h=c?d?"This KPI counts on no date, so the trend can't show. Turn it off, or drop a date on Trend By.":"This KPI counts on no date. Drop a date on Trend By to show a trend.":d?i?"Trend By sets the grain. Remove it to pick one here.":l==="automatic"?"Follows the period the KPI counts: a different dashboard date changes it.":`Always by ${l}.`:"A line of the value over the period it counts.";return(/* @__PURE__ */n(Se,{value:"kpi-trend",className:"border-none","data-role":"kpi-trend-settings",children:[/* @__PURE__ */e(Te,{className:"flex items-center gap-2 py-2 text-[12px] hover:no-underline [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground",children:/* @__PURE__ */n("div",{className:"flex flex-1 items-center gap-2",children:[/* @__PURE__ */e(Ns,{className:"h-3.5 w-3.5 text-foreground/60","aria-hidden":!0}),/* @__PURE__ */e("span",{children:"Trend"})]})}),/* @__PURE__ */n(ke,{className:"space-y-3 pb-4 pt-2",children:[/* @__PURE__ */n("div",{className:"flex items-center justify-between",children:[/* @__PURE__ */e(D,{htmlFor:"kpi-trend",className:"text-xs",children:"Show trend"}),/* @__PURE__ */e(we,{id:"kpi-trend",size:"xs",checked:d,disabled:c&&!d,onCheckedChange:u})]}),d&&!c&&/* @__PURE__ */n("div",{className:"space-y-2","data-role":"kpi-trend-grain",children:[/* @__PURE__ */e(D,{htmlFor:"kpi-trend-grain",className:"text-xs",children:"Grain"}),i?/* @__PURE__ */n("div",{className:"flex h-8 items-center justify-between rounded-control border border-border bg-muted/30 px-2.5 text-xs text-foreground/80",children:[Ka(i.granularity)," · from Trend By",/* @__PURE__ */e(ed,{className:"h-3 w-3 text-muted-foreground","aria-hidden":!0})]}):/* @__PURE__ */n(ne,{value:l,onValueChange:p,children:[/* @__PURE__ */e(re,{id:"kpi-trend-grain",size:"xs",children:/* @__PURE__ */e(se,{})}),/* @__PURE__ */n(le,{children:[/* @__PURE__ */e(U,{value:"automatic",className:"text-xs",children:x?`Automatic · ${Ka(x)}`:"Automatic"}),Yd.map(y=>{const A=o?Zl(o,y)>ei:!1;return/* @__PURE__ */n(U,{value:y,className:"text-xs",disabled:A&&y!==l,children:[Ka(y),A?" · too many points":""]},y);})]})]})]}),/* @__PURE__ */e("p",{className:"text-[11px] text-muted-foreground",children:h})]})]}));}const ap=/* @__PURE__ */new Set(["area","bar","bubble","bullet","combo","doughnut","funnel","horizontalBar","line","pie","polarArea","radar","scatter","stackedArea","stackedBar","stackedLine","tornado"]);function np(){const t=E(u=>u.card),a=E(u=>{var p;return(p=u.card)==null?void 0:p.preferences;}),s=Be(),{setCardPreferences:r,updateCardInFrame:i}=me(),c=a==null?void 0:a.tooltipConfig,[d,l]=Y(!!(c!=null&&c.valueFormat));if(!t||!ap.has(s||""))return null;const o=d||c!=null&&c.valueFormat?"override":"inherit",x=u=>{const p={...(a||{}),tooltipConfig:u};r(p),i({...t,preferences:p});};return/* @__PURE__ */n(Se,{value:"tooltip-format",className:"border-b-0",children:[/* @__PURE__ */e(Te,{className:"flex w-full items-center gap-2 py-2 text-[12px] font-medium hover:no-underline",children:/* @__PURE__ */n("div",{className:"flex items-center gap-2",children:[/* @__PURE__ */e(ut,{className:"h-3.5 w-3.5 text-foreground/60"}),/* @__PURE__ */e("span",{children:"Tooltip Format"})]})}),/* @__PURE__ */n(ke,{className:"space-y-4 pt-2",children:[/* @__PURE__ */n("div",{className:"flex items-center justify-between",children:[/* @__PURE__ */n("div",{className:"space-y-1",children:[/* @__PURE__ */e(D,{className:"text-xs font-medium text-muted-foreground",children:"Override metric format"}),/* @__PURE__ */e("div",{className:"text-xs text-muted-foreground",children:"Keep this off to inherit from each metric."})]}),/* @__PURE__ */e(we,{size:"sm",checked:o==="override",onCheckedChange:u=>{if(l(u),!u){const{valueFormat:p,...h}=c??{};x(h);}}})]}),o==="override"&&/* @__PURE__ */e(sa,{formatOptions:Tn(c==null?void 0:c.valueFormat)||{},onFormatOptionsChange:u=>x({...c,valueFormat:kn(u)}),showTitle:!1})]})]});}function Ks({mode:t}){const a=E(s=>{var r;return(r=s.card)==null?void 0:r.type;});return ms(a)?null:/* @__PURE__ */n(be,{children:[a==="combo"&&/* @__PURE__ */e(Nh,{}),(a==="area"||a==="stackedArea")&&/* @__PURE__ */e(Eh,{}),a==="line"&&/* @__PURE__ */e(Rh,{}),(a==="bar"||a==="horizontalBar"||a==="stackedBar")&&/* @__PURE__ */e(_h,{}),/* @__PURE__ */e($h,{}),/* @__PURE__ */e(Gh,{}),/* @__PURE__ */e(lh,{}),t==="config"&&/* @__PURE__ */e(Gm,{}),t==="config"&&/* @__PURE__ */e(Jh,{}),t==="config"&&/* @__PURE__ */e(ep,{}),/* @__PURE__ */e(oh,{}),a==="bullet"&&/* @__PURE__ */e(ch,{}),a==="funnel"&&/* @__PURE__ */e(mh,{}),(a==="bubble"||a==="scatter")&&/* @__PURE__ */e(dh,{}),(a==="stackedBar"||a==="stackedLine")&&/* @__PURE__ */e(Qh,{}),/* @__PURE__ */e(ah,{}),/* @__PURE__ */e(nh,{}),/* @__PURE__ */e(rh,{}),/* @__PURE__ */e(sh,{}),/* @__PURE__ */e(np,{})]});}function rp(){const t=E(s=>s.card),a=t==null?void 0:t.type;return a?/* @__PURE__ */n("div",{className:"space-y-4 px-6 py-4",children:[/* @__PURE__ */e(Ds,{chartType:a}),/* @__PURE__ */e(ra,{type:"single",collapsible:!0,className:"w-full px-2",children:/* @__PURE__ */e(Ks,{mode:"dev"})})]}):null;}function sp({focusSection:t,focusRequestId:a}){const r=E(c=>c.card).type;function i(){if(sn(r))return/* @__PURE__ */e(zs,{cardType:r,focusSection:t,focusRequestId:a});switch(r){case"kpi":return/* @__PURE__ */e(Bm,{});case"custom":return/* @__PURE__ */e("div",{className:"px-6 py-2",children:/* @__PURE__ */e(Rs,{})});case"text":return/* @__PURE__ */e(Xm,{});case"customVisual":return/* @__PURE__ */e("div",{className:"px-6",children:/* @__PURE__ */e(Ls,{})});default:return/* @__PURE__ */e(rp,{});}}return/* @__PURE__ */n(xn,{className:"h-full w-full text-sm",children:[i(),/* @__PURE__ */e(td,{orientation:"horizontal"})]});}const lp=32;function ip(){const t=Ee(null),a=E(p=>p.isDevMode),[s,r]=Y(!1),[i,c]=Y({section:null,id:0}),d=!a||s,l=()=>r(p=>!p),o=p=>{p&&c(h=>({section:p,id:h.id+1})),a&&r(!0);},x=()=>{const p=t.current;p&&(p.isCollapsed()?p.expand():p.collapse());},u={show:a,isOpen:d,onToggle:l,onOpen:o};return/* @__PURE__ */n(Za,{direction:"vertical",className:"min-h-[250px] min-w-full max-w-lg",children:[/* @__PURE__ */e(Ct,{ref:t,role:"query-section",className:"flex",minSize:20,defaultSize:50,collapsible:!0,collapsedSize:0,children:/* @__PURE__ */e("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:/* @__PURE__ */e(Bu,{})})}),/* @__PURE__ */e(xm,{onToggleEditor:x,children:/* @__PURE__ */e(La,{mode:"toolbar",visualAsideControl:u})}),/* @__PURE__ */e(Ct,{role:"visual-section",minSize:0,defaultSize:50,children:d?/* @__PURE__ */n(Za,{direction:"horizontal",children:[/* @__PURE__ */e(Ct,{minSize:40,defaultSize:75,maxSize:100,children:/* @__PURE__ */e(La,{mode:"canvas",visualAsideControl:u})}),/* @__PURE__ */e(ws,{}),/* @__PURE__ */e(Ct,{className:"flex",defaultSize:lp,maxSize:45,children:/* @__PURE__ */e(sp,{focusSection:i.section,focusRequestId:i.id})})]}):/* @__PURE__ */e(La,{mode:"canvas",visualAsideControl:u})})]});}const op="inline-flex w-3 shrink-0 cursor-grab items-center text-muted-foreground/40 transition-colors duration-150 group-hover:text-muted-foreground group-focus-within:text-muted-foreground hover:!text-foreground active:cursor-grabbing";function br({label:t}){const a=t.indexOf(" › ");return a<0?/* @__PURE__ */e(be,{children:t}):/* @__PURE__ */n(be,{children:[t.slice(0,a)," ",/* @__PURE__ */e("span",{className:"mx-1 text-muted-foreground",children:"›"})," ",t.slice(a+3)]});}function qs({id:t,field:a,zone:s,label:r,dataType:i,nativeDataType:c,calculated:d,open:l,onOpenChange:o,onRemove:x,sortDirection:u,onSortDirectionChange:p,badge:h,children:m}){const{attributes:C,listeners:S,setNodeRef:w,isDragging:v}=Vo({id:Bo(t),data:{origin:s,field:a}}),{setNodeRef:y}=Yr({id:zo(t),data:{kind:"pill",zone:s,pillId:t}}),A=rt(b=>{w(b),y(b);},[w,y]);return/* @__PURE__ */n(it,{modal:!0,open:l,onOpenChange:o,children:[/* @__PURE__ */n("div",{ref:A,className:W("group flex h-7 w-full items-center gap-1.5 rounded-control border bg-background px-1.5 transition-colors",l?"border-foreground/30 bg-muted/40":"border-border hover:bg-muted/40",v&&"z-50 scale-95 opacity-50"),children:[/* @__PURE__ */e("button",{type:"button",...C,...S,"aria-label":`Drag ${r}`,className:op,onClick:b=>b.stopPropagation(),children:/* @__PURE__ */e(as,{className:"h-3 w-3"})}),/* @__PURE__ */e(Ko,{dataType:i,nativeDataType:c,calculated:d}),m?/* @__PURE__ */e(xt,{asChild:!0,children:/* @__PURE__ */e("button",{type:"button","aria-label":`${r} settings`,className:"block w-0 min-w-0 flex-1 truncate text-left text-[12px] text-foreground hover:underline data-[state=open]:underline",onClick:b=>b.stopPropagation(),children:/* @__PURE__ */e($n,{className:"block truncate",children:/* @__PURE__ */e(br,{label:r})})})}):/* @__PURE__ */e($n,{className:"block w-0 min-w-0 flex-1 text-[12px] text-foreground",children:/* @__PURE__ */e(br,{label:r})}),h,p&&/* @__PURE__ */e("button",{type:"button","aria-label":u==="asc"?"Switch to descending":"Switch to ascending",className:"inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-[3px] text-muted-foreground hover:bg-muted hover:text-foreground",onClick:b=>{b.stopPropagation(),p(u==="asc"?"desc":"asc");},children:u==="asc"?/* @__PURE__ */e(ad,{className:"h-3 w-3"}):/* @__PURE__ */e(nd,{className:"h-3 w-3"})}),/* @__PURE__ */e("button",{type:"button","aria-label":"Remove",className:"inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-[3px] text-muted-foreground opacity-0 hover:bg-muted hover:text-foreground group-focus-within:opacity-100 group-hover:opacity-100 [@media(hover:none)]:opacity-100",onClick:b=>{b.stopPropagation(),x();},children:/* @__PURE__ */e(ia,{className:"h-3 w-3"})})]}),m&&/* @__PURE__ */n(ot,{align:"start",sideOffset:6,className:"flex max-h-[480px] w-[320px] flex-col p-0",children:[/* @__PURE__ */e(qo,{field:a,title:r,onClose:()=>o(!1)}),/* @__PURE__ */e("div",{className:"min-h-0 flex-1 space-y-3 overflow-y-auto p-3",children:m})]})]});}function cp(t){const a=$o(t),{field:s,zone:r}=t;return/* @__PURE__ */n(be,{children:[/* @__PURE__ */e(qs,{id:s.id,field:s,zone:r,label:a.label,dataType:a.dataType,nativeDataType:a.nativeDataType,calculated:a.calculated,open:a.open,onOpenChange:a.setOpen,onRemove:a.remove,sortDirection:a.sortDirection,onSortDirectionChange:a.onSortDirectionChange,badge:a.badge,children:a.settings}),a.dialogs]});}function dp({field:t,zone:a,onRemove:s}){const[r,i]=Y(!1);return/* @__PURE__ */e(qs,{id:t.id,field:t,zone:a,label:ni(t),dataType:t.dataType,nativeDataType:t.nativeDataType,calculated:jo(t),open:r,onOpenChange:i,onRemove:s,children:/* @__PURE__ */e(Ha,{fieldId:t.id})});}function up({concept:t}){const{title:a,description:s}=mp[t];return/* @__PURE__ */n(St,{openDelay:150,closeDelay:50,children:[/* @__PURE__ */e(Tt,{asChild:!0,children:/* @__PURE__ */e("button",{type:"button","aria-label":`What does ${a} mean?`,className:"inline-flex h-3 w-3 shrink-0 items-center justify-center text-muted-foreground/70 transition-colors hover:text-foreground",children:/* @__PURE__ */e(mu,{className:"h-3 w-3"})})}),/* @__PURE__ */n(kt,{side:"right",align:"start",sideOffset:8,className:"w-[260px] space-y-2 rounded-control border border-border bg-popover p-3 shadow-[0_4px_16px_rgba(0,0,0,0.08)]",children:[/* @__PURE__ */n("div",{className:"space-y-1",children:[/* @__PURE__ */e("p",{className:"text-[12px] font-semibold text-foreground",children:a}),/* @__PURE__ */e("p",{className:"text-[11px] leading-[1.45] text-muted-foreground",children:s})]}),t!=="detailColumns"&&/* @__PURE__ */e(hp,{highlight:t})]})]});}const mp={groupBy:{title:"Rows",description:"Each unique value becomes a row. Use for the dimensions you want stacked vertically."},pivotBy:{title:"Pivot Columns",description:"Each unique value spreads across as a column, splitting your metrics horizontally."},metrics:{title:"Metrics",description:"The aggregated numbers (sum, count, avg…) that fill the cells of your chart or table."},detailColumns:{title:"Columns",description:"Raw column values with no aggregation — the underlying detail rows from the database."}};function hp({highlight:t}){const a=t==="pivotBy",s=t==="groupBy",r=t==="metrics",i="bg-foreground/[0.06] font-medium text-foreground dark:bg-foreground/[0.12]";return/* @__PURE__ */e("div",{className:"overflow-hidden rounded-control border border-border",children:/* @__PURE__ */n("table",{className:"w-full text-[10px]",children:[/* @__PURE__ */e("thead",{children:/* @__PURE__ */n("tr",{className:"border-b border-border bg-muted/40",children:[/* @__PURE__ */e("th",{className:"px-1.5 py-1 text-left font-normal text-muted-foreground"}),["North","South","East"].map(c=>/* @__PURE__ */e("th",{className:W("px-1.5 py-1 text-center font-normal text-muted-foreground",a&&i),children:c},c))]})}),/* @__PURE__ */e("tbody",{children:vr.map((c,d)=>/* @__PURE__ */n("tr",{className:W(d!==vr.length-1&&"border-b border-border/60"),children:[/* @__PURE__ */e("td",{className:W("px-1.5 py-1 text-left text-muted-foreground",s&&i),children:c.label}),c.values.map((l,o)=>/* @__PURE__ */e("td",{className:W("px-1.5 py-1 text-right font-mono tabular-nums text-muted-foreground",r&&i),children:l},o))]},c.label))})]})});}const vr=[{label:"Electronics",values:["2,300","1,800","3,400"]},{label:"Clothing",values:["1,300","620","480"]}],pp={groupBy:ls,pivotBy:ss,metrics:Qo,detailColumns:ts,sortBy:vs};function Bt({onRemoveField:t,zone:a,fields:s,label:r,placeholder:i,shouldShow:c,hasPivotColumns:d=!1}){const{setNodeRef:l}=Yr({id:Ho(a),data:{kind:"shelf",zone:a,pillIds:s.map(b=>b.id)}}),o=Uo(a),{updateSortByColumn:x}=me(),u=E(b=>b.card),p=E(b=>b.card.type),h=s.length>0,m=o!==null,C=(o==null?void 0:o.kind)!=="refused",S=(o==null?void 0:o.kind)==="refused"?Go(o.notice,r):null,w=rt((b,z)=>{var j;!((j=u.config)!=null&&j.sortByColumns)||u.config.sortByColumns.findIndex($=>$.id===b)===-1||x(u.id,b,{direction:z});},[u,x]),v=X(()=>/* @__PURE__ */e("div",{className:"space-y-1",children:s.map((b,z)=>{const j=b.direction;return/* @__PURE__ */n("div",{className:"relative",children:[/* @__PURE__ */e(fp,{zone:a,pillId:b.id,isLast:z===s.length-1}),p==="matrixTable"?/* @__PURE__ */e(dp,{field:b,zone:a,onRemove:()=>t(a,z)}):/* @__PURE__ */e(cp,{field:b,zone:a,index:z,sortDirection:j,onSortDirectionChange:$=>w(b.id,$),hasPivotColumns:d,cardType:p})]},b.id);})}),[s,a,p,d,t,w]);if(a==="sortBy"&&c===!1)return null;const y=a!=="sortBy"&&p!=="kpi",A=pp[a]||ga;return/* @__PURE__ */n("div",{ref:l,className:"w-full",role:"group","aria-label":r,children:[/* @__PURE__ */n("div",{className:"mb-1 flex min-w-0 items-center justify-between gap-2",children:[/* @__PURE__ */e(D,{className:"block shrink-0 text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:r}),S&&/* @__PURE__ */e("span",{role:"status","data-shelf-refusal-reason":"",className:"min-w-0 truncate text-[11px] text-destructive",children:S})]}),/* @__PURE__ */e("div",{className:W("rounded-control transition-colors",{"border border-foreground/40 bg-muted/50":m&&C,"border border-destructive/40 bg-destructive/5":m&&!C,"border border-dashed border-border/50 bg-background":!m&&!h}),children:s.length===0?/* @__PURE__ */n("div",{className:"flex h-9 items-center justify-center gap-1.5 text-[11px] text-muted-foreground/80",children:[/* @__PURE__ */e(A,{className:"h-3 w-3 shrink-0 text-muted-foreground/60"}),/* @__PURE__ */e("span",{children:i}),y&&/* @__PURE__ */e(up,{concept:a})]}):v})]});}function fp({zone:t,pillId:a,isLast:s}){const r=Wo(t,a,s);return r?/* @__PURE__ */n("div",{"aria-hidden":!0,"data-shelf-insertion-line":r,className:W("pointer-events-none absolute inset-x-0 z-10 flex h-1.5 items-center",r==="top"?"-top-[5px]":"-bottom-[5px]"),children:[/* @__PURE__ */e("span",{className:"h-1.5 w-1.5 shrink-0 rounded-full border-[1.5px] border-foreground bg-background"}),/* @__PURE__ */e("span",{className:"h-0.5 flex-1 bg-foreground"})]}):null;}const gp="text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground";function xp({card:t,metric:a,children:s}){var x,u;const{data:r}=je(t),i=r==null?void 0:r.metadata,c=Vd(i==null?void 0:i.dateContext,a?ds(i==null?void 0:i.comparisonMetadata,a):void 0),d=r==null?void 0:r.records,l=((x=ri({renderCard:t,records:d,metadata:i}).trend)==null?void 0:x.points.length)??0,o=((u=t.config)==null?void 0:u.kpiBand)==="trend"?Xd(i==null?void 0:i.trend,l):void 0;return/* @__PURE__ */e(be,{children:s(c,o)});}function bp({view:t,trend:a}){const s=fe(i=>i.dashboard),r=Bd(t,{cardTitle:i=>{var c;return s?(c=wd(s,i))==null?void 0:c.title:void 0;}});return/* @__PURE__ */e(vp,{words:r,trend:a});}function vp({words:t,trend:a}){return/* @__PURE__ */n("div",{className:"space-y-1.5 pt-1","data-role":"kpi-date-section",children:[/* @__PURE__ */e("div",{className:gp,children:"Date"}),/* @__PURE__ */n("div",{className:"rounded-control border border-border bg-muted/20 text-[12px]",children:[/* @__PURE__ */n("div",{className:"flex items-start gap-2 border-b border-border/70 px-2.5 py-2",children:[/* @__PURE__ */e(rd,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-muted-foreground","aria-hidden":!0}),t.field?/* @__PURE__ */n("div",{className:"min-w-0",children:[/* @__PURE__ */e("div",{className:"truncate font-medium",children:t.field.name}),/* @__PURE__ */e("div",{className:"text-[11px] text-muted-foreground",children:t.field.from})]}):/* @__PURE__ */e("div",{className:"text-muted-foreground",children:"No date"})]}),t.windows.length>0&&/* @__PURE__ */e("div",{className:"space-y-2 border-b border-border/70 px-2.5 py-2",children:t.windows.map(s=>/* @__PURE__ */n("div",{className:W(!s.applied&&"opacity-50"),children:[/* @__PURE__ */e("div",{className:W("leading-tight",!s.applied&&"line-through"),children:s.text}),/* @__PURE__ */e("div",{className:"text-[11px] leading-tight text-muted-foreground",children:s.from})]},`${s.text}|${s.from}`))}),/* @__PURE__ */n("div",{className:"space-y-2 px-2.5 py-2",children:[/* @__PURE__ */n("div",{children:[/* @__PURE__ */e("div",{className:"text-[11px] leading-tight text-muted-foreground",children:"Counts"}),/* @__PURE__ */e("div",{className:"font-medium leading-tight",children:t.counts})]}),t.compared&&/* @__PURE__ */n("div",{children:[/* @__PURE__ */e("div",{className:"text-[11px] leading-tight text-muted-foreground",children:"Compared with"}),/* @__PURE__ */e("div",{className:"leading-tight",children:t.compared})]}),a&&/* @__PURE__ */n("div",{"data-role":"kpi-trend-row",children:[/* @__PURE__ */e("div",{className:"text-[11px] leading-tight text-muted-foreground",children:"Trend"}),/* @__PURE__ */e("div",{className:"leading-tight",children:a.head}),/* @__PURE__ */e("div",{className:"text-[11px] leading-tight text-muted-foreground",children:a.detail})]})]}),t.note&&/* @__PURE__ */n("div",{"data-role":"kpi-date-note",className:W("flex gap-1.5 border-t px-2.5 py-2 text-[11.5px] leading-snug",t.note.tone==="warn"?"border-amber-200 bg-amber-50 text-amber-900 dark:border-amber-900/50 dark:bg-amber-950/30 dark:text-amber-200":"border-border/70 text-muted-foreground"),children:[t.note.tone==="warn"?/* @__PURE__ */e(sd,{className:"mt-0.5 h-3.5 w-3.5 shrink-0","aria-hidden":!0}):/* @__PURE__ */e(ut,{className:"mt-0.5 h-3.5 w-3.5 shrink-0","aria-hidden":!0}),/* @__PURE__ */e("span",{children:t.note.text})]})]})]});}const yp=[];function Np({onRemoveField:t,onResetFields:a,groupByFields:s,pivotByFields:r,metricsFields:i,sortByFields:c,detailFields:d}){var Q,J,Z;const[l,o]=Y(!1),{startOver:x,restore:u}=Yo();E(G=>{var q;return!!((q=G.card.customCardPreferences)!=null&&q.url);});const p=E(G=>G.card),h=E(G=>G.frame),m=vt(h,p),{manifest:C}=bt(((Q=m==null?void 0:m.customCardPreferences)==null?void 0:Q.url)||""),S=(J=C==null?void 0:C.visuals)==null?void 0:J.find(G=>{var q;return G.name===((q=m==null?void 0:m.customCardPreferences)==null?void 0:q.componentName);}),w=yt(m,S)==="multiple";w&&(Z=m==null?void 0:m.customCardPreferences)!=null&&Z.url;const v=Md(S==null?void 0:S.slots);E(G=>G.actions.updateCardConfig);const y=E(G=>G.actions.updateCard),A=fe(G=>G.actions.updateDashboardCalculatedFields),z=fe(G=>{var q;return G.visualEditPendingDashboardCalculatedFields??((q=G.dashboard)==null?void 0:q.calculatedFields);})??yp,{scopedFields:B}=Wr(),{userContext:j}=on(),$=w&&(m==null?void 0:m.id)===p.id&&v?v:p==null?void 0:p.type,I=$==="detailTable",O=s.length>0||i.length>0||d.length>0,L=!I&&($!=="kpi"||i.length<=2),k=!I,K=!I&&$!=="kpi",M=$!=="kpi"&&$!=="matrixTable"&&O,f=I,F="Drop sort fields here",g=Xo(j),N=["pie","doughnut","polar","funnel","bubble","scatter"].includes($),T=K&&!N,_=$==="kpi"&&p.type==="kpi"&&!w&&!nn(p),P=G=>$==="kpi"?{label:"Trend By",placeholder:zd(G)??"Drop trend field here"}:{label:"Rows",placeholder:"Drop dimensions here"},R=()=>$==="kpi"?{label:"Metric",placeholder:"Drop metric here"}:{label:"Metrics",placeholder:"Drop metrics here"},V=(G,q)=>/* @__PURE__ */n("div",{className:"space-y-3 px-4 pb-6 pt-3",children:[L&&/* @__PURE__ */e(Bt,{zone:"groupBy",onRemoveField:t,fields:s,label:P(G).label,placeholder:P(G).placeholder}),T&&/* @__PURE__ */e(Bt,{zone:"pivotBy",onRemoveField:t,fields:r,label:"Pivot Columns",placeholder:"Drop pivot fields here"}),k&&/* @__PURE__ */e(Bt,{zone:"metrics",onRemoveField:t,fields:i,label:R().label,placeholder:R().placeholder,hasPivotColumns:r.length>0}),f&&/* @__PURE__ */e(Bt,{zone:"detailColumns",onRemoveField:t,fields:d,label:"Columns",placeholder:"Drop columns here"}),i.length>=1&&g&&/* @__PURE__ */n(ce,{variant:"outline",size:"sm",onClick:()=>o(!0),className:"mt-1.5 w-full justify-start border-border/60 border-dashed bg-background text-xs text-foreground/70 hover:bg-muted/40 hover:text-foreground",children:[/* @__PURE__ */e(tc,{className:"mr-2 h-4 w-4"}),"Create Metric"]}),G&&/* @__PURE__ */e(bp,{view:G,trend:q}),M&&/* @__PURE__ */e(Bt,{zone:"sortBy",onRemoveField:t,fields:c,label:"Sort By",placeholder:F})]});return/* @__PURE__ */n(be,{children:[/* @__PURE__ */n("div",{"data-shelf-scroll-header":"",className:"sticky top-0 z-10 flex items-center justify-between bg-background px-4 py-2",children:[/* @__PURE__ */e("span",{className:"text-[11px] font-semibold uppercase tracking-[0.08em] text-foreground/70",children:"Fields"}),/* @__PURE__ */e(wp,{card:p,hasFields:O,onClearFields:()=>{var pe;const G=p,q=si.flatMap(ge=>{var Fe;return((Fe=G.config)==null?void 0:Fe[ge])??[];}),ae=((pe=$a(G))==null?void 0:pe.joins)??[];a();const de=q.map(ge=>ge.label||ge.name),he=de.length>4?`${de.slice(0,3).join(", ")} and ${de.length-3} more`:de.join(", "),ie=ae.length===1?` The join to ${Ir(ae[0].target)} stays.`:ae.length?" The joins stay.":"";$e("Cleared the fields",{description:`${he?`Removed ${he}.`:""}${ie}`.trim()||void 0,action:{label:"Undo",onClick:()=>u(G)}});},onStartOver:x})]}),_?/* @__PURE__ */e(xp,{card:p,metric:i[0],children:(G,q)=>V(G,q)}):V(void 0),/* @__PURE__ */e(Jo,{open:l,onOpenChange:o,availableFields:B,initialFieldType:"metric",allowedFieldTypes:["metric"],onSave:G=>{if(G.role!=="metric")return;const{nextStoredFields:q}=ec({storedFields:p.calculatedFields||[],sharedFields:z,updatedField:G,previousScope:"card"});y(p.id,{calculatedFields:q});},onSaveToDashboard:G=>{if(G.role!=="metric")return;const{nextSharedFields:q}=Zo({storedFields:p.calculatedFields||[],sharedFields:z,updatedField:G,previousScope:"dashboard"});A(q);},cardId:p.id})]});}function Cp(){var A,b,z;const t=E(B=>{var j;return(j=B.card)==null?void 0:j.type;}),a=t==="kpi",s=t==="customVisual",[r,i]=Y(a||s),[c,d]=Y(!1),l=E(B=>{var j;return!!((j=B.card.customCardPreferences)!=null&&j.url);}),o=E(B=>B.card),x=E(B=>B.frame),u=vt(x,o),{manifest:p}=bt(((A=u==null?void 0:u.customCardPreferences)==null?void 0:A.url)||""),h=(b=p==null?void 0:p.visuals)==null?void 0:b.find(B=>{var j;return B.name===((j=u==null?void 0:u.customCardPreferences)==null?void 0:j.componentName);}),C=yt(u,h)==="multiple"&&!!((z=u==null?void 0:u.customCardPreferences)!=null&&z.url),S=!l||C,w=l||C,v=a?"KPI Settings":s?"Visual":"Chart Settings",y=S&&!ms(t);return ve(()=>{(a||s)&&i(!0);},[a,s]),!y&&!w?null:/* @__PURE__ */n("div",{className:"shrink-0 border-t border-border bg-background",children:[y&&r&&/* @__PURE__ */e("div",{className:W("overflow-y-auto border-b border-border px-4",a?"max-h-[72vh]":"max-h-[50vh]"),children:s?/* @__PURE__ */e(Ls,{}):/* @__PURE__ */e(ra,{type:"single",collapsible:!0,className:"w-full divide-y divide-border/60 [&_h3]:sticky [&_h3]:top-0 [&_h3]:z-10 [&_h3]:bg-background",children:/* @__PURE__ */e(Ks,{mode:"config"})})}),y&&/* @__PURE__ */n("button",{type:"button",onClick:()=>i(B=>!B),className:"flex w-full items-center justify-between px-4 py-2.5 text-left transition-colors hover:bg-muted/50",children:[/* @__PURE__ */n("span",{className:"inline-flex items-center gap-2",children:[/* @__PURE__ */e(fa,{className:"h-3.5 w-3.5 text-muted-foreground"}),/* @__PURE__ */e("span",{className:"text-[11px] font-semibold uppercase tracking-[0.08em] text-foreground/70",children:v})]}),/* @__PURE__ */e(Ft,{className:W("h-3 w-3 text-muted-foreground transition-transform",r&&"rotate-180"),strokeWidth:1.75})]}),w&&c&&/* @__PURE__ */e("div",{className:"max-h-[40vh] overflow-y-auto border-b border-t border-border px-4",children:/* @__PURE__ */e(Rs,{})}),w&&/* @__PURE__ */n("button",{type:"button",onClick:()=>d(B=>!B),className:W("flex w-full items-center justify-between px-4 py-2.5 text-left transition-colors hover:bg-muted/50",y&&"border-t border-border"),children:[/* @__PURE__ */n("span",{className:"inline-flex items-center gap-2",children:[/* @__PURE__ */e(ys,{className:"h-3.5 w-3.5 text-muted-foreground"}),/* @__PURE__ */e("span",{className:"text-[11px] font-semibold uppercase tracking-[0.08em] text-foreground/70",children:"Component settings"})]}),/* @__PURE__ */e(Ft,{className:W("h-3 w-3 text-muted-foreground transition-transform",c&&"rotate-180"),strokeWidth:1.75})]})]});}function wp({card:t,hasFields:a,onClearFields:s,onStartOver:r}){var d,l;if(!(t.type==="matrixTable"?[]:((d=$a(t))==null?void 0:d.joins)??[]).length)return a?/* @__PURE__ */e("button",{type:"button",onClick:s,className:"text-[11px] text-muted-foreground transition-colors hover:text-foreground",children:"Clear fields"}):null;const c=Ir((l=$a(t))==null?void 0:l.baseEntity);return/* @__PURE__ */n("div",{className:"flex items-center",children:[/* @__PURE__ */e("button",{type:"button",onClick:s,disabled:!a,className:"rounded-l-control px-1 text-[11px] text-muted-foreground transition-colors hover:text-foreground disabled:pointer-events-none disabled:opacity-40",children:"Clear fields"}),/* @__PURE__ */n(ma,{modal:!1,children:[/* @__PURE__ */e(ha,{asChild:!0,children:/* @__PURE__ */e("button",{type:"button","aria-label":"More ways to clear",className:"rounded-r-control px-0.5 text-muted-foreground transition-colors hover:text-foreground",children:/* @__PURE__ */e(Ft,{className:"h-3 w-3"})})}),/* @__PURE__ */n(pa,{align:"end",className:"w-[240px]",children:[/* @__PURE__ */n(Ge,{disabled:!a,onClick:s,className:"flex flex-col items-start gap-0",children:[/* @__PURE__ */e("span",{className:"text-[12.5px]",children:"Clear fields"}),/* @__PURE__ */e("span",{className:"text-[11px] text-muted-foreground",children:"Empty the shelves; joins stay"})]}),/* @__PURE__ */n(Ge,{onClick:r,className:"flex flex-col items-start gap-0",children:[/* @__PURE__ */e("span",{className:"text-[12.5px]",children:"Start over"}),/* @__PURE__ */n("span",{className:"text-[11px] text-muted-foreground",children:["Clear fields and joins; keep ",/* @__PURE__ */e("span",{className:"font-mono",children:c})]})]})]})]})]});}function Sp(){const t=E(l=>l.card),{autoJoinMetadata:a}=je(t);if(!(a!=null&&a.autoResolved))return null;const{resolvedJoinPlan:s}=a,r=(s==null?void 0:s.joins)||[];if(r.length===0)return null;const i=l=>!l||l.length===0?"No conditions":l.map(o=>{var h,m,C,S;const x=`${(h=o.source)==null?void 0:h.entityName}.${(m=o.source)==null?void 0:m.name}`,u=`${(C=o.target)==null?void 0:C.entityName}.${(S=o.target)==null?void 0:S.name}`,p=o.operator||"=";return`${x} ${p} ${u}`;}).join(" AND "),c=l=>!l.joinKeyGroups||l.joinKeyGroups.length===0?"No conditions defined":l.joinKeyGroups.length===1?i(l.joinKeyGroups[0].keys):l.joinKeyGroups.map((o,x)=>({id:x,operator:o.operator,condition:i(o.keys)})),d=/* @__PURE__ */e(Lt,{children:/* @__PURE__ */n(mt,{children:[/* @__PURE__ */e(ht,{asChild:!0,children:/* @__PURE__ */e("button",{type:"button",className:"shrink-0 cursor-help rounded-control px-1 font-mono text-[10px] tabular-nums text-muted-foreground/70 transition-colors hover:bg-muted hover:text-foreground","aria-label":`${r.length} resolved ${r.length===1?"join":"joins"}`,children:r.length})}),/* @__PURE__ */e(pt,{side:"bottom",align:"start",className:"max-w-md border border-border bg-popover p-2 text-popover-foreground shadow-[0_4px_16px_rgba(0,0,0,0.08)]",children:/* @__PURE__ */e("div",{className:"space-y-2",children:r.map((l,o)=>{const x=c(l),u=Array.isArray(x);return/* @__PURE__ */n("div",{className:"rounded-md border border-border bg-background p-2 text-foreground",children:[/* @__PURE__ */n("div",{className:"mb-1 flex items-center justify-between gap-2",children:[/* @__PURE__ */n("div",{className:"flex items-center gap-2 text-xs",children:[/* @__PURE__ */e("span",{className:"font-medium text-foreground",children:l.source.name}),/* @__PURE__ */e(ld,{className:"size-3 text-muted-foreground"}),/* @__PURE__ */e("span",{className:"font-medium text-foreground",children:l.target.name})]}),/* @__PURE__ */e("span",{className:"shrink-0 rounded-[3px] border border-border px-1 font-mono text-[10px] uppercase tracking-[0.06em] text-muted-foreground",children:l.joinType})]}),/* @__PURE__ */e("div",{className:"mt-1 space-y-1",children:u?x.map(p=>/* @__PURE__ */n("div",{className:"rounded bg-muted/30 px-2 py-1",children:[/* @__PURE__ */e("code",{className:"block break-all text-xs text-muted-foreground",children:p.condition}),p.operator&&/* @__PURE__ */n("span",{className:"ml-2 text-xs text-muted-foreground",children:["(",p.operator,")"]})]},p.id)):/* @__PURE__ */e("div",{className:"rounded bg-muted/30 px-2 py-1",children:/* @__PURE__ */e("code",{className:"block break-all text-xs text-muted-foreground",children:x})})})]},l.id||o);})})})]})});return/* @__PURE__ */n("div",{className:"flex h-7 w-full items-center gap-2 rounded-control border border-input bg-background px-2 text-left transition-colors hover:bg-muted",children:[/* @__PURE__ */e(ac,{className:"h-3 w-3 shrink-0 text-muted-foreground",strokeWidth:1.75}),/* @__PURE__ */e("span",{className:"min-w-0 flex-1 truncate text-[13px] text-foreground",children:"Resolved joins"}),d]});}function Tp({onRemoveField:t,onResetFields:a,selectedChart:s,onChartChange:r,isVisible:i=!0,onToggleVisibility:c,groupByFields:d,pivotByFields:l,metricsFields:o,sortByFields:x,detailFields:u}){const p=E(m=>m.editorContext),h=(p==null?void 0:p.type)==="documentSection";return i?/* @__PURE__ */n("div",{"data-content":"Chart Configuration Panel",className:"flex w-[325px] min-w-[325px] shrink-0 flex-col overflow-hidden border-r border-border bg-background transition-all duration-300 ease-in-out",children:[!h&&/* @__PURE__ */n("div",{className:"flex items-start",children:[/* @__PURE__ */e("div",{className:"min-w-0 flex-1",children:/* @__PURE__ */e(nm,{selectedChart:s,onChartChange:r})}),c&&/* @__PURE__ */e("div",{className:"px-2 pt-4",children:/* @__PURE__ */e(Ve,{tooltip:"Hide chart configuration","aria-label":"Hide chart configuration",onClick:c,className:"h-7 w-7 rounded-[5px] p-0 text-muted-foreground hover:text-foreground",children:/* @__PURE__ */e(id,{className:"h-4 w-4",strokeWidth:1.75})})})]}),/* @__PURE__ */n(xn,{className:"min-h-0 w-full flex-1 basis-0 border-t border-border [&>[data-radix-scroll-area-viewport]]:overscroll-none [&>[data-radix-scroll-area-viewport]>div]:!block [&>[data-radix-scroll-area-viewport]>div]:w-full",children:[/* @__PURE__ */e("div",{className:"px-4 pt-4 empty:hidden",children:/* @__PURE__ */e(Sp,{})}),/* @__PURE__ */e(Np,{onRemoveField:t,onResetFields:a,groupByFields:d,pivotByFields:l,metricsFields:o,sortByFields:x,detailFields:u})]}),/* @__PURE__ */e(Cp,{})]}):/* @__PURE__ */e("div",{"data-content":"Chart Configuration Panel (collapsed)",className:"flex w-9 shrink-0 flex-col items-center border-r border-border bg-background transition-all duration-300 ease-in-out",children:c&&/* @__PURE__ */e(Ve,{tooltip:"Show chart configuration","aria-label":"Show chart configuration",onClick:c,className:"mt-3 h-7 w-7 rounded-[5px] p-0 text-muted-foreground hover:text-foreground",children:/* @__PURE__ */e(nt,{className:"h-4 w-4",strokeWidth:1.75})})});}function kp({cardId:t,filters:a,onFiltersChange:s,onClearFilters:r,availableFields:i,source:c,isOpen:d,onOpenChange:l}){return/* @__PURE__ */n(Ht,{modal:!1,open:d,onOpenChange:l,children:[d&&/* @__PURE__ */e("div",{className:"pointer-events-none fixed inset-0 z-40 bg-zinc-950/40 backdrop-blur-sm"}),/* @__PURE__ */n(Ut,{className:"flex max-h-[80vh] w-[min(880px,92vw)] max-w-none flex-col gap-0 overflow-hidden p-0 [&>button:last-child]:top-3",onInteractOutside:u=>{u.preventDefault();},children:[/* @__PURE__ */n("div",{className:"flex h-10 shrink-0 items-center gap-2 border-b border-border pl-3 pr-10",children:[/* @__PURE__ */e(xa,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),/* @__PURE__ */e(Gt,{className:"truncate text-[13px] font-medium",children:"Card filters"}),/* @__PURE__ */e(Et,{className:"sr-only",children:"Add filters to the card to limit the data that is displayed."})]}),/* @__PURE__ */e(Pd,{filters:a,availableFields:i,source:c,onSave:u=>{s(t,u),l(!1);},onCancel:()=>l(!1),onClearAll:()=>{r(t),l(!1);}})]})]});}function Ip({activeView:t,onViewChange:a,splitViewEnabled:s,hasQueryError:r=!1}){const i=E(x=>x.card),{config:c}=wn(bn).tokenProps,d=(c==null?void 0:c.showInfoTab)!==!1&&Er(i.type),l=!s&&ln(i.type),o=[{id:"chart",label:"Visual"}];return l&&o.push({id:"table",label:"Results"}),d&&o.push({id:"info",label:r?"Error":"Info",isError:r}),/* @__PURE__ */e(ft,{value:t,onValueChange:x=>a(x),children:/* @__PURE__ */e(gt,{variant:"underline",className:"gap-5 border-b-0",children:o.map(x=>/* @__PURE__ */e(qe,{value:x.id,className:W("px-0 text-[13px]",x.isError&&"text-destructive hover:text-destructive focus-visible:text-destructive data-[state=active]:border-destructive data-[state=active]:text-destructive"),children:x.label},x.id))})});}const Ep=[{value:"10",label:"10"},{value:"20",label:"20"},{value:"50",label:"50"},{value:"100",label:"100"},{value:"200",label:"200"},{value:"500",label:"500"},{value:"1000",label:"1,000"}];function Fp(){var s,r;const t=E(i=>i.card),{updateRowLimit:a}=me();return/* @__PURE__ */n(ne,{value:((r=(s=t.config)==null?void 0:s.rowLimit)==null?void 0:r.toString())||"100",onValueChange:i=>a(t.id,parseInt(i)),children:[/* @__PURE__ */n(re,{size:"xs","aria-label":"Row limit",className:"h-6 w-auto gap-1 rounded-control border-transparent bg-transparent px-1.5 py-0 text-[11px] text-muted-foreground shadow-none transition-colors hover:bg-accent hover:text-accent-foreground [&>svg]:h-3 [&>svg]:w-3",children:[/* @__PURE__ */e("span",{children:"Limit"}),/* @__PURE__ */e("span",{className:"font-medium tabular-nums text-foreground",children:/* @__PURE__ */e(se,{})})]}),/* @__PURE__ */e(le,{align:"end",children:Ep.map(i=>/* @__PURE__ */e(U,{value:i.value,className:"text-[12px] tabular-nums",children:i.label},i.value))})]});}function Mp({card:t,queryData:a,isLoading:s,isFetching:r,pagination:i,onPaginationChange:c,onSortChange:d,sortState:l,splitViewEnabled:o}){var u;const x=X(()=>(a==null?void 0:a.records)||[],[a==null?void 0:a.records]);return!o||!ln(t.type)?/* @__PURE__ */e(an,{}):/* @__PURE__ */n(Za,{direction:"vertical",className:"h-full min-h-0 w-full",children:[/* @__PURE__ */e(Ct,{defaultSize:60,minSize:30,role:"chart-section",className:"flex flex-col",children:/* @__PURE__ */e(an,{})}),/* @__PURE__ */e(ws,{withHandle:!0,title:"Drag to resize."}),/* @__PURE__ */e(Ct,{defaultSize:40,minSize:20,role:"results-section",className:"flex flex-col",children:/* @__PURE__ */n("div",{className:W("relative flex h-full min-h-0 max-w-full flex-1 grow basis-0",cn),children:[(s||r)&&(a==null?void 0:a.records)&&/* @__PURE__ */e("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-background/50",children:/* @__PURE__ */e(tt,{size:"md",color:"muted","aria-label":"Loading data"})}),(a==null?void 0:a.records)&&/* @__PURE__ */e(Zt,{card:t,data:x,resultColumns:a==null?void 0:a.columns,columnKeyMap:a==null?void 0:a.columnKeyMap,totalsByColumnId:a==null?void 0:a.tableTotalsByColumnId,columnTotals:a==null?void 0:a.tableColumnTotals,comparisonMetadata:(u=a==null?void 0:a.metadata)==null?void 0:u.comparisonMetadata,paginationMetadata:i,onPaginationChange:c,isLoading:s||r,onSortChange:d,sortState:l})]})})]});}function Op(t,a){const[s,r]=Y(()=>{const i=localStorage.getItem(t);return i?JSON.parse(i):a;});return ve(()=>{localStorage.setItem(t,JSON.stringify(s));},[s,t]),[s,r];}const Ap="semaphor-split-view-enabled";function Rp(){return Op(Ap,!0);}function Lp({error:t,showInfoTab:a}){return/* @__PURE__ */e(nc,{className:"mx-4 mt-3",hint:a?"The Error tab has the query and its payload.":"Contact your administrator for help resolving this issue.",detail:a?t:void 0});}function Pp({card:t,effectiveCardType:a=t.type,queryOutput:s}){return sn(a)?/* @__PURE__ */n(od,{modal:!1,children:[/* @__PURE__ */e(cd,{asChild:!0,children:/* @__PURE__ */e(Ve,{tooltip:"Table settings",className:"h-7 w-7 rounded-[5px] p-0",buttonProps:{type:"button","aria-label":"Table settings"},children:/* @__PURE__ */e(fa,{className:"h-3.5 w-3.5",strokeWidth:1.75})})}),/* @__PURE__ */n(dd,{side:"right",hideOverlay:!0,className:"flex w-[420px] flex-col gap-0 p-0 sm:max-w-[420px]",children:[/* @__PURE__ */e(ud,{className:"sr-only",children:"Table settings"}),/* @__PURE__ */e(md,{className:"sr-only",children:"Configure table presentation and conditional formatting."}),/* @__PURE__ */n("div",{className:"border-b px-4 py-3",children:[/* @__PURE__ */e("div",{className:"text-[13px] font-semibold text-foreground",children:"Table settings"}),/* @__PURE__ */e("div",{className:"mt-0.5 text-[11px] text-muted-foreground",children:"Settings apply to this table and document exports that reuse it."})]}),/* @__PURE__ */e("div",{className:"min-h-0 flex-1 overflow-auto",children:/* @__PURE__ */e(zs,{cardType:a,queryOutput:s,focusSection:"style"})})]})]}):null;}function Dp({className:t,visible:a}){const s=fe(l=>l.selectedFrameId),r=rc(l=>l.selectedVisual),i=E(l=>l.frame),d=!!!(i!=null&&i.visualId||r!=null&&r.id)&&!!s;return!a||d?null:/* @__PURE__ */e("div",{className:W("flex",t),children:/* @__PURE__ */e(ps,{showLabel:!0,className:"h-6 w-fit px-2 py-0.5 text-[11px]"})});}function _p({activeView:t,onViewChange:a,onFiltersClick:s,activeCard:r}){var Ue;const i=E(ue=>ue.card),c=E(ue=>ue.inlineFilterValuesMap[(r==null?void 0:r.id)||""]),d=E(ue=>ue.actions.removeCardInlineFilterValue),l=fe(ue=>ue.selectedSheetId),{updateCardConfig:o,setCard:x,updateCardInFrame:u}=me(),[p,h]=Y(!1),[m,C]=Y(!1),[S,w]=Y(null),{config:v}=wn(bn).tokenProps,y=(v==null?void 0:v.showInfoTab)!==!1,A=(v==null?void 0:v.showQueryDebugTools)!==!1,[b,z]=Rp(),B=ln(i.type),j=y&&Er(i.type),$=y&&!j,I=t==="table"&&(b||!B)||t==="info"&&!j?"chart":t;E(ue=>{var Ce;return!!((Ce=ue.card.customCardPreferences)!=null&&Ce.url);});const O=Be(),{data:L,errorMessage:k,isLoading:K,isFetching:M,errorSql:f,pagination:F,refetch:g,comparisonMetadata:N,queryRequestPayload:T,resolvedPrimaryDateField:_}=je(r),P=da(r,L),R=()=>{var Me;const ue=fe.getState(),Ce=qu(Fn.QUERY_GENERATION,{cardConfig:i.config,dataSource:r.dataSource,dashboardFilters:Hd({dashboard:ue.dashboard,runtimeValues:{dashboardInputValues:ue.dashboardInputValues},adHocFilterValues:ue.adHocFilterValues,sheetId:l,sheetKind:"dashboard",calendar:((Me=ue.reportContext)==null?void 0:Me.calendar)??null}),errorMessage:k,errorSql:f,generatedSql:L==null?void 0:L.sql});w(Ce),C(!0);},V=()=>{const ue=E.getState().actions;ue.setIsDevMode(!0),ue.setCardSql(f||""),setTimeout(()=>{ue.setRunSql(!0);},100);},Q=A?{queryRequest:T,queryResponse:L}:void 0,J=X(()=>(L==null?void 0:L.records)||[],[L==null?void 0:L.records]),Z=X(()=>!M&&J.length>0?Object.keys(J[0]):[],[M,J]),G=X(()=>({keys:Z,columnKeyMap:L==null?void 0:L.columnKeyMap,resultColumns:L==null?void 0:L.columns}),[Z,L==null?void 0:L.columnKeyMap,L==null?void 0:L.columns]),q=jr(r),ae=E(ue=>ue.frame),[de,he]=Y(),ie=()=>{const ue=!b;ue&&I==="table"&&a("chart"),z(ue);},pe=(ue,Ce)=>{const Me={...r,paginationConfig:{page:ue+1,pageSize:Ce}};x(Me),u(Me);},ge=ue=>{if(!i.config)return;const Ce=Vr(ue,i.config.metricColumns,i.config.groupByColumns,i.config.detailColumns);o(i.id,{...i.config,sortByColumns:Ce});},Fe=X(()=>{var ue;return sc((ue=i.config)==null?void 0:ue.sortByColumns);},[(Ue=i.config)==null?void 0:Ue.sortByColumns]),Re=lc(Xt(r)||null);return/* @__PURE__ */e("div",{className:"relative flex w-0 grow flex-col",children:/* @__PURE__ */n("div",{className:"group/visualization relative flex h-full max-w-full grow flex-col",children:[/* @__PURE__ */n("div",{className:"flex h-11 items-center gap-3 border-b border-border px-4",children:[/* @__PURE__ */n("div",{className:"flex items-baseline gap-3",children:[/* @__PURE__ */e("div",{className:"flex h-11 items-end gap-5",children:/* @__PURE__ */e(Ip,{activeView:I,onViewChange:a,splitViewEnabled:b,hasQueryError:!!k})}),O==="kpi"&&/* @__PURE__ */e(Dp,{visible:!0,className:"self-center"}),N&&i.type!=="table"&&/* @__PURE__ */e(hd,{metadata:N})]}),/* @__PURE__ */n("div",{className:"flex grow items-center justify-end gap-1",children:[!pd(O)&&/* @__PURE__ */e(Fp,{}),/* @__PURE__ */e(ic,{cardId:r.id,cardFilters:Xt(r),cardFilterCount:Re,onFiltersClick:s,inlineFilters:ii(r),inlineFilterValues:li(r,c),sheetId:l||"",removeInlineFilterValue:ue=>d(r.id,ue),resolvedPrimaryDateField:_}),I==="chart"&&/* @__PURE__ */e(Pp,{card:r,effectiveCardType:O,queryOutput:G}),I==="chart"&&/* @__PURE__ */e(Os,{showInlineFilters:!1,showControls:!1,showDisplayOptions:!1}),/* @__PURE__ */n(ma,{modal:!1,children:[/* @__PURE__ */e(ha,{asChild:!0,children:/* @__PURE__ */e(Ve,{tooltip:"More Options",className:"h-7 w-7 rounded-[5px] p-0","aria-label":"More options",children:/* @__PURE__ */e(Hr,{className:"h-3.5 w-3.5"})})}),/* @__PURE__ */n(pa,{align:"end",className:"w-60",children:[/* @__PURE__ */n(Ge,{disabled:q?q.isFetching:K||M,onSelect:()=>{var ue;if(q){(ue=q.refresh)==null||ue.call(q);return;}g();},children:[/* @__PURE__ */e(Ja,{className:"h-3.5 w-3.5 text-muted-foreground"}),"Refresh"]}),I==="chart"&&/* @__PURE__ */n(be,{children:[/* @__PURE__ */n(Ge,{onSelect:s,children:[/* @__PURE__ */e(xa,{className:"h-3.5 w-3.5 text-muted-foreground"}),"Card filters",Re>0&&/* @__PURE__ */e("span",{className:"ml-auto text-[11px] tabular-nums text-muted-foreground",children:Re})]}),/* @__PURE__ */e(On,{triggerVariant:"menu",className:"w-full"}),/* @__PURE__ */e(An,{triggerVariant:"menu",className:"w-full"}),/* @__PURE__ */e(Mn,{triggerVariant:"menu",className:"w-full"}),B&&/* @__PURE__ */n(Ge,{onClick:ie,children:[b?/* @__PURE__ */e(gu,{className:"h-3.5 w-3.5 text-muted-foreground"}):/* @__PURE__ */e(yu,{className:"h-3.5 w-3.5 text-muted-foreground"}),b?"Hide results table":"Show results table"]}),q&&/* @__PURE__ */n(Ge,{disabled:q.isFetching||!q.hasDelivery,title:q.hasDelivery?void 0:"Available once the preview has loaded.",onClick:()=>he(q.readDelivery()),children:[/* @__PURE__ */e(Qa,{className:"h-3.5 w-3.5 text-muted-foreground"}),"Download"]})]})]})]})]})]}),/* @__PURE__ */n("div",{className:"flex min-h-0 grow flex-col",children:[I==="chart"?k?$?/* @__PURE__ */e("div",{className:"flex min-h-0 flex-1 flex-col px-1 pb-2",children:/* @__PURE__ */e(jn,{error:k,errorSql:f,onSendFeedback:R,onOpenInEditor:rn(i.type)?V:void 0})}):/* @__PURE__ */e(Lp,{error:k,showInfoTab:j}):/* @__PURE__ */e("div",{className:"flex grow flex-col",children:/* @__PURE__ */e(Mp,{card:P,queryData:L,isLoading:K,isFetching:M,pagination:F,onPaginationChange:pe,onSortChange:ge,sortState:Fe,splitViewEnabled:b})}):null,I==="table"&&(L==null?void 0:L.records)&&/* @__PURE__ */n("div",{className:W("relative flex h-full min-h-0 max-w-full flex-1 grow basis-0",cn),children:[(K||M)&&(L==null?void 0:L.records)&&/* @__PURE__ */e("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-background/50",children:/* @__PURE__ */e(tt,{size:"md",color:"muted","aria-label":"Loading data"})}),/* @__PURE__ */e(Zt,{card:P,data:J,resultColumns:L.columns,columnKeyMap:L.columnKeyMap,totalsByColumnId:L==null?void 0:L.tableTotalsByColumnId,columnTotals:L==null?void 0:L.tableColumnTotals,comparisonMetadata:N,paginationMetadata:F,onPaginationChange:pe,isLoading:K||M,onSortChange:ge,sortState:Fe})]}),I==="info"&&j&&/* @__PURE__ */e("div",{className:"flex min-h-0 flex-1 flex-col pb-2",children:/* @__PURE__ */e("div",{className:"flex min-h-0 flex-1 flex-col rounded-md bg-background px-1",children:k?/* @__PURE__ */e(jn,{error:k,errorSql:f,defaultDetailsOpen:!0,debugPayloads:Q,onSendFeedback:R,onOpenInEditor:V}):((L==null?void 0:L.sql)&&/* @__PURE__ */e(As,{sql:L.sql,debugPayloads:Q}))})})]}),de&&r&&ae&&/* @__PURE__ */e(is,{isOpen:!0,onClose:()=>he(void 0),card:r,frame:ae,matrix:de}),S&&/* @__PURE__ */e(En,{open:m,onOpenChange:C,feedbackData:S})]})});}const Vp=()=>{const t=console.error;console.error=(...r)=>{r.length>0&&typeof r[0]=="string"&&r[0].includes("ResizeObserver loop completed with undelivered notifications")||t.apply(console,r);};const a=r=>{if(r.message&&(r.message.includes("ResizeObserver loop completed with undelivered notifications")||r.message.includes("ResizeObserver loop limit exceeded")))return r.preventDefault(),r.stopPropagation(),!1;},s=r=>{var i;if((i=r.reason)!=null&&i.message&&(r.reason.message.includes("ResizeObserver loop completed with undelivered notifications")||r.reason.message.includes("ResizeObserver loop limit exceeded")))return r.preventDefault(),!1;};return window.addEventListener("error",a,!0),window.addEventListener("unhandledrejection",s,!0),()=>{console.error=t,window.removeEventListener("error",a,!0),window.removeEventListener("unhandledrejection",s,!0);};};function Bp(){const[t,a]=Y("chart"),[s,r]=Y(!1),[i,c]=Y(!0),[d,l]=Y(!0),o=fe(F=>F.isVisualEditing),x=In(),u=E(F=>F.card.type);ve(()=>Vp(),[]);const p=F=>{x(F);},h=E(F=>F.frame),m=E(F=>F.card);E(F=>F.activeTabCardId),E(F=>F.actions.getAvailableFields);const{addCard:C,removeCard:S,updateCard:w,setActiveCard:v,updateFilters:y,clearFilters:A}=me(),{scopedFields:b=[]}=$r(),z=m,{getFieldsForContainer:B,placeField:j,previewFieldPlacement:$,removeField:I,resetFields:O}=pn(z,b),L=(F,g)=>{g&&y(F,g);},k=F=>{A(F);},{filterableFields:K}=oc(m),M=F=>{if(!F)return 0;let g=F.conditions.length;return F.groups.forEach(N=>{g+=M(N);}),g;},f=M(Xt(z)||null);return(/* @__PURE__ */n(cc,{activeCardId:h.activeCardId,placeField:j,previewFieldPlacement:$,children:[/* @__PURE__ */n("div",{className:"flex h-full grow",children:[/* @__PURE__ */e(Cs,{isVisible:i,onToggleVisibility:()=>c(!i)}),/* @__PURE__ */n("div",{className:"flex flex-1 transition-all duration-300 ease-in-out",children:[/* @__PURE__ */e(Tp,{onRemoveField:I,onResetFields:O,selectedChart:u,onChartChange:p,groupByFields:B("groupBy"),pivotByFields:B("pivotBy"),metricsFields:B("metrics"),sortByFields:B("sortBy"),detailFields:B("detailColumns"),isVisible:d,onToggleVisibility:()=>l(!d)}),/* @__PURE__ */e(_p,{selectedChart:u,activeView:t,onViewChange:a,onFiltersClick:()=>r(!0),filterCount:f,activeCard:z,getFieldsForContainer:B,cards:h.cards,activeCardId:h.activeCardId,addCard:C,setActiveCard:v})]}),!i&&o&&/* @__PURE__ */e("div",{className:"fixed left-6 top-[105px] z-50",children:/* @__PURE__ */e(ce,{size:"sm",variant:"outline",className:"h-10 w-10 rounded-full border-border bg-background p-0 shadow-lg hover:bg-muted",onClick:()=>c(!0),title:"Show Data Source Panel",children:/* @__PURE__ */e(fd,{className:"h-4 w-4"})})})]}),z&&/* @__PURE__ */e(kp,{cardId:z.id,filters:Xt(z)||null,onFiltersChange:L,onClearFilters:k,availableFields:K,isOpen:s,onOpenChange:r})]}));}function zp({authToken:t,onSave:a,onClose:s}){const r=E(u=>u.isDevMode),i=vn(),{setAuthToken:c}=gd(),{setOnSave:d,setOnClose:l}=me();ve(()=>{a&&d(a),s&&l(s);},[a,d,s,l]),ve(()=>{t&&t.accessToken&&c(t);},[t,c]);function o(){return/* @__PURE__ */n(be,{children:[/* @__PURE__ */e(Cs,{isVisible:!0,onToggleVisibility:()=>{}}),/* @__PURE__ */e("div",{className:"relative flex grow",children:/* @__PURE__ */e("div",{"data-content":"editor-main",className:"min-w-[510px] flex-1 basis-0 overflow-hidden",children:/* @__PURE__ */e(ip,{})})})]});}function x(){return/* @__PURE__ */e("div",{className:"relative flex h-full grow",children:/* @__PURE__ */e("div",{"data-content":"explorer",className:"min-w-[510px] flex-1 basis-0 overflow-hidden",children:/* @__PURE__ */e(Bp,{})})});}return(/* @__PURE__ */e(xd,{children:/* @__PURE__ */e(ua,{FallbackComponent:dc,children:r?/* @__PURE__ */e("section",{className:"isolate flex h-full grow","data-content":"editor-panel",style:i.dashboardContainerStyle,children:o()}):/* @__PURE__ */e("section",{className:"isolate flex h-full grow","data-content":"editor-panel",style:i.dashboardContainerStyle,children:x()})})}));}function Nf(){fe(m=>m.selectedCardId);const t=fe(m=>m.selectedSheetId),a=fe(m=>m.dashboard),{setIsVisualEditing:s,setSelectedSheetId:r}=fe(m=>m.actions),i=E(m=>m.editorContext),{clearEditorContext:c}=E(m=>m.actions),d=uc(),l=vn(),o=fe(m=>m.isVisualEditing),x=fe(m=>m.actions.updateFrame),u=mc();async function p(m){var y,A,b;if((i==null?void 0:i.type)==="documentSection"){await d.commit(m);return;}const C=t?(y=a==null?void 0:a.sheets)==null?void 0:y.some(z=>{var B;return z.id===t&&((B=z.frames)==null?void 0:B.some(j=>j.id===m.id));}):!1,S=(b=(A=a==null?void 0:a.sheets)==null?void 0:A.find(z=>{var B;return(B=z.frames)==null?void 0:B.some(j=>j.id===m.id);}))==null?void 0:b.id,w=C?t:S||null;if(!w)return;const v=oi(a,m.id);try{const z=await u(m,{previousFrame:v});x(w,m,{semanticExecutionPayload:z,origin:"editor"}),t!==w&&r(w),s(!1);}catch(z){console.error("Failed to resolve semantic metadata on save:",z),$e.error(z instanceof Error?z.message:"Failed to resolve semantic metadata for this visual");}}function h(){if((i==null?void 0:i.type)==="documentSection"){d.discard();return;}c(),s(!1);}return/* @__PURE__ */e("div",{role:"editor-container",className:W("flex-1 grow basis-0 overflow-auto",{"max-h-0 overflow-hidden":!o}),style:l.dashboardContainerStyle,children:/* @__PURE__ */e(zp,{onSave:p,onClose:h})});}export{Nf as default};