react-semaphor 0.0.36 → 0.0.37

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.
@@ -50957,7 +50957,7 @@ function Xde(e) {
50957
50957
  /* @__PURE__ */ _.jsxs(us, { className: " text-xs space-y-2", children: [
50958
50958
  /* @__PURE__ */ _.jsxs("p", { children: [
50959
50959
  "Click ",
50960
- /* @__PURE__ */ _.jsx("b", { children: "Format" }),
50960
+ /* @__PURE__ */ _.jsx("b", { children: "Customize" }),
50961
50961
  " and change the `type` property in the dataset."
50962
50962
  ] }),
50963
50963
  /* @__PURE__ */ _.jsx("pre", { children: JSON.stringify(Gde, null, 2) })
@@ -50968,7 +50968,7 @@ function Xde(e) {
50968
50968
  /* @__PURE__ */ _.jsxs(us, { className: " text-xs space-y-2", children: [
50969
50969
  /* @__PURE__ */ _.jsxs("p", { children: [
50970
50970
  "Click ",
50971
- /* @__PURE__ */ _.jsx("b", { children: "Format" }),
50971
+ /* @__PURE__ */ _.jsx("b", { children: "Customize" }),
50972
50972
  " and add `fill` property to the dataset. See",
50973
50973
  /* @__PURE__ */ _.jsx(
50974
50974
  "a",
@@ -496,4 +496,4 @@ SELECT label, measure FROM table
496
496
  Table Columns: ${g==null?void 0:g.map(K=>`${K.column_name} | ${K.data_type}`).join(", ")}
497
497
  User SQL: ${p}
498
498
  `,x=` 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.
499
- Visual Query Syntax: ${Dne}`,{data:w,isLoading:_,isFetching:C,isError:O,refetch:P}=Sr({queryKey:["ai-query"],queryFn:()=>Za("https://semaphor.cloud/api/v1/ai",(s==null?void 0:s.accessToken)||"",{user_content:`userContent: ${y} ${a?x:""}`}),enabled:!1});function k(K){if(K.toLowerCase().includes("bar"))f("bar");else if(K.toLowerCase().includes("line"))f("line");else if(K.toLowerCase().includes("bubble"))f("bubble");else if(K.toLowerCase().includes("scatter"))f("scatter");else if(K.toLowerCase().includes("stacked"))f("stackedBar");else if(K.toLowerCase().includes("pie"))f("pie");else if(K.toLowerCase().includes("donut")||K.toLowerCase().includes("doughnut"))f("doughnut");else if(K.toLowerCase().includes("radar"))f("radar");else return f("bar"),!1;return!0}function A(){n&&(k(n)&&l(!0),P())}m.useEffect(()=>{i&&(A(),o(!1))},[i,o]);const L={fontFamily:"Arial, sans-serif",lineHeight:1.6,fontSize:15,padding:"5px",width:"100%"},F={fontFamily:"monospace",fontSize:14,lineHeight:1.6},B={fontFamily:"Arial, sans-serif",lineHeight:1.6,fontSize:15,padding:"2px 0",marginLeft:20,listStyleType:"disc"},V={p:({node:K,...Y})=>S.jsx("p",{style:L,...Y}),pre:({node:K,...Y})=>S.jsxs("pre",{className:" bg-muted/50 space-y-2 p-3 rounded-sm",style:F,children:[S.jsx("code",{className:" whitespace-normal",children:Y.children}),S.jsxs("div",{className:" flex justify-start gap-2",children:[S.jsx(ft,{onClick:H,size:"sm",variant:"outline",children:S.jsx(GE,{})}),S.jsx(ft,{onClick:$=>{const X=H($);X&&(t(!1),c(X),d(!0))},size:"sm",variant:"outline",children:S.jsx(Uj,{})})]})]}),li:({node:K,...Y})=>S.jsx("li",{style:B,...Y})};function H(K){const Y=K.currentTarget.closest("pre");if(!Y)return;const $=Y.textContent||Y.innerText;return navigator.clipboard.writeText($).then(()=>console.log("Text copied to clipboard")).catch(X=>console.error("Error in copying text: ",X)),$}return S.jsxs(ZM,{open:e,onOpenChange:t,children:[S.jsx(JM,{asChild:!0,children:S.jsx(ft,{size:"sm",className:"",variant:"outline",children:S.jsx(KB,{strokeWidth:1.5,size:18})})}),S.jsxs(Ty,{className:"sm:max-w-[425px] md:min-w-[625px] md:max-h-[625px] flex flex-col justify-between overflow-auto",children:[S.jsxs(Ay,{children:[S.jsx(Iy,{children:"Ask"}),S.jsx(Ry,{children:"Need assistance with SQL queries? Feel free to ask me any question!"})]}),S.jsx(El,{className:"h-[625px] w-full border-t ",children:(!_||!C)&&S.jsx(kne,{className:" pl-1 pr-3 py-1 w-full xbg-red-100 overflow-auto ",components:V,children:w==null?void 0:w.response})}),S.jsxs("div",{children:[S.jsx(Lc,{className:Oe(" invisible h-1 w-full animate-pulse",{visible:_||C})}),S.jsxs("div",{className:" border rounded-md flex items-center w-full",children:[S.jsx(Ny,{onKeyDown:K=>{K.key==="Enter"&&!K.shiftKey&&(K.preventDefault(),r(""),A())},placeholder:"Type something...",onFocus:K=>{const Y=K.target,$=Y.value.length;Y.setSelectionRange($,$)},className:" border-none resize-none min-h-7 max-h-10 focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",value:n,onChange:K=>r(K.target.value)})," ",S.jsx(ft,{className:"h-8",size:"sm",variant:"ghost",onClick:A,children:!_&&!C?S.jsx(Wj,{}):S.jsx(ku,{className:" w-4 h-4 animate-spin mr-2 text-foreground/50"})})]})]})]})]})}function Ane(){const{theme:e}=bm(),t=m.useRef(),n=m.useRef(),[r,i]=m.useState(!1),[o,s]=m.useState(!1),[a,l]=m.useState(""),[c,d]=m.useState(!1);m.useState("");const f=xe(W=>W.authToken),g=_e(W=>W.card),p=xe(W=>W.theme),v=_e(W=>W.selectedConnectionId),y=_e(W=>W.selectedDatabaseName),x=_e(W=>W.selectedSchemaName),w=_e(W=>W.selectedTableName),_=_e(W=>W.actions.setCardSql),C=_e(W=>W.card.sql),O=_e(W=>W.selectedConnectionId),P=_e(W=>W.filterValues),k=_e(W=>W.applyFilters),A=_e(W=>W.actions.setCardCustomCfg),L=_e(W=>W.actions.setFilterValues),F=_e(W=>W.onSave),B=_e(W=>W.actions.setApplyFilters),V=_e(W=>W.onClose),H=_e(W=>W.actions.setCardData),K=_e(W=>W.actions.setSqlGen),Y=_e(W=>W.runSql),$=_e(W=>W.actions.setRunSql),X=_e(W=>W.actions.setIsSqlRunning),{data:j,isLoading:ne,isFetching:se,isSuccess:D,isError:q,error:re,status:R,refetch:te}=Sr({queryKey:[C],queryFn:()=>Ts("https://semaphor.cloud/api/v1/query",(f==null?void 0:f.accessToken)||"",{connection_id:O,sql:C,active_filters:k?P:[]}),enabled:!1,retry:!1});m.useEffect(()=>{j&&(console.log("queryData",j),H(j.records))},[j,H]),m.useEffect(()=>{Y&&(te(),$(!1))},[Y,te,$]),m.useEffect(()=>{(ne||se)&&X(!0),(q||D)&&X(!1)},[ne,se,q,D,X]);function ge(){_(""),H([]),K({}),A("")}const pe=W=>{n.current=W};function de(){if(C&&!C.includes("{{")){const W=wQ(C);_(W),F==null||F({...g,sql:W,lastSelectedSchema:x,lastSelectedDatabase:y,lastSelectedTable:w,connectionId:v})}else F==null||F(g)}function ie(){V==null||V()}m.useEffect(()=>{const W=t.current,be=n.current;if(W){const oe=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",Te=p==="system"?oe:p;W.editor.defineTheme("default",{base:Te==="light"?"vs":"vs-dark",inherit:!0,rules:[],colors:{"editor.background":Te==="light"?"#ffffff":"#020817"}}),W.editor.setTheme("default")}return be&&W&&be.addCommand(W.KeyMod.Shift|W.KeyCode.Enter,function(){return console.log("Executing query..."),te(),!1}),()=>{}},[e,p,t.current]);function J(W){t.current=W}return S.jsxs("section",{className:"grow h-full flex flex-col justify-end pt-8 pb-4 ",children:[S.jsxs("div",{className:"w-full h-full grow flex relative justify-between ",children:[S.jsx("div",{className:`flex ${r?"w-2/3":"w-[95%]"} h-full xbg-red-100 p-1`,children:S.jsx(_y,{theme:"default",onChange:W=>{_(W),console.log(W)},value:C,options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"sql",defaultValue:"SELECT * FROM table",beforeMount:J,onMount:pe})}),r&&S.jsx("div",{className:"xbg-red-200 p-1 w-1/3 text-xs relative overflow-hidden xbg-yellow-100 ",children:S.jsxs("div",{className:"max-h-[250px] overflow-y-auto ",children:[S.jsxs("div",{className:"flex gap-2 items-center",children:[S.jsx(VQ,{checked:k,onCheckedChange:()=>B(!k),text:"Apply Filters"}),S.jsx(HQ,{})]}),S.jsx(_y,{theme:"default",onChange:W=>{if(W)try{JSON.parse(W),L(JSON.parse(W))}catch{}},defaultLanguage:"json",className:"h-[250px] overflow-y-auto mt-1",value:JSON.stringify(P,null,2),options:{readOnly:!0,minimap:{enabled:!1},lineNumbers:"off",glyphMargin:!1,wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:12,renderLineHighlight:"none"}})]})}),P&&r&&S.jsx(xu,{onClick:()=>i(!1),className:"absolute right-6 top-1 w-3 h-3 text-foreground/50 hover:text-foreground hover:cursor-pointer"}),P&&!r&&S.jsx(F2,{onClick:()=>i(!0),className:Oe("absolute right-6 top-1 w-3 h-3 text-foreground/50 hover:text-foreground hover:cursor-pointer",{"text-red-800 font-bold":k})})]}),S.jsxs("div",{className:" flex grow pl-8 pr-6 gap-2 justify-between item-center",children:[S.jsxs("div",{className:"flex grow gap-2 items-center",children:[S.jsxs(ft,{disabled:ne||se,onClick:()=>{te()},className:" shrink-0",size:"sm",variant:"outline",children:[(ne||se)&&S.jsx(ku,{className:"w-4 h-4 mr-2 animate-spin text-foreground/50"}),"Run"]}),q&&S.jsx(IQ,{error:re.message}),S.jsx(ft,{onClick:ge,className:"",size:"sm",variant:"outline",children:"Clear"}),S.jsx(Lp,{value:a,placeholder:"Type something...",onChange:W=>{l(W.target.value)},onKeyDown:W=>{W.key==="Enter"&&(W.preventDefault(),console.log("enter pressed"),d(!0),s(!0))},className:" bg-muted border-none h-9 focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0"}),S.jsx(Tne,{open:o,setOpen:s,userInput:a,triggerAIRun:c,setTriggerAIRun:d,setUserInput:W=>l(W)})]}),S.jsxs("div",{className:"flex gap-2 items-end ",children:[S.jsx(ft,{onClick:de,className:" w-full",size:"sm",variant:"outline",children:"Update"}),S.jsx(ft,{onClick:ie,className:" w-full",size:"sm",variant:"outline",children:"Close"})]})]})]})}const TT="Switch",[Ine,ffe]=Pn(TT),[Rne,Nne]=Ine(TT),Lne=m.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:i,defaultChecked:o,required:s,disabled:a,value:l="on",onCheckedChange:c,...d}=e,[f,g]=m.useState(null),p=et(t,_=>g(_)),v=m.useRef(!1),y=f?!!f.closest("form"):!0,[x=!1,w]=Qn({prop:i,defaultProp:o,onChange:c});return m.createElement(Rne,{scope:n,checked:x,disabled:a},m.createElement(Be.button,le({type:"button",role:"switch","aria-checked":x,"aria-required":s,"data-state":AT(x),"data-disabled":a?"":void 0,disabled:a,value:l},d,{ref:p,onClick:Ce(e.onClick,_=>{w(C=>!C),y&&(v.current=_.isPropagationStopped(),v.current||_.stopPropagation())})})),y&&m.createElement(jne,{control:f,bubbles:!v.current,name:r,value:l,checked:x,required:s,disabled:a,style:{transform:"translateX(-100%)"}}))}),$ne="SwitchThumb",Fne=m.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,i=Nne($ne,n);return m.createElement(Be.span,le({"data-state":AT(i.checked),"data-disabled":i.disabled?"":void 0},r,{ref:t}))}),jne=e=>{const{control:t,checked:n,bubbles:r=!0,...i}=e,o=m.useRef(null),s=yp(n),a=Oh(t);return m.useEffect(()=>{const l=o.current,c=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(c,"checked").set;if(s!==n&&f){const g=new Event("click",{bubbles:r});f.call(l,n),l.dispatchEvent(g)}},[s,n,r]),m.createElement("input",le({type:"checkbox","aria-hidden":!0,defaultChecked:n},i,{tabIndex:-1,ref:o,style:{...e.style,...a,position:"absolute",pointerEvents:"none",opacity:0,margin:0}}))};function AT(e){return e?"checked":"unchecked"}const IT=Lne,zne=Fne,RT=ue.forwardRef(({className:e,...t},n)=>S.jsx(IT,{className:Oe("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...t,ref:n,children:S.jsx(zne,{className:Oe("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));RT.displayName=IT.displayName;function NT({className:e,...t}){const[n,r]=m.useState(0),i=xe(l=>l.themeStyle),o=_e(l=>l.card),s=_e(l=>l.actions.setCard);if(m.useEffect(()=>{r(n+1)},[o.data,o.type,o.cfg,o.customCfg,i]),!o.id)return null;let a;return o.data&&o.data.length>0&&(a=wb({data:o.data,cardType:o.type,cfg:o.cfg,customCfg:o.customCfg})),S.jsxs(_v,{role:"editor-visual-card",className:Oe(" relative h-full flex flex-col rounded-none",e),...t,children:[S.jsxs(Sv,{children:[S.jsx(Wc,{text:o.title,onSave:l=>s({...o,title:l}),children:S.jsx(Cv,{className:"text-base",children:o.title})}),S.jsx(Wc,{text:o.description||"",onSave:l=>s({...o,description:l}),children:S.jsxs(Ev,{children:[" ",o.description]})})]}),S.jsxs(Pv,{className:"flex flex-col pb-3 grow",children:[o.type!=="table"&&a&&S.jsx(qE,{cfg:a},n),o.type==="table"&&o.data&&o.data.length>0&&S.jsx(rP,{children:S.jsx(t0,{data:o==null?void 0:o.data})})]})]})}function Bne(){const[e,t]=m.useState(!1),[n,r]=m.useState(""),[i,o]=m.useState(""),[s,a]=m.useState(""),l=_e(x=>x.card),c=_e(x=>x.card.customCfg),d=_e(x=>x.actions.setCardCustomCfg);function f(x){var C,O;const w={...x,data:{...x==null?void 0:x.data,datasets:(O=(C=x==null?void 0:x.data)==null?void 0:C.datasets)==null?void 0:O.map(P=>({...P,data:[]}))}};return JSON.stringify(w,null,1)}function g(){if(!l.data||l.data.length===0)return;const x=wb({data:l.data,cardType:l.type,cfg:l.cfg});x&&(r(JSON.stringify(x,null,1)),c&&o(JSON.stringify(c,null,1)))}function p(){if(i)try{const x=JSON.parse(i);return x?(d(x),a(""),o(""),x):void 0}catch(x){console.log(x),a("Invalid JSON")}}function v(){o(""),d(null)}function y(){let x;if(c){const w=Ns.cloneDeep(l.cfg),_=Ns.merge(w,c);return x=f(_),x}return n?(x=f(JSON.parse(n)),x):""}return S.jsxs(ZM,{open:e,onOpenChange:t,children:[S.jsx(JM,{asChild:!0,children:S.jsx(ft,{onClick:g,className:`h-7 ${c&&"border-foreground/50 dark:border-foreground/70"}`,size:"sm",variant:"outline",children:c?"Custom Config":"Customize"})}),S.jsx(Ty,{className:" sm:max-w-[425px] md:min-w-[600px] md:min-h-[700px] lg:min-w-[800px] xl:min-w-[1000px]",children:S.jsxs("div",{className:"bg-red-x100 flex flex-col gap-2 justify-between",children:[S.jsxs(Ay,{className:"",children:[S.jsx(Iy,{children:"Customize Chart"}),S.jsxs(Ry,{children:["See the configuration options and documentation",S.jsx("a",{target:"_blank",className:"ml-1 underline text-blue-500 ",href:"https://www.chartjs.org/docs/latest/samples/bar/vertical.html",children:"here."})]})]}),S.jsxs("div",{className:"grow flex flex-wrap gap-2",children:[S.jsx(NT,{className:"flex-1 rounded shadow-none"}),S.jsxs(t_,{defaultValue:"custom-config",className:" flex flex-col flex-1",children:[S.jsxs(n_,{className:" justify-start border rounded-sm rounded-b-none border-b-0 ",children:[S.jsxs(Pm,{value:"custom-config",children:[c&&S.jsx(UE,{className:"w-5 h-5 mr-1 text-green-600"}),c?"Custom Config":"Default Config"]}),S.jsx(Pm,{className:"",value:"output",children:"Output"})]}),S.jsx(uf,{className:" grow mt-0 bg-red-x p-2 border border-t-0 rounded-b ",value:"output",children:S.jsx(Ny,{disabled:!0,value:n,className:" border-none resize-none font-mono h-full focus-visible:ring-0 focus-visible:ring-offset-0"})}),S.jsx(uf,{className:"grow mt-0 border border-t-0 rounded-b ",value:"custom-config",children:S.jsx(_y,{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:y(),onChange:x=>o(x)})})]})]}),S.jsxs(tD,{className:"flex items-center",children:[S.jsx(Ml,{className:"text-red-500 mr-2",children:s}),S.jsx(ft,{disabled:!c,onClick:v,variant:"outline",children:"Reset"}),S.jsx(ft,{onClick:p,variant:"outline",children:"Apply"}),S.jsx(ft,{onClick:()=>t(!1),variant:"outline",children:"Close"})]})]})})]})}var LT={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},$T=m.createContext&&m.createContext(LT),Vne=["attr","size","title"];function Hne(e,t){if(e==null)return{};var n=Wne(e,t),r,i;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(i=0;i<o.length;i++)r=o[i],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function Wne(e,t){if(e==null)return{};var n={},r=Object.keys(e),i,o;for(o=0;o<r.length;o++)i=r[o],!(t.indexOf(i)>=0)&&(n[i]=e[i]);return n}function Yp(){return Yp=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Yp.apply(this,arguments)}function FT(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function Kp(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?FT(Object(n),!0).forEach(function(r){qne(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):FT(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function qne(e,t,n){return t=Une(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Une(e){var t=Gne(e,"string");return typeof t=="symbol"?t:String(t)}function Gne(e,t){if(typeof e!="object"||e===null)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function jT(e){return e&&e.map((t,n)=>m.createElement(t.tag,Kp({key:n},t.attr),jT(t.child)))}function ud(e){return t=>m.createElement(Yne,Yp({attr:Kp({},e.attr)},t),jT(e.child))}function Yne(e){var t=n=>{var{attr:r,size:i,title:o}=e,s=Hne(e,Vne),a=i||n.size||"1em",l;return n.className&&(l=n.className),e.className&&(l=(l?l+" ":"")+e.className),m.createElement("svg",Yp({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},n.attr,r,s,{className:l,style:Kp(Kp({color:e.color||n.color},n.style),e.style),height:a,width:a,xmlns:"http://www.w3.org/2000/svg"}),o&&m.createElement("title",null,o),e.children)};return $T!==void 0?m.createElement($T.Consumer,null,n=>t(n)):t(LT)}function zT(e){return ud({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 BT(e){return ud({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 VT(e){return ud({tag:"svg",attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M137,28.05a11.94,11.94,0,0,0-9.12,3.08A12.09,12.09,0,0,0,124,40V80.67a11.88,11.88,0,0,0,9.9,11.81,36,36,0,1,1-41.85,37.4c-.47-9.14,1.47-16.8,5.75-22.79h0a11.89,11.89,0,0,0-1.3-15.35L68.87,63.51a12,12,0,0,0-17.74.83A99.6,99.6,0,0,0,57.79,199.2,99.24,99.24,0,0,0,128,228h1.43A100.29,100.29,0,0,0,228,129.42C228.72,77.21,188.76,32.68,137,28.05ZM57.28,69.46A4,4,0,0,1,60.2,68h.19a3.91,3.91,0,0,1,2.79,1.14L90.81,97.36a3.93,3.93,0,0,1,.48,5.08A40.47,40.47,0,0,0,84.08,124h-48A90.36,90.36,0,0,1,57.28,69.46ZM36.09,132H84.18A44,44,0,0,0,124,171.81V219.9A92,92,0,0,1,36.09,132ZM193,193a91.43,91.43,0,0,1-61,26.92V171.82a43.51,43.51,0,0,0,26-11.63,44,44,0,0,0-22.79-75.6A4,4,0,0,1,132,80.67V40a4,4,0,0,1,1.31-3,3.89,3.89,0,0,1,3-1c47.59,4.26,84.34,45.24,83.67,93.29A91.42,91.42,0,0,1,193,193Z"},child:[]}]})(e)}function HT(e){return ud({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 WT(e){return ud({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 Kne(){const[e,t]=m.useState(!1),n=_e(s=>s.card.type),r=_e(s=>s.actions.setCardType),i=_e(s=>s.actions.setCardCustomCfg);function o(s){r(s),i(null),t(!1)}return S.jsxs(dp,{open:e,onOpenChange:t,children:[S.jsx(fp,{asChild:!0,children:S.jsx(ft,{className:"h-7 px-2",variant:"outline",children:S.jsx(Xne,{className:"h-4 w-4",chartType:n})})}),S.jsx(Wu,{className:"w-50",children:S.jsxs("div",{className:"grid grid-cols-3 place-items-center ",children:[S.jsx(ft,{onClick:()=>o("bar"),className:"font-normal",variant:"ghost",children:S.jsx(N2,{strokeWidth:1})}),S.jsx(ft,{onClick:()=>o("line"),variant:"ghost",children:S.jsx(j2,{strokeWidth:1})}),S.jsx(ft,{onClick:()=>o("stackedBar"),variant:"ghost",children:S.jsx(WT,{className:"h-6 w-6 text-foreground/50 ",strokeWidth:0})}),S.jsx(ft,{onClick:()=>o("scatter"),variant:"ghost",children:S.jsx(B2,{strokeWidth:1})}),S.jsx(ft,{onClick:()=>o("bubble"),variant:"ghost",children:S.jsx(HT,{strokeWidth:2})}),S.jsx(ft,{onClick:()=>o("pie"),variant:"ghost",children:S.jsx(z2,{strokeWidth:1})}),S.jsx(ft,{onClick:()=>o("doughnut"),variant:"ghost",children:S.jsx(VT,{className:"h-7 w-7",strokeWidth:.5})}),S.jsx(ft,{onClick:()=>o("radar"),variant:"ghost",children:S.jsx(zT,{className:"h-6 w-6 text-foreground/50 font-extralight",strokeWidth:.5})}),S.jsx(ft,{onClick:()=>o("polarArea"),variant:"ghost",children:S.jsx(BT,{className:"h-6 w-6 text-foreground/50",strokeWidth:1})}),S.jsx(ft,{onClick:()=>o("table"),variant:"ghost",children:S.jsx(jb,{className:"h-6 w-6 text-foreground/90",strokeWidth:1})})]})})]})}function Xne({chartType:e,className:t}){switch(e){case"bar":return S.jsx(N2,{className:t});case"line":return S.jsx(j2,{className:t});case"pie":return S.jsx(z2,{className:t});case"radar":return S.jsx(zT,{className:t});case"scatter":return S.jsx(B2,{className:t});case"bubble":return S.jsx(HT,{className:t});case"doughnut":return S.jsx(VT,{className:t});case"stackedBar":return S.jsx(WT,{className:"h-5 w-5 text-foreground/50 ",strokeWidth:0});case"polarArea":return S.jsx(BT,{className:t});default:return S.jsx(jb,{className:t})}}function Qne(){const e=_e(n=>n.card.refreshInterval),t=_e(n=>n.actions.setCardRefreshInterval);return S.jsxs(dp,{children:[S.jsx(fp,{asChild:!0,children:S.jsx(ft,{className:"h-7",variant:"outline",children:"Realtime"})}),S.jsx(Wu,{className:"w-[200px]",children:S.jsx("div",{className:"grid gap-4",children:S.jsx("div",{className:"grid gap-2",children:S.jsxs("div",{className:"grid grid-cols-5 items-center gap-1",children:[S.jsx(Ml,{className:"col-span-3",htmlFor:"width",children:"Refresh Every"}),S.jsx(Lp,{value:e||"",onChange:n=>t(n.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 qT(){const e=_e(r=>r.card),t=_e(r=>r.isShowingVisual),n=_e(r=>r.isSqlRunning);return _e(r=>r.onSave),_e(r=>r.onClose),_e(r=>r.actions.setCardSql),_e(r=>r.actions.setCardType),_e(r=>r.actions.setSqlGen),S.jsxs("div",{className:" h-full relative flex flex-col",children:[n&&S.jsx(ku,{className:" w-10 h-10 z-10 absolute m-auto left-0 right-0 top-0 bottom-0 animate-spin text-foreground/10 "}),S.jsxs("div",{className:" h-10 px-6 pt-6 bg-red-x100 mb-0 z-10 right-0 flex justify-end items-center gap-2",children:[t&&S.jsxs("div",{className:"bg-red-x00 flex grow gap-2",children:[S.jsx(Kne,{}),S.jsx(Bne,{}),S.jsx(Qne,{})]}),S.jsx(Zne,{})]}),t?S.jsx(NT,{className:"grow border-none shadow-none "}):S.jsx("div",{className:"w-full mt-4 px-6 bg-red-x00 grow border-none shadow-none overflow-y-auto ",children:e.data&&e.data.length>0&&S.jsx(t0,{data:e.data})})]})}function Zne(){const e=_e(n=>n.isShowingVisual),t=_e(n=>n.actions.setIsShowingVisual);return S.jsxs("div",{className:" flex items-center space-x-2",children:[S.jsx(Ml,{htmlFor:"visualize",children:"Chart"}),S.jsx(RT,{checked:e,onCheckedChange:()=>t(!e),id:"visualize",className:"data-[state=checked]:bg-foreground/50"})]})}const UT="Collapsible",[Jne,GT]=Pn(UT),[ere,mx]=Jne(UT),tre=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:i,disabled:o,onOpenChange:s,...a}=e,[l=!1,c]=Qn({prop:r,defaultProp:i,onChange:s});return m.createElement(ere,{scope:n,disabled:o,contentId:or(),open:l,onOpenToggle:m.useCallback(()=>c(d=>!d),[c])},m.createElement(Be.div,le({"data-state":vx(l),"data-disabled":o?"":void 0},a,{ref:t})))}),nre="CollapsibleTrigger",rre=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,i=mx(nre,n);return m.createElement(Be.button,le({type:"button","aria-controls":i.contentId,"aria-expanded":i.open||!1,"data-state":vx(i.open),"data-disabled":i.disabled?"":void 0,disabled:i.disabled},r,{ref:t,onClick:Ce(e.onClick,i.onOpenToggle)}))}),YT="CollapsibleContent",ire=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,i=mx(YT,e.__scopeCollapsible);return m.createElement(vn,{present:n||i.open},({present:o})=>m.createElement(ore,le({},r,{ref:t,present:o})))}),ore=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:i,...o}=e,s=mx(YT,n),[a,l]=m.useState(r),c=m.useRef(null),d=et(t,c),f=m.useRef(0),g=f.current,p=m.useRef(0),v=p.current,y=s.open||a,x=m.useRef(y),w=m.useRef();return m.useEffect(()=>{const _=requestAnimationFrame(()=>x.current=!1);return()=>cancelAnimationFrame(_)},[]),Vn(()=>{const _=c.current;if(_){w.current=w.current||{transitionDuration:_.style.transitionDuration,animationName:_.style.animationName},_.style.transitionDuration="0s",_.style.animationName="none";const C=_.getBoundingClientRect();f.current=C.height,p.current=C.width,x.current||(_.style.transitionDuration=w.current.transitionDuration,_.style.animationName=w.current.animationName),l(r)}},[s.open,r]),m.createElement(Be.div,le({"data-state":vx(s.open),"data-disabled":s.disabled?"":void 0,id:s.contentId,hidden:!y},o,{ref:d,style:{"--radix-collapsible-content-height":g?`${g}px`:void 0,"--radix-collapsible-content-width":v?`${v}px`:void 0,...e.style}}),y&&i)});function vx(e){return e?"open":"closed"}const sre=tre,are=rre,lre=ire,ls="Accordion",cre=["Home","End","ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],[bx,ure,dre]=lf(ls),[Xp,hfe]=Pn(ls,[dre,GT]),yx=GT(),KT=m.forwardRef((e,t)=>{const{type:n,...r}=e,i=r,o=r;return m.createElement(bx.Provider,{scope:e.__scopeAccordion},n==="multiple"?m.createElement(gre,le({},o,{ref:t})):m.createElement(pre,le({},i,{ref:t})))});KT.propTypes={type(e){const t=e.value||e.defaultValue;return e.type&&!["single","multiple"].includes(e.type)?new Error("Invalid prop `type` supplied to `Accordion`. Expected one of `single | multiple`."):e.type==="multiple"&&typeof t=="string"?new Error("Invalid prop `type` supplied to `Accordion`. Expected `single` when `defaultValue` or `value` is type `string`."):e.type==="single"&&Array.isArray(t)?new Error("Invalid prop `type` supplied to `Accordion`. Expected `multiple` when `defaultValue` or `value` is type `string[]`."):null}};const[XT,fre]=Xp(ls),[QT,hre]=Xp(ls,{collapsible:!1}),pre=m.forwardRef((e,t)=>{const{value:n,defaultValue:r,onValueChange:i=()=>{},collapsible:o=!1,...s}=e,[a,l]=Qn({prop:n,defaultProp:r,onChange:i});return m.createElement(XT,{scope:e.__scopeAccordion,value:a?[a]:[],onItemOpen:l,onItemClose:m.useCallback(()=>o&&l(""),[o,l])},m.createElement(QT,{scope:e.__scopeAccordion,collapsible:o},m.createElement(ZT,le({},s,{ref:t}))))}),gre=m.forwardRef((e,t)=>{const{value:n,defaultValue:r,onValueChange:i=()=>{},...o}=e,[s=[],a]=Qn({prop:n,defaultProp:r,onChange:i}),l=m.useCallback(d=>a((f=[])=>[...f,d]),[a]),c=m.useCallback(d=>a((f=[])=>f.filter(g=>g!==d)),[a]);return m.createElement(XT,{scope:e.__scopeAccordion,value:s,onItemOpen:l,onItemClose:c},m.createElement(QT,{scope:e.__scopeAccordion,collapsible:!0},m.createElement(ZT,le({},o,{ref:t}))))}),[mre,Qp]=Xp(ls),ZT=m.forwardRef((e,t)=>{const{__scopeAccordion:n,disabled:r,dir:i,orientation:o="vertical",...s}=e,a=m.useRef(null),l=et(a,t),c=ure(n),f=Ls(i)==="ltr",g=Ce(e.onKeyDown,p=>{var v;if(!cre.includes(p.key))return;const y=p.target,x=c().filter(F=>{var B;return!((B=F.ref.current)!==null&&B!==void 0&&B.disabled)}),w=x.findIndex(F=>F.ref.current===y),_=x.length;if(w===-1)return;p.preventDefault();let C=w;const O=0,P=_-1,k=()=>{C=w+1,C>P&&(C=O)},A=()=>{C=w-1,C<O&&(C=P)};switch(p.key){case"Home":C=O;break;case"End":C=P;break;case"ArrowRight":o==="horizontal"&&(f?k():A());break;case"ArrowDown":o==="vertical"&&k();break;case"ArrowLeft":o==="horizontal"&&(f?A():k());break;case"ArrowUp":o==="vertical"&&A();break}const L=C%_;(v=x[L].ref.current)===null||v===void 0||v.focus()});return m.createElement(mre,{scope:n,disabled:r,direction:i,orientation:o},m.createElement(bx.Slot,{scope:n},m.createElement(Be.div,le({},s,{"data-orientation":o,ref:l,onKeyDown:r?void 0:g}))))}),xx="AccordionItem",[vre,wx]=Xp(xx),bre=m.forwardRef((e,t)=>{const{__scopeAccordion:n,value:r,...i}=e,o=Qp(xx,n),s=fre(xx,n),a=yx(n),l=or(),c=r&&s.value.includes(r)||!1,d=o.disabled||e.disabled;return m.createElement(vre,{scope:n,open:c,disabled:d,triggerId:l},m.createElement(sre,le({"data-orientation":o.orientation,"data-state":eA(c)},a,i,{ref:t,disabled:d,open:c,onOpenChange:f=>{f?s.onItemOpen(r):s.onItemClose(r)}})))}),yre="AccordionHeader",xre=m.forwardRef((e,t)=>{const{__scopeAccordion:n,...r}=e,i=Qp(ls,n),o=wx(yre,n);return m.createElement(Be.h3,le({"data-orientation":i.orientation,"data-state":eA(o.open),"data-disabled":o.disabled?"":void 0},r,{ref:t}))}),JT="AccordionTrigger",wre=m.forwardRef((e,t)=>{const{__scopeAccordion:n,...r}=e,i=Qp(ls,n),o=wx(JT,n),s=hre(JT,n),a=yx(n);return m.createElement(bx.ItemSlot,{scope:n},m.createElement(are,le({"aria-disabled":o.open&&!s.collapsible||void 0,"data-orientation":i.orientation,id:o.triggerId},a,r,{ref:t})))}),_re="AccordionContent",Sre=m.forwardRef((e,t)=>{const{__scopeAccordion:n,...r}=e,i=Qp(ls,n),o=wx(_re,n),s=yx(n);return m.createElement(lre,le({role:"region","aria-labelledby":o.triggerId,"data-orientation":i.orientation},s,r,{ref:t,style:{"--radix-accordion-content-height":"var(--radix-collapsible-content-height)","--radix-accordion-content-width":"var(--radix-collapsible-content-width)",...e.style}}))});function eA(e){return e?"open":"closed"}const Cre=KT,Ere=bre,Pre=xre,tA=wre,nA=Sre,rA=Cre,cs=ue.forwardRef(({className:e,...t},n)=>S.jsx(Ere,{ref:n,className:Oe("border-b",e),...t}));cs.displayName="AccordionItem";const us=ue.forwardRef(({className:e,children:t,...n},r)=>S.jsx(Pre,{className:"flex",children:S.jsxs(tA,{ref:r,className:Oe("flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180",e),...n,children:[t,S.jsx(Fb,{className:"h-4 w-4 shrink-0 transition-transform duration-200"})]})}));us.displayName=tA.displayName;const ds=ue.forwardRef(({className:e,children:t,...n},r)=>S.jsx(nA,{ref:r,className:"overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...n,children:S.jsx("div",{className:Oe("pb-4 pt-0",e),children:t})}));ds.displayName=nA.displayName;const iA="Radio",[Ore,oA]=Pn(iA),[kre,Mre]=Ore(iA),Dre=m.forwardRef((e,t)=>{const{__scopeRadio:n,name:r,checked:i=!1,required:o,disabled:s,value:a="on",onCheck:l,...c}=e,[d,f]=m.useState(null),g=et(t,y=>f(y)),p=m.useRef(!1),v=d?!!d.closest("form"):!0;return m.createElement(kre,{scope:n,checked:i,disabled:s},m.createElement(Be.button,le({type:"button",role:"radio","aria-checked":i,"data-state":sA(i),"data-disabled":s?"":void 0,disabled:s,value:a},c,{ref:g,onClick:Ce(e.onClick,y=>{i||l==null||l(),v&&(p.current=y.isPropagationStopped(),p.current||y.stopPropagation())})})),v&&m.createElement(Ire,{control:d,bubbles:!p.current,name:r,value:a,checked:i,required:o,disabled:s,style:{transform:"translateX(-100%)"}}))}),Tre="RadioIndicator",Are=m.forwardRef((e,t)=>{const{__scopeRadio:n,forceMount:r,...i}=e,o=Mre(Tre,n);return m.createElement(vn,{present:r||o.checked},m.createElement(Be.span,le({"data-state":sA(o.checked),"data-disabled":o.disabled?"":void 0},i,{ref:t})))}),Ire=e=>{const{control:t,checked:n,bubbles:r=!0,...i}=e,o=m.useRef(null),s=yp(n),a=Oh(t);return m.useEffect(()=>{const l=o.current,c=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(c,"checked").set;if(s!==n&&f){const g=new Event("click",{bubbles:r});f.call(l,n),l.dispatchEvent(g)}},[s,n,r]),m.createElement("input",le({type:"radio","aria-hidden":!0,defaultChecked:n},i,{tabIndex:-1,ref:o,style:{...e.style,...a,position:"absolute",pointerEvents:"none",opacity:0,margin:0}}))};function sA(e){return e?"checked":"unchecked"}const Rre=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],aA="RadioGroup",[Nre,pfe]=Pn(aA,[nl,oA]),lA=nl(),cA=oA(),[Lre,$re]=Nre(aA),Fre=m.forwardRef((e,t)=>{const{__scopeRadioGroup:n,name:r,defaultValue:i,value:o,required:s=!1,disabled:a=!1,orientation:l,dir:c,loop:d=!0,onValueChange:f,...g}=e,p=lA(n),v=Ls(c),[y,x]=Qn({prop:o,defaultProp:i,onChange:f});return m.createElement(Lre,{scope:n,name:r,required:s,disabled:a,value:y,onValueChange:x},m.createElement(Sm,le({asChild:!0},p,{orientation:l,dir:v,loop:d}),m.createElement(Be.div,le({role:"radiogroup","aria-required":s,"aria-orientation":l,"data-disabled":a?"":void 0,dir:v},g,{ref:t}))))}),jre="RadioGroupItem",zre=m.forwardRef((e,t)=>{const{__scopeRadioGroup:n,disabled:r,...i}=e,o=$re(jre,n),s=o.disabled||r,a=lA(n),l=cA(n),c=m.useRef(null),d=et(t,c),f=o.value===i.value,g=m.useRef(!1);return m.useEffect(()=>{const p=y=>{Rre.includes(y.key)&&(g.current=!0)},v=()=>g.current=!1;return document.addEventListener("keydown",p),document.addEventListener("keyup",v),()=>{document.removeEventListener("keydown",p),document.removeEventListener("keyup",v)}},[]),m.createElement(Cm,le({asChild:!0},a,{focusable:!s,active:f}),m.createElement(Dre,le({disabled:s,required:o.required,checked:f},l,i,{name:o.name,ref:d,onCheck:()=>o.onValueChange(i.value),onKeyDown:Ce(p=>{p.key==="Enter"&&p.preventDefault()}),onFocus:Ce(i.onFocus,()=>{var p;g.current&&((p=c.current)===null||p===void 0||p.click())})})))}),Bre=m.forwardRef((e,t)=>{const{__scopeRadioGroup:n,...r}=e,i=cA(n);return m.createElement(Are,le({},i,r,{ref:t}))}),uA=Fre,dA=zre,Vre=Bre,fA=ue.forwardRef(({className:e,...t},n)=>S.jsx(uA,{className:Oe("grid gap-2",e),...t,ref:n}));fA.displayName=uA.displayName;const _x=ue.forwardRef(({className:e,...t},n)=>S.jsx(dA,{ref:n,className:Oe("aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:S.jsx(Vre,{className:"flex items-center justify-center",children:S.jsx($2,{className:"h-2.5 w-2.5 fill-current text-current"})})}));_x.displayName=dA.displayName;function hA(){var i;const e=_e(o=>o.card.cfg),t=_e(o=>o.actions.setCardCfg),n=(i=e==null?void 0:e.options)==null?void 0:i.indexAxis;function r(o){const s={...e,options:{...e==null?void 0:e.options,indexAxis:o}};t(s)}return S.jsxs("div",{children:[S.jsx("p",{className:"font-semibold",children:"Orientation"}),S.jsxs(fA,{value:n,onValueChange:r,className:"flex gap-3 mt-2 ",defaultValue:"x",children:[S.jsxs("div",{className:"flex items-center space-x-2",children:[S.jsx(_x,{value:"x",id:"r1"}),S.jsx("label",{className:"text-sm",htmlFor:"r1",children:"Vertical"})]}),S.jsxs("div",{className:"flex items-center space-x-2",children:[S.jsx(_x,{value:"y",id:"r2"}),S.jsx("label",{className:"text-sm",htmlFor:"r2",children:"Horizontal"})]})]})]})}function pA(){var r,i,o;const e=_e(s=>s.card.cfg),t=_e(s=>s.actions.setCardCfg);function n(s){var c;const a={datalabels:{display:s!=="none",align:s,anchor:s,clamp:!0}},l={...e,options:{...e==null?void 0:e.options,plugins:{...(c=e==null?void 0:e.options)==null?void 0:c.plugins,...a}}};t(l),console.log(s)}return S.jsxs(S.Fragment,{children:[S.jsx("label",{className:"font-medium",children:"Data Labels"}),S.jsxs(zk,{value:(o=(i=(r=e==null?void 0:e.options)==null?void 0:r.plugins)==null?void 0:i.datalabels)==null?void 0:o.anchor,onValueChange:n,defaultValue:"none",children:[S.jsx(py,{className:"w-[180px] mt-2 focus:ring-1 focus:ring-offset-0 h-7",children:S.jsx(Vk,{placeholder:"Select position"})}),S.jsx(gy,{children:S.jsxs(Bk,{children:[S.jsx(Cp,{children:"Data Labels"}),S.jsx(ba,{value:"none",children:"None"}),S.jsx(ba,{value:"start",children:"Start"}),S.jsx(ba,{value:"center",children:"Center"}),S.jsx(ba,{value:"end",children:"End"})]})})]})]})}function gA(){const e=_e(i=>i.card.preferences),t=_e(i=>i.actions.setCardPreferences),n=_e(i=>{var o;return(o=i.card.preferences)==null?void 0:o.filterOnClickField}),r=_e(i=>i.actions.setFilterOnClickField);return S.jsxs("div",{children:[S.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[S.jsx(ky,{checked:!!(e!=null&&e.filterOnClick),onCheckedChange:i=>{t({...e,filterOnClick:!!i})}}),S.jsx(Ml,{children:"Filter on click"})]}),(e==null?void 0:e.filterOnClick)===!0&&S.jsxs("div",{className:"flex gap-2 items-center",children:[S.jsx(Lp,{value:n||"",className:" h-7 font-mono text-xs focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",placeholder:"expression (optional)",onChange:i=>r(i.target.value)}),S.jsxs(Nb,{children:[S.jsx(D2,{children:S.jsx(YE,{className:"h-4 w-4 opacity-70"})}),S.jsx(Th,{children:S.jsxs("div",{className:"max-w-[200px]",children:["The x-axis expression of your query. Example:",S.jsx("div",{className:" mt-1 text-xs font-mono",children:"TO_CHAR(order_date, 'YYYY-MM')"})]})})]})]})]})}const Hre={datasets:[{type:"line",label:"Sum_sales",data:[]},{type:"bar",label:"Sum_profit",data:[]}]},Wre={datasets:[{fill:"origin",type:"line",label:"Sum_sales",data:[]}]};function qre(){const e=_e(t=>t.card.type);return S.jsxs("div",{className:"p-6 space-y-6",children:[S.jsx(rA,{className:" ",type:"single",collapsible:!0,children:Ure(e)}),S.jsx("section",{className:"",children:["line","bar"].includes(e)&&S.jsx(hA,{})}),S.jsx("div",{children:S.jsx(pA,{})}),S.jsx("div",{children:S.jsx(gA,{})})]})}function Ure(e){if(["line","bar"].includes(e))return S.jsxs(S.Fragment,{children:[S.jsxs(cs,{className:"border-muted",value:"item-1",children:[S.jsx(us,{className:" font-normal",children:S.jsxs("p",{children:["Create a ",S.jsx("span",{children:"chart"})," query"]})}),S.jsxs(ds,{className:" ",children:[S.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"}),S.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs",children:[S.jsx("li",{children:"X-axis - Category (ex. city)"}),S.jsx("li",{children:"Y-axis - Number (ex. population)"})]})]})]}),S.jsxs(cs,{className:"border-muted",value:"item-2",children:[S.jsx(us,{className:" font-normal",children:"Create a mixed chart"}),S.jsxs(ds,{className:" text-xs space-y-2",children:[S.jsxs("p",{children:["Click ",S.jsx("b",{children:"Format"})," and change the `type` property in the dataset."]}),S.jsx("pre",{children:JSON.stringify(Hre,null,2)})]})]}),S.jsxs(cs,{className:"border-muted",value:"item-3",children:[S.jsx(us,{className:" font-normal",children:"Create an area chart"}),S.jsxs(ds,{className:" text-xs space-y-2",children:[S.jsxs("p",{children:["Click ",S.jsx("b",{children:"Format"})," and add `fill` property to the dataset. See",S.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."]}),S.jsx("pre",{children:JSON.stringify(Wre,null,2)})]})]})]});if(e==="bubble")return S.jsx(S.Fragment,{children:S.jsxs(cs,{className:"border-muted",value:"item-1",children:[S.jsx(us,{className:" font-normal",children:S.jsxs("p",{children:["How to create a ",S.jsx("span",{children:e})," chart query?"]})}),S.jsxs(ds,{className:" ",children:[S.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"}),S.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs",children:[S.jsx("li",{children:"Label - Category (ex. city)"}),S.jsx("li",{children:"Bubble Group (opt) - Category (ex. state)"}),S.jsx("li",{children:"X-axis - Number (ex. avg. age)"}),S.jsx("li",{children:"Y-axis - Number (ex. avg. weight)"}),S.jsx("li",{children:"Radius - Number (ex. population)"})]})]})]})});if(e==="scatter")return S.jsx(S.Fragment,{children:S.jsxs(cs,{value:"item-1",children:[S.jsx(us,{className:" font-normal",children:S.jsxs("p",{children:["How to create a ",S.jsx("span",{children:e})," chart query?"]})}),S.jsxs(ds,{className:" ",children:[S.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"}),S.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs",children:[S.jsx("li",{children:"Label - Category (ex. city)"}),S.jsx("li",{children:"Group (opt) - Category (ex. state)"}),S.jsx("li",{children:"X-axis - Number (ex. avg. age)"}),S.jsx("li",{children:"Y-axis - Number (ex. avg. weight)"})]})]})]})});if(["pie","doughnut","polarArea"].includes(e))return S.jsx(S.Fragment,{children:S.jsxs(cs,{value:"item-1",children:[S.jsx(us,{className:" font-normal",children:S.jsxs("p",{children:["How to create a"," ",S.jsxs("span",{children:[e==="polarArea"?"polar":e," "]})," ","chart query?"]})}),S.jsxs(ds,{className:" ",children:[S.jsx("div",{className:"bg-muted px-2 py-1 rounded font-mono font-semibold text-xs",children:"SELECT label, measure FROM table"}),S.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs",children:[S.jsx("li",{children:"Label - Category (ex. city)"}),S.jsx("li",{children:"Measure - Number (ex. population)"})]})]})]})})}function Gre(){return S.jsxs("div",{className:"px-6 py-2 space-y-6",children:[S.jsx(rA,{className:" ",type:"single",collapsible:!0,children:S.jsxs(cs,{className:"border-muted",value:"item-1",children:[S.jsx(us,{className:" font-normal",children:"Stacked chart query?"}),S.jsxs(ds,{className:" ",children:[S.jsx("div",{className:"bg-muted px-2 py-1 rounded font-mono font-semibold text-xs",children:"SELECT x-axis, stack-by, y-axis FROM table"}),S.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs",children:[S.jsx("li",{children:"X-axis - Category (ex. country)"}),S.jsx("li",{children:"Stack by - Category (ex. city)"}),S.jsx("li",{children:"Y-axis - Number (ex. population)"})]})]})]})}),S.jsx("section",{className:"",children:S.jsx(hA,{})}),S.jsx("div",{children:S.jsx(pA,{})}),S.jsx("div",{children:S.jsx(gA,{})})]})}function Yre(){const e=_e(t=>t.card.type);return S.jsx(El,{className:" text-sm h-full w-full ",children:e==="stackedBar"?S.jsx(Gre,{}):S.jsx(qre,{})})}function Kre(){const e=_e(t=>t.isShowingVisual);return S.jsxs(bM,{direction:"vertical",className:"min-w-full max-w-lg min-h-[250px]",children:[S.jsx(Dp,{minSize:30,defaultSize:35,children:S.jsx(Ane,{})}),S.jsx(yM,{}),S.jsx(Dp,{minSize:60,defaultSize:75,children:e?S.jsxs(bM,{direction:"horizontal",children:[S.jsx(S.Fragment,{children:S.jsx(Dp,{className:"flex min-w-[275px]",minSize:20,defaultSize:25,maxSize:30,children:S.jsx(Yre,{})})}),S.jsx(yM,{}),S.jsx(Dp,{minSize:40,defaultSize:70,maxSize:100,children:S.jsx(qT,{})})]}):S.jsx(qT,{})})]})}function Xre({authToken:e,onSave:t,onClose:n}){_e(s=>s.actions.setCard);const r=_e(s=>s.actions.setOnSave),i=_e(s=>s.actions.setOnClose),o=xe(s=>s.actions.setAuthToken);return m.useEffect(()=>{t&&r(t),n&&i(n)},[t,r,n,i]),m.useEffect(()=>{e&&e.accessToken&&o(e)},[e,o]),S.jsxs(xk,{children:[S.jsx(wk,{className:"border rounded-none border-y-2 border-l-2 border-muted",children:S.jsx(Uk,{})}),S.jsx(_k,{className:"border-2 rounded-none border-muted",children:S.jsx(Kre,{})})]})}function Qre(){xe(s=>s.selectedCardId);const e=xe(s=>s.selectedSheetId),t=xe(s=>s.actions.setIsVisualEditing);xe(s=>s.actions.setIsEditorSaveEvent);const n=xe(s=>s.isVisualEditing);xe(s=>s.actions.getSelectedCard());const r=xe(s=>s.actions.updateCard);function i(s){e&&(r(e,s),t(!1))}function o(){t(!1)}return S.jsx("div",{className:`grow flex ${n?"block":"hidden"}`,children:S.jsx(Xre,{onSave:i,onClose:o})})}function Zre({columns:e,tableName:t}){const n=_e(f=>f.selectedConnectionId),r=_e(f=>f.selectedDatabaseName),i=_e(f=>f.selectedSchemaName),o=_e(f=>f.selectedTableName),s=xe(f=>f.dashboard.filters)||[],a=xe(f=>f.actions.addFilter),l=xe(f=>f.actions.removeFilter),c=xe(f=>f.actions.removeFilterValue);function d(f){const g=s==null?void 0:s.find(p=>p.column===f.column_name&&p.table===o&&p.database===r);if(g)c(g.id),l(g.id);else{const p=S0(i||"",t),v=`SELECT ${f.column_name}, COUNT(*) FROM ${p} GROUP BY ${f.column_name} ORDER BY ${f.column_name} ASC LIMIT 50`,y=`SELECT min(${f.column_name}) as min, max(${f.column_name}) as max FROM ${p}`;if(t==="api"&&n){a({id:vh(),column:f.column_name,title:f.column_name,dataType:f.data_type,table:"api",database:"NA",connectionId:n,sql:Iu.includes(f.data_type)?y:v});return}if(!n||!r||!o)throw new Error("missing connectionId, database, or table");a({id:vh(),column:f.column_name,title:f.column_name,dataType:f.data_type,table:o,database:r,connectionId:n,sql:Iu.includes(f.data_type)?y:v})}}return S.jsx(El,{className:" h-[70vh] mt-2",children:e==null?void 0:e.map(f=>{const g=s==null?void 0:s.find(p=>p.column===f.column_name&&p.table===o&&p.database===r);return S.jsx("div",{onClick:()=>d(f),className:Oe(" group flex text-sm items-center justify-between px-3 py-[6px] transition-colors hover:bg-muted/50 cursor-pointer border border-background border-dashed",{"bg-muted ":g}),children:S.jsxs("div",{className:"flex items-center gap-2 ",children:[S.jsx(qk,{column:f}),S.jsx("span",{children:f.column_name})]})},f.column_name)})})}function Jre(){xe(t=>t.showFilters);const e=xe(t=>t.actions.setShowFilters);return S.jsxs("section",{className:" relative space-y-4 py-0 px-4 border-muted bg-red-x100",children:[S.jsx(ft,{onClick:()=>e(!1),className:" p-0 h-7 w-7 absolute top-0 right-4",variant:"outline",children:S.jsx(xu,{})}),S.jsx("p",{className:"text-md",children:"Data Columns"}),S.jsx("div",{children:S.jsx(Uk,{ColumnsComponent:(t,n,r)=>S.jsx(Zre,{schemaName:t,tableName:n,columns:r})})})]})}function eie(){const e=xe(n=>n.showFilters),t=xe(n=>n.isVisualEditing);return S.jsxs("div",{role:"dashboard-plus-main",className:` flex grow ${t?"hidden":"block"} `,children:[S.jsx(qO,{}),e&&S.jsx("div",{role:"filter-aside-container",className:" border min-h-[80vh] w-[300px]",children:S.jsx(Jre,{})})]})}function tie(){const e=xe(r=>r.dashboard),t=xe(r=>r.actions.setDashboard),n=xe(r=>r.showDashboardJSON);return xe(r=>r.actions.setShowDashboardJSON),S.jsx("div",{className:Oe(" p-2",{hidden:!n}),children:S.jsx(RM,{onChange:r=>{if(r)try{JSON.parse(r),t(JSON.parse(r))}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 nie({showControls:e=!1,showFooter:t=!0,...n}){return xe(r=>r.isVisualEditing),S.jsxs(UO,{children:[e&&S.jsx(lK,{}),S.jsx(tie,{}),S.jsxs(Hw,{...n,children:[S.jsx(Qre,{}),S.jsx(eie,{})]})]})}function rie(){const e=xe(t=>t.actions);return{setDashboardTitle:e.setDashboardTitle,getStyle:e.getStyle,getDashboard:e.getDashboard,setOnSaveFunction:e.setOnSaveFunction,setOnAddCard:e.setOnAddCard,setOnUpateCard:e.setOnUpdateCard,setOnRemoveCard:e.setOnRemoveCard}}dt.Dashboard=GO,dt.DashboardPlus=nie,dt.DashboardWC=BG,dt.cleanCard=yk,dt.getDashbaordStateWithoutData=bk,dt.useActions=rie,dt.useDashboardStore=xe,Object.defineProperty(dt,Symbol.toStringTag,{value:"Module"})});
499
+ Visual Query Syntax: ${Dne}`,{data:w,isLoading:_,isFetching:C,isError:O,refetch:P}=Sr({queryKey:["ai-query"],queryFn:()=>Za("https://semaphor.cloud/api/v1/ai",(s==null?void 0:s.accessToken)||"",{user_content:`userContent: ${y} ${a?x:""}`}),enabled:!1});function k(K){if(K.toLowerCase().includes("bar"))f("bar");else if(K.toLowerCase().includes("line"))f("line");else if(K.toLowerCase().includes("bubble"))f("bubble");else if(K.toLowerCase().includes("scatter"))f("scatter");else if(K.toLowerCase().includes("stacked"))f("stackedBar");else if(K.toLowerCase().includes("pie"))f("pie");else if(K.toLowerCase().includes("donut")||K.toLowerCase().includes("doughnut"))f("doughnut");else if(K.toLowerCase().includes("radar"))f("radar");else return f("bar"),!1;return!0}function A(){n&&(k(n)&&l(!0),P())}m.useEffect(()=>{i&&(A(),o(!1))},[i,o]);const L={fontFamily:"Arial, sans-serif",lineHeight:1.6,fontSize:15,padding:"5px",width:"100%"},F={fontFamily:"monospace",fontSize:14,lineHeight:1.6},B={fontFamily:"Arial, sans-serif",lineHeight:1.6,fontSize:15,padding:"2px 0",marginLeft:20,listStyleType:"disc"},V={p:({node:K,...Y})=>S.jsx("p",{style:L,...Y}),pre:({node:K,...Y})=>S.jsxs("pre",{className:" bg-muted/50 space-y-2 p-3 rounded-sm",style:F,children:[S.jsx("code",{className:" whitespace-normal",children:Y.children}),S.jsxs("div",{className:" flex justify-start gap-2",children:[S.jsx(ft,{onClick:H,size:"sm",variant:"outline",children:S.jsx(GE,{})}),S.jsx(ft,{onClick:$=>{const X=H($);X&&(t(!1),c(X),d(!0))},size:"sm",variant:"outline",children:S.jsx(Uj,{})})]})]}),li:({node:K,...Y})=>S.jsx("li",{style:B,...Y})};function H(K){const Y=K.currentTarget.closest("pre");if(!Y)return;const $=Y.textContent||Y.innerText;return navigator.clipboard.writeText($).then(()=>console.log("Text copied to clipboard")).catch(X=>console.error("Error in copying text: ",X)),$}return S.jsxs(ZM,{open:e,onOpenChange:t,children:[S.jsx(JM,{asChild:!0,children:S.jsx(ft,{size:"sm",className:"",variant:"outline",children:S.jsx(KB,{strokeWidth:1.5,size:18})})}),S.jsxs(Ty,{className:"sm:max-w-[425px] md:min-w-[625px] md:max-h-[625px] flex flex-col justify-between overflow-auto",children:[S.jsxs(Ay,{children:[S.jsx(Iy,{children:"Ask"}),S.jsx(Ry,{children:"Need assistance with SQL queries? Feel free to ask me any question!"})]}),S.jsx(El,{className:"h-[625px] w-full border-t ",children:(!_||!C)&&S.jsx(kne,{className:" pl-1 pr-3 py-1 w-full xbg-red-100 overflow-auto ",components:V,children:w==null?void 0:w.response})}),S.jsxs("div",{children:[S.jsx(Lc,{className:Oe(" invisible h-1 w-full animate-pulse",{visible:_||C})}),S.jsxs("div",{className:" border rounded-md flex items-center w-full",children:[S.jsx(Ny,{onKeyDown:K=>{K.key==="Enter"&&!K.shiftKey&&(K.preventDefault(),r(""),A())},placeholder:"Type something...",onFocus:K=>{const Y=K.target,$=Y.value.length;Y.setSelectionRange($,$)},className:" border-none resize-none min-h-7 max-h-10 focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",value:n,onChange:K=>r(K.target.value)})," ",S.jsx(ft,{className:"h-8",size:"sm",variant:"ghost",onClick:A,children:!_&&!C?S.jsx(Wj,{}):S.jsx(ku,{className:" w-4 h-4 animate-spin mr-2 text-foreground/50"})})]})]})]})]})}function Ane(){const{theme:e}=bm(),t=m.useRef(),n=m.useRef(),[r,i]=m.useState(!1),[o,s]=m.useState(!1),[a,l]=m.useState(""),[c,d]=m.useState(!1);m.useState("");const f=xe(W=>W.authToken),g=_e(W=>W.card),p=xe(W=>W.theme),v=_e(W=>W.selectedConnectionId),y=_e(W=>W.selectedDatabaseName),x=_e(W=>W.selectedSchemaName),w=_e(W=>W.selectedTableName),_=_e(W=>W.actions.setCardSql),C=_e(W=>W.card.sql),O=_e(W=>W.selectedConnectionId),P=_e(W=>W.filterValues),k=_e(W=>W.applyFilters),A=_e(W=>W.actions.setCardCustomCfg),L=_e(W=>W.actions.setFilterValues),F=_e(W=>W.onSave),B=_e(W=>W.actions.setApplyFilters),V=_e(W=>W.onClose),H=_e(W=>W.actions.setCardData),K=_e(W=>W.actions.setSqlGen),Y=_e(W=>W.runSql),$=_e(W=>W.actions.setRunSql),X=_e(W=>W.actions.setIsSqlRunning),{data:j,isLoading:ne,isFetching:se,isSuccess:D,isError:q,error:re,status:R,refetch:te}=Sr({queryKey:[C],queryFn:()=>Ts("https://semaphor.cloud/api/v1/query",(f==null?void 0:f.accessToken)||"",{connection_id:O,sql:C,active_filters:k?P:[]}),enabled:!1,retry:!1});m.useEffect(()=>{j&&(console.log("queryData",j),H(j.records))},[j,H]),m.useEffect(()=>{Y&&(te(),$(!1))},[Y,te,$]),m.useEffect(()=>{(ne||se)&&X(!0),(q||D)&&X(!1)},[ne,se,q,D,X]);function ge(){_(""),H([]),K({}),A("")}const pe=W=>{n.current=W};function de(){if(C&&!C.includes("{{")){const W=wQ(C);_(W),F==null||F({...g,sql:W,lastSelectedSchema:x,lastSelectedDatabase:y,lastSelectedTable:w,connectionId:v})}else F==null||F(g)}function ie(){V==null||V()}m.useEffect(()=>{const W=t.current,be=n.current;if(W){const oe=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",Te=p==="system"?oe:p;W.editor.defineTheme("default",{base:Te==="light"?"vs":"vs-dark",inherit:!0,rules:[],colors:{"editor.background":Te==="light"?"#ffffff":"#020817"}}),W.editor.setTheme("default")}return be&&W&&be.addCommand(W.KeyMod.Shift|W.KeyCode.Enter,function(){return console.log("Executing query..."),te(),!1}),()=>{}},[e,p,t.current]);function J(W){t.current=W}return S.jsxs("section",{className:"grow h-full flex flex-col justify-end pt-8 pb-4 ",children:[S.jsxs("div",{className:"w-full h-full grow flex relative justify-between ",children:[S.jsx("div",{className:`flex ${r?"w-2/3":"w-[95%]"} h-full xbg-red-100 p-1`,children:S.jsx(_y,{theme:"default",onChange:W=>{_(W),console.log(W)},value:C,options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"sql",defaultValue:"SELECT * FROM table",beforeMount:J,onMount:pe})}),r&&S.jsx("div",{className:"xbg-red-200 p-1 w-1/3 text-xs relative overflow-hidden xbg-yellow-100 ",children:S.jsxs("div",{className:"max-h-[250px] overflow-y-auto ",children:[S.jsxs("div",{className:"flex gap-2 items-center",children:[S.jsx(VQ,{checked:k,onCheckedChange:()=>B(!k),text:"Apply Filters"}),S.jsx(HQ,{})]}),S.jsx(_y,{theme:"default",onChange:W=>{if(W)try{JSON.parse(W),L(JSON.parse(W))}catch{}},defaultLanguage:"json",className:"h-[250px] overflow-y-auto mt-1",value:JSON.stringify(P,null,2),options:{readOnly:!0,minimap:{enabled:!1},lineNumbers:"off",glyphMargin:!1,wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:12,renderLineHighlight:"none"}})]})}),P&&r&&S.jsx(xu,{onClick:()=>i(!1),className:"absolute right-6 top-1 w-3 h-3 text-foreground/50 hover:text-foreground hover:cursor-pointer"}),P&&!r&&S.jsx(F2,{onClick:()=>i(!0),className:Oe("absolute right-6 top-1 w-3 h-3 text-foreground/50 hover:text-foreground hover:cursor-pointer",{"text-red-800 font-bold":k})})]}),S.jsxs("div",{className:" flex grow pl-8 pr-6 gap-2 justify-between item-center",children:[S.jsxs("div",{className:"flex grow gap-2 items-center",children:[S.jsxs(ft,{disabled:ne||se,onClick:()=>{te()},className:" shrink-0",size:"sm",variant:"outline",children:[(ne||se)&&S.jsx(ku,{className:"w-4 h-4 mr-2 animate-spin text-foreground/50"}),"Run"]}),q&&S.jsx(IQ,{error:re.message}),S.jsx(ft,{onClick:ge,className:"",size:"sm",variant:"outline",children:"Clear"}),S.jsx(Lp,{value:a,placeholder:"Type something...",onChange:W=>{l(W.target.value)},onKeyDown:W=>{W.key==="Enter"&&(W.preventDefault(),console.log("enter pressed"),d(!0),s(!0))},className:" bg-muted border-none h-9 focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0"}),S.jsx(Tne,{open:o,setOpen:s,userInput:a,triggerAIRun:c,setTriggerAIRun:d,setUserInput:W=>l(W)})]}),S.jsxs("div",{className:"flex gap-2 items-end ",children:[S.jsx(ft,{onClick:de,className:" w-full",size:"sm",variant:"outline",children:"Update"}),S.jsx(ft,{onClick:ie,className:" w-full",size:"sm",variant:"outline",children:"Close"})]})]})]})}const TT="Switch",[Ine,ffe]=Pn(TT),[Rne,Nne]=Ine(TT),Lne=m.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:i,defaultChecked:o,required:s,disabled:a,value:l="on",onCheckedChange:c,...d}=e,[f,g]=m.useState(null),p=et(t,_=>g(_)),v=m.useRef(!1),y=f?!!f.closest("form"):!0,[x=!1,w]=Qn({prop:i,defaultProp:o,onChange:c});return m.createElement(Rne,{scope:n,checked:x,disabled:a},m.createElement(Be.button,le({type:"button",role:"switch","aria-checked":x,"aria-required":s,"data-state":AT(x),"data-disabled":a?"":void 0,disabled:a,value:l},d,{ref:p,onClick:Ce(e.onClick,_=>{w(C=>!C),y&&(v.current=_.isPropagationStopped(),v.current||_.stopPropagation())})})),y&&m.createElement(jne,{control:f,bubbles:!v.current,name:r,value:l,checked:x,required:s,disabled:a,style:{transform:"translateX(-100%)"}}))}),$ne="SwitchThumb",Fne=m.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,i=Nne($ne,n);return m.createElement(Be.span,le({"data-state":AT(i.checked),"data-disabled":i.disabled?"":void 0},r,{ref:t}))}),jne=e=>{const{control:t,checked:n,bubbles:r=!0,...i}=e,o=m.useRef(null),s=yp(n),a=Oh(t);return m.useEffect(()=>{const l=o.current,c=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(c,"checked").set;if(s!==n&&f){const g=new Event("click",{bubbles:r});f.call(l,n),l.dispatchEvent(g)}},[s,n,r]),m.createElement("input",le({type:"checkbox","aria-hidden":!0,defaultChecked:n},i,{tabIndex:-1,ref:o,style:{...e.style,...a,position:"absolute",pointerEvents:"none",opacity:0,margin:0}}))};function AT(e){return e?"checked":"unchecked"}const IT=Lne,zne=Fne,RT=ue.forwardRef(({className:e,...t},n)=>S.jsx(IT,{className:Oe("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...t,ref:n,children:S.jsx(zne,{className:Oe("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));RT.displayName=IT.displayName;function NT({className:e,...t}){const[n,r]=m.useState(0),i=xe(l=>l.themeStyle),o=_e(l=>l.card),s=_e(l=>l.actions.setCard);if(m.useEffect(()=>{r(n+1)},[o.data,o.type,o.cfg,o.customCfg,i]),!o.id)return null;let a;return o.data&&o.data.length>0&&(a=wb({data:o.data,cardType:o.type,cfg:o.cfg,customCfg:o.customCfg})),S.jsxs(_v,{role:"editor-visual-card",className:Oe(" relative h-full flex flex-col rounded-none",e),...t,children:[S.jsxs(Sv,{children:[S.jsx(Wc,{text:o.title,onSave:l=>s({...o,title:l}),children:S.jsx(Cv,{className:"text-base",children:o.title})}),S.jsx(Wc,{text:o.description||"",onSave:l=>s({...o,description:l}),children:S.jsxs(Ev,{children:[" ",o.description]})})]}),S.jsxs(Pv,{className:"flex flex-col pb-3 grow",children:[o.type!=="table"&&a&&S.jsx(qE,{cfg:a},n),o.type==="table"&&o.data&&o.data.length>0&&S.jsx(rP,{children:S.jsx(t0,{data:o==null?void 0:o.data})})]})]})}function Bne(){const[e,t]=m.useState(!1),[n,r]=m.useState(""),[i,o]=m.useState(""),[s,a]=m.useState(""),l=_e(x=>x.card),c=_e(x=>x.card.customCfg),d=_e(x=>x.actions.setCardCustomCfg);function f(x){var C,O;const w={...x,data:{...x==null?void 0:x.data,datasets:(O=(C=x==null?void 0:x.data)==null?void 0:C.datasets)==null?void 0:O.map(P=>({...P,data:[]}))}};return JSON.stringify(w,null,1)}function g(){if(!l.data||l.data.length===0)return;const x=wb({data:l.data,cardType:l.type,cfg:l.cfg});x&&(r(JSON.stringify(x,null,1)),c&&o(JSON.stringify(c,null,1)))}function p(){if(i)try{const x=JSON.parse(i);return x?(d(x),a(""),o(""),x):void 0}catch(x){console.log(x),a("Invalid JSON")}}function v(){o(""),d(null)}function y(){let x;if(c){const w=Ns.cloneDeep(l.cfg),_=Ns.merge(w,c);return x=f(_),x}return n?(x=f(JSON.parse(n)),x):""}return S.jsxs(ZM,{open:e,onOpenChange:t,children:[S.jsx(JM,{asChild:!0,children:S.jsx(ft,{onClick:g,className:`h-7 ${c&&"border-foreground/50 dark:border-foreground/70"}`,size:"sm",variant:"outline",children:c?"Custom Config":"Customize"})}),S.jsx(Ty,{className:" sm:max-w-[425px] md:min-w-[600px] md:min-h-[700px] lg:min-w-[800px] xl:min-w-[1000px]",children:S.jsxs("div",{className:"bg-red-x100 flex flex-col gap-2 justify-between",children:[S.jsxs(Ay,{className:"",children:[S.jsx(Iy,{children:"Customize Chart"}),S.jsxs(Ry,{children:["See the configuration options and documentation",S.jsx("a",{target:"_blank",className:"ml-1 underline text-blue-500 ",href:"https://www.chartjs.org/docs/latest/samples/bar/vertical.html",children:"here."})]})]}),S.jsxs("div",{className:"grow flex flex-wrap gap-2",children:[S.jsx(NT,{className:"flex-1 rounded shadow-none"}),S.jsxs(t_,{defaultValue:"custom-config",className:" flex flex-col flex-1",children:[S.jsxs(n_,{className:" justify-start border rounded-sm rounded-b-none border-b-0 ",children:[S.jsxs(Pm,{value:"custom-config",children:[c&&S.jsx(UE,{className:"w-5 h-5 mr-1 text-green-600"}),c?"Custom Config":"Default Config"]}),S.jsx(Pm,{className:"",value:"output",children:"Output"})]}),S.jsx(uf,{className:" grow mt-0 bg-red-x p-2 border border-t-0 rounded-b ",value:"output",children:S.jsx(Ny,{disabled:!0,value:n,className:" border-none resize-none font-mono h-full focus-visible:ring-0 focus-visible:ring-offset-0"})}),S.jsx(uf,{className:"grow mt-0 border border-t-0 rounded-b ",value:"custom-config",children:S.jsx(_y,{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:y(),onChange:x=>o(x)})})]})]}),S.jsxs(tD,{className:"flex items-center",children:[S.jsx(Ml,{className:"text-red-500 mr-2",children:s}),S.jsx(ft,{disabled:!c,onClick:v,variant:"outline",children:"Reset"}),S.jsx(ft,{onClick:p,variant:"outline",children:"Apply"}),S.jsx(ft,{onClick:()=>t(!1),variant:"outline",children:"Close"})]})]})})]})}var LT={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},$T=m.createContext&&m.createContext(LT),Vne=["attr","size","title"];function Hne(e,t){if(e==null)return{};var n=Wne(e,t),r,i;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(i=0;i<o.length;i++)r=o[i],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function Wne(e,t){if(e==null)return{};var n={},r=Object.keys(e),i,o;for(o=0;o<r.length;o++)i=r[o],!(t.indexOf(i)>=0)&&(n[i]=e[i]);return n}function Yp(){return Yp=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Yp.apply(this,arguments)}function FT(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function Kp(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?FT(Object(n),!0).forEach(function(r){qne(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):FT(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function qne(e,t,n){return t=Une(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Une(e){var t=Gne(e,"string");return typeof t=="symbol"?t:String(t)}function Gne(e,t){if(typeof e!="object"||e===null)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function jT(e){return e&&e.map((t,n)=>m.createElement(t.tag,Kp({key:n},t.attr),jT(t.child)))}function ud(e){return t=>m.createElement(Yne,Yp({attr:Kp({},e.attr)},t),jT(e.child))}function Yne(e){var t=n=>{var{attr:r,size:i,title:o}=e,s=Hne(e,Vne),a=i||n.size||"1em",l;return n.className&&(l=n.className),e.className&&(l=(l?l+" ":"")+e.className),m.createElement("svg",Yp({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},n.attr,r,s,{className:l,style:Kp(Kp({color:e.color||n.color},n.style),e.style),height:a,width:a,xmlns:"http://www.w3.org/2000/svg"}),o&&m.createElement("title",null,o),e.children)};return $T!==void 0?m.createElement($T.Consumer,null,n=>t(n)):t(LT)}function zT(e){return ud({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 BT(e){return ud({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 VT(e){return ud({tag:"svg",attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M137,28.05a11.94,11.94,0,0,0-9.12,3.08A12.09,12.09,0,0,0,124,40V80.67a11.88,11.88,0,0,0,9.9,11.81,36,36,0,1,1-41.85,37.4c-.47-9.14,1.47-16.8,5.75-22.79h0a11.89,11.89,0,0,0-1.3-15.35L68.87,63.51a12,12,0,0,0-17.74.83A99.6,99.6,0,0,0,57.79,199.2,99.24,99.24,0,0,0,128,228h1.43A100.29,100.29,0,0,0,228,129.42C228.72,77.21,188.76,32.68,137,28.05ZM57.28,69.46A4,4,0,0,1,60.2,68h.19a3.91,3.91,0,0,1,2.79,1.14L90.81,97.36a3.93,3.93,0,0,1,.48,5.08A40.47,40.47,0,0,0,84.08,124h-48A90.36,90.36,0,0,1,57.28,69.46ZM36.09,132H84.18A44,44,0,0,0,124,171.81V219.9A92,92,0,0,1,36.09,132ZM193,193a91.43,91.43,0,0,1-61,26.92V171.82a43.51,43.51,0,0,0,26-11.63,44,44,0,0,0-22.79-75.6A4,4,0,0,1,132,80.67V40a4,4,0,0,1,1.31-3,3.89,3.89,0,0,1,3-1c47.59,4.26,84.34,45.24,83.67,93.29A91.42,91.42,0,0,1,193,193Z"},child:[]}]})(e)}function HT(e){return ud({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 WT(e){return ud({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 Kne(){const[e,t]=m.useState(!1),n=_e(s=>s.card.type),r=_e(s=>s.actions.setCardType),i=_e(s=>s.actions.setCardCustomCfg);function o(s){r(s),i(null),t(!1)}return S.jsxs(dp,{open:e,onOpenChange:t,children:[S.jsx(fp,{asChild:!0,children:S.jsx(ft,{className:"h-7 px-2",variant:"outline",children:S.jsx(Xne,{className:"h-4 w-4",chartType:n})})}),S.jsx(Wu,{className:"w-50",children:S.jsxs("div",{className:"grid grid-cols-3 place-items-center ",children:[S.jsx(ft,{onClick:()=>o("bar"),className:"font-normal",variant:"ghost",children:S.jsx(N2,{strokeWidth:1})}),S.jsx(ft,{onClick:()=>o("line"),variant:"ghost",children:S.jsx(j2,{strokeWidth:1})}),S.jsx(ft,{onClick:()=>o("stackedBar"),variant:"ghost",children:S.jsx(WT,{className:"h-6 w-6 text-foreground/50 ",strokeWidth:0})}),S.jsx(ft,{onClick:()=>o("scatter"),variant:"ghost",children:S.jsx(B2,{strokeWidth:1})}),S.jsx(ft,{onClick:()=>o("bubble"),variant:"ghost",children:S.jsx(HT,{strokeWidth:2})}),S.jsx(ft,{onClick:()=>o("pie"),variant:"ghost",children:S.jsx(z2,{strokeWidth:1})}),S.jsx(ft,{onClick:()=>o("doughnut"),variant:"ghost",children:S.jsx(VT,{className:"h-7 w-7",strokeWidth:.5})}),S.jsx(ft,{onClick:()=>o("radar"),variant:"ghost",children:S.jsx(zT,{className:"h-6 w-6 text-foreground/50 font-extralight",strokeWidth:.5})}),S.jsx(ft,{onClick:()=>o("polarArea"),variant:"ghost",children:S.jsx(BT,{className:"h-6 w-6 text-foreground/50",strokeWidth:1})}),S.jsx(ft,{onClick:()=>o("table"),variant:"ghost",children:S.jsx(jb,{className:"h-6 w-6 text-foreground/90",strokeWidth:1})})]})})]})}function Xne({chartType:e,className:t}){switch(e){case"bar":return S.jsx(N2,{className:t});case"line":return S.jsx(j2,{className:t});case"pie":return S.jsx(z2,{className:t});case"radar":return S.jsx(zT,{className:t});case"scatter":return S.jsx(B2,{className:t});case"bubble":return S.jsx(HT,{className:t});case"doughnut":return S.jsx(VT,{className:t});case"stackedBar":return S.jsx(WT,{className:"h-5 w-5 text-foreground/50 ",strokeWidth:0});case"polarArea":return S.jsx(BT,{className:t});default:return S.jsx(jb,{className:t})}}function Qne(){const e=_e(n=>n.card.refreshInterval),t=_e(n=>n.actions.setCardRefreshInterval);return S.jsxs(dp,{children:[S.jsx(fp,{asChild:!0,children:S.jsx(ft,{className:"h-7",variant:"outline",children:"Realtime"})}),S.jsx(Wu,{className:"w-[200px]",children:S.jsx("div",{className:"grid gap-4",children:S.jsx("div",{className:"grid gap-2",children:S.jsxs("div",{className:"grid grid-cols-5 items-center gap-1",children:[S.jsx(Ml,{className:"col-span-3",htmlFor:"width",children:"Refresh Every"}),S.jsx(Lp,{value:e||"",onChange:n=>t(n.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 qT(){const e=_e(r=>r.card),t=_e(r=>r.isShowingVisual),n=_e(r=>r.isSqlRunning);return _e(r=>r.onSave),_e(r=>r.onClose),_e(r=>r.actions.setCardSql),_e(r=>r.actions.setCardType),_e(r=>r.actions.setSqlGen),S.jsxs("div",{className:" h-full relative flex flex-col",children:[n&&S.jsx(ku,{className:" w-10 h-10 z-10 absolute m-auto left-0 right-0 top-0 bottom-0 animate-spin text-foreground/10 "}),S.jsxs("div",{className:" h-10 px-6 pt-6 bg-red-x100 mb-0 z-10 right-0 flex justify-end items-center gap-2",children:[t&&S.jsxs("div",{className:"bg-red-x00 flex grow gap-2",children:[S.jsx(Kne,{}),S.jsx(Bne,{}),S.jsx(Qne,{})]}),S.jsx(Zne,{})]}),t?S.jsx(NT,{className:"grow border-none shadow-none "}):S.jsx("div",{className:"w-full mt-4 px-6 bg-red-x00 grow border-none shadow-none overflow-y-auto ",children:e.data&&e.data.length>0&&S.jsx(t0,{data:e.data})})]})}function Zne(){const e=_e(n=>n.isShowingVisual),t=_e(n=>n.actions.setIsShowingVisual);return S.jsxs("div",{className:" flex items-center space-x-2",children:[S.jsx(Ml,{htmlFor:"visualize",children:"Chart"}),S.jsx(RT,{checked:e,onCheckedChange:()=>t(!e),id:"visualize",className:"data-[state=checked]:bg-foreground/50"})]})}const UT="Collapsible",[Jne,GT]=Pn(UT),[ere,mx]=Jne(UT),tre=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:i,disabled:o,onOpenChange:s,...a}=e,[l=!1,c]=Qn({prop:r,defaultProp:i,onChange:s});return m.createElement(ere,{scope:n,disabled:o,contentId:or(),open:l,onOpenToggle:m.useCallback(()=>c(d=>!d),[c])},m.createElement(Be.div,le({"data-state":vx(l),"data-disabled":o?"":void 0},a,{ref:t})))}),nre="CollapsibleTrigger",rre=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,i=mx(nre,n);return m.createElement(Be.button,le({type:"button","aria-controls":i.contentId,"aria-expanded":i.open||!1,"data-state":vx(i.open),"data-disabled":i.disabled?"":void 0,disabled:i.disabled},r,{ref:t,onClick:Ce(e.onClick,i.onOpenToggle)}))}),YT="CollapsibleContent",ire=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,i=mx(YT,e.__scopeCollapsible);return m.createElement(vn,{present:n||i.open},({present:o})=>m.createElement(ore,le({},r,{ref:t,present:o})))}),ore=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:i,...o}=e,s=mx(YT,n),[a,l]=m.useState(r),c=m.useRef(null),d=et(t,c),f=m.useRef(0),g=f.current,p=m.useRef(0),v=p.current,y=s.open||a,x=m.useRef(y),w=m.useRef();return m.useEffect(()=>{const _=requestAnimationFrame(()=>x.current=!1);return()=>cancelAnimationFrame(_)},[]),Vn(()=>{const _=c.current;if(_){w.current=w.current||{transitionDuration:_.style.transitionDuration,animationName:_.style.animationName},_.style.transitionDuration="0s",_.style.animationName="none";const C=_.getBoundingClientRect();f.current=C.height,p.current=C.width,x.current||(_.style.transitionDuration=w.current.transitionDuration,_.style.animationName=w.current.animationName),l(r)}},[s.open,r]),m.createElement(Be.div,le({"data-state":vx(s.open),"data-disabled":s.disabled?"":void 0,id:s.contentId,hidden:!y},o,{ref:d,style:{"--radix-collapsible-content-height":g?`${g}px`:void 0,"--radix-collapsible-content-width":v?`${v}px`:void 0,...e.style}}),y&&i)});function vx(e){return e?"open":"closed"}const sre=tre,are=rre,lre=ire,ls="Accordion",cre=["Home","End","ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],[bx,ure,dre]=lf(ls),[Xp,hfe]=Pn(ls,[dre,GT]),yx=GT(),KT=m.forwardRef((e,t)=>{const{type:n,...r}=e,i=r,o=r;return m.createElement(bx.Provider,{scope:e.__scopeAccordion},n==="multiple"?m.createElement(gre,le({},o,{ref:t})):m.createElement(pre,le({},i,{ref:t})))});KT.propTypes={type(e){const t=e.value||e.defaultValue;return e.type&&!["single","multiple"].includes(e.type)?new Error("Invalid prop `type` supplied to `Accordion`. Expected one of `single | multiple`."):e.type==="multiple"&&typeof t=="string"?new Error("Invalid prop `type` supplied to `Accordion`. Expected `single` when `defaultValue` or `value` is type `string`."):e.type==="single"&&Array.isArray(t)?new Error("Invalid prop `type` supplied to `Accordion`. Expected `multiple` when `defaultValue` or `value` is type `string[]`."):null}};const[XT,fre]=Xp(ls),[QT,hre]=Xp(ls,{collapsible:!1}),pre=m.forwardRef((e,t)=>{const{value:n,defaultValue:r,onValueChange:i=()=>{},collapsible:o=!1,...s}=e,[a,l]=Qn({prop:n,defaultProp:r,onChange:i});return m.createElement(XT,{scope:e.__scopeAccordion,value:a?[a]:[],onItemOpen:l,onItemClose:m.useCallback(()=>o&&l(""),[o,l])},m.createElement(QT,{scope:e.__scopeAccordion,collapsible:o},m.createElement(ZT,le({},s,{ref:t}))))}),gre=m.forwardRef((e,t)=>{const{value:n,defaultValue:r,onValueChange:i=()=>{},...o}=e,[s=[],a]=Qn({prop:n,defaultProp:r,onChange:i}),l=m.useCallback(d=>a((f=[])=>[...f,d]),[a]),c=m.useCallback(d=>a((f=[])=>f.filter(g=>g!==d)),[a]);return m.createElement(XT,{scope:e.__scopeAccordion,value:s,onItemOpen:l,onItemClose:c},m.createElement(QT,{scope:e.__scopeAccordion,collapsible:!0},m.createElement(ZT,le({},o,{ref:t}))))}),[mre,Qp]=Xp(ls),ZT=m.forwardRef((e,t)=>{const{__scopeAccordion:n,disabled:r,dir:i,orientation:o="vertical",...s}=e,a=m.useRef(null),l=et(a,t),c=ure(n),f=Ls(i)==="ltr",g=Ce(e.onKeyDown,p=>{var v;if(!cre.includes(p.key))return;const y=p.target,x=c().filter(F=>{var B;return!((B=F.ref.current)!==null&&B!==void 0&&B.disabled)}),w=x.findIndex(F=>F.ref.current===y),_=x.length;if(w===-1)return;p.preventDefault();let C=w;const O=0,P=_-1,k=()=>{C=w+1,C>P&&(C=O)},A=()=>{C=w-1,C<O&&(C=P)};switch(p.key){case"Home":C=O;break;case"End":C=P;break;case"ArrowRight":o==="horizontal"&&(f?k():A());break;case"ArrowDown":o==="vertical"&&k();break;case"ArrowLeft":o==="horizontal"&&(f?A():k());break;case"ArrowUp":o==="vertical"&&A();break}const L=C%_;(v=x[L].ref.current)===null||v===void 0||v.focus()});return m.createElement(mre,{scope:n,disabled:r,direction:i,orientation:o},m.createElement(bx.Slot,{scope:n},m.createElement(Be.div,le({},s,{"data-orientation":o,ref:l,onKeyDown:r?void 0:g}))))}),xx="AccordionItem",[vre,wx]=Xp(xx),bre=m.forwardRef((e,t)=>{const{__scopeAccordion:n,value:r,...i}=e,o=Qp(xx,n),s=fre(xx,n),a=yx(n),l=or(),c=r&&s.value.includes(r)||!1,d=o.disabled||e.disabled;return m.createElement(vre,{scope:n,open:c,disabled:d,triggerId:l},m.createElement(sre,le({"data-orientation":o.orientation,"data-state":eA(c)},a,i,{ref:t,disabled:d,open:c,onOpenChange:f=>{f?s.onItemOpen(r):s.onItemClose(r)}})))}),yre="AccordionHeader",xre=m.forwardRef((e,t)=>{const{__scopeAccordion:n,...r}=e,i=Qp(ls,n),o=wx(yre,n);return m.createElement(Be.h3,le({"data-orientation":i.orientation,"data-state":eA(o.open),"data-disabled":o.disabled?"":void 0},r,{ref:t}))}),JT="AccordionTrigger",wre=m.forwardRef((e,t)=>{const{__scopeAccordion:n,...r}=e,i=Qp(ls,n),o=wx(JT,n),s=hre(JT,n),a=yx(n);return m.createElement(bx.ItemSlot,{scope:n},m.createElement(are,le({"aria-disabled":o.open&&!s.collapsible||void 0,"data-orientation":i.orientation,id:o.triggerId},a,r,{ref:t})))}),_re="AccordionContent",Sre=m.forwardRef((e,t)=>{const{__scopeAccordion:n,...r}=e,i=Qp(ls,n),o=wx(_re,n),s=yx(n);return m.createElement(lre,le({role:"region","aria-labelledby":o.triggerId,"data-orientation":i.orientation},s,r,{ref:t,style:{"--radix-accordion-content-height":"var(--radix-collapsible-content-height)","--radix-accordion-content-width":"var(--radix-collapsible-content-width)",...e.style}}))});function eA(e){return e?"open":"closed"}const Cre=KT,Ere=bre,Pre=xre,tA=wre,nA=Sre,rA=Cre,cs=ue.forwardRef(({className:e,...t},n)=>S.jsx(Ere,{ref:n,className:Oe("border-b",e),...t}));cs.displayName="AccordionItem";const us=ue.forwardRef(({className:e,children:t,...n},r)=>S.jsx(Pre,{className:"flex",children:S.jsxs(tA,{ref:r,className:Oe("flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180",e),...n,children:[t,S.jsx(Fb,{className:"h-4 w-4 shrink-0 transition-transform duration-200"})]})}));us.displayName=tA.displayName;const ds=ue.forwardRef(({className:e,children:t,...n},r)=>S.jsx(nA,{ref:r,className:"overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...n,children:S.jsx("div",{className:Oe("pb-4 pt-0",e),children:t})}));ds.displayName=nA.displayName;const iA="Radio",[Ore,oA]=Pn(iA),[kre,Mre]=Ore(iA),Dre=m.forwardRef((e,t)=>{const{__scopeRadio:n,name:r,checked:i=!1,required:o,disabled:s,value:a="on",onCheck:l,...c}=e,[d,f]=m.useState(null),g=et(t,y=>f(y)),p=m.useRef(!1),v=d?!!d.closest("form"):!0;return m.createElement(kre,{scope:n,checked:i,disabled:s},m.createElement(Be.button,le({type:"button",role:"radio","aria-checked":i,"data-state":sA(i),"data-disabled":s?"":void 0,disabled:s,value:a},c,{ref:g,onClick:Ce(e.onClick,y=>{i||l==null||l(),v&&(p.current=y.isPropagationStopped(),p.current||y.stopPropagation())})})),v&&m.createElement(Ire,{control:d,bubbles:!p.current,name:r,value:a,checked:i,required:o,disabled:s,style:{transform:"translateX(-100%)"}}))}),Tre="RadioIndicator",Are=m.forwardRef((e,t)=>{const{__scopeRadio:n,forceMount:r,...i}=e,o=Mre(Tre,n);return m.createElement(vn,{present:r||o.checked},m.createElement(Be.span,le({"data-state":sA(o.checked),"data-disabled":o.disabled?"":void 0},i,{ref:t})))}),Ire=e=>{const{control:t,checked:n,bubbles:r=!0,...i}=e,o=m.useRef(null),s=yp(n),a=Oh(t);return m.useEffect(()=>{const l=o.current,c=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(c,"checked").set;if(s!==n&&f){const g=new Event("click",{bubbles:r});f.call(l,n),l.dispatchEvent(g)}},[s,n,r]),m.createElement("input",le({type:"radio","aria-hidden":!0,defaultChecked:n},i,{tabIndex:-1,ref:o,style:{...e.style,...a,position:"absolute",pointerEvents:"none",opacity:0,margin:0}}))};function sA(e){return e?"checked":"unchecked"}const Rre=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],aA="RadioGroup",[Nre,pfe]=Pn(aA,[nl,oA]),lA=nl(),cA=oA(),[Lre,$re]=Nre(aA),Fre=m.forwardRef((e,t)=>{const{__scopeRadioGroup:n,name:r,defaultValue:i,value:o,required:s=!1,disabled:a=!1,orientation:l,dir:c,loop:d=!0,onValueChange:f,...g}=e,p=lA(n),v=Ls(c),[y,x]=Qn({prop:o,defaultProp:i,onChange:f});return m.createElement(Lre,{scope:n,name:r,required:s,disabled:a,value:y,onValueChange:x},m.createElement(Sm,le({asChild:!0},p,{orientation:l,dir:v,loop:d}),m.createElement(Be.div,le({role:"radiogroup","aria-required":s,"aria-orientation":l,"data-disabled":a?"":void 0,dir:v},g,{ref:t}))))}),jre="RadioGroupItem",zre=m.forwardRef((e,t)=>{const{__scopeRadioGroup:n,disabled:r,...i}=e,o=$re(jre,n),s=o.disabled||r,a=lA(n),l=cA(n),c=m.useRef(null),d=et(t,c),f=o.value===i.value,g=m.useRef(!1);return m.useEffect(()=>{const p=y=>{Rre.includes(y.key)&&(g.current=!0)},v=()=>g.current=!1;return document.addEventListener("keydown",p),document.addEventListener("keyup",v),()=>{document.removeEventListener("keydown",p),document.removeEventListener("keyup",v)}},[]),m.createElement(Cm,le({asChild:!0},a,{focusable:!s,active:f}),m.createElement(Dre,le({disabled:s,required:o.required,checked:f},l,i,{name:o.name,ref:d,onCheck:()=>o.onValueChange(i.value),onKeyDown:Ce(p=>{p.key==="Enter"&&p.preventDefault()}),onFocus:Ce(i.onFocus,()=>{var p;g.current&&((p=c.current)===null||p===void 0||p.click())})})))}),Bre=m.forwardRef((e,t)=>{const{__scopeRadioGroup:n,...r}=e,i=cA(n);return m.createElement(Are,le({},i,r,{ref:t}))}),uA=Fre,dA=zre,Vre=Bre,fA=ue.forwardRef(({className:e,...t},n)=>S.jsx(uA,{className:Oe("grid gap-2",e),...t,ref:n}));fA.displayName=uA.displayName;const _x=ue.forwardRef(({className:e,...t},n)=>S.jsx(dA,{ref:n,className:Oe("aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:S.jsx(Vre,{className:"flex items-center justify-center",children:S.jsx($2,{className:"h-2.5 w-2.5 fill-current text-current"})})}));_x.displayName=dA.displayName;function hA(){var i;const e=_e(o=>o.card.cfg),t=_e(o=>o.actions.setCardCfg),n=(i=e==null?void 0:e.options)==null?void 0:i.indexAxis;function r(o){const s={...e,options:{...e==null?void 0:e.options,indexAxis:o}};t(s)}return S.jsxs("div",{children:[S.jsx("p",{className:"font-semibold",children:"Orientation"}),S.jsxs(fA,{value:n,onValueChange:r,className:"flex gap-3 mt-2 ",defaultValue:"x",children:[S.jsxs("div",{className:"flex items-center space-x-2",children:[S.jsx(_x,{value:"x",id:"r1"}),S.jsx("label",{className:"text-sm",htmlFor:"r1",children:"Vertical"})]}),S.jsxs("div",{className:"flex items-center space-x-2",children:[S.jsx(_x,{value:"y",id:"r2"}),S.jsx("label",{className:"text-sm",htmlFor:"r2",children:"Horizontal"})]})]})]})}function pA(){var r,i,o;const e=_e(s=>s.card.cfg),t=_e(s=>s.actions.setCardCfg);function n(s){var c;const a={datalabels:{display:s!=="none",align:s,anchor:s,clamp:!0}},l={...e,options:{...e==null?void 0:e.options,plugins:{...(c=e==null?void 0:e.options)==null?void 0:c.plugins,...a}}};t(l),console.log(s)}return S.jsxs(S.Fragment,{children:[S.jsx("label",{className:"font-medium",children:"Data Labels"}),S.jsxs(zk,{value:(o=(i=(r=e==null?void 0:e.options)==null?void 0:r.plugins)==null?void 0:i.datalabels)==null?void 0:o.anchor,onValueChange:n,defaultValue:"none",children:[S.jsx(py,{className:"w-[180px] mt-2 focus:ring-1 focus:ring-offset-0 h-7",children:S.jsx(Vk,{placeholder:"Select position"})}),S.jsx(gy,{children:S.jsxs(Bk,{children:[S.jsx(Cp,{children:"Data Labels"}),S.jsx(ba,{value:"none",children:"None"}),S.jsx(ba,{value:"start",children:"Start"}),S.jsx(ba,{value:"center",children:"Center"}),S.jsx(ba,{value:"end",children:"End"})]})})]})]})}function gA(){const e=_e(i=>i.card.preferences),t=_e(i=>i.actions.setCardPreferences),n=_e(i=>{var o;return(o=i.card.preferences)==null?void 0:o.filterOnClickField}),r=_e(i=>i.actions.setFilterOnClickField);return S.jsxs("div",{children:[S.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[S.jsx(ky,{checked:!!(e!=null&&e.filterOnClick),onCheckedChange:i=>{t({...e,filterOnClick:!!i})}}),S.jsx(Ml,{children:"Filter on click"})]}),(e==null?void 0:e.filterOnClick)===!0&&S.jsxs("div",{className:"flex gap-2 items-center",children:[S.jsx(Lp,{value:n||"",className:" h-7 font-mono text-xs focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",placeholder:"expression (optional)",onChange:i=>r(i.target.value)}),S.jsxs(Nb,{children:[S.jsx(D2,{children:S.jsx(YE,{className:"h-4 w-4 opacity-70"})}),S.jsx(Th,{children:S.jsxs("div",{className:"max-w-[200px]",children:["The x-axis expression of your query. Example:",S.jsx("div",{className:" mt-1 text-xs font-mono",children:"TO_CHAR(order_date, 'YYYY-MM')"})]})})]})]})]})}const Hre={datasets:[{type:"line",label:"Sum_sales",data:[]},{type:"bar",label:"Sum_profit",data:[]}]},Wre={datasets:[{fill:"origin",type:"line",label:"Sum_sales",data:[]}]};function qre(){const e=_e(t=>t.card.type);return S.jsxs("div",{className:"p-6 space-y-6",children:[S.jsx(rA,{className:" ",type:"single",collapsible:!0,children:Ure(e)}),S.jsx("section",{className:"",children:["line","bar"].includes(e)&&S.jsx(hA,{})}),S.jsx("div",{children:S.jsx(pA,{})}),S.jsx("div",{children:S.jsx(gA,{})})]})}function Ure(e){if(["line","bar"].includes(e))return S.jsxs(S.Fragment,{children:[S.jsxs(cs,{className:"border-muted",value:"item-1",children:[S.jsx(us,{className:" font-normal",children:S.jsxs("p",{children:["Create a ",S.jsx("span",{children:"chart"})," query"]})}),S.jsxs(ds,{className:" ",children:[S.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"}),S.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs",children:[S.jsx("li",{children:"X-axis - Category (ex. city)"}),S.jsx("li",{children:"Y-axis - Number (ex. population)"})]})]})]}),S.jsxs(cs,{className:"border-muted",value:"item-2",children:[S.jsx(us,{className:" font-normal",children:"Create a mixed chart"}),S.jsxs(ds,{className:" text-xs space-y-2",children:[S.jsxs("p",{children:["Click ",S.jsx("b",{children:"Customize"})," and change the `type` property in the dataset."]}),S.jsx("pre",{children:JSON.stringify(Hre,null,2)})]})]}),S.jsxs(cs,{className:"border-muted",value:"item-3",children:[S.jsx(us,{className:" font-normal",children:"Create an area chart"}),S.jsxs(ds,{className:" text-xs space-y-2",children:[S.jsxs("p",{children:["Click ",S.jsx("b",{children:"Customize"})," and add `fill` property to the dataset. See",S.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."]}),S.jsx("pre",{children:JSON.stringify(Wre,null,2)})]})]})]});if(e==="bubble")return S.jsx(S.Fragment,{children:S.jsxs(cs,{className:"border-muted",value:"item-1",children:[S.jsx(us,{className:" font-normal",children:S.jsxs("p",{children:["How to create a ",S.jsx("span",{children:e})," chart query?"]})}),S.jsxs(ds,{className:" ",children:[S.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"}),S.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs",children:[S.jsx("li",{children:"Label - Category (ex. city)"}),S.jsx("li",{children:"Bubble Group (opt) - Category (ex. state)"}),S.jsx("li",{children:"X-axis - Number (ex. avg. age)"}),S.jsx("li",{children:"Y-axis - Number (ex. avg. weight)"}),S.jsx("li",{children:"Radius - Number (ex. population)"})]})]})]})});if(e==="scatter")return S.jsx(S.Fragment,{children:S.jsxs(cs,{value:"item-1",children:[S.jsx(us,{className:" font-normal",children:S.jsxs("p",{children:["How to create a ",S.jsx("span",{children:e})," chart query?"]})}),S.jsxs(ds,{className:" ",children:[S.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"}),S.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs",children:[S.jsx("li",{children:"Label - Category (ex. city)"}),S.jsx("li",{children:"Group (opt) - Category (ex. state)"}),S.jsx("li",{children:"X-axis - Number (ex. avg. age)"}),S.jsx("li",{children:"Y-axis - Number (ex. avg. weight)"})]})]})]})});if(["pie","doughnut","polarArea"].includes(e))return S.jsx(S.Fragment,{children:S.jsxs(cs,{value:"item-1",children:[S.jsx(us,{className:" font-normal",children:S.jsxs("p",{children:["How to create a"," ",S.jsxs("span",{children:[e==="polarArea"?"polar":e," "]})," ","chart query?"]})}),S.jsxs(ds,{className:" ",children:[S.jsx("div",{className:"bg-muted px-2 py-1 rounded font-mono font-semibold text-xs",children:"SELECT label, measure FROM table"}),S.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs",children:[S.jsx("li",{children:"Label - Category (ex. city)"}),S.jsx("li",{children:"Measure - Number (ex. population)"})]})]})]})})}function Gre(){return S.jsxs("div",{className:"px-6 py-2 space-y-6",children:[S.jsx(rA,{className:" ",type:"single",collapsible:!0,children:S.jsxs(cs,{className:"border-muted",value:"item-1",children:[S.jsx(us,{className:" font-normal",children:"Stacked chart query?"}),S.jsxs(ds,{className:" ",children:[S.jsx("div",{className:"bg-muted px-2 py-1 rounded font-mono font-semibold text-xs",children:"SELECT x-axis, stack-by, y-axis FROM table"}),S.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs",children:[S.jsx("li",{children:"X-axis - Category (ex. country)"}),S.jsx("li",{children:"Stack by - Category (ex. city)"}),S.jsx("li",{children:"Y-axis - Number (ex. population)"})]})]})]})}),S.jsx("section",{className:"",children:S.jsx(hA,{})}),S.jsx("div",{children:S.jsx(pA,{})}),S.jsx("div",{children:S.jsx(gA,{})})]})}function Yre(){const e=_e(t=>t.card.type);return S.jsx(El,{className:" text-sm h-full w-full ",children:e==="stackedBar"?S.jsx(Gre,{}):S.jsx(qre,{})})}function Kre(){const e=_e(t=>t.isShowingVisual);return S.jsxs(bM,{direction:"vertical",className:"min-w-full max-w-lg min-h-[250px]",children:[S.jsx(Dp,{minSize:30,defaultSize:35,children:S.jsx(Ane,{})}),S.jsx(yM,{}),S.jsx(Dp,{minSize:60,defaultSize:75,children:e?S.jsxs(bM,{direction:"horizontal",children:[S.jsx(S.Fragment,{children:S.jsx(Dp,{className:"flex min-w-[275px]",minSize:20,defaultSize:25,maxSize:30,children:S.jsx(Yre,{})})}),S.jsx(yM,{}),S.jsx(Dp,{minSize:40,defaultSize:70,maxSize:100,children:S.jsx(qT,{})})]}):S.jsx(qT,{})})]})}function Xre({authToken:e,onSave:t,onClose:n}){_e(s=>s.actions.setCard);const r=_e(s=>s.actions.setOnSave),i=_e(s=>s.actions.setOnClose),o=xe(s=>s.actions.setAuthToken);return m.useEffect(()=>{t&&r(t),n&&i(n)},[t,r,n,i]),m.useEffect(()=>{e&&e.accessToken&&o(e)},[e,o]),S.jsxs(xk,{children:[S.jsx(wk,{className:"border rounded-none border-y-2 border-l-2 border-muted",children:S.jsx(Uk,{})}),S.jsx(_k,{className:"border-2 rounded-none border-muted",children:S.jsx(Kre,{})})]})}function Qre(){xe(s=>s.selectedCardId);const e=xe(s=>s.selectedSheetId),t=xe(s=>s.actions.setIsVisualEditing);xe(s=>s.actions.setIsEditorSaveEvent);const n=xe(s=>s.isVisualEditing);xe(s=>s.actions.getSelectedCard());const r=xe(s=>s.actions.updateCard);function i(s){e&&(r(e,s),t(!1))}function o(){t(!1)}return S.jsx("div",{className:`grow flex ${n?"block":"hidden"}`,children:S.jsx(Xre,{onSave:i,onClose:o})})}function Zre({columns:e,tableName:t}){const n=_e(f=>f.selectedConnectionId),r=_e(f=>f.selectedDatabaseName),i=_e(f=>f.selectedSchemaName),o=_e(f=>f.selectedTableName),s=xe(f=>f.dashboard.filters)||[],a=xe(f=>f.actions.addFilter),l=xe(f=>f.actions.removeFilter),c=xe(f=>f.actions.removeFilterValue);function d(f){const g=s==null?void 0:s.find(p=>p.column===f.column_name&&p.table===o&&p.database===r);if(g)c(g.id),l(g.id);else{const p=S0(i||"",t),v=`SELECT ${f.column_name}, COUNT(*) FROM ${p} GROUP BY ${f.column_name} ORDER BY ${f.column_name} ASC LIMIT 50`,y=`SELECT min(${f.column_name}) as min, max(${f.column_name}) as max FROM ${p}`;if(t==="api"&&n){a({id:vh(),column:f.column_name,title:f.column_name,dataType:f.data_type,table:"api",database:"NA",connectionId:n,sql:Iu.includes(f.data_type)?y:v});return}if(!n||!r||!o)throw new Error("missing connectionId, database, or table");a({id:vh(),column:f.column_name,title:f.column_name,dataType:f.data_type,table:o,database:r,connectionId:n,sql:Iu.includes(f.data_type)?y:v})}}return S.jsx(El,{className:" h-[70vh] mt-2",children:e==null?void 0:e.map(f=>{const g=s==null?void 0:s.find(p=>p.column===f.column_name&&p.table===o&&p.database===r);return S.jsx("div",{onClick:()=>d(f),className:Oe(" group flex text-sm items-center justify-between px-3 py-[6px] transition-colors hover:bg-muted/50 cursor-pointer border border-background border-dashed",{"bg-muted ":g}),children:S.jsxs("div",{className:"flex items-center gap-2 ",children:[S.jsx(qk,{column:f}),S.jsx("span",{children:f.column_name})]})},f.column_name)})})}function Jre(){xe(t=>t.showFilters);const e=xe(t=>t.actions.setShowFilters);return S.jsxs("section",{className:" relative space-y-4 py-0 px-4 border-muted bg-red-x100",children:[S.jsx(ft,{onClick:()=>e(!1),className:" p-0 h-7 w-7 absolute top-0 right-4",variant:"outline",children:S.jsx(xu,{})}),S.jsx("p",{className:"text-md",children:"Data Columns"}),S.jsx("div",{children:S.jsx(Uk,{ColumnsComponent:(t,n,r)=>S.jsx(Zre,{schemaName:t,tableName:n,columns:r})})})]})}function eie(){const e=xe(n=>n.showFilters),t=xe(n=>n.isVisualEditing);return S.jsxs("div",{role:"dashboard-plus-main",className:` flex grow ${t?"hidden":"block"} `,children:[S.jsx(qO,{}),e&&S.jsx("div",{role:"filter-aside-container",className:" border min-h-[80vh] w-[300px]",children:S.jsx(Jre,{})})]})}function tie(){const e=xe(r=>r.dashboard),t=xe(r=>r.actions.setDashboard),n=xe(r=>r.showDashboardJSON);return xe(r=>r.actions.setShowDashboardJSON),S.jsx("div",{className:Oe(" p-2",{hidden:!n}),children:S.jsx(RM,{onChange:r=>{if(r)try{JSON.parse(r),t(JSON.parse(r))}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 nie({showControls:e=!1,showFooter:t=!0,...n}){return xe(r=>r.isVisualEditing),S.jsxs(UO,{children:[e&&S.jsx(lK,{}),S.jsx(tie,{}),S.jsxs(Hw,{...n,children:[S.jsx(Qre,{}),S.jsx(eie,{})]})]})}function rie(){const e=xe(t=>t.actions);return{setDashboardTitle:e.setDashboardTitle,getStyle:e.getStyle,getDashboard:e.getDashboard,setOnSaveFunction:e.setOnSaveFunction,setOnAddCard:e.setOnAddCard,setOnUpateCard:e.setOnUpdateCard,setOnRemoveCard:e.setOnRemoveCard}}dt.Dashboard=GO,dt.DashboardPlus=nie,dt.DashboardWC=BG,dt.cleanCard=yk,dt.getDashbaordStateWithoutData=bk,dt.useActions=rie,dt.useDashboardStore=xe,Object.defineProperty(dt,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "email": "support@semaphor.cloud"
6
6
  },
7
7
  "license": "MIT",
8
- "version": "0.0.36",
8
+ "version": "0.0.37",
9
9
  "description": "Fully interactive and customizable dashboards for your apps. Embed analytics and insights into your app with ease.",
10
10
  "keywords": [
11
11
  "react",