react-semaphor 0.0.228 → 0.0.230

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.
@@ -1,4 +1,4 @@
1
- "use strict";const e=require("./index-5I0YebI6.js"),b=require("react");/**
1
+ "use strict";const e=require("./index-8_ihvapU.js"),b=require("react");/**
2
2
  * @license lucide-react v0.379.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -212,4 +212,4 @@ SELECT label, measure FROM table
212
212
  Table Columns: ${E==null?void 0:E.map(y=>`${y.column_name} | ${y.data_type}`).join(", ")}
213
213
  User SQL: ${k}
214
214
  ${f&&`Base Queries: ${JSON.stringify(f)} `}`,T=` When the user asks for a specific chart please use the following query structure to generate the chart query. Do not make up the column names. Use only the table columns provided above for the query. Replace x-axis, y-axis, and lables with the appropriate column names.
215
- Visual Query Syntax: ${Qt}`,{data:z,isLoading:A,isFetching:S,isError:C,refetch:L}=e.useQuery({queryKey:["ai-query"],queryFn:()=>e.getRequest("https://semaphor.cloud/api/v1/ai",(l==null?void 0:l.accessToken)||"",{user_content:`userContent: ${D} ${h?T:""}`}),enabled:!1});function O(y){if(y.toLowerCase().includes("bar"))m("bar");else if(y.toLowerCase().includes("line"))m("line");else if(y.toLowerCase().includes("bubble"))m("bubble");else if(y.toLowerCase().includes("scatter"))m("scatter");else if(y.toLowerCase().includes("stacked"))m("stackedBar");else if(y.toLowerCase().includes("pie"))m("pie");else if(y.toLowerCase().includes("donut")||y.toLowerCase().includes("doughnut"))m("doughnut");else if(y.toLowerCase().includes("radar"))m("radar");else return m("bar"),!1;return!0}b.useEffect(()=>{z&&v(y=>[...y,{role:"ai",content:z.response}])},[z]),b.useEffect(()=>{const y=setTimeout(()=>{var R;c.current&&(c.current.scroll({top:c.current.scrollHeight,behavior:"smooth"}),(R=d.current)==null||R.focus())},100);return()=>clearTimeout(y)},[x]);function w(){s&&(v(y=>[...y,{role:"user",content:s}]),O(s)&&p(!0),r(""),L())}b.useEffect(()=>{o&&(w(),u(!1))},[o,u]);const F={fontFamily:"Arial, sans-serif",lineHeight:1.6,fontSize:15,width:"100%"},_={fontFamily:"monospace",fontSize:14,lineHeight:1.6},B={fontFamily:"Arial, sans-serif",lineHeight:1.6,fontSize:15,padding:"2px 0",marginLeft:20,listStyleType:"disc"},G={p:({node:y,...R})=>e.jsxRuntimeExports.jsx("p",{style:F,...R}),code:({node:y,...R})=>e.jsxRuntimeExports.jsx("code",{className:"rounded-sm bg-muted px-2 py-1 text-sm",...R}),pre:({node:y,...R})=>e.jsxRuntimeExports.jsxs("pre",{className:"space-y-2 rounded-sm bg-muted/50 p-3",style:_,children:[e.jsxRuntimeExports.jsx("code",{className:"whitespace-normal text-sm",children:R.children}),e.jsxRuntimeExports.jsxs("div",{className:"flex justify-start gap-2",children:[e.jsxRuntimeExports.jsx(e.Button,{onClick:q,size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(e.ClipboardCopyIcon,{})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:N=>{const M=q(N);M&&(n(!1),j(M),a(!0))},size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(e.PlayIcon,{})})]})]}),li:({node:y,...R})=>e.jsxRuntimeExports.jsx("li",{style:B,...R})};function q(y){const R=y.currentTarget.closest("pre");if(!R)return;const N=R.textContent||R.innerText;return navigator.clipboard.writeText(N).then(()=>console.log("Text copied to clipboard")).catch(M=>console.error("Error in copying text: ",M)),N}function Q(){return x==null?void 0:x.map((y,R)=>y.role==="user"?e.jsxRuntimeExports.jsxs("div",{className:"flex items-start rounded-md bg-muted p-3 text-sm",children:[e.jsxRuntimeExports.jsx(Ft,{className:"mr-2 h-5 w-5"}),e.jsxRuntimeExports.jsx("div",{children:y.content})]},R):y.role==="ai"?e.jsxRuntimeExports.jsx(e.Markdown,{className:"w-full overflow-auto py-1",components:G,children:z==null?void 0:z.response.replace(/DuckDB/gi,"Semaphor")},R):e.jsxRuntimeExports.jsx("div",{},R))}return e.jsxRuntimeExports.jsxs(e.Dialog,{open:t,onOpenChange:n,children:[e.jsxRuntimeExports.jsx(e.DialogTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.Button,{size:"sm",className:"w-full justify-start border font-normal text-muted-foreground focus-visible:ring-0 focus-visible:ring-offset-0",variant:"secondary",children:"Type your question here..."})}),e.jsxRuntimeExports.jsxs(e.DialogContent,{className:"flex flex-col justify-between overflow-auto sm:max-w-[425px] md:max-h-[625px] md:min-w-[625px]",children:[e.jsxRuntimeExports.jsxs(e.DialogHeader,{children:[e.jsxRuntimeExports.jsx(e.DialogTitle,{children:"Assistant"}),e.jsxRuntimeExports.jsx(e.DialogDescription,{children:"What can I help you with?"})]}),e.jsxRuntimeExports.jsx("div",{ref:c,className:"h-[625px] w-full overflow-auto border-t border-t-muted",children:e.jsxRuntimeExports.jsx("div",{className:"space-y-4 py-2 pr-3",role:"messages",children:Q()})}),e.jsxRuntimeExports.jsx("div",{children:e.jsxRuntimeExports.jsxs("div",{className:"flex w-full items-center rounded-md border",children:[e.jsxRuntimeExports.jsx(e.Textarea,{autoFocus:!0,ref:d,onKeyDown:y=>{y.key==="Enter"&&!y.shiftKey&&(y.preventDefault(),r(""),w())},placeholder:"Type your question here...",onFocus:y=>{const R=y.target,N=R.value.length;R.setSelectionRange(N,N)},className:e.cn("max-h-10 min-h-7 resize-none border-none focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0"),disabled:A||S,value:s,onChange:y=>r(y.target.value)})," ",e.jsxRuntimeExports.jsx(e.Button,{className:"h-8",size:"sm",variant:"ghost",onClick:w,children:!A&&!S?e.jsxRuntimeExports.jsx(e.PaperPlaneIcon,{}):e.jsxRuntimeExports.jsx(de,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"})})]})})]})]})}var We={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Be=b.createContext&&b.createContext(We),Ut=["attr","size","title"];function Wt(t,n){if(t==null)return{};var s=Yt(t,n),r,o;if(Object.getOwnPropertySymbols){var u=Object.getOwnPropertySymbols(t);for(o=0;o<u.length;o++)r=u[o],!(n.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(t,r)&&(s[r]=t[r])}return s}function Yt(t,n){if(t==null)return{};var s={},r=Object.keys(t),o,u;for(u=0;u<r.length;u++)o=r[u],!(n.indexOf(o)>=0)&&(s[o]=t[o]);return s}function ve(){return ve=Object.assign?Object.assign.bind():function(t){for(var n=1;n<arguments.length;n++){var s=arguments[n];for(var r in s)Object.prototype.hasOwnProperty.call(s,r)&&(t[r]=s[r])}return t},ve.apply(this,arguments)}function Ve(t,n){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),s.push.apply(s,r)}return s}function Ce(t){for(var n=1;n<arguments.length;n++){var s=arguments[n]!=null?arguments[n]:{};n%2?Ve(Object(s),!0).forEach(function(r){Xt(t,r,s[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):Ve(Object(s)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(s,r))})}return t}function Xt(t,n,s){return n=Zt(n),n in t?Object.defineProperty(t,n,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[n]=s,t}function Zt(t){var n=es(t,"string");return typeof n=="symbol"?n:String(n)}function es(t,n){if(typeof t!="object"||t===null)return t;var s=t[Symbol.toPrimitive];if(s!==void 0){var r=s.call(t,n||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(n==="string"?String:Number)(t)}function Ye(t){return t&&t.map((n,s)=>b.createElement(n.tag,Ce({key:s},n.attr),Ye(n.child)))}function ee(t){return n=>b.createElement(ts,ve({attr:Ce({},t.attr)},n),Ye(t.child))}function ts(t){var n=s=>{var{attr:r,size:o,title:u}=t,d=Wt(t,Ut),c=o||s.size||"1em",l;return s.className&&(l=s.className),t.className&&(l=(l?l+" ":"")+t.className),b.createElement("svg",ve({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},s.attr,r,d,{className:l,style:Ce(Ce({color:t.color||s.color},s.style),t.style),height:c,width:c,xmlns:"http://www.w3.org/2000/svg"}),u&&b.createElement("title",null,u),t.children)};return Be!==void 0?b.createElement(Be.Consumer,null,s=>n(s)):n(We)}function ss(t){return ee({tag:"svg",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:[]}]})(t)}function ns(){const{theme:t}=e.useTheme(),n=b.useRef(),s=b.useRef(),[r,o]=b.useState(!1),[u,d]=b.useState(!1),[c,l]=b.useState(!1),[h,p]=b.useState(""),[j,f]=b.useState(!1),{authToken:a}=e.useSemaphorContext();e.useDashboardStore(i=>i.selectedSheetId);const m=e.useDashboardStore(i=>i.dashboard.baseQueries),x=e.useEditorStore(i=>i.card),v=e.useDashboardStore(i=>i.theme),E=e.useEditorStore(i=>i.isShowingVisual),k=e.useEditorStore(i=>i.selectedConnectionId),g=e.useEditorStore(i=>i.selectedDatabaseName),D=e.useEditorStore(i=>i.selectedDatamodelId),T=e.useEditorStore(i=>i.selectedSchemaName);e.useDashboardStore(i=>i.actions.updateFrameCard);const z=e.useEditorStore(i=>i.selectedTableName),A=e.useEditorStore(i=>i.card.sql),S=e.useEditorStore(i=>i.card.python),C=e.resolveBaseQuery(A,m),L=e.useEditorStore(i=>i.selectedConnectionId),O=e.useEditorStore(i=>i.frame),w=e.useEditorStore(i=>i.filterValues),F=e.useEditorStore(i=>i.applyFilters),{setCardCustomCfg:_,setQueryResultColumns:B,setFilterValues:G,setCardSql:q,setCardPython:Q,setQueryError:y,setPythonStdOut:R,setCardPreferences:N}=e.useEditorStore(i=>i.actions),M=e.useEditorStore(i=>i.onSave),te=e.useEditorStore(i=>i.actions.setApplyFilters),K=e.useEditorStore(i=>i.onClose),I=e.useEditorStore(i=>i.actions.setCardData),H=e.useEditorStore(i=>i.actions.setSqlGen),$=e.useEditorStore(i=>i.runSql),re=e.useEditorStore(i=>i.actions.setRunSql),se=e.useEditorStore(i=>i.actions.setIsSqlRunning),{data:V,isLoading:J,isFetching:U,isSuccess:oe,isError:ae,error:pe,status:Oe,refetch:le}=e.useQuery({queryKey:[C,S],queryFn:()=>e.postRequest("https://semaphor.cloud/api/v1/query",(a==null?void 0:a.accessToken)||"",{connection_id:L,sql:C,python:S===e.PYTHON_DEFAULT_CODE?"":S,active_filters:F?w:[]}),enabled:!1,retry:!1});b.useEffect(()=>{if(V&&(I(V.records),V.rowLimitExceeded&&e.Jt.error("Row limit (10,000) exceeded. Refine your query.",{position:"top-center",richColors:!0}),R((V==null?void 0:V.output)||""),V.records.length>0)){const{dimensionKeys:i}=e.getKeys(V.records);B(i)}},[V,I,B,R]),b.useEffect(()=>{$&&(le(),re(!1))},[$,le,re]),b.useEffect(()=>{(J||U)&&se(!0),(ae||oe)&&se(!1),ae?(y(pe.message),I([]),B([]),R("")):y("")},[J,U,V,R,ae,oe,se,I,B,y,pe]);function ke(){q(""),I([]),H({}),_(""),N({})}const fe=i=>{s.current=i};function we(){let i=A;A&&!A.includes("{{")&&(i=Ht(A),q(i));const W={...x,lastSelectedSchema:T,lastSelectedDatamodelId:D,lastSelectedDatabase:g,lastSelectedTable:z,connectionId:k,type:E?x.type:"table",sql:i,customCfg:E?x.customCfg:null},je=O.cards.map(ie=>ie.id===x.id?W:ie);M==null||M({...O,cards:je})}function Ae(){K==null||K()}function ge(i){const W=getComputedStyle(document.documentElement).getPropertyValue(i);return Re(W)}function Re(i){const[W,je,ie]=i.split(" "),P=parseFloat(W),ct=parseFloat(je),xt=parseFloat(ie),ut=ct/100,qe=xt/100,ne=(1-Math.abs(2*qe-1))*ut,ce=ne*(1-Math.abs(P/60%2-1)),De=qe-ne/2;let Y=0,X=0,Z=0;0<=P&&P<60?(Y=ne,X=ce,Z=0):60<=P&&P<120?(Y=ce,X=ne,Z=0):120<=P&&P<180?(Y=0,X=ne,Z=ce):180<=P&&P<240?(Y=0,X=ce,Z=ne):240<=P&&P<300?(Y=ce,X=0,Z=ne):300<=P&&P<360&&(Y=ne,X=0,Z=ce),Y=Math.round((Y+De)*255),X=Math.round((X+De)*255),Z=Math.round((Z+De)*255);const Te=dt=>{const Ie=dt.toString(16);return Ie.length==1?"0"+Ie:Ie};return`#${Te(Y)}${Te(X)}${Te(Z)}`}b.useEffect(()=>{const i=n.current,W=s.current;if(i){const je=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",ie=v==="system"?je:v;i.editor.defineTheme("default",{base:ie==="light"?"vs":"vs-dark",inherit:!0,rules:[],colors:{"editor.background":ie==="light"?"#ffffff":ge("--semaphor-background")}}),i.editor.setTheme("default")}return W&&i&&W.addCommand(i.KeyMod.Shift|i.KeyCode.Enter,function(){return console.log("Executing query..."),le(),!1}),()=>{}},[t,v,n.current]);function he(i){n.current=i}function be(){return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[u&&e.jsxRuntimeExports.jsx("div",{className:"xbg-yellow-100 relative flex w-1/3 min-w-0 grow overflow-hidden border-l p-1 text-xs",role:"editor-filter-container",children:e.jsxRuntimeExports.jsxs("div",{className:"w-[99%]",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2 pt-3",children:[e.jsxRuntimeExports.jsx($t,{checked:F,onCheckedChange:()=>te(!F),text:"Apply Filters"}),e.jsxRuntimeExports.jsx(Gt,{}),w&&u&&e.jsxRuntimeExports.jsx(e.Cross2Icon,{onClick:()=>d(!1),className:"bg-background/50 text-foreground/50 hover:cursor-pointer hover:text-foreground"})]}),e.jsxRuntimeExports.jsx(e.Ft,{theme:"default",onChange:i=>{if(i)try{JSON.parse(i),G(JSON.parse(i))}catch{}},defaultLanguage:"json",className:"mt-1 min-h-[220px]",value:JSON.stringify(w,null,2),options:{readOnly:!0,minimap:{enabled:!1},lineNumbers:"off",glyphMargin:!1,wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:12,renderLineHighlight:"none"}})]})}),w&&!u&&e.jsxRuntimeExports.jsx(Pe,{onClick:()=>d(!0),className:e.cn("absolute bottom-4 right-6 h-3 w-3 text-foreground/50 hover:cursor-pointer hover:text-foreground",{"font-bold text-red-800":F})})]})}function Se(){return e.jsxRuntimeExports.jsxs(e.ResizablePanelGroup,{className:"flex grow pb-1",direction:"vertical",role:"editor-resizable-group",children:[e.jsxRuntimeExports.jsxs(e.ResizablePanel,{id:"1",order:1,defaultSize:r?20:100,className:"relative flex grow",children:[e.jsxRuntimeExports.jsx("div",{role:"sql-container",className:"relative flex w-[99%]",children:e.jsxRuntimeExports.jsx(e.Ft,{theme:"default",className:"pt-3",onChange:i=>{q(i)},value:A,options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"sql",beforeMount:he,onMount:fe})}),r&&e.jsxRuntimeExports.jsx("code",{className:"absolute right-6 top-3 text-sm text-muted-foreground/70",children:"sql"})]}),r&&e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(e.ResizableHandle,{withHandle:!0,className:"border"}),e.jsxRuntimeExports.jsxs(e.ResizablePanel,{id:"2",order:2,defaultSize:80,className:"relative flex grow",children:[e.jsxRuntimeExports.jsx("div",{role:"python-container",className:"relative flex w-[99%] pt-0",children:e.jsxRuntimeExports.jsx(e.Ft,{className:"pt-3",theme:"default",onChange:i=>{Q(i&&i.trim()||"")},value:S||e.PYTHON_DEFAULT_CODE,options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"python",beforeMount:he,onMount:fe})}),e.jsxRuntimeExports.jsx("code",{className:"absolute right-6 top-3 text-sm text-muted-foreground/70",children:"python"})]})]})]})}return e.jsxRuntimeExports.jsxs("section",{role:"editor-section",className:"flex grow flex-col justify-end",children:[e.jsxRuntimeExports.jsxs("div",{role:"sql-editor",className:"relative flex grow justify-between overflow-y-scroll",children:[Se(),be()]}),e.jsxRuntimeExports.jsxs("div",{role:"editor-controls",className:"item-center flex flex-wrap justify-between gap-2 px-6 py-4",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex grow items-center gap-2",children:[e.jsxRuntimeExports.jsxs(e.Button,{title:"Shift + Enter",disabled:J||U,onClick:()=>{le()},className:"shrink-0",size:"sm",variant:"outline",children:[J||U?e.jsxRuntimeExports.jsx(de,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"}):e.jsxRuntimeExports.jsx(kt,{className:"mr-2 h-4 w-4"}),"Run"]}),ae&&e.jsxRuntimeExports.jsx(Pt,{error:pe.message,setShowAIDialog:l,setTriggerAIRun:f,setUserInputforAI:p}),e.jsxRuntimeExports.jsxs(e.Button,{onClick:ke,className:"",size:"sm",variant:"outline",children:[e.jsxRuntimeExports.jsx(Et,{className:"mr-2 size-4"}),"Clear"]}),e.jsxRuntimeExports.jsx(e.Toggle,{pressed:r,onPressedChange:i=>o(i),className:"",size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(ss,{className:"size-4 text-foreground/70"})}),e.jsxRuntimeExports.jsx(Jt,{open:c,setOpen:l,userInput:h,triggerAIRun:j,setTriggerAIRun:f,setUserInput:i=>p(i)})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-end gap-2",children:[e.jsxRuntimeExports.jsxs(e.Button,{onClick:we,size:"sm",variant:"outline",children:[e.jsxRuntimeExports.jsx(e.Check,{className:"mr-2 size-4 font-bold text-green-600"}),"Accept"]}),e.jsxRuntimeExports.jsxs(e.Button,{onClick:Ae,className:"w-full",size:"sm",variant:"outline",children:[e.jsxRuntimeExports.jsx(e.Cross2Icon,{className:"mr-2 size-4"}),"Close"]})]})]})]})}function rs({data:t}){var d;const[n,s]=b.useState([]),o=Object.keys(t[0]).map(c=>({accessorKey:c,header:({column:l})=>{const h=l.getIsSorted();return e.jsxRuntimeExports.jsx("div",{className:"flex gap-2",children:e.jsxRuntimeExports.jsxs("div",{className:"flex cursor-pointer items-center",onClick:()=>l.toggleSorting(l.getIsSorted()==="asc"),children:[c,h==="asc"?e.jsxRuntimeExports.jsx(e.TriangleUpIcon,{className:"ml-2 h-5 w-5"}):h==="desc"?e.jsxRuntimeExports.jsx(e.TriangleDownIcon,{className:"ml-2 h-5 w-5"}):null]})})}})),u=e.useReactTable({data:t,columns:o,getCoreRowModel:e.getCoreRowModel(),getPaginationRowModel:e.getPaginationRowModel(),onSortingChange:s,getSortedRowModel:e.getSortedRowModel(),manualPagination:!0,state:{sorting:n}});return e.jsxRuntimeExports.jsxs(e.Table$1,{children:[e.jsxRuntimeExports.jsx(e.TableHeader,{children:u.getHeaderGroups().map(c=>e.jsxRuntimeExports.jsx(e.TableRow,{children:c.headers.map(l=>e.jsxRuntimeExports.jsx(e.TableHead,{className:"sticky top-0 bg-muted",children:l.isPlaceholder?null:e.flexRender(l.column.columnDef.header,l.getContext())},l.id))},c.id))}),e.jsxRuntimeExports.jsx(e.TableBody,{children:(d=u.getRowModel().rows)!=null&&d.length?u.getRowModel().rows.map(c=>e.jsxRuntimeExports.jsx(e.TableRow,{className:"whitespace-nowrap py-2","data-state":c.getIsSelected()&&"selected",children:c.getVisibleCells().map(l=>e.jsxRuntimeExports.jsx(e.TableCell,{children:e.flexRender(l.column.columnDef.cell,l.getContext())},l.id))},c.id)):e.jsxRuntimeExports.jsx(e.TableRow,{children:e.jsxRuntimeExports.jsx(e.TableCell,{colSpan:o.length,className:"h-24 text-center",children:"No results."})})})]})}function Xe({showCard:t,className:n,...s}){var c;b.useState(0);const r=e.useDashboardStore(l=>l.themeStyle),o=e.useEditorStore(l=>l.card),u=e.useEditorStore(l=>l.actions.setCard);if(b.useEffect(()=>{},[o.data,o.type,o.cfg,o.customCfg,r,o.preferences]),!o.id)return null;let d;return o.data&&o.data.length>0&&(d=e.createChartConfig({data:o.data,cardType:o.type,cfg:o.cfg,customCfg:o.customCfg,preferences:o.preferences})),e.jsxRuntimeExports.jsxs(e.Card,{role:"editor-visual-card",className:e.cn("relative flex h-full flex-col rounded-none",n),...s,children:[e.jsxRuntimeExports.jsxs(e.CardHeader,{className:"py-4",children:[e.jsxRuntimeExports.jsx(e.Editable,{text:o.title,onSave:l=>u({...o,title:l}),children:e.jsxRuntimeExports.jsx("div",{className:"flex items-center gap-2",children:e.jsxRuntimeExports.jsx(e.CardTitle,{className:"text-base",children:o.title})})},o.title),e.jsxRuntimeExports.jsx(e.Editable,{text:o.description||"",onSave:l=>u({...o,description:l}),children:e.jsxRuntimeExports.jsxs(e.CardDescription,{children:[" ",o.description]})},o.description)]}),e.jsxRuntimeExports.jsxs(e.CardContent,{className:"flex grow flex-col pb-3",children:[o.type!=="table"&&d&&e.jsxRuntimeExports.jsx(e.ChartJsVisual,{cfg:d},JSON.stringify(d)+JSON.stringify(o.preferences)+((c=o==null?void 0:o.preferences)==null?void 0:c.customVisualCode)),o.type==="table"&&o.data&&o.data.length>0&&e.jsxRuntimeExports.jsx(e.$57acba87d6e25586$export$ccf8d8d7bbf3c2cc,{className:"flex min-h-0 flex-1 grow basis-0",children:e.jsxRuntimeExports.jsx(e.TableVisual,{card:o,data:o==null?void 0:o.data})})]})]})}function os(){const[t,n]=b.useState(!1),[s,r]=b.useState(""),[o,u]=b.useState(""),[d,c]=b.useState(""),[l,h]=b.useState(""),p=e.useEditorStore(g=>g.card),j=e.useEditorStore(g=>g.card.customCfg),{setCardCustomCfg:f,setCustomVisualCode:a}=e.useEditorActions();function m(g){var z,A;const D={...g,data:{...g==null?void 0:g.data,datasets:(A=(z=g==null?void 0:g.data)==null?void 0:z.datasets)==null?void 0:A.map(S=>({...S,data:[]}))}};return JSON.stringify(D,null,1)}function x(){var D,T;if(!p.data||p.data.length===0)return;const g=e.createChartConfig({data:p.data,cardType:p.type,cfg:p.cfg,preferences:p.preferences});g&&(r(JSON.stringify(g,null,1)),(D=p==null?void 0:p.preferences)!=null&&D.customVisualCode&&c((T=p==null?void 0:p.preferences)==null?void 0:T.customVisualCode),j&&u(JSON.stringify(j,null,1)))}function v(){if(d&&a(d),!!o)try{const g=JSON.parse(o);return g?(f(g),h(""),u(""),g):void 0}catch(g){console.log(g),h("Invalid JSON")}}function E(){u(""),f(null)}function k(){let g;if(j){const D=e._.cloneDeep(p.cfg),T=e._.merge(D,j);return g=m(T),g}return s?(g=m(JSON.parse(s)),g):""}return e.jsxRuntimeExports.jsxs(e.Dialog,{open:t,onOpenChange:n,children:[e.jsxRuntimeExports.jsx(e.DialogTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.Button,{onClick:x,className:` ${j&&"border-foreground/50 dark:border-foreground/70"}`,size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(e.Settings,{className:"h-4 w-4"})})}),e.jsxRuntimeExports.jsxs(e.DialogContent,{className:"max-h-[70vh] min-h-[70vh] overflow-auto sm:min-w-[900px] lg:min-w-[1200px]",children:[e.jsxRuntimeExports.jsxs(e.DialogHeader,{className:"",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.DialogTitle,{children:"Customize Card"}),e.jsxRuntimeExports.jsxs(e.Tooltip,{children:[e.jsxRuntimeExports.jsx(e.TooltipTrigger,{children:e.jsxRuntimeExports.jsx(bt,{onClick:()=>{navigator.clipboard.writeText(p.id)},className:"size-3 cursor-pointer text-muted-foreground/70 transition-colors hover:text-muted-foreground"})}),e.jsxRuntimeExports.jsx(e.TooltipContent,{side:"right",align:"center",children:e.jsxRuntimeExports.jsx("p",{className:"text-xs",children:"Copy Card ID"})})]})]}),e.jsxRuntimeExports.jsxs(e.DialogDescription,{children:["See the configuration options and documentation",e.jsxRuntimeExports.jsx("a",{target:"_blank",className:"ml-1 text-blue-500 underline",href:"https://www.chartjs.org/docs/latest/samples/bar/vertical.html",children:"here."})]})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex grow gap-2",children:[e.jsxRuntimeExports.jsx(Xe,{className:"w-1/2 rounded shadow-none"}),e.jsxRuntimeExports.jsxs(e.Tabs,{defaultValue:"custom-config",className:"flex w-1/2 flex-col",children:[e.jsxRuntimeExports.jsxs(e.TabsList,{className:"justify-start rounded-sm rounded-b-none border border-b-0",children:[e.jsxRuntimeExports.jsxs(e.TabsTrigger,{value:"custom-config",children:[j&&e.jsxRuntimeExports.jsx(e.CheckIcon,{className:"mr-1 h-5 w-5 text-green-600"}),j?"Custom Config":"Default Config"]}),e.jsxRuntimeExports.jsx(e.TabsTrigger,{className:"",value:"output",children:"Output"}),e.jsxRuntimeExports.jsx(e.TabsTrigger,{className:"",value:"custom-code",children:"Custom Code"})]}),e.jsxRuntimeExports.jsx(e.TabsContent,{className:"bg-red-x mt-0 grow rounded-b border border-t-0 p-2",value:"output",children:e.jsxRuntimeExports.jsx(e.Textarea,{disabled:!0,value:s,className:"h-full resize-none border-none font-mono focus-visible:ring-0 focus-visible:ring-offset-0"})}),e.jsxRuntimeExports.jsx(e.TabsContent,{className:"mt-0 grow rounded-b border border-t-0",value:"custom-config",children:e.jsxRuntimeExports.jsx(e.Ft,{className:"h-full w-full overflow-hidden",theme:"default",options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"json",value:k(),onChange:g=>u(g)})}),e.jsxRuntimeExports.jsx(e.TabsContent,{className:"mt-0 grow rounded-b border border-t-0",value:"custom-code",children:e.jsxRuntimeExports.jsx(e.Ft,{className:"h-full w-full overflow-hidden",theme:"default",options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"javascript",value:d,onChange:g=>c(g||"")})})]})]}),e.jsxRuntimeExports.jsxs(e.DialogFooter,{className:"flex items-center",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"mr-2 text-red-500",children:l}),e.jsxRuntimeExports.jsx(e.Button,{disabled:!j,onClick:E,variant:"outline",children:"Reset"}),e.jsxRuntimeExports.jsx(e.Button,{onClick:v,variant:"outline",children:"Apply"}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>n(!1),variant:"outline",children:"Close"})]})]})]})}function Ze(t){return ee({tag:"svg",attr:{viewBox:"0 0 1024 1024"},child:[{tag:"path",attr:{d:"M926.8 397.1l-396-288a31.81 31.81 0 0 0-37.6 0l-396 288a31.99 31.99 0 0 0-11.6 35.8l151.3 466a32 32 0 0 0 30.4 22.1h489.5c13.9 0 26.1-8.9 30.4-22.1l151.3-466c4.2-13.2-.5-27.6-11.7-35.8zM838.6 417l-98.5 32-200-144.7V199.9L838.6 417zM466 567.2l-89.1 122.3-55.2-169.2L466 567.2zm-116.3-96.8L484 373.3v140.8l-134.3-43.7zM512 599.2l93.9 128.9H418.1L512 599.2zm28.1-225.9l134.2 97.1L540.1 514V373.3zM558 567.2l144.3-46.9-55.2 169.2L558 567.2zm-74-367.3v104.4L283.9 449l-98.5-32L484 199.9zM169.3 470.8l86.5 28.1 80.4 246.4-53.8 73.9-113.1-348.4zM327.1 853l50.3-69h269.3l50.3 69H327.1zm414.5-33.8l-53.8-73.9 80.4-246.4 86.5-28.1-113.1 348.4z"},child:[]}]})(t)}function et(t){return ee({tag:"svg",attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M137.39,24.06A16,16,0,0,0,120,40V80.67a15.86,15.86,0,0,0,13.25,15.76A32,32,0,1,1,96,129.68c-.41-8.22,1.27-15,5-20.26h0a15.86,15.86,0,0,0-1.69-20.47L71.69,60.68a16,16,0,0,0-23.63,1.1A103.6,103.6,0,0,0,55,202.05,103.24,103.24,0,0,0,128,232h1.49A104.3,104.3,0,0,0,232,129.48C232.75,75.18,191.19,28.88,137.39,24.06ZM60.32,71.94l27.61,28.19,0,.06A43.29,43.29,0,0,0,80.44,120H40.36A87.13,87.13,0,0,1,60.32,71.94ZM40.37,136h40.3A48,48,0,0,0,120,175.34v40.3A88,88,0,0,1,40.37,136Zm149.77,54.14A87.45,87.45,0,0,1,136,215.61V175.34a47.55,47.55,0,0,0,24.73-12.23A48,48,0,0,0,136,80.66L136,40c45.52,4.08,80.67,43.28,80,89.25A87.45,87.45,0,0,1,190.14,190.14Z"},child:[]}]})(t)}function tt(t){return ee({tag:"svg",attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm87.63,96H191.48A64.1,64.1,0,0,0,136,64.52V40.37A88.13,88.13,0,0,1,215.63,120ZM120,120H80.68A48.09,48.09,0,0,1,120,80.68Zm0,16v39.32A48.09,48.09,0,0,1,80.68,136Zm16,0h39.32A48.09,48.09,0,0,1,136,175.32Zm0-16V80.68A48.09,48.09,0,0,1,175.32,120ZM120,40.37V64.52A64.1,64.1,0,0,0,64.52,120H40.37A88.13,88.13,0,0,1,120,40.37ZM40.37,136H64.52A64.1,64.1,0,0,0,120,191.48v24.15A88.13,88.13,0,0,1,40.37,136ZM136,215.63V191.48A64.1,64.1,0,0,0,191.48,136h24.15A88.13,88.13,0,0,1,136,215.63Z"},child:[]}]})(t)}function st(t){return ee({tag:"svg",attr:{viewBox:"0 0 24 24",strokeWidth:"2",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},child:[]},{tag:"path",attr:{d:"M6 16m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"},child:[]},{tag:"path",attr:{d:"M16 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"},child:[]},{tag:"path",attr:{d:"M14.5 7.5m-4.5 0a4.5 4.5 0 1 0 9 0a4.5 4.5 0 1 0 -9 0"},child:[]}]})(t)}function nt(t){return ee({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"m2 19.99 7.5-7.51 4 4 7.09-7.97L22 9.92l-8.5 9.56-4-4-6 6.01-1.5-1.5zm1.5-4.5 6-6.01 4 4L22 3.92l-1.41-1.41-7.09 7.97-4-4L2 13.99l1.5 1.5z"},child:[]}]})(t)}function rt(t){return ee({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M4 9h4v11H4zM4 4h4v4H4zM10 7h4v4h-4zM16 10h4v4h-4zM16 15h4v5h-4zM10 12h4v8h-4z"},child:[]}]})(t)}function ot(t){return ee({tag:"svg",attr:{version:"1.2",baseProfile:"tiny",viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M4 18c-.552 0-1-.448-1-1v-6.382l-.553.276c-.495.248-1.095.046-1.342-.447-.247-.494-.046-1.094.448-1.342l2-1c.31-.155.678-.139.973.044.294.183.474.504.474.851v8c0 .552-.448 1-1 1zM13 18h-5c-.404 0-.769-.244-.924-.617-.155-.374-.069-.804.217-1.09l4-4c.254-.254.394-.591.394-.95 0-.358-.14-.695-.394-.949-.508-.508-1.39-.508-1.9.001-.253.252-.393.589-.393.948 0 .552-.448 1-1 1s-1-.448-1-1c0-.894.348-1.733.98-2.364 1.265-1.263 3.464-1.263 4.727.001.632.631.979 1.471.979 2.363 0 .893-.348 1.733-.979 2.364l-2.293 2.293h2.586c.552 0 1 .448 1 1s-.448 1-1 1zM20.955 12.377c.338-.457.545-1.016.545-1.627 0-1.517-1.234-2.75-2.75-2.75-1.031 0-1.966.569-2.44 1.484-.254.49-.063 1.094.428 1.348.49.254 1.094.062 1.348-.428.128-.249.383-.404.664-.404.414 0 .75.336.75.75s-.336.75-.75.75c-.552 0-1 .448-1 1s.448 1 1 1c.689 0 1.25.561 1.25 1.25s-.561 1.25-1.25 1.25-1.25-.561-1.25-1.25c0-.552-.448-1-1-1s-1 .448-1 1c0 1.792 1.458 3.25 3.25 3.25s3.25-1.458 3.25-3.25c0-.939-.406-1.779-1.045-2.373z"},child:[]}]})(t)}function it(t){return ee({tag:"svg",attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M217 25v14h78V25h-78zm0 32v46h14V71h50v32h14V57h-78zm32 32v14h14V89h-14zm-64 32v46h30v-46h-30zm48 0v14h46v-14h-46zm64 0v46h30v-46h-30zm-64 32v14h46v-14h-46zm-80 32v46h62v-46h-62zm80 0v14h46v-14h-46zm64 0v46h62v-46h-62zm-64 32v14h46v-14h-46zm-112 32v46h94v-46h-94zm112 0v14h46v-14h-46zm64 0v46h94v-46h-94zm-64 32v14h46v-14h-46zM89 313v46h126v-46H89zm144 0v14h46v-14h-46zm64 0v46h126v-46H297zm-64 32v14h46v-14h-46zM57 377v46h158v-46H57zm176 0v14h46v-14h-46zm64 0v46h158v-46H297zm-64 32v14h46v-14h-46zM25 441v46h190v-46H25zm208 0v14h46v-14h-46zm64 0v46h190v-46H297zm-64 32v14h46v-14h-46z"},child:[]}]})(t)}function is(){const[t,n]=b.useState(!1),s=e.useEditorStore(l=>l.card.type),{setCardType:r,setCardPreferences:o,setChartOrientation:u}=e.useEditorStore(l=>l.actions),d=e.useEditorStore(l=>l.actions.setCardCustomCfg);function c(l){d(null),o({}),r(l),n(!1)}return e.jsxRuntimeExports.jsxs(e.Popover,{open:t,onOpenChange:n,children:[e.jsxRuntimeExports.jsx(e.PopoverTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.Button,{size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(as,{className:"h-4 w-4",chartType:s})})}),e.jsxRuntimeExports.jsx(e.PopoverContent,{className:"w-50",children:e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 place-items-center",children:[e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>c("bar"),className:"font-normal",variant:"ghost",children:e.jsxRuntimeExports.jsx(ze,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>c("line"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Le,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>c("stackedBar"),variant:"ghost",children:e.jsxRuntimeExports.jsx(rt,{className:"size-5",strokeWidth:0})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>c("stackedLine"),variant:"ghost",children:e.jsxRuntimeExports.jsx(nt,{className:"size-5",strokeWidth:0})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>c("scatter"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Qe,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>c("bubble"),variant:"ghost",children:e.jsxRuntimeExports.jsx(st,{className:"size-4"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>c("pie"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ge,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>c("doughnut"),variant:"ghost",children:e.jsxRuntimeExports.jsx(et,{className:"size-5",strokeWidth:1})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>c("radar"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ze,{className:"size-5 font-extralight",strokeWidth:.5})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>c("polarArea"),variant:"ghost",children:e.jsxRuntimeExports.jsx(tt,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>c("pyramid"),variant:"ghost",children:e.jsxRuntimeExports.jsx(it,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>c("range"),variant:"ghost",children:e.jsxRuntimeExports.jsx($e,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>c("table"),variant:"ghost",children:e.jsxRuntimeExports.jsx(e.Table,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>c("kpi"),variant:"ghost",children:e.jsxRuntimeExports.jsx(ot,{className:"size-6"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>c("text"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Fe,{className:"size-4"})})]})})]})}function as({chartType:t,className:n}){switch(t){case"bar":return e.jsxRuntimeExports.jsx(ze,{className:n});case"line":return e.jsxRuntimeExports.jsx(Le,{className:n});case"pie":return e.jsxRuntimeExports.jsx(Ge,{className:n});case"radar":return e.jsxRuntimeExports.jsx(Ze,{className:n});case"scatter":return e.jsxRuntimeExports.jsx(Qe,{className:n});case"bubble":return e.jsxRuntimeExports.jsx(st,{className:n});case"doughnut":return e.jsxRuntimeExports.jsx(et,{className:n});case"stackedBar":return e.jsxRuntimeExports.jsx(rt,{className:"size-4 text-foreground/70"});case"stackedLine":return e.jsxRuntimeExports.jsx(nt,{className:"size-4 text-foreground/70"});case"polarArea":return e.jsxRuntimeExports.jsx(tt,{className:n});case"pyramid":return e.jsxRuntimeExports.jsx(it,{className:n});case"range":return e.jsxRuntimeExports.jsx($e,{className:n});case"kpi":return e.jsxRuntimeExports.jsx(ot,{className:n});case"text":return e.jsxRuntimeExports.jsx(Fe,{className:n});default:return e.jsxRuntimeExports.jsx(e.Table,{className:n})}}function _e(){const t=e.useEditorStore(x=>x.frame),n=e.useEditorStore(x=>x.card),s=e.useEditorStore(x=>x.card.data),r=e.useEditorStore(x=>x.isShowingVisual),o=e.useEditorStore(x=>x.isSqlRunning),u=e.useEditorStore(x=>x.queryError),d=e.useEditorStore(x=>x.pythonStdOut),c=e.useEditorStore(x=>x.actions.setRunSql);e.useEditorStore(x=>x.onSave),e.useEditorStore(x=>x.onClose),e.useEditorStore(x=>x.actions.setCardSql),e.useEditorStore(x=>x.actions.setCardType),e.useEditorStore(x=>x.actions.setSqlGen);const{setFrame:l,setCard:h,updateCardInFrame:p}=e.useEditorActions();if(!n)return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:"No Active Card"});function j(){const x={id:e.v4(),title:"Title",description:"Description",preferences:{onClickFilter:[{columnIndex:0,expression:""}]},type:"bar",sql:"",data:[]},v={...t,cards:[...t.cards,x],activeCardId:x.id};l(v),h(x)}function f(x){const v=t.cards.filter(g=>g.id!==x),E=v[0],k={...t,cards:v,activeCardId:E.id};l(k),h(E)}function a(x){const v={...t,cards:t.cards.map(k=>k.id===n.id?n:k),activeCardId:x};l(v);const E=v.cards.find(k=>k.id===x);h(E),E.sql&&E.data&&E.data.length===0&&c(!0)}function m(){return n.type==="kpi"?e.jsxRuntimeExports.jsx("div",{className:"flex grow items-center justify-center",children:e.jsxRuntimeExports.jsx("div",{className:"w-1/2 rounded-md border",children:e.jsxRuntimeExports.jsx(e.KPICard,{isLoading:o,card:n})})}):n.type==="text"?e.jsxRuntimeExports.jsx("div",{className:"flex grow items-center justify-center",children:e.jsxRuntimeExports.jsx("div",{className:"w-1/2 rounded-md border",children:e.jsxRuntimeExports.jsx(e.TextCard,{isLoading:o,card:n})})}):e.jsxRuntimeExports.jsxs(e.Tabs,{onValueChange:a,value:t.activeCardId,className:"flex grow flex-col pb-3",children:[t.cards.map(x=>e.jsxRuntimeExports.jsx(e.TabsContent,{className:"mt-0 grow",value:x.id,children:e.jsxRuntimeExports.jsx(Xe,{showCard:x,className:"grow border-none shadow-none"})},x.id)),e.jsxRuntimeExports.jsxs(e.TabsList,{className:"mx-6 flex justify-start",children:[t.cards.map(x=>e.jsxRuntimeExports.jsx(e.Editable,{text:x.tabTitle||x.title,onSave:v=>{h({...x,tabTitle:v}),p({...x,tabTitle:v})},children:e.jsxRuntimeExports.jsxs(e.TabsTrigger,{className:"",value:x.id,children:[x.tabTitle||x.title,t.activeCardId===x.id&&t.cards.length>1&&e.jsxRuntimeExports.jsx(e.X,{className:"ml-2 size-3.5 text-muted-foreground hover:text-foreground",onClick:()=>f(x.id)})]})},x.id)),e.jsxRuntimeExports.jsx(e.Button,{className:"ml-1 h-8 px-2 hover:bg-muted-foreground/50",variant:"outline",onClick:j,children:e.jsxRuntimeExports.jsx(e.Plus,{className:"h-4 w-4"})})]})]})}return e.jsxRuntimeExports.jsxs("div",{className:"relative flex h-full flex-col pt-3",children:[o&&e.jsxRuntimeExports.jsx(de,{className:"absolute bottom-0 left-0 right-0 top-0 z-10 m-auto h-10 w-10 animate-spin text-foreground/10"}),e.jsxRuntimeExports.jsxs("div",{className:"mb-0 flex min-h-10 items-center justify-end gap-2 px-6",children:[r&&e.jsxRuntimeExports.jsxs("div",{className:"flex grow items-center gap-2",children:[e.jsxRuntimeExports.jsx(is,{}),n.type!=="table"&&e.jsxRuntimeExports.jsx(os,{})]}),e.jsxRuntimeExports.jsx(cs,{})]}),r?m():e.jsxRuntimeExports.jsxs("div",{className:"flex min-h-0 w-full flex-1 grow basis-0 px-6",children:[d&&e.jsxRuntimeExports.jsx(ls,{}),n.data&&n.data.length>0&&e.jsxRuntimeExports.jsx(rs,{data:s||[]}),u&&e.jsxRuntimeExports.jsx("span",{className:"font-mono text-sm",children:u})]})]})}function ls(){const t=e.useEditorStore(s=>s.pythonStdOut);if(!t)return null;const n=t.replace(/\n/g,"<br>");return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx("p",{className:"font-mono text-sm",children:"Output:"}),e.jsxRuntimeExports.jsx("div",{dangerouslySetInnerHTML:{__html:n},className:"bg-muted p-2 font-mono text-sm"}),e.jsxRuntimeExports.jsx(e.Separator,{className:"mb-2"})]})}function cs(){const t=e.useEditorStore(s=>s.isShowingVisual),n=e.useEditorStore(s=>s.actions.setIsShowingVisual);return e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.Label,{htmlFor:"visualize",children:"Chart"}),e.jsxRuntimeExports.jsx(e.Switch,{checked:t,onCheckedChange:()=>n(!t),id:"visualize",className:"data-[state=checked]:bg-foreground/50"})]})}function me(){const[t,n]=b.useState([]);e.useEditorStore(p=>p.card.cfg);const s=e.useEditorStore(p=>p.card.preferences),{setCardCfg:r,setFilterOnClickColumnIndex:o,setCardPreferences:u}=e.useEditorStore(p=>p.actions),d=e.useEditorStore(p=>p.queryResultColumns);e.useEditorStore(p=>{var j;return(j=p.card.preferences)==null?void 0:j.filterOnClickColumnIndex}),b.useEffect(()=>{d&&n(new Array(d.length).fill(!1))},[d]);function c(p,j){var f,a;j?s!=null&&s.onClickFilter&&((f=s==null?void 0:s.onClickFilter)==null?void 0:f.length)>0?u({...s,onClickFilter:[...s.onClickFilter,{columnIndex:p,expression:""}]}):u({...s,onClickFilter:[{columnIndex:p,expression:""}]}):(u({...s,onClickFilter:(a=s==null?void 0:s.onClickFilter)==null?void 0:a.filter(m=>m.columnIndex!==p)}),n(m=>{const x=[...m];return x[p]=!1,x}))}function l(p,j){var a;const f=(a=s==null?void 0:s.onClickFilter)==null?void 0:a.map(m=>m.columnIndex===p?{...m,expression:j.target.value}:m);u({...s,onClickFilter:f})}function h(p){var j,f,a,m;if(t!=null&&t[p]||(f=(j=s==null?void 0:s.onClickFilter)==null?void 0:j.find(x=>x.columnIndex===p))!=null&&f.expression)return e.jsxRuntimeExports.jsx(e.Input,{value:(m=(a=s==null?void 0:s.onClickFilter)==null?void 0:a.find(x=>x.columnIndex===p))==null?void 0:m.expression,onChange:x=>l(p,x),type:"text",className:" h-9 w-full focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0 font-mono text-xs",placeholder:"Expression"})}return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:d==null?void 0:d.map((p,j)=>{var f,a;return e.jsxRuntimeExports.jsx("div",{className:"flex items-center justify-between space-y-2 xbg-red-100 group",children:e.jsxRuntimeExports.jsxs("div",{className:" grow",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center py-2 space-x-2",children:[e.jsxRuntimeExports.jsx(e.Checkbox,{checked:!!((f=s==null?void 0:s.onClickFilter)!=null&&f.find(m=>m.columnIndex===j)),onCheckedChange:m=>c(j,m)}),e.jsxRuntimeExports.jsx("label",{className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:p}),e.jsxRuntimeExports.jsx("div",{className:"flex gap-2 items-center ",children:((a=s==null?void 0:s.onClickFilter)==null?void 0:a.find(m=>m.columnIndex===j))&&e.jsxRuntimeExports.jsx(Ke,{onClick:()=>{n(m=>{const x=[...m];return x[j]=!m[j],x})},className:" invisible group-hover:visible size-3 text-gray-400 cursor-pointer"})})]}),h(j)]})},p)})})}function Ne(){var d,c,l;const t=e.useEditorStore(h=>h.card.preferences),n=e.useEditorStore(h=>h.card.cfg),{setCardCfg:s,setCardPreferences:r,setChartOrientation:o}=e.useEditorStore(h=>h.actions);(d=n==null?void 0:n.options)!=null&&d.indexAxis;function u(h){o(h)}return e.jsxRuntimeExports.jsxs(e.RadioGroup,{value:((c=t==null?void 0:t.chartOptions)==null?void 0:c.indexAxis)||((l=n==null?void 0:n.options)==null?void 0:l.indexAxis)||"x",onValueChange:u,className:"flex gap-3",defaultValue:"x",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:"x",id:"r1"}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r1",children:"Vertical"})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:"y",id:"r2"}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r2",children:"Horizontal"})]})]})}const xe="focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0";function He(t,n){var r,o,u;const s=e.getNumberAxis(t,n);return((u=(o=(r=t==null?void 0:t.chartOptions)==null?void 0:r.scales)==null?void 0:o[s])==null?void 0:u.type)||"linear"}function at(){var _,B,G,q,Q,y;const[t,n]=b.useState(!1),s=e.useEditorStore(R=>{var N;return(N=R.card)==null?void 0:N.preferences}),r=e.useEditorStore(R=>{var N;return(N=R.card)==null?void 0:N.cfg}),o=e.getNumberAxis(s,r),[u,d]=b.useState(He(s)),[c,l]=b.useState(((G=(B=(_=s==null?void 0:s.chartOptions)==null?void 0:_.scales)==null?void 0:B[o])==null?void 0:G.min)||""),[h,p]=b.useState(((y=(Q=(q=s==null?void 0:s.chartOptions)==null?void 0:q.scales)==null?void 0:Q[o])==null?void 0:y.max)||""),[j,f]=b.useState(c||h?"custom":"auto"),[a,m]=b.useState(""),[x,v]=b.useState(0),[E,k]=b.useState(""),[g,D]=b.useState(""),[T,z]=b.useState(""),A=e.useEditorStore(R=>R.actions.setCardPreferences),S=e.useEditorStore(R=>{var N;return(N=R.card)==null?void 0:N.type}),C=["pie","doughnut","polarArea"].includes(S);b.useEffect(()=>{var R,N,M,te,K,I,H,$,re,se,V,J,U,oe;d(He(s)),l(((M=(N=(R=s==null?void 0:s.chartOptions)==null?void 0:R.scales)==null?void 0:N[o])==null?void 0:M.min)===0?0:""),p(((I=(K=(te=s==null?void 0:s.chartOptions)==null?void 0:te.scales)==null?void 0:K[o])==null?void 0:I.max)||""),m(((se=(re=($=(H=s==null?void 0:s.chartOptions)==null?void 0:H.scales)==null?void 0:$[o])==null?void 0:re.ticks)==null?void 0:se.stepSize)||""),v(((V=s==null?void 0:s.numberAxisFormat)==null?void 0:V.decimalPlaces)||0),k(((J=s==null?void 0:s.numberAxisFormat)==null?void 0:J.suffix)||""),D(((U=s==null?void 0:s.numberAxisFormat)==null?void 0:U.currency)||""),z(((oe=s==null?void 0:s.numberAxisFormat)==null?void 0:oe.locale)||"")},[t,s,o]);function L(R,N){return N===""||/^[0-9\b]+$/.test(N)?Number(N):Number(R)}function O(){return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-6 items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"col-span-2 hover:cursor-pointer hover:underline",htmlFor:"currency",children:e.jsxRuntimeExports.jsx("a",{target:"_blank",href:"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat",children:"Currency"})}),e.jsxRuntimeExports.jsx(e.Input,{value:g,placeholder:"USD",onChange:R=>D(R.target.value),id:"currency",className:`col-span-2 h-8 w-full ${xe}`}),e.jsxRuntimeExports.jsx(e.Input,{value:T,placeholder:"en-US",onChange:R=>z(R.target.value),id:"locale",className:`col-span-2 h-8 w-full ${xe}`})]}),e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-9 items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"col-span-3",htmlFor:"format",children:"Decimals"}),e.jsxRuntimeExports.jsx(e.Input,{value:x,onChange:R=>v(Number(R.target.value)),id:"format",className:`col-span-6 h-8 w-full tracking-wide ${xe}`})]})]})}function w(){return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Label,{htmlFor:"range",children:"Range"}),e.jsxRuntimeExports.jsx(e.Input,{id:"min",value:c,onChange:R=>l(N=>L(N,R.target.value)),className:`col-span-1 h-8 w-full ${xe}`}),e.jsxRuntimeExports.jsx(e.Input,{value:h,onChange:R=>p(N=>L(N,R.target.value)),id:"max",className:`col-span-1 h-8 w-full ${xe}`})]}),e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Label,{htmlFor:"step-size",children:"Step Size"}),e.jsxRuntimeExports.jsx(e.Input,{value:a,onChange:R=>m(N=>L(N,R.target.value)),id:"step-size",className:`col-span-1 h-8 w-full ${xe}`})]})]})}function F(){var M;let R={};j==="custom"&&(R={min:c,max:h,ticks:{stepSize:a}});const N={...s||{},chartOptions:{...s==null?void 0:s.chartOptions,scales:{...(M=s==null?void 0:s.chartOptions)==null?void 0:M.scales,[o]:{type:u,...u==="linear"?R:{}}}},numberAxisFormat:{decimalPlaces:x,suffix:E,currency:g,locale:T}};console.log(N),A(N)}return e.jsxRuntimeExports.jsxs(e.Popover,{onOpenChange:R=>n(R),children:[e.jsxRuntimeExports.jsx(e.PopoverTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.SliderIcon,{className:"size-4 cursor-pointer text-muted-foreground hover:text-foreground"})}),e.jsxRuntimeExports.jsx(e.PopoverContent,{align:"center",className:"max-w-65",children:e.jsxRuntimeExports.jsxs("div",{className:"grid gap-4",children:[e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsx("h4",{className:"font-medium leading-none",children:"Scale Options"}),e.jsxRuntimeExports.jsx("p",{className:"text-sm text-muted-foreground",children:"Set the scale for the number axis"})]}),e.jsxRuntimeExports.jsxs("div",{className:"grid gap-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Label,{htmlFor:"scale",children:"Type"}),e.jsxRuntimeExports.jsxs(e.Select,{disabled:C,value:u,onValueChange:R=>d(R),children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:"col-span-2 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsxRuntimeExports.jsx(e.SelectValue,{})}),e.jsxRuntimeExports.jsx(e.SelectContent,{id:"type",children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[e.jsxRuntimeExports.jsx(e.SelectLabel,{children:"Option"}),e.jsxRuntimeExports.jsx(e.SelectItem,{value:"linear",children:"Linear"}),e.jsxRuntimeExports.jsx(e.SelectItem,{value:"logarithmic",children:"Logarithmic"})]})})]})]}),u=="linear"&&e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 items-center gap-2 py-1",children:[e.jsxRuntimeExports.jsx(e.Label,{htmlFor:"scale-option",children:"Setup"}),e.jsxRuntimeExports.jsxs(e.RadioGroup,{disabled:C,id:"scale-option",value:j,onValueChange:R=>f(R),className:"col-span-2 flex gap-3",defaultValue:"x",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:"auto",id:"r1"}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r1",children:"Auto"})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:"custom",id:"r2"}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r2",children:"Custom"})]})]})]}),j==="custom"&&u=="linear"&&w(),O(),e.jsxRuntimeExports.jsx(e.SelectSeparator,{}),e.jsxRuntimeExports.jsx("div",{className:"grid grid-cols-3",children:e.jsxRuntimeExports.jsx(e.Button,{onClick:F,variant:"secondary",className:"col-span-1 col-start-3 h-8 w-full",children:"Apply"})})]})]})})]})}function xs({idx:t}){var c;const n=e.useEditorStore(l=>{var h;return(h=l.card)==null?void 0:h.preferences}),s=e.useEditorStore(l=>{var h;return(h=l.card.preferences)==null?void 0:h.datasetOptions}),r=e.useEditorStore(l=>l.actions.setCardPreferences),o=(c=n==null?void 0:n.chartOptions)==null?void 0:c.indexAxis,u=s==null?void 0:s.find(l=>l.idx===t);function d(l,h){(l==="end"||l==="start")&&e.getContrastColor(e.getCanvasBackgroundColor());const p={display:l!=="none",align:l,anchor:l,clamp:!0};if(!u)r({...n,datasetOptions:[...s||[],{idx:h,datalabels:p}]});else{const j={...u};j.datalabels=p;const f=s==null?void 0:s.map(a=>a.idx===h?j:a);r({...n,datasetOptions:f})}}return e.jsxRuntimeExports.jsxs(e.Popover,{children:[e.jsxRuntimeExports.jsx(e.PopoverTrigger,{children:e.jsxRuntimeExports.jsx(zt,{className:"invisible size-4 rotate-[135deg] cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"})}),e.jsxRuntimeExports.jsx(e.PopoverContent,{className:"w-fit p-1",children:e.jsxRuntimeExports.jsxs("div",{className:"flex gap-1",children:[e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>d("none",t),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsxRuntimeExports.jsx(e.X,{className:"size-4"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>d("start",t),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsxRuntimeExports.jsx(St,{className:e.cn("h-4 w-4",{"rotate-90":o==="y"})})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>d("center",t),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsxRuntimeExports.jsx(vt,{className:e.cn("h-4 w-4",{"rotate-90":o==="y"})})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>d("end",t),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsxRuntimeExports.jsx(yt,{className:e.cn("h-4 w-4",{"rotate-90":o==="y"})})})]})})]})}function lt(){const t=e.useEditorStore(l=>l.card),n=e.useEditorStore(l=>{var h,p,j;return(j=(p=(h=l==null?void 0:l.card)==null?void 0:h.preferences)==null?void 0:p.chartOptions)==null?void 0:j.indexAxis}),s=n==="y"?"Y axis":"X axis",r=n==="y"?"X axis":"Y axis",{keys:o,metricKeys:u,dimensionKeys:d}=e.getKeys(t.data||[]);let c=u;if(["stackedBar","stackedLine"].includes(t.type)){const l=e.pivotData({dataArray:t.data||[],groupKey:d[0],pivotKey:d[1],valueKey:c[0]}),{metricKeys:h}=e.getKeys(l);c=h}return o.length===0?null:e.jsxRuntimeExports.jsxs("div",{className:"space-y-4",children:[e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsx(e.Label,{children:s}),e.jsxRuntimeExports.jsx("div",{className:"my-1 space-y-1",children:e.jsxRuntimeExports.jsx("div",{className:"rounded-md bg-muted/70 px-2 py-1 hover:bg-muted",children:e.jsxRuntimeExports.jsx("p",{children:d[0]})})})]}),e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center justify-between gap-5",children:[e.jsxRuntimeExports.jsx(e.Label,{children:r}),e.jsxRuntimeExports.jsx(at,{})]}),e.jsxRuntimeExports.jsx("div",{className:"my-1 space-y-1",children:c.map((l,h)=>e.jsxRuntimeExports.jsx(us,{col:l,idx:h},l))})]})]})}function us({col:t,idx:n}){const s=e.useEditorStore(c=>{var l;return(l=c.card)==null?void 0:l.preferences}),r=e.useEditorStore(c=>{var l;return(l=c.card.preferences)==null?void 0:l.datasetOptions}),o=r==null?void 0:r.find(c=>c.idx===n),{setCardPreferences:u}=e.useEditorStore(c=>c.actions);function d(c){if(!o)u({...s,datasetOptions:[...r||[],{idx:n,type:c==="area"?"line":c,fill:c==="area"?"origin":""}]});else{const l={...o};l.type=c==="area"?"line":c,l.fill=c==="area"?"origin":"";const h=r==null?void 0:r.map(p=>p.idx===n?l:p);u({...s,datasetOptions:h})}}return e.jsxRuntimeExports.jsxs("div",{className:"group flex items-center justify-between gap-5 rounded-md bg-muted/70 px-2 py-1 hover:bg-muted",children:[e.jsxRuntimeExports.jsx("p",{children:t}),e.jsxRuntimeExports.jsxs("div",{className:"flex gap-2",children:[e.jsxRuntimeExports.jsx(ze,{onClick:()=>d("bar"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsxRuntimeExports.jsx(Le,{onClick:()=>d("line"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsxRuntimeExports.jsx(mt,{onClick:()=>d("area"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsxRuntimeExports.jsx(e.Separator,{orientation:"vertical",className:"invisible size-4 cursor-pointer py-2 text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsxRuntimeExports.jsx(xs,{idx:n})]})]})}function ds({cardType:t}){return e.jsxRuntimeExports.jsx("div",{className:"space-y-6 px-6 py-2",children:e.jsxRuntimeExports.jsxs(e.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:`${e.titleCase(t)} Chart`}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 font-mono text-xs",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT x-axis, y-axis-1, y-axis-2,... FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"x-axis - category"}),e.jsxRuntimeExports.jsx("li",{children:"y-axis1 - number"}),e.jsxRuntimeExports.jsx("li",{children:"y-axis2 - number"})]}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:n=>n.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#line-chart",children:"example"})," in the docs."]})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-2",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Settings"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 px-2",children:[e.jsxRuntimeExports.jsx(Ne,{}),e.jsxRuntimeExports.jsx(lt,{})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filter on click"}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:"px-2",children:e.jsxRuntimeExports.jsx(me,{})})]})]})})}function Me(){var o,u,d;const t=e.useEditorStore(c=>c.card.cfg),n=e.useEditorStore(c=>c.actions.setCardCfg),s=e.useEditorStore(c=>c.card.type);function r(c){var p;const l={datalabels:{display:c!=="none",align:c,anchor:c,clamp:!0}},h={...t,options:{...t==null?void 0:t.options,plugins:{...(p=t==null?void 0:t.options)==null?void 0:p.plugins,...l}}};n(h),console.log(c)}return e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxRuntimeExports.jsx("label",{className:"font-medium",children:"Data Labels"}),!["pyramid"].includes(s)&&e.jsxRuntimeExports.jsx(at,{})]}),e.jsxRuntimeExports.jsxs(e.Select,{value:(d=(u=(o=t==null?void 0:t.options)==null?void 0:o.plugins)==null?void 0:u.datalabels)==null?void 0:d.anchor,onValueChange:r,defaultValue:"none",children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:"h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsxRuntimeExports.jsx(e.SelectValue,{placeholder:"Select position"})}),e.jsxRuntimeExports.jsx(e.SelectContent,{children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[e.jsxRuntimeExports.jsx(e.SelectLabel,{children:"Data Labels"}),e.jsxRuntimeExports.jsx(e.SelectItem,{value:"none",children:"None"}),s!=="pyramid"&&e.jsxRuntimeExports.jsx(e.SelectItem,{value:"start",children:"Start"}),e.jsxRuntimeExports.jsx(e.SelectItem,{value:"center",children:"Center"}),s!=="pyramid"&&e.jsxRuntimeExports.jsx(e.SelectItem,{value:"end",children:"End"})]})})]})]})}function ms({cardType:t}){function n(s){const r="SELECT label, [group], x-axis, y-axis, radius FROM table",o="SELECT label, [group], x-axis, y-axis FROM table";return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx("div",{className:"bg-muted px-2 py-1 rounded text-xs",children:s==="bubble"?r:o}),e.jsxRuntimeExports.jsxs("ul",{className:" ml-6 list-disc [&>li]:mt-2 text-xs",children:[e.jsxRuntimeExports.jsx("li",{children:"label - category"}),e.jsxRuntimeExports.jsx("li",{children:"group - category"}),e.jsxRuntimeExports.jsx("li",{children:"x-axis - category"}),e.jsxRuntimeExports.jsx("li",{children:"y-axis - category"}),s==="bubble"&&e.jsxRuntimeExports.jsx("li",{children:"radius - number"})]}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:u=>u.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#pie-chart",children:"example"})," in the docs."]})]})}return e.jsxRuntimeExports.jsx("div",{className:"px-6 py-2 space-y-6",children:e.jsxRuntimeExports.jsxs(e.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:`${e.titleCase(t)} Chart`}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:" space-y-4 font-mono text-xs ",children:n(t)})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-2",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Settings"}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:"px-2",children:e.jsxRuntimeExports.jsx(Me,{})})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filter on click"}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:"px-2",children:e.jsxRuntimeExports.jsx(me,{})})]})]})})}const ps={datasets:[{type:"line",label:"Sum_sales",data:[]},{type:"bar",label:"Sum_profit",data:[]}]},hs={datasets:[{fill:"origin",type:"line",label:"Sum_sales",data:[]}]};function js(){const t=e.useEditorStore(n=>n.card.type);return e.jsxRuntimeExports.jsxs("div",{className:"space-y-6 p-6",children:[e.jsxRuntimeExports.jsx(e.Accordion,{className:" ",type:"single",collapsible:!0,children:Es(t)}),e.jsxRuntimeExports.jsx("section",{className:"",children:["line","bar"].includes(t)&&e.jsxRuntimeExports.jsx(Ne,{})}),e.jsxRuntimeExports.jsx("div",{children:!["kpi"].includes(t)&&e.jsxRuntimeExports.jsx(Me,{})}),e.jsxRuntimeExports.jsx("div",{children:!["kpi"].includes(t)&&e.jsxRuntimeExports.jsx(me,{})})]})}function Es(t){if(["line","bar"].includes(t))return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"font-normal",children:e.jsxRuntimeExports.jsx("p",{children:"Chart Query"})}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:" ",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs font-semibold",children:"SELECT x-axis, y-axis-1, y-axis-2, y-axis-3,... FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"X-axis - Category (ex. city)"}),e.jsxRuntimeExports.jsx("li",{children:"Y-axis - Number (ex. population)"})]})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-2",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"font-normal",children:"Mixed Chart"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-2 text-xs",children:[e.jsxRuntimeExports.jsxs("p",{children:["Click ",e.jsxRuntimeExports.jsx("b",{children:"Customize"})," and change the `type` property in the dataset."]}),e.jsxRuntimeExports.jsx("pre",{children:JSON.stringify(ps,null,2)})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"font-normal",children:"Area Chart"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-2 text-xs",children:[e.jsxRuntimeExports.jsxs("p",{children:["Click ",e.jsxRuntimeExports.jsx("b",{children:"Customize"})," and add `fill` property to the dataset. See",e.jsxRuntimeExports.jsx("a",{className:"mx-1 text-blue-500 hover:underline",href:"https://www.chartjs.org/docs/latest/samples/area/line-boundaries.html",target:"_blank",children:"docs"}),"for more options."]}),e.jsxRuntimeExports.jsx("pre",{children:JSON.stringify(hs,null,2)})]})]})]});if(t==="bubble")return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"font-normal",children:e.jsxRuntimeExports.jsxs("p",{children:["How to create a ",e.jsxRuntimeExports.jsx("span",{children:t})," chart query?"]})}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:" ",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs font-semibold",children:"SELECT label, x-axis, y-axis, radius FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"Label - Category (ex. city)"}),e.jsxRuntimeExports.jsx("li",{children:"Bubble Group (opt) - Category (ex. state)"}),e.jsxRuntimeExports.jsx("li",{children:"X-axis - Number (ex. avg. age)"}),e.jsxRuntimeExports.jsx("li",{children:"Y-axis - Number (ex. avg. weight)"}),e.jsxRuntimeExports.jsx("li",{children:"Radius - Number (ex. population)"})]})]})]})});if(t==="scatter")return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"font-normal",children:e.jsxRuntimeExports.jsxs("p",{children:["How to create a ",e.jsxRuntimeExports.jsx("span",{children:t})," chart query?"]})}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:" ",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs font-semibold",children:"SELECT label, x-axis, y-axis FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"Label - Category (ex. city)"}),e.jsxRuntimeExports.jsx("li",{children:"Group (opt) - Category (ex. state)"}),e.jsxRuntimeExports.jsx("li",{children:"X-axis - Number (ex. avg. age)"}),e.jsxRuntimeExports.jsx("li",{children:"Y-axis - Number (ex. avg. weight)"})]})]})]})});if(["pie","doughnut","polarArea"].includes(t))return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"font-normal",children:e.jsxRuntimeExports.jsxs("p",{children:[e.jsxRuntimeExports.jsx("span",{children:t==="polarArea"?"Polar":t.charAt(0).toUpperCase()+t.slice(1)})," ","chart query"]})}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:" ",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs font-semibold",children:"SELECT label, measure FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"Label - Category (ex. city)"}),e.jsxRuntimeExports.jsx("li",{children:"Measure - Number (ex. population)"})]})]})]})})}function fs(){var l,h,p,j,f;const t=e.useEditorStore(a=>a.card.preferences),n=e.useEditorStore(a=>a.actions.setCardPreferences),s=e.useEditorStore(a=>a.actions.setNumberFormat);e.useEditorStore(a=>{var m,x;return(x=(m=a.card.preferences)==null?void 0:m.formatNumber)==null?void 0:x.decimalPlaces});const r=e.useEditorStore(a=>{var m,x;return(x=(m=a.card.preferences)==null?void 0:m.formatNumber)==null?void 0:x.locale}),o=e.useEditorStore(a=>{var m,x;return(x=(m=a.card.preferences)==null?void 0:m.formatNumber)==null?void 0:x.currency});e.useEditorStore(a=>a.actions.setFilterOnClickField);const u=e.useEditorStore(a=>{var m,x;return(x=(m=a.card.preferences)==null?void 0:m.formatNumber)==null?void 0:x.colorRanges})||[],d=e.useEditorStore(a=>a.actions.setColorRanges),c=[...new Set(e.LOCALE_CURRENCY_PAIRS.map(a=>a.currency))];return e.jsxRuntimeExports.jsxs("div",{children:[e.jsxRuntimeExports.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Checkbox,{checked:!!((l=t==null?void 0:t.formatNumber)!=null&&l.enabled),onCheckedChange:a=>{n({...t,formatNumber:{...t==null?void 0:t.formatNumber,enabled:a}})}}),e.jsxRuntimeExports.jsx(e.Label,{children:"Format Number"})]}),((h=t==null?void 0:t.formatNumber)==null?void 0:h.enabled)===!0&&e.jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxRuntimeExports.jsx("div",{children:e.jsxRuntimeExports.jsxs("div",{className:"space-y-4 p-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"w-full space-y-1",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Locale"}),e.jsxRuntimeExports.jsxs(e.Select,{value:r||"en-US",onValueChange:a=>{var m,x,v;return s(((m=t==null?void 0:t.formatNumber)==null?void 0:m.decimalPlaces)||0,((x=t==null?void 0:t.formatNumber)==null?void 0:x.currency)||"",a||"en-US",((v=t==null?void 0:t.formatNumber)==null?void 0:v.suffix)||"")},children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:"col-span-6 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsxRuntimeExports.jsx(e.SelectValue,{})}),e.jsxRuntimeExports.jsx(e.SelectContent,{children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[e.jsxRuntimeExports.jsx(e.SelectLabel,{children:"Format"}),e.LOCALE_CURRENCY_PAIRS.map(a=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:a.locale,children:a.locale},a.locale))]})})]})]}),e.jsxRuntimeExports.jsxs("div",{className:"w-full space-y-1",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Currency"}),e.jsxRuntimeExports.jsxs(e.Select,{value:o||"none",onValueChange:a=>{var m,x,v;return s(((m=t==null?void 0:t.formatNumber)==null?void 0:m.decimalPlaces)||0,a==="none"?"":a,((x=t==null?void 0:t.formatNumber)==null?void 0:x.locale)||"",((v=t==null?void 0:t.formatNumber)==null?void 0:v.suffix)||"")},children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:"col-span-6 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsxRuntimeExports.jsx(e.SelectValue,{})}),e.jsxRuntimeExports.jsx(e.SelectContent,{children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[e.jsxRuntimeExports.jsx(e.SelectLabel,{children:"Currency"}),e.jsxRuntimeExports.jsx(e.SelectItem,{value:"none",children:"None"},"none"),c.map(a=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:a,children:a},a))]})})]})]})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex gap-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"w-full space-y-1",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Decimals"}),e.jsxRuntimeExports.jsxs(e.Select,{value:((j=(p=t==null?void 0:t.formatNumber)==null?void 0:p.decimalPlaces)==null?void 0:j.toString())||"0",onValueChange:a=>{var m,x,v;return s(Number(a),((m=t==null?void 0:t.formatNumber)==null?void 0:m.currency)||"",((x=t==null?void 0:t.formatNumber)==null?void 0:x.locale)||"",((v=t==null?void 0:t.formatNumber)==null?void 0:v.suffix)||"")},children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:"col-span-3 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsxRuntimeExports.jsx(e.SelectValue,{})}),e.jsxRuntimeExports.jsx(e.SelectContent,{children:["0","1","2","3","4"].map(a=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:a,children:a},a))})]})]}),e.jsxRuntimeExports.jsxs("div",{className:"w-full space-y-1",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Suffix"}),e.jsxRuntimeExports.jsx(e.Input,{value:((f=t==null?void 0:t.formatNumber)==null?void 0:f.suffix)||"",className:"h-8 font-mono text-xs focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",placeholder:"K, M, B, %",onChange:a=>{var m,x,v;return s(((m=t==null?void 0:t.formatNumber)==null?void 0:m.decimalPlaces)||0,((x=t==null?void 0:t.formatNumber)==null?void 0:x.currency)||"",((v=t==null?void 0:t.formatNumber)==null?void 0:v.locale)||"",a.target.value)}})]})]})]})}),e.jsxRuntimeExports.jsx(e.Separator,{className:"my-3"}),e.jsxRuntimeExports.jsx(e.ColorFormat,{colorRanges:u,setColorRanges:d})]})]})}function gs(){return e.jsxRuntimeExports.jsxs("div",{className:"space-y-6 px-6 py-2",children:[e.jsxRuntimeExports.jsx(e.Accordion,{type:"single",collapsible:!0,children:e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"",children:"KPI Query"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"font-mono",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs",children:"SELECT current, previous FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"current - number"}),e.jsxRuntimeExports.jsx("li",{children:"previous - number"})]}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:t=>t.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#kpi",children:"example"})," in the docs."]})]})]})}),e.jsxRuntimeExports.jsx("section",{className:"",children:e.jsxRuntimeExports.jsx(fs,{})}),e.jsxRuntimeExports.jsx("div",{}),e.jsxRuntimeExports.jsx("div",{})]})}function Rs(){var r;const t=e.useEditorStore(o=>o.card.preferences),{setCardPreferences:n}=e.useEditorStore(o=>o.actions);function s(o){n({...t,textVisualOptions:{...t==null?void 0:t.textVisualOptions,isDynamicText:o==="dynamic"}})}return e.jsxRuntimeExports.jsxs(e.RadioGroup,{value:(r=t==null?void 0:t.textVisualOptions)!=null&&r.isDynamicText?"dynamic":"static",onValueChange:s,className:"flex gap-3",defaultValue:"x",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:"static",id:"r1"}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r1",children:"Static"})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:"dynamic",id:"r2"}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r2",children:"Dynamic"})]})]})}function ye({cardType:t,docContent:n,suffix:s="Chart"}){return e.jsxRuntimeExports.jsx("div",{className:"space-y-6 px-6 py-2",children:e.jsxRuntimeExports.jsxs(e.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:`${e.titleCase(t)} ${s}`}),e.jsxRuntimeExports.jsx(e.AccordionContent,{children:n||e.jsxRuntimeExports.jsxs("div",{className:"space-y-4 font-mono text-xs",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT label, measure FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"label - category"}),e.jsxRuntimeExports.jsx("li",{children:"measure - number"})]}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:r=>r.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#pie-chart",children:"example"})," in the docs."]})]})})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-2",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Settings"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 px-2",children:[t==="range"&&e.jsxRuntimeExports.jsx(Ne,{}),t!=="text"&&e.jsxRuntimeExports.jsx(Me,{}),t==="text"&&e.jsxRuntimeExports.jsx(Rs,{})]})]}),!["range","text"].includes(t)&&e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filter on click"}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:"px-2",children:e.jsxRuntimeExports.jsx(me,{})})]})]})})}function bs(){return e.jsxRuntimeExports.jsx("div",{className:"space-y-6 px-6 py-2",children:e.jsxRuntimeExports.jsxs(e.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Stacked Chart"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 font-mono text-xs",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT x-axis, stack-by, y-axis FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"x-axis - category"}),e.jsxRuntimeExports.jsx("li",{children:"stack by - category"}),e.jsxRuntimeExports.jsx("li",{children:"y-axis - number"})]}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:t=>t.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#stacked-chart",children:"example"})," in the docs."]})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-2",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Settings"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 px-2",children:[e.jsxRuntimeExports.jsx(Ne,{}),e.jsxRuntimeExports.jsx(lt,{})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filter on click"}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:"px-2",children:e.jsxRuntimeExports.jsx(me,{})})]})]})})}function Ss({}){const t=e.useEditorStore(r=>{var o;return(o=r.card)==null?void 0:o.preferences}),n=e.useEditorStore(r=>r.actions.setCardPreferences),s=r=>{n({...t,allowDownload:r})};return e.jsxRuntimeExports.jsxs("div",{className:"space-y-6 px-6 py-2",children:[e.jsxRuntimeExports.jsx(e.Accordion,{defaultValue:["item-3"],type:"multiple",children:e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filter on click"}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:"px-2",children:e.jsxRuntimeExports.jsx(me,{})})]})}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.Checkbox,{onCheckedChange:s,id:"allow-download"}),e.jsxRuntimeExports.jsx("label",{htmlFor:"allow-download",className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:"Allow Download"})]})]})}const ys=e.jsxRuntimeExports.jsxs("div",{className:"space-y-4 font-mono text-xs",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT dimension, cohort, metric FROM table"}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:t=>t.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#pyramid-chart",children:"example"})," in the docs."]})]}),vs=e.jsxRuntimeExports.jsxs("div",{className:"space-y-4 font-mono text-xs",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT y-axis, label, range-from, range-to, range-value FROM table"}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:t=>t.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#range-charts",children:"example"})," in the docs."]})]}),Cs=e.jsxRuntimeExports.jsxs("div",{className:"space-y-4 font-mono text-xs",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT text FROM table limit 1"}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:t=>t.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#text-visual",children:"example"})," in the docs."]})]});function Ns(){const t=e.useEditorStore(s=>s.card.type);function n(s){switch(s){case"stackedBar":case"stackedLine":return e.jsxRuntimeExports.jsx(bs,{});case"pyramid":return e.jsxRuntimeExports.jsx(ye,{docContent:ys,cardType:s});case"kpi":return e.jsxRuntimeExports.jsx(gs,{});case"line":case"bar":return e.jsxRuntimeExports.jsx(ds,{cardType:s});case"range":return e.jsxRuntimeExports.jsx(ye,{docContent:vs,cardType:s});case"pie":case"doughnut":case"polarArea":case"radar":return e.jsxRuntimeExports.jsx(ye,{cardType:s});case"bubble":case"scatter":return e.jsxRuntimeExports.jsx(ms,{cardType:s});case"table":return e.jsxRuntimeExports.jsx(Ss,{cardType:s});case"text":return e.jsxRuntimeExports.jsx(ye,{docContent:Cs,cardType:s,suffix:"Visual"});default:return e.jsxRuntimeExports.jsx(js,{})}}return e.jsxRuntimeExports.jsx(e.ScrollArea,{className:"h-full w-full text-sm",children:n(t)})}function ks(){const t=e.useEditorStore(n=>n.isShowingVisual);return e.jsxRuntimeExports.jsxs(e.ResizablePanelGroup,{direction:"vertical",className:"min-h-[250px] min-w-full max-w-lg",children:[e.jsxRuntimeExports.jsx(e.ResizablePanel,{role:"query-section",className:"flex",minSize:20,defaultSize:40,children:e.jsxRuntimeExports.jsx(ns,{})}),e.jsxRuntimeExports.jsx(e.ResizableHandle,{withHandle:!0,className:"border"}),e.jsxRuntimeExports.jsx(e.ResizablePanel,{className:"pb-1",role:"visual-section",minSize:0,defaultSize:60,children:t?e.jsxRuntimeExports.jsxs(e.ResizablePanelGroup,{direction:"horizontal",children:[e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsx(e.ResizablePanel,{className:"flex min-w-[275px]",minSize:20,defaultSize:25,maxSize:30,children:e.jsxRuntimeExports.jsx(Ns,{})})}),e.jsxRuntimeExports.jsx(e.ResizableHandle,{className:"border"}),e.jsxRuntimeExports.jsx(e.ResizablePanel,{minSize:40,defaultSize:75,maxSize:100,children:e.jsxRuntimeExports.jsx(_e,{})})]}):e.jsxRuntimeExports.jsx(_e,{})})]})}function ws({authToken:t,onSave:n,onClose:s}){const r=e.useEditorStore(d=>d.actions.setOnSave),o=e.useEditorStore(d=>d.actions.setOnClose),u=e.useDashboardStore(d=>d.actions.setAuthToken);return b.useEffect(()=>{n&&r(n),s&&o(s)},[n,r,s,o]),b.useEffect(()=>{t&&t.accessToken&&u(t)},[t,u]),e.jsxRuntimeExports.jsxs(e.EditorPanel,{className:"rounded-none",role:"editor-panel",children:[e.jsxRuntimeExports.jsx(e.EditorAside,{className:"rounded-none border-r-[1.5px]",children:e.jsxRuntimeExports.jsx(Ue,{})}),e.jsxRuntimeExports.jsx(e.EditorMain,{children:e.jsxRuntimeExports.jsx(ks,{})})]})}function As(){e.useDashboardStore(d=>d.selectedCardId);const t=e.useDashboardStore(d=>d.selectedSheetId),{setIsVisualEditing:n}=e.useDashboardStore(d=>d.actions),s=e.useDashboardStore(d=>d.isVisualEditing),r=e.useDashboardStore(d=>d.actions.updateFrame);function o(d){t&&(r(t,d),n(!1))}function u(){n(!1)}return e.jsxRuntimeExports.jsx("div",{role:"editor-container",className:e.cn("flex grow",{block:s,hidden:!s}),children:e.jsxRuntimeExports.jsx(ws,{onSave:o,onClose:u})})}function Ds({columns:t,tableName:n}){const s=e.useEditorStore(a=>a.selectedConnectionId),r=e.useEditorStore(a=>a.selectedDatamodelId),o=e.useEditorStore(a=>a.selectedDatabaseName),u=e.useEditorStore(a=>a.selectedSchemaName),d=e.useEditorStore(a=>a.selectedTableName),c=e.useDashboardStore(a=>a.dashboard.filters)||[],l=e.useDashboardStore(a=>a.actions.addFilter),h=e.useDashboardStore(a=>a.actions.removeFilter),p=e.useDashboardStore(a=>a.actions.removeFilterValue),{modelItems:j}=Ee();function f(a){var z;const m=e.fmt(a.column_name),x=e.fmt(o||""),v=e.fmt(u||""),E=e.fmt(n);let k=e.getQualifiedTableName(v,E),g=`${k}.${m}`;const D=(z=j==null?void 0:j.find(A=>A.id===r))==null?void 0:z.name;r&&r!=="none"&&(g=`${e.DATAMODEL_NAMESPCACE}.${D}.${m}`,k=`${e.DATAMODEL_NAMESPCACE}.${D}`),console.log("find",g,E,x);const T=c==null?void 0:c.find(A=>A.column===g&&A.table===E&&(A.database===x||A.database===o));if(T)p(T.id),h(T.id);else{if(n==="api"&&s){l({id:e.v4(),column:g,title:a.column_name,dataType:a.data_type,table:"api",database:"",connectionId:s,operation:"in",sql:e.getDefaultFilterSql(a.data_type,k,m)});return}l({id:e.v4(),column:g,title:a.column_name,dataType:a.data_type,table:d||"",database:o||"",connectionId:s||"",operation:"in",sql:e.getDefaultFilterSql(a.data_type,k,m)})}}return e.jsxRuntimeExports.jsx("div",{className:"xbg-red-100 flex-1 basis-0 flex-col overflow-scroll px-3",children:t==null?void 0:t.map(a=>{const m=c==null?void 0:c.find(x=>x.column===e.fmt(a.column_name)&&x.table===d&&x.database===o);return e.jsxRuntimeExports.jsx("div",{onClick:()=>f(a),className:e.cn("group flex cursor-pointer items-center justify-between border border-dashed border-background px-3 py-[6px] text-sm transition-colors hover:bg-muted/50",{"bg-muted":m}),children:e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxRuntimeExports.jsx(Je,{column:a}),e.jsxRuntimeExports.jsx("span",{children:a.column_name})]})},a.column_name)})})}function Ts(){e.useDashboardStore(n=>n.showFilters);const t=e.useDashboardStore(n=>n.actions.setShowFilters);return e.jsxRuntimeExports.jsxs("section",{className:"relative flex grow flex-col border-l px-4",children:[e.jsxRuntimeExports.jsxs("div",{className:"mt-4 flex items-center justify-between gap-2 px-3",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"text-lg",children:"Filters"}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>t(!1),className:"h-7 w-7 p-0",variant:"ghost",children:e.jsxRuntimeExports.jsx(e.Cross2Icon,{})})]}),e.jsxRuntimeExports.jsx("div",{className:"flex grow",children:e.jsxRuntimeExports.jsx(Ue,{ColumnsComponent:(n,s,r)=>e.jsxRuntimeExports.jsx(Ds,{schemaName:n,tableName:s,columns:r})})})]})}function Is(){e.useDashboardStore(s=>s.dashboard);const t=e.useDashboardStore(s=>s.showFilters),n=e.useDashboardStore(s=>s.isVisualEditing);return e.useDashboardStore(s=>s.bookmarkKey),e.jsxRuntimeExports.jsxs("div",{role:"dashboard-plus-main",className:e.cn("grow",{hidden:n,flex:!n}),children:[e.jsxRuntimeExports.jsx(e.DashboardTabs,{}),t&&e.jsxRuntimeExports.jsx("div",{role:"filter-aside-container",className:"flex",children:e.jsxRuntimeExports.jsx(Ts,{})})]})}function zs(){const t=e.useDashboardStore(r=>r.dashboard),n=e.useDashboardStore(r=>r.actions.setDashboard),s=e.useDashboardStore(r=>r.showDashboardJSON);return e.useDashboardStore(r=>r.actions.setShowDashboardJSON),e.jsxRuntimeExports.jsx("div",{className:e.cn(" p-2",{hidden:!s}),children:e.jsxRuntimeExports.jsx(e.de,{onChange:r=>{if(r)try{JSON.parse(r),n(JSON.parse(r))}catch{}},defaultLanguage:"json",className:"h-[550px] overflow-y-auto ",value:JSON.stringify(t,null,2),options:{minimap:{enabled:!1},glyphMargin:!1,wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:12,renderLineHighlight:"none"}})})}function Ls({showControls:t=!1,showFooter:n=!0,...s}){return e.jsxRuntimeExports.jsxs(e.SemaphorContextProvider,{dashboardProps:s,children:[e.jsxRuntimeExports.jsx(e.Te,{}),e.jsxRuntimeExports.jsxs(e.UXProvider,{children:[e.jsxRuntimeExports.jsx(zs,{}),e.jsxRuntimeExports.jsxs(e.DashboardPanel,{...s,children:[t&&e.jsxRuntimeExports.jsx(Bt,{}),e.jsxRuntimeExports.jsx(As,{}),e.jsxRuntimeExports.jsx(Is,{})]})]})]})}exports.DashboardPlus=Ls;exports.LoaderCircle=de;exports.SelectComponent=ue;exports.useEditorAside=Ee;
215
+ Visual Query Syntax: ${Qt}`,{data:z,isLoading:A,isFetching:S,isError:C,refetch:L}=e.useQuery({queryKey:["ai-query"],queryFn:()=>e.getRequest("https://semaphor.cloud/api/v1/ai",(l==null?void 0:l.accessToken)||"",{user_content:`userContent: ${D} ${h?T:""}`}),enabled:!1});function O(y){if(y.toLowerCase().includes("bar"))m("bar");else if(y.toLowerCase().includes("line"))m("line");else if(y.toLowerCase().includes("bubble"))m("bubble");else if(y.toLowerCase().includes("scatter"))m("scatter");else if(y.toLowerCase().includes("stacked"))m("stackedBar");else if(y.toLowerCase().includes("pie"))m("pie");else if(y.toLowerCase().includes("donut")||y.toLowerCase().includes("doughnut"))m("doughnut");else if(y.toLowerCase().includes("radar"))m("radar");else return m("bar"),!1;return!0}b.useEffect(()=>{z&&v(y=>[...y,{role:"ai",content:z.response}])},[z]),b.useEffect(()=>{const y=setTimeout(()=>{var R;c.current&&(c.current.scroll({top:c.current.scrollHeight,behavior:"smooth"}),(R=d.current)==null||R.focus())},100);return()=>clearTimeout(y)},[x]);function w(){s&&(v(y=>[...y,{role:"user",content:s}]),O(s)&&p(!0),r(""),L())}b.useEffect(()=>{o&&(w(),u(!1))},[o,u]);const F={fontFamily:"Arial, sans-serif",lineHeight:1.6,fontSize:15,width:"100%"},_={fontFamily:"monospace",fontSize:14,lineHeight:1.6},B={fontFamily:"Arial, sans-serif",lineHeight:1.6,fontSize:15,padding:"2px 0",marginLeft:20,listStyleType:"disc"},G={p:({node:y,...R})=>e.jsxRuntimeExports.jsx("p",{style:F,...R}),code:({node:y,...R})=>e.jsxRuntimeExports.jsx("code",{className:"rounded-sm bg-muted px-2 py-1 text-sm",...R}),pre:({node:y,...R})=>e.jsxRuntimeExports.jsxs("pre",{className:"space-y-2 rounded-sm bg-muted/50 p-3",style:_,children:[e.jsxRuntimeExports.jsx("code",{className:"whitespace-normal text-sm",children:R.children}),e.jsxRuntimeExports.jsxs("div",{className:"flex justify-start gap-2",children:[e.jsxRuntimeExports.jsx(e.Button,{onClick:q,size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(e.ClipboardCopyIcon,{})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:N=>{const M=q(N);M&&(n(!1),j(M),a(!0))},size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(e.PlayIcon,{})})]})]}),li:({node:y,...R})=>e.jsxRuntimeExports.jsx("li",{style:B,...R})};function q(y){const R=y.currentTarget.closest("pre");if(!R)return;const N=R.textContent||R.innerText;return navigator.clipboard.writeText(N).then(()=>console.log("Text copied to clipboard")).catch(M=>console.error("Error in copying text: ",M)),N}function Q(){return x==null?void 0:x.map((y,R)=>y.role==="user"?e.jsxRuntimeExports.jsxs("div",{className:"flex items-start rounded-md bg-muted p-3 text-sm",children:[e.jsxRuntimeExports.jsx(Ft,{className:"mr-2 h-5 w-5"}),e.jsxRuntimeExports.jsx("div",{children:y.content})]},R):y.role==="ai"?e.jsxRuntimeExports.jsx(e.Markdown,{className:"w-full overflow-auto py-1",components:G,children:z==null?void 0:z.response.replace(/DuckDB/gi,"Semaphor")},R):e.jsxRuntimeExports.jsx("div",{},R))}return e.jsxRuntimeExports.jsxs(e.Dialog,{open:t,onOpenChange:n,children:[e.jsxRuntimeExports.jsx(e.DialogTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.Button,{size:"sm",className:"w-full justify-start border font-normal text-muted-foreground focus-visible:ring-0 focus-visible:ring-offset-0",variant:"secondary",children:"Type your question here..."})}),e.jsxRuntimeExports.jsxs(e.DialogContent,{className:"flex flex-col justify-between overflow-auto sm:max-w-[425px] md:max-h-[625px] md:min-w-[625px]",children:[e.jsxRuntimeExports.jsxs(e.DialogHeader,{children:[e.jsxRuntimeExports.jsx(e.DialogTitle,{children:"Assistant"}),e.jsxRuntimeExports.jsx(e.DialogDescription,{children:"What can I help you with?"})]}),e.jsxRuntimeExports.jsx("div",{ref:c,className:"h-[625px] w-full overflow-auto border-t border-t-muted",children:e.jsxRuntimeExports.jsx("div",{className:"space-y-4 py-2 pr-3",role:"messages",children:Q()})}),e.jsxRuntimeExports.jsx("div",{children:e.jsxRuntimeExports.jsxs("div",{className:"flex w-full items-center rounded-md border",children:[e.jsxRuntimeExports.jsx(e.Textarea,{autoFocus:!0,ref:d,onKeyDown:y=>{y.key==="Enter"&&!y.shiftKey&&(y.preventDefault(),r(""),w())},placeholder:"Type your question here...",onFocus:y=>{const R=y.target,N=R.value.length;R.setSelectionRange(N,N)},className:e.cn("max-h-10 min-h-7 resize-none border-none focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0"),disabled:A||S,value:s,onChange:y=>r(y.target.value)})," ",e.jsxRuntimeExports.jsx(e.Button,{className:"h-8",size:"sm",variant:"ghost",onClick:w,children:!A&&!S?e.jsxRuntimeExports.jsx(e.PaperPlaneIcon,{}):e.jsxRuntimeExports.jsx(de,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"})})]})})]})]})}var We={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Be=b.createContext&&b.createContext(We),Ut=["attr","size","title"];function Wt(t,n){if(t==null)return{};var s=Yt(t,n),r,o;if(Object.getOwnPropertySymbols){var u=Object.getOwnPropertySymbols(t);for(o=0;o<u.length;o++)r=u[o],!(n.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(t,r)&&(s[r]=t[r])}return s}function Yt(t,n){if(t==null)return{};var s={},r=Object.keys(t),o,u;for(u=0;u<r.length;u++)o=r[u],!(n.indexOf(o)>=0)&&(s[o]=t[o]);return s}function ve(){return ve=Object.assign?Object.assign.bind():function(t){for(var n=1;n<arguments.length;n++){var s=arguments[n];for(var r in s)Object.prototype.hasOwnProperty.call(s,r)&&(t[r]=s[r])}return t},ve.apply(this,arguments)}function Ve(t,n){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),s.push.apply(s,r)}return s}function Ce(t){for(var n=1;n<arguments.length;n++){var s=arguments[n]!=null?arguments[n]:{};n%2?Ve(Object(s),!0).forEach(function(r){Xt(t,r,s[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):Ve(Object(s)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(s,r))})}return t}function Xt(t,n,s){return n=Zt(n),n in t?Object.defineProperty(t,n,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[n]=s,t}function Zt(t){var n=es(t,"string");return typeof n=="symbol"?n:String(n)}function es(t,n){if(typeof t!="object"||t===null)return t;var s=t[Symbol.toPrimitive];if(s!==void 0){var r=s.call(t,n||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(n==="string"?String:Number)(t)}function Ye(t){return t&&t.map((n,s)=>b.createElement(n.tag,Ce({key:s},n.attr),Ye(n.child)))}function ee(t){return n=>b.createElement(ts,ve({attr:Ce({},t.attr)},n),Ye(t.child))}function ts(t){var n=s=>{var{attr:r,size:o,title:u}=t,d=Wt(t,Ut),c=o||s.size||"1em",l;return s.className&&(l=s.className),t.className&&(l=(l?l+" ":"")+t.className),b.createElement("svg",ve({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},s.attr,r,d,{className:l,style:Ce(Ce({color:t.color||s.color},s.style),t.style),height:c,width:c,xmlns:"http://www.w3.org/2000/svg"}),u&&b.createElement("title",null,u),t.children)};return Be!==void 0?b.createElement(Be.Consumer,null,s=>n(s)):n(We)}function ss(t){return ee({tag:"svg",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:[]}]})(t)}function ns(){const{theme:t}=e.useTheme(),n=b.useRef(),s=b.useRef(),[r,o]=b.useState(!1),[u,d]=b.useState(!1),[c,l]=b.useState(!1),[h,p]=b.useState(""),[j,f]=b.useState(!1),{authToken:a}=e.useSemaphorContext();e.useDashboardStore(i=>i.selectedSheetId);const m=e.useDashboardStore(i=>i.dashboard.baseQueries),x=e.useEditorStore(i=>i.card),v=e.useDashboardStore(i=>i.theme),E=e.useEditorStore(i=>i.isShowingVisual),k=e.useEditorStore(i=>i.selectedConnectionId),g=e.useEditorStore(i=>i.selectedDatabaseName),D=e.useEditorStore(i=>i.selectedDatamodelId),T=e.useEditorStore(i=>i.selectedSchemaName);e.useDashboardStore(i=>i.actions.updateFrameCard);const z=e.useEditorStore(i=>i.selectedTableName),A=e.useEditorStore(i=>i.card.sql),S=e.useEditorStore(i=>i.card.python),C=e.resolveBaseQuery(A,m),L=e.useEditorStore(i=>i.selectedConnectionId),O=e.useEditorStore(i=>i.frame),w=e.useEditorStore(i=>i.filterValues),F=e.useEditorStore(i=>i.applyFilters),{setCardCustomCfg:_,setQueryResultColumns:B,setFilterValues:G,setCardSql:q,setCardPython:Q,setQueryError:y,setPythonStdOut:R,setCardPreferences:N}=e.useEditorStore(i=>i.actions),M=e.useEditorStore(i=>i.onSave),te=e.useEditorStore(i=>i.actions.setApplyFilters),K=e.useEditorStore(i=>i.onClose),I=e.useEditorStore(i=>i.actions.setCardData),H=e.useEditorStore(i=>i.actions.setSqlGen),$=e.useEditorStore(i=>i.runSql),re=e.useEditorStore(i=>i.actions.setRunSql),se=e.useEditorStore(i=>i.actions.setIsSqlRunning),{data:V,isLoading:J,isFetching:U,isSuccess:oe,isError:ae,error:pe,status:Oe,refetch:le}=e.useQuery({queryKey:[C,S],queryFn:()=>e.postRequest("https://semaphor.cloud/api/v1/query",(a==null?void 0:a.accessToken)||"",{connection_id:L,sql:C,python:S===e.PYTHON_DEFAULT_CODE?"":S,active_filters:F?w:[]}),enabled:!1,retry:!1});b.useEffect(()=>{if(V&&(I(V.records),V.rowLimitExceeded&&e.Jt.error("Row limit (10,000) exceeded. Refine your query.",{position:"top-center",richColors:!0}),R((V==null?void 0:V.output)||""),V.records.length>0)){const{dimensionKeys:i}=e.getKeys(V.records);B(i)}},[V,I,B,R]),b.useEffect(()=>{$&&(le(),re(!1))},[$,le,re]),b.useEffect(()=>{(J||U)&&se(!0),(ae||oe)&&se(!1),ae?(y(pe.message),I([]),B([]),R("")):y("")},[J,U,V,R,ae,oe,se,I,B,y,pe]);function ke(){q(""),I([]),H({}),_(""),N({})}const fe=i=>{s.current=i};function we(){let i=A;A&&!A.includes("{{")&&(i=Ht(A),q(i));const W={...x,lastSelectedSchema:T,lastSelectedDatamodelId:D,lastSelectedDatabase:g,lastSelectedTable:z,connectionId:k,type:E?x.type:"table",sql:i,customCfg:E?x.customCfg:null},je=O.cards.map(ie=>ie.id===x.id?W:ie);M==null||M({...O,cards:je})}function Ae(){K==null||K()}function ge(i){const W=getComputedStyle(document.documentElement).getPropertyValue(i);return Re(W)}function Re(i){const[W,je,ie]=i.split(" "),P=parseFloat(W),ct=parseFloat(je),xt=parseFloat(ie),ut=ct/100,qe=xt/100,ne=(1-Math.abs(2*qe-1))*ut,ce=ne*(1-Math.abs(P/60%2-1)),De=qe-ne/2;let Y=0,X=0,Z=0;0<=P&&P<60?(Y=ne,X=ce,Z=0):60<=P&&P<120?(Y=ce,X=ne,Z=0):120<=P&&P<180?(Y=0,X=ne,Z=ce):180<=P&&P<240?(Y=0,X=ce,Z=ne):240<=P&&P<300?(Y=ce,X=0,Z=ne):300<=P&&P<360&&(Y=ne,X=0,Z=ce),Y=Math.round((Y+De)*255),X=Math.round((X+De)*255),Z=Math.round((Z+De)*255);const Te=dt=>{const Ie=dt.toString(16);return Ie.length==1?"0"+Ie:Ie};return`#${Te(Y)}${Te(X)}${Te(Z)}`}b.useEffect(()=>{const i=n.current,W=s.current;if(i){const je=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",ie=v==="system"?je:v;i.editor.defineTheme("default",{base:ie==="light"?"vs":"vs-dark",inherit:!0,rules:[],colors:{"editor.background":ie==="light"?"#ffffff":ge("--semaphor-background")}}),i.editor.setTheme("default")}return W&&i&&W.addCommand(i.KeyMod.Shift|i.KeyCode.Enter,function(){return console.log("Executing query..."),le(),!1}),()=>{}},[t,v,n.current]);function he(i){n.current=i}function be(){return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[u&&e.jsxRuntimeExports.jsx("div",{className:"xbg-yellow-100 relative flex w-1/3 min-w-0 grow overflow-hidden border-l p-1 text-xs",role:"editor-filter-container",children:e.jsxRuntimeExports.jsxs("div",{className:"w-[99%]",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2 pt-3",children:[e.jsxRuntimeExports.jsx($t,{checked:F,onCheckedChange:()=>te(!F),text:"Apply Filters"}),e.jsxRuntimeExports.jsx(Gt,{}),w&&u&&e.jsxRuntimeExports.jsx(e.Cross2Icon,{onClick:()=>d(!1),className:"bg-background/50 text-foreground/50 hover:cursor-pointer hover:text-foreground"})]}),e.jsxRuntimeExports.jsx(e.Ft,{theme:"default",onChange:i=>{if(i)try{JSON.parse(i),G(JSON.parse(i))}catch{}},defaultLanguage:"json",className:"mt-1 min-h-[220px]",value:JSON.stringify(w,null,2),options:{readOnly:!0,minimap:{enabled:!1},lineNumbers:"off",glyphMargin:!1,wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:12,renderLineHighlight:"none"}})]})}),w&&!u&&e.jsxRuntimeExports.jsx(Pe,{onClick:()=>d(!0),className:e.cn("absolute bottom-4 right-6 h-3 w-3 text-foreground/50 hover:cursor-pointer hover:text-foreground",{"font-bold text-red-800":F})})]})}function Se(){return e.jsxRuntimeExports.jsxs(e.ResizablePanelGroup,{className:"flex grow pb-1",direction:"vertical",role:"editor-resizable-group",children:[e.jsxRuntimeExports.jsxs(e.ResizablePanel,{id:"1",order:1,defaultSize:r?20:100,className:"relative flex grow",children:[e.jsxRuntimeExports.jsx("div",{role:"sql-container",className:"relative flex w-[99%]",children:e.jsxRuntimeExports.jsx(e.Ft,{theme:"default",className:"pt-3",onChange:i=>{q(i)},value:A,options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"sql",beforeMount:he,onMount:fe})}),r&&e.jsxRuntimeExports.jsx("code",{className:"absolute right-6 top-3 text-sm text-muted-foreground/70",children:"sql"})]}),r&&e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(e.ResizableHandle,{withHandle:!0,className:"border"}),e.jsxRuntimeExports.jsxs(e.ResizablePanel,{id:"2",order:2,defaultSize:80,className:"relative flex grow",children:[e.jsxRuntimeExports.jsx("div",{role:"python-container",className:"relative flex w-[99%] pt-0",children:e.jsxRuntimeExports.jsx(e.Ft,{className:"pt-3",theme:"default",onChange:i=>{Q(i&&i.trim()||"")},value:S||e.PYTHON_DEFAULT_CODE,options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"python",beforeMount:he,onMount:fe})}),e.jsxRuntimeExports.jsx("code",{className:"absolute right-6 top-3 text-sm text-muted-foreground/70",children:"python"})]})]})]})}return e.jsxRuntimeExports.jsxs("section",{role:"editor-section",className:"flex grow flex-col justify-end",children:[e.jsxRuntimeExports.jsxs("div",{role:"sql-editor",className:"relative flex grow justify-between overflow-y-scroll",children:[Se(),be()]}),e.jsxRuntimeExports.jsxs("div",{role:"editor-controls",className:"item-center flex flex-wrap justify-between gap-2 px-6 py-4",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex grow items-center gap-2",children:[e.jsxRuntimeExports.jsxs(e.Button,{title:"Shift + Enter",disabled:J||U,onClick:()=>{le()},className:"shrink-0",size:"sm",variant:"outline",children:[J||U?e.jsxRuntimeExports.jsx(de,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"}):e.jsxRuntimeExports.jsx(kt,{className:"mr-2 h-4 w-4"}),"Run"]}),ae&&e.jsxRuntimeExports.jsx(Pt,{error:pe.message,setShowAIDialog:l,setTriggerAIRun:f,setUserInputforAI:p}),e.jsxRuntimeExports.jsxs(e.Button,{onClick:ke,className:"",size:"sm",variant:"outline",children:[e.jsxRuntimeExports.jsx(Et,{className:"mr-2 size-4"}),"Clear"]}),e.jsxRuntimeExports.jsx(e.Toggle,{pressed:r,onPressedChange:i=>o(i),className:"",size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(ss,{className:"size-4 text-foreground/70"})}),e.jsxRuntimeExports.jsx(Jt,{open:c,setOpen:l,userInput:h,triggerAIRun:j,setTriggerAIRun:f,setUserInput:i=>p(i)})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-end gap-2",children:[e.jsxRuntimeExports.jsxs(e.Button,{onClick:we,size:"sm",variant:"outline",children:[e.jsxRuntimeExports.jsx(e.Check,{className:"mr-2 size-4 font-bold text-green-600"}),"Accept"]}),e.jsxRuntimeExports.jsxs(e.Button,{onClick:Ae,className:"w-full",size:"sm",variant:"outline",children:[e.jsxRuntimeExports.jsx(e.Cross2Icon,{className:"mr-2 size-4"}),"Close"]})]})]})]})}function rs({data:t}){var d;const[n,s]=b.useState([]),o=Object.keys(t[0]).map(c=>({accessorKey:c,header:({column:l})=>{const h=l.getIsSorted();return e.jsxRuntimeExports.jsx("div",{className:"flex gap-2",children:e.jsxRuntimeExports.jsxs("div",{className:"flex cursor-pointer items-center",onClick:()=>l.toggleSorting(l.getIsSorted()==="asc"),children:[c,h==="asc"?e.jsxRuntimeExports.jsx(e.TriangleUpIcon,{className:"ml-2 h-5 w-5"}):h==="desc"?e.jsxRuntimeExports.jsx(e.TriangleDownIcon,{className:"ml-2 h-5 w-5"}):null]})})}})),u=e.useReactTable({data:t,columns:o,getCoreRowModel:e.getCoreRowModel(),getPaginationRowModel:e.getPaginationRowModel(),onSortingChange:s,getSortedRowModel:e.getSortedRowModel(),manualPagination:!0,state:{sorting:n}});return e.jsxRuntimeExports.jsxs(e.Table$1,{children:[e.jsxRuntimeExports.jsx(e.TableHeader,{children:u.getHeaderGroups().map(c=>e.jsxRuntimeExports.jsx(e.TableRow,{children:c.headers.map(l=>e.jsxRuntimeExports.jsx(e.TableHead,{className:"sticky top-0 bg-muted",children:l.isPlaceholder?null:e.flexRender(l.column.columnDef.header,l.getContext())},l.id))},c.id))}),e.jsxRuntimeExports.jsx(e.TableBody,{children:(d=u.getRowModel().rows)!=null&&d.length?u.getRowModel().rows.map(c=>e.jsxRuntimeExports.jsx(e.TableRow,{className:"whitespace-nowrap py-2","data-state":c.getIsSelected()&&"selected",children:c.getVisibleCells().map(l=>e.jsxRuntimeExports.jsx(e.TableCell,{children:e.flexRender(l.column.columnDef.cell,l.getContext())},l.id))},c.id)):e.jsxRuntimeExports.jsx(e.TableRow,{children:e.jsxRuntimeExports.jsx(e.TableCell,{colSpan:o.length,className:"h-24 text-center",children:"No results."})})})]})}function Xe({showCard:t,className:n,...s}){var c;b.useState(0);const r=e.useDashboardStore(l=>l.themeStyle),o=e.useEditorStore(l=>l.card),u=e.useEditorStore(l=>l.actions.setCard);if(b.useEffect(()=>{},[o.data,o.type,o.cfg,o.customCfg,r,o.preferences]),!o.id)return null;let d;return o.data&&o.data.length>0&&(d=e.createChartConfig({data:o.data,cardType:o.type,cfg:o.cfg,customCfg:o.customCfg,preferences:o.preferences})),e.jsxRuntimeExports.jsxs(e.Card,{role:"editor-visual-card",className:e.cn("relative flex h-full flex-col rounded-none",n),...s,children:[e.jsxRuntimeExports.jsxs(e.CardHeader,{className:"py-4",children:[e.jsxRuntimeExports.jsx(e.Editable,{text:o.title,onSave:l=>u({...o,title:l}),children:e.jsxRuntimeExports.jsx("div",{className:"flex items-center gap-2",children:e.jsxRuntimeExports.jsx(e.CardTitle,{className:"text-base",children:o.title})})},o.title),e.jsxRuntimeExports.jsx(e.Editable,{text:o.description||"",onSave:l=>u({...o,description:l}),children:e.jsxRuntimeExports.jsxs(e.CardDescription,{children:[" ",o.description]})},o.description)]}),e.jsxRuntimeExports.jsxs(e.CardContent,{className:"flex grow flex-col pb-3",children:[o.type!=="table"&&d&&e.jsxRuntimeExports.jsx(e.ChartJsVisual,{cfg:d},JSON.stringify(d)+JSON.stringify(o.preferences)+((c=o==null?void 0:o.preferences)==null?void 0:c.customVisualCode)),o.type==="table"&&o.data&&o.data.length>0&&e.jsxRuntimeExports.jsx(e.$57acba87d6e25586$export$ccf8d8d7bbf3c2cc,{className:"flex min-h-0 flex-1 grow basis-0",children:e.jsxRuntimeExports.jsx(e.TableVisual,{card:o,data:o==null?void 0:o.data})})]})]})}function os(){const[t,n]=b.useState(!1),[s,r]=b.useState(""),[o,u]=b.useState(""),[d,c]=b.useState(""),[l,h]=b.useState(""),p=e.useEditorStore(g=>g.card),j=e.useEditorStore(g=>g.card.customCfg),{setCardCustomCfg:f,setCustomVisualCode:a}=e.useEditorActions();function m(g){var z,A;const D={...g,data:{...g==null?void 0:g.data,datasets:(A=(z=g==null?void 0:g.data)==null?void 0:z.datasets)==null?void 0:A.map(S=>({...S,data:[]}))}};return JSON.stringify(D,null,1)}function x(){var D,T;if(!p.data||p.data.length===0)return;const g=e.createChartConfig({data:p.data,cardType:p.type,cfg:p.cfg,preferences:p.preferences});g&&(r(JSON.stringify(g,null,1)),(D=p==null?void 0:p.preferences)!=null&&D.customVisualCode&&c((T=p==null?void 0:p.preferences)==null?void 0:T.customVisualCode),j&&u(JSON.stringify(j,null,1)))}function v(){if(d&&a(d),!!o)try{const g=JSON.parse(o);return g?(f(g),h(""),u(""),g):void 0}catch(g){console.log(g),h("Invalid JSON")}}function E(){u(""),f(null)}function k(){let g;if(j){const D=e._.cloneDeep(p.cfg),T=e._.merge(D,j);return g=m(T),g}return s?(g=m(JSON.parse(s)),g):""}return e.jsxRuntimeExports.jsxs(e.Dialog,{open:t,onOpenChange:n,children:[e.jsxRuntimeExports.jsx(e.DialogTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.Button,{onClick:x,className:` ${j&&"border-foreground/50 dark:border-foreground/70"}`,size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(e.Settings,{className:"h-4 w-4"})})}),e.jsxRuntimeExports.jsxs(e.DialogContent,{className:"max-h-[70vh] min-h-[70vh] overflow-auto sm:min-w-[900px] lg:min-w-[1200px]",children:[e.jsxRuntimeExports.jsxs(e.DialogHeader,{className:"",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.DialogTitle,{children:"Customize Card"}),e.jsxRuntimeExports.jsxs(e.Tooltip,{children:[e.jsxRuntimeExports.jsx(e.TooltipTrigger,{children:e.jsxRuntimeExports.jsx(bt,{onClick:()=>{navigator.clipboard.writeText(p.id)},className:"size-3 cursor-pointer text-muted-foreground/70 transition-colors hover:text-muted-foreground"})}),e.jsxRuntimeExports.jsx(e.TooltipContent,{side:"right",align:"center",children:e.jsxRuntimeExports.jsx("p",{className:"text-xs",children:"Copy Card ID"})})]})]}),e.jsxRuntimeExports.jsxs(e.DialogDescription,{children:["See the configuration options and documentation",e.jsxRuntimeExports.jsx("a",{target:"_blank",className:"ml-1 text-blue-500 underline",href:"https://www.chartjs.org/docs/latest/samples/bar/vertical.html",children:"here."})]})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex grow gap-2",children:[e.jsxRuntimeExports.jsx(Xe,{className:"w-1/2 rounded shadow-none"}),e.jsxRuntimeExports.jsxs(e.Tabs,{defaultValue:"custom-config",className:"flex w-1/2 flex-col",children:[e.jsxRuntimeExports.jsxs(e.TabsList,{className:"justify-start rounded-sm rounded-b-none border border-b-0",children:[e.jsxRuntimeExports.jsxs(e.TabsTrigger,{value:"custom-config",children:[j&&e.jsxRuntimeExports.jsx(e.CheckIcon,{className:"mr-1 h-5 w-5 text-green-600"}),j?"Custom Config":"Default Config"]}),e.jsxRuntimeExports.jsx(e.TabsTrigger,{className:"",value:"output",children:"Output"}),e.jsxRuntimeExports.jsx(e.TabsTrigger,{className:"",value:"custom-code",children:"Custom Code"})]}),e.jsxRuntimeExports.jsx(e.TabsContent,{className:"bg-red-x mt-0 grow rounded-b border border-t-0 p-2",value:"output",children:e.jsxRuntimeExports.jsx(e.Textarea,{disabled:!0,value:s,className:"h-full resize-none border-none font-mono focus-visible:ring-0 focus-visible:ring-offset-0"})}),e.jsxRuntimeExports.jsx(e.TabsContent,{className:"mt-0 grow rounded-b border border-t-0",value:"custom-config",children:e.jsxRuntimeExports.jsx(e.Ft,{className:"h-full w-full overflow-hidden",theme:"default",options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"json",value:k(),onChange:g=>u(g)})}),e.jsxRuntimeExports.jsx(e.TabsContent,{className:"mt-0 grow rounded-b border border-t-0",value:"custom-code",children:e.jsxRuntimeExports.jsx(e.Ft,{className:"h-full w-full overflow-hidden",theme:"default",options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"javascript",value:d,onChange:g=>c(g||"")})})]})]}),e.jsxRuntimeExports.jsxs(e.DialogFooter,{className:"flex items-center",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"mr-2 text-red-500",children:l}),e.jsxRuntimeExports.jsx(e.Button,{disabled:!j,onClick:E,variant:"outline",children:"Reset"}),e.jsxRuntimeExports.jsx(e.Button,{onClick:v,variant:"outline",children:"Apply"}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>n(!1),variant:"outline",children:"Close"})]})]})]})}function Ze(t){return ee({tag:"svg",attr:{viewBox:"0 0 1024 1024"},child:[{tag:"path",attr:{d:"M926.8 397.1l-396-288a31.81 31.81 0 0 0-37.6 0l-396 288a31.99 31.99 0 0 0-11.6 35.8l151.3 466a32 32 0 0 0 30.4 22.1h489.5c13.9 0 26.1-8.9 30.4-22.1l151.3-466c4.2-13.2-.5-27.6-11.7-35.8zM838.6 417l-98.5 32-200-144.7V199.9L838.6 417zM466 567.2l-89.1 122.3-55.2-169.2L466 567.2zm-116.3-96.8L484 373.3v140.8l-134.3-43.7zM512 599.2l93.9 128.9H418.1L512 599.2zm28.1-225.9l134.2 97.1L540.1 514V373.3zM558 567.2l144.3-46.9-55.2 169.2L558 567.2zm-74-367.3v104.4L283.9 449l-98.5-32L484 199.9zM169.3 470.8l86.5 28.1 80.4 246.4-53.8 73.9-113.1-348.4zM327.1 853l50.3-69h269.3l50.3 69H327.1zm414.5-33.8l-53.8-73.9 80.4-246.4 86.5-28.1-113.1 348.4z"},child:[]}]})(t)}function et(t){return ee({tag:"svg",attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M137.39,24.06A16,16,0,0,0,120,40V80.67a15.86,15.86,0,0,0,13.25,15.76A32,32,0,1,1,96,129.68c-.41-8.22,1.27-15,5-20.26h0a15.86,15.86,0,0,0-1.69-20.47L71.69,60.68a16,16,0,0,0-23.63,1.1A103.6,103.6,0,0,0,55,202.05,103.24,103.24,0,0,0,128,232h1.49A104.3,104.3,0,0,0,232,129.48C232.75,75.18,191.19,28.88,137.39,24.06ZM60.32,71.94l27.61,28.19,0,.06A43.29,43.29,0,0,0,80.44,120H40.36A87.13,87.13,0,0,1,60.32,71.94ZM40.37,136h40.3A48,48,0,0,0,120,175.34v40.3A88,88,0,0,1,40.37,136Zm149.77,54.14A87.45,87.45,0,0,1,136,215.61V175.34a47.55,47.55,0,0,0,24.73-12.23A48,48,0,0,0,136,80.66L136,40c45.52,4.08,80.67,43.28,80,89.25A87.45,87.45,0,0,1,190.14,190.14Z"},child:[]}]})(t)}function tt(t){return ee({tag:"svg",attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm87.63,96H191.48A64.1,64.1,0,0,0,136,64.52V40.37A88.13,88.13,0,0,1,215.63,120ZM120,120H80.68A48.09,48.09,0,0,1,120,80.68Zm0,16v39.32A48.09,48.09,0,0,1,80.68,136Zm16,0h39.32A48.09,48.09,0,0,1,136,175.32Zm0-16V80.68A48.09,48.09,0,0,1,175.32,120ZM120,40.37V64.52A64.1,64.1,0,0,0,64.52,120H40.37A88.13,88.13,0,0,1,120,40.37ZM40.37,136H64.52A64.1,64.1,0,0,0,120,191.48v24.15A88.13,88.13,0,0,1,40.37,136ZM136,215.63V191.48A64.1,64.1,0,0,0,191.48,136h24.15A88.13,88.13,0,0,1,136,215.63Z"},child:[]}]})(t)}function st(t){return ee({tag:"svg",attr:{viewBox:"0 0 24 24",strokeWidth:"2",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},child:[]},{tag:"path",attr:{d:"M6 16m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"},child:[]},{tag:"path",attr:{d:"M16 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"},child:[]},{tag:"path",attr:{d:"M14.5 7.5m-4.5 0a4.5 4.5 0 1 0 9 0a4.5 4.5 0 1 0 -9 0"},child:[]}]})(t)}function nt(t){return ee({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"m2 19.99 7.5-7.51 4 4 7.09-7.97L22 9.92l-8.5 9.56-4-4-6 6.01-1.5-1.5zm1.5-4.5 6-6.01 4 4L22 3.92l-1.41-1.41-7.09 7.97-4-4L2 13.99l1.5 1.5z"},child:[]}]})(t)}function rt(t){return ee({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M4 9h4v11H4zM4 4h4v4H4zM10 7h4v4h-4zM16 10h4v4h-4zM16 15h4v5h-4zM10 12h4v8h-4z"},child:[]}]})(t)}function ot(t){return ee({tag:"svg",attr:{version:"1.2",baseProfile:"tiny",viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M4 18c-.552 0-1-.448-1-1v-6.382l-.553.276c-.495.248-1.095.046-1.342-.447-.247-.494-.046-1.094.448-1.342l2-1c.31-.155.678-.139.973.044.294.183.474.504.474.851v8c0 .552-.448 1-1 1zM13 18h-5c-.404 0-.769-.244-.924-.617-.155-.374-.069-.804.217-1.09l4-4c.254-.254.394-.591.394-.95 0-.358-.14-.695-.394-.949-.508-.508-1.39-.508-1.9.001-.253.252-.393.589-.393.948 0 .552-.448 1-1 1s-1-.448-1-1c0-.894.348-1.733.98-2.364 1.265-1.263 3.464-1.263 4.727.001.632.631.979 1.471.979 2.363 0 .893-.348 1.733-.979 2.364l-2.293 2.293h2.586c.552 0 1 .448 1 1s-.448 1-1 1zM20.955 12.377c.338-.457.545-1.016.545-1.627 0-1.517-1.234-2.75-2.75-2.75-1.031 0-1.966.569-2.44 1.484-.254.49-.063 1.094.428 1.348.49.254 1.094.062 1.348-.428.128-.249.383-.404.664-.404.414 0 .75.336.75.75s-.336.75-.75.75c-.552 0-1 .448-1 1s.448 1 1 1c.689 0 1.25.561 1.25 1.25s-.561 1.25-1.25 1.25-1.25-.561-1.25-1.25c0-.552-.448-1-1-1s-1 .448-1 1c0 1.792 1.458 3.25 3.25 3.25s3.25-1.458 3.25-3.25c0-.939-.406-1.779-1.045-2.373z"},child:[]}]})(t)}function it(t){return ee({tag:"svg",attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M217 25v14h78V25h-78zm0 32v46h14V71h50v32h14V57h-78zm32 32v14h14V89h-14zm-64 32v46h30v-46h-30zm48 0v14h46v-14h-46zm64 0v46h30v-46h-30zm-64 32v14h46v-14h-46zm-80 32v46h62v-46h-62zm80 0v14h46v-14h-46zm64 0v46h62v-46h-62zm-64 32v14h46v-14h-46zm-112 32v46h94v-46h-94zm112 0v14h46v-14h-46zm64 0v46h94v-46h-94zm-64 32v14h46v-14h-46zM89 313v46h126v-46H89zm144 0v14h46v-14h-46zm64 0v46h126v-46H297zm-64 32v14h46v-14h-46zM57 377v46h158v-46H57zm176 0v14h46v-14h-46zm64 0v46h158v-46H297zm-64 32v14h46v-14h-46zM25 441v46h190v-46H25zm208 0v14h46v-14h-46zm64 0v46h190v-46H297zm-64 32v14h46v-14h-46z"},child:[]}]})(t)}function is(){const[t,n]=b.useState(!1),s=e.useEditorStore(l=>l.card.type),{setCardType:r,setCardPreferences:o,setChartOrientation:u}=e.useEditorStore(l=>l.actions),d=e.useEditorStore(l=>l.actions.setCardCustomCfg);function c(l){d(null),o({}),r(l),n(!1)}return e.jsxRuntimeExports.jsxs(e.Popover,{open:t,onOpenChange:n,children:[e.jsxRuntimeExports.jsx(e.PopoverTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.Button,{size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(as,{className:"h-4 w-4",chartType:s})})}),e.jsxRuntimeExports.jsx(e.PopoverContent,{className:"w-50",children:e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 place-items-center",children:[e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>c("bar"),className:"font-normal",variant:"ghost",children:e.jsxRuntimeExports.jsx(ze,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>c("line"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Le,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>c("stackedBar"),variant:"ghost",children:e.jsxRuntimeExports.jsx(rt,{className:"size-5",strokeWidth:0})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>c("stackedLine"),variant:"ghost",children:e.jsxRuntimeExports.jsx(nt,{className:"size-5",strokeWidth:0})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>c("scatter"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Qe,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>c("bubble"),variant:"ghost",children:e.jsxRuntimeExports.jsx(st,{className:"size-4"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>c("pie"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ge,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>c("doughnut"),variant:"ghost",children:e.jsxRuntimeExports.jsx(et,{className:"size-5",strokeWidth:1})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>c("radar"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ze,{className:"size-5 font-extralight",strokeWidth:.5})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>c("polarArea"),variant:"ghost",children:e.jsxRuntimeExports.jsx(tt,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>c("pyramid"),variant:"ghost",children:e.jsxRuntimeExports.jsx(it,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>c("range"),variant:"ghost",children:e.jsxRuntimeExports.jsx($e,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>c("table"),variant:"ghost",children:e.jsxRuntimeExports.jsx(e.Table,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>c("kpi"),variant:"ghost",children:e.jsxRuntimeExports.jsx(ot,{className:"size-6"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>c("text"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Fe,{className:"size-4"})})]})})]})}function as({chartType:t,className:n}){switch(t){case"bar":return e.jsxRuntimeExports.jsx(ze,{className:n});case"line":return e.jsxRuntimeExports.jsx(Le,{className:n});case"pie":return e.jsxRuntimeExports.jsx(Ge,{className:n});case"radar":return e.jsxRuntimeExports.jsx(Ze,{className:n});case"scatter":return e.jsxRuntimeExports.jsx(Qe,{className:n});case"bubble":return e.jsxRuntimeExports.jsx(st,{className:n});case"doughnut":return e.jsxRuntimeExports.jsx(et,{className:n});case"stackedBar":return e.jsxRuntimeExports.jsx(rt,{className:"size-4 text-foreground/70"});case"stackedLine":return e.jsxRuntimeExports.jsx(nt,{className:"size-4 text-foreground/70"});case"polarArea":return e.jsxRuntimeExports.jsx(tt,{className:n});case"pyramid":return e.jsxRuntimeExports.jsx(it,{className:n});case"range":return e.jsxRuntimeExports.jsx($e,{className:n});case"kpi":return e.jsxRuntimeExports.jsx(ot,{className:n});case"text":return e.jsxRuntimeExports.jsx(Fe,{className:n});default:return e.jsxRuntimeExports.jsx(e.Table,{className:n})}}function _e(){const t=e.useEditorStore(x=>x.frame),n=e.useEditorStore(x=>x.card),s=e.useEditorStore(x=>x.card.data),r=e.useEditorStore(x=>x.isShowingVisual),o=e.useEditorStore(x=>x.isSqlRunning),u=e.useEditorStore(x=>x.queryError),d=e.useEditorStore(x=>x.pythonStdOut),c=e.useEditorStore(x=>x.actions.setRunSql);e.useEditorStore(x=>x.onSave),e.useEditorStore(x=>x.onClose),e.useEditorStore(x=>x.actions.setCardSql),e.useEditorStore(x=>x.actions.setCardType),e.useEditorStore(x=>x.actions.setSqlGen);const{setFrame:l,setCard:h,updateCardInFrame:p}=e.useEditorActions();if(!n)return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:"No Active Card"});function j(){const x={id:e.v4(),title:"Title",description:"Description",preferences:{onClickFilter:[{columnIndex:0,expression:""}]},type:"bar",sql:"",data:[]},v={...t,cards:[...t.cards,x],activeCardId:x.id};l(v),h(x)}function f(x){const v=t.cards.filter(g=>g.id!==x),E=v[0],k={...t,cards:v,activeCardId:E.id};l(k),h(E)}function a(x){const v={...t,cards:t.cards.map(k=>k.id===n.id?n:k),activeCardId:x};l(v);const E=v.cards.find(k=>k.id===x);h(E),E.sql&&E.data&&E.data.length===0&&c(!0)}function m(){return n.type==="kpi"?e.jsxRuntimeExports.jsx("div",{className:"flex grow items-center justify-center",children:e.jsxRuntimeExports.jsx("div",{className:"w-1/2 rounded-md border",children:e.jsxRuntimeExports.jsx(e.KPICard,{isLoading:o,card:n})})}):n.type==="text"?e.jsxRuntimeExports.jsx("div",{className:"flex grow items-center justify-center",children:e.jsxRuntimeExports.jsx("div",{className:"w-1/2 rounded-md border",children:e.jsxRuntimeExports.jsx(e.TextCard,{isLoading:o,card:n})})}):e.jsxRuntimeExports.jsxs(e.Tabs,{onValueChange:a,value:t.activeCardId,className:"flex grow flex-col pb-3",children:[t.cards.map(x=>e.jsxRuntimeExports.jsx(e.TabsContent,{className:"mt-0 grow",value:x.id,children:e.jsxRuntimeExports.jsx(Xe,{showCard:x,className:"grow border-none shadow-none"})},x.id)),e.jsxRuntimeExports.jsxs(e.TabsList,{className:"mx-6 flex justify-start",children:[t.cards.map(x=>e.jsxRuntimeExports.jsx(e.Editable,{text:x.tabTitle||x.title,onSave:v=>{h({...n,tabTitle:v}),p({...n,tabTitle:v})},children:e.jsxRuntimeExports.jsxs(e.TabsTrigger,{className:"",value:x.id,children:[x.tabTitle||x.title,t.activeCardId===x.id&&t.cards.length>1&&e.jsxRuntimeExports.jsx(e.X,{className:"ml-2 size-3.5 text-muted-foreground hover:text-foreground",onClick:()=>f(x.id)})]})},x.id)),e.jsxRuntimeExports.jsx(e.Button,{className:"ml-1 h-8 px-2 hover:bg-muted-foreground/50",variant:"outline",onClick:j,children:e.jsxRuntimeExports.jsx(e.Plus,{className:"h-4 w-4"})})]})]})}return e.jsxRuntimeExports.jsxs("div",{className:"relative flex h-full flex-col pt-3",children:[o&&e.jsxRuntimeExports.jsx(de,{className:"absolute bottom-0 left-0 right-0 top-0 z-10 m-auto h-10 w-10 animate-spin text-foreground/10"}),e.jsxRuntimeExports.jsxs("div",{className:"mb-0 flex min-h-10 items-center justify-end gap-2 px-6",children:[r&&e.jsxRuntimeExports.jsxs("div",{className:"flex grow items-center gap-2",children:[e.jsxRuntimeExports.jsx(is,{}),n.type!=="table"&&e.jsxRuntimeExports.jsx(os,{})]}),e.jsxRuntimeExports.jsx(cs,{})]}),r?m():e.jsxRuntimeExports.jsxs("div",{className:"flex min-h-0 w-full flex-1 grow basis-0 px-6",children:[d&&e.jsxRuntimeExports.jsx(ls,{}),n.data&&n.data.length>0&&e.jsxRuntimeExports.jsx(rs,{data:s||[]}),u&&e.jsxRuntimeExports.jsx("span",{className:"font-mono text-sm",children:u})]})]})}function ls(){const t=e.useEditorStore(s=>s.pythonStdOut);if(!t)return null;const n=t.replace(/\n/g,"<br>");return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx("p",{className:"font-mono text-sm",children:"Output:"}),e.jsxRuntimeExports.jsx("div",{dangerouslySetInnerHTML:{__html:n},className:"bg-muted p-2 font-mono text-sm"}),e.jsxRuntimeExports.jsx(e.Separator,{className:"mb-2"})]})}function cs(){const t=e.useEditorStore(s=>s.isShowingVisual),n=e.useEditorStore(s=>s.actions.setIsShowingVisual);return e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.Label,{htmlFor:"visualize",children:"Chart"}),e.jsxRuntimeExports.jsx(e.Switch,{checked:t,onCheckedChange:()=>n(!t),id:"visualize",className:"data-[state=checked]:bg-foreground/50"})]})}function me(){const[t,n]=b.useState([]);e.useEditorStore(p=>p.card.cfg);const s=e.useEditorStore(p=>p.card.preferences),{setCardCfg:r,setFilterOnClickColumnIndex:o,setCardPreferences:u}=e.useEditorStore(p=>p.actions),d=e.useEditorStore(p=>p.queryResultColumns);e.useEditorStore(p=>{var j;return(j=p.card.preferences)==null?void 0:j.filterOnClickColumnIndex}),b.useEffect(()=>{d&&n(new Array(d.length).fill(!1))},[d]);function c(p,j){var f,a;j?s!=null&&s.onClickFilter&&((f=s==null?void 0:s.onClickFilter)==null?void 0:f.length)>0?u({...s,onClickFilter:[...s.onClickFilter,{columnIndex:p,expression:""}]}):u({...s,onClickFilter:[{columnIndex:p,expression:""}]}):(u({...s,onClickFilter:(a=s==null?void 0:s.onClickFilter)==null?void 0:a.filter(m=>m.columnIndex!==p)}),n(m=>{const x=[...m];return x[p]=!1,x}))}function l(p,j){var a;const f=(a=s==null?void 0:s.onClickFilter)==null?void 0:a.map(m=>m.columnIndex===p?{...m,expression:j.target.value}:m);u({...s,onClickFilter:f})}function h(p){var j,f,a,m;if(t!=null&&t[p]||(f=(j=s==null?void 0:s.onClickFilter)==null?void 0:j.find(x=>x.columnIndex===p))!=null&&f.expression)return e.jsxRuntimeExports.jsx(e.Input,{value:(m=(a=s==null?void 0:s.onClickFilter)==null?void 0:a.find(x=>x.columnIndex===p))==null?void 0:m.expression,onChange:x=>l(p,x),type:"text",className:" h-9 w-full focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0 font-mono text-xs",placeholder:"Expression"})}return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:d==null?void 0:d.map((p,j)=>{var f,a;return e.jsxRuntimeExports.jsx("div",{className:"flex items-center justify-between space-y-2 xbg-red-100 group",children:e.jsxRuntimeExports.jsxs("div",{className:" grow",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center py-2 space-x-2",children:[e.jsxRuntimeExports.jsx(e.Checkbox,{checked:!!((f=s==null?void 0:s.onClickFilter)!=null&&f.find(m=>m.columnIndex===j)),onCheckedChange:m=>c(j,m)}),e.jsxRuntimeExports.jsx("label",{className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:p}),e.jsxRuntimeExports.jsx("div",{className:"flex gap-2 items-center ",children:((a=s==null?void 0:s.onClickFilter)==null?void 0:a.find(m=>m.columnIndex===j))&&e.jsxRuntimeExports.jsx(Ke,{onClick:()=>{n(m=>{const x=[...m];return x[j]=!m[j],x})},className:" invisible group-hover:visible size-3 text-gray-400 cursor-pointer"})})]}),h(j)]})},p)})})}function Ne(){var d,c,l;const t=e.useEditorStore(h=>h.card.preferences),n=e.useEditorStore(h=>h.card.cfg),{setCardCfg:s,setCardPreferences:r,setChartOrientation:o}=e.useEditorStore(h=>h.actions);(d=n==null?void 0:n.options)!=null&&d.indexAxis;function u(h){o(h)}return e.jsxRuntimeExports.jsxs(e.RadioGroup,{value:((c=t==null?void 0:t.chartOptions)==null?void 0:c.indexAxis)||((l=n==null?void 0:n.options)==null?void 0:l.indexAxis)||"x",onValueChange:u,className:"flex gap-3",defaultValue:"x",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:"x",id:"r1"}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r1",children:"Vertical"})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:"y",id:"r2"}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r2",children:"Horizontal"})]})]})}const xe="focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0";function He(t,n){var r,o,u;const s=e.getNumberAxis(t,n);return((u=(o=(r=t==null?void 0:t.chartOptions)==null?void 0:r.scales)==null?void 0:o[s])==null?void 0:u.type)||"linear"}function at(){var _,B,G,q,Q,y;const[t,n]=b.useState(!1),s=e.useEditorStore(R=>{var N;return(N=R.card)==null?void 0:N.preferences}),r=e.useEditorStore(R=>{var N;return(N=R.card)==null?void 0:N.cfg}),o=e.getNumberAxis(s,r),[u,d]=b.useState(He(s)),[c,l]=b.useState(((G=(B=(_=s==null?void 0:s.chartOptions)==null?void 0:_.scales)==null?void 0:B[o])==null?void 0:G.min)||""),[h,p]=b.useState(((y=(Q=(q=s==null?void 0:s.chartOptions)==null?void 0:q.scales)==null?void 0:Q[o])==null?void 0:y.max)||""),[j,f]=b.useState(c||h?"custom":"auto"),[a,m]=b.useState(""),[x,v]=b.useState(0),[E,k]=b.useState(""),[g,D]=b.useState(""),[T,z]=b.useState(""),A=e.useEditorStore(R=>R.actions.setCardPreferences),S=e.useEditorStore(R=>{var N;return(N=R.card)==null?void 0:N.type}),C=["pie","doughnut","polarArea"].includes(S);b.useEffect(()=>{var R,N,M,te,K,I,H,$,re,se,V,J,U,oe;d(He(s)),l(((M=(N=(R=s==null?void 0:s.chartOptions)==null?void 0:R.scales)==null?void 0:N[o])==null?void 0:M.min)===0?0:""),p(((I=(K=(te=s==null?void 0:s.chartOptions)==null?void 0:te.scales)==null?void 0:K[o])==null?void 0:I.max)||""),m(((se=(re=($=(H=s==null?void 0:s.chartOptions)==null?void 0:H.scales)==null?void 0:$[o])==null?void 0:re.ticks)==null?void 0:se.stepSize)||""),v(((V=s==null?void 0:s.numberAxisFormat)==null?void 0:V.decimalPlaces)||0),k(((J=s==null?void 0:s.numberAxisFormat)==null?void 0:J.suffix)||""),D(((U=s==null?void 0:s.numberAxisFormat)==null?void 0:U.currency)||""),z(((oe=s==null?void 0:s.numberAxisFormat)==null?void 0:oe.locale)||"")},[t,s,o]);function L(R,N){return N===""||/^[0-9\b]+$/.test(N)?Number(N):Number(R)}function O(){return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-6 items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"col-span-2 hover:cursor-pointer hover:underline",htmlFor:"currency",children:e.jsxRuntimeExports.jsx("a",{target:"_blank",href:"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat",children:"Currency"})}),e.jsxRuntimeExports.jsx(e.Input,{value:g,placeholder:"USD",onChange:R=>D(R.target.value),id:"currency",className:`col-span-2 h-8 w-full ${xe}`}),e.jsxRuntimeExports.jsx(e.Input,{value:T,placeholder:"en-US",onChange:R=>z(R.target.value),id:"locale",className:`col-span-2 h-8 w-full ${xe}`})]}),e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-9 items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"col-span-3",htmlFor:"format",children:"Decimals"}),e.jsxRuntimeExports.jsx(e.Input,{value:x,onChange:R=>v(Number(R.target.value)),id:"format",className:`col-span-6 h-8 w-full tracking-wide ${xe}`})]})]})}function w(){return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Label,{htmlFor:"range",children:"Range"}),e.jsxRuntimeExports.jsx(e.Input,{id:"min",value:c,onChange:R=>l(N=>L(N,R.target.value)),className:`col-span-1 h-8 w-full ${xe}`}),e.jsxRuntimeExports.jsx(e.Input,{value:h,onChange:R=>p(N=>L(N,R.target.value)),id:"max",className:`col-span-1 h-8 w-full ${xe}`})]}),e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Label,{htmlFor:"step-size",children:"Step Size"}),e.jsxRuntimeExports.jsx(e.Input,{value:a,onChange:R=>m(N=>L(N,R.target.value)),id:"step-size",className:`col-span-1 h-8 w-full ${xe}`})]})]})}function F(){var M;let R={};j==="custom"&&(R={min:c,max:h,ticks:{stepSize:a}});const N={...s||{},chartOptions:{...s==null?void 0:s.chartOptions,scales:{...(M=s==null?void 0:s.chartOptions)==null?void 0:M.scales,[o]:{type:u,...u==="linear"?R:{}}}},numberAxisFormat:{decimalPlaces:x,suffix:E,currency:g,locale:T}};console.log(N),A(N)}return e.jsxRuntimeExports.jsxs(e.Popover,{onOpenChange:R=>n(R),children:[e.jsxRuntimeExports.jsx(e.PopoverTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.SliderIcon,{className:"size-4 cursor-pointer text-muted-foreground hover:text-foreground"})}),e.jsxRuntimeExports.jsx(e.PopoverContent,{align:"center",className:"max-w-65",children:e.jsxRuntimeExports.jsxs("div",{className:"grid gap-4",children:[e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsx("h4",{className:"font-medium leading-none",children:"Scale Options"}),e.jsxRuntimeExports.jsx("p",{className:"text-sm text-muted-foreground",children:"Set the scale for the number axis"})]}),e.jsxRuntimeExports.jsxs("div",{className:"grid gap-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Label,{htmlFor:"scale",children:"Type"}),e.jsxRuntimeExports.jsxs(e.Select,{disabled:C,value:u,onValueChange:R=>d(R),children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:"col-span-2 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsxRuntimeExports.jsx(e.SelectValue,{})}),e.jsxRuntimeExports.jsx(e.SelectContent,{id:"type",children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[e.jsxRuntimeExports.jsx(e.SelectLabel,{children:"Option"}),e.jsxRuntimeExports.jsx(e.SelectItem,{value:"linear",children:"Linear"}),e.jsxRuntimeExports.jsx(e.SelectItem,{value:"logarithmic",children:"Logarithmic"})]})})]})]}),u=="linear"&&e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 items-center gap-2 py-1",children:[e.jsxRuntimeExports.jsx(e.Label,{htmlFor:"scale-option",children:"Setup"}),e.jsxRuntimeExports.jsxs(e.RadioGroup,{disabled:C,id:"scale-option",value:j,onValueChange:R=>f(R),className:"col-span-2 flex gap-3",defaultValue:"x",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:"auto",id:"r1"}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r1",children:"Auto"})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:"custom",id:"r2"}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r2",children:"Custom"})]})]})]}),j==="custom"&&u=="linear"&&w(),O(),e.jsxRuntimeExports.jsx(e.SelectSeparator,{}),e.jsxRuntimeExports.jsx("div",{className:"grid grid-cols-3",children:e.jsxRuntimeExports.jsx(e.Button,{onClick:F,variant:"secondary",className:"col-span-1 col-start-3 h-8 w-full",children:"Apply"})})]})]})})]})}function xs({idx:t}){var c;const n=e.useEditorStore(l=>{var h;return(h=l.card)==null?void 0:h.preferences}),s=e.useEditorStore(l=>{var h;return(h=l.card.preferences)==null?void 0:h.datasetOptions}),r=e.useEditorStore(l=>l.actions.setCardPreferences),o=(c=n==null?void 0:n.chartOptions)==null?void 0:c.indexAxis,u=s==null?void 0:s.find(l=>l.idx===t);function d(l,h){(l==="end"||l==="start")&&e.getContrastColor(e.getCanvasBackgroundColor());const p={display:l!=="none",align:l,anchor:l,clamp:!0};if(!u)r({...n,datasetOptions:[...s||[],{idx:h,datalabels:p}]});else{const j={...u};j.datalabels=p;const f=s==null?void 0:s.map(a=>a.idx===h?j:a);r({...n,datasetOptions:f})}}return e.jsxRuntimeExports.jsxs(e.Popover,{children:[e.jsxRuntimeExports.jsx(e.PopoverTrigger,{children:e.jsxRuntimeExports.jsx(zt,{className:"invisible size-4 rotate-[135deg] cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"})}),e.jsxRuntimeExports.jsx(e.PopoverContent,{className:"w-fit p-1",children:e.jsxRuntimeExports.jsxs("div",{className:"flex gap-1",children:[e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>d("none",t),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsxRuntimeExports.jsx(e.X,{className:"size-4"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>d("start",t),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsxRuntimeExports.jsx(St,{className:e.cn("h-4 w-4",{"rotate-90":o==="y"})})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>d("center",t),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsxRuntimeExports.jsx(vt,{className:e.cn("h-4 w-4",{"rotate-90":o==="y"})})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>d("end",t),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsxRuntimeExports.jsx(yt,{className:e.cn("h-4 w-4",{"rotate-90":o==="y"})})})]})})]})}function lt(){const t=e.useEditorStore(l=>l.card),n=e.useEditorStore(l=>{var h,p,j;return(j=(p=(h=l==null?void 0:l.card)==null?void 0:h.preferences)==null?void 0:p.chartOptions)==null?void 0:j.indexAxis}),s=n==="y"?"Y axis":"X axis",r=n==="y"?"X axis":"Y axis",{keys:o,metricKeys:u,dimensionKeys:d}=e.getKeys(t.data||[]);let c=u;if(["stackedBar","stackedLine"].includes(t.type)){const l=e.pivotData({dataArray:t.data||[],groupKey:d[0],pivotKey:d[1],valueKey:c[0]}),{metricKeys:h}=e.getKeys(l);c=h}return o.length===0?null:e.jsxRuntimeExports.jsxs("div",{className:"space-y-4",children:[e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsx(e.Label,{children:s}),e.jsxRuntimeExports.jsx("div",{className:"my-1 space-y-1",children:e.jsxRuntimeExports.jsx("div",{className:"rounded-md bg-muted/70 px-2 py-1 hover:bg-muted",children:e.jsxRuntimeExports.jsx("p",{children:d[0]})})})]}),e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center justify-between gap-5",children:[e.jsxRuntimeExports.jsx(e.Label,{children:r}),e.jsxRuntimeExports.jsx(at,{})]}),e.jsxRuntimeExports.jsx("div",{className:"my-1 space-y-1",children:c.map((l,h)=>e.jsxRuntimeExports.jsx(us,{col:l,idx:h},l))})]})]})}function us({col:t,idx:n}){const s=e.useEditorStore(c=>{var l;return(l=c.card)==null?void 0:l.preferences}),r=e.useEditorStore(c=>{var l;return(l=c.card.preferences)==null?void 0:l.datasetOptions}),o=r==null?void 0:r.find(c=>c.idx===n),{setCardPreferences:u}=e.useEditorStore(c=>c.actions);function d(c){if(!o)u({...s,datasetOptions:[...r||[],{idx:n,type:c==="area"?"line":c,fill:c==="area"?"origin":""}]});else{const l={...o};l.type=c==="area"?"line":c,l.fill=c==="area"?"origin":"";const h=r==null?void 0:r.map(p=>p.idx===n?l:p);u({...s,datasetOptions:h})}}return e.jsxRuntimeExports.jsxs("div",{className:"group flex items-center justify-between gap-5 rounded-md bg-muted/70 px-2 py-1 hover:bg-muted",children:[e.jsxRuntimeExports.jsx("p",{children:t}),e.jsxRuntimeExports.jsxs("div",{className:"flex gap-2",children:[e.jsxRuntimeExports.jsx(ze,{onClick:()=>d("bar"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsxRuntimeExports.jsx(Le,{onClick:()=>d("line"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsxRuntimeExports.jsx(mt,{onClick:()=>d("area"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsxRuntimeExports.jsx(e.Separator,{orientation:"vertical",className:"invisible size-4 cursor-pointer py-2 text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsxRuntimeExports.jsx(xs,{idx:n})]})]})}function ds({cardType:t}){return e.jsxRuntimeExports.jsx("div",{className:"space-y-6 px-6 py-2",children:e.jsxRuntimeExports.jsxs(e.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:`${e.titleCase(t)} Chart`}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 font-mono text-xs",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT x-axis, y-axis-1, y-axis-2,... FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"x-axis - category"}),e.jsxRuntimeExports.jsx("li",{children:"y-axis1 - number"}),e.jsxRuntimeExports.jsx("li",{children:"y-axis2 - number"})]}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:n=>n.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#line-chart",children:"example"})," in the docs."]})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-2",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Settings"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 px-2",children:[e.jsxRuntimeExports.jsx(Ne,{}),e.jsxRuntimeExports.jsx(lt,{})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filter on click"}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:"px-2",children:e.jsxRuntimeExports.jsx(me,{})})]})]})})}function Me(){var o,u,d;const t=e.useEditorStore(c=>c.card.cfg),n=e.useEditorStore(c=>c.actions.setCardCfg),s=e.useEditorStore(c=>c.card.type);function r(c){var p;const l={datalabels:{display:c!=="none",align:c,anchor:c,clamp:!0}},h={...t,options:{...t==null?void 0:t.options,plugins:{...(p=t==null?void 0:t.options)==null?void 0:p.plugins,...l}}};n(h),console.log(c)}return e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxRuntimeExports.jsx("label",{className:"font-medium",children:"Data Labels"}),!["pyramid"].includes(s)&&e.jsxRuntimeExports.jsx(at,{})]}),e.jsxRuntimeExports.jsxs(e.Select,{value:(d=(u=(o=t==null?void 0:t.options)==null?void 0:o.plugins)==null?void 0:u.datalabels)==null?void 0:d.anchor,onValueChange:r,defaultValue:"none",children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:"h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsxRuntimeExports.jsx(e.SelectValue,{placeholder:"Select position"})}),e.jsxRuntimeExports.jsx(e.SelectContent,{children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[e.jsxRuntimeExports.jsx(e.SelectLabel,{children:"Data Labels"}),e.jsxRuntimeExports.jsx(e.SelectItem,{value:"none",children:"None"}),s!=="pyramid"&&e.jsxRuntimeExports.jsx(e.SelectItem,{value:"start",children:"Start"}),e.jsxRuntimeExports.jsx(e.SelectItem,{value:"center",children:"Center"}),s!=="pyramid"&&e.jsxRuntimeExports.jsx(e.SelectItem,{value:"end",children:"End"})]})})]})]})}function ms({cardType:t}){function n(s){const r="SELECT label, [group], x-axis, y-axis, radius FROM table",o="SELECT label, [group], x-axis, y-axis FROM table";return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx("div",{className:"bg-muted px-2 py-1 rounded text-xs",children:s==="bubble"?r:o}),e.jsxRuntimeExports.jsxs("ul",{className:" ml-6 list-disc [&>li]:mt-2 text-xs",children:[e.jsxRuntimeExports.jsx("li",{children:"label - category"}),e.jsxRuntimeExports.jsx("li",{children:"group - category"}),e.jsxRuntimeExports.jsx("li",{children:"x-axis - category"}),e.jsxRuntimeExports.jsx("li",{children:"y-axis - category"}),s==="bubble"&&e.jsxRuntimeExports.jsx("li",{children:"radius - number"})]}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:u=>u.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#pie-chart",children:"example"})," in the docs."]})]})}return e.jsxRuntimeExports.jsx("div",{className:"px-6 py-2 space-y-6",children:e.jsxRuntimeExports.jsxs(e.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:`${e.titleCase(t)} Chart`}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:" space-y-4 font-mono text-xs ",children:n(t)})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-2",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Settings"}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:"px-2",children:e.jsxRuntimeExports.jsx(Me,{})})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filter on click"}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:"px-2",children:e.jsxRuntimeExports.jsx(me,{})})]})]})})}const ps={datasets:[{type:"line",label:"Sum_sales",data:[]},{type:"bar",label:"Sum_profit",data:[]}]},hs={datasets:[{fill:"origin",type:"line",label:"Sum_sales",data:[]}]};function js(){const t=e.useEditorStore(n=>n.card.type);return e.jsxRuntimeExports.jsxs("div",{className:"space-y-6 p-6",children:[e.jsxRuntimeExports.jsx(e.Accordion,{className:" ",type:"single",collapsible:!0,children:Es(t)}),e.jsxRuntimeExports.jsx("section",{className:"",children:["line","bar"].includes(t)&&e.jsxRuntimeExports.jsx(Ne,{})}),e.jsxRuntimeExports.jsx("div",{children:!["kpi"].includes(t)&&e.jsxRuntimeExports.jsx(Me,{})}),e.jsxRuntimeExports.jsx("div",{children:!["kpi"].includes(t)&&e.jsxRuntimeExports.jsx(me,{})})]})}function Es(t){if(["line","bar"].includes(t))return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"font-normal",children:e.jsxRuntimeExports.jsx("p",{children:"Chart Query"})}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:" ",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs font-semibold",children:"SELECT x-axis, y-axis-1, y-axis-2, y-axis-3,... FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"X-axis - Category (ex. city)"}),e.jsxRuntimeExports.jsx("li",{children:"Y-axis - Number (ex. population)"})]})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-2",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"font-normal",children:"Mixed Chart"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-2 text-xs",children:[e.jsxRuntimeExports.jsxs("p",{children:["Click ",e.jsxRuntimeExports.jsx("b",{children:"Customize"})," and change the `type` property in the dataset."]}),e.jsxRuntimeExports.jsx("pre",{children:JSON.stringify(ps,null,2)})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"font-normal",children:"Area Chart"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-2 text-xs",children:[e.jsxRuntimeExports.jsxs("p",{children:["Click ",e.jsxRuntimeExports.jsx("b",{children:"Customize"})," and add `fill` property to the dataset. See",e.jsxRuntimeExports.jsx("a",{className:"mx-1 text-blue-500 hover:underline",href:"https://www.chartjs.org/docs/latest/samples/area/line-boundaries.html",target:"_blank",children:"docs"}),"for more options."]}),e.jsxRuntimeExports.jsx("pre",{children:JSON.stringify(hs,null,2)})]})]})]});if(t==="bubble")return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"font-normal",children:e.jsxRuntimeExports.jsxs("p",{children:["How to create a ",e.jsxRuntimeExports.jsx("span",{children:t})," chart query?"]})}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:" ",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs font-semibold",children:"SELECT label, x-axis, y-axis, radius FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"Label - Category (ex. city)"}),e.jsxRuntimeExports.jsx("li",{children:"Bubble Group (opt) - Category (ex. state)"}),e.jsxRuntimeExports.jsx("li",{children:"X-axis - Number (ex. avg. age)"}),e.jsxRuntimeExports.jsx("li",{children:"Y-axis - Number (ex. avg. weight)"}),e.jsxRuntimeExports.jsx("li",{children:"Radius - Number (ex. population)"})]})]})]})});if(t==="scatter")return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"font-normal",children:e.jsxRuntimeExports.jsxs("p",{children:["How to create a ",e.jsxRuntimeExports.jsx("span",{children:t})," chart query?"]})}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:" ",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs font-semibold",children:"SELECT label, x-axis, y-axis FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"Label - Category (ex. city)"}),e.jsxRuntimeExports.jsx("li",{children:"Group (opt) - Category (ex. state)"}),e.jsxRuntimeExports.jsx("li",{children:"X-axis - Number (ex. avg. age)"}),e.jsxRuntimeExports.jsx("li",{children:"Y-axis - Number (ex. avg. weight)"})]})]})]})});if(["pie","doughnut","polarArea"].includes(t))return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"font-normal",children:e.jsxRuntimeExports.jsxs("p",{children:[e.jsxRuntimeExports.jsx("span",{children:t==="polarArea"?"Polar":t.charAt(0).toUpperCase()+t.slice(1)})," ","chart query"]})}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:" ",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs font-semibold",children:"SELECT label, measure FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"Label - Category (ex. city)"}),e.jsxRuntimeExports.jsx("li",{children:"Measure - Number (ex. population)"})]})]})]})})}function fs(){var l,h,p,j,f;const t=e.useEditorStore(a=>a.card.preferences),n=e.useEditorStore(a=>a.actions.setCardPreferences),s=e.useEditorStore(a=>a.actions.setNumberFormat);e.useEditorStore(a=>{var m,x;return(x=(m=a.card.preferences)==null?void 0:m.formatNumber)==null?void 0:x.decimalPlaces});const r=e.useEditorStore(a=>{var m,x;return(x=(m=a.card.preferences)==null?void 0:m.formatNumber)==null?void 0:x.locale}),o=e.useEditorStore(a=>{var m,x;return(x=(m=a.card.preferences)==null?void 0:m.formatNumber)==null?void 0:x.currency});e.useEditorStore(a=>a.actions.setFilterOnClickField);const u=e.useEditorStore(a=>{var m,x;return(x=(m=a.card.preferences)==null?void 0:m.formatNumber)==null?void 0:x.colorRanges})||[],d=e.useEditorStore(a=>a.actions.setColorRanges),c=[...new Set(e.LOCALE_CURRENCY_PAIRS.map(a=>a.currency))];return e.jsxRuntimeExports.jsxs("div",{children:[e.jsxRuntimeExports.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Checkbox,{checked:!!((l=t==null?void 0:t.formatNumber)!=null&&l.enabled),onCheckedChange:a=>{n({...t,formatNumber:{...t==null?void 0:t.formatNumber,enabled:a}})}}),e.jsxRuntimeExports.jsx(e.Label,{children:"Format Number"})]}),((h=t==null?void 0:t.formatNumber)==null?void 0:h.enabled)===!0&&e.jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxRuntimeExports.jsx("div",{children:e.jsxRuntimeExports.jsxs("div",{className:"space-y-4 p-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"w-full space-y-1",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Locale"}),e.jsxRuntimeExports.jsxs(e.Select,{value:r||"en-US",onValueChange:a=>{var m,x,v;return s(((m=t==null?void 0:t.formatNumber)==null?void 0:m.decimalPlaces)||0,((x=t==null?void 0:t.formatNumber)==null?void 0:x.currency)||"",a||"en-US",((v=t==null?void 0:t.formatNumber)==null?void 0:v.suffix)||"")},children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:"col-span-6 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsxRuntimeExports.jsx(e.SelectValue,{})}),e.jsxRuntimeExports.jsx(e.SelectContent,{children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[e.jsxRuntimeExports.jsx(e.SelectLabel,{children:"Format"}),e.LOCALE_CURRENCY_PAIRS.map(a=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:a.locale,children:a.locale},a.locale))]})})]})]}),e.jsxRuntimeExports.jsxs("div",{className:"w-full space-y-1",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Currency"}),e.jsxRuntimeExports.jsxs(e.Select,{value:o||"none",onValueChange:a=>{var m,x,v;return s(((m=t==null?void 0:t.formatNumber)==null?void 0:m.decimalPlaces)||0,a==="none"?"":a,((x=t==null?void 0:t.formatNumber)==null?void 0:x.locale)||"",((v=t==null?void 0:t.formatNumber)==null?void 0:v.suffix)||"")},children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:"col-span-6 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsxRuntimeExports.jsx(e.SelectValue,{})}),e.jsxRuntimeExports.jsx(e.SelectContent,{children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[e.jsxRuntimeExports.jsx(e.SelectLabel,{children:"Currency"}),e.jsxRuntimeExports.jsx(e.SelectItem,{value:"none",children:"None"},"none"),c.map(a=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:a,children:a},a))]})})]})]})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex gap-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"w-full space-y-1",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Decimals"}),e.jsxRuntimeExports.jsxs(e.Select,{value:((j=(p=t==null?void 0:t.formatNumber)==null?void 0:p.decimalPlaces)==null?void 0:j.toString())||"0",onValueChange:a=>{var m,x,v;return s(Number(a),((m=t==null?void 0:t.formatNumber)==null?void 0:m.currency)||"",((x=t==null?void 0:t.formatNumber)==null?void 0:x.locale)||"",((v=t==null?void 0:t.formatNumber)==null?void 0:v.suffix)||"")},children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:"col-span-3 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsxRuntimeExports.jsx(e.SelectValue,{})}),e.jsxRuntimeExports.jsx(e.SelectContent,{children:["0","1","2","3","4"].map(a=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:a,children:a},a))})]})]}),e.jsxRuntimeExports.jsxs("div",{className:"w-full space-y-1",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Suffix"}),e.jsxRuntimeExports.jsx(e.Input,{value:((f=t==null?void 0:t.formatNumber)==null?void 0:f.suffix)||"",className:"h-8 font-mono text-xs focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",placeholder:"K, M, B, %",onChange:a=>{var m,x,v;return s(((m=t==null?void 0:t.formatNumber)==null?void 0:m.decimalPlaces)||0,((x=t==null?void 0:t.formatNumber)==null?void 0:x.currency)||"",((v=t==null?void 0:t.formatNumber)==null?void 0:v.locale)||"",a.target.value)}})]})]})]})}),e.jsxRuntimeExports.jsx(e.Separator,{className:"my-3"}),e.jsxRuntimeExports.jsx(e.ColorFormat,{colorRanges:u,setColorRanges:d})]})]})}function gs(){return e.jsxRuntimeExports.jsxs("div",{className:"space-y-6 px-6 py-2",children:[e.jsxRuntimeExports.jsx(e.Accordion,{type:"single",collapsible:!0,children:e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"",children:"KPI Query"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"font-mono",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs",children:"SELECT current, previous FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"current - number"}),e.jsxRuntimeExports.jsx("li",{children:"previous - number"})]}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:t=>t.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#kpi",children:"example"})," in the docs."]})]})]})}),e.jsxRuntimeExports.jsx("section",{className:"",children:e.jsxRuntimeExports.jsx(fs,{})}),e.jsxRuntimeExports.jsx("div",{}),e.jsxRuntimeExports.jsx("div",{})]})}function Rs(){var r;const t=e.useEditorStore(o=>o.card.preferences),{setCardPreferences:n}=e.useEditorStore(o=>o.actions);function s(o){n({...t,textVisualOptions:{...t==null?void 0:t.textVisualOptions,isDynamicText:o==="dynamic"}})}return e.jsxRuntimeExports.jsxs(e.RadioGroup,{value:(r=t==null?void 0:t.textVisualOptions)!=null&&r.isDynamicText?"dynamic":"static",onValueChange:s,className:"flex gap-3",defaultValue:"x",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:"static",id:"r1"}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r1",children:"Static"})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:"dynamic",id:"r2"}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r2",children:"Dynamic"})]})]})}function ye({cardType:t,docContent:n,suffix:s="Chart"}){return e.jsxRuntimeExports.jsx("div",{className:"space-y-6 px-6 py-2",children:e.jsxRuntimeExports.jsxs(e.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:`${e.titleCase(t)} ${s}`}),e.jsxRuntimeExports.jsx(e.AccordionContent,{children:n||e.jsxRuntimeExports.jsxs("div",{className:"space-y-4 font-mono text-xs",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT label, measure FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"label - category"}),e.jsxRuntimeExports.jsx("li",{children:"measure - number"})]}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:r=>r.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#pie-chart",children:"example"})," in the docs."]})]})})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-2",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Settings"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 px-2",children:[t==="range"&&e.jsxRuntimeExports.jsx(Ne,{}),t!=="text"&&e.jsxRuntimeExports.jsx(Me,{}),t==="text"&&e.jsxRuntimeExports.jsx(Rs,{})]})]}),!["range","text"].includes(t)&&e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filter on click"}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:"px-2",children:e.jsxRuntimeExports.jsx(me,{})})]})]})})}function bs(){return e.jsxRuntimeExports.jsx("div",{className:"space-y-6 px-6 py-2",children:e.jsxRuntimeExports.jsxs(e.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Stacked Chart"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 font-mono text-xs",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT x-axis, stack-by, y-axis FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"x-axis - category"}),e.jsxRuntimeExports.jsx("li",{children:"stack by - category"}),e.jsxRuntimeExports.jsx("li",{children:"y-axis - number"})]}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:t=>t.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#stacked-chart",children:"example"})," in the docs."]})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-2",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Settings"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 px-2",children:[e.jsxRuntimeExports.jsx(Ne,{}),e.jsxRuntimeExports.jsx(lt,{})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filter on click"}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:"px-2",children:e.jsxRuntimeExports.jsx(me,{})})]})]})})}function Ss({}){const t=e.useEditorStore(r=>{var o;return(o=r.card)==null?void 0:o.preferences}),n=e.useEditorStore(r=>r.actions.setCardPreferences),s=r=>{n({...t,allowDownload:r})};return e.jsxRuntimeExports.jsxs("div",{className:"space-y-6 px-6 py-2",children:[e.jsxRuntimeExports.jsx(e.Accordion,{defaultValue:["item-3"],type:"multiple",children:e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filter on click"}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:"px-2",children:e.jsxRuntimeExports.jsx(me,{})})]})}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.Checkbox,{onCheckedChange:s,id:"allow-download"}),e.jsxRuntimeExports.jsx("label",{htmlFor:"allow-download",className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:"Allow Download"})]})]})}const ys=e.jsxRuntimeExports.jsxs("div",{className:"space-y-4 font-mono text-xs",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT dimension, cohort, metric FROM table"}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:t=>t.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#pyramid-chart",children:"example"})," in the docs."]})]}),vs=e.jsxRuntimeExports.jsxs("div",{className:"space-y-4 font-mono text-xs",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT y-axis, label, range-from, range-to, range-value FROM table"}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:t=>t.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#range-charts",children:"example"})," in the docs."]})]}),Cs=e.jsxRuntimeExports.jsxs("div",{className:"space-y-4 font-mono text-xs",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT text FROM table limit 1"}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:t=>t.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#text-visual",children:"example"})," in the docs."]})]});function Ns(){const t=e.useEditorStore(s=>s.card.type);function n(s){switch(s){case"stackedBar":case"stackedLine":return e.jsxRuntimeExports.jsx(bs,{});case"pyramid":return e.jsxRuntimeExports.jsx(ye,{docContent:ys,cardType:s});case"kpi":return e.jsxRuntimeExports.jsx(gs,{});case"line":case"bar":return e.jsxRuntimeExports.jsx(ds,{cardType:s});case"range":return e.jsxRuntimeExports.jsx(ye,{docContent:vs,cardType:s});case"pie":case"doughnut":case"polarArea":case"radar":return e.jsxRuntimeExports.jsx(ye,{cardType:s});case"bubble":case"scatter":return e.jsxRuntimeExports.jsx(ms,{cardType:s});case"table":return e.jsxRuntimeExports.jsx(Ss,{cardType:s});case"text":return e.jsxRuntimeExports.jsx(ye,{docContent:Cs,cardType:s,suffix:"Visual"});default:return e.jsxRuntimeExports.jsx(js,{})}}return e.jsxRuntimeExports.jsx(e.ScrollArea,{className:"h-full w-full text-sm",children:n(t)})}function ks(){const t=e.useEditorStore(n=>n.isShowingVisual);return e.jsxRuntimeExports.jsxs(e.ResizablePanelGroup,{direction:"vertical",className:"min-h-[250px] min-w-full max-w-lg",children:[e.jsxRuntimeExports.jsx(e.ResizablePanel,{role:"query-section",className:"flex",minSize:20,defaultSize:40,children:e.jsxRuntimeExports.jsx(ns,{})}),e.jsxRuntimeExports.jsx(e.ResizableHandle,{withHandle:!0,className:"border"}),e.jsxRuntimeExports.jsx(e.ResizablePanel,{className:"pb-1",role:"visual-section",minSize:0,defaultSize:60,children:t?e.jsxRuntimeExports.jsxs(e.ResizablePanelGroup,{direction:"horizontal",children:[e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsx(e.ResizablePanel,{className:"flex min-w-[275px]",minSize:20,defaultSize:25,maxSize:30,children:e.jsxRuntimeExports.jsx(Ns,{})})}),e.jsxRuntimeExports.jsx(e.ResizableHandle,{className:"border"}),e.jsxRuntimeExports.jsx(e.ResizablePanel,{minSize:40,defaultSize:75,maxSize:100,children:e.jsxRuntimeExports.jsx(_e,{})})]}):e.jsxRuntimeExports.jsx(_e,{})})]})}function ws({authToken:t,onSave:n,onClose:s}){const r=e.useEditorStore(d=>d.actions.setOnSave),o=e.useEditorStore(d=>d.actions.setOnClose),u=e.useDashboardStore(d=>d.actions.setAuthToken);return b.useEffect(()=>{n&&r(n),s&&o(s)},[n,r,s,o]),b.useEffect(()=>{t&&t.accessToken&&u(t)},[t,u]),e.jsxRuntimeExports.jsxs(e.EditorPanel,{className:"rounded-none",role:"editor-panel",children:[e.jsxRuntimeExports.jsx(e.EditorAside,{className:"rounded-none border-r-[1.5px]",children:e.jsxRuntimeExports.jsx(Ue,{})}),e.jsxRuntimeExports.jsx(e.EditorMain,{children:e.jsxRuntimeExports.jsx(ks,{})})]})}function As(){e.useDashboardStore(d=>d.selectedCardId);const t=e.useDashboardStore(d=>d.selectedSheetId),{setIsVisualEditing:n}=e.useDashboardStore(d=>d.actions),s=e.useDashboardStore(d=>d.isVisualEditing),r=e.useDashboardStore(d=>d.actions.updateFrame);function o(d){t&&(r(t,d),n(!1))}function u(){n(!1)}return e.jsxRuntimeExports.jsx("div",{role:"editor-container",className:e.cn("flex grow",{block:s,hidden:!s}),children:e.jsxRuntimeExports.jsx(ws,{onSave:o,onClose:u})})}function Ds({columns:t,tableName:n}){const s=e.useEditorStore(a=>a.selectedConnectionId),r=e.useEditorStore(a=>a.selectedDatamodelId),o=e.useEditorStore(a=>a.selectedDatabaseName),u=e.useEditorStore(a=>a.selectedSchemaName),d=e.useEditorStore(a=>a.selectedTableName),c=e.useDashboardStore(a=>a.dashboard.filters)||[],l=e.useDashboardStore(a=>a.actions.addFilter),h=e.useDashboardStore(a=>a.actions.removeFilter),p=e.useDashboardStore(a=>a.actions.removeFilterValue),{modelItems:j}=Ee();function f(a){var z;const m=e.fmt(a.column_name),x=e.fmt(o||""),v=e.fmt(u||""),E=e.fmt(n);let k=e.getQualifiedTableName(v,E),g=`${k}.${m}`;const D=(z=j==null?void 0:j.find(A=>A.id===r))==null?void 0:z.name;r&&r!=="none"&&(g=`${e.DATAMODEL_NAMESPCACE}.${D}.${m}`,k=`${e.DATAMODEL_NAMESPCACE}.${D}`),console.log("find",g,E,x);const T=c==null?void 0:c.find(A=>A.column===g&&A.table===E&&(A.database===x||A.database===o));if(T)p(T.id),h(T.id);else{if(n==="api"&&s){l({id:e.v4(),column:g,title:a.column_name,dataType:a.data_type,table:"api",database:"",connectionId:s,operation:"in",sql:e.getDefaultFilterSql(a.data_type,k,m)});return}l({id:e.v4(),column:g,title:a.column_name,dataType:a.data_type,table:d||"",database:o||"",connectionId:s||"",operation:"in",sql:e.getDefaultFilterSql(a.data_type,k,m)})}}return e.jsxRuntimeExports.jsx("div",{className:"xbg-red-100 flex-1 basis-0 flex-col overflow-scroll px-3",children:t==null?void 0:t.map(a=>{const m=c==null?void 0:c.find(x=>x.column===e.fmt(a.column_name)&&x.table===d&&x.database===o);return e.jsxRuntimeExports.jsx("div",{onClick:()=>f(a),className:e.cn("group flex cursor-pointer items-center justify-between border border-dashed border-background px-3 py-[6px] text-sm transition-colors hover:bg-muted/50",{"bg-muted":m}),children:e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxRuntimeExports.jsx(Je,{column:a}),e.jsxRuntimeExports.jsx("span",{children:a.column_name})]})},a.column_name)})})}function Ts(){e.useDashboardStore(n=>n.showFilters);const t=e.useDashboardStore(n=>n.actions.setShowFilters);return e.jsxRuntimeExports.jsxs("section",{className:"relative flex grow flex-col border-l px-4",children:[e.jsxRuntimeExports.jsxs("div",{className:"mt-4 flex items-center justify-between gap-2 px-3",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"text-lg",children:"Filters"}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>t(!1),className:"h-7 w-7 p-0",variant:"ghost",children:e.jsxRuntimeExports.jsx(e.Cross2Icon,{})})]}),e.jsxRuntimeExports.jsx("div",{className:"flex grow",children:e.jsxRuntimeExports.jsx(Ue,{ColumnsComponent:(n,s,r)=>e.jsxRuntimeExports.jsx(Ds,{schemaName:n,tableName:s,columns:r})})})]})}function Is(){e.useDashboardStore(s=>s.dashboard);const t=e.useDashboardStore(s=>s.showFilters),n=e.useDashboardStore(s=>s.isVisualEditing);return e.useDashboardStore(s=>s.bookmarkKey),e.jsxRuntimeExports.jsxs("div",{role:"dashboard-plus-main",className:e.cn("grow",{hidden:n,flex:!n}),children:[e.jsxRuntimeExports.jsx(e.DashboardTabs,{}),t&&e.jsxRuntimeExports.jsx("div",{role:"filter-aside-container",className:"flex",children:e.jsxRuntimeExports.jsx(Ts,{})})]})}function zs(){const t=e.useDashboardStore(r=>r.dashboard),n=e.useDashboardStore(r=>r.actions.setDashboard),s=e.useDashboardStore(r=>r.showDashboardJSON);return e.useDashboardStore(r=>r.actions.setShowDashboardJSON),e.jsxRuntimeExports.jsx("div",{className:e.cn(" p-2",{hidden:!s}),children:e.jsxRuntimeExports.jsx(e.de,{onChange:r=>{if(r)try{JSON.parse(r),n(JSON.parse(r))}catch{}},defaultLanguage:"json",className:"h-[550px] overflow-y-auto ",value:JSON.stringify(t,null,2),options:{minimap:{enabled:!1},glyphMargin:!1,wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:12,renderLineHighlight:"none"}})})}function Ls({showControls:t=!1,showFooter:n=!0,...s}){return e.jsxRuntimeExports.jsxs(e.SemaphorContextProvider,{dashboardProps:s,children:[e.jsxRuntimeExports.jsx(e.Te,{}),e.jsxRuntimeExports.jsxs(e.UXProvider,{children:[e.jsxRuntimeExports.jsx(zs,{}),e.jsxRuntimeExports.jsxs(e.DashboardPanel,{...s,children:[t&&e.jsxRuntimeExports.jsx(Bt,{}),e.jsxRuntimeExports.jsx(As,{}),e.jsxRuntimeExports.jsx(Is,{})]})]})]})}exports.DashboardPlus=Ls;exports.LoaderCircle=de;exports.SelectComponent=ue;exports.useEditorAside=Ee;
@@ -1,4 +1,4 @@
1
- import { O as T, b as w, j as e, P as Ss, Q as ks, R as k, U as ws, V as zs, W as Fs, X as Ms, Y as Os, Z as G, _ as he, $ as sa, J as aa, M as De, a0 as Ka, a1 as Ga, a2 as Ja, a3 as Ua, a4 as Qa, a5 as Wa, a6 as $s, a7 as Be, a8 as Ue, a9 as $e, T as Ts, e as ta, g as Ls, aa as Me, ab as Oe, f as ee, ac as Te, ad as Le, ae as Pe, af as Ae, ag as X, ah as Ds, G as c, ai as ls, aj as is, ak as Ya, al as os, w as na, v as ra, t as ue, am as Za, r as Xa, N as la, s as et, an as st, B as at, ao as ia, ap as tt, S as As, z as nt, n as Ps, aq as js, A as oa, ar as bs, u as Qe, as as me, at as be, au as Ke, av as ca, aw as da, ax as ha, ay as ma, az as ua, aA as rt, aB as lt, aC as xa, aD as it, aE as ot, aF as ct, aG as dt, aH as ht, aI as ys, aJ as mt, aK as He, aL as vs, aM as Fe, aN as Ns, aO as Ks, aP as ut, aQ as xt, aR as pt, aS as ft, aT as gt, aU as gs, aV as jt, aW as Gs, aX as bt, aY as Js, aZ as yt, a_ as vt, a$ as Nt, b0 as pa, l as Ct, C as St, E as Cs, d as kt, h as wt, i as zt, o as Ft, b1 as Mt, m as Ot, H as fa, b2 as Tt, b3 as ga, b4 as ja, b5 as as, b6 as Lt, b7 as ts, b8 as Us, K as Dt, b9 as At, ba, bb as Et, bc as Es, bd as Ee, be as ya, bf as It, bg as Vt, bh as qt, bi as Rt, bj as _t, bk as Ce, bl as H, bm as B, bn as Is, bo as $, bp as Qs, bq as Ht, br as Bt, bs as $t, bt as Pt, bu as Ws, bv as Kt, bw as Gt, bx as Jt, by as Ut, bz as Qt, bA as Wt } from "./index-9atMGUeK.js";
1
+ import { O as T, b as w, j as e, P as Ss, Q as ks, R as k, U as ws, V as zs, W as Fs, X as Ms, Y as Os, Z as G, _ as he, $ as sa, J as aa, M as De, a0 as Ka, a1 as Ga, a2 as Ja, a3 as Ua, a4 as Qa, a5 as Wa, a6 as $s, a7 as Be, a8 as Ue, a9 as $e, T as Ts, e as ta, g as Ls, aa as Me, ab as Oe, f as ee, ac as Te, ad as Le, ae as Pe, af as Ae, ag as X, ah as Ds, G as c, ai as ls, aj as is, ak as Ya, al as os, w as na, v as ra, t as ue, am as Za, r as Xa, N as la, s as et, an as st, B as at, ao as ia, ap as tt, S as As, z as nt, n as Ps, aq as js, A as oa, ar as bs, u as Qe, as as me, at as be, au as Ke, av as ca, aw as da, ax as ha, ay as ma, az as ua, aA as rt, aB as lt, aC as xa, aD as it, aE as ot, aF as ct, aG as dt, aH as ht, aI as ys, aJ as mt, aK as He, aL as vs, aM as Fe, aN as Ns, aO as Ks, aP as ut, aQ as xt, aR as pt, aS as ft, aT as gt, aU as gs, aV as jt, aW as Gs, aX as bt, aY as Js, aZ as yt, a_ as vt, a$ as Nt, b0 as pa, l as Ct, C as St, E as Cs, d as kt, h as wt, i as zt, o as Ft, b1 as Mt, m as Ot, H as fa, b2 as Tt, b3 as ga, b4 as ja, b5 as as, b6 as Lt, b7 as ts, b8 as Us, K as Dt, b9 as At, ba, bb as Et, bc as Es, bd as Ee, be as ya, bf as It, bg as Vt, bh as qt, bi as Rt, bj as _t, bk as Ce, bl as H, bm as B, bn as Is, bo as $, bp as Qs, bq as Ht, br as Bt, bs as $t, bt as Pt, bu as Ws, bv as Kt, bw as Gt, bx as Jt, by as Ut, bz as Qt, bA as Wt } from "./index-xyzOo2JH.js";
2
2
  import xe, { useState as O, useEffect as Q, useMemo as Yt, useRef as Ge } from "react";
3
3
  /**
4
4
  * @license lucide-react v0.379.0 - ISC
@@ -2932,7 +2932,7 @@ function Xs() {
2932
2932
  {
2933
2933
  text: h.tabTitle || h.title,
2934
2934
  onSave: (S) => {
2935
- f({ ...h, tabTitle: S }), p({ ...h, tabTitle: S });
2935
+ f({ ...t, tabTitle: S }), p({ ...t, tabTitle: S });
2936
2936
  },
2937
2937
  children: /* @__PURE__ */ e.jsxs(as, { className: "", value: h.id, children: [
2938
2938
  h.tabTitle || h.title,