react-semaphor 0.0.149 → 0.0.150
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.
- package/dist/chunks/{dashboard-plus-V8yyjys7.js → dashboard-plus-1qhhIbxX.js} +2 -2
- package/dist/chunks/{dashboard-plus-VO-o8Q5m.js → dashboard-plus-yoSVBMke.js} +774 -774
- package/dist/chunks/index-e4IBsALI.js +364 -0
- package/dist/chunks/{index-A53WxJ05.js → index-yLUZIbzY.js} +11806 -14124
- package/dist/dashboard/index.cjs +1 -1
- package/dist/dashboard/index.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +3 -3
- package/dist/surfboard/index.cjs +1 -1
- package/dist/surfboard/index.js +2 -2
- package/package.json +1 -1
- package/dist/chunks/2DAFLIRC-HTB0OzHP.js +0 -1086
- package/dist/chunks/2DAFLIRC-LUJ-HNQs.js +0 -9088
- package/dist/chunks/index-tGO1Iq1M.js +0 -364
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const t=require("./index-
|
|
1
|
+
"use strict";const t=require("./index-e4IBsALI.js"),A=require("react");/**
|
|
2
2
|
* @license lucide-react v0.379.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -225,4 +225,4 @@ SELECT label, measure FROM table
|
|
|
225
225
|
Table Columns: ${y==null?void 0:y.map(N=>`${N.column_name} | ${N.data_type}`).join(", ")}
|
|
226
226
|
User SQL: ${w}
|
|
227
227
|
${m&&`Base Queries: ${JSON.stringify(m)} `}`,O=` 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.
|
|
228
|
-
Visual Query Syntax: ${fu}`,{data:b,isLoading:M,isFetching:T,isError:z,refetch:H}=t.useQuery({queryKey:["ai-query"],queryFn:()=>t.getRequest("https://semaphor.cloud/api/v1/ai",(u==null?void 0:u.accessToken)||"",{user_content:`userContent: ${D} ${c?O:""}`}),enabled:!1});function I(N){if(N.toLowerCase().includes("bar"))j("bar");else if(N.toLowerCase().includes("line"))j("line");else if(N.toLowerCase().includes("bubble"))j("bubble");else if(N.toLowerCase().includes("scatter"))j("scatter");else if(N.toLowerCase().includes("stacked"))j("stackedBar");else if(N.toLowerCase().includes("pie"))j("pie");else if(N.toLowerCase().includes("donut")||N.toLowerCase().includes("doughnut"))j("doughnut");else if(N.toLowerCase().includes("radar"))j("radar");else return j("bar"),!1;return!0}A.useEffect(()=>{b&&k(N=>[...N,{role:"ai",content:b.response}])},[b]),A.useEffect(()=>{const N=setTimeout(()=>{var h;a.current&&(a.current.scroll({top:a.current.scrollHeight,behavior:"smooth"}),(h=l.current)==null||h.focus())},100);return()=>clearTimeout(N)},[E]);function v(){r&&(k(N=>[...N,{role:"user",content:r}]),I(r)&&x(!0),i(""),H())}A.useEffect(()=>{s&&(v(),o(!1))},[s,o]);const U={fontFamily:"Arial, sans-serif",lineHeight:1.6,fontSize:15,width:"100%"},$={fontFamily:"monospace",fontSize:14,lineHeight:1.6},P={fontFamily:"Arial, sans-serif",lineHeight:1.6,fontSize:15,padding:"2px 0",marginLeft:20,listStyleType:"disc"},q={p:({node:N,...h})=>t.jsxRuntimeExports.jsx("p",{style:U,...h}),code:({node:N,...h})=>t.jsxRuntimeExports.jsx("code",{className:"rounded-sm bg-muted px-2 py-1 text-sm",...h}),pre:({node:N,...h})=>t.jsxRuntimeExports.jsxs("pre",{className:"space-y-2 rounded-sm bg-muted/50 p-3",style:$,children:[t.jsxRuntimeExports.jsx("code",{className:"whitespace-normal text-sm",children:h.children}),t.jsxRuntimeExports.jsxs("div",{className:"flex justify-start gap-2",children:[t.jsxRuntimeExports.jsx(t.Button,{onClick:Q,size:"sm",variant:"outline",children:t.jsxRuntimeExports.jsx(t.ClipboardCopyIcon,{})}),t.jsxRuntimeExports.jsx(t.Button,{onClick:J=>{const te=Q(J);te&&(n(!1),p(te),d(!0))},size:"sm",variant:"outline",children:t.jsxRuntimeExports.jsx(t.PlayIcon,{})})]})]}),li:({node:N,...h})=>t.jsxRuntimeExports.jsx("li",{style:P,...h})};function Q(N){const h=N.currentTarget.closest("pre");if(!h)return;const J=h.textContent||h.innerText;return navigator.clipboard.writeText(J).then(()=>console.log("Text copied to clipboard")).catch(te=>console.error("Error in copying text: ",te)),J}function re(){return E==null?void 0:E.map((N,h)=>N.role==="user"?t.jsxRuntimeExports.jsxs("div",{className:"flex items-start rounded-md bg-muted p-3 text-sm",children:[t.jsxRuntimeExports.jsx(Ti,{className:"mr-2 h-5 w-5"}),t.jsxRuntimeExports.jsx("div",{children:N.content})]},h):N.role==="ai"?t.jsxRuntimeExports.jsx(t.jsxRuntimeExports.Fragment,{children:t.jsxRuntimeExports.jsx(mu,{className:"w-full overflow-auto py-1",components:q,children:b==null?void 0:b.response},h)}):t.jsxRuntimeExports.jsx("div",{},h))}return t.jsxRuntimeExports.jsxs(t.Dialog,{open:e,onOpenChange:n,children:[t.jsxRuntimeExports.jsx(t.DialogTrigger,{asChild:!0,children:t.jsxRuntimeExports.jsx(t.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..."})}),t.jsxRuntimeExports.jsxs(t.DialogContent,{className:"flex flex-col justify-between overflow-auto sm:max-w-[425px] md:max-h-[625px] md:min-w-[625px]",children:[t.jsxRuntimeExports.jsxs(t.DialogHeader,{children:[t.jsxRuntimeExports.jsx(t.DialogTitle,{children:"Assistant"}),t.jsxRuntimeExports.jsx(t.DialogDescription,{children:"What can I help you with?"})]}),t.jsxRuntimeExports.jsx("div",{ref:a,className:"h-[625px] w-full overflow-auto border-t border-t-muted",children:t.jsxRuntimeExports.jsx("div",{className:"space-y-4 py-2 pr-3",role:"messages",children:re()})}),t.jsxRuntimeExports.jsx("div",{children:t.jsxRuntimeExports.jsxs("div",{className:"flex w-full items-center rounded-md border",children:[t.jsxRuntimeExports.jsx(t.Textarea,{autoFocus:!0,ref:l,onKeyDown:N=>{N.key==="Enter"&&!N.shiftKey&&(N.preventDefault(),i(""),v())},placeholder:"Type your question here...",onFocus:N=>{const h=N.target,J=h.value.length;h.setSelectionRange(J,J)},className:t.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:M||T,value:r,onChange:N=>i(N.target.value)})," ",t.jsxRuntimeExports.jsx(t.Button,{className:"h-8",size:"sm",variant:"ghost",onClick:v,children:!M&&!T?t.jsxRuntimeExports.jsx(t.PaperPlaneIcon,{}):t.jsxRuntimeExports.jsx(t.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"})})]})})]})]})}var Jr={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},er=A.createContext&&A.createContext(Jr),ju=["attr","size","title"];function yu(e,n){if(e==null)return{};var r=Eu(e,n),i,s;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(s=0;s<o.length;s++)i=o[s],!(n.indexOf(i)>=0)&&Object.prototype.propertyIsEnumerable.call(e,i)&&(r[i]=e[i])}return r}function Eu(e,n){if(e==null)return{};var r={},i=Object.keys(e),s,o;for(o=0;o<i.length;o++)s=i[o],!(n.indexOf(s)>=0)&&(r[s]=e[s]);return r}function ut(){return ut=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},ut.apply(this,arguments)}function tr(e,n){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);n&&(i=i.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),r.push.apply(r,i)}return r}function ct(e){for(var n=1;n<arguments.length;n++){var r=arguments[n]!=null?arguments[n]:{};n%2?tr(Object(r),!0).forEach(function(i){bu(e,i,r[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):tr(Object(r)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(r,i))})}return e}function bu(e,n,r){return n=ku(n),n in e?Object.defineProperty(e,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[n]=r,e}function ku(e){var n=Su(e,"string");return typeof n=="symbol"?n:String(n)}function Su(e,n){if(typeof e!="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var i=r.call(e,n||"default");if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(n==="string"?String:Number)(e)}function Xr(e){return e&&e.map((n,r)=>A.createElement(n.tag,ct({key:r},n.attr),Xr(n.child)))}function ze(e){return n=>A.createElement(Ru,ut({attr:ct({},e.attr)},n),Xr(e.child))}function Ru(e){var n=r=>{var{attr:i,size:s,title:o}=e,l=yu(e,ju),a=s||r.size||"1em",u;return r.className&&(u=r.className),e.className&&(u=(u?u+" ":"")+e.className),A.createElement("svg",ut({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},r.attr,i,l,{className:u,style:ct(ct({color:e.color||r.color},r.style),e.style),height:a,width:a,xmlns:"http://www.w3.org/2000/svg"}),o&&A.createElement("title",null,o),e.children)};return er!==void 0?A.createElement(er.Consumer,null,r=>n(r)):n(Jr)}function Cu(e){return ze({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:[]}]})(e)}function wu(){const{theme:e}=t.useTheme(),n=A.useRef(),r=A.useRef(),[i,s]=A.useState(!1),[o,l]=A.useState(!1),[a,u]=A.useState(!1),[c,x]=A.useState(""),[p,m]=A.useState(!1),{authToken:d}=t.useSemaphorContext();t.useDashboardStore(g=>g.selectedSheetId);const j=t.useDashboardStore(g=>g.dashboard.baseQueries),E=t.useEditorStore(g=>g.card),k=t.useDashboardStore(g=>g.theme),y=t.useEditorStore(g=>g.isShowingVisual),w=t.useEditorStore(g=>g.selectedConnectionId),S=t.useEditorStore(g=>g.selectedDatabaseName),D=t.useEditorStore(g=>g.selectedSchemaName);t.useDashboardStore(g=>g.actions.updateFrameCard);const O=t.useEditorStore(g=>g.selectedTableName),b=t.useEditorStore(g=>g.card.sql),M=t.useEditorStore(g=>g.card.python),T=t.resolveBaseQuery(b,j),z=t.useEditorStore(g=>g.selectedConnectionId),H=t.useEditorStore(g=>g.frame),I=t.useEditorStore(g=>g.filterValues),v=t.useEditorStore(g=>g.applyFilters),{setCardCustomCfg:U,setQueryResultColumns:$,setFilterValues:P,setCardSql:q,setCardPython:Q,setQueryError:re,setPythonStdOut:N}=t.useEditorStore(g=>g.actions),h=t.useEditorStore(g=>g.onSave),J=t.useEditorStore(g=>g.actions.setApplyFilters),te=t.useEditorStore(g=>g.onClose),f=t.useEditorStore(g=>g.actions.setCardData),ae=t.useEditorStore(g=>g.actions.setSqlGen),ge=t.useEditorStore(g=>g.runSql),X=t.useEditorStore(g=>g.actions.setRunSql),ke=t.useEditorStore(g=>g.actions.setIsSqlRunning),{data:ne,isLoading:he,isFetching:xe,isSuccess:Le,isError:Oe,error:He,status:mt,refetch:Ie}=t.useQuery({queryKey:[T,M],queryFn:()=>t.postRequest("https://semaphor.cloud/api/v1/query",(d==null?void 0:d.accessToken)||"",{connection_id:z,sql:T,python:M===t.PYTHON_DEFAULT_CODE?"":M,active_filters:v?I:[]}),enabled:!1,retry:!1});A.useEffect(()=>{if(ne&&(f(ne.records),N((ne==null?void 0:ne.output)||""),ne.records.length>0)){const{dimensionKeys:g}=t.getKeys(ne.records);$(g)}},[ne,f,$,N]),A.useEffect(()=>{ge&&(Ie(),X(!1))},[ge,Ie,X]),A.useEffect(()=>{(he||xe)&&ke(!0),(Oe||Le)&&ke(!1),Oe?(re(He.message),f([]),$([]),N("")):re("")},[he,xe,ne,N,Oe,Le,ke,f,$,re,He]);function Je(){q(""),f([]),ae({}),U("")}const Xe=g=>{r.current=g};function Ye(){let g=b;b&&!b.includes("{{")&&(g=Pi(b),q(g));const C={...E,lastSelectedSchema:D,lastSelectedDatabase:S,lastSelectedTable:O,connectionId:w,type:y?E.type:"table",sql:g,customCfg:y?E.customCfg:null},L=H.cards.map(B=>B.id===E.id?C:B);h==null||h({...H,cards:L})}function Ze(){te==null||te()}function ht(g){const C=getComputedStyle(document.documentElement).getPropertyValue(g);return ft(C)}function ft(g){const[C,L,B]=g.split(" "),_=parseFloat(C),ue=parseFloat(L),Se=parseFloat(B),fe=ue/100,we=Se/100,se=(1-Math.abs(2*we-1))*fe,Y=se*(1-Math.abs(_/60%2-1)),je=we-se/2;let ee=0,Re=0,Ce=0;0<=_&&_<60?(ee=se,Re=Y,Ce=0):60<=_&&_<120?(ee=Y,Re=se,Ce=0):120<=_&&_<180?(ee=0,Re=se,Ce=Y):180<=_&&_<240?(ee=0,Re=Y,Ce=se):240<=_&&_<300?(ee=Y,Re=0,Ce=se):300<=_&&_<360&&(ee=se,Re=0,Ce=Y),ee=Math.round((ee+je)*255),Re=Math.round((Re+je)*255),Ce=Math.round((Ce+je)*255);const yt=li=>{const Et=li.toString(16);return Et.length==1?"0"+Et:Et};return`#${yt(ee)}${yt(Re)}${yt(Ce)}`}A.useEffect(()=>{const g=n.current,C=r.current;if(g){const L=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",B=k==="system"?L:k;g.editor.defineTheme("default",{base:B==="light"?"vs":"vs-dark",inherit:!0,rules:[],colors:{"editor.background":B==="light"?"#ffffff":ht("--background")}}),g.editor.setTheme("default")}return C&&g&&C.addCommand(g.KeyMod.Shift|g.KeyCode.Enter,function(){return console.log("Executing query..."),Ie(),!1}),()=>{}},[e,k,n.current]);function et(g){n.current=g}function gt(){return t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[o&&t.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:t.jsxRuntimeExports.jsxs("div",{className:"w-[99%]",children:[t.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2 pt-3",children:[t.jsxRuntimeExports.jsx(_i,{checked:v,onCheckedChange:()=>J(!v),text:"Apply Filters"}),t.jsxRuntimeExports.jsx(Vi,{}),I&&o&&t.jsxRuntimeExports.jsx(t.Cross2Icon,{onClick:()=>l(!1),className:"bg-background/50 text-foreground/50 hover:cursor-pointer hover:text-foreground"})]}),t.jsxRuntimeExports.jsx(t.Ft,{theme:"default",onChange:g=>{if(g)try{JSON.parse(g),P(JSON.parse(g))}catch{}},defaultLanguage:"json",className:"mt-1 min-h-[220px]",value:JSON.stringify(I,null,2),options:{readOnly:!0,minimap:{enabled:!1},lineNumbers:"off",glyphMargin:!1,wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:12,renderLineHighlight:"none"}})]})}),I&&!o&&t.jsxRuntimeExports.jsx(ir,{onClick:()=>l(!0),className:t.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 jt(){return t.jsxRuntimeExports.jsxs(Lt,{className:"flex grow pb-1",direction:"vertical",role:"editor-resizable-group",children:[t.jsxRuntimeExports.jsxs(Fe,{id:"1",order:1,defaultSize:i?20:100,className:"relative flex grow",children:[t.jsxRuntimeExports.jsx("div",{role:"sql-container",className:"relative flex w-[99%]",children:t.jsxRuntimeExports.jsx(t.Ft,{theme:"default",className:"pt-3",onChange:g=>{q(g)},value:b,options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"sql",defaultValue:"SELECT * FROM table",beforeMount:et,onMount:Xe})}),i&&t.jsxRuntimeExports.jsx("code",{className:"absolute right-6 top-3 text-sm text-muted-foreground/70",children:"sql"})]}),i&&t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsx(Ot,{withHandle:!0,className:"border"}),t.jsxRuntimeExports.jsxs(Fe,{id:"2",order:2,defaultSize:80,className:"relative flex grow",children:[t.jsxRuntimeExports.jsx("div",{role:"python-container",className:"relative flex w-[99%] pt-0",children:t.jsxRuntimeExports.jsx(t.Ft,{className:"pt-3",theme:"default",onChange:g=>{Q(g&&g.trim()||"")},value:M||t.PYTHON_DEFAULT_CODE,options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"python",beforeMount:et,onMount:Xe})}),t.jsxRuntimeExports.jsx("code",{className:"absolute right-6 top-3 text-sm text-muted-foreground/70",children:"python"})]})]})]})}return t.jsxRuntimeExports.jsxs("section",{role:"editor-section",className:"flex grow flex-col justify-end",children:[t.jsxRuntimeExports.jsxs("div",{role:"sql-editor",className:"relative flex grow justify-between overflow-y-scroll",children:[jt(),gt()]}),t.jsxRuntimeExports.jsxs("div",{role:"editor-controls",className:"item-center flex flex-wrap justify-between gap-2 px-6 py-4",children:[t.jsxRuntimeExports.jsxs("div",{className:"flex grow items-center gap-2",children:[t.jsxRuntimeExports.jsxs(t.Button,{disabled:he||xe,onClick:()=>{Ie()},className:"shrink-0",size:"sm",variant:"outline",children:[he||xe?t.jsxRuntimeExports.jsx(t.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"}):t.jsxRuntimeExports.jsx(Si,{className:"mr-2 h-4 w-4"}),"Run"]}),Oe&&t.jsxRuntimeExports.jsx(Bi,{error:He.message,setShowAIDialog:u,setTriggerAIRun:m,setUserInputforAI:x}),t.jsxRuntimeExports.jsxs(t.Button,{onClick:Je,className:"",size:"sm",variant:"outline",children:[t.jsxRuntimeExports.jsx(xi,{className:"mr-2 size-4"}),"Clear"]}),t.jsxRuntimeExports.jsx(t.Toggle,{pressed:i,onPressedChange:g=>s(g),className:"",size:"sm",variant:"outline",children:t.jsxRuntimeExports.jsx(Cu,{className:"size-4 text-foreground/70"})}),t.jsxRuntimeExports.jsx(gu,{open:a,setOpen:u,userInput:c,triggerAIRun:p,setTriggerAIRun:m,setUserInput:g=>x(g)})]}),t.jsxRuntimeExports.jsxs("div",{className:"flex items-end gap-2",children:[t.jsxRuntimeExports.jsxs(t.Button,{onClick:Ye,size:"sm",variant:"outline",children:[t.jsxRuntimeExports.jsx(t.Check,{className:"mr-2 size-4 font-bold text-green-600"}),"Accept"]}),t.jsxRuntimeExports.jsxs(t.Button,{onClick:Ze,className:"w-full",size:"sm",variant:"outline",children:[t.jsxRuntimeExports.jsx(t.Cross2Icon,{className:"mr-2 size-4"}),"Close"]})]})]})]})}function vu({data:e}){var l;const[n,r]=A.useState([]),s=Object.keys(e[0]).map(a=>({accessorKey:a,header:({column:u})=>{const c=u.getIsSorted();return t.jsxRuntimeExports.jsx("div",{className:"flex gap-2",children:t.jsxRuntimeExports.jsxs("div",{className:"flex cursor-pointer items-center",onClick:()=>u.toggleSorting(u.getIsSorted()==="asc"),children:[a,c==="asc"?t.jsxRuntimeExports.jsx(t.TriangleUpIcon,{className:"ml-2 h-5 w-5"}):c==="desc"?t.jsxRuntimeExports.jsx(t.TriangleDownIcon,{className:"ml-2 h-5 w-5"}):null]})})}})),o=t.useReactTable({data:e,columns:s,getCoreRowModel:t.getCoreRowModel(),getPaginationRowModel:t.getPaginationRowModel(),onSortingChange:r,getSortedRowModel:t.getSortedRowModel(),manualPagination:!0,state:{sorting:n}});return t.jsxRuntimeExports.jsxs(t.Table,{children:[t.jsxRuntimeExports.jsx(t.TableHeader,{children:o.getHeaderGroups().map(a=>t.jsxRuntimeExports.jsx(t.TableRow,{children:a.headers.map(u=>t.jsxRuntimeExports.jsx(t.TableHead,{className:"sticky top-0 bg-muted",children:u.isPlaceholder?null:t.flexRender(u.column.columnDef.header,u.getContext())},u.id))},a.id))}),t.jsxRuntimeExports.jsx(t.TableBody,{children:(l=o.getRowModel().rows)!=null&&l.length?o.getRowModel().rows.map(a=>t.jsxRuntimeExports.jsx(t.TableRow,{className:"whitespace-nowrap py-2","data-state":a.getIsSelected()&&"selected",children:a.getVisibleCells().map(u=>t.jsxRuntimeExports.jsx(t.TableCell,{children:t.flexRender(u.column.columnDef.cell,u.getContext())},u.id))},a.id)):t.jsxRuntimeExports.jsx(t.TableRow,{children:t.jsxRuntimeExports.jsx(t.TableCell,{colSpan:s.length,className:"h-24 text-center",children:"No results."})})})]})}function Yr({className:e,...n}){A.useState(0);const r=t.useDashboardStore(l=>l.themeStyle),i=t.useEditorStore(l=>l.card),s=t.useEditorStore(l=>l.actions.setCard);if(A.useEffect(()=>{},[i.data,i.type,i.cfg,i.customCfg,r,i.preferences]),!i.id)return null;let o;return i.data&&i.data.length>0&&(o=t.createChartConfig({data:i.data,cardType:i.type,cfg:i.cfg,customCfg:i.customCfg,preferences:i.preferences})),t.jsxRuntimeExports.jsxs(t.Card,{role:"editor-visual-card",className:t.cn("relative flex h-full flex-col rounded-none",e),...n,children:[t.jsxRuntimeExports.jsxs(t.CardHeader,{className:"py-4",children:[t.jsxRuntimeExports.jsx(t.Editable,{text:i.title,onSave:l=>s({...i,title:l}),children:t.jsxRuntimeExports.jsx("div",{className:"flex items-center gap-2",children:t.jsxRuntimeExports.jsx(t.CardTitle,{className:"text-base",children:i.title})})},i.title),t.jsxRuntimeExports.jsx(t.Editable,{text:i.description||"",onSave:l=>s({...i,description:l}),children:t.jsxRuntimeExports.jsxs(t.CardDescription,{children:[" ",i.description]})},i.description)]}),t.jsxRuntimeExports.jsxs(t.CardContent,{className:"flex grow flex-col pb-3",children:[i.type!=="table"&&o&&t.jsxRuntimeExports.jsx(t.ChartJsVisual,{cfg:o},JSON.stringify(o)),i.type==="table"&&i.data&&i.data.length>0&&t.jsxRuntimeExports.jsx(t.$57acba87d6e25586$export$ccf8d8d7bbf3c2cc,{className:"flex min-h-0 flex-1 grow basis-0",children:t.jsxRuntimeExports.jsx(t.TableVisual,{card:i,data:i==null?void 0:i.data})})]})]})}function Nu(){const[e,n]=A.useState(!1),[r,i]=A.useState(""),[s,o]=A.useState(""),[l,a]=A.useState(""),u=t.useEditorStore(k=>k.card),c=t.useEditorStore(k=>k.card.customCfg),x=t.useEditorStore(k=>k.actions.setCardCustomCfg);function p(k){var S,D;const y={...k,data:{...k==null?void 0:k.data,datasets:(D=(S=k==null?void 0:k.data)==null?void 0:S.datasets)==null?void 0:D.map(O=>({...O,data:[]}))}};return JSON.stringify(y,null,1)}function m(){if(!u.data||u.data.length===0)return;const k=t.createChartConfig({data:u.data,cardType:u.type,cfg:u.cfg,preferences:u.preferences});k&&(i(JSON.stringify(k,null,1)),c&&o(JSON.stringify(c,null,1)))}function d(){if(s)try{const k=JSON.parse(s);return k?(x(k),a(""),o(""),k):void 0}catch(k){console.log(k),a("Invalid JSON")}}function j(){o(""),x(null)}function E(){let k;if(c){const y=t._.cloneDeep(u.cfg),w=t._.merge(y,c);return k=p(w),k}return r?(k=p(JSON.parse(r)),k):""}return t.jsxRuntimeExports.jsxs(t.Dialog,{open:e,onOpenChange:n,children:[t.jsxRuntimeExports.jsx(t.DialogTrigger,{asChild:!0,children:t.jsxRuntimeExports.jsx(t.Button,{onClick:m,className:` ${c&&"border-foreground/50 dark:border-foreground/70"}`,size:"sm",variant:"outline",children:t.jsxRuntimeExports.jsx(t.Settings,{className:"h-4 w-4"})})}),t.jsxRuntimeExports.jsxs(t.DialogContent,{className:"max-h-[70vh] min-h-[70vh] min-w-[900px] overflow-auto",children:[t.jsxRuntimeExports.jsxs(t.DialogHeader,{className:"",children:[t.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxRuntimeExports.jsx(t.DialogTitle,{children:"Customize Card"}),t.jsxRuntimeExports.jsxs(t.Tooltip,{children:[t.jsxRuntimeExports.jsx(t.TooltipTrigger,{children:t.jsxRuntimeExports.jsx(gi,{onClick:()=>{navigator.clipboard.writeText(u.id)},className:"size-3 cursor-pointer text-muted-foreground/70 transition-colors hover:text-muted-foreground"})}),t.jsxRuntimeExports.jsx(t.TooltipContent,{side:"right",align:"center",children:t.jsxRuntimeExports.jsx("p",{className:"text-xs",children:"Copy Card ID"})})]})]}),t.jsxRuntimeExports.jsxs(t.DialogDescription,{children:["See the configuration options and documentation",t.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."})]})]}),t.jsxRuntimeExports.jsxs("div",{className:"flex grow gap-2",children:[t.jsxRuntimeExports.jsx(Yr,{className:"w-1/2 rounded shadow-none"}),t.jsxRuntimeExports.jsxs(t.Tabs,{defaultValue:"custom-config",className:"flex w-1/2 flex-col",children:[t.jsxRuntimeExports.jsxs(t.TabsList,{className:"justify-start rounded-sm rounded-b-none border border-b-0",children:[t.jsxRuntimeExports.jsxs(t.TabsTrigger,{value:"custom-config",children:[c&&t.jsxRuntimeExports.jsx(t.CheckIcon,{className:"mr-1 h-5 w-5 text-green-600"}),c?"Custom Config":"Default Config"]}),t.jsxRuntimeExports.jsx(t.TabsTrigger,{className:"",value:"output",children:"Output"})]}),t.jsxRuntimeExports.jsx(t.TabsContent,{className:"bg-red-x mt-0 grow rounded-b border border-t-0 p-2",value:"output",children:t.jsxRuntimeExports.jsx(t.Textarea,{disabled:!0,value:r,className:"h-full resize-none border-none font-mono focus-visible:ring-0 focus-visible:ring-offset-0"})}),t.jsxRuntimeExports.jsx(t.TabsContent,{className:"mt-0 grow rounded-b border border-t-0",value:"custom-config",children:t.jsxRuntimeExports.jsx(t.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:E(),onChange:k=>o(k)})})]})]}),t.jsxRuntimeExports.jsxs(t.DialogFooter,{className:"flex items-center",children:[t.jsxRuntimeExports.jsx(t.Label,{className:"mr-2 text-red-500",children:l}),t.jsxRuntimeExports.jsx(t.Button,{disabled:!c,onClick:j,variant:"outline",children:"Reset"}),t.jsxRuntimeExports.jsx(t.Button,{onClick:d,variant:"outline",children:"Apply"}),t.jsxRuntimeExports.jsx(t.Button,{onClick:()=>n(!1),variant:"outline",children:"Close"})]})]})]})}function Zr(e){return ze({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:[]}]})(e)}function ei(e){return ze({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:[]}]})(e)}function ti(e){return ze({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:[]}]})(e)}function ni(e){return ze({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:[]}]})(e)}function ri(e){return ze({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:[]}]})(e)}function ii(e){return ze({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:[]}]})(e)}function Iu(){const[e,n]=A.useState(!1),r=t.useEditorStore(l=>l.card.type),i=t.useEditorStore(l=>l.actions.setCardType),s=t.useEditorStore(l=>l.actions.setCardCustomCfg);function o(l){i(l),s(null),n(!1)}return t.jsxRuntimeExports.jsxs(t.Popover,{open:e,onOpenChange:n,children:[t.jsxRuntimeExports.jsx(t.PopoverTrigger,{asChild:!0,children:t.jsxRuntimeExports.jsx(t.Button,{size:"sm",variant:"outline",children:t.jsxRuntimeExports.jsx(Au,{className:"h-4 w-4",chartType:r})})}),t.jsxRuntimeExports.jsx(t.PopoverContent,{className:"w-50",children:t.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 place-items-center ",children:[t.jsxRuntimeExports.jsx(t.Button,{onClick:()=>o("bar"),className:"font-normal",variant:"ghost",children:t.jsxRuntimeExports.jsx(Ut,{className:"size-5"})}),t.jsxRuntimeExports.jsx(t.Button,{onClick:()=>o("line"),variant:"ghost",children:t.jsxRuntimeExports.jsx($t,{className:"size-5"})}),t.jsxRuntimeExports.jsx(t.Button,{onClick:()=>o("stackedBar"),variant:"ghost",children:t.jsxRuntimeExports.jsx(ri,{className:"size-5 ",strokeWidth:0})}),t.jsxRuntimeExports.jsx(t.Button,{onClick:()=>o("scatter"),variant:"ghost",children:t.jsxRuntimeExports.jsx(ar,{className:"size-5"})}),t.jsxRuntimeExports.jsx(t.Button,{onClick:()=>o("bubble"),variant:"ghost",children:t.jsxRuntimeExports.jsx(ni,{className:"size-4"})}),t.jsxRuntimeExports.jsx(t.Button,{onClick:()=>o("pie"),variant:"ghost",children:t.jsxRuntimeExports.jsx(or,{className:"size-5"})}),t.jsxRuntimeExports.jsx(t.Button,{onClick:()=>o("doughnut"),variant:"ghost",children:t.jsxRuntimeExports.jsx(ei,{className:"size-5 ",strokeWidth:1})}),t.jsxRuntimeExports.jsx(t.Button,{onClick:()=>o("radar"),variant:"ghost",children:t.jsxRuntimeExports.jsx(Zr,{className:"size-5 font-extralight",strokeWidth:.5})}),t.jsxRuntimeExports.jsx(t.Button,{onClick:()=>o("polarArea"),variant:"ghost",children:t.jsxRuntimeExports.jsx(ti,{className:"size-5 "})}),t.jsxRuntimeExports.jsx(t.Button,{onClick:()=>o("table"),variant:"ghost",children:t.jsxRuntimeExports.jsx(Kt,{className:"size-5 "})}),t.jsxRuntimeExports.jsx(t.Button,{onClick:()=>o("kpi"),variant:"ghost",children:t.jsxRuntimeExports.jsx(ii,{className:"size-6 "})})]})})]})}function Au({chartType:e,className:n}){switch(e){case"bar":return t.jsxRuntimeExports.jsx(Ut,{className:n});case"line":return t.jsxRuntimeExports.jsx($t,{className:n});case"pie":return t.jsxRuntimeExports.jsx(or,{className:n});case"radar":return t.jsxRuntimeExports.jsx(Zr,{className:n});case"scatter":return t.jsxRuntimeExports.jsx(ar,{className:n});case"bubble":return t.jsxRuntimeExports.jsx(ni,{className:n});case"doughnut":return t.jsxRuntimeExports.jsx(ei,{className:n});case"stackedBar":return t.jsxRuntimeExports.jsx(ri,{className:"size-4 text-foreground/70 "});case"polarArea":return t.jsxRuntimeExports.jsx(ti,{className:n});case"kpi":return t.jsxRuntimeExports.jsx(ii,{className:n});default:return t.jsxRuntimeExports.jsx(Kt,{className:n})}}function Tu(){const e=t.useEditorStore(r=>r.card.refreshInterval),n=t.useEditorStore(r=>r.actions.setCardRefreshInterval);return t.jsxRuntimeExports.jsxs(t.Popover,{children:[t.jsxRuntimeExports.jsx(t.PopoverTrigger,{asChild:!0,children:t.jsxRuntimeExports.jsx(t.Button,{size:"sm",variant:"outline",children:t.jsxRuntimeExports.jsx(ai,{className:"w-4 h-4"})})}),t.jsxRuntimeExports.jsx(t.PopoverContent,{className:"w-[200px]",children:t.jsxRuntimeExports.jsx("div",{className:"grid gap-4",children:t.jsxRuntimeExports.jsx("div",{className:"grid gap-2",children:t.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-5 items-center gap-1",children:[t.jsxRuntimeExports.jsx(t.Label,{className:"col-span-3",htmlFor:"width",children:"Refresh Every"}),t.jsxRuntimeExports.jsx(t.Input,{value:e||"",onChange:r=>n(r.target.value),id:"width",placeholder:"30s",className:"col-span-2 h-7 focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-0"})]})})})})]})}function nr(){t.useEditorStore(l=>l.frame);const e=t.useEditorStore(l=>l.card),n=t.useEditorStore(l=>l.card.data),r=t.useEditorStore(l=>l.isShowingVisual),i=t.useEditorStore(l=>l.isSqlRunning),s=t.useEditorStore(l=>l.queryError),o=t.useEditorStore(l=>l.pythonStdOut);return t.useEditorStore(l=>l.onSave),t.useEditorStore(l=>l.onClose),t.useEditorStore(l=>l.actions.setCardSql),t.useEditorStore(l=>l.actions.setCardType),t.useEditorStore(l=>l.actions.setSqlGen),e?t.jsxRuntimeExports.jsxs("div",{className:"relative flex h-full flex-col py-3",children:[i&&t.jsxRuntimeExports.jsx(t.LoaderCircle,{className:"absolute bottom-0 left-0 right-0 top-0 z-10 m-auto h-10 w-10 animate-spin text-foreground/10"}),t.jsxRuntimeExports.jsxs("div",{className:"mb-0 flex min-h-10 items-center justify-end gap-2 px-6",children:[r&&t.jsxRuntimeExports.jsxs("div",{className:"flex grow items-center gap-2",children:[t.jsxRuntimeExports.jsx(Iu,{}),t.jsxRuntimeExports.jsx(Nu,{}),t.jsxRuntimeExports.jsx(Tu,{})]}),t.jsxRuntimeExports.jsx(Lu,{})]}),r?e.type==="kpi"?t.jsxRuntimeExports.jsx("div",{className:"flex grow items-center justify-center",children:t.jsxRuntimeExports.jsx("div",{className:"w-1/2 rounded-md border",children:t.jsxRuntimeExports.jsx(t.KPICard,{isLoading:i,card:e})})}):t.jsxRuntimeExports.jsx(Yr,{className:"grow border-none shadow-none"}):t.jsxRuntimeExports.jsxs("div",{className:"flex min-h-0 w-full flex-1 grow basis-0 px-6",children:[o&&t.jsxRuntimeExports.jsx(zu,{}),e.data&&e.data.length>0&&t.jsxRuntimeExports.jsx(vu,{data:n||[]}),s&&t.jsxRuntimeExports.jsx("span",{className:"font-mono text-sm",children:s})]})]}):t.jsxRuntimeExports.jsx(t.jsxRuntimeExports.Fragment,{children:"No Active Card"})}function zu(){const e=t.useEditorStore(r=>r.pythonStdOut);if(!e)return null;const n=e.replace(/\n/g,"<br>");return t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsx("p",{className:"font-mono text-sm",children:"Output:"}),t.jsxRuntimeExports.jsx("div",{dangerouslySetInnerHTML:{__html:n},className:"bg-muted p-2 font-mono text-sm"}),t.jsxRuntimeExports.jsx(t.Separator,{className:"mb-2"})]})}function Lu(){const e=t.useEditorStore(r=>r.isShowingVisual),n=t.useEditorStore(r=>r.actions.setIsShowingVisual);return t.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsxRuntimeExports.jsx(t.Label,{htmlFor:"visualize",children:"Chart"}),t.jsxRuntimeExports.jsx(t.Switch$1,{checked:e,onCheckedChange:()=>n(!e),id:"visualize",className:"data-[state=checked]:bg-foreground/50"})]})}function Ve(){const[e,n]=A.useState([]);t.useEditorStore(x=>x.card.cfg);const r=t.useEditorStore(x=>x.card.preferences),{setCardCfg:i,setFilterOnClickColumnIndex:s,setCardPreferences:o}=t.useEditorStore(x=>x.actions),l=t.useEditorStore(x=>x.queryResultColumns);t.useEditorStore(x=>{var p;return(p=x.card.preferences)==null?void 0:p.filterOnClickColumnIndex}),A.useEffect(()=>{l&&n(new Array(l.length).fill(!1))},[l]);function a(x,p){var m,d;p?r!=null&&r.onClickFilter&&((m=r==null?void 0:r.onClickFilter)==null?void 0:m.length)>0?o({...r,onClickFilter:[...r.onClickFilter,{columnIndex:x,expression:""}]}):o({...r,onClickFilter:[{columnIndex:x,expression:""}]}):(o({...r,onClickFilter:(d=r==null?void 0:r.onClickFilter)==null?void 0:d.filter(j=>j.columnIndex!==x)}),n(j=>{const E=[...j];return E[x]=!1,E}))}function u(x,p){var d;const m=(d=r==null?void 0:r.onClickFilter)==null?void 0:d.map(j=>j.columnIndex===x?{...j,expression:p.target.value}:j);o({...r,onClickFilter:m})}function c(x){var p,m,d,j;if(e!=null&&e[x]||(m=(p=r==null?void 0:r.onClickFilter)==null?void 0:p.find(E=>E.columnIndex===x))!=null&&m.expression)return t.jsxRuntimeExports.jsx(t.Input,{value:(j=(d=r==null?void 0:r.onClickFilter)==null?void 0:d.find(E=>E.columnIndex===x))==null?void 0:j.expression,onChange:E=>u(x,E),type:"text",className:" h-9 w-full focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0 font-mono text-xs",placeholder:"Expression"})}return t.jsxRuntimeExports.jsx(t.jsxRuntimeExports.Fragment,{children:l==null?void 0:l.map((x,p)=>{var m,d;return t.jsxRuntimeExports.jsx("div",{className:"flex items-center justify-between space-y-2 xbg-red-100 group",children:t.jsxRuntimeExports.jsxs("div",{className:" grow",children:[t.jsxRuntimeExports.jsxs("div",{className:"flex items-center py-2 space-x-2",children:[t.jsxRuntimeExports.jsx(t.Checkbox,{checked:!!((m=r==null?void 0:r.onClickFilter)!=null&&m.find(j=>j.columnIndex===p)),onCheckedChange:j=>a(p,j)}),t.jsxRuntimeExports.jsx("label",{className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:x}),t.jsxRuntimeExports.jsx("div",{className:"flex gap-2 items-center ",children:((d=r==null?void 0:r.onClickFilter)==null?void 0:d.find(j=>j.columnIndex===p))&&t.jsxRuntimeExports.jsx(sr,{onClick:()=>{n(j=>{const E=[...j];return E[p]=!j[p],E})},className:" invisible group-hover:visible size-3 text-gray-400 cursor-pointer"})})]}),c(p)]})},x)})})}function an(){var o,l;const e=t.useEditorStore(a=>a.card.preferences),n=t.useEditorStore(a=>a.card.cfg),{setCardCfg:r,setCardPreferences:i}=t.useEditorStore(a=>a.actions);(o=n==null?void 0:n.options)!=null&&o.indexAxis;function s(a){var x,p,m,d,j,E;let u={};(x=e==null?void 0:e.chartOptions)!=null&&x.scales&&(u={x:(m=(p=e==null?void 0:e.chartOptions)==null?void 0:p.scales)==null?void 0:m.y,y:(j=(d=e==null?void 0:e.chartOptions)==null?void 0:d.scales)==null?void 0:j.x});const c={...e,chartOptions:{...e==null?void 0:e.chartOptions,scales:{...(E=e==null?void 0:e.chartOptions)==null?void 0:E.scales,...u},indexAxis:a}};i(c)}return t.jsxRuntimeExports.jsxs(t.RadioGroup,{value:((l=e==null?void 0:e.chartOptions)==null?void 0:l.indexAxis)||"x",onValueChange:s,className:"flex gap-3",defaultValue:"x",children:[t.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsxRuntimeExports.jsx(t.RadioGroupItem,{value:"x",id:"r1"}),t.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r1",children:"Vertical"})]}),t.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsxRuntimeExports.jsx(t.RadioGroupItem,{value:"y",id:"r2"}),t.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r2",children:"Horizontal"})]})]})}const zt="focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0";function si(e){var r,i;return(r=e==null?void 0:e.chartOptions)!=null&&r.indexAxis?((i=e==null?void 0:e.chartOptions)==null?void 0:i.indexAxis)==="x"?"y":"x":"y"}function rr(e){var r,i,s;const n=si(e);return((s=(i=(r=e==null?void 0:e.chartOptions)==null?void 0:r.scales)==null?void 0:i[n])==null?void 0:s.type)||"linear"}function Ou(){var w,S,D,O,b,M;const[e,n]=A.useState(!1),r=t.useEditorStore(T=>{var z;return(z=T.card)==null?void 0:z.preferences}),i=si(r),[s,o]=A.useState(rr(r)),[l,a]=A.useState(((D=(S=(w=r==null?void 0:r.chartOptions)==null?void 0:w.scales)==null?void 0:S[i])==null?void 0:D.min)||""),[u,c]=A.useState(((M=(b=(O=r==null?void 0:r.chartOptions)==null?void 0:O.scales)==null?void 0:b[i])==null?void 0:M.max)||""),[x,p]=A.useState(l||u?"custom":"auto"),[m,d]=A.useState(""),j=t.useEditorStore(T=>T.actions.setCardPreferences);A.useEffect(()=>{var T,z,H,I,v,U,$,P,q,Q;o(rr(r)),a(((H=(z=(T=r==null?void 0:r.chartOptions)==null?void 0:T.scales)==null?void 0:z[i])==null?void 0:H.min)===0?0:""),c(((U=(v=(I=r==null?void 0:r.chartOptions)==null?void 0:I.scales)==null?void 0:v[i])==null?void 0:U.max)||""),d(((Q=(q=(P=($=r==null?void 0:r.chartOptions)==null?void 0:$.scales)==null?void 0:P[i])==null?void 0:q.ticks)==null?void 0:Q.stepSize)||"")},[e,r,i]);function E(T,z){return z===""||/^[0-9\b]+$/.test(z)?Number(z):Number(T)}function k(){return t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[t.jsxRuntimeExports.jsx(t.Label,{htmlFor:"range",children:"Range"}),t.jsxRuntimeExports.jsx(t.Input,{id:"min",value:l,onChange:T=>a(z=>E(z,T.target.value)),className:`col-span-1 h-8 w-full ${zt}`}),t.jsxRuntimeExports.jsx(t.Input,{value:u,onChange:T=>c(z=>E(z,T.target.value)),id:"max",className:`col-span-1 h-8 w-full ${zt}`})]}),t.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[t.jsxRuntimeExports.jsx(t.Label,{htmlFor:"step-size",children:"Step Size"}),t.jsxRuntimeExports.jsx(t.Input,{value:m,onChange:T=>d(z=>E(z,T.target.value)),id:"step-size",className:`col-span-1 h-8 w-full ${zt}`})]})]})}function y(){var H;let T={};x==="custom"&&(T={min:l,max:u,ticks:{stepSize:m}});const z={...r||{},chartOptions:{...r==null?void 0:r.chartOptions,scales:{...(H=r==null?void 0:r.chartOptions)==null?void 0:H.scales,[i]:{type:s,...s==="linear"?T:{}}}}};j(z)}return t.jsxRuntimeExports.jsxs(t.Popover,{onOpenChange:T=>n(T),children:[t.jsxRuntimeExports.jsx(t.PopoverTrigger,{asChild:!0,children:t.jsxRuntimeExports.jsx(t.SliderIcon,{className:"size-4 cursor-pointer text-muted-foreground hover:text-foreground"})}),t.jsxRuntimeExports.jsx(t.PopoverContent,{align:"center",className:"max-w-65",children:t.jsxRuntimeExports.jsxs("div",{className:"grid gap-4",children:[t.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[t.jsxRuntimeExports.jsx("h4",{className:"font-medium leading-none",children:"Scale Options"}),t.jsxRuntimeExports.jsx("p",{className:"text-sm text-muted-foreground",children:"Set the scale for the number axis"})]}),t.jsxRuntimeExports.jsxs("div",{className:"grid gap-2",children:[t.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[t.jsxRuntimeExports.jsx(t.Label,{htmlFor:"scale",children:"Type"}),t.jsxRuntimeExports.jsxs(t.Select,{value:s,onValueChange:T=>o(T),children:[t.jsxRuntimeExports.jsx(t.SelectTrigger,{className:"col-span-2 h-8 w-full focus:ring-1 focus:ring-offset-0",children:t.jsxRuntimeExports.jsx(t.SelectValue,{})}),t.jsxRuntimeExports.jsx(t.SelectContent,{id:"type",children:t.jsxRuntimeExports.jsxs(t.SelectGroup,{children:[t.jsxRuntimeExports.jsx(t.SelectLabel,{children:"Option"}),t.jsxRuntimeExports.jsx(t.SelectItem,{value:"linear",children:"Linear"}),t.jsxRuntimeExports.jsx(t.SelectItem,{value:"logarithmic",children:"Logarithmic"})]})})]})]}),s=="linear"&&t.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 items-center gap-2 py-1",children:[t.jsxRuntimeExports.jsx(t.Label,{htmlFor:"scale-option",children:"Setup"}),t.jsxRuntimeExports.jsxs(t.RadioGroup,{id:"scale-option",value:x,onValueChange:T=>p(T),className:"col-span-2 flex gap-3",defaultValue:"x",children:[t.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsxRuntimeExports.jsx(t.RadioGroupItem,{value:"auto",id:"r1"}),t.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r1",children:"Auto"})]}),t.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsxRuntimeExports.jsx(t.RadioGroupItem,{value:"custom",id:"r2"}),t.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r2",children:"Custom"})]})]})]}),x==="custom"&&s=="linear"&&k(),t.jsxRuntimeExports.jsx(t.SelectSeparator,{}),t.jsxRuntimeExports.jsx("div",{className:"grid grid-cols-3",children:t.jsxRuntimeExports.jsx(t.Button,{onClick:y,variant:"secondary",className:"col-span-1 col-start-3 h-8 w-full",children:"Apply"})})]})]})})]})}function Du({idx:e}){var a;const n=t.useEditorStore(u=>{var c;return(c=u.card)==null?void 0:c.preferences}),r=t.useEditorStore(u=>{var c;return(c=u.card.preferences)==null?void 0:c.datasetOptions}),i=t.useEditorStore(u=>u.actions.setCardPreferences),s=(a=n==null?void 0:n.chartOptions)==null?void 0:a.indexAxis,o=r==null?void 0:r.find(u=>u.idx===e);function l(u,c){(u==="end"||u==="start")&&t.getContrastColor(t.getCanvasBackgroundColor());const x={display:u!=="none",align:u,anchor:u,clamp:!0};if(!o)i({...n,datasetOptions:[...r||[],{idx:c,datalabels:x}]});else{const p={...o};p.datalabels=x;const m=r==null?void 0:r.map(d=>d.idx===c?p:d);i({...n,datasetOptions:m})}}return t.jsxRuntimeExports.jsxs(t.Popover,{children:[t.jsxRuntimeExports.jsx(t.PopoverTrigger,{children:t.jsxRuntimeExports.jsx(Ni,{className:"invisible size-4 rotate-[135deg] cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"})}),t.jsxRuntimeExports.jsxs(t.PopoverContent,{className:"flex w-fit gap-1 p-1",children:[t.jsxRuntimeExports.jsx(t.Button,{onClick:()=>l("none",e),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:t.jsxRuntimeExports.jsx(t.X,{className:"size-4"})}),t.jsxRuntimeExports.jsx(t.Button,{onClick:()=>l("start",e),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:t.jsxRuntimeExports.jsx(ji,{className:t.cn("h-4 w-4",{"rotate-90":s==="y"})})}),t.jsxRuntimeExports.jsx(t.Button,{onClick:()=>l("center",e),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:t.jsxRuntimeExports.jsx(Ei,{className:t.cn("h-4 w-4",{"rotate-90":s==="y"})})}),t.jsxRuntimeExports.jsx(t.Button,{onClick:()=>l("end",e),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:t.jsxRuntimeExports.jsx(yi,{className:t.cn("h-4 w-4",{"rotate-90":s==="y"})})})]})]})}function oi(){const e=t.useEditorStore(u=>u.card),n=t.useEditorStore(u=>{var c,x,p;return(p=(x=(c=u==null?void 0:u.card)==null?void 0:c.preferences)==null?void 0:x.chartOptions)==null?void 0:p.indexAxis}),r=n==="y"?"Y axis":"X axis",i=n==="y"?"X axis":"Y axis",{keys:s,metricKeys:o,dimensionKeys:l}=t.getKeys(e.data||[]);let a=o;if(e.type==="stackedBar"){const u=t.pivotData({dataArray:e.data||[],groupKey:l[0],pivotKey:l[1],valueKey:a[0]}),{metricKeys:c}=t.getKeys(u);a=c}return s.length===0?null:t.jsxRuntimeExports.jsxs("div",{className:"space-y-4",children:[t.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[t.jsxRuntimeExports.jsx(t.Label,{children:r}),t.jsxRuntimeExports.jsx("div",{className:"my-1 space-y-1",children:t.jsxRuntimeExports.jsx("div",{className:"rounded-md bg-muted/70 px-2 py-1 hover:bg-muted",children:t.jsxRuntimeExports.jsx("p",{children:l[0]})})})]}),t.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[t.jsxRuntimeExports.jsxs("div",{className:"flex items-center justify-between gap-5",children:[t.jsxRuntimeExports.jsx(t.Label,{children:i}),t.jsxRuntimeExports.jsx(Ou,{})]}),t.jsxRuntimeExports.jsx("div",{className:"my-1 space-y-1",children:a.map((u,c)=>t.jsxRuntimeExports.jsx(Fu,{col:u,idx:c},u))})]})]})}function Fu({col:e,idx:n}){const r=t.useEditorStore(a=>{var u;return(u=a.card)==null?void 0:u.preferences}),i=t.useEditorStore(a=>{var u;return(u=a.card.preferences)==null?void 0:u.datasetOptions}),s=i==null?void 0:i.find(a=>a.idx===n),{setCardPreferences:o}=t.useEditorStore(a=>a.actions);function l(a){if(!s)o({...r,datasetOptions:[...i||[],{idx:n,type:a==="area"?"line":a,fill:a==="area"?"origin":""}]});else{const u={...s};u.type=a==="area"?"line":a,u.fill=a==="area"?"origin":"";const c=i==null?void 0:i.map(x=>x.idx===n?u:x);o({...r,datasetOptions:c})}}return t.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:[t.jsxRuntimeExports.jsx("p",{children:e}),t.jsxRuntimeExports.jsxs("div",{className:"flex gap-2",children:[t.jsxRuntimeExports.jsx(Ut,{onClick:()=>l("bar"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),t.jsxRuntimeExports.jsx($t,{onClick:()=>l("line"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),t.jsxRuntimeExports.jsx(ui,{onClick:()=>l("area"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),t.jsxRuntimeExports.jsx(t.Separator,{orientation:"vertical",className:"invisible size-4 cursor-pointer py-2 text-muted-foreground hover:text-foreground group-hover:visible"}),t.jsxRuntimeExports.jsx(Du,{idx:n})]})]})}function Mu({cardType:e}){return t.jsxRuntimeExports.jsx("div",{className:"space-y-6 px-6 py-2",children:t.jsxRuntimeExports.jsxs(t.Accordion,{defaultValue:["item-2"],type:"multiple",children:[t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-1",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{children:`${t.titleCase(e)} Chart`}),t.jsxRuntimeExports.jsxs(t.AccordionContent,{className:"space-y-4 font-mono text-xs",children:[t.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"}),t.jsxRuntimeExports.jsxs("ul",{className:"ml-6 list-disc text-xs [&>li]:mt-2",children:[t.jsxRuntimeExports.jsx("li",{children:"x-axis - category"}),t.jsxRuntimeExports.jsx("li",{children:"y-axis1 - number"}),t.jsxRuntimeExports.jsx("li",{children:"y-axis2 - number"})]}),t.jsxRuntimeExports.jsxs("div",{children:["See ",t.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:n=>n.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#line-chart",children:"example"})," in the docs."]})]})]}),t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-2",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{children:"Settings"}),t.jsxRuntimeExports.jsxs(t.AccordionContent,{className:"space-y-4 px-2",children:[t.jsxRuntimeExports.jsx(an,{}),t.jsxRuntimeExports.jsx(oi,{})]})]}),t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-3",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{children:"Filter on click"}),t.jsxRuntimeExports.jsx(t.AccordionContent,{className:"px-2",children:t.jsxRuntimeExports.jsx(Ve,{})})]})]})})}function un(){var i,s,o;const e=t.useEditorStore(l=>l.card.cfg),n=t.useEditorStore(l=>l.actions.setCardCfg);function r(l){var c;const a={datalabels:{display:l!=="none",align:l,anchor:l,clamp:!0}},u={...e,options:{...e==null?void 0:e.options,plugins:{...(c=e==null?void 0:e.options)==null?void 0:c.plugins,...a}}};n(u),console.log(l)}return t.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[t.jsxRuntimeExports.jsx("label",{className:"font-medium",children:"Data Labels"}),t.jsxRuntimeExports.jsxs(t.Select,{value:(o=(s=(i=e==null?void 0:e.options)==null?void 0:i.plugins)==null?void 0:s.datalabels)==null?void 0:o.anchor,onValueChange:r,defaultValue:"none",children:[t.jsxRuntimeExports.jsx(t.SelectTrigger,{className:"h-8 w-[180px] focus:ring-1 focus:ring-offset-0",children:t.jsxRuntimeExports.jsx(t.SelectValue,{placeholder:"Select position"})}),t.jsxRuntimeExports.jsx(t.SelectContent,{children:t.jsxRuntimeExports.jsxs(t.SelectGroup,{children:[t.jsxRuntimeExports.jsx(t.SelectLabel,{children:"Data Labels"}),t.jsxRuntimeExports.jsx(t.SelectItem,{value:"none",children:"None"}),t.jsxRuntimeExports.jsx(t.SelectItem,{value:"start",children:"Start"}),t.jsxRuntimeExports.jsx(t.SelectItem,{value:"center",children:"Center"}),t.jsxRuntimeExports.jsx(t.SelectItem,{value:"end",children:"End"})]})})]})]})}function Pu({cardType:e}){function n(r){const i="SELECT label, [group], x-axis, y-axis, radius FROM table",s="SELECT label, [group], x-axis, y-axis FROM table";return t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsx("div",{className:"bg-muted px-2 py-1 rounded text-xs",children:r==="bubble"?i:s}),t.jsxRuntimeExports.jsxs("ul",{className:" ml-6 list-disc [&>li]:mt-2 text-xs",children:[t.jsxRuntimeExports.jsx("li",{children:"label - category"}),t.jsxRuntimeExports.jsx("li",{children:"group - category"}),t.jsxRuntimeExports.jsx("li",{children:"x-axis - category"}),t.jsxRuntimeExports.jsx("li",{children:"y-axis - category"}),r==="bubble"&&t.jsxRuntimeExports.jsx("li",{children:"radius - number"})]}),t.jsxRuntimeExports.jsxs("div",{children:["See ",t.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:o=>o.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#pie-chart",children:"example"})," in the docs."]})]})}return t.jsxRuntimeExports.jsx("div",{className:"px-6 py-2 space-y-6",children:t.jsxRuntimeExports.jsxs(t.Accordion,{defaultValue:["item-2"],type:"multiple",children:[t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-1",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{children:`${t.titleCase(e)} Chart`}),t.jsxRuntimeExports.jsx(t.AccordionContent,{className:" space-y-4 font-mono text-xs ",children:n(e)})]}),t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-2",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{children:"Settings"}),t.jsxRuntimeExports.jsx(t.AccordionContent,{className:"px-2",children:t.jsxRuntimeExports.jsx(un,{})})]}),t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-3",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{children:"Filter on click"}),t.jsxRuntimeExports.jsx(t.AccordionContent,{className:"px-2",children:t.jsxRuntimeExports.jsx(Ve,{})})]})]})})}const Bu={datasets:[{type:"line",label:"Sum_sales",data:[]},{type:"bar",label:"Sum_profit",data:[]}]},_u={datasets:[{fill:"origin",type:"line",label:"Sum_sales",data:[]}]};function Vu(){const e=t.useEditorStore(n=>n.card.type);return t.jsxRuntimeExports.jsxs("div",{className:"p-6 space-y-6",children:[t.jsxRuntimeExports.jsx(t.Accordion,{className:" ",type:"single",collapsible:!0,children:Hu(e)}),t.jsxRuntimeExports.jsx("section",{className:"",children:["line","bar"].includes(e)&&t.jsxRuntimeExports.jsx(an,{})}),t.jsxRuntimeExports.jsx("div",{children:!["kpi"].includes(e)&&t.jsxRuntimeExports.jsx(un,{})}),t.jsxRuntimeExports.jsx("div",{children:!["kpi"].includes(e)&&t.jsxRuntimeExports.jsx(Ve,{})})]})}function Hu(e){if(["line","bar"].includes(e))return t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-1",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{className:" font-normal",children:t.jsxRuntimeExports.jsx("p",{children:"Chart Query"})}),t.jsxRuntimeExports.jsxs(t.AccordionContent,{className:" ",children:[t.jsxRuntimeExports.jsx("div",{className:"bg-muted px-2 py-1 rounded font-mono font-semibold text-xs",children:"SELECT x-axis, y-axis-1, y-axis-2, y-axis-3,... FROM table"}),t.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs",children:[t.jsxRuntimeExports.jsx("li",{children:"X-axis - Category (ex. city)"}),t.jsxRuntimeExports.jsx("li",{children:"Y-axis - Number (ex. population)"})]})]})]}),t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-2",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{className:" font-normal",children:"Mixed Chart"}),t.jsxRuntimeExports.jsxs(t.AccordionContent,{className:" text-xs space-y-2",children:[t.jsxRuntimeExports.jsxs("p",{children:["Click ",t.jsxRuntimeExports.jsx("b",{children:"Customize"})," and change the `type` property in the dataset."]}),t.jsxRuntimeExports.jsx("pre",{children:JSON.stringify(Bu,null,2)})]})]}),t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-3",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{className:" font-normal",children:"Area Chart"}),t.jsxRuntimeExports.jsxs(t.AccordionContent,{className:" text-xs space-y-2",children:[t.jsxRuntimeExports.jsxs("p",{children:["Click ",t.jsxRuntimeExports.jsx("b",{children:"Customize"})," and add `fill` property to the dataset. See",t.jsxRuntimeExports.jsx("a",{className:"text-blue-500 hover:underline mx-1",href:"https://www.chartjs.org/docs/latest/samples/area/line-boundaries.html",target:"_blank",children:"docs"}),"for more options."]}),t.jsxRuntimeExports.jsx("pre",{children:JSON.stringify(_u,null,2)})]})]})]});if(e==="bubble")return t.jsxRuntimeExports.jsx(t.jsxRuntimeExports.Fragment,{children:t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-1",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{className:" font-normal",children:t.jsxRuntimeExports.jsxs("p",{children:["How to create a ",t.jsxRuntimeExports.jsx("span",{children:e})," chart query?"]})}),t.jsxRuntimeExports.jsxs(t.AccordionContent,{className:" ",children:[t.jsxRuntimeExports.jsx("div",{className:"bg-muted px-2 py-1 rounded font-mono font-semibold text-xs",children:"SELECT label, x-axis, y-axis, radius FROM table"}),t.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs",children:[t.jsxRuntimeExports.jsx("li",{children:"Label - Category (ex. city)"}),t.jsxRuntimeExports.jsx("li",{children:"Bubble Group (opt) - Category (ex. state)"}),t.jsxRuntimeExports.jsx("li",{children:"X-axis - Number (ex. avg. age)"}),t.jsxRuntimeExports.jsx("li",{children:"Y-axis - Number (ex. avg. weight)"}),t.jsxRuntimeExports.jsx("li",{children:"Radius - Number (ex. population)"})]})]})]})});if(e==="scatter")return t.jsxRuntimeExports.jsx(t.jsxRuntimeExports.Fragment,{children:t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-1",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{className:" font-normal",children:t.jsxRuntimeExports.jsxs("p",{children:["How to create a ",t.jsxRuntimeExports.jsx("span",{children:e})," chart query?"]})}),t.jsxRuntimeExports.jsxs(t.AccordionContent,{className:" ",children:[t.jsxRuntimeExports.jsx("div",{className:"bg-muted px-2 py-1 rounded font-mono font-semibold text-xs",children:"SELECT label, x-axis, y-axis FROM table"}),t.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs",children:[t.jsxRuntimeExports.jsx("li",{children:"Label - Category (ex. city)"}),t.jsxRuntimeExports.jsx("li",{children:"Group (opt) - Category (ex. state)"}),t.jsxRuntimeExports.jsx("li",{children:"X-axis - Number (ex. avg. age)"}),t.jsxRuntimeExports.jsx("li",{children:"Y-axis - Number (ex. avg. weight)"})]})]})]})});if(["pie","doughnut","polarArea"].includes(e))return t.jsxRuntimeExports.jsx(t.jsxRuntimeExports.Fragment,{children:t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-1",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{className:" font-normal",children:t.jsxRuntimeExports.jsxs("p",{children:[t.jsxRuntimeExports.jsx("span",{children:e==="polarArea"?"Polar":e.charAt(0).toUpperCase()+e.slice(1)})," ","chart query"]})}),t.jsxRuntimeExports.jsxs(t.AccordionContent,{className:" ",children:[t.jsxRuntimeExports.jsx("div",{className:"bg-muted px-2 py-1 rounded font-mono font-semibold text-xs",children:"SELECT label, measure FROM table"}),t.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs",children:[t.jsxRuntimeExports.jsx("li",{children:"Label - Category (ex. city)"}),t.jsxRuntimeExports.jsx("li",{children:"Measure - Number (ex. population)"})]})]})]})})}function qu(){var l,a,u;const e=t.useEditorStore(c=>c.card.preferences),n=t.useEditorStore(c=>c.actions.setCardPreferences),r=t.useEditorStore(c=>c.actions.setNumberFormat),i=t.useEditorStore(c=>{var x,p;return(p=(x=c.card.preferences)==null?void 0:x.formatNumber)==null?void 0:p.format}),s=t.useEditorStore(c=>{var x,p;return(p=(x=c.card.preferences)==null?void 0:x.formatNumber)==null?void 0:p.locale}),o=t.useEditorStore(c=>{var x,p;return(p=(x=c.card.preferences)==null?void 0:x.formatNumber)==null?void 0:p.currency});return t.useEditorStore(c=>c.actions.setFilterOnClickField),t.jsxRuntimeExports.jsxs("div",{children:[t.jsxRuntimeExports.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[t.jsxRuntimeExports.jsx(t.Checkbox,{checked:!!((l=e==null?void 0:e.formatNumber)!=null&&l.enabled),onCheckedChange:c=>{n({...e,formatNumber:{...e==null?void 0:e.formatNumber,enabled:c}})}}),t.jsxRuntimeExports.jsx(t.Label,{children:"Format Number"})]}),((a=e==null?void 0:e.formatNumber)==null?void 0:a.enabled)===!0&&t.jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsxRuntimeExports.jsxs("div",{children:[t.jsxRuntimeExports.jsx(t.Label,{className:"text-xs",children:"Currency"}),t.jsxRuntimeExports.jsxs("div",{className:"flex gap-1",children:[t.jsxRuntimeExports.jsx(t.Input,{value:o||"",className:"h-7 w-20 font-mono text-xs focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",placeholder:"USD",onChange:c=>{var x,p,m;return r(((x=e==null?void 0:e.formatNumber)==null?void 0:x.format)||"",c.target.value,((p=e==null?void 0:e.formatNumber)==null?void 0:p.locale)||"",((m=e==null?void 0:e.formatNumber)==null?void 0:m.suffix)||"")}}),t.jsxRuntimeExports.jsx(t.Input,{value:s||"",className:"h-7 w-20 font-mono text-xs focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",placeholder:"en-US",onChange:c=>{var x,p,m;return r(((x=e==null?void 0:e.formatNumber)==null?void 0:x.format)||"",((p=e==null?void 0:e.formatNumber)==null?void 0:p.currency)||"",c.target.value,((m=e==null?void 0:e.formatNumber)==null?void 0:m.suffix)||"")}})]})]}),t.jsxRuntimeExports.jsxs("div",{children:[t.jsxRuntimeExports.jsxs("div",{className:"flex gap-1",children:[t.jsxRuntimeExports.jsx(t.Label,{className:"text-xs",children:"Format"}),t.jsxRuntimeExports.jsxs(t.Tooltip,{children:[t.jsxRuntimeExports.jsx(t.TooltipTrigger,{children:t.jsxRuntimeExports.jsx(t.InfoCircledIcon,{strokeWidth:1,className:"h-3 w-3 opacity-70"})}),t.jsxRuntimeExports.jsx(t.TooltipContent,{children:t.jsxRuntimeExports.jsxs("div",{className:"max-w-[200px]",children:["Format number",t.jsxRuntimeExports.jsx("div",{className:"mt-1 font-mono text-xs",children:"#.## for 123.43"})]})})]})]}),t.jsxRuntimeExports.jsx("div",{children:t.jsxRuntimeExports.jsx(t.Input,{value:i||"",className:"h-7 font-mono text-xs focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",placeholder:"###,###.##",onChange:c=>{var x,p,m;return r(c.target.value,((x=e==null?void 0:e.formatNumber)==null?void 0:x.currency)||"",((p=e==null?void 0:e.formatNumber)==null?void 0:p.locale)||"",((m=e==null?void 0:e.formatNumber)==null?void 0:m.suffix)||"")}})})]}),t.jsxRuntimeExports.jsxs("div",{children:[t.jsxRuntimeExports.jsx(t.Label,{className:"text-xs",children:"Suffix"}),t.jsxRuntimeExports.jsx(t.Input,{value:((u=e==null?void 0:e.formatNumber)==null?void 0:u.suffix)||"",className:"h-7 font-mono text-xs focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",placeholder:"K, M, B",onChange:c=>{var x,p,m;return r(((x=e==null?void 0:e.formatNumber)==null?void 0:x.format)||"",((p=e==null?void 0:e.formatNumber)==null?void 0:p.currency)||"",((m=e==null?void 0:e.formatNumber)==null?void 0:m.locale)||"",c.target.value)}})]})]})]})}function Uu(){return t.jsxRuntimeExports.jsxs("div",{className:"space-y-6 px-6 py-2",children:[t.jsxRuntimeExports.jsx(t.Accordion,{type:"single",collapsible:!0,children:t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-1",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{className:"",children:"KPI Query"}),t.jsxRuntimeExports.jsxs(t.AccordionContent,{className:"font-mono",children:[t.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs",children:"SELECT current, previous FROM table"}),t.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs [&>li]:mt-2",children:[t.jsxRuntimeExports.jsx("li",{children:"current - number"}),t.jsxRuntimeExports.jsx("li",{children:"previous - number"})]}),t.jsxRuntimeExports.jsxs("div",{children:["See ",t.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:e=>e.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#kpi",children:"example"})," in the docs."]})]})]})}),t.jsxRuntimeExports.jsx("section",{className:"",children:t.jsxRuntimeExports.jsx(qu,{})}),t.jsxRuntimeExports.jsx("div",{}),t.jsxRuntimeExports.jsx("div",{})]})}function $u({cardType:e}){return t.jsxRuntimeExports.jsx("div",{className:"px-6 py-2 space-y-6",children:t.jsxRuntimeExports.jsxs(t.Accordion,{defaultValue:["item-2"],type:"multiple",children:[t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-1",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{children:`${t.titleCase(e)} Chart`}),t.jsxRuntimeExports.jsxs(t.AccordionContent,{className:" space-y-4 font-mono text-xs ",children:[t.jsxRuntimeExports.jsx("div",{className:"bg-muted px-2 py-1 rounded text-xs",children:"SELECT label, measure FROM table"}),t.jsxRuntimeExports.jsxs("ul",{className:" ml-6 list-disc [&>li]:mt-2 text-xs",children:[t.jsxRuntimeExports.jsx("li",{children:"label - category"}),t.jsxRuntimeExports.jsx("li",{children:"measure - number"})]}),t.jsxRuntimeExports.jsxs("div",{children:["See ",t.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."]})]})]}),t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-2",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{children:"Settings"}),t.jsxRuntimeExports.jsx(t.AccordionContent,{className:"px-2",children:t.jsxRuntimeExports.jsx(un,{})})]}),t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-3",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{children:"Filter on click"}),t.jsxRuntimeExports.jsx(t.AccordionContent,{className:"px-2",children:t.jsxRuntimeExports.jsx(Ve,{})})]})]})})}function Ku(){return t.jsxRuntimeExports.jsx("div",{className:"space-y-6 px-6 py-2",children:t.jsxRuntimeExports.jsxs(t.Accordion,{defaultValue:["item-2"],type:"multiple",children:[t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-1",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{children:"Stacked Chart"}),t.jsxRuntimeExports.jsxs(t.AccordionContent,{className:"space-y-4 font-mono text-xs",children:[t.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT x-axis, stack-by, y-axis FROM table"}),t.jsxRuntimeExports.jsxs("ul",{className:"ml-6 list-disc text-xs [&>li]:mt-2",children:[t.jsxRuntimeExports.jsx("li",{children:"x-axis - category"}),t.jsxRuntimeExports.jsx("li",{children:"stack by - category"}),t.jsxRuntimeExports.jsx("li",{children:"y-axis - number"})]}),t.jsxRuntimeExports.jsxs("div",{children:["See ",t.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:e=>e.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#stacked-chart",children:"example"})," in the docs."]})]})]}),t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-2",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{children:"Settings"}),t.jsxRuntimeExports.jsxs(t.AccordionContent,{className:"space-y-4 px-2",children:[t.jsxRuntimeExports.jsx(an,{}),t.jsxRuntimeExports.jsx(oi,{})]})]}),t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-3",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{children:"Filter on click"}),t.jsxRuntimeExports.jsx(t.AccordionContent,{className:"px-2",children:t.jsxRuntimeExports.jsx(Ve,{})})]})]})})}function Wu({cardType:e}){return console.log("TableVisualSettings",e),t.jsxRuntimeExports.jsx("div",{className:"space-y-6 px-6 py-2",children:t.jsxRuntimeExports.jsx(t.Accordion,{defaultValue:["item-3"],type:"multiple",children:t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-3",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{children:"Filter on click"}),t.jsxRuntimeExports.jsx(t.AccordionContent,{className:"px-2",children:t.jsxRuntimeExports.jsx(Ve,{})})]})})})}function Gu(){const e=t.useEditorStore(r=>r.card.type);function n(r){switch(r){case"stackedBar":return t.jsxRuntimeExports.jsx(Ku,{});case"kpi":return t.jsxRuntimeExports.jsx(Uu,{});case"line":case"bar":return t.jsxRuntimeExports.jsx(Mu,{cardType:r});case"pie":case"doughnut":case"polarArea":case"radar":return t.jsxRuntimeExports.jsx($u,{cardType:r});case"bubble":case"scatter":return t.jsxRuntimeExports.jsx(Pu,{cardType:r});case"table":return t.jsxRuntimeExports.jsx(Wu,{cardType:r});default:return t.jsxRuntimeExports.jsx(Vu,{})}}return t.jsxRuntimeExports.jsx(t.ScrollArea,{className:"h-full w-full text-sm",children:n(e)})}function Qu(){const e=t.useEditorStore(n=>n.isShowingVisual);return t.jsxRuntimeExports.jsxs(Lt,{direction:"vertical",className:"min-w-full max-w-lg min-h-[250px]",children:[t.jsxRuntimeExports.jsx(Fe,{role:"query-section",className:"flex",minSize:20,defaultSize:40,children:t.jsxRuntimeExports.jsx(wu,{})}),t.jsxRuntimeExports.jsx(Ot,{withHandle:!0,className:"border "}),t.jsxRuntimeExports.jsx(Fe,{className:"pb-1",role:"visual-section",minSize:0,defaultSize:60,children:e?t.jsxRuntimeExports.jsxs(Lt,{direction:"horizontal",children:[t.jsxRuntimeExports.jsx(t.jsxRuntimeExports.Fragment,{children:t.jsxRuntimeExports.jsx(Fe,{className:"flex min-w-[275px]",minSize:20,defaultSize:25,maxSize:30,children:t.jsxRuntimeExports.jsx(Gu,{})})}),t.jsxRuntimeExports.jsx(Ot,{className:"border "}),t.jsxRuntimeExports.jsx(Fe,{minSize:40,defaultSize:75,maxSize:100,children:t.jsxRuntimeExports.jsx(nr,{})})]}):t.jsxRuntimeExports.jsx(nr,{})})]})}function Ju({authToken:e,onSave:n,onClose:r}){const i=t.useEditorStore(l=>l.actions.setOnSave),s=t.useEditorStore(l=>l.actions.setOnClose),o=t.useDashboardStore(l=>l.actions.setAuthToken);return A.useEffect(()=>{n&&i(n),r&&s(r)},[n,i,r,s]),A.useEffect(()=>{e&&e.accessToken&&o(e)},[e,o]),t.jsxRuntimeExports.jsxs(t.EditorPanel,{className:"rounded-none",role:"editor-panel",children:[t.jsxRuntimeExports.jsx(t.EditorAside,{className:"rounded-none border-r-[1.5px]",children:t.jsxRuntimeExports.jsx(cr,{})}),t.jsxRuntimeExports.jsx(t.EditorMain,{children:t.jsxRuntimeExports.jsx(Qu,{})})]})}function Xu(){t.useDashboardStore(l=>l.selectedCardId);const e=t.useDashboardStore(l=>l.selectedSheetId),{setIsVisualEditing:n}=t.useDashboardStore(l=>l.actions),r=t.useDashboardStore(l=>l.isVisualEditing),i=t.useDashboardStore(l=>l.actions.updateFrame);function s(l){e&&(i(e,l),n(!1))}function o(){n(!1)}return t.jsxRuntimeExports.jsx("div",{role:"editor-container",className:t.cn("flex grow",{block:r,hidden:!r}),children:t.jsxRuntimeExports.jsx(Ju,{onSave:s,onClose:o})})}function Yu({columns:e,tableName:n}){const r=t.useEditorStore(p=>p.selectedConnectionId),i=t.useEditorStore(p=>p.selectedDatabaseName),s=t.useEditorStore(p=>p.selectedSchemaName),o=t.useEditorStore(p=>p.selectedTableName),l=t.useDashboardStore(p=>p.dashboard.filters)||[],a=t.useDashboardStore(p=>p.actions.addFilter),u=t.useDashboardStore(p=>p.actions.removeFilter),c=t.useDashboardStore(p=>p.actions.removeFilterValue);function x(p){const m=t.fmt(p.column_name),d=t.fmt(i||""),j=t.fmt(s||""),E=t.fmt(n),k=t.getQualifiedTableName(j,E),y=`${k}.${m}`;console.log("find",y,E,d);const w=l==null?void 0:l.find(S=>S.column===y&&S.table===E&&(S.database===d||S.database===i));if(w)c(w.id),u(w.id);else{if(n==="api"&&r){a({id:t.v4(),column:y,title:p.column_name,dataType:p.data_type,table:"api",database:"NA",connectionId:r,operation:"in",sql:t.getDefaultFilterSql(p.data_type,k,m)});return}if(!r||!i||!o)throw new Error("missing connectionId, database, or table");a({id:t.v4(),column:`${k}.${m}`,title:p.column_name,dataType:p.data_type,table:o,database:i,connectionId:r,operation:"in",sql:t.getDefaultFilterSql(p.data_type,k,m)})}}return t.jsxRuntimeExports.jsx("div",{className:"xbg-red-100 flex-1 basis-0 flex-col overflow-scroll px-3",children:e==null?void 0:e.map(p=>{const m=l==null?void 0:l.find(d=>d.column===t.fmt(p.column_name)&&d.table===o&&d.database===i);return t.jsxRuntimeExports.jsx("div",{onClick:()=>x(p),className:t.cn("group flex cursor-pointer items-center justify-between border border-dashed border-background px-3 py-[6px] text-sm transition-colors hover:bg-muted/50",{"bg-muted":m}),children:t.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxRuntimeExports.jsx(ur,{column:p}),t.jsxRuntimeExports.jsx("span",{children:p.column_name})]})},p.column_name)})})}function Zu(){t.useDashboardStore(n=>n.showFilters);const e=t.useDashboardStore(n=>n.actions.setShowFilters);return t.jsxRuntimeExports.jsxs("section",{className:"relative flex grow flex-col border-l px-4",children:[t.jsxRuntimeExports.jsxs("div",{className:"mt-4 flex items-center justify-between gap-2 px-3",children:[t.jsxRuntimeExports.jsx(t.Label,{className:"text-lg",children:"Filters"}),t.jsxRuntimeExports.jsx(t.Button,{onClick:()=>e(!1),className:"h-7 w-7 p-0",variant:"ghost",children:t.jsxRuntimeExports.jsx(t.Cross2Icon,{})})]}),t.jsxRuntimeExports.jsx("div",{className:"flex grow",children:t.jsxRuntimeExports.jsx(cr,{ColumnsComponent:(n,r,i)=>t.jsxRuntimeExports.jsx(Yu,{schemaName:n,tableName:r,columns:i})})})]})}function ec(){t.useDashboardStore(r=>r.dashboard);const e=t.useDashboardStore(r=>r.showFilters),n=t.useDashboardStore(r=>r.isVisualEditing);return t.useDashboardStore(r=>r.bookmarkKey),t.jsxRuntimeExports.jsxs("div",{role:"dashboard-plus-main",className:t.cn("grow",{hidden:n,flex:!n}),children:[t.jsxRuntimeExports.jsx(t.DashboardTabs,{}),e&&t.jsxRuntimeExports.jsx("div",{role:"filter-aside-container",className:"flex",children:t.jsxRuntimeExports.jsx(Zu,{})})]})}function tc(){const e=t.useDashboardStore(i=>i.dashboard),n=t.useDashboardStore(i=>i.actions.setDashboard),r=t.useDashboardStore(i=>i.showDashboardJSON);return t.useDashboardStore(i=>i.actions.setShowDashboardJSON),t.jsxRuntimeExports.jsx("div",{className:t.cn(" p-2",{hidden:!r}),children:t.jsxRuntimeExports.jsx(t.de,{onChange:i=>{if(i)try{JSON.parse(i),n(JSON.parse(i))}catch{}},defaultLanguage:"json",className:"h-[550px] overflow-y-auto ",value:JSON.stringify(e,null,2),options:{minimap:{enabled:!1},glyphMargin:!1,wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:12,renderLineHighlight:"none"}})})}function nc({showControls:e=!1,showFooter:n=!0,...r}){return t.jsxRuntimeExports.jsx(t.SemaphorContextProvider,{dashboardProps:r,children:t.jsxRuntimeExports.jsxs(t.UXProvider,{children:[t.jsxRuntimeExports.jsx(tc,{}),t.jsxRuntimeExports.jsxs(t.DashboardPanel,{...r,children:[e&&t.jsxRuntimeExports.jsx(Di,{}),t.jsxRuntimeExports.jsx(Xu,{}),t.jsxRuntimeExports.jsx(ec,{})]})]})})}exports.DashboardPlus=nc;exports.SelectComponent=Ue;
|
|
228
|
+
Visual Query Syntax: ${fu}`,{data:b,isLoading:M,isFetching:T,isError:z,refetch:H}=t.useQuery({queryKey:["ai-query"],queryFn:()=>t.getRequest("https://semaphor.cloud/api/v1/ai",(u==null?void 0:u.accessToken)||"",{user_content:`userContent: ${D} ${c?O:""}`}),enabled:!1});function I(N){if(N.toLowerCase().includes("bar"))j("bar");else if(N.toLowerCase().includes("line"))j("line");else if(N.toLowerCase().includes("bubble"))j("bubble");else if(N.toLowerCase().includes("scatter"))j("scatter");else if(N.toLowerCase().includes("stacked"))j("stackedBar");else if(N.toLowerCase().includes("pie"))j("pie");else if(N.toLowerCase().includes("donut")||N.toLowerCase().includes("doughnut"))j("doughnut");else if(N.toLowerCase().includes("radar"))j("radar");else return j("bar"),!1;return!0}A.useEffect(()=>{b&&k(N=>[...N,{role:"ai",content:b.response}])},[b]),A.useEffect(()=>{const N=setTimeout(()=>{var h;a.current&&(a.current.scroll({top:a.current.scrollHeight,behavior:"smooth"}),(h=l.current)==null||h.focus())},100);return()=>clearTimeout(N)},[E]);function v(){r&&(k(N=>[...N,{role:"user",content:r}]),I(r)&&x(!0),i(""),H())}A.useEffect(()=>{s&&(v(),o(!1))},[s,o]);const U={fontFamily:"Arial, sans-serif",lineHeight:1.6,fontSize:15,width:"100%"},$={fontFamily:"monospace",fontSize:14,lineHeight:1.6},P={fontFamily:"Arial, sans-serif",lineHeight:1.6,fontSize:15,padding:"2px 0",marginLeft:20,listStyleType:"disc"},q={p:({node:N,...h})=>t.jsxRuntimeExports.jsx("p",{style:U,...h}),code:({node:N,...h})=>t.jsxRuntimeExports.jsx("code",{className:"rounded-sm bg-muted px-2 py-1 text-sm",...h}),pre:({node:N,...h})=>t.jsxRuntimeExports.jsxs("pre",{className:"space-y-2 rounded-sm bg-muted/50 p-3",style:$,children:[t.jsxRuntimeExports.jsx("code",{className:"whitespace-normal text-sm",children:h.children}),t.jsxRuntimeExports.jsxs("div",{className:"flex justify-start gap-2",children:[t.jsxRuntimeExports.jsx(t.Button,{onClick:Q,size:"sm",variant:"outline",children:t.jsxRuntimeExports.jsx(t.ClipboardCopyIcon,{})}),t.jsxRuntimeExports.jsx(t.Button,{onClick:J=>{const te=Q(J);te&&(n(!1),p(te),d(!0))},size:"sm",variant:"outline",children:t.jsxRuntimeExports.jsx(t.PlayIcon,{})})]})]}),li:({node:N,...h})=>t.jsxRuntimeExports.jsx("li",{style:P,...h})};function Q(N){const h=N.currentTarget.closest("pre");if(!h)return;const J=h.textContent||h.innerText;return navigator.clipboard.writeText(J).then(()=>console.log("Text copied to clipboard")).catch(te=>console.error("Error in copying text: ",te)),J}function re(){return E==null?void 0:E.map((N,h)=>N.role==="user"?t.jsxRuntimeExports.jsxs("div",{className:"flex items-start rounded-md bg-muted p-3 text-sm",children:[t.jsxRuntimeExports.jsx(Ti,{className:"mr-2 h-5 w-5"}),t.jsxRuntimeExports.jsx("div",{children:N.content})]},h):N.role==="ai"?t.jsxRuntimeExports.jsx(t.jsxRuntimeExports.Fragment,{children:t.jsxRuntimeExports.jsx(mu,{className:"w-full overflow-auto py-1",components:q,children:b==null?void 0:b.response},h)}):t.jsxRuntimeExports.jsx("div",{},h))}return t.jsxRuntimeExports.jsxs(t.Dialog,{open:e,onOpenChange:n,children:[t.jsxRuntimeExports.jsx(t.DialogTrigger,{asChild:!0,children:t.jsxRuntimeExports.jsx(t.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..."})}),t.jsxRuntimeExports.jsxs(t.DialogContent,{className:"flex flex-col justify-between overflow-auto sm:max-w-[425px] md:max-h-[625px] md:min-w-[625px]",children:[t.jsxRuntimeExports.jsxs(t.DialogHeader,{children:[t.jsxRuntimeExports.jsx(t.DialogTitle,{children:"Assistant"}),t.jsxRuntimeExports.jsx(t.DialogDescription,{children:"What can I help you with?"})]}),t.jsxRuntimeExports.jsx("div",{ref:a,className:"h-[625px] w-full overflow-auto border-t border-t-muted",children:t.jsxRuntimeExports.jsx("div",{className:"space-y-4 py-2 pr-3",role:"messages",children:re()})}),t.jsxRuntimeExports.jsx("div",{children:t.jsxRuntimeExports.jsxs("div",{className:"flex w-full items-center rounded-md border",children:[t.jsxRuntimeExports.jsx(t.Textarea,{autoFocus:!0,ref:l,onKeyDown:N=>{N.key==="Enter"&&!N.shiftKey&&(N.preventDefault(),i(""),v())},placeholder:"Type your question here...",onFocus:N=>{const h=N.target,J=h.value.length;h.setSelectionRange(J,J)},className:t.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:M||T,value:r,onChange:N=>i(N.target.value)})," ",t.jsxRuntimeExports.jsx(t.Button,{className:"h-8",size:"sm",variant:"ghost",onClick:v,children:!M&&!T?t.jsxRuntimeExports.jsx(t.PaperPlaneIcon,{}):t.jsxRuntimeExports.jsx(t.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"})})]})})]})]})}var Jr={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},er=A.createContext&&A.createContext(Jr),ju=["attr","size","title"];function yu(e,n){if(e==null)return{};var r=Eu(e,n),i,s;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(s=0;s<o.length;s++)i=o[s],!(n.indexOf(i)>=0)&&Object.prototype.propertyIsEnumerable.call(e,i)&&(r[i]=e[i])}return r}function Eu(e,n){if(e==null)return{};var r={},i=Object.keys(e),s,o;for(o=0;o<i.length;o++)s=i[o],!(n.indexOf(s)>=0)&&(r[s]=e[s]);return r}function ut(){return ut=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},ut.apply(this,arguments)}function tr(e,n){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);n&&(i=i.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),r.push.apply(r,i)}return r}function ct(e){for(var n=1;n<arguments.length;n++){var r=arguments[n]!=null?arguments[n]:{};n%2?tr(Object(r),!0).forEach(function(i){bu(e,i,r[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):tr(Object(r)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(r,i))})}return e}function bu(e,n,r){return n=ku(n),n in e?Object.defineProperty(e,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[n]=r,e}function ku(e){var n=Su(e,"string");return typeof n=="symbol"?n:String(n)}function Su(e,n){if(typeof e!="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var i=r.call(e,n||"default");if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(n==="string"?String:Number)(e)}function Xr(e){return e&&e.map((n,r)=>A.createElement(n.tag,ct({key:r},n.attr),Xr(n.child)))}function ze(e){return n=>A.createElement(Ru,ut({attr:ct({},e.attr)},n),Xr(e.child))}function Ru(e){var n=r=>{var{attr:i,size:s,title:o}=e,l=yu(e,ju),a=s||r.size||"1em",u;return r.className&&(u=r.className),e.className&&(u=(u?u+" ":"")+e.className),A.createElement("svg",ut({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},r.attr,i,l,{className:u,style:ct(ct({color:e.color||r.color},r.style),e.style),height:a,width:a,xmlns:"http://www.w3.org/2000/svg"}),o&&A.createElement("title",null,o),e.children)};return er!==void 0?A.createElement(er.Consumer,null,r=>n(r)):n(Jr)}function Cu(e){return ze({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:[]}]})(e)}function wu(){const{theme:e}=t.useTheme(),n=A.useRef(),r=A.useRef(),[i,s]=A.useState(!1),[o,l]=A.useState(!1),[a,u]=A.useState(!1),[c,x]=A.useState(""),[p,m]=A.useState(!1),{authToken:d}=t.useSemaphorContext();t.useDashboardStore(g=>g.selectedSheetId);const j=t.useDashboardStore(g=>g.dashboard.baseQueries),E=t.useEditorStore(g=>g.card),k=t.useDashboardStore(g=>g.theme),y=t.useEditorStore(g=>g.isShowingVisual),w=t.useEditorStore(g=>g.selectedConnectionId),S=t.useEditorStore(g=>g.selectedDatabaseName),D=t.useEditorStore(g=>g.selectedSchemaName);t.useDashboardStore(g=>g.actions.updateFrameCard);const O=t.useEditorStore(g=>g.selectedTableName),b=t.useEditorStore(g=>g.card.sql),M=t.useEditorStore(g=>g.card.python),T=t.resolveBaseQuery(b,j),z=t.useEditorStore(g=>g.selectedConnectionId),H=t.useEditorStore(g=>g.frame),I=t.useEditorStore(g=>g.filterValues),v=t.useEditorStore(g=>g.applyFilters),{setCardCustomCfg:U,setQueryResultColumns:$,setFilterValues:P,setCardSql:q,setCardPython:Q,setQueryError:re,setPythonStdOut:N}=t.useEditorStore(g=>g.actions),h=t.useEditorStore(g=>g.onSave),J=t.useEditorStore(g=>g.actions.setApplyFilters),te=t.useEditorStore(g=>g.onClose),f=t.useEditorStore(g=>g.actions.setCardData),ae=t.useEditorStore(g=>g.actions.setSqlGen),ge=t.useEditorStore(g=>g.runSql),X=t.useEditorStore(g=>g.actions.setRunSql),ke=t.useEditorStore(g=>g.actions.setIsSqlRunning),{data:ne,isLoading:he,isFetching:xe,isSuccess:Le,isError:Oe,error:He,status:mt,refetch:Ie}=t.useQuery({queryKey:[T,M],queryFn:()=>t.postRequest("https://semaphor.cloud/api/v1/query",(d==null?void 0:d.accessToken)||"",{connection_id:z,sql:T,python:M===t.PYTHON_DEFAULT_CODE?"":M,active_filters:v?I:[]}),enabled:!1,retry:!1});A.useEffect(()=>{if(ne&&(f(ne.records),N((ne==null?void 0:ne.output)||""),ne.records.length>0)){const{dimensionKeys:g}=t.getKeys(ne.records);$(g)}},[ne,f,$,N]),A.useEffect(()=>{ge&&(Ie(),X(!1))},[ge,Ie,X]),A.useEffect(()=>{(he||xe)&&ke(!0),(Oe||Le)&&ke(!1),Oe?(re(He.message),f([]),$([]),N("")):re("")},[he,xe,ne,N,Oe,Le,ke,f,$,re,He]);function Je(){q(""),f([]),ae({}),U("")}const Xe=g=>{r.current=g};function Ye(){let g=b;b&&!b.includes("{{")&&(g=Pi(b),q(g));const C={...E,lastSelectedSchema:D,lastSelectedDatabase:S,lastSelectedTable:O,connectionId:w,type:y?E.type:"table",sql:g,customCfg:y?E.customCfg:null},L=H.cards.map(B=>B.id===E.id?C:B);h==null||h({...H,cards:L})}function Ze(){te==null||te()}function ht(g){const C=getComputedStyle(document.documentElement).getPropertyValue(g);return ft(C)}function ft(g){const[C,L,B]=g.split(" "),_=parseFloat(C),ue=parseFloat(L),Se=parseFloat(B),fe=ue/100,we=Se/100,se=(1-Math.abs(2*we-1))*fe,Y=se*(1-Math.abs(_/60%2-1)),je=we-se/2;let ee=0,Re=0,Ce=0;0<=_&&_<60?(ee=se,Re=Y,Ce=0):60<=_&&_<120?(ee=Y,Re=se,Ce=0):120<=_&&_<180?(ee=0,Re=se,Ce=Y):180<=_&&_<240?(ee=0,Re=Y,Ce=se):240<=_&&_<300?(ee=Y,Re=0,Ce=se):300<=_&&_<360&&(ee=se,Re=0,Ce=Y),ee=Math.round((ee+je)*255),Re=Math.round((Re+je)*255),Ce=Math.round((Ce+je)*255);const yt=li=>{const Et=li.toString(16);return Et.length==1?"0"+Et:Et};return`#${yt(ee)}${yt(Re)}${yt(Ce)}`}A.useEffect(()=>{const g=n.current,C=r.current;if(g){const L=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",B=k==="system"?L:k;g.editor.defineTheme("default",{base:B==="light"?"vs":"vs-dark",inherit:!0,rules:[],colors:{"editor.background":B==="light"?"#ffffff":ht("--background")}}),g.editor.setTheme("default")}return C&&g&&C.addCommand(g.KeyMod.Shift|g.KeyCode.Enter,function(){return console.log("Executing query..."),Ie(),!1}),()=>{}},[e,k,n.current]);function et(g){n.current=g}function gt(){return t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[o&&t.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:t.jsxRuntimeExports.jsxs("div",{className:"w-[99%]",children:[t.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2 pt-3",children:[t.jsxRuntimeExports.jsx(_i,{checked:v,onCheckedChange:()=>J(!v),text:"Apply Filters"}),t.jsxRuntimeExports.jsx(Vi,{}),I&&o&&t.jsxRuntimeExports.jsx(t.Cross2Icon,{onClick:()=>l(!1),className:"bg-background/50 text-foreground/50 hover:cursor-pointer hover:text-foreground"})]}),t.jsxRuntimeExports.jsx(t.Ft,{theme:"default",onChange:g=>{if(g)try{JSON.parse(g),P(JSON.parse(g))}catch{}},defaultLanguage:"json",className:"mt-1 min-h-[220px]",value:JSON.stringify(I,null,2),options:{readOnly:!0,minimap:{enabled:!1},lineNumbers:"off",glyphMargin:!1,wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:12,renderLineHighlight:"none"}})]})}),I&&!o&&t.jsxRuntimeExports.jsx(ir,{onClick:()=>l(!0),className:t.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 jt(){return t.jsxRuntimeExports.jsxs(Lt,{className:"flex grow pb-1",direction:"vertical",role:"editor-resizable-group",children:[t.jsxRuntimeExports.jsxs(Fe,{id:"1",order:1,defaultSize:i?20:100,className:"relative flex grow",children:[t.jsxRuntimeExports.jsx("div",{role:"sql-container",className:"relative flex w-[99%]",children:t.jsxRuntimeExports.jsx(t.Ft,{theme:"default",className:"pt-3",onChange:g=>{q(g)},value:b,options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"sql",defaultValue:"SELECT * FROM table",beforeMount:et,onMount:Xe})}),i&&t.jsxRuntimeExports.jsx("code",{className:"absolute right-6 top-3 text-sm text-muted-foreground/70",children:"sql"})]}),i&&t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsx(Ot,{withHandle:!0,className:"border"}),t.jsxRuntimeExports.jsxs(Fe,{id:"2",order:2,defaultSize:80,className:"relative flex grow",children:[t.jsxRuntimeExports.jsx("div",{role:"python-container",className:"relative flex w-[99%] pt-0",children:t.jsxRuntimeExports.jsx(t.Ft,{className:"pt-3",theme:"default",onChange:g=>{Q(g&&g.trim()||"")},value:M||t.PYTHON_DEFAULT_CODE,options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"python",beforeMount:et,onMount:Xe})}),t.jsxRuntimeExports.jsx("code",{className:"absolute right-6 top-3 text-sm text-muted-foreground/70",children:"python"})]})]})]})}return t.jsxRuntimeExports.jsxs("section",{role:"editor-section",className:"flex grow flex-col justify-end",children:[t.jsxRuntimeExports.jsxs("div",{role:"sql-editor",className:"relative flex grow justify-between overflow-y-scroll",children:[jt(),gt()]}),t.jsxRuntimeExports.jsxs("div",{role:"editor-controls",className:"item-center flex flex-wrap justify-between gap-2 px-6 py-4",children:[t.jsxRuntimeExports.jsxs("div",{className:"flex grow items-center gap-2",children:[t.jsxRuntimeExports.jsxs(t.Button,{disabled:he||xe,onClick:()=>{Ie()},className:"shrink-0",size:"sm",variant:"outline",children:[he||xe?t.jsxRuntimeExports.jsx(t.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"}):t.jsxRuntimeExports.jsx(Si,{className:"mr-2 h-4 w-4"}),"Run"]}),Oe&&t.jsxRuntimeExports.jsx(Bi,{error:He.message,setShowAIDialog:u,setTriggerAIRun:m,setUserInputforAI:x}),t.jsxRuntimeExports.jsxs(t.Button,{onClick:Je,className:"",size:"sm",variant:"outline",children:[t.jsxRuntimeExports.jsx(xi,{className:"mr-2 size-4"}),"Clear"]}),t.jsxRuntimeExports.jsx(t.Toggle,{pressed:i,onPressedChange:g=>s(g),className:"",size:"sm",variant:"outline",children:t.jsxRuntimeExports.jsx(Cu,{className:"size-4 text-foreground/70"})}),t.jsxRuntimeExports.jsx(gu,{open:a,setOpen:u,userInput:c,triggerAIRun:p,setTriggerAIRun:m,setUserInput:g=>x(g)})]}),t.jsxRuntimeExports.jsxs("div",{className:"flex items-end gap-2",children:[t.jsxRuntimeExports.jsxs(t.Button,{onClick:Ye,size:"sm",variant:"outline",children:[t.jsxRuntimeExports.jsx(t.Check,{className:"mr-2 size-4 font-bold text-green-600"}),"Accept"]}),t.jsxRuntimeExports.jsxs(t.Button,{onClick:Ze,className:"w-full",size:"sm",variant:"outline",children:[t.jsxRuntimeExports.jsx(t.Cross2Icon,{className:"mr-2 size-4"}),"Close"]})]})]})]})}function vu({data:e}){var l;const[n,r]=A.useState([]),s=Object.keys(e[0]).map(a=>({accessorKey:a,header:({column:u})=>{const c=u.getIsSorted();return t.jsxRuntimeExports.jsx("div",{className:"flex gap-2",children:t.jsxRuntimeExports.jsxs("div",{className:"flex cursor-pointer items-center",onClick:()=>u.toggleSorting(u.getIsSorted()==="asc"),children:[a,c==="asc"?t.jsxRuntimeExports.jsx(t.TriangleUpIcon,{className:"ml-2 h-5 w-5"}):c==="desc"?t.jsxRuntimeExports.jsx(t.TriangleDownIcon,{className:"ml-2 h-5 w-5"}):null]})})}})),o=t.useReactTable({data:e,columns:s,getCoreRowModel:t.getCoreRowModel(),getPaginationRowModel:t.getPaginationRowModel(),onSortingChange:r,getSortedRowModel:t.getSortedRowModel(),manualPagination:!0,state:{sorting:n}});return t.jsxRuntimeExports.jsxs(t.Table,{children:[t.jsxRuntimeExports.jsx(t.TableHeader,{children:o.getHeaderGroups().map(a=>t.jsxRuntimeExports.jsx(t.TableRow,{children:a.headers.map(u=>t.jsxRuntimeExports.jsx(t.TableHead,{className:"sticky top-0 bg-muted",children:u.isPlaceholder?null:t.flexRender(u.column.columnDef.header,u.getContext())},u.id))},a.id))}),t.jsxRuntimeExports.jsx(t.TableBody,{children:(l=o.getRowModel().rows)!=null&&l.length?o.getRowModel().rows.map(a=>t.jsxRuntimeExports.jsx(t.TableRow,{className:"whitespace-nowrap py-2","data-state":a.getIsSelected()&&"selected",children:a.getVisibleCells().map(u=>t.jsxRuntimeExports.jsx(t.TableCell,{children:t.flexRender(u.column.columnDef.cell,u.getContext())},u.id))},a.id)):t.jsxRuntimeExports.jsx(t.TableRow,{children:t.jsxRuntimeExports.jsx(t.TableCell,{colSpan:s.length,className:"h-24 text-center",children:"No results."})})})]})}function Yr({className:e,...n}){A.useState(0);const r=t.useDashboardStore(l=>l.themeStyle),i=t.useEditorStore(l=>l.card),s=t.useEditorStore(l=>l.actions.setCard);if(A.useEffect(()=>{},[i.data,i.type,i.cfg,i.customCfg,r,i.preferences]),!i.id)return null;let o;return i.data&&i.data.length>0&&(o=t.createChartConfig({data:i.data,cardType:i.type,cfg:i.cfg,customCfg:i.customCfg,preferences:i.preferences})),t.jsxRuntimeExports.jsxs(t.Card,{role:"editor-visual-card",className:t.cn("relative flex h-full flex-col rounded-none",e),...n,children:[t.jsxRuntimeExports.jsxs(t.CardHeader,{className:"py-4",children:[t.jsxRuntimeExports.jsx(t.Editable,{text:i.title,onSave:l=>s({...i,title:l}),children:t.jsxRuntimeExports.jsx("div",{className:"flex items-center gap-2",children:t.jsxRuntimeExports.jsx(t.CardTitle,{className:"text-base",children:i.title})})},i.title),t.jsxRuntimeExports.jsx(t.Editable,{text:i.description||"",onSave:l=>s({...i,description:l}),children:t.jsxRuntimeExports.jsxs(t.CardDescription,{children:[" ",i.description]})},i.description)]}),t.jsxRuntimeExports.jsxs(t.CardContent,{className:"flex grow flex-col pb-3",children:[i.type!=="table"&&o&&t.jsxRuntimeExports.jsx(t.ChartJsVisual,{cfg:o},JSON.stringify(o)),i.type==="table"&&i.data&&i.data.length>0&&t.jsxRuntimeExports.jsx(t.$57acba87d6e25586$export$ccf8d8d7bbf3c2cc,{className:"flex min-h-0 flex-1 grow basis-0",children:t.jsxRuntimeExports.jsx(t.TableVisual,{card:i,data:i==null?void 0:i.data})})]})]})}function Nu(){const[e,n]=A.useState(!1),[r,i]=A.useState(""),[s,o]=A.useState(""),[l,a]=A.useState(""),u=t.useEditorStore(k=>k.card),c=t.useEditorStore(k=>k.card.customCfg),x=t.useEditorStore(k=>k.actions.setCardCustomCfg);function p(k){var S,D;const y={...k,data:{...k==null?void 0:k.data,datasets:(D=(S=k==null?void 0:k.data)==null?void 0:S.datasets)==null?void 0:D.map(O=>({...O,data:[]}))}};return JSON.stringify(y,null,1)}function m(){if(!u.data||u.data.length===0)return;const k=t.createChartConfig({data:u.data,cardType:u.type,cfg:u.cfg,preferences:u.preferences});k&&(i(JSON.stringify(k,null,1)),c&&o(JSON.stringify(c,null,1)))}function d(){if(s)try{const k=JSON.parse(s);return k?(x(k),a(""),o(""),k):void 0}catch(k){console.log(k),a("Invalid JSON")}}function j(){o(""),x(null)}function E(){let k;if(c){const y=t._.cloneDeep(u.cfg),w=t._.merge(y,c);return k=p(w),k}return r?(k=p(JSON.parse(r)),k):""}return t.jsxRuntimeExports.jsxs(t.Dialog,{open:e,onOpenChange:n,children:[t.jsxRuntimeExports.jsx(t.DialogTrigger,{asChild:!0,children:t.jsxRuntimeExports.jsx(t.Button,{onClick:m,className:` ${c&&"border-foreground/50 dark:border-foreground/70"}`,size:"sm",variant:"outline",children:t.jsxRuntimeExports.jsx(t.Settings,{className:"h-4 w-4"})})}),t.jsxRuntimeExports.jsxs(t.DialogContent,{className:"max-h-[70vh] min-h-[70vh] min-w-[900px] overflow-auto",children:[t.jsxRuntimeExports.jsxs(t.DialogHeader,{className:"",children:[t.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxRuntimeExports.jsx(t.DialogTitle,{children:"Customize Card"}),t.jsxRuntimeExports.jsxs(t.Tooltip,{children:[t.jsxRuntimeExports.jsx(t.TooltipTrigger,{children:t.jsxRuntimeExports.jsx(gi,{onClick:()=>{navigator.clipboard.writeText(u.id)},className:"size-3 cursor-pointer text-muted-foreground/70 transition-colors hover:text-muted-foreground"})}),t.jsxRuntimeExports.jsx(t.TooltipContent,{side:"right",align:"center",children:t.jsxRuntimeExports.jsx("p",{className:"text-xs",children:"Copy Card ID"})})]})]}),t.jsxRuntimeExports.jsxs(t.DialogDescription,{children:["See the configuration options and documentation",t.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."})]})]}),t.jsxRuntimeExports.jsxs("div",{className:"flex grow gap-2",children:[t.jsxRuntimeExports.jsx(Yr,{className:"w-1/2 rounded shadow-none"}),t.jsxRuntimeExports.jsxs(t.Tabs,{defaultValue:"custom-config",className:"flex w-1/2 flex-col",children:[t.jsxRuntimeExports.jsxs(t.TabsList,{className:"justify-start rounded-sm rounded-b-none border border-b-0",children:[t.jsxRuntimeExports.jsxs(t.TabsTrigger,{value:"custom-config",children:[c&&t.jsxRuntimeExports.jsx(t.CheckIcon,{className:"mr-1 h-5 w-5 text-green-600"}),c?"Custom Config":"Default Config"]}),t.jsxRuntimeExports.jsx(t.TabsTrigger,{className:"",value:"output",children:"Output"})]}),t.jsxRuntimeExports.jsx(t.TabsContent,{className:"bg-red-x mt-0 grow rounded-b border border-t-0 p-2",value:"output",children:t.jsxRuntimeExports.jsx(t.Textarea,{disabled:!0,value:r,className:"h-full resize-none border-none font-mono focus-visible:ring-0 focus-visible:ring-offset-0"})}),t.jsxRuntimeExports.jsx(t.TabsContent,{className:"mt-0 grow rounded-b border border-t-0",value:"custom-config",children:t.jsxRuntimeExports.jsx(t.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:E(),onChange:k=>o(k)})})]})]}),t.jsxRuntimeExports.jsxs(t.DialogFooter,{className:"flex items-center",children:[t.jsxRuntimeExports.jsx(t.Label,{className:"mr-2 text-red-500",children:l}),t.jsxRuntimeExports.jsx(t.Button,{disabled:!c,onClick:j,variant:"outline",children:"Reset"}),t.jsxRuntimeExports.jsx(t.Button,{onClick:d,variant:"outline",children:"Apply"}),t.jsxRuntimeExports.jsx(t.Button,{onClick:()=>n(!1),variant:"outline",children:"Close"})]})]})]})}function Zr(e){return ze({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:[]}]})(e)}function ei(e){return ze({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:[]}]})(e)}function ti(e){return ze({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:[]}]})(e)}function ni(e){return ze({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:[]}]})(e)}function ri(e){return ze({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:[]}]})(e)}function ii(e){return ze({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:[]}]})(e)}function Iu(){const[e,n]=A.useState(!1),r=t.useEditorStore(l=>l.card.type),i=t.useEditorStore(l=>l.actions.setCardType),s=t.useEditorStore(l=>l.actions.setCardCustomCfg);function o(l){i(l),s(null),n(!1)}return t.jsxRuntimeExports.jsxs(t.Popover,{open:e,onOpenChange:n,children:[t.jsxRuntimeExports.jsx(t.PopoverTrigger,{asChild:!0,children:t.jsxRuntimeExports.jsx(t.Button,{size:"sm",variant:"outline",children:t.jsxRuntimeExports.jsx(Au,{className:"h-4 w-4",chartType:r})})}),t.jsxRuntimeExports.jsx(t.PopoverContent,{className:"w-50",children:t.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 place-items-center ",children:[t.jsxRuntimeExports.jsx(t.Button,{onClick:()=>o("bar"),className:"font-normal",variant:"ghost",children:t.jsxRuntimeExports.jsx(Ut,{className:"size-5"})}),t.jsxRuntimeExports.jsx(t.Button,{onClick:()=>o("line"),variant:"ghost",children:t.jsxRuntimeExports.jsx($t,{className:"size-5"})}),t.jsxRuntimeExports.jsx(t.Button,{onClick:()=>o("stackedBar"),variant:"ghost",children:t.jsxRuntimeExports.jsx(ri,{className:"size-5 ",strokeWidth:0})}),t.jsxRuntimeExports.jsx(t.Button,{onClick:()=>o("scatter"),variant:"ghost",children:t.jsxRuntimeExports.jsx(ar,{className:"size-5"})}),t.jsxRuntimeExports.jsx(t.Button,{onClick:()=>o("bubble"),variant:"ghost",children:t.jsxRuntimeExports.jsx(ni,{className:"size-4"})}),t.jsxRuntimeExports.jsx(t.Button,{onClick:()=>o("pie"),variant:"ghost",children:t.jsxRuntimeExports.jsx(or,{className:"size-5"})}),t.jsxRuntimeExports.jsx(t.Button,{onClick:()=>o("doughnut"),variant:"ghost",children:t.jsxRuntimeExports.jsx(ei,{className:"size-5 ",strokeWidth:1})}),t.jsxRuntimeExports.jsx(t.Button,{onClick:()=>o("radar"),variant:"ghost",children:t.jsxRuntimeExports.jsx(Zr,{className:"size-5 font-extralight",strokeWidth:.5})}),t.jsxRuntimeExports.jsx(t.Button,{onClick:()=>o("polarArea"),variant:"ghost",children:t.jsxRuntimeExports.jsx(ti,{className:"size-5 "})}),t.jsxRuntimeExports.jsx(t.Button,{onClick:()=>o("table"),variant:"ghost",children:t.jsxRuntimeExports.jsx(Kt,{className:"size-5 "})}),t.jsxRuntimeExports.jsx(t.Button,{onClick:()=>o("kpi"),variant:"ghost",children:t.jsxRuntimeExports.jsx(ii,{className:"size-6 "})})]})})]})}function Au({chartType:e,className:n}){switch(e){case"bar":return t.jsxRuntimeExports.jsx(Ut,{className:n});case"line":return t.jsxRuntimeExports.jsx($t,{className:n});case"pie":return t.jsxRuntimeExports.jsx(or,{className:n});case"radar":return t.jsxRuntimeExports.jsx(Zr,{className:n});case"scatter":return t.jsxRuntimeExports.jsx(ar,{className:n});case"bubble":return t.jsxRuntimeExports.jsx(ni,{className:n});case"doughnut":return t.jsxRuntimeExports.jsx(ei,{className:n});case"stackedBar":return t.jsxRuntimeExports.jsx(ri,{className:"size-4 text-foreground/70 "});case"polarArea":return t.jsxRuntimeExports.jsx(ti,{className:n});case"kpi":return t.jsxRuntimeExports.jsx(ii,{className:n});default:return t.jsxRuntimeExports.jsx(Kt,{className:n})}}function Tu(){const e=t.useEditorStore(r=>r.card.refreshInterval),n=t.useEditorStore(r=>r.actions.setCardRefreshInterval);return t.jsxRuntimeExports.jsxs(t.Popover,{children:[t.jsxRuntimeExports.jsx(t.PopoverTrigger,{asChild:!0,children:t.jsxRuntimeExports.jsx(t.Button,{size:"sm",variant:"outline",children:t.jsxRuntimeExports.jsx(ai,{className:"w-4 h-4"})})}),t.jsxRuntimeExports.jsx(t.PopoverContent,{className:"w-[200px]",children:t.jsxRuntimeExports.jsx("div",{className:"grid gap-4",children:t.jsxRuntimeExports.jsx("div",{className:"grid gap-2",children:t.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-5 items-center gap-1",children:[t.jsxRuntimeExports.jsx(t.Label,{className:"col-span-3",htmlFor:"width",children:"Refresh Every"}),t.jsxRuntimeExports.jsx(t.Input,{value:e||"",onChange:r=>n(r.target.value),id:"width",placeholder:"30s",className:"col-span-2 h-7 focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-0"})]})})})})]})}function nr(){t.useEditorStore(l=>l.frame);const e=t.useEditorStore(l=>l.card),n=t.useEditorStore(l=>l.card.data),r=t.useEditorStore(l=>l.isShowingVisual),i=t.useEditorStore(l=>l.isSqlRunning),s=t.useEditorStore(l=>l.queryError),o=t.useEditorStore(l=>l.pythonStdOut);return t.useEditorStore(l=>l.onSave),t.useEditorStore(l=>l.onClose),t.useEditorStore(l=>l.actions.setCardSql),t.useEditorStore(l=>l.actions.setCardType),t.useEditorStore(l=>l.actions.setSqlGen),e?t.jsxRuntimeExports.jsxs("div",{className:"relative flex h-full flex-col py-3",children:[i&&t.jsxRuntimeExports.jsx(t.LoaderCircle,{className:"absolute bottom-0 left-0 right-0 top-0 z-10 m-auto h-10 w-10 animate-spin text-foreground/10"}),t.jsxRuntimeExports.jsxs("div",{className:"mb-0 flex min-h-10 items-center justify-end gap-2 px-6",children:[r&&t.jsxRuntimeExports.jsxs("div",{className:"flex grow items-center gap-2",children:[t.jsxRuntimeExports.jsx(Iu,{}),t.jsxRuntimeExports.jsx(Nu,{}),t.jsxRuntimeExports.jsx(Tu,{})]}),t.jsxRuntimeExports.jsx(Lu,{})]}),r?e.type==="kpi"?t.jsxRuntimeExports.jsx("div",{className:"flex grow items-center justify-center",children:t.jsxRuntimeExports.jsx("div",{className:"w-1/2 rounded-md border",children:t.jsxRuntimeExports.jsx(t.KPICard,{isLoading:i,card:e})})}):t.jsxRuntimeExports.jsx(Yr,{className:"grow border-none shadow-none"}):t.jsxRuntimeExports.jsxs("div",{className:"flex min-h-0 w-full flex-1 grow basis-0 px-6",children:[o&&t.jsxRuntimeExports.jsx(zu,{}),e.data&&e.data.length>0&&t.jsxRuntimeExports.jsx(vu,{data:n||[]}),s&&t.jsxRuntimeExports.jsx("span",{className:"font-mono text-sm",children:s})]})]}):t.jsxRuntimeExports.jsx(t.jsxRuntimeExports.Fragment,{children:"No Active Card"})}function zu(){const e=t.useEditorStore(r=>r.pythonStdOut);if(!e)return null;const n=e.replace(/\n/g,"<br>");return t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsx("p",{className:"font-mono text-sm",children:"Output:"}),t.jsxRuntimeExports.jsx("div",{dangerouslySetInnerHTML:{__html:n},className:"bg-muted p-2 font-mono text-sm"}),t.jsxRuntimeExports.jsx(t.Separator,{className:"mb-2"})]})}function Lu(){const e=t.useEditorStore(r=>r.isShowingVisual),n=t.useEditorStore(r=>r.actions.setIsShowingVisual);return t.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsxRuntimeExports.jsx(t.Label,{htmlFor:"visualize",children:"Chart"}),t.jsxRuntimeExports.jsx(t.Switch,{checked:e,onCheckedChange:()=>n(!e),id:"visualize",className:"data-[state=checked]:bg-foreground/50"})]})}function Ve(){const[e,n]=A.useState([]);t.useEditorStore(x=>x.card.cfg);const r=t.useEditorStore(x=>x.card.preferences),{setCardCfg:i,setFilterOnClickColumnIndex:s,setCardPreferences:o}=t.useEditorStore(x=>x.actions),l=t.useEditorStore(x=>x.queryResultColumns);t.useEditorStore(x=>{var p;return(p=x.card.preferences)==null?void 0:p.filterOnClickColumnIndex}),A.useEffect(()=>{l&&n(new Array(l.length).fill(!1))},[l]);function a(x,p){var m,d;p?r!=null&&r.onClickFilter&&((m=r==null?void 0:r.onClickFilter)==null?void 0:m.length)>0?o({...r,onClickFilter:[...r.onClickFilter,{columnIndex:x,expression:""}]}):o({...r,onClickFilter:[{columnIndex:x,expression:""}]}):(o({...r,onClickFilter:(d=r==null?void 0:r.onClickFilter)==null?void 0:d.filter(j=>j.columnIndex!==x)}),n(j=>{const E=[...j];return E[x]=!1,E}))}function u(x,p){var d;const m=(d=r==null?void 0:r.onClickFilter)==null?void 0:d.map(j=>j.columnIndex===x?{...j,expression:p.target.value}:j);o({...r,onClickFilter:m})}function c(x){var p,m,d,j;if(e!=null&&e[x]||(m=(p=r==null?void 0:r.onClickFilter)==null?void 0:p.find(E=>E.columnIndex===x))!=null&&m.expression)return t.jsxRuntimeExports.jsx(t.Input,{value:(j=(d=r==null?void 0:r.onClickFilter)==null?void 0:d.find(E=>E.columnIndex===x))==null?void 0:j.expression,onChange:E=>u(x,E),type:"text",className:" h-9 w-full focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0 font-mono text-xs",placeholder:"Expression"})}return t.jsxRuntimeExports.jsx(t.jsxRuntimeExports.Fragment,{children:l==null?void 0:l.map((x,p)=>{var m,d;return t.jsxRuntimeExports.jsx("div",{className:"flex items-center justify-between space-y-2 xbg-red-100 group",children:t.jsxRuntimeExports.jsxs("div",{className:" grow",children:[t.jsxRuntimeExports.jsxs("div",{className:"flex items-center py-2 space-x-2",children:[t.jsxRuntimeExports.jsx(t.Checkbox,{checked:!!((m=r==null?void 0:r.onClickFilter)!=null&&m.find(j=>j.columnIndex===p)),onCheckedChange:j=>a(p,j)}),t.jsxRuntimeExports.jsx("label",{className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:x}),t.jsxRuntimeExports.jsx("div",{className:"flex gap-2 items-center ",children:((d=r==null?void 0:r.onClickFilter)==null?void 0:d.find(j=>j.columnIndex===p))&&t.jsxRuntimeExports.jsx(sr,{onClick:()=>{n(j=>{const E=[...j];return E[p]=!j[p],E})},className:" invisible group-hover:visible size-3 text-gray-400 cursor-pointer"})})]}),c(p)]})},x)})})}function an(){var o,l;const e=t.useEditorStore(a=>a.card.preferences),n=t.useEditorStore(a=>a.card.cfg),{setCardCfg:r,setCardPreferences:i}=t.useEditorStore(a=>a.actions);(o=n==null?void 0:n.options)!=null&&o.indexAxis;function s(a){var x,p,m,d,j,E;let u={};(x=e==null?void 0:e.chartOptions)!=null&&x.scales&&(u={x:(m=(p=e==null?void 0:e.chartOptions)==null?void 0:p.scales)==null?void 0:m.y,y:(j=(d=e==null?void 0:e.chartOptions)==null?void 0:d.scales)==null?void 0:j.x});const c={...e,chartOptions:{...e==null?void 0:e.chartOptions,scales:{...(E=e==null?void 0:e.chartOptions)==null?void 0:E.scales,...u},indexAxis:a}};i(c)}return t.jsxRuntimeExports.jsxs(t.RadioGroup,{value:((l=e==null?void 0:e.chartOptions)==null?void 0:l.indexAxis)||"x",onValueChange:s,className:"flex gap-3",defaultValue:"x",children:[t.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsxRuntimeExports.jsx(t.RadioGroupItem,{value:"x",id:"r1"}),t.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r1",children:"Vertical"})]}),t.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsxRuntimeExports.jsx(t.RadioGroupItem,{value:"y",id:"r2"}),t.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r2",children:"Horizontal"})]})]})}const zt="focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0";function si(e){var r,i;return(r=e==null?void 0:e.chartOptions)!=null&&r.indexAxis?((i=e==null?void 0:e.chartOptions)==null?void 0:i.indexAxis)==="x"?"y":"x":"y"}function rr(e){var r,i,s;const n=si(e);return((s=(i=(r=e==null?void 0:e.chartOptions)==null?void 0:r.scales)==null?void 0:i[n])==null?void 0:s.type)||"linear"}function Ou(){var w,S,D,O,b,M;const[e,n]=A.useState(!1),r=t.useEditorStore(T=>{var z;return(z=T.card)==null?void 0:z.preferences}),i=si(r),[s,o]=A.useState(rr(r)),[l,a]=A.useState(((D=(S=(w=r==null?void 0:r.chartOptions)==null?void 0:w.scales)==null?void 0:S[i])==null?void 0:D.min)||""),[u,c]=A.useState(((M=(b=(O=r==null?void 0:r.chartOptions)==null?void 0:O.scales)==null?void 0:b[i])==null?void 0:M.max)||""),[x,p]=A.useState(l||u?"custom":"auto"),[m,d]=A.useState(""),j=t.useEditorStore(T=>T.actions.setCardPreferences);A.useEffect(()=>{var T,z,H,I,v,U,$,P,q,Q;o(rr(r)),a(((H=(z=(T=r==null?void 0:r.chartOptions)==null?void 0:T.scales)==null?void 0:z[i])==null?void 0:H.min)===0?0:""),c(((U=(v=(I=r==null?void 0:r.chartOptions)==null?void 0:I.scales)==null?void 0:v[i])==null?void 0:U.max)||""),d(((Q=(q=(P=($=r==null?void 0:r.chartOptions)==null?void 0:$.scales)==null?void 0:P[i])==null?void 0:q.ticks)==null?void 0:Q.stepSize)||"")},[e,r,i]);function E(T,z){return z===""||/^[0-9\b]+$/.test(z)?Number(z):Number(T)}function k(){return t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[t.jsxRuntimeExports.jsx(t.Label,{htmlFor:"range",children:"Range"}),t.jsxRuntimeExports.jsx(t.Input,{id:"min",value:l,onChange:T=>a(z=>E(z,T.target.value)),className:`col-span-1 h-8 w-full ${zt}`}),t.jsxRuntimeExports.jsx(t.Input,{value:u,onChange:T=>c(z=>E(z,T.target.value)),id:"max",className:`col-span-1 h-8 w-full ${zt}`})]}),t.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[t.jsxRuntimeExports.jsx(t.Label,{htmlFor:"step-size",children:"Step Size"}),t.jsxRuntimeExports.jsx(t.Input,{value:m,onChange:T=>d(z=>E(z,T.target.value)),id:"step-size",className:`col-span-1 h-8 w-full ${zt}`})]})]})}function y(){var H;let T={};x==="custom"&&(T={min:l,max:u,ticks:{stepSize:m}});const z={...r||{},chartOptions:{...r==null?void 0:r.chartOptions,scales:{...(H=r==null?void 0:r.chartOptions)==null?void 0:H.scales,[i]:{type:s,...s==="linear"?T:{}}}}};j(z)}return t.jsxRuntimeExports.jsxs(t.Popover,{onOpenChange:T=>n(T),children:[t.jsxRuntimeExports.jsx(t.PopoverTrigger,{asChild:!0,children:t.jsxRuntimeExports.jsx(t.SliderIcon,{className:"size-4 cursor-pointer text-muted-foreground hover:text-foreground"})}),t.jsxRuntimeExports.jsx(t.PopoverContent,{align:"center",className:"max-w-65",children:t.jsxRuntimeExports.jsxs("div",{className:"grid gap-4",children:[t.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[t.jsxRuntimeExports.jsx("h4",{className:"font-medium leading-none",children:"Scale Options"}),t.jsxRuntimeExports.jsx("p",{className:"text-sm text-muted-foreground",children:"Set the scale for the number axis"})]}),t.jsxRuntimeExports.jsxs("div",{className:"grid gap-2",children:[t.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[t.jsxRuntimeExports.jsx(t.Label,{htmlFor:"scale",children:"Type"}),t.jsxRuntimeExports.jsxs(t.Select,{value:s,onValueChange:T=>o(T),children:[t.jsxRuntimeExports.jsx(t.SelectTrigger,{className:"col-span-2 h-8 w-full focus:ring-1 focus:ring-offset-0",children:t.jsxRuntimeExports.jsx(t.SelectValue,{})}),t.jsxRuntimeExports.jsx(t.SelectContent,{id:"type",children:t.jsxRuntimeExports.jsxs(t.SelectGroup,{children:[t.jsxRuntimeExports.jsx(t.SelectLabel,{children:"Option"}),t.jsxRuntimeExports.jsx(t.SelectItem,{value:"linear",children:"Linear"}),t.jsxRuntimeExports.jsx(t.SelectItem,{value:"logarithmic",children:"Logarithmic"})]})})]})]}),s=="linear"&&t.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 items-center gap-2 py-1",children:[t.jsxRuntimeExports.jsx(t.Label,{htmlFor:"scale-option",children:"Setup"}),t.jsxRuntimeExports.jsxs(t.RadioGroup,{id:"scale-option",value:x,onValueChange:T=>p(T),className:"col-span-2 flex gap-3",defaultValue:"x",children:[t.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsxRuntimeExports.jsx(t.RadioGroupItem,{value:"auto",id:"r1"}),t.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r1",children:"Auto"})]}),t.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsxRuntimeExports.jsx(t.RadioGroupItem,{value:"custom",id:"r2"}),t.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r2",children:"Custom"})]})]})]}),x==="custom"&&s=="linear"&&k(),t.jsxRuntimeExports.jsx(t.SelectSeparator,{}),t.jsxRuntimeExports.jsx("div",{className:"grid grid-cols-3",children:t.jsxRuntimeExports.jsx(t.Button,{onClick:y,variant:"secondary",className:"col-span-1 col-start-3 h-8 w-full",children:"Apply"})})]})]})})]})}function Du({idx:e}){var a;const n=t.useEditorStore(u=>{var c;return(c=u.card)==null?void 0:c.preferences}),r=t.useEditorStore(u=>{var c;return(c=u.card.preferences)==null?void 0:c.datasetOptions}),i=t.useEditorStore(u=>u.actions.setCardPreferences),s=(a=n==null?void 0:n.chartOptions)==null?void 0:a.indexAxis,o=r==null?void 0:r.find(u=>u.idx===e);function l(u,c){(u==="end"||u==="start")&&t.getContrastColor(t.getCanvasBackgroundColor());const x={display:u!=="none",align:u,anchor:u,clamp:!0};if(!o)i({...n,datasetOptions:[...r||[],{idx:c,datalabels:x}]});else{const p={...o};p.datalabels=x;const m=r==null?void 0:r.map(d=>d.idx===c?p:d);i({...n,datasetOptions:m})}}return t.jsxRuntimeExports.jsxs(t.Popover,{children:[t.jsxRuntimeExports.jsx(t.PopoverTrigger,{children:t.jsxRuntimeExports.jsx(Ni,{className:"invisible size-4 rotate-[135deg] cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"})}),t.jsxRuntimeExports.jsxs(t.PopoverContent,{className:"flex w-fit gap-1 p-1",children:[t.jsxRuntimeExports.jsx(t.Button,{onClick:()=>l("none",e),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:t.jsxRuntimeExports.jsx(t.X,{className:"size-4"})}),t.jsxRuntimeExports.jsx(t.Button,{onClick:()=>l("start",e),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:t.jsxRuntimeExports.jsx(ji,{className:t.cn("h-4 w-4",{"rotate-90":s==="y"})})}),t.jsxRuntimeExports.jsx(t.Button,{onClick:()=>l("center",e),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:t.jsxRuntimeExports.jsx(Ei,{className:t.cn("h-4 w-4",{"rotate-90":s==="y"})})}),t.jsxRuntimeExports.jsx(t.Button,{onClick:()=>l("end",e),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:t.jsxRuntimeExports.jsx(yi,{className:t.cn("h-4 w-4",{"rotate-90":s==="y"})})})]})]})}function oi(){const e=t.useEditorStore(u=>u.card),n=t.useEditorStore(u=>{var c,x,p;return(p=(x=(c=u==null?void 0:u.card)==null?void 0:c.preferences)==null?void 0:x.chartOptions)==null?void 0:p.indexAxis}),r=n==="y"?"Y axis":"X axis",i=n==="y"?"X axis":"Y axis",{keys:s,metricKeys:o,dimensionKeys:l}=t.getKeys(e.data||[]);let a=o;if(e.type==="stackedBar"){const u=t.pivotData({dataArray:e.data||[],groupKey:l[0],pivotKey:l[1],valueKey:a[0]}),{metricKeys:c}=t.getKeys(u);a=c}return s.length===0?null:t.jsxRuntimeExports.jsxs("div",{className:"space-y-4",children:[t.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[t.jsxRuntimeExports.jsx(t.Label,{children:r}),t.jsxRuntimeExports.jsx("div",{className:"my-1 space-y-1",children:t.jsxRuntimeExports.jsx("div",{className:"rounded-md bg-muted/70 px-2 py-1 hover:bg-muted",children:t.jsxRuntimeExports.jsx("p",{children:l[0]})})})]}),t.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[t.jsxRuntimeExports.jsxs("div",{className:"flex items-center justify-between gap-5",children:[t.jsxRuntimeExports.jsx(t.Label,{children:i}),t.jsxRuntimeExports.jsx(Ou,{})]}),t.jsxRuntimeExports.jsx("div",{className:"my-1 space-y-1",children:a.map((u,c)=>t.jsxRuntimeExports.jsx(Fu,{col:u,idx:c},u))})]})]})}function Fu({col:e,idx:n}){const r=t.useEditorStore(a=>{var u;return(u=a.card)==null?void 0:u.preferences}),i=t.useEditorStore(a=>{var u;return(u=a.card.preferences)==null?void 0:u.datasetOptions}),s=i==null?void 0:i.find(a=>a.idx===n),{setCardPreferences:o}=t.useEditorStore(a=>a.actions);function l(a){if(!s)o({...r,datasetOptions:[...i||[],{idx:n,type:a==="area"?"line":a,fill:a==="area"?"origin":""}]});else{const u={...s};u.type=a==="area"?"line":a,u.fill=a==="area"?"origin":"";const c=i==null?void 0:i.map(x=>x.idx===n?u:x);o({...r,datasetOptions:c})}}return t.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:[t.jsxRuntimeExports.jsx("p",{children:e}),t.jsxRuntimeExports.jsxs("div",{className:"flex gap-2",children:[t.jsxRuntimeExports.jsx(Ut,{onClick:()=>l("bar"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),t.jsxRuntimeExports.jsx($t,{onClick:()=>l("line"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),t.jsxRuntimeExports.jsx(ui,{onClick:()=>l("area"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),t.jsxRuntimeExports.jsx(t.Separator,{orientation:"vertical",className:"invisible size-4 cursor-pointer py-2 text-muted-foreground hover:text-foreground group-hover:visible"}),t.jsxRuntimeExports.jsx(Du,{idx:n})]})]})}function Mu({cardType:e}){return t.jsxRuntimeExports.jsx("div",{className:"space-y-6 px-6 py-2",children:t.jsxRuntimeExports.jsxs(t.Accordion,{defaultValue:["item-2"],type:"multiple",children:[t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-1",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{children:`${t.titleCase(e)} Chart`}),t.jsxRuntimeExports.jsxs(t.AccordionContent,{className:"space-y-4 font-mono text-xs",children:[t.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"}),t.jsxRuntimeExports.jsxs("ul",{className:"ml-6 list-disc text-xs [&>li]:mt-2",children:[t.jsxRuntimeExports.jsx("li",{children:"x-axis - category"}),t.jsxRuntimeExports.jsx("li",{children:"y-axis1 - number"}),t.jsxRuntimeExports.jsx("li",{children:"y-axis2 - number"})]}),t.jsxRuntimeExports.jsxs("div",{children:["See ",t.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:n=>n.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#line-chart",children:"example"})," in the docs."]})]})]}),t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-2",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{children:"Settings"}),t.jsxRuntimeExports.jsxs(t.AccordionContent,{className:"space-y-4 px-2",children:[t.jsxRuntimeExports.jsx(an,{}),t.jsxRuntimeExports.jsx(oi,{})]})]}),t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-3",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{children:"Filter on click"}),t.jsxRuntimeExports.jsx(t.AccordionContent,{className:"px-2",children:t.jsxRuntimeExports.jsx(Ve,{})})]})]})})}function un(){var i,s,o;const e=t.useEditorStore(l=>l.card.cfg),n=t.useEditorStore(l=>l.actions.setCardCfg);function r(l){var c;const a={datalabels:{display:l!=="none",align:l,anchor:l,clamp:!0}},u={...e,options:{...e==null?void 0:e.options,plugins:{...(c=e==null?void 0:e.options)==null?void 0:c.plugins,...a}}};n(u),console.log(l)}return t.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[t.jsxRuntimeExports.jsx("label",{className:"font-medium",children:"Data Labels"}),t.jsxRuntimeExports.jsxs(t.Select,{value:(o=(s=(i=e==null?void 0:e.options)==null?void 0:i.plugins)==null?void 0:s.datalabels)==null?void 0:o.anchor,onValueChange:r,defaultValue:"none",children:[t.jsxRuntimeExports.jsx(t.SelectTrigger,{className:"h-8 w-[180px] focus:ring-1 focus:ring-offset-0",children:t.jsxRuntimeExports.jsx(t.SelectValue,{placeholder:"Select position"})}),t.jsxRuntimeExports.jsx(t.SelectContent,{children:t.jsxRuntimeExports.jsxs(t.SelectGroup,{children:[t.jsxRuntimeExports.jsx(t.SelectLabel,{children:"Data Labels"}),t.jsxRuntimeExports.jsx(t.SelectItem,{value:"none",children:"None"}),t.jsxRuntimeExports.jsx(t.SelectItem,{value:"start",children:"Start"}),t.jsxRuntimeExports.jsx(t.SelectItem,{value:"center",children:"Center"}),t.jsxRuntimeExports.jsx(t.SelectItem,{value:"end",children:"End"})]})})]})]})}function Pu({cardType:e}){function n(r){const i="SELECT label, [group], x-axis, y-axis, radius FROM table",s="SELECT label, [group], x-axis, y-axis FROM table";return t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsx("div",{className:"bg-muted px-2 py-1 rounded text-xs",children:r==="bubble"?i:s}),t.jsxRuntimeExports.jsxs("ul",{className:" ml-6 list-disc [&>li]:mt-2 text-xs",children:[t.jsxRuntimeExports.jsx("li",{children:"label - category"}),t.jsxRuntimeExports.jsx("li",{children:"group - category"}),t.jsxRuntimeExports.jsx("li",{children:"x-axis - category"}),t.jsxRuntimeExports.jsx("li",{children:"y-axis - category"}),r==="bubble"&&t.jsxRuntimeExports.jsx("li",{children:"radius - number"})]}),t.jsxRuntimeExports.jsxs("div",{children:["See ",t.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:o=>o.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#pie-chart",children:"example"})," in the docs."]})]})}return t.jsxRuntimeExports.jsx("div",{className:"px-6 py-2 space-y-6",children:t.jsxRuntimeExports.jsxs(t.Accordion,{defaultValue:["item-2"],type:"multiple",children:[t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-1",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{children:`${t.titleCase(e)} Chart`}),t.jsxRuntimeExports.jsx(t.AccordionContent,{className:" space-y-4 font-mono text-xs ",children:n(e)})]}),t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-2",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{children:"Settings"}),t.jsxRuntimeExports.jsx(t.AccordionContent,{className:"px-2",children:t.jsxRuntimeExports.jsx(un,{})})]}),t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-3",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{children:"Filter on click"}),t.jsxRuntimeExports.jsx(t.AccordionContent,{className:"px-2",children:t.jsxRuntimeExports.jsx(Ve,{})})]})]})})}const Bu={datasets:[{type:"line",label:"Sum_sales",data:[]},{type:"bar",label:"Sum_profit",data:[]}]},_u={datasets:[{fill:"origin",type:"line",label:"Sum_sales",data:[]}]};function Vu(){const e=t.useEditorStore(n=>n.card.type);return t.jsxRuntimeExports.jsxs("div",{className:"p-6 space-y-6",children:[t.jsxRuntimeExports.jsx(t.Accordion,{className:" ",type:"single",collapsible:!0,children:Hu(e)}),t.jsxRuntimeExports.jsx("section",{className:"",children:["line","bar"].includes(e)&&t.jsxRuntimeExports.jsx(an,{})}),t.jsxRuntimeExports.jsx("div",{children:!["kpi"].includes(e)&&t.jsxRuntimeExports.jsx(un,{})}),t.jsxRuntimeExports.jsx("div",{children:!["kpi"].includes(e)&&t.jsxRuntimeExports.jsx(Ve,{})})]})}function Hu(e){if(["line","bar"].includes(e))return t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-1",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{className:" font-normal",children:t.jsxRuntimeExports.jsx("p",{children:"Chart Query"})}),t.jsxRuntimeExports.jsxs(t.AccordionContent,{className:" ",children:[t.jsxRuntimeExports.jsx("div",{className:"bg-muted px-2 py-1 rounded font-mono font-semibold text-xs",children:"SELECT x-axis, y-axis-1, y-axis-2, y-axis-3,... FROM table"}),t.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs",children:[t.jsxRuntimeExports.jsx("li",{children:"X-axis - Category (ex. city)"}),t.jsxRuntimeExports.jsx("li",{children:"Y-axis - Number (ex. population)"})]})]})]}),t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-2",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{className:" font-normal",children:"Mixed Chart"}),t.jsxRuntimeExports.jsxs(t.AccordionContent,{className:" text-xs space-y-2",children:[t.jsxRuntimeExports.jsxs("p",{children:["Click ",t.jsxRuntimeExports.jsx("b",{children:"Customize"})," and change the `type` property in the dataset."]}),t.jsxRuntimeExports.jsx("pre",{children:JSON.stringify(Bu,null,2)})]})]}),t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-3",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{className:" font-normal",children:"Area Chart"}),t.jsxRuntimeExports.jsxs(t.AccordionContent,{className:" text-xs space-y-2",children:[t.jsxRuntimeExports.jsxs("p",{children:["Click ",t.jsxRuntimeExports.jsx("b",{children:"Customize"})," and add `fill` property to the dataset. See",t.jsxRuntimeExports.jsx("a",{className:"text-blue-500 hover:underline mx-1",href:"https://www.chartjs.org/docs/latest/samples/area/line-boundaries.html",target:"_blank",children:"docs"}),"for more options."]}),t.jsxRuntimeExports.jsx("pre",{children:JSON.stringify(_u,null,2)})]})]})]});if(e==="bubble")return t.jsxRuntimeExports.jsx(t.jsxRuntimeExports.Fragment,{children:t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-1",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{className:" font-normal",children:t.jsxRuntimeExports.jsxs("p",{children:["How to create a ",t.jsxRuntimeExports.jsx("span",{children:e})," chart query?"]})}),t.jsxRuntimeExports.jsxs(t.AccordionContent,{className:" ",children:[t.jsxRuntimeExports.jsx("div",{className:"bg-muted px-2 py-1 rounded font-mono font-semibold text-xs",children:"SELECT label, x-axis, y-axis, radius FROM table"}),t.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs",children:[t.jsxRuntimeExports.jsx("li",{children:"Label - Category (ex. city)"}),t.jsxRuntimeExports.jsx("li",{children:"Bubble Group (opt) - Category (ex. state)"}),t.jsxRuntimeExports.jsx("li",{children:"X-axis - Number (ex. avg. age)"}),t.jsxRuntimeExports.jsx("li",{children:"Y-axis - Number (ex. avg. weight)"}),t.jsxRuntimeExports.jsx("li",{children:"Radius - Number (ex. population)"})]})]})]})});if(e==="scatter")return t.jsxRuntimeExports.jsx(t.jsxRuntimeExports.Fragment,{children:t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-1",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{className:" font-normal",children:t.jsxRuntimeExports.jsxs("p",{children:["How to create a ",t.jsxRuntimeExports.jsx("span",{children:e})," chart query?"]})}),t.jsxRuntimeExports.jsxs(t.AccordionContent,{className:" ",children:[t.jsxRuntimeExports.jsx("div",{className:"bg-muted px-2 py-1 rounded font-mono font-semibold text-xs",children:"SELECT label, x-axis, y-axis FROM table"}),t.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs",children:[t.jsxRuntimeExports.jsx("li",{children:"Label - Category (ex. city)"}),t.jsxRuntimeExports.jsx("li",{children:"Group (opt) - Category (ex. state)"}),t.jsxRuntimeExports.jsx("li",{children:"X-axis - Number (ex. avg. age)"}),t.jsxRuntimeExports.jsx("li",{children:"Y-axis - Number (ex. avg. weight)"})]})]})]})});if(["pie","doughnut","polarArea"].includes(e))return t.jsxRuntimeExports.jsx(t.jsxRuntimeExports.Fragment,{children:t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-1",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{className:" font-normal",children:t.jsxRuntimeExports.jsxs("p",{children:[t.jsxRuntimeExports.jsx("span",{children:e==="polarArea"?"Polar":e.charAt(0).toUpperCase()+e.slice(1)})," ","chart query"]})}),t.jsxRuntimeExports.jsxs(t.AccordionContent,{className:" ",children:[t.jsxRuntimeExports.jsx("div",{className:"bg-muted px-2 py-1 rounded font-mono font-semibold text-xs",children:"SELECT label, measure FROM table"}),t.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs",children:[t.jsxRuntimeExports.jsx("li",{children:"Label - Category (ex. city)"}),t.jsxRuntimeExports.jsx("li",{children:"Measure - Number (ex. population)"})]})]})]})})}function qu(){var l,a,u;const e=t.useEditorStore(c=>c.card.preferences),n=t.useEditorStore(c=>c.actions.setCardPreferences),r=t.useEditorStore(c=>c.actions.setNumberFormat),i=t.useEditorStore(c=>{var x,p;return(p=(x=c.card.preferences)==null?void 0:x.formatNumber)==null?void 0:p.format}),s=t.useEditorStore(c=>{var x,p;return(p=(x=c.card.preferences)==null?void 0:x.formatNumber)==null?void 0:p.locale}),o=t.useEditorStore(c=>{var x,p;return(p=(x=c.card.preferences)==null?void 0:x.formatNumber)==null?void 0:p.currency});return t.useEditorStore(c=>c.actions.setFilterOnClickField),t.jsxRuntimeExports.jsxs("div",{children:[t.jsxRuntimeExports.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[t.jsxRuntimeExports.jsx(t.Checkbox,{checked:!!((l=e==null?void 0:e.formatNumber)!=null&&l.enabled),onCheckedChange:c=>{n({...e,formatNumber:{...e==null?void 0:e.formatNumber,enabled:c}})}}),t.jsxRuntimeExports.jsx(t.Label,{children:"Format Number"})]}),((a=e==null?void 0:e.formatNumber)==null?void 0:a.enabled)===!0&&t.jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsxRuntimeExports.jsxs("div",{children:[t.jsxRuntimeExports.jsx(t.Label,{className:"text-xs",children:"Currency"}),t.jsxRuntimeExports.jsxs("div",{className:"flex gap-1",children:[t.jsxRuntimeExports.jsx(t.Input,{value:o||"",className:"h-7 w-20 font-mono text-xs focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",placeholder:"USD",onChange:c=>{var x,p,m;return r(((x=e==null?void 0:e.formatNumber)==null?void 0:x.format)||"",c.target.value,((p=e==null?void 0:e.formatNumber)==null?void 0:p.locale)||"",((m=e==null?void 0:e.formatNumber)==null?void 0:m.suffix)||"")}}),t.jsxRuntimeExports.jsx(t.Input,{value:s||"",className:"h-7 w-20 font-mono text-xs focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",placeholder:"en-US",onChange:c=>{var x,p,m;return r(((x=e==null?void 0:e.formatNumber)==null?void 0:x.format)||"",((p=e==null?void 0:e.formatNumber)==null?void 0:p.currency)||"",c.target.value,((m=e==null?void 0:e.formatNumber)==null?void 0:m.suffix)||"")}})]})]}),t.jsxRuntimeExports.jsxs("div",{children:[t.jsxRuntimeExports.jsxs("div",{className:"flex gap-1",children:[t.jsxRuntimeExports.jsx(t.Label,{className:"text-xs",children:"Format"}),t.jsxRuntimeExports.jsxs(t.Tooltip,{children:[t.jsxRuntimeExports.jsx(t.TooltipTrigger,{children:t.jsxRuntimeExports.jsx(t.InfoCircledIcon,{strokeWidth:1,className:"h-3 w-3 opacity-70"})}),t.jsxRuntimeExports.jsx(t.TooltipContent,{children:t.jsxRuntimeExports.jsxs("div",{className:"max-w-[200px]",children:["Format number",t.jsxRuntimeExports.jsx("div",{className:"mt-1 font-mono text-xs",children:"#.## for 123.43"})]})})]})]}),t.jsxRuntimeExports.jsx("div",{children:t.jsxRuntimeExports.jsx(t.Input,{value:i||"",className:"h-7 font-mono text-xs focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",placeholder:"###,###.##",onChange:c=>{var x,p,m;return r(c.target.value,((x=e==null?void 0:e.formatNumber)==null?void 0:x.currency)||"",((p=e==null?void 0:e.formatNumber)==null?void 0:p.locale)||"",((m=e==null?void 0:e.formatNumber)==null?void 0:m.suffix)||"")}})})]}),t.jsxRuntimeExports.jsxs("div",{children:[t.jsxRuntimeExports.jsx(t.Label,{className:"text-xs",children:"Suffix"}),t.jsxRuntimeExports.jsx(t.Input,{value:((u=e==null?void 0:e.formatNumber)==null?void 0:u.suffix)||"",className:"h-7 font-mono text-xs focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",placeholder:"K, M, B",onChange:c=>{var x,p,m;return r(((x=e==null?void 0:e.formatNumber)==null?void 0:x.format)||"",((p=e==null?void 0:e.formatNumber)==null?void 0:p.currency)||"",((m=e==null?void 0:e.formatNumber)==null?void 0:m.locale)||"",c.target.value)}})]})]})]})}function Uu(){return t.jsxRuntimeExports.jsxs("div",{className:"space-y-6 px-6 py-2",children:[t.jsxRuntimeExports.jsx(t.Accordion,{type:"single",collapsible:!0,children:t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-1",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{className:"",children:"KPI Query"}),t.jsxRuntimeExports.jsxs(t.AccordionContent,{className:"font-mono",children:[t.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs",children:"SELECT current, previous FROM table"}),t.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs [&>li]:mt-2",children:[t.jsxRuntimeExports.jsx("li",{children:"current - number"}),t.jsxRuntimeExports.jsx("li",{children:"previous - number"})]}),t.jsxRuntimeExports.jsxs("div",{children:["See ",t.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:e=>e.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#kpi",children:"example"})," in the docs."]})]})]})}),t.jsxRuntimeExports.jsx("section",{className:"",children:t.jsxRuntimeExports.jsx(qu,{})}),t.jsxRuntimeExports.jsx("div",{}),t.jsxRuntimeExports.jsx("div",{})]})}function $u({cardType:e}){return t.jsxRuntimeExports.jsx("div",{className:"px-6 py-2 space-y-6",children:t.jsxRuntimeExports.jsxs(t.Accordion,{defaultValue:["item-2"],type:"multiple",children:[t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-1",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{children:`${t.titleCase(e)} Chart`}),t.jsxRuntimeExports.jsxs(t.AccordionContent,{className:" space-y-4 font-mono text-xs ",children:[t.jsxRuntimeExports.jsx("div",{className:"bg-muted px-2 py-1 rounded text-xs",children:"SELECT label, measure FROM table"}),t.jsxRuntimeExports.jsxs("ul",{className:" ml-6 list-disc [&>li]:mt-2 text-xs",children:[t.jsxRuntimeExports.jsx("li",{children:"label - category"}),t.jsxRuntimeExports.jsx("li",{children:"measure - number"})]}),t.jsxRuntimeExports.jsxs("div",{children:["See ",t.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."]})]})]}),t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-2",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{children:"Settings"}),t.jsxRuntimeExports.jsx(t.AccordionContent,{className:"px-2",children:t.jsxRuntimeExports.jsx(un,{})})]}),t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-3",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{children:"Filter on click"}),t.jsxRuntimeExports.jsx(t.AccordionContent,{className:"px-2",children:t.jsxRuntimeExports.jsx(Ve,{})})]})]})})}function Ku(){return t.jsxRuntimeExports.jsx("div",{className:"space-y-6 px-6 py-2",children:t.jsxRuntimeExports.jsxs(t.Accordion,{defaultValue:["item-2"],type:"multiple",children:[t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-1",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{children:"Stacked Chart"}),t.jsxRuntimeExports.jsxs(t.AccordionContent,{className:"space-y-4 font-mono text-xs",children:[t.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT x-axis, stack-by, y-axis FROM table"}),t.jsxRuntimeExports.jsxs("ul",{className:"ml-6 list-disc text-xs [&>li]:mt-2",children:[t.jsxRuntimeExports.jsx("li",{children:"x-axis - category"}),t.jsxRuntimeExports.jsx("li",{children:"stack by - category"}),t.jsxRuntimeExports.jsx("li",{children:"y-axis - number"})]}),t.jsxRuntimeExports.jsxs("div",{children:["See ",t.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:e=>e.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#stacked-chart",children:"example"})," in the docs."]})]})]}),t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-2",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{children:"Settings"}),t.jsxRuntimeExports.jsxs(t.AccordionContent,{className:"space-y-4 px-2",children:[t.jsxRuntimeExports.jsx(an,{}),t.jsxRuntimeExports.jsx(oi,{})]})]}),t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-3",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{children:"Filter on click"}),t.jsxRuntimeExports.jsx(t.AccordionContent,{className:"px-2",children:t.jsxRuntimeExports.jsx(Ve,{})})]})]})})}function Wu({cardType:e}){return console.log("TableVisualSettings",e),t.jsxRuntimeExports.jsx("div",{className:"space-y-6 px-6 py-2",children:t.jsxRuntimeExports.jsx(t.Accordion,{defaultValue:["item-3"],type:"multiple",children:t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-3",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{children:"Filter on click"}),t.jsxRuntimeExports.jsx(t.AccordionContent,{className:"px-2",children:t.jsxRuntimeExports.jsx(Ve,{})})]})})})}function Gu(){const e=t.useEditorStore(r=>r.card.type);function n(r){switch(r){case"stackedBar":return t.jsxRuntimeExports.jsx(Ku,{});case"kpi":return t.jsxRuntimeExports.jsx(Uu,{});case"line":case"bar":return t.jsxRuntimeExports.jsx(Mu,{cardType:r});case"pie":case"doughnut":case"polarArea":case"radar":return t.jsxRuntimeExports.jsx($u,{cardType:r});case"bubble":case"scatter":return t.jsxRuntimeExports.jsx(Pu,{cardType:r});case"table":return t.jsxRuntimeExports.jsx(Wu,{cardType:r});default:return t.jsxRuntimeExports.jsx(Vu,{})}}return t.jsxRuntimeExports.jsx(t.ScrollArea,{className:"h-full w-full text-sm",children:n(e)})}function Qu(){const e=t.useEditorStore(n=>n.isShowingVisual);return t.jsxRuntimeExports.jsxs(Lt,{direction:"vertical",className:"min-w-full max-w-lg min-h-[250px]",children:[t.jsxRuntimeExports.jsx(Fe,{role:"query-section",className:"flex",minSize:20,defaultSize:40,children:t.jsxRuntimeExports.jsx(wu,{})}),t.jsxRuntimeExports.jsx(Ot,{withHandle:!0,className:"border "}),t.jsxRuntimeExports.jsx(Fe,{className:"pb-1",role:"visual-section",minSize:0,defaultSize:60,children:e?t.jsxRuntimeExports.jsxs(Lt,{direction:"horizontal",children:[t.jsxRuntimeExports.jsx(t.jsxRuntimeExports.Fragment,{children:t.jsxRuntimeExports.jsx(Fe,{className:"flex min-w-[275px]",minSize:20,defaultSize:25,maxSize:30,children:t.jsxRuntimeExports.jsx(Gu,{})})}),t.jsxRuntimeExports.jsx(Ot,{className:"border "}),t.jsxRuntimeExports.jsx(Fe,{minSize:40,defaultSize:75,maxSize:100,children:t.jsxRuntimeExports.jsx(nr,{})})]}):t.jsxRuntimeExports.jsx(nr,{})})]})}function Ju({authToken:e,onSave:n,onClose:r}){const i=t.useEditorStore(l=>l.actions.setOnSave),s=t.useEditorStore(l=>l.actions.setOnClose),o=t.useDashboardStore(l=>l.actions.setAuthToken);return A.useEffect(()=>{n&&i(n),r&&s(r)},[n,i,r,s]),A.useEffect(()=>{e&&e.accessToken&&o(e)},[e,o]),t.jsxRuntimeExports.jsxs(t.EditorPanel,{className:"rounded-none",role:"editor-panel",children:[t.jsxRuntimeExports.jsx(t.EditorAside,{className:"rounded-none border-r-[1.5px]",children:t.jsxRuntimeExports.jsx(cr,{})}),t.jsxRuntimeExports.jsx(t.EditorMain,{children:t.jsxRuntimeExports.jsx(Qu,{})})]})}function Xu(){t.useDashboardStore(l=>l.selectedCardId);const e=t.useDashboardStore(l=>l.selectedSheetId),{setIsVisualEditing:n}=t.useDashboardStore(l=>l.actions),r=t.useDashboardStore(l=>l.isVisualEditing),i=t.useDashboardStore(l=>l.actions.updateFrame);function s(l){e&&(i(e,l),n(!1))}function o(){n(!1)}return t.jsxRuntimeExports.jsx("div",{role:"editor-container",className:t.cn("flex grow",{block:r,hidden:!r}),children:t.jsxRuntimeExports.jsx(Ju,{onSave:s,onClose:o})})}function Yu({columns:e,tableName:n}){const r=t.useEditorStore(p=>p.selectedConnectionId),i=t.useEditorStore(p=>p.selectedDatabaseName),s=t.useEditorStore(p=>p.selectedSchemaName),o=t.useEditorStore(p=>p.selectedTableName),l=t.useDashboardStore(p=>p.dashboard.filters)||[],a=t.useDashboardStore(p=>p.actions.addFilter),u=t.useDashboardStore(p=>p.actions.removeFilter),c=t.useDashboardStore(p=>p.actions.removeFilterValue);function x(p){const m=t.fmt(p.column_name),d=t.fmt(i||""),j=t.fmt(s||""),E=t.fmt(n),k=t.getQualifiedTableName(j,E),y=`${k}.${m}`;console.log("find",y,E,d);const w=l==null?void 0:l.find(S=>S.column===y&&S.table===E&&(S.database===d||S.database===i));if(w)c(w.id),u(w.id);else{if(n==="api"&&r){a({id:t.v4(),column:y,title:p.column_name,dataType:p.data_type,table:"api",database:"NA",connectionId:r,operation:"in",sql:t.getDefaultFilterSql(p.data_type,k,m)});return}if(!r||!i||!o)throw new Error("missing connectionId, database, or table");a({id:t.v4(),column:`${k}.${m}`,title:p.column_name,dataType:p.data_type,table:o,database:i,connectionId:r,operation:"in",sql:t.getDefaultFilterSql(p.data_type,k,m)})}}return t.jsxRuntimeExports.jsx("div",{className:"xbg-red-100 flex-1 basis-0 flex-col overflow-scroll px-3",children:e==null?void 0:e.map(p=>{const m=l==null?void 0:l.find(d=>d.column===t.fmt(p.column_name)&&d.table===o&&d.database===i);return t.jsxRuntimeExports.jsx("div",{onClick:()=>x(p),className:t.cn("group flex cursor-pointer items-center justify-between border border-dashed border-background px-3 py-[6px] text-sm transition-colors hover:bg-muted/50",{"bg-muted":m}),children:t.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxRuntimeExports.jsx(ur,{column:p}),t.jsxRuntimeExports.jsx("span",{children:p.column_name})]})},p.column_name)})})}function Zu(){t.useDashboardStore(n=>n.showFilters);const e=t.useDashboardStore(n=>n.actions.setShowFilters);return t.jsxRuntimeExports.jsxs("section",{className:"relative flex grow flex-col border-l px-4",children:[t.jsxRuntimeExports.jsxs("div",{className:"mt-4 flex items-center justify-between gap-2 px-3",children:[t.jsxRuntimeExports.jsx(t.Label,{className:"text-lg",children:"Filters"}),t.jsxRuntimeExports.jsx(t.Button,{onClick:()=>e(!1),className:"h-7 w-7 p-0",variant:"ghost",children:t.jsxRuntimeExports.jsx(t.Cross2Icon,{})})]}),t.jsxRuntimeExports.jsx("div",{className:"flex grow",children:t.jsxRuntimeExports.jsx(cr,{ColumnsComponent:(n,r,i)=>t.jsxRuntimeExports.jsx(Yu,{schemaName:n,tableName:r,columns:i})})})]})}function ec(){t.useDashboardStore(r=>r.dashboard);const e=t.useDashboardStore(r=>r.showFilters),n=t.useDashboardStore(r=>r.isVisualEditing);return t.useDashboardStore(r=>r.bookmarkKey),t.jsxRuntimeExports.jsxs("div",{role:"dashboard-plus-main",className:t.cn("grow",{hidden:n,flex:!n}),children:[t.jsxRuntimeExports.jsx(t.DashboardTabs,{}),e&&t.jsxRuntimeExports.jsx("div",{role:"filter-aside-container",className:"flex",children:t.jsxRuntimeExports.jsx(Zu,{})})]})}function tc(){const e=t.useDashboardStore(i=>i.dashboard),n=t.useDashboardStore(i=>i.actions.setDashboard),r=t.useDashboardStore(i=>i.showDashboardJSON);return t.useDashboardStore(i=>i.actions.setShowDashboardJSON),t.jsxRuntimeExports.jsx("div",{className:t.cn(" p-2",{hidden:!r}),children:t.jsxRuntimeExports.jsx(t.de,{onChange:i=>{if(i)try{JSON.parse(i),n(JSON.parse(i))}catch{}},defaultLanguage:"json",className:"h-[550px] overflow-y-auto ",value:JSON.stringify(e,null,2),options:{minimap:{enabled:!1},glyphMargin:!1,wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:12,renderLineHighlight:"none"}})})}function nc({showControls:e=!1,showFooter:n=!0,...r}){return t.jsxRuntimeExports.jsx(t.SemaphorContextProvider,{dashboardProps:r,children:t.jsxRuntimeExports.jsxs(t.UXProvider,{children:[t.jsxRuntimeExports.jsx(tc,{}),t.jsxRuntimeExports.jsxs(t.DashboardPanel,{...r,children:[e&&t.jsxRuntimeExports.jsx(Di,{}),t.jsxRuntimeExports.jsx(Xu,{}),t.jsxRuntimeExports.jsx(ec,{})]})]})})}exports.DashboardPlus=nc;exports.SelectComponent=Ue;
|