react-semaphor 0.0.269 → 0.0.270

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.
@@ -237,4 +237,4 @@ SELECT label, measure FROM table
237
237
  Table Columns: ${I==null?void 0:I.map(C=>`${C.column_name} | ${C.data_type}`).join(", ")}
238
238
  User SQL: ${L}
239
239
  ${p&&`Base Queries: ${JSON.stringify(p)} `}`,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.
240
- Visual Query Syntax: ${Xs}`,{data:E,isLoading:v,isFetching:R,isError:f,refetch:z}=e.useQuery({queryKey:["ai-query"],queryFn:()=>e.getRequest("https://semaphor.cloud/api/v1/ai",(i==null?void 0:i.accessToken)||"",{user_content:`userContent: ${D} ${m?T:""}`}),enabled:!1});function O(C){if(C.toLowerCase().includes("bar"))j("bar");else if(C.toLowerCase().includes("line"))j("line");else if(C.toLowerCase().includes("bubble"))j("bubble");else if(C.toLowerCase().includes("scatter"))j("scatter");else if(C.toLowerCase().includes("stacked"))j("stackedBar");else if(C.toLowerCase().includes("pie"))j("pie");else if(C.toLowerCase().includes("donut")||C.toLowerCase().includes("doughnut"))j("doughnut");else if(C.toLowerCase().includes("radar"))j("radar");else return j("bar"),!1;return!0}S.useEffect(()=>{E&&N(C=>[...C,{role:"ai",content:E.response}])},[E]),S.useEffect(()=>{const C=setTimeout(()=>{var A;c.current&&(c.current.scroll({top:c.current.scrollHeight,behavior:"smooth"}),(A=a.current)==null||A.focus())},100);return()=>clearTimeout(C)},[x]);function F(){t&&(N(C=>[...C,{role:"user",content:t}]),O(t)&&u(!0),n(""),z())}S.useEffect(()=>{o&&(F(),l(!1))},[o,l]);const V={fontFamily:"Arial, sans-serif",lineHeight:1.6,fontSize:15,width:"100%"},P={fontFamily:"monospace",fontSize:14,lineHeight:1.6},_={fontFamily:"Arial, sans-serif",lineHeight:1.6,fontSize:15,padding:"2px 0",marginLeft:20,listStyleType:"disc"},K={p:({node:C,...A})=>e.jsxRuntimeExports.jsx("p",{style:V,...A}),code:({node:C,...A})=>e.jsxRuntimeExports.jsx("code",{className:"rounded-sm bg-muted px-2 py-1 text-sm",...A}),pre:({node:C,...A})=>e.jsxRuntimeExports.jsxs("pre",{className:"space-y-2 rounded-sm bg-muted/50 p-3",style:P,children:[e.jsxRuntimeExports.jsx("code",{className:"whitespace-normal text-sm",children:A.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:H=>{const k=q(H);k&&(r(!1),g(k),d(!0))},size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(e.PlayIcon,{})})]})]}),li:({node:C,...A})=>e.jsxRuntimeExports.jsx("li",{style:_,...A})};function q(C){const A=C.currentTarget.closest("pre");if(!A)return;const H=A.textContent||A.innerText;return navigator.clipboard.writeText(H).then(()=>console.log("Text copied to clipboard")).catch(k=>console.error("Error in copying text: ",k)),H}function W(){return x==null?void 0:x.map((C,A)=>C.role==="user"?e.jsxRuntimeExports.jsxs("div",{className:"flex items-start rounded-md bg-muted p-3 text-sm",children:[e.jsxRuntimeExports.jsx(Es,{className:"mr-2 h-5 w-5"}),e.jsxRuntimeExports.jsx("div",{children:C.content})]},A):C.role==="ai"?e.jsxRuntimeExports.jsx(e.Markdown,{className:"w-full overflow-auto py-1",components:K,children:E==null?void 0:E.response.replace(/DuckDB/gi,"Semaphor")},A):e.jsxRuntimeExports.jsx("div",{},A))}return e.jsxRuntimeExports.jsxs(e.Dialog,{open:s,onOpenChange:r,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:W()})}),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:a,onKeyDown:C=>{C.key==="Enter"&&!C.shiftKey&&(C.preventDefault(),n(""),F())},placeholder:"Type your question here...",onFocus:C=>{const A=C.target,H=A.value.length;A.setSelectionRange(H,H)},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:v||R,value:t,onChange:C=>n(C.target.value)})," ",e.jsxRuntimeExports.jsx(e.Button,{className:"h-8",size:"sm",variant:"ghost",onClick:F,children:!v&&!R?e.jsxRuntimeExports.jsx(e.PaperPlaneIcon,{}):e.jsxRuntimeExports.jsx(le,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"})})]})})]})]})}var bs={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},_e=S.createContext&&S.createContext(bs),et=["attr","size","title"];function st(s,r){if(s==null)return{};var t=tt(s,r),n,o;if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(s);for(o=0;o<l.length;o++)n=l[o],!(r.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(s,n)&&(t[n]=s[n])}return t}function tt(s,r){if(s==null)return{};var t={},n=Object.keys(s),o,l;for(l=0;l<n.length;l++)o=n[l],!(r.indexOf(o)>=0)&&(t[o]=s[o]);return t}function ge(){return ge=Object.assign?Object.assign.bind():function(s){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(s[n]=t[n])}return s},ge.apply(this,arguments)}function Be(s,r){var t=Object.keys(s);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(s);r&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(s,o).enumerable})),t.push.apply(t,n)}return t}function Re(s){for(var r=1;r<arguments.length;r++){var t=arguments[r]!=null?arguments[r]:{};r%2?Be(Object(t),!0).forEach(function(n){nt(s,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(t)):Be(Object(t)).forEach(function(n){Object.defineProperty(s,n,Object.getOwnPropertyDescriptor(t,n))})}return s}function nt(s,r,t){return r=rt(r),r in s?Object.defineProperty(s,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):s[r]=t,s}function rt(s){var r=ot(s,"string");return typeof r=="symbol"?r:String(r)}function ot(s,r){if(typeof s!="object"||s===null)return s;var t=s[Symbol.toPrimitive];if(t!==void 0){var n=t.call(s,r||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(s)}function ys(s){return s&&s.map((r,t)=>S.createElement(r.tag,Re({key:t},r.attr),ys(r.child)))}function Z(s){return r=>S.createElement(it,ge({attr:Re({},s.attr)},r),ys(s.child))}function it(s){var r=t=>{var{attr:n,size:o,title:l}=s,a=st(s,et),c=o||t.size||"1em",i;return t.className&&(i=t.className),s.className&&(i=(i?i+" ":"")+s.className),S.createElement("svg",ge({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},t.attr,n,a,{className:i,style:Re(Re({color:s.color||t.color},t.style),s.style),height:c,width:c,xmlns:"http://www.w3.org/2000/svg"}),l&&S.createElement("title",null,l),s.children)};return _e!==void 0?S.createElement(_e.Consumer,null,t=>r(t)):r(bs)}function at(s){return Z({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:[]}]})(s)}function lt(){const{theme:s}=e.useTheme(),r=S.useRef(),t=S.useRef(),[n,o]=S.useState(!1),[l,a]=S.useState(!1),[c,i]=S.useState(!1),[m,u]=S.useState(""),[g,p]=S.useState(!1),{authToken:d}=e.useSemaphorContext();e.useDashboardStore(h=>h.selectedSheetId);const j=e.useDashboardStore(h=>h.dashboard.baseQueries),x=e.useEditorStore(h=>h.card),N=e.useDashboardStore(h=>h.theme),I=e.useEditorStore(h=>h.isShowingVisual);e.useDashboardStore(h=>h.onAcceptChanges);const L=e.useEditorStore(h=>h.selectedConnectionId),b=e.useEditorStore(h=>h.selectedDatabaseName),D=e.useEditorStore(h=>h.selectedDatamodelId),T=e.useEditorStore(h=>h.selectedSchemaName);e.useDashboardStore(h=>h.actions.updateFrameCard);const E=e.useEditorStore(h=>h.selectedTableName),v=e.useEditorStore(h=>h.card.sql),R=e.useEditorStore(h=>h.card.python),f=e.resolveBaseQuery(v,j),z=e.useEditorStore(h=>h.selectedConnectionId),O=e.useEditorStore(h=>h.frame),F=e.useDashboardStore(h=>h.filterValues),V=e.useEditorStore(h=>h.applyFilters),{setCardCustomCfg:P,setQueryResultColumns:_,setFilterValues:K,setCardSql:q,setCardPython:W,setQueryError:C,setPythonStdOut:A,setCardPreferences:H}=e.useEditorStore(h=>h.actions),k=e.useEditorStore(h=>h.onSave),w=e.useEditorStore(h=>h.actions.setApplyFilters),$=e.useEditorStore(h=>h.onClose),M=e.useEditorStore(h=>h.actions.setCardData),G=e.useEditorStore(h=>h.actions.setSqlGen),Q=e.useEditorStore(h=>h.runSql),te=e.useEditorStore(h=>h.actions.setRunSql),ee=e.useEditorStore(h=>h.actions.setIsSqlRunning),{data:B,isLoading:J,isFetching:Y,isSuccess:ne,isError:X,error:se,status:Oe,refetch:ie}=e.useQuery({queryKey:[f,R],queryFn:()=>e.postRequest("https://semaphor.cloud/api/v1/query",(d==null?void 0:d.accessToken)||"",{connection_id:z,sql:f,python:R===e.PYTHON_DEFAULT_CODE?"":R,active_filters:V?F:[]}),enabled:!1,retry:!1});S.useEffect(()=>{if(B&&(M(B.records),B.rowLimitExceeded&&e.Jt.error("Row limit (10,000) exceeded. Refine your query.",{position:"top-center",richColors:!0}),A((B==null?void 0:B.output)||""),B.records.length>0)){const{dimensionKeys:h}=e.getKeys(B.records);_(h)}},[B,M,_,A]),S.useEffect(()=>{Q&&(ie(),te(!1))},[Q,ie,te]),S.useEffect(()=>{(J||Y)&&ee(!0),(X||ne)&&ee(!1),X?(C(se.message),M([]),_([]),A("")):C("")},[J,Y,B,A,X,ne,ee,M,_,C,se]);function Ce(){q(""),M([]),G({}),P(""),H({})}const me=h=>{t.current=h};function Ne(h,y){if(h.length===0)return"";if(y){const re=h.find(U=>U.id===y);if(re){const U=re.tabTitle;if(U=="All__Header")return h[0].id;if(U&&U.endsWith("__Header")){const Ms=U.split("__")[0],Ve=h.find(Os=>Os.tabTitle===Ms);return Ve?Ve.id:h[0].id}return y}}return h[0].id}function we(){let h=v;v&&!v.includes("{{")&&(h=Us(v),q(h));const y={...x,lastSelectedSchema:T,lastSelectedDatamodelId:D,lastSelectedDatabase:b,lastSelectedTable:E,connectionId:L,type:I?x.type:"table",sql:h,customCfg:I?x.customCfg:null},re=O.cards.map(ke=>ke.id===x.id?y:ke),U={...O,cards:re,activeCardId:Ne(re,O.activeCardId)};k==null||k(U)}function pe(){$==null||$()}S.useEffect(()=>{const h=r.current,y=t.current;if(h){const re=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",U=N==="system"?re:N;h.editor.defineTheme("default",{base:U==="light"?"vs":"vs-dark",inherit:!0,rules:[],colors:{"editor.background":U==="light"?"#ffffff":e.getCssVariableValue("--semaphor-background")}}),h.editor.setTheme("default")}return y&&h&&y.addCommand(h.KeyMod.Shift|h.KeyCode.Enter,function(){return console.log("Executing query..."),ie(),!1}),()=>{}},[s,N,r.current]);function ue(h){r.current=h}function je(){return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[l&&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(Ws,{checked:V,onCheckedChange:()=>w(!V),text:"Apply Filters"}),e.jsxRuntimeExports.jsx(Ys,{}),F&&l&&e.jsxRuntimeExports.jsx(e.Cross2Icon,{onClick:()=>a(!1),className:"bg-background/50 text-foreground/50 hover:cursor-pointer hover:text-foreground"})]}),e.jsxRuntimeExports.jsx(e.Ft,{theme:"default",onChange:h=>{if(h)try{JSON.parse(h),K(JSON.parse(h))}catch{}},defaultLanguage:"json",className:"mt-1 min-h-[220px]",value:JSON.stringify(F,null,2),options:{readOnly:!0,minimap:{enabled:!1},lineNumbers:"off",glyphMargin:!1,wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:12,renderLineHighlight:"none"}})]})}),F&&!l&&e.jsxRuntimeExports.jsx(e.Filter,{onClick:()=>a(!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":V})})]})}function he(){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:n?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:h=>{q(h)},value:v,options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"sql",beforeMount:ue,onMount:me})}),n&&e.jsxRuntimeExports.jsx("code",{className:"absolute right-6 top-3 text-sm text-muted-foreground/70",children:"sql"})]}),n&&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:h=>{W(h&&h.trim()||"")},value:R||e.PYTHON_DEFAULT_CODE,options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"python",beforeMount:ue,onMount:me})}),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:[he(),je()]}),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||Y,onClick:()=>{ie()},className:"shrink-0",size:"sm",variant:"outline",children:[J||Y?e.jsxRuntimeExports.jsx(le,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"}):e.jsxRuntimeExports.jsx(cs,{className:"mr-2 h-4 w-4"}),"Run"]}),X&&e.jsxRuntimeExports.jsx(Ks,{error:se.message,setShowAIDialog:i,setTriggerAIRun:p,setUserInputforAI:u}),e.jsxRuntimeExports.jsxs(e.Button,{onClick:Ce,className:"",size:"sm",variant:"outline",children:[e.jsxRuntimeExports.jsx(Je,{className:"mr-2 size-4"}),"Clear"]}),e.jsxRuntimeExports.jsx(e.Toggle,{pressed:n,onPressedChange:h=>o(h),className:"",size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(at,{className:"size-4 text-foreground/70"})}),e.jsxRuntimeExports.jsx(Zs,{open:c,setOpen:i,userInput:m,triggerAIRun:g,setTriggerAIRun:p,setUserInput:h=>u(h)})]}),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:pe,className:"w-full",size:"sm",variant:"outline",children:[e.jsxRuntimeExports.jsx(e.Cross2Icon,{className:"mr-2 size-4"}),"Close"]})]})]})]})}function ct({data:s}){var a;const[r,t]=S.useState([]),o=Object.keys(s[0]).map(c=>({accessorKey:c,header:({column:i})=>{const m=i.getIsSorted();return e.jsxRuntimeExports.jsx("div",{className:"flex gap-2",children:e.jsxRuntimeExports.jsxs("div",{className:"flex cursor-pointer items-center",onClick:()=>i.toggleSorting(i.getIsSorted()==="asc"),children:[c,m==="asc"?e.jsxRuntimeExports.jsx(e.TriangleUpIcon,{className:"ml-2 h-5 w-5"}):m==="desc"?e.jsxRuntimeExports.jsx(e.TriangleDownIcon,{className:"ml-2 h-5 w-5"}):null]})})}})),l=e.useReactTable({data:s,columns:o,getCoreRowModel:e.getCoreRowModel(),getPaginationRowModel:e.getPaginationRowModel(),onSortingChange:t,getSortedRowModel:e.getSortedRowModel(),manualPagination:!0,state:{sorting:r}});return e.jsxRuntimeExports.jsxs(e.Table$1,{children:[e.jsxRuntimeExports.jsx(e.TableHeader,{children:l.getHeaderGroups().map(c=>e.jsxRuntimeExports.jsx(e.TableRow,{children:c.headers.map(i=>e.jsxRuntimeExports.jsx(e.TableHead,{className:"sticky top-0 bg-muted",children:i.isPlaceholder?null:e.flexRender(i.column.columnDef.header,i.getContext())},i.id))},c.id))}),e.jsxRuntimeExports.jsx(e.TableBody,{children:(a=l.getRowModel().rows)!=null&&a.length?l.getRowModel().rows.map(c=>e.jsxRuntimeExports.jsx(e.TableRow,{className:"whitespace-nowrap py-2","data-state":c.getIsSelected()&&"selected",children:c.getVisibleCells().map(i=>e.jsxRuntimeExports.jsx(e.TableCell,{children:e.flexRender(i.column.columnDef.cell,i.getContext())},i.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 xt({card:s}){var c,i,m,u,g,p,d,j;(c=s.customCardPreferences)!=null&&c.inputData;const{getCard:r}=e.useCustomVisual(((i=s.customCardPreferences)==null?void 0:i.url)||""),t=((m=s.customCardPreferences)==null?void 0:m.visualType)||"single",n=e.useEditorStore(x=>x.frame);if(e.useEditorActions(),!((u=s.customCardPreferences)!=null&&u.componentName))return null;const o=r((g=s.customCardPreferences)==null?void 0:g.componentName),l=x=>{console.log("data",x),s.customCardPreferences},a=Object.keys(((p=s.customCardPreferences)==null?void 0:p.dataInputCardIds)||{}).map(x=>{var L,b,D;const N=(b=(L=s.customCardPreferences)==null?void 0:L.dataInputCardIds)==null?void 0:b[x].cardId,I=(D=n==null?void 0:n.cards)==null?void 0:D.find(T=>T.id===N);return I||null});return e.jsxRuntimeExports.jsx("div",{className:"semaphor-custom mb-3 flex grow basis-0 flex-col space-y-2 overflow-y-auto",children:e.jsxRuntimeExports.jsxs(S.Suspense,{fallback:e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{}),children:[o&&t==="single"&&e.jsxRuntimeExports.jsx(o,{settings:(d=s.customCardPreferences)==null?void 0:d.settings,onDataChange:l,data:s.data}),o&&t==="multiple"&&e.jsxRuntimeExports.jsx("div",{className:"flex flex-col gap-2",children:e.jsxRuntimeExports.jsx(o,{onDataChange:l,settings:a.map(x=>{var N;return(N=x==null?void 0:x.customCardPreferences)==null?void 0:N.settings}),data:a.map(x=>(x==null?void 0:x.data)||[])})})]},(j=s.customCardPreferences)==null?void 0:j.componentName)})}function Ss({className:s,...r}){var g;S.useState(0);const t=e.useDashboardStore(p=>p.themeStyle),n=e.useEditorStore(p=>p.card),o=e.useEditorStore(p=>p.frame),l=e.useDashboardStore(p=>p.dashboard.filters);e.useDashboardStore(p=>p.filterValues),e.useEditorStore(p=>p.actions.setRunSql);const{updateFilter:a}=e.useDashboardActions(),c=l==null?void 0:l.find(p=>p.id===o.filterId),i=e.useEditorStore(p=>p.actions.setCard);if(S.useEffect(()=>{},[n.data,n.type,n.cfg,n.customCfg,t,n.preferences]),!n.id)return null;let m;n.data&&n.data.length>0&&(m=e.createChartConfig({data:n.data,cardType:n.type,cfg:n.cfg,customCfg:n.customCfg,preferences:n.preferences}));function u(p){return e.jsxRuntimeExports.jsx(xt,{card:p})}return e.jsxRuntimeExports.jsxs(e.Card,{role:"editor-visual-card",className:e.cn("relative flex h-full flex-col rounded-none",s),...r,children:[e.jsxRuntimeExports.jsxs(e.CardHeader,{className:"flex flex-row items-start justify-between py-4",children:[e.jsxRuntimeExports.jsxs("div",{children:[e.jsxRuntimeExports.jsx(e.Editable,{text:n.title,onSave:p=>i({...n,title:p}),children:e.jsxRuntimeExports.jsx("div",{className:"flex items-center gap-2",children:e.jsxRuntimeExports.jsx(e.CardTitle,{className:"text-base",children:n.title})})},n.title),e.jsxRuntimeExports.jsx(e.Editable,{text:n.description||"",onSave:p=>i({...n,description:p}),children:e.jsxRuntimeExports.jsxs(e.CardDescription,{children:[" ",n.description]})},n.description)]}),c&&e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxRuntimeExports.jsx(e.Editable,{className:"my-1",text:c.title||c.column,onSave:p=>a({...c,title:p}),children:e.jsxRuntimeExports.jsx(e.Label,{children:c.title})}),e.getFilterComponent(c)]})]}),e.jsxRuntimeExports.jsxs(e.CardContent,{className:"flex grow flex-col",children:[n.type==="custom"&&u(n),!["table","custom"].includes(n.type)&&m&&e.jsxRuntimeExports.jsx(e.ChartJsVisual,{cfg:m},JSON.stringify(m)+JSON.stringify(n.preferences)+((g=n==null?void 0:n.preferences)==null?void 0:g.customVisualCode)),n.type==="table"&&n.data&&n.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:n,data:n==null?void 0:n.data})})]})]})}function ut(){const[s,r]=S.useState(!1),[t,n]=S.useState(""),[o,l]=S.useState(""),[a,c]=S.useState(""),[i,m]=S.useState(""),u=e.useEditorStore(b=>b.card),g=e.useEditorStore(b=>b.card.customCfg),{setCardCustomCfg:p,setCustomVisualCode:d}=e.useEditorActions();function j(b){var E,v;const D={...b,data:{...b==null?void 0:b.data,datasets:(v=(E=b==null?void 0:b.data)==null?void 0:E.datasets)==null?void 0:v.map(R=>({...R,data:[]}))}};return JSON.stringify(D,null,1)}function x(){var D,T;if(!u.data||u.data.length===0)return;const b=e.createChartConfig({data:u.data,cardType:u.type,cfg:u.cfg,preferences:u.preferences});b&&(n(JSON.stringify(b,null,1)),(D=u==null?void 0:u.preferences)!=null&&D.customVisualCode&&c((T=u==null?void 0:u.preferences)==null?void 0:T.customVisualCode),g&&l(JSON.stringify(g,null,1)))}function N(){if(a&&d(a),!!o)try{const b=JSON.parse(o);return b?(p(b),m(""),l(""),b):void 0}catch(b){console.log(b),m("Invalid JSON")}}function I(){l(""),p(null)}function L(){let b;if(g){const D=e._.cloneDeep(u.cfg),T=e._.merge(D,g);return b=j(T),b}return t?(b=j(JSON.parse(t)),b):""}return e.jsxRuntimeExports.jsxs(e.Dialog,{open:s,onOpenChange:r,children:[e.jsxRuntimeExports.jsx(e.DialogTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.Button,{onClick:x,className:` ${g&&"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(ns,{onClick:()=>{navigator.clipboard.writeText(u.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(Ss,{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:[g&&e.jsxRuntimeExports.jsx(e.CheckIcon,{className:"mr-1 h-5 w-5 text-green-600"}),g?"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:t,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:L(),onChange:b=>l(b)})}),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:a,onChange:b=>c(b||"")})})]})]}),e.jsxRuntimeExports.jsxs(e.DialogFooter,{className:"flex items-center",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"mr-2 text-red-500",children:i}),e.jsxRuntimeExports.jsx(e.Button,{disabled:!g,onClick:I,variant:"outline",children:"Reset"}),e.jsxRuntimeExports.jsx(e.Button,{onClick:N,variant:"outline",children:"Apply"}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>r(!1),variant:"outline",children:"Close"})]})]})]})}function vs(s){return Z({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:[]}]})(s)}function Cs(s){return Z({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:[]}]})(s)}function Ns(s){return Z({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:[]}]})(s)}function ws(s){return Z({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:[]}]})(s)}function ks(s){return Z({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:[]}]})(s)}function Is(s){return Z({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:[]}]})(s)}function Ls(s){return Z({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:[]}]})(s)}function Ds(s){return Z({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:[]}]})(s)}function Ts(){const{authToken:s}=e.useSemaphorContext(),{data:r,isLoading:t,isFetching:n,isError:o}=e.useQuery({queryKey:["plugins",s==null?void 0:s.accessToken],queryFn:()=>e.getPlugins(s==null?void 0:s.accessToken)});return{data:r,isLoading:t,isFetching:n,isError:o}}function dt({onChartTypeChange:s}){const[r,t]=S.useState([]),{data:n}=Ts();return S.useEffect(()=>{(async()=>{var l;if(n){const c=(await Promise.all((l=n==null?void 0:n.plugins)==null?void 0:l.map(async i=>(await e.loadManifest(i.value)).visuals.map(g=>({name:g.name,icon:g.icon,url:i.value}))))).flat();t(c)}})()},[n]),e.jsxRuntimeExports.jsx("div",{className:"grid grid-cols-4 place-items-center",children:r.map((o,l)=>e.jsxRuntimeExports.jsx(mt,{text:o.name,onClick:()=>s("custom",o),icon:o.icon},o.url+o.name+l))})}const mt=({text:s,icon:r,onClick:t})=>{const[n,o]=S.useState(null);S.useEffect(()=>{r&&(async()=>{const i=(await Promise.resolve().then(()=>require("./lucide-react-Q2RoCwZI.js")))[r];o(i)})()},[r]);const l=s.charAt(0).toUpperCase();return e.jsxRuntimeExports.jsx(e.Button,{onClick:t,title:s,variant:"ghost",children:n?e.jsxRuntimeExports.jsx(n,{className:"h-4 w-4"}):l})};function pt(){const[s,r]=S.useState(!1),t=e.useEditorStore(m=>m.card.type),{setCardType:n,setCardPreferences:o,setChartOrientation:l}=e.useEditorStore(m=>m.actions),{setCardCustomCfg:a,setCustomCardPreferences:c}=e.useEditorActions();function i(m,u){a(null),o({}),n(m),u&&c({type:"component",visualType:"single",url:u.url,componentName:u.name,icon:u.icon}),r(!1)}return e.jsxRuntimeExports.jsxs(e.Popover,{open:s,onOpenChange:r,children:[e.jsxRuntimeExports.jsx(e.PopoverTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.Button,{size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(jt,{className:"h-4 w-4",chartType:t})})}),e.jsxRuntimeExports.jsxs(e.PopoverContent,{className:"w-50",children:[e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-4 place-items-center",children:[e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>i("bar"),className:"font-normal",variant:"ghost",children:e.jsxRuntimeExports.jsx(be,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>i("line"),variant:"ghost",children:e.jsxRuntimeExports.jsx(ye,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>i("stackedBar"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Is,{className:"size-5",strokeWidth:0})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>i("stackedLine"),variant:"ghost",children:e.jsxRuntimeExports.jsx(ks,{className:"size-5",strokeWidth:0})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>i("scatter"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Te,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>i("bubble"),variant:"ghost",children:e.jsxRuntimeExports.jsx(ws,{className:"size-4"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>i("pie"),variant:"ghost",children:e.jsxRuntimeExports.jsx(De,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>i("doughnut"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Cs,{className:"size-5",strokeWidth:1})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>i("radar"),variant:"ghost",children:e.jsxRuntimeExports.jsx(vs,{className:"size-5 font-extralight",strokeWidth:.5})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>i("polarArea"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ns,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>i("pyramid"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ds,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>i("range"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Le,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>i("table"),variant:"ghost",children:e.jsxRuntimeExports.jsx(e.Table,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>i("kpi"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ls,{className:"size-6"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>i("text"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Se,{className:"size-4"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>i("custom"),variant:"ghost",children:e.jsxRuntimeExports.jsx(ze,{className:"size-4"})})]}),e.jsxRuntimeExports.jsx(e.Separator,{className:"my-2"}),e.jsxRuntimeExports.jsx(dt,{onChartTypeChange:i})]})]})}function jt({chartType:s,className:r}){switch(s){case"bar":return e.jsxRuntimeExports.jsx(be,{className:r});case"line":return e.jsxRuntimeExports.jsx(ye,{className:r});case"pie":return e.jsxRuntimeExports.jsx(De,{className:r});case"radar":return e.jsxRuntimeExports.jsx(vs,{className:r});case"scatter":return e.jsxRuntimeExports.jsx(Te,{className:r});case"bubble":return e.jsxRuntimeExports.jsx(ws,{className:r});case"doughnut":return e.jsxRuntimeExports.jsx(Cs,{className:r});case"stackedBar":return e.jsxRuntimeExports.jsx(Is,{className:"size-4 text-foreground/70"});case"stackedLine":return e.jsxRuntimeExports.jsx(ks,{className:"size-4 text-foreground/70"});case"polarArea":return e.jsxRuntimeExports.jsx(Ns,{className:r});case"pyramid":return e.jsxRuntimeExports.jsx(Ds,{className:r});case"range":return e.jsxRuntimeExports.jsx(Le,{className:r});case"kpi":return e.jsxRuntimeExports.jsx(Ls,{className:r});case"text":return e.jsxRuntimeExports.jsx(Se,{className:r});case"custom":return e.jsxRuntimeExports.jsx(ze,{className:r});default:return e.jsxRuntimeExports.jsx(e.Table,{className:r})}}function He(){const s=e.useEditorStore(E=>E.frame),r=e.useEditorStore(E=>E.card),t=e.useEditorStore(E=>E.card.data),n=e.useEditorStore(E=>E.isShowingVisual),o=e.useEditorStore(E=>E.isSqlRunning),l=e.useEditorStore(E=>E.queryError),a=e.useEditorStore(E=>E.pythonStdOut),c=e.useEditorStore(E=>E.actions.setRunSql);e.useEditorStore(E=>E.onSave),e.useEditorStore(E=>E.onClose),e.useEditorStore(E=>E.actions.setCardSql),e.useEditorStore(E=>E.actions.setCardType),e.useEditorStore(E=>E.actions.setSqlGen);const{setFrame:i,setCard:m,updateCardInFrame:u}=e.useEditorActions();if(!r)return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:"No Active Card"});function g(){const E={id:e.v4(),title:"Title",description:"Description",preferences:{onClickFilter:[{columnIndex:0,expression:""}]},type:"bar",sql:"",data:[]};p(E)}function p(E){const v={...s,cards:[...s.cards,E],activeCardId:E.id};i(v),m(E)}function d(){const E={...r,id:e.v4(),title:`${r.title} Copy`,tabTitle:`${r.tabTitle} Copy`};p(E)}function j(E){const v=s.cards.filter(z=>z.id!==E),R=v[0],f={...s,cards:v,activeCardId:R.id};i(f),m(R)}function x(E){const v={...s,cards:s.cards.map(f=>f.id===r.id?r:f),activeCardId:E};i(v);const R=v.cards.find(f=>f.id===E);m(R),R.sql&&R.data&&R.data.length===0&&c(!0)}const N=(E,v)=>{console.log("handleDragStart",v),E.dataTransfer.setData("tabIndex",v.toString())},I=E=>{E.preventDefault()},L=(E,v)=>{const R=E.dataTransfer.getData("tabIndex");if(R===v.toString())return;const f=Array.from(s.cards),[z]=f.splice(parseInt(R),1);f.splice(v,0,z),i({...s,cards:f})};function b(E,v){return E.cards.length===1&&(v.displayTab===!0||v.displayTab===void 0)||E.activeCardId!==v.id&&(v.displayTab===!0||v.displayTab===void 0)?null:e.jsxRuntimeExports.jsx("div",{onClick:()=>{const R=v.displayTab===void 0?!1:!v.displayTab;m({...v,displayTab:R}),u({...v,displayTab:R})},children:v.displayTab===!0||v.displayTab===void 0?e.jsxRuntimeExports.jsx(Xe,{className:"mr-2 size-3.5 text-muted-foreground hover:text-foreground"}):e.jsxRuntimeExports.jsx(Ye,{className:"mr-2 size-3.5 text-muted-foreground hover:text-foreground"})})}function D(){return e.jsxRuntimeExports.jsxs(e.Tabs,{onValueChange:x,value:s.activeCardId,className:"flex grow flex-col",children:[s.cards.map(E=>e.jsxRuntimeExports.jsx(e.TabsContent,{className:"mt-0 grow",value:E.id,children:T()},E.id)),e.jsxRuntimeExports.jsx(e.TabsList,{className:"group mx-6 justify-between",children:e.jsxRuntimeExports.jsxs("div",{className:"flex items-center",children:[s.cards.map((E,v)=>e.jsxRuntimeExports.jsx(e.Editable,{text:E.tabTitle||E.title,onSave:R=>{m({...r,tabTitle:R}),u({...r,tabTitle:R})},children:e.jsxRuntimeExports.jsxs(e.TabsTrigger,{draggable:!0,onDragStart:R=>N(R,v),onDragOver:I,onDrop:R=>L(R,v),className:"",value:E.id,children:[b(s,E),E.tabTitle||E.title,s.activeCardId===E.id&&s.cards.length>1&&e.jsxRuntimeExports.jsx(e.X,{className:"ml-2 size-3.5 text-muted-foreground hover:text-foreground",onClick:()=>j(E.id)})]})},E.id)),e.jsxRuntimeExports.jsx(e.Button,{className:"ml-1 h-8 px-2 hover:bg-muted-foreground/50",variant:"outline",onClick:g,children:e.jsxRuntimeExports.jsx(e.Plus,{className:"h-4 w-4"})}),e.jsxRuntimeExports.jsx(e.Button,{className:"invisible ml-1 h-8 px-2 hover:bg-muted-foreground/50 group-hover:visible",variant:"outline",onClick:d,children:e.jsxRuntimeExports.jsx(Ue,{className:"h-4 w-4"})})]})})]})}function T(){return r.type==="kpi"?e.jsxRuntimeExports.jsx("div",{className:"flex h-full 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:r})})}):r.type==="text"?e.jsxRuntimeExports.jsx("div",{className:"flex h-full 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:r})})}):e.jsxRuntimeExports.jsx(Ss,{className:"grow border-none shadow-none"})}return e.jsxRuntimeExports.jsxs("div",{className:"relative flex h-full flex-col py-3",children:[o&&e.jsxRuntimeExports.jsx(le,{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:[n&&e.jsxRuntimeExports.jsxs("div",{className:"flex grow items-center gap-2",children:[e.jsxRuntimeExports.jsx(pt,{}),r.type!=="table"&&e.jsxRuntimeExports.jsx(ut,{})]}),e.jsxRuntimeExports.jsx(Et,{})]}),n?D():e.jsxRuntimeExports.jsxs("div",{className:"flex min-h-0 w-full flex-1 grow basis-0 px-6",children:[a&&e.jsxRuntimeExports.jsx(ht,{}),r.data&&r.data.length>0&&e.jsxRuntimeExports.jsx(ct,{data:t||[]}),l&&e.jsxRuntimeExports.jsx("span",{className:"font-mono text-sm",children:l})]})]})}function ht(){const s=e.useEditorStore(t=>t.pythonStdOut);if(!s)return null;const r=s.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:r},className:"bg-muted p-2 font-mono text-sm"}),e.jsxRuntimeExports.jsx(e.Separator,{className:"mb-2"})]})}function Et(){const s=e.useEditorStore(t=>t.isShowingVisual),r=e.useEditorStore(t=>t.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:s,onCheckedChange:()=>r(!s),id:"visualize",className:"data-[state=checked]:bg-foreground/50"})]})}function ft({options:s,value:r,onValueChange:t}){return e.jsxRuntimeExports.jsx(e.RadioGroup,{value:r,onValueChange:t,className:"flex gap-4",defaultValue:s[0].value,children:s.map(n=>e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:n.value,id:n.value}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:n.value,children:n.label})]},n.value))})}function de({label:s,options:r,value:t,onValueChange:n,className:o}){return e.jsxRuntimeExports.jsxs(e.Select,{value:t,onValueChange:n,children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:e.cn("w-full focus:ring-0 focus:ring-offset-0",o),children:e.jsxRuntimeExports.jsx(e.SelectValue,{placeholder:s})}),e.jsxRuntimeExports.jsx(e.SelectContent,{children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[e.jsxRuntimeExports.jsx(e.SelectLabel,{children:s}),r.map(l=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:l.value,children:l.label},l.value))]})})]})}function gt(){var j;const s=e.useEditorStore(x=>x.card.customCardPreferences),{data:r}=Ts(),t=(r==null?void 0:r.plugins)||[];e.useEditorStore(x=>x.card);const n=e.useEditorStore(x=>x.frame),o=(s==null?void 0:s.visualType)||"single",{setCustomCardPreferences:l}=e.useEditorActions(),{components:a,manifest:c}=e.useCustomVisual((s==null?void 0:s.url)||""),i=(j=c==null?void 0:c.visuals)==null?void 0:j.find(x=>x.name===(s==null?void 0:s.componentName));function m(x,N){if(!s)return;const L={...(s==null?void 0:s.dataInputCardIds)||{},[x]:{cardId:N,hookRef:null}};l({...s,dataInputCardIds:L})}function u(x){var I,L;const N=(I=n==null?void 0:n.cards)==null?void 0:I.filter(b=>{var D;return((D=b==null?void 0:b.customCardPreferences)==null?void 0:D.visualType)!=="multiple"}).map(b=>({value:b.id,label:b.tabTitle||b.title}));return e.jsxRuntimeExports.jsx("div",{className:"space-y-2",children:(L=x==null?void 0:x.dataInputs)==null?void 0:L.map((b,D)=>{var T,E;return e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-10 gap-2",children:[e.jsxRuntimeExports.jsx("div",{className:"col-span-4 flex items-center",children:b}),e.jsxRuntimeExports.jsx(de,{className:"col-span-6 h-8 w-full justify-between",label:"",options:N||[],value:((E=(T=s==null?void 0:s.dataInputCardIds)==null?void 0:T[D])==null?void 0:E.cardId)||"",onValueChange:v=>m(D,v)})]},D+Math.random())})})}function g(x,N,I=[]){var L,b;return s?x==="input"?e.jsxRuntimeExports.jsx(e.Input,{className:`h-8 w-full ${e.removeRing}`,value:((L=s==null?void 0:s.settings)==null?void 0:L[N])||"",onChange:D=>{l({...s,settings:{...s==null?void 0:s.settings,[N]:D.target.value}})}},N):x==="select"?e.jsxRuntimeExports.jsx(de,{className:"h-8 w-full",label:"",options:I,value:((b=s==null?void 0:s.settings)==null?void 0:b[N])||"",onValueChange:D=>{l({...s,settings:{...s==null?void 0:s.settings,[N]:D}})}}):null:null}function p(x){const N=Object.entries((x==null?void 0:x.settings)||{});return e.jsxRuntimeExports.jsx("div",{className:"space-y-3",children:N.map(([I,L])=>e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsx(e.Label,{children:L.title}),g(L.ui,I,L.options)]},I))})}function d(x){s&&l({...s,visualType:x,componentName:""})}return e.jsxRuntimeExports.jsxs("div",{className:"space-y-4 p-6 text-sm",children:[e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsx(e.Label,{children:`${(s==null?void 0:s.type)==="component"||(s==null?void 0:s.type)===void 0?"Plugin ID":"Website URL"}`}),e.jsxRuntimeExports.jsx("div",{className:"px-2",children:e.jsxRuntimeExports.jsx(de,{className:"h-8 w-full",label:"",options:t,value:(s==null?void 0:s.url)||"",onValueChange:x=>l({...s||{url:"",componentName:""},url:x})})})]}),((s==null?void 0:s.type)==="component"||(s==null?void 0:s.type)===void 0)&&e.jsxRuntimeExports.jsx(ft,{options:[{value:"single",label:"Single Visual"},{value:"multiple",label:"Multi-Visual"}],value:o,onValueChange:d}),((s==null?void 0:s.type)==="component"||(s==null?void 0:s.type)===void 0)&&s&&e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Component"}),e.jsxRuntimeExports.jsx("div",{className:"space-y-2 px-2",children:a&&e.jsxRuntimeExports.jsx(de,{className:"h-8 w-full",label:"",options:(a==null?void 0:a.filter(x=>x.type===o).map(x=>({value:x.name,label:x.name})))||[],value:s.componentName,onValueChange:x=>{console.log("changing value",x),l({...s,componentName:x})}})})]}),i&&i.dataInputs&&e.jsxRuntimeExports.jsxs("div",{className:"space-y-3",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Input Mapping"}),e.jsxRuntimeExports.jsx("div",{className:"px-2",children:u(i)})]}),i&&i.settings&&e.jsxRuntimeExports.jsxs("div",{className:"space-y-3",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Settings"}),e.jsxRuntimeExports.jsx("div",{className:"px-2",children:p(i)})]})]})]})}function ce(){const[s,r]=S.useState([]);e.useEditorStore(u=>u.card.cfg);const t=e.useEditorStore(u=>u.card.preferences),{setCardCfg:n,setFilterOnClickColumnIndex:o,setCardPreferences:l}=e.useEditorStore(u=>u.actions),a=e.useEditorStore(u=>u.queryResultColumns);e.useEditorStore(u=>{var g;return(g=u.card.preferences)==null?void 0:g.filterOnClickColumnIndex}),S.useEffect(()=>{a&&r(new Array(a.length).fill(!1))},[a]);function c(u,g){var p,d;g?t!=null&&t.onClickFilter&&((p=t==null?void 0:t.onClickFilter)==null?void 0:p.length)>0?l({...t,onClickFilter:[...t.onClickFilter,{columnIndex:u,expression:""}]}):l({...t,onClickFilter:[{columnIndex:u,expression:""}]}):(l({...t,onClickFilter:(d=t==null?void 0:t.onClickFilter)==null?void 0:d.filter(j=>j.columnIndex!==u)}),r(j=>{const x=[...j];return x[u]=!1,x}))}function i(u,g){var d;const p=(d=t==null?void 0:t.onClickFilter)==null?void 0:d.map(j=>j.columnIndex===u?{...j,expression:g.target.value}:j);l({...t,onClickFilter:p})}function m(u){var g,p,d,j;if(s!=null&&s[u]||(p=(g=t==null?void 0:t.onClickFilter)==null?void 0:g.find(x=>x.columnIndex===u))!=null&&p.expression)return e.jsxRuntimeExports.jsx(e.Input,{value:(j=(d=t==null?void 0:t.onClickFilter)==null?void 0:d.find(x=>x.columnIndex===u))==null?void 0:j.expression,onChange:x=>i(u,x),type:"text",className:"h-9 w-full font-mono text-xs focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",placeholder:"Expression"})}return e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"On Click"}),a==null?void 0:a.map((u,g)=>{var p,d;return e.jsxRuntimeExports.jsx("div",{className:"xbg-red-100 group flex items-center justify-between space-y-2",children:e.jsxRuntimeExports.jsxs("div",{className:"grow",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2 py-2",children:[e.jsxRuntimeExports.jsx(e.Checkbox,{checked:!!((p=t==null?void 0:t.onClickFilter)!=null&&p.find(j=>j.columnIndex===g)),onCheckedChange:j=>c(g,j)}),e.jsxRuntimeExports.jsx("label",{className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:u}),e.jsxRuntimeExports.jsx("div",{className:"flex items-center gap-2",children:((d=t==null?void 0:t.onClickFilter)==null?void 0:d.find(j=>j.columnIndex===g))&&e.jsxRuntimeExports.jsx(Ae,{onClick:()=>{r(j=>{const x=[...j];return x[g]=!j[g],x})},className:"invisible size-3 cursor-pointer text-gray-400 group-hover:visible"})})]}),m(g)]})},u)})]})}function ve(){var a,c,i;const s=e.useEditorStore(m=>m.card.preferences),r=e.useEditorStore(m=>m.card.cfg),{setCardCfg:t,setCardPreferences:n,setChartOrientation:o}=e.useEditorStore(m=>m.actions);(a=r==null?void 0:r.options)!=null&&a.indexAxis;function l(m){o(m)}return e.jsxRuntimeExports.jsxs(e.RadioGroup,{value:((c=s==null?void 0:s.chartOptions)==null?void 0:c.indexAxis)||((i=r==null?void 0:r.options)==null?void 0:i.indexAxis)||"x",onValueChange:l,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 Ee="focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0";function Pe(s,r){var n,o,l;const t=e.getNumberAxis(s,r);return((l=(o=(n=s==null?void 0:s.chartOptions)==null?void 0:n.scales)==null?void 0:o[t])==null?void 0:l.type)||"linear"}function As(){var K,q,W,C,A,H;const[s,r]=S.useState(!1),t=e.useEditorStore(k=>{var w;return(w=k.card)==null?void 0:w.preferences}),n=e.useEditorStore(k=>{var w;return(w=k.card)==null?void 0:w.cfg}),o=e.getNumberAxis(t,n),[l,a]=S.useState(Pe(t)),[c,i]=S.useState(((W=(q=(K=t==null?void 0:t.chartOptions)==null?void 0:K.scales)==null?void 0:q[o])==null?void 0:W.min)||""),[m,u]=S.useState(((H=(A=(C=t==null?void 0:t.chartOptions)==null?void 0:C.scales)==null?void 0:A[o])==null?void 0:H.max)||""),[g,p]=S.useState(c||m?"custom":"auto"),[d,j]=S.useState(""),[x,N]=S.useState(0),[I,L]=S.useState(""),[b,D]=S.useState(""),[T,E]=S.useState(""),v=e.useEditorStore(k=>k.actions.setCardPreferences),{updateCardInFrame:R}=e.useEditorActions(),f=e.useEditorStore(k=>k.card),z=e.useEditorStore(k=>{var w;return(w=k.card)==null?void 0:w.type}),O=["pie","doughnut","polarArea"].includes(z);S.useEffect(()=>{var k,w,$,M,G,Q,te,ee,B,J,Y,ne,X,se;a(Pe(t)),i((($=(w=(k=t==null?void 0:t.chartOptions)==null?void 0:k.scales)==null?void 0:w[o])==null?void 0:$.min)===0?0:""),u(((Q=(G=(M=t==null?void 0:t.chartOptions)==null?void 0:M.scales)==null?void 0:G[o])==null?void 0:Q.max)||""),j(((J=(B=(ee=(te=t==null?void 0:t.chartOptions)==null?void 0:te.scales)==null?void 0:ee[o])==null?void 0:B.ticks)==null?void 0:J.stepSize)||""),N(((Y=t==null?void 0:t.numberAxisFormat)==null?void 0:Y.decimalPlaces)||0),L(((ne=t==null?void 0:t.numberAxisFormat)==null?void 0:ne.suffix)||""),D(((X=t==null?void 0:t.numberAxisFormat)==null?void 0:X.currency)||""),E(((se=t==null?void 0:t.numberAxisFormat)==null?void 0:se.locale)||"")},[s,t,o]);function F(k,w){return w===""||/^[0-9\b]+$/.test(w)?Number(w):Number(k)}function V(){const k=[...new Set(e.LOCALE_CURRENCY_PAIRS.map(w=>w.currency))];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.jsxs(e.Select,{value:b||"none",onValueChange:w=>D(w==="none"?"":w),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,{children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[e.jsxRuntimeExports.jsx(e.SelectLabel,{children:"Currency"}),e.jsxRuntimeExports.jsx(e.SelectItem,{value:"none",children:"None"}),k.map(w=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:w,children:w},w))]})})]}),e.jsxRuntimeExports.jsxs(e.Select,{value:T,onValueChange:w=>E(w),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,{children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[e.jsxRuntimeExports.jsx(e.SelectLabel,{children:"Locale"}),e.LOCALE_CURRENCY_PAIRS.map(w=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:w.locale,children:w.locale},w.locale))]})})]})]}),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:w=>N(Number(w.target.value)),id:"format",className:`col-span-6 h-8 w-full tracking-wide ${Ee}`})]})]})}function P(){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:k=>i(w=>F(w,k.target.value)),className:`col-span-1 h-8 w-full ${Ee}`}),e.jsxRuntimeExports.jsx(e.Input,{value:m,onChange:k=>u(w=>F(w,k.target.value)),id:"max",className:`col-span-1 h-8 w-full ${Ee}`})]}),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:d,onChange:k=>j(w=>F(w,k.target.value)),id:"step-size",className:`col-span-1 h-8 w-full ${Ee}`})]})]})}function _(){var M;let k={};g==="custom"&&(k={min:c,max:m,ticks:{stepSize:d}});const w={...t||{},chartOptions:{...t==null?void 0:t.chartOptions,scales:{...(M=t==null?void 0:t.chartOptions)==null?void 0:M.scales,[o]:{type:l,...l==="linear"?k:{}}}},numberAxisFormat:{decimalPlaces:x,suffix:I,currency:b,locale:T}};console.log(w),v(w);const $={...f,preferences:w};R($)}return e.jsxRuntimeExports.jsxs(e.Popover,{onOpenChange:k=>r(k),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:O,value:l,onValueChange:k=>a(k),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"})]})})]})]}),l=="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:O,id:"scale-option",value:g,onValueChange:k=>p(k),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"})]})]})]}),g==="custom"&&l=="linear"&&P(),V(),e.jsxRuntimeExports.jsx(e.SelectSeparator,{}),e.jsxRuntimeExports.jsx("div",{className:"grid grid-cols-3",children:e.jsxRuntimeExports.jsx(e.Button,{onClick:_,variant:"secondary",className:"col-span-1 col-start-3 h-8 w-full",children:"Apply"})})]})]})})]})}function Rt({idx:s}){var c;const r=e.useEditorStore(i=>{var m;return(m=i.card)==null?void 0:m.preferences}),t=e.useEditorStore(i=>{var m;return(m=i.card.preferences)==null?void 0:m.datasetOptions}),n=e.useEditorStore(i=>i.actions.setCardPreferences),o=(c=r==null?void 0:r.chartOptions)==null?void 0:c.indexAxis,l=t==null?void 0:t.find(i=>i.idx===s);function a(i,m){(i==="end"||i==="start")&&e.getContrastColor(e.getCanvasBackgroundColor());const u={display:i!=="none",align:i,anchor:i,clamp:!0};if(!l)n({...r,datasetOptions:[...t||[],{idx:m,datalabels:u}]});else{const g={...l};g.datalabels=u;const p=t==null?void 0:t.map(d=>d.idx===m?g:d);n({...r,datasetOptions:p})}}return e.jsxRuntimeExports.jsxs(e.Popover,{children:[e.jsxRuntimeExports.jsx(e.PopoverTrigger,{children:e.jsxRuntimeExports.jsx(js,{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:()=>a("none",s),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:()=>a("start",s),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsxRuntimeExports.jsx(rs,{className:e.cn("h-4 w-4",{"rotate-90":o==="y"})})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>a("center",s),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsxRuntimeExports.jsx(is,{className:e.cn("h-4 w-4",{"rotate-90":o==="y"})})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>a("end",s),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsxRuntimeExports.jsx(os,{className:e.cn("h-4 w-4",{"rotate-90":o==="y"})})})]})})]})}function zs(){const s=e.useEditorStore(i=>i.card),r=e.useEditorStore(i=>{var m,u,g;return(g=(u=(m=i==null?void 0:i.card)==null?void 0:m.preferences)==null?void 0:u.chartOptions)==null?void 0:g.indexAxis}),t=r==="y"?"Y axis":"X axis",n=r==="y"?"X axis":"Y axis",{keys:o,metricKeys:l,dimensionKeys:a}=e.getKeys(s.data||[]);let c=l;if(["stackedBar","stackedLine"].includes(s.type)){const i=e.pivotData({dataArray:s.data||[],groupKey:a[0],pivotKey:a[1],valueKey:c[0]}),{metricKeys:m}=e.getKeys(i);c=m}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:t}),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:a[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:n}),e.jsxRuntimeExports.jsx(As,{})]}),e.jsxRuntimeExports.jsx("div",{className:"my-1 space-y-1",children:c.map((i,m)=>e.jsxRuntimeExports.jsx(bt,{col:i,idx:m},i))})]})]})}function bt({col:s,idx:r}){const t=e.useEditorStore(c=>{var i;return(i=c.card)==null?void 0:i.preferences}),n=e.useEditorStore(c=>{var i;return(i=c.card.preferences)==null?void 0:i.datasetOptions}),o=n==null?void 0:n.find(c=>c.idx===r),{setCardPreferences:l}=e.useEditorStore(c=>c.actions);function a(c){if(!o)l({...t,datasetOptions:[...n||[],{idx:r,type:c==="area"?"line":c,fill:c==="area"?"origin":""}]});else{const i={...o};i.type=c==="area"?"line":c,i.fill=c==="area"?"origin":"";const m=n==null?void 0:n.map(u=>u.idx===r?i:u);l({...t,datasetOptions:m})}}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:s}),e.jsxRuntimeExports.jsxs("div",{className:"flex gap-2",children:[e.jsxRuntimeExports.jsx(be,{onClick:()=>a("bar"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsxRuntimeExports.jsx(ye,{onClick:()=>a("line"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsxRuntimeExports.jsx(Ge,{onClick:()=>a("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(Rt,{idx:r})]})]})}function Fs(){const s=e.useEditorStore(p=>p.selectedConnectionId),r=e.useEditorStore(p=>p.selectedDatamodelId),t=e.useEditorStore(p=>p.selectedDatabaseName),n=e.useEditorStore(p=>p.selectedSchemaName),o=e.useEditorStore(p=>p.selectedTableName),l=e.useDashboardStore(p=>p.dashboard.filters)||[],a=e.useDashboardStore(p=>p.actions.addFilter),c=e.useDashboardStore(p=>p.actions.removeFilter),i=e.useDashboardStore(p=>p.actions.removeFilterValue),{modelItems:m,tableName:u}=oe();function g(p,d="dashboard"){var E;const j=e.fmt(p.column_name),x=e.fmt(t||""),N=e.fmt(n||""),I=e.fmt(u);let L=e.getQualifiedTableName(N,I),b=`${L}.${j}`;const D=(E=m==null?void 0:m.find(v=>v.id===r))==null?void 0:E.name;r&&r!=="none"&&(b=`${e.DATAMODEL_NAMESPCACE}.${D}.${j}`,L=`${e.DATAMODEL_NAMESPCACE}.${D}`);const T=l==null?void 0:l.find(v=>v.column===b&&v.table===I&&(v.database===x||v.database===t));if(T)i(T.id),c(T.id);else{const v=e.v4();return u==="api"&&s?(a({location:d,id:v,column:b,title:p.column_name,dataType:p.data_type,table:"api",database:"",connectionId:s,operation:"in",sql:e.getDefaultFilterSql(p.data_type,L,j)}),v):(a({id:v,location:d,column:b,title:p.column_name,dataType:p.data_type,table:o||"",database:t||"",connectionId:s||"",operation:"in",sql:e.getDefaultFilterSql(p.data_type,L,j)}),v)}}return{assignFilter:g}}function xe(){const s=e.useDashboardStore(c=>c.dashboard.filters),r=e.useEditorStore(c=>c.frame),{setFrame:t}=e.useEditorActions(),{columns:n}=oe(),{assignFilter:o}=Fs();function l(c){const i=o(c,"frame");t({...r,filterId:i})}const a=s==null?void 0:s.find(c=>c.id===r.filterId);return e.jsxRuntimeExports.jsxs("div",{className:"space-y-3",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Card Filter"}),e.jsxRuntimeExports.jsx(yt,{onSelect:l,columns:n}),a&&e.jsxRuntimeExports.jsx(e.FilterHeader,{filter:a})]})}function yt({columns:s,onSelect:r}){var a;const[t,n]=qe.useState(!1),[o,l]=qe.useState("");return e.jsxRuntimeExports.jsxs(e.Popover,{open:t,onOpenChange:n,children:[e.jsxRuntimeExports.jsx(e.PopoverTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsxs(e.Button,{size:"sm",variant:"outline",role:"combobox","aria-expanded":t,className:"w-full justify-between font-normal",children:[o?(a=s.find(c=>c.column_name===o))==null?void 0:a.column_name:"Select Column...",e.jsxRuntimeExports.jsx(e.CaretSortIcon,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsxRuntimeExports.jsx(e.PopoverContent,{className:"w-[200px] p-0",children:e.jsxRuntimeExports.jsxs(e.Command,{children:[e.jsxRuntimeExports.jsx(e.CommandInput,{placeholder:"Search column",className:"h-9"}),e.jsxRuntimeExports.jsxs(e.CommandList,{children:[e.jsxRuntimeExports.jsx(e.CommandEmpty,{children:"No framework found."}),e.jsxRuntimeExports.jsx(e.CommandGroup,{children:s.map(c=>e.jsxRuntimeExports.jsxs(e.CommandItem,{value:c.column_name,onSelect:i=>{const m=i===o?"":i;l(m),n(!1),m&&r(c)},children:[c.column_name,e.jsxRuntimeExports.jsx(e.CheckIcon,{className:e.cn("ml-auto h-4 w-4",o===c.column_name?"opacity-100":"opacity-0")})]},c.column_name))})]})]})})]})}function St({cardType:s}){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(s)} 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:r=>r.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(ve,{}),e.jsxRuntimeExports.jsx(zs,{})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filters"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 px-2",children:[e.jsxRuntimeExports.jsx(ce,{}),e.jsxRuntimeExports.jsx(xe,{})]})]})]})})}function Me(){var o,l,a;const s=e.useEditorStore(c=>c.card.cfg),r=e.useEditorStore(c=>c.actions.setCardCfg),t=e.useEditorStore(c=>c.card.type);function n(c){var u;const i={datalabels:{display:c!=="none",align:c,anchor:c,clamp:!0}},m={...s,options:{...s==null?void 0:s.options,plugins:{...(u=s==null?void 0:s.options)==null?void 0:u.plugins,...i}}};r(m),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(t)&&e.jsxRuntimeExports.jsx(As,{})]}),e.jsxRuntimeExports.jsxs(e.Select,{value:(a=(l=(o=s==null?void 0:s.options)==null?void 0:o.plugins)==null?void 0:l.datalabels)==null?void 0:a.anchor,onValueChange:n,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"}),t!=="pyramid"&&e.jsxRuntimeExports.jsx(e.SelectItem,{value:"start",children:"Start"}),e.jsxRuntimeExports.jsx(e.SelectItem,{value:"center",children:"Center"}),t!=="pyramid"&&e.jsxRuntimeExports.jsx(e.SelectItem,{value:"end",children:"End"})]})})]})]})}function vt({cardType:s}){function r(t){const n="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:"rounded bg-muted px-2 py-1 text-xs",children:t==="bubble"?n:o}),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:"group - category"}),e.jsxRuntimeExports.jsx("li",{children:"x-axis - category"}),e.jsxRuntimeExports.jsx("li",{children:"y-axis - category"}),t==="bubble"&&e.jsxRuntimeExports.jsx("li",{children:"radius - number"})]}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:l=>l.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:"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(s)} Chart`}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:"space-y-4 font-mono text-xs",children:r(s)})]}),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:"Filters"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 px-2",children:[e.jsxRuntimeExports.jsx(ce,{}),e.jsxRuntimeExports.jsx(xe,{})]})]})]})})}const Ct={datasets:[{type:"line",label:"Sum_sales",data:[]},{type:"bar",label:"Sum_profit",data:[]}]},Nt={datasets:[{fill:"origin",type:"line",label:"Sum_sales",data:[]}]};function wt(){const s=e.useEditorStore(r=>r.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:kt(s)}),e.jsxRuntimeExports.jsx("section",{className:"",children:["line","bar"].includes(s)&&e.jsxRuntimeExports.jsx(ve,{})}),!["kpi"].includes(s)&&e.jsxRuntimeExports.jsxs("div",{className:"space-y-4",children:[e.jsxRuntimeExports.jsx(Me,{}),e.jsxRuntimeExports.jsx(ce,{}),e.jsxRuntimeExports.jsx(xe,{})]})]})}function kt(s){if(["line","bar"].includes(s))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(Ct,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(Nt,null,2)})]})]})]});if(s==="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:s})," 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(s==="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:s})," 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(s))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:s==="polarArea"?"Polar":s.charAt(0).toUpperCase()+s.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 It(){var i,m,u,g,p;const s=e.useEditorStore(d=>d.card.preferences),r=e.useEditorStore(d=>d.actions.setCardPreferences),t=e.useEditorStore(d=>d.actions.setNumberFormat);e.useEditorStore(d=>{var j,x;return(x=(j=d.card.preferences)==null?void 0:j.formatNumber)==null?void 0:x.decimalPlaces});const n=e.useEditorStore(d=>{var j,x;return(x=(j=d.card.preferences)==null?void 0:j.formatNumber)==null?void 0:x.locale}),o=e.useEditorStore(d=>{var j,x;return(x=(j=d.card.preferences)==null?void 0:j.formatNumber)==null?void 0:x.currency});e.useEditorStore(d=>d.actions.setFilterOnClickField);const l=e.useEditorStore(d=>{var j,x;return(x=(j=d.card.preferences)==null?void 0:j.formatNumber)==null?void 0:x.colorRanges})||[],a=e.useEditorStore(d=>d.actions.setColorRanges),c=[...new Set(e.LOCALE_CURRENCY_PAIRS.map(d=>d.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:!!((i=s==null?void 0:s.formatNumber)!=null&&i.enabled),onCheckedChange:d=>{r({...s,formatNumber:{...s==null?void 0:s.formatNumber,enabled:d}})}}),e.jsxRuntimeExports.jsx(e.Label,{children:"Format Number"})]}),((m=s==null?void 0:s.formatNumber)==null?void 0:m.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:n||"en-US",onValueChange:d=>{var j,x,N;return t(((j=s==null?void 0:s.formatNumber)==null?void 0:j.decimalPlaces)||0,((x=s==null?void 0:s.formatNumber)==null?void 0:x.currency)||"",d||"en-US",((N=s==null?void 0:s.formatNumber)==null?void 0:N.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(d=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:d.locale,children:d.locale},d.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:d=>{var j,x,N;return t(((j=s==null?void 0:s.formatNumber)==null?void 0:j.decimalPlaces)||0,d==="none"?"":d,((x=s==null?void 0:s.formatNumber)==null?void 0:x.locale)||"",((N=s==null?void 0:s.formatNumber)==null?void 0:N.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(d=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:d,children:d},d))]})})]})]})]}),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:((g=(u=s==null?void 0:s.formatNumber)==null?void 0:u.decimalPlaces)==null?void 0:g.toString())||"0",onValueChange:d=>{var j,x,N;return t(Number(d),((j=s==null?void 0:s.formatNumber)==null?void 0:j.currency)||"",((x=s==null?void 0:s.formatNumber)==null?void 0:x.locale)||"",((N=s==null?void 0:s.formatNumber)==null?void 0:N.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(d=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:d,children:d},d))})]})]}),e.jsxRuntimeExports.jsxs("div",{className:"w-full space-y-1",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Suffix"}),e.jsxRuntimeExports.jsx(e.Input,{value:((p=s==null?void 0:s.formatNumber)==null?void 0:p.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:d=>{var j,x,N;return t(((j=s==null?void 0:s.formatNumber)==null?void 0:j.decimalPlaces)||0,((x=s==null?void 0:s.formatNumber)==null?void 0:x.currency)||"",((N=s==null?void 0:s.formatNumber)==null?void 0:N.locale)||"",d.target.value)}})]})]})]})}),e.jsxRuntimeExports.jsx(e.Separator,{className:"my-3"}),e.jsxRuntimeExports.jsx(e.ColorFormat,{colorRanges:l,setColorRanges:a})]})]})}function Lt(){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:s=>s.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(It,{})}),e.jsxRuntimeExports.jsx("div",{}),e.jsxRuntimeExports.jsx("div",{})]})}function Dt(){var n;const s=e.useEditorStore(o=>o.card.preferences),{setCardPreferences:r}=e.useEditorStore(o=>o.actions);function t(o){r({...s,textVisualOptions:{...s==null?void 0:s.textVisualOptions,isDynamicText:o==="dynamic"}})}return e.jsxRuntimeExports.jsxs(e.RadioGroup,{value:(n=s==null?void 0:s.textVisualOptions)!=null&&n.isDynamicText?"dynamic":"static",onValueChange:t,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 fe({cardType:s,docContent:r,suffix:t="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(s)} ${t}`}),e.jsxRuntimeExports.jsx(e.AccordionContent,{children:r||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:n=>n.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:[s==="range"&&e.jsxRuntimeExports.jsx(ve,{}),s!=="text"&&e.jsxRuntimeExports.jsx(Me,{}),s==="text"&&e.jsxRuntimeExports.jsx(Dt,{})]})]}),!["range","text"].includes(s)&&e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filters"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 px-2",children:[e.jsxRuntimeExports.jsx(ce,{}),e.jsxRuntimeExports.jsx(xe,{})]})]})]})})}function Tt(){const s=e.useEditorStore(n=>{var o,l;return(l=(o=n==null?void 0:n.card)==null?void 0:o.preferences)==null?void 0:l.sortChart}),{setSortChart:r}=e.useEditorActions();function t(){return e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Sort"}),e.jsxRuntimeExports.jsx(de,{className:"h-8",label:"Sort Chart",options:[{label:"None",value:"none"},{label:"ASC",value:"asc"},{label:"DESC",value:"desc"}],value:s||"none",onValueChange:n=>{r(n)}})]})}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:n=>n.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(ve,{}),t(),e.jsxRuntimeExports.jsx(zs,{})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filters"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 px-2",children:[e.jsxRuntimeExports.jsx(ce,{}),e.jsxRuntimeExports.jsx(xe,{})]})]})]})})}function At({}){const s=e.useEditorStore(n=>{var o;return(o=n.card)==null?void 0:o.preferences}),r=e.useEditorStore(n=>n.actions.setCardPreferences),t=n=>{r({...s,allowDownload:n})};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:"Filters"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 px-2",children:[e.jsxRuntimeExports.jsx(ce,{}),e.jsxRuntimeExports.jsx(xe,{})]})]})}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.Checkbox,{onCheckedChange:t,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 zt=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:s=>s.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#pyramid-chart",children:"example"})," in the docs."]})]}),Ft=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:s=>s.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#range-charts",children:"example"})," in the docs."]})]}),Mt=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:s=>s.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#text-visual",children:"example"})," in the docs."]})]});function Ot(){const s=e.useEditorStore(t=>t.card.type);function r(t){switch(t){case"stackedBar":case"stackedLine":return e.jsxRuntimeExports.jsx(Tt,{});case"pyramid":return e.jsxRuntimeExports.jsx(fe,{docContent:zt,cardType:t});case"kpi":return e.jsxRuntimeExports.jsx(Lt,{});case"line":case"bar":return e.jsxRuntimeExports.jsx(St,{cardType:t});case"range":return e.jsxRuntimeExports.jsx(fe,{docContent:Ft,cardType:t});case"pie":case"doughnut":case"polarArea":case"radar":return e.jsxRuntimeExports.jsx(fe,{cardType:t});case"bubble":case"scatter":return e.jsxRuntimeExports.jsx(vt,{cardType:t});case"table":return e.jsxRuntimeExports.jsx(At,{cardType:t});case"text":return e.jsxRuntimeExports.jsx(fe,{docContent:Mt,cardType:t,suffix:"Visual"});case"custom":return e.jsxRuntimeExports.jsx(gt,{});default:return e.jsxRuntimeExports.jsx(wt,{})}}return e.jsxRuntimeExports.jsx(e.ScrollArea,{className:"h-full w-full text-sm",children:r(s)})}function Vt(){const s=e.useEditorStore(r=>r.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(lt,{})}),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:s?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(Ot,{})})}),e.jsxRuntimeExports.jsx(e.ResizableHandle,{className:"border"}),e.jsxRuntimeExports.jsx(e.ResizablePanel,{minSize:40,defaultSize:75,maxSize:100,children:e.jsxRuntimeExports.jsx(He,{})})]}):e.jsxRuntimeExports.jsx(He,{})})]})}function qt({authToken:s,onSave:r,onClose:t}){const n=e.useEditorStore(a=>a.actions.setOnSave),o=e.useEditorStore(a=>a.actions.setOnClose),l=e.useDashboardStore(a=>a.actions.setAuthToken);return S.useEffect(()=>{r&&n(r),t&&o(t)},[r,n,t,o]),S.useEffect(()=>{s&&s.accessToken&&l(s)},[s,l]),e.jsxRuntimeExports.jsx(e.ErrorBoundary,{FallbackComponent:e.Fallback,children: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(Rs,{})}),e.jsxRuntimeExports.jsx(e.EditorMain,{children:e.jsxRuntimeExports.jsx(Vt,{})})]})})}function _t(){e.useDashboardStore(a=>a.selectedCardId);const s=e.useDashboardStore(a=>a.selectedSheetId),{setIsVisualEditing:r}=e.useDashboardStore(a=>a.actions),t=e.useDashboardStore(a=>a.isVisualEditing),n=e.useDashboardStore(a=>a.actions.updateFrame);function o(a){s&&(n(s,a),r(!1))}function l(){r(!1)}return e.jsxRuntimeExports.jsx("div",{role:"editor-container",className:e.cn("flex grow",{block:t,hidden:!t}),children:e.jsxRuntimeExports.jsx(qt,{onSave:o,onClose:l})})}function Bt(){e.useEditorStore(a=>a.selectedConnectionId),e.useEditorStore(a=>a.selectedDatamodelId);const s=e.useEditorStore(a=>a.selectedDatabaseName);e.useEditorStore(a=>a.selectedSchemaName);const r=e.useEditorStore(a=>a.selectedTableName),t=e.useDashboardStore(a=>a.dashboard.filters)||[];e.useDashboardStore(a=>a.actions.addFilter),e.useDashboardStore(a=>a.actions.removeFilter),e.useDashboardStore(a=>a.actions.removeFilterValue);const{modelItems:n,columns:o}=oe(),{assignFilter:l}=Fs();return e.jsxRuntimeExports.jsx("div",{className:"xbg-red-100 flex-1 basis-0 flex-col overflow-scroll px-3",children:o==null?void 0:o.map(a=>{const c=t==null?void 0:t.find(i=>i.column===e.fmt(a.column_name)&&i.table===r&&i.database===s);return e.jsxRuntimeExports.jsx("div",{onClick:()=>l(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":c}),children:e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxRuntimeExports.jsx(gs,{column:a}),e.jsxRuntimeExports.jsx("span",{children:a.column_name})]})},a.column_name)})})}function Ht(){e.useDashboardStore(r=>r.showFilters);const s=e.useDashboardStore(r=>r.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:()=>s(!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(Rs,{ColumnsComponent:()=>e.jsxRuntimeExports.jsx(Bt,{})})})]})}function Pt(){const s=e.useDashboardStore(t=>t.showFilters),r=e.useDashboardStore(t=>t.isVisualEditing);return e.jsxRuntimeExports.jsxs("div",{role:"dashboard-plus-main",className:e.cn("grow",{hidden:r,flex:!r}),children:[e.jsxRuntimeExports.jsx(e.DashboardTabs,{}),s&&e.jsxRuntimeExports.jsx("div",{role:"filter-aside-container",className:"flex",children:e.jsxRuntimeExports.jsx(Ht,{})})]})}function $t(){const s=e.useDashboardStore(n=>n.dashboard),r=e.useDashboardStore(n=>n.actions.setDashboard),t=e.useDashboardStore(n=>n.showDashboardJSON);return e.useDashboardStore(n=>n.actions.setShowDashboardJSON),e.jsxRuntimeExports.jsx("div",{className:e.cn(" p-2",{hidden:!t}),children:e.jsxRuntimeExports.jsx(e.de,{onChange:n=>{if(n)try{JSON.parse(n),r(JSON.parse(n))}catch{}},defaultLanguage:"json",className:"h-[550px] overflow-y-auto ",value:JSON.stringify(s,null,2),options:{minimap:{enabled:!1},glyphMargin:!1,wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:12,renderLineHighlight:"none"}})})}function Gt({showControls:s=!1,showFooter:r=!0,...t}){return e.jsxRuntimeExports.jsx(e.ErrorBoundary,{FallbackComponent:e.Fallback,children:e.jsxRuntimeExports.jsxs(e.SemaphorContextProvider,{dashboardProps:t,children:[e.jsxRuntimeExports.jsx(e.Te,{}),e.jsxRuntimeExports.jsxs(e.UXProvider,{children:[e.jsxRuntimeExports.jsx($t,{}),e.jsxRuntimeExports.jsxs(e.DashboardPanel,{...t,children:[s&&e.jsxRuntimeExports.jsx($s,{}),e.jsxRuntimeExports.jsx(_t,{}),e.jsxRuntimeExports.jsx(Pt,{})]})]})]})})}exports.Box=$e;exports.ChartArea=Ge;exports.ChartColumnIncreasing=be;exports.ChartLine=ye;exports.ChartNoAxesGantt=Le;exports.ChartPie=De;exports.ChartScatter=Te;exports.CircleX=Qe;exports.CopyPlus=Ue;exports.DashboardPlus=Gt;exports.Database=Ke;exports.EllipsisVertical=We;exports.Eraser=Je;exports.Eye=Xe;exports.EyeClosed=Ye;exports.Glasses=Ze;exports.Hammer=es;exports.Hash=ss;exports.House=ts;exports.Key=ns;exports.ListEnd=rs;exports.ListStart=os;exports.ListX=is;exports.LoaderCircle=le;exports.MessageSquareMore=as;exports.Network=ls;exports.Pencil=Ae;exports.Play=cs;exports.Plug2=xs;exports.Save=us;exports.SelectComponent=ae;exports.Shapes=ze;exports.ShieldQuestion=ds;exports.Sigma=ms;exports.SwatchBook=ps;exports.Tag=js;exports.ToggleLeft=hs;exports.Type=Se;exports.User=Es;exports.cleanCard=fs;exports.getDashbaordStateWithoutData=Fe;exports.useEditorAside=oe;
240
+ Visual Query Syntax: ${Xs}`,{data:E,isLoading:v,isFetching:R,isError:f,refetch:z}=e.useQuery({queryKey:["ai-query"],queryFn:()=>e.getRequest("https://semaphor.cloud/api/v1/ai",(i==null?void 0:i.accessToken)||"",{user_content:`userContent: ${D} ${m?T:""}`}),enabled:!1});function O(C){if(C.toLowerCase().includes("bar"))j("bar");else if(C.toLowerCase().includes("line"))j("line");else if(C.toLowerCase().includes("bubble"))j("bubble");else if(C.toLowerCase().includes("scatter"))j("scatter");else if(C.toLowerCase().includes("stacked"))j("stackedBar");else if(C.toLowerCase().includes("pie"))j("pie");else if(C.toLowerCase().includes("donut")||C.toLowerCase().includes("doughnut"))j("doughnut");else if(C.toLowerCase().includes("radar"))j("radar");else return j("bar"),!1;return!0}S.useEffect(()=>{E&&N(C=>[...C,{role:"ai",content:E.response}])},[E]),S.useEffect(()=>{const C=setTimeout(()=>{var A;c.current&&(c.current.scroll({top:c.current.scrollHeight,behavior:"smooth"}),(A=a.current)==null||A.focus())},100);return()=>clearTimeout(C)},[x]);function F(){t&&(N(C=>[...C,{role:"user",content:t}]),O(t)&&u(!0),n(""),z())}S.useEffect(()=>{o&&(F(),l(!1))},[o,l]);const V={fontFamily:"Arial, sans-serif",lineHeight:1.6,fontSize:15,width:"100%"},P={fontFamily:"monospace",fontSize:14,lineHeight:1.6},_={fontFamily:"Arial, sans-serif",lineHeight:1.6,fontSize:15,padding:"2px 0",marginLeft:20,listStyleType:"disc"},K={p:({node:C,...A})=>e.jsxRuntimeExports.jsx("p",{style:V,...A}),code:({node:C,...A})=>e.jsxRuntimeExports.jsx("code",{className:"rounded-sm bg-muted px-2 py-1 text-sm",...A}),pre:({node:C,...A})=>e.jsxRuntimeExports.jsxs("pre",{className:"space-y-2 rounded-sm bg-muted/50 p-3",style:P,children:[e.jsxRuntimeExports.jsx("code",{className:"whitespace-normal text-sm",children:A.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:H=>{const k=q(H);k&&(r(!1),g(k),d(!0))},size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(e.PlayIcon,{})})]})]}),li:({node:C,...A})=>e.jsxRuntimeExports.jsx("li",{style:_,...A})};function q(C){const A=C.currentTarget.closest("pre");if(!A)return;const H=A.textContent||A.innerText;return navigator.clipboard.writeText(H).then(()=>console.log("Text copied to clipboard")).catch(k=>console.error("Error in copying text: ",k)),H}function W(){return x==null?void 0:x.map((C,A)=>C.role==="user"?e.jsxRuntimeExports.jsxs("div",{className:"flex items-start rounded-md bg-muted p-3 text-sm",children:[e.jsxRuntimeExports.jsx(Es,{className:"mr-2 h-5 w-5"}),e.jsxRuntimeExports.jsx("div",{children:C.content})]},A):C.role==="ai"?e.jsxRuntimeExports.jsx(e.Markdown,{className:"w-full overflow-auto py-1",components:K,children:E==null?void 0:E.response.replace(/DuckDB/gi,"Semaphor")},A):e.jsxRuntimeExports.jsx("div",{},A))}return e.jsxRuntimeExports.jsxs(e.Dialog,{open:s,onOpenChange:r,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:W()})}),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:a,onKeyDown:C=>{C.key==="Enter"&&!C.shiftKey&&(C.preventDefault(),n(""),F())},placeholder:"Type your question here...",onFocus:C=>{const A=C.target,H=A.value.length;A.setSelectionRange(H,H)},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:v||R,value:t,onChange:C=>n(C.target.value)})," ",e.jsxRuntimeExports.jsx(e.Button,{className:"h-8",size:"sm",variant:"ghost",onClick:F,children:!v&&!R?e.jsxRuntimeExports.jsx(e.PaperPlaneIcon,{}):e.jsxRuntimeExports.jsx(le,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"})})]})})]})]})}var bs={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},_e=S.createContext&&S.createContext(bs),et=["attr","size","title"];function st(s,r){if(s==null)return{};var t=tt(s,r),n,o;if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(s);for(o=0;o<l.length;o++)n=l[o],!(r.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(s,n)&&(t[n]=s[n])}return t}function tt(s,r){if(s==null)return{};var t={},n=Object.keys(s),o,l;for(l=0;l<n.length;l++)o=n[l],!(r.indexOf(o)>=0)&&(t[o]=s[o]);return t}function ge(){return ge=Object.assign?Object.assign.bind():function(s){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(s[n]=t[n])}return s},ge.apply(this,arguments)}function Be(s,r){var t=Object.keys(s);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(s);r&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(s,o).enumerable})),t.push.apply(t,n)}return t}function Re(s){for(var r=1;r<arguments.length;r++){var t=arguments[r]!=null?arguments[r]:{};r%2?Be(Object(t),!0).forEach(function(n){nt(s,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(t)):Be(Object(t)).forEach(function(n){Object.defineProperty(s,n,Object.getOwnPropertyDescriptor(t,n))})}return s}function nt(s,r,t){return r=rt(r),r in s?Object.defineProperty(s,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):s[r]=t,s}function rt(s){var r=ot(s,"string");return typeof r=="symbol"?r:String(r)}function ot(s,r){if(typeof s!="object"||s===null)return s;var t=s[Symbol.toPrimitive];if(t!==void 0){var n=t.call(s,r||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(s)}function ys(s){return s&&s.map((r,t)=>S.createElement(r.tag,Re({key:t},r.attr),ys(r.child)))}function Z(s){return r=>S.createElement(it,ge({attr:Re({},s.attr)},r),ys(s.child))}function it(s){var r=t=>{var{attr:n,size:o,title:l}=s,a=st(s,et),c=o||t.size||"1em",i;return t.className&&(i=t.className),s.className&&(i=(i?i+" ":"")+s.className),S.createElement("svg",ge({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},t.attr,n,a,{className:i,style:Re(Re({color:s.color||t.color},t.style),s.style),height:c,width:c,xmlns:"http://www.w3.org/2000/svg"}),l&&S.createElement("title",null,l),s.children)};return _e!==void 0?S.createElement(_e.Consumer,null,t=>r(t)):r(bs)}function at(s){return Z({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:[]}]})(s)}function lt(){const{theme:s}=e.useTheme(),r=S.useRef(),t=S.useRef(),[n,o]=S.useState(!1),[l,a]=S.useState(!1),[c,i]=S.useState(!1),[m,u]=S.useState(""),[g,p]=S.useState(!1),{authToken:d}=e.useSemaphorContext();e.useDashboardStore(h=>h.selectedSheetId);const j=e.useDashboardStore(h=>h.dashboard.baseQueries),x=e.useEditorStore(h=>h.card),N=e.useDashboardStore(h=>h.theme),I=e.useEditorStore(h=>h.isShowingVisual);e.useDashboardStore(h=>h.onAcceptChanges);const L=e.useEditorStore(h=>h.selectedConnectionId),b=e.useEditorStore(h=>h.selectedDatabaseName),D=e.useEditorStore(h=>h.selectedDatamodelId),T=e.useEditorStore(h=>h.selectedSchemaName);e.useDashboardStore(h=>h.actions.updateFrameCard);const E=e.useEditorStore(h=>h.selectedTableName),v=e.useEditorStore(h=>h.card.sql),R=e.useEditorStore(h=>h.card.python),f=e.resolveBaseQuery(v,j),z=e.useEditorStore(h=>h.selectedConnectionId),O=e.useEditorStore(h=>h.frame),F=e.useDashboardStore(h=>h.filterValues),V=e.useEditorStore(h=>h.applyFilters),{setCardCustomCfg:P,setQueryResultColumns:_,setFilterValues:K,setCardSql:q,setCardPython:W,setQueryError:C,setPythonStdOut:A,setCardPreferences:H}=e.useEditorStore(h=>h.actions),k=e.useEditorStore(h=>h.onSave),w=e.useEditorStore(h=>h.actions.setApplyFilters),$=e.useEditorStore(h=>h.onClose),M=e.useEditorStore(h=>h.actions.setCardData),G=e.useEditorStore(h=>h.actions.setSqlGen),Q=e.useEditorStore(h=>h.runSql),te=e.useEditorStore(h=>h.actions.setRunSql),ee=e.useEditorStore(h=>h.actions.setIsSqlRunning),{data:B,isLoading:J,isFetching:Y,isSuccess:ne,isError:X,error:se,status:Oe,refetch:ie}=e.useQuery({queryKey:[f,R],queryFn:()=>e.postRequest("https://semaphor.cloud/api/v1/query",(d==null?void 0:d.accessToken)||"",{connection_id:z,sql:f,python:R===e.PYTHON_DEFAULT_CODE?"":R,active_filters:V?F:[]}),enabled:!1,retry:!1});S.useEffect(()=>{if(B&&(M(B.records),B.rowLimitExceeded&&e.Jt.error("Row limit (10,000) exceeded. Refine your query.",{position:"top-center",richColors:!0}),A((B==null?void 0:B.output)||""),B.records.length>0)){const{dimensionKeys:h}=e.getKeys(B.records);_(h)}},[B,M,_,A]),S.useEffect(()=>{Q&&(ie(),te(!1))},[Q,ie,te]),S.useEffect(()=>{(J||Y)&&ee(!0),(X||ne)&&ee(!1),X?(C(se.message),M([]),_([]),A("")):C("")},[J,Y,B,A,X,ne,ee,M,_,C,se]);function Ce(){q(""),M([]),G({}),P(""),H({})}const me=h=>{t.current=h};function Ne(h,y){if(h.length===0)return"";if(y){const re=h.find(U=>U.id===y);if(re){const U=re.tabTitle;if(U=="All__Header")return h[0].id;if(U&&U.endsWith("__Header")){const Ms=U.split("__")[0],Ve=h.find(Os=>Os.tabTitle===Ms);return Ve?Ve.id:h[0].id}return y}}return h[0].id}function we(){let h=v;v&&!v.includes("{{")&&(h=Us(v),q(h));const y={...x,lastSelectedSchema:T,lastSelectedDatamodelId:D,lastSelectedDatabase:b,lastSelectedTable:E,connectionId:L,type:I?x.type:"table",sql:h,customCfg:I?x.customCfg:null},re=O.cards.map(ke=>ke.id===x.id?y:ke),U={...O,cards:re,activeCardId:Ne(re,O.activeCardId)};k==null||k(U)}function pe(){$==null||$()}S.useEffect(()=>{const h=r.current,y=t.current;if(h){const re=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",U=N==="system"?re:N;h.editor.defineTheme("default",{base:U==="light"?"vs":"vs-dark",inherit:!0,rules:[],colors:{"editor.background":U==="light"?"#ffffff":e.getCssVariableValue("--semaphor-background")}}),h.editor.setTheme("default")}return y&&h&&y.addCommand(h.KeyMod.Shift|h.KeyCode.Enter,function(){return console.log("Executing query..."),ie(),!1}),()=>{}},[s,N,r.current]);function ue(h){r.current=h}function je(){return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[l&&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(Ws,{checked:V,onCheckedChange:()=>w(!V),text:"Apply Filters"}),e.jsxRuntimeExports.jsx(Ys,{}),F&&l&&e.jsxRuntimeExports.jsx(e.Cross2Icon,{onClick:()=>a(!1),className:"bg-background/50 text-foreground/50 hover:cursor-pointer hover:text-foreground"})]}),e.jsxRuntimeExports.jsx(e.Ft,{theme:"default",onChange:h=>{if(h)try{JSON.parse(h),K(JSON.parse(h))}catch{}},defaultLanguage:"json",className:"mt-1 min-h-[220px]",value:JSON.stringify(F,null,2),options:{readOnly:!0,minimap:{enabled:!1},lineNumbers:"off",glyphMargin:!1,wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:12,renderLineHighlight:"none"}})]})}),F&&!l&&e.jsxRuntimeExports.jsx(e.Filter,{onClick:()=>a(!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":V})})]})}function he(){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:n?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:h=>{q(h)},value:v,options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"sql",beforeMount:ue,onMount:me})}),n&&e.jsxRuntimeExports.jsx("code",{className:"absolute right-6 top-3 text-sm text-muted-foreground/70",children:"sql"})]}),n&&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:h=>{W(h&&h.trim()||"")},value:R||e.PYTHON_DEFAULT_CODE,options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"python",beforeMount:ue,onMount:me})}),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:[he(),je()]}),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||Y,onClick:()=>{ie()},className:"shrink-0",size:"sm",variant:"outline",children:[J||Y?e.jsxRuntimeExports.jsx(le,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"}):e.jsxRuntimeExports.jsx(cs,{className:"mr-2 h-4 w-4"}),"Run"]}),X&&e.jsxRuntimeExports.jsx(Ks,{error:se.message,setShowAIDialog:i,setTriggerAIRun:p,setUserInputforAI:u}),e.jsxRuntimeExports.jsxs(e.Button,{onClick:Ce,className:"",size:"sm",variant:"outline",children:[e.jsxRuntimeExports.jsx(Je,{className:"mr-2 size-4"}),"Clear"]}),e.jsxRuntimeExports.jsx(e.Toggle,{pressed:n,onPressedChange:h=>o(h),className:"",size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(at,{className:"size-4 text-foreground/70"})}),e.jsxRuntimeExports.jsx(Zs,{open:c,setOpen:i,userInput:m,triggerAIRun:g,setTriggerAIRun:p,setUserInput:h=>u(h)})]}),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:pe,className:"w-full",size:"sm",variant:"outline",children:[e.jsxRuntimeExports.jsx(e.Cross2Icon,{className:"mr-2 size-4"}),"Close"]})]})]})]})}function ct({data:s}){var a;const[r,t]=S.useState([]),o=Object.keys(s[0]).map(c=>({accessorKey:c,header:({column:i})=>{const m=i.getIsSorted();return e.jsxRuntimeExports.jsx("div",{className:"flex gap-2",children:e.jsxRuntimeExports.jsxs("div",{className:"flex cursor-pointer items-center",onClick:()=>i.toggleSorting(i.getIsSorted()==="asc"),children:[c,m==="asc"?e.jsxRuntimeExports.jsx(e.TriangleUpIcon,{className:"ml-2 h-5 w-5"}):m==="desc"?e.jsxRuntimeExports.jsx(e.TriangleDownIcon,{className:"ml-2 h-5 w-5"}):null]})})}})),l=e.useReactTable({data:s,columns:o,getCoreRowModel:e.getCoreRowModel(),getPaginationRowModel:e.getPaginationRowModel(),onSortingChange:t,getSortedRowModel:e.getSortedRowModel(),manualPagination:!0,state:{sorting:r}});return e.jsxRuntimeExports.jsxs(e.Table$1,{children:[e.jsxRuntimeExports.jsx(e.TableHeader,{children:l.getHeaderGroups().map(c=>e.jsxRuntimeExports.jsx(e.TableRow,{children:c.headers.map(i=>e.jsxRuntimeExports.jsx(e.TableHead,{className:"sticky top-0 bg-muted",children:i.isPlaceholder?null:e.flexRender(i.column.columnDef.header,i.getContext())},i.id))},c.id))}),e.jsxRuntimeExports.jsx(e.TableBody,{children:(a=l.getRowModel().rows)!=null&&a.length?l.getRowModel().rows.map(c=>e.jsxRuntimeExports.jsx(e.TableRow,{className:"whitespace-nowrap py-2","data-state":c.getIsSelected()&&"selected",children:c.getVisibleCells().map(i=>e.jsxRuntimeExports.jsx(e.TableCell,{children:e.flexRender(i.column.columnDef.cell,i.getContext())},i.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 xt({card:s}){var c,i,m,u,g,p,d,j;(c=s.customCardPreferences)!=null&&c.inputData;const{getCard:r}=e.useCustomVisual(((i=s.customCardPreferences)==null?void 0:i.url)||""),t=((m=s.customCardPreferences)==null?void 0:m.visualType)||"single",n=e.useEditorStore(x=>x.frame);if(e.useEditorActions(),!((u=s.customCardPreferences)!=null&&u.componentName))return null;const o=r((g=s.customCardPreferences)==null?void 0:g.componentName),l=x=>{console.log("data",x),s.customCardPreferences},a=Object.keys(((p=s.customCardPreferences)==null?void 0:p.dataInputCardIds)||{}).map(x=>{var L,b,D;const N=(b=(L=s.customCardPreferences)==null?void 0:L.dataInputCardIds)==null?void 0:b[x].cardId,I=(D=n==null?void 0:n.cards)==null?void 0:D.find(T=>T.id===N);return I||null});return e.jsxRuntimeExports.jsx("div",{className:"semaphor-custom mb-3 flex grow basis-0 flex-col space-y-2 overflow-y-auto",children:e.jsxRuntimeExports.jsxs(S.Suspense,{fallback:e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{}),children:[o&&t==="single"&&e.jsxRuntimeExports.jsx(o,{settings:(d=s.customCardPreferences)==null?void 0:d.settings,onDataChange:l,data:s.data}),o&&t==="multiple"&&e.jsxRuntimeExports.jsx("div",{className:"flex flex-col gap-2",children:e.jsxRuntimeExports.jsx(o,{onDataChange:l,settings:a.map(x=>{var N;return(N=x==null?void 0:x.customCardPreferences)==null?void 0:N.settings}),data:a.map(x=>(x==null?void 0:x.data)||[])})})]},(j=s.customCardPreferences)==null?void 0:j.componentName)})}function Ss({className:s,...r}){var g;S.useState(0);const t=e.useDashboardStore(p=>p.themeStyle),n=e.useEditorStore(p=>p.card),o=e.useEditorStore(p=>p.frame),l=e.useDashboardStore(p=>p.dashboard.filters);e.useDashboardStore(p=>p.filterValues),e.useEditorStore(p=>p.actions.setRunSql);const{updateFilter:a}=e.useDashboardActions(),c=l==null?void 0:l.find(p=>p.id===o.filterId),i=e.useEditorStore(p=>p.actions.setCard);if(S.useEffect(()=>{},[n.data,n.type,n.cfg,n.customCfg,t,n.preferences]),!n.id)return null;let m;n.data&&n.data.length>0&&(m=e.createChartConfig({data:n.data,cardType:n.type,cfg:n.cfg,customCfg:n.customCfg,preferences:n.preferences}));function u(p){return e.jsxRuntimeExports.jsx(xt,{card:p})}return e.jsxRuntimeExports.jsxs(e.Card,{role:"editor-visual-card",className:e.cn("relative flex h-full flex-col rounded-none",s),...r,children:[e.jsxRuntimeExports.jsxs(e.CardHeader,{className:"flex flex-row items-start justify-between py-4",children:[e.jsxRuntimeExports.jsxs("div",{children:[e.jsxRuntimeExports.jsx(e.Editable,{text:n.title,onSave:p=>i({...n,title:p}),children:e.jsxRuntimeExports.jsx("div",{className:"flex items-center gap-2",children:e.jsxRuntimeExports.jsx(e.CardTitle,{className:"text-base",children:n.title})})},n.title),e.jsxRuntimeExports.jsx(e.Editable,{text:n.description||"",onSave:p=>i({...n,description:p}),children:e.jsxRuntimeExports.jsxs(e.CardDescription,{children:[" ",n.description]})},n.description)]}),c&&e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxRuntimeExports.jsx(e.Editable,{className:"my-1",text:c.title||c.column,onSave:p=>a({...c,title:p}),children:e.jsxRuntimeExports.jsx(e.Label,{children:c.title})}),e.getFilterComponent(c)]})]}),e.jsxRuntimeExports.jsxs(e.CardContent,{className:"flex grow flex-col",children:[n.type==="custom"&&u(n),!["table","custom"].includes(n.type)&&m&&e.jsxRuntimeExports.jsx(e.ChartJsVisual,{cfg:m},JSON.stringify(m)+JSON.stringify(n.preferences)+((g=n==null?void 0:n.preferences)==null?void 0:g.customVisualCode)),n.type==="table"&&n.data&&n.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:n,data:n==null?void 0:n.data})})]})]})}function ut(){const[s,r]=S.useState(!1),[t,n]=S.useState(""),[o,l]=S.useState(""),[a,c]=S.useState(""),[i,m]=S.useState(""),u=e.useEditorStore(b=>b.card),g=e.useEditorStore(b=>b.card.customCfg),{setCardCustomCfg:p,setCustomVisualCode:d}=e.useEditorActions();function j(b){var E,v;const D={...b,data:{...b==null?void 0:b.data,datasets:(v=(E=b==null?void 0:b.data)==null?void 0:E.datasets)==null?void 0:v.map(R=>({...R,data:[]}))}};return JSON.stringify(D,null,1)}function x(){var D,T;if(!u.data||u.data.length===0)return;const b=e.createChartConfig({data:u.data,cardType:u.type,cfg:u.cfg,preferences:u.preferences});b&&(n(JSON.stringify(b,null,1)),(D=u==null?void 0:u.preferences)!=null&&D.customVisualCode&&c((T=u==null?void 0:u.preferences)==null?void 0:T.customVisualCode),g&&l(JSON.stringify(g,null,1)))}function N(){if(a&&d(a),!!o)try{const b=JSON.parse(o);return b?(p(b),m(""),l(""),b):void 0}catch(b){console.log(b),m("Invalid JSON")}}function I(){l(""),p(null)}function L(){let b;if(g){const D=e._.cloneDeep(u.cfg),T=e._.merge(D,g);return b=j(T),b}return t?(b=j(JSON.parse(t)),b):""}return e.jsxRuntimeExports.jsxs(e.Dialog,{open:s,onOpenChange:r,children:[e.jsxRuntimeExports.jsx(e.DialogTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.Button,{onClick:x,className:` ${g&&"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(ns,{onClick:()=>{navigator.clipboard.writeText(u.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(Ss,{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:[g&&e.jsxRuntimeExports.jsx(e.CheckIcon,{className:"mr-1 h-5 w-5 text-green-600"}),g?"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:t,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:L(),onChange:b=>l(b)})}),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:a,onChange:b=>c(b||"")})})]})]}),e.jsxRuntimeExports.jsxs(e.DialogFooter,{className:"flex items-center",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"mr-2 text-red-500",children:i}),e.jsxRuntimeExports.jsx(e.Button,{disabled:!g,onClick:I,variant:"outline",children:"Reset"}),e.jsxRuntimeExports.jsx(e.Button,{onClick:N,variant:"outline",children:"Apply"}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>r(!1),variant:"outline",children:"Close"})]})]})]})}function vs(s){return Z({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:[]}]})(s)}function Cs(s){return Z({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:[]}]})(s)}function Ns(s){return Z({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:[]}]})(s)}function ws(s){return Z({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:[]}]})(s)}function ks(s){return Z({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:[]}]})(s)}function Is(s){return Z({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:[]}]})(s)}function Ls(s){return Z({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:[]}]})(s)}function Ds(s){return Z({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:[]}]})(s)}function Ts(){const{authToken:s}=e.useSemaphorContext(),{data:r,isLoading:t,isFetching:n,isError:o}=e.useQuery({queryKey:["plugins",s==null?void 0:s.accessToken],queryFn:()=>e.getPlugins(s==null?void 0:s.accessToken)});return{data:r,isLoading:t,isFetching:n,isError:o}}function dt({onChartTypeChange:s}){const[r,t]=S.useState([]),{data:n}=Ts();return S.useEffect(()=>{(async()=>{var l;if(n){const c=(await Promise.all((l=n==null?void 0:n.plugins)==null?void 0:l.map(async i=>(await e.loadManifest(i.value)).visuals.map(g=>({name:g.name,icon:g.icon,url:i.value}))))).flat();t(c)}})()},[n]),e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(e.Separator,{className:"my-2"}),e.jsxRuntimeExports.jsx("div",{className:"grid grid-cols-4 place-items-center",children:r.map((o,l)=>e.jsxRuntimeExports.jsx(mt,{text:o.name,onClick:()=>s("custom",o),icon:o.icon},o.url+o.name+l))})]})}const mt=({text:s,icon:r,onClick:t})=>{const[n,o]=S.useState(null);S.useEffect(()=>{r&&(async()=>{const i=(await Promise.resolve().then(()=>require("./lucide-react-dz8u_KCM.js")))[r];o(i)})()},[r]);const l=s.charAt(0).toUpperCase();return e.jsxRuntimeExports.jsx(e.Button,{onClick:t,title:s,variant:"ghost",children:n?e.jsxRuntimeExports.jsx(n,{className:"h-4 w-4"}):l})};function pt(){const[s,r]=S.useState(!1),t=e.useEditorStore(m=>m.card.type),{setCardType:n,setCardPreferences:o,setChartOrientation:l}=e.useEditorStore(m=>m.actions),{setCardCustomCfg:a,setCustomCardPreferences:c}=e.useEditorActions();function i(m,u){a(null),o({}),n(m),u&&c({type:"component",visualType:"single",url:u.url,componentName:u.name,icon:u.icon}),r(!1)}return e.jsxRuntimeExports.jsxs(e.Popover,{open:s,onOpenChange:r,children:[e.jsxRuntimeExports.jsx(e.PopoverTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.Button,{size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(jt,{className:"h-4 w-4",chartType:t})})}),e.jsxRuntimeExports.jsxs(e.PopoverContent,{className:"w-50",children:[e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-4 place-items-center",children:[e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>i("bar"),className:"font-normal",variant:"ghost",children:e.jsxRuntimeExports.jsx(be,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>i("line"),variant:"ghost",children:e.jsxRuntimeExports.jsx(ye,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>i("stackedBar"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Is,{className:"size-5",strokeWidth:0})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>i("stackedLine"),variant:"ghost",children:e.jsxRuntimeExports.jsx(ks,{className:"size-5",strokeWidth:0})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>i("scatter"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Te,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>i("bubble"),variant:"ghost",children:e.jsxRuntimeExports.jsx(ws,{className:"size-4"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>i("pie"),variant:"ghost",children:e.jsxRuntimeExports.jsx(De,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>i("doughnut"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Cs,{className:"size-5",strokeWidth:1})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>i("radar"),variant:"ghost",children:e.jsxRuntimeExports.jsx(vs,{className:"size-5 font-extralight",strokeWidth:.5})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>i("polarArea"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ns,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>i("pyramid"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ds,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>i("range"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Le,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>i("table"),variant:"ghost",children:e.jsxRuntimeExports.jsx(e.Table,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>i("kpi"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ls,{className:"size-6"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>i("text"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Se,{className:"size-4"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>i("custom"),variant:"ghost",children:e.jsxRuntimeExports.jsx(ze,{className:"size-4"})})]}),e.jsxRuntimeExports.jsx(dt,{onChartTypeChange:i})]})]})}function jt({chartType:s,className:r}){switch(s){case"bar":return e.jsxRuntimeExports.jsx(be,{className:r});case"line":return e.jsxRuntimeExports.jsx(ye,{className:r});case"pie":return e.jsxRuntimeExports.jsx(De,{className:r});case"radar":return e.jsxRuntimeExports.jsx(vs,{className:r});case"scatter":return e.jsxRuntimeExports.jsx(Te,{className:r});case"bubble":return e.jsxRuntimeExports.jsx(ws,{className:r});case"doughnut":return e.jsxRuntimeExports.jsx(Cs,{className:r});case"stackedBar":return e.jsxRuntimeExports.jsx(Is,{className:"size-4 text-foreground/70"});case"stackedLine":return e.jsxRuntimeExports.jsx(ks,{className:"size-4 text-foreground/70"});case"polarArea":return e.jsxRuntimeExports.jsx(Ns,{className:r});case"pyramid":return e.jsxRuntimeExports.jsx(Ds,{className:r});case"range":return e.jsxRuntimeExports.jsx(Le,{className:r});case"kpi":return e.jsxRuntimeExports.jsx(Ls,{className:r});case"text":return e.jsxRuntimeExports.jsx(Se,{className:r});case"custom":return e.jsxRuntimeExports.jsx(ze,{className:r});default:return e.jsxRuntimeExports.jsx(e.Table,{className:r})}}function He(){const s=e.useEditorStore(E=>E.frame),r=e.useEditorStore(E=>E.card),t=e.useEditorStore(E=>E.card.data),n=e.useEditorStore(E=>E.isShowingVisual),o=e.useEditorStore(E=>E.isSqlRunning),l=e.useEditorStore(E=>E.queryError),a=e.useEditorStore(E=>E.pythonStdOut),c=e.useEditorStore(E=>E.actions.setRunSql);e.useEditorStore(E=>E.onSave),e.useEditorStore(E=>E.onClose),e.useEditorStore(E=>E.actions.setCardSql),e.useEditorStore(E=>E.actions.setCardType),e.useEditorStore(E=>E.actions.setSqlGen);const{setFrame:i,setCard:m,updateCardInFrame:u}=e.useEditorActions();if(!r)return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:"No Active Card"});function g(){const E={id:e.v4(),title:"Title",description:"Description",preferences:{onClickFilter:[{columnIndex:0,expression:""}]},type:"bar",sql:"",data:[]};p(E)}function p(E){const v={...s,cards:[...s.cards,E],activeCardId:E.id};i(v),m(E)}function d(){const E={...r,id:e.v4(),title:`${r.title} Copy`,tabTitle:`${r.tabTitle} Copy`};p(E)}function j(E){const v=s.cards.filter(z=>z.id!==E),R=v[0],f={...s,cards:v,activeCardId:R.id};i(f),m(R)}function x(E){const v={...s,cards:s.cards.map(f=>f.id===r.id?r:f),activeCardId:E};i(v);const R=v.cards.find(f=>f.id===E);m(R),R.sql&&R.data&&R.data.length===0&&c(!0)}const N=(E,v)=>{console.log("handleDragStart",v),E.dataTransfer.setData("tabIndex",v.toString())},I=E=>{E.preventDefault()},L=(E,v)=>{const R=E.dataTransfer.getData("tabIndex");if(R===v.toString())return;const f=Array.from(s.cards),[z]=f.splice(parseInt(R),1);f.splice(v,0,z),i({...s,cards:f})};function b(E,v){return E.cards.length===1&&(v.displayTab===!0||v.displayTab===void 0)||E.activeCardId!==v.id&&(v.displayTab===!0||v.displayTab===void 0)?null:e.jsxRuntimeExports.jsx("div",{onClick:()=>{const R=v.displayTab===void 0?!1:!v.displayTab;m({...v,displayTab:R}),u({...v,displayTab:R})},children:v.displayTab===!0||v.displayTab===void 0?e.jsxRuntimeExports.jsx(Xe,{className:"mr-2 size-3.5 text-muted-foreground hover:text-foreground"}):e.jsxRuntimeExports.jsx(Ye,{className:"mr-2 size-3.5 text-muted-foreground hover:text-foreground"})})}function D(){return e.jsxRuntimeExports.jsxs(e.Tabs,{onValueChange:x,value:s.activeCardId,className:"flex grow flex-col",children:[s.cards.map(E=>e.jsxRuntimeExports.jsx(e.TabsContent,{className:"mt-0 grow",value:E.id,children:T()},E.id)),e.jsxRuntimeExports.jsx(e.TabsList,{className:"group mx-6 justify-between",children:e.jsxRuntimeExports.jsxs("div",{className:"flex items-center",children:[s.cards.map((E,v)=>e.jsxRuntimeExports.jsx(e.Editable,{text:E.tabTitle||E.title,onSave:R=>{m({...r,tabTitle:R}),u({...r,tabTitle:R})},children:e.jsxRuntimeExports.jsxs(e.TabsTrigger,{draggable:!0,onDragStart:R=>N(R,v),onDragOver:I,onDrop:R=>L(R,v),className:"",value:E.id,children:[b(s,E),E.tabTitle||E.title,s.activeCardId===E.id&&s.cards.length>1&&e.jsxRuntimeExports.jsx(e.X,{className:"ml-2 size-3.5 text-muted-foreground hover:text-foreground",onClick:()=>j(E.id)})]})},E.id)),e.jsxRuntimeExports.jsx(e.Button,{className:"ml-1 h-8 px-2 hover:bg-muted-foreground/50",variant:"outline",onClick:g,children:e.jsxRuntimeExports.jsx(e.Plus,{className:"h-4 w-4"})}),e.jsxRuntimeExports.jsx(e.Button,{className:"invisible ml-1 h-8 px-2 hover:bg-muted-foreground/50 group-hover:visible",variant:"outline",onClick:d,children:e.jsxRuntimeExports.jsx(Ue,{className:"h-4 w-4"})})]})})]})}function T(){return r.type==="kpi"?e.jsxRuntimeExports.jsx("div",{className:"flex h-full 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:r})})}):r.type==="text"?e.jsxRuntimeExports.jsx("div",{className:"flex h-full 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:r})})}):e.jsxRuntimeExports.jsx(Ss,{className:"grow border-none shadow-none"})}return e.jsxRuntimeExports.jsxs("div",{className:"relative flex h-full flex-col py-3",children:[o&&e.jsxRuntimeExports.jsx(le,{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:[n&&e.jsxRuntimeExports.jsxs("div",{className:"flex grow items-center gap-2",children:[e.jsxRuntimeExports.jsx(pt,{}),r.type!=="table"&&e.jsxRuntimeExports.jsx(ut,{})]}),e.jsxRuntimeExports.jsx(Et,{})]}),n?D():e.jsxRuntimeExports.jsxs("div",{className:"flex min-h-0 w-full flex-1 grow basis-0 px-6",children:[a&&e.jsxRuntimeExports.jsx(ht,{}),r.data&&r.data.length>0&&e.jsxRuntimeExports.jsx(ct,{data:t||[]}),l&&e.jsxRuntimeExports.jsx("span",{className:"font-mono text-sm",children:l})]})]})}function ht(){const s=e.useEditorStore(t=>t.pythonStdOut);if(!s)return null;const r=s.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:r},className:"bg-muted p-2 font-mono text-sm"}),e.jsxRuntimeExports.jsx(e.Separator,{className:"mb-2"})]})}function Et(){const s=e.useEditorStore(t=>t.isShowingVisual),r=e.useEditorStore(t=>t.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:s,onCheckedChange:()=>r(!s),id:"visualize",className:"data-[state=checked]:bg-foreground/50"})]})}function ft({options:s,value:r,onValueChange:t}){return e.jsxRuntimeExports.jsx(e.RadioGroup,{value:r,onValueChange:t,className:"flex gap-4",defaultValue:s[0].value,children:s.map(n=>e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:n.value,id:n.value}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:n.value,children:n.label})]},n.value))})}function de({label:s,options:r,value:t,onValueChange:n,className:o}){return e.jsxRuntimeExports.jsxs(e.Select,{value:t,onValueChange:n,children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:e.cn("w-full focus:ring-0 focus:ring-offset-0",o),children:e.jsxRuntimeExports.jsx(e.SelectValue,{placeholder:s})}),e.jsxRuntimeExports.jsx(e.SelectContent,{children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[e.jsxRuntimeExports.jsx(e.SelectLabel,{children:s}),r.map(l=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:l.value,children:l.label},l.value))]})})]})}function gt(){var j;const s=e.useEditorStore(x=>x.card.customCardPreferences),{data:r}=Ts(),t=(r==null?void 0:r.plugins)||[];e.useEditorStore(x=>x.card);const n=e.useEditorStore(x=>x.frame),o=(s==null?void 0:s.visualType)||"single",{setCustomCardPreferences:l}=e.useEditorActions(),{components:a,manifest:c}=e.useCustomVisual((s==null?void 0:s.url)||""),i=(j=c==null?void 0:c.visuals)==null?void 0:j.find(x=>x.name===(s==null?void 0:s.componentName));function m(x,N){if(!s)return;const L={...(s==null?void 0:s.dataInputCardIds)||{},[x]:{cardId:N,hookRef:null}};l({...s,dataInputCardIds:L})}function u(x){var I,L;const N=(I=n==null?void 0:n.cards)==null?void 0:I.filter(b=>{var D;return((D=b==null?void 0:b.customCardPreferences)==null?void 0:D.visualType)!=="multiple"}).map(b=>({value:b.id,label:b.tabTitle||b.title}));return e.jsxRuntimeExports.jsx("div",{className:"space-y-2",children:(L=x==null?void 0:x.dataInputs)==null?void 0:L.map((b,D)=>{var T,E;return e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-10 gap-2",children:[e.jsxRuntimeExports.jsx("div",{className:"col-span-4 flex items-center",children:b}),e.jsxRuntimeExports.jsx(de,{className:"col-span-6 h-8 w-full justify-between",label:"",options:N||[],value:((E=(T=s==null?void 0:s.dataInputCardIds)==null?void 0:T[D])==null?void 0:E.cardId)||"",onValueChange:v=>m(D,v)})]},D+Math.random())})})}function g(x,N,I=[]){var L,b;return s?x==="input"?e.jsxRuntimeExports.jsx(e.Input,{className:`h-8 w-full ${e.removeRing}`,value:((L=s==null?void 0:s.settings)==null?void 0:L[N])||"",onChange:D=>{l({...s,settings:{...s==null?void 0:s.settings,[N]:D.target.value}})}},N):x==="select"?e.jsxRuntimeExports.jsx(de,{className:"h-8 w-full",label:"",options:I,value:((b=s==null?void 0:s.settings)==null?void 0:b[N])||"",onValueChange:D=>{l({...s,settings:{...s==null?void 0:s.settings,[N]:D}})}}):null:null}function p(x){const N=Object.entries((x==null?void 0:x.settings)||{});return e.jsxRuntimeExports.jsx("div",{className:"space-y-3",children:N.map(([I,L])=>e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsx(e.Label,{children:L.title}),g(L.ui,I,L.options)]},I))})}function d(x){s&&l({...s,visualType:x,componentName:""})}return e.jsxRuntimeExports.jsxs("div",{className:"space-y-4 p-6 text-sm",children:[e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsx(e.Label,{children:`${(s==null?void 0:s.type)==="component"||(s==null?void 0:s.type)===void 0?"Plugin ID":"Website URL"}`}),e.jsxRuntimeExports.jsx("div",{className:"px-2",children:e.jsxRuntimeExports.jsx(de,{className:"h-8 w-full",label:"",options:t,value:(s==null?void 0:s.url)||"",onValueChange:x=>l({...s||{url:"",componentName:""},url:x})})})]}),((s==null?void 0:s.type)==="component"||(s==null?void 0:s.type)===void 0)&&e.jsxRuntimeExports.jsx(ft,{options:[{value:"single",label:"Single Visual"},{value:"multiple",label:"Multi-Visual"}],value:o,onValueChange:d}),((s==null?void 0:s.type)==="component"||(s==null?void 0:s.type)===void 0)&&s&&e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Component"}),e.jsxRuntimeExports.jsx("div",{className:"space-y-2 px-2",children:a&&e.jsxRuntimeExports.jsx(de,{className:"h-8 w-full",label:"",options:(a==null?void 0:a.filter(x=>x.type===o).map(x=>({value:x.name,label:x.name})))||[],value:s.componentName,onValueChange:x=>{console.log("changing value",x),l({...s,componentName:x})}})})]}),i&&i.dataInputs&&e.jsxRuntimeExports.jsxs("div",{className:"space-y-3",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Input Mapping"}),e.jsxRuntimeExports.jsx("div",{className:"px-2",children:u(i)})]}),i&&i.settings&&e.jsxRuntimeExports.jsxs("div",{className:"space-y-3",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Settings"}),e.jsxRuntimeExports.jsx("div",{className:"px-2",children:p(i)})]})]})]})}function ce(){const[s,r]=S.useState([]);e.useEditorStore(u=>u.card.cfg);const t=e.useEditorStore(u=>u.card.preferences),{setCardCfg:n,setFilterOnClickColumnIndex:o,setCardPreferences:l}=e.useEditorStore(u=>u.actions),a=e.useEditorStore(u=>u.queryResultColumns);e.useEditorStore(u=>{var g;return(g=u.card.preferences)==null?void 0:g.filterOnClickColumnIndex}),S.useEffect(()=>{a&&r(new Array(a.length).fill(!1))},[a]);function c(u,g){var p,d;g?t!=null&&t.onClickFilter&&((p=t==null?void 0:t.onClickFilter)==null?void 0:p.length)>0?l({...t,onClickFilter:[...t.onClickFilter,{columnIndex:u,expression:""}]}):l({...t,onClickFilter:[{columnIndex:u,expression:""}]}):(l({...t,onClickFilter:(d=t==null?void 0:t.onClickFilter)==null?void 0:d.filter(j=>j.columnIndex!==u)}),r(j=>{const x=[...j];return x[u]=!1,x}))}function i(u,g){var d;const p=(d=t==null?void 0:t.onClickFilter)==null?void 0:d.map(j=>j.columnIndex===u?{...j,expression:g.target.value}:j);l({...t,onClickFilter:p})}function m(u){var g,p,d,j;if(s!=null&&s[u]||(p=(g=t==null?void 0:t.onClickFilter)==null?void 0:g.find(x=>x.columnIndex===u))!=null&&p.expression)return e.jsxRuntimeExports.jsx(e.Input,{value:(j=(d=t==null?void 0:t.onClickFilter)==null?void 0:d.find(x=>x.columnIndex===u))==null?void 0:j.expression,onChange:x=>i(u,x),type:"text",className:"h-9 w-full font-mono text-xs focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",placeholder:"Expression"})}return e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"On Click"}),a==null?void 0:a.map((u,g)=>{var p,d;return e.jsxRuntimeExports.jsx("div",{className:"xbg-red-100 group flex items-center justify-between space-y-2",children:e.jsxRuntimeExports.jsxs("div",{className:"grow",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2 py-2",children:[e.jsxRuntimeExports.jsx(e.Checkbox,{checked:!!((p=t==null?void 0:t.onClickFilter)!=null&&p.find(j=>j.columnIndex===g)),onCheckedChange:j=>c(g,j)}),e.jsxRuntimeExports.jsx("label",{className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:u}),e.jsxRuntimeExports.jsx("div",{className:"flex items-center gap-2",children:((d=t==null?void 0:t.onClickFilter)==null?void 0:d.find(j=>j.columnIndex===g))&&e.jsxRuntimeExports.jsx(Ae,{onClick:()=>{r(j=>{const x=[...j];return x[g]=!j[g],x})},className:"invisible size-3 cursor-pointer text-gray-400 group-hover:visible"})})]}),m(g)]})},u)})]})}function ve(){var a,c,i;const s=e.useEditorStore(m=>m.card.preferences),r=e.useEditorStore(m=>m.card.cfg),{setCardCfg:t,setCardPreferences:n,setChartOrientation:o}=e.useEditorStore(m=>m.actions);(a=r==null?void 0:r.options)!=null&&a.indexAxis;function l(m){o(m)}return e.jsxRuntimeExports.jsxs(e.RadioGroup,{value:((c=s==null?void 0:s.chartOptions)==null?void 0:c.indexAxis)||((i=r==null?void 0:r.options)==null?void 0:i.indexAxis)||"x",onValueChange:l,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 Ee="focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0";function Pe(s,r){var n,o,l;const t=e.getNumberAxis(s,r);return((l=(o=(n=s==null?void 0:s.chartOptions)==null?void 0:n.scales)==null?void 0:o[t])==null?void 0:l.type)||"linear"}function As(){var K,q,W,C,A,H;const[s,r]=S.useState(!1),t=e.useEditorStore(k=>{var w;return(w=k.card)==null?void 0:w.preferences}),n=e.useEditorStore(k=>{var w;return(w=k.card)==null?void 0:w.cfg}),o=e.getNumberAxis(t,n),[l,a]=S.useState(Pe(t)),[c,i]=S.useState(((W=(q=(K=t==null?void 0:t.chartOptions)==null?void 0:K.scales)==null?void 0:q[o])==null?void 0:W.min)||""),[m,u]=S.useState(((H=(A=(C=t==null?void 0:t.chartOptions)==null?void 0:C.scales)==null?void 0:A[o])==null?void 0:H.max)||""),[g,p]=S.useState(c||m?"custom":"auto"),[d,j]=S.useState(""),[x,N]=S.useState(0),[I,L]=S.useState(""),[b,D]=S.useState(""),[T,E]=S.useState(""),v=e.useEditorStore(k=>k.actions.setCardPreferences),{updateCardInFrame:R}=e.useEditorActions(),f=e.useEditorStore(k=>k.card),z=e.useEditorStore(k=>{var w;return(w=k.card)==null?void 0:w.type}),O=["pie","doughnut","polarArea"].includes(z);S.useEffect(()=>{var k,w,$,M,G,Q,te,ee,B,J,Y,ne,X,se;a(Pe(t)),i((($=(w=(k=t==null?void 0:t.chartOptions)==null?void 0:k.scales)==null?void 0:w[o])==null?void 0:$.min)===0?0:""),u(((Q=(G=(M=t==null?void 0:t.chartOptions)==null?void 0:M.scales)==null?void 0:G[o])==null?void 0:Q.max)||""),j(((J=(B=(ee=(te=t==null?void 0:t.chartOptions)==null?void 0:te.scales)==null?void 0:ee[o])==null?void 0:B.ticks)==null?void 0:J.stepSize)||""),N(((Y=t==null?void 0:t.numberAxisFormat)==null?void 0:Y.decimalPlaces)||0),L(((ne=t==null?void 0:t.numberAxisFormat)==null?void 0:ne.suffix)||""),D(((X=t==null?void 0:t.numberAxisFormat)==null?void 0:X.currency)||""),E(((se=t==null?void 0:t.numberAxisFormat)==null?void 0:se.locale)||"")},[s,t,o]);function F(k,w){return w===""||/^[0-9\b]+$/.test(w)?Number(w):Number(k)}function V(){const k=[...new Set(e.LOCALE_CURRENCY_PAIRS.map(w=>w.currency))];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.jsxs(e.Select,{value:b||"none",onValueChange:w=>D(w==="none"?"":w),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,{children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[e.jsxRuntimeExports.jsx(e.SelectLabel,{children:"Currency"}),e.jsxRuntimeExports.jsx(e.SelectItem,{value:"none",children:"None"}),k.map(w=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:w,children:w},w))]})})]}),e.jsxRuntimeExports.jsxs(e.Select,{value:T,onValueChange:w=>E(w),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,{children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[e.jsxRuntimeExports.jsx(e.SelectLabel,{children:"Locale"}),e.LOCALE_CURRENCY_PAIRS.map(w=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:w.locale,children:w.locale},w.locale))]})})]})]}),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:w=>N(Number(w.target.value)),id:"format",className:`col-span-6 h-8 w-full tracking-wide ${Ee}`})]})]})}function P(){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:k=>i(w=>F(w,k.target.value)),className:`col-span-1 h-8 w-full ${Ee}`}),e.jsxRuntimeExports.jsx(e.Input,{value:m,onChange:k=>u(w=>F(w,k.target.value)),id:"max",className:`col-span-1 h-8 w-full ${Ee}`})]}),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:d,onChange:k=>j(w=>F(w,k.target.value)),id:"step-size",className:`col-span-1 h-8 w-full ${Ee}`})]})]})}function _(){var M;let k={};g==="custom"&&(k={min:c,max:m,ticks:{stepSize:d}});const w={...t||{},chartOptions:{...t==null?void 0:t.chartOptions,scales:{...(M=t==null?void 0:t.chartOptions)==null?void 0:M.scales,[o]:{type:l,...l==="linear"?k:{}}}},numberAxisFormat:{decimalPlaces:x,suffix:I,currency:b,locale:T}};console.log(w),v(w);const $={...f,preferences:w};R($)}return e.jsxRuntimeExports.jsxs(e.Popover,{onOpenChange:k=>r(k),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:O,value:l,onValueChange:k=>a(k),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"})]})})]})]}),l=="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:O,id:"scale-option",value:g,onValueChange:k=>p(k),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"})]})]})]}),g==="custom"&&l=="linear"&&P(),V(),e.jsxRuntimeExports.jsx(e.SelectSeparator,{}),e.jsxRuntimeExports.jsx("div",{className:"grid grid-cols-3",children:e.jsxRuntimeExports.jsx(e.Button,{onClick:_,variant:"secondary",className:"col-span-1 col-start-3 h-8 w-full",children:"Apply"})})]})]})})]})}function Rt({idx:s}){var c;const r=e.useEditorStore(i=>{var m;return(m=i.card)==null?void 0:m.preferences}),t=e.useEditorStore(i=>{var m;return(m=i.card.preferences)==null?void 0:m.datasetOptions}),n=e.useEditorStore(i=>i.actions.setCardPreferences),o=(c=r==null?void 0:r.chartOptions)==null?void 0:c.indexAxis,l=t==null?void 0:t.find(i=>i.idx===s);function a(i,m){(i==="end"||i==="start")&&e.getContrastColor(e.getCanvasBackgroundColor());const u={display:i!=="none",align:i,anchor:i,clamp:!0};if(!l)n({...r,datasetOptions:[...t||[],{idx:m,datalabels:u}]});else{const g={...l};g.datalabels=u;const p=t==null?void 0:t.map(d=>d.idx===m?g:d);n({...r,datasetOptions:p})}}return e.jsxRuntimeExports.jsxs(e.Popover,{children:[e.jsxRuntimeExports.jsx(e.PopoverTrigger,{children:e.jsxRuntimeExports.jsx(js,{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:()=>a("none",s),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:()=>a("start",s),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsxRuntimeExports.jsx(rs,{className:e.cn("h-4 w-4",{"rotate-90":o==="y"})})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>a("center",s),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsxRuntimeExports.jsx(is,{className:e.cn("h-4 w-4",{"rotate-90":o==="y"})})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>a("end",s),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsxRuntimeExports.jsx(os,{className:e.cn("h-4 w-4",{"rotate-90":o==="y"})})})]})})]})}function zs(){const s=e.useEditorStore(i=>i.card),r=e.useEditorStore(i=>{var m,u,g;return(g=(u=(m=i==null?void 0:i.card)==null?void 0:m.preferences)==null?void 0:u.chartOptions)==null?void 0:g.indexAxis}),t=r==="y"?"Y axis":"X axis",n=r==="y"?"X axis":"Y axis",{keys:o,metricKeys:l,dimensionKeys:a}=e.getKeys(s.data||[]);let c=l;if(["stackedBar","stackedLine"].includes(s.type)){const i=e.pivotData({dataArray:s.data||[],groupKey:a[0],pivotKey:a[1],valueKey:c[0]}),{metricKeys:m}=e.getKeys(i);c=m}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:t}),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:a[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:n}),e.jsxRuntimeExports.jsx(As,{})]}),e.jsxRuntimeExports.jsx("div",{className:"my-1 space-y-1",children:c.map((i,m)=>e.jsxRuntimeExports.jsx(bt,{col:i,idx:m},i))})]})]})}function bt({col:s,idx:r}){const t=e.useEditorStore(c=>{var i;return(i=c.card)==null?void 0:i.preferences}),n=e.useEditorStore(c=>{var i;return(i=c.card.preferences)==null?void 0:i.datasetOptions}),o=n==null?void 0:n.find(c=>c.idx===r),{setCardPreferences:l}=e.useEditorStore(c=>c.actions);function a(c){if(!o)l({...t,datasetOptions:[...n||[],{idx:r,type:c==="area"?"line":c,fill:c==="area"?"origin":""}]});else{const i={...o};i.type=c==="area"?"line":c,i.fill=c==="area"?"origin":"";const m=n==null?void 0:n.map(u=>u.idx===r?i:u);l({...t,datasetOptions:m})}}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:s}),e.jsxRuntimeExports.jsxs("div",{className:"flex gap-2",children:[e.jsxRuntimeExports.jsx(be,{onClick:()=>a("bar"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsxRuntimeExports.jsx(ye,{onClick:()=>a("line"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsxRuntimeExports.jsx(Ge,{onClick:()=>a("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(Rt,{idx:r})]})]})}function Fs(){const s=e.useEditorStore(p=>p.selectedConnectionId),r=e.useEditorStore(p=>p.selectedDatamodelId),t=e.useEditorStore(p=>p.selectedDatabaseName),n=e.useEditorStore(p=>p.selectedSchemaName),o=e.useEditorStore(p=>p.selectedTableName),l=e.useDashboardStore(p=>p.dashboard.filters)||[],a=e.useDashboardStore(p=>p.actions.addFilter),c=e.useDashboardStore(p=>p.actions.removeFilter),i=e.useDashboardStore(p=>p.actions.removeFilterValue),{modelItems:m,tableName:u}=oe();function g(p,d="dashboard"){var E;const j=e.fmt(p.column_name),x=e.fmt(t||""),N=e.fmt(n||""),I=e.fmt(u);let L=e.getQualifiedTableName(N,I),b=`${L}.${j}`;const D=(E=m==null?void 0:m.find(v=>v.id===r))==null?void 0:E.name;r&&r!=="none"&&(b=`${e.DATAMODEL_NAMESPCACE}.${D}.${j}`,L=`${e.DATAMODEL_NAMESPCACE}.${D}`);const T=l==null?void 0:l.find(v=>v.column===b&&v.table===I&&(v.database===x||v.database===t));if(T)i(T.id),c(T.id);else{const v=e.v4();return u==="api"&&s?(a({location:d,id:v,column:b,title:p.column_name,dataType:p.data_type,table:"api",database:"",connectionId:s,operation:"in",sql:e.getDefaultFilterSql(p.data_type,L,j)}),v):(a({id:v,location:d,column:b,title:p.column_name,dataType:p.data_type,table:o||"",database:t||"",connectionId:s||"",operation:"in",sql:e.getDefaultFilterSql(p.data_type,L,j)}),v)}}return{assignFilter:g}}function xe(){const s=e.useDashboardStore(c=>c.dashboard.filters),r=e.useEditorStore(c=>c.frame),{setFrame:t}=e.useEditorActions(),{columns:n}=oe(),{assignFilter:o}=Fs();function l(c){const i=o(c,"frame");t({...r,filterId:i})}const a=s==null?void 0:s.find(c=>c.id===r.filterId);return e.jsxRuntimeExports.jsxs("div",{className:"space-y-3",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Card Filter"}),e.jsxRuntimeExports.jsx(yt,{onSelect:l,columns:n}),a&&e.jsxRuntimeExports.jsx(e.FilterHeader,{filter:a})]})}function yt({columns:s,onSelect:r}){var a;const[t,n]=qe.useState(!1),[o,l]=qe.useState("");return e.jsxRuntimeExports.jsxs(e.Popover,{open:t,onOpenChange:n,children:[e.jsxRuntimeExports.jsx(e.PopoverTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsxs(e.Button,{size:"sm",variant:"outline",role:"combobox","aria-expanded":t,className:"w-full justify-between font-normal",children:[o?(a=s.find(c=>c.column_name===o))==null?void 0:a.column_name:"Select Column...",e.jsxRuntimeExports.jsx(e.CaretSortIcon,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsxRuntimeExports.jsx(e.PopoverContent,{className:"w-[200px] p-0",children:e.jsxRuntimeExports.jsxs(e.Command,{children:[e.jsxRuntimeExports.jsx(e.CommandInput,{placeholder:"Search column",className:"h-9"}),e.jsxRuntimeExports.jsxs(e.CommandList,{children:[e.jsxRuntimeExports.jsx(e.CommandEmpty,{children:"No framework found."}),e.jsxRuntimeExports.jsx(e.CommandGroup,{children:s.map(c=>e.jsxRuntimeExports.jsxs(e.CommandItem,{value:c.column_name,onSelect:i=>{const m=i===o?"":i;l(m),n(!1),m&&r(c)},children:[c.column_name,e.jsxRuntimeExports.jsx(e.CheckIcon,{className:e.cn("ml-auto h-4 w-4",o===c.column_name?"opacity-100":"opacity-0")})]},c.column_name))})]})]})})]})}function St({cardType:s}){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(s)} 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:r=>r.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(ve,{}),e.jsxRuntimeExports.jsx(zs,{})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filters"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 px-2",children:[e.jsxRuntimeExports.jsx(ce,{}),e.jsxRuntimeExports.jsx(xe,{})]})]})]})})}function Me(){var o,l,a;const s=e.useEditorStore(c=>c.card.cfg),r=e.useEditorStore(c=>c.actions.setCardCfg),t=e.useEditorStore(c=>c.card.type);function n(c){var u;const i={datalabels:{display:c!=="none",align:c,anchor:c,clamp:!0}},m={...s,options:{...s==null?void 0:s.options,plugins:{...(u=s==null?void 0:s.options)==null?void 0:u.plugins,...i}}};r(m),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(t)&&e.jsxRuntimeExports.jsx(As,{})]}),e.jsxRuntimeExports.jsxs(e.Select,{value:(a=(l=(o=s==null?void 0:s.options)==null?void 0:o.plugins)==null?void 0:l.datalabels)==null?void 0:a.anchor,onValueChange:n,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"}),t!=="pyramid"&&e.jsxRuntimeExports.jsx(e.SelectItem,{value:"start",children:"Start"}),e.jsxRuntimeExports.jsx(e.SelectItem,{value:"center",children:"Center"}),t!=="pyramid"&&e.jsxRuntimeExports.jsx(e.SelectItem,{value:"end",children:"End"})]})})]})]})}function vt({cardType:s}){function r(t){const n="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:"rounded bg-muted px-2 py-1 text-xs",children:t==="bubble"?n:o}),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:"group - category"}),e.jsxRuntimeExports.jsx("li",{children:"x-axis - category"}),e.jsxRuntimeExports.jsx("li",{children:"y-axis - category"}),t==="bubble"&&e.jsxRuntimeExports.jsx("li",{children:"radius - number"})]}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:l=>l.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:"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(s)} Chart`}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:"space-y-4 font-mono text-xs",children:r(s)})]}),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:"Filters"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 px-2",children:[e.jsxRuntimeExports.jsx(ce,{}),e.jsxRuntimeExports.jsx(xe,{})]})]})]})})}const Ct={datasets:[{type:"line",label:"Sum_sales",data:[]},{type:"bar",label:"Sum_profit",data:[]}]},Nt={datasets:[{fill:"origin",type:"line",label:"Sum_sales",data:[]}]};function wt(){const s=e.useEditorStore(r=>r.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:kt(s)}),e.jsxRuntimeExports.jsx("section",{className:"",children:["line","bar"].includes(s)&&e.jsxRuntimeExports.jsx(ve,{})}),!["kpi"].includes(s)&&e.jsxRuntimeExports.jsxs("div",{className:"space-y-4",children:[e.jsxRuntimeExports.jsx(Me,{}),e.jsxRuntimeExports.jsx(ce,{}),e.jsxRuntimeExports.jsx(xe,{})]})]})}function kt(s){if(["line","bar"].includes(s))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(Ct,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(Nt,null,2)})]})]})]});if(s==="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:s})," 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(s==="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:s})," 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(s))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:s==="polarArea"?"Polar":s.charAt(0).toUpperCase()+s.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 It(){var i,m,u,g,p;const s=e.useEditorStore(d=>d.card.preferences),r=e.useEditorStore(d=>d.actions.setCardPreferences),t=e.useEditorStore(d=>d.actions.setNumberFormat);e.useEditorStore(d=>{var j,x;return(x=(j=d.card.preferences)==null?void 0:j.formatNumber)==null?void 0:x.decimalPlaces});const n=e.useEditorStore(d=>{var j,x;return(x=(j=d.card.preferences)==null?void 0:j.formatNumber)==null?void 0:x.locale}),o=e.useEditorStore(d=>{var j,x;return(x=(j=d.card.preferences)==null?void 0:j.formatNumber)==null?void 0:x.currency});e.useEditorStore(d=>d.actions.setFilterOnClickField);const l=e.useEditorStore(d=>{var j,x;return(x=(j=d.card.preferences)==null?void 0:j.formatNumber)==null?void 0:x.colorRanges})||[],a=e.useEditorStore(d=>d.actions.setColorRanges),c=[...new Set(e.LOCALE_CURRENCY_PAIRS.map(d=>d.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:!!((i=s==null?void 0:s.formatNumber)!=null&&i.enabled),onCheckedChange:d=>{r({...s,formatNumber:{...s==null?void 0:s.formatNumber,enabled:d}})}}),e.jsxRuntimeExports.jsx(e.Label,{children:"Format Number"})]}),((m=s==null?void 0:s.formatNumber)==null?void 0:m.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:n||"en-US",onValueChange:d=>{var j,x,N;return t(((j=s==null?void 0:s.formatNumber)==null?void 0:j.decimalPlaces)||0,((x=s==null?void 0:s.formatNumber)==null?void 0:x.currency)||"",d||"en-US",((N=s==null?void 0:s.formatNumber)==null?void 0:N.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(d=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:d.locale,children:d.locale},d.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:d=>{var j,x,N;return t(((j=s==null?void 0:s.formatNumber)==null?void 0:j.decimalPlaces)||0,d==="none"?"":d,((x=s==null?void 0:s.formatNumber)==null?void 0:x.locale)||"",((N=s==null?void 0:s.formatNumber)==null?void 0:N.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(d=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:d,children:d},d))]})})]})]})]}),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:((g=(u=s==null?void 0:s.formatNumber)==null?void 0:u.decimalPlaces)==null?void 0:g.toString())||"0",onValueChange:d=>{var j,x,N;return t(Number(d),((j=s==null?void 0:s.formatNumber)==null?void 0:j.currency)||"",((x=s==null?void 0:s.formatNumber)==null?void 0:x.locale)||"",((N=s==null?void 0:s.formatNumber)==null?void 0:N.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(d=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:d,children:d},d))})]})]}),e.jsxRuntimeExports.jsxs("div",{className:"w-full space-y-1",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Suffix"}),e.jsxRuntimeExports.jsx(e.Input,{value:((p=s==null?void 0:s.formatNumber)==null?void 0:p.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:d=>{var j,x,N;return t(((j=s==null?void 0:s.formatNumber)==null?void 0:j.decimalPlaces)||0,((x=s==null?void 0:s.formatNumber)==null?void 0:x.currency)||"",((N=s==null?void 0:s.formatNumber)==null?void 0:N.locale)||"",d.target.value)}})]})]})]})}),e.jsxRuntimeExports.jsx(e.Separator,{className:"my-3"}),e.jsxRuntimeExports.jsx(e.ColorFormat,{colorRanges:l,setColorRanges:a})]})]})}function Lt(){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:s=>s.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(It,{})}),e.jsxRuntimeExports.jsx("div",{}),e.jsxRuntimeExports.jsx("div",{})]})}function Dt(){var n;const s=e.useEditorStore(o=>o.card.preferences),{setCardPreferences:r}=e.useEditorStore(o=>o.actions);function t(o){r({...s,textVisualOptions:{...s==null?void 0:s.textVisualOptions,isDynamicText:o==="dynamic"}})}return e.jsxRuntimeExports.jsxs(e.RadioGroup,{value:(n=s==null?void 0:s.textVisualOptions)!=null&&n.isDynamicText?"dynamic":"static",onValueChange:t,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 fe({cardType:s,docContent:r,suffix:t="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(s)} ${t}`}),e.jsxRuntimeExports.jsx(e.AccordionContent,{children:r||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:n=>n.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:[s==="range"&&e.jsxRuntimeExports.jsx(ve,{}),s!=="text"&&e.jsxRuntimeExports.jsx(Me,{}),s==="text"&&e.jsxRuntimeExports.jsx(Dt,{})]})]}),!["range","text"].includes(s)&&e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filters"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 px-2",children:[e.jsxRuntimeExports.jsx(ce,{}),e.jsxRuntimeExports.jsx(xe,{})]})]})]})})}function Tt(){const s=e.useEditorStore(n=>{var o,l;return(l=(o=n==null?void 0:n.card)==null?void 0:o.preferences)==null?void 0:l.sortChart}),{setSortChart:r}=e.useEditorActions();function t(){return e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Sort"}),e.jsxRuntimeExports.jsx(de,{className:"h-8",label:"Sort Chart",options:[{label:"None",value:"none"},{label:"ASC",value:"asc"},{label:"DESC",value:"desc"}],value:s||"none",onValueChange:n=>{r(n)}})]})}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:n=>n.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(ve,{}),t(),e.jsxRuntimeExports.jsx(zs,{})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filters"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 px-2",children:[e.jsxRuntimeExports.jsx(ce,{}),e.jsxRuntimeExports.jsx(xe,{})]})]})]})})}function At({}){const s=e.useEditorStore(n=>{var o;return(o=n.card)==null?void 0:o.preferences}),r=e.useEditorStore(n=>n.actions.setCardPreferences),t=n=>{r({...s,allowDownload:n})};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:"Filters"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 px-2",children:[e.jsxRuntimeExports.jsx(ce,{}),e.jsxRuntimeExports.jsx(xe,{})]})]})}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.Checkbox,{onCheckedChange:t,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 zt=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:s=>s.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#pyramid-chart",children:"example"})," in the docs."]})]}),Ft=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:s=>s.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#range-charts",children:"example"})," in the docs."]})]}),Mt=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:s=>s.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#text-visual",children:"example"})," in the docs."]})]});function Ot(){const s=e.useEditorStore(t=>t.card.type);function r(t){switch(t){case"stackedBar":case"stackedLine":return e.jsxRuntimeExports.jsx(Tt,{});case"pyramid":return e.jsxRuntimeExports.jsx(fe,{docContent:zt,cardType:t});case"kpi":return e.jsxRuntimeExports.jsx(Lt,{});case"line":case"bar":return e.jsxRuntimeExports.jsx(St,{cardType:t});case"range":return e.jsxRuntimeExports.jsx(fe,{docContent:Ft,cardType:t});case"pie":case"doughnut":case"polarArea":case"radar":return e.jsxRuntimeExports.jsx(fe,{cardType:t});case"bubble":case"scatter":return e.jsxRuntimeExports.jsx(vt,{cardType:t});case"table":return e.jsxRuntimeExports.jsx(At,{cardType:t});case"text":return e.jsxRuntimeExports.jsx(fe,{docContent:Mt,cardType:t,suffix:"Visual"});case"custom":return e.jsxRuntimeExports.jsx(gt,{});default:return e.jsxRuntimeExports.jsx(wt,{})}}return e.jsxRuntimeExports.jsx(e.ScrollArea,{className:"h-full w-full text-sm",children:r(s)})}function Vt(){const s=e.useEditorStore(r=>r.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(lt,{})}),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:s?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(Ot,{})})}),e.jsxRuntimeExports.jsx(e.ResizableHandle,{className:"border"}),e.jsxRuntimeExports.jsx(e.ResizablePanel,{minSize:40,defaultSize:75,maxSize:100,children:e.jsxRuntimeExports.jsx(He,{})})]}):e.jsxRuntimeExports.jsx(He,{})})]})}function qt({authToken:s,onSave:r,onClose:t}){const n=e.useEditorStore(a=>a.actions.setOnSave),o=e.useEditorStore(a=>a.actions.setOnClose),l=e.useDashboardStore(a=>a.actions.setAuthToken);return S.useEffect(()=>{r&&n(r),t&&o(t)},[r,n,t,o]),S.useEffect(()=>{s&&s.accessToken&&l(s)},[s,l]),e.jsxRuntimeExports.jsx(e.ErrorBoundary,{FallbackComponent:e.Fallback,children: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(Rs,{})}),e.jsxRuntimeExports.jsx(e.EditorMain,{children:e.jsxRuntimeExports.jsx(Vt,{})})]})})}function _t(){e.useDashboardStore(a=>a.selectedCardId);const s=e.useDashboardStore(a=>a.selectedSheetId),{setIsVisualEditing:r}=e.useDashboardStore(a=>a.actions),t=e.useDashboardStore(a=>a.isVisualEditing),n=e.useDashboardStore(a=>a.actions.updateFrame);function o(a){s&&(n(s,a),r(!1))}function l(){r(!1)}return e.jsxRuntimeExports.jsx("div",{role:"editor-container",className:e.cn("flex grow",{block:t,hidden:!t}),children:e.jsxRuntimeExports.jsx(qt,{onSave:o,onClose:l})})}function Bt(){e.useEditorStore(a=>a.selectedConnectionId),e.useEditorStore(a=>a.selectedDatamodelId);const s=e.useEditorStore(a=>a.selectedDatabaseName);e.useEditorStore(a=>a.selectedSchemaName);const r=e.useEditorStore(a=>a.selectedTableName),t=e.useDashboardStore(a=>a.dashboard.filters)||[];e.useDashboardStore(a=>a.actions.addFilter),e.useDashboardStore(a=>a.actions.removeFilter),e.useDashboardStore(a=>a.actions.removeFilterValue);const{modelItems:n,columns:o}=oe(),{assignFilter:l}=Fs();return e.jsxRuntimeExports.jsx("div",{className:"xbg-red-100 flex-1 basis-0 flex-col overflow-scroll px-3",children:o==null?void 0:o.map(a=>{const c=t==null?void 0:t.find(i=>i.column===e.fmt(a.column_name)&&i.table===r&&i.database===s);return e.jsxRuntimeExports.jsx("div",{onClick:()=>l(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":c}),children:e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxRuntimeExports.jsx(gs,{column:a}),e.jsxRuntimeExports.jsx("span",{children:a.column_name})]})},a.column_name)})})}function Ht(){e.useDashboardStore(r=>r.showFilters);const s=e.useDashboardStore(r=>r.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:()=>s(!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(Rs,{ColumnsComponent:()=>e.jsxRuntimeExports.jsx(Bt,{})})})]})}function Pt(){const s=e.useDashboardStore(t=>t.showFilters),r=e.useDashboardStore(t=>t.isVisualEditing);return e.jsxRuntimeExports.jsxs("div",{role:"dashboard-plus-main",className:e.cn("grow",{hidden:r,flex:!r}),children:[e.jsxRuntimeExports.jsx(e.DashboardTabs,{}),s&&e.jsxRuntimeExports.jsx("div",{role:"filter-aside-container",className:"flex",children:e.jsxRuntimeExports.jsx(Ht,{})})]})}function $t(){const s=e.useDashboardStore(n=>n.dashboard),r=e.useDashboardStore(n=>n.actions.setDashboard),t=e.useDashboardStore(n=>n.showDashboardJSON);return e.useDashboardStore(n=>n.actions.setShowDashboardJSON),e.jsxRuntimeExports.jsx("div",{className:e.cn(" p-2",{hidden:!t}),children:e.jsxRuntimeExports.jsx(e.de,{onChange:n=>{if(n)try{JSON.parse(n),r(JSON.parse(n))}catch{}},defaultLanguage:"json",className:"h-[550px] overflow-y-auto ",value:JSON.stringify(s,null,2),options:{minimap:{enabled:!1},glyphMargin:!1,wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:12,renderLineHighlight:"none"}})})}function Gt({showControls:s=!1,showFooter:r=!0,...t}){return e.jsxRuntimeExports.jsx(e.ErrorBoundary,{FallbackComponent:e.Fallback,children:e.jsxRuntimeExports.jsxs(e.SemaphorContextProvider,{dashboardProps:t,children:[e.jsxRuntimeExports.jsx(e.Te,{}),e.jsxRuntimeExports.jsxs(e.UXProvider,{children:[e.jsxRuntimeExports.jsx($t,{}),e.jsxRuntimeExports.jsxs(e.DashboardPanel,{...t,children:[s&&e.jsxRuntimeExports.jsx($s,{}),e.jsxRuntimeExports.jsx(_t,{}),e.jsxRuntimeExports.jsx(Pt,{})]})]})]})})}exports.Box=$e;exports.ChartArea=Ge;exports.ChartColumnIncreasing=be;exports.ChartLine=ye;exports.ChartNoAxesGantt=Le;exports.ChartPie=De;exports.ChartScatter=Te;exports.CircleX=Qe;exports.CopyPlus=Ue;exports.DashboardPlus=Gt;exports.Database=Ke;exports.EllipsisVertical=We;exports.Eraser=Je;exports.Eye=Xe;exports.EyeClosed=Ye;exports.Glasses=Ze;exports.Hammer=es;exports.Hash=ss;exports.House=ts;exports.Key=ns;exports.ListEnd=rs;exports.ListStart=os;exports.ListX=is;exports.LoaderCircle=le;exports.MessageSquareMore=as;exports.Network=ls;exports.Pencil=Ae;exports.Play=cs;exports.Plug2=xs;exports.Save=us;exports.SelectComponent=ae;exports.Shapes=ze;exports.ShieldQuestion=ds;exports.Sigma=ms;exports.SwatchBook=ps;exports.Tag=js;exports.ToggleLeft=hs;exports.Type=Se;exports.User=Es;exports.cleanCard=fs;exports.getDashbaordStateWithoutData=Fe;exports.useEditorAside=oe;
@@ -2962,15 +2962,18 @@ function xl({
2962
2962
  a(d);
2963
2963
  }
2964
2964
  })();
2965
- }, [t]), /* @__PURE__ */ e.jsx("div", { className: "grid grid-cols-4 place-items-center", children: n.map((l, o) => /* @__PURE__ */ e.jsx(
2966
- pl,
2967
- {
2968
- text: l.name,
2969
- onClick: () => s("custom", l),
2970
- icon: l.icon
2971
- },
2972
- l.url + l.name + o
2973
- )) });
2965
+ }, [t]), /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
2966
+ /* @__PURE__ */ e.jsx(Me, { className: "my-2" }),
2967
+ /* @__PURE__ */ e.jsx("div", { className: "grid grid-cols-4 place-items-center", children: n.map((l, o) => /* @__PURE__ */ e.jsx(
2968
+ pl,
2969
+ {
2970
+ text: l.name,
2971
+ onClick: () => s("custom", l),
2972
+ icon: l.icon
2973
+ },
2974
+ l.url + l.name + o
2975
+ )) })
2976
+ ] });
2974
2977
  }
2975
2978
  const pl = ({
2976
2979
  text: s,
@@ -2980,7 +2983,7 @@ const pl = ({
2980
2983
  const [t, l] = E(null);
2981
2984
  Y(() => {
2982
2985
  n && (async () => {
2983
- const i = (await import("./lucide-react-nEOSuAeg.js"))[n];
2986
+ const i = (await import("./lucide-react-5Xr4kIU7.js"))[n];
2984
2987
  l(i);
2985
2988
  })();
2986
2989
  }, [n]);
@@ -3138,7 +3141,6 @@ function fl() {
3138
3141
  }
3139
3142
  )
3140
3143
  ] }),
3141
- /* @__PURE__ */ e.jsx(Me, { className: "my-2" }),
3142
3144
  /* @__PURE__ */ e.jsx(xl, { onChartTypeChange: i })
3143
3145
  ] })
3144
3146
  ] });
@@ -1,6 +1,6 @@
1
1
  import { J as a, ao as e, am as t, aF as c, bP as h, bQ as d, bR as o, bS as y, bT as i, bU as s, a7 as n, bV as r, bW as k, bX as p, bY as l, Q as M, bZ as u, b_ as v, b0 as g, ah as m, b$ as x, c0 as L, bc as w } from "./index-aHW1mk38.js";
2
2
  import { c1 as Pv } from "./index-aHW1mk38.js";
3
- import { B as C, C as f, a as I, b as S, d as q, e as b, f as H, h as A, i as z, j as P, E as V, k as j, l as B, m as F, G as D, H as R, n as T, o as U, K as O, p as Z, q as G, r as W, L as E, M as X, N, P as K, s as J, t as Q, v as Y, w as _, x as $, y as a1, z as e1, T as t1, A as c1, F as h1, U as d1 } from "./dashboard-plus-uNI1Wta1.js";
3
+ import { B as C, C as f, a as I, b as S, d as q, e as b, f as H, h as A, i as z, j as P, E as V, k as j, l as B, m as F, G as D, H as R, n as T, o as U, K as O, p as Z, q as G, r as W, L as E, M as X, N, P as K, s as J, t as Q, v as Y, w as _, x as $, y as a1, z as e1, T as t1, A as c1, F as h1, U as d1 } from "./dashboard-plus-YXEbQOX0.js";
4
4
  import "react";
5
5
  import "react-dom";
6
6
  /**
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-FZ_klwnO.js"),a=require("./dashboard-plus-hg0m94JG.js");require("react");require("react-dom");/**
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-FZ_klwnO.js"),a=require("./dashboard-plus-Al07EmF3.js");require("react");require("react-dom");/**
2
2
  * @license lucide-react v0.453.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./chunks/index-FZ_klwnO.js"),n=require("./chunks/dashboard-plus-hg0m94JG.js"),I=require("react");require("react-dom");function N({card:t,footer:u,className:c,...h}){const{customCards:r}=e.useSemaphorContext(),m=I.useRef(null),{isError:p,isLoading:i,isFetching:a,cfg:x,visualKey:C,handleDatapointClick:f}=e.useDashboardCard(t),l=e.useDashboardStore(s=>s.themeStyle),d=e.useDashboardStore(s=>s.selectedSheetId),E=e.useDashboardStore(s=>s.selectedCardId),j=e.useDashboardStore(s=>s.isDashboardEditing),{setCardTitle:D,setCardDescription:g,setSelectedCardId:b}=e.useDashboardActions();function S(s){s.stopPropagation(),b(d,t.id)}function T(){if(r&&r.length>0){const s=r.find(o=>o.cardId===t.id);if(s&&s.replaceDefault){const o=s.content;if(o)return e.jsxRuntimeExports.jsx(o,{card:t})}}return t.type==="kpi"?t.data&&t.data.length>0&&e.jsxRuntimeExports.jsx(e.KPICard,{isLoading:i||a,card:t}):y}function R(){if(p)return e.jsxRuntimeExports.jsx("p",{className:"text-sm",children:"Oops! It seems like something went wrong. Please review your connection or filters."});if(t.type==="table"&&t.data&&t.data.length>0)return e.jsxRuntimeExports.jsxs(e.ScrollArea,{children:[e.jsxRuntimeExports.jsx(e.TableVisual,{card:t,data:t.data}),e.jsxRuntimeExports.jsx(e.ScrollBar,{orientation:"horizontal"})]});if(r&&r.length>0){const s=r.find(o=>o.cardId===t.id);if(s&&s.content){const o=s.content;return e.jsxRuntimeExports.jsx(o,{card:t})}}if(x)return e.jsxRuntimeExports.jsx(e.ChartJsVisual,{cfg:x,onDatapointClick:f},C)}function A(){if(r&&r.length>0){const s=r.find(o=>o.cardId===t.id);if(s&&s.footer){const o=s.footer;if(o)return e.jsxRuntimeExports.jsx(o,{card:t})}}return u||null}if(!t.id)return null;const y=e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs(e.CardHeader,{className:"pb-4",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Editable,{text:t.title,onSave:s=>D(d,t.id,s),children:e.jsxRuntimeExports.jsx(e.CardTitle,{className:"text-base",children:t.title})}),t.refreshInterval&&e.jsxRuntimeExports.jsxs(e.Tooltip,{children:[e.jsxRuntimeExports.jsx(e.TooltipTrigger,{className:"pr-1",children:e.jsxRuntimeExports.jsx("div",{className:e.cn("h-2 w-2 rounded-full bg-green-500 transition-opacity",{"opacity-10":i||a})})}),e.jsxRuntimeExports.jsx(e.TooltipContent,{side:"right",align:"center",children:e.jsxRuntimeExports.jsx("p",{className:"text-xs",children:`Realtime (${t==null?void 0:t.refreshInterval})`})})]}),!t.refreshInterval&&(i||a)&&e.jsxRuntimeExports.jsx(n.LoaderCircle,{className:"h-4 w-4 animate-spin text-muted-foreground"})]}),e.jsxRuntimeExports.jsx(e.Editable,{text:(t==null?void 0:t.description)||"",onSave:s=>g(d,t.id,s),children:e.jsxRuntimeExports.jsxs(e.CardDescription,{children:[" ",t.description]})})]}),e.jsxRuntimeExports.jsx(e.CardContent,{className:"relative flex grow flex-col overflow-auto pb-0",children:R()}),e.jsxRuntimeExports.jsx(e.CardFooter,{children:A()})]});return e.jsxRuntimeExports.jsx(e.Card,{tabIndex:-1,ref:m,role:"dashboard-card",onClick:S,className:e.cn("relative flex h-full flex-col rounded-sm",{"border-dashed border-foreground/50":E===t.id&&j},l==null?void 0:l.dashboardCard,c),...h,children:T()})}exports.BOOLEAN_DATA_TYPES=e.BOOLEAN_DATA_TYPES;exports.DATE_DATA_TYPES=e.DATE_DATA_TYPES;exports.Dashboard=e.Dashboard;exports.DashboardWC=e.DashboardWC;exports.NUMBER_DATA_TYPES=e.NUMBER_DATA_TYPES;exports.SemaphorQueryClient=e.SemaphorQueryClient;exports.TEXT_DATA_TYPES=e.TEXT_DATA_TYPES;exports.createSqlGenConfig=e.createSqlGenConfig;exports.fmt=e.fmt;exports.getColumnDataType=e.getColumnDataType;exports.getFilterValueType=e.getFilterValueType;exports.getQualifiedTableName=e.getQualifiedTableName;exports.getSql=e.getSql;exports.isColumnInSqlGen=e.isColumnInSqlGen;exports.resolveDataType=e.resolveDataType;exports.useCard=e.useCard;exports.useDashboardActions=e.useDashboardActions;exports.useDashboardStore=e.useDashboardStore;exports.useEditorActions=e.useEditorActions;exports.useEditorStore=e.useEditorStore;exports.SelectComponent=n.SelectComponent;exports.Surfboard=n.DashboardPlus;exports.cleanCard=n.cleanCard;exports.getDashbaordStateWithoutData=n.getDashbaordStateWithoutData;exports.useEditorAside=n.useEditorAside;exports.DashboardCard=N;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./chunks/index-FZ_klwnO.js"),n=require("./chunks/dashboard-plus-Al07EmF3.js"),I=require("react");require("react-dom");function N({card:t,footer:u,className:c,...h}){const{customCards:r}=e.useSemaphorContext(),m=I.useRef(null),{isError:p,isLoading:i,isFetching:a,cfg:x,visualKey:C,handleDatapointClick:f}=e.useDashboardCard(t),l=e.useDashboardStore(s=>s.themeStyle),d=e.useDashboardStore(s=>s.selectedSheetId),E=e.useDashboardStore(s=>s.selectedCardId),j=e.useDashboardStore(s=>s.isDashboardEditing),{setCardTitle:D,setCardDescription:g,setSelectedCardId:b}=e.useDashboardActions();function S(s){s.stopPropagation(),b(d,t.id)}function T(){if(r&&r.length>0){const s=r.find(o=>o.cardId===t.id);if(s&&s.replaceDefault){const o=s.content;if(o)return e.jsxRuntimeExports.jsx(o,{card:t})}}return t.type==="kpi"?t.data&&t.data.length>0&&e.jsxRuntimeExports.jsx(e.KPICard,{isLoading:i||a,card:t}):y}function R(){if(p)return e.jsxRuntimeExports.jsx("p",{className:"text-sm",children:"Oops! It seems like something went wrong. Please review your connection or filters."});if(t.type==="table"&&t.data&&t.data.length>0)return e.jsxRuntimeExports.jsxs(e.ScrollArea,{children:[e.jsxRuntimeExports.jsx(e.TableVisual,{card:t,data:t.data}),e.jsxRuntimeExports.jsx(e.ScrollBar,{orientation:"horizontal"})]});if(r&&r.length>0){const s=r.find(o=>o.cardId===t.id);if(s&&s.content){const o=s.content;return e.jsxRuntimeExports.jsx(o,{card:t})}}if(x)return e.jsxRuntimeExports.jsx(e.ChartJsVisual,{cfg:x,onDatapointClick:f},C)}function A(){if(r&&r.length>0){const s=r.find(o=>o.cardId===t.id);if(s&&s.footer){const o=s.footer;if(o)return e.jsxRuntimeExports.jsx(o,{card:t})}}return u||null}if(!t.id)return null;const y=e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs(e.CardHeader,{className:"pb-4",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Editable,{text:t.title,onSave:s=>D(d,t.id,s),children:e.jsxRuntimeExports.jsx(e.CardTitle,{className:"text-base",children:t.title})}),t.refreshInterval&&e.jsxRuntimeExports.jsxs(e.Tooltip,{children:[e.jsxRuntimeExports.jsx(e.TooltipTrigger,{className:"pr-1",children:e.jsxRuntimeExports.jsx("div",{className:e.cn("h-2 w-2 rounded-full bg-green-500 transition-opacity",{"opacity-10":i||a})})}),e.jsxRuntimeExports.jsx(e.TooltipContent,{side:"right",align:"center",children:e.jsxRuntimeExports.jsx("p",{className:"text-xs",children:`Realtime (${t==null?void 0:t.refreshInterval})`})})]}),!t.refreshInterval&&(i||a)&&e.jsxRuntimeExports.jsx(n.LoaderCircle,{className:"h-4 w-4 animate-spin text-muted-foreground"})]}),e.jsxRuntimeExports.jsx(e.Editable,{text:(t==null?void 0:t.description)||"",onSave:s=>g(d,t.id,s),children:e.jsxRuntimeExports.jsxs(e.CardDescription,{children:[" ",t.description]})})]}),e.jsxRuntimeExports.jsx(e.CardContent,{className:"relative flex grow flex-col overflow-auto pb-0",children:R()}),e.jsxRuntimeExports.jsx(e.CardFooter,{children:A()})]});return e.jsxRuntimeExports.jsx(e.Card,{tabIndex:-1,ref:m,role:"dashboard-card",onClick:S,className:e.cn("relative flex h-full flex-col rounded-sm",{"border-dashed border-foreground/50":E===t.id&&j},l==null?void 0:l.dashboardCard,c),...h,children:T()})}exports.BOOLEAN_DATA_TYPES=e.BOOLEAN_DATA_TYPES;exports.DATE_DATA_TYPES=e.DATE_DATA_TYPES;exports.Dashboard=e.Dashboard;exports.DashboardWC=e.DashboardWC;exports.NUMBER_DATA_TYPES=e.NUMBER_DATA_TYPES;exports.SemaphorQueryClient=e.SemaphorQueryClient;exports.TEXT_DATA_TYPES=e.TEXT_DATA_TYPES;exports.createSqlGenConfig=e.createSqlGenConfig;exports.fmt=e.fmt;exports.getColumnDataType=e.getColumnDataType;exports.getFilterValueType=e.getFilterValueType;exports.getQualifiedTableName=e.getQualifiedTableName;exports.getSql=e.getSql;exports.isColumnInSqlGen=e.isColumnInSqlGen;exports.resolveDataType=e.resolveDataType;exports.useCard=e.useCard;exports.useDashboardActions=e.useDashboardActions;exports.useDashboardStore=e.useDashboardStore;exports.useEditorActions=e.useEditorActions;exports.useEditorStore=e.useEditorStore;exports.SelectComponent=n.SelectComponent;exports.Surfboard=n.DashboardPlus;exports.cleanCard=n.cleanCard;exports.getDashbaordStateWithoutData=n.getDashbaordStateWithoutData;exports.useEditorAside=n.useEditorAside;exports.DashboardCard=N;
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { u as _, a as w, b as r, c as F, j as t, C as P, E as f, d as k, T as R, e as L, f as h, g as q, h as B, i as Y, k as G, l as K, K as O, S as V, m as z, n as H, o as Q } from "./chunks/index-aHW1mk38.js";
2
2
  import { B as se, s as ae, D as oe, q as re, N as ne, I as ie, r as le, w as de, t as ue, y as ce, x as fe, A as he, v as Ce, z as me, F as xe, p as pe, H as ge, G as je } from "./chunks/index-aHW1mk38.js";
3
- import { L as W } from "./chunks/dashboard-plus-uNI1Wta1.js";
4
- import { S as be, D as Se, c as Te, g as Ee, u as Ie } from "./chunks/dashboard-plus-uNI1Wta1.js";
3
+ import { L as W } from "./chunks/dashboard-plus-YXEbQOX0.js";
4
+ import { S as be, D as Se, c as Te, g as Ee, u as Ie } from "./chunks/dashboard-plus-YXEbQOX0.js";
5
5
  import J from "react";
6
6
  import "react-dom";
7
7
  function Z({
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../chunks/dashboard-plus-hg0m94JG.js");require("../chunks/index-FZ_klwnO.js");require("react");require("react-dom");exports.Surfboard=r.DashboardPlus;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../chunks/dashboard-plus-Al07EmF3.js");require("../chunks/index-FZ_klwnO.js");require("react");require("react-dom");exports.Surfboard=r.DashboardPlus;
@@ -1,4 +1,4 @@
1
- import { D as i } from "../chunks/dashboard-plus-uNI1Wta1.js";
1
+ import { D as i } from "../chunks/dashboard-plus-YXEbQOX0.js";
2
2
  import "../chunks/index-aHW1mk38.js";
3
3
  import "react";
4
4
  import "react-dom";
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "email": "support@semaphor.cloud"
6
6
  },
7
7
  "license": "MIT",
8
- "version": "0.0.269",
8
+ "version": "0.0.270",
9
9
  "description": "Fully interactive and customizable dashboards for your apps.",
10
10
  "keywords": [
11
11
  "react",