semaphor 0.0.14 → 0.0.15

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.
@@ -51489,9 +51489,9 @@ function mfe() {
51489
51489
  "div",
51490
51490
  {
51491
51491
  role: "dashboard-plus-main",
51492
- className: Me("flex grow", {
51492
+ className: Me(" grow", {
51493
51493
  hidden: t,
51494
- block: !t
51494
+ flex: !t
51495
51495
  }),
51496
51496
  children: [
51497
51497
  /* @__PURE__ */ w.jsx(oM, {}),
@@ -51499,7 +51499,6 @@ function mfe() {
51499
51499
  "div",
51500
51500
  {
51501
51501
  role: "filter-aside-container",
51502
- className: "",
51503
51502
  children: /* @__PURE__ */ w.jsx(gfe, {})
51504
51503
  }
51505
51504
  )
@@ -502,4 +502,4 @@ SELECT label, measure FROM table
502
502
  Table Columns: ${p==null?void 0:p.map(X=>`${X.column_name} | ${X.data_type}`).join(", ")}
503
503
  User SQL: ${g}
504
504
  `,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.
505
- Visual Query Syntax: ${Vne}`,{data:w,isLoading:S,isFetching:C,isError:P,refetch:O}=Sr({queryKey:["ai-query"],queryFn:()=>tl("https://semaphor.cloud/api/v1/ai",(s==null?void 0:s.accessToken)||"",{user_content:`userContent: ${y} ${a?x:""}`}),enabled:!1});function k(X){if(X.toLowerCase().includes("bar"))f("bar");else if(X.toLowerCase().includes("line"))f("line");else if(X.toLowerCase().includes("bubble"))f("bubble");else if(X.toLowerCase().includes("scatter"))f("scatter");else if(X.toLowerCase().includes("stacked"))f("stackedBar");else if(X.toLowerCase().includes("pie"))f("pie");else if(X.toLowerCase().includes("donut")||X.toLowerCase().includes("doughnut"))f("doughnut");else if(X.toLowerCase().includes("radar"))f("radar");else return f("bar"),!1;return!0}function A(){n&&(k(n)&&l(!0),O())}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},z={fontFamily:"Arial, sans-serif",lineHeight:1.6,fontSize:15,padding:"2px 0",marginLeft:20,listStyleType:"disc"},B={p:({node:X,...K})=>_.jsx("p",{style:L,...K}),pre:({node:X,...K})=>_.jsxs("pre",{className:" bg-muted/50 space-y-2 p-3 rounded-sm",style:F,children:[_.jsx("code",{className:" whitespace-normal",children:K.children}),_.jsxs("div",{className:" flex justify-start gap-2",children:[_.jsx(it,{onClick:V,size:"sm",variant:"outline",children:_.jsx(JE,{})}),_.jsx(it,{onClick:$=>{const J=V($);J&&(t(!1),c(J),d(!0))},size:"sm",variant:"outline",children:_.jsx(Zj,{})})]})]}),li:({node:X,...K})=>_.jsx("li",{style:z,...K})};function V(X){const K=X.currentTarget.closest("pre");if(!K)return;const $=K.textContent||K.innerText;return navigator.clipboard.writeText($).then(()=>console.log("Text copied to clipboard")).catch(J=>console.error("Error in copying text: ",J)),$}return _.jsxs(wy,{open:e,onOpenChange:t,children:[_.jsx(_y,{asChild:!0,children:_.jsx(it,{size:"sm",className:"",variant:"outline",children:_.jsx(nV,{strokeWidth:1,size:16})})}),_.jsxs(_p,{className:" border-muted sm:max-w-[425px] md:min-w-[625px] md:max-h-[625px] flex flex-col justify-between overflow-auto",children:[_.jsxs(Sp,{children:[_.jsx(Cp,{children:"Ask"}),_.jsx(Ep,{children:"Need assistance with SQL queries? Feel free to ask me any question!"})]}),_.jsx(kl,{className:"h-[625px] w-full border-t border-t-muted ",children:(!S||!C)&&_.jsx(zne,{className:" pl-1 pr-3 py-1 w-full xbg-red-100 overflow-auto ",components:B,children:w==null?void 0:w.response})}),_.jsxs("div",{children:[_.jsx(lf,{className:Pe(" invisible h-1 w-full animate-pulse",{visible:S||C})}),_.jsxs("div",{className:" border rounded-md flex items-center w-full",children:[_.jsx(By,{onKeyDown:X=>{X.key==="Enter"&&!X.shiftKey&&(X.preventDefault(),r(""),A())},placeholder:"Type something...",onFocus:X=>{const K=X.target,$=K.value.length;K.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:X=>r(X.target.value)})," ",_.jsx(it,{className:"h-8",size:"sm",variant:"ghost",onClick:A,children:!S&&!C?_.jsx(Xj,{}):_.jsx(ku,{className:" w-4 h-4 animate-spin mr-2 text-foreground/50"})})]})]})]})]})}function Wne(){const{theme:e}=Em(),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=ge(H=>H.authToken),p=_e(H=>H.card),g=ge(H=>H.theme),v=_e(H=>H.selectedConnectionId),y=_e(H=>H.selectedDatabaseName),x=_e(H=>H.selectedSchemaName),w=_e(H=>H.selectedTableName),S=_e(H=>H.actions.setCardSql),C=_e(H=>H.card.sql),P=_e(H=>H.selectedConnectionId),O=_e(H=>H.filterValues),k=_e(H=>H.applyFilters),A=_e(H=>H.actions.setCardCustomCfg),L=_e(H=>H.actions.setFilterValues),F=_e(H=>H.onSave),z=_e(H=>H.actions.setApplyFilters),B=_e(H=>H.onClose),V=_e(H=>H.actions.setCardData),X=_e(H=>H.actions.setSqlGen),K=_e(H=>H.runSql),$=_e(H=>H.actions.setRunSql),J=_e(H=>H.actions.setIsSqlRunning),{data:G,isLoading:q,isFetching:se,isSuccess:D,isError:W,error:re,status:N,refetch:ne}=Sr({queryKey:[C],queryFn:()=>Is("https://semaphor.cloud/api/v1/query",(f==null?void 0:f.accessToken)||"",{connection_id:P,sql:C,active_filters:k?O:[]}),enabled:!1,retry:!1});m.useEffect(()=>{G&&(console.log("queryData",G),V(G.records))},[G,V]),m.useEffect(()=>{K&&(ne(),$(!1))},[K,ne,$]),m.useEffect(()=>{(q||se)&&J(!0),(W||D)&&J(!1)},[q,se,W,D,J]);function me(){S(""),V([]),X({}),A("")}const he=H=>{n.current=H};function de(){if(C&&!C.includes("{{")){const H=cZ(C);S(H),F==null||F({...p,sql:H,lastSelectedSchema:x,lastSelectedDatabase:y,lastSelectedTable:w,connectionId:v})}else F==null||F(p)}function ie(){B==null||B()}m.useEffect(()=>{const H=t.current,ye=n.current;if(H){const oe=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",Te=g==="system"?oe:g;H.editor.defineTheme("default",{base:Te==="light"?"vs":"vs-dark",inherit:!0,rules:[],colors:{"editor.background":Te==="light"?"#ffffff":"#020817"}}),H.editor.setTheme("default")}return ye&&H&&ye.addCommand(H.KeyMod.Shift|H.KeyCode.Enter,function(){return console.log("Executing query..."),ne(),!1}),()=>{}},[e,g,t.current]);function ee(H){t.current=H}return _.jsxs("section",{role:"editor-section",className:"grow flex flex-col justify-end pt-3 p-1 ",children:[_.jsxs("div",{className:" grow flex relative overflow-y-scroll justify-between ",children:[_.jsx("div",{role:"editor-container",className:`flex ${r?"w-2/3":"w-[95%]"} xbg-red-100 p-1`,children:_.jsx(Ry,{theme:"default",onChange:H=>{S(H),console.log(H)},value:C,options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"sql",defaultValue:"SELECT * FROM table",beforeMount:ee,onMount:he})}),r&&_.jsx("div",{className:" w-1/3 text-xs relative overflow-hidden xbg-yellow-100 p-1 ",children:_.jsxs("div",{className:"min-h-0 ",children:[_.jsxs("div",{className:"flex gap-2 items-center",children:[_.jsx(_Z,{checked:k,onCheckedChange:()=>z(!k),text:"Apply Filters"}),_.jsx(SZ,{})]}),_.jsx(Ry,{theme:"default",onChange:H=>{if(H)try{JSON.parse(H),L(JSON.parse(H))}catch{}},defaultLanguage:"json",className:"min-h-[220px] mt-1",value:JSON.stringify(O,null,2),options:{readOnly:!0,minimap:{enabled:!1},lineNumbers:"off",glyphMargin:!1,wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:12,renderLineHighlight:"none"}})]})}),O&&r&&_.jsx(ia,{onClick:()=>i(!1),className:"absolute right-6 top-1 w-3 h-3 text-foreground/50 hover:text-foreground hover:cursor-pointer"}),O&&!r&&_.jsx(W2,{onClick:()=>i(!0),className:Pe("absolute right-6 top-1 w-3 h-3 text-foreground/50 hover:text-foreground hover:cursor-pointer",{"text-red-800 font-bold":k})})]}),_.jsxs("div",{className:" flex grow px-6 pt-3 pb-4 gap-2 justify-between item-center",children:[_.jsxs("div",{className:"flex grow gap-2 items-center",children:[_.jsxs(it,{disabled:q||se,onClick:()=>{ne()},className:" shrink-0",size:"sm",variant:"outline",children:[(q||se)&&_.jsx(ku,{className:"w-4 h-4 mr-2 animate-spin text-foreground/50"}),"Run"]}),W&&_.jsx(wZ,{error:re.message}),_.jsx(it,{onClick:me,className:"",size:"sm",variant:"outline",children:"Clear"}),_.jsx(Ku,{value:a,placeholder:"Type something...",onChange:H=>{l(H.target.value)},onKeyDown:H=>{H.key==="Enter"&&(H.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"}),_.jsx(Hne,{open:o,setOpen:s,userInput:a,triggerAIRun:c,setTriggerAIRun:d,setUserInput:H=>l(H)})]}),_.jsxs("div",{className:"flex gap-2 items-end ",children:[_.jsx(it,{onClick:de,size:"sm",variant:"outline",children:_.jsx(Rh,{size:16,strokeWidth:2,className:"text-green-600 font-bold"})}),_.jsx(it,{onClick:ie,className:" w-full",size:"sm",variant:"outline",children:_.jsx(ia,{className:" h-3.5 w-3.5"})})]})]})]})}const $T="Switch",[qne,Sfe]=Pn($T),[Une,Gne]=qne($T),Yne=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,p]=m.useState(null),g=et(t,S=>p(S)),v=m.useRef(!1),y=f?!!f.closest("form"):!0,[x=!1,w]=Qn({prop:i,defaultProp:o,onChange:c});return m.createElement(Une,{scope:n,checked:x,disabled:a},m.createElement(Be.button,le({type:"button",role:"switch","aria-checked":x,"aria-required":s,"data-state":FT(x),"data-disabled":a?"":void 0,disabled:a,value:l},d,{ref:g,onClick:Ce(e.onClick,S=>{w(C=>!C),y&&(v.current=S.isPropagationStopped(),v.current||S.stopPropagation())})})),y&&m.createElement(Qne,{control:f,bubbles:!v.current,name:r,value:l,checked:x,required:s,disabled:a,style:{transform:"translateX(-100%)"}}))}),Kne="SwitchThumb",Xne=m.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,i=Gne(Kne,n);return m.createElement(Be.span,le({"data-state":FT(i.checked),"data-disabled":i.disabled?"":void 0},r,{ref:t}))}),Qne=e=>{const{control:t,checked:n,bubbles:r=!0,...i}=e,o=m.useRef(null),s=Op(n),a=Mh(t);return m.useEffect(()=>{const l=o.current,c=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(c,"checked").set;if(s!==n&&f){const p=new Event("click",{bubbles:r});f.call(l,n),l.dispatchEvent(p)}},[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 FT(e){return e?"checked":"unchecked"}const jT=Yne,Zne=Xne,zT=ue.forwardRef(({className:e,...t},n)=>_.jsx(jT,{className:Pe("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:_.jsx(Zne,{className:Pe("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")})}));zT.displayName=jT.displayName;function BT({className:e,...t}){const[n,r]=m.useState(0),i=ge(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=kb({data:o.data,cardType:o.type,cfg:o.cfg,customCfg:o.customCfg})),_.jsxs(Mv,{role:"editor-visual-card",className:Pe(" relative h-full flex flex-col rounded-none",e),...t,children:[_.jsxs(Dv,{children:[_.jsx(qc,{text:o.title,onSave:l=>s({...o,title:l}),children:_.jsx(Tv,{className:"text-base",children:o.title})}),_.jsx(qc,{text:o.description||"",onSave:l=>s({...o,description:l}),children:_.jsxs(Av,{children:[" ",o.description]})})]}),_.jsxs(Iv,{className:"flex flex-col pb-3 grow",children:[o.type!=="table"&&a&&_.jsx(QE,{cfg:a},n),o.type==="table"&&o.data&&o.data.length>0&&_.jsx(cO,{children:_.jsx(a0,{data:o==null?void 0:o.data})})]})]})}function Jne(){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,P;const w={...x,data:{...x==null?void 0:x.data,datasets:(P=(C=x==null?void 0:x.data)==null?void 0:C.datasets)==null?void 0:P.map(O=>({...O,data:[]}))}};return JSON.stringify(w,null,1)}function p(){if(!l.data||l.data.length===0)return;const x=kb({data:l.data,cardType:l.type,cfg:l.cfg});x&&(r(JSON.stringify(x,null,1)),c&&o(JSON.stringify(c,null,1)))}function g(){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=$s.cloneDeep(l.cfg),S=$s.merge(w,c);return x=f(S),x}return n?(x=f(JSON.parse(n)),x):""}return _.jsxs(wy,{open:e,onOpenChange:t,children:[_.jsx(_y,{asChild:!0,children:_.jsx(it,{onClick:p,className:`h-7 ${c&&"border-foreground/50 dark:border-foreground/70"}`,size:"sm",variant:"outline",children:c?"Custom Config":"Customize"})}),_.jsx(_p,{className:" sm:max-w-[425px] md:min-w-[600px] md:min-h-[700px] lg:min-w-[800px] xl:min-w-[1000px]",children:_.jsxs("div",{className:"bg-red-x100 flex flex-col gap-2 justify-between",children:[_.jsxs(Sp,{className:"",children:[_.jsx(Cp,{children:"Customize Chart"}),_.jsxs(Ep,{children:["See the configuration options and documentation",_.jsx("a",{target:"_blank",className:"ml-1 underline text-blue-500 ",href:"https://www.chartjs.org/docs/latest/samples/bar/vertical.html",children:"here."})]})]}),_.jsxs("div",{className:"grow flex flex-wrap gap-2",children:[_.jsx(BT,{className:"flex-1 rounded shadow-none"}),_.jsxs(a_,{defaultValue:"custom-config",className:" flex flex-col flex-1",children:[_.jsxs(l_,{className:" justify-start border rounded-sm rounded-b-none border-b-0 ",children:[_.jsxs(Im,{value:"custom-config",children:[c&&_.jsx(ZE,{className:"w-5 h-5 mr-1 text-green-600"}),c?"Custom Config":"Default Config"]}),_.jsx(Im,{className:"",value:"output",children:"Output"})]}),_.jsx(ff,{className:" grow mt-0 bg-red-x p-2 border border-t-0 rounded-b ",value:"output",children:_.jsx(By,{disabled:!0,value:n,className:" border-none resize-none font-mono h-full focus-visible:ring-0 focus-visible:ring-offset-0"})}),_.jsx(ff,{className:"grow mt-0 border border-t-0 rounded-b ",value:"custom-config",children:_.jsx(Ry,{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)})})]})]}),_.jsxs(Sy,{className:"flex items-center",children:[_.jsx(ns,{className:"text-red-500 mr-2",children:s}),_.jsx(it,{disabled:!c,onClick:v,variant:"outline",children:"Reset"}),_.jsx(it,{onClick:g,variant:"outline",children:"Apply"}),_.jsx(it,{onClick:()=>t(!1),variant:"outline",children:"Close"})]})]})})]})}var VT={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},HT=m.createContext&&m.createContext(VT),ere=["attr","size","title"];function tre(e,t){if(e==null)return{};var n=nre(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 nre(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 tg(){return tg=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},tg.apply(this,arguments)}function WT(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 ng(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?WT(Object(n),!0).forEach(function(r){rre(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):WT(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function rre(e,t,n){return t=ire(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ire(e){var t=ore(e,"string");return typeof t=="symbol"?t:String(t)}function ore(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 qT(e){return e&&e.map((t,n)=>m.createElement(t.tag,ng({key:n},t.attr),qT(t.child)))}function dd(e){return t=>m.createElement(sre,tg({attr:ng({},e.attr)},t),qT(e.child))}function sre(e){var t=n=>{var{attr:r,size:i,title:o}=e,s=tre(e,ere),a=i||n.size||"1em",l;return n.className&&(l=n.className),e.className&&(l=(l?l+" ":"")+e.className),m.createElement("svg",tg({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},n.attr,r,s,{className:l,style:ng(ng({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 HT!==void 0?m.createElement(HT.Consumer,null,n=>t(n)):t(VT)}function UT(e){return dd({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 GT(e){return dd({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 YT(e){return dd({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 KT(e){return dd({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 XT(e){return dd({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 are(){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 _.jsxs(pp,{open:e,onOpenChange:t,children:[_.jsx(gp,{asChild:!0,children:_.jsx(it,{className:"h-7 px-2",variant:"outline",children:_.jsx(lre,{className:"h-4 w-4",chartType:n})})}),_.jsx(Wu,{className:"w-50",children:_.jsxs("div",{className:"grid grid-cols-3 place-items-center ",children:[_.jsx(it,{onClick:()=>o("bar"),className:"font-normal",variant:"ghost",children:_.jsx(B2,{strokeWidth:1})}),_.jsx(it,{onClick:()=>o("line"),variant:"ghost",children:_.jsx(q2,{strokeWidth:1})}),_.jsx(it,{onClick:()=>o("stackedBar"),variant:"ghost",children:_.jsx(XT,{className:"h-6 w-6 text-foreground/50 ",strokeWidth:0})}),_.jsx(it,{onClick:()=>o("scatter"),variant:"ghost",children:_.jsx(G2,{strokeWidth:1})}),_.jsx(it,{onClick:()=>o("bubble"),variant:"ghost",children:_.jsx(KT,{strokeWidth:2})}),_.jsx(it,{onClick:()=>o("pie"),variant:"ghost",children:_.jsx(U2,{strokeWidth:1})}),_.jsx(it,{onClick:()=>o("doughnut"),variant:"ghost",children:_.jsx(YT,{className:"h-7 w-7",strokeWidth:.5})}),_.jsx(it,{onClick:()=>o("radar"),variant:"ghost",children:_.jsx(UT,{className:"h-6 w-6 text-foreground/50 font-extralight",strokeWidth:.5})}),_.jsx(it,{onClick:()=>o("polarArea"),variant:"ghost",children:_.jsx(GT,{className:"h-6 w-6 text-foreground/50",strokeWidth:1})}),_.jsx(it,{onClick:()=>o("table"),variant:"ghost",children:_.jsx(qb,{className:"h-6 w-6 text-foreground/90",strokeWidth:1})})]})})]})}function lre({chartType:e,className:t}){switch(e){case"bar":return _.jsx(B2,{className:t});case"line":return _.jsx(q2,{className:t});case"pie":return _.jsx(U2,{className:t});case"radar":return _.jsx(UT,{className:t});case"scatter":return _.jsx(G2,{className:t});case"bubble":return _.jsx(KT,{className:t});case"doughnut":return _.jsx(YT,{className:t});case"stackedBar":return _.jsx(XT,{className:"h-5 w-5 text-foreground/50 ",strokeWidth:0});case"polarArea":return _.jsx(GT,{className:t});default:return _.jsx(qb,{className:t})}}function cre(){const e=_e(n=>n.card.refreshInterval),t=_e(n=>n.actions.setCardRefreshInterval);return _.jsxs(pp,{children:[_.jsx(gp,{asChild:!0,children:_.jsx(it,{className:"h-7",variant:"outline",children:"Realtime"})}),_.jsx(Wu,{className:"w-[200px]",children:_.jsx("div",{className:"grid gap-4",children:_.jsx("div",{className:"grid gap-2",children:_.jsxs("div",{className:"grid grid-cols-5 items-center gap-1",children:[_.jsx(ns,{className:"col-span-3",htmlFor:"width",children:"Refresh Every"}),_.jsx(Ku,{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),_.jsxs("div",{className:" h-full relative flex flex-col",children:[n&&_.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 "}),_.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&&_.jsxs("div",{className:"bg-red-x00 flex grow gap-2",children:[_.jsx(are,{}),_.jsx(Jne,{}),_.jsx(cre,{})]}),_.jsx(ure,{})]}),t?_.jsx(BT,{className:"grow border-none shadow-none "}):_.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&&_.jsx(a0,{data:e.data})})]})}function ure(){const e=_e(n=>n.isShowingVisual),t=_e(n=>n.actions.setIsShowingVisual);return _.jsxs("div",{className:" flex items-center space-x-2",children:[_.jsx(ns,{htmlFor:"visualize",children:"Chart"}),_.jsx(zT,{checked:e,onCheckedChange:()=>t(!e),id:"visualize",className:"data-[state=checked]:bg-foreground/50"})]})}const ZT="Collapsible",[dre,JT]=Pn(ZT),[fre,_x]=dre(ZT),hre=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(fre,{scope:n,disabled:o,contentId:or(),open:l,onOpenToggle:m.useCallback(()=>c(d=>!d),[c])},m.createElement(Be.div,le({"data-state":Sx(l),"data-disabled":o?"":void 0},a,{ref:t})))}),pre="CollapsibleTrigger",gre=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,i=_x(pre,n);return m.createElement(Be.button,le({type:"button","aria-controls":i.contentId,"aria-expanded":i.open||!1,"data-state":Sx(i.open),"data-disabled":i.disabled?"":void 0,disabled:i.disabled},r,{ref:t,onClick:Ce(e.onClick,i.onOpenToggle)}))}),eA="CollapsibleContent",mre=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,i=_x(eA,e.__scopeCollapsible);return m.createElement(vn,{present:n||i.open},({present:o})=>m.createElement(vre,le({},r,{ref:t,present:o})))}),vre=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:i,...o}=e,s=_x(eA,n),[a,l]=m.useState(r),c=m.useRef(null),d=et(t,c),f=m.useRef(0),p=f.current,g=m.useRef(0),v=g.current,y=s.open||a,x=m.useRef(y),w=m.useRef();return m.useEffect(()=>{const S=requestAnimationFrame(()=>x.current=!1);return()=>cancelAnimationFrame(S)},[]),Vn(()=>{const S=c.current;if(S){w.current=w.current||{transitionDuration:S.style.transitionDuration,animationName:S.style.animationName},S.style.transitionDuration="0s",S.style.animationName="none";const C=S.getBoundingClientRect();f.current=C.height,g.current=C.width,x.current||(S.style.transitionDuration=w.current.transitionDuration,S.style.animationName=w.current.animationName),l(r)}},[s.open,r]),m.createElement(Be.div,le({"data-state":Sx(s.open),"data-disabled":s.disabled?"":void 0,id:s.contentId,hidden:!y},o,{ref:d,style:{"--radix-collapsible-content-height":p?`${p}px`:void 0,"--radix-collapsible-content-width":v?`${v}px`:void 0,...e.style}}),y&&i)});function Sx(e){return e?"open":"closed"}const bre=hre,yre=gre,xre=mre,us="Accordion",wre=["Home","End","ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],[Cx,_re,Sre]=uf(us),[rg,Cfe]=Pn(us,[Sre,JT]),Ex=JT(),tA=m.forwardRef((e,t)=>{const{type:n,...r}=e,i=r,o=r;return m.createElement(Cx.Provider,{scope:e.__scopeAccordion},n==="multiple"?m.createElement(Pre,le({},o,{ref:t})):m.createElement(Ore,le({},i,{ref:t})))});tA.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[nA,Cre]=rg(us),[rA,Ere]=rg(us,{collapsible:!1}),Ore=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(nA,{scope:e.__scopeAccordion,value:a?[a]:[],onItemOpen:l,onItemClose:m.useCallback(()=>o&&l(""),[o,l])},m.createElement(rA,{scope:e.__scopeAccordion,collapsible:o},m.createElement(iA,le({},s,{ref:t}))))}),Pre=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(p=>p!==d)),[a]);return m.createElement(nA,{scope:e.__scopeAccordion,value:s,onItemOpen:l,onItemClose:c},m.createElement(rA,{scope:e.__scopeAccordion,collapsible:!0},m.createElement(iA,le({},o,{ref:t}))))}),[kre,ig]=rg(us),iA=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=_re(n),f=Fs(i)==="ltr",p=Ce(e.onKeyDown,g=>{var v;if(!wre.includes(g.key))return;const y=g.target,x=c().filter(F=>{var z;return!((z=F.ref.current)!==null&&z!==void 0&&z.disabled)}),w=x.findIndex(F=>F.ref.current===y),S=x.length;if(w===-1)return;g.preventDefault();let C=w;const P=0,O=S-1,k=()=>{C=w+1,C>O&&(C=P)},A=()=>{C=w-1,C<P&&(C=O)};switch(g.key){case"Home":C=P;break;case"End":C=O;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%S;(v=x[L].ref.current)===null||v===void 0||v.focus()});return m.createElement(kre,{scope:n,disabled:r,direction:i,orientation:o},m.createElement(Cx.Slot,{scope:n},m.createElement(Be.div,le({},s,{"data-orientation":o,ref:l,onKeyDown:r?void 0:p}))))}),Ox="AccordionItem",[Mre,Px]=rg(Ox),Dre=m.forwardRef((e,t)=>{const{__scopeAccordion:n,value:r,...i}=e,o=ig(Ox,n),s=Cre(Ox,n),a=Ex(n),l=or(),c=r&&s.value.includes(r)||!1,d=o.disabled||e.disabled;return m.createElement(Mre,{scope:n,open:c,disabled:d,triggerId:l},m.createElement(bre,le({"data-orientation":o.orientation,"data-state":sA(c)},a,i,{ref:t,disabled:d,open:c,onOpenChange:f=>{f?s.onItemOpen(r):s.onItemClose(r)}})))}),Tre="AccordionHeader",Are=m.forwardRef((e,t)=>{const{__scopeAccordion:n,...r}=e,i=ig(us,n),o=Px(Tre,n);return m.createElement(Be.h3,le({"data-orientation":i.orientation,"data-state":sA(o.open),"data-disabled":o.disabled?"":void 0},r,{ref:t}))}),oA="AccordionTrigger",Ire=m.forwardRef((e,t)=>{const{__scopeAccordion:n,...r}=e,i=ig(us,n),o=Px(oA,n),s=Ere(oA,n),a=Ex(n);return m.createElement(Cx.ItemSlot,{scope:n},m.createElement(yre,le({"aria-disabled":o.open&&!s.collapsible||void 0,"data-orientation":i.orientation,id:o.triggerId},a,r,{ref:t})))}),Nre="AccordionContent",Rre=m.forwardRef((e,t)=>{const{__scopeAccordion:n,...r}=e,i=ig(us,n),o=Px(Nre,n),s=Ex(n);return m.createElement(xre,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 sA(e){return e?"open":"closed"}const Lre=tA,$re=Dre,Fre=Are,aA=Ire,lA=Rre,cA=Lre,ds=ue.forwardRef(({className:e,...t},n)=>_.jsx($re,{ref:n,className:Pe("border-b",e),...t}));ds.displayName="AccordionItem";const fs=ue.forwardRef(({className:e,children:t,...n},r)=>_.jsx(Fre,{className:"flex",children:_.jsxs(aA,{ref:r,className:Pe("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,_.jsx(Wb,{className:"h-4 w-4 shrink-0 transition-transform duration-200"})]})}));fs.displayName=aA.displayName;const hs=ue.forwardRef(({className:e,children:t,...n},r)=>_.jsx(lA,{ref:r,className:"overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...n,children:_.jsx("div",{className:Pe("pb-4 pt-0",e),children:t})}));hs.displayName=lA.displayName;const uA="Radio",[jre,dA]=Pn(uA),[zre,Bre]=jre(uA),Vre=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),p=et(t,y=>f(y)),g=m.useRef(!1),v=d?!!d.closest("form"):!0;return m.createElement(zre,{scope:n,checked:i,disabled:s},m.createElement(Be.button,le({type:"button",role:"radio","aria-checked":i,"data-state":fA(i),"data-disabled":s?"":void 0,disabled:s,value:a},c,{ref:p,onClick:Ce(e.onClick,y=>{i||l==null||l(),v&&(g.current=y.isPropagationStopped(),g.current||y.stopPropagation())})})),v&&m.createElement(qre,{control:d,bubbles:!g.current,name:r,value:a,checked:i,required:o,disabled:s,style:{transform:"translateX(-100%)"}}))}),Hre="RadioIndicator",Wre=m.forwardRef((e,t)=>{const{__scopeRadio:n,forceMount:r,...i}=e,o=Bre(Hre,n);return m.createElement(vn,{present:r||o.checked},m.createElement(Be.span,le({"data-state":fA(o.checked),"data-disabled":o.disabled?"":void 0},i,{ref:t})))}),qre=e=>{const{control:t,checked:n,bubbles:r=!0,...i}=e,o=m.useRef(null),s=Op(n),a=Mh(t);return m.useEffect(()=>{const l=o.current,c=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(c,"checked").set;if(s!==n&&f){const p=new Event("click",{bubbles:r});f.call(l,n),l.dispatchEvent(p)}},[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 fA(e){return e?"checked":"unchecked"}const Ure=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],hA="RadioGroup",[Gre,Efe]=Pn(hA,[ol,dA]),pA=ol(),gA=dA(),[Yre,Kre]=Gre(hA),Xre=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,...p}=e,g=pA(n),v=Fs(c),[y,x]=Qn({prop:o,defaultProp:i,onChange:f});return m.createElement(Yre,{scope:n,name:r,required:s,disabled:a,value:y,onValueChange:x},m.createElement(Dm,le({asChild:!0},g,{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},p,{ref:t}))))}),Qre="RadioGroupItem",Zre=m.forwardRef((e,t)=>{const{__scopeRadioGroup:n,disabled:r,...i}=e,o=Kre(Qre,n),s=o.disabled||r,a=pA(n),l=gA(n),c=m.useRef(null),d=et(t,c),f=o.value===i.value,p=m.useRef(!1);return m.useEffect(()=>{const g=y=>{Ure.includes(y.key)&&(p.current=!0)},v=()=>p.current=!1;return document.addEventListener("keydown",g),document.addEventListener("keyup",v),()=>{document.removeEventListener("keydown",g),document.removeEventListener("keyup",v)}},[]),m.createElement(Tm,le({asChild:!0},a,{focusable:!s,active:f}),m.createElement(Vre,le({disabled:s,required:o.required,checked:f},l,i,{name:o.name,ref:d,onCheck:()=>o.onValueChange(i.value),onKeyDown:Ce(g=>{g.key==="Enter"&&g.preventDefault()}),onFocus:Ce(i.onFocus,()=>{var g;p.current&&((g=c.current)===null||g===void 0||g.click())})})))}),Jre=m.forwardRef((e,t)=>{const{__scopeRadioGroup:n,...r}=e,i=gA(n);return m.createElement(Wre,le({},i,r,{ref:t}))}),mA=Xre,vA=Zre,eie=Jre,bA=ue.forwardRef(({className:e,...t},n)=>_.jsx(mA,{className:Pe("grid gap-2",e),...t,ref:n}));bA.displayName=mA.displayName;const kx=ue.forwardRef(({className:e,...t},n)=>_.jsx(vA,{ref:n,className:Pe("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:_.jsx(eie,{className:"flex items-center justify-center",children:_.jsx(H2,{className:"h-2.5 w-2.5 fill-current text-current"})})}));kx.displayName=vA.displayName;function yA(){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 _.jsxs("div",{children:[_.jsx("p",{className:"font-semibold",children:"Orientation"}),_.jsxs(bA,{value:n,onValueChange:r,className:"flex gap-3 mt-2 ",defaultValue:"x",children:[_.jsxs("div",{className:"flex items-center space-x-2",children:[_.jsx(kx,{value:"x",id:"r1"}),_.jsx("label",{className:"text-sm",htmlFor:"r1",children:"Vertical"})]}),_.jsxs("div",{className:"flex items-center space-x-2",children:[_.jsx(kx,{value:"y",id:"r2"}),_.jsx("label",{className:"text-sm",htmlFor:"r2",children:"Horizontal"})]})]})]})}function xA(){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 _.jsxs(_.Fragment,{children:[_.jsx("label",{className:"font-medium",children:"Data Labels"}),_.jsxs(lM,{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:[_.jsx(Py,{className:"w-[180px] mt-2 focus:ring-1 focus:ring-offset-0 h-7",children:_.jsx(uM,{placeholder:"Select position"})}),_.jsx(ky,{children:_.jsxs(cM,{children:[_.jsx(Ap,{children:"Data Labels"}),_.jsx(_a,{value:"none",children:"None"}),_.jsx(_a,{value:"start",children:"Start"}),_.jsx(_a,{value:"center",children:"Center"}),_.jsx(_a,{value:"end",children:"End"})]})})]})]})}function wA(){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 _.jsxs("div",{children:[_.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[_.jsx(Pp,{checked:!!(e!=null&&e.filterOnClick),onCheckedChange:i=>{t({...e,filterOnClick:!!i})}}),_.jsx(ns,{children:"Filter on click"})]}),(e==null?void 0:e.filterOnClick)===!0&&_.jsxs("div",{className:"flex gap-2 items-center",children:[_.jsx(Ku,{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)}),_.jsxs(Vb,{children:[_.jsx(L2,{children:_.jsx(e2,{className:"h-4 w-4 opacity-70"})}),_.jsx(Ih,{children:_.jsxs("div",{className:"max-w-[200px]",children:["The x-axis expression of your query. Example:",_.jsx("div",{className:" mt-1 text-xs font-mono",children:"TO_CHAR(order_date, 'YYYY-MM')"})]})})]})]})]})}const tie={datasets:[{type:"line",label:"Sum_sales",data:[]},{type:"bar",label:"Sum_profit",data:[]}]},nie={datasets:[{fill:"origin",type:"line",label:"Sum_sales",data:[]}]};function rie(){const e=_e(t=>t.card.type);return _.jsxs("div",{className:"p-6 space-y-6",children:[_.jsx(cA,{className:" ",type:"single",collapsible:!0,children:iie(e)}),_.jsx("section",{className:"",children:["line","bar"].includes(e)&&_.jsx(yA,{})}),_.jsx("div",{children:_.jsx(xA,{})}),_.jsx("div",{children:_.jsx(wA,{})})]})}function iie(e){if(["line","bar"].includes(e))return _.jsxs(_.Fragment,{children:[_.jsxs(ds,{className:"border-muted",value:"item-1",children:[_.jsx(fs,{className:" font-normal",children:_.jsx("p",{children:"Chart Query"})}),_.jsxs(hs,{className:" ",children:[_.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"}),_.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs",children:[_.jsx("li",{children:"X-axis - Category (ex. city)"}),_.jsx("li",{children:"Y-axis - Number (ex. population)"})]})]})]}),_.jsxs(ds,{className:"border-muted",value:"item-2",children:[_.jsx(fs,{className:" font-normal",children:"Mixed Chart"}),_.jsxs(hs,{className:" text-xs space-y-2",children:[_.jsxs("p",{children:["Click ",_.jsx("b",{children:"Customize"})," and change the `type` property in the dataset."]}),_.jsx("pre",{children:JSON.stringify(tie,null,2)})]})]}),_.jsxs(ds,{className:"border-muted",value:"item-3",children:[_.jsx(fs,{className:" font-normal",children:"Area Chart"}),_.jsxs(hs,{className:" text-xs space-y-2",children:[_.jsxs("p",{children:["Click ",_.jsx("b",{children:"Customize"})," and add `fill` property to the dataset. See",_.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."]}),_.jsx("pre",{children:JSON.stringify(nie,null,2)})]})]})]});if(e==="bubble")return _.jsx(_.Fragment,{children:_.jsxs(ds,{className:"border-muted",value:"item-1",children:[_.jsx(fs,{className:" font-normal",children:_.jsxs("p",{children:["How to create a ",_.jsx("span",{children:e})," chart query?"]})}),_.jsxs(hs,{className:" ",children:[_.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"}),_.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs",children:[_.jsx("li",{children:"Label - Category (ex. city)"}),_.jsx("li",{children:"Bubble Group (opt) - Category (ex. state)"}),_.jsx("li",{children:"X-axis - Number (ex. avg. age)"}),_.jsx("li",{children:"Y-axis - Number (ex. avg. weight)"}),_.jsx("li",{children:"Radius - Number (ex. population)"})]})]})]})});if(e==="scatter")return _.jsx(_.Fragment,{children:_.jsxs(ds,{value:"item-1",children:[_.jsx(fs,{className:" font-normal",children:_.jsxs("p",{children:["How to create a ",_.jsx("span",{children:e})," chart query?"]})}),_.jsxs(hs,{className:" ",children:[_.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"}),_.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs",children:[_.jsx("li",{children:"Label - Category (ex. city)"}),_.jsx("li",{children:"Group (opt) - Category (ex. state)"}),_.jsx("li",{children:"X-axis - Number (ex. avg. age)"}),_.jsx("li",{children:"Y-axis - Number (ex. avg. weight)"})]})]})]})});if(["pie","doughnut","polarArea"].includes(e))return _.jsx(_.Fragment,{children:_.jsxs(ds,{value:"item-1",children:[_.jsx(fs,{className:" font-normal",children:_.jsxs("p",{children:["How to create a"," ",_.jsxs("span",{children:[e==="polarArea"?"polar":e," "]})," ","chart query?"]})}),_.jsxs(hs,{className:" ",children:[_.jsx("div",{className:"bg-muted px-2 py-1 rounded font-mono font-semibold text-xs",children:"SELECT label, measure FROM table"}),_.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs",children:[_.jsx("li",{children:"Label - Category (ex. city)"}),_.jsx("li",{children:"Measure - Number (ex. population)"})]})]})]})})}function oie(){return _.jsxs("div",{className:"px-6 py-2 space-y-6",children:[_.jsx(cA,{className:" ",type:"single",collapsible:!0,children:_.jsxs(ds,{className:"border-muted",value:"item-1",children:[_.jsx(fs,{className:" font-normal",children:"Stacked chart query?"}),_.jsxs(hs,{className:" ",children:[_.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"}),_.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs",children:[_.jsx("li",{children:"X-axis - Category (ex. country)"}),_.jsx("li",{children:"Stack by - Category (ex. city)"}),_.jsx("li",{children:"Y-axis - Number (ex. population)"})]})]})]})}),_.jsx("section",{className:"",children:_.jsx(yA,{})}),_.jsx("div",{children:_.jsx(xA,{})}),_.jsx("div",{children:_.jsx(wA,{})})]})}function sie(){const e=_e(t=>t.card.type);return _.jsx(kl,{className:" text-sm h-full w-full ",children:e==="stackedBar"?_.jsx(oie,{}):_.jsx(rie,{})})}function aie(){const e=_e(t=>t.isShowingVisual);return _.jsxs(zM,{direction:"vertical",className:"min-w-full max-w-lg min-h-[250px]",children:[_.jsx(Fp,{className:"flex",minSize:40,defaultSize:40,children:_.jsx(Wne,{})}),_.jsx(BM,{className:"border-[1.5px] border-muted"}),_.jsx(Fp,{minSize:60,defaultSize:60,children:e?_.jsxs(zM,{direction:"horizontal",children:[_.jsx(_.Fragment,{children:_.jsx(Fp,{className:"flex min-w-[275px]",minSize:20,defaultSize:25,maxSize:30,children:_.jsx(sie,{})})}),_.jsx(BM,{className:"border-[1.5px] border-muted"}),_.jsx(Fp,{minSize:40,defaultSize:75,maxSize:100,children:_.jsx(QT,{})})]}):_.jsx(QT,{})})]})}function lie({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=ge(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]),_.jsxs(Bk,{className:"border-x border-b rounded-none border-muted ",children:[_.jsx(Vk,{className:" rounded-none border-r-[3px] border-muted ",children:_.jsx(pM,{})}),_.jsx(Hk,{children:_.jsx(aie,{})})]})}function cie(){ge(s=>s.selectedCardId);const e=ge(s=>s.selectedSheetId),t=ge(s=>s.actions.setIsVisualEditing);ge(s=>s.actions.setIsEditorSaveEvent);const n=ge(s=>s.isVisualEditing);ge(s=>s.actions.getSelectedCard());const r=ge(s=>s.actions.updateCard);function i(s){e&&(r(e,s),t(!1))}function o(){t(!1)}return _.jsx("div",{role:"editor-container",className:Pe("grow flex",{block:n,hidden:!n}),children:_.jsx(lie,{onSave:i,onClose:o})})}function uie({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=ge(f=>f.dashboard.filters)||[],a=ge(f=>f.actions.addFilter),l=ge(f=>f.actions.removeFilter),c=ge(f=>f.actions.removeFilterValue);function d(f){const p=s==null?void 0:s.find(g=>g.column===f.column_name&&g.table===o&&g.database===r);if(p)c(p.id),l(p.id);else{const g=M0(i||"",t),v=`SELECT ${f.column_name}, COUNT(*) FROM ${g} 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 ${g}`;if(t==="api"&&n){a({id:yh(),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:yh(),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 _.jsx(kl,{className:" h-[70vh] mt-2 xbg-red-100 px-3",children:e==null?void 0:e.map(f=>{const p=s==null?void 0:s.find(g=>g.column===f.column_name&&g.table===o&&g.database===r);return _.jsx("div",{onClick:()=>d(f),className:Pe(" 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 ":p}),children:_.jsxs("div",{className:"flex items-center gap-2 ",children:[_.jsx(hM,{column:f}),_.jsx("span",{children:f.column_name})]})},f.column_name)})})}function die(){ge(t=>t.showFilters);const e=ge(t=>t.actions.setShowFilters);return _.jsxs("section",{className:" relative space-y-4 py-0 px-4 border-muted bg-red-x100",children:[_.jsx(it,{onClick:()=>e(!1),className:" p-0 h-7 w-7 absolute top-0 right-4",variant:"outline",children:_.jsx(ia,{})}),_.jsx("p",{className:"text-md px-2",children:"Data Columns"}),_.jsx("div",{children:_.jsx(pM,{ColumnsComponent:(t,n,r)=>_.jsx(uie,{schemaName:t,tableName:n,columns:r})})})]})}function fie(){ge(n=>n.dashboard);const e=ge(n=>n.showFilters),t=ge(n=>n.isVisualEditing);return ge(n=>n.bookmarkKey),_.jsxs("div",{role:"dashboard-plus-main",className:Pe("flex grow",{hidden:t,block:!t}),children:[_.jsx(QP,{}),e&&_.jsx("div",{role:"filter-aside-container",className:"",children:_.jsx(die,{})})]})}function hie(){const e=ge(r=>r.dashboard),t=ge(r=>r.actions.setDashboard),n=ge(r=>r.showDashboardJSON);return ge(r=>r.actions.setShowDashboardJSON),_.jsx("div",{className:Pe(" p-2",{hidden:!n}),children:_.jsx(nD,{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 pie({showControls:e=!1,showFooter:t=!0,...n}){return ge(r=>r.isVisualEditing),_.jsxs(ZP,{children:[_.jsx(hie,{}),_.jsxs(Kw,{...n,children:[e&&_.jsx(XK,{}),_.jsx(cie,{}),_.jsx(fie,{})]})]})}function gie(){const e=ge(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}}ct.Dashboard=JP,ct.DashboardPlus=pie,ct.DashboardWC=YG,ct.cleanCard=Pk,ct.getBookmarkKey=ss,ct.getDashbaordStateWithoutData=by,ct.useActions=gie,ct.useDashboardStore=ge,Object.defineProperty(ct,Symbol.toStringTag,{value:"Module"})});
505
+ Visual Query Syntax: ${Vne}`,{data:w,isLoading:S,isFetching:C,isError:P,refetch:O}=Sr({queryKey:["ai-query"],queryFn:()=>tl("https://semaphor.cloud/api/v1/ai",(s==null?void 0:s.accessToken)||"",{user_content:`userContent: ${y} ${a?x:""}`}),enabled:!1});function k(X){if(X.toLowerCase().includes("bar"))f("bar");else if(X.toLowerCase().includes("line"))f("line");else if(X.toLowerCase().includes("bubble"))f("bubble");else if(X.toLowerCase().includes("scatter"))f("scatter");else if(X.toLowerCase().includes("stacked"))f("stackedBar");else if(X.toLowerCase().includes("pie"))f("pie");else if(X.toLowerCase().includes("donut")||X.toLowerCase().includes("doughnut"))f("doughnut");else if(X.toLowerCase().includes("radar"))f("radar");else return f("bar"),!1;return!0}function A(){n&&(k(n)&&l(!0),O())}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},z={fontFamily:"Arial, sans-serif",lineHeight:1.6,fontSize:15,padding:"2px 0",marginLeft:20,listStyleType:"disc"},B={p:({node:X,...K})=>_.jsx("p",{style:L,...K}),pre:({node:X,...K})=>_.jsxs("pre",{className:" bg-muted/50 space-y-2 p-3 rounded-sm",style:F,children:[_.jsx("code",{className:" whitespace-normal",children:K.children}),_.jsxs("div",{className:" flex justify-start gap-2",children:[_.jsx(it,{onClick:V,size:"sm",variant:"outline",children:_.jsx(JE,{})}),_.jsx(it,{onClick:$=>{const J=V($);J&&(t(!1),c(J),d(!0))},size:"sm",variant:"outline",children:_.jsx(Zj,{})})]})]}),li:({node:X,...K})=>_.jsx("li",{style:z,...K})};function V(X){const K=X.currentTarget.closest("pre");if(!K)return;const $=K.textContent||K.innerText;return navigator.clipboard.writeText($).then(()=>console.log("Text copied to clipboard")).catch(J=>console.error("Error in copying text: ",J)),$}return _.jsxs(wy,{open:e,onOpenChange:t,children:[_.jsx(_y,{asChild:!0,children:_.jsx(it,{size:"sm",className:"",variant:"outline",children:_.jsx(nV,{strokeWidth:1,size:16})})}),_.jsxs(_p,{className:" border-muted sm:max-w-[425px] md:min-w-[625px] md:max-h-[625px] flex flex-col justify-between overflow-auto",children:[_.jsxs(Sp,{children:[_.jsx(Cp,{children:"Ask"}),_.jsx(Ep,{children:"Need assistance with SQL queries? Feel free to ask me any question!"})]}),_.jsx(kl,{className:"h-[625px] w-full border-t border-t-muted ",children:(!S||!C)&&_.jsx(zne,{className:" pl-1 pr-3 py-1 w-full xbg-red-100 overflow-auto ",components:B,children:w==null?void 0:w.response})}),_.jsxs("div",{children:[_.jsx(lf,{className:Pe(" invisible h-1 w-full animate-pulse",{visible:S||C})}),_.jsxs("div",{className:" border rounded-md flex items-center w-full",children:[_.jsx(By,{onKeyDown:X=>{X.key==="Enter"&&!X.shiftKey&&(X.preventDefault(),r(""),A())},placeholder:"Type something...",onFocus:X=>{const K=X.target,$=K.value.length;K.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:X=>r(X.target.value)})," ",_.jsx(it,{className:"h-8",size:"sm",variant:"ghost",onClick:A,children:!S&&!C?_.jsx(Xj,{}):_.jsx(ku,{className:" w-4 h-4 animate-spin mr-2 text-foreground/50"})})]})]})]})]})}function Wne(){const{theme:e}=Em(),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=ge(H=>H.authToken),p=_e(H=>H.card),g=ge(H=>H.theme),v=_e(H=>H.selectedConnectionId),y=_e(H=>H.selectedDatabaseName),x=_e(H=>H.selectedSchemaName),w=_e(H=>H.selectedTableName),S=_e(H=>H.actions.setCardSql),C=_e(H=>H.card.sql),P=_e(H=>H.selectedConnectionId),O=_e(H=>H.filterValues),k=_e(H=>H.applyFilters),A=_e(H=>H.actions.setCardCustomCfg),L=_e(H=>H.actions.setFilterValues),F=_e(H=>H.onSave),z=_e(H=>H.actions.setApplyFilters),B=_e(H=>H.onClose),V=_e(H=>H.actions.setCardData),X=_e(H=>H.actions.setSqlGen),K=_e(H=>H.runSql),$=_e(H=>H.actions.setRunSql),J=_e(H=>H.actions.setIsSqlRunning),{data:G,isLoading:q,isFetching:se,isSuccess:D,isError:W,error:re,status:N,refetch:ne}=Sr({queryKey:[C],queryFn:()=>Is("https://semaphor.cloud/api/v1/query",(f==null?void 0:f.accessToken)||"",{connection_id:P,sql:C,active_filters:k?O:[]}),enabled:!1,retry:!1});m.useEffect(()=>{G&&(console.log("queryData",G),V(G.records))},[G,V]),m.useEffect(()=>{K&&(ne(),$(!1))},[K,ne,$]),m.useEffect(()=>{(q||se)&&J(!0),(W||D)&&J(!1)},[q,se,W,D,J]);function me(){S(""),V([]),X({}),A("")}const he=H=>{n.current=H};function de(){if(C&&!C.includes("{{")){const H=cZ(C);S(H),F==null||F({...p,sql:H,lastSelectedSchema:x,lastSelectedDatabase:y,lastSelectedTable:w,connectionId:v})}else F==null||F(p)}function ie(){B==null||B()}m.useEffect(()=>{const H=t.current,ye=n.current;if(H){const oe=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",Te=g==="system"?oe:g;H.editor.defineTheme("default",{base:Te==="light"?"vs":"vs-dark",inherit:!0,rules:[],colors:{"editor.background":Te==="light"?"#ffffff":"#020817"}}),H.editor.setTheme("default")}return ye&&H&&ye.addCommand(H.KeyMod.Shift|H.KeyCode.Enter,function(){return console.log("Executing query..."),ne(),!1}),()=>{}},[e,g,t.current]);function ee(H){t.current=H}return _.jsxs("section",{role:"editor-section",className:"grow flex flex-col justify-end pt-3 p-1 ",children:[_.jsxs("div",{className:" grow flex relative overflow-y-scroll justify-between ",children:[_.jsx("div",{role:"editor-container",className:`flex ${r?"w-2/3":"w-[95%]"} xbg-red-100 p-1`,children:_.jsx(Ry,{theme:"default",onChange:H=>{S(H),console.log(H)},value:C,options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"sql",defaultValue:"SELECT * FROM table",beforeMount:ee,onMount:he})}),r&&_.jsx("div",{className:" w-1/3 text-xs relative overflow-hidden xbg-yellow-100 p-1 ",children:_.jsxs("div",{className:"min-h-0 ",children:[_.jsxs("div",{className:"flex gap-2 items-center",children:[_.jsx(_Z,{checked:k,onCheckedChange:()=>z(!k),text:"Apply Filters"}),_.jsx(SZ,{})]}),_.jsx(Ry,{theme:"default",onChange:H=>{if(H)try{JSON.parse(H),L(JSON.parse(H))}catch{}},defaultLanguage:"json",className:"min-h-[220px] mt-1",value:JSON.stringify(O,null,2),options:{readOnly:!0,minimap:{enabled:!1},lineNumbers:"off",glyphMargin:!1,wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:12,renderLineHighlight:"none"}})]})}),O&&r&&_.jsx(ia,{onClick:()=>i(!1),className:"absolute right-6 top-1 w-3 h-3 text-foreground/50 hover:text-foreground hover:cursor-pointer"}),O&&!r&&_.jsx(W2,{onClick:()=>i(!0),className:Pe("absolute right-6 top-1 w-3 h-3 text-foreground/50 hover:text-foreground hover:cursor-pointer",{"text-red-800 font-bold":k})})]}),_.jsxs("div",{className:" flex grow px-6 pt-3 pb-4 gap-2 justify-between item-center",children:[_.jsxs("div",{className:"flex grow gap-2 items-center",children:[_.jsxs(it,{disabled:q||se,onClick:()=>{ne()},className:" shrink-0",size:"sm",variant:"outline",children:[(q||se)&&_.jsx(ku,{className:"w-4 h-4 mr-2 animate-spin text-foreground/50"}),"Run"]}),W&&_.jsx(wZ,{error:re.message}),_.jsx(it,{onClick:me,className:"",size:"sm",variant:"outline",children:"Clear"}),_.jsx(Ku,{value:a,placeholder:"Type something...",onChange:H=>{l(H.target.value)},onKeyDown:H=>{H.key==="Enter"&&(H.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"}),_.jsx(Hne,{open:o,setOpen:s,userInput:a,triggerAIRun:c,setTriggerAIRun:d,setUserInput:H=>l(H)})]}),_.jsxs("div",{className:"flex gap-2 items-end ",children:[_.jsx(it,{onClick:de,size:"sm",variant:"outline",children:_.jsx(Rh,{size:16,strokeWidth:2,className:"text-green-600 font-bold"})}),_.jsx(it,{onClick:ie,className:" w-full",size:"sm",variant:"outline",children:_.jsx(ia,{className:" h-3.5 w-3.5"})})]})]})]})}const $T="Switch",[qne,Sfe]=Pn($T),[Une,Gne]=qne($T),Yne=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,p]=m.useState(null),g=et(t,S=>p(S)),v=m.useRef(!1),y=f?!!f.closest("form"):!0,[x=!1,w]=Qn({prop:i,defaultProp:o,onChange:c});return m.createElement(Une,{scope:n,checked:x,disabled:a},m.createElement(Be.button,le({type:"button",role:"switch","aria-checked":x,"aria-required":s,"data-state":FT(x),"data-disabled":a?"":void 0,disabled:a,value:l},d,{ref:g,onClick:Ce(e.onClick,S=>{w(C=>!C),y&&(v.current=S.isPropagationStopped(),v.current||S.stopPropagation())})})),y&&m.createElement(Qne,{control:f,bubbles:!v.current,name:r,value:l,checked:x,required:s,disabled:a,style:{transform:"translateX(-100%)"}}))}),Kne="SwitchThumb",Xne=m.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,i=Gne(Kne,n);return m.createElement(Be.span,le({"data-state":FT(i.checked),"data-disabled":i.disabled?"":void 0},r,{ref:t}))}),Qne=e=>{const{control:t,checked:n,bubbles:r=!0,...i}=e,o=m.useRef(null),s=Op(n),a=Mh(t);return m.useEffect(()=>{const l=o.current,c=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(c,"checked").set;if(s!==n&&f){const p=new Event("click",{bubbles:r});f.call(l,n),l.dispatchEvent(p)}},[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 FT(e){return e?"checked":"unchecked"}const jT=Yne,Zne=Xne,zT=ue.forwardRef(({className:e,...t},n)=>_.jsx(jT,{className:Pe("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:_.jsx(Zne,{className:Pe("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")})}));zT.displayName=jT.displayName;function BT({className:e,...t}){const[n,r]=m.useState(0),i=ge(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=kb({data:o.data,cardType:o.type,cfg:o.cfg,customCfg:o.customCfg})),_.jsxs(Mv,{role:"editor-visual-card",className:Pe(" relative h-full flex flex-col rounded-none",e),...t,children:[_.jsxs(Dv,{children:[_.jsx(qc,{text:o.title,onSave:l=>s({...o,title:l}),children:_.jsx(Tv,{className:"text-base",children:o.title})}),_.jsx(qc,{text:o.description||"",onSave:l=>s({...o,description:l}),children:_.jsxs(Av,{children:[" ",o.description]})})]}),_.jsxs(Iv,{className:"flex flex-col pb-3 grow",children:[o.type!=="table"&&a&&_.jsx(QE,{cfg:a},n),o.type==="table"&&o.data&&o.data.length>0&&_.jsx(cO,{children:_.jsx(a0,{data:o==null?void 0:o.data})})]})]})}function Jne(){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,P;const w={...x,data:{...x==null?void 0:x.data,datasets:(P=(C=x==null?void 0:x.data)==null?void 0:C.datasets)==null?void 0:P.map(O=>({...O,data:[]}))}};return JSON.stringify(w,null,1)}function p(){if(!l.data||l.data.length===0)return;const x=kb({data:l.data,cardType:l.type,cfg:l.cfg});x&&(r(JSON.stringify(x,null,1)),c&&o(JSON.stringify(c,null,1)))}function g(){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=$s.cloneDeep(l.cfg),S=$s.merge(w,c);return x=f(S),x}return n?(x=f(JSON.parse(n)),x):""}return _.jsxs(wy,{open:e,onOpenChange:t,children:[_.jsx(_y,{asChild:!0,children:_.jsx(it,{onClick:p,className:`h-7 ${c&&"border-foreground/50 dark:border-foreground/70"}`,size:"sm",variant:"outline",children:c?"Custom Config":"Customize"})}),_.jsx(_p,{className:" sm:max-w-[425px] md:min-w-[600px] md:min-h-[700px] lg:min-w-[800px] xl:min-w-[1000px]",children:_.jsxs("div",{className:"bg-red-x100 flex flex-col gap-2 justify-between",children:[_.jsxs(Sp,{className:"",children:[_.jsx(Cp,{children:"Customize Chart"}),_.jsxs(Ep,{children:["See the configuration options and documentation",_.jsx("a",{target:"_blank",className:"ml-1 underline text-blue-500 ",href:"https://www.chartjs.org/docs/latest/samples/bar/vertical.html",children:"here."})]})]}),_.jsxs("div",{className:"grow flex flex-wrap gap-2",children:[_.jsx(BT,{className:"flex-1 rounded shadow-none"}),_.jsxs(a_,{defaultValue:"custom-config",className:" flex flex-col flex-1",children:[_.jsxs(l_,{className:" justify-start border rounded-sm rounded-b-none border-b-0 ",children:[_.jsxs(Im,{value:"custom-config",children:[c&&_.jsx(ZE,{className:"w-5 h-5 mr-1 text-green-600"}),c?"Custom Config":"Default Config"]}),_.jsx(Im,{className:"",value:"output",children:"Output"})]}),_.jsx(ff,{className:" grow mt-0 bg-red-x p-2 border border-t-0 rounded-b ",value:"output",children:_.jsx(By,{disabled:!0,value:n,className:" border-none resize-none font-mono h-full focus-visible:ring-0 focus-visible:ring-offset-0"})}),_.jsx(ff,{className:"grow mt-0 border border-t-0 rounded-b ",value:"custom-config",children:_.jsx(Ry,{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)})})]})]}),_.jsxs(Sy,{className:"flex items-center",children:[_.jsx(ns,{className:"text-red-500 mr-2",children:s}),_.jsx(it,{disabled:!c,onClick:v,variant:"outline",children:"Reset"}),_.jsx(it,{onClick:g,variant:"outline",children:"Apply"}),_.jsx(it,{onClick:()=>t(!1),variant:"outline",children:"Close"})]})]})})]})}var VT={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},HT=m.createContext&&m.createContext(VT),ere=["attr","size","title"];function tre(e,t){if(e==null)return{};var n=nre(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 nre(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 tg(){return tg=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},tg.apply(this,arguments)}function WT(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 ng(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?WT(Object(n),!0).forEach(function(r){rre(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):WT(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function rre(e,t,n){return t=ire(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ire(e){var t=ore(e,"string");return typeof t=="symbol"?t:String(t)}function ore(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 qT(e){return e&&e.map((t,n)=>m.createElement(t.tag,ng({key:n},t.attr),qT(t.child)))}function dd(e){return t=>m.createElement(sre,tg({attr:ng({},e.attr)},t),qT(e.child))}function sre(e){var t=n=>{var{attr:r,size:i,title:o}=e,s=tre(e,ere),a=i||n.size||"1em",l;return n.className&&(l=n.className),e.className&&(l=(l?l+" ":"")+e.className),m.createElement("svg",tg({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},n.attr,r,s,{className:l,style:ng(ng({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 HT!==void 0?m.createElement(HT.Consumer,null,n=>t(n)):t(VT)}function UT(e){return dd({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 GT(e){return dd({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 YT(e){return dd({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 KT(e){return dd({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 XT(e){return dd({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 are(){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 _.jsxs(pp,{open:e,onOpenChange:t,children:[_.jsx(gp,{asChild:!0,children:_.jsx(it,{className:"h-7 px-2",variant:"outline",children:_.jsx(lre,{className:"h-4 w-4",chartType:n})})}),_.jsx(Wu,{className:"w-50",children:_.jsxs("div",{className:"grid grid-cols-3 place-items-center ",children:[_.jsx(it,{onClick:()=>o("bar"),className:"font-normal",variant:"ghost",children:_.jsx(B2,{strokeWidth:1})}),_.jsx(it,{onClick:()=>o("line"),variant:"ghost",children:_.jsx(q2,{strokeWidth:1})}),_.jsx(it,{onClick:()=>o("stackedBar"),variant:"ghost",children:_.jsx(XT,{className:"h-6 w-6 text-foreground/50 ",strokeWidth:0})}),_.jsx(it,{onClick:()=>o("scatter"),variant:"ghost",children:_.jsx(G2,{strokeWidth:1})}),_.jsx(it,{onClick:()=>o("bubble"),variant:"ghost",children:_.jsx(KT,{strokeWidth:2})}),_.jsx(it,{onClick:()=>o("pie"),variant:"ghost",children:_.jsx(U2,{strokeWidth:1})}),_.jsx(it,{onClick:()=>o("doughnut"),variant:"ghost",children:_.jsx(YT,{className:"h-7 w-7",strokeWidth:.5})}),_.jsx(it,{onClick:()=>o("radar"),variant:"ghost",children:_.jsx(UT,{className:"h-6 w-6 text-foreground/50 font-extralight",strokeWidth:.5})}),_.jsx(it,{onClick:()=>o("polarArea"),variant:"ghost",children:_.jsx(GT,{className:"h-6 w-6 text-foreground/50",strokeWidth:1})}),_.jsx(it,{onClick:()=>o("table"),variant:"ghost",children:_.jsx(qb,{className:"h-6 w-6 text-foreground/90",strokeWidth:1})})]})})]})}function lre({chartType:e,className:t}){switch(e){case"bar":return _.jsx(B2,{className:t});case"line":return _.jsx(q2,{className:t});case"pie":return _.jsx(U2,{className:t});case"radar":return _.jsx(UT,{className:t});case"scatter":return _.jsx(G2,{className:t});case"bubble":return _.jsx(KT,{className:t});case"doughnut":return _.jsx(YT,{className:t});case"stackedBar":return _.jsx(XT,{className:"h-5 w-5 text-foreground/50 ",strokeWidth:0});case"polarArea":return _.jsx(GT,{className:t});default:return _.jsx(qb,{className:t})}}function cre(){const e=_e(n=>n.card.refreshInterval),t=_e(n=>n.actions.setCardRefreshInterval);return _.jsxs(pp,{children:[_.jsx(gp,{asChild:!0,children:_.jsx(it,{className:"h-7",variant:"outline",children:"Realtime"})}),_.jsx(Wu,{className:"w-[200px]",children:_.jsx("div",{className:"grid gap-4",children:_.jsx("div",{className:"grid gap-2",children:_.jsxs("div",{className:"grid grid-cols-5 items-center gap-1",children:[_.jsx(ns,{className:"col-span-3",htmlFor:"width",children:"Refresh Every"}),_.jsx(Ku,{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),_.jsxs("div",{className:" h-full relative flex flex-col",children:[n&&_.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 "}),_.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&&_.jsxs("div",{className:"bg-red-x00 flex grow gap-2",children:[_.jsx(are,{}),_.jsx(Jne,{}),_.jsx(cre,{})]}),_.jsx(ure,{})]}),t?_.jsx(BT,{className:"grow border-none shadow-none "}):_.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&&_.jsx(a0,{data:e.data})})]})}function ure(){const e=_e(n=>n.isShowingVisual),t=_e(n=>n.actions.setIsShowingVisual);return _.jsxs("div",{className:" flex items-center space-x-2",children:[_.jsx(ns,{htmlFor:"visualize",children:"Chart"}),_.jsx(zT,{checked:e,onCheckedChange:()=>t(!e),id:"visualize",className:"data-[state=checked]:bg-foreground/50"})]})}const ZT="Collapsible",[dre,JT]=Pn(ZT),[fre,_x]=dre(ZT),hre=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(fre,{scope:n,disabled:o,contentId:or(),open:l,onOpenToggle:m.useCallback(()=>c(d=>!d),[c])},m.createElement(Be.div,le({"data-state":Sx(l),"data-disabled":o?"":void 0},a,{ref:t})))}),pre="CollapsibleTrigger",gre=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,i=_x(pre,n);return m.createElement(Be.button,le({type:"button","aria-controls":i.contentId,"aria-expanded":i.open||!1,"data-state":Sx(i.open),"data-disabled":i.disabled?"":void 0,disabled:i.disabled},r,{ref:t,onClick:Ce(e.onClick,i.onOpenToggle)}))}),eA="CollapsibleContent",mre=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,i=_x(eA,e.__scopeCollapsible);return m.createElement(vn,{present:n||i.open},({present:o})=>m.createElement(vre,le({},r,{ref:t,present:o})))}),vre=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:i,...o}=e,s=_x(eA,n),[a,l]=m.useState(r),c=m.useRef(null),d=et(t,c),f=m.useRef(0),p=f.current,g=m.useRef(0),v=g.current,y=s.open||a,x=m.useRef(y),w=m.useRef();return m.useEffect(()=>{const S=requestAnimationFrame(()=>x.current=!1);return()=>cancelAnimationFrame(S)},[]),Vn(()=>{const S=c.current;if(S){w.current=w.current||{transitionDuration:S.style.transitionDuration,animationName:S.style.animationName},S.style.transitionDuration="0s",S.style.animationName="none";const C=S.getBoundingClientRect();f.current=C.height,g.current=C.width,x.current||(S.style.transitionDuration=w.current.transitionDuration,S.style.animationName=w.current.animationName),l(r)}},[s.open,r]),m.createElement(Be.div,le({"data-state":Sx(s.open),"data-disabled":s.disabled?"":void 0,id:s.contentId,hidden:!y},o,{ref:d,style:{"--radix-collapsible-content-height":p?`${p}px`:void 0,"--radix-collapsible-content-width":v?`${v}px`:void 0,...e.style}}),y&&i)});function Sx(e){return e?"open":"closed"}const bre=hre,yre=gre,xre=mre,us="Accordion",wre=["Home","End","ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],[Cx,_re,Sre]=uf(us),[rg,Cfe]=Pn(us,[Sre,JT]),Ex=JT(),tA=m.forwardRef((e,t)=>{const{type:n,...r}=e,i=r,o=r;return m.createElement(Cx.Provider,{scope:e.__scopeAccordion},n==="multiple"?m.createElement(Pre,le({},o,{ref:t})):m.createElement(Ore,le({},i,{ref:t})))});tA.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[nA,Cre]=rg(us),[rA,Ere]=rg(us,{collapsible:!1}),Ore=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(nA,{scope:e.__scopeAccordion,value:a?[a]:[],onItemOpen:l,onItemClose:m.useCallback(()=>o&&l(""),[o,l])},m.createElement(rA,{scope:e.__scopeAccordion,collapsible:o},m.createElement(iA,le({},s,{ref:t}))))}),Pre=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(p=>p!==d)),[a]);return m.createElement(nA,{scope:e.__scopeAccordion,value:s,onItemOpen:l,onItemClose:c},m.createElement(rA,{scope:e.__scopeAccordion,collapsible:!0},m.createElement(iA,le({},o,{ref:t}))))}),[kre,ig]=rg(us),iA=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=_re(n),f=Fs(i)==="ltr",p=Ce(e.onKeyDown,g=>{var v;if(!wre.includes(g.key))return;const y=g.target,x=c().filter(F=>{var z;return!((z=F.ref.current)!==null&&z!==void 0&&z.disabled)}),w=x.findIndex(F=>F.ref.current===y),S=x.length;if(w===-1)return;g.preventDefault();let C=w;const P=0,O=S-1,k=()=>{C=w+1,C>O&&(C=P)},A=()=>{C=w-1,C<P&&(C=O)};switch(g.key){case"Home":C=P;break;case"End":C=O;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%S;(v=x[L].ref.current)===null||v===void 0||v.focus()});return m.createElement(kre,{scope:n,disabled:r,direction:i,orientation:o},m.createElement(Cx.Slot,{scope:n},m.createElement(Be.div,le({},s,{"data-orientation":o,ref:l,onKeyDown:r?void 0:p}))))}),Ox="AccordionItem",[Mre,Px]=rg(Ox),Dre=m.forwardRef((e,t)=>{const{__scopeAccordion:n,value:r,...i}=e,o=ig(Ox,n),s=Cre(Ox,n),a=Ex(n),l=or(),c=r&&s.value.includes(r)||!1,d=o.disabled||e.disabled;return m.createElement(Mre,{scope:n,open:c,disabled:d,triggerId:l},m.createElement(bre,le({"data-orientation":o.orientation,"data-state":sA(c)},a,i,{ref:t,disabled:d,open:c,onOpenChange:f=>{f?s.onItemOpen(r):s.onItemClose(r)}})))}),Tre="AccordionHeader",Are=m.forwardRef((e,t)=>{const{__scopeAccordion:n,...r}=e,i=ig(us,n),o=Px(Tre,n);return m.createElement(Be.h3,le({"data-orientation":i.orientation,"data-state":sA(o.open),"data-disabled":o.disabled?"":void 0},r,{ref:t}))}),oA="AccordionTrigger",Ire=m.forwardRef((e,t)=>{const{__scopeAccordion:n,...r}=e,i=ig(us,n),o=Px(oA,n),s=Ere(oA,n),a=Ex(n);return m.createElement(Cx.ItemSlot,{scope:n},m.createElement(yre,le({"aria-disabled":o.open&&!s.collapsible||void 0,"data-orientation":i.orientation,id:o.triggerId},a,r,{ref:t})))}),Nre="AccordionContent",Rre=m.forwardRef((e,t)=>{const{__scopeAccordion:n,...r}=e,i=ig(us,n),o=Px(Nre,n),s=Ex(n);return m.createElement(xre,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 sA(e){return e?"open":"closed"}const Lre=tA,$re=Dre,Fre=Are,aA=Ire,lA=Rre,cA=Lre,ds=ue.forwardRef(({className:e,...t},n)=>_.jsx($re,{ref:n,className:Pe("border-b",e),...t}));ds.displayName="AccordionItem";const fs=ue.forwardRef(({className:e,children:t,...n},r)=>_.jsx(Fre,{className:"flex",children:_.jsxs(aA,{ref:r,className:Pe("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,_.jsx(Wb,{className:"h-4 w-4 shrink-0 transition-transform duration-200"})]})}));fs.displayName=aA.displayName;const hs=ue.forwardRef(({className:e,children:t,...n},r)=>_.jsx(lA,{ref:r,className:"overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...n,children:_.jsx("div",{className:Pe("pb-4 pt-0",e),children:t})}));hs.displayName=lA.displayName;const uA="Radio",[jre,dA]=Pn(uA),[zre,Bre]=jre(uA),Vre=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),p=et(t,y=>f(y)),g=m.useRef(!1),v=d?!!d.closest("form"):!0;return m.createElement(zre,{scope:n,checked:i,disabled:s},m.createElement(Be.button,le({type:"button",role:"radio","aria-checked":i,"data-state":fA(i),"data-disabled":s?"":void 0,disabled:s,value:a},c,{ref:p,onClick:Ce(e.onClick,y=>{i||l==null||l(),v&&(g.current=y.isPropagationStopped(),g.current||y.stopPropagation())})})),v&&m.createElement(qre,{control:d,bubbles:!g.current,name:r,value:a,checked:i,required:o,disabled:s,style:{transform:"translateX(-100%)"}}))}),Hre="RadioIndicator",Wre=m.forwardRef((e,t)=>{const{__scopeRadio:n,forceMount:r,...i}=e,o=Bre(Hre,n);return m.createElement(vn,{present:r||o.checked},m.createElement(Be.span,le({"data-state":fA(o.checked),"data-disabled":o.disabled?"":void 0},i,{ref:t})))}),qre=e=>{const{control:t,checked:n,bubbles:r=!0,...i}=e,o=m.useRef(null),s=Op(n),a=Mh(t);return m.useEffect(()=>{const l=o.current,c=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(c,"checked").set;if(s!==n&&f){const p=new Event("click",{bubbles:r});f.call(l,n),l.dispatchEvent(p)}},[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 fA(e){return e?"checked":"unchecked"}const Ure=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],hA="RadioGroup",[Gre,Efe]=Pn(hA,[ol,dA]),pA=ol(),gA=dA(),[Yre,Kre]=Gre(hA),Xre=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,...p}=e,g=pA(n),v=Fs(c),[y,x]=Qn({prop:o,defaultProp:i,onChange:f});return m.createElement(Yre,{scope:n,name:r,required:s,disabled:a,value:y,onValueChange:x},m.createElement(Dm,le({asChild:!0},g,{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},p,{ref:t}))))}),Qre="RadioGroupItem",Zre=m.forwardRef((e,t)=>{const{__scopeRadioGroup:n,disabled:r,...i}=e,o=Kre(Qre,n),s=o.disabled||r,a=pA(n),l=gA(n),c=m.useRef(null),d=et(t,c),f=o.value===i.value,p=m.useRef(!1);return m.useEffect(()=>{const g=y=>{Ure.includes(y.key)&&(p.current=!0)},v=()=>p.current=!1;return document.addEventListener("keydown",g),document.addEventListener("keyup",v),()=>{document.removeEventListener("keydown",g),document.removeEventListener("keyup",v)}},[]),m.createElement(Tm,le({asChild:!0},a,{focusable:!s,active:f}),m.createElement(Vre,le({disabled:s,required:o.required,checked:f},l,i,{name:o.name,ref:d,onCheck:()=>o.onValueChange(i.value),onKeyDown:Ce(g=>{g.key==="Enter"&&g.preventDefault()}),onFocus:Ce(i.onFocus,()=>{var g;p.current&&((g=c.current)===null||g===void 0||g.click())})})))}),Jre=m.forwardRef((e,t)=>{const{__scopeRadioGroup:n,...r}=e,i=gA(n);return m.createElement(Wre,le({},i,r,{ref:t}))}),mA=Xre,vA=Zre,eie=Jre,bA=ue.forwardRef(({className:e,...t},n)=>_.jsx(mA,{className:Pe("grid gap-2",e),...t,ref:n}));bA.displayName=mA.displayName;const kx=ue.forwardRef(({className:e,...t},n)=>_.jsx(vA,{ref:n,className:Pe("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:_.jsx(eie,{className:"flex items-center justify-center",children:_.jsx(H2,{className:"h-2.5 w-2.5 fill-current text-current"})})}));kx.displayName=vA.displayName;function yA(){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 _.jsxs("div",{children:[_.jsx("p",{className:"font-semibold",children:"Orientation"}),_.jsxs(bA,{value:n,onValueChange:r,className:"flex gap-3 mt-2 ",defaultValue:"x",children:[_.jsxs("div",{className:"flex items-center space-x-2",children:[_.jsx(kx,{value:"x",id:"r1"}),_.jsx("label",{className:"text-sm",htmlFor:"r1",children:"Vertical"})]}),_.jsxs("div",{className:"flex items-center space-x-2",children:[_.jsx(kx,{value:"y",id:"r2"}),_.jsx("label",{className:"text-sm",htmlFor:"r2",children:"Horizontal"})]})]})]})}function xA(){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 _.jsxs(_.Fragment,{children:[_.jsx("label",{className:"font-medium",children:"Data Labels"}),_.jsxs(lM,{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:[_.jsx(Py,{className:"w-[180px] mt-2 focus:ring-1 focus:ring-offset-0 h-7",children:_.jsx(uM,{placeholder:"Select position"})}),_.jsx(ky,{children:_.jsxs(cM,{children:[_.jsx(Ap,{children:"Data Labels"}),_.jsx(_a,{value:"none",children:"None"}),_.jsx(_a,{value:"start",children:"Start"}),_.jsx(_a,{value:"center",children:"Center"}),_.jsx(_a,{value:"end",children:"End"})]})})]})]})}function wA(){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 _.jsxs("div",{children:[_.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[_.jsx(Pp,{checked:!!(e!=null&&e.filterOnClick),onCheckedChange:i=>{t({...e,filterOnClick:!!i})}}),_.jsx(ns,{children:"Filter on click"})]}),(e==null?void 0:e.filterOnClick)===!0&&_.jsxs("div",{className:"flex gap-2 items-center",children:[_.jsx(Ku,{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)}),_.jsxs(Vb,{children:[_.jsx(L2,{children:_.jsx(e2,{className:"h-4 w-4 opacity-70"})}),_.jsx(Ih,{children:_.jsxs("div",{className:"max-w-[200px]",children:["The x-axis expression of your query. Example:",_.jsx("div",{className:" mt-1 text-xs font-mono",children:"TO_CHAR(order_date, 'YYYY-MM')"})]})})]})]})]})}const tie={datasets:[{type:"line",label:"Sum_sales",data:[]},{type:"bar",label:"Sum_profit",data:[]}]},nie={datasets:[{fill:"origin",type:"line",label:"Sum_sales",data:[]}]};function rie(){const e=_e(t=>t.card.type);return _.jsxs("div",{className:"p-6 space-y-6",children:[_.jsx(cA,{className:" ",type:"single",collapsible:!0,children:iie(e)}),_.jsx("section",{className:"",children:["line","bar"].includes(e)&&_.jsx(yA,{})}),_.jsx("div",{children:_.jsx(xA,{})}),_.jsx("div",{children:_.jsx(wA,{})})]})}function iie(e){if(["line","bar"].includes(e))return _.jsxs(_.Fragment,{children:[_.jsxs(ds,{className:"border-muted",value:"item-1",children:[_.jsx(fs,{className:" font-normal",children:_.jsx("p",{children:"Chart Query"})}),_.jsxs(hs,{className:" ",children:[_.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"}),_.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs",children:[_.jsx("li",{children:"X-axis - Category (ex. city)"}),_.jsx("li",{children:"Y-axis - Number (ex. population)"})]})]})]}),_.jsxs(ds,{className:"border-muted",value:"item-2",children:[_.jsx(fs,{className:" font-normal",children:"Mixed Chart"}),_.jsxs(hs,{className:" text-xs space-y-2",children:[_.jsxs("p",{children:["Click ",_.jsx("b",{children:"Customize"})," and change the `type` property in the dataset."]}),_.jsx("pre",{children:JSON.stringify(tie,null,2)})]})]}),_.jsxs(ds,{className:"border-muted",value:"item-3",children:[_.jsx(fs,{className:" font-normal",children:"Area Chart"}),_.jsxs(hs,{className:" text-xs space-y-2",children:[_.jsxs("p",{children:["Click ",_.jsx("b",{children:"Customize"})," and add `fill` property to the dataset. See",_.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."]}),_.jsx("pre",{children:JSON.stringify(nie,null,2)})]})]})]});if(e==="bubble")return _.jsx(_.Fragment,{children:_.jsxs(ds,{className:"border-muted",value:"item-1",children:[_.jsx(fs,{className:" font-normal",children:_.jsxs("p",{children:["How to create a ",_.jsx("span",{children:e})," chart query?"]})}),_.jsxs(hs,{className:" ",children:[_.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"}),_.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs",children:[_.jsx("li",{children:"Label - Category (ex. city)"}),_.jsx("li",{children:"Bubble Group (opt) - Category (ex. state)"}),_.jsx("li",{children:"X-axis - Number (ex. avg. age)"}),_.jsx("li",{children:"Y-axis - Number (ex. avg. weight)"}),_.jsx("li",{children:"Radius - Number (ex. population)"})]})]})]})});if(e==="scatter")return _.jsx(_.Fragment,{children:_.jsxs(ds,{value:"item-1",children:[_.jsx(fs,{className:" font-normal",children:_.jsxs("p",{children:["How to create a ",_.jsx("span",{children:e})," chart query?"]})}),_.jsxs(hs,{className:" ",children:[_.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"}),_.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs",children:[_.jsx("li",{children:"Label - Category (ex. city)"}),_.jsx("li",{children:"Group (opt) - Category (ex. state)"}),_.jsx("li",{children:"X-axis - Number (ex. avg. age)"}),_.jsx("li",{children:"Y-axis - Number (ex. avg. weight)"})]})]})]})});if(["pie","doughnut","polarArea"].includes(e))return _.jsx(_.Fragment,{children:_.jsxs(ds,{value:"item-1",children:[_.jsx(fs,{className:" font-normal",children:_.jsxs("p",{children:["How to create a"," ",_.jsxs("span",{children:[e==="polarArea"?"polar":e," "]})," ","chart query?"]})}),_.jsxs(hs,{className:" ",children:[_.jsx("div",{className:"bg-muted px-2 py-1 rounded font-mono font-semibold text-xs",children:"SELECT label, measure FROM table"}),_.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs",children:[_.jsx("li",{children:"Label - Category (ex. city)"}),_.jsx("li",{children:"Measure - Number (ex. population)"})]})]})]})})}function oie(){return _.jsxs("div",{className:"px-6 py-2 space-y-6",children:[_.jsx(cA,{className:" ",type:"single",collapsible:!0,children:_.jsxs(ds,{className:"border-muted",value:"item-1",children:[_.jsx(fs,{className:" font-normal",children:"Stacked chart query?"}),_.jsxs(hs,{className:" ",children:[_.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"}),_.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs",children:[_.jsx("li",{children:"X-axis - Category (ex. country)"}),_.jsx("li",{children:"Stack by - Category (ex. city)"}),_.jsx("li",{children:"Y-axis - Number (ex. population)"})]})]})]})}),_.jsx("section",{className:"",children:_.jsx(yA,{})}),_.jsx("div",{children:_.jsx(xA,{})}),_.jsx("div",{children:_.jsx(wA,{})})]})}function sie(){const e=_e(t=>t.card.type);return _.jsx(kl,{className:" text-sm h-full w-full ",children:e==="stackedBar"?_.jsx(oie,{}):_.jsx(rie,{})})}function aie(){const e=_e(t=>t.isShowingVisual);return _.jsxs(zM,{direction:"vertical",className:"min-w-full max-w-lg min-h-[250px]",children:[_.jsx(Fp,{className:"flex",minSize:40,defaultSize:40,children:_.jsx(Wne,{})}),_.jsx(BM,{className:"border-[1.5px] border-muted"}),_.jsx(Fp,{minSize:60,defaultSize:60,children:e?_.jsxs(zM,{direction:"horizontal",children:[_.jsx(_.Fragment,{children:_.jsx(Fp,{className:"flex min-w-[275px]",minSize:20,defaultSize:25,maxSize:30,children:_.jsx(sie,{})})}),_.jsx(BM,{className:"border-[1.5px] border-muted"}),_.jsx(Fp,{minSize:40,defaultSize:75,maxSize:100,children:_.jsx(QT,{})})]}):_.jsx(QT,{})})]})}function lie({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=ge(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]),_.jsxs(Bk,{className:"border-x border-b rounded-none border-muted ",children:[_.jsx(Vk,{className:" rounded-none border-r-[3px] border-muted ",children:_.jsx(pM,{})}),_.jsx(Hk,{children:_.jsx(aie,{})})]})}function cie(){ge(s=>s.selectedCardId);const e=ge(s=>s.selectedSheetId),t=ge(s=>s.actions.setIsVisualEditing);ge(s=>s.actions.setIsEditorSaveEvent);const n=ge(s=>s.isVisualEditing);ge(s=>s.actions.getSelectedCard());const r=ge(s=>s.actions.updateCard);function i(s){e&&(r(e,s),t(!1))}function o(){t(!1)}return _.jsx("div",{role:"editor-container",className:Pe("grow flex",{block:n,hidden:!n}),children:_.jsx(lie,{onSave:i,onClose:o})})}function uie({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=ge(f=>f.dashboard.filters)||[],a=ge(f=>f.actions.addFilter),l=ge(f=>f.actions.removeFilter),c=ge(f=>f.actions.removeFilterValue);function d(f){const p=s==null?void 0:s.find(g=>g.column===f.column_name&&g.table===o&&g.database===r);if(p)c(p.id),l(p.id);else{const g=M0(i||"",t),v=`SELECT ${f.column_name}, COUNT(*) FROM ${g} 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 ${g}`;if(t==="api"&&n){a({id:yh(),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:yh(),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 _.jsx(kl,{className:" h-[70vh] mt-2 xbg-red-100 px-3",children:e==null?void 0:e.map(f=>{const p=s==null?void 0:s.find(g=>g.column===f.column_name&&g.table===o&&g.database===r);return _.jsx("div",{onClick:()=>d(f),className:Pe(" 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 ":p}),children:_.jsxs("div",{className:"flex items-center gap-2 ",children:[_.jsx(hM,{column:f}),_.jsx("span",{children:f.column_name})]})},f.column_name)})})}function die(){ge(t=>t.showFilters);const e=ge(t=>t.actions.setShowFilters);return _.jsxs("section",{className:" relative space-y-4 py-0 px-4 border-muted bg-red-x100",children:[_.jsx(it,{onClick:()=>e(!1),className:" p-0 h-7 w-7 absolute top-0 right-4",variant:"outline",children:_.jsx(ia,{})}),_.jsx("p",{className:"text-md px-2",children:"Data Columns"}),_.jsx("div",{children:_.jsx(pM,{ColumnsComponent:(t,n,r)=>_.jsx(uie,{schemaName:t,tableName:n,columns:r})})})]})}function fie(){ge(n=>n.dashboard);const e=ge(n=>n.showFilters),t=ge(n=>n.isVisualEditing);return ge(n=>n.bookmarkKey),_.jsxs("div",{role:"dashboard-plus-main",className:Pe(" grow",{hidden:t,flex:!t}),children:[_.jsx(QP,{}),e&&_.jsx("div",{role:"filter-aside-container",children:_.jsx(die,{})})]})}function hie(){const e=ge(r=>r.dashboard),t=ge(r=>r.actions.setDashboard),n=ge(r=>r.showDashboardJSON);return ge(r=>r.actions.setShowDashboardJSON),_.jsx("div",{className:Pe(" p-2",{hidden:!n}),children:_.jsx(nD,{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 pie({showControls:e=!1,showFooter:t=!0,...n}){return ge(r=>r.isVisualEditing),_.jsxs(ZP,{children:[_.jsx(hie,{}),_.jsxs(Kw,{...n,children:[e&&_.jsx(XK,{}),_.jsx(cie,{}),_.jsx(fie,{})]})]})}function gie(){const e=ge(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}}ct.Dashboard=JP,ct.DashboardPlus=pie,ct.DashboardWC=YG,ct.cleanCard=Pk,ct.getBookmarkKey=ss,ct.getDashbaordStateWithoutData=by,ct.useActions=gie,ct.useDashboardStore=ge,Object.defineProperty(ct,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.14",
8
+ "version": "0.0.15",
9
9
  "description": "Fully interactive and customizable dashboards for your apps.",
10
10
  "keywords": [
11
11
  "react",