react-semaphor 0.1.247 → 0.1.248

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 (26) hide show
  1. package/dist/chunks/{dashboard-controls-D8wqZxCi.js → dashboard-controls-CcBYCUyU.js} +1 -1
  2. package/dist/chunks/{dashboard-controls-qYUMEzBr.js → dashboard-controls-ftroIaNx.js} +4 -4
  3. package/dist/chunks/{dashboard-json-DujK2HDj.js → dashboard-json-DlMnblcC.js} +1 -1
  4. package/dist/chunks/{dashboard-json-B-bQL1ZF.js → dashboard-json-NeZhQblG.js} +1 -1
  5. package/dist/chunks/{dashboard-summary-settings-dialog-C83sgPRW.js → dashboard-summary-settings-dialog-BP2d8qXY.js} +1 -1
  6. package/dist/chunks/{dashboard-summary-settings-dialog-B9155s2W.js → dashboard-summary-settings-dialog-PIw3yw3g.js} +1 -1
  7. package/dist/chunks/{edit-dashboard-visual-BQYI84VR.js → edit-dashboard-visual-XRVx1WJw.js} +2 -2
  8. package/dist/chunks/{edit-dashboard-visual-D4O6wY24.js → edit-dashboard-visual-eZZFFLbw.js} +18 -12
  9. package/dist/chunks/{editor-action-buttons-vCojlAQ-.js → editor-action-buttons-D2GgF45c.js} +2 -2
  10. package/dist/chunks/{editor-action-buttons-DhhZOsQV.js → editor-action-buttons-tq0tFVfj.js} +1 -1
  11. package/dist/chunks/{index-CB2vXsPg.js → index-CFyPug8b.js} +27875 -28117
  12. package/dist/chunks/{index-iF4085Zd.js → index-DGpLwb-T.js} +210 -210
  13. package/dist/chunks/{notification-bell-C2K_DGKF.js → notification-bell--dNtQUYL.js} +3 -3
  14. package/dist/chunks/{notification-bell-WlmbKJeN.js → notification-bell-CLFSIKbb.js} +1 -1
  15. package/dist/chunks/{resource-management-panel-CbxtZtfG.js → resource-management-panel-C1tJjUe9.js} +1 -1
  16. package/dist/chunks/{resource-management-panel-DbiWt5FX.js → resource-management-panel-DjmiAnYz.js} +2 -2
  17. package/dist/chunks/{use-visual-utils-BzlMPpHV.js → use-visual-utils-B6nZIeae.js} +1 -1
  18. package/dist/chunks/{use-visual-utils-BKWme54p.js → use-visual-utils-Cdc_8imE.js} +1 -1
  19. package/dist/dashboard/index.cjs +1 -1
  20. package/dist/dashboard/index.js +1 -1
  21. package/dist/index.cjs +1 -1
  22. package/dist/index.js +5 -5
  23. package/dist/style.css +1 -1
  24. package/dist/surfboard/index.cjs +1 -1
  25. package/dist/surfboard/index.js +2 -2
  26. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("./index-iF4085Zd.js"),b=require("react");require("react-dom");const _=require("./notification-bell-WlmbKJeN.js"),Ss=require("./date-formatter-CqXdM6JO.js"),Pe=require("./dashboard-summary-settings-dialog-B9155s2W.js"),ys=require("./use-debounced-dirty-check-XHSwAefL.js"),xe=require("./normalize-dashboard-for-dirty-check-B7NQDI1H.js"),Fe=require("./editor-action-buttons-DhhZOsQV.js");function Ds(t){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const a in t)if(a!=="default"){const r=Object.getOwnPropertyDescriptor(t,a);Object.defineProperty(n,a,r.get?r:{enumerable:!0,get:()=>t[a]})}}return n.default=t,Object.freeze(n)}const w=Ds(b);/**
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("./index-DGpLwb-T.js"),b=require("react");require("react-dom");const _=require("./notification-bell-CLFSIKbb.js"),Ss=require("./date-formatter-CqXdM6JO.js"),Pe=require("./dashboard-summary-settings-dialog-PIw3yw3g.js"),ys=require("./use-debounced-dirty-check-XHSwAefL.js"),xe=require("./normalize-dashboard-for-dirty-check-B7NQDI1H.js"),Fe=require("./editor-action-buttons-tq0tFVfj.js");function Ds(t){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const a in t)if(a!=="default"){const r=Object.getOwnPropertyDescriptor(t,a);Object.defineProperty(n,a,r.get?r:{enumerable:!0,get:()=>t[a]})}}return n.default=t,Object.freeze(n)}const w=Ds(b);/**
2
2
  * @license lucide-react v0.453.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,14 +1,14 @@
1
1
  import { jsxs as r, jsx as e, Fragment as M } from "react/jsx-runtime";
2
- import { bK as Z, cL as wa, u as w, c0 as Ke, c1 as Qe, B as E, c3 as We, c4 as j, cM as Je, N as Es, b as G, e as Xe, cN as xa, b$ as Ye, f as Ze, g as es, h as ss, i as Ls, L as Re, I as oe, v as Da, a4 as V, cO as fe, c8 as Ge, cP as Ca, cQ as Ns, cR as As, c as X, cS as ks, cT as Ea, cq as as, cU as La, cV as Aa, cW as ka, cX as Ma, cY as Oa, cZ as Ia, H as be, c_ as ye, x as k, c$ as Ms, cA as Ta, d0 as _a, w as Y, c7 as H, d1 as Pa, d2 as Ua, d3 as Fe, d4 as Ra, d5 as Ga, d6 as Os, d7 as Is, d8 as ge, d9 as ve, cw as Ve, ce as je, da as qe, c9 as Ts, db as He, dc as _s, dd as Fa, ch as Ps, ci as Us, cj as Rs, ck as Gs, cl as Fs, cm as Vs, cn as js, co as $e, b_ as Va, de as ja, aa as qa, U as Ss, a9 as pe, df as Ha, ag as $a, ab as Te, dg as za, dh as Ba, di as Ka, av as Qa, dj as Wa, dk as Ja, bR as Xa, bS as Ya, bT as Za, dl as et, bV as st, c5 as at, an as tt, dm as rt, dn as nt, dp as ot, dq as it, dr as lt, ds as ct, c2 as dt, a6 as ut, cb as mt, dt as ht, af as pt, a7 as ft, am as gt } from "./index-CB2vXsPg.js";
2
+ import { bK as Z, cL as wa, u as w, c0 as Ke, c1 as Qe, B as E, c3 as We, c4 as j, cM as Je, N as Es, b as G, e as Xe, cN as xa, b$ as Ye, f as Ze, g as es, h as ss, i as Ls, L as Re, I as oe, v as Da, a4 as V, cO as fe, c8 as Ge, cP as Ca, cQ as Ns, cR as As, c as X, cS as ks, cT as Ea, cq as as, cU as La, cV as Aa, cW as ka, cX as Ma, cY as Oa, cZ as Ia, H as be, c_ as ye, x as k, c$ as Ms, cA as Ta, d0 as _a, w as Y, c7 as H, d1 as Pa, d2 as Ua, d3 as Fe, d4 as Ra, d5 as Ga, d6 as Os, d7 as Is, d8 as ge, d9 as ve, cw as Ve, ce as je, da as qe, c9 as Ts, db as He, dc as _s, dd as Fa, ch as Ps, ci as Us, cj as Rs, ck as Gs, cl as Fs, cm as Vs, cn as js, co as $e, b_ as Va, de as ja, aa as qa, U as Ss, a9 as pe, df as Ha, ag as $a, ab as Te, dg as za, dh as Ba, di as Ka, av as Qa, dj as Wa, dk as Ja, bR as Xa, bS as Ya, bT as Za, dl as et, bV as st, c5 as at, an as tt, dm as rt, dn as nt, dp as ot, dq as it, dr as lt, ds as ct, c2 as dt, a6 as ut, cb as mt, dt as ht, af as pt, a7 as ft, am as gt } from "./index-CFyPug8b.js";
3
3
  import * as L from "react";
4
4
  import qs, { useState as S, useMemo as q, useEffect as vt, useCallback as bt } from "react";
5
5
  import "react-dom";
6
- import { b as yt, u as Nt, c as St, A as wt, V as xt, N as Dt, U as Ct } from "./notification-bell-C2K_DGKF.js";
6
+ import { b as yt, u as Nt, c as St, A as wt, V as xt, N as Dt, U as Ct } from "./notification-bell--dNtQUYL.js";
7
7
  import { l as Et } from "./date-formatter-vkCj9Ct-.js";
8
- import { C as Lt, D as At } from "./dashboard-summary-settings-dialog-C83sgPRW.js";
8
+ import { C as Lt, D as At } from "./dashboard-summary-settings-dialog-BP2d8qXY.js";
9
9
  import { u as kt } from "./use-debounced-dirty-check-BwAbnX_5.js";
10
10
  import { s as _e } from "./normalize-dashboard-for-dirty-check-Bn27S0PN.js";
11
- import { S as ws } from "./editor-action-buttons-vCojlAQ-.js";
11
+ import { S as ws } from "./editor-action-buttons-D2GgF45c.js";
12
12
  /**
13
13
  * @license lucide-react v0.453.0 - ISC
14
14
  *
@@ -1,5 +1,5 @@
1
1
  import { jsxs as o, jsx as r } from "react/jsx-runtime";
2
- import { u as s, c as l, B as h, X as d, d as c } from "./index-CB2vXsPg.js";
2
+ import { u as s, c as l, B as h, X as d, d as c } from "./index-CFyPug8b.js";
3
3
  import "react";
4
4
  import "react-dom";
5
5
  function N() {
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),a=require("./index-iF4085Zd.js");require("react");require("react-dom");function i(){const o=a.useDashboardStore(e=>e.dashboard),r=a.useDashboardStore(e=>e.actions.setDashboard),t=a.useDashboardStore(e=>e.showDashboardJSON),n=a.useDashboardStore(e=>e.actions.setShowDashboardJSON);return s.jsxs("div",{className:a.cn("relative p-2",{hidden:!t}),children:[s.jsxs(a.Button,{variant:"secondary",size:"sm",className:"absolute right-2 top-2 z-10 h-8",onClick:()=>n(!1),children:[s.jsx(a.X,{className:"mr-2 h-4 w-4"}),"Close"]}),s.jsx(a.de,{onChange:e=>{if(e)try{JSON.parse(e),r(JSON.parse(e))}catch{}},defaultLanguage:"json",className:"h-[550px] overflow-y-auto",value:JSON.stringify(o,null,2),options:{minimap:{enabled:!1},glyphMargin:!1,wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:12,renderLineHighlight:"none"}})]})}exports.default=i;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),a=require("./index-DGpLwb-T.js");require("react");require("react-dom");function i(){const o=a.useDashboardStore(e=>e.dashboard),r=a.useDashboardStore(e=>e.actions.setDashboard),t=a.useDashboardStore(e=>e.showDashboardJSON),n=a.useDashboardStore(e=>e.actions.setShowDashboardJSON);return s.jsxs("div",{className:a.cn("relative p-2",{hidden:!t}),children:[s.jsxs(a.Button,{variant:"secondary",size:"sm",className:"absolute right-2 top-2 z-10 h-8",onClick:()=>n(!1),children:[s.jsx(a.X,{className:"mr-2 h-4 w-4"}),"Close"]}),s.jsx(a.de,{onChange:e=>{if(e)try{JSON.parse(e),r(JSON.parse(e))}catch{}},defaultLanguage:"json",className:"h-[550px] overflow-y-auto",value:JSON.stringify(o,null,2),options:{minimap:{enabled:!1},glyphMargin:!1,wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:12,renderLineHighlight:"none"}})]})}exports.default=i;
@@ -1,6 +1,6 @@
1
1
  import { jsx as e, jsxs as s, Fragment as oe } from "react/jsx-runtime";
2
2
  import de, { useState as h, useCallback as L, useEffect as G, useMemo as z } from "react";
3
- import { b as ue, e as X, f as Z, g as J, h as K, i as q, R as $, c as C, j as F, L as b, P as me, k as he, B as P, C as fe, l as pe, m as ve, n as be, o as Se, p as ge, q as B, r as O, s as W, t as ye, v as Y, w as we, x as A, S as xe, y as Ne, z as Ce, A as Te, E as ke, F as R, I as Ie } from "./index-CB2vXsPg.js";
3
+ import { b as ue, e as X, f as Z, g as J, h as K, i as q, R as $, c as C, j as F, L as b, P as me, k as he, B as P, C as fe, l as pe, m as ve, n as be, o as Se, p as ge, q as B, r as O, s as W, t as ye, v as Y, w as we, x as A, S as xe, y as Ne, z as Ce, A as Te, E as ke, F as R, I as Ie } from "./index-CFyPug8b.js";
4
4
  function Ee() {
5
5
  var k, I, E, N;
6
6
  const { authToken: a, tokenProps: r } = ue(), [l, S] = h(!1), [p, g] = h(!1), [x, y] = h(!1), [v, o] = h(null), [u, n] = h(null), w = u || {
@@ -1 +1 @@
1
- "use strict";const e=require("react/jsx-runtime"),l=require("react"),a=require("./index-iF4085Zd.js");function W(){var N,C,T,y;const{authToken:s,tokenProps:r}=a.useSemaphorContext(),[i,S]=l.useState(!1),[x,v]=l.useState(!1),[j,b]=l.useState(!1),[p,u]=l.useState(null),[m,n]=l.useState(null),g=m||{tz:((C=(N=r==null?void 0:r.params)==null?void 0:N.calendarContext)==null?void 0:C.tz)||null,weekStart:((y=(T=r==null?void 0:r.params)==null?void 0:T.calendarContext)==null?void 0:y.weekStart)??null},d=l.useCallback(async()=>{if(!(!(s!=null&&s.accessToken)||!(r!=null&&r.apiServiceUrl))){S(!0),u(null);try{const c=await fetch(`${r.apiServiceUrl}/v1/user-preferences/calendar`,{method:"GET",headers:{Authorization:`Bearer ${s.accessToken}`}});if(!c.ok){const h=await c.json().catch(()=>({}));throw new Error(h.error||"Failed to fetch preferences")}const o=await c.json();n({tz:o.tz,weekStart:o.weekStart,source:o.source,isInherited:o.isInherited,userHasPrefs:o.userHasPrefs,inherited:o.inherited})}catch(c){const o=c instanceof Error?c.message:"Unknown error";u(o)}finally{S(!1)}}},[s,r]);l.useEffect(()=>{d()},[d]);const f=l.useCallback(async c=>{if(!(s!=null&&s.accessToken)||!(r!=null&&r.apiServiceUrl))return u("Not authenticated"),!1;v(!0),u(null);try{const o=await fetch(`${r.apiServiceUrl}/v1/user-preferences/calendar`,{method:"PATCH",headers:{"Content-Type":"application/json",Authorization:`Bearer ${s.accessToken}`},body:JSON.stringify(c)});if(!o.ok){const h=await o.json().catch(()=>({}));throw new Error(h.error||"Failed to update preferences")}return await d(),!0}catch(o){const h=o instanceof Error?o.message:"Unknown error";return u(h),!1}finally{v(!1)}},[s,r,d]),w=l.useCallback(async()=>{if(!(s!=null&&s.accessToken)||!(r!=null&&r.apiServiceUrl))return u("Not authenticated"),!1;b(!0),u(null);try{const c=await fetch(`${r.apiServiceUrl}/v1/user-preferences/calendar`,{method:"DELETE",headers:{Authorization:`Bearer ${s.accessToken}`}});if(!c.ok){const h=await c.json().catch(()=>({}));throw new Error(h.error||"Failed to clear preferences")}const o=await c.text();if(o)try{const h=JSON.parse(o);return n({tz:h.tz,weekStart:h.weekStart,source:h.source,isInherited:h.isInherited??!0,userHasPrefs:!1,inherited:h.inherited}),!0}catch{}return await d(),!0}catch(c){const o=c instanceof Error?c.message:"Unknown error";return u(o),!1}finally{b(!1)}},[s,r,d]);return{preferences:g,isLoading:i,isSaving:x,isClearing:j,error:p,updatePreferences:f,clearPreferences:w,refetch:d}}const I=[{value:"America/New_York",label:"Eastern Time (US & Canada)"},{value:"America/Chicago",label:"Central Time (US & Canada)"},{value:"America/Denver",label:"Mountain Time (US & Canada)"},{value:"America/Los_Angeles",label:"Pacific Time (US & Canada)"},{value:"America/Phoenix",label:"Arizona"},{value:"America/Anchorage",label:"Alaska"},{value:"Pacific/Honolulu",label:"Hawaii"},{value:"Europe/London",label:"London"},{value:"Europe/Paris",label:"Paris, Berlin, Rome"},{value:"Asia/Tokyo",label:"Tokyo"},{value:"Asia/Shanghai",label:"Beijing, Shanghai"},{value:"Asia/Kolkata",label:"Mumbai, New Delhi"},{value:"Australia/Sydney",label:"Sydney"},{value:"UTC",label:"UTC"}],M=[{value:0,label:"Sunday"},{value:1,label:"Monday"},{value:6,label:"Saturday"}];function G(){try{const s=Intl;if(s.supportedValuesOf)return s.supportedValuesOf("timeZone")}catch{}return I.map(s=>s.value)}function V(s){switch(s){case"tenant":return"tenant";case"organization":return"organization";case"system":return"system";default:return"default"}}function L(s){const r=I.find(i=>i.value===s);return r?r.label:s}function X(s){const r=M.find(i=>i.value===s);return r?r.label:String(s)}function q({open:s,onOpenChange:r}){var E,P,A;const{preferences:i,isLoading:S,isSaving:x,isClearing:v,updatePreferences:j,clearPreferences:b}=W(),p=i.tz||((E=i.inherited)==null?void 0:E.tz)||Intl.DateTimeFormat().resolvedOptions().timeZone,u=i.weekStart??((P=i.inherited)==null?void 0:P.weekStart)??1,[m,n]=l.useState(!i.userHasPrefs),[g,d]=l.useState(!1),[f,w]=l.useState(p),[N,C]=l.useState(u),[T,y]=l.useState(!1),c=l.useMemo(()=>G(),[]),o=l.useMemo(()=>c.filter(t=>!I.some(R=>R.value===t)),[c]),h=l.useMemo(()=>L(f),[f]),F=i.inherited?L(i.inherited.tz):"UTC",H=i.inherited?X(i.inherited.weekStart):"Monday",B=V((A=i.inherited)==null?void 0:A.source);l.useEffect(()=>{if(!s){d(!1);return}g||(i.userHasPrefs!==void 0&&n(!i.userHasPrefs),w(p),C(u))},[s,g,i.userHasPrefs,p,u]);const _=async()=>{if(S){a.ue.error("Preferences are still loading. Please try again.");return}m?await b()?(a.ue.success("Now using default settings. Please refresh the page to apply changes.",{duration:5e3}),r(!1)):a.ue.error("Failed to save preferences. Please try again."):await j({tz:f,weekStart:N})?(a.ue.success("Preferences saved. Please refresh the page to apply changes.",{duration:5e3}),r(!1)):a.ue.error("Failed to save preferences. Please try again.")},$=()=>{r(!1)},D=x||v,O=D||S;return e.jsx(a.Dialog,{open:s,onOpenChange:r,children:e.jsxs(a.DialogContent,{className:"sm:max-w-[425px]",children:[e.jsxs(a.DialogHeader,{children:[e.jsx(a.DialogTitle,{children:"Calendar Preferences"}),e.jsx(a.DialogDescription,{children:"Set your timezone and week start preferences for date calculations and displays."})]}),e.jsxs("div",{className:"space-y-6 py-4",children:[e.jsxs(a.RadioGroup,{value:m?"defaults":"custom",onValueChange:t=>{d(!0),n(t==="defaults")},className:"space-y-3",children:[e.jsxs("div",{className:a.cn("flex items-start space-x-3 rounded-lg border p-4 cursor-pointer transition-colors",m?"border-primary bg-primary/5":"border-border hover:border-muted-foreground/50"),onClick:()=>{d(!0),n(!0)},children:[e.jsx(a.RadioGroupItem,{value:"defaults",id:"mode-defaults"}),e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsxs(a.Label,{htmlFor:"mode-defaults",className:"cursor-pointer font-medium",children:["Use ",B," defaults"]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[F,", Week starts ",H]})]})]}),e.jsxs("div",{className:a.cn("flex items-start space-x-3 rounded-lg border p-4 cursor-pointer transition-colors",m?"border-border hover:border-muted-foreground/50":"border-primary bg-primary/5"),onClick:()=>{d(!0),n(!1)},children:[e.jsx(a.RadioGroupItem,{value:"custom",id:"mode-custom"}),e.jsx(a.Label,{htmlFor:"mode-custom",className:"cursor-pointer font-medium",children:"Use custom settings"})]})]}),e.jsxs("div",{className:a.cn("space-y-6 transition-opacity",m&&"opacity-50 pointer-events-none"),children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(a.Label,{children:"Timezone"}),e.jsxs(a.Popover,{open:T,onOpenChange:y,modal:!0,children:[e.jsx(a.PopoverTrigger,{asChild:!0,children:e.jsxs(a.Button,{variant:"outline",role:"combobox","aria-expanded":T,className:"w-full justify-between",disabled:m,children:[h,e.jsx(a.ChevronsUpDown,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(a.PopoverContent,{className:"z-50 w-[--radix-popover-trigger-width] p-0",align:"start",children:e.jsxs(a.Command,{className:"overflow-visible",children:[e.jsx(a.CommandInput,{placeholder:"Search timezones..."}),e.jsxs(a.CommandList,{children:[e.jsx(a.CommandEmpty,{children:"No timezone found."}),e.jsx(a.CommandGroup,{heading:"Common",children:I.map(t=>e.jsxs(a.CommandItem,{value:`${t.value} ${t.label}`,onSelect:()=>{d(!0),w(t.value),y(!1)},children:[e.jsx(a.Check,{className:a.cn("mr-2 h-4 w-4",f===t.value?"opacity-100":"opacity-0")}),e.jsx("span",{className:"flex-1",children:t.label}),e.jsx("span",{className:"text-xs text-muted-foreground",children:t.value})]},t.value))}),e.jsx(a.CommandSeparator,{}),e.jsx(a.CommandGroup,{heading:"All Timezones",children:o.map(t=>e.jsxs(a.CommandItem,{value:t,onSelect:()=>{d(!0),w(t),y(!1)},children:[e.jsx(a.Check,{className:a.cn("mr-2 h-4 w-4",f===t?"opacity-100":"opacity-0")}),t]},t))})]})]})})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(a.Label,{children:"Week Starts On"}),e.jsx(a.RadioGroup,{value:String(N),onValueChange:t=>{d(!0),C(Number(t))},className:"flex gap-4",disabled:m,children:M.map(t=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(a.RadioGroupItem,{value:String(t.value),id:`week-start-${t.value}`,disabled:m}),e.jsx(a.Label,{htmlFor:`week-start-${t.value}`,className:a.cn("cursor-pointer font-normal",m&&"cursor-not-allowed"),children:t.label})]},t.value))})]})]})]}),e.jsxs(a.DialogFooter,{children:[e.jsx(a.Button,{variant:"outline",onClick:$,disabled:D,children:"Cancel"}),e.jsx(a.Button,{onClick:_,disabled:O,children:D?e.jsxs(e.Fragment,{children:[e.jsx(a.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]}):"Save"})]})]})})}const k=6,z=1,U=20;function Z(s){return Number.isNaN(s)?k:Math.min(U,Math.max(z,s))}function J({open:s,onOpenChange:r,dashboard:i,onApply:S,disabled:x=!1}){const[v,j]=l.useState(!1),[b,p]=l.useState("top"),[u,m]=l.useState(String(k)),n=i.summary;l.useEffect(()=>{s&&(j((n==null?void 0:n.enabled)===!0),p((n==null?void 0:n.position)==="bottom"?"bottom":"top"),m(String((n==null?void 0:n.maxItems)??k)))},[s,n==null?void 0:n.enabled,n==null?void 0:n.position,n==null?void 0:n.maxItems]);const g=l.useMemo(()=>Z(Number.parseInt(u||`${k}`,10)),[u]),d=()=>{S({enabled:v,position:b,maxItems:g}),r(!1)};return e.jsx(a.Dialog,{open:s,onOpenChange:r,children:e.jsxs(a.DialogContent,{className:"sm:max-w-[420px]",children:[e.jsxs(a.DialogHeader,{children:[e.jsx(a.DialogTitle,{children:"Summary Settings"}),e.jsx(a.DialogDescription,{children:"Configure dashboard-level summary display. Card-level summary settings still control which cards contribute."})]}),e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(a.Label,{htmlFor:"dashboard-summary-enabled",children:"Enable Dashboard Summary"}),e.jsx(a.SmallSwitch,{id:"dashboard-summary-enabled",checked:v,disabled:x,onCheckedChange:j})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(a.Label,{htmlFor:"dashboard-summary-position",children:"Position"}),e.jsxs(a.Select,{value:b,disabled:x,onValueChange:f=>p(f),children:[e.jsx(a.SelectTrigger,{id:"dashboard-summary-position",children:e.jsx(a.SelectValue,{placeholder:"Select position"})}),e.jsxs(a.SelectContent,{children:[e.jsx(a.SelectItem,{value:"top",children:"Top"}),e.jsx(a.SelectItem,{value:"bottom",children:"Bottom"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(a.Label,{htmlFor:"dashboard-summary-max-items",children:"Max Items"}),e.jsx(a.Input,{id:"dashboard-summary-max-items",type:"number",min:z,max:U,disabled:x,value:u,onChange:f=>m(f.target.value),onBlur:()=>m(String(g))}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Display limit only. Computation is unchanged."})]}),x&&e.jsx("p",{className:"text-xs text-amber-700",children:"Enter dashboard edit mode to modify summary settings."})]}),e.jsxs(a.DialogFooter,{children:[e.jsx(a.Button,{variant:"outline",onClick:()=>r(!1),children:"Cancel"}),e.jsx(a.Button,{onClick:d,disabled:x,children:"Apply"})]})]})})}exports.CalendarPreferencesDialog=q;exports.DashboardSummarySettingsDialog=J;
1
+ "use strict";const e=require("react/jsx-runtime"),l=require("react"),a=require("./index-DGpLwb-T.js");function W(){var N,C,T,y;const{authToken:s,tokenProps:r}=a.useSemaphorContext(),[i,S]=l.useState(!1),[x,v]=l.useState(!1),[j,b]=l.useState(!1),[p,u]=l.useState(null),[m,n]=l.useState(null),g=m||{tz:((C=(N=r==null?void 0:r.params)==null?void 0:N.calendarContext)==null?void 0:C.tz)||null,weekStart:((y=(T=r==null?void 0:r.params)==null?void 0:T.calendarContext)==null?void 0:y.weekStart)??null},d=l.useCallback(async()=>{if(!(!(s!=null&&s.accessToken)||!(r!=null&&r.apiServiceUrl))){S(!0),u(null);try{const c=await fetch(`${r.apiServiceUrl}/v1/user-preferences/calendar`,{method:"GET",headers:{Authorization:`Bearer ${s.accessToken}`}});if(!c.ok){const h=await c.json().catch(()=>({}));throw new Error(h.error||"Failed to fetch preferences")}const o=await c.json();n({tz:o.tz,weekStart:o.weekStart,source:o.source,isInherited:o.isInherited,userHasPrefs:o.userHasPrefs,inherited:o.inherited})}catch(c){const o=c instanceof Error?c.message:"Unknown error";u(o)}finally{S(!1)}}},[s,r]);l.useEffect(()=>{d()},[d]);const f=l.useCallback(async c=>{if(!(s!=null&&s.accessToken)||!(r!=null&&r.apiServiceUrl))return u("Not authenticated"),!1;v(!0),u(null);try{const o=await fetch(`${r.apiServiceUrl}/v1/user-preferences/calendar`,{method:"PATCH",headers:{"Content-Type":"application/json",Authorization:`Bearer ${s.accessToken}`},body:JSON.stringify(c)});if(!o.ok){const h=await o.json().catch(()=>({}));throw new Error(h.error||"Failed to update preferences")}return await d(),!0}catch(o){const h=o instanceof Error?o.message:"Unknown error";return u(h),!1}finally{v(!1)}},[s,r,d]),w=l.useCallback(async()=>{if(!(s!=null&&s.accessToken)||!(r!=null&&r.apiServiceUrl))return u("Not authenticated"),!1;b(!0),u(null);try{const c=await fetch(`${r.apiServiceUrl}/v1/user-preferences/calendar`,{method:"DELETE",headers:{Authorization:`Bearer ${s.accessToken}`}});if(!c.ok){const h=await c.json().catch(()=>({}));throw new Error(h.error||"Failed to clear preferences")}const o=await c.text();if(o)try{const h=JSON.parse(o);return n({tz:h.tz,weekStart:h.weekStart,source:h.source,isInherited:h.isInherited??!0,userHasPrefs:!1,inherited:h.inherited}),!0}catch{}return await d(),!0}catch(c){const o=c instanceof Error?c.message:"Unknown error";return u(o),!1}finally{b(!1)}},[s,r,d]);return{preferences:g,isLoading:i,isSaving:x,isClearing:j,error:p,updatePreferences:f,clearPreferences:w,refetch:d}}const I=[{value:"America/New_York",label:"Eastern Time (US & Canada)"},{value:"America/Chicago",label:"Central Time (US & Canada)"},{value:"America/Denver",label:"Mountain Time (US & Canada)"},{value:"America/Los_Angeles",label:"Pacific Time (US & Canada)"},{value:"America/Phoenix",label:"Arizona"},{value:"America/Anchorage",label:"Alaska"},{value:"Pacific/Honolulu",label:"Hawaii"},{value:"Europe/London",label:"London"},{value:"Europe/Paris",label:"Paris, Berlin, Rome"},{value:"Asia/Tokyo",label:"Tokyo"},{value:"Asia/Shanghai",label:"Beijing, Shanghai"},{value:"Asia/Kolkata",label:"Mumbai, New Delhi"},{value:"Australia/Sydney",label:"Sydney"},{value:"UTC",label:"UTC"}],M=[{value:0,label:"Sunday"},{value:1,label:"Monday"},{value:6,label:"Saturday"}];function G(){try{const s=Intl;if(s.supportedValuesOf)return s.supportedValuesOf("timeZone")}catch{}return I.map(s=>s.value)}function V(s){switch(s){case"tenant":return"tenant";case"organization":return"organization";case"system":return"system";default:return"default"}}function L(s){const r=I.find(i=>i.value===s);return r?r.label:s}function X(s){const r=M.find(i=>i.value===s);return r?r.label:String(s)}function q({open:s,onOpenChange:r}){var E,P,A;const{preferences:i,isLoading:S,isSaving:x,isClearing:v,updatePreferences:j,clearPreferences:b}=W(),p=i.tz||((E=i.inherited)==null?void 0:E.tz)||Intl.DateTimeFormat().resolvedOptions().timeZone,u=i.weekStart??((P=i.inherited)==null?void 0:P.weekStart)??1,[m,n]=l.useState(!i.userHasPrefs),[g,d]=l.useState(!1),[f,w]=l.useState(p),[N,C]=l.useState(u),[T,y]=l.useState(!1),c=l.useMemo(()=>G(),[]),o=l.useMemo(()=>c.filter(t=>!I.some(R=>R.value===t)),[c]),h=l.useMemo(()=>L(f),[f]),F=i.inherited?L(i.inherited.tz):"UTC",H=i.inherited?X(i.inherited.weekStart):"Monday",B=V((A=i.inherited)==null?void 0:A.source);l.useEffect(()=>{if(!s){d(!1);return}g||(i.userHasPrefs!==void 0&&n(!i.userHasPrefs),w(p),C(u))},[s,g,i.userHasPrefs,p,u]);const _=async()=>{if(S){a.ue.error("Preferences are still loading. Please try again.");return}m?await b()?(a.ue.success("Now using default settings. Please refresh the page to apply changes.",{duration:5e3}),r(!1)):a.ue.error("Failed to save preferences. Please try again."):await j({tz:f,weekStart:N})?(a.ue.success("Preferences saved. Please refresh the page to apply changes.",{duration:5e3}),r(!1)):a.ue.error("Failed to save preferences. Please try again.")},$=()=>{r(!1)},D=x||v,O=D||S;return e.jsx(a.Dialog,{open:s,onOpenChange:r,children:e.jsxs(a.DialogContent,{className:"sm:max-w-[425px]",children:[e.jsxs(a.DialogHeader,{children:[e.jsx(a.DialogTitle,{children:"Calendar Preferences"}),e.jsx(a.DialogDescription,{children:"Set your timezone and week start preferences for date calculations and displays."})]}),e.jsxs("div",{className:"space-y-6 py-4",children:[e.jsxs(a.RadioGroup,{value:m?"defaults":"custom",onValueChange:t=>{d(!0),n(t==="defaults")},className:"space-y-3",children:[e.jsxs("div",{className:a.cn("flex items-start space-x-3 rounded-lg border p-4 cursor-pointer transition-colors",m?"border-primary bg-primary/5":"border-border hover:border-muted-foreground/50"),onClick:()=>{d(!0),n(!0)},children:[e.jsx(a.RadioGroupItem,{value:"defaults",id:"mode-defaults"}),e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsxs(a.Label,{htmlFor:"mode-defaults",className:"cursor-pointer font-medium",children:["Use ",B," defaults"]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[F,", Week starts ",H]})]})]}),e.jsxs("div",{className:a.cn("flex items-start space-x-3 rounded-lg border p-4 cursor-pointer transition-colors",m?"border-border hover:border-muted-foreground/50":"border-primary bg-primary/5"),onClick:()=>{d(!0),n(!1)},children:[e.jsx(a.RadioGroupItem,{value:"custom",id:"mode-custom"}),e.jsx(a.Label,{htmlFor:"mode-custom",className:"cursor-pointer font-medium",children:"Use custom settings"})]})]}),e.jsxs("div",{className:a.cn("space-y-6 transition-opacity",m&&"opacity-50 pointer-events-none"),children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(a.Label,{children:"Timezone"}),e.jsxs(a.Popover,{open:T,onOpenChange:y,modal:!0,children:[e.jsx(a.PopoverTrigger,{asChild:!0,children:e.jsxs(a.Button,{variant:"outline",role:"combobox","aria-expanded":T,className:"w-full justify-between",disabled:m,children:[h,e.jsx(a.ChevronsUpDown,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(a.PopoverContent,{className:"z-50 w-[--radix-popover-trigger-width] p-0",align:"start",children:e.jsxs(a.Command,{className:"overflow-visible",children:[e.jsx(a.CommandInput,{placeholder:"Search timezones..."}),e.jsxs(a.CommandList,{children:[e.jsx(a.CommandEmpty,{children:"No timezone found."}),e.jsx(a.CommandGroup,{heading:"Common",children:I.map(t=>e.jsxs(a.CommandItem,{value:`${t.value} ${t.label}`,onSelect:()=>{d(!0),w(t.value),y(!1)},children:[e.jsx(a.Check,{className:a.cn("mr-2 h-4 w-4",f===t.value?"opacity-100":"opacity-0")}),e.jsx("span",{className:"flex-1",children:t.label}),e.jsx("span",{className:"text-xs text-muted-foreground",children:t.value})]},t.value))}),e.jsx(a.CommandSeparator,{}),e.jsx(a.CommandGroup,{heading:"All Timezones",children:o.map(t=>e.jsxs(a.CommandItem,{value:t,onSelect:()=>{d(!0),w(t),y(!1)},children:[e.jsx(a.Check,{className:a.cn("mr-2 h-4 w-4",f===t?"opacity-100":"opacity-0")}),t]},t))})]})]})})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(a.Label,{children:"Week Starts On"}),e.jsx(a.RadioGroup,{value:String(N),onValueChange:t=>{d(!0),C(Number(t))},className:"flex gap-4",disabled:m,children:M.map(t=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(a.RadioGroupItem,{value:String(t.value),id:`week-start-${t.value}`,disabled:m}),e.jsx(a.Label,{htmlFor:`week-start-${t.value}`,className:a.cn("cursor-pointer font-normal",m&&"cursor-not-allowed"),children:t.label})]},t.value))})]})]})]}),e.jsxs(a.DialogFooter,{children:[e.jsx(a.Button,{variant:"outline",onClick:$,disabled:D,children:"Cancel"}),e.jsx(a.Button,{onClick:_,disabled:O,children:D?e.jsxs(e.Fragment,{children:[e.jsx(a.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]}):"Save"})]})]})})}const k=6,z=1,U=20;function Z(s){return Number.isNaN(s)?k:Math.min(U,Math.max(z,s))}function J({open:s,onOpenChange:r,dashboard:i,onApply:S,disabled:x=!1}){const[v,j]=l.useState(!1),[b,p]=l.useState("top"),[u,m]=l.useState(String(k)),n=i.summary;l.useEffect(()=>{s&&(j((n==null?void 0:n.enabled)===!0),p((n==null?void 0:n.position)==="bottom"?"bottom":"top"),m(String((n==null?void 0:n.maxItems)??k)))},[s,n==null?void 0:n.enabled,n==null?void 0:n.position,n==null?void 0:n.maxItems]);const g=l.useMemo(()=>Z(Number.parseInt(u||`${k}`,10)),[u]),d=()=>{S({enabled:v,position:b,maxItems:g}),r(!1)};return e.jsx(a.Dialog,{open:s,onOpenChange:r,children:e.jsxs(a.DialogContent,{className:"sm:max-w-[420px]",children:[e.jsxs(a.DialogHeader,{children:[e.jsx(a.DialogTitle,{children:"Summary Settings"}),e.jsx(a.DialogDescription,{children:"Configure dashboard-level summary display. Card-level summary settings still control which cards contribute."})]}),e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(a.Label,{htmlFor:"dashboard-summary-enabled",children:"Enable Dashboard Summary"}),e.jsx(a.SmallSwitch,{id:"dashboard-summary-enabled",checked:v,disabled:x,onCheckedChange:j})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(a.Label,{htmlFor:"dashboard-summary-position",children:"Position"}),e.jsxs(a.Select,{value:b,disabled:x,onValueChange:f=>p(f),children:[e.jsx(a.SelectTrigger,{id:"dashboard-summary-position",children:e.jsx(a.SelectValue,{placeholder:"Select position"})}),e.jsxs(a.SelectContent,{children:[e.jsx(a.SelectItem,{value:"top",children:"Top"}),e.jsx(a.SelectItem,{value:"bottom",children:"Bottom"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(a.Label,{htmlFor:"dashboard-summary-max-items",children:"Max Items"}),e.jsx(a.Input,{id:"dashboard-summary-max-items",type:"number",min:z,max:U,disabled:x,value:u,onChange:f=>m(f.target.value),onBlur:()=>m(String(g))}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Display limit only. Computation is unchanged."})]}),x&&e.jsx("p",{className:"text-xs text-amber-700",children:"Enter dashboard edit mode to modify summary settings."})]}),e.jsxs(a.DialogFooter,{children:[e.jsx(a.Button,{variant:"outline",onClick:()=>r(!1),children:"Cancel"}),e.jsx(a.Button,{onClick:d,disabled:x,children:"Apply"})]})]})})}exports.CalendarPreferencesDialog=q;exports.DashboardSummarySettingsDialog=J;
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("./index-iF4085Zd.js"),N=require("react"),Ae=require("./editor-action-buttons-DhhZOsQV.js"),dn=require("react-dom");function un(s){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const a in s)if(a!=="default"){const r=Object.getOwnPropertyDescriptor(s,a);Object.defineProperty(n,a,r.get?r:{enumerable:!0,get:()=>s[a]})}}return n.default=s,Object.freeze(n)}const ns=un(N);/**
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("./index-DGpLwb-T.js"),N=require("react"),Ae=require("./editor-action-buttons-tq0tFVfj.js"),dn=require("react-dom");function un(s){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const a in s)if(a!=="default"){const r=Object.getOwnPropertyDescriptor(s,a);Object.defineProperty(n,a,r.get?r:{enumerable:!0,get:()=>s[a]})}}return n.default=s,Object.freeze(n)}const ns=un(N);/**
2
2
  * @license lucide-react v0.453.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -164,7 +164,7 @@ ${b.joinType} JOIN ${w.name}
164
164
  ON ${p}`}),k},isValidConfiguration:()=>!(!a.baseEntity.name||a.joins.some(b=>!b.source.name||!b.target.name)||a.joins.some(b=>b.joinKeyGroups.some(w=>w.keys.length===0))||a.joins.some(b=>b.joinKeyGroups.some(w=>w.keys.some(D=>!D.source.name||!D.target.name||!D.operator))))}}function Fn({joinPlan:s,availableDataSources:n,onSave:a,onRemove:r,onCancel:i}){const{setCardConfig:c}=t.useEditorActions();t.useEditorStore(p=>p.card.config);const{columnGroups:o}=t.useColumns(),d=o.filter(p=>p.entityName!==t.CALCULATED_FIELDS_GROUP_NAME),{joinPlan:l,expandedJoins:m,setJoinPlan:h,addJoin:x,removeJoin:u,updateJoin:g,moveJoinUp:f,moveJoinDown:j,toggleJoinExpansion:v,getAvailableSourceEntities:T,getAvailableTargetEntities:I,addJoinKeyGroup:z,updateGroupOperator:L,removeJoinKeyGroup:E,addJoinKey:C,updateJoinKey:A,removeJoinKey:k,generateSQLPreview:b,isValidConfiguration:w}=On({initialJoinPlan:s,availableDataSources:n}),D=p=>{const O=d.find(V=>V.entityName===p);return(O==null?void 0:O.columns)||[]};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(t.Label,{children:"Base Entity (FROM clause)"}),e.jsxs(t.Select,{value:l.baseEntity.name,onValueChange:p=>{const O=n.find(V=>V.name===p);h({...l,baseEntity:{connectionId:(O==null?void 0:O.connectionId)||"",connectionType:(O==null?void 0:O.connectionType)||"none",type:(O==null?void 0:O.type)||"table",name:p,database:O==null?void 0:O.database,schema:O==null?void 0:O.schema}})},children:[e.jsx(t.SelectTrigger,{children:e.jsx(t.SelectValue,{placeholder:"Select base entity..."})}),e.jsx(t.SelectContent,{children:n.map(p=>e.jsx(t.SelectItem,{className:"hover:bg-muted",value:p.name,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(t.Badge,{variant:"outline",className:"text-xs",children:p.type}),p.name,e.jsx(t.Badge,{variant:"outline",className:"text-xs text-green-600",children:"BASE"})]})},p.name))})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"This entity will be used as the base table in the FROM clause of the SQL query."})]}),e.jsxs("div",{className:"rounded-md border p-3",children:[e.jsx("div",{className:"mb-2 text-xs font-medium text-muted-foreground",children:"Join SQL Preview"}),e.jsx("code",{className:"block whitespace-pre-wrap break-all text-xs",children:b()})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(t.Label,{children:["Joins Configuration (",l.joins.length,")"]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs(t.Button,{variant:"outline",size:"sm",onClick:x,children:[e.jsx(t.Plus,{className:"mr-1 h-4 w-4"}),"Add Join"]})})]}),l.joins.length===0?e.jsx("div",{className:"rounded-lg border border-dashed py-8 text-center text-muted-foreground",children:e.jsx("p",{children:"No joins configured. Add a join to connect multiple data sources."})}):e.jsx("div",{className:"max-h-[300px] space-y-4 overflow-y-auto",children:l.joins.map(p=>{const O=n.find(M=>M.name===p.source.name),V=n.find(M=>M.name===p.target.name),y=m.has(p.id);return e.jsxs(t.Card,{className:"border",children:[e.jsx(t.CardHeader,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(t.Badge,{children:p.sequence}),e.jsxs(t.CardTitle,{className:"text-sm",children:["Join ",p.sequence,O&&V&&e.jsxs("span",{className:"ml-2 font-normal text-gray-600",children:["(",O.name," → ",V.name,")"]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(t.Button,{variant:"ghost",size:"sm",onClick:()=>f(p.id),disabled:p.sequence===1,children:e.jsx(t.ArrowUp,{className:"h-4 w-4"})}),e.jsx(t.Button,{variant:"ghost",size:"sm",onClick:()=>j(p.id),disabled:p.sequence===l.joins.length,children:e.jsx(t.ArrowDown,{className:"h-4 w-4"})}),e.jsx(t.Button,{variant:"ghost",size:"sm",onClick:()=>v(p.id),children:y?e.jsx(t.ChevronUp,{className:"h-4 w-4"}):e.jsx(t.ChevronDown,{className:"h-4 w-4"})}),e.jsx(t.Button,{variant:"ghost",size:"sm",onClick:()=>u(p.id),children:e.jsx(t.X,{className:"h-4 w-4"})})]})]})}),y&&e.jsxs(t.CardContent,{className:"space-y-4 pb-6",children:[e.jsxs("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(t.Label,{children:"Source"}),e.jsxs(t.Select,{value:p.source.name,onValueChange:M=>{const S=n.find(P=>P.name===M);g(p.id,{source:{connectionId:(S==null?void 0:S.connectionId)||"",connectionType:(S==null?void 0:S.connectionType)||"none",type:(S==null?void 0:S.type)||"table",name:M,database:S==null?void 0:S.database,schema:S==null?void 0:S.schema}})},children:[e.jsx(t.SelectTrigger,{children:e.jsx(t.SelectValue,{placeholder:"Select source..."})}),e.jsx(t.SelectContent,{children:T(p.id).map(M=>e.jsx(t.SelectItem,{className:"hover:bg-muted",value:M.name,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(t.Badge,{variant:"outline",className:"text-xs",children:M.type}),M.name]})},M.name))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(t.Label,{children:"Join Type"}),e.jsxs(t.Select,{value:p.joinType,onValueChange:M=>g(p.id,{joinType:M}),children:[e.jsx(t.SelectTrigger,{children:e.jsx(t.SelectValue,{})}),e.jsxs(t.SelectContent,{children:[e.jsx(t.SelectItem,{className:"hover:bg-muted",value:"INNER",children:"INNER JOIN"}),e.jsx(t.SelectItem,{className:"hover:bg-muted",value:"LEFT",children:"LEFT JOIN"}),e.jsx(t.SelectItem,{className:"hover:bg-muted",value:"RIGHT",children:"RIGHT JOIN"}),e.jsx(t.SelectItem,{className:"hover:bg-muted",value:"FULL",children:"FULL JOIN"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(t.Label,{children:"Target"}),e.jsxs(t.Select,{value:p.target.name,onValueChange:M=>{const S=n.find(P=>P.name===M);g(p.id,{target:{connectionId:(S==null?void 0:S.connectionId)||"",connectionType:(S==null?void 0:S.connectionType)||"none",type:(S==null?void 0:S.type)||"table",name:M,database:S==null?void 0:S.database,schema:S==null?void 0:S.schema}})},disabled:!p.source.name,children:[e.jsx(t.SelectTrigger,{children:e.jsx(t.SelectValue,{placeholder:"Select target..."})}),e.jsx(t.SelectContent,{children:p.source.name?I(p.source.name).map(M=>e.jsx(t.SelectItem,{className:"hover:bg-muted",value:M.name,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(t.Badge,{variant:"outline",className:"text-xs",children:M.type}),M.name,M.name===p.source.name&&e.jsx(t.Badge,{variant:"outline",className:"text-xs text-yellow-600",children:"(Self-join)"})]})},M.name)):[]})]})]})]}),p.source.name&&p.target.name&&O&&V&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(t.Label,{children:"Join Conditions"}),e.jsxs(t.Button,{type:"button",variant:"outline",size:"sm",onClick:()=>z(p.id),children:[e.jsx(t.Plus,{className:"mr-1 h-3 w-3"})," Add Condition Group"]})]}),p.joinKeyGroups.length===0?e.jsx("div",{className:"rounded-md border p-3 text-center text-sm text-gray-500",children:"No join conditions defined. Add condition groups to specify how data sources should be joined."}):e.jsx("div",{className:"space-y-4",children:p.joinKeyGroups.map((M,S)=>e.jsxs("div",{className:"space-y-3 rounded-md border p-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(t.Label,{children:["Group ",S+1]}),S>0&&e.jsxs("div",{className:"flex items-center gap-2 rounded-md bg-gray-100 px-2 py-1",children:[e.jsx(t.Label,{className:"text-xs font-normal",children:"Join with:"}),e.jsx("span",{className:"text-sm font-medium",children:"OR"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(t.Select,{value:M.operator,onValueChange:P=>L(p.id,S,P),children:[e.jsx(t.SelectTrigger,{className:"w-[100px]",children:e.jsx(t.SelectValue,{})}),e.jsxs(t.SelectContent,{children:[e.jsx(t.SelectItem,{className:"hover:bg-muted",value:"AND",children:"AND"}),e.jsx(t.SelectItem,{value:"OR",children:"OR"})]})]}),e.jsx(t.Button,{type:"button",variant:"ghost",size:"sm",onClick:()=>E(p.id,S),children:e.jsx(t.Trash2,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[M.keys.length===0?e.jsx("div",{className:"rounded-md border border-dashed p-3 text-center text-sm text-gray-500",children:"No conditions in this group. Add conditions to specify join criteria."}):e.jsx("div",{className:"space-y-2",children:M.keys.map((P,F)=>e.jsxs("div",{className:"flex flex-col items-start gap-2 rounded-md border p-2 sm:flex-row sm:items-center",children:[F>0&&e.jsx("div",{className:"self-center rounded-md bg-gray-100 px-2 py-1 text-xs font-medium",children:M.operator}),e.jsx("div",{className:"mb-2 w-full sm:mb-0 sm:flex-1",children:e.jsxs(t.Select,{value:P.source.name,onValueChange:R=>A(p.id,S,F,"sourceColumnName",R),children:[e.jsx(t.SelectTrigger,{children:e.jsx(t.SelectValue,{placeholder:"Source column"})}),e.jsx(t.SelectContent,{children:D(p.source.name).map(R=>e.jsx(t.SelectItem,{className:"hover:bg-muted",value:R.name,children:e.jsxs("div",{className:"flex w-full items-center justify-between",children:[e.jsx("span",{children:R.name}),e.jsx(t.Badge,{variant:"outline",className:"ml-2 text-xs",children:R.dataType})]})},R.name))})]})}),e.jsx("div",{className:"mb-2 w-full sm:mb-0 sm:w-20",children:e.jsxs(t.Select,{value:P.operator,onValueChange:R=>A(p.id,S,F,"operator",R),children:[e.jsx(t.SelectTrigger,{children:e.jsx(t.SelectValue,{})}),e.jsxs(t.SelectContent,{children:[e.jsx(t.SelectItem,{className:"hover:bg-muted",value:"=",children:"="}),e.jsx(t.SelectItem,{className:"hover:bg-muted",value:"<",children:"<"}),e.jsx(t.SelectItem,{className:"hover:bg-muted",value:">",children:">"}),e.jsx(t.SelectItem,{className:"hover:bg-muted",value:"<=",children:"<="}),e.jsx(t.SelectItem,{className:"hover:bg-muted",value:">=",children:">="})]})]})}),e.jsx("div",{className:"mb-2 w-full sm:mb-0 sm:flex-1",children:e.jsxs(t.Select,{value:P.target.name,onValueChange:R=>A(p.id,S,F,"targetColumnName",R),children:[e.jsx(t.SelectTrigger,{children:e.jsx(t.SelectValue,{placeholder:"Target column"})}),e.jsx(t.SelectContent,{children:D(p.target.name).map(R=>e.jsx(t.SelectItem,{className:"hover:bg-muted",value:R.name,children:e.jsxs("div",{className:"flex w-full items-center justify-between hover:bg-muted",children:[e.jsx("span",{children:R.name}),e.jsx(t.Badge,{variant:"outline",className:"ml-2 text-xs",children:R.dataType})]})},R.name))})]})}),e.jsx(t.Button,{type:"button",variant:"ghost",size:"sm",className:"self-center",onClick:()=>k(p.id,S,F),children:e.jsx(t.X,{className:"size-3.5"})})]},P.id||F))}),e.jsxs(t.Button,{type:"button",variant:"outline",size:"sm",className:"mt-2",onClick:()=>C(p.id,S),children:[e.jsx(t.Plus,{className:"mr-1 h-3 w-3"})," Add Condition"]})]})]},M.id))})]})]})]},p.id)})})]}),e.jsxs("div",{className:"flex justify-end gap-2 border-t pt-4",children:[e.jsx(t.Button,{variant:"outline",onClick:()=>{r(),i()},children:"Remove All"}),e.jsx(t.Button,{variant:"outline",onClick:i,children:"Cancel"}),e.jsx(t.Button,{onClick:()=>a(l),disabled:!w(),children:"Save"})]})]})}function ka({children:s,open:n,onOpenChange:a,joinPlan:r,availableDataSources:i,onRemove:c,onSave:o,onCancel:d}){return e.jsxs(t.Dialog,{open:n,onOpenChange:a,children:[e.jsxs(t.DialogContent,{className:"max-w-4xl",children:[e.jsxs(t.DialogHeader,{children:[e.jsx(t.DialogTitle,{children:"Join Configuration"}),e.jsx(t.DialogDescription,{children:"Configure the join between the two entities to combine the fields."})]}),e.jsx(Fn,{joinPlan:r,availableDataSources:i,onSave:o,onCancel:d,onRemove:c})]}),s]})}function Rn({joins:s,baseEntityId:n,availableDataSources:a,generateSQLPreview:r}){return e.jsxs("div",{className:"my-2 max-h-[400px] divide-y divide-border overflow-y-auto",children:[s.length>0&&e.jsxs("div",{className:"px-4 py-2",children:[e.jsx("h3",{className:"mb-3 text-left font-semibold",children:"Join Chain"}),e.jsx("div",{className:"flex flex-wrap items-center gap-2",children:(()=>{const i=[...s].sort((o,d)=>o.sequence-d.sequence),c=a.find(o=>o.name===n);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-1 rounded-md border bg-muted px-2 py-1",children:[e.jsx(t.Badge,{variant:"secondary",className:"text-xs",children:c==null?void 0:c.type}),e.jsx("span",{className:"text-xs font-medium",children:c==null?void 0:c.name}),e.jsx(t.Badge,{variant:"outline",className:"text-xs text-green-600",children:"BASE"})]}),i.map(o=>{const d=a.find(l=>l.name===o.target.name);return e.jsxs("div",{className:"flex items-center",children:[e.jsxs("div",{className:"mx-1 flex items-center gap-1",children:[e.jsx(t.Badge,{variant:"outline",className:"text-xs",children:o.joinType}),e.jsx("span",{className:"text-muted-foreground",children:"→"})]}),e.jsxs("div",{className:"flex items-center gap-1 rounded-md border bg-muted px-2 py-1",children:[e.jsx(t.Badge,{variant:"secondary",className:"text-xs",children:d==null?void 0:d.type}),e.jsx("span",{className:"text-xs font-medium",children:d==null?void 0:d.name})]})]},o.id)})]})})()})]}),e.jsxs("div",{className:"p-4",children:[e.jsxs("h3",{className:"mb-3 text-left text-sm font-medium",children:["Configured Joins (",s.length,")"]}),e.jsx("div",{className:"space-y-2",children:[...s].sort((i,c)=>i.sequence-c.sequence).map((i,c)=>{const o=a.find(m=>m.name===i.source.name),d=a.find(m=>m.name===i.target.name),l=i.joinKeyGroups.reduce((m,h)=>m+h.keys.length,0);return e.jsxs("div",{className:"rounded-md bg-muted p-2 text-left",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(t.Badge,{variant:"secondary",className:"shrink-0 text-xs",children:c+1}),e.jsx(t.Badge,{variant:"outline",className:"shrink-0 text-xs",children:i.joinType}),e.jsxs(t.Badge,{variant:"outline",className:"ml-auto shrink-0 text-xs",children:[l," condition",l>1?"s":""]})]}),e.jsxs("div",{className:"mt-1 truncate pl-1 text-xs text-muted-foreground",children:[o==null?void 0:o.name," → ",d==null?void 0:d.name]})]},i.id)})})]}),e.jsxs("div",{className:"p-4",children:[e.jsx("h3",{className:"mb-3 text-left text-sm font-medium",children:"SQL Query"}),e.jsx("div",{className:"overflow-x-auto rounded-md border bg-muted p-3",children:e.jsx("pre",{className:"whitespace-pre-wrap break-all text-left font-mono text-xs text-muted-foreground",children:r()})})]})]})}function sa({open:s,onOpenChange:n,variant:a="button"}={}){var I,z;const r=t.useEditorStore(L=>L.card),{autoJoinMetadata:i}=t.useDashboardCardQuery(r),c=t.useEditorStore(L=>L.actions.updateCardConfig),o=((I=r==null?void 0:r.config)==null?void 0:I.joinPlan)||{baseEntity:{type:"table",name:"",database:"",schema:"",connectionId:"",connectionType:"none",dialect:"none"},joins:[]},[d,l]=N.useState(!1),m=s!==void 0,h=m?s:d,x=m?n:l,u=((z=r==null?void 0:r.dataSource)==null?void 0:z.selectedEntities)||[],g=L=>{c(r.id,{...r==null?void 0:r.config,joinPlan:L}),x(!1)},f=()=>{c(r.id,{...r==null?void 0:r.config,joinPlan:void 0})},j=()=>{x(!1)},v=()=>{const L=[...o.joins].sort((A,k)=>A.sequence-k.sequence),E=o.baseEntity;if(!E.name)return"SELECT * FROM table -- Please select a base entity";let C=`SELECT *
165
165
  FROM ${E.name}`;return L.forEach(A=>{const k=u.find(D=>D.name===A.target.name);if(!k)return;const b=A.joinKeyGroups.filter(D=>D.keys&&D.keys.length>0).map(D=>{const p=D.keys.filter(O=>{var V,y,M,S;return((V=O.source)==null?void 0:V.name)&&((y=O.target)==null?void 0:y.name)&&((M=O.source)==null?void 0:M.entityName)&&((S=O.target)==null?void 0:S.entityName)}).map(O=>`${O.source.entityName}.${O.source.name} ${O.operator} ${O.target.entityName}.${O.target.name}`);return p.length>1?`(${p.join(` ${D.operator} `)})`:p[0]}).filter(Boolean),w=b.length>1?b.join(" OR "):b[0]||"condition_here";C+=`
166
166
  ${A.joinType} JOIN ${k.name}
167
- ON ${w}`}),C};if(u.length<2)return null;const T=o.joins.length>0&&e.jsx(t.TooltipContent,{side:"bottom",className:"ml-4 max-w-md overflow-hidden p-0",children:e.jsx(Rn,{joins:o.joins,baseEntityId:o.baseEntity.name,availableDataSources:u,generateSQLPreview:v})});return e.jsxs(e.Fragment,{children:[e.jsx(t.TooltipProvider,{children:e.jsxs(t.Tooltip,{children:[e.jsx(t.TooltipTrigger,{asChild:!0,children:a==="badge"?e.jsxs(t.Badge,{variant:"secondary",className:"h-5 cursor-pointer gap-1 px-1.5 text-xs transition-colors hover:bg-secondary/80",onClick:L=>{L.stopPropagation(),x(!0)},children:[e.jsx(t.Link,{className:"h-3 w-3"}),o.joins.length]}):e.jsxs(t.Button,{onClick:()=>x(!0),variant:"outline",className:"w-full bg-muted/50",children:[e.jsx(t.Link,{className:"mr-2 h-3.5 w-3.5"}),o.joins.length===0?"Configure Joins":o.joins.length===1?"Join":"Joins",o.joins.length>0&&e.jsx("span",{className:"ml-2 flex h-5 min-w-5 items-center justify-center rounded-full border bg-muted-foreground px-1.5 text-xs font-medium text-background",children:o.joins.length}),(i==null?void 0:i.autoResolved)&&e.jsxs(t.Badge,{variant:"secondary",className:"ml-2 h-5 gap-1 bg-blue-50 text-blue-700 dark:bg-blue-950 dark:text-blue-300",children:[e.jsx(t.Sparkles,{className:"h-3 w-3"}),"Auto"]})]})}),T]})}),e.jsx(ka,{open:h,onOpenChange:x,joinPlan:o,availableDataSources:u,onSave:g,onCancel:j,onRemove:f,children:e.jsx("div",{})})]})}function Vn({open:s,onOpenChange:n}){const[a,r]=N.useState([]),{updateDataSource:i}=t.useEditorActions(),c=t.useDashboardStore(f=>f.dashboard.aiContext),o=(c==null?void 0:c.selectedEntities)||[];N.useEffect(()=>{s&&r([])},[s]);const d=f=>{r(j=>j.some(T=>T.name===f.name&&T.type===f.type)?j.filter(T=>!(T.name===f.name&&T.type===f.type)):[...j,f])},l=()=>{r([...o])},m=()=>{r([])},h=()=>{if(a.length===0)return;const f=a[0],j=f.connectionId||"",v=f.connectionType||"",I=a.some(L=>L.type==="dataset")?"semanticDomain":"database";i({connectionId:j,connectionType:v,mode:I,selectedEntities:a}),n(!1)},x=f=>"label"in f&&f.label?f.label:f.name,u=f=>{if("description"in f&&f.description)return f.description;const j=[];return f.database&&j.push(f.database),f.schema&&j.push(f.schema),f.name&&j.push(f.name),j.join(".")},g=f=>a.some(j=>j.name===f.name&&j.type===f.type);return o.length===0?e.jsx(t.Dialog,{open:s,onOpenChange:n,children:e.jsxs(t.DialogContent,{className:"max-w-md",children:[e.jsxs(t.DialogHeader,{children:[e.jsx(t.DialogTitle,{children:"No Data Available"}),e.jsx(t.DialogDescription,{children:"No entities are currently available in the AI context. Please add some data sources to the dashboard first."})]}),e.jsx(t.DialogFooter,{children:e.jsx(t.Button,{onClick:()=>n(!1),children:"Close"})})]})}):e.jsx(t.Dialog,{open:s,onOpenChange:n,children:e.jsxs(t.DialogContent,{className:"flex max-w-2xl flex-col",children:[e.jsxs(t.DialogHeader,{children:[e.jsx(t.DialogTitle,{children:"Select Data to Analyze"}),e.jsx(t.DialogDescription,{children:"Choose entities from the dashboard's context"})]}),e.jsxs("div",{className:"flex-1 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(t.Button,{variant:"outline",size:"sm",onClick:l,disabled:a.length===o.length,children:"Select All"}),e.jsx(t.Button,{variant:"outline",size:"sm",onClick:m,disabled:a.length===0,children:"Clear All"})]}),e.jsxs(t.Badge,{variant:"secondary",children:[a.length," of ",o.length," selected"]})]}),e.jsx(t.Separator,{}),e.jsx(t.ScrollArea,{className:"h-64",children:e.jsx("div",{className:"space-y-2",children:o.map((f,j)=>e.jsxs("div",{className:t.cn("flex items-center gap-3 rounded-lg border p-3 transition-colors hover:bg-muted/50",g(f)&&"border-primary bg-primary/5"),children:[e.jsx(t.Checkbox,{checked:g(f),onCheckedChange:()=>d(f)}),e.jsx("div",{className:"flex items-center gap-2 text-muted-foreground",children:t.getEntityIcon(f.type)}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate font-medium",children:x(f)}),e.jsx("div",{className:"truncate text-sm text-muted-foreground",children:u(f)})]}),e.jsx(t.Badge,{variant:"outline",className:"text-xs",children:f.type})]},`${f.type}-${f.name}-${j}`))})})]}),e.jsx(t.DialogFooter,{children:e.jsx("div",{className:"flex w-full justify-between",children:e.jsxs("div",{className:"flex grow justify-end gap-2",children:[e.jsx(t.Button,{variant:"outline",onClick:()=>n(!1),children:"Cancel"}),e.jsxs(t.Button,{onClick:h,disabled:a.length===0,children:["Select"," ",a.length>0?`(${a.length})`:""]})]})})})]})})}function aa({entities:s,title:n}){const{isConsoleMode:a}=t.useDashboardPreferences();return e.jsx(t.TooltipContent,{side:"top",className:"ml-5 max-w-xs",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm font-medium",children:n??`${s.length} more entities`}),e.jsx("div",{className:"space-y-1",children:s.map((r,i)=>{const c=t.getEntityDetails(r),o=c.find(l=>l.label==="Description"&&l.value),d=c.filter(l=>l.label==="Description"?!1:a?!0:!["Connection","Database","Schema"].includes(l.label)).slice(0,3);return e.jsxs("div",{className:"border-b border-border pb-1 last:border-b-0",children:[e.jsx("div",{className:"text-xs font-medium",children:t.getDisplayName(r)}),o&&e.jsxs("div",{className:"mb-1 mt-1",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:"Description:"}),e.jsx("div",{className:"text-xs leading-relaxed",children:o.value})]}),d.length>0&&e.jsx("div",{className:"mt-1 space-y-0.5",children:d.map((l,m)=>e.jsxs("div",{className:"flex justify-between text-xs",children:[e.jsxs("span",{className:"mr-2 text-muted-foreground",children:[l.label,":"]}),e.jsx("span",{className:"font-mono",children:l.value})]},m))})]},`remaining-${r.type}-${r.name}-${i}`)})})]})})}function Da(s,n){const[a,r]=N.useState(()=>{const i=localStorage.getItem(s);return i?JSON.parse(i):n});return N.useEffect(()=>{localStorage.setItem(s,JSON.stringify(a))},[a,s]),[a,r]}function Aa({isVisible:s}){var j,v;const n=t.useEditorStore(T=>T.isDevMode);t.useSyncLegacyEditorState();const[a,r]=N.useState(!1),[i,c]=N.useState(!1),[o,d]=Da("semaphor:data-source-collapsed",!1),l=t.useEditorStore(T=>T.card.dataSource),m=t.useEditorStore(T=>{var I,z;return(z=(I=T.card)==null?void 0:I.config)==null?void 0:z.joinPlan}),{updateDataSource:h}=t.useEditorActions(),x=((j=l==null?void 0:l.selectedEntities)==null?void 0:j.length)||0,u=((v=m==null?void 0:m.joins)==null?void 0:v.length)||0,f={...{connectionId:"",connectionType:"",mode:"database",selectedEntities:[]},...l,selectedEntities:(l==null?void 0:l.selectedEntities)||[]};return e.jsxs("div",{className:t.cn("flex shrink-0 flex-col overflow-hidden bg-background transition-all duration-300 ease-in-out",{"w-[325px]":s,"min-w-[325px]":s,"w-0":!s,"min-w-0":!s}),children:[x===0&&u===0?e.jsx("div",{className:"px-4 pt-4",children:e.jsx("div",{className:"rounded-xl border border-border/55 bg-card p-3 shadow-[0_1px_2px_rgba(15,23,42,0.05)]",children:e.jsxs(t.Button,{className:"w-full bg-background",variant:"outline",onClick:()=>r(!0),children:[e.jsx(t.Database,{className:"mr-2 h-3.5 w-3.5"}),"Choose Dataset"]})})}):e.jsx("div",{className:"px-4 pt-4",children:e.jsxs("div",{className:"rounded-xl border border-border/55 bg-card p-3 shadow-[0_1px_2px_rgba(15,23,42,0.05)]",children:[e.jsxs("div",{className:t.cn("flex cursor-pointer items-center justify-between px-1",o?"pb-0":"pb-3"),onClick:()=>d(!o),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium text-foreground",children:"Data Source"}),o&&e.jsxs("div",{className:"flex items-center gap-1.5",onClick:T=>T.stopPropagation(),children:[x>0&&e.jsx(t.TooltipProvider,{delayDuration:100,children:e.jsxs(t.Tooltip,{children:[e.jsx(t.TooltipTrigger,{asChild:!0,children:e.jsxs(t.Badge,{variant:"secondary",className:"h-5 cursor-pointer gap-1 px-1.5 text-xs transition-colors hover:bg-secondary/80",onClick:()=>r(!0),children:[e.jsx(t.Database,{className:"h-3 w-3"}),x]})}),e.jsx(aa,{entities:f.selectedEntities,title:`${x} selected ${x===1?"entity":"entities"}`})]})}),u>0&&!n&&e.jsx(sa,{variant:"badge"})]})]}),e.jsx(t.Button,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:T=>{T.stopPropagation(),d(!o)},children:o?e.jsx(t.ChevronDown,{className:"h-4 w-4"}):e.jsx(t.ChevronUp,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:t.cn("flex flex-col overflow-hidden transition-all duration-200 ease-in-out",o?"max-h-0 opacity-0":"max-h-96 opacity-100"),children:[e.jsx("div",{className:"px-1",children:e.jsx(t.TooltipProvider,{children:e.jsxs(t.Tooltip,{children:[e.jsx(t.TooltipTrigger,{asChild:!0,children:e.jsxs(t.Button,{className:"w-full bg-background",variant:"outline",onClick:()=>r(!0),children:[e.jsx(t.Database,{className:"mr-2 h-3.5 w-3.5"}),x===1?"Dataset":"Datasets",e.jsx("span",{className:"ml-2 flex h-5 min-w-5 items-center justify-center rounded-full border bg-muted-foreground px-1.5 text-xs font-medium text-background",children:x})]})}),e.jsx(aa,{entities:f.selectedEntities,title:`${x} selected ${x===1?"entity":"entities"}`})]})})}),!n&&x>1&&e.jsx("div",{className:"mt-3 px-1",children:e.jsx(sa,{})})]})]})}),e.jsx("div",{className:"min-h-0 flex-1 px-4 pb-4 pt-2",children:e.jsx("div",{className:"h-full overflow-hidden rounded-xl border border-border/55 bg-card shadow-[0_1px_2px_rgba(15,23,42,0.05)]",children:e.jsx(t.FieldsSection,{})})}),e.jsx(t.DataSourceDialog,{incomingSelectedEntities:(l==null?void 0:l.selectedEntities)||[],dialogMode:"dataSource",open:a,onOpenChange:r,dataSource:f}),e.jsx(Vn,{open:i,onOpenChange:c})]})}function Pn(s){return t.GenIcon({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M439.8 200.5c-7.7-30.9-22.3-54.2-53.4-54.2h-40.1v47.4c0 36.8-31.2 67.8-66.8 67.8H172.7c-29.2 0-53.4 25-53.4 54.3v101.8c0 29 25.2 46 53.4 54.3 33.8 9.9 66.3 11.7 106.8 0 26.9-7.8 53.4-23.5 53.4-54.3v-40.7H226.2v-13.6h160.2c31.1 0 42.6-21.7 53.4-54.2 11.2-33.5 10.7-65.7 0-108.6zM286.2 404c11.1 0 20.1 9.1 20.1 20.3 0 11.3-9 20.4-20.1 20.4-11 0-20.1-9.2-20.1-20.4.1-11.3 9.1-20.3 20.1-20.3zM167.8 248.1h106.8c29.7 0 53.4-24.5 53.4-54.3V91.9c0-29-24.4-50.7-53.4-55.6-35.8-5.9-74.7-5.6-106.8.1-45.2 8-53.4 24.7-53.4 55.6v40.7h106.9v13.6h-147c-31.1 0-58.3 18.7-66.8 54.2-9.8 40.7-10.2 66.1 0 108.6 7.6 31.6 25.7 54.2 56.8 54.2H101v-48.8c0-35.3 30.5-66.4 66.8-66.4zm-6.7-142.6c-11.1 0-20.1-9.1-20.1-20.3.1-11.3 9-20.4 20.1-20.4 11 0 20.1 9.2 20.1 20.4s-9 20.3-20.1 20.3z"},child:[]}]})(s)}function Ma(s){const{theme:n}=t.useTheme(),a=t.useDashboardStore(j=>j.theme),r=t.useEditorStore(j=>j.frame),i=t.useEditorStore(j=>j.card),c=t.useEditorStore(j=>j.activeTabCardId),o=t.Le(),{refetch:d}=t.useDashboardCardQuery(i),{updateCardTab:l,setRunSql:m}=t.useEditorActions(),h=N.useRef(void 0),x=N.useRef({}),u=r.cards.find(j=>j.id===c),g=N.useCallback(()=>{let j="";return s==="python"&&(j=(u==null?void 0:u.python)||t.PYTHON_DEFAULT_CODE),s==="sql"&&(j=(u==null?void 0:u.sql)||""),j},[s,u]);N.useEffect(()=>{if(c&&i.id&&i.id!==c){if(h.current&&o){const j=h.current.getModel();j&&(x.current[i.id]=j);let v=x.current[c];if(!v){const T=g();v=o.editor.createModel(T,s),x.current[c]=v}h.current.setModel(v)}l(c,i),m(!0)}},[c,i,l,o,m,s,g]),N.useEffect(()=>{if(!o)return;const j=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",v=a==="system"?j:a;o.editor.defineTheme("default",{base:v==="light"?"vs":"vs-dark",inherit:!0,rules:[],colors:{"editor.background":v==="light"?"#ffffff":t.hslStringToHex("240 10% 10%")}}),o.editor.setTheme("default")},[n,a,o]),N.useEffect(()=>{const j=h.current;j&&o&&i&&j.addCommand(o.KeyMod.Shift|o.KeyCode.Enter,function(){return d(),!1})},[o,d,i]);function f(j,v){if(h.current=j,!x.current[i.id]){const T=j.getModel(),I=g();x.current[i.id]=T||(v==null?void 0:v.editor.createModel(I,s))||j.getModel()}j.setModel(x.current[i.id])}return{handleEditorDidMount:f}}const Bn=300;function zn(){const s=t.useEditorStore(h=>h.card.sql),n=t.useEditorStore(h=>h.sqlGen),{setCardSql:a,setSqlGen:r}=t.useEditorActions(),{handleEditorDidMount:i}=Ma("sql"),c=N.useRef(n);c.current=n;const o=N.useCallback(h=>{a(h)},[a]),{value:d,onChange:l}=Ia({storeValue:s,defaultValue:"",onStoreUpdate:o,delay:Bn});function m(h){l(h),t.isObjectEmpty(c.current)||r({})}return e.jsxs("div",{className:"relative h-full w-full",children:[!d&&e.jsx("div",{className:"pointer-events-none absolute left-[36px] top-3 z-10 font-mono text-sm text-muted-foreground",children:"Write your SQL here"}),e.jsx(t.Ft,{theme:"default",className:"pt-3",onChange:m,value:d,options:{minimap:{enabled:!1},glyphMargin:!1,lineNumbersMinChars:2,lineDecorationsWidth:0,wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:13,renderLineHighlight:"none"},defaultLanguage:"sql",onMount:i})]})}const qn=300;function _n(){const s=t.useEditorStore(c=>c.card.python),{setCardPython:n}=t.useEditorActions(),{handleEditorDidMount:a}=Ma("python"),{value:r,onChange:i}=Ia({storeValue:s,defaultValue:t.PYTHON_DEFAULT_CODE,onStoreUpdate:n,delay:qn});return e.jsx(t.Ft,{className:"pt-3",theme:"default",onChange:i,value:r,options:{minimap:{enabled:!1},glyphMargin:!1,lineNumbersMinChars:2,lineDecorationsWidth:0,wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:13,renderLineHighlight:"none"},defaultLanguage:"python",onMount:a})}const $n={async writeTextToClipboard(s){return typeof navigator>"u"||!navigator.clipboard?!1:(await navigator.clipboard.writeText(s),!0)}},Ot=50,Kn=[{target:"queryRequest",label:"Query Request"},{target:"queryResponse",label:"Query Response"},{target:"cardConfig",label:"Card Config"},{target:"dataSource",label:"Data Source"},{target:"columns",label:"Columns"},{target:"dashboardFilters",label:"Dashboard Filters"},{target:"cardMetadata",label:"Card Metadata IDs"}];function na(s){try{return JSON.stringify(s,null,2)}catch(n){return console.error("Unable to stringify debug payload",n),null}}function ft(s){switch(s){case"queryRequest":return"Query Request";case"queryResponse":return"Query Response";case"cardConfig":return"Card Config";case"dataSource":return"Data Source";case"cardMetadata":return"Card Metadata IDs";case"columns":return"Columns";case"dashboardFilters":return"Dashboard Filters";default:return"Payload"}}function Gn(s){if(!s||typeof s!="object")return{value:s};const n=s.records;return!Array.isArray(n)||n.length<=Ot?{value:s}:{value:{...s,records:n.slice(0,Ot),previewMeta:{truncatedRecords:!0,displayedRecords:Ot,totalRecords:n.length}},truncationMessage:`Preview showing first ${Ot} records of ${n.length}. Copy actions include full payload.`}}function La({sql:s,showCardDetails:n=!1,debugPayloads:a,className:r}){const[i,c]=N.useState(!1),[o,d]=N.useState(null),l=t.useEditorStore(w=>w.card),m=t.useEditorStore(w=>w.frame),h=t.useEditorStore(w=>w.isDevMode),x=t.useDashboardStore(w=>w.selectedSheetId),u=t.useDashboardStore(w=>{var D;return(D=w.dashboard)==null?void 0:D.id}),{switchEditorMode:g,setRunSql:f}=t.useEditorActions(),j=N.useMemo(()=>({cardId:l.id||null,frameId:m.id||null,sheetId:x||null,dashboardId:u||null}),[l.id,m.id,x,u]),v=N.useMemo(()=>({queryRequest:a==null?void 0:a.queryRequest,queryResponse:a==null?void 0:a.queryResponse,cardConfig:l.config,dataSource:l.dataSource,columns:a==null?void 0:a.columns,dashboardFilters:a==null?void 0:a.dashboardFilters,cardMetadata:j}),[a==null?void 0:a.queryRequest,a==null?void 0:a.queryResponse,a==null?void 0:a.columns,a==null?void 0:a.dashboardFilters,l.config,l.dataSource,j]),T=n&&i&&!!a,I=N.useMemo(()=>[{label:"Card ID",value:l.id||""},{label:"Frame ID",value:m.id||""},{label:"Sheet ID",value:x||""},{label:"Dashboard ID",value:u||""}],[l.id,m.id,x,u]),z=()=>{g("dev",{sqlToLoad:s}),setTimeout(()=>{f(!0)},100)},L=w=>v[w]!==void 0,E=N.useMemo(()=>{if(!o)return null;const w=v[o];if(w===void 0)return null;const D=o==="queryResponse"?Gn(w):{value:w},p=na(D.value);return p?{target:o,title:ft(o),json:p,truncationMessage:D.truncationMessage}:null},[o,v]),C=E?E.title:"Preview Payload",A=async w=>{const D=v[w];if(D===void 0)return t.ue.error(`No ${ft(w).toLowerCase()} available`),!1;const p=na(D);if(!p)return t.ue.error(`Unable to serialize ${ft(w).toLowerCase()}`),!1;try{return await $n.writeTextToClipboard(p)?(t.ue.success(`${ft(w)} copied`),!0):(t.ue.error("Clipboard is not available"),!1)}catch(O){return console.error("Failed to copy debug payload",O),t.ue.error(`Unable to copy ${ft(w).toLowerCase()}`),!1}},k=async()=>E?A(E.target):!1,b=w=>{if(v[w]===void 0){t.ue.error(`No ${ft(w).toLowerCase()} available`);return}d(w)};return e.jsxs("div",{className:t.cn("flex min-h-0 flex-1 flex-col",r),children:[!h&&e.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[e.jsxs(t.Button,{onClick:z,variant:"secondary",size:"sm",children:[e.jsx(Ta,{className:"mr-2 h-4 w-4"}),"View in SQL Editor"]}),n&&e.jsxs(t.Button,{onClick:()=>c(!i),variant:"outline",size:"sm",children:[e.jsx(t.Info,{className:"mr-2 h-4 w-4"}),"Card Details"]})]}),i&&n&&e.jsx("div",{className:"mb-3 rounded-lg border border-border bg-muted/30 p-4",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-sm font-semibold",children:"Card Information"}),e.jsx(t.Button,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>c(!1),children:e.jsx(Ae.CircleX,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"grid grid-cols-1 gap-2 md:grid-cols-2",children:I.map(w=>e.jsxs("div",{className:"min-w-0 rounded-md bg-background/60 px-3 py-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:w.label}),e.jsx(t.CopyButton,{text:w.value,className:"h-6 w-6 shrink-0"})]}),e.jsx("code",{title:w.value||"N/A",className:"mt-1 block whitespace-normal break-all font-mono text-xs",children:w.value||"N/A"})]},w.label))}),T&&e.jsxs("div",{className:"space-y-2 rounded-md border border-border/60 bg-background/70 p-3",children:[e.jsx("p",{className:"text-xs font-semibold text-muted-foreground",children:"Debug Tools"}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs(t.DropdownMenu,{children:[e.jsx(t.DropdownMenuTrigger,{asChild:!0,children:e.jsxs(t.Button,{variant:"outline",size:"sm",className:"h-8","aria-label":"Preview Payload Menu",children:[e.jsx(t.Eye,{className:"mr-1.5 h-3.5 w-3.5"}),C,e.jsx(t.ChevronDown,{className:"ml-1.5 h-3.5 w-3.5"})]})}),e.jsx(t.DropdownMenuContent,{align:"start",className:"w-56",children:Kn.map(w=>e.jsx(t.DropdownMenuItem,{disabled:!L(w.target),onSelect:()=>b(w.target),className:t.cn(o===w.target&&"bg-accent"),children:w.label},`preview-${w.target}`))})]})}),E&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("p",{className:"text-xs font-medium text-muted-foreground",children:[E.title," Preview"]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(t.CopyButton,{text:E.json,className:"h-6 w-6",ariaLabel:"Copy Payload",onCopy:k}),e.jsxs(t.Button,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>d(null),children:[e.jsx(Ae.CircleX,{className:"mr-1 h-3.5 w-3.5"}),"Hide"]})]})]}),E.truncationMessage&&e.jsx("p",{className:"text-xs text-muted-foreground",children:E.truncationMessage}),e.jsx("div",{className:"max-h-80 overflow-auto",children:e.jsx(t.CodeHighlighter,{code:E.json,language:"json"})})]})]})]})}),e.jsx("div",{className:"min-h-0 flex-1 overflow-auto text-xs leading-relaxed text-foreground/80",children:e.jsx("div",{className:"flex flex-col space-y-1.5",children:e.jsxs("div",{className:"group relative",children:[e.jsx("div",{className:"absolute right-2 top-2 z-10 rounded-md border border-border/60 bg-background/85 p-0.5 shadow-sm backdrop-blur-sm transition-opacity duration-150",children:e.jsx(t.CopyButton,{text:s,className:"h-6 w-6 px-0 text-muted-foreground/80 hover:text-foreground"})}),e.jsx(t.CodeHighlighter,{code:s,language:"sql",wrapLongLines:!0})]})})})]})}function Un(s){const{request:n,mode:a="draft",currentSql:r,selectedTableName:i,selectedSchemaName:c,selectedDatabaseName:o}=s,d=[o?`Database: ${o}`:"",c?`Schema: ${c}`:"",i?`Table: ${i}`:""].filter(Boolean);return["You are an expert SQL writing assistant embedded in a query editor.",`Write SQL only. You may call only read-only tools when needed: ${t.INLINE_ALLOWED_TOOL_LIST}.`,"Do not call mutation tools or chart-creation tools; those require Full Assistant.","Return exactly one SQL statement inside a single ```sql fenced block.","After the code block, optionally include one short sentence.",a==="refine"&&r?"Mode: Refine existing SQL. Keep the current query structure and only apply the requested changes unless the current query is invalid.":"Mode: Draft new SQL from the request.",d.length>0?`Context:
167
+ ON ${w}`}),C};if(u.length<2)return null;const T=o.joins.length>0&&e.jsx(t.TooltipContent,{side:"bottom",className:"ml-4 max-w-md overflow-hidden p-0",children:e.jsx(Rn,{joins:o.joins,baseEntityId:o.baseEntity.name,availableDataSources:u,generateSQLPreview:v})});return e.jsxs(e.Fragment,{children:[e.jsx(t.TooltipProvider,{children:e.jsxs(t.Tooltip,{children:[e.jsx(t.TooltipTrigger,{asChild:!0,children:a==="badge"?e.jsxs(t.Badge,{variant:"secondary",className:"h-5 cursor-pointer gap-1 px-1.5 text-xs transition-colors hover:bg-secondary/80",onClick:L=>{L.stopPropagation(),x(!0)},children:[e.jsx(t.Link,{className:"h-3 w-3"}),o.joins.length]}):e.jsxs(t.Button,{onClick:()=>x(!0),variant:"outline",className:"w-full bg-muted/50",children:[e.jsx(t.Link,{className:"mr-2 h-3.5 w-3.5"}),o.joins.length===0?"Configure Joins":o.joins.length===1?"Join":"Joins",o.joins.length>0&&e.jsx("span",{className:"ml-2 flex h-5 min-w-5 items-center justify-center rounded-full border bg-muted-foreground px-1.5 text-xs font-medium text-background",children:o.joins.length}),(i==null?void 0:i.autoResolved)&&e.jsxs(t.Badge,{variant:"secondary",className:"ml-2 h-5 gap-1 bg-blue-50 text-blue-700 dark:bg-blue-950 dark:text-blue-300",children:[e.jsx(t.Sparkles,{className:"h-3 w-3"}),"Auto"]})]})}),T]})}),e.jsx(ka,{open:h,onOpenChange:x,joinPlan:o,availableDataSources:u,onSave:g,onCancel:j,onRemove:f,children:e.jsx("div",{})})]})}function Vn({open:s,onOpenChange:n}){const[a,r]=N.useState([]),{updateDataSource:i}=t.useEditorActions(),c=t.useDashboardStore(f=>f.dashboard.aiContext),o=(c==null?void 0:c.selectedEntities)||[];N.useEffect(()=>{s&&r([])},[s]);const d=f=>{r(j=>j.some(T=>T.name===f.name&&T.type===f.type)?j.filter(T=>!(T.name===f.name&&T.type===f.type)):[...j,f])},l=()=>{r([...o])},m=()=>{r([])},h=()=>{if(a.length===0)return;const f=a[0],j=f.connectionId||"",v=f.connectionType||"",I=a.some(L=>L.type==="dataset")?"semanticDomain":"database";i({connectionId:j,connectionType:v,mode:I,selectedEntities:a}),n(!1)},x=f=>"label"in f&&f.label?f.label:f.name,u=f=>{if("description"in f&&f.description)return f.description;const j=[];return f.database&&j.push(f.database),f.schema&&j.push(f.schema),f.name&&j.push(f.name),j.join(".")},g=f=>a.some(j=>j.name===f.name&&j.type===f.type);return o.length===0?e.jsx(t.Dialog,{open:s,onOpenChange:n,children:e.jsxs(t.DialogContent,{className:"max-w-md",children:[e.jsxs(t.DialogHeader,{children:[e.jsx(t.DialogTitle,{children:"No Data Available"}),e.jsx(t.DialogDescription,{children:"No entities are currently available in the AI context. Please add some data sources to the dashboard first."})]}),e.jsx(t.DialogFooter,{children:e.jsx(t.Button,{onClick:()=>n(!1),children:"Close"})})]})}):e.jsx(t.Dialog,{open:s,onOpenChange:n,children:e.jsxs(t.DialogContent,{className:"flex max-w-2xl flex-col",children:[e.jsxs(t.DialogHeader,{children:[e.jsx(t.DialogTitle,{children:"Select Data to Analyze"}),e.jsx(t.DialogDescription,{children:"Choose entities from the dashboard's context"})]}),e.jsxs("div",{className:"flex-1 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(t.Button,{variant:"outline",size:"sm",onClick:l,disabled:a.length===o.length,children:"Select All"}),e.jsx(t.Button,{variant:"outline",size:"sm",onClick:m,disabled:a.length===0,children:"Clear All"})]}),e.jsxs(t.Badge,{variant:"secondary",children:[a.length," of ",o.length," selected"]})]}),e.jsx(t.Separator,{}),e.jsx(t.ScrollArea,{className:"h-64",children:e.jsx("div",{className:"space-y-2",children:o.map((f,j)=>e.jsxs("div",{className:t.cn("flex items-center gap-3 rounded-lg border p-3 transition-colors hover:bg-muted/50",g(f)&&"border-primary bg-primary/5"),children:[e.jsx(t.Checkbox,{checked:g(f),onCheckedChange:()=>d(f)}),e.jsx("div",{className:"flex items-center gap-2 text-muted-foreground",children:t.getEntityIcon(f.type)}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate font-medium",children:x(f)}),e.jsx("div",{className:"truncate text-sm text-muted-foreground",children:u(f)})]}),e.jsx(t.Badge,{variant:"outline",className:"text-xs",children:f.type})]},`${f.type}-${f.name}-${j}`))})})]}),e.jsx(t.DialogFooter,{children:e.jsx("div",{className:"flex w-full justify-between",children:e.jsxs("div",{className:"flex grow justify-end gap-2",children:[e.jsx(t.Button,{variant:"outline",onClick:()=>n(!1),children:"Cancel"}),e.jsxs(t.Button,{onClick:h,disabled:a.length===0,children:["Select"," ",a.length>0?`(${a.length})`:""]})]})})})]})})}function aa({entities:s,title:n}){const{isConsoleMode:a}=t.useDashboardPreferences();return e.jsx(t.TooltipContent,{side:"top",className:"ml-5 max-w-xs",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm font-medium",children:n??`${s.length} more entities`}),e.jsx("div",{className:"space-y-1",children:s.map((r,i)=>{const c=t.getEntityDetails(r),o=c.find(l=>l.label==="Description"&&l.value),d=c.filter(l=>l.label==="Description"?!1:a?!0:!["Connection","Database","Schema"].includes(l.label)).slice(0,3);return e.jsxs("div",{className:"border-b border-border pb-1 last:border-b-0",children:[e.jsx("div",{className:"text-xs font-medium",children:t.getDisplayName(r)}),o&&e.jsxs("div",{className:"mb-1 mt-1",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:"Description:"}),e.jsx("div",{className:"text-xs leading-relaxed",children:o.value})]}),d.length>0&&e.jsx("div",{className:"mt-1 space-y-0.5",children:d.map((l,m)=>e.jsxs("div",{className:"flex justify-between text-xs",children:[e.jsxs("span",{className:"mr-2 text-muted-foreground",children:[l.label,":"]}),e.jsx("span",{className:"font-mono",children:l.value})]},m))})]},`remaining-${r.type}-${r.name}-${i}`)})})]})})}function Da(s,n){const[a,r]=N.useState(()=>{const i=localStorage.getItem(s);return i?JSON.parse(i):n});return N.useEffect(()=>{localStorage.setItem(s,JSON.stringify(a))},[a,s]),[a,r]}function Aa({isVisible:s}){var j,v;const n=t.useEditorStore(T=>T.isDevMode);t.useSyncLegacyEditorState();const[a,r]=N.useState(!1),[i,c]=N.useState(!1),[o,d]=Da("semaphor:data-source-collapsed",!1),l=t.useEditorStore(T=>T.card.dataSource),m=t.useEditorStore(T=>{var I,z;return(z=(I=T.card)==null?void 0:I.config)==null?void 0:z.joinPlan}),{updateDataSource:h}=t.useEditorActions(),x=((j=l==null?void 0:l.selectedEntities)==null?void 0:j.length)||0,u=((v=m==null?void 0:m.joins)==null?void 0:v.length)||0,f={...{connectionId:"",connectionType:"",mode:"database",selectedEntities:[]},...l,selectedEntities:(l==null?void 0:l.selectedEntities)||[]};return e.jsxs("div",{className:t.cn("flex shrink-0 flex-col overflow-hidden bg-background transition-all duration-300 ease-in-out",{"w-[325px]":s,"min-w-[325px]":s,"w-0":!s,"min-w-0":!s}),children:[x===0&&u===0?e.jsx("div",{className:"px-4 pt-4",children:e.jsx("div",{className:"rounded-xl border border-border/55 bg-card p-3 shadow-[0_1px_2px_rgba(15,23,42,0.05)]",children:e.jsxs(t.Button,{className:"w-full bg-background",variant:"outline",onClick:()=>r(!0),children:[e.jsx(t.Database,{className:"mr-2 h-3.5 w-3.5"}),"Choose Dataset"]})})}):e.jsx("div",{className:"px-4 pt-4",children:e.jsxs("div",{className:"rounded-xl border border-border/55 bg-card p-3 shadow-[0_1px_2px_rgba(15,23,42,0.05)]",children:[e.jsxs("div",{className:t.cn("flex cursor-pointer items-center justify-between px-1",o?"pb-0":"pb-3"),onClick:()=>d(!o),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium text-foreground",children:"Data Source"}),o&&e.jsxs("div",{className:"flex items-center gap-1.5",onClick:T=>T.stopPropagation(),children:[x>0&&e.jsx(t.TooltipProvider,{delayDuration:100,children:e.jsxs(t.Tooltip,{children:[e.jsx(t.TooltipTrigger,{asChild:!0,children:e.jsxs(t.Badge,{variant:"secondary",className:"h-5 cursor-pointer gap-1 px-1.5 text-xs transition-colors hover:bg-secondary/80",onClick:()=>r(!0),children:[e.jsx(t.Database,{className:"h-3 w-3"}),x]})}),e.jsx(aa,{entities:f.selectedEntities,title:`${x} selected ${x===1?"entity":"entities"}`})]})}),u>0&&!n&&e.jsx(sa,{variant:"badge"})]})]}),e.jsx(t.Button,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:T=>{T.stopPropagation(),d(!o)},children:o?e.jsx(t.ChevronDown,{className:"h-4 w-4"}):e.jsx(t.ChevronUp,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:t.cn("flex flex-col overflow-hidden transition-all duration-200 ease-in-out",o?"max-h-0 opacity-0":"max-h-96 opacity-100"),children:[e.jsx("div",{className:"px-1",children:e.jsx(t.TooltipProvider,{children:e.jsxs(t.Tooltip,{children:[e.jsx(t.TooltipTrigger,{asChild:!0,children:e.jsxs(t.Button,{className:"w-full bg-background",variant:"outline",onClick:()=>r(!0),children:[e.jsx(t.Database,{className:"mr-2 h-3.5 w-3.5"}),x===1?"Dataset":"Datasets",e.jsx("span",{className:"ml-2 flex h-5 min-w-5 items-center justify-center rounded-full border bg-muted-foreground px-1.5 text-xs font-medium text-background",children:x})]})}),e.jsx(aa,{entities:f.selectedEntities,title:`${x} selected ${x===1?"entity":"entities"}`})]})})}),!n&&x>1&&e.jsx("div",{className:"mt-3 px-1",children:e.jsx(sa,{})})]})]})}),e.jsx("div",{className:"min-h-0 flex-1 px-4 pb-4 pt-2",children:e.jsx("div",{className:"h-full overflow-hidden rounded-xl border border-border/55 bg-card shadow-[0_1px_2px_rgba(15,23,42,0.05)]",children:e.jsx(t.FieldsSection,{})})}),e.jsx(t.DataSourceDialog,{incomingSelectedEntities:(l==null?void 0:l.selectedEntities)||[],dialogMode:"dataSource",open:a,onOpenChange:r,dataSource:f}),e.jsx(Vn,{open:i,onOpenChange:c})]})}function Pn(s){return t.GenIcon({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M439.8 200.5c-7.7-30.9-22.3-54.2-53.4-54.2h-40.1v47.4c0 36.8-31.2 67.8-66.8 67.8H172.7c-29.2 0-53.4 25-53.4 54.3v101.8c0 29 25.2 46 53.4 54.3 33.8 9.9 66.3 11.7 106.8 0 26.9-7.8 53.4-23.5 53.4-54.3v-40.7H226.2v-13.6h160.2c31.1 0 42.6-21.7 53.4-54.2 11.2-33.5 10.7-65.7 0-108.6zM286.2 404c11.1 0 20.1 9.1 20.1 20.3 0 11.3-9 20.4-20.1 20.4-11 0-20.1-9.2-20.1-20.4.1-11.3 9.1-20.3 20.1-20.3zM167.8 248.1h106.8c29.7 0 53.4-24.5 53.4-54.3V91.9c0-29-24.4-50.7-53.4-55.6-35.8-5.9-74.7-5.6-106.8.1-45.2 8-53.4 24.7-53.4 55.6v40.7h106.9v13.6h-147c-31.1 0-58.3 18.7-66.8 54.2-9.8 40.7-10.2 66.1 0 108.6 7.6 31.6 25.7 54.2 56.8 54.2H101v-48.8c0-35.3 30.5-66.4 66.8-66.4zm-6.7-142.6c-11.1 0-20.1-9.1-20.1-20.3.1-11.3 9-20.4 20.1-20.4 11 0 20.1 9.2 20.1 20.4s-9 20.3-20.1 20.3z"},child:[]}]})(s)}function Ma(s){const{theme:n}=t.useTheme(),a=t.useDashboardStore(j=>j.theme),r=t.useEditorStore(j=>j.frame),i=t.useEditorStore(j=>j.card),c=t.useEditorStore(j=>j.activeTabCardId),o=t.Le(),{refetch:d}=t.useDashboardCardQuery(i),{updateCardTab:l,setRunSql:m}=t.useEditorActions(),h=N.useRef(void 0),x=N.useRef({}),u=r.cards.find(j=>j.id===c),g=N.useCallback(()=>{let j="";return s==="python"&&(j=(u==null?void 0:u.python)||t.PYTHON_DEFAULT_CODE),s==="sql"&&(j=(u==null?void 0:u.sql)||""),j},[s,u]);N.useEffect(()=>{if(c&&i.id&&i.id!==c){if(h.current&&o){const j=h.current.getModel();j&&(x.current[i.id]=j);let v=x.current[c];if(!v){const T=g();v=o.editor.createModel(T,s),x.current[c]=v}h.current.setModel(v)}l(c,i),m(!0)}},[c,i,l,o,m,s,g]),N.useEffect(()=>{if(!o)return;const j=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",v=a==="system"?j:a;o.editor.defineTheme("default",{base:v==="light"?"vs":"vs-dark",inherit:!0,rules:[],colors:{"editor.background":v==="light"?"#ffffff":t.hslStringToHex("240 10% 10%")}}),o.editor.setTheme("default")},[n,a,o]),N.useEffect(()=>{const j=h.current;j&&o&&i&&j.addCommand(o.KeyMod.Shift|o.KeyCode.Enter,function(){return d(),!1})},[o,d,i]);function f(j,v){if(h.current=j,!x.current[i.id]){const T=j.getModel(),I=g();x.current[i.id]=T||(v==null?void 0:v.editor.createModel(I,s))||j.getModel()}j.setModel(x.current[i.id])}return{handleEditorDidMount:f}}const Bn=300;function zn(){const s=t.useEditorStore(h=>h.card.sql),n=t.useEditorStore(h=>h.sqlGen),{setCardSql:a,setSqlGen:r}=t.useEditorActions(),{handleEditorDidMount:i}=Ma("sql"),c=N.useRef(n);c.current=n;const o=N.useCallback(h=>{a(h)},[a]),{value:d,onChange:l}=Ia({storeValue:s,defaultValue:"",onStoreUpdate:o,delay:Bn});function m(h){l(h),t.isObjectEmpty(c.current)||r({})}return e.jsxs("div",{className:"relative h-full w-full",children:[!d&&e.jsx("div",{className:"pointer-events-none absolute left-[36px] top-3 z-10 font-mono text-sm text-muted-foreground",children:"Write your SQL here"}),e.jsx(t.Ft,{theme:"default",className:"pt-3",onChange:m,value:d,options:{minimap:{enabled:!1},glyphMargin:!1,lineNumbersMinChars:2,lineDecorationsWidth:0,wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:13,renderLineHighlight:"none"},defaultLanguage:"sql",onMount:i})]})}const qn=300;function _n(){const s=t.useEditorStore(c=>c.card.python),{setCardPython:n}=t.useEditorActions(),{handleEditorDidMount:a}=Ma("python"),{value:r,onChange:i}=Ia({storeValue:s,defaultValue:t.PYTHON_DEFAULT_CODE,onStoreUpdate:n,delay:qn});return e.jsx(t.Ft,{className:"pt-3",theme:"default",onChange:i,value:r,options:{minimap:{enabled:!1},glyphMargin:!1,lineNumbersMinChars:2,lineDecorationsWidth:0,wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:13,renderLineHighlight:"none"},defaultLanguage:"python",onMount:a})}const $n={async writeTextToClipboard(s){return typeof navigator>"u"||!navigator.clipboard?!1:(await navigator.clipboard.writeText(s),!0)}},Ot=50,Kn=[{target:"queryRequest",label:"Query Request"},{target:"queryResponse",label:"Query Response"},{target:"cardConfig",label:"Card Config"},{target:"dataSource",label:"Data Source"},{target:"columns",label:"Columns"},{target:"dashboardFilters",label:"Dashboard Filters"},{target:"cardMetadata",label:"Card Metadata IDs"}];function na(s){try{return JSON.stringify(s,null,2)}catch(n){return console.error("Unable to stringify debug payload",n),null}}function ft(s){switch(s){case"queryRequest":return"Query Request";case"queryResponse":return"Query Response";case"cardConfig":return"Card Config";case"dataSource":return"Data Source";case"cardMetadata":return"Card Metadata IDs";case"columns":return"Columns";case"dashboardFilters":return"Dashboard Filters";default:return"Payload"}}function Gn(s){if(!s||typeof s!="object")return{value:s};const n=s.records;return!Array.isArray(n)||n.length<=Ot?{value:s}:{value:{...s,records:n.slice(0,Ot),previewMeta:{truncatedRecords:!0,displayedRecords:Ot,totalRecords:n.length}},truncationMessage:`Preview showing first ${Ot} records of ${n.length}. Copy actions include full payload.`}}function La({sql:s,showCardDetails:n=!1,debugPayloads:a,className:r}){const[i,c]=N.useState(!1),[o,d]=N.useState(null),l=t.useEditorStore(w=>w.card),m=t.useEditorStore(w=>w.frame),h=t.useEditorStore(w=>w.isDevMode),x=t.useDashboardStore(w=>w.selectedSheetId),u=t.useDashboardStore(w=>{var D;return(D=w.dashboard)==null?void 0:D.id}),{switchEditorMode:g,setRunSql:f}=t.useEditorActions(),j=N.useMemo(()=>({cardId:l.id||null,frameId:m.id||null,sheetId:x||null,dashboardId:u||null}),[l.id,m.id,x,u]),v=N.useMemo(()=>({queryRequest:a==null?void 0:a.queryRequest,queryResponse:a==null?void 0:a.queryResponse,cardConfig:l.config,dataSource:l.dataSource,columns:a==null?void 0:a.columns,dashboardFilters:a==null?void 0:a.dashboardFilters,cardMetadata:j}),[a==null?void 0:a.queryRequest,a==null?void 0:a.queryResponse,a==null?void 0:a.columns,a==null?void 0:a.dashboardFilters,l.config,l.dataSource,j]),T=n&&i&&!!a,I=N.useMemo(()=>[{label:"Card ID",value:l.id||""},{label:"Frame ID",value:m.id||""},{label:"Sheet ID",value:x||""},{label:"Dashboard ID",value:u||""}],[l.id,m.id,x,u]),z=()=>{g("dev",{sqlToLoad:s}),setTimeout(()=>{f(!0)},100)},L=w=>v[w]!==void 0,E=N.useMemo(()=>{if(!o)return null;const w=v[o];if(w===void 0)return null;const D=o==="queryResponse"?Gn(w):{value:w},p=na(D.value);return p?{target:o,title:ft(o),json:p,truncationMessage:D.truncationMessage}:null},[o,v]),C=E?E.title:"Preview Payload",A=async w=>{const D=v[w];if(D===void 0)return t.ue.error(`No ${ft(w).toLowerCase()} available`),!1;const p=na(D);if(!p)return t.ue.error(`Unable to serialize ${ft(w).toLowerCase()}`),!1;try{return await $n.writeTextToClipboard(p)?(t.ue.success(`${ft(w)} copied`),!0):(t.ue.error("Clipboard is not available"),!1)}catch(O){return console.error("Failed to copy debug payload",O),t.ue.error(`Unable to copy ${ft(w).toLowerCase()}`),!1}},k=async()=>E?A(E.target):!1,b=w=>{if(v[w]===void 0){t.ue.error(`No ${ft(w).toLowerCase()} available`);return}d(w)};return e.jsxs("div",{className:t.cn("flex min-h-0 flex-1 flex-col",r),children:[!h&&e.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[e.jsxs(t.Button,{onClick:z,variant:"secondary",size:"sm",children:[e.jsx(Ta,{className:"mr-2 h-4 w-4"}),"View in SQL Editor"]}),n&&e.jsxs(t.Button,{onClick:()=>c(!i),variant:"outline",size:"sm",children:[e.jsx(t.Info,{className:"mr-2 h-4 w-4"}),"Card Details"]})]}),i&&n&&e.jsx("div",{className:"mb-3 rounded-lg border border-border bg-muted/30 p-4",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-sm font-semibold",children:"Card Information"}),e.jsx(t.Button,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>c(!1),children:e.jsx(Ae.CircleX,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"grid grid-cols-1 gap-2 md:grid-cols-2",children:I.map(w=>e.jsxs("div",{className:"min-w-0 rounded-md bg-background/60 px-3 py-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:w.label}),e.jsx(t.CopyButton,{text:w.value,className:"h-6 w-6 shrink-0"})]}),e.jsx("code",{title:w.value||"N/A",className:"mt-1 block whitespace-normal break-all font-mono text-xs",children:w.value||"N/A"})]},w.label))}),T&&e.jsxs("div",{className:"space-y-2 rounded-md border border-border/60 bg-background/70 p-3",children:[e.jsx("p",{className:"text-xs font-semibold text-muted-foreground",children:"Debug Tools"}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs(t.DropdownMenu,{children:[e.jsx(t.DropdownMenuTrigger,{asChild:!0,children:e.jsxs(t.Button,{variant:"outline",size:"sm",className:"h-8","aria-label":"Preview Payload Menu",children:[e.jsx(t.Eye,{className:"mr-1.5 h-3.5 w-3.5"}),C,e.jsx(t.ChevronDown,{className:"ml-1.5 h-3.5 w-3.5"})]})}),e.jsx(t.DropdownMenuContent,{align:"start",className:"w-56",children:Kn.map(w=>e.jsx(t.DropdownMenuItem,{disabled:!L(w.target),onSelect:()=>b(w.target),className:t.cn(o===w.target&&"bg-accent"),children:w.label},`preview-${w.target}`))})]})}),E&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("p",{className:"text-xs font-medium text-muted-foreground",children:[E.title," Preview"]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(t.CopyButton,{text:E.json,className:"h-6 w-6",ariaLabel:"Copy Payload",onCopy:k}),e.jsxs(t.Button,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>d(null),children:[e.jsx(Ae.CircleX,{className:"mr-1 h-3.5 w-3.5"}),"Hide"]})]})]}),E.truncationMessage&&e.jsx("p",{className:"text-xs text-muted-foreground",children:E.truncationMessage}),e.jsx("div",{className:"max-h-80 overflow-auto",children:e.jsx(t.CodeHighlighter,{code:E.json,language:"json"})})]})]})]})}),e.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:e.jsxs("div",{className:"overflow-hidden rounded-xl border border-border/60 bg-gradient-to-b from-background to-muted/[0.18] shadow-sm",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-border/50 bg-background/80 px-3 py-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"rounded-md border border-border/60 bg-muted/60 px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-[0.12em] text-muted-foreground",children:"SQL"}),e.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Generated query"})]}),e.jsx("div",{className:"rounded-md border border-border/60 bg-background/85 p-0.5 shadow-sm backdrop-blur-sm",children:e.jsx(t.CopyButton,{text:s,className:"h-6 w-6 px-0 text-muted-foreground/80 hover:text-foreground"})})]}),e.jsx("div",{className:"group relative overflow-auto px-1 py-1 text-xs leading-relaxed text-foreground/80",children:e.jsx(t.CodeHighlighter,{code:s,language:"sql",wrapLongLines:!0})})]})})]})}function Un(s){const{request:n,mode:a="draft",currentSql:r,selectedTableName:i,selectedSchemaName:c,selectedDatabaseName:o}=s,d=[o?`Database: ${o}`:"",c?`Schema: ${c}`:"",i?`Table: ${i}`:""].filter(Boolean);return["You are an expert SQL writing assistant embedded in a query editor.",`Write SQL only. You may call only read-only tools when needed: ${t.INLINE_ALLOWED_TOOL_LIST}.`,"Do not call mutation tools or chart-creation tools; those require Full Assistant.","Return exactly one SQL statement inside a single ```sql fenced block.","After the code block, optionally include one short sentence.",a==="refine"&&r?"Mode: Refine existing SQL. Keep the current query structure and only apply the requested changes unless the current query is invalid.":"Mode: Draft new SQL from the request.",d.length>0?`Context:
168
168
  ${d.join(`
169
169
  `)}`:"",r?a==="refine"?`Current SQL (must refine):
170
170
  ${r}`:`Current SQL (revise if useful):
@@ -1,8 +1,8 @@
1
1
  import { jsxs as a, jsx as e, Fragment as be } from "react/jsx-runtime";
2
- import { bK as Le, du as oo, x as xt, M as ge, U as M, dv as fn, dw as co, L as V, y as te, z as ae, A as ne, E as se, F as _, bU as Qe, B as H, b$ as kt, dx as _n, dy as ql, dz as zl, dA as _l, dB as jl, dC as jn, a3 as Ft, X as at, dD as zs, c9 as _s, e as Ma, f as Oa, g as Fa, h as Ra, i as un, bY as yt, bV as mt, bR as ht, bS as rt, bT as lt, dE as Zr, dF as Kl, u as Ve, v as Ds, dG as La, ce as Ua, c as Z, dc as vt, dH as Gl, b_ as Ul, dI as uo, dJ as mo, dK as ho, dL as on, dM as po, dN as Hl, dO as fo, cL as Jl, dP as go, dQ as Ql, dR as xo, dS as js, dT as bo, dU as jt, dV as cn, c0 as Ha, c1 as Ja, dW as As, c3 as Qa, c4 as ut, dX as Pa, dY as vo, dZ as Es, d_ as Mn, b as ua, aa as Yl, d$ as dn, e0 as Ks, e1 as yo, e2 as No, e3 as Wl, e4 as Xl, e5 as Zl, c$ as Gs, I as Ye, P as It, e6 as Co, l as Dt, e7 as wo, w as ra, e8 as So, e9 as To, H as ko, ea as Io, bL as Ya, bM as ma, bN as ha, bO as gn, bP as qt, bQ as Aa, eb as Ms, ec as la, ed as bt, ee as ia, ef as Do, eg as Pn, eh as Vn, ei as Bn, ej as Us, dp as Va, ek as xn, el as Ao, R as bn, em as Kn, en as Wa, cf as Hs, eo as ei, j as Wt, cG as Eo, ep as Vt, eq as zt, er as Mo, es as _t, cq as Js, cD as Qs, N as ti, et as Ys, eu as Oo, ev as ai, ew as ni, ex as $t, dk as us, ey as Fo, ez as Ro, eA as Lo, eB as si, ar as ri, eC as li, eD as Po, eE as Vo, eF as Bo, eG as Gn, eH as $o, eI as qo, eJ as el, eK as zo, V as Un, a1 as Ws, eL as _o, eM as Xs, cN as jo, eN as tl, a4 as dt, eO as Ko, d6 as Zs, d7 as er, d8 as sa, d9 as On, eP as Go, dl as Uo, eQ as ii, eR as Ho, eS as Jo, cw as Hn, cu as ct, eT as Qo, eU as Yo, eV as al, eW as Wo, k as Rt, cO as Jn, c8 as Pt, eX as Gt, eY as oa, eZ as ca, e_ as Xt, e$ as Ba, f0 as Xo, a_ as Zo, f1 as ec, f2 as tc, f3 as ac, f4 as nc, cC as Ea, f5 as sc, f6 as oi, f7 as rc, f8 as lc, f9 as ic, fa as oc, fb as ci, fc as cc, fd as dc, fe as uc, ff as mc, fg as hc, fh as pc, fi as Os, fj as fc, fk as gc, fl as xc, fm as Fs, fn as bc, fo as vc, fp as yc, fq as Nc, fr as Cc, fs as Qt, ft as di, c2 as tr, cH as wc, c5 as Sc, fu as ui, fv as mn, fw as $n, fx as Tc, fy as $a, fz as qe, fA as ze, fB as _e, fC as kc, fD as Ic, fE as Dc, fF as Ac, fG as Ut, fH as Dn, fI as nl, fJ as Ec, dq as mi, S as Ge, fK as Mc, fL as Oc, fM as Fc, fN as Rc, fO as Lc, fP as Pc, m as qa, n as za, o as _a, p as ja, q as Ka, r as Ga, fQ as Vc, fR as Bc, fS as sl, fT as $c, s as pa, fU as qc, fV as ms, fW as rl, fX as zc, fY as Tt, fZ as _c, f_ as jc, f$ as Kc, g0 as Gc, g1 as vn, g2 as Uc, g3 as hs, g4 as hi, g5 as Hc, g6 as Jc, g7 as Qc, g8 as qn, g9 as Yc, ga as Wc, gb as ar, gc as nr, gd as pi, ge as Xc, ct as fi, gf as gi, gg as Qn, dt as Zc, gh as et, bc as ed, gi as td, gj as ad, b8 as ll, gk as il, gl as nd, gm as sd, gn as rd, go as ld, gp as id, gq as od, gr as cd, gs as dd, gt as ud, gu as md, gv as hd, gw as pd, gx as fd, gy as gd, gz as xi, gA as xd, gB as bd, gC as vd, gD as yd, gE as Nd, gF as Cd, gG as wd, gH as Sd, gI as Td, gJ as kd, gK as Id, gL as Dd, gM as Ad, gN as bi, gO as Ed, gP as Yn, gQ as vi, gR as yi, gS as Md, gT as Od, gU as Wn, gV as ps, gW as Fd, gX as Rd, gY as Ld, gZ as Pd, g_ as Vd, g$ as ol, h0 as da, h1 as Bd, h2 as Ni, aW as $d, h3 as cl, cy as dl, h4 as qd, h5 as zd, h6 as _d, h7 as Fn, h8 as jd, h9 as sr, ha as Rn, hb as Kd, hc as Gd, hd as zn, he as Ud, C as Hd, hf as Jd, hg as Qd, hh as Yd, hi as hn, hj as Ht, hk as Rs, hl as Ls, hm as pn, hn as Ci, aU as Wd, ho as Xd, hp as fs, hq as Zd, hr as gs, hs as eu, ht as ul, hu as ml, hv as tu, hw as au, hx as nu, hy as su, hz as ru, hA as lu, hB as iu, hC as Xn, cb as Zn, hD as hl, hE as wi, df as xs, hF as ou, hG as cu, hH as du, W as uu } from "./index-CB2vXsPg.js";
2
+ import { bK as Le, du as oo, x as xt, M as ge, U as M, dv as fn, dw as co, L as V, y as te, z as ae, A as ne, E as se, F as _, bU as Qe, B as H, b$ as kt, dx as _n, dy as ql, dz as zl, dA as _l, dB as jl, dC as jn, a3 as Ft, X as at, dD as zs, c9 as _s, e as Ma, f as Oa, g as Fa, h as Ra, i as un, bY as yt, bV as mt, bR as ht, bS as rt, bT as lt, dE as Zr, dF as Kl, u as Ve, v as Ds, dG as La, ce as Ua, c as Z, dc as vt, dH as Gl, b_ as Ul, dI as uo, dJ as mo, dK as ho, dL as on, dM as po, dN as Hl, dO as fo, cL as Jl, dP as go, dQ as Ql, dR as xo, dS as js, dT as bo, dU as jt, dV as cn, c0 as Ha, c1 as Ja, dW as As, c3 as Qa, c4 as ut, dX as Pa, dY as vo, dZ as Es, d_ as Mn, b as ua, aa as Yl, d$ as dn, e0 as Ks, e1 as yo, e2 as No, e3 as Wl, e4 as Xl, e5 as Zl, c$ as Gs, I as Ye, P as It, e6 as Co, l as Dt, e7 as wo, w as ra, e8 as So, e9 as To, H as ko, ea as Io, bL as Ya, bM as ma, bN as ha, bO as gn, bP as qt, bQ as Aa, eb as Ms, ec as la, ed as bt, ee as ia, ef as Do, eg as Pn, eh as Vn, ei as Bn, ej as Us, dp as Va, ek as xn, el as Ao, R as bn, em as Kn, en as Wa, cf as Hs, eo as ei, j as Wt, cG as Eo, ep as Vt, eq as zt, er as Mo, es as _t, cq as Js, cD as Qs, N as ti, et as Ys, eu as Oo, ev as ai, ew as ni, ex as $t, dk as us, ey as Fo, ez as Ro, eA as Lo, eB as si, ar as ri, eC as li, eD as Po, eE as Vo, eF as Bo, eG as Gn, eH as $o, eI as qo, eJ as el, eK as zo, V as Un, a1 as Ws, eL as _o, eM as Xs, cN as jo, eN as tl, a4 as dt, eO as Ko, d6 as Zs, d7 as er, d8 as sa, d9 as On, eP as Go, dl as Uo, eQ as ii, eR as Ho, eS as Jo, cw as Hn, cu as ct, eT as Qo, eU as Yo, eV as al, eW as Wo, k as Rt, cO as Jn, c8 as Pt, eX as Gt, eY as oa, eZ as ca, e_ as Xt, e$ as Ba, f0 as Xo, a_ as Zo, f1 as ec, f2 as tc, f3 as ac, f4 as nc, cC as Ea, f5 as sc, f6 as oi, f7 as rc, f8 as lc, f9 as ic, fa as oc, fb as ci, fc as cc, fd as dc, fe as uc, ff as mc, fg as hc, fh as pc, fi as Os, fj as fc, fk as gc, fl as xc, fm as Fs, fn as bc, fo as vc, fp as yc, fq as Nc, fr as Cc, fs as Qt, ft as di, c2 as tr, cH as wc, c5 as Sc, fu as ui, fv as mn, fw as $n, fx as Tc, fy as $a, fz as qe, fA as ze, fB as _e, fC as kc, fD as Ic, fE as Dc, fF as Ac, fG as Ut, fH as Dn, fI as nl, fJ as Ec, dq as mi, S as Ge, fK as Mc, fL as Oc, fM as Fc, fN as Rc, fO as Lc, fP as Pc, m as qa, n as za, o as _a, p as ja, q as Ka, r as Ga, fQ as Vc, fR as Bc, fS as sl, fT as $c, s as pa, fU as qc, fV as ms, fW as rl, fX as zc, fY as Tt, fZ as _c, f_ as jc, f$ as Kc, g0 as Gc, g1 as vn, g2 as Uc, g3 as hs, g4 as hi, g5 as Hc, g6 as Jc, g7 as Qc, g8 as qn, g9 as Yc, ga as Wc, gb as ar, gc as nr, gd as pi, ge as Xc, ct as fi, gf as gi, gg as Qn, dt as Zc, gh as et, bc as ed, gi as td, gj as ad, b8 as ll, gk as il, gl as nd, gm as sd, gn as rd, go as ld, gp as id, gq as od, gr as cd, gs as dd, gt as ud, gu as md, gv as hd, gw as pd, gx as fd, gy as gd, gz as xi, gA as xd, gB as bd, gC as vd, gD as yd, gE as Nd, gF as Cd, gG as wd, gH as Sd, gI as Td, gJ as kd, gK as Id, gL as Dd, gM as Ad, gN as bi, gO as Ed, gP as Yn, gQ as vi, gR as yi, gS as Md, gT as Od, gU as Wn, gV as ps, gW as Fd, gX as Rd, gY as Ld, gZ as Pd, g_ as Vd, g$ as ol, h0 as da, h1 as Bd, h2 as Ni, aW as $d, h3 as cl, cy as dl, h4 as qd, h5 as zd, h6 as _d, h7 as Fn, h8 as jd, h9 as sr, ha as Rn, hb as Kd, hc as Gd, hd as zn, he as Ud, C as Hd, hf as Jd, hg as Qd, hh as Yd, hi as hn, hj as Ht, hk as Rs, hl as Ls, hm as pn, hn as Ci, aU as Wd, ho as Xd, hp as fs, hq as Zd, hr as gs, hs as eu, ht as ul, hu as ml, hv as tu, hw as au, hx as nu, hy as su, hz as ru, hA as lu, hB as iu, hC as Xn, cb as Zn, hD as hl, hE as wi, df as xs, hF as ou, hG as cu, hH as du, W as uu } from "./index-CFyPug8b.js";
3
3
  import * as Ps from "react";
4
4
  import Vs, { useState as K, useRef as Re, useEffect as we, useCallback as Ie, useMemo as ce, useContext as rr, Suspense as mu } from "react";
5
- import { C as pl, e as lr, u as pt, V as hu } from "./editor-action-buttons-vCojlAQ-.js";
5
+ import { C as pl, e as lr, u as pt, V as hu } from "./editor-action-buttons-D2GgF45c.js";
6
6
  import { createPortal as pu } from "react-dom";
7
7
  /**
8
8
  * @license lucide-react v0.453.0 - ISC
@@ -2372,16 +2372,22 @@ function Oi({
2372
2372
  ] })
2373
2373
  ] })
2374
2374
  ] }) }),
2375
- /* @__PURE__ */ e("div", { className: "min-h-0 flex-1 overflow-auto text-xs leading-relaxed text-foreground/80", children: /* @__PURE__ */ e("div", { className: "flex flex-col space-y-1.5", children: /* @__PURE__ */ a("div", { className: "group relative", children: [
2376
- /* @__PURE__ */ e("div", { className: "absolute right-2 top-2 z-10 rounded-md border border-border/60 bg-background/85 p-0.5 shadow-sm backdrop-blur-sm transition-opacity duration-150", children: /* @__PURE__ */ e(
2377
- cn,
2378
- {
2379
- text: t,
2380
- className: "h-6 w-6 px-0 text-muted-foreground/80 hover:text-foreground"
2381
- }
2382
- ) }),
2383
- /* @__PURE__ */ e(Pa, { code: t, language: "sql", wrapLongLines: !0 })
2384
- ] }) }) })
2375
+ /* @__PURE__ */ e("div", { className: "min-h-0 flex-1 overflow-auto", children: /* @__PURE__ */ a("div", { className: "overflow-hidden rounded-xl border border-border/60 bg-gradient-to-b from-background to-muted/[0.18] shadow-sm", children: [
2376
+ /* @__PURE__ */ a("div", { className: "flex items-center justify-between border-b border-border/50 bg-background/80 px-3 py-2", children: [
2377
+ /* @__PURE__ */ a("div", { className: "flex items-center gap-2", children: [
2378
+ /* @__PURE__ */ e("span", { className: "rounded-md border border-border/60 bg-muted/60 px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-[0.12em] text-muted-foreground", children: "SQL" }),
2379
+ /* @__PURE__ */ e("span", { className: "text-xs font-medium text-muted-foreground", children: "Generated query" })
2380
+ ] }),
2381
+ /* @__PURE__ */ e("div", { className: "rounded-md border border-border/60 bg-background/85 p-0.5 shadow-sm backdrop-blur-sm", children: /* @__PURE__ */ e(
2382
+ cn,
2383
+ {
2384
+ text: t,
2385
+ className: "h-6 w-6 px-0 text-muted-foreground/80 hover:text-foreground"
2386
+ }
2387
+ ) })
2388
+ ] }),
2389
+ /* @__PURE__ */ e("div", { className: "group relative overflow-auto px-1 py-1 text-xs leading-relaxed text-foreground/80", children: /* @__PURE__ */ e(Pa, { code: t, language: "sql", wrapLongLines: !0 }) })
2390
+ ] }) })
2385
2391
  ] });
2386
2392
  }
2387
2393
  function Qu(t) {
@@ -1,6 +1,6 @@
1
- import { bK as T, U as i, bL as B, bM as te, bN as se, bO as re, bP as le, bQ as oe, u as V, a9 as ne, bR as ie, bS as de, bT as ue, bU as ce, c as S, bV as pe, bW as me, M as x, B as I, s as ye, H as D, N as U, J as K, bX as j, w as O, bY as H, X, x as C } from "./index-CB2vXsPg.js";
1
+ import { bK as T, U as i, bL as B, bM as te, bN as se, bO as re, bP as le, bQ as oe, u as V, a9 as ne, bR as ie, bS as de, bT as ue, bU as ce, c as S, bV as pe, bW as me, M as x, B as I, s as ye, H as D, N as U, J as K, bX as j, w as O, bY as H, X, x as C } from "./index-CFyPug8b.js";
2
2
  import { jsx as y, jsxs as f, Fragment as q } from "react/jsx-runtime";
3
- import { u as be, a as M } from "./use-visual-utils-BKWme54p.js";
3
+ import { u as be, a as M } from "./use-visual-utils-Cdc_8imE.js";
4
4
  import { useMemo as k, useState as G } from "react";
5
5
  /**
6
6
  * @license lucide-react v0.453.0 - ISC
@@ -1,4 +1,4 @@
1
- "use strict";const e=require("./index-iF4085Zd.js"),a=require("react/jsx-runtime"),k=require("./use-visual-utils-BzlMPpHV.js"),v=require("react");/**
1
+ "use strict";const e=require("./index-DGpLwb-T.js"),a=require("react/jsx-runtime"),k=require("./use-visual-utils-B6nZIeae.js"),v=require("react");/**
2
2
  * @license lucide-react v0.453.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.