react-semaphor 0.0.184 → 0.0.186

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { P as L, b as k, j as e, Q as us, R as xs, U as z, V as $s, W as ps, X as fs, Y as gs, Z as js, _ as R, $ as ae, a0 as Ks, J as Us, O as Ae, a1 as Ia, a2 as qa, a3 as Va, a4 as Ra, a5 as _a, a6 as Ha, a7 as Os, a8 as Re, a9 as $e, aa as We, T as bs, e as Ps, g as ys, ab as Fe, ac as Oe, f as W, ad as Me, ae as Te, af as _e, ag as Le, ah as X, ai as vs, G as r, aj as Ke, ak as Ue, al as Ba, am as Pe, w as Gs, v as Js, t as he, an as $a, r as Ka, N as Qs, s as Ua, ao as Pa, B as Ga, ap as Ws, aq as Ja, L as He, S as Ns, z as Qa, n as Ms, ar as Ts, A as cs, u as es, as as Ce, at as we, au as Ys, av as Xs, aw as Zs, ax as ea, ay as sa, az as Wa, aA as Ya, aB as aa, aC as Xa, aD as Za, aE as et, aF as st, aG as at, aH as ds, aI as tt, aJ as Ve, aK as hs, aL as ze, aM as ms, aN as As, aO as nt, aP as lt, aQ as rt, aR as it, aS as ot, aT as ls, aU as ct, aV as Ls, aW as dt, aX as Es, aY as ht, aZ as mt, a_ as ut, a$ as ta, l as xt, C as pt, E as Ds, d as ft, h as gt, i as jt, o as bt, b0 as yt, m as vt, H as Nt, b1 as Ct, b2 as St, b3 as kt, b4 as rs, b5 as wt, b6 as is, b7 as Is, K as zt, b8 as Cs, b9 as Ft, ba as na, bb as Ot, bc as la, bd as Ye, be as Mt, bf as Ee, bg as _, bh as H, bi as ra, bj as B, bk as qs, bl as Tt, bm as At, bn as Lt, bo as Et, bp as Dt, bq as It, br as qt, bs as Vt, bt as Vs, bu as Rt, bv as _t, bw as Ht, bx as Bt, by as $t, bz as Kt } from "./index-XM_hhHm4.js";
1
+ import { P as L, b as k, j as e, Q as us, R as xs, U as z, V as $s, W as ps, X as fs, Y as gs, Z as js, _ as R, $ as ae, a0 as Ks, J as Us, O as Ae, a1 as Ia, a2 as qa, a3 as Va, a4 as Ra, a5 as _a, a6 as Ha, a7 as Os, a8 as Re, a9 as $e, aa as We, T as bs, e as Ps, g as ys, ab as Fe, ac as Oe, f as W, ad as Me, ae as Te, af as _e, ag as Le, ah as X, ai as vs, G as r, aj as Ke, ak as Ue, al as Ba, am as Pe, w as Gs, v as Js, t as he, an as $a, r as Ka, N as Qs, s as Ua, ao as Pa, B as Ga, ap as Ws, aq as Ja, L as He, S as Ns, z as Qa, n as Ms, ar as Ts, A as cs, u as es, as as Ce, at as we, au as Ys, av as Xs, aw as Zs, ax as ea, ay as sa, az as Wa, aA as Ya, aB as aa, aC as Xa, aD as Za, aE as et, aF as st, aG as at, aH as ds, aI as tt, aJ as Ve, aK as hs, aL as ze, aM as ms, aN as As, aO as nt, aP as lt, aQ as rt, aR as it, aS as ot, aT as ls, aU as ct, aV as Ls, aW as dt, aX as Es, aY as ht, aZ as mt, a_ as ut, a$ as ta, l as xt, C as pt, E as Ds, d as ft, h as gt, i as jt, o as bt, b0 as yt, m as vt, H as Nt, b1 as Ct, b2 as St, b3 as kt, b4 as rs, b5 as wt, b6 as is, b7 as Is, K as zt, b8 as Cs, b9 as Ft, ba as na, bb as Ot, bc as la, bd as Ye, be as Mt, bf as Ee, bg as _, bh as H, bi as ra, bj as B, bk as qs, bl as Tt, bm as At, bn as Lt, bo as Et, bp as Dt, bq as It, br as qt, bs as Vt, bt as Vs, bu as Rt, bv as _t, bw as Ht, bx as Bt, by as $t, bz as Kt } from "./index-zzQRnCNa.js";
2
2
  import me, { useState as T, useEffect as K, useMemo as Ut, useRef as Be } from "react";
3
3
  /**
4
4
  * @license lucide-react v0.379.0 - ISC
@@ -3959,7 +3959,7 @@ const tl = /* @__PURE__ */ e.jsxs("div", { className: "space-y-4 font-mono text-
3959
3959
  target: "_blank",
3960
3960
  onClick: (s) => s.stopPropagation(),
3961
3961
  className: "text-blue-700",
3962
- href: "https://docs.semaphor.cloud/concepts/visuals#range-chart",
3962
+ href: "https://docs.semaphor.cloud/concepts/visuals#range-charts",
3963
3963
  children: "example"
3964
3964
  }
3965
3965
  ),
@@ -1,4 +1,4 @@
1
- "use strict";const e=require("./index-4uv99fdq.js"),f=require("react");/**
1
+ "use strict";const e=require("./index-WpPvkxrt.js"),f=require("react");/**
2
2
  * @license lucide-react v0.379.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -207,4 +207,4 @@ SELECT label, measure FROM table
207
207
  Table Columns: ${g==null?void 0:g.map(R=>`${R.column_name} | ${R.data_type}`).join(", ")}
208
208
  User SQL: ${A}
209
209
  ${S&&`Base Queries: ${JSON.stringify(S)} `}`,E=` 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.
210
- Visual Query Syntax: ${Hs}`,{data:N,isLoading:z,isFetching:I,isError:_,refetch:F}=e.useQuery({queryKey:["ai-query"],queryFn:()=>e.getRequest("https://semaphor.cloud/api/v1/ai",(x==null?void 0:x.accessToken)||"",{user_content:`userContent: ${k} ${j?E:""}`}),enabled:!1});function O(R){if(R.toLowerCase().includes("bar"))m("bar");else if(R.toLowerCase().includes("line"))m("line");else if(R.toLowerCase().includes("bubble"))m("bubble");else if(R.toLowerCase().includes("scatter"))m("scatter");else if(R.toLowerCase().includes("stacked"))m("stackedBar");else if(R.toLowerCase().includes("pie"))m("pie");else if(R.toLowerCase().includes("donut")||R.toLowerCase().includes("doughnut"))m("doughnut");else if(R.toLowerCase().includes("radar"))m("radar");else return m("bar"),!1;return!0}f.useEffect(()=>{N&&C(R=>[...R,{role:"ai",content:N.response}])},[N]),f.useEffect(()=>{const R=setTimeout(()=>{var b;l.current&&(l.current.scroll({top:l.current.scrollHeight,behavior:"smooth"}),(b=o.current)==null||b.focus())},100);return()=>clearTimeout(R)},[h]);function T(){t&&(C(R=>[...R,{role:"user",content:t}]),O(t)&&u(!0),r(""),F())}f.useEffect(()=>{i&&(T(),a(!1))},[i,a]);const K={fontFamily:"Arial, sans-serif",lineHeight:1.6,fontSize:15,width:"100%"},q={fontFamily:"monospace",fontSize:14,lineHeight:1.6},P={fontFamily:"Arial, sans-serif",lineHeight:1.6,fontSize:15,padding:"2px 0",marginLeft:20,listStyleType:"disc"},H={p:({node:R,...b})=>e.jsxRuntimeExports.jsx("p",{style:K,...b}),code:({node:R,...b})=>e.jsxRuntimeExports.jsx("code",{className:"rounded-sm bg-muted px-2 py-1 text-sm",...b}),pre:({node:R,...b})=>e.jsxRuntimeExports.jsxs("pre",{className:"space-y-2 rounded-sm bg-muted/50 p-3",style:q,children:[e.jsxRuntimeExports.jsx("code",{className:"whitespace-normal text-sm",children:b.children}),e.jsxRuntimeExports.jsxs("div",{className:"flex justify-start gap-2",children:[e.jsxRuntimeExports.jsx(e.Button,{onClick:M,size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(e.ClipboardCopyIcon,{})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:w=>{const L=M(w);L&&(n(!1),d(L),c(!0))},size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(e.PlayIcon,{})})]})]}),li:({node:R,...b})=>e.jsxRuntimeExports.jsx("li",{style:P,...b})};function M(R){const b=R.currentTarget.closest("pre");if(!b)return;const w=b.textContent||b.innerText;return navigator.clipboard.writeText(w).then(()=>console.log("Text copied to clipboard")).catch(L=>console.error("Error in copying text: ",L)),w}function D(){return h==null?void 0:h.map((R,b)=>R.role==="user"?e.jsxRuntimeExports.jsxs("div",{className:"flex items-start rounded-md bg-muted p-3 text-sm",children:[e.jsxRuntimeExports.jsx(Ts,{className:"mr-2 h-5 w-5"}),e.jsxRuntimeExports.jsx("div",{children:R.content})]},b):R.role==="ai"?e.jsxRuntimeExports.jsx(e.Markdown,{className:"w-full overflow-auto py-1",components:H,children:N==null?void 0:N.response.replace(/DuckDB/gi,"Semaphor")},b):e.jsxRuntimeExports.jsx("div",{},b))}return e.jsxRuntimeExports.jsxs(e.Dialog,{open:s,onOpenChange:n,children:[e.jsxRuntimeExports.jsx(e.DialogTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.Button,{size:"sm",className:"w-full justify-start border font-normal text-muted-foreground focus-visible:ring-0 focus-visible:ring-offset-0",variant:"secondary",children:"Type your question here..."})}),e.jsxRuntimeExports.jsxs(e.DialogContent,{className:"flex flex-col justify-between overflow-auto sm:max-w-[425px] md:max-h-[625px] md:min-w-[625px]",children:[e.jsxRuntimeExports.jsxs(e.DialogHeader,{children:[e.jsxRuntimeExports.jsx(e.DialogTitle,{children:"Assistant"}),e.jsxRuntimeExports.jsx(e.DialogDescription,{children:"What can I help you with?"})]}),e.jsxRuntimeExports.jsx("div",{ref:l,className:"h-[625px] w-full overflow-auto border-t border-t-muted",children:e.jsxRuntimeExports.jsx("div",{className:"space-y-4 py-2 pr-3",role:"messages",children:D()})}),e.jsxRuntimeExports.jsx("div",{children:e.jsxRuntimeExports.jsxs("div",{className:"flex w-full items-center rounded-md border",children:[e.jsxRuntimeExports.jsx(e.Textarea,{autoFocus:!0,ref:o,onKeyDown:R=>{R.key==="Enter"&&!R.shiftKey&&(R.preventDefault(),r(""),T())},placeholder:"Type your question here...",onFocus:R=>{const b=R.target,w=b.value.length;b.setSelectionRange(w,w)},className:e.cn("max-h-10 min-h-7 resize-none border-none focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0"),disabled:z||I,value:t,onChange:R=>r(R.target.value)})," ",e.jsxRuntimeExports.jsx(e.Button,{className:"h-8",size:"sm",variant:"ghost",onClick:T,children:!z&&!I?e.jsxRuntimeExports.jsx(e.PaperPlaneIcon,{}):e.jsxRuntimeExports.jsx(e.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"})})]})})]})]})}var _e={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Ae=f.createContext&&f.createContext(_e),$s=["attr","size","title"];function Ks(s,n){if(s==null)return{};var t=Gs(s,n),r,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(s);for(i=0;i<a.length;i++)r=a[i],!(n.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(s,r)&&(t[r]=s[r])}return t}function Gs(s,n){if(s==null)return{};var t={},r=Object.keys(s),i,a;for(a=0;a<r.length;a++)i=r[a],!(n.indexOf(i)>=0)&&(t[i]=s[i]);return t}function Ee(){return Ee=Object.assign?Object.assign.bind():function(s){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(s[r]=t[r])}return s},Ee.apply(this,arguments)}function Te(s,n){var t=Object.keys(s);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(s);n&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(s,i).enumerable})),t.push.apply(t,r)}return t}function fe(s){for(var n=1;n<arguments.length;n++){var t=arguments[n]!=null?arguments[n]:{};n%2?Te(Object(t),!0).forEach(function(r){Us(s,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(t)):Te(Object(t)).forEach(function(r){Object.defineProperty(s,r,Object.getOwnPropertyDescriptor(t,r))})}return s}function Us(s,n,t){return n=Qs(n),n in s?Object.defineProperty(s,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):s[n]=t,s}function Qs(s){var n=Js(s,"string");return typeof n=="symbol"?n:String(n)}function Js(s,n){if(typeof s!="object"||s===null)return s;var t=s[Symbol.toPrimitive];if(t!==void 0){var r=t.call(s,n||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(n==="string"?String:Number)(s)}function He(s){return s&&s.map((n,t)=>f.createElement(n.tag,fe({key:t},n.attr),He(n.child)))}function te(s){return n=>f.createElement(Ws,Ee({attr:fe({},s.attr)},n),He(s.child))}function Ws(s){var n=t=>{var{attr:r,size:i,title:a}=s,o=Ks(s,$s),l=i||t.size||"1em",x;return t.className&&(x=t.className),s.className&&(x=(x?x+" ":"")+s.className),f.createElement("svg",Ee({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},t.attr,r,o,{className:x,style:fe(fe({color:s.color||t.color},t.style),s.style),height:l,width:l,xmlns:"http://www.w3.org/2000/svg"}),a&&f.createElement("title",null,a),s.children)};return Ae!==void 0?f.createElement(Ae.Consumer,null,t=>n(t)):n(_e)}function Ys(s){return te({tag:"svg",attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M439.8 200.5c-7.7-30.9-22.3-54.2-53.4-54.2h-40.1v47.4c0 36.8-31.2 67.8-66.8 67.8H172.7c-29.2 0-53.4 25-53.4 54.3v101.8c0 29 25.2 46 53.4 54.3 33.8 9.9 66.3 11.7 106.8 0 26.9-7.8 53.4-23.5 53.4-54.3v-40.7H226.2v-13.6h160.2c31.1 0 42.6-21.7 53.4-54.2 11.2-33.5 10.7-65.7 0-108.6zM286.2 404c11.1 0 20.1 9.1 20.1 20.3 0 11.3-9 20.4-20.1 20.4-11 0-20.1-9.2-20.1-20.4.1-11.3 9.1-20.3 20.1-20.3zM167.8 248.1h106.8c29.7 0 53.4-24.5 53.4-54.3V91.9c0-29-24.4-50.7-53.4-55.6-35.8-5.9-74.7-5.6-106.8.1-45.2 8-53.4 24.7-53.4 55.6v40.7h106.9v13.6h-147c-31.1 0-58.3 18.7-66.8 54.2-9.8 40.7-10.2 66.1 0 108.6 7.6 31.6 25.7 54.2 56.8 54.2H101v-48.8c0-35.3 30.5-66.4 66.8-66.4zm-6.7-142.6c-11.1 0-20.1-9.1-20.1-20.3.1-11.3 9-20.4 20.1-20.4 11 0 20.1 9.2 20.1 20.4s-9 20.3-20.1 20.3z"},child:[]}]})(s)}function Xs(){const{theme:s}=e.useTheme(),n=f.useRef(),t=f.useRef(),[r,i]=f.useState(!1),[a,o]=f.useState(!1),[l,x]=f.useState(!1),[j,u]=f.useState(""),[d,S]=f.useState(!1),{authToken:c}=e.useSemaphorContext();e.useDashboardStore(p=>p.selectedSheetId);const m=e.useDashboardStore(p=>p.dashboard.baseQueries),h=e.useEditorStore(p=>p.card),C=e.useDashboardStore(p=>p.theme),g=e.useEditorStore(p=>p.isShowingVisual),A=e.useEditorStore(p=>p.selectedConnectionId),y=e.useEditorStore(p=>p.selectedDatabaseName),k=e.useEditorStore(p=>p.selectedSchemaName);e.useDashboardStore(p=>p.actions.updateFrameCard);const E=e.useEditorStore(p=>p.selectedTableName),N=e.useEditorStore(p=>p.card.sql),z=e.useEditorStore(p=>p.card.python),I=e.resolveBaseQuery(N,m),_=e.useEditorStore(p=>p.selectedConnectionId),F=e.useEditorStore(p=>p.frame),O=e.useEditorStore(p=>p.filterValues),T=e.useEditorStore(p=>p.applyFilters),{setCardCustomCfg:K,setQueryResultColumns:q,setFilterValues:P,setCardSql:H,setCardPython:M,setQueryError:D,setPythonStdOut:R,setCardPreferences:b}=e.useEditorStore(p=>p.actions),w=e.useEditorStore(p=>p.onSave),L=e.useEditorStore(p=>p.actions.setApplyFilters),Z=e.useEditorStore(p=>p.onClose),$=e.useEditorStore(p=>p.actions.setCardData),re=e.useEditorStore(p=>p.actions.setSqlGen),ne=e.useEditorStore(p=>p.runSql),oe=e.useEditorStore(p=>p.actions.setRunSql),ee=e.useEditorStore(p=>p.actions.setIsSqlRunning),{data:B,isLoading:G,isFetching:U,isSuccess:ie,isError:Q,error:ue,status:ge,refetch:ae}=e.useQuery({queryKey:[I,z],queryFn:()=>e.postRequest("https://semaphor.cloud/api/v1/query",(c==null?void 0:c.accessToken)||"",{connection_id:_,sql:I,python:z===e.PYTHON_DEFAULT_CODE?"":z,active_filters:T?O:[]}),enabled:!1,retry:!1});f.useEffect(()=>{if(B&&($(B.records),R((B==null?void 0:B.output)||""),B.records.length>0)){const{dimensionKeys:p}=e.getKeys(B.records);q(p)}},[B,$,q,R]),f.useEffect(()=>{ne&&(ae(),oe(!1))},[ne,ae,oe]),f.useEffect(()=>{(G||U)&&ee(!0),(Q||ie)&&ee(!1),Q?(D(ue.message),$([]),q([]),R("")):D("")},[G,U,B,R,Q,ie,ee,$,q,D,ue]);function je(){H(""),$([]),re({}),K(""),b({})}const de=p=>{t.current=p};function v(){let p=N;N&&!N.includes("{{")&&(p=Bs(N),H(p));const J={...h,lastSelectedSchema:k,lastSelectedDatabase:y,lastSelectedTable:E,connectionId:A,type:g?h.type:"table",sql:p,customCfg:g?h.customCfg:null},me=F.cards.map(le=>le.id===h.id?J:le);w==null||w({...F,cards:me})}function Ze(){Z==null||Z()}function es(p){const J=getComputedStyle(document.documentElement).getPropertyValue(p);return ss(J)}function ss(p){const[J,me,le]=p.split(" "),V=parseFloat(J),ns=parseFloat(me),os=parseFloat(le),is=ns/100,ze=os/100,se=(1-Math.abs(2*ze-1))*is,ce=se*(1-Math.abs(V/60%2-1)),Re=ze-se/2;let W=0,Y=0,X=0;0<=V&&V<60?(W=se,Y=ce,X=0):60<=V&&V<120?(W=ce,Y=se,X=0):120<=V&&V<180?(W=0,Y=se,X=ce):180<=V&&V<240?(W=0,Y=ce,X=se):240<=V&&V<300?(W=ce,Y=0,X=se):300<=V&&V<360&&(W=se,Y=0,X=ce),W=Math.round((W+Re)*255),Y=Math.round((Y+Re)*255),X=Math.round((X+Re)*255);const be=as=>{const Se=as.toString(16);return Se.length==1?"0"+Se:Se};return`#${be(W)}${be(Y)}${be(X)}`}f.useEffect(()=>{const p=n.current,J=t.current;if(p){const me=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",le=C==="system"?me:C;p.editor.defineTheme("default",{base:le==="light"?"vs":"vs-dark",inherit:!0,rules:[],colors:{"editor.background":le==="light"?"#ffffff":es("--background")}}),p.editor.setTheme("default")}return J&&p&&J.addCommand(p.KeyMod.Shift|p.KeyCode.Enter,function(){return console.log("Executing query..."),ae(),!1}),()=>{}},[s,C,n.current]);function we(p){n.current=p}function ts(){return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[a&&e.jsxRuntimeExports.jsx("div",{className:"xbg-yellow-100 relative flex w-1/3 min-w-0 grow overflow-hidden border-l p-1 text-xs",role:"editor-filter-container",children:e.jsxRuntimeExports.jsxs("div",{className:"w-[99%]",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2 pt-3",children:[e.jsxRuntimeExports.jsx(Vs,{checked:T,onCheckedChange:()=>L(!T),text:"Apply Filters"}),e.jsxRuntimeExports.jsx(_s,{}),O&&a&&e.jsxRuntimeExports.jsx(e.Cross2Icon,{onClick:()=>o(!1),className:"bg-background/50 text-foreground/50 hover:cursor-pointer hover:text-foreground"})]}),e.jsxRuntimeExports.jsx(e.Ft,{theme:"default",onChange:p=>{if(p)try{JSON.parse(p),P(JSON.parse(p))}catch{}},defaultLanguage:"json",className:"mt-1 min-h-[220px]",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&&!a&&e.jsxRuntimeExports.jsx(Le,{onClick:()=>o(!0),className:e.cn("absolute bottom-4 right-6 h-3 w-3 text-foreground/50 hover:cursor-pointer hover:text-foreground",{"font-bold text-red-800":T})})]})}function rs(){return e.jsxRuntimeExports.jsxs(e.ResizablePanelGroup,{className:"flex grow pb-1",direction:"vertical",role:"editor-resizable-group",children:[e.jsxRuntimeExports.jsxs(e.ResizablePanel,{id:"1",order:1,defaultSize:r?20:100,className:"relative flex grow",children:[e.jsxRuntimeExports.jsx("div",{role:"sql-container",className:"relative flex w-[99%]",children:e.jsxRuntimeExports.jsx(e.Ft,{theme:"default",className:"pt-3",onChange:p=>{H(p)},value:N,options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"sql",defaultValue:"SELECT * FROM table",beforeMount:we,onMount:de})}),r&&e.jsxRuntimeExports.jsx("code",{className:"absolute right-6 top-3 text-sm text-muted-foreground/70",children:"sql"})]}),r&&e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(e.ResizableHandle,{withHandle:!0,className:"border"}),e.jsxRuntimeExports.jsxs(e.ResizablePanel,{id:"2",order:2,defaultSize:80,className:"relative flex grow",children:[e.jsxRuntimeExports.jsx("div",{role:"python-container",className:"relative flex w-[99%] pt-0",children:e.jsxRuntimeExports.jsx(e.Ft,{className:"pt-3",theme:"default",onChange:p=>{M(p&&p.trim()||"")},value:z||e.PYTHON_DEFAULT_CODE,options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"python",beforeMount:we,onMount:de})}),e.jsxRuntimeExports.jsx("code",{className:"absolute right-6 top-3 text-sm text-muted-foreground/70",children:"python"})]})]})]})}return e.jsxRuntimeExports.jsxs("section",{role:"editor-section",className:"flex grow flex-col justify-end",children:[e.jsxRuntimeExports.jsxs("div",{role:"sql-editor",className:"relative flex grow justify-between overflow-y-scroll",children:[rs(),ts()]}),e.jsxRuntimeExports.jsxs("div",{role:"editor-controls",className:"item-center flex flex-wrap justify-between gap-2 px-6 py-4",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex grow items-center gap-2",children:[e.jsxRuntimeExports.jsxs(e.Button,{title:"Shift + Enter",disabled:G||U,onClick:()=>{ae()},className:"shrink-0",size:"sm",variant:"outline",children:[G||U?e.jsxRuntimeExports.jsx(e.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"}):e.jsxRuntimeExports.jsx(Ss,{className:"mr-2 h-4 w-4"}),"Run"]}),Q&&e.jsxRuntimeExports.jsx(qs,{error:ue.message,setShowAIDialog:x,setTriggerAIRun:S,setUserInputforAI:u}),e.jsxRuntimeExports.jsxs(e.Button,{onClick:je,className:"",size:"sm",variant:"outline",children:[e.jsxRuntimeExports.jsx(ds,{className:"mr-2 size-4"}),"Clear"]}),e.jsxRuntimeExports.jsx(e.Toggle,{pressed:r,onPressedChange:p=>i(p),className:"",size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(Ys,{className:"size-4 text-foreground/70"})}),e.jsxRuntimeExports.jsx(Ps,{open:l,setOpen:x,userInput:j,triggerAIRun:d,setTriggerAIRun:S,setUserInput:p=>u(p)})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-end gap-2",children:[e.jsxRuntimeExports.jsxs(e.Button,{onClick:v,size:"sm",variant:"outline",children:[e.jsxRuntimeExports.jsx(e.Check,{className:"mr-2 size-4 font-bold text-green-600"}),"Accept"]}),e.jsxRuntimeExports.jsxs(e.Button,{onClick:Ze,className:"w-full",size:"sm",variant:"outline",children:[e.jsxRuntimeExports.jsx(e.Cross2Icon,{className:"mr-2 size-4"}),"Close"]})]})]})]})}function Zs({data:s}){var o;const[n,t]=f.useState([]),i=Object.keys(s[0]).map(l=>({accessorKey:l,header:({column:x})=>{const j=x.getIsSorted();return e.jsxRuntimeExports.jsx("div",{className:"flex gap-2",children:e.jsxRuntimeExports.jsxs("div",{className:"flex cursor-pointer items-center",onClick:()=>x.toggleSorting(x.getIsSorted()==="asc"),children:[l,j==="asc"?e.jsxRuntimeExports.jsx(e.TriangleUpIcon,{className:"ml-2 h-5 w-5"}):j==="desc"?e.jsxRuntimeExports.jsx(e.TriangleDownIcon,{className:"ml-2 h-5 w-5"}):null]})})}})),a=e.useReactTable({data:s,columns:i,getCoreRowModel:e.getCoreRowModel(),getPaginationRowModel:e.getPaginationRowModel(),onSortingChange:t,getSortedRowModel:e.getSortedRowModel(),manualPagination:!0,state:{sorting:n}});return e.jsxRuntimeExports.jsxs(e.Table$1,{children:[e.jsxRuntimeExports.jsx(e.TableHeader,{children:a.getHeaderGroups().map(l=>e.jsxRuntimeExports.jsx(e.TableRow,{children:l.headers.map(x=>e.jsxRuntimeExports.jsx(e.TableHead,{className:"sticky top-0 bg-muted",children:x.isPlaceholder?null:e.flexRender(x.column.columnDef.header,x.getContext())},x.id))},l.id))}),e.jsxRuntimeExports.jsx(e.TableBody,{children:(o=a.getRowModel().rows)!=null&&o.length?a.getRowModel().rows.map(l=>e.jsxRuntimeExports.jsx(e.TableRow,{className:"whitespace-nowrap py-2","data-state":l.getIsSelected()&&"selected",children:l.getVisibleCells().map(x=>e.jsxRuntimeExports.jsx(e.TableCell,{children:e.flexRender(x.column.columnDef.cell,x.getContext())},x.id))},l.id)):e.jsxRuntimeExports.jsx(e.TableRow,{children:e.jsxRuntimeExports.jsx(e.TableCell,{colSpan:i.length,className:"h-24 text-center",children:"No results."})})})]})}function Pe({className:s,...n}){var o;f.useState(0);const t=e.useDashboardStore(l=>l.themeStyle),r=e.useEditorStore(l=>l.card),i=e.useEditorStore(l=>l.actions.setCard);if(f.useEffect(()=>{},[r.data,r.type,r.cfg,r.customCfg,t,r.preferences]),!r.id)return null;let a;return r.data&&r.data.length>0&&(a=e.createChartConfig({data:r.data,cardType:r.type,cfg:r.cfg,customCfg:r.customCfg,preferences:r.preferences})),e.jsxRuntimeExports.jsxs(e.Card,{role:"editor-visual-card",className:e.cn("relative flex h-full flex-col rounded-none",s),...n,children:[e.jsxRuntimeExports.jsxs(e.CardHeader,{className:"py-4",children:[e.jsxRuntimeExports.jsx(e.Editable,{text:r.title,onSave:l=>i({...r,title:l}),children:e.jsxRuntimeExports.jsx("div",{className:"flex items-center gap-2",children:e.jsxRuntimeExports.jsx(e.CardTitle,{className:"text-base",children:r.title})})},r.title),e.jsxRuntimeExports.jsx(e.Editable,{text:r.description||"",onSave:l=>i({...r,description:l}),children:e.jsxRuntimeExports.jsxs(e.CardDescription,{children:[" ",r.description]})},r.description)]}),e.jsxRuntimeExports.jsxs(e.CardContent,{className:"flex grow flex-col pb-3",children:[r.type!=="table"&&a&&e.jsxRuntimeExports.jsx(e.ChartJsVisual,{cfg:a},JSON.stringify(a)+JSON.stringify(r.preferences)+((o=r==null?void 0:r.preferences)==null?void 0:o.customVisualCode)),r.type==="table"&&r.data&&r.data.length>0&&e.jsxRuntimeExports.jsx(e.$57acba87d6e25586$export$ccf8d8d7bbf3c2cc,{className:"flex min-h-0 flex-1 grow basis-0",children:e.jsxRuntimeExports.jsx(e.TableVisual,{card:r,data:r==null?void 0:r.data})})]})]})}function et(){const[s,n]=f.useState(!1),[t,r]=f.useState(""),[i,a]=f.useState(""),[o,l]=f.useState(""),[x,j]=f.useState(""),u=e.useEditorStore(y=>y.card),d=e.useEditorStore(y=>y.card.customCfg),{setCardCustomCfg:S,setCustomVisualCode:c}=e.useEditorActions();function m(y){var N,z;const k={...y,data:{...y==null?void 0:y.data,datasets:(z=(N=y==null?void 0:y.data)==null?void 0:N.datasets)==null?void 0:z.map(I=>({...I,data:[]}))}};return JSON.stringify(k,null,1)}function h(){var k,E;if(!u.data||u.data.length===0)return;const y=e.createChartConfig({data:u.data,cardType:u.type,cfg:u.cfg,preferences:u.preferences});y&&(r(JSON.stringify(y,null,1)),(k=u==null?void 0:u.preferences)!=null&&k.customVisualCode&&l((E=u==null?void 0:u.preferences)==null?void 0:E.customVisualCode),d&&a(JSON.stringify(d,null,1)))}function C(){if(o&&c(o),!!i)try{const y=JSON.parse(i);return y?(S(y),j(""),a(""),y):void 0}catch(y){console.log(y),j("Invalid JSON")}}function g(){a(""),S(null)}function A(){let y;if(d){const k=e._.cloneDeep(u.cfg),E=e._.merge(k,d);return y=m(E),y}return t?(y=m(JSON.parse(t)),y):""}return e.jsxRuntimeExports.jsxs(e.Dialog,{open:s,onOpenChange:n,children:[e.jsxRuntimeExports.jsx(e.DialogTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.Button,{onClick:h,className:` ${d&&"border-foreground/50 dark:border-foreground/70"}`,size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(e.Settings,{className:"h-4 w-4"})})}),e.jsxRuntimeExports.jsxs(e.DialogContent,{className:"max-h-[70vh] min-h-[70vh] overflow-auto sm:min-w-[900px] lg:min-w-[1200px]",children:[e.jsxRuntimeExports.jsxs(e.DialogHeader,{className:"",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.DialogTitle,{children:"Customize Card"}),e.jsxRuntimeExports.jsxs(e.Tooltip,{children:[e.jsxRuntimeExports.jsx(e.TooltipTrigger,{children:e.jsxRuntimeExports.jsx(js,{onClick:()=>{navigator.clipboard.writeText(u.id)},className:"size-3 cursor-pointer text-muted-foreground/70 transition-colors hover:text-muted-foreground"})}),e.jsxRuntimeExports.jsx(e.TooltipContent,{side:"right",align:"center",children:e.jsxRuntimeExports.jsx("p",{className:"text-xs",children:"Copy Card ID"})})]})]}),e.jsxRuntimeExports.jsxs(e.DialogDescription,{children:["See the configuration options and documentation",e.jsxRuntimeExports.jsx("a",{target:"_blank",className:"ml-1 text-blue-500 underline",href:"https://www.chartjs.org/docs/latest/samples/bar/vertical.html",children:"here."})]})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex grow gap-2",children:[e.jsxRuntimeExports.jsx(Pe,{className:"w-1/2 rounded shadow-none"}),e.jsxRuntimeExports.jsxs(e.Tabs,{defaultValue:"custom-config",className:"flex w-1/2 flex-col",children:[e.jsxRuntimeExports.jsxs(e.TabsList,{className:"justify-start rounded-sm rounded-b-none border border-b-0",children:[e.jsxRuntimeExports.jsxs(e.TabsTrigger,{value:"custom-config",children:[d&&e.jsxRuntimeExports.jsx(e.CheckIcon,{className:"mr-1 h-5 w-5 text-green-600"}),d?"Custom Config":"Default Config"]}),e.jsxRuntimeExports.jsx(e.TabsTrigger,{className:"",value:"output",children:"Output"}),e.jsxRuntimeExports.jsx(e.TabsTrigger,{className:"",value:"custom-code",children:"Custom Code"})]}),e.jsxRuntimeExports.jsx(e.TabsContent,{className:"bg-red-x mt-0 grow rounded-b border border-t-0 p-2",value:"output",children:e.jsxRuntimeExports.jsx(e.Textarea,{disabled:!0,value:t,className:"h-full resize-none border-none font-mono focus-visible:ring-0 focus-visible:ring-offset-0"})}),e.jsxRuntimeExports.jsx(e.TabsContent,{className:"mt-0 grow rounded-b border border-t-0",value:"custom-config",children:e.jsxRuntimeExports.jsx(e.Ft,{className:"h-full w-full overflow-hidden",theme:"default",options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"json",value:A(),onChange:y=>a(y)})}),e.jsxRuntimeExports.jsx(e.TabsContent,{className:"mt-0 grow rounded-b border border-t-0",value:"custom-code",children:e.jsxRuntimeExports.jsx(e.Ft,{className:"h-full w-full overflow-hidden",theme:"default",options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"javascript",value:o,onChange:y=>l(y||"")})})]})]}),e.jsxRuntimeExports.jsxs(e.DialogFooter,{className:"flex items-center",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"mr-2 text-red-500",children:x}),e.jsxRuntimeExports.jsx(e.Button,{disabled:!d,onClick:g,variant:"outline",children:"Reset"}),e.jsxRuntimeExports.jsx(e.Button,{onClick:C,variant:"outline",children:"Apply"}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>n(!1),variant:"outline",children:"Close"})]})]})]})}function $e(s){return te({tag:"svg",attr:{viewBox:"0 0 1024 1024"},child:[{tag:"path",attr:{d:"M926.8 397.1l-396-288a31.81 31.81 0 0 0-37.6 0l-396 288a31.99 31.99 0 0 0-11.6 35.8l151.3 466a32 32 0 0 0 30.4 22.1h489.5c13.9 0 26.1-8.9 30.4-22.1l151.3-466c4.2-13.2-.5-27.6-11.7-35.8zM838.6 417l-98.5 32-200-144.7V199.9L838.6 417zM466 567.2l-89.1 122.3-55.2-169.2L466 567.2zm-116.3-96.8L484 373.3v140.8l-134.3-43.7zM512 599.2l93.9 128.9H418.1L512 599.2zm28.1-225.9l134.2 97.1L540.1 514V373.3zM558 567.2l144.3-46.9-55.2 169.2L558 567.2zm-74-367.3v104.4L283.9 449l-98.5-32L484 199.9zM169.3 470.8l86.5 28.1 80.4 246.4-53.8 73.9-113.1-348.4zM327.1 853l50.3-69h269.3l50.3 69H327.1zm414.5-33.8l-53.8-73.9 80.4-246.4 86.5-28.1-113.1 348.4z"},child:[]}]})(s)}function Ke(s){return te({tag:"svg",attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M137.39,24.06A16,16,0,0,0,120,40V80.67a15.86,15.86,0,0,0,13.25,15.76A32,32,0,1,1,96,129.68c-.41-8.22,1.27-15,5-20.26h0a15.86,15.86,0,0,0-1.69-20.47L71.69,60.68a16,16,0,0,0-23.63,1.1A103.6,103.6,0,0,0,55,202.05,103.24,103.24,0,0,0,128,232h1.49A104.3,104.3,0,0,0,232,129.48C232.75,75.18,191.19,28.88,137.39,24.06ZM60.32,71.94l27.61,28.19,0,.06A43.29,43.29,0,0,0,80.44,120H40.36A87.13,87.13,0,0,1,60.32,71.94ZM40.37,136h40.3A48,48,0,0,0,120,175.34v40.3A88,88,0,0,1,40.37,136Zm149.77,54.14A87.45,87.45,0,0,1,136,215.61V175.34a47.55,47.55,0,0,0,24.73-12.23A48,48,0,0,0,136,80.66L136,40c45.52,4.08,80.67,43.28,80,89.25A87.45,87.45,0,0,1,190.14,190.14Z"},child:[]}]})(s)}function Ge(s){return te({tag:"svg",attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm87.63,96H191.48A64.1,64.1,0,0,0,136,64.52V40.37A88.13,88.13,0,0,1,215.63,120ZM120,120H80.68A48.09,48.09,0,0,1,120,80.68Zm0,16v39.32A48.09,48.09,0,0,1,80.68,136Zm16,0h39.32A48.09,48.09,0,0,1,136,175.32Zm0-16V80.68A48.09,48.09,0,0,1,175.32,120ZM120,40.37V64.52A64.1,64.1,0,0,0,64.52,120H40.37A88.13,88.13,0,0,1,120,40.37ZM40.37,136H64.52A64.1,64.1,0,0,0,120,191.48v24.15A88.13,88.13,0,0,1,40.37,136ZM136,215.63V191.48A64.1,64.1,0,0,0,191.48,136h24.15A88.13,88.13,0,0,1,136,215.63Z"},child:[]}]})(s)}function Ue(s){return te({tag:"svg",attr:{viewBox:"0 0 24 24",strokeWidth:"2",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},child:[]},{tag:"path",attr:{d:"M6 16m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"},child:[]},{tag:"path",attr:{d:"M16 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"},child:[]},{tag:"path",attr:{d:"M14.5 7.5m-4.5 0a4.5 4.5 0 1 0 9 0a4.5 4.5 0 1 0 -9 0"},child:[]}]})(s)}function Qe(s){return te({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M4 9h4v11H4zM4 4h4v4H4zM10 7h4v4h-4zM16 10h4v4h-4zM16 15h4v5h-4zM10 12h4v8h-4z"},child:[]}]})(s)}function Je(s){return te({tag:"svg",attr:{version:"1.2",baseProfile:"tiny",viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M4 18c-.552 0-1-.448-1-1v-6.382l-.553.276c-.495.248-1.095.046-1.342-.447-.247-.494-.046-1.094.448-1.342l2-1c.31-.155.678-.139.973.044.294.183.474.504.474.851v8c0 .552-.448 1-1 1zM13 18h-5c-.404 0-.769-.244-.924-.617-.155-.374-.069-.804.217-1.09l4-4c.254-.254.394-.591.394-.95 0-.358-.14-.695-.394-.949-.508-.508-1.39-.508-1.9.001-.253.252-.393.589-.393.948 0 .552-.448 1-1 1s-1-.448-1-1c0-.894.348-1.733.98-2.364 1.265-1.263 3.464-1.263 4.727.001.632.631.979 1.471.979 2.363 0 .893-.348 1.733-.979 2.364l-2.293 2.293h2.586c.552 0 1 .448 1 1s-.448 1-1 1zM20.955 12.377c.338-.457.545-1.016.545-1.627 0-1.517-1.234-2.75-2.75-2.75-1.031 0-1.966.569-2.44 1.484-.254.49-.063 1.094.428 1.348.49.254 1.094.062 1.348-.428.128-.249.383-.404.664-.404.414 0 .75.336.75.75s-.336.75-.75.75c-.552 0-1 .448-1 1s.448 1 1 1c.689 0 1.25.561 1.25 1.25s-.561 1.25-1.25 1.25-1.25-.561-1.25-1.25c0-.552-.448-1-1-1s-1 .448-1 1c0 1.792 1.458 3.25 3.25 3.25s3.25-1.458 3.25-3.25c0-.939-.406-1.779-1.045-2.373z"},child:[]}]})(s)}function We(s){return te({tag:"svg",attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M217 25v14h78V25h-78zm0 32v46h14V71h50v32h14V57h-78zm32 32v14h14V89h-14zm-64 32v46h30v-46h-30zm48 0v14h46v-14h-46zm64 0v46h30v-46h-30zm-64 32v14h46v-14h-46zm-80 32v46h62v-46h-62zm80 0v14h46v-14h-46zm64 0v46h62v-46h-62zm-64 32v14h46v-14h-46zm-112 32v46h94v-46h-94zm112 0v14h46v-14h-46zm64 0v46h94v-46h-94zm-64 32v14h46v-14h-46zM89 313v46h126v-46H89zm144 0v14h46v-14h-46zm64 0v46h126v-46H297zm-64 32v14h46v-14h-46zM57 377v46h158v-46H57zm176 0v14h46v-14h-46zm64 0v46h158v-46H297zm-64 32v14h46v-14h-46zM25 441v46h190v-46H25zm208 0v14h46v-14h-46zm64 0v46h190v-46H297zm-64 32v14h46v-14h-46z"},child:[]}]})(s)}function st(){const[s,n]=f.useState(!1),t=e.useEditorStore(l=>l.card.type),{setCardType:r,setCardPreferences:i}=e.useEditorStore(l=>l.actions),a=e.useEditorStore(l=>l.actions.setCardCustomCfg);function o(l){r(l),a(null),i({}),n(!1)}return e.jsxRuntimeExports.jsxs(e.Popover,{open:s,onOpenChange:n,children:[e.jsxRuntimeExports.jsx(e.PopoverTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.Button,{size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(tt,{className:"h-4 w-4",chartType:t})})}),e.jsxRuntimeExports.jsx(e.PopoverContent,{className:"w-50",children:e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 place-items-center",children:[e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("bar"),className:"font-normal",variant:"ghost",children:e.jsxRuntimeExports.jsx(ve,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("line"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ce,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("stackedBar"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Qe,{className:"size-5",strokeWidth:0})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("scatter"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Be,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("bubble"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ue,{className:"size-4"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("pie"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Me,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("doughnut"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ke,{className:"size-5",strokeWidth:1})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("radar"),variant:"ghost",children:e.jsxRuntimeExports.jsx($e,{className:"size-5 font-extralight",strokeWidth:.5})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("polarArea"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ge,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("pyramid"),variant:"ghost",children:e.jsxRuntimeExports.jsx(We,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("range"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Fe,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("table"),variant:"ghost",children:e.jsxRuntimeExports.jsx(e.Table,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("kpi"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Je,{className:"size-6"})})]})})]})}function tt({chartType:s,className:n}){switch(s){case"bar":return e.jsxRuntimeExports.jsx(ve,{className:n});case"line":return e.jsxRuntimeExports.jsx(Ce,{className:n});case"pie":return e.jsxRuntimeExports.jsx(Me,{className:n});case"radar":return e.jsxRuntimeExports.jsx($e,{className:n});case"scatter":return e.jsxRuntimeExports.jsx(Be,{className:n});case"bubble":return e.jsxRuntimeExports.jsx(Ue,{className:n});case"doughnut":return e.jsxRuntimeExports.jsx(Ke,{className:n});case"stackedBar":return e.jsxRuntimeExports.jsx(Qe,{className:"size-4 text-foreground/70"});case"polarArea":return e.jsxRuntimeExports.jsx(Ge,{className:n});case"pyramid":return e.jsxRuntimeExports.jsx(We,{className:n});case"range":return e.jsxRuntimeExports.jsx(Fe,{className:n});case"kpi":return e.jsxRuntimeExports.jsx(Je,{className:n});default:return e.jsxRuntimeExports.jsx(e.Table,{className:n})}}function rt(){const s=e.useEditorStore(t=>t.card.refreshInterval),n=e.useEditorStore(t=>t.actions.setCardRefreshInterval);return e.jsxRuntimeExports.jsxs(e.Popover,{children:[e.jsxRuntimeExports.jsx(e.PopoverTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.Button,{size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(ls,{className:"w-4 h-4"})})}),e.jsxRuntimeExports.jsx(e.PopoverContent,{className:"w-[200px]",children:e.jsxRuntimeExports.jsx("div",{className:"grid gap-4",children:e.jsxRuntimeExports.jsx("div",{className:"grid gap-2",children:e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-5 items-center gap-1",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"col-span-3",htmlFor:"width",children:"Refresh Every"}),e.jsxRuntimeExports.jsx(e.Input,{value:s||"",onChange:t=>n(t.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 De(){e.useEditorStore(o=>o.frame);const s=e.useEditorStore(o=>o.card),n=e.useEditorStore(o=>o.card.data),t=e.useEditorStore(o=>o.isShowingVisual),r=e.useEditorStore(o=>o.isSqlRunning),i=e.useEditorStore(o=>o.queryError),a=e.useEditorStore(o=>o.pythonStdOut);return e.useEditorStore(o=>o.onSave),e.useEditorStore(o=>o.onClose),e.useEditorStore(o=>o.actions.setCardSql),e.useEditorStore(o=>o.actions.setCardType),e.useEditorStore(o=>o.actions.setSqlGen),s?e.jsxRuntimeExports.jsxs("div",{className:"relative flex h-full flex-col pt-3",children:[r&&e.jsxRuntimeExports.jsx(e.LoaderCircle,{className:"absolute bottom-0 left-0 right-0 top-0 z-10 m-auto h-10 w-10 animate-spin text-foreground/10"}),e.jsxRuntimeExports.jsxs("div",{className:"mb-0 flex min-h-10 items-center justify-end gap-2 px-6",children:[t&&e.jsxRuntimeExports.jsxs("div",{className:"flex grow items-center gap-2",children:[e.jsxRuntimeExports.jsx(st,{}),s.type!=="table"&&e.jsxRuntimeExports.jsx(et,{}),e.jsxRuntimeExports.jsx(rt,{})]}),e.jsxRuntimeExports.jsx(ot,{})]}),t?s.type==="kpi"?e.jsxRuntimeExports.jsx("div",{className:"flex grow items-center justify-center",children:e.jsxRuntimeExports.jsx("div",{className:"w-1/2 rounded-md border",children:e.jsxRuntimeExports.jsx(e.KPICard,{isLoading:r,card:s})})}):e.jsxRuntimeExports.jsx(Pe,{className:"grow border-none shadow-none"}):e.jsxRuntimeExports.jsxs("div",{className:"flex min-h-0 w-full flex-1 grow basis-0 px-6",children:[a&&e.jsxRuntimeExports.jsx(nt,{}),s.data&&s.data.length>0&&e.jsxRuntimeExports.jsx(Zs,{data:n||[]}),i&&e.jsxRuntimeExports.jsx("span",{className:"font-mono text-sm",children:i})]})]}):e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:"No Active Card"})}function nt(){const s=e.useEditorStore(t=>t.pythonStdOut);if(!s)return null;const n=s.replace(/\n/g,"<br>");return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx("p",{className:"font-mono text-sm",children:"Output:"}),e.jsxRuntimeExports.jsx("div",{dangerouslySetInnerHTML:{__html:n},className:"bg-muted p-2 font-mono text-sm"}),e.jsxRuntimeExports.jsx(e.Separator,{className:"mb-2"})]})}function ot(){const s=e.useEditorStore(t=>t.isShowingVisual),n=e.useEditorStore(t=>t.actions.setIsShowingVisual);return e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.Label,{htmlFor:"visualize",children:"Chart"}),e.jsxRuntimeExports.jsx(e.Switch,{checked:s,onCheckedChange:()=>n(!s),id:"visualize",className:"data-[state=checked]:bg-foreground/50"})]})}const xe="focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0";function Ie(s,n){var r,i,a;const t=e.getNumberAxis(s,n);return((a=(i=(r=s==null?void 0:s.chartOptions)==null?void 0:r.scales)==null?void 0:i[t])==null?void 0:a.type)||"linear"}function Ye(){var q,P,H,M,D,R;const[s,n]=f.useState(!1),t=e.useEditorStore(b=>{var w;return(w=b.card)==null?void 0:w.preferences}),r=e.useEditorStore(b=>{var w;return(w=b.card)==null?void 0:w.cfg}),i=e.getNumberAxis(t,r),[a,o]=f.useState(Ie(t)),[l,x]=f.useState(((H=(P=(q=t==null?void 0:t.chartOptions)==null?void 0:q.scales)==null?void 0:P[i])==null?void 0:H.min)||""),[j,u]=f.useState(((R=(D=(M=t==null?void 0:t.chartOptions)==null?void 0:M.scales)==null?void 0:D[i])==null?void 0:R.max)||""),[d,S]=f.useState(l||j?"custom":"auto"),[c,m]=f.useState(""),[h,C]=f.useState(0),[g,A]=f.useState(""),[y,k]=f.useState(""),[E,N]=f.useState(""),z=e.useEditorStore(b=>b.actions.setCardPreferences),I=e.useEditorStore(b=>{var w;return(w=b.card)==null?void 0:w.type}),_=["pie","doughnut","polarArea"].includes(I);f.useEffect(()=>{var b,w,L,Z,$,re,ne,oe,ee,B,G,U,ie,Q;o(Ie(t)),x(((L=(w=(b=t==null?void 0:t.chartOptions)==null?void 0:b.scales)==null?void 0:w[i])==null?void 0:L.min)===0?0:""),u(((re=($=(Z=t==null?void 0:t.chartOptions)==null?void 0:Z.scales)==null?void 0:$[i])==null?void 0:re.max)||""),m(((B=(ee=(oe=(ne=t==null?void 0:t.chartOptions)==null?void 0:ne.scales)==null?void 0:oe[i])==null?void 0:ee.ticks)==null?void 0:B.stepSize)||""),C(((G=t==null?void 0:t.numberAxisFormat)==null?void 0:G.decimalPlaces)||0),A(((U=t==null?void 0:t.numberAxisFormat)==null?void 0:U.suffix)||""),k(((ie=t==null?void 0:t.numberAxisFormat)==null?void 0:ie.currency)||""),N(((Q=t==null?void 0:t.numberAxisFormat)==null?void 0:Q.locale)||"")},[s,t,i]);function F(b,w){return w===""||/^[0-9\b]+$/.test(w)?Number(w):Number(b)}function O(){return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-6 items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"col-span-2 hover:cursor-pointer hover:underline",htmlFor:"currency",children:e.jsxRuntimeExports.jsx("a",{target:"_blank",href:"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat",children:"Currency"})}),e.jsxRuntimeExports.jsx(e.Input,{value:y,placeholder:"USD",onChange:b=>k(b.target.value),id:"currency",className:`col-span-2 h-8 w-full ${xe}`}),e.jsxRuntimeExports.jsx(e.Input,{value:E,placeholder:"en-US",onChange:b=>N(b.target.value),id:"locale",className:`col-span-2 h-8 w-full ${xe}`})]}),e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-9 items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"col-span-3",htmlFor:"format",children:"Decimals"}),e.jsxRuntimeExports.jsx(e.Input,{value:h,onChange:b=>C(Number(b.target.value)),id:"format",className:`col-span-6 h-8 w-full tracking-wide ${xe}`})]})]})}function T(){return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Label,{htmlFor:"range",children:"Range"}),e.jsxRuntimeExports.jsx(e.Input,{id:"min",value:l,onChange:b=>x(w=>F(w,b.target.value)),className:`col-span-1 h-8 w-full ${xe}`}),e.jsxRuntimeExports.jsx(e.Input,{value:j,onChange:b=>u(w=>F(w,b.target.value)),id:"max",className:`col-span-1 h-8 w-full ${xe}`})]}),e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Label,{htmlFor:"step-size",children:"Step Size"}),e.jsxRuntimeExports.jsx(e.Input,{value:c,onChange:b=>m(w=>F(w,b.target.value)),id:"step-size",className:`col-span-1 h-8 w-full ${xe}`})]})]})}function K(){var L;let b={};d==="custom"&&(b={min:l,max:j,ticks:{stepSize:c}});const w={...t||{},chartOptions:{...t==null?void 0:t.chartOptions,scales:{...(L=t==null?void 0:t.chartOptions)==null?void 0:L.scales,[i]:{type:a,...a==="linear"?b:{}}}},numberAxisFormat:{decimalPlaces:h,suffix:g,currency:y,locale:E}};z(w)}return e.jsxRuntimeExports.jsxs(e.Popover,{onOpenChange:b=>n(b),children:[e.jsxRuntimeExports.jsx(e.PopoverTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.SliderIcon,{className:"size-4 cursor-pointer text-muted-foreground hover:text-foreground"})}),e.jsxRuntimeExports.jsx(e.PopoverContent,{align:"center",className:"max-w-65",children:e.jsxRuntimeExports.jsxs("div",{className:"grid gap-4",children:[e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsx("h4",{className:"font-medium leading-none",children:"Scale Options"}),e.jsxRuntimeExports.jsx("p",{className:"text-sm text-muted-foreground",children:"Set the scale for the number axis"})]}),e.jsxRuntimeExports.jsxs("div",{className:"grid gap-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Label,{htmlFor:"scale",children:"Type"}),e.jsxRuntimeExports.jsxs(e.Select,{disabled:_,value:a,onValueChange:b=>o(b),children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:"col-span-2 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsxRuntimeExports.jsx(e.SelectValue,{})}),e.jsxRuntimeExports.jsx(e.SelectContent,{id:"type",children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[e.jsxRuntimeExports.jsx(e.SelectLabel,{children:"Option"}),e.jsxRuntimeExports.jsx(e.SelectItem,{value:"linear",children:"Linear"}),e.jsxRuntimeExports.jsx(e.SelectItem,{value:"logarithmic",children:"Logarithmic"})]})})]})]}),a=="linear"&&e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 items-center gap-2 py-1",children:[e.jsxRuntimeExports.jsx(e.Label,{htmlFor:"scale-option",children:"Setup"}),e.jsxRuntimeExports.jsxs(e.RadioGroup,{disabled:_,id:"scale-option",value:d,onValueChange:b=>S(b),className:"col-span-2 flex gap-3",defaultValue:"x",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:"auto",id:"r1"}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r1",children:"Auto"})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:"custom",id:"r2"}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r2",children:"Custom"})]})]})]}),d==="custom"&&a=="linear"&&T(),O(),e.jsxRuntimeExports.jsx(e.SelectSeparator,{}),e.jsxRuntimeExports.jsx("div",{className:"grid grid-cols-3",children:e.jsxRuntimeExports.jsx(e.Button,{onClick:K,variant:"secondary",className:"col-span-1 col-start-3 h-8 w-full",children:"Apply"})})]})]})})]})}function ke(){var i,a,o;const s=e.useEditorStore(l=>l.card.cfg),n=e.useEditorStore(l=>l.actions.setCardCfg),t=e.useEditorStore(l=>l.card.type);function r(l){var u;const x={datalabels:{display:l!=="none",align:l,anchor:l,clamp:!0}},j={...s,options:{...s==null?void 0:s.options,plugins:{...(u=s==null?void 0:s.options)==null?void 0:u.plugins,...x}}};n(j),console.log(l)}return e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxRuntimeExports.jsx("label",{className:"font-medium",children:"Data Labels"}),!["pyramid","range"].includes(t)&&e.jsxRuntimeExports.jsx(Ye,{})]}),e.jsxRuntimeExports.jsxs(e.Select,{value:(o=(a=(i=s==null?void 0:s.options)==null?void 0:i.plugins)==null?void 0:a.datalabels)==null?void 0:o.anchor,onValueChange:r,defaultValue:"none",children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:"h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsxRuntimeExports.jsx(e.SelectValue,{placeholder:"Select position"})}),e.jsxRuntimeExports.jsx(e.SelectContent,{children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[e.jsxRuntimeExports.jsx(e.SelectLabel,{children:"Data Labels"}),e.jsxRuntimeExports.jsx(e.SelectItem,{value:"none",children:"None"}),t!=="pyramid"&&e.jsxRuntimeExports.jsx(e.SelectItem,{value:"start",children:"Start"}),e.jsxRuntimeExports.jsx(e.SelectItem,{value:"center",children:"Center"}),t!=="pyramid"&&e.jsxRuntimeExports.jsx(e.SelectItem,{value:"end",children:"End"})]})})]})]})}function he(){const[s,n]=f.useState([]);e.useEditorStore(u=>u.card.cfg);const t=e.useEditorStore(u=>u.card.preferences),{setCardCfg:r,setFilterOnClickColumnIndex:i,setCardPreferences:a}=e.useEditorStore(u=>u.actions),o=e.useEditorStore(u=>u.queryResultColumns);e.useEditorStore(u=>{var d;return(d=u.card.preferences)==null?void 0:d.filterOnClickColumnIndex}),f.useEffect(()=>{o&&n(new Array(o.length).fill(!1))},[o]);function l(u,d){var S,c;d?t!=null&&t.onClickFilter&&((S=t==null?void 0:t.onClickFilter)==null?void 0:S.length)>0?a({...t,onClickFilter:[...t.onClickFilter,{columnIndex:u,expression:""}]}):a({...t,onClickFilter:[{columnIndex:u,expression:""}]}):(a({...t,onClickFilter:(c=t==null?void 0:t.onClickFilter)==null?void 0:c.filter(m=>m.columnIndex!==u)}),n(m=>{const h=[...m];return h[u]=!1,h}))}function x(u,d){var c;const S=(c=t==null?void 0:t.onClickFilter)==null?void 0:c.map(m=>m.columnIndex===u?{...m,expression:d.target.value}:m);a({...t,onClickFilter:S})}function j(u){var d,S,c,m;if(s!=null&&s[u]||(S=(d=t==null?void 0:t.onClickFilter)==null?void 0:d.find(h=>h.columnIndex===u))!=null&&S.expression)return e.jsxRuntimeExports.jsx(e.Input,{value:(m=(c=t==null?void 0:t.onClickFilter)==null?void 0:c.find(h=>h.columnIndex===u))==null?void 0:m.expression,onChange:h=>x(u,h),type:"text",className:" h-9 w-full focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0 font-mono text-xs",placeholder:"Expression"})}return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:o==null?void 0:o.map((u,d)=>{var S,c;return e.jsxRuntimeExports.jsx("div",{className:"flex items-center justify-between space-y-2 xbg-red-100 group",children:e.jsxRuntimeExports.jsxs("div",{className:" grow",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center py-2 space-x-2",children:[e.jsxRuntimeExports.jsx(e.Checkbox,{checked:!!((S=t==null?void 0:t.onClickFilter)!=null&&S.find(m=>m.columnIndex===d)),onCheckedChange:m=>l(d,m)}),e.jsxRuntimeExports.jsx("label",{className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:u}),e.jsxRuntimeExports.jsx("div",{className:"flex gap-2 items-center ",children:((c=t==null?void 0:t.onClickFilter)==null?void 0:c.find(m=>m.columnIndex===d))&&e.jsxRuntimeExports.jsx(Oe,{onClick:()=>{n(m=>{const h=[...m];return h[d]=!m[d],h})},className:" invisible group-hover:visible size-3 text-gray-400 cursor-pointer"})})]}),j(d)]})},u)})})}function it({cardType:s}){function n(t){const r="SELECT label, [group], x-axis, y-axis, radius FROM table",i="SELECT label, [group], x-axis, y-axis FROM table";return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx("div",{className:"bg-muted px-2 py-1 rounded text-xs",children:t==="bubble"?r:i}),e.jsxRuntimeExports.jsxs("ul",{className:" ml-6 list-disc [&>li]:mt-2 text-xs",children:[e.jsxRuntimeExports.jsx("li",{children:"label - category"}),e.jsxRuntimeExports.jsx("li",{children:"group - category"}),e.jsxRuntimeExports.jsx("li",{children:"x-axis - category"}),e.jsxRuntimeExports.jsx("li",{children:"y-axis - category"}),t==="bubble"&&e.jsxRuntimeExports.jsx("li",{children:"radius - number"})]}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:a=>a.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#pie-chart",children:"example"})," in the docs."]})]})}return e.jsxRuntimeExports.jsx("div",{className:"px-6 py-2 space-y-6",children:e.jsxRuntimeExports.jsxs(e.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:`${e.titleCase(s)} Chart`}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:" space-y-4 font-mono text-xs ",children:n(s)})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-2",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Settings"}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:"px-2",children:e.jsxRuntimeExports.jsx(ke,{})})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filter on click"}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:"px-2",children:e.jsxRuntimeExports.jsx(he,{})})]})]})})}function Xe(){var a,o,l;const s=e.useEditorStore(x=>x.card.preferences),n=e.useEditorStore(x=>x.card.cfg),{setCardCfg:t,setCardPreferences:r}=e.useEditorStore(x=>x.actions);(a=n==null?void 0:n.options)!=null&&a.indexAxis;function i(x){var d,S,c,m,h,C;let j={};(d=s==null?void 0:s.chartOptions)!=null&&d.scales&&(j={x:(c=(S=s==null?void 0:s.chartOptions)==null?void 0:S.scales)==null?void 0:c.y,y:(h=(m=s==null?void 0:s.chartOptions)==null?void 0:m.scales)==null?void 0:h.x});const u={...s,chartOptions:{...s==null?void 0:s.chartOptions,scales:{...(C=s==null?void 0:s.chartOptions)==null?void 0:C.scales,...j},indexAxis:x}};r(u)}return e.jsxRuntimeExports.jsxs(e.RadioGroup,{value:((o=s==null?void 0:s.chartOptions)==null?void 0:o.indexAxis)||((l=n==null?void 0:n.options)==null?void 0:l.indexAxis)||"x",onValueChange:i,className:"flex gap-3",defaultValue:"x",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:"x",id:"r1"}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r1",children:"Vertical"})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:"y",id:"r2"}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r2",children:"Horizontal"})]})]})}const at={datasets:[{type:"line",label:"Sum_sales",data:[]},{type:"bar",label:"Sum_profit",data:[]}]},lt={datasets:[{fill:"origin",type:"line",label:"Sum_sales",data:[]}]};function ct(){const s=e.useEditorStore(n=>n.card.type);return e.jsxRuntimeExports.jsxs("div",{className:"space-y-6 p-6",children:[e.jsxRuntimeExports.jsx(e.Accordion,{className:" ",type:"single",collapsible:!0,children:xt(s)}),e.jsxRuntimeExports.jsx("section",{className:"",children:["line","bar"].includes(s)&&e.jsxRuntimeExports.jsx(Xe,{})}),e.jsxRuntimeExports.jsx("div",{children:!["kpi"].includes(s)&&e.jsxRuntimeExports.jsx(ke,{})}),e.jsxRuntimeExports.jsx("div",{children:!["kpi"].includes(s)&&e.jsxRuntimeExports.jsx(he,{})})]})}function xt(s){if(["line","bar"].includes(s))return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"font-normal",children:e.jsxRuntimeExports.jsx("p",{children:"Chart Query"})}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:" ",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs font-semibold",children:"SELECT x-axis, y-axis-1, y-axis-2, y-axis-3,... FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"X-axis - Category (ex. city)"}),e.jsxRuntimeExports.jsx("li",{children:"Y-axis - Number (ex. population)"})]})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-2",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"font-normal",children:"Mixed Chart"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-2 text-xs",children:[e.jsxRuntimeExports.jsxs("p",{children:["Click ",e.jsxRuntimeExports.jsx("b",{children:"Customize"})," and change the `type` property in the dataset."]}),e.jsxRuntimeExports.jsx("pre",{children:JSON.stringify(at,null,2)})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"font-normal",children:"Area Chart"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-2 text-xs",children:[e.jsxRuntimeExports.jsxs("p",{children:["Click ",e.jsxRuntimeExports.jsx("b",{children:"Customize"})," and add `fill` property to the dataset. See",e.jsxRuntimeExports.jsx("a",{className:"mx-1 text-blue-500 hover:underline",href:"https://www.chartjs.org/docs/latest/samples/area/line-boundaries.html",target:"_blank",children:"docs"}),"for more options."]}),e.jsxRuntimeExports.jsx("pre",{children:JSON.stringify(lt,null,2)})]})]})]});if(s==="bubble")return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"font-normal",children:e.jsxRuntimeExports.jsxs("p",{children:["How to create a ",e.jsxRuntimeExports.jsx("span",{children:s})," chart query?"]})}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:" ",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs font-semibold",children:"SELECT label, x-axis, y-axis, radius FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"Label - Category (ex. city)"}),e.jsxRuntimeExports.jsx("li",{children:"Bubble Group (opt) - Category (ex. state)"}),e.jsxRuntimeExports.jsx("li",{children:"X-axis - Number (ex. avg. age)"}),e.jsxRuntimeExports.jsx("li",{children:"Y-axis - Number (ex. avg. weight)"}),e.jsxRuntimeExports.jsx("li",{children:"Radius - Number (ex. population)"})]})]})]})});if(s==="scatter")return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"font-normal",children:e.jsxRuntimeExports.jsxs("p",{children:["How to create a ",e.jsxRuntimeExports.jsx("span",{children:s})," chart query?"]})}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:" ",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs font-semibold",children:"SELECT label, x-axis, y-axis FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"Label - Category (ex. city)"}),e.jsxRuntimeExports.jsx("li",{children:"Group (opt) - Category (ex. state)"}),e.jsxRuntimeExports.jsx("li",{children:"X-axis - Number (ex. avg. age)"}),e.jsxRuntimeExports.jsx("li",{children:"Y-axis - Number (ex. avg. weight)"})]})]})]})});if(["pie","doughnut","polarArea"].includes(s))return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"font-normal",children:e.jsxRuntimeExports.jsxs("p",{children:[e.jsxRuntimeExports.jsx("span",{children:s==="polarArea"?"Polar":s.charAt(0).toUpperCase()+s.slice(1)})," ","chart query"]})}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:" ",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs font-semibold",children:"SELECT label, measure FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"Label - Category (ex. city)"}),e.jsxRuntimeExports.jsx("li",{children:"Measure - Number (ex. population)"})]})]})]})})}function ut(){var x,j,u,d,S;const s=e.useEditorStore(c=>c.card.preferences),n=e.useEditorStore(c=>c.actions.setCardPreferences),t=e.useEditorStore(c=>c.actions.setNumberFormat);e.useEditorStore(c=>{var m,h;return(h=(m=c.card.preferences)==null?void 0:m.formatNumber)==null?void 0:h.decimalPlaces});const r=e.useEditorStore(c=>{var m,h;return(h=(m=c.card.preferences)==null?void 0:m.formatNumber)==null?void 0:h.locale}),i=e.useEditorStore(c=>{var m,h;return(h=(m=c.card.preferences)==null?void 0:m.formatNumber)==null?void 0:h.currency});e.useEditorStore(c=>c.actions.setFilterOnClickField);const a=e.useEditorStore(c=>{var m,h;return(h=(m=c.card.preferences)==null?void 0:m.formatNumber)==null?void 0:h.colorRanges})||[],o=e.useEditorStore(c=>c.actions.setColorRanges),l=[...new Set(e.LOCALE_CURRENCY_PAIRS.map(c=>c.currency))];return e.jsxRuntimeExports.jsxs("div",{children:[e.jsxRuntimeExports.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Checkbox,{checked:!!((x=s==null?void 0:s.formatNumber)!=null&&x.enabled),onCheckedChange:c=>{n({...s,formatNumber:{...s==null?void 0:s.formatNumber,enabled:c}})}}),e.jsxRuntimeExports.jsx(e.Label,{children:"Format Number"})]}),((j=s==null?void 0:s.formatNumber)==null?void 0:j.enabled)===!0&&e.jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxRuntimeExports.jsx("div",{children:e.jsxRuntimeExports.jsxs("div",{className:"space-y-4 p-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"w-full space-y-1",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Locale"}),e.jsxRuntimeExports.jsxs(e.Select,{value:r||"en-US",onValueChange:c=>{var m,h,C;return t(((m=s==null?void 0:s.formatNumber)==null?void 0:m.decimalPlaces)||0,((h=s==null?void 0:s.formatNumber)==null?void 0:h.currency)||"",c||"en-US",((C=s==null?void 0:s.formatNumber)==null?void 0:C.suffix)||"")},children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:"col-span-6 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsxRuntimeExports.jsx(e.SelectValue,{})}),e.jsxRuntimeExports.jsx(e.SelectContent,{children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[e.jsxRuntimeExports.jsx(e.SelectLabel,{children:"Format"}),e.LOCALE_CURRENCY_PAIRS.map(c=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:c.locale,children:c.locale},c.locale))]})})]})]}),e.jsxRuntimeExports.jsxs("div",{className:"w-full space-y-1",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Currency"}),e.jsxRuntimeExports.jsxs(e.Select,{value:i||"none",onValueChange:c=>{var m,h,C;return t(((m=s==null?void 0:s.formatNumber)==null?void 0:m.decimalPlaces)||0,c==="none"?"":c,((h=s==null?void 0:s.formatNumber)==null?void 0:h.locale)||"",((C=s==null?void 0:s.formatNumber)==null?void 0:C.suffix)||"")},children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:"col-span-6 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsxRuntimeExports.jsx(e.SelectValue,{})}),e.jsxRuntimeExports.jsx(e.SelectContent,{children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[e.jsxRuntimeExports.jsx(e.SelectLabel,{children:"Currency"}),e.jsxRuntimeExports.jsx(e.SelectItem,{value:"none",children:"None"},"none"),l.map(c=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:c,children:c},c))]})})]})]})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex gap-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"w-full space-y-1",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Decimals"}),e.jsxRuntimeExports.jsxs(e.Select,{value:((d=(u=s==null?void 0:s.formatNumber)==null?void 0:u.decimalPlaces)==null?void 0:d.toString())||"0",onValueChange:c=>{var m,h,C;return t(Number(c),((m=s==null?void 0:s.formatNumber)==null?void 0:m.currency)||"",((h=s==null?void 0:s.formatNumber)==null?void 0:h.locale)||"",((C=s==null?void 0:s.formatNumber)==null?void 0:C.suffix)||"")},children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:"col-span-3 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsxRuntimeExports.jsx(e.SelectValue,{})}),e.jsxRuntimeExports.jsx(e.SelectContent,{children:["0","1","2","3","4"].map(c=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:c,children:c},c))})]})]}),e.jsxRuntimeExports.jsxs("div",{className:"w-full space-y-1",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Suffix"}),e.jsxRuntimeExports.jsx(e.Input,{value:((S=s==null?void 0:s.formatNumber)==null?void 0:S.suffix)||"",className:"h-8 font-mono text-xs focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",placeholder:"K, M, B, %",onChange:c=>{var m,h,C;return t(((m=s==null?void 0:s.formatNumber)==null?void 0:m.decimalPlaces)||0,((h=s==null?void 0:s.formatNumber)==null?void 0:h.currency)||"",((C=s==null?void 0:s.formatNumber)==null?void 0:C.locale)||"",c.target.value)}})]})]})]})}),e.jsxRuntimeExports.jsx(e.Separator,{className:"my-3"}),e.jsxRuntimeExports.jsx(e.ColorFormat,{colorRanges:a,setColorRanges:o})]})]})}function dt(){return e.jsxRuntimeExports.jsxs("div",{className:"space-y-6 px-6 py-2",children:[e.jsxRuntimeExports.jsx(e.Accordion,{type:"single",collapsible:!0,children:e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"",children:"KPI Query"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"font-mono",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs",children:"SELECT current, previous FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"current - number"}),e.jsxRuntimeExports.jsx("li",{children:"previous - number"})]}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:s=>s.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#kpi",children:"example"})," in the docs."]})]})]})}),e.jsxRuntimeExports.jsx("section",{className:"",children:e.jsxRuntimeExports.jsx(ut,{})}),e.jsxRuntimeExports.jsx("div",{}),e.jsxRuntimeExports.jsx("div",{})]})}function ye({cardType:s,docContent:n}){return e.jsxRuntimeExports.jsx("div",{className:"space-y-6 px-6 py-2",children:e.jsxRuntimeExports.jsxs(e.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:`${e.titleCase(s)} Chart`}),e.jsxRuntimeExports.jsx(e.AccordionContent,{children:n||e.jsxRuntimeExports.jsxs("div",{className:"space-y-4 font-mono text-xs",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT label, measure FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"label - category"}),e.jsxRuntimeExports.jsx("li",{children:"measure - number"})]}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:t=>t.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#pie-chart",children:"example"})," in the docs."]})]})})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-2",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Settings"}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:"px-2",children:e.jsxRuntimeExports.jsx(ke,{})})]}),s!=="range"&&e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filter on click"}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:"px-2",children:e.jsxRuntimeExports.jsx(he,{})})]})]})})}function mt({idx:s}){var l;const n=e.useEditorStore(x=>{var j;return(j=x.card)==null?void 0:j.preferences}),t=e.useEditorStore(x=>{var j;return(j=x.card.preferences)==null?void 0:j.datasetOptions}),r=e.useEditorStore(x=>x.actions.setCardPreferences),i=(l=n==null?void 0:n.chartOptions)==null?void 0:l.indexAxis,a=t==null?void 0:t.find(x=>x.idx===s);function o(x,j){(x==="end"||x==="start")&&e.getContrastColor(e.getCanvasBackgroundColor());const u={display:x!=="none",align:x,anchor:x,clamp:!0};if(!a)r({...n,datasetOptions:[...t||[],{idx:j,datalabels:u}]});else{const d={...a};d.datalabels=u;const S=t==null?void 0:t.map(c=>c.idx===j?d:c);r({...n,datasetOptions:S})}}return e.jsxRuntimeExports.jsxs(e.Popover,{children:[e.jsxRuntimeExports.jsx(e.PopoverTrigger,{children:e.jsxRuntimeExports.jsx(ws,{className:"invisible size-4 rotate-[135deg] cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"})}),e.jsxRuntimeExports.jsx(e.PopoverContent,{className:"w-fit p-1",children:e.jsxRuntimeExports.jsxs("div",{className:"flex gap-1",children:[e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("none",s),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsxRuntimeExports.jsx(e.X,{className:"size-4"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("start",s),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsxRuntimeExports.jsx(Es,{className:e.cn("h-4 w-4",{"rotate-90":i==="y"})})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("center",s),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsxRuntimeExports.jsx(gs,{className:e.cn("h-4 w-4",{"rotate-90":i==="y"})})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("end",s),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsxRuntimeExports.jsx(fs,{className:e.cn("h-4 w-4",{"rotate-90":i==="y"})})})]})})]})}function pt(){const s=e.useEditorStore(x=>x.card),n=e.useEditorStore(x=>{var j,u,d;return(d=(u=(j=x==null?void 0:x.card)==null?void 0:j.preferences)==null?void 0:u.chartOptions)==null?void 0:d.indexAxis}),t=n==="y"?"Y axis":"X axis",r=n==="y"?"X axis":"Y axis",{keys:i,metricKeys:a,dimensionKeys:o}=e.getKeys(s.data||[]);let l=a;if(s.type==="stackedBar"){const x=e.pivotData({dataArray:s.data||[],groupKey:o[0],pivotKey:o[1],valueKey:l[0]}),{metricKeys:j}=e.getKeys(x);l=j}return i.length===0?null:e.jsxRuntimeExports.jsxs("div",{className:"space-y-4",children:[e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsx(e.Label,{children:t}),e.jsxRuntimeExports.jsx("div",{className:"my-1 space-y-1",children:e.jsxRuntimeExports.jsx("div",{className:"rounded-md bg-muted/70 px-2 py-1 hover:bg-muted",children:e.jsxRuntimeExports.jsx("p",{children:o[0]})})})]}),e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center justify-between gap-5",children:[e.jsxRuntimeExports.jsx(e.Label,{children:r}),e.jsxRuntimeExports.jsx(Ye,{})]}),e.jsxRuntimeExports.jsx("div",{className:"my-1 space-y-1",children:l.map((x,j)=>e.jsxRuntimeExports.jsx(ht,{col:x,idx:j},x))})]})]})}function ht({col:s,idx:n}){const t=e.useEditorStore(l=>{var x;return(x=l.card)==null?void 0:x.preferences}),r=e.useEditorStore(l=>{var x;return(x=l.card.preferences)==null?void 0:x.datasetOptions}),i=r==null?void 0:r.find(l=>l.idx===n),{setCardPreferences:a}=e.useEditorStore(l=>l.actions);function o(l){if(!i)a({...t,datasetOptions:[...r||[],{idx:n,type:l==="area"?"line":l,fill:l==="area"?"origin":""}]});else{const x={...i};x.type=l==="area"?"line":l,x.fill=l==="area"?"origin":"";const j=r==null?void 0:r.map(u=>u.idx===n?x:u);a({...t,datasetOptions:j})}}return e.jsxRuntimeExports.jsxs("div",{className:"group flex items-center justify-between gap-5 rounded-md bg-muted/70 px-2 py-1 hover:bg-muted",children:[e.jsxRuntimeExports.jsx("p",{children:s}),e.jsxRuntimeExports.jsxs("div",{className:"flex gap-2",children:[e.jsxRuntimeExports.jsx(ve,{onClick:()=>o("bar"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsxRuntimeExports.jsx(Ce,{onClick:()=>o("line"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsxRuntimeExports.jsx(cs,{onClick:()=>o("area"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsxRuntimeExports.jsx(e.Separator,{orientation:"vertical",className:"invisible size-4 cursor-pointer py-2 text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsxRuntimeExports.jsx(mt,{idx:n})]})]})}function jt(){return e.jsxRuntimeExports.jsx("div",{className:"space-y-6 px-6 py-2",children:e.jsxRuntimeExports.jsxs(e.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Stacked Chart"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 font-mono text-xs",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT x-axis, stack-by, y-axis FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"x-axis - category"}),e.jsxRuntimeExports.jsx("li",{children:"stack by - category"}),e.jsxRuntimeExports.jsx("li",{children:"y-axis - number"})]}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:s=>s.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#stacked-chart",children:"example"})," in the docs."]})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-2",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Settings"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 px-2",children:[e.jsxRuntimeExports.jsx(Xe,{}),e.jsxRuntimeExports.jsx(pt,{})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filter on click"}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:"px-2",children:e.jsxRuntimeExports.jsx(he,{})})]})]})})}function Et({}){const s=e.useEditorStore(r=>{var i;return(i=r.card)==null?void 0:i.preferences}),n=e.useEditorStore(r=>r.actions.setCardPreferences),t=r=>{n({...s,allowDownload:r})};return e.jsxRuntimeExports.jsxs("div",{className:"space-y-6 px-6 py-2",children:[e.jsxRuntimeExports.jsx(e.Accordion,{defaultValue:["item-3"],type:"multiple",children:e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filter on click"}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:"px-2",children:e.jsxRuntimeExports.jsx(he,{})})]})}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.Checkbox,{onCheckedChange:t,id:"allow-download"}),e.jsxRuntimeExports.jsx("label",{htmlFor:"allow-download",className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:"Allow Download"})]})]})}const ft=e.jsxRuntimeExports.jsxs("div",{className:"space-y-4 font-mono text-xs",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT dimension, cohort, metric FROM table"}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:s=>s.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#pyramid-chart",children:"example"})," in the docs."]})]}),gt=e.jsxRuntimeExports.jsxs("div",{className:"space-y-4 font-mono text-xs",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT y-axis, label, range-from, range-to, range-value FROM table"}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:s=>s.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#range-chart",children:"example"})," in the docs."]})]});function Rt(){const s=e.useEditorStore(t=>t.card.type);function n(t){switch(t){case"stackedBar":return e.jsxRuntimeExports.jsx(jt,{});case"pyramid":return e.jsxRuntimeExports.jsx(ye,{docContent:ft,cardType:t});case"kpi":return e.jsxRuntimeExports.jsx(dt,{});case"line":case"bar":case"range":return e.jsxRuntimeExports.jsx(ye,{docContent:gt,cardType:t});case"pie":case"doughnut":case"polarArea":case"radar":return e.jsxRuntimeExports.jsx(ye,{cardType:t});case"bubble":case"scatter":return e.jsxRuntimeExports.jsx(it,{cardType:t});case"table":return e.jsxRuntimeExports.jsx(Et,{cardType:t});default:return e.jsxRuntimeExports.jsx(ct,{})}}return e.jsxRuntimeExports.jsx(e.ScrollArea,{className:"h-full w-full text-sm",children:n(s)})}function bt(){const s=e.useEditorStore(n=>n.isShowingVisual);return e.jsxRuntimeExports.jsxs(e.ResizablePanelGroup,{direction:"vertical",className:"min-w-full max-w-lg min-h-[250px]",children:[e.jsxRuntimeExports.jsx(e.ResizablePanel,{role:"query-section",className:"flex",minSize:20,defaultSize:40,children:e.jsxRuntimeExports.jsx(Xs,{})}),e.jsxRuntimeExports.jsx(e.ResizableHandle,{withHandle:!0,className:"border "}),e.jsxRuntimeExports.jsx(e.ResizablePanel,{className:"pb-1",role:"visual-section",minSize:0,defaultSize:60,children:s?e.jsxRuntimeExports.jsxs(e.ResizablePanelGroup,{direction:"horizontal",children:[e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsx(e.ResizablePanel,{className:"flex min-w-[275px]",minSize:20,defaultSize:25,maxSize:30,children:e.jsxRuntimeExports.jsx(Rt,{})})}),e.jsxRuntimeExports.jsx(e.ResizableHandle,{className:"border "}),e.jsxRuntimeExports.jsx(e.ResizablePanel,{minSize:40,defaultSize:75,maxSize:100,children:e.jsxRuntimeExports.jsx(De,{})})]}):e.jsxRuntimeExports.jsx(De,{})})]})}function St({authToken:s,onSave:n,onClose:t}){const r=e.useEditorStore(o=>o.actions.setOnSave),i=e.useEditorStore(o=>o.actions.setOnClose),a=e.useDashboardStore(o=>o.actions.setAuthToken);return f.useEffect(()=>{n&&r(n),t&&i(t)},[n,r,t,i]),f.useEffect(()=>{s&&s.accessToken&&a(s)},[s,a]),e.jsxRuntimeExports.jsxs(e.EditorPanel,{className:"rounded-none",role:"editor-panel",children:[e.jsxRuntimeExports.jsx(e.EditorAside,{className:"rounded-none border-r-[1.5px]",children:e.jsxRuntimeExports.jsx(Ve,{})}),e.jsxRuntimeExports.jsx(e.EditorMain,{children:e.jsxRuntimeExports.jsx(bt,{})})]})}function yt(){e.useDashboardStore(o=>o.selectedCardId);const s=e.useDashboardStore(o=>o.selectedSheetId),{setIsVisualEditing:n}=e.useDashboardStore(o=>o.actions),t=e.useDashboardStore(o=>o.isVisualEditing),r=e.useDashboardStore(o=>o.actions.updateFrame);function i(o){s&&(r(s,o),n(!1))}function a(){n(!1)}return e.jsxRuntimeExports.jsx("div",{role:"editor-container",className:e.cn("flex grow",{block:t,hidden:!t}),children:e.jsxRuntimeExports.jsx(St,{onSave:i,onClose:a})})}function vt({columns:s,tableName:n}){const t=e.useEditorStore(d=>d.selectedConnectionId),r=e.useEditorStore(d=>d.selectedDatabaseName),i=e.useEditorStore(d=>d.selectedSchemaName),a=e.useEditorStore(d=>d.selectedTableName),o=e.useDashboardStore(d=>d.dashboard.filters)||[],l=e.useDashboardStore(d=>d.actions.addFilter),x=e.useDashboardStore(d=>d.actions.removeFilter),j=e.useDashboardStore(d=>d.actions.removeFilterValue);function u(d){const S=e.fmt(d.column_name),c=e.fmt(r||""),m=e.fmt(i||""),h=e.fmt(n),C=e.getQualifiedTableName(m,h),g=`${C}.${S}`;console.log("find",g,h,c);const A=o==null?void 0:o.find(y=>y.column===g&&y.table===h&&(y.database===c||y.database===r));if(A)j(A.id),x(A.id);else{if(n==="api"&&t){l({id:e.v4(),column:g,title:d.column_name,dataType:d.data_type,table:"api",database:"",connectionId:t,operation:"in",sql:e.getDefaultFilterSql(d.data_type,C,S)});return}l({id:e.v4(),column:`${C}.${S}`,title:d.column_name,dataType:d.data_type,table:a||"",database:r||"",connectionId:t||"",operation:"in",sql:e.getDefaultFilterSql(d.data_type,C,S)})}}return e.jsxRuntimeExports.jsx("div",{className:"xbg-red-100 flex-1 basis-0 flex-col overflow-scroll px-3",children:s==null?void 0:s.map(d=>{const S=o==null?void 0:o.find(c=>c.column===e.fmt(d.column_name)&&c.table===a&&c.database===r);return e.jsxRuntimeExports.jsx("div",{onClick:()=>u(d),className:e.cn("group flex cursor-pointer items-center justify-between border border-dashed border-background px-3 py-[6px] text-sm transition-colors hover:bg-muted/50",{"bg-muted":S}),children:e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxRuntimeExports.jsx(qe,{column:d}),e.jsxRuntimeExports.jsx("span",{children:d.column_name})]})},d.column_name)})})}function Ct(){e.useDashboardStore(n=>n.showFilters);const s=e.useDashboardStore(n=>n.actions.setShowFilters);return e.jsxRuntimeExports.jsxs("section",{className:"relative flex grow flex-col border-l px-4",children:[e.jsxRuntimeExports.jsxs("div",{className:"mt-4 flex items-center justify-between gap-2 px-3",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"text-lg",children:"Filters"}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>s(!1),className:"h-7 w-7 p-0",variant:"ghost",children:e.jsxRuntimeExports.jsx(e.Cross2Icon,{})})]}),e.jsxRuntimeExports.jsx("div",{className:"flex grow",children:e.jsxRuntimeExports.jsx(Ve,{ColumnsComponent:(n,t,r)=>e.jsxRuntimeExports.jsx(vt,{schemaName:n,tableName:t,columns:r})})})]})}function Nt(){e.useDashboardStore(t=>t.dashboard);const s=e.useDashboardStore(t=>t.showFilters),n=e.useDashboardStore(t=>t.isVisualEditing);return e.useDashboardStore(t=>t.bookmarkKey),e.jsxRuntimeExports.jsxs("div",{role:"dashboard-plus-main",className:e.cn("grow",{hidden:n,flex:!n}),children:[e.jsxRuntimeExports.jsx(e.DashboardTabs,{}),s&&e.jsxRuntimeExports.jsx("div",{role:"filter-aside-container",className:"flex",children:e.jsxRuntimeExports.jsx(Ct,{})})]})}function kt(){const s=e.useDashboardStore(r=>r.dashboard),n=e.useDashboardStore(r=>r.actions.setDashboard),t=e.useDashboardStore(r=>r.showDashboardJSON);return e.useDashboardStore(r=>r.actions.setShowDashboardJSON),e.jsxRuntimeExports.jsx("div",{className:e.cn(" p-2",{hidden:!t}),children:e.jsxRuntimeExports.jsx(e.de,{onChange:r=>{if(r)try{JSON.parse(r),n(JSON.parse(r))}catch{}},defaultLanguage:"json",className:"h-[550px] overflow-y-auto ",value:JSON.stringify(s,null,2),options:{minimap:{enabled:!1},glyphMargin:!1,wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:12,renderLineHighlight:"none"}})})}function wt({showControls:s=!1,showFooter:n=!0,...t}){return e.jsxRuntimeExports.jsxs(e.SemaphorContextProvider,{dashboardProps:t,children:[e.jsxRuntimeExports.jsx(e.Te,{}),e.jsxRuntimeExports.jsxs(e.UXProvider,{children:[e.jsxRuntimeExports.jsx(kt,{}),e.jsxRuntimeExports.jsxs(e.DashboardPanel,{...t,children:[s&&e.jsxRuntimeExports.jsx(Fs,{}),e.jsxRuntimeExports.jsx(yt,{}),e.jsxRuntimeExports.jsx(Nt,{})]})]})]})}exports.DashboardPlus=wt;exports.SelectComponent=pe;exports.useEditorAside=Ne;
210
+ Visual Query Syntax: ${Hs}`,{data:N,isLoading:z,isFetching:I,isError:_,refetch:F}=e.useQuery({queryKey:["ai-query"],queryFn:()=>e.getRequest("https://semaphor.cloud/api/v1/ai",(x==null?void 0:x.accessToken)||"",{user_content:`userContent: ${k} ${j?E:""}`}),enabled:!1});function O(R){if(R.toLowerCase().includes("bar"))m("bar");else if(R.toLowerCase().includes("line"))m("line");else if(R.toLowerCase().includes("bubble"))m("bubble");else if(R.toLowerCase().includes("scatter"))m("scatter");else if(R.toLowerCase().includes("stacked"))m("stackedBar");else if(R.toLowerCase().includes("pie"))m("pie");else if(R.toLowerCase().includes("donut")||R.toLowerCase().includes("doughnut"))m("doughnut");else if(R.toLowerCase().includes("radar"))m("radar");else return m("bar"),!1;return!0}f.useEffect(()=>{N&&C(R=>[...R,{role:"ai",content:N.response}])},[N]),f.useEffect(()=>{const R=setTimeout(()=>{var b;l.current&&(l.current.scroll({top:l.current.scrollHeight,behavior:"smooth"}),(b=o.current)==null||b.focus())},100);return()=>clearTimeout(R)},[h]);function T(){t&&(C(R=>[...R,{role:"user",content:t}]),O(t)&&u(!0),r(""),F())}f.useEffect(()=>{i&&(T(),a(!1))},[i,a]);const K={fontFamily:"Arial, sans-serif",lineHeight:1.6,fontSize:15,width:"100%"},q={fontFamily:"monospace",fontSize:14,lineHeight:1.6},P={fontFamily:"Arial, sans-serif",lineHeight:1.6,fontSize:15,padding:"2px 0",marginLeft:20,listStyleType:"disc"},H={p:({node:R,...b})=>e.jsxRuntimeExports.jsx("p",{style:K,...b}),code:({node:R,...b})=>e.jsxRuntimeExports.jsx("code",{className:"rounded-sm bg-muted px-2 py-1 text-sm",...b}),pre:({node:R,...b})=>e.jsxRuntimeExports.jsxs("pre",{className:"space-y-2 rounded-sm bg-muted/50 p-3",style:q,children:[e.jsxRuntimeExports.jsx("code",{className:"whitespace-normal text-sm",children:b.children}),e.jsxRuntimeExports.jsxs("div",{className:"flex justify-start gap-2",children:[e.jsxRuntimeExports.jsx(e.Button,{onClick:M,size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(e.ClipboardCopyIcon,{})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:w=>{const L=M(w);L&&(n(!1),d(L),c(!0))},size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(e.PlayIcon,{})})]})]}),li:({node:R,...b})=>e.jsxRuntimeExports.jsx("li",{style:P,...b})};function M(R){const b=R.currentTarget.closest("pre");if(!b)return;const w=b.textContent||b.innerText;return navigator.clipboard.writeText(w).then(()=>console.log("Text copied to clipboard")).catch(L=>console.error("Error in copying text: ",L)),w}function D(){return h==null?void 0:h.map((R,b)=>R.role==="user"?e.jsxRuntimeExports.jsxs("div",{className:"flex items-start rounded-md bg-muted p-3 text-sm",children:[e.jsxRuntimeExports.jsx(Ts,{className:"mr-2 h-5 w-5"}),e.jsxRuntimeExports.jsx("div",{children:R.content})]},b):R.role==="ai"?e.jsxRuntimeExports.jsx(e.Markdown,{className:"w-full overflow-auto py-1",components:H,children:N==null?void 0:N.response.replace(/DuckDB/gi,"Semaphor")},b):e.jsxRuntimeExports.jsx("div",{},b))}return e.jsxRuntimeExports.jsxs(e.Dialog,{open:s,onOpenChange:n,children:[e.jsxRuntimeExports.jsx(e.DialogTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.Button,{size:"sm",className:"w-full justify-start border font-normal text-muted-foreground focus-visible:ring-0 focus-visible:ring-offset-0",variant:"secondary",children:"Type your question here..."})}),e.jsxRuntimeExports.jsxs(e.DialogContent,{className:"flex flex-col justify-between overflow-auto sm:max-w-[425px] md:max-h-[625px] md:min-w-[625px]",children:[e.jsxRuntimeExports.jsxs(e.DialogHeader,{children:[e.jsxRuntimeExports.jsx(e.DialogTitle,{children:"Assistant"}),e.jsxRuntimeExports.jsx(e.DialogDescription,{children:"What can I help you with?"})]}),e.jsxRuntimeExports.jsx("div",{ref:l,className:"h-[625px] w-full overflow-auto border-t border-t-muted",children:e.jsxRuntimeExports.jsx("div",{className:"space-y-4 py-2 pr-3",role:"messages",children:D()})}),e.jsxRuntimeExports.jsx("div",{children:e.jsxRuntimeExports.jsxs("div",{className:"flex w-full items-center rounded-md border",children:[e.jsxRuntimeExports.jsx(e.Textarea,{autoFocus:!0,ref:o,onKeyDown:R=>{R.key==="Enter"&&!R.shiftKey&&(R.preventDefault(),r(""),T())},placeholder:"Type your question here...",onFocus:R=>{const b=R.target,w=b.value.length;b.setSelectionRange(w,w)},className:e.cn("max-h-10 min-h-7 resize-none border-none focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0"),disabled:z||I,value:t,onChange:R=>r(R.target.value)})," ",e.jsxRuntimeExports.jsx(e.Button,{className:"h-8",size:"sm",variant:"ghost",onClick:T,children:!z&&!I?e.jsxRuntimeExports.jsx(e.PaperPlaneIcon,{}):e.jsxRuntimeExports.jsx(e.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"})})]})})]})]})}var _e={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Ae=f.createContext&&f.createContext(_e),$s=["attr","size","title"];function Ks(s,n){if(s==null)return{};var t=Gs(s,n),r,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(s);for(i=0;i<a.length;i++)r=a[i],!(n.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(s,r)&&(t[r]=s[r])}return t}function Gs(s,n){if(s==null)return{};var t={},r=Object.keys(s),i,a;for(a=0;a<r.length;a++)i=r[a],!(n.indexOf(i)>=0)&&(t[i]=s[i]);return t}function Ee(){return Ee=Object.assign?Object.assign.bind():function(s){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(s[r]=t[r])}return s},Ee.apply(this,arguments)}function Te(s,n){var t=Object.keys(s);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(s);n&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(s,i).enumerable})),t.push.apply(t,r)}return t}function fe(s){for(var n=1;n<arguments.length;n++){var t=arguments[n]!=null?arguments[n]:{};n%2?Te(Object(t),!0).forEach(function(r){Us(s,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(t)):Te(Object(t)).forEach(function(r){Object.defineProperty(s,r,Object.getOwnPropertyDescriptor(t,r))})}return s}function Us(s,n,t){return n=Qs(n),n in s?Object.defineProperty(s,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):s[n]=t,s}function Qs(s){var n=Js(s,"string");return typeof n=="symbol"?n:String(n)}function Js(s,n){if(typeof s!="object"||s===null)return s;var t=s[Symbol.toPrimitive];if(t!==void 0){var r=t.call(s,n||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(n==="string"?String:Number)(s)}function He(s){return s&&s.map((n,t)=>f.createElement(n.tag,fe({key:t},n.attr),He(n.child)))}function te(s){return n=>f.createElement(Ws,Ee({attr:fe({},s.attr)},n),He(s.child))}function Ws(s){var n=t=>{var{attr:r,size:i,title:a}=s,o=Ks(s,$s),l=i||t.size||"1em",x;return t.className&&(x=t.className),s.className&&(x=(x?x+" ":"")+s.className),f.createElement("svg",Ee({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},t.attr,r,o,{className:x,style:fe(fe({color:s.color||t.color},t.style),s.style),height:l,width:l,xmlns:"http://www.w3.org/2000/svg"}),a&&f.createElement("title",null,a),s.children)};return Ae!==void 0?f.createElement(Ae.Consumer,null,t=>n(t)):n(_e)}function Ys(s){return te({tag:"svg",attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M439.8 200.5c-7.7-30.9-22.3-54.2-53.4-54.2h-40.1v47.4c0 36.8-31.2 67.8-66.8 67.8H172.7c-29.2 0-53.4 25-53.4 54.3v101.8c0 29 25.2 46 53.4 54.3 33.8 9.9 66.3 11.7 106.8 0 26.9-7.8 53.4-23.5 53.4-54.3v-40.7H226.2v-13.6h160.2c31.1 0 42.6-21.7 53.4-54.2 11.2-33.5 10.7-65.7 0-108.6zM286.2 404c11.1 0 20.1 9.1 20.1 20.3 0 11.3-9 20.4-20.1 20.4-11 0-20.1-9.2-20.1-20.4.1-11.3 9.1-20.3 20.1-20.3zM167.8 248.1h106.8c29.7 0 53.4-24.5 53.4-54.3V91.9c0-29-24.4-50.7-53.4-55.6-35.8-5.9-74.7-5.6-106.8.1-45.2 8-53.4 24.7-53.4 55.6v40.7h106.9v13.6h-147c-31.1 0-58.3 18.7-66.8 54.2-9.8 40.7-10.2 66.1 0 108.6 7.6 31.6 25.7 54.2 56.8 54.2H101v-48.8c0-35.3 30.5-66.4 66.8-66.4zm-6.7-142.6c-11.1 0-20.1-9.1-20.1-20.3.1-11.3 9-20.4 20.1-20.4 11 0 20.1 9.2 20.1 20.4s-9 20.3-20.1 20.3z"},child:[]}]})(s)}function Xs(){const{theme:s}=e.useTheme(),n=f.useRef(),t=f.useRef(),[r,i]=f.useState(!1),[a,o]=f.useState(!1),[l,x]=f.useState(!1),[j,u]=f.useState(""),[d,S]=f.useState(!1),{authToken:c}=e.useSemaphorContext();e.useDashboardStore(p=>p.selectedSheetId);const m=e.useDashboardStore(p=>p.dashboard.baseQueries),h=e.useEditorStore(p=>p.card),C=e.useDashboardStore(p=>p.theme),g=e.useEditorStore(p=>p.isShowingVisual),A=e.useEditorStore(p=>p.selectedConnectionId),y=e.useEditorStore(p=>p.selectedDatabaseName),k=e.useEditorStore(p=>p.selectedSchemaName);e.useDashboardStore(p=>p.actions.updateFrameCard);const E=e.useEditorStore(p=>p.selectedTableName),N=e.useEditorStore(p=>p.card.sql),z=e.useEditorStore(p=>p.card.python),I=e.resolveBaseQuery(N,m),_=e.useEditorStore(p=>p.selectedConnectionId),F=e.useEditorStore(p=>p.frame),O=e.useEditorStore(p=>p.filterValues),T=e.useEditorStore(p=>p.applyFilters),{setCardCustomCfg:K,setQueryResultColumns:q,setFilterValues:P,setCardSql:H,setCardPython:M,setQueryError:D,setPythonStdOut:R,setCardPreferences:b}=e.useEditorStore(p=>p.actions),w=e.useEditorStore(p=>p.onSave),L=e.useEditorStore(p=>p.actions.setApplyFilters),Z=e.useEditorStore(p=>p.onClose),$=e.useEditorStore(p=>p.actions.setCardData),re=e.useEditorStore(p=>p.actions.setSqlGen),ne=e.useEditorStore(p=>p.runSql),oe=e.useEditorStore(p=>p.actions.setRunSql),ee=e.useEditorStore(p=>p.actions.setIsSqlRunning),{data:B,isLoading:G,isFetching:U,isSuccess:ie,isError:Q,error:ue,status:ge,refetch:ae}=e.useQuery({queryKey:[I,z],queryFn:()=>e.postRequest("https://semaphor.cloud/api/v1/query",(c==null?void 0:c.accessToken)||"",{connection_id:_,sql:I,python:z===e.PYTHON_DEFAULT_CODE?"":z,active_filters:T?O:[]}),enabled:!1,retry:!1});f.useEffect(()=>{if(B&&($(B.records),R((B==null?void 0:B.output)||""),B.records.length>0)){const{dimensionKeys:p}=e.getKeys(B.records);q(p)}},[B,$,q,R]),f.useEffect(()=>{ne&&(ae(),oe(!1))},[ne,ae,oe]),f.useEffect(()=>{(G||U)&&ee(!0),(Q||ie)&&ee(!1),Q?(D(ue.message),$([]),q([]),R("")):D("")},[G,U,B,R,Q,ie,ee,$,q,D,ue]);function je(){H(""),$([]),re({}),K(""),b({})}const de=p=>{t.current=p};function v(){let p=N;N&&!N.includes("{{")&&(p=Bs(N),H(p));const J={...h,lastSelectedSchema:k,lastSelectedDatabase:y,lastSelectedTable:E,connectionId:A,type:g?h.type:"table",sql:p,customCfg:g?h.customCfg:null},me=F.cards.map(le=>le.id===h.id?J:le);w==null||w({...F,cards:me})}function Ze(){Z==null||Z()}function es(p){const J=getComputedStyle(document.documentElement).getPropertyValue(p);return ss(J)}function ss(p){const[J,me,le]=p.split(" "),V=parseFloat(J),ns=parseFloat(me),os=parseFloat(le),is=ns/100,ze=os/100,se=(1-Math.abs(2*ze-1))*is,ce=se*(1-Math.abs(V/60%2-1)),Re=ze-se/2;let W=0,Y=0,X=0;0<=V&&V<60?(W=se,Y=ce,X=0):60<=V&&V<120?(W=ce,Y=se,X=0):120<=V&&V<180?(W=0,Y=se,X=ce):180<=V&&V<240?(W=0,Y=ce,X=se):240<=V&&V<300?(W=ce,Y=0,X=se):300<=V&&V<360&&(W=se,Y=0,X=ce),W=Math.round((W+Re)*255),Y=Math.round((Y+Re)*255),X=Math.round((X+Re)*255);const be=as=>{const Se=as.toString(16);return Se.length==1?"0"+Se:Se};return`#${be(W)}${be(Y)}${be(X)}`}f.useEffect(()=>{const p=n.current,J=t.current;if(p){const me=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",le=C==="system"?me:C;p.editor.defineTheme("default",{base:le==="light"?"vs":"vs-dark",inherit:!0,rules:[],colors:{"editor.background":le==="light"?"#ffffff":es("--background")}}),p.editor.setTheme("default")}return J&&p&&J.addCommand(p.KeyMod.Shift|p.KeyCode.Enter,function(){return console.log("Executing query..."),ae(),!1}),()=>{}},[s,C,n.current]);function we(p){n.current=p}function ts(){return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[a&&e.jsxRuntimeExports.jsx("div",{className:"xbg-yellow-100 relative flex w-1/3 min-w-0 grow overflow-hidden border-l p-1 text-xs",role:"editor-filter-container",children:e.jsxRuntimeExports.jsxs("div",{className:"w-[99%]",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2 pt-3",children:[e.jsxRuntimeExports.jsx(Vs,{checked:T,onCheckedChange:()=>L(!T),text:"Apply Filters"}),e.jsxRuntimeExports.jsx(_s,{}),O&&a&&e.jsxRuntimeExports.jsx(e.Cross2Icon,{onClick:()=>o(!1),className:"bg-background/50 text-foreground/50 hover:cursor-pointer hover:text-foreground"})]}),e.jsxRuntimeExports.jsx(e.Ft,{theme:"default",onChange:p=>{if(p)try{JSON.parse(p),P(JSON.parse(p))}catch{}},defaultLanguage:"json",className:"mt-1 min-h-[220px]",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&&!a&&e.jsxRuntimeExports.jsx(Le,{onClick:()=>o(!0),className:e.cn("absolute bottom-4 right-6 h-3 w-3 text-foreground/50 hover:cursor-pointer hover:text-foreground",{"font-bold text-red-800":T})})]})}function rs(){return e.jsxRuntimeExports.jsxs(e.ResizablePanelGroup,{className:"flex grow pb-1",direction:"vertical",role:"editor-resizable-group",children:[e.jsxRuntimeExports.jsxs(e.ResizablePanel,{id:"1",order:1,defaultSize:r?20:100,className:"relative flex grow",children:[e.jsxRuntimeExports.jsx("div",{role:"sql-container",className:"relative flex w-[99%]",children:e.jsxRuntimeExports.jsx(e.Ft,{theme:"default",className:"pt-3",onChange:p=>{H(p)},value:N,options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"sql",defaultValue:"SELECT * FROM table",beforeMount:we,onMount:de})}),r&&e.jsxRuntimeExports.jsx("code",{className:"absolute right-6 top-3 text-sm text-muted-foreground/70",children:"sql"})]}),r&&e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(e.ResizableHandle,{withHandle:!0,className:"border"}),e.jsxRuntimeExports.jsxs(e.ResizablePanel,{id:"2",order:2,defaultSize:80,className:"relative flex grow",children:[e.jsxRuntimeExports.jsx("div",{role:"python-container",className:"relative flex w-[99%] pt-0",children:e.jsxRuntimeExports.jsx(e.Ft,{className:"pt-3",theme:"default",onChange:p=>{M(p&&p.trim()||"")},value:z||e.PYTHON_DEFAULT_CODE,options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"python",beforeMount:we,onMount:de})}),e.jsxRuntimeExports.jsx("code",{className:"absolute right-6 top-3 text-sm text-muted-foreground/70",children:"python"})]})]})]})}return e.jsxRuntimeExports.jsxs("section",{role:"editor-section",className:"flex grow flex-col justify-end",children:[e.jsxRuntimeExports.jsxs("div",{role:"sql-editor",className:"relative flex grow justify-between overflow-y-scroll",children:[rs(),ts()]}),e.jsxRuntimeExports.jsxs("div",{role:"editor-controls",className:"item-center flex flex-wrap justify-between gap-2 px-6 py-4",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex grow items-center gap-2",children:[e.jsxRuntimeExports.jsxs(e.Button,{title:"Shift + Enter",disabled:G||U,onClick:()=>{ae()},className:"shrink-0",size:"sm",variant:"outline",children:[G||U?e.jsxRuntimeExports.jsx(e.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"}):e.jsxRuntimeExports.jsx(Ss,{className:"mr-2 h-4 w-4"}),"Run"]}),Q&&e.jsxRuntimeExports.jsx(qs,{error:ue.message,setShowAIDialog:x,setTriggerAIRun:S,setUserInputforAI:u}),e.jsxRuntimeExports.jsxs(e.Button,{onClick:je,className:"",size:"sm",variant:"outline",children:[e.jsxRuntimeExports.jsx(ds,{className:"mr-2 size-4"}),"Clear"]}),e.jsxRuntimeExports.jsx(e.Toggle,{pressed:r,onPressedChange:p=>i(p),className:"",size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(Ys,{className:"size-4 text-foreground/70"})}),e.jsxRuntimeExports.jsx(Ps,{open:l,setOpen:x,userInput:j,triggerAIRun:d,setTriggerAIRun:S,setUserInput:p=>u(p)})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-end gap-2",children:[e.jsxRuntimeExports.jsxs(e.Button,{onClick:v,size:"sm",variant:"outline",children:[e.jsxRuntimeExports.jsx(e.Check,{className:"mr-2 size-4 font-bold text-green-600"}),"Accept"]}),e.jsxRuntimeExports.jsxs(e.Button,{onClick:Ze,className:"w-full",size:"sm",variant:"outline",children:[e.jsxRuntimeExports.jsx(e.Cross2Icon,{className:"mr-2 size-4"}),"Close"]})]})]})]})}function Zs({data:s}){var o;const[n,t]=f.useState([]),i=Object.keys(s[0]).map(l=>({accessorKey:l,header:({column:x})=>{const j=x.getIsSorted();return e.jsxRuntimeExports.jsx("div",{className:"flex gap-2",children:e.jsxRuntimeExports.jsxs("div",{className:"flex cursor-pointer items-center",onClick:()=>x.toggleSorting(x.getIsSorted()==="asc"),children:[l,j==="asc"?e.jsxRuntimeExports.jsx(e.TriangleUpIcon,{className:"ml-2 h-5 w-5"}):j==="desc"?e.jsxRuntimeExports.jsx(e.TriangleDownIcon,{className:"ml-2 h-5 w-5"}):null]})})}})),a=e.useReactTable({data:s,columns:i,getCoreRowModel:e.getCoreRowModel(),getPaginationRowModel:e.getPaginationRowModel(),onSortingChange:t,getSortedRowModel:e.getSortedRowModel(),manualPagination:!0,state:{sorting:n}});return e.jsxRuntimeExports.jsxs(e.Table$1,{children:[e.jsxRuntimeExports.jsx(e.TableHeader,{children:a.getHeaderGroups().map(l=>e.jsxRuntimeExports.jsx(e.TableRow,{children:l.headers.map(x=>e.jsxRuntimeExports.jsx(e.TableHead,{className:"sticky top-0 bg-muted",children:x.isPlaceholder?null:e.flexRender(x.column.columnDef.header,x.getContext())},x.id))},l.id))}),e.jsxRuntimeExports.jsx(e.TableBody,{children:(o=a.getRowModel().rows)!=null&&o.length?a.getRowModel().rows.map(l=>e.jsxRuntimeExports.jsx(e.TableRow,{className:"whitespace-nowrap py-2","data-state":l.getIsSelected()&&"selected",children:l.getVisibleCells().map(x=>e.jsxRuntimeExports.jsx(e.TableCell,{children:e.flexRender(x.column.columnDef.cell,x.getContext())},x.id))},l.id)):e.jsxRuntimeExports.jsx(e.TableRow,{children:e.jsxRuntimeExports.jsx(e.TableCell,{colSpan:i.length,className:"h-24 text-center",children:"No results."})})})]})}function Pe({className:s,...n}){var o;f.useState(0);const t=e.useDashboardStore(l=>l.themeStyle),r=e.useEditorStore(l=>l.card),i=e.useEditorStore(l=>l.actions.setCard);if(f.useEffect(()=>{},[r.data,r.type,r.cfg,r.customCfg,t,r.preferences]),!r.id)return null;let a;return r.data&&r.data.length>0&&(a=e.createChartConfig({data:r.data,cardType:r.type,cfg:r.cfg,customCfg:r.customCfg,preferences:r.preferences})),e.jsxRuntimeExports.jsxs(e.Card,{role:"editor-visual-card",className:e.cn("relative flex h-full flex-col rounded-none",s),...n,children:[e.jsxRuntimeExports.jsxs(e.CardHeader,{className:"py-4",children:[e.jsxRuntimeExports.jsx(e.Editable,{text:r.title,onSave:l=>i({...r,title:l}),children:e.jsxRuntimeExports.jsx("div",{className:"flex items-center gap-2",children:e.jsxRuntimeExports.jsx(e.CardTitle,{className:"text-base",children:r.title})})},r.title),e.jsxRuntimeExports.jsx(e.Editable,{text:r.description||"",onSave:l=>i({...r,description:l}),children:e.jsxRuntimeExports.jsxs(e.CardDescription,{children:[" ",r.description]})},r.description)]}),e.jsxRuntimeExports.jsxs(e.CardContent,{className:"flex grow flex-col pb-3",children:[r.type!=="table"&&a&&e.jsxRuntimeExports.jsx(e.ChartJsVisual,{cfg:a},JSON.stringify(a)+JSON.stringify(r.preferences)+((o=r==null?void 0:r.preferences)==null?void 0:o.customVisualCode)),r.type==="table"&&r.data&&r.data.length>0&&e.jsxRuntimeExports.jsx(e.$57acba87d6e25586$export$ccf8d8d7bbf3c2cc,{className:"flex min-h-0 flex-1 grow basis-0",children:e.jsxRuntimeExports.jsx(e.TableVisual,{card:r,data:r==null?void 0:r.data})})]})]})}function et(){const[s,n]=f.useState(!1),[t,r]=f.useState(""),[i,a]=f.useState(""),[o,l]=f.useState(""),[x,j]=f.useState(""),u=e.useEditorStore(y=>y.card),d=e.useEditorStore(y=>y.card.customCfg),{setCardCustomCfg:S,setCustomVisualCode:c}=e.useEditorActions();function m(y){var N,z;const k={...y,data:{...y==null?void 0:y.data,datasets:(z=(N=y==null?void 0:y.data)==null?void 0:N.datasets)==null?void 0:z.map(I=>({...I,data:[]}))}};return JSON.stringify(k,null,1)}function h(){var k,E;if(!u.data||u.data.length===0)return;const y=e.createChartConfig({data:u.data,cardType:u.type,cfg:u.cfg,preferences:u.preferences});y&&(r(JSON.stringify(y,null,1)),(k=u==null?void 0:u.preferences)!=null&&k.customVisualCode&&l((E=u==null?void 0:u.preferences)==null?void 0:E.customVisualCode),d&&a(JSON.stringify(d,null,1)))}function C(){if(o&&c(o),!!i)try{const y=JSON.parse(i);return y?(S(y),j(""),a(""),y):void 0}catch(y){console.log(y),j("Invalid JSON")}}function g(){a(""),S(null)}function A(){let y;if(d){const k=e._.cloneDeep(u.cfg),E=e._.merge(k,d);return y=m(E),y}return t?(y=m(JSON.parse(t)),y):""}return e.jsxRuntimeExports.jsxs(e.Dialog,{open:s,onOpenChange:n,children:[e.jsxRuntimeExports.jsx(e.DialogTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.Button,{onClick:h,className:` ${d&&"border-foreground/50 dark:border-foreground/70"}`,size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(e.Settings,{className:"h-4 w-4"})})}),e.jsxRuntimeExports.jsxs(e.DialogContent,{className:"max-h-[70vh] min-h-[70vh] overflow-auto sm:min-w-[900px] lg:min-w-[1200px]",children:[e.jsxRuntimeExports.jsxs(e.DialogHeader,{className:"",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.DialogTitle,{children:"Customize Card"}),e.jsxRuntimeExports.jsxs(e.Tooltip,{children:[e.jsxRuntimeExports.jsx(e.TooltipTrigger,{children:e.jsxRuntimeExports.jsx(js,{onClick:()=>{navigator.clipboard.writeText(u.id)},className:"size-3 cursor-pointer text-muted-foreground/70 transition-colors hover:text-muted-foreground"})}),e.jsxRuntimeExports.jsx(e.TooltipContent,{side:"right",align:"center",children:e.jsxRuntimeExports.jsx("p",{className:"text-xs",children:"Copy Card ID"})})]})]}),e.jsxRuntimeExports.jsxs(e.DialogDescription,{children:["See the configuration options and documentation",e.jsxRuntimeExports.jsx("a",{target:"_blank",className:"ml-1 text-blue-500 underline",href:"https://www.chartjs.org/docs/latest/samples/bar/vertical.html",children:"here."})]})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex grow gap-2",children:[e.jsxRuntimeExports.jsx(Pe,{className:"w-1/2 rounded shadow-none"}),e.jsxRuntimeExports.jsxs(e.Tabs,{defaultValue:"custom-config",className:"flex w-1/2 flex-col",children:[e.jsxRuntimeExports.jsxs(e.TabsList,{className:"justify-start rounded-sm rounded-b-none border border-b-0",children:[e.jsxRuntimeExports.jsxs(e.TabsTrigger,{value:"custom-config",children:[d&&e.jsxRuntimeExports.jsx(e.CheckIcon,{className:"mr-1 h-5 w-5 text-green-600"}),d?"Custom Config":"Default Config"]}),e.jsxRuntimeExports.jsx(e.TabsTrigger,{className:"",value:"output",children:"Output"}),e.jsxRuntimeExports.jsx(e.TabsTrigger,{className:"",value:"custom-code",children:"Custom Code"})]}),e.jsxRuntimeExports.jsx(e.TabsContent,{className:"bg-red-x mt-0 grow rounded-b border border-t-0 p-2",value:"output",children:e.jsxRuntimeExports.jsx(e.Textarea,{disabled:!0,value:t,className:"h-full resize-none border-none font-mono focus-visible:ring-0 focus-visible:ring-offset-0"})}),e.jsxRuntimeExports.jsx(e.TabsContent,{className:"mt-0 grow rounded-b border border-t-0",value:"custom-config",children:e.jsxRuntimeExports.jsx(e.Ft,{className:"h-full w-full overflow-hidden",theme:"default",options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"json",value:A(),onChange:y=>a(y)})}),e.jsxRuntimeExports.jsx(e.TabsContent,{className:"mt-0 grow rounded-b border border-t-0",value:"custom-code",children:e.jsxRuntimeExports.jsx(e.Ft,{className:"h-full w-full overflow-hidden",theme:"default",options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"javascript",value:o,onChange:y=>l(y||"")})})]})]}),e.jsxRuntimeExports.jsxs(e.DialogFooter,{className:"flex items-center",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"mr-2 text-red-500",children:x}),e.jsxRuntimeExports.jsx(e.Button,{disabled:!d,onClick:g,variant:"outline",children:"Reset"}),e.jsxRuntimeExports.jsx(e.Button,{onClick:C,variant:"outline",children:"Apply"}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>n(!1),variant:"outline",children:"Close"})]})]})]})}function $e(s){return te({tag:"svg",attr:{viewBox:"0 0 1024 1024"},child:[{tag:"path",attr:{d:"M926.8 397.1l-396-288a31.81 31.81 0 0 0-37.6 0l-396 288a31.99 31.99 0 0 0-11.6 35.8l151.3 466a32 32 0 0 0 30.4 22.1h489.5c13.9 0 26.1-8.9 30.4-22.1l151.3-466c4.2-13.2-.5-27.6-11.7-35.8zM838.6 417l-98.5 32-200-144.7V199.9L838.6 417zM466 567.2l-89.1 122.3-55.2-169.2L466 567.2zm-116.3-96.8L484 373.3v140.8l-134.3-43.7zM512 599.2l93.9 128.9H418.1L512 599.2zm28.1-225.9l134.2 97.1L540.1 514V373.3zM558 567.2l144.3-46.9-55.2 169.2L558 567.2zm-74-367.3v104.4L283.9 449l-98.5-32L484 199.9zM169.3 470.8l86.5 28.1 80.4 246.4-53.8 73.9-113.1-348.4zM327.1 853l50.3-69h269.3l50.3 69H327.1zm414.5-33.8l-53.8-73.9 80.4-246.4 86.5-28.1-113.1 348.4z"},child:[]}]})(s)}function Ke(s){return te({tag:"svg",attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M137.39,24.06A16,16,0,0,0,120,40V80.67a15.86,15.86,0,0,0,13.25,15.76A32,32,0,1,1,96,129.68c-.41-8.22,1.27-15,5-20.26h0a15.86,15.86,0,0,0-1.69-20.47L71.69,60.68a16,16,0,0,0-23.63,1.1A103.6,103.6,0,0,0,55,202.05,103.24,103.24,0,0,0,128,232h1.49A104.3,104.3,0,0,0,232,129.48C232.75,75.18,191.19,28.88,137.39,24.06ZM60.32,71.94l27.61,28.19,0,.06A43.29,43.29,0,0,0,80.44,120H40.36A87.13,87.13,0,0,1,60.32,71.94ZM40.37,136h40.3A48,48,0,0,0,120,175.34v40.3A88,88,0,0,1,40.37,136Zm149.77,54.14A87.45,87.45,0,0,1,136,215.61V175.34a47.55,47.55,0,0,0,24.73-12.23A48,48,0,0,0,136,80.66L136,40c45.52,4.08,80.67,43.28,80,89.25A87.45,87.45,0,0,1,190.14,190.14Z"},child:[]}]})(s)}function Ge(s){return te({tag:"svg",attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm87.63,96H191.48A64.1,64.1,0,0,0,136,64.52V40.37A88.13,88.13,0,0,1,215.63,120ZM120,120H80.68A48.09,48.09,0,0,1,120,80.68Zm0,16v39.32A48.09,48.09,0,0,1,80.68,136Zm16,0h39.32A48.09,48.09,0,0,1,136,175.32Zm0-16V80.68A48.09,48.09,0,0,1,175.32,120ZM120,40.37V64.52A64.1,64.1,0,0,0,64.52,120H40.37A88.13,88.13,0,0,1,120,40.37ZM40.37,136H64.52A64.1,64.1,0,0,0,120,191.48v24.15A88.13,88.13,0,0,1,40.37,136ZM136,215.63V191.48A64.1,64.1,0,0,0,191.48,136h24.15A88.13,88.13,0,0,1,136,215.63Z"},child:[]}]})(s)}function Ue(s){return te({tag:"svg",attr:{viewBox:"0 0 24 24",strokeWidth:"2",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},child:[]},{tag:"path",attr:{d:"M6 16m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"},child:[]},{tag:"path",attr:{d:"M16 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"},child:[]},{tag:"path",attr:{d:"M14.5 7.5m-4.5 0a4.5 4.5 0 1 0 9 0a4.5 4.5 0 1 0 -9 0"},child:[]}]})(s)}function Qe(s){return te({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M4 9h4v11H4zM4 4h4v4H4zM10 7h4v4h-4zM16 10h4v4h-4zM16 15h4v5h-4zM10 12h4v8h-4z"},child:[]}]})(s)}function Je(s){return te({tag:"svg",attr:{version:"1.2",baseProfile:"tiny",viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M4 18c-.552 0-1-.448-1-1v-6.382l-.553.276c-.495.248-1.095.046-1.342-.447-.247-.494-.046-1.094.448-1.342l2-1c.31-.155.678-.139.973.044.294.183.474.504.474.851v8c0 .552-.448 1-1 1zM13 18h-5c-.404 0-.769-.244-.924-.617-.155-.374-.069-.804.217-1.09l4-4c.254-.254.394-.591.394-.95 0-.358-.14-.695-.394-.949-.508-.508-1.39-.508-1.9.001-.253.252-.393.589-.393.948 0 .552-.448 1-1 1s-1-.448-1-1c0-.894.348-1.733.98-2.364 1.265-1.263 3.464-1.263 4.727.001.632.631.979 1.471.979 2.363 0 .893-.348 1.733-.979 2.364l-2.293 2.293h2.586c.552 0 1 .448 1 1s-.448 1-1 1zM20.955 12.377c.338-.457.545-1.016.545-1.627 0-1.517-1.234-2.75-2.75-2.75-1.031 0-1.966.569-2.44 1.484-.254.49-.063 1.094.428 1.348.49.254 1.094.062 1.348-.428.128-.249.383-.404.664-.404.414 0 .75.336.75.75s-.336.75-.75.75c-.552 0-1 .448-1 1s.448 1 1 1c.689 0 1.25.561 1.25 1.25s-.561 1.25-1.25 1.25-1.25-.561-1.25-1.25c0-.552-.448-1-1-1s-1 .448-1 1c0 1.792 1.458 3.25 3.25 3.25s3.25-1.458 3.25-3.25c0-.939-.406-1.779-1.045-2.373z"},child:[]}]})(s)}function We(s){return te({tag:"svg",attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M217 25v14h78V25h-78zm0 32v46h14V71h50v32h14V57h-78zm32 32v14h14V89h-14zm-64 32v46h30v-46h-30zm48 0v14h46v-14h-46zm64 0v46h30v-46h-30zm-64 32v14h46v-14h-46zm-80 32v46h62v-46h-62zm80 0v14h46v-14h-46zm64 0v46h62v-46h-62zm-64 32v14h46v-14h-46zm-112 32v46h94v-46h-94zm112 0v14h46v-14h-46zm64 0v46h94v-46h-94zm-64 32v14h46v-14h-46zM89 313v46h126v-46H89zm144 0v14h46v-14h-46zm64 0v46h126v-46H297zm-64 32v14h46v-14h-46zM57 377v46h158v-46H57zm176 0v14h46v-14h-46zm64 0v46h158v-46H297zm-64 32v14h46v-14h-46zM25 441v46h190v-46H25zm208 0v14h46v-14h-46zm64 0v46h190v-46H297zm-64 32v14h46v-14h-46z"},child:[]}]})(s)}function st(){const[s,n]=f.useState(!1),t=e.useEditorStore(l=>l.card.type),{setCardType:r,setCardPreferences:i}=e.useEditorStore(l=>l.actions),a=e.useEditorStore(l=>l.actions.setCardCustomCfg);function o(l){r(l),a(null),i({}),n(!1)}return e.jsxRuntimeExports.jsxs(e.Popover,{open:s,onOpenChange:n,children:[e.jsxRuntimeExports.jsx(e.PopoverTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.Button,{size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(tt,{className:"h-4 w-4",chartType:t})})}),e.jsxRuntimeExports.jsx(e.PopoverContent,{className:"w-50",children:e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 place-items-center",children:[e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("bar"),className:"font-normal",variant:"ghost",children:e.jsxRuntimeExports.jsx(ve,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("line"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ce,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("stackedBar"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Qe,{className:"size-5",strokeWidth:0})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("scatter"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Be,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("bubble"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ue,{className:"size-4"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("pie"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Me,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("doughnut"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ke,{className:"size-5",strokeWidth:1})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("radar"),variant:"ghost",children:e.jsxRuntimeExports.jsx($e,{className:"size-5 font-extralight",strokeWidth:.5})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("polarArea"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ge,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("pyramid"),variant:"ghost",children:e.jsxRuntimeExports.jsx(We,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("range"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Fe,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("table"),variant:"ghost",children:e.jsxRuntimeExports.jsx(e.Table,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("kpi"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Je,{className:"size-6"})})]})})]})}function tt({chartType:s,className:n}){switch(s){case"bar":return e.jsxRuntimeExports.jsx(ve,{className:n});case"line":return e.jsxRuntimeExports.jsx(Ce,{className:n});case"pie":return e.jsxRuntimeExports.jsx(Me,{className:n});case"radar":return e.jsxRuntimeExports.jsx($e,{className:n});case"scatter":return e.jsxRuntimeExports.jsx(Be,{className:n});case"bubble":return e.jsxRuntimeExports.jsx(Ue,{className:n});case"doughnut":return e.jsxRuntimeExports.jsx(Ke,{className:n});case"stackedBar":return e.jsxRuntimeExports.jsx(Qe,{className:"size-4 text-foreground/70"});case"polarArea":return e.jsxRuntimeExports.jsx(Ge,{className:n});case"pyramid":return e.jsxRuntimeExports.jsx(We,{className:n});case"range":return e.jsxRuntimeExports.jsx(Fe,{className:n});case"kpi":return e.jsxRuntimeExports.jsx(Je,{className:n});default:return e.jsxRuntimeExports.jsx(e.Table,{className:n})}}function rt(){const s=e.useEditorStore(t=>t.card.refreshInterval),n=e.useEditorStore(t=>t.actions.setCardRefreshInterval);return e.jsxRuntimeExports.jsxs(e.Popover,{children:[e.jsxRuntimeExports.jsx(e.PopoverTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.Button,{size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(ls,{className:"w-4 h-4"})})}),e.jsxRuntimeExports.jsx(e.PopoverContent,{className:"w-[200px]",children:e.jsxRuntimeExports.jsx("div",{className:"grid gap-4",children:e.jsxRuntimeExports.jsx("div",{className:"grid gap-2",children:e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-5 items-center gap-1",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"col-span-3",htmlFor:"width",children:"Refresh Every"}),e.jsxRuntimeExports.jsx(e.Input,{value:s||"",onChange:t=>n(t.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 De(){e.useEditorStore(o=>o.frame);const s=e.useEditorStore(o=>o.card),n=e.useEditorStore(o=>o.card.data),t=e.useEditorStore(o=>o.isShowingVisual),r=e.useEditorStore(o=>o.isSqlRunning),i=e.useEditorStore(o=>o.queryError),a=e.useEditorStore(o=>o.pythonStdOut);return e.useEditorStore(o=>o.onSave),e.useEditorStore(o=>o.onClose),e.useEditorStore(o=>o.actions.setCardSql),e.useEditorStore(o=>o.actions.setCardType),e.useEditorStore(o=>o.actions.setSqlGen),s?e.jsxRuntimeExports.jsxs("div",{className:"relative flex h-full flex-col pt-3",children:[r&&e.jsxRuntimeExports.jsx(e.LoaderCircle,{className:"absolute bottom-0 left-0 right-0 top-0 z-10 m-auto h-10 w-10 animate-spin text-foreground/10"}),e.jsxRuntimeExports.jsxs("div",{className:"mb-0 flex min-h-10 items-center justify-end gap-2 px-6",children:[t&&e.jsxRuntimeExports.jsxs("div",{className:"flex grow items-center gap-2",children:[e.jsxRuntimeExports.jsx(st,{}),s.type!=="table"&&e.jsxRuntimeExports.jsx(et,{}),e.jsxRuntimeExports.jsx(rt,{})]}),e.jsxRuntimeExports.jsx(ot,{})]}),t?s.type==="kpi"?e.jsxRuntimeExports.jsx("div",{className:"flex grow items-center justify-center",children:e.jsxRuntimeExports.jsx("div",{className:"w-1/2 rounded-md border",children:e.jsxRuntimeExports.jsx(e.KPICard,{isLoading:r,card:s})})}):e.jsxRuntimeExports.jsx(Pe,{className:"grow border-none shadow-none"}):e.jsxRuntimeExports.jsxs("div",{className:"flex min-h-0 w-full flex-1 grow basis-0 px-6",children:[a&&e.jsxRuntimeExports.jsx(nt,{}),s.data&&s.data.length>0&&e.jsxRuntimeExports.jsx(Zs,{data:n||[]}),i&&e.jsxRuntimeExports.jsx("span",{className:"font-mono text-sm",children:i})]})]}):e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:"No Active Card"})}function nt(){const s=e.useEditorStore(t=>t.pythonStdOut);if(!s)return null;const n=s.replace(/\n/g,"<br>");return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx("p",{className:"font-mono text-sm",children:"Output:"}),e.jsxRuntimeExports.jsx("div",{dangerouslySetInnerHTML:{__html:n},className:"bg-muted p-2 font-mono text-sm"}),e.jsxRuntimeExports.jsx(e.Separator,{className:"mb-2"})]})}function ot(){const s=e.useEditorStore(t=>t.isShowingVisual),n=e.useEditorStore(t=>t.actions.setIsShowingVisual);return e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.Label,{htmlFor:"visualize",children:"Chart"}),e.jsxRuntimeExports.jsx(e.Switch,{checked:s,onCheckedChange:()=>n(!s),id:"visualize",className:"data-[state=checked]:bg-foreground/50"})]})}const xe="focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0";function Ie(s,n){var r,i,a;const t=e.getNumberAxis(s,n);return((a=(i=(r=s==null?void 0:s.chartOptions)==null?void 0:r.scales)==null?void 0:i[t])==null?void 0:a.type)||"linear"}function Ye(){var q,P,H,M,D,R;const[s,n]=f.useState(!1),t=e.useEditorStore(b=>{var w;return(w=b.card)==null?void 0:w.preferences}),r=e.useEditorStore(b=>{var w;return(w=b.card)==null?void 0:w.cfg}),i=e.getNumberAxis(t,r),[a,o]=f.useState(Ie(t)),[l,x]=f.useState(((H=(P=(q=t==null?void 0:t.chartOptions)==null?void 0:q.scales)==null?void 0:P[i])==null?void 0:H.min)||""),[j,u]=f.useState(((R=(D=(M=t==null?void 0:t.chartOptions)==null?void 0:M.scales)==null?void 0:D[i])==null?void 0:R.max)||""),[d,S]=f.useState(l||j?"custom":"auto"),[c,m]=f.useState(""),[h,C]=f.useState(0),[g,A]=f.useState(""),[y,k]=f.useState(""),[E,N]=f.useState(""),z=e.useEditorStore(b=>b.actions.setCardPreferences),I=e.useEditorStore(b=>{var w;return(w=b.card)==null?void 0:w.type}),_=["pie","doughnut","polarArea"].includes(I);f.useEffect(()=>{var b,w,L,Z,$,re,ne,oe,ee,B,G,U,ie,Q;o(Ie(t)),x(((L=(w=(b=t==null?void 0:t.chartOptions)==null?void 0:b.scales)==null?void 0:w[i])==null?void 0:L.min)===0?0:""),u(((re=($=(Z=t==null?void 0:t.chartOptions)==null?void 0:Z.scales)==null?void 0:$[i])==null?void 0:re.max)||""),m(((B=(ee=(oe=(ne=t==null?void 0:t.chartOptions)==null?void 0:ne.scales)==null?void 0:oe[i])==null?void 0:ee.ticks)==null?void 0:B.stepSize)||""),C(((G=t==null?void 0:t.numberAxisFormat)==null?void 0:G.decimalPlaces)||0),A(((U=t==null?void 0:t.numberAxisFormat)==null?void 0:U.suffix)||""),k(((ie=t==null?void 0:t.numberAxisFormat)==null?void 0:ie.currency)||""),N(((Q=t==null?void 0:t.numberAxisFormat)==null?void 0:Q.locale)||"")},[s,t,i]);function F(b,w){return w===""||/^[0-9\b]+$/.test(w)?Number(w):Number(b)}function O(){return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-6 items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"col-span-2 hover:cursor-pointer hover:underline",htmlFor:"currency",children:e.jsxRuntimeExports.jsx("a",{target:"_blank",href:"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat",children:"Currency"})}),e.jsxRuntimeExports.jsx(e.Input,{value:y,placeholder:"USD",onChange:b=>k(b.target.value),id:"currency",className:`col-span-2 h-8 w-full ${xe}`}),e.jsxRuntimeExports.jsx(e.Input,{value:E,placeholder:"en-US",onChange:b=>N(b.target.value),id:"locale",className:`col-span-2 h-8 w-full ${xe}`})]}),e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-9 items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"col-span-3",htmlFor:"format",children:"Decimals"}),e.jsxRuntimeExports.jsx(e.Input,{value:h,onChange:b=>C(Number(b.target.value)),id:"format",className:`col-span-6 h-8 w-full tracking-wide ${xe}`})]})]})}function T(){return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Label,{htmlFor:"range",children:"Range"}),e.jsxRuntimeExports.jsx(e.Input,{id:"min",value:l,onChange:b=>x(w=>F(w,b.target.value)),className:`col-span-1 h-8 w-full ${xe}`}),e.jsxRuntimeExports.jsx(e.Input,{value:j,onChange:b=>u(w=>F(w,b.target.value)),id:"max",className:`col-span-1 h-8 w-full ${xe}`})]}),e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Label,{htmlFor:"step-size",children:"Step Size"}),e.jsxRuntimeExports.jsx(e.Input,{value:c,onChange:b=>m(w=>F(w,b.target.value)),id:"step-size",className:`col-span-1 h-8 w-full ${xe}`})]})]})}function K(){var L;let b={};d==="custom"&&(b={min:l,max:j,ticks:{stepSize:c}});const w={...t||{},chartOptions:{...t==null?void 0:t.chartOptions,scales:{...(L=t==null?void 0:t.chartOptions)==null?void 0:L.scales,[i]:{type:a,...a==="linear"?b:{}}}},numberAxisFormat:{decimalPlaces:h,suffix:g,currency:y,locale:E}};z(w)}return e.jsxRuntimeExports.jsxs(e.Popover,{onOpenChange:b=>n(b),children:[e.jsxRuntimeExports.jsx(e.PopoverTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.SliderIcon,{className:"size-4 cursor-pointer text-muted-foreground hover:text-foreground"})}),e.jsxRuntimeExports.jsx(e.PopoverContent,{align:"center",className:"max-w-65",children:e.jsxRuntimeExports.jsxs("div",{className:"grid gap-4",children:[e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsx("h4",{className:"font-medium leading-none",children:"Scale Options"}),e.jsxRuntimeExports.jsx("p",{className:"text-sm text-muted-foreground",children:"Set the scale for the number axis"})]}),e.jsxRuntimeExports.jsxs("div",{className:"grid gap-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Label,{htmlFor:"scale",children:"Type"}),e.jsxRuntimeExports.jsxs(e.Select,{disabled:_,value:a,onValueChange:b=>o(b),children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:"col-span-2 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsxRuntimeExports.jsx(e.SelectValue,{})}),e.jsxRuntimeExports.jsx(e.SelectContent,{id:"type",children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[e.jsxRuntimeExports.jsx(e.SelectLabel,{children:"Option"}),e.jsxRuntimeExports.jsx(e.SelectItem,{value:"linear",children:"Linear"}),e.jsxRuntimeExports.jsx(e.SelectItem,{value:"logarithmic",children:"Logarithmic"})]})})]})]}),a=="linear"&&e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 items-center gap-2 py-1",children:[e.jsxRuntimeExports.jsx(e.Label,{htmlFor:"scale-option",children:"Setup"}),e.jsxRuntimeExports.jsxs(e.RadioGroup,{disabled:_,id:"scale-option",value:d,onValueChange:b=>S(b),className:"col-span-2 flex gap-3",defaultValue:"x",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:"auto",id:"r1"}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r1",children:"Auto"})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:"custom",id:"r2"}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r2",children:"Custom"})]})]})]}),d==="custom"&&a=="linear"&&T(),O(),e.jsxRuntimeExports.jsx(e.SelectSeparator,{}),e.jsxRuntimeExports.jsx("div",{className:"grid grid-cols-3",children:e.jsxRuntimeExports.jsx(e.Button,{onClick:K,variant:"secondary",className:"col-span-1 col-start-3 h-8 w-full",children:"Apply"})})]})]})})]})}function ke(){var i,a,o;const s=e.useEditorStore(l=>l.card.cfg),n=e.useEditorStore(l=>l.actions.setCardCfg),t=e.useEditorStore(l=>l.card.type);function r(l){var u;const x={datalabels:{display:l!=="none",align:l,anchor:l,clamp:!0}},j={...s,options:{...s==null?void 0:s.options,plugins:{...(u=s==null?void 0:s.options)==null?void 0:u.plugins,...x}}};n(j),console.log(l)}return e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxRuntimeExports.jsx("label",{className:"font-medium",children:"Data Labels"}),!["pyramid","range"].includes(t)&&e.jsxRuntimeExports.jsx(Ye,{})]}),e.jsxRuntimeExports.jsxs(e.Select,{value:(o=(a=(i=s==null?void 0:s.options)==null?void 0:i.plugins)==null?void 0:a.datalabels)==null?void 0:o.anchor,onValueChange:r,defaultValue:"none",children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:"h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsxRuntimeExports.jsx(e.SelectValue,{placeholder:"Select position"})}),e.jsxRuntimeExports.jsx(e.SelectContent,{children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[e.jsxRuntimeExports.jsx(e.SelectLabel,{children:"Data Labels"}),e.jsxRuntimeExports.jsx(e.SelectItem,{value:"none",children:"None"}),t!=="pyramid"&&e.jsxRuntimeExports.jsx(e.SelectItem,{value:"start",children:"Start"}),e.jsxRuntimeExports.jsx(e.SelectItem,{value:"center",children:"Center"}),t!=="pyramid"&&e.jsxRuntimeExports.jsx(e.SelectItem,{value:"end",children:"End"})]})})]})]})}function he(){const[s,n]=f.useState([]);e.useEditorStore(u=>u.card.cfg);const t=e.useEditorStore(u=>u.card.preferences),{setCardCfg:r,setFilterOnClickColumnIndex:i,setCardPreferences:a}=e.useEditorStore(u=>u.actions),o=e.useEditorStore(u=>u.queryResultColumns);e.useEditorStore(u=>{var d;return(d=u.card.preferences)==null?void 0:d.filterOnClickColumnIndex}),f.useEffect(()=>{o&&n(new Array(o.length).fill(!1))},[o]);function l(u,d){var S,c;d?t!=null&&t.onClickFilter&&((S=t==null?void 0:t.onClickFilter)==null?void 0:S.length)>0?a({...t,onClickFilter:[...t.onClickFilter,{columnIndex:u,expression:""}]}):a({...t,onClickFilter:[{columnIndex:u,expression:""}]}):(a({...t,onClickFilter:(c=t==null?void 0:t.onClickFilter)==null?void 0:c.filter(m=>m.columnIndex!==u)}),n(m=>{const h=[...m];return h[u]=!1,h}))}function x(u,d){var c;const S=(c=t==null?void 0:t.onClickFilter)==null?void 0:c.map(m=>m.columnIndex===u?{...m,expression:d.target.value}:m);a({...t,onClickFilter:S})}function j(u){var d,S,c,m;if(s!=null&&s[u]||(S=(d=t==null?void 0:t.onClickFilter)==null?void 0:d.find(h=>h.columnIndex===u))!=null&&S.expression)return e.jsxRuntimeExports.jsx(e.Input,{value:(m=(c=t==null?void 0:t.onClickFilter)==null?void 0:c.find(h=>h.columnIndex===u))==null?void 0:m.expression,onChange:h=>x(u,h),type:"text",className:" h-9 w-full focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0 font-mono text-xs",placeholder:"Expression"})}return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:o==null?void 0:o.map((u,d)=>{var S,c;return e.jsxRuntimeExports.jsx("div",{className:"flex items-center justify-between space-y-2 xbg-red-100 group",children:e.jsxRuntimeExports.jsxs("div",{className:" grow",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center py-2 space-x-2",children:[e.jsxRuntimeExports.jsx(e.Checkbox,{checked:!!((S=t==null?void 0:t.onClickFilter)!=null&&S.find(m=>m.columnIndex===d)),onCheckedChange:m=>l(d,m)}),e.jsxRuntimeExports.jsx("label",{className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:u}),e.jsxRuntimeExports.jsx("div",{className:"flex gap-2 items-center ",children:((c=t==null?void 0:t.onClickFilter)==null?void 0:c.find(m=>m.columnIndex===d))&&e.jsxRuntimeExports.jsx(Oe,{onClick:()=>{n(m=>{const h=[...m];return h[d]=!m[d],h})},className:" invisible group-hover:visible size-3 text-gray-400 cursor-pointer"})})]}),j(d)]})},u)})})}function it({cardType:s}){function n(t){const r="SELECT label, [group], x-axis, y-axis, radius FROM table",i="SELECT label, [group], x-axis, y-axis FROM table";return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx("div",{className:"bg-muted px-2 py-1 rounded text-xs",children:t==="bubble"?r:i}),e.jsxRuntimeExports.jsxs("ul",{className:" ml-6 list-disc [&>li]:mt-2 text-xs",children:[e.jsxRuntimeExports.jsx("li",{children:"label - category"}),e.jsxRuntimeExports.jsx("li",{children:"group - category"}),e.jsxRuntimeExports.jsx("li",{children:"x-axis - category"}),e.jsxRuntimeExports.jsx("li",{children:"y-axis - category"}),t==="bubble"&&e.jsxRuntimeExports.jsx("li",{children:"radius - number"})]}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:a=>a.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#pie-chart",children:"example"})," in the docs."]})]})}return e.jsxRuntimeExports.jsx("div",{className:"px-6 py-2 space-y-6",children:e.jsxRuntimeExports.jsxs(e.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:`${e.titleCase(s)} Chart`}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:" space-y-4 font-mono text-xs ",children:n(s)})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-2",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Settings"}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:"px-2",children:e.jsxRuntimeExports.jsx(ke,{})})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filter on click"}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:"px-2",children:e.jsxRuntimeExports.jsx(he,{})})]})]})})}function Xe(){var a,o,l;const s=e.useEditorStore(x=>x.card.preferences),n=e.useEditorStore(x=>x.card.cfg),{setCardCfg:t,setCardPreferences:r}=e.useEditorStore(x=>x.actions);(a=n==null?void 0:n.options)!=null&&a.indexAxis;function i(x){var d,S,c,m,h,C;let j={};(d=s==null?void 0:s.chartOptions)!=null&&d.scales&&(j={x:(c=(S=s==null?void 0:s.chartOptions)==null?void 0:S.scales)==null?void 0:c.y,y:(h=(m=s==null?void 0:s.chartOptions)==null?void 0:m.scales)==null?void 0:h.x});const u={...s,chartOptions:{...s==null?void 0:s.chartOptions,scales:{...(C=s==null?void 0:s.chartOptions)==null?void 0:C.scales,...j},indexAxis:x}};r(u)}return e.jsxRuntimeExports.jsxs(e.RadioGroup,{value:((o=s==null?void 0:s.chartOptions)==null?void 0:o.indexAxis)||((l=n==null?void 0:n.options)==null?void 0:l.indexAxis)||"x",onValueChange:i,className:"flex gap-3",defaultValue:"x",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:"x",id:"r1"}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r1",children:"Vertical"})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:"y",id:"r2"}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r2",children:"Horizontal"})]})]})}const at={datasets:[{type:"line",label:"Sum_sales",data:[]},{type:"bar",label:"Sum_profit",data:[]}]},lt={datasets:[{fill:"origin",type:"line",label:"Sum_sales",data:[]}]};function ct(){const s=e.useEditorStore(n=>n.card.type);return e.jsxRuntimeExports.jsxs("div",{className:"space-y-6 p-6",children:[e.jsxRuntimeExports.jsx(e.Accordion,{className:" ",type:"single",collapsible:!0,children:xt(s)}),e.jsxRuntimeExports.jsx("section",{className:"",children:["line","bar"].includes(s)&&e.jsxRuntimeExports.jsx(Xe,{})}),e.jsxRuntimeExports.jsx("div",{children:!["kpi"].includes(s)&&e.jsxRuntimeExports.jsx(ke,{})}),e.jsxRuntimeExports.jsx("div",{children:!["kpi"].includes(s)&&e.jsxRuntimeExports.jsx(he,{})})]})}function xt(s){if(["line","bar"].includes(s))return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"font-normal",children:e.jsxRuntimeExports.jsx("p",{children:"Chart Query"})}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:" ",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs font-semibold",children:"SELECT x-axis, y-axis-1, y-axis-2, y-axis-3,... FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"X-axis - Category (ex. city)"}),e.jsxRuntimeExports.jsx("li",{children:"Y-axis - Number (ex. population)"})]})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-2",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"font-normal",children:"Mixed Chart"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-2 text-xs",children:[e.jsxRuntimeExports.jsxs("p",{children:["Click ",e.jsxRuntimeExports.jsx("b",{children:"Customize"})," and change the `type` property in the dataset."]}),e.jsxRuntimeExports.jsx("pre",{children:JSON.stringify(at,null,2)})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"font-normal",children:"Area Chart"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-2 text-xs",children:[e.jsxRuntimeExports.jsxs("p",{children:["Click ",e.jsxRuntimeExports.jsx("b",{children:"Customize"})," and add `fill` property to the dataset. See",e.jsxRuntimeExports.jsx("a",{className:"mx-1 text-blue-500 hover:underline",href:"https://www.chartjs.org/docs/latest/samples/area/line-boundaries.html",target:"_blank",children:"docs"}),"for more options."]}),e.jsxRuntimeExports.jsx("pre",{children:JSON.stringify(lt,null,2)})]})]})]});if(s==="bubble")return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"font-normal",children:e.jsxRuntimeExports.jsxs("p",{children:["How to create a ",e.jsxRuntimeExports.jsx("span",{children:s})," chart query?"]})}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:" ",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs font-semibold",children:"SELECT label, x-axis, y-axis, radius FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"Label - Category (ex. city)"}),e.jsxRuntimeExports.jsx("li",{children:"Bubble Group (opt) - Category (ex. state)"}),e.jsxRuntimeExports.jsx("li",{children:"X-axis - Number (ex. avg. age)"}),e.jsxRuntimeExports.jsx("li",{children:"Y-axis - Number (ex. avg. weight)"}),e.jsxRuntimeExports.jsx("li",{children:"Radius - Number (ex. population)"})]})]})]})});if(s==="scatter")return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"font-normal",children:e.jsxRuntimeExports.jsxs("p",{children:["How to create a ",e.jsxRuntimeExports.jsx("span",{children:s})," chart query?"]})}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:" ",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs font-semibold",children:"SELECT label, x-axis, y-axis FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"Label - Category (ex. city)"}),e.jsxRuntimeExports.jsx("li",{children:"Group (opt) - Category (ex. state)"}),e.jsxRuntimeExports.jsx("li",{children:"X-axis - Number (ex. avg. age)"}),e.jsxRuntimeExports.jsx("li",{children:"Y-axis - Number (ex. avg. weight)"})]})]})]})});if(["pie","doughnut","polarArea"].includes(s))return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"font-normal",children:e.jsxRuntimeExports.jsxs("p",{children:[e.jsxRuntimeExports.jsx("span",{children:s==="polarArea"?"Polar":s.charAt(0).toUpperCase()+s.slice(1)})," ","chart query"]})}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:" ",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs font-semibold",children:"SELECT label, measure FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"Label - Category (ex. city)"}),e.jsxRuntimeExports.jsx("li",{children:"Measure - Number (ex. population)"})]})]})]})})}function ut(){var x,j,u,d,S;const s=e.useEditorStore(c=>c.card.preferences),n=e.useEditorStore(c=>c.actions.setCardPreferences),t=e.useEditorStore(c=>c.actions.setNumberFormat);e.useEditorStore(c=>{var m,h;return(h=(m=c.card.preferences)==null?void 0:m.formatNumber)==null?void 0:h.decimalPlaces});const r=e.useEditorStore(c=>{var m,h;return(h=(m=c.card.preferences)==null?void 0:m.formatNumber)==null?void 0:h.locale}),i=e.useEditorStore(c=>{var m,h;return(h=(m=c.card.preferences)==null?void 0:m.formatNumber)==null?void 0:h.currency});e.useEditorStore(c=>c.actions.setFilterOnClickField);const a=e.useEditorStore(c=>{var m,h;return(h=(m=c.card.preferences)==null?void 0:m.formatNumber)==null?void 0:h.colorRanges})||[],o=e.useEditorStore(c=>c.actions.setColorRanges),l=[...new Set(e.LOCALE_CURRENCY_PAIRS.map(c=>c.currency))];return e.jsxRuntimeExports.jsxs("div",{children:[e.jsxRuntimeExports.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Checkbox,{checked:!!((x=s==null?void 0:s.formatNumber)!=null&&x.enabled),onCheckedChange:c=>{n({...s,formatNumber:{...s==null?void 0:s.formatNumber,enabled:c}})}}),e.jsxRuntimeExports.jsx(e.Label,{children:"Format Number"})]}),((j=s==null?void 0:s.formatNumber)==null?void 0:j.enabled)===!0&&e.jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxRuntimeExports.jsx("div",{children:e.jsxRuntimeExports.jsxs("div",{className:"space-y-4 p-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"w-full space-y-1",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Locale"}),e.jsxRuntimeExports.jsxs(e.Select,{value:r||"en-US",onValueChange:c=>{var m,h,C;return t(((m=s==null?void 0:s.formatNumber)==null?void 0:m.decimalPlaces)||0,((h=s==null?void 0:s.formatNumber)==null?void 0:h.currency)||"",c||"en-US",((C=s==null?void 0:s.formatNumber)==null?void 0:C.suffix)||"")},children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:"col-span-6 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsxRuntimeExports.jsx(e.SelectValue,{})}),e.jsxRuntimeExports.jsx(e.SelectContent,{children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[e.jsxRuntimeExports.jsx(e.SelectLabel,{children:"Format"}),e.LOCALE_CURRENCY_PAIRS.map(c=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:c.locale,children:c.locale},c.locale))]})})]})]}),e.jsxRuntimeExports.jsxs("div",{className:"w-full space-y-1",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Currency"}),e.jsxRuntimeExports.jsxs(e.Select,{value:i||"none",onValueChange:c=>{var m,h,C;return t(((m=s==null?void 0:s.formatNumber)==null?void 0:m.decimalPlaces)||0,c==="none"?"":c,((h=s==null?void 0:s.formatNumber)==null?void 0:h.locale)||"",((C=s==null?void 0:s.formatNumber)==null?void 0:C.suffix)||"")},children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:"col-span-6 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsxRuntimeExports.jsx(e.SelectValue,{})}),e.jsxRuntimeExports.jsx(e.SelectContent,{children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[e.jsxRuntimeExports.jsx(e.SelectLabel,{children:"Currency"}),e.jsxRuntimeExports.jsx(e.SelectItem,{value:"none",children:"None"},"none"),l.map(c=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:c,children:c},c))]})})]})]})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex gap-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"w-full space-y-1",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Decimals"}),e.jsxRuntimeExports.jsxs(e.Select,{value:((d=(u=s==null?void 0:s.formatNumber)==null?void 0:u.decimalPlaces)==null?void 0:d.toString())||"0",onValueChange:c=>{var m,h,C;return t(Number(c),((m=s==null?void 0:s.formatNumber)==null?void 0:m.currency)||"",((h=s==null?void 0:s.formatNumber)==null?void 0:h.locale)||"",((C=s==null?void 0:s.formatNumber)==null?void 0:C.suffix)||"")},children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:"col-span-3 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsxRuntimeExports.jsx(e.SelectValue,{})}),e.jsxRuntimeExports.jsx(e.SelectContent,{children:["0","1","2","3","4"].map(c=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:c,children:c},c))})]})]}),e.jsxRuntimeExports.jsxs("div",{className:"w-full space-y-1",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Suffix"}),e.jsxRuntimeExports.jsx(e.Input,{value:((S=s==null?void 0:s.formatNumber)==null?void 0:S.suffix)||"",className:"h-8 font-mono text-xs focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",placeholder:"K, M, B, %",onChange:c=>{var m,h,C;return t(((m=s==null?void 0:s.formatNumber)==null?void 0:m.decimalPlaces)||0,((h=s==null?void 0:s.formatNumber)==null?void 0:h.currency)||"",((C=s==null?void 0:s.formatNumber)==null?void 0:C.locale)||"",c.target.value)}})]})]})]})}),e.jsxRuntimeExports.jsx(e.Separator,{className:"my-3"}),e.jsxRuntimeExports.jsx(e.ColorFormat,{colorRanges:a,setColorRanges:o})]})]})}function dt(){return e.jsxRuntimeExports.jsxs("div",{className:"space-y-6 px-6 py-2",children:[e.jsxRuntimeExports.jsx(e.Accordion,{type:"single",collapsible:!0,children:e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"",children:"KPI Query"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"font-mono",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs",children:"SELECT current, previous FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"current - number"}),e.jsxRuntimeExports.jsx("li",{children:"previous - number"})]}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:s=>s.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#kpi",children:"example"})," in the docs."]})]})]})}),e.jsxRuntimeExports.jsx("section",{className:"",children:e.jsxRuntimeExports.jsx(ut,{})}),e.jsxRuntimeExports.jsx("div",{}),e.jsxRuntimeExports.jsx("div",{})]})}function ye({cardType:s,docContent:n}){return e.jsxRuntimeExports.jsx("div",{className:"space-y-6 px-6 py-2",children:e.jsxRuntimeExports.jsxs(e.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:`${e.titleCase(s)} Chart`}),e.jsxRuntimeExports.jsx(e.AccordionContent,{children:n||e.jsxRuntimeExports.jsxs("div",{className:"space-y-4 font-mono text-xs",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT label, measure FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"label - category"}),e.jsxRuntimeExports.jsx("li",{children:"measure - number"})]}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:t=>t.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#pie-chart",children:"example"})," in the docs."]})]})})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-2",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Settings"}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:"px-2",children:e.jsxRuntimeExports.jsx(ke,{})})]}),s!=="range"&&e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filter on click"}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:"px-2",children:e.jsxRuntimeExports.jsx(he,{})})]})]})})}function mt({idx:s}){var l;const n=e.useEditorStore(x=>{var j;return(j=x.card)==null?void 0:j.preferences}),t=e.useEditorStore(x=>{var j;return(j=x.card.preferences)==null?void 0:j.datasetOptions}),r=e.useEditorStore(x=>x.actions.setCardPreferences),i=(l=n==null?void 0:n.chartOptions)==null?void 0:l.indexAxis,a=t==null?void 0:t.find(x=>x.idx===s);function o(x,j){(x==="end"||x==="start")&&e.getContrastColor(e.getCanvasBackgroundColor());const u={display:x!=="none",align:x,anchor:x,clamp:!0};if(!a)r({...n,datasetOptions:[...t||[],{idx:j,datalabels:u}]});else{const d={...a};d.datalabels=u;const S=t==null?void 0:t.map(c=>c.idx===j?d:c);r({...n,datasetOptions:S})}}return e.jsxRuntimeExports.jsxs(e.Popover,{children:[e.jsxRuntimeExports.jsx(e.PopoverTrigger,{children:e.jsxRuntimeExports.jsx(ws,{className:"invisible size-4 rotate-[135deg] cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"})}),e.jsxRuntimeExports.jsx(e.PopoverContent,{className:"w-fit p-1",children:e.jsxRuntimeExports.jsxs("div",{className:"flex gap-1",children:[e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("none",s),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsxRuntimeExports.jsx(e.X,{className:"size-4"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("start",s),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsxRuntimeExports.jsx(Es,{className:e.cn("h-4 w-4",{"rotate-90":i==="y"})})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("center",s),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsxRuntimeExports.jsx(gs,{className:e.cn("h-4 w-4",{"rotate-90":i==="y"})})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("end",s),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsxRuntimeExports.jsx(fs,{className:e.cn("h-4 w-4",{"rotate-90":i==="y"})})})]})})]})}function pt(){const s=e.useEditorStore(x=>x.card),n=e.useEditorStore(x=>{var j,u,d;return(d=(u=(j=x==null?void 0:x.card)==null?void 0:j.preferences)==null?void 0:u.chartOptions)==null?void 0:d.indexAxis}),t=n==="y"?"Y axis":"X axis",r=n==="y"?"X axis":"Y axis",{keys:i,metricKeys:a,dimensionKeys:o}=e.getKeys(s.data||[]);let l=a;if(s.type==="stackedBar"){const x=e.pivotData({dataArray:s.data||[],groupKey:o[0],pivotKey:o[1],valueKey:l[0]}),{metricKeys:j}=e.getKeys(x);l=j}return i.length===0?null:e.jsxRuntimeExports.jsxs("div",{className:"space-y-4",children:[e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsx(e.Label,{children:t}),e.jsxRuntimeExports.jsx("div",{className:"my-1 space-y-1",children:e.jsxRuntimeExports.jsx("div",{className:"rounded-md bg-muted/70 px-2 py-1 hover:bg-muted",children:e.jsxRuntimeExports.jsx("p",{children:o[0]})})})]}),e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center justify-between gap-5",children:[e.jsxRuntimeExports.jsx(e.Label,{children:r}),e.jsxRuntimeExports.jsx(Ye,{})]}),e.jsxRuntimeExports.jsx("div",{className:"my-1 space-y-1",children:l.map((x,j)=>e.jsxRuntimeExports.jsx(ht,{col:x,idx:j},x))})]})]})}function ht({col:s,idx:n}){const t=e.useEditorStore(l=>{var x;return(x=l.card)==null?void 0:x.preferences}),r=e.useEditorStore(l=>{var x;return(x=l.card.preferences)==null?void 0:x.datasetOptions}),i=r==null?void 0:r.find(l=>l.idx===n),{setCardPreferences:a}=e.useEditorStore(l=>l.actions);function o(l){if(!i)a({...t,datasetOptions:[...r||[],{idx:n,type:l==="area"?"line":l,fill:l==="area"?"origin":""}]});else{const x={...i};x.type=l==="area"?"line":l,x.fill=l==="area"?"origin":"";const j=r==null?void 0:r.map(u=>u.idx===n?x:u);a({...t,datasetOptions:j})}}return e.jsxRuntimeExports.jsxs("div",{className:"group flex items-center justify-between gap-5 rounded-md bg-muted/70 px-2 py-1 hover:bg-muted",children:[e.jsxRuntimeExports.jsx("p",{children:s}),e.jsxRuntimeExports.jsxs("div",{className:"flex gap-2",children:[e.jsxRuntimeExports.jsx(ve,{onClick:()=>o("bar"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsxRuntimeExports.jsx(Ce,{onClick:()=>o("line"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsxRuntimeExports.jsx(cs,{onClick:()=>o("area"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsxRuntimeExports.jsx(e.Separator,{orientation:"vertical",className:"invisible size-4 cursor-pointer py-2 text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsxRuntimeExports.jsx(mt,{idx:n})]})]})}function jt(){return e.jsxRuntimeExports.jsx("div",{className:"space-y-6 px-6 py-2",children:e.jsxRuntimeExports.jsxs(e.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Stacked Chart"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 font-mono text-xs",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT x-axis, stack-by, y-axis FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"x-axis - category"}),e.jsxRuntimeExports.jsx("li",{children:"stack by - category"}),e.jsxRuntimeExports.jsx("li",{children:"y-axis - number"})]}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:s=>s.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#stacked-chart",children:"example"})," in the docs."]})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-2",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Settings"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 px-2",children:[e.jsxRuntimeExports.jsx(Xe,{}),e.jsxRuntimeExports.jsx(pt,{})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filter on click"}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:"px-2",children:e.jsxRuntimeExports.jsx(he,{})})]})]})})}function Et({}){const s=e.useEditorStore(r=>{var i;return(i=r.card)==null?void 0:i.preferences}),n=e.useEditorStore(r=>r.actions.setCardPreferences),t=r=>{n({...s,allowDownload:r})};return e.jsxRuntimeExports.jsxs("div",{className:"space-y-6 px-6 py-2",children:[e.jsxRuntimeExports.jsx(e.Accordion,{defaultValue:["item-3"],type:"multiple",children:e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filter on click"}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:"px-2",children:e.jsxRuntimeExports.jsx(he,{})})]})}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.Checkbox,{onCheckedChange:t,id:"allow-download"}),e.jsxRuntimeExports.jsx("label",{htmlFor:"allow-download",className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:"Allow Download"})]})]})}const ft=e.jsxRuntimeExports.jsxs("div",{className:"space-y-4 font-mono text-xs",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT dimension, cohort, metric FROM table"}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:s=>s.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#pyramid-chart",children:"example"})," in the docs."]})]}),gt=e.jsxRuntimeExports.jsxs("div",{className:"space-y-4 font-mono text-xs",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT y-axis, label, range-from, range-to, range-value FROM table"}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:s=>s.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#range-charts",children:"example"})," in the docs."]})]});function Rt(){const s=e.useEditorStore(t=>t.card.type);function n(t){switch(t){case"stackedBar":return e.jsxRuntimeExports.jsx(jt,{});case"pyramid":return e.jsxRuntimeExports.jsx(ye,{docContent:ft,cardType:t});case"kpi":return e.jsxRuntimeExports.jsx(dt,{});case"line":case"bar":case"range":return e.jsxRuntimeExports.jsx(ye,{docContent:gt,cardType:t});case"pie":case"doughnut":case"polarArea":case"radar":return e.jsxRuntimeExports.jsx(ye,{cardType:t});case"bubble":case"scatter":return e.jsxRuntimeExports.jsx(it,{cardType:t});case"table":return e.jsxRuntimeExports.jsx(Et,{cardType:t});default:return e.jsxRuntimeExports.jsx(ct,{})}}return e.jsxRuntimeExports.jsx(e.ScrollArea,{className:"h-full w-full text-sm",children:n(s)})}function bt(){const s=e.useEditorStore(n=>n.isShowingVisual);return e.jsxRuntimeExports.jsxs(e.ResizablePanelGroup,{direction:"vertical",className:"min-w-full max-w-lg min-h-[250px]",children:[e.jsxRuntimeExports.jsx(e.ResizablePanel,{role:"query-section",className:"flex",minSize:20,defaultSize:40,children:e.jsxRuntimeExports.jsx(Xs,{})}),e.jsxRuntimeExports.jsx(e.ResizableHandle,{withHandle:!0,className:"border "}),e.jsxRuntimeExports.jsx(e.ResizablePanel,{className:"pb-1",role:"visual-section",minSize:0,defaultSize:60,children:s?e.jsxRuntimeExports.jsxs(e.ResizablePanelGroup,{direction:"horizontal",children:[e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsx(e.ResizablePanel,{className:"flex min-w-[275px]",minSize:20,defaultSize:25,maxSize:30,children:e.jsxRuntimeExports.jsx(Rt,{})})}),e.jsxRuntimeExports.jsx(e.ResizableHandle,{className:"border "}),e.jsxRuntimeExports.jsx(e.ResizablePanel,{minSize:40,defaultSize:75,maxSize:100,children:e.jsxRuntimeExports.jsx(De,{})})]}):e.jsxRuntimeExports.jsx(De,{})})]})}function St({authToken:s,onSave:n,onClose:t}){const r=e.useEditorStore(o=>o.actions.setOnSave),i=e.useEditorStore(o=>o.actions.setOnClose),a=e.useDashboardStore(o=>o.actions.setAuthToken);return f.useEffect(()=>{n&&r(n),t&&i(t)},[n,r,t,i]),f.useEffect(()=>{s&&s.accessToken&&a(s)},[s,a]),e.jsxRuntimeExports.jsxs(e.EditorPanel,{className:"rounded-none",role:"editor-panel",children:[e.jsxRuntimeExports.jsx(e.EditorAside,{className:"rounded-none border-r-[1.5px]",children:e.jsxRuntimeExports.jsx(Ve,{})}),e.jsxRuntimeExports.jsx(e.EditorMain,{children:e.jsxRuntimeExports.jsx(bt,{})})]})}function yt(){e.useDashboardStore(o=>o.selectedCardId);const s=e.useDashboardStore(o=>o.selectedSheetId),{setIsVisualEditing:n}=e.useDashboardStore(o=>o.actions),t=e.useDashboardStore(o=>o.isVisualEditing),r=e.useDashboardStore(o=>o.actions.updateFrame);function i(o){s&&(r(s,o),n(!1))}function a(){n(!1)}return e.jsxRuntimeExports.jsx("div",{role:"editor-container",className:e.cn("flex grow",{block:t,hidden:!t}),children:e.jsxRuntimeExports.jsx(St,{onSave:i,onClose:a})})}function vt({columns:s,tableName:n}){const t=e.useEditorStore(d=>d.selectedConnectionId),r=e.useEditorStore(d=>d.selectedDatabaseName),i=e.useEditorStore(d=>d.selectedSchemaName),a=e.useEditorStore(d=>d.selectedTableName),o=e.useDashboardStore(d=>d.dashboard.filters)||[],l=e.useDashboardStore(d=>d.actions.addFilter),x=e.useDashboardStore(d=>d.actions.removeFilter),j=e.useDashboardStore(d=>d.actions.removeFilterValue);function u(d){const S=e.fmt(d.column_name),c=e.fmt(r||""),m=e.fmt(i||""),h=e.fmt(n),C=e.getQualifiedTableName(m,h),g=`${C}.${S}`;console.log("find",g,h,c);const A=o==null?void 0:o.find(y=>y.column===g&&y.table===h&&(y.database===c||y.database===r));if(A)j(A.id),x(A.id);else{if(n==="api"&&t){l({id:e.v4(),column:g,title:d.column_name,dataType:d.data_type,table:"api",database:"",connectionId:t,operation:"in",sql:e.getDefaultFilterSql(d.data_type,C,S)});return}l({id:e.v4(),column:`${C}.${S}`,title:d.column_name,dataType:d.data_type,table:a||"",database:r||"",connectionId:t||"",operation:"in",sql:e.getDefaultFilterSql(d.data_type,C,S)})}}return e.jsxRuntimeExports.jsx("div",{className:"xbg-red-100 flex-1 basis-0 flex-col overflow-scroll px-3",children:s==null?void 0:s.map(d=>{const S=o==null?void 0:o.find(c=>c.column===e.fmt(d.column_name)&&c.table===a&&c.database===r);return e.jsxRuntimeExports.jsx("div",{onClick:()=>u(d),className:e.cn("group flex cursor-pointer items-center justify-between border border-dashed border-background px-3 py-[6px] text-sm transition-colors hover:bg-muted/50",{"bg-muted":S}),children:e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxRuntimeExports.jsx(qe,{column:d}),e.jsxRuntimeExports.jsx("span",{children:d.column_name})]})},d.column_name)})})}function Ct(){e.useDashboardStore(n=>n.showFilters);const s=e.useDashboardStore(n=>n.actions.setShowFilters);return e.jsxRuntimeExports.jsxs("section",{className:"relative flex grow flex-col border-l px-4",children:[e.jsxRuntimeExports.jsxs("div",{className:"mt-4 flex items-center justify-between gap-2 px-3",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"text-lg",children:"Filters"}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>s(!1),className:"h-7 w-7 p-0",variant:"ghost",children:e.jsxRuntimeExports.jsx(e.Cross2Icon,{})})]}),e.jsxRuntimeExports.jsx("div",{className:"flex grow",children:e.jsxRuntimeExports.jsx(Ve,{ColumnsComponent:(n,t,r)=>e.jsxRuntimeExports.jsx(vt,{schemaName:n,tableName:t,columns:r})})})]})}function Nt(){e.useDashboardStore(t=>t.dashboard);const s=e.useDashboardStore(t=>t.showFilters),n=e.useDashboardStore(t=>t.isVisualEditing);return e.useDashboardStore(t=>t.bookmarkKey),e.jsxRuntimeExports.jsxs("div",{role:"dashboard-plus-main",className:e.cn("grow",{hidden:n,flex:!n}),children:[e.jsxRuntimeExports.jsx(e.DashboardTabs,{}),s&&e.jsxRuntimeExports.jsx("div",{role:"filter-aside-container",className:"flex",children:e.jsxRuntimeExports.jsx(Ct,{})})]})}function kt(){const s=e.useDashboardStore(r=>r.dashboard),n=e.useDashboardStore(r=>r.actions.setDashboard),t=e.useDashboardStore(r=>r.showDashboardJSON);return e.useDashboardStore(r=>r.actions.setShowDashboardJSON),e.jsxRuntimeExports.jsx("div",{className:e.cn(" p-2",{hidden:!t}),children:e.jsxRuntimeExports.jsx(e.de,{onChange:r=>{if(r)try{JSON.parse(r),n(JSON.parse(r))}catch{}},defaultLanguage:"json",className:"h-[550px] overflow-y-auto ",value:JSON.stringify(s,null,2),options:{minimap:{enabled:!1},glyphMargin:!1,wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:12,renderLineHighlight:"none"}})})}function wt({showControls:s=!1,showFooter:n=!0,...t}){return e.jsxRuntimeExports.jsxs(e.SemaphorContextProvider,{dashboardProps:t,children:[e.jsxRuntimeExports.jsx(e.Te,{}),e.jsxRuntimeExports.jsxs(e.UXProvider,{children:[e.jsxRuntimeExports.jsx(kt,{}),e.jsxRuntimeExports.jsxs(e.DashboardPanel,{...t,children:[s&&e.jsxRuntimeExports.jsx(Fs,{}),e.jsxRuntimeExports.jsx(yt,{}),e.jsxRuntimeExports.jsx(Nt,{})]})]})]})}exports.DashboardPlus=wt;exports.SelectComponent=pe;exports.useEditorAside=Ne;
@@ -85,7 +85,7 @@ __p += '`),Rt&&(we+=`' +
85
85
  function print() { __p += __j.call(arguments, '') }
86
86
  `:`;
87
87
  `)+we+`return __p
88
- }`;var pt=vC(function(){return Mt(z,Be+"return "+we).apply(n,W)});if(pt.source=we,Pv(pt))throw pt;return pt}function L4(d){return Lt(d).toLowerCase()}function F4(d){return Lt(d).toUpperCase()}function z4(d,h,y){if(d=Lt(d),d&&(y||h===n))return R_(d);if(!d||!(h=Ir(h)))return d;var C=Eo(d),M=Eo(h),z=P_(C,M),W=O_(C,M)+1;return ns(C,z,W).join("")}function j4(d,h,y){if(d=Lt(d),d&&(y||h===n))return d.slice(0,D_(d)+1);if(!d||!(h=Ir(h)))return d;var C=Eo(d),M=O_(C,Eo(h))+1;return ns(C,0,M).join("")}function B4(d,h,y){if(d=Lt(d),d&&(y||h===n))return d.replace(Ks,"");if(!d||!(h=Ir(h)))return d;var C=Eo(d),M=P_(C,Eo(h));return ns(C,M).join("")}function V4(d,h){var y=I,C=F;if(pn(h)){var M="separator"in h?h.separator:M;y="length"in h?ut(h.length):y,C="omission"in h?Ir(h.omission):C}d=Lt(d);var z=d.length;if(fl(d)){var W=Eo(d);z=W.length}if(y>=z)return d;var Y=y-hl(C);if(Y<1)return C;var re=W?ns(W,0,Y).join(""):d.slice(0,Y);if(M===n)return re+C;if(W&&(Y+=re.length-Y),Ov(M)){if(d.slice(Y).search(M)){var ve,ye=re;for(M.global||(M=Wm(M.source,Lt(He.exec(M))+"g")),M.lastIndex=0;ve=M.exec(ye);)var we=ve.index;re=re.slice(0,we===n?Y:we)}}else if(d.indexOf(Ir(M),Y)!=Y){var Ae=re.lastIndexOf(M);Ae>-1&&(re=re.slice(0,Ae))}return re+C}function H4(d){return d=Lt(d),d&&hr.test(d)?d.replace(Wt,bN):d}var W4=xl(function(d,h,y){return d+(y?" ":"")+h.toUpperCase()}),Tv=bS("toUpperCase");function mC(d,h,y){return d=Lt(d),h=y?n:h,h===n?hN(d)?wN(d):oN(d):d.match(h)||[]}var vC=vt(function(d,h){try{return Mr(d,n,h)}catch(y){return Pv(y)?y:new ot(y)}}),U4=bi(function(d,h){return so(h,function(y){y=Vo(y),mi(d,y,Ev(d[y],d))}),d});function q4(d){var h=d==null?0:d.length,y=Ye();return d=h?fn(d,function(C){if(typeof C[1]!="function")throw new ao(s);return[y(C[0]),C[1]]}):[],vt(function(C){for(var M=-1;++M<h;){var z=d[M];if(Mr(z[0],this,C))return Mr(z[1],this,C)}})}function G4(d){return b3(co(d,f))}function kv(d){return function(){return d}}function Y4(d,h){return d==null||d!==d?h:d}var K4=xS(),X4=xS(!0);function vr(d){return d}function Mv(d){return X_(typeof d=="function"?d:co(d,f))}function Q4(d){return J_(co(d,f))}function J4(d,h){return Z_(d,co(h,f))}var Z4=vt(function(d,h){return function(y){return Jc(y,d,h)}}),e6=vt(function(d,h){return function(y){return Jc(d,y,h)}});function Av(d,h,y){var C=Nn(h),M=Uf(h,C);y==null&&!(pn(h)&&(M.length||!C.length))&&(y=h,h=d,d=this,M=Uf(h,Nn(h)));var z=!(pn(y)&&"chain"in y)||!!y.chain,W=xi(d);return so(M,function(Y){var re=h[Y];d[Y]=re,W&&(d.prototype[Y]=function(){var ve=this.__chain__;if(z||ve){var ye=d(this.__wrapped__),we=ye.__actions__=pr(this.__actions__);return we.push({func:re,args:arguments,thisArg:d}),ye.__chain__=ve,ye}return re.apply(d,Xi([this.value()],arguments))})}),d}function t6(){return Vn._===this&&(Vn._=PN),this}function Iv(){}function n6(d){return d=ut(d),vt(function(h){return eS(h,d)})}var r6=fv(fn),o6=fv(w_),i6=fv(Lm);function bC(d){return yv(d)?Fm(Vo(d)):I3(d)}function s6(d){return function(h){return d==null?n:na(d,h)}}var a6=_S(),l6=_S(!0);function Nv(){return[]}function Lv(){return!1}function c6(){return{}}function u6(){return""}function d6(){return!0}function f6(d,h){if(d=ut(d),d<1||d>q)return[];var y=V,C=Kn(d,V);h=Ye(h),d-=V;for(var M=Bm(C,h);++y<d;)h(y);return M}function h6(d){return st(d)?fn(d,Vo):Nr(d)?[d]:pr(FS(Lt(d)))}function p6(d){var h=++EN;return Lt(d)+h}var g6=Qf(function(d,h){return d+h},0),m6=hv("ceil"),v6=Qf(function(d,h){return d/h},1),b6=hv("floor");function y6(d){return d&&d.length?Wf(d,vr,Jm):n}function x6(d,h){return d&&d.length?Wf(d,Ye(h,2),Jm):n}function w6(d){return C_(d,vr)}function _6(d,h){return C_(d,Ye(h,2))}function S6(d){return d&&d.length?Wf(d,vr,nv):n}function C6(d,h){return d&&d.length?Wf(d,Ye(h,2),nv):n}var E6=Qf(function(d,h){return d*h},1),R6=hv("round"),P6=Qf(function(d,h){return d-h},0);function O6(d){return d&&d.length?jm(d,vr):0}function $6(d,h){return d&&d.length?jm(d,Ye(h,2)):0}return L.after=QL,L.ary=KS,L.assign=FF,L.assignIn=cC,L.assignInWith=uh,L.assignWith=zF,L.at=jF,L.before=XS,L.bind=Ev,L.bindAll=U4,L.bindKey=QS,L.castArray=cF,L.chain=qS,L.chunk=b7,L.compact=y7,L.concat=x7,L.cond=q4,L.conforms=G4,L.constant=kv,L.countBy=OL,L.create=BF,L.curry=JS,L.curryRight=ZS,L.debounce=eC,L.defaults=VF,L.defaultsDeep=HF,L.defer=JL,L.delay=ZL,L.difference=w7,L.differenceBy=_7,L.differenceWith=S7,L.drop=C7,L.dropRight=E7,L.dropRightWhile=R7,L.dropWhile=P7,L.fill=O7,L.filter=DL,L.flatMap=ML,L.flatMapDeep=AL,L.flatMapDepth=IL,L.flatten=VS,L.flattenDeep=$7,L.flattenDepth=D7,L.flip=eF,L.flow=K4,L.flowRight=X4,L.fromPairs=T7,L.functions=XF,L.functionsIn=QF,L.groupBy=NL,L.initial=M7,L.intersection=A7,L.intersectionBy=I7,L.intersectionWith=N7,L.invert=ZF,L.invertBy=e4,L.invokeMap=FL,L.iteratee=Mv,L.keyBy=zL,L.keys=Nn,L.keysIn=mr,L.map=oh,L.mapKeys=n4,L.mapValues=r4,L.matches=Q4,L.matchesProperty=J4,L.memoize=sh,L.merge=o4,L.mergeWith=uC,L.method=Z4,L.methodOf=e6,L.mixin=Av,L.negate=ah,L.nthArg=n6,L.omit=i4,L.omitBy=s4,L.once=tF,L.orderBy=jL,L.over=r6,L.overArgs=nF,L.overEvery=o6,L.overSome=i6,L.partial=Rv,L.partialRight=tC,L.partition=BL,L.pick=a4,L.pickBy=dC,L.property=bC,L.propertyOf=s6,L.pull=j7,L.pullAll=WS,L.pullAllBy=B7,L.pullAllWith=V7,L.pullAt=H7,L.range=a6,L.rangeRight=l6,L.rearg=rF,L.reject=WL,L.remove=W7,L.rest=oF,L.reverse=Sv,L.sampleSize=qL,L.set=c4,L.setWith=u4,L.shuffle=GL,L.slice=U7,L.sortBy=XL,L.sortedUniq=J7,L.sortedUniqBy=Z7,L.split=M4,L.spread=iF,L.tail=eL,L.take=tL,L.takeRight=nL,L.takeRightWhile=rL,L.takeWhile=oL,L.tap=yL,L.throttle=sF,L.thru=rh,L.toArray=sC,L.toPairs=fC,L.toPairsIn=hC,L.toPath=h6,L.toPlainObject=lC,L.transform=d4,L.unary=aF,L.union=iL,L.unionBy=sL,L.unionWith=aL,L.uniq=lL,L.uniqBy=cL,L.uniqWith=uL,L.unset=f4,L.unzip=Cv,L.unzipWith=US,L.update=h4,L.updateWith=p4,L.values=Sl,L.valuesIn=g4,L.without=dL,L.words=mC,L.wrap=lF,L.xor=fL,L.xorBy=hL,L.xorWith=pL,L.zip=gL,L.zipObject=mL,L.zipObjectDeep=vL,L.zipWith=bL,L.entries=fC,L.entriesIn=hC,L.extend=cC,L.extendWith=uh,Av(L,L),L.add=g6,L.attempt=vC,L.camelCase=y4,L.capitalize=pC,L.ceil=m6,L.clamp=m4,L.clone=uF,L.cloneDeep=fF,L.cloneDeepWith=hF,L.cloneWith=dF,L.conformsTo=pF,L.deburr=gC,L.defaultTo=Y4,L.divide=v6,L.endsWith=x4,L.eq=Po,L.escape=w4,L.escapeRegExp=_4,L.every=$L,L.find=TL,L.findIndex=jS,L.findKey=WF,L.findLast=kL,L.findLastIndex=BS,L.findLastKey=UF,L.floor=b6,L.forEach=GS,L.forEachRight=YS,L.forIn=qF,L.forInRight=GF,L.forOwn=YF,L.forOwnRight=KF,L.get=$v,L.gt=gF,L.gte=mF,L.has=JF,L.hasIn=Dv,L.head=HS,L.identity=vr,L.includes=LL,L.indexOf=k7,L.inRange=v4,L.invoke=t4,L.isArguments=ia,L.isArray=st,L.isArrayBuffer=vF,L.isArrayLike=gr,L.isArrayLikeObject=xn,L.isBoolean=bF,L.isBuffer=rs,L.isDate=yF,L.isElement=xF,L.isEmpty=wF,L.isEqual=_F,L.isEqualWith=SF,L.isError=Pv,L.isFinite=CF,L.isFunction=xi,L.isInteger=nC,L.isLength=lh,L.isMap=rC,L.isMatch=EF,L.isMatchWith=RF,L.isNaN=PF,L.isNative=OF,L.isNil=DF,L.isNull=$F,L.isNumber=oC,L.isObject=pn,L.isObjectLike=mn,L.isPlainObject=ou,L.isRegExp=Ov,L.isSafeInteger=TF,L.isSet=iC,L.isString=ch,L.isSymbol=Nr,L.isTypedArray=_l,L.isUndefined=kF,L.isWeakMap=MF,L.isWeakSet=AF,L.join=L7,L.kebabCase=S4,L.last=fo,L.lastIndexOf=F7,L.lowerCase=C4,L.lowerFirst=E4,L.lt=IF,L.lte=NF,L.max=y6,L.maxBy=x6,L.mean=w6,L.meanBy=_6,L.min=S6,L.minBy=C6,L.stubArray=Nv,L.stubFalse=Lv,L.stubObject=c6,L.stubString=u6,L.stubTrue=d6,L.multiply=E6,L.nth=z7,L.noConflict=t6,L.noop=Iv,L.now=ih,L.pad=R4,L.padEnd=P4,L.padStart=O4,L.parseInt=$4,L.random=b4,L.reduce=VL,L.reduceRight=HL,L.repeat=D4,L.replace=T4,L.result=l4,L.round=R6,L.runInContext=te,L.sample=UL,L.size=YL,L.snakeCase=k4,L.some=KL,L.sortedIndex=q7,L.sortedIndexBy=G7,L.sortedIndexOf=Y7,L.sortedLastIndex=K7,L.sortedLastIndexBy=X7,L.sortedLastIndexOf=Q7,L.startCase=A4,L.startsWith=I4,L.subtract=P6,L.sum=O6,L.sumBy=$6,L.template=N4,L.times=f6,L.toFinite=wi,L.toInteger=ut,L.toLength=aC,L.toLower=L4,L.toNumber=ho,L.toSafeInteger=LF,L.toString=Lt,L.toUpper=F4,L.trim=z4,L.trimEnd=j4,L.trimStart=B4,L.truncate=V4,L.unescape=H4,L.uniqueId=p6,L.upperCase=W4,L.upperFirst=Tv,L.each=GS,L.eachRight=YS,L.first=HS,Av(L,function(){var d={};return jo(L,function(h,y){Bt.call(L.prototype,y)||(d[y]=h)}),d}(),{chain:!1}),L.VERSION=r,so(["bind","bindKey","curry","curryRight","partial","partialRight"],function(d){L[d].placeholder=L}),so(["drop","take"],function(d,h){Ct.prototype[d]=function(y){y=y===n?1:Dn(ut(y),0);var C=this.__filtered__&&!h?new Ct(this):this.clone();return C.__filtered__?C.__takeCount__=Kn(y,C.__takeCount__):C.__views__.push({size:Kn(y,V),type:d+(C.__dir__<0?"Right":"")}),C},Ct.prototype[d+"Right"]=function(y){return this.reverse()[d](y).reverse()}}),so(["filter","map","takeWhile"],function(d,h){var y=h+1,C=y==U||y==X;Ct.prototype[d]=function(M){var z=this.clone();return z.__iteratees__.push({iteratee:Ye(M,3),type:y}),z.__filtered__=z.__filtered__||C,z}}),so(["head","last"],function(d,h){var y="take"+(h?"Right":"");Ct.prototype[d]=function(){return this[y](1).value()[0]}}),so(["initial","tail"],function(d,h){var y="drop"+(h?"":"Right");Ct.prototype[d]=function(){return this.__filtered__?new Ct(this):this[y](1)}}),Ct.prototype.compact=function(){return this.filter(vr)},Ct.prototype.find=function(d){return this.filter(d).head()},Ct.prototype.findLast=function(d){return this.reverse().find(d)},Ct.prototype.invokeMap=vt(function(d,h){return typeof d=="function"?new Ct(this):this.map(function(y){return Jc(y,d,h)})}),Ct.prototype.reject=function(d){return this.filter(ah(Ye(d)))},Ct.prototype.slice=function(d,h){d=ut(d);var y=this;return y.__filtered__&&(d>0||h<0)?new Ct(y):(d<0?y=y.takeRight(-d):d&&(y=y.drop(d)),h!==n&&(h=ut(h),y=h<0?y.dropRight(-h):y.take(h-d)),y)},Ct.prototype.takeRightWhile=function(d){return this.reverse().takeWhile(d).reverse()},Ct.prototype.toArray=function(){return this.take(V)},jo(Ct.prototype,function(d,h){var y=/^(?:filter|find|map|reject)|While$/.test(h),C=/^(?:head|last)$/.test(h),M=L[C?"take"+(h=="last"?"Right":""):h],z=C||/^find/.test(h);M&&(L.prototype[h]=function(){var W=this.__wrapped__,Y=C?[1]:arguments,re=W instanceof Ct,ve=Y[0],ye=re||st(W),we=function(_t){var Rt=M.apply(L,Xi([_t],Y));return C&&Ae?Rt[0]:Rt};ye&&y&&typeof ve=="function"&&ve.length!=1&&(re=ye=!1);var Ae=this.__chain__,Be=!!this.__actions__.length,Ke=z&&!Ae,pt=re&&!Be;if(!z&&ye){W=pt?W:new Ct(this);var Xe=d.apply(W,Y);return Xe.__actions__.push({func:rh,args:[we],thisArg:n}),new lo(Xe,Ae)}return Ke&&pt?d.apply(this,Y):(Xe=this.thru(we),Ke?C?Xe.value()[0]:Xe.value():Xe)})}),so(["pop","push","shift","sort","splice","unshift"],function(d){var h=$f[d],y=/^(?:push|sort|unshift)$/.test(d)?"tap":"thru",C=/^(?:pop|shift)$/.test(d);L.prototype[d]=function(){var M=arguments;if(C&&!this.__chain__){var z=this.value();return h.apply(st(z)?z:[],M)}return this[y](function(W){return h.apply(st(W)?W:[],M)})}}),jo(Ct.prototype,function(d,h){var y=L[h];if(y){var C=y.name+"";Bt.call(vl,C)||(vl[C]=[]),vl[C].push({name:h,func:y})}}),vl[Xf(n,w).name]=[{name:"wrapper",func:n}],Ct.prototype.clone=HN,Ct.prototype.reverse=WN,Ct.prototype.value=UN,L.prototype.at=xL,L.prototype.chain=wL,L.prototype.commit=_L,L.prototype.next=SL,L.prototype.plant=EL,L.prototype.reverse=RL,L.prototype.toJSON=L.prototype.valueOf=L.prototype.value=PL,L.prototype.first=L.prototype.head,Uc&&(L.prototype[Uc]=CL),L},pl=_N();Qs?((Qs.exports=pl)._=pl,Mm._=pl):Vn._=pl}).call(ms)})(Mp,Mp.exports);var Fl=Mp.exports;const Fi=Oc(Fl);function FC({id:e,layouts:t,initialHeight:n,y:r,x:o,w:i,minH:s}){const a={i:e,x:o??0,y:r??1/0,w:i||20,h:n||35,minW:6,minH:s||10};t||(t={}),PO.forEach(l=>{t!=null&&t[l]||(t={...t,[l]:[]}),t[l].push(a)})}function zC(e,t){t&&PO.forEach(n=>{t!=null&&t[n]&&(t[n]=t[n].filter(r=>r.i!==e))})}const De=gO()(_O((e,t)=>({isSessionExpired:!1,currentBreakpoint:"lg",dashboard:{id:"",style:P0},showContext:!1,selectedSheetId:null,selectedCardId:null,selectedFrameId:null,selectedCard:null,showFilters:!1,isDashboardEditing:!0,isVisualEditing:!1,showDashboardJSON:!1,filteringCards:[],actions:{setGlobalStyle:n=>{e(r=>{r.dashboard.globalStyle=n})},setAIScopeTables:n=>{e(r=>{r.dashboard.aiScopeTables=n})},setIsSessionExpired:n=>{e(()=>({isSessionExpired:n}))},setCardPython:(n,r)=>{e(o=>{var s,a;const i=(a=(s=o.dashboard)==null?void 0:s.sheets)==null?void 0:a.find(l=>l.id===o.selectedSheetId);i&&Fl.forEach(i.frames,l=>{var u;const c=(u=l.cards)==null?void 0:u.find(f=>f.id===n);c&&(c.python=r)})})},addBaseQuery:n=>{e(r=>{var o;r.dashboard.baseQueries||(r.dashboard.baseQueries=[]),(o=r.dashboard.baseQueries)==null||o.push(n)})},removeBaseQuery:n=>{e(r=>{var i,s;const o=(i=r.dashboard.baseQueries)==null?void 0:i.findIndex(a=>a.id===n);o!=null&&o>-1&&((s=r.dashboard.baseQueries)==null||s.splice(o,1))})},setBaseQueries:n=>{e(r=>{r.dashboard.baseQueries=n})},setCurrentBreakpoint:n=>{e(()=>({currentBreakpoint:n}))},addFilteringCard:n=>{e(r=>{var o;(o=r.filteringCards)==null||o.push(n)})},removeFilteringCard:n=>{e(r=>{var i,s;const o=(i=r.filteringCards)==null?void 0:i.findIndex(a=>a.id===n.id);o!==void 0&&o>-1&&((s=r.filteringCards)==null||s.splice(o,1))})},setCustomCards:n=>{e(r=>{r.dashboard.customCards=n})},setAuthToken:n=>{e(()=>({authToken:n}))},setThemeStyle:n=>{e(()=>({themeStyle:n}))},setDashboard:n=>e({dashboard:n}),setBookmarkKey:n=>{e(()=>({bookmarkKey:n}))},setDashboardTheme:n=>{e(r=>{r.theme=n})},setSheets:n=>{e(r=>{r.dashboard&&(r.dashboard.sheets=n)})},setCardTitle:(n,r,o)=>{e(i=>{var a,l;const s=(l=(a=i.dashboard)==null?void 0:a.sheets)==null?void 0:l.find(c=>c.id===n);s&&Fl.forEach(s.frames,c=>{var f;const u=(f=c.cards)==null?void 0:f.find(p=>p.id===r);u&&(u.title=o)})})},setCardInfo:(n,r)=>{e(o=>{var s,a;const i=(a=(s=o.dashboard)==null?void 0:s.sheets)==null?void 0:a.find(l=>l.id===o.selectedSheetId);i&&Fl.forEach(i.frames,l=>{var u;const c=(u=l.cards)==null?void 0:u.find(f=>f.id===n);c&&(c.info=r)})})},setCardDescription:(n,r,o)=>{e(i=>{var a,l;const s=(l=(a=i.dashboard)==null?void 0:a.sheets)==null?void 0:l.find(c=>c.id===n);s&&Fl.forEach(s.frames,c=>{var f;const u=(f=c.cards)==null?void 0:f.find(p=>p.id===r);u&&(u.description=o)})})},setCardSql:(n,r,o)=>{e(i=>{var a,l,c,u;const s=(l=(a=i.dashboard)==null?void 0:a.sheets)==null?void 0:l.find(f=>f.id===n);if(s){const f=(c=s.cards)==null?void 0:c.find(p=>p.id===r);f&&(f.sql=o,(u=i.onUpdateCard)==null||u.call(i,f,n))}})},setFrameCardData:(n,r,o)=>{e(i=>{var a,l;const s=(l=(a=i.dashboard)==null?void 0:a.sheets)==null?void 0:l.find(c=>c.id===n);s&&Fl.forEach(s.frames,c=>{var f;const u=(f=c.cards)==null?void 0:f.find(p=>p.id===r);u&&(u.data=o)})})},setSheetLayout:(n,r)=>{e(o=>{var s,a;const i=(a=(s=o.dashboard)==null?void 0:s.sheets)==null?void 0:a.find(l=>l.id===n);i&&(i.layout=r)})},setSheetLayouts:(n,r)=>{e(o=>{var s,a;const i=(a=(s=o.dashboard)==null?void 0:s.sheets)==null?void 0:a.find(l=>l.id===n);i&&(i.layouts=r)})},setShowContext:n=>{e(()=>({showContext:n}))},setShowFilters:n=>{e(()=>({showFilters:n}))},setFilterValues:n=>{e(()=>({filterValues:n}))},addOrUpdateFilterValue:n=>{e(r=>{if(r.filterValues){const o=r.filterValues.findIndex(i=>i.filterId===n.filterId);o>-1?r.filterValues.splice(o,1,n):r.filterValues.push(n)}else r.filterValues=[n]})},addOrUpdateFilterValues:n=>{e(r=>{r.filterValues?n.forEach(o=>{var s,a,l;const i=(s=r==null?void 0:r.filterValues)==null?void 0:s.findIndex(c=>c.filterId===o.filterId);i!==void 0&&i>-1?(a=r.filterValues)==null||a.splice(i,1,o):(l=r.filterValues)==null||l.push(o)}):r.filterValues=n})},removeFilterValue:n=>{e(r=>{if(r.filterValues){const o=r.filterValues.filter(i=>i.filterId!==n&&!i.filterId.startsWith(n));r.filterValues=o}})},replaceFilterValue:n=>{e(r=>{if(r.filterValues){const o=r.filterValues.findIndex(i=>i.filterId===n.filterId);o>-1&&r.filterValues.splice(o,1,n)}})},addFilter:n=>{e(r=>{var i,s;r.dashboard.filters?(i=r.dashboard.filters)==null||i.push(n):r.dashboard.filters=[n];const o=(s=r.dashboard.sheets)==null?void 0:s.find(a=>a.id===r.selectedSheetId);FC({id:n.id,layouts:o==null?void 0:o.layouts,y:0,initialHeight:8,minH:7,w:10})})},removeFilter:n=>{e(r=>{var o,i,s;if(r.dashboard.filters){const a=(o=r.dashboard.filters)==null?void 0:o.findIndex(l=>l.id===n);if(a>-1){(i=r.dashboard.filters)==null||i.splice(a,1);const l=(s=r.dashboard.sheets)==null?void 0:s.find(c=>c.id===r.selectedSheetId);zC(n,l==null?void 0:l.layouts)}}})},updateFrameCard:(n,r,o)=>{e(i=>{var l,c,u,f,p;const s=(c=(l=i.dashboard)==null?void 0:l.sheets)==null?void 0:c.find(g=>g.id===n);if(!s)return;const a=(u=s==null?void 0:s.frames)==null?void 0:u.find(g=>g.id===r);if(a){const g=(f=a.cards)==null?void 0:f.findIndex(v=>v.id===o.id);g>-1&&((p=a.cards)==null||p.splice(g,1,o))}})},updateFilter:n=>{e(r=>{var o,i;if(r.dashboard.filters){const s=(o=r.dashboard.filters)==null?void 0:o.findIndex(a=>a.id===n.id);s>-1&&((i=r.dashboard.filters)==null||i.splice(s,1,n))}})},setIsDashboardEditing:n=>{e(()=>({isDashboardEditing:n}))},setShowDashboardJSON:n=>{e(()=>({showDashboardJSON:n}))},setIsVisualEditing:n=>{e(()=>({isVisualEditing:n}))},addFrame:(n,r,o)=>{e(i=>{var a,l,c,u;const s=(l=(a=i.dashboard)==null?void 0:a.sheets)==null?void 0:l.find(f=>f.id===n);if(s){s.frames||(s.frames=[]),(c=s.frames)==null||c.push(r);let f=1/0,p=0;o==="start"&&(f=0),FC({id:r.id,layouts:s.layouts,minH:10,x:p,y:f}),(u=i.onAddFrame)==null||u.call(i,r,n)}})},removeFrame:(n,r)=>{e(o=>{var s,a,l,c,u;const i=(a=(s=o.dashboard)==null?void 0:s.sheets)==null?void 0:a.find(f=>f.id===n);if(i){const f=(l=i.frames)==null?void 0:l.findIndex(p=>p.id===r);console.log(f),typeof f=="number"&&f>-1&&((c=i.frames)==null||c.splice(f,1),(u=i.layout)==null||u.splice(f,1),zC(r,i.layouts))}})},updateFrame:(n,r)=>{e(o=>{var a,l,c,u;const i=(l=(a=o.dashboard)==null?void 0:a.sheets)==null?void 0:l.find(f=>f.id===n),s=(c=i==null?void 0:i.frames)==null?void 0:c.findIndex(f=>f.id===r.id);i&&((u=i.frames)==null||u.splice(s,1,r))})},updateCard:(n,r)=>{e(o=>{var a,l,c,u,f;const i=(l=(a=o.dashboard)==null?void 0:a.sheets)==null?void 0:l.find(p=>p.id===n),s=(c=i==null?void 0:i.cards)==null?void 0:c.findIndex(p=>p.id===r.id);i&&((u=i.cards)==null||u.splice(s,1,r),(f=o.onUpdateCard)==null||f.call(o,r,n))})},removeCard:(n,r)=>{e(o=>{var a,l,c,u,f,p;const i=(l=(a=o.dashboard)==null?void 0:a.sheets)==null?void 0:l.find(g=>g.id===n),s=(c=i==null?void 0:i.cards)==null?void 0:c.findIndex(g=>g.id===r.id);i&&((u=i.cards)==null||u.splice(s,1),(f=i.layout)==null||f.splice(s,1),(p=o.onRemoveCard)==null||p.call(o,r,n))})},setStyle:n=>{e(r=>{r.dashboard&&(r.dashboard.style=n)})},setSelectedCardId:(n,r)=>{e(o=>{var s,a,l;const i=(a=(s=o.dashboard)==null?void 0:s.sheets)==null?void 0:a.find(c=>c.id===n);i&&(((l=i.cards)==null?void 0:l.find(u=>u.id===r))?o.selectedCardId=r:o.selectedCardId=null)})},setSelectedFrameId:n=>{e(r=>{var i,s;((s=(i=r.dashboard)==null?void 0:i.sheets)==null?void 0:s.find(a=>a.id===r.selectedSheetId))&&(r.selectedFrameId=n)})},setSelectedSheetId:n=>{e(r=>{var i,s;((s=(i=r.dashboard)==null?void 0:i.sheets)==null?void 0:s.find(a=>a.id===n))&&(r.selectedSheetId=n)})},setOnSaveFunction:n=>{e(()=>({onSaveFunction:n}))},setOnAddCard:n=>{e(()=>({onAddCard:n}))},setOnUpdateCard:n=>{e(()=>({onUpdateCard:n}))},setOnRemoveCard:n=>{e(()=>({onRemoveCard:n}))},setOnEvent:n=>{e(()=>({onEvent:n}))},getDashboard:()=>t().dashboard,getSelectedSheet:()=>{var n,r;return(r=(n=t().dashboard)==null?void 0:n.sheets)==null?void 0:r.find(o=>o.id===t().selectedSheetId)},getSelectedFrame:()=>{var r,o,i;const n=(o=(r=t().dashboard)==null?void 0:r.sheets)==null?void 0:o.find(s=>s.id===t().selectedSheetId);return(i=n==null?void 0:n.frames)==null?void 0:i.find(s=>s.id===t().selectedFrameId)},getCard:n=>{var o,i;const r=(o=t().dashboard)==null?void 0:o.sheets;if(r)for(let s=0;s<r.length;s++){const a=r[s].frames;if(a)for(let l=0;l<a.length;l++){const c=(i=a[l].cards)==null?void 0:i.find(u=>u.id===n);if(c)return c}}},getSelectedSheetLayout:()=>{var r,o;const n=(o=(r=t().dashboard)==null?void 0:r.sheets)==null?void 0:o.find(i=>i.id===t().selectedSheetId);return n==null?void 0:n.layout},getSelectedSheetLayouts:()=>{var r,o;const n=(o=(r=t().dashboard)==null?void 0:r.sheets)==null?void 0:o.find(i=>i.id===t().selectedSheetId);return n==null?void 0:n.layouts},getStyle:()=>{var n;return(n=t().dashboard)==null?void 0:n.style},handleDataPointClickAction:(n,r)=>{Q9({card:n,dataPoint:r,set:e,get:t})}}}))),Wi=()=>De(e=>e.actions);var Jd=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},gc=typeof window>"u"||"Deno"in window;function bo(){}function J9(e,t){return typeof e=="function"?e(t):e}function $0(e){return typeof e=="number"&&e>=0&&e!==1/0}function $O(e,t){return Math.max(e+(t||0)-Date.now(),0)}function jC(e,t){const{type:n="all",exact:r,fetchStatus:o,predicate:i,queryKey:s,stale:a}=e;if(s){if(r){if(t.queryHash!==mx(s,t.options))return!1}else if(!td(t.queryKey,s))return!1}if(n!=="all"){const l=t.isActive();if(n==="active"&&!l||n==="inactive"&&l)return!1}return!(typeof a=="boolean"&&t.isStale()!==a||typeof o<"u"&&o!==t.state.fetchStatus||i&&!i(t))}function BC(e,t){const{exact:n,status:r,predicate:o,mutationKey:i}=e;if(i){if(!t.options.mutationKey)return!1;if(n){if(ed(t.options.mutationKey)!==ed(i))return!1}else if(!td(t.options.mutationKey,i))return!1}return!(r&&t.state.status!==r||o&&!o(t))}function mx(e,t){return((t==null?void 0:t.queryKeyHashFn)||ed)(e)}function ed(e){return JSON.stringify(e,(t,n)=>T0(n)?Object.keys(n).sort().reduce((r,o)=>(r[o]=n[o],r),{}):n)}function td(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?!Object.keys(t).some(n=>!td(e[n],t[n])):!1}function DO(e,t){if(e===t)return e;const n=VC(e)&&VC(t);if(n||T0(e)&&T0(t)){const r=n?e:Object.keys(e),o=r.length,i=n?t:Object.keys(t),s=i.length,a=n?[]:{};let l=0;for(let c=0;c<s;c++){const u=n?c:i[c];!n&&e[u]===void 0&&t[u]===void 0&&r.includes(u)?(a[u]=void 0,l++):(a[u]=DO(e[u],t[u]),a[u]===e[u]&&e[u]!==void 0&&l++)}return o===s&&l===o?e:a}return t}function D0(e,t){if(e&&!t||t&&!e)return!1;for(const n in e)if(e[n]!==t[n])return!1;return!0}function VC(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function T0(e){if(!HC(e))return!1;const t=e.constructor;if(typeof t>"u")return!0;const n=t.prototype;return!(!HC(n)||!n.hasOwnProperty("isPrototypeOf"))}function HC(e){return Object.prototype.toString.call(e)==="[object Object]"}function Z9(e){return new Promise(t=>{setTimeout(t,e)})}function k0(e,t,n){return typeof n.structuralSharing=="function"?n.structuralSharing(e,t):n.structuralSharing!==!1?DO(e,t):t}function e8(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function t8(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var Ra,vs,Ql,QP,n8=(QP=class extends Jd{constructor(){super();We(this,Ra,void 0);We(this,vs,void 0);We(this,Ql,void 0);Le(this,Ql,t=>{if(!gc&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){ne(this,vs)||this.setEventListener(ne(this,Ql))}onUnsubscribe(){var t;this.hasListeners()||((t=ne(this,vs))==null||t.call(this),Le(this,vs,void 0))}setEventListener(t){var n;Le(this,Ql,t),(n=ne(this,vs))==null||n.call(this),Le(this,vs,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){ne(this,Ra)!==t&&(Le(this,Ra,t),this.onFocus())}onFocus(){this.listeners.forEach(t=>{t()})}isFocused(){var t;return typeof ne(this,Ra)=="boolean"?ne(this,Ra):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},Ra=new WeakMap,vs=new WeakMap,Ql=new WeakMap,QP),Ap=new n8,Jl,bs,Zl,JP,r8=(JP=class extends Jd{constructor(){super();We(this,Jl,!0);We(this,bs,void 0);We(this,Zl,void 0);Le(this,Zl,t=>{if(!gc&&window.addEventListener){const n=()=>t(!0),r=()=>t(!1);return window.addEventListener("online",n,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",r)}}})}onSubscribe(){ne(this,bs)||this.setEventListener(ne(this,Zl))}onUnsubscribe(){var t;this.hasListeners()||((t=ne(this,bs))==null||t.call(this),Le(this,bs,void 0))}setEventListener(t){var n;Le(this,Zl,t),(n=ne(this,bs))==null||n.call(this),Le(this,bs,t(this.setOnline.bind(this)))}setOnline(t){ne(this,Jl)!==t&&(Le(this,Jl,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return ne(this,Jl)}},Jl=new WeakMap,bs=new WeakMap,Zl=new WeakMap,JP),Ip=new r8;function o8(e){return Math.min(1e3*2**e,3e4)}function _g(e){return(e??"online")==="online"?Ip.isOnline():!0}var TO=class{constructor(e){this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function qv(e){return e instanceof TO}function kO(e){let t=!1,n=0,r=!1,o,i,s;const a=new Promise((x,w)=>{i=x,s=w}),l=x=>{var w;r||(g(new TO(x)),(w=e.abort)==null||w.call(e))},c=()=>{t=!0},u=()=>{t=!1},f=()=>!Ap.isFocused()||e.networkMode!=="always"&&!Ip.isOnline(),p=x=>{var w;r||(r=!0,(w=e.onSuccess)==null||w.call(e,x),o==null||o(),i(x))},g=x=>{var w;r||(r=!0,(w=e.onError)==null||w.call(e,x),o==null||o(),s(x))},v=()=>new Promise(x=>{var w;o=_=>{const S=r||!f();return S&&x(_),S},(w=e.onPause)==null||w.call(e)}).then(()=>{var x;o=void 0,r||(x=e.onContinue)==null||x.call(e)}),b=()=>{if(r)return;let x;try{x=e.fn()}catch(w){x=Promise.reject(w)}Promise.resolve(x).then(p).catch(w=>{var O;if(r)return;const _=e.retry??(gc?0:3),S=e.retryDelay??o8,R=typeof S=="function"?S(n,w):S,E=_===!0||typeof _=="number"&&n<_||typeof _=="function"&&_(n,w);if(t||!E){g(w);return}n++,(O=e.onFail)==null||O.call(e,n,w),Z9(R).then(()=>{if(f())return v()}).then(()=>{t?g(w):b()})})};return _g(e.networkMode)?b():v().then(b),{promise:a,cancel:l,continue:()=>(o==null?void 0:o())?a:Promise.resolve(),cancelRetry:c,continueRetry:u}}function i8(){let e=[],t=0,n=p=>{p()},r=p=>{p()},o=p=>setTimeout(p,0);const i=p=>{o=p},s=p=>{let g;t++;try{g=p()}finally{t--,t||c()}return g},a=p=>{t?e.push(p):o(()=>{n(p)})},l=p=>(...g)=>{a(()=>{p(...g)})},c=()=>{const p=e;e=[],p.length&&o(()=>{r(()=>{p.forEach(g=>{n(g)})})})};return{batch:s,batchCalls:l,schedule:a,setNotifyFunction:p=>{n=p},setBatchNotifyFunction:p=>{r=p},setScheduler:i}}var qn=i8(),Pa,ZP,MO=(ZP=class{constructor(){We(this,Pa,void 0)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),$0(this.gcTime)&&Le(this,Pa,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(gc?1/0:5*60*1e3))}clearGcTimeout(){ne(this,Pa)&&(clearTimeout(ne(this,Pa)),Le(this,Pa,void 0))}},Pa=new WeakMap,ZP),ec,tc,go,ys,mo,Ln,Fd,Oa,nc,pp,To,Ri,eO,s8=(eO=class extends MO{constructor(t){super();We(this,nc);We(this,To);We(this,ec,void 0);We(this,tc,void 0);We(this,go,void 0);We(this,ys,void 0);We(this,mo,void 0);We(this,Ln,void 0);We(this,Fd,void 0);We(this,Oa,void 0);Le(this,Oa,!1),Le(this,Fd,t.defaultOptions),bt(this,nc,pp).call(this,t.options),Le(this,Ln,[]),Le(this,go,t.cache),this.queryKey=t.queryKey,this.queryHash=t.queryHash,Le(this,ec,t.state||a8(this.options)),this.state=ne(this,ec),this.scheduleGc()}get meta(){return this.options.meta}optionalRemove(){!ne(this,Ln).length&&this.state.fetchStatus==="idle"&&ne(this,go).remove(this)}setData(t,n){const r=k0(this.state.data,t,this.options);return bt(this,To,Ri).call(this,{data:r,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),r}setState(t,n){bt(this,To,Ri).call(this,{type:"setState",state:t,setStateOptions:n})}cancel(t){var r;const n=ne(this,ys);return(r=ne(this,mo))==null||r.cancel(t),n?n.then(bo).catch(bo):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(ne(this,ec))}isActive(){return ne(this,Ln).some(t=>t.options.enabled!==!1)}isDisabled(){return this.getObserversCount()>0&&!this.isActive()}isStale(){return this.state.isInvalidated||!this.state.dataUpdatedAt||ne(this,Ln).some(t=>t.getCurrentResult().isStale)}isStaleByTime(t=0){return this.state.isInvalidated||!this.state.dataUpdatedAt||!$O(this.state.dataUpdatedAt,t)}onFocus(){var n;const t=ne(this,Ln).find(r=>r.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(n=ne(this,mo))==null||n.continue()}onOnline(){var n;const t=ne(this,Ln).find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(n=ne(this,mo))==null||n.continue()}addObserver(t){ne(this,Ln).includes(t)||(ne(this,Ln).push(t),this.clearGcTimeout(),ne(this,go).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){ne(this,Ln).includes(t)&&(Le(this,Ln,ne(this,Ln).filter(n=>n!==t)),ne(this,Ln).length||(ne(this,mo)&&(ne(this,Oa)?ne(this,mo).cancel({revert:!0}):ne(this,mo).cancelRetry()),this.scheduleGc()),ne(this,go).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return ne(this,Ln).length}invalidate(){this.state.isInvalidated||bt(this,To,Ri).call(this,{type:"invalidate"})}fetch(t,n){var c,u,f,p;if(this.state.fetchStatus!=="idle"){if(this.state.dataUpdatedAt&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(ne(this,ys))return(c=ne(this,mo))==null||c.continueRetry(),ne(this,ys)}if(t&&bt(this,nc,pp).call(this,t),!this.options.queryFn){const g=ne(this,Ln).find(v=>v.options.queryFn);g&&bt(this,nc,pp).call(this,g.options)}process.env.NODE_ENV!=="production"&&(Array.isArray(this.options.queryKey)||console.error("As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']"));const r=new AbortController,o={queryKey:this.queryKey,meta:this.meta},i=g=>{Object.defineProperty(g,"signal",{enumerable:!0,get:()=>(Le(this,Oa,!0),r.signal)})};i(o);const s=()=>this.options.queryFn?(Le(this,Oa,!1),this.options.persister?this.options.persister(this.options.queryFn,o,this):this.options.queryFn(o)):Promise.reject(new Error(`Missing queryFn: '${this.options.queryHash}'`)),a={fetchOptions:n,options:this.options,queryKey:this.queryKey,state:this.state,fetchFn:s};i(a),(u=this.options.behavior)==null||u.onFetch(a,this),Le(this,tc,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((f=a.fetchOptions)==null?void 0:f.meta))&&bt(this,To,Ri).call(this,{type:"fetch",meta:(p=a.fetchOptions)==null?void 0:p.meta});const l=g=>{var v,b,x,w;qv(g)&&g.silent||bt(this,To,Ri).call(this,{type:"error",error:g}),qv(g)||((b=(v=ne(this,go).config).onError)==null||b.call(v,g,this),(w=(x=ne(this,go).config).onSettled)==null||w.call(x,this.state.data,g,this)),this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1};return Le(this,mo,kO({fn:a.fetchFn,abort:r.abort.bind(r),onSuccess:g=>{var v,b,x,w;if(typeof g>"u"){process.env.NODE_ENV!=="production"&&console.error(`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`),l(new Error(`${this.queryHash} data is undefined`));return}this.setData(g),(b=(v=ne(this,go).config).onSuccess)==null||b.call(v,g,this),(w=(x=ne(this,go).config).onSettled)==null||w.call(x,g,this.state.error,this),this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1},onError:l,onFail:(g,v)=>{bt(this,To,Ri).call(this,{type:"failed",failureCount:g,error:v})},onPause:()=>{bt(this,To,Ri).call(this,{type:"pause"})},onContinue:()=>{bt(this,To,Ri).call(this,{type:"continue"})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode})),Le(this,ys,ne(this,mo).promise),ne(this,ys)}},ec=new WeakMap,tc=new WeakMap,go=new WeakMap,ys=new WeakMap,mo=new WeakMap,Ln=new WeakMap,Fd=new WeakMap,Oa=new WeakMap,nc=new WeakSet,pp=function(t){this.options={...ne(this,Fd),...t},this.updateGcTime(this.options.gcTime)},To=new WeakSet,Ri=function(t){const n=r=>{switch(t.type){case"failed":return{...r,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:t.meta??null,fetchStatus:_g(this.options.networkMode)?"fetching":"paused",...!r.dataUpdatedAt&&{error:null,status:"pending"}};case"success":return{...r,data:t.data,dataUpdateCount:r.dataUpdateCount+1,dataUpdatedAt:t.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const o=t.error;return qv(o)&&o.revert&&ne(this,tc)?{...ne(this,tc),fetchStatus:"idle"}:{...r,error:o,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:o,fetchStatus:"idle",status:"error"};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}};this.state=n(this.state),qn.batch(()=>{ne(this,Ln).forEach(r=>{r.onQueryUpdate()}),ne(this,go).notify({query:this,type:"updated",action:t})})},eO);function a8(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,n=typeof t<"u",r=n?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var Go,tO,AO=(tO=class extends Jd{constructor(t={}){super();We(this,Go,void 0);this.config=t,Le(this,Go,new Map)}build(t,n,r){const o=n.queryKey,i=n.queryHash??mx(o,n);let s=this.get(i);return s||(s=new s8({cache:this,queryKey:o,queryHash:i,options:t.defaultQueryOptions(n),state:r,defaultOptions:t.getQueryDefaults(o)}),this.add(s)),s}add(t){ne(this,Go).has(t.queryHash)||(ne(this,Go).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const n=ne(this,Go).get(t.queryHash);n&&(t.destroy(),n===t&&ne(this,Go).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){qn.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return ne(this,Go).get(t)}getAll(){return[...ne(this,Go).values()]}find(t){const n={exact:!0,...t};return this.getAll().find(r=>jC(n,r))}findAll(t={}){const n=this.getAll();return Object.keys(t).length>0?n.filter(r=>jC(t,r)):n}notify(t){qn.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){qn.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){qn.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Go=new WeakMap,tO),Yo,zd,Hr,rc,Ko,fs,nO,l8=(nO=class extends MO{constructor(t){super();We(this,Ko);We(this,Yo,void 0);We(this,zd,void 0);We(this,Hr,void 0);We(this,rc,void 0);this.mutationId=t.mutationId,Le(this,zd,t.defaultOptions),Le(this,Hr,t.mutationCache),Le(this,Yo,[]),this.state=t.state||c8(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options={...ne(this,zd),...t},this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){ne(this,Yo).includes(t)||(ne(this,Yo).push(t),this.clearGcTimeout(),ne(this,Hr).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){Le(this,Yo,ne(this,Yo).filter(n=>n!==t)),this.scheduleGc(),ne(this,Hr).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){ne(this,Yo).length||(this.state.status==="pending"?this.scheduleGc():ne(this,Hr).remove(this))}continue(){var t;return((t=ne(this,rc))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var o,i,s,a,l,c,u,f,p,g,v,b,x,w,_,S,R,E,O,A;const n=()=>(Le(this,rc,kO({fn:()=>this.options.mutationFn?this.options.mutationFn(t):Promise.reject(new Error("No mutationFn found")),onFail:(k,$)=>{bt(this,Ko,fs).call(this,{type:"failed",failureCount:k,error:$})},onPause:()=>{bt(this,Ko,fs).call(this,{type:"pause"})},onContinue:()=>{bt(this,Ko,fs).call(this,{type:"continue"})},retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode})),ne(this,rc).promise),r=this.state.status==="pending";try{if(!r){bt(this,Ko,fs).call(this,{type:"pending",variables:t}),await((i=(o=ne(this,Hr).config).onMutate)==null?void 0:i.call(o,t,this));const $=await((a=(s=this.options).onMutate)==null?void 0:a.call(s,t));$!==this.state.context&&bt(this,Ko,fs).call(this,{type:"pending",context:$,variables:t})}const k=await n();return await((c=(l=ne(this,Hr).config).onSuccess)==null?void 0:c.call(l,k,t,this.state.context,this)),await((f=(u=this.options).onSuccess)==null?void 0:f.call(u,k,t,this.state.context)),await((g=(p=ne(this,Hr).config).onSettled)==null?void 0:g.call(p,k,null,this.state.variables,this.state.context,this)),await((b=(v=this.options).onSettled)==null?void 0:b.call(v,k,null,t,this.state.context)),bt(this,Ko,fs).call(this,{type:"success",data:k}),k}catch(k){try{throw await((w=(x=ne(this,Hr).config).onError)==null?void 0:w.call(x,k,t,this.state.context,this)),await((S=(_=this.options).onError)==null?void 0:S.call(_,k,t,this.state.context)),await((E=(R=ne(this,Hr).config).onSettled)==null?void 0:E.call(R,void 0,k,this.state.variables,this.state.context,this)),await((A=(O=this.options).onSettled)==null?void 0:A.call(O,void 0,k,t,this.state.context)),k}finally{bt(this,Ko,fs).call(this,{type:"error",error:k})}}}},Yo=new WeakMap,zd=new WeakMap,Hr=new WeakMap,rc=new WeakMap,Ko=new WeakSet,fs=function(t){const n=r=>{switch(t.type){case"failed":return{...r,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:!_g(this.options.networkMode),status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...r,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:t.error,failureCount:r.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=n(this.state),qn.batch(()=>{ne(this,Yo).forEach(r=>{r.onMutationUpdate(t)}),ne(this,Hr).notify({mutation:this,type:"updated",action:t})})},nO);function c8(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var vo,jd,$a,rO,u8=(rO=class extends Jd{constructor(t={}){super();We(this,vo,void 0);We(this,jd,void 0);We(this,$a,void 0);this.config=t,Le(this,vo,[]),Le(this,jd,0)}build(t,n,r){const o=new l8({mutationCache:this,mutationId:++dh(this,jd)._,options:t.defaultMutationOptions(n),state:r});return this.add(o),o}add(t){ne(this,vo).push(t),this.notify({type:"added",mutation:t})}remove(t){Le(this,vo,ne(this,vo).filter(n=>n!==t)),this.notify({type:"removed",mutation:t})}clear(){qn.batch(()=>{ne(this,vo).forEach(t=>{this.remove(t)})})}getAll(){return ne(this,vo)}find(t){const n={exact:!0,...t};return ne(this,vo).find(r=>BC(n,r))}findAll(t={}){return ne(this,vo).filter(n=>BC(t,n))}notify(t){qn.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){return Le(this,$a,(ne(this,$a)??Promise.resolve()).then(()=>{const t=ne(this,vo).filter(n=>n.state.isPaused);return qn.batch(()=>t.reduce((n,r)=>n.then(()=>r.continue().catch(bo)),Promise.resolve()))}).then(()=>{Le(this,$a,void 0)})),ne(this,$a)}},vo=new WeakMap,jd=new WeakMap,$a=new WeakMap,rO);function d8(e){return{onFetch:(t,n)=>{const r=async()=>{var v,b,x,w,_;const o=t.options,i=(x=(b=(v=t.fetchOptions)==null?void 0:v.meta)==null?void 0:b.fetchMore)==null?void 0:x.direction,s=((w=t.state.data)==null?void 0:w.pages)||[],a=((_=t.state.data)==null?void 0:_.pageParams)||[],l={pages:[],pageParams:[]};let c=!1;const u=S=>{Object.defineProperty(S,"signal",{enumerable:!0,get:()=>(t.signal.aborted?c=!0:t.signal.addEventListener("abort",()=>{c=!0}),t.signal)})},f=t.options.queryFn||(()=>Promise.reject(new Error(`Missing queryFn: '${t.options.queryHash}'`))),p=async(S,R,E)=>{if(c)return Promise.reject();if(R==null&&S.pages.length)return Promise.resolve(S);const O={queryKey:t.queryKey,pageParam:R,direction:E?"backward":"forward",meta:t.options.meta};u(O);const A=await f(O),{maxPages:k}=t.options,$=E?t8:e8;return{pages:$(S.pages,A,k),pageParams:$(S.pageParams,R,k)}};let g;if(i&&s.length){const S=i==="backward",R=S?f8:WC,E={pages:s,pageParams:a},O=R(o,E);g=await p(E,O,S)}else{g=await p(l,a[0]??o.initialPageParam);const S=e??s.length;for(let R=1;R<S;R++){const E=WC(o,g);g=await p(g,E)}}return g};t.options.persister?t.fetchFn=()=>{var o,i;return(i=(o=t.options).persister)==null?void 0:i.call(o,r,{queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=r}}}function WC(e,{pages:t,pageParams:n}){const r=t.length-1;return e.getNextPageParam(t[r],t,n[r],n)}function f8(e,{pages:t,pageParams:n}){var r;return(r=e.getPreviousPageParam)==null?void 0:r.call(e,t[0],t,n[0],n)}var Tn,xs,ws,oc,ic,_s,sc,ac,oO,h8=(oO=class{constructor(e={}){We(this,Tn,void 0);We(this,xs,void 0);We(this,ws,void 0);We(this,oc,void 0);We(this,ic,void 0);We(this,_s,void 0);We(this,sc,void 0);We(this,ac,void 0);Le(this,Tn,e.queryCache||new AO),Le(this,xs,e.mutationCache||new u8),Le(this,ws,e.defaultOptions||{}),Le(this,oc,new Map),Le(this,ic,new Map),Le(this,_s,0)}mount(){dh(this,_s)._++,ne(this,_s)===1&&(Le(this,sc,Ap.subscribe(()=>{Ap.isFocused()&&(this.resumePausedMutations(),ne(this,Tn).onFocus())})),Le(this,ac,Ip.subscribe(()=>{Ip.isOnline()&&(this.resumePausedMutations(),ne(this,Tn).onOnline())})))}unmount(){var e,t;dh(this,_s)._--,ne(this,_s)===0&&((e=ne(this,sc))==null||e.call(this),Le(this,sc,void 0),(t=ne(this,ac))==null||t.call(this),Le(this,ac,void 0))}isFetching(e){return ne(this,Tn).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return ne(this,xs).findAll({...e,status:"pending"}).length}getQueryData(e){var t;return(t=ne(this,Tn).find({queryKey:e}))==null?void 0:t.state.data}ensureQueryData(e){const t=this.getQueryData(e.queryKey);return t!==void 0?Promise.resolve(t):this.fetchQuery(e)}getQueriesData(e){return this.getQueryCache().findAll(e).map(({queryKey:t,state:n})=>{const r=n.data;return[t,r]})}setQueryData(e,t,n){const r=ne(this,Tn).find({queryKey:e}),o=r==null?void 0:r.state.data,i=J9(t,o);if(typeof i>"u")return;const s=this.defaultQueryOptions({queryKey:e});return ne(this,Tn).build(this,s).setData(i,{...n,manual:!0})}setQueriesData(e,t,n){return qn.batch(()=>this.getQueryCache().findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,n)]))}getQueryState(e){var t;return(t=ne(this,Tn).find({queryKey:e}))==null?void 0:t.state}removeQueries(e){const t=ne(this,Tn);qn.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=ne(this,Tn),r={type:"active",...e};return qn.batch(()=>(n.findAll(e).forEach(o=>{o.reset()}),this.refetchQueries(r,t)))}cancelQueries(e={},t={}){const n={revert:!0,...t},r=qn.batch(()=>ne(this,Tn).findAll(e).map(o=>o.cancel(n)));return Promise.all(r).then(bo).catch(bo)}invalidateQueries(e={},t={}){return qn.batch(()=>{if(ne(this,Tn).findAll(e).forEach(r=>{r.invalidate()}),e.refetchType==="none")return Promise.resolve();const n={...e,type:e.refetchType??e.type??"active"};return this.refetchQueries(n,t)})}refetchQueries(e={},t){const n={...t,cancelRefetch:(t==null?void 0:t.cancelRefetch)??!0},r=qn.batch(()=>ne(this,Tn).findAll(e).filter(o=>!o.isDisabled()).map(o=>{let i=o.fetch(void 0,n);return n.throwOnError||(i=i.catch(bo)),o.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(r).then(bo)}fetchQuery(e){const t=this.defaultQueryOptions(e);typeof t.retry>"u"&&(t.retry=!1);const n=ne(this,Tn).build(this,t);return n.isStaleByTime(t.staleTime)?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(bo).catch(bo)}fetchInfiniteQuery(e){return e.behavior=d8(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(bo).catch(bo)}resumePausedMutations(){return ne(this,xs).resumePausedMutations()}getQueryCache(){return ne(this,Tn)}getMutationCache(){return ne(this,xs)}getDefaultOptions(){return ne(this,ws)}setDefaultOptions(e){Le(this,ws,e)}setQueryDefaults(e,t){ne(this,oc).set(ed(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...ne(this,oc).values()];let n={};return t.forEach(r=>{td(e,r.queryKey)&&(n={...n,...r.defaultOptions})}),n}setMutationDefaults(e,t){ne(this,ic).set(ed(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...ne(this,ic).values()];let n={};return t.forEach(r=>{td(e,r.mutationKey)&&(n={...n,...r.defaultOptions})}),n}defaultQueryOptions(e){if(e!=null&&e._defaulted)return e;const t={...ne(this,ws).queries,...(e==null?void 0:e.queryKey)&&this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=mx(t.queryKey,t)),typeof t.refetchOnReconnect>"u"&&(t.refetchOnReconnect=t.networkMode!=="always"),typeof t.throwOnError>"u"&&(t.throwOnError=!!t.suspense),typeof t.networkMode>"u"&&t.persister&&(t.networkMode="offlineFirst"),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...ne(this,ws).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){ne(this,Tn).clear(),ne(this,xs).clear()}},Tn=new WeakMap,xs=new WeakMap,ws=new WeakMap,oc=new WeakMap,ic=new WeakMap,_s=new WeakMap,sc=new WeakMap,ac=new WeakMap,oO),Sr,rn,Bd,cr,Da,lc,Xo,Vd,cc,uc,Ta,ka,Ss,dc,Ma,Cu,Hd,M0,Wd,A0,Ud,I0,qd,N0,Gd,L0,Yd,F0,Kd,z0,mg,IO,iO,p8=(iO=class extends Jd{constructor(t,n){super();We(this,Ma);We(this,Hd);We(this,Wd);We(this,Ud);We(this,qd);We(this,Gd);We(this,Yd);We(this,Kd);We(this,mg);We(this,Sr,void 0);We(this,rn,void 0);We(this,Bd,void 0);We(this,cr,void 0);We(this,Da,void 0);We(this,lc,void 0);We(this,Xo,void 0);We(this,Vd,void 0);We(this,cc,void 0);We(this,uc,void 0);We(this,Ta,void 0);We(this,ka,void 0);We(this,Ss,void 0);We(this,dc,new Set);this.options=n,Le(this,Sr,t),Le(this,Xo,null),this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(ne(this,rn).addObserver(this),UC(ne(this,rn),this.options)?bt(this,Ma,Cu).call(this):this.updateResult(),bt(this,qd,N0).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return j0(ne(this,rn),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return j0(ne(this,rn),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,bt(this,Gd,L0).call(this),bt(this,Yd,F0).call(this),ne(this,rn).removeObserver(this)}setOptions(t,n){const r=this.options,o=ne(this,rn);if(this.options=ne(this,Sr).defaultQueryOptions(t),D0(r,this.options)||ne(this,Sr).getQueryCache().notify({type:"observerOptionsUpdated",query:ne(this,rn),observer:this}),typeof this.options.enabled<"u"&&typeof this.options.enabled!="boolean")throw new Error("Expected enabled to be a boolean");this.options.queryKey||(this.options.queryKey=r.queryKey),bt(this,Kd,z0).call(this);const i=this.hasListeners();i&&qC(ne(this,rn),o,this.options,r)&&bt(this,Ma,Cu).call(this),this.updateResult(n),i&&(ne(this,rn)!==o||this.options.enabled!==r.enabled||this.options.staleTime!==r.staleTime)&&bt(this,Hd,M0).call(this);const s=bt(this,Wd,A0).call(this);i&&(ne(this,rn)!==o||this.options.enabled!==r.enabled||s!==ne(this,Ss))&&bt(this,Ud,I0).call(this,s)}getOptimisticResult(t){const n=ne(this,Sr).getQueryCache().build(ne(this,Sr),t),r=this.createResult(n,t);return m8(this,r)&&(Le(this,cr,r),Le(this,lc,this.options),Le(this,Da,ne(this,rn).state)),r}getCurrentResult(){return ne(this,cr)}trackResult(t){const n={};return Object.keys(t).forEach(r=>{Object.defineProperty(n,r,{configurable:!1,enumerable:!0,get:()=>(ne(this,dc).add(r),t[r])})}),n}getCurrentQuery(){return ne(this,rn)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const n=ne(this,Sr).defaultQueryOptions(t),r=ne(this,Sr).getQueryCache().build(ne(this,Sr),n);return r.isFetchingOptimistic=!0,r.fetch().then(()=>this.createResult(r,n))}fetch(t){return bt(this,Ma,Cu).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),ne(this,cr)))}createResult(t,n){var O;const r=ne(this,rn),o=this.options,i=ne(this,cr),s=ne(this,Da),a=ne(this,lc),c=t!==r?t.state:ne(this,Bd),{state:u}=t;let{error:f,errorUpdatedAt:p,fetchStatus:g,status:v}=u,b=!1,x;if(n._optimisticResults){const A=this.hasListeners(),k=!A&&UC(t,n),$=A&&qC(t,r,n,o);(k||$)&&(g=_g(t.options.networkMode)?"fetching":"paused",u.dataUpdatedAt||(v="pending")),n._optimisticResults==="isRestoring"&&(g="idle")}if(n.select&&typeof u.data<"u")if(i&&u.data===(s==null?void 0:s.data)&&n.select===ne(this,Vd))x=ne(this,cc);else try{Le(this,Vd,n.select),x=n.select(u.data),x=k0(i==null?void 0:i.data,x,n),Le(this,cc,x),Le(this,Xo,null)}catch(A){Le(this,Xo,A)}else x=u.data;if(typeof n.placeholderData<"u"&&typeof x>"u"&&v==="pending"){let A;if(i!=null&&i.isPlaceholderData&&n.placeholderData===(a==null?void 0:a.placeholderData))A=i.data;else if(A=typeof n.placeholderData=="function"?n.placeholderData((O=ne(this,uc))==null?void 0:O.state.data,ne(this,uc)):n.placeholderData,n.select&&typeof A<"u")try{A=n.select(A),Le(this,Xo,null)}catch(k){Le(this,Xo,k)}typeof A<"u"&&(v="success",x=k0(i==null?void 0:i.data,A,n),b=!0)}ne(this,Xo)&&(f=ne(this,Xo),x=ne(this,cc),p=Date.now(),v="error");const w=g==="fetching",_=v==="pending",S=v==="error",R=_&&w;return{status:v,fetchStatus:g,isPending:_,isSuccess:v==="success",isError:S,isInitialLoading:R,isLoading:R,data:x,dataUpdatedAt:u.dataUpdatedAt,error:f,errorUpdatedAt:p,failureCount:u.fetchFailureCount,failureReason:u.fetchFailureReason,errorUpdateCount:u.errorUpdateCount,isFetched:u.dataUpdateCount>0||u.errorUpdateCount>0,isFetchedAfterMount:u.dataUpdateCount>c.dataUpdateCount||u.errorUpdateCount>c.errorUpdateCount,isFetching:w,isRefetching:w&&!_,isLoadingError:S&&u.dataUpdatedAt===0,isPaused:g==="paused",isPlaceholderData:b,isRefetchError:S&&u.dataUpdatedAt!==0,isStale:vx(t,n),refetch:this.refetch}}updateResult(t){const n=ne(this,cr),r=this.createResult(ne(this,rn),this.options);if(Le(this,Da,ne(this,rn).state),Le(this,lc,this.options),ne(this,Da).data!==void 0&&Le(this,uc,ne(this,rn)),D0(r,n))return;Le(this,cr,r);const o={},i=()=>{if(!n)return!0;const{notifyOnChangeProps:s}=this.options,a=typeof s=="function"?s():s;if(a==="all"||!a&&!ne(this,dc).size)return!0;const l=new Set(a??ne(this,dc));return this.options.throwOnError&&l.add("error"),Object.keys(ne(this,cr)).some(c=>{const u=c;return ne(this,cr)[u]!==n[u]&&l.has(u)})};(t==null?void 0:t.listeners)!==!1&&i()&&(o.listeners=!0),bt(this,mg,IO).call(this,{...o,...t})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&bt(this,qd,N0).call(this)}},Sr=new WeakMap,rn=new WeakMap,Bd=new WeakMap,cr=new WeakMap,Da=new WeakMap,lc=new WeakMap,Xo=new WeakMap,Vd=new WeakMap,cc=new WeakMap,uc=new WeakMap,Ta=new WeakMap,ka=new WeakMap,Ss=new WeakMap,dc=new WeakMap,Ma=new WeakSet,Cu=function(t){bt(this,Kd,z0).call(this);let n=ne(this,rn).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(bo)),n},Hd=new WeakSet,M0=function(){if(bt(this,Gd,L0).call(this),gc||ne(this,cr).isStale||!$0(this.options.staleTime))return;const n=$O(ne(this,cr).dataUpdatedAt,this.options.staleTime)+1;Le(this,Ta,setTimeout(()=>{ne(this,cr).isStale||this.updateResult()},n))},Wd=new WeakSet,A0=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(ne(this,rn)):this.options.refetchInterval)??!1},Ud=new WeakSet,I0=function(t){bt(this,Yd,F0).call(this),Le(this,Ss,t),!(gc||this.options.enabled===!1||!$0(ne(this,Ss))||ne(this,Ss)===0)&&Le(this,ka,setInterval(()=>{(this.options.refetchIntervalInBackground||Ap.isFocused())&&bt(this,Ma,Cu).call(this)},ne(this,Ss)))},qd=new WeakSet,N0=function(){bt(this,Hd,M0).call(this),bt(this,Ud,I0).call(this,bt(this,Wd,A0).call(this))},Gd=new WeakSet,L0=function(){ne(this,Ta)&&(clearTimeout(ne(this,Ta)),Le(this,Ta,void 0))},Yd=new WeakSet,F0=function(){ne(this,ka)&&(clearInterval(ne(this,ka)),Le(this,ka,void 0))},Kd=new WeakSet,z0=function(){const t=ne(this,Sr).getQueryCache().build(ne(this,Sr),this.options);if(t===ne(this,rn))return;const n=ne(this,rn);Le(this,rn,t),Le(this,Bd,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},mg=new WeakSet,IO=function(t){qn.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(ne(this,cr))}),ne(this,Sr).getQueryCache().notify({query:ne(this,rn),type:"observerResultsUpdated"})})},iO);function g8(e,t){return t.enabled!==!1&&!e.state.dataUpdatedAt&&!(e.state.status==="error"&&t.retryOnMount===!1)}function UC(e,t){return g8(e,t)||e.state.dataUpdatedAt>0&&j0(e,t,t.refetchOnMount)}function j0(e,t,n){if(t.enabled!==!1){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&vx(e,t)}return!1}function qC(e,t,n,r){return n.enabled!==!1&&(e!==t||r.enabled===!1)&&(!n.suspense||e.state.status!=="error")&&vx(e,n)}function vx(e,t){return e.isStaleByTime(t.staleTime)}function m8(e,t){return!D0(e.getCurrentResult(),t)}var NO=pe.createContext(void 0),LO=e=>{const t=pe.useContext(NO);if(e)return e;if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},v8=({client:e,children:t})=>(pe.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),pe.createElement(NO.Provider,{value:e},t)),FO=pe.createContext(!1),b8=()=>pe.useContext(FO);FO.Provider;function y8(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var x8=pe.createContext(y8()),w8=()=>pe.useContext(x8);function _8(e,t){return typeof e=="function"?e(...t):!!e}var S8=(e,t)=>{(e.suspense||e.throwOnError)&&(t.isReset()||(e.retryOnMount=!1))},C8=e=>{pe.useEffect(()=>{e.clearReset()},[e])},E8=({result:e,errorResetBoundary:t,throwOnError:n,query:r})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&_8(n,[e.error,r]),R8=e=>{e.suspense&&typeof e.staleTime!="number"&&(e.staleTime=1e3)},P8=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,O8=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function $8(e,t,n){if(process.env.NODE_ENV!=="production"&&(typeof e!="object"||Array.isArray(e)))throw new Error('Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object');const r=LO(n),o=b8(),i=w8(),s=r.defaultQueryOptions(e);s._optimisticResults=o?"isRestoring":"optimistic",R8(s),S8(s,i),C8(i);const[a]=pe.useState(()=>new t(r,s)),l=a.getOptimisticResult(s);if(pe.useSyncExternalStore(pe.useCallback(c=>{const u=o?()=>{}:a.subscribe(qn.batchCalls(c));return a.updateResult(),u},[a,o]),()=>a.getCurrentResult(),()=>a.getCurrentResult()),pe.useEffect(()=>{a.setOptions(s,{listeners:!1})},[s,a]),P8(s,l))throw O8(s,a,i);if(E8({result:l,errorResetBoundary:i,throwOnError:s.throwOnError,query:r.getQueryCache().get(s.queryHash)}))throw l.error;return s.notifyOnChangeProps?l:a.trackResult(l)}function Zd(e,t){return $8(e,p8,t)}const D8={theme:"system",setTheme:()=>null},zO=m.createContext(D8);function T8({children:e,defaultTheme:t="system",storageKey:n="vite-ui-theme",...r}){const[o,i]=m.useState(()=>localStorage.getItem(n)||t);m.useEffect(()=>{const a=window.document.documentElement;if(a.classList.remove("light","dark"),o==="system"){const l=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";a.classList.add(l);return}a.classList.add(o)},[o]);const s={theme:o,setTheme:a=>{localStorage.setItem(n,a),i(a)}};return P.jsx(zO.Provider,{...r,value:s,children:e})}const jO=()=>{const e=m.useContext(zO);if(e===void 0)throw new Error("useTheme must be used within a ThemeProvider");return e};async function k8(e){return await(await fetch("https://semaphor.cloud/api/v1/dashboard",{headers:{Authorization:`Bearer ${e}`}})).json()}function BO(e){return e==="system"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":e}function GC(e,t){const n=BO(e);return n==="dark"?Fi.merge({...t==null?void 0:t.default},{...t==null?void 0:t.dark}):t==null?void 0:t.default}function M8({authToken:e,customStyle:t,currentTheme:n,onSave:r,onEvent:o}){const{data:i,refetch:s,isLoading:a,isError:l}=Zd({queryKey:["dashboard",e==null?void 0:e.accessToken],queryFn:()=>k8(e==null?void 0:e.accessToken),enabled:!1}),{theme:c,setTheme:u}=jO(),f=De(A=>A.dashboard.globalStyle),{setDashboard:p,setSelectedSheetId:g,setStyle:v,setOnSaveFunction:b}=De(A=>A.actions);De(A=>A.actions.setCustomCards);const x=De(A=>A.actions.setFilterValues),w=De(A=>A.actions.setBookmarkKey),_=De(A=>A.actions.setAuthToken),S=De(A=>A.actions.setThemeStyle),R=De(A=>A.actions.setDashboardTheme),E=De(A=>A.actions.setOnEvent);m.useEffect(()=>{if(c){const A=BO(c);R(A)}},[c,R]),m.useEffect(()=>{n&&u(n)},[n,u]);function O(){const A=Fi.cloneDeep(P0),k=Fi.merge(A,f);if(t){const $=Fi.merge(k,t),I=GC(c,$);S(I),v($)}else{const $=GC(c,k);S($),v(P0)}}return m.useEffect(()=>{i&&i.dashboard&&O()},[c,t,f]),m.useEffect(()=>{var F;if(!i||!i.dashboard)return;const A=i.dashboard,k=_I(A.id),$=JSON.parse(localStorage.getItem(k)||"[]"),I=$.find(j=>j.default===!0);if(I)p(I.template),O(),w(I.name),I.filterValues&&x(I.filterValues);else{p(A),O();const j=$.find(K=>(K==null?void 0:K.name)==="Original");j?j.template=A:$.push({name:"Original",template:A,default:!1}),localStorage.setItem(k,JSON.stringify($))}g((F=A.sheets)==null?void 0:F[0].id)},[i,p,g,x,w]),m.useEffect(()=>{r&&b(r),o&&E(o)},[r,b,o,E]),m.useEffect(()=>{e&&e.accessToken&&(_(e),s())},[e,s,_]),{isLoading:a,isError:l}}function bx({className:e,...t}){return P.jsx("div",{className:Ee("animate-pulse rounded-md bg-muted",e),...t})}const yx=pe.forwardRef(({className:e,...t},n)=>P.jsx("div",{ref:n,className:Ee("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));yx.displayName="Card";const Sg=pe.forwardRef(({className:e,...t},n)=>P.jsx("div",{ref:n,className:Ee("flex flex-col space-y-1.5 p-6",e),...t}));Sg.displayName="CardHeader";const ef=pe.forwardRef(({className:e,...t},n)=>P.jsx("h3",{ref:n,className:Ee("text-2xl font-semibold leading-none tracking-tight",e),...t}));ef.displayName="CardTitle";const xx=pe.forwardRef(({className:e,...t},n)=>P.jsx("p",{ref:n,className:Ee("text-sm text-muted-foreground",e),...t}));xx.displayName="CardDescription";const Cg=pe.forwardRef(({className:e,...t},n)=>P.jsx("div",{ref:n,className:Ee("px-6 pt-0",e),...t}));Cg.displayName="CardContent";const wx=pe.forwardRef(({className:e,...t},n)=>P.jsx("div",{ref:n,className:Ee("flex items-center p-6 pt-0",e),...t}));wx.displayName="CardFooter";function VO({className:e,customStyle:t,onSave:n,onEvent:r,LoadingComponent:o,ErrorComponent:i,onChartElementClicked:s,id:a,authToken:l,currentTheme:c,version:u,customCards:f,...p}){De(w=>w.selectedSheetId);const g=De(w=>w.themeStyle),v=De(w=>w.isSessionExpired),{isLoading:b,isError:x}=M8({authToken:l,customStyle:t,currentTheme:c,onSave:n,onEvent:r});return b||!l?(r==null||r({type:"info",message:"Loading dashboard"}),o?P.jsx(o,{message:"loading"}):P.jsx("div",{className:"flex items-center gap-3",children:P.jsx(bx,{className:"h-1 w-full dark:h-[2px]"})})):x?(r==null||r({type:"error",message:"Error fetching dashboard"}),i?(console.log("Error fetching dashboard"),P.jsx(i,{})):P.jsx("div",{children:"Error"})):v?(r==null||r({type:"error",message:"Session Expired"}),P.jsx("div",{className:"flex h-full items-center justify-center",children:P.jsxs("div",{className:"space-y-4 rounded-md border border-muted p-10",children:[P.jsx(ef,{children:"Session Expired"}),P.jsx("p",{className:"text-muted-foreground",children:"Please refresh your page to continue."})]})})):P.jsx("div",{className:Ee("flex h-full grow flex-col justify-between",g==null?void 0:g.dashboardPanel,e),role:"dashboard-panel",...p})}function le(){return le=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},le.apply(this,arguments)}function Re(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function Bn(e,t=[]){let n=[];function r(i,s){const a=m.createContext(s),l=n.length;n=[...n,s];function c(f){const{scope:p,children:g,...v}=f,b=(p==null?void 0:p[e][l])||a,x=m.useMemo(()=>v,Object.values(v));return m.createElement(b.Provider,{value:x},g)}function u(f,p){const g=(p==null?void 0:p[e][l])||a,v=m.useContext(g);if(v)return v;if(s!==void 0)return s;throw new Error(`\`${f}\` must be used within \`${i}\``)}return c.displayName=i+"Provider",[c,u]}const o=()=>{const i=n.map(s=>m.createContext(s));return function(a){const l=(a==null?void 0:a[e])||i;return m.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return o.scopeName=e,[r,A8(o,...t)]}function A8(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(i){const s=r.reduce((a,{useScope:l,scopeName:c})=>{const f=l(i)[`__scope${c}`];return{...a,...f}},{});return m.useMemo(()=>({[`__scope${t.scopeName}`]:s}),[s])}};return n.scopeName=t.scopeName,n}function I8(e,t){typeof e=="function"?e(t):e!=null&&(e.current=t)}function Eg(...e){return t=>e.forEach(n=>I8(n,t))}function lt(...e){return m.useCallback(Eg(...e),e)}const ji=m.forwardRef((e,t)=>{const{children:n,...r}=e,o=m.Children.toArray(n),i=o.find(N8);if(i){const s=i.props.children,a=o.map(l=>l===i?m.Children.count(s)>1?m.Children.only(null):m.isValidElement(s)?s.props.children:null:l);return m.createElement(B0,le({},r,{ref:t}),m.isValidElement(s)?m.cloneElement(s,void 0,a):null)}return m.createElement(B0,le({},r,{ref:t}),n)});ji.displayName="Slot";const B0=m.forwardRef((e,t)=>{const{children:n,...r}=e;return m.isValidElement(n)?m.cloneElement(n,{...L8(r,n.props),ref:t?Eg(t,n.ref):n.ref}):m.Children.count(n)>1?m.Children.only(null):null});B0.displayName="SlotClone";const HO=({children:e})=>m.createElement(m.Fragment,null,e);function N8(e){return m.isValidElement(e)&&e.type===HO}function L8(e,t){const n={...t};for(const r in t){const o=e[r],i=t[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...a)=>{i(...a),o(...a)}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...e,...n}}function Rg(e){const t=e+"CollectionProvider",[n,r]=Bn(t),[o,i]=n(t,{collectionRef:{current:null},itemMap:new Map}),s=g=>{const{scope:v,children:b}=g,x=m.useRef(null),w=m.useRef(new Map).current;return m.createElement(o,{scope:v,itemMap:w,collectionRef:x},b)},a=e+"CollectionSlot",l=m.forwardRef((g,v)=>{const{scope:b,children:x}=g,w=i(a,b),_=lt(v,w.collectionRef);return m.createElement(ji,{ref:_},x)}),c=e+"CollectionItemSlot",u="data-radix-collection-item",f=m.forwardRef((g,v)=>{const{scope:b,children:x,...w}=g,_=m.useRef(null),S=lt(v,_),R=i(c,b);return m.useEffect(()=>(R.itemMap.set(_,{ref:_,...w}),()=>void R.itemMap.delete(_))),m.createElement(ji,{[u]:"",ref:S},x)});function p(g){const v=i(e+"CollectionConsumer",g);return m.useCallback(()=>{const x=v.collectionRef.current;if(!x)return[];const w=Array.from(x.querySelectorAll(`[${u}]`));return Array.from(v.itemMap.values()).sort((R,E)=>w.indexOf(R.ref.current)-w.indexOf(E.ref.current))},[v.collectionRef,v.itemMap])}return[{Provider:s,Slot:l,ItemSlot:f},p,r]}const tr=globalThis!=null&&globalThis.document?m.useLayoutEffect:()=>{},F8=pe.useId||(()=>{});let z8=0;function $r(e){const[t,n]=pe.useState(F8());return tr(()=>{e||n(r=>r??String(z8++))},[e]),e||(t?`radix-${t}`:"")}const j8=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],Ue=j8.reduce((e,t)=>{const n=m.forwardRef((r,o)=>{const{asChild:i,...s}=r,a=i?ji:t;return m.useEffect(()=>{window[Symbol.for("radix-ui")]=!0},[]),m.createElement(a,le({},s,{ref:o}))});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{});function WO(e,t){e&&Fo.flushSync(()=>e.dispatchEvent(t))}function Mn(e){const t=m.useRef(e);return m.useEffect(()=>{t.current=e}),m.useMemo(()=>(...n)=>{var r;return(r=t.current)===null||r===void 0?void 0:r.call(t,...n)},[])}function nr({prop:e,defaultProp:t,onChange:n=()=>{}}){const[r,o]=B8({defaultProp:t,onChange:n}),i=e!==void 0,s=i?e:r,a=Mn(n),l=m.useCallback(c=>{if(i){const f=typeof c=="function"?c(e):c;f!==e&&a(f)}else o(c)},[i,e,o,a]);return[s,l]}function B8({defaultProp:e,onChange:t}){const n=m.useState(e),[r]=n,o=m.useRef(r),i=Mn(t);return m.useEffect(()=>{o.current!==r&&(i(r),o.current=r)},[r,o,i]),n}const V8=m.createContext(void 0);function Qa(e){const t=m.useContext(V8);return e||t||"ltr"}const Gv="rovingFocusGroup.onEntryFocus",H8={bubbles:!1,cancelable:!0},_x="RovingFocusGroup",[V0,UO,W8]=Rg(_x),[U8,Dc]=Bn(_x,[W8]),[q8,G8]=U8(_x),Y8=m.forwardRef((e,t)=>m.createElement(V0.Provider,{scope:e.__scopeRovingFocusGroup},m.createElement(V0.Slot,{scope:e.__scopeRovingFocusGroup},m.createElement(K8,le({},e,{ref:t}))))),K8=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:i,currentTabStopId:s,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:c,...u}=e,f=m.useRef(null),p=lt(t,f),g=Qa(i),[v=null,b]=nr({prop:s,defaultProp:a,onChange:l}),[x,w]=m.useState(!1),_=Mn(c),S=UO(n),R=m.useRef(!1),[E,O]=m.useState(0);return m.useEffect(()=>{const A=f.current;if(A)return A.addEventListener(Gv,_),()=>A.removeEventListener(Gv,_)},[_]),m.createElement(q8,{scope:n,orientation:r,dir:g,loop:o,currentTabStopId:v,onItemFocus:m.useCallback(A=>b(A),[b]),onItemShiftTab:m.useCallback(()=>w(!0),[]),onFocusableItemAdd:m.useCallback(()=>O(A=>A+1),[]),onFocusableItemRemove:m.useCallback(()=>O(A=>A-1),[])},m.createElement(Ue.div,le({tabIndex:x||E===0?-1:0,"data-orientation":r},u,{ref:p,style:{outline:"none",...e.style},onMouseDown:Re(e.onMouseDown,()=>{R.current=!0}),onFocus:Re(e.onFocus,A=>{const k=!R.current;if(A.target===A.currentTarget&&k&&!x){const $=new CustomEvent(Gv,H8);if(A.currentTarget.dispatchEvent($),!$.defaultPrevented){const I=S().filter(B=>B.focusable),F=I.find(B=>B.active),j=I.find(B=>B.id===v),U=[F,j,...I].filter(Boolean).map(B=>B.ref.current);qO(U)}}R.current=!1}),onBlur:Re(e.onBlur,()=>w(!1))})))}),X8="RovingFocusGroupItem",Q8=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:i,...s}=e,a=$r(),l=i||a,c=G8(X8,n),u=c.currentTabStopId===l,f=UO(n),{onFocusableItemAdd:p,onFocusableItemRemove:g}=c;return m.useEffect(()=>{if(r)return p(),()=>g()},[r,p,g]),m.createElement(V0.ItemSlot,{scope:n,id:l,focusable:r,active:o},m.createElement(Ue.span,le({tabIndex:u?0:-1,"data-orientation":c.orientation},s,{ref:t,onMouseDown:Re(e.onMouseDown,v=>{r?c.onItemFocus(l):v.preventDefault()}),onFocus:Re(e.onFocus,()=>c.onItemFocus(l)),onKeyDown:Re(e.onKeyDown,v=>{if(v.key==="Tab"&&v.shiftKey){c.onItemShiftTab();return}if(v.target!==v.currentTarget)return;const b=ez(v,c.orientation,c.dir);if(b!==void 0){v.preventDefault();let w=f().filter(_=>_.focusable).map(_=>_.ref.current);if(b==="last")w.reverse();else if(b==="prev"||b==="next"){b==="prev"&&w.reverse();const _=w.indexOf(v.currentTarget);w=c.loop?tz(w,_+1):w.slice(_+1)}setTimeout(()=>qO(w))}})})))}),J8={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Z8(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function ez(e,t,n){const r=Z8(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return J8[r]}function qO(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function tz(e,t){return e.map((n,r)=>e[(t+r)%e.length])}const Sx=Y8,Cx=Q8;function nz(e,t){return m.useReducer((n,r)=>{const o=t[n][r];return o??n},e)}const Rn=e=>{const{present:t,children:n}=e,r=rz(t),o=typeof n=="function"?n({present:r.isPresent}):m.Children.only(n),i=lt(r.ref,o.ref);return typeof n=="function"||r.isPresent?m.cloneElement(o,{ref:i}):null};Rn.displayName="Presence";function rz(e){const[t,n]=m.useState(),r=m.useRef({}),o=m.useRef(e),i=m.useRef("none"),s=e?"mounted":"unmounted",[a,l]=nz(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return m.useEffect(()=>{const c=gh(r.current);i.current=a==="mounted"?c:"none"},[a]),tr(()=>{const c=r.current,u=o.current;if(u!==e){const p=i.current,g=gh(c);e?l("MOUNT"):g==="none"||(c==null?void 0:c.display)==="none"?l("UNMOUNT"):l(u&&p!==g?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,l]),tr(()=>{if(t){const c=f=>{const g=gh(r.current).includes(f.animationName);f.target===t&&g&&Fo.flushSync(()=>l("ANIMATION_END"))},u=f=>{f.target===t&&(i.current=gh(r.current))};return t.addEventListener("animationstart",u),t.addEventListener("animationcancel",c),t.addEventListener("animationend",c),()=>{t.removeEventListener("animationstart",u),t.removeEventListener("animationcancel",c),t.removeEventListener("animationend",c)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:m.useCallback(c=>{c&&(r.current=getComputedStyle(c)),n(c)},[])}}function gh(e){return(e==null?void 0:e.animationName)||"none"}const GO="Tabs",[oz,jpe]=Bn(GO,[Dc]),YO=Dc(),[iz,Ex]=oz(GO),sz=m.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,onValueChange:o,defaultValue:i,orientation:s="horizontal",dir:a,activationMode:l="automatic",...c}=e,u=Qa(a),[f,p]=nr({prop:r,onChange:o,defaultProp:i});return m.createElement(iz,{scope:n,baseId:$r(),value:f,onValueChange:p,orientation:s,dir:u,activationMode:l},m.createElement(Ue.div,le({dir:u,"data-orientation":s},c,{ref:t})))}),az="TabsList",lz=m.forwardRef((e,t)=>{const{__scopeTabs:n,loop:r=!0,...o}=e,i=Ex(az,n),s=YO(n);return m.createElement(Sx,le({asChild:!0},s,{orientation:i.orientation,dir:i.dir,loop:r}),m.createElement(Ue.div,le({role:"tablist","aria-orientation":i.orientation},o,{ref:t})))}),cz="TabsTrigger",uz=m.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,disabled:o=!1,...i}=e,s=Ex(cz,n),a=YO(n),l=KO(s.baseId,r),c=XO(s.baseId,r),u=r===s.value;return m.createElement(Cx,le({asChild:!0},a,{focusable:!o,active:u}),m.createElement(Ue.button,le({type:"button",role:"tab","aria-selected":u,"aria-controls":c,"data-state":u?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:l},i,{ref:t,onMouseDown:Re(e.onMouseDown,f=>{!o&&f.button===0&&f.ctrlKey===!1?s.onValueChange(r):f.preventDefault()}),onKeyDown:Re(e.onKeyDown,f=>{[" ","Enter"].includes(f.key)&&s.onValueChange(r)}),onFocus:Re(e.onFocus,()=>{const f=s.activationMode!=="manual";!u&&!o&&f&&s.onValueChange(r)})})))}),dz="TabsContent",fz=m.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,forceMount:o,children:i,...s}=e,a=Ex(dz,n),l=KO(a.baseId,r),c=XO(a.baseId,r),u=r===a.value,f=m.useRef(u);return m.useEffect(()=>{const p=requestAnimationFrame(()=>f.current=!1);return()=>cancelAnimationFrame(p)},[]),m.createElement(Rn,{present:o||u},({present:p})=>m.createElement(Ue.div,le({"data-state":u?"active":"inactive","data-orientation":a.orientation,role:"tabpanel","aria-labelledby":l,hidden:!p,id:c,tabIndex:0},s,{ref:t,style:{...e.style,animationDuration:f.current?"0s":void 0}}),p&&i))});function KO(e,t){return`${e}-trigger-${t}`}function XO(e,t){return`${e}-content-${t}`}const hz=sz,QO=lz,JO=uz,ZO=fz,e$=hz,t$=pe.forwardRef(({className:e,...t},n)=>P.jsx(QO,{ref:n,className:Ee("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",e),...t}));t$.displayName=QO.displayName;const n$=pe.forwardRef(({className:e,...t},n)=>P.jsx(JO,{ref:n,className:Ee("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",e),...t}));n$.displayName=JO.displayName;const Rx=pe.forwardRef(({className:e,...t},n)=>P.jsx(ZO,{ref:n,className:Ee("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",e),...t}));Rx.displayName=ZO.displayName;var r$={exports:{}},tf={},H0={exports:{}};(function(e,t){(function(n,r){r(t)})(ms,function(n){function r(oe){return function(ie,be,G,me,_e,Pe,$e){return oe(ie,be,$e)}}function o(oe){return function(ie,be,G,me){if(!ie||!be||typeof ie!="object"||typeof be!="object")return oe(ie,be,G,me);var _e=me.get(ie),Pe=me.get(be);if(_e&&Pe)return _e===be&&Pe===ie;me.set(ie,be),me.set(be,ie);var $e=oe(ie,be,G,me);return me.delete(ie),me.delete(be),$e}}function i(oe,ee){var ie={};for(var be in oe)ie[be]=oe[be];for(var be in ee)ie[be]=ee[be];return ie}function s(oe){return oe.constructor===Object||oe.constructor==null}function a(oe){return typeof oe.then=="function"}function l(oe,ee){return oe===ee||oe!==oe&&ee!==ee}var c="[object Arguments]",u="[object Boolean]",f="[object Date]",p="[object RegExp]",g="[object Map]",v="[object Number]",b="[object Object]",x="[object Set]",w="[object String]",_=Object.prototype.toString;function S(oe){var ee=oe.areArraysEqual,ie=oe.areDatesEqual,be=oe.areMapsEqual,G=oe.areObjectsEqual,me=oe.areRegExpsEqual,_e=oe.areSetsEqual,Pe=oe.createIsNestedEqual,$e=Pe(Ve);function Ve(Fe,ke,Ge){if(Fe===ke)return!0;if(!Fe||!ke||typeof Fe!="object"||typeof ke!="object")return Fe!==Fe&&ke!==ke;if(s(Fe)&&s(ke))return G(Fe,ke,$e,Ge);var ct=Array.isArray(Fe),kt=Array.isArray(ke);if(ct||kt)return ct===kt&&ee(Fe,ke,$e,Ge);var Dt=_.call(Fe);return Dt!==_.call(ke)?!1:Dt===f?ie(Fe,ke,$e,Ge):Dt===p?me(Fe,ke,$e,Ge):Dt===g?be(Fe,ke,$e,Ge):Dt===x?_e(Fe,ke,$e,Ge):Dt===b||Dt===c?a(Fe)||a(ke)?!1:G(Fe,ke,$e,Ge):Dt===u||Dt===v||Dt===w?l(Fe.valueOf(),ke.valueOf()):!1}return Ve}function R(oe,ee,ie,be){var G=oe.length;if(ee.length!==G)return!1;for(;G-- >0;)if(!ie(oe[G],ee[G],G,G,oe,ee,be))return!1;return!0}var E=o(R);function O(oe,ee){return l(oe.valueOf(),ee.valueOf())}function A(oe,ee,ie,be){var G=oe.size===ee.size;if(!G)return!1;if(!oe.size)return!0;var me={},_e=0;return oe.forEach(function(Pe,$e){if(G){var Ve=!1,Fe=0;ee.forEach(function(ke,Ge){!Ve&&!me[Fe]&&(Ve=ie($e,Ge,_e,Fe,oe,ee,be)&&ie(Pe,ke,$e,Ge,oe,ee,be))&&(me[Fe]=!0),Fe++}),_e++,G=Ve}}),G}var k=o(A),$="_owner",I=Object.prototype.hasOwnProperty;function F(oe,ee,ie,be){var G=Object.keys(oe),me=G.length;if(Object.keys(ee).length!==me)return!1;for(var _e;me-- >0;){if(_e=G[me],_e===$){var Pe=!!oe.$$typeof,$e=!!ee.$$typeof;if((Pe||$e)&&Pe!==$e)return!1}if(!I.call(ee,_e)||!ie(oe[_e],ee[_e],_e,_e,oe,ee,be))return!1}return!0}var j=o(F);function K(oe,ee){return oe.source===ee.source&&oe.flags===ee.flags}function U(oe,ee,ie,be){var G=oe.size===ee.size;if(!G)return!1;if(!oe.size)return!0;var me={};return oe.forEach(function(_e,Pe){if(G){var $e=!1,Ve=0;ee.forEach(function(Fe,ke){!$e&&!me[Ve]&&($e=ie(_e,Fe,Pe,ke,oe,ee,be))&&(me[Ve]=!0),Ve++}),G=$e}}),G}var B=o(U),X=Object.freeze({areArraysEqual:R,areDatesEqual:O,areMapsEqual:A,areObjectsEqual:F,areRegExpsEqual:K,areSetsEqual:U,createIsNestedEqual:r}),H=Object.freeze({areArraysEqual:E,areDatesEqual:O,areMapsEqual:k,areObjectsEqual:j,areRegExpsEqual:K,areSetsEqual:B,createIsNestedEqual:r}),q=S(X);function Z(oe,ee){return q(oe,ee,void 0)}var T=S(i(X,{createIsNestedEqual:function(){return l}}));function V(oe,ee){return T(oe,ee,void 0)}var Q=S(H);function N(oe,ee){return Q(oe,ee,new WeakMap)}var se=S(i(H,{createIsNestedEqual:function(){return l}}));function ae(oe,ee){return se(oe,ee,new WeakMap)}function ue(oe){return S(i(X,oe(X)))}function fe(oe){var ee=S(i(H,oe(H)));return function(ie,be,G){return G===void 0&&(G=new WeakMap),ee(ie,be,G)}}n.circularDeepEqual=N,n.circularShallowEqual=ae,n.createCustomCircularEqual=fe,n.createCustomEqual=ue,n.deepEqual=Z,n.sameValueZeroEqual=l,n.shallowEqual=V,Object.defineProperty(n,"__esModule",{value:!0})})})(H0,H0.exports);var Px=H0.exports;const Ox=lx(I6);var wt={},pz=function(t,n,r){return t===n?!0:t.className===n.className&&r(t.style,n.style)&&t.width===n.width&&t.autoSize===n.autoSize&&t.cols===n.cols&&t.draggableCancel===n.draggableCancel&&t.draggableHandle===n.draggableHandle&&r(t.verticalCompact,n.verticalCompact)&&r(t.compactType,n.compactType)&&r(t.layout,n.layout)&&r(t.margin,n.margin)&&r(t.containerPadding,n.containerPadding)&&t.rowHeight===n.rowHeight&&t.maxRows===n.maxRows&&t.isBounded===n.isBounded&&t.isDraggable===n.isDraggable&&t.isResizable===n.isResizable&&t.allowOverlap===n.allowOverlap&&t.preventCollision===n.preventCollision&&t.useCSSTransforms===n.useCSSTransforms&&t.transformScale===n.transformScale&&t.isDroppable===n.isDroppable&&r(t.resizeHandles,n.resizeHandles)&&r(t.resizeHandle,n.resizeHandle)&&t.onLayoutChange===n.onLayoutChange&&t.onDragStart===n.onDragStart&&t.onDrag===n.onDrag&&t.onDragStop===n.onDragStop&&t.onResizeStart===n.onResizeStart&&t.onResize===n.onResize&&t.onResizeStop===n.onResizeStop&&t.onDrop===n.onDrop&&r(t.droppingItem,n.droppingItem)&&r(t.innerRef,n.innerRef)};Object.defineProperty(wt,"__esModule",{value:!0});wt.bottom=$x;wt.childrenEqual=bz;wt.cloneLayout=o$;wt.cloneLayoutItem=Aa;wt.collides=Pg;wt.compact=s$;wt.compactItem=a$;wt.compactType=kz;wt.correctBounds=l$;wt.fastPositionEqual=xz;wt.fastRGLPropsEqual=void 0;wt.getAllCollisions=c$;wt.getFirstCollision=_a;wt.getLayoutItem=Dx;wt.getStatics=Tx;wt.modifyLayout=i$;wt.moveElement=Ru;wt.moveElementAwayFromCollision=U0;wt.noop=void 0;wt.perc=_z;wt.resizeItemInDirection=Oz;wt.setTopLeft=Dz;wt.setTransform=$z;wt.sortLayoutItems=Lx;wt.sortLayoutItemsByColRow=p$;wt.sortLayoutItemsByRowCol=h$;wt.synchronizeLayoutWithChildren=Tz;wt.validateLayout=g$;wt.withLayoutItem=vz;var YC=Px,Eu=gz(m);function gz(e){return e&&e.__esModule?e:{default:e}}const mz=process.env.NODE_ENV==="production";function $x(e){let t=0,n;for(let r=0,o=e.length;r<o;r++)n=e[r].y+e[r].h,n>t&&(t=n);return t}function o$(e){const t=Array(e.length);for(let n=0,r=e.length;n<r;n++)t[n]=Aa(e[n]);return t}function i$(e,t){const n=Array(e.length);for(let r=0,o=e.length;r<o;r++)t.i===e[r].i?n[r]=t:n[r]=e[r];return n}function vz(e,t,n){let r=Dx(e,t);return r?(r=n(Aa(r)),e=i$(e,r),[e,r]):[e,null]}function Aa(e){return{w:e.w,h:e.h,x:e.x,y:e.y,i:e.i,minW:e.minW,maxW:e.maxW,minH:e.minH,maxH:e.maxH,moved:!!e.moved,static:!!e.static,isDraggable:e.isDraggable,isResizable:e.isResizable,resizeHandles:e.resizeHandles,isBounded:e.isBounded}}function bz(e,t){return(0,YC.deepEqual)(Eu.default.Children.map(e,n=>n==null?void 0:n.key),Eu.default.Children.map(t,n=>n==null?void 0:n.key))&&(0,YC.deepEqual)(Eu.default.Children.map(e,n=>n==null?void 0:n.props["data-grid"]),Eu.default.Children.map(t,n=>n==null?void 0:n.props["data-grid"]))}const yz=pz;wt.fastRGLPropsEqual=yz;function xz(e,t){return e.left===t.left&&e.top===t.top&&e.width===t.width&&e.height===t.height}function Pg(e,t){return!(e.i===t.i||e.x+e.w<=t.x||e.x>=t.x+t.w||e.y+e.h<=t.y||e.y>=t.y+t.h)}function s$(e,t,n,r){const o=Tx(e),i=Lx(e,t),s=Array(e.length);for(let a=0,l=i.length;a<l;a++){let c=Aa(i[a]);c.static||(c=a$(o,c,t,n,i,r),o.push(c)),s[e.indexOf(i[a])]=c,c.moved=!1}return s}const wz={x:"w",y:"h"};function W0(e,t,n,r){const o=wz[r];t[r]+=1;const i=e.map(s=>s.i).indexOf(t.i);for(let s=i+1;s<e.length;s++){const a=e[s];if(!a.static){if(a.y>t.y+t.h)break;Pg(t,a)&&W0(e,a,n+t[o],r)}}t[r]=n}function a$(e,t,n,r,o,i){const s=n==="vertical",a=n==="horizontal";if(s)for(t.y=Math.min($x(e),t.y);t.y>0&&!_a(e,t);)t.y--;else if(a)for(;t.x>0&&!_a(e,t);)t.x--;let l;for(;(l=_a(e,t))&&!(n===null&&i);)if(a?W0(o,t,l.x+l.w,"x"):W0(o,t,l.y+l.h,"y"),a&&t.x+t.w>r)for(t.x=r-t.w,t.y++;t.x>0&&!_a(e,t);)t.x--;return t.y=Math.max(t.y,0),t.x=Math.max(t.x,0),t}function l$(e,t){const n=Tx(e);for(let r=0,o=e.length;r<o;r++){const i=e[r];if(i.x+i.w>t.cols&&(i.x=t.cols-i.w),i.x<0&&(i.x=0,i.w=t.cols),!i.static)n.push(i);else for(;_a(n,i);)i.y++}return e}function Dx(e,t){for(let n=0,r=e.length;n<r;n++)if(e[n].i===t)return e[n]}function _a(e,t){for(let n=0,r=e.length;n<r;n++)if(Pg(e[n],t))return e[n]}function c$(e,t){return e.filter(n=>Pg(n,t))}function Tx(e){return e.filter(t=>t.static)}function Ru(e,t,n,r,o,i,s,a,l){if(t.static&&t.isDraggable!==!0||t.y===r&&t.x===n)return e;"Moving element ".concat(t.i," to [").concat(String(n),",").concat(String(r),"] from [").concat(t.x,",").concat(t.y,"]");const c=t.x,u=t.y;typeof n=="number"&&(t.x=n),typeof r=="number"&&(t.y=r),t.moved=!0;let f=Lx(e,s);(s==="vertical"&&typeof r=="number"?u>=r:s==="horizontal"&&typeof n=="number"?c>=n:!1)&&(f=f.reverse());const g=c$(f,t),v=g.length>0;if(v&&l)return o$(e);if(v&&i)return"Collision prevented on ".concat(t.i,", reverting."),t.x=c,t.y=u,t.moved=!1,e;for(let b=0,x=g.length;b<x;b++){const w=g[b];"Resolving collision between ".concat(t.i," at [").concat(t.x,",").concat(t.y,"] and ").concat(w.i," at [").concat(w.x,",").concat(w.y,"]"),!w.moved&&(w.static?e=U0(e,w,t,o,s):e=U0(e,t,w,o,s))}return e}function U0(e,t,n,r,o,i){const s=o==="horizontal",a=o==="vertical",l=t.static;if(r){r=!1;const f={x:s?Math.max(t.x-n.w,0):n.x,y:a?Math.max(t.y-n.h,0):n.y,w:n.w,h:n.h,i:"-1"},p=_a(e,f),g=p&&p.y+p.h>t.y,v=p&&t.x+t.w>p.x;if(p){if(g&&a)return Ru(e,n,void 0,t.y+1,r,l,o);if(g&&o==null)return t.y=n.y,n.y=n.y+n.h,e;if(v&&s)return Ru(e,t,n.x,void 0,r,l,o)}else return"Doing reverse collision on ".concat(n.i," up to [").concat(f.x,",").concat(f.y,"]."),Ru(e,n,s?f.x:void 0,a?f.y:void 0,r,l,o)}const c=s?n.x+1:void 0,u=a?n.y+1:void 0;return c==null&&u==null?e:Ru(e,n,s?n.x+1:void 0,a?n.y+1:void 0,r,l,o)}function _z(e){return e*100+"%"}const u$=(e,t,n,r)=>e+n>r?t:n,d$=(e,t,n)=>e<0?t:n,f$=e=>Math.max(0,e),kx=e=>Math.max(0,e),Mx=(e,t,n)=>{let{left:r,height:o,width:i}=t;const s=e.top-(o-e.height);return{left:r,width:i,height:d$(s,e.height,o),top:kx(s)}},Ax=(e,t,n)=>{let{top:r,left:o,height:i,width:s}=t;return{top:r,height:i,width:u$(e.left,e.width,s,n),left:f$(o)}},Ix=(e,t,n)=>{let{top:r,height:o,width:i}=t;const s=e.left-(i-e.width);return{height:o,width:s<0?e.width:u$(e.left,e.width,i,n),top:kx(r),left:f$(s)}},Nx=(e,t,n)=>{let{top:r,left:o,height:i,width:s}=t;return{width:s,left:o,height:d$(r,e.height,i),top:kx(r)}},Sz=function(){return Mx(arguments.length<=0?void 0:arguments[0],Ax(...arguments))},Cz=function(){return Mx(arguments.length<=0?void 0:arguments[0],Ix(...arguments))},Ez=function(){return Nx(arguments.length<=0?void 0:arguments[0],Ax(...arguments))},Rz=function(){return Nx(arguments.length<=0?void 0:arguments[0],Ix(...arguments))},Pz={n:Mx,ne:Sz,e:Ax,se:Ez,s:Nx,sw:Rz,w:Ix,nw:Cz};function Oz(e,t,n,r){const o=Pz[e];return o?o(t,{...t,...n},r):n}function $z(e){let{top:t,left:n,width:r,height:o}=e;const i="translate(".concat(n,"px,").concat(t,"px)");return{transform:i,WebkitTransform:i,MozTransform:i,msTransform:i,OTransform:i,width:"".concat(r,"px"),height:"".concat(o,"px"),position:"absolute"}}function Dz(e){let{top:t,left:n,width:r,height:o}=e;return{top:"".concat(t,"px"),left:"".concat(n,"px"),width:"".concat(r,"px"),height:"".concat(o,"px"),position:"absolute"}}function Lx(e,t){return t==="horizontal"?p$(e):t==="vertical"?h$(e):e}function h$(e){return e.slice(0).sort(function(t,n){return t.y>n.y||t.y===n.y&&t.x>n.x?1:t.y===n.y&&t.x===n.x?0:-1})}function p$(e){return e.slice(0).sort(function(t,n){return t.x>n.x||t.x===n.x&&t.y>n.y?1:-1})}function Tz(e,t,n,r,o){e=e||[];const i=[];Eu.default.Children.forEach(t,a=>{if((a==null?void 0:a.key)==null)return;const l=Dx(e,String(a.key)),c=a.props["data-grid"];l&&c==null?i.push(Aa(l)):c?(mz||g$([c],"ReactGridLayout.children"),i.push(Aa({...c,i:a.key}))):i.push(Aa({w:1,h:1,x:0,y:$x(i),i:String(a.key)}))});const s=l$(i,{cols:n});return o?s:s$(s,r,n)}function g$(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"Layout";const n=["x","y","w","h"];if(!Array.isArray(e))throw new Error(t+" must be an array!");for(let r=0,o=e.length;r<o;r++){const i=e[r];for(let s=0;s<n.length;s++)if(typeof i[n[s]]!="number")throw new Error("ReactGridLayout: "+t+"["+r+"]."+n[s]+" must be a number!")}}function kz(e){const{verticalCompact:t,compactType:n}=e||{};return t===!1?null:n}const Mz=()=>{};wt.noop=Mz;var li={};Object.defineProperty(li,"__esModule",{value:!0});li.calcGridColWidth=Og;li.calcGridItemPosition=Az;li.calcGridItemWHPx=q0;li.calcWH=Nz;li.calcXY=Iz;li.clamp=Sa;function Og(e){const{margin:t,containerPadding:n,containerWidth:r,cols:o}=e;return(r-t[0]*(o-1)-n[0]*2)/o}function q0(e,t,n){return Number.isFinite(e)?Math.round(t*e+Math.max(0,e-1)*n):e}function Az(e,t,n,r,o,i){const{margin:s,containerPadding:a,rowHeight:l}=e,c=Og(e),u={};return i&&i.resizing?(u.width=Math.round(i.resizing.width),u.height=Math.round(i.resizing.height)):(u.width=q0(r,c,s[0]),u.height=q0(o,l,s[1])),i&&i.dragging?(u.top=Math.round(i.dragging.top),u.left=Math.round(i.dragging.left)):i&&i.resizing&&typeof i.resizing.top=="number"&&typeof i.resizing.left=="number"?(u.top=Math.round(i.resizing.top),u.left=Math.round(i.resizing.left)):(u.top=Math.round((l+s[1])*n+a[1]),u.left=Math.round((c+s[0])*t+a[0])),u}function Iz(e,t,n,r,o){const{margin:i,cols:s,rowHeight:a,maxRows:l}=e,c=Og(e);let u=Math.round((n-i[0])/(c+i[0])),f=Math.round((t-i[1])/(a+i[1]));return u=Sa(u,0,s-r),f=Sa(f,0,l-o),{x:u,y:f}}function Nz(e,t,n,r,o,i){const{margin:s,maxRows:a,cols:l,rowHeight:c}=e,u=Og(e);let f=Math.round((t+s[0])/(u+s[0])),p=Math.round((n+s[1])/(c+s[1])),g=Sa(f,0,l-r),v=Sa(p,0,a-o);return["sw","w","nw"].indexOf(i)!==-1&&(g=Sa(f,0,l)),["nw","n","ne"].indexOf(i)!==-1&&(v=Sa(p,0,a)),{w:g,h:v}}function Sa(e,t,n){return Math.max(Math.min(e,n),t)}var $g={},G0={exports:{}},Yv,KC;function Fx(){if(KC)return Yv;KC=1;var e="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return Yv=e,Yv}var Kv,XC;function Lz(){if(XC)return Kv;XC=1;var e=Fx();function t(){}function n(){}return n.resetWarningCache=t,Kv=function(){function r(s,a,l,c,u,f){if(f!==e){var p=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw p.name="Invariant Violation",p}}r.isRequired=r;function o(){return r}var i={array:r,bigint:r,bool:r,func:r,number:r,object:r,string:r,symbol:r,any:r,arrayOf:o,element:r,elementType:r,instanceOf:o,node:r,objectOf:o,oneOf:o,oneOfType:o,shape:o,exact:o,checkPropTypes:n,resetWarningCache:t};return i.PropTypes=i,i},Kv}var mh={exports:{}},Ft={};/** @license React v16.13.1
88
+ }`;var pt=vC(function(){return Mt(z,Be+"return "+we).apply(n,W)});if(pt.source=we,Pv(pt))throw pt;return pt}function L4(d){return Lt(d).toLowerCase()}function F4(d){return Lt(d).toUpperCase()}function z4(d,h,y){if(d=Lt(d),d&&(y||h===n))return R_(d);if(!d||!(h=Ir(h)))return d;var C=Eo(d),M=Eo(h),z=P_(C,M),W=O_(C,M)+1;return ns(C,z,W).join("")}function j4(d,h,y){if(d=Lt(d),d&&(y||h===n))return d.slice(0,D_(d)+1);if(!d||!(h=Ir(h)))return d;var C=Eo(d),M=O_(C,Eo(h))+1;return ns(C,0,M).join("")}function B4(d,h,y){if(d=Lt(d),d&&(y||h===n))return d.replace(Ks,"");if(!d||!(h=Ir(h)))return d;var C=Eo(d),M=P_(C,Eo(h));return ns(C,M).join("")}function V4(d,h){var y=I,C=F;if(pn(h)){var M="separator"in h?h.separator:M;y="length"in h?ut(h.length):y,C="omission"in h?Ir(h.omission):C}d=Lt(d);var z=d.length;if(fl(d)){var W=Eo(d);z=W.length}if(y>=z)return d;var Y=y-hl(C);if(Y<1)return C;var re=W?ns(W,0,Y).join(""):d.slice(0,Y);if(M===n)return re+C;if(W&&(Y+=re.length-Y),Ov(M)){if(d.slice(Y).search(M)){var ve,ye=re;for(M.global||(M=Wm(M.source,Lt(He.exec(M))+"g")),M.lastIndex=0;ve=M.exec(ye);)var we=ve.index;re=re.slice(0,we===n?Y:we)}}else if(d.indexOf(Ir(M),Y)!=Y){var Ae=re.lastIndexOf(M);Ae>-1&&(re=re.slice(0,Ae))}return re+C}function H4(d){return d=Lt(d),d&&hr.test(d)?d.replace(Wt,bN):d}var W4=xl(function(d,h,y){return d+(y?" ":"")+h.toUpperCase()}),Tv=bS("toUpperCase");function mC(d,h,y){return d=Lt(d),h=y?n:h,h===n?hN(d)?wN(d):oN(d):d.match(h)||[]}var vC=vt(function(d,h){try{return Mr(d,n,h)}catch(y){return Pv(y)?y:new ot(y)}}),U4=bi(function(d,h){return so(h,function(y){y=Vo(y),mi(d,y,Ev(d[y],d))}),d});function q4(d){var h=d==null?0:d.length,y=Ye();return d=h?fn(d,function(C){if(typeof C[1]!="function")throw new ao(s);return[y(C[0]),C[1]]}):[],vt(function(C){for(var M=-1;++M<h;){var z=d[M];if(Mr(z[0],this,C))return Mr(z[1],this,C)}})}function G4(d){return b3(co(d,f))}function kv(d){return function(){return d}}function Y4(d,h){return d==null||d!==d?h:d}var K4=xS(),X4=xS(!0);function vr(d){return d}function Mv(d){return X_(typeof d=="function"?d:co(d,f))}function Q4(d){return J_(co(d,f))}function J4(d,h){return Z_(d,co(h,f))}var Z4=vt(function(d,h){return function(y){return Jc(y,d,h)}}),e6=vt(function(d,h){return function(y){return Jc(d,y,h)}});function Av(d,h,y){var C=Nn(h),M=Uf(h,C);y==null&&!(pn(h)&&(M.length||!C.length))&&(y=h,h=d,d=this,M=Uf(h,Nn(h)));var z=!(pn(y)&&"chain"in y)||!!y.chain,W=xi(d);return so(M,function(Y){var re=h[Y];d[Y]=re,W&&(d.prototype[Y]=function(){var ve=this.__chain__;if(z||ve){var ye=d(this.__wrapped__),we=ye.__actions__=pr(this.__actions__);return we.push({func:re,args:arguments,thisArg:d}),ye.__chain__=ve,ye}return re.apply(d,Xi([this.value()],arguments))})}),d}function t6(){return Vn._===this&&(Vn._=PN),this}function Iv(){}function n6(d){return d=ut(d),vt(function(h){return eS(h,d)})}var r6=fv(fn),o6=fv(w_),i6=fv(Lm);function bC(d){return yv(d)?Fm(Vo(d)):I3(d)}function s6(d){return function(h){return d==null?n:na(d,h)}}var a6=_S(),l6=_S(!0);function Nv(){return[]}function Lv(){return!1}function c6(){return{}}function u6(){return""}function d6(){return!0}function f6(d,h){if(d=ut(d),d<1||d>q)return[];var y=V,C=Kn(d,V);h=Ye(h),d-=V;for(var M=Bm(C,h);++y<d;)h(y);return M}function h6(d){return st(d)?fn(d,Vo):Nr(d)?[d]:pr(FS(Lt(d)))}function p6(d){var h=++EN;return Lt(d)+h}var g6=Qf(function(d,h){return d+h},0),m6=hv("ceil"),v6=Qf(function(d,h){return d/h},1),b6=hv("floor");function y6(d){return d&&d.length?Wf(d,vr,Jm):n}function x6(d,h){return d&&d.length?Wf(d,Ye(h,2),Jm):n}function w6(d){return C_(d,vr)}function _6(d,h){return C_(d,Ye(h,2))}function S6(d){return d&&d.length?Wf(d,vr,nv):n}function C6(d,h){return d&&d.length?Wf(d,Ye(h,2),nv):n}var E6=Qf(function(d,h){return d*h},1),R6=hv("round"),P6=Qf(function(d,h){return d-h},0);function O6(d){return d&&d.length?jm(d,vr):0}function $6(d,h){return d&&d.length?jm(d,Ye(h,2)):0}return L.after=QL,L.ary=KS,L.assign=FF,L.assignIn=cC,L.assignInWith=uh,L.assignWith=zF,L.at=jF,L.before=XS,L.bind=Ev,L.bindAll=U4,L.bindKey=QS,L.castArray=cF,L.chain=qS,L.chunk=b7,L.compact=y7,L.concat=x7,L.cond=q4,L.conforms=G4,L.constant=kv,L.countBy=OL,L.create=BF,L.curry=JS,L.curryRight=ZS,L.debounce=eC,L.defaults=VF,L.defaultsDeep=HF,L.defer=JL,L.delay=ZL,L.difference=w7,L.differenceBy=_7,L.differenceWith=S7,L.drop=C7,L.dropRight=E7,L.dropRightWhile=R7,L.dropWhile=P7,L.fill=O7,L.filter=DL,L.flatMap=ML,L.flatMapDeep=AL,L.flatMapDepth=IL,L.flatten=VS,L.flattenDeep=$7,L.flattenDepth=D7,L.flip=eF,L.flow=K4,L.flowRight=X4,L.fromPairs=T7,L.functions=XF,L.functionsIn=QF,L.groupBy=NL,L.initial=M7,L.intersection=A7,L.intersectionBy=I7,L.intersectionWith=N7,L.invert=ZF,L.invertBy=e4,L.invokeMap=FL,L.iteratee=Mv,L.keyBy=zL,L.keys=Nn,L.keysIn=mr,L.map=oh,L.mapKeys=n4,L.mapValues=r4,L.matches=Q4,L.matchesProperty=J4,L.memoize=sh,L.merge=o4,L.mergeWith=uC,L.method=Z4,L.methodOf=e6,L.mixin=Av,L.negate=ah,L.nthArg=n6,L.omit=i4,L.omitBy=s4,L.once=tF,L.orderBy=jL,L.over=r6,L.overArgs=nF,L.overEvery=o6,L.overSome=i6,L.partial=Rv,L.partialRight=tC,L.partition=BL,L.pick=a4,L.pickBy=dC,L.property=bC,L.propertyOf=s6,L.pull=j7,L.pullAll=WS,L.pullAllBy=B7,L.pullAllWith=V7,L.pullAt=H7,L.range=a6,L.rangeRight=l6,L.rearg=rF,L.reject=WL,L.remove=W7,L.rest=oF,L.reverse=Sv,L.sampleSize=qL,L.set=c4,L.setWith=u4,L.shuffle=GL,L.slice=U7,L.sortBy=XL,L.sortedUniq=J7,L.sortedUniqBy=Z7,L.split=M4,L.spread=iF,L.tail=eL,L.take=tL,L.takeRight=nL,L.takeRightWhile=rL,L.takeWhile=oL,L.tap=yL,L.throttle=sF,L.thru=rh,L.toArray=sC,L.toPairs=fC,L.toPairsIn=hC,L.toPath=h6,L.toPlainObject=lC,L.transform=d4,L.unary=aF,L.union=iL,L.unionBy=sL,L.unionWith=aL,L.uniq=lL,L.uniqBy=cL,L.uniqWith=uL,L.unset=f4,L.unzip=Cv,L.unzipWith=US,L.update=h4,L.updateWith=p4,L.values=Sl,L.valuesIn=g4,L.without=dL,L.words=mC,L.wrap=lF,L.xor=fL,L.xorBy=hL,L.xorWith=pL,L.zip=gL,L.zipObject=mL,L.zipObjectDeep=vL,L.zipWith=bL,L.entries=fC,L.entriesIn=hC,L.extend=cC,L.extendWith=uh,Av(L,L),L.add=g6,L.attempt=vC,L.camelCase=y4,L.capitalize=pC,L.ceil=m6,L.clamp=m4,L.clone=uF,L.cloneDeep=fF,L.cloneDeepWith=hF,L.cloneWith=dF,L.conformsTo=pF,L.deburr=gC,L.defaultTo=Y4,L.divide=v6,L.endsWith=x4,L.eq=Po,L.escape=w4,L.escapeRegExp=_4,L.every=$L,L.find=TL,L.findIndex=jS,L.findKey=WF,L.findLast=kL,L.findLastIndex=BS,L.findLastKey=UF,L.floor=b6,L.forEach=GS,L.forEachRight=YS,L.forIn=qF,L.forInRight=GF,L.forOwn=YF,L.forOwnRight=KF,L.get=$v,L.gt=gF,L.gte=mF,L.has=JF,L.hasIn=Dv,L.head=HS,L.identity=vr,L.includes=LL,L.indexOf=k7,L.inRange=v4,L.invoke=t4,L.isArguments=ia,L.isArray=st,L.isArrayBuffer=vF,L.isArrayLike=gr,L.isArrayLikeObject=xn,L.isBoolean=bF,L.isBuffer=rs,L.isDate=yF,L.isElement=xF,L.isEmpty=wF,L.isEqual=_F,L.isEqualWith=SF,L.isError=Pv,L.isFinite=CF,L.isFunction=xi,L.isInteger=nC,L.isLength=lh,L.isMap=rC,L.isMatch=EF,L.isMatchWith=RF,L.isNaN=PF,L.isNative=OF,L.isNil=DF,L.isNull=$F,L.isNumber=oC,L.isObject=pn,L.isObjectLike=mn,L.isPlainObject=ou,L.isRegExp=Ov,L.isSafeInteger=TF,L.isSet=iC,L.isString=ch,L.isSymbol=Nr,L.isTypedArray=_l,L.isUndefined=kF,L.isWeakMap=MF,L.isWeakSet=AF,L.join=L7,L.kebabCase=S4,L.last=fo,L.lastIndexOf=F7,L.lowerCase=C4,L.lowerFirst=E4,L.lt=IF,L.lte=NF,L.max=y6,L.maxBy=x6,L.mean=w6,L.meanBy=_6,L.min=S6,L.minBy=C6,L.stubArray=Nv,L.stubFalse=Lv,L.stubObject=c6,L.stubString=u6,L.stubTrue=d6,L.multiply=E6,L.nth=z7,L.noConflict=t6,L.noop=Iv,L.now=ih,L.pad=R4,L.padEnd=P4,L.padStart=O4,L.parseInt=$4,L.random=b4,L.reduce=VL,L.reduceRight=HL,L.repeat=D4,L.replace=T4,L.result=l4,L.round=R6,L.runInContext=te,L.sample=UL,L.size=YL,L.snakeCase=k4,L.some=KL,L.sortedIndex=q7,L.sortedIndexBy=G7,L.sortedIndexOf=Y7,L.sortedLastIndex=K7,L.sortedLastIndexBy=X7,L.sortedLastIndexOf=Q7,L.startCase=A4,L.startsWith=I4,L.subtract=P6,L.sum=O6,L.sumBy=$6,L.template=N4,L.times=f6,L.toFinite=wi,L.toInteger=ut,L.toLength=aC,L.toLower=L4,L.toNumber=ho,L.toSafeInteger=LF,L.toString=Lt,L.toUpper=F4,L.trim=z4,L.trimEnd=j4,L.trimStart=B4,L.truncate=V4,L.unescape=H4,L.uniqueId=p6,L.upperCase=W4,L.upperFirst=Tv,L.each=GS,L.eachRight=YS,L.first=HS,Av(L,function(){var d={};return jo(L,function(h,y){Bt.call(L.prototype,y)||(d[y]=h)}),d}(),{chain:!1}),L.VERSION=r,so(["bind","bindKey","curry","curryRight","partial","partialRight"],function(d){L[d].placeholder=L}),so(["drop","take"],function(d,h){Ct.prototype[d]=function(y){y=y===n?1:Dn(ut(y),0);var C=this.__filtered__&&!h?new Ct(this):this.clone();return C.__filtered__?C.__takeCount__=Kn(y,C.__takeCount__):C.__views__.push({size:Kn(y,V),type:d+(C.__dir__<0?"Right":"")}),C},Ct.prototype[d+"Right"]=function(y){return this.reverse()[d](y).reverse()}}),so(["filter","map","takeWhile"],function(d,h){var y=h+1,C=y==U||y==X;Ct.prototype[d]=function(M){var z=this.clone();return z.__iteratees__.push({iteratee:Ye(M,3),type:y}),z.__filtered__=z.__filtered__||C,z}}),so(["head","last"],function(d,h){var y="take"+(h?"Right":"");Ct.prototype[d]=function(){return this[y](1).value()[0]}}),so(["initial","tail"],function(d,h){var y="drop"+(h?"":"Right");Ct.prototype[d]=function(){return this.__filtered__?new Ct(this):this[y](1)}}),Ct.prototype.compact=function(){return this.filter(vr)},Ct.prototype.find=function(d){return this.filter(d).head()},Ct.prototype.findLast=function(d){return this.reverse().find(d)},Ct.prototype.invokeMap=vt(function(d,h){return typeof d=="function"?new Ct(this):this.map(function(y){return Jc(y,d,h)})}),Ct.prototype.reject=function(d){return this.filter(ah(Ye(d)))},Ct.prototype.slice=function(d,h){d=ut(d);var y=this;return y.__filtered__&&(d>0||h<0)?new Ct(y):(d<0?y=y.takeRight(-d):d&&(y=y.drop(d)),h!==n&&(h=ut(h),y=h<0?y.dropRight(-h):y.take(h-d)),y)},Ct.prototype.takeRightWhile=function(d){return this.reverse().takeWhile(d).reverse()},Ct.prototype.toArray=function(){return this.take(V)},jo(Ct.prototype,function(d,h){var y=/^(?:filter|find|map|reject)|While$/.test(h),C=/^(?:head|last)$/.test(h),M=L[C?"take"+(h=="last"?"Right":""):h],z=C||/^find/.test(h);M&&(L.prototype[h]=function(){var W=this.__wrapped__,Y=C?[1]:arguments,re=W instanceof Ct,ve=Y[0],ye=re||st(W),we=function(_t){var Rt=M.apply(L,Xi([_t],Y));return C&&Ae?Rt[0]:Rt};ye&&y&&typeof ve=="function"&&ve.length!=1&&(re=ye=!1);var Ae=this.__chain__,Be=!!this.__actions__.length,Ke=z&&!Ae,pt=re&&!Be;if(!z&&ye){W=pt?W:new Ct(this);var Xe=d.apply(W,Y);return Xe.__actions__.push({func:rh,args:[we],thisArg:n}),new lo(Xe,Ae)}return Ke&&pt?d.apply(this,Y):(Xe=this.thru(we),Ke?C?Xe.value()[0]:Xe.value():Xe)})}),so(["pop","push","shift","sort","splice","unshift"],function(d){var h=$f[d],y=/^(?:push|sort|unshift)$/.test(d)?"tap":"thru",C=/^(?:pop|shift)$/.test(d);L.prototype[d]=function(){var M=arguments;if(C&&!this.__chain__){var z=this.value();return h.apply(st(z)?z:[],M)}return this[y](function(W){return h.apply(st(W)?W:[],M)})}}),jo(Ct.prototype,function(d,h){var y=L[h];if(y){var C=y.name+"";Bt.call(vl,C)||(vl[C]=[]),vl[C].push({name:h,func:y})}}),vl[Xf(n,w).name]=[{name:"wrapper",func:n}],Ct.prototype.clone=HN,Ct.prototype.reverse=WN,Ct.prototype.value=UN,L.prototype.at=xL,L.prototype.chain=wL,L.prototype.commit=_L,L.prototype.next=SL,L.prototype.plant=EL,L.prototype.reverse=RL,L.prototype.toJSON=L.prototype.valueOf=L.prototype.value=PL,L.prototype.first=L.prototype.head,Uc&&(L.prototype[Uc]=CL),L},pl=_N();Qs?((Qs.exports=pl)._=pl,Mm._=pl):Vn._=pl}).call(ms)})(Mp,Mp.exports);var Fl=Mp.exports;const Fi=Oc(Fl);function FC({id:e,layouts:t,initialHeight:n,y:r,x:o,w:i,minH:s}){const a={i:e,x:o??0,y:r??1/0,w:i||20,h:n||35,minW:6,minH:s||10};t||(t={}),PO.forEach(l=>{t!=null&&t[l]||(t={...t,[l]:[]}),t[l].push(a)})}function zC(e,t){t&&PO.forEach(n=>{t!=null&&t[n]&&(t[n]=t[n].filter(r=>r.i!==e))})}const De=gO()(_O((e,t)=>({isSessionExpired:!1,currentBreakpoint:"lg",dashboard:{id:"",style:P0},showContext:!1,selectedSheetId:null,selectedCardId:null,selectedFrameId:null,selectedCard:null,showFilters:!1,isDashboardEditing:!1,isVisualEditing:!1,showDashboardJSON:!1,filteringCards:[],actions:{setGlobalStyle:n=>{e(r=>{r.dashboard.globalStyle=n})},setAIScopeTables:n=>{e(r=>{r.dashboard.aiScopeTables=n})},setIsSessionExpired:n=>{e(()=>({isSessionExpired:n}))},setCardPython:(n,r)=>{e(o=>{var s,a;const i=(a=(s=o.dashboard)==null?void 0:s.sheets)==null?void 0:a.find(l=>l.id===o.selectedSheetId);i&&Fl.forEach(i.frames,l=>{var u;const c=(u=l.cards)==null?void 0:u.find(f=>f.id===n);c&&(c.python=r)})})},addBaseQuery:n=>{e(r=>{var o;r.dashboard.baseQueries||(r.dashboard.baseQueries=[]),(o=r.dashboard.baseQueries)==null||o.push(n)})},removeBaseQuery:n=>{e(r=>{var i,s;const o=(i=r.dashboard.baseQueries)==null?void 0:i.findIndex(a=>a.id===n);o!=null&&o>-1&&((s=r.dashboard.baseQueries)==null||s.splice(o,1))})},setBaseQueries:n=>{e(r=>{r.dashboard.baseQueries=n})},setCurrentBreakpoint:n=>{e(()=>({currentBreakpoint:n}))},addFilteringCard:n=>{e(r=>{var o;(o=r.filteringCards)==null||o.push(n)})},removeFilteringCard:n=>{e(r=>{var i,s;const o=(i=r.filteringCards)==null?void 0:i.findIndex(a=>a.id===n.id);o!==void 0&&o>-1&&((s=r.filteringCards)==null||s.splice(o,1))})},setCustomCards:n=>{e(r=>{r.dashboard.customCards=n})},setAuthToken:n=>{e(()=>({authToken:n}))},setThemeStyle:n=>{e(()=>({themeStyle:n}))},setDashboard:n=>e({dashboard:n}),setBookmarkKey:n=>{e(()=>({bookmarkKey:n}))},setDashboardTheme:n=>{e(r=>{r.theme=n})},setSheets:n=>{e(r=>{r.dashboard&&(r.dashboard.sheets=n)})},setCardTitle:(n,r,o)=>{e(i=>{var a,l;const s=(l=(a=i.dashboard)==null?void 0:a.sheets)==null?void 0:l.find(c=>c.id===n);s&&Fl.forEach(s.frames,c=>{var f;const u=(f=c.cards)==null?void 0:f.find(p=>p.id===r);u&&(u.title=o)})})},setCardInfo:(n,r)=>{e(o=>{var s,a;const i=(a=(s=o.dashboard)==null?void 0:s.sheets)==null?void 0:a.find(l=>l.id===o.selectedSheetId);i&&Fl.forEach(i.frames,l=>{var u;const c=(u=l.cards)==null?void 0:u.find(f=>f.id===n);c&&(c.info=r)})})},setCardDescription:(n,r,o)=>{e(i=>{var a,l;const s=(l=(a=i.dashboard)==null?void 0:a.sheets)==null?void 0:l.find(c=>c.id===n);s&&Fl.forEach(s.frames,c=>{var f;const u=(f=c.cards)==null?void 0:f.find(p=>p.id===r);u&&(u.description=o)})})},setCardSql:(n,r,o)=>{e(i=>{var a,l,c,u;const s=(l=(a=i.dashboard)==null?void 0:a.sheets)==null?void 0:l.find(f=>f.id===n);if(s){const f=(c=s.cards)==null?void 0:c.find(p=>p.id===r);f&&(f.sql=o,(u=i.onUpdateCard)==null||u.call(i,f,n))}})},setFrameCardData:(n,r,o)=>{e(i=>{var a,l;const s=(l=(a=i.dashboard)==null?void 0:a.sheets)==null?void 0:l.find(c=>c.id===n);s&&Fl.forEach(s.frames,c=>{var f;const u=(f=c.cards)==null?void 0:f.find(p=>p.id===r);u&&(u.data=o)})})},setSheetLayout:(n,r)=>{e(o=>{var s,a;const i=(a=(s=o.dashboard)==null?void 0:s.sheets)==null?void 0:a.find(l=>l.id===n);i&&(i.layout=r)})},setSheetLayouts:(n,r)=>{e(o=>{var s,a;const i=(a=(s=o.dashboard)==null?void 0:s.sheets)==null?void 0:a.find(l=>l.id===n);i&&(i.layouts=r)})},setShowContext:n=>{e(()=>({showContext:n}))},setShowFilters:n=>{e(()=>({showFilters:n}))},setFilterValues:n=>{e(()=>({filterValues:n}))},addOrUpdateFilterValue:n=>{e(r=>{if(r.filterValues){const o=r.filterValues.findIndex(i=>i.filterId===n.filterId);o>-1?r.filterValues.splice(o,1,n):r.filterValues.push(n)}else r.filterValues=[n]})},addOrUpdateFilterValues:n=>{e(r=>{r.filterValues?n.forEach(o=>{var s,a,l;const i=(s=r==null?void 0:r.filterValues)==null?void 0:s.findIndex(c=>c.filterId===o.filterId);i!==void 0&&i>-1?(a=r.filterValues)==null||a.splice(i,1,o):(l=r.filterValues)==null||l.push(o)}):r.filterValues=n})},removeFilterValue:n=>{e(r=>{if(r.filterValues){const o=r.filterValues.filter(i=>i.filterId!==n&&!i.filterId.startsWith(n));r.filterValues=o}})},replaceFilterValue:n=>{e(r=>{if(r.filterValues){const o=r.filterValues.findIndex(i=>i.filterId===n.filterId);o>-1&&r.filterValues.splice(o,1,n)}})},addFilter:n=>{e(r=>{var i,s;r.dashboard.filters?(i=r.dashboard.filters)==null||i.push(n):r.dashboard.filters=[n];const o=(s=r.dashboard.sheets)==null?void 0:s.find(a=>a.id===r.selectedSheetId);FC({id:n.id,layouts:o==null?void 0:o.layouts,y:0,initialHeight:8,minH:7,w:10})})},removeFilter:n=>{e(r=>{var o,i,s;if(r.dashboard.filters){const a=(o=r.dashboard.filters)==null?void 0:o.findIndex(l=>l.id===n);if(a>-1){(i=r.dashboard.filters)==null||i.splice(a,1);const l=(s=r.dashboard.sheets)==null?void 0:s.find(c=>c.id===r.selectedSheetId);zC(n,l==null?void 0:l.layouts)}}})},updateFrameCard:(n,r,o)=>{e(i=>{var l,c,u,f,p;const s=(c=(l=i.dashboard)==null?void 0:l.sheets)==null?void 0:c.find(g=>g.id===n);if(!s)return;const a=(u=s==null?void 0:s.frames)==null?void 0:u.find(g=>g.id===r);if(a){const g=(f=a.cards)==null?void 0:f.findIndex(v=>v.id===o.id);g>-1&&((p=a.cards)==null||p.splice(g,1,o))}})},updateFilter:n=>{e(r=>{var o,i;if(r.dashboard.filters){const s=(o=r.dashboard.filters)==null?void 0:o.findIndex(a=>a.id===n.id);s>-1&&((i=r.dashboard.filters)==null||i.splice(s,1,n))}})},setIsDashboardEditing:n=>{e(()=>({isDashboardEditing:n}))},setShowDashboardJSON:n=>{e(()=>({showDashboardJSON:n}))},setIsVisualEditing:n=>{e(()=>({isVisualEditing:n}))},addFrame:(n,r,o)=>{e(i=>{var a,l,c,u;const s=(l=(a=i.dashboard)==null?void 0:a.sheets)==null?void 0:l.find(f=>f.id===n);if(s){s.frames||(s.frames=[]),(c=s.frames)==null||c.push(r);let f=1/0,p=0;o==="start"&&(f=0),FC({id:r.id,layouts:s.layouts,minH:10,x:p,y:f}),(u=i.onAddFrame)==null||u.call(i,r,n)}})},removeFrame:(n,r)=>{e(o=>{var s,a,l,c,u;const i=(a=(s=o.dashboard)==null?void 0:s.sheets)==null?void 0:a.find(f=>f.id===n);if(i){const f=(l=i.frames)==null?void 0:l.findIndex(p=>p.id===r);console.log(f),typeof f=="number"&&f>-1&&((c=i.frames)==null||c.splice(f,1),(u=i.layout)==null||u.splice(f,1),zC(r,i.layouts))}})},updateFrame:(n,r)=>{e(o=>{var a,l,c,u;const i=(l=(a=o.dashboard)==null?void 0:a.sheets)==null?void 0:l.find(f=>f.id===n),s=(c=i==null?void 0:i.frames)==null?void 0:c.findIndex(f=>f.id===r.id);i&&((u=i.frames)==null||u.splice(s,1,r))})},updateCard:(n,r)=>{e(o=>{var a,l,c,u,f;const i=(l=(a=o.dashboard)==null?void 0:a.sheets)==null?void 0:l.find(p=>p.id===n),s=(c=i==null?void 0:i.cards)==null?void 0:c.findIndex(p=>p.id===r.id);i&&((u=i.cards)==null||u.splice(s,1,r),(f=o.onUpdateCard)==null||f.call(o,r,n))})},removeCard:(n,r)=>{e(o=>{var a,l,c,u,f,p;const i=(l=(a=o.dashboard)==null?void 0:a.sheets)==null?void 0:l.find(g=>g.id===n),s=(c=i==null?void 0:i.cards)==null?void 0:c.findIndex(g=>g.id===r.id);i&&((u=i.cards)==null||u.splice(s,1),(f=i.layout)==null||f.splice(s,1),(p=o.onRemoveCard)==null||p.call(o,r,n))})},setStyle:n=>{e(r=>{r.dashboard&&(r.dashboard.style=n)})},setSelectedCardId:(n,r)=>{e(o=>{var s,a,l;const i=(a=(s=o.dashboard)==null?void 0:s.sheets)==null?void 0:a.find(c=>c.id===n);i&&(((l=i.cards)==null?void 0:l.find(u=>u.id===r))?o.selectedCardId=r:o.selectedCardId=null)})},setSelectedFrameId:n=>{e(r=>{var i,s;((s=(i=r.dashboard)==null?void 0:i.sheets)==null?void 0:s.find(a=>a.id===r.selectedSheetId))&&(r.selectedFrameId=n)})},setSelectedSheetId:n=>{e(r=>{var i,s;((s=(i=r.dashboard)==null?void 0:i.sheets)==null?void 0:s.find(a=>a.id===n))&&(r.selectedSheetId=n)})},setOnSaveFunction:n=>{e(()=>({onSaveFunction:n}))},setOnAddCard:n=>{e(()=>({onAddCard:n}))},setOnUpdateCard:n=>{e(()=>({onUpdateCard:n}))},setOnRemoveCard:n=>{e(()=>({onRemoveCard:n}))},setOnEvent:n=>{e(()=>({onEvent:n}))},getDashboard:()=>t().dashboard,getSelectedSheet:()=>{var n,r;return(r=(n=t().dashboard)==null?void 0:n.sheets)==null?void 0:r.find(o=>o.id===t().selectedSheetId)},getSelectedFrame:()=>{var r,o,i;const n=(o=(r=t().dashboard)==null?void 0:r.sheets)==null?void 0:o.find(s=>s.id===t().selectedSheetId);return(i=n==null?void 0:n.frames)==null?void 0:i.find(s=>s.id===t().selectedFrameId)},getCard:n=>{var o,i;const r=(o=t().dashboard)==null?void 0:o.sheets;if(r)for(let s=0;s<r.length;s++){const a=r[s].frames;if(a)for(let l=0;l<a.length;l++){const c=(i=a[l].cards)==null?void 0:i.find(u=>u.id===n);if(c)return c}}},getSelectedSheetLayout:()=>{var r,o;const n=(o=(r=t().dashboard)==null?void 0:r.sheets)==null?void 0:o.find(i=>i.id===t().selectedSheetId);return n==null?void 0:n.layout},getSelectedSheetLayouts:()=>{var r,o;const n=(o=(r=t().dashboard)==null?void 0:r.sheets)==null?void 0:o.find(i=>i.id===t().selectedSheetId);return n==null?void 0:n.layouts},getStyle:()=>{var n;return(n=t().dashboard)==null?void 0:n.style},handleDataPointClickAction:(n,r)=>{Q9({card:n,dataPoint:r,set:e,get:t})}}}))),Wi=()=>De(e=>e.actions);var Jd=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},gc=typeof window>"u"||"Deno"in window;function bo(){}function J9(e,t){return typeof e=="function"?e(t):e}function $0(e){return typeof e=="number"&&e>=0&&e!==1/0}function $O(e,t){return Math.max(e+(t||0)-Date.now(),0)}function jC(e,t){const{type:n="all",exact:r,fetchStatus:o,predicate:i,queryKey:s,stale:a}=e;if(s){if(r){if(t.queryHash!==mx(s,t.options))return!1}else if(!td(t.queryKey,s))return!1}if(n!=="all"){const l=t.isActive();if(n==="active"&&!l||n==="inactive"&&l)return!1}return!(typeof a=="boolean"&&t.isStale()!==a||typeof o<"u"&&o!==t.state.fetchStatus||i&&!i(t))}function BC(e,t){const{exact:n,status:r,predicate:o,mutationKey:i}=e;if(i){if(!t.options.mutationKey)return!1;if(n){if(ed(t.options.mutationKey)!==ed(i))return!1}else if(!td(t.options.mutationKey,i))return!1}return!(r&&t.state.status!==r||o&&!o(t))}function mx(e,t){return((t==null?void 0:t.queryKeyHashFn)||ed)(e)}function ed(e){return JSON.stringify(e,(t,n)=>T0(n)?Object.keys(n).sort().reduce((r,o)=>(r[o]=n[o],r),{}):n)}function td(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?!Object.keys(t).some(n=>!td(e[n],t[n])):!1}function DO(e,t){if(e===t)return e;const n=VC(e)&&VC(t);if(n||T0(e)&&T0(t)){const r=n?e:Object.keys(e),o=r.length,i=n?t:Object.keys(t),s=i.length,a=n?[]:{};let l=0;for(let c=0;c<s;c++){const u=n?c:i[c];!n&&e[u]===void 0&&t[u]===void 0&&r.includes(u)?(a[u]=void 0,l++):(a[u]=DO(e[u],t[u]),a[u]===e[u]&&e[u]!==void 0&&l++)}return o===s&&l===o?e:a}return t}function D0(e,t){if(e&&!t||t&&!e)return!1;for(const n in e)if(e[n]!==t[n])return!1;return!0}function VC(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function T0(e){if(!HC(e))return!1;const t=e.constructor;if(typeof t>"u")return!0;const n=t.prototype;return!(!HC(n)||!n.hasOwnProperty("isPrototypeOf"))}function HC(e){return Object.prototype.toString.call(e)==="[object Object]"}function Z9(e){return new Promise(t=>{setTimeout(t,e)})}function k0(e,t,n){return typeof n.structuralSharing=="function"?n.structuralSharing(e,t):n.structuralSharing!==!1?DO(e,t):t}function e8(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function t8(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var Ra,vs,Ql,QP,n8=(QP=class extends Jd{constructor(){super();We(this,Ra,void 0);We(this,vs,void 0);We(this,Ql,void 0);Le(this,Ql,t=>{if(!gc&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){ne(this,vs)||this.setEventListener(ne(this,Ql))}onUnsubscribe(){var t;this.hasListeners()||((t=ne(this,vs))==null||t.call(this),Le(this,vs,void 0))}setEventListener(t){var n;Le(this,Ql,t),(n=ne(this,vs))==null||n.call(this),Le(this,vs,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){ne(this,Ra)!==t&&(Le(this,Ra,t),this.onFocus())}onFocus(){this.listeners.forEach(t=>{t()})}isFocused(){var t;return typeof ne(this,Ra)=="boolean"?ne(this,Ra):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},Ra=new WeakMap,vs=new WeakMap,Ql=new WeakMap,QP),Ap=new n8,Jl,bs,Zl,JP,r8=(JP=class extends Jd{constructor(){super();We(this,Jl,!0);We(this,bs,void 0);We(this,Zl,void 0);Le(this,Zl,t=>{if(!gc&&window.addEventListener){const n=()=>t(!0),r=()=>t(!1);return window.addEventListener("online",n,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",r)}}})}onSubscribe(){ne(this,bs)||this.setEventListener(ne(this,Zl))}onUnsubscribe(){var t;this.hasListeners()||((t=ne(this,bs))==null||t.call(this),Le(this,bs,void 0))}setEventListener(t){var n;Le(this,Zl,t),(n=ne(this,bs))==null||n.call(this),Le(this,bs,t(this.setOnline.bind(this)))}setOnline(t){ne(this,Jl)!==t&&(Le(this,Jl,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return ne(this,Jl)}},Jl=new WeakMap,bs=new WeakMap,Zl=new WeakMap,JP),Ip=new r8;function o8(e){return Math.min(1e3*2**e,3e4)}function _g(e){return(e??"online")==="online"?Ip.isOnline():!0}var TO=class{constructor(e){this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function qv(e){return e instanceof TO}function kO(e){let t=!1,n=0,r=!1,o,i,s;const a=new Promise((x,w)=>{i=x,s=w}),l=x=>{var w;r||(g(new TO(x)),(w=e.abort)==null||w.call(e))},c=()=>{t=!0},u=()=>{t=!1},f=()=>!Ap.isFocused()||e.networkMode!=="always"&&!Ip.isOnline(),p=x=>{var w;r||(r=!0,(w=e.onSuccess)==null||w.call(e,x),o==null||o(),i(x))},g=x=>{var w;r||(r=!0,(w=e.onError)==null||w.call(e,x),o==null||o(),s(x))},v=()=>new Promise(x=>{var w;o=_=>{const S=r||!f();return S&&x(_),S},(w=e.onPause)==null||w.call(e)}).then(()=>{var x;o=void 0,r||(x=e.onContinue)==null||x.call(e)}),b=()=>{if(r)return;let x;try{x=e.fn()}catch(w){x=Promise.reject(w)}Promise.resolve(x).then(p).catch(w=>{var O;if(r)return;const _=e.retry??(gc?0:3),S=e.retryDelay??o8,R=typeof S=="function"?S(n,w):S,E=_===!0||typeof _=="number"&&n<_||typeof _=="function"&&_(n,w);if(t||!E){g(w);return}n++,(O=e.onFail)==null||O.call(e,n,w),Z9(R).then(()=>{if(f())return v()}).then(()=>{t?g(w):b()})})};return _g(e.networkMode)?b():v().then(b),{promise:a,cancel:l,continue:()=>(o==null?void 0:o())?a:Promise.resolve(),cancelRetry:c,continueRetry:u}}function i8(){let e=[],t=0,n=p=>{p()},r=p=>{p()},o=p=>setTimeout(p,0);const i=p=>{o=p},s=p=>{let g;t++;try{g=p()}finally{t--,t||c()}return g},a=p=>{t?e.push(p):o(()=>{n(p)})},l=p=>(...g)=>{a(()=>{p(...g)})},c=()=>{const p=e;e=[],p.length&&o(()=>{r(()=>{p.forEach(g=>{n(g)})})})};return{batch:s,batchCalls:l,schedule:a,setNotifyFunction:p=>{n=p},setBatchNotifyFunction:p=>{r=p},setScheduler:i}}var qn=i8(),Pa,ZP,MO=(ZP=class{constructor(){We(this,Pa,void 0)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),$0(this.gcTime)&&Le(this,Pa,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(gc?1/0:5*60*1e3))}clearGcTimeout(){ne(this,Pa)&&(clearTimeout(ne(this,Pa)),Le(this,Pa,void 0))}},Pa=new WeakMap,ZP),ec,tc,go,ys,mo,Ln,Fd,Oa,nc,pp,To,Ri,eO,s8=(eO=class extends MO{constructor(t){super();We(this,nc);We(this,To);We(this,ec,void 0);We(this,tc,void 0);We(this,go,void 0);We(this,ys,void 0);We(this,mo,void 0);We(this,Ln,void 0);We(this,Fd,void 0);We(this,Oa,void 0);Le(this,Oa,!1),Le(this,Fd,t.defaultOptions),bt(this,nc,pp).call(this,t.options),Le(this,Ln,[]),Le(this,go,t.cache),this.queryKey=t.queryKey,this.queryHash=t.queryHash,Le(this,ec,t.state||a8(this.options)),this.state=ne(this,ec),this.scheduleGc()}get meta(){return this.options.meta}optionalRemove(){!ne(this,Ln).length&&this.state.fetchStatus==="idle"&&ne(this,go).remove(this)}setData(t,n){const r=k0(this.state.data,t,this.options);return bt(this,To,Ri).call(this,{data:r,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),r}setState(t,n){bt(this,To,Ri).call(this,{type:"setState",state:t,setStateOptions:n})}cancel(t){var r;const n=ne(this,ys);return(r=ne(this,mo))==null||r.cancel(t),n?n.then(bo).catch(bo):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(ne(this,ec))}isActive(){return ne(this,Ln).some(t=>t.options.enabled!==!1)}isDisabled(){return this.getObserversCount()>0&&!this.isActive()}isStale(){return this.state.isInvalidated||!this.state.dataUpdatedAt||ne(this,Ln).some(t=>t.getCurrentResult().isStale)}isStaleByTime(t=0){return this.state.isInvalidated||!this.state.dataUpdatedAt||!$O(this.state.dataUpdatedAt,t)}onFocus(){var n;const t=ne(this,Ln).find(r=>r.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(n=ne(this,mo))==null||n.continue()}onOnline(){var n;const t=ne(this,Ln).find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(n=ne(this,mo))==null||n.continue()}addObserver(t){ne(this,Ln).includes(t)||(ne(this,Ln).push(t),this.clearGcTimeout(),ne(this,go).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){ne(this,Ln).includes(t)&&(Le(this,Ln,ne(this,Ln).filter(n=>n!==t)),ne(this,Ln).length||(ne(this,mo)&&(ne(this,Oa)?ne(this,mo).cancel({revert:!0}):ne(this,mo).cancelRetry()),this.scheduleGc()),ne(this,go).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return ne(this,Ln).length}invalidate(){this.state.isInvalidated||bt(this,To,Ri).call(this,{type:"invalidate"})}fetch(t,n){var c,u,f,p;if(this.state.fetchStatus!=="idle"){if(this.state.dataUpdatedAt&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(ne(this,ys))return(c=ne(this,mo))==null||c.continueRetry(),ne(this,ys)}if(t&&bt(this,nc,pp).call(this,t),!this.options.queryFn){const g=ne(this,Ln).find(v=>v.options.queryFn);g&&bt(this,nc,pp).call(this,g.options)}process.env.NODE_ENV!=="production"&&(Array.isArray(this.options.queryKey)||console.error("As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']"));const r=new AbortController,o={queryKey:this.queryKey,meta:this.meta},i=g=>{Object.defineProperty(g,"signal",{enumerable:!0,get:()=>(Le(this,Oa,!0),r.signal)})};i(o);const s=()=>this.options.queryFn?(Le(this,Oa,!1),this.options.persister?this.options.persister(this.options.queryFn,o,this):this.options.queryFn(o)):Promise.reject(new Error(`Missing queryFn: '${this.options.queryHash}'`)),a={fetchOptions:n,options:this.options,queryKey:this.queryKey,state:this.state,fetchFn:s};i(a),(u=this.options.behavior)==null||u.onFetch(a,this),Le(this,tc,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((f=a.fetchOptions)==null?void 0:f.meta))&&bt(this,To,Ri).call(this,{type:"fetch",meta:(p=a.fetchOptions)==null?void 0:p.meta});const l=g=>{var v,b,x,w;qv(g)&&g.silent||bt(this,To,Ri).call(this,{type:"error",error:g}),qv(g)||((b=(v=ne(this,go).config).onError)==null||b.call(v,g,this),(w=(x=ne(this,go).config).onSettled)==null||w.call(x,this.state.data,g,this)),this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1};return Le(this,mo,kO({fn:a.fetchFn,abort:r.abort.bind(r),onSuccess:g=>{var v,b,x,w;if(typeof g>"u"){process.env.NODE_ENV!=="production"&&console.error(`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`),l(new Error(`${this.queryHash} data is undefined`));return}this.setData(g),(b=(v=ne(this,go).config).onSuccess)==null||b.call(v,g,this),(w=(x=ne(this,go).config).onSettled)==null||w.call(x,g,this.state.error,this),this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1},onError:l,onFail:(g,v)=>{bt(this,To,Ri).call(this,{type:"failed",failureCount:g,error:v})},onPause:()=>{bt(this,To,Ri).call(this,{type:"pause"})},onContinue:()=>{bt(this,To,Ri).call(this,{type:"continue"})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode})),Le(this,ys,ne(this,mo).promise),ne(this,ys)}},ec=new WeakMap,tc=new WeakMap,go=new WeakMap,ys=new WeakMap,mo=new WeakMap,Ln=new WeakMap,Fd=new WeakMap,Oa=new WeakMap,nc=new WeakSet,pp=function(t){this.options={...ne(this,Fd),...t},this.updateGcTime(this.options.gcTime)},To=new WeakSet,Ri=function(t){const n=r=>{switch(t.type){case"failed":return{...r,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:t.meta??null,fetchStatus:_g(this.options.networkMode)?"fetching":"paused",...!r.dataUpdatedAt&&{error:null,status:"pending"}};case"success":return{...r,data:t.data,dataUpdateCount:r.dataUpdateCount+1,dataUpdatedAt:t.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const o=t.error;return qv(o)&&o.revert&&ne(this,tc)?{...ne(this,tc),fetchStatus:"idle"}:{...r,error:o,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:o,fetchStatus:"idle",status:"error"};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}};this.state=n(this.state),qn.batch(()=>{ne(this,Ln).forEach(r=>{r.onQueryUpdate()}),ne(this,go).notify({query:this,type:"updated",action:t})})},eO);function a8(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,n=typeof t<"u",r=n?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var Go,tO,AO=(tO=class extends Jd{constructor(t={}){super();We(this,Go,void 0);this.config=t,Le(this,Go,new Map)}build(t,n,r){const o=n.queryKey,i=n.queryHash??mx(o,n);let s=this.get(i);return s||(s=new s8({cache:this,queryKey:o,queryHash:i,options:t.defaultQueryOptions(n),state:r,defaultOptions:t.getQueryDefaults(o)}),this.add(s)),s}add(t){ne(this,Go).has(t.queryHash)||(ne(this,Go).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const n=ne(this,Go).get(t.queryHash);n&&(t.destroy(),n===t&&ne(this,Go).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){qn.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return ne(this,Go).get(t)}getAll(){return[...ne(this,Go).values()]}find(t){const n={exact:!0,...t};return this.getAll().find(r=>jC(n,r))}findAll(t={}){const n=this.getAll();return Object.keys(t).length>0?n.filter(r=>jC(t,r)):n}notify(t){qn.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){qn.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){qn.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Go=new WeakMap,tO),Yo,zd,Hr,rc,Ko,fs,nO,l8=(nO=class extends MO{constructor(t){super();We(this,Ko);We(this,Yo,void 0);We(this,zd,void 0);We(this,Hr,void 0);We(this,rc,void 0);this.mutationId=t.mutationId,Le(this,zd,t.defaultOptions),Le(this,Hr,t.mutationCache),Le(this,Yo,[]),this.state=t.state||c8(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options={...ne(this,zd),...t},this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){ne(this,Yo).includes(t)||(ne(this,Yo).push(t),this.clearGcTimeout(),ne(this,Hr).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){Le(this,Yo,ne(this,Yo).filter(n=>n!==t)),this.scheduleGc(),ne(this,Hr).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){ne(this,Yo).length||(this.state.status==="pending"?this.scheduleGc():ne(this,Hr).remove(this))}continue(){var t;return((t=ne(this,rc))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var o,i,s,a,l,c,u,f,p,g,v,b,x,w,_,S,R,E,O,A;const n=()=>(Le(this,rc,kO({fn:()=>this.options.mutationFn?this.options.mutationFn(t):Promise.reject(new Error("No mutationFn found")),onFail:(k,$)=>{bt(this,Ko,fs).call(this,{type:"failed",failureCount:k,error:$})},onPause:()=>{bt(this,Ko,fs).call(this,{type:"pause"})},onContinue:()=>{bt(this,Ko,fs).call(this,{type:"continue"})},retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode})),ne(this,rc).promise),r=this.state.status==="pending";try{if(!r){bt(this,Ko,fs).call(this,{type:"pending",variables:t}),await((i=(o=ne(this,Hr).config).onMutate)==null?void 0:i.call(o,t,this));const $=await((a=(s=this.options).onMutate)==null?void 0:a.call(s,t));$!==this.state.context&&bt(this,Ko,fs).call(this,{type:"pending",context:$,variables:t})}const k=await n();return await((c=(l=ne(this,Hr).config).onSuccess)==null?void 0:c.call(l,k,t,this.state.context,this)),await((f=(u=this.options).onSuccess)==null?void 0:f.call(u,k,t,this.state.context)),await((g=(p=ne(this,Hr).config).onSettled)==null?void 0:g.call(p,k,null,this.state.variables,this.state.context,this)),await((b=(v=this.options).onSettled)==null?void 0:b.call(v,k,null,t,this.state.context)),bt(this,Ko,fs).call(this,{type:"success",data:k}),k}catch(k){try{throw await((w=(x=ne(this,Hr).config).onError)==null?void 0:w.call(x,k,t,this.state.context,this)),await((S=(_=this.options).onError)==null?void 0:S.call(_,k,t,this.state.context)),await((E=(R=ne(this,Hr).config).onSettled)==null?void 0:E.call(R,void 0,k,this.state.variables,this.state.context,this)),await((A=(O=this.options).onSettled)==null?void 0:A.call(O,void 0,k,t,this.state.context)),k}finally{bt(this,Ko,fs).call(this,{type:"error",error:k})}}}},Yo=new WeakMap,zd=new WeakMap,Hr=new WeakMap,rc=new WeakMap,Ko=new WeakSet,fs=function(t){const n=r=>{switch(t.type){case"failed":return{...r,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:!_g(this.options.networkMode),status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...r,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:t.error,failureCount:r.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=n(this.state),qn.batch(()=>{ne(this,Yo).forEach(r=>{r.onMutationUpdate(t)}),ne(this,Hr).notify({mutation:this,type:"updated",action:t})})},nO);function c8(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var vo,jd,$a,rO,u8=(rO=class extends Jd{constructor(t={}){super();We(this,vo,void 0);We(this,jd,void 0);We(this,$a,void 0);this.config=t,Le(this,vo,[]),Le(this,jd,0)}build(t,n,r){const o=new l8({mutationCache:this,mutationId:++dh(this,jd)._,options:t.defaultMutationOptions(n),state:r});return this.add(o),o}add(t){ne(this,vo).push(t),this.notify({type:"added",mutation:t})}remove(t){Le(this,vo,ne(this,vo).filter(n=>n!==t)),this.notify({type:"removed",mutation:t})}clear(){qn.batch(()=>{ne(this,vo).forEach(t=>{this.remove(t)})})}getAll(){return ne(this,vo)}find(t){const n={exact:!0,...t};return ne(this,vo).find(r=>BC(n,r))}findAll(t={}){return ne(this,vo).filter(n=>BC(t,n))}notify(t){qn.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){return Le(this,$a,(ne(this,$a)??Promise.resolve()).then(()=>{const t=ne(this,vo).filter(n=>n.state.isPaused);return qn.batch(()=>t.reduce((n,r)=>n.then(()=>r.continue().catch(bo)),Promise.resolve()))}).then(()=>{Le(this,$a,void 0)})),ne(this,$a)}},vo=new WeakMap,jd=new WeakMap,$a=new WeakMap,rO);function d8(e){return{onFetch:(t,n)=>{const r=async()=>{var v,b,x,w,_;const o=t.options,i=(x=(b=(v=t.fetchOptions)==null?void 0:v.meta)==null?void 0:b.fetchMore)==null?void 0:x.direction,s=((w=t.state.data)==null?void 0:w.pages)||[],a=((_=t.state.data)==null?void 0:_.pageParams)||[],l={pages:[],pageParams:[]};let c=!1;const u=S=>{Object.defineProperty(S,"signal",{enumerable:!0,get:()=>(t.signal.aborted?c=!0:t.signal.addEventListener("abort",()=>{c=!0}),t.signal)})},f=t.options.queryFn||(()=>Promise.reject(new Error(`Missing queryFn: '${t.options.queryHash}'`))),p=async(S,R,E)=>{if(c)return Promise.reject();if(R==null&&S.pages.length)return Promise.resolve(S);const O={queryKey:t.queryKey,pageParam:R,direction:E?"backward":"forward",meta:t.options.meta};u(O);const A=await f(O),{maxPages:k}=t.options,$=E?t8:e8;return{pages:$(S.pages,A,k),pageParams:$(S.pageParams,R,k)}};let g;if(i&&s.length){const S=i==="backward",R=S?f8:WC,E={pages:s,pageParams:a},O=R(o,E);g=await p(E,O,S)}else{g=await p(l,a[0]??o.initialPageParam);const S=e??s.length;for(let R=1;R<S;R++){const E=WC(o,g);g=await p(g,E)}}return g};t.options.persister?t.fetchFn=()=>{var o,i;return(i=(o=t.options).persister)==null?void 0:i.call(o,r,{queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=r}}}function WC(e,{pages:t,pageParams:n}){const r=t.length-1;return e.getNextPageParam(t[r],t,n[r],n)}function f8(e,{pages:t,pageParams:n}){var r;return(r=e.getPreviousPageParam)==null?void 0:r.call(e,t[0],t,n[0],n)}var Tn,xs,ws,oc,ic,_s,sc,ac,oO,h8=(oO=class{constructor(e={}){We(this,Tn,void 0);We(this,xs,void 0);We(this,ws,void 0);We(this,oc,void 0);We(this,ic,void 0);We(this,_s,void 0);We(this,sc,void 0);We(this,ac,void 0);Le(this,Tn,e.queryCache||new AO),Le(this,xs,e.mutationCache||new u8),Le(this,ws,e.defaultOptions||{}),Le(this,oc,new Map),Le(this,ic,new Map),Le(this,_s,0)}mount(){dh(this,_s)._++,ne(this,_s)===1&&(Le(this,sc,Ap.subscribe(()=>{Ap.isFocused()&&(this.resumePausedMutations(),ne(this,Tn).onFocus())})),Le(this,ac,Ip.subscribe(()=>{Ip.isOnline()&&(this.resumePausedMutations(),ne(this,Tn).onOnline())})))}unmount(){var e,t;dh(this,_s)._--,ne(this,_s)===0&&((e=ne(this,sc))==null||e.call(this),Le(this,sc,void 0),(t=ne(this,ac))==null||t.call(this),Le(this,ac,void 0))}isFetching(e){return ne(this,Tn).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return ne(this,xs).findAll({...e,status:"pending"}).length}getQueryData(e){var t;return(t=ne(this,Tn).find({queryKey:e}))==null?void 0:t.state.data}ensureQueryData(e){const t=this.getQueryData(e.queryKey);return t!==void 0?Promise.resolve(t):this.fetchQuery(e)}getQueriesData(e){return this.getQueryCache().findAll(e).map(({queryKey:t,state:n})=>{const r=n.data;return[t,r]})}setQueryData(e,t,n){const r=ne(this,Tn).find({queryKey:e}),o=r==null?void 0:r.state.data,i=J9(t,o);if(typeof i>"u")return;const s=this.defaultQueryOptions({queryKey:e});return ne(this,Tn).build(this,s).setData(i,{...n,manual:!0})}setQueriesData(e,t,n){return qn.batch(()=>this.getQueryCache().findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,n)]))}getQueryState(e){var t;return(t=ne(this,Tn).find({queryKey:e}))==null?void 0:t.state}removeQueries(e){const t=ne(this,Tn);qn.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=ne(this,Tn),r={type:"active",...e};return qn.batch(()=>(n.findAll(e).forEach(o=>{o.reset()}),this.refetchQueries(r,t)))}cancelQueries(e={},t={}){const n={revert:!0,...t},r=qn.batch(()=>ne(this,Tn).findAll(e).map(o=>o.cancel(n)));return Promise.all(r).then(bo).catch(bo)}invalidateQueries(e={},t={}){return qn.batch(()=>{if(ne(this,Tn).findAll(e).forEach(r=>{r.invalidate()}),e.refetchType==="none")return Promise.resolve();const n={...e,type:e.refetchType??e.type??"active"};return this.refetchQueries(n,t)})}refetchQueries(e={},t){const n={...t,cancelRefetch:(t==null?void 0:t.cancelRefetch)??!0},r=qn.batch(()=>ne(this,Tn).findAll(e).filter(o=>!o.isDisabled()).map(o=>{let i=o.fetch(void 0,n);return n.throwOnError||(i=i.catch(bo)),o.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(r).then(bo)}fetchQuery(e){const t=this.defaultQueryOptions(e);typeof t.retry>"u"&&(t.retry=!1);const n=ne(this,Tn).build(this,t);return n.isStaleByTime(t.staleTime)?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(bo).catch(bo)}fetchInfiniteQuery(e){return e.behavior=d8(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(bo).catch(bo)}resumePausedMutations(){return ne(this,xs).resumePausedMutations()}getQueryCache(){return ne(this,Tn)}getMutationCache(){return ne(this,xs)}getDefaultOptions(){return ne(this,ws)}setDefaultOptions(e){Le(this,ws,e)}setQueryDefaults(e,t){ne(this,oc).set(ed(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...ne(this,oc).values()];let n={};return t.forEach(r=>{td(e,r.queryKey)&&(n={...n,...r.defaultOptions})}),n}setMutationDefaults(e,t){ne(this,ic).set(ed(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...ne(this,ic).values()];let n={};return t.forEach(r=>{td(e,r.mutationKey)&&(n={...n,...r.defaultOptions})}),n}defaultQueryOptions(e){if(e!=null&&e._defaulted)return e;const t={...ne(this,ws).queries,...(e==null?void 0:e.queryKey)&&this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=mx(t.queryKey,t)),typeof t.refetchOnReconnect>"u"&&(t.refetchOnReconnect=t.networkMode!=="always"),typeof t.throwOnError>"u"&&(t.throwOnError=!!t.suspense),typeof t.networkMode>"u"&&t.persister&&(t.networkMode="offlineFirst"),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...ne(this,ws).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){ne(this,Tn).clear(),ne(this,xs).clear()}},Tn=new WeakMap,xs=new WeakMap,ws=new WeakMap,oc=new WeakMap,ic=new WeakMap,_s=new WeakMap,sc=new WeakMap,ac=new WeakMap,oO),Sr,rn,Bd,cr,Da,lc,Xo,Vd,cc,uc,Ta,ka,Ss,dc,Ma,Cu,Hd,M0,Wd,A0,Ud,I0,qd,N0,Gd,L0,Yd,F0,Kd,z0,mg,IO,iO,p8=(iO=class extends Jd{constructor(t,n){super();We(this,Ma);We(this,Hd);We(this,Wd);We(this,Ud);We(this,qd);We(this,Gd);We(this,Yd);We(this,Kd);We(this,mg);We(this,Sr,void 0);We(this,rn,void 0);We(this,Bd,void 0);We(this,cr,void 0);We(this,Da,void 0);We(this,lc,void 0);We(this,Xo,void 0);We(this,Vd,void 0);We(this,cc,void 0);We(this,uc,void 0);We(this,Ta,void 0);We(this,ka,void 0);We(this,Ss,void 0);We(this,dc,new Set);this.options=n,Le(this,Sr,t),Le(this,Xo,null),this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(ne(this,rn).addObserver(this),UC(ne(this,rn),this.options)?bt(this,Ma,Cu).call(this):this.updateResult(),bt(this,qd,N0).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return j0(ne(this,rn),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return j0(ne(this,rn),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,bt(this,Gd,L0).call(this),bt(this,Yd,F0).call(this),ne(this,rn).removeObserver(this)}setOptions(t,n){const r=this.options,o=ne(this,rn);if(this.options=ne(this,Sr).defaultQueryOptions(t),D0(r,this.options)||ne(this,Sr).getQueryCache().notify({type:"observerOptionsUpdated",query:ne(this,rn),observer:this}),typeof this.options.enabled<"u"&&typeof this.options.enabled!="boolean")throw new Error("Expected enabled to be a boolean");this.options.queryKey||(this.options.queryKey=r.queryKey),bt(this,Kd,z0).call(this);const i=this.hasListeners();i&&qC(ne(this,rn),o,this.options,r)&&bt(this,Ma,Cu).call(this),this.updateResult(n),i&&(ne(this,rn)!==o||this.options.enabled!==r.enabled||this.options.staleTime!==r.staleTime)&&bt(this,Hd,M0).call(this);const s=bt(this,Wd,A0).call(this);i&&(ne(this,rn)!==o||this.options.enabled!==r.enabled||s!==ne(this,Ss))&&bt(this,Ud,I0).call(this,s)}getOptimisticResult(t){const n=ne(this,Sr).getQueryCache().build(ne(this,Sr),t),r=this.createResult(n,t);return m8(this,r)&&(Le(this,cr,r),Le(this,lc,this.options),Le(this,Da,ne(this,rn).state)),r}getCurrentResult(){return ne(this,cr)}trackResult(t){const n={};return Object.keys(t).forEach(r=>{Object.defineProperty(n,r,{configurable:!1,enumerable:!0,get:()=>(ne(this,dc).add(r),t[r])})}),n}getCurrentQuery(){return ne(this,rn)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const n=ne(this,Sr).defaultQueryOptions(t),r=ne(this,Sr).getQueryCache().build(ne(this,Sr),n);return r.isFetchingOptimistic=!0,r.fetch().then(()=>this.createResult(r,n))}fetch(t){return bt(this,Ma,Cu).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),ne(this,cr)))}createResult(t,n){var O;const r=ne(this,rn),o=this.options,i=ne(this,cr),s=ne(this,Da),a=ne(this,lc),c=t!==r?t.state:ne(this,Bd),{state:u}=t;let{error:f,errorUpdatedAt:p,fetchStatus:g,status:v}=u,b=!1,x;if(n._optimisticResults){const A=this.hasListeners(),k=!A&&UC(t,n),$=A&&qC(t,r,n,o);(k||$)&&(g=_g(t.options.networkMode)?"fetching":"paused",u.dataUpdatedAt||(v="pending")),n._optimisticResults==="isRestoring"&&(g="idle")}if(n.select&&typeof u.data<"u")if(i&&u.data===(s==null?void 0:s.data)&&n.select===ne(this,Vd))x=ne(this,cc);else try{Le(this,Vd,n.select),x=n.select(u.data),x=k0(i==null?void 0:i.data,x,n),Le(this,cc,x),Le(this,Xo,null)}catch(A){Le(this,Xo,A)}else x=u.data;if(typeof n.placeholderData<"u"&&typeof x>"u"&&v==="pending"){let A;if(i!=null&&i.isPlaceholderData&&n.placeholderData===(a==null?void 0:a.placeholderData))A=i.data;else if(A=typeof n.placeholderData=="function"?n.placeholderData((O=ne(this,uc))==null?void 0:O.state.data,ne(this,uc)):n.placeholderData,n.select&&typeof A<"u")try{A=n.select(A),Le(this,Xo,null)}catch(k){Le(this,Xo,k)}typeof A<"u"&&(v="success",x=k0(i==null?void 0:i.data,A,n),b=!0)}ne(this,Xo)&&(f=ne(this,Xo),x=ne(this,cc),p=Date.now(),v="error");const w=g==="fetching",_=v==="pending",S=v==="error",R=_&&w;return{status:v,fetchStatus:g,isPending:_,isSuccess:v==="success",isError:S,isInitialLoading:R,isLoading:R,data:x,dataUpdatedAt:u.dataUpdatedAt,error:f,errorUpdatedAt:p,failureCount:u.fetchFailureCount,failureReason:u.fetchFailureReason,errorUpdateCount:u.errorUpdateCount,isFetched:u.dataUpdateCount>0||u.errorUpdateCount>0,isFetchedAfterMount:u.dataUpdateCount>c.dataUpdateCount||u.errorUpdateCount>c.errorUpdateCount,isFetching:w,isRefetching:w&&!_,isLoadingError:S&&u.dataUpdatedAt===0,isPaused:g==="paused",isPlaceholderData:b,isRefetchError:S&&u.dataUpdatedAt!==0,isStale:vx(t,n),refetch:this.refetch}}updateResult(t){const n=ne(this,cr),r=this.createResult(ne(this,rn),this.options);if(Le(this,Da,ne(this,rn).state),Le(this,lc,this.options),ne(this,Da).data!==void 0&&Le(this,uc,ne(this,rn)),D0(r,n))return;Le(this,cr,r);const o={},i=()=>{if(!n)return!0;const{notifyOnChangeProps:s}=this.options,a=typeof s=="function"?s():s;if(a==="all"||!a&&!ne(this,dc).size)return!0;const l=new Set(a??ne(this,dc));return this.options.throwOnError&&l.add("error"),Object.keys(ne(this,cr)).some(c=>{const u=c;return ne(this,cr)[u]!==n[u]&&l.has(u)})};(t==null?void 0:t.listeners)!==!1&&i()&&(o.listeners=!0),bt(this,mg,IO).call(this,{...o,...t})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&bt(this,qd,N0).call(this)}},Sr=new WeakMap,rn=new WeakMap,Bd=new WeakMap,cr=new WeakMap,Da=new WeakMap,lc=new WeakMap,Xo=new WeakMap,Vd=new WeakMap,cc=new WeakMap,uc=new WeakMap,Ta=new WeakMap,ka=new WeakMap,Ss=new WeakMap,dc=new WeakMap,Ma=new WeakSet,Cu=function(t){bt(this,Kd,z0).call(this);let n=ne(this,rn).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(bo)),n},Hd=new WeakSet,M0=function(){if(bt(this,Gd,L0).call(this),gc||ne(this,cr).isStale||!$0(this.options.staleTime))return;const n=$O(ne(this,cr).dataUpdatedAt,this.options.staleTime)+1;Le(this,Ta,setTimeout(()=>{ne(this,cr).isStale||this.updateResult()},n))},Wd=new WeakSet,A0=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(ne(this,rn)):this.options.refetchInterval)??!1},Ud=new WeakSet,I0=function(t){bt(this,Yd,F0).call(this),Le(this,Ss,t),!(gc||this.options.enabled===!1||!$0(ne(this,Ss))||ne(this,Ss)===0)&&Le(this,ka,setInterval(()=>{(this.options.refetchIntervalInBackground||Ap.isFocused())&&bt(this,Ma,Cu).call(this)},ne(this,Ss)))},qd=new WeakSet,N0=function(){bt(this,Hd,M0).call(this),bt(this,Ud,I0).call(this,bt(this,Wd,A0).call(this))},Gd=new WeakSet,L0=function(){ne(this,Ta)&&(clearTimeout(ne(this,Ta)),Le(this,Ta,void 0))},Yd=new WeakSet,F0=function(){ne(this,ka)&&(clearInterval(ne(this,ka)),Le(this,ka,void 0))},Kd=new WeakSet,z0=function(){const t=ne(this,Sr).getQueryCache().build(ne(this,Sr),this.options);if(t===ne(this,rn))return;const n=ne(this,rn);Le(this,rn,t),Le(this,Bd,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},mg=new WeakSet,IO=function(t){qn.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(ne(this,cr))}),ne(this,Sr).getQueryCache().notify({query:ne(this,rn),type:"observerResultsUpdated"})})},iO);function g8(e,t){return t.enabled!==!1&&!e.state.dataUpdatedAt&&!(e.state.status==="error"&&t.retryOnMount===!1)}function UC(e,t){return g8(e,t)||e.state.dataUpdatedAt>0&&j0(e,t,t.refetchOnMount)}function j0(e,t,n){if(t.enabled!==!1){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&vx(e,t)}return!1}function qC(e,t,n,r){return n.enabled!==!1&&(e!==t||r.enabled===!1)&&(!n.suspense||e.state.status!=="error")&&vx(e,n)}function vx(e,t){return e.isStaleByTime(t.staleTime)}function m8(e,t){return!D0(e.getCurrentResult(),t)}var NO=pe.createContext(void 0),LO=e=>{const t=pe.useContext(NO);if(e)return e;if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},v8=({client:e,children:t})=>(pe.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),pe.createElement(NO.Provider,{value:e},t)),FO=pe.createContext(!1),b8=()=>pe.useContext(FO);FO.Provider;function y8(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var x8=pe.createContext(y8()),w8=()=>pe.useContext(x8);function _8(e,t){return typeof e=="function"?e(...t):!!e}var S8=(e,t)=>{(e.suspense||e.throwOnError)&&(t.isReset()||(e.retryOnMount=!1))},C8=e=>{pe.useEffect(()=>{e.clearReset()},[e])},E8=({result:e,errorResetBoundary:t,throwOnError:n,query:r})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&_8(n,[e.error,r]),R8=e=>{e.suspense&&typeof e.staleTime!="number"&&(e.staleTime=1e3)},P8=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,O8=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function $8(e,t,n){if(process.env.NODE_ENV!=="production"&&(typeof e!="object"||Array.isArray(e)))throw new Error('Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object');const r=LO(n),o=b8(),i=w8(),s=r.defaultQueryOptions(e);s._optimisticResults=o?"isRestoring":"optimistic",R8(s),S8(s,i),C8(i);const[a]=pe.useState(()=>new t(r,s)),l=a.getOptimisticResult(s);if(pe.useSyncExternalStore(pe.useCallback(c=>{const u=o?()=>{}:a.subscribe(qn.batchCalls(c));return a.updateResult(),u},[a,o]),()=>a.getCurrentResult(),()=>a.getCurrentResult()),pe.useEffect(()=>{a.setOptions(s,{listeners:!1})},[s,a]),P8(s,l))throw O8(s,a,i);if(E8({result:l,errorResetBoundary:i,throwOnError:s.throwOnError,query:r.getQueryCache().get(s.queryHash)}))throw l.error;return s.notifyOnChangeProps?l:a.trackResult(l)}function Zd(e,t){return $8(e,p8,t)}const D8={theme:"system",setTheme:()=>null},zO=m.createContext(D8);function T8({children:e,defaultTheme:t="system",storageKey:n="vite-ui-theme",...r}){const[o,i]=m.useState(()=>localStorage.getItem(n)||t);m.useEffect(()=>{const a=window.document.documentElement;if(a.classList.remove("light","dark"),o==="system"){const l=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";a.classList.add(l);return}a.classList.add(o)},[o]);const s={theme:o,setTheme:a=>{localStorage.setItem(n,a),i(a)}};return P.jsx(zO.Provider,{...r,value:s,children:e})}const jO=()=>{const e=m.useContext(zO);if(e===void 0)throw new Error("useTheme must be used within a ThemeProvider");return e};async function k8(e){return await(await fetch("https://semaphor.cloud/api/v1/dashboard",{headers:{Authorization:`Bearer ${e}`}})).json()}function BO(e){return e==="system"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":e}function GC(e,t){const n=BO(e);return n==="dark"?Fi.merge({...t==null?void 0:t.default},{...t==null?void 0:t.dark}):t==null?void 0:t.default}function M8({authToken:e,customStyle:t,currentTheme:n,onSave:r,onEvent:o}){const{data:i,refetch:s,isLoading:a,isError:l}=Zd({queryKey:["dashboard",e==null?void 0:e.accessToken],queryFn:()=>k8(e==null?void 0:e.accessToken),enabled:!1}),{theme:c,setTheme:u}=jO(),f=De(A=>A.dashboard.globalStyle),{setDashboard:p,setSelectedSheetId:g,setStyle:v,setOnSaveFunction:b}=De(A=>A.actions);De(A=>A.actions.setCustomCards);const x=De(A=>A.actions.setFilterValues),w=De(A=>A.actions.setBookmarkKey),_=De(A=>A.actions.setAuthToken),S=De(A=>A.actions.setThemeStyle),R=De(A=>A.actions.setDashboardTheme),E=De(A=>A.actions.setOnEvent);m.useEffect(()=>{if(c){const A=BO(c);R(A)}},[c,R]),m.useEffect(()=>{n&&u(n)},[n,u]);function O(){const A=Fi.cloneDeep(P0),k=Fi.merge(A,f);if(t){const $=Fi.merge(k,t),I=GC(c,$);S(I),v($)}else{const $=GC(c,k);S($),v(P0)}}return m.useEffect(()=>{i&&i.dashboard&&O()},[c,t,f]),m.useEffect(()=>{var F;if(!i||!i.dashboard)return;const A=i.dashboard,k=_I(A.id),$=JSON.parse(localStorage.getItem(k)||"[]"),I=$.find(j=>j.default===!0);if(I)p(I.template),O(),w(I.name),I.filterValues&&x(I.filterValues);else{p(A),O();const j=$.find(K=>(K==null?void 0:K.name)==="Original");j?j.template=A:$.push({name:"Original",template:A,default:!1}),localStorage.setItem(k,JSON.stringify($))}g((F=A.sheets)==null?void 0:F[0].id)},[i,p,g,x,w]),m.useEffect(()=>{r&&b(r),o&&E(o)},[r,b,o,E]),m.useEffect(()=>{e&&e.accessToken&&(_(e),s())},[e,s,_]),{isLoading:a,isError:l}}function bx({className:e,...t}){return P.jsx("div",{className:Ee("animate-pulse rounded-md bg-muted",e),...t})}const yx=pe.forwardRef(({className:e,...t},n)=>P.jsx("div",{ref:n,className:Ee("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));yx.displayName="Card";const Sg=pe.forwardRef(({className:e,...t},n)=>P.jsx("div",{ref:n,className:Ee("flex flex-col space-y-1.5 p-6",e),...t}));Sg.displayName="CardHeader";const ef=pe.forwardRef(({className:e,...t},n)=>P.jsx("h3",{ref:n,className:Ee("text-2xl font-semibold leading-none tracking-tight",e),...t}));ef.displayName="CardTitle";const xx=pe.forwardRef(({className:e,...t},n)=>P.jsx("p",{ref:n,className:Ee("text-sm text-muted-foreground",e),...t}));xx.displayName="CardDescription";const Cg=pe.forwardRef(({className:e,...t},n)=>P.jsx("div",{ref:n,className:Ee("px-6 pt-0",e),...t}));Cg.displayName="CardContent";const wx=pe.forwardRef(({className:e,...t},n)=>P.jsx("div",{ref:n,className:Ee("flex items-center p-6 pt-0",e),...t}));wx.displayName="CardFooter";function VO({className:e,customStyle:t,onSave:n,onEvent:r,LoadingComponent:o,ErrorComponent:i,onChartElementClicked:s,id:a,authToken:l,currentTheme:c,version:u,customCards:f,...p}){De(w=>w.selectedSheetId);const g=De(w=>w.themeStyle),v=De(w=>w.isSessionExpired),{isLoading:b,isError:x}=M8({authToken:l,customStyle:t,currentTheme:c,onSave:n,onEvent:r});return b||!l?(r==null||r({type:"info",message:"Loading dashboard"}),o?P.jsx(o,{message:"loading"}):P.jsx("div",{className:"flex items-center gap-3",children:P.jsx(bx,{className:"h-1 w-full dark:h-[2px]"})})):x?(r==null||r({type:"error",message:"Error fetching dashboard"}),i?(console.log("Error fetching dashboard"),P.jsx(i,{})):P.jsx("div",{children:"Error"})):v?(r==null||r({type:"error",message:"Session Expired"}),P.jsx("div",{className:"flex h-full items-center justify-center",children:P.jsxs("div",{className:"space-y-4 rounded-md border border-muted p-10",children:[P.jsx(ef,{children:"Session Expired"}),P.jsx("p",{className:"text-muted-foreground",children:"Please refresh your page to continue."})]})})):P.jsx("div",{className:Ee("flex h-full grow flex-col justify-between",g==null?void 0:g.dashboardPanel,e),role:"dashboard-panel",...p})}function le(){return le=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},le.apply(this,arguments)}function Re(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function Bn(e,t=[]){let n=[];function r(i,s){const a=m.createContext(s),l=n.length;n=[...n,s];function c(f){const{scope:p,children:g,...v}=f,b=(p==null?void 0:p[e][l])||a,x=m.useMemo(()=>v,Object.values(v));return m.createElement(b.Provider,{value:x},g)}function u(f,p){const g=(p==null?void 0:p[e][l])||a,v=m.useContext(g);if(v)return v;if(s!==void 0)return s;throw new Error(`\`${f}\` must be used within \`${i}\``)}return c.displayName=i+"Provider",[c,u]}const o=()=>{const i=n.map(s=>m.createContext(s));return function(a){const l=(a==null?void 0:a[e])||i;return m.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return o.scopeName=e,[r,A8(o,...t)]}function A8(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(i){const s=r.reduce((a,{useScope:l,scopeName:c})=>{const f=l(i)[`__scope${c}`];return{...a,...f}},{});return m.useMemo(()=>({[`__scope${t.scopeName}`]:s}),[s])}};return n.scopeName=t.scopeName,n}function I8(e,t){typeof e=="function"?e(t):e!=null&&(e.current=t)}function Eg(...e){return t=>e.forEach(n=>I8(n,t))}function lt(...e){return m.useCallback(Eg(...e),e)}const ji=m.forwardRef((e,t)=>{const{children:n,...r}=e,o=m.Children.toArray(n),i=o.find(N8);if(i){const s=i.props.children,a=o.map(l=>l===i?m.Children.count(s)>1?m.Children.only(null):m.isValidElement(s)?s.props.children:null:l);return m.createElement(B0,le({},r,{ref:t}),m.isValidElement(s)?m.cloneElement(s,void 0,a):null)}return m.createElement(B0,le({},r,{ref:t}),n)});ji.displayName="Slot";const B0=m.forwardRef((e,t)=>{const{children:n,...r}=e;return m.isValidElement(n)?m.cloneElement(n,{...L8(r,n.props),ref:t?Eg(t,n.ref):n.ref}):m.Children.count(n)>1?m.Children.only(null):null});B0.displayName="SlotClone";const HO=({children:e})=>m.createElement(m.Fragment,null,e);function N8(e){return m.isValidElement(e)&&e.type===HO}function L8(e,t){const n={...t};for(const r in t){const o=e[r],i=t[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...a)=>{i(...a),o(...a)}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...e,...n}}function Rg(e){const t=e+"CollectionProvider",[n,r]=Bn(t),[o,i]=n(t,{collectionRef:{current:null},itemMap:new Map}),s=g=>{const{scope:v,children:b}=g,x=m.useRef(null),w=m.useRef(new Map).current;return m.createElement(o,{scope:v,itemMap:w,collectionRef:x},b)},a=e+"CollectionSlot",l=m.forwardRef((g,v)=>{const{scope:b,children:x}=g,w=i(a,b),_=lt(v,w.collectionRef);return m.createElement(ji,{ref:_},x)}),c=e+"CollectionItemSlot",u="data-radix-collection-item",f=m.forwardRef((g,v)=>{const{scope:b,children:x,...w}=g,_=m.useRef(null),S=lt(v,_),R=i(c,b);return m.useEffect(()=>(R.itemMap.set(_,{ref:_,...w}),()=>void R.itemMap.delete(_))),m.createElement(ji,{[u]:"",ref:S},x)});function p(g){const v=i(e+"CollectionConsumer",g);return m.useCallback(()=>{const x=v.collectionRef.current;if(!x)return[];const w=Array.from(x.querySelectorAll(`[${u}]`));return Array.from(v.itemMap.values()).sort((R,E)=>w.indexOf(R.ref.current)-w.indexOf(E.ref.current))},[v.collectionRef,v.itemMap])}return[{Provider:s,Slot:l,ItemSlot:f},p,r]}const tr=globalThis!=null&&globalThis.document?m.useLayoutEffect:()=>{},F8=pe.useId||(()=>{});let z8=0;function $r(e){const[t,n]=pe.useState(F8());return tr(()=>{e||n(r=>r??String(z8++))},[e]),e||(t?`radix-${t}`:"")}const j8=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],Ue=j8.reduce((e,t)=>{const n=m.forwardRef((r,o)=>{const{asChild:i,...s}=r,a=i?ji:t;return m.useEffect(()=>{window[Symbol.for("radix-ui")]=!0},[]),m.createElement(a,le({},s,{ref:o}))});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{});function WO(e,t){e&&Fo.flushSync(()=>e.dispatchEvent(t))}function Mn(e){const t=m.useRef(e);return m.useEffect(()=>{t.current=e}),m.useMemo(()=>(...n)=>{var r;return(r=t.current)===null||r===void 0?void 0:r.call(t,...n)},[])}function nr({prop:e,defaultProp:t,onChange:n=()=>{}}){const[r,o]=B8({defaultProp:t,onChange:n}),i=e!==void 0,s=i?e:r,a=Mn(n),l=m.useCallback(c=>{if(i){const f=typeof c=="function"?c(e):c;f!==e&&a(f)}else o(c)},[i,e,o,a]);return[s,l]}function B8({defaultProp:e,onChange:t}){const n=m.useState(e),[r]=n,o=m.useRef(r),i=Mn(t);return m.useEffect(()=>{o.current!==r&&(i(r),o.current=r)},[r,o,i]),n}const V8=m.createContext(void 0);function Qa(e){const t=m.useContext(V8);return e||t||"ltr"}const Gv="rovingFocusGroup.onEntryFocus",H8={bubbles:!1,cancelable:!0},_x="RovingFocusGroup",[V0,UO,W8]=Rg(_x),[U8,Dc]=Bn(_x,[W8]),[q8,G8]=U8(_x),Y8=m.forwardRef((e,t)=>m.createElement(V0.Provider,{scope:e.__scopeRovingFocusGroup},m.createElement(V0.Slot,{scope:e.__scopeRovingFocusGroup},m.createElement(K8,le({},e,{ref:t}))))),K8=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:i,currentTabStopId:s,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:c,...u}=e,f=m.useRef(null),p=lt(t,f),g=Qa(i),[v=null,b]=nr({prop:s,defaultProp:a,onChange:l}),[x,w]=m.useState(!1),_=Mn(c),S=UO(n),R=m.useRef(!1),[E,O]=m.useState(0);return m.useEffect(()=>{const A=f.current;if(A)return A.addEventListener(Gv,_),()=>A.removeEventListener(Gv,_)},[_]),m.createElement(q8,{scope:n,orientation:r,dir:g,loop:o,currentTabStopId:v,onItemFocus:m.useCallback(A=>b(A),[b]),onItemShiftTab:m.useCallback(()=>w(!0),[]),onFocusableItemAdd:m.useCallback(()=>O(A=>A+1),[]),onFocusableItemRemove:m.useCallback(()=>O(A=>A-1),[])},m.createElement(Ue.div,le({tabIndex:x||E===0?-1:0,"data-orientation":r},u,{ref:p,style:{outline:"none",...e.style},onMouseDown:Re(e.onMouseDown,()=>{R.current=!0}),onFocus:Re(e.onFocus,A=>{const k=!R.current;if(A.target===A.currentTarget&&k&&!x){const $=new CustomEvent(Gv,H8);if(A.currentTarget.dispatchEvent($),!$.defaultPrevented){const I=S().filter(B=>B.focusable),F=I.find(B=>B.active),j=I.find(B=>B.id===v),U=[F,j,...I].filter(Boolean).map(B=>B.ref.current);qO(U)}}R.current=!1}),onBlur:Re(e.onBlur,()=>w(!1))})))}),X8="RovingFocusGroupItem",Q8=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:i,...s}=e,a=$r(),l=i||a,c=G8(X8,n),u=c.currentTabStopId===l,f=UO(n),{onFocusableItemAdd:p,onFocusableItemRemove:g}=c;return m.useEffect(()=>{if(r)return p(),()=>g()},[r,p,g]),m.createElement(V0.ItemSlot,{scope:n,id:l,focusable:r,active:o},m.createElement(Ue.span,le({tabIndex:u?0:-1,"data-orientation":c.orientation},s,{ref:t,onMouseDown:Re(e.onMouseDown,v=>{r?c.onItemFocus(l):v.preventDefault()}),onFocus:Re(e.onFocus,()=>c.onItemFocus(l)),onKeyDown:Re(e.onKeyDown,v=>{if(v.key==="Tab"&&v.shiftKey){c.onItemShiftTab();return}if(v.target!==v.currentTarget)return;const b=ez(v,c.orientation,c.dir);if(b!==void 0){v.preventDefault();let w=f().filter(_=>_.focusable).map(_=>_.ref.current);if(b==="last")w.reverse();else if(b==="prev"||b==="next"){b==="prev"&&w.reverse();const _=w.indexOf(v.currentTarget);w=c.loop?tz(w,_+1):w.slice(_+1)}setTimeout(()=>qO(w))}})})))}),J8={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Z8(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function ez(e,t,n){const r=Z8(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return J8[r]}function qO(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function tz(e,t){return e.map((n,r)=>e[(t+r)%e.length])}const Sx=Y8,Cx=Q8;function nz(e,t){return m.useReducer((n,r)=>{const o=t[n][r];return o??n},e)}const Rn=e=>{const{present:t,children:n}=e,r=rz(t),o=typeof n=="function"?n({present:r.isPresent}):m.Children.only(n),i=lt(r.ref,o.ref);return typeof n=="function"||r.isPresent?m.cloneElement(o,{ref:i}):null};Rn.displayName="Presence";function rz(e){const[t,n]=m.useState(),r=m.useRef({}),o=m.useRef(e),i=m.useRef("none"),s=e?"mounted":"unmounted",[a,l]=nz(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return m.useEffect(()=>{const c=gh(r.current);i.current=a==="mounted"?c:"none"},[a]),tr(()=>{const c=r.current,u=o.current;if(u!==e){const p=i.current,g=gh(c);e?l("MOUNT"):g==="none"||(c==null?void 0:c.display)==="none"?l("UNMOUNT"):l(u&&p!==g?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,l]),tr(()=>{if(t){const c=f=>{const g=gh(r.current).includes(f.animationName);f.target===t&&g&&Fo.flushSync(()=>l("ANIMATION_END"))},u=f=>{f.target===t&&(i.current=gh(r.current))};return t.addEventListener("animationstart",u),t.addEventListener("animationcancel",c),t.addEventListener("animationend",c),()=>{t.removeEventListener("animationstart",u),t.removeEventListener("animationcancel",c),t.removeEventListener("animationend",c)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:m.useCallback(c=>{c&&(r.current=getComputedStyle(c)),n(c)},[])}}function gh(e){return(e==null?void 0:e.animationName)||"none"}const GO="Tabs",[oz,jpe]=Bn(GO,[Dc]),YO=Dc(),[iz,Ex]=oz(GO),sz=m.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,onValueChange:o,defaultValue:i,orientation:s="horizontal",dir:a,activationMode:l="automatic",...c}=e,u=Qa(a),[f,p]=nr({prop:r,onChange:o,defaultProp:i});return m.createElement(iz,{scope:n,baseId:$r(),value:f,onValueChange:p,orientation:s,dir:u,activationMode:l},m.createElement(Ue.div,le({dir:u,"data-orientation":s},c,{ref:t})))}),az="TabsList",lz=m.forwardRef((e,t)=>{const{__scopeTabs:n,loop:r=!0,...o}=e,i=Ex(az,n),s=YO(n);return m.createElement(Sx,le({asChild:!0},s,{orientation:i.orientation,dir:i.dir,loop:r}),m.createElement(Ue.div,le({role:"tablist","aria-orientation":i.orientation},o,{ref:t})))}),cz="TabsTrigger",uz=m.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,disabled:o=!1,...i}=e,s=Ex(cz,n),a=YO(n),l=KO(s.baseId,r),c=XO(s.baseId,r),u=r===s.value;return m.createElement(Cx,le({asChild:!0},a,{focusable:!o,active:u}),m.createElement(Ue.button,le({type:"button",role:"tab","aria-selected":u,"aria-controls":c,"data-state":u?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:l},i,{ref:t,onMouseDown:Re(e.onMouseDown,f=>{!o&&f.button===0&&f.ctrlKey===!1?s.onValueChange(r):f.preventDefault()}),onKeyDown:Re(e.onKeyDown,f=>{[" ","Enter"].includes(f.key)&&s.onValueChange(r)}),onFocus:Re(e.onFocus,()=>{const f=s.activationMode!=="manual";!u&&!o&&f&&s.onValueChange(r)})})))}),dz="TabsContent",fz=m.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,forceMount:o,children:i,...s}=e,a=Ex(dz,n),l=KO(a.baseId,r),c=XO(a.baseId,r),u=r===a.value,f=m.useRef(u);return m.useEffect(()=>{const p=requestAnimationFrame(()=>f.current=!1);return()=>cancelAnimationFrame(p)},[]),m.createElement(Rn,{present:o||u},({present:p})=>m.createElement(Ue.div,le({"data-state":u?"active":"inactive","data-orientation":a.orientation,role:"tabpanel","aria-labelledby":l,hidden:!p,id:c,tabIndex:0},s,{ref:t,style:{...e.style,animationDuration:f.current?"0s":void 0}}),p&&i))});function KO(e,t){return`${e}-trigger-${t}`}function XO(e,t){return`${e}-content-${t}`}const hz=sz,QO=lz,JO=uz,ZO=fz,e$=hz,t$=pe.forwardRef(({className:e,...t},n)=>P.jsx(QO,{ref:n,className:Ee("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",e),...t}));t$.displayName=QO.displayName;const n$=pe.forwardRef(({className:e,...t},n)=>P.jsx(JO,{ref:n,className:Ee("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",e),...t}));n$.displayName=JO.displayName;const Rx=pe.forwardRef(({className:e,...t},n)=>P.jsx(ZO,{ref:n,className:Ee("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",e),...t}));Rx.displayName=ZO.displayName;var r$={exports:{}},tf={},H0={exports:{}};(function(e,t){(function(n,r){r(t)})(ms,function(n){function r(oe){return function(ie,be,G,me,_e,Pe,$e){return oe(ie,be,$e)}}function o(oe){return function(ie,be,G,me){if(!ie||!be||typeof ie!="object"||typeof be!="object")return oe(ie,be,G,me);var _e=me.get(ie),Pe=me.get(be);if(_e&&Pe)return _e===be&&Pe===ie;me.set(ie,be),me.set(be,ie);var $e=oe(ie,be,G,me);return me.delete(ie),me.delete(be),$e}}function i(oe,ee){var ie={};for(var be in oe)ie[be]=oe[be];for(var be in ee)ie[be]=ee[be];return ie}function s(oe){return oe.constructor===Object||oe.constructor==null}function a(oe){return typeof oe.then=="function"}function l(oe,ee){return oe===ee||oe!==oe&&ee!==ee}var c="[object Arguments]",u="[object Boolean]",f="[object Date]",p="[object RegExp]",g="[object Map]",v="[object Number]",b="[object Object]",x="[object Set]",w="[object String]",_=Object.prototype.toString;function S(oe){var ee=oe.areArraysEqual,ie=oe.areDatesEqual,be=oe.areMapsEqual,G=oe.areObjectsEqual,me=oe.areRegExpsEqual,_e=oe.areSetsEqual,Pe=oe.createIsNestedEqual,$e=Pe(Ve);function Ve(Fe,ke,Ge){if(Fe===ke)return!0;if(!Fe||!ke||typeof Fe!="object"||typeof ke!="object")return Fe!==Fe&&ke!==ke;if(s(Fe)&&s(ke))return G(Fe,ke,$e,Ge);var ct=Array.isArray(Fe),kt=Array.isArray(ke);if(ct||kt)return ct===kt&&ee(Fe,ke,$e,Ge);var Dt=_.call(Fe);return Dt!==_.call(ke)?!1:Dt===f?ie(Fe,ke,$e,Ge):Dt===p?me(Fe,ke,$e,Ge):Dt===g?be(Fe,ke,$e,Ge):Dt===x?_e(Fe,ke,$e,Ge):Dt===b||Dt===c?a(Fe)||a(ke)?!1:G(Fe,ke,$e,Ge):Dt===u||Dt===v||Dt===w?l(Fe.valueOf(),ke.valueOf()):!1}return Ve}function R(oe,ee,ie,be){var G=oe.length;if(ee.length!==G)return!1;for(;G-- >0;)if(!ie(oe[G],ee[G],G,G,oe,ee,be))return!1;return!0}var E=o(R);function O(oe,ee){return l(oe.valueOf(),ee.valueOf())}function A(oe,ee,ie,be){var G=oe.size===ee.size;if(!G)return!1;if(!oe.size)return!0;var me={},_e=0;return oe.forEach(function(Pe,$e){if(G){var Ve=!1,Fe=0;ee.forEach(function(ke,Ge){!Ve&&!me[Fe]&&(Ve=ie($e,Ge,_e,Fe,oe,ee,be)&&ie(Pe,ke,$e,Ge,oe,ee,be))&&(me[Fe]=!0),Fe++}),_e++,G=Ve}}),G}var k=o(A),$="_owner",I=Object.prototype.hasOwnProperty;function F(oe,ee,ie,be){var G=Object.keys(oe),me=G.length;if(Object.keys(ee).length!==me)return!1;for(var _e;me-- >0;){if(_e=G[me],_e===$){var Pe=!!oe.$$typeof,$e=!!ee.$$typeof;if((Pe||$e)&&Pe!==$e)return!1}if(!I.call(ee,_e)||!ie(oe[_e],ee[_e],_e,_e,oe,ee,be))return!1}return!0}var j=o(F);function K(oe,ee){return oe.source===ee.source&&oe.flags===ee.flags}function U(oe,ee,ie,be){var G=oe.size===ee.size;if(!G)return!1;if(!oe.size)return!0;var me={};return oe.forEach(function(_e,Pe){if(G){var $e=!1,Ve=0;ee.forEach(function(Fe,ke){!$e&&!me[Ve]&&($e=ie(_e,Fe,Pe,ke,oe,ee,be))&&(me[Ve]=!0),Ve++}),G=$e}}),G}var B=o(U),X=Object.freeze({areArraysEqual:R,areDatesEqual:O,areMapsEqual:A,areObjectsEqual:F,areRegExpsEqual:K,areSetsEqual:U,createIsNestedEqual:r}),H=Object.freeze({areArraysEqual:E,areDatesEqual:O,areMapsEqual:k,areObjectsEqual:j,areRegExpsEqual:K,areSetsEqual:B,createIsNestedEqual:r}),q=S(X);function Z(oe,ee){return q(oe,ee,void 0)}var T=S(i(X,{createIsNestedEqual:function(){return l}}));function V(oe,ee){return T(oe,ee,void 0)}var Q=S(H);function N(oe,ee){return Q(oe,ee,new WeakMap)}var se=S(i(H,{createIsNestedEqual:function(){return l}}));function ae(oe,ee){return se(oe,ee,new WeakMap)}function ue(oe){return S(i(X,oe(X)))}function fe(oe){var ee=S(i(H,oe(H)));return function(ie,be,G){return G===void 0&&(G=new WeakMap),ee(ie,be,G)}}n.circularDeepEqual=N,n.circularShallowEqual=ae,n.createCustomCircularEqual=fe,n.createCustomEqual=ue,n.deepEqual=Z,n.sameValueZeroEqual=l,n.shallowEqual=V,Object.defineProperty(n,"__esModule",{value:!0})})})(H0,H0.exports);var Px=H0.exports;const Ox=lx(I6);var wt={},pz=function(t,n,r){return t===n?!0:t.className===n.className&&r(t.style,n.style)&&t.width===n.width&&t.autoSize===n.autoSize&&t.cols===n.cols&&t.draggableCancel===n.draggableCancel&&t.draggableHandle===n.draggableHandle&&r(t.verticalCompact,n.verticalCompact)&&r(t.compactType,n.compactType)&&r(t.layout,n.layout)&&r(t.margin,n.margin)&&r(t.containerPadding,n.containerPadding)&&t.rowHeight===n.rowHeight&&t.maxRows===n.maxRows&&t.isBounded===n.isBounded&&t.isDraggable===n.isDraggable&&t.isResizable===n.isResizable&&t.allowOverlap===n.allowOverlap&&t.preventCollision===n.preventCollision&&t.useCSSTransforms===n.useCSSTransforms&&t.transformScale===n.transformScale&&t.isDroppable===n.isDroppable&&r(t.resizeHandles,n.resizeHandles)&&r(t.resizeHandle,n.resizeHandle)&&t.onLayoutChange===n.onLayoutChange&&t.onDragStart===n.onDragStart&&t.onDrag===n.onDrag&&t.onDragStop===n.onDragStop&&t.onResizeStart===n.onResizeStart&&t.onResize===n.onResize&&t.onResizeStop===n.onResizeStop&&t.onDrop===n.onDrop&&r(t.droppingItem,n.droppingItem)&&r(t.innerRef,n.innerRef)};Object.defineProperty(wt,"__esModule",{value:!0});wt.bottom=$x;wt.childrenEqual=bz;wt.cloneLayout=o$;wt.cloneLayoutItem=Aa;wt.collides=Pg;wt.compact=s$;wt.compactItem=a$;wt.compactType=kz;wt.correctBounds=l$;wt.fastPositionEqual=xz;wt.fastRGLPropsEqual=void 0;wt.getAllCollisions=c$;wt.getFirstCollision=_a;wt.getLayoutItem=Dx;wt.getStatics=Tx;wt.modifyLayout=i$;wt.moveElement=Ru;wt.moveElementAwayFromCollision=U0;wt.noop=void 0;wt.perc=_z;wt.resizeItemInDirection=Oz;wt.setTopLeft=Dz;wt.setTransform=$z;wt.sortLayoutItems=Lx;wt.sortLayoutItemsByColRow=p$;wt.sortLayoutItemsByRowCol=h$;wt.synchronizeLayoutWithChildren=Tz;wt.validateLayout=g$;wt.withLayoutItem=vz;var YC=Px,Eu=gz(m);function gz(e){return e&&e.__esModule?e:{default:e}}const mz=process.env.NODE_ENV==="production";function $x(e){let t=0,n;for(let r=0,o=e.length;r<o;r++)n=e[r].y+e[r].h,n>t&&(t=n);return t}function o$(e){const t=Array(e.length);for(let n=0,r=e.length;n<r;n++)t[n]=Aa(e[n]);return t}function i$(e,t){const n=Array(e.length);for(let r=0,o=e.length;r<o;r++)t.i===e[r].i?n[r]=t:n[r]=e[r];return n}function vz(e,t,n){let r=Dx(e,t);return r?(r=n(Aa(r)),e=i$(e,r),[e,r]):[e,null]}function Aa(e){return{w:e.w,h:e.h,x:e.x,y:e.y,i:e.i,minW:e.minW,maxW:e.maxW,minH:e.minH,maxH:e.maxH,moved:!!e.moved,static:!!e.static,isDraggable:e.isDraggable,isResizable:e.isResizable,resizeHandles:e.resizeHandles,isBounded:e.isBounded}}function bz(e,t){return(0,YC.deepEqual)(Eu.default.Children.map(e,n=>n==null?void 0:n.key),Eu.default.Children.map(t,n=>n==null?void 0:n.key))&&(0,YC.deepEqual)(Eu.default.Children.map(e,n=>n==null?void 0:n.props["data-grid"]),Eu.default.Children.map(t,n=>n==null?void 0:n.props["data-grid"]))}const yz=pz;wt.fastRGLPropsEqual=yz;function xz(e,t){return e.left===t.left&&e.top===t.top&&e.width===t.width&&e.height===t.height}function Pg(e,t){return!(e.i===t.i||e.x+e.w<=t.x||e.x>=t.x+t.w||e.y+e.h<=t.y||e.y>=t.y+t.h)}function s$(e,t,n,r){const o=Tx(e),i=Lx(e,t),s=Array(e.length);for(let a=0,l=i.length;a<l;a++){let c=Aa(i[a]);c.static||(c=a$(o,c,t,n,i,r),o.push(c)),s[e.indexOf(i[a])]=c,c.moved=!1}return s}const wz={x:"w",y:"h"};function W0(e,t,n,r){const o=wz[r];t[r]+=1;const i=e.map(s=>s.i).indexOf(t.i);for(let s=i+1;s<e.length;s++){const a=e[s];if(!a.static){if(a.y>t.y+t.h)break;Pg(t,a)&&W0(e,a,n+t[o],r)}}t[r]=n}function a$(e,t,n,r,o,i){const s=n==="vertical",a=n==="horizontal";if(s)for(t.y=Math.min($x(e),t.y);t.y>0&&!_a(e,t);)t.y--;else if(a)for(;t.x>0&&!_a(e,t);)t.x--;let l;for(;(l=_a(e,t))&&!(n===null&&i);)if(a?W0(o,t,l.x+l.w,"x"):W0(o,t,l.y+l.h,"y"),a&&t.x+t.w>r)for(t.x=r-t.w,t.y++;t.x>0&&!_a(e,t);)t.x--;return t.y=Math.max(t.y,0),t.x=Math.max(t.x,0),t}function l$(e,t){const n=Tx(e);for(let r=0,o=e.length;r<o;r++){const i=e[r];if(i.x+i.w>t.cols&&(i.x=t.cols-i.w),i.x<0&&(i.x=0,i.w=t.cols),!i.static)n.push(i);else for(;_a(n,i);)i.y++}return e}function Dx(e,t){for(let n=0,r=e.length;n<r;n++)if(e[n].i===t)return e[n]}function _a(e,t){for(let n=0,r=e.length;n<r;n++)if(Pg(e[n],t))return e[n]}function c$(e,t){return e.filter(n=>Pg(n,t))}function Tx(e){return e.filter(t=>t.static)}function Ru(e,t,n,r,o,i,s,a,l){if(t.static&&t.isDraggable!==!0||t.y===r&&t.x===n)return e;"Moving element ".concat(t.i," to [").concat(String(n),",").concat(String(r),"] from [").concat(t.x,",").concat(t.y,"]");const c=t.x,u=t.y;typeof n=="number"&&(t.x=n),typeof r=="number"&&(t.y=r),t.moved=!0;let f=Lx(e,s);(s==="vertical"&&typeof r=="number"?u>=r:s==="horizontal"&&typeof n=="number"?c>=n:!1)&&(f=f.reverse());const g=c$(f,t),v=g.length>0;if(v&&l)return o$(e);if(v&&i)return"Collision prevented on ".concat(t.i,", reverting."),t.x=c,t.y=u,t.moved=!1,e;for(let b=0,x=g.length;b<x;b++){const w=g[b];"Resolving collision between ".concat(t.i," at [").concat(t.x,",").concat(t.y,"] and ").concat(w.i," at [").concat(w.x,",").concat(w.y,"]"),!w.moved&&(w.static?e=U0(e,w,t,o,s):e=U0(e,t,w,o,s))}return e}function U0(e,t,n,r,o,i){const s=o==="horizontal",a=o==="vertical",l=t.static;if(r){r=!1;const f={x:s?Math.max(t.x-n.w,0):n.x,y:a?Math.max(t.y-n.h,0):n.y,w:n.w,h:n.h,i:"-1"},p=_a(e,f),g=p&&p.y+p.h>t.y,v=p&&t.x+t.w>p.x;if(p){if(g&&a)return Ru(e,n,void 0,t.y+1,r,l,o);if(g&&o==null)return t.y=n.y,n.y=n.y+n.h,e;if(v&&s)return Ru(e,t,n.x,void 0,r,l,o)}else return"Doing reverse collision on ".concat(n.i," up to [").concat(f.x,",").concat(f.y,"]."),Ru(e,n,s?f.x:void 0,a?f.y:void 0,r,l,o)}const c=s?n.x+1:void 0,u=a?n.y+1:void 0;return c==null&&u==null?e:Ru(e,n,s?n.x+1:void 0,a?n.y+1:void 0,r,l,o)}function _z(e){return e*100+"%"}const u$=(e,t,n,r)=>e+n>r?t:n,d$=(e,t,n)=>e<0?t:n,f$=e=>Math.max(0,e),kx=e=>Math.max(0,e),Mx=(e,t,n)=>{let{left:r,height:o,width:i}=t;const s=e.top-(o-e.height);return{left:r,width:i,height:d$(s,e.height,o),top:kx(s)}},Ax=(e,t,n)=>{let{top:r,left:o,height:i,width:s}=t;return{top:r,height:i,width:u$(e.left,e.width,s,n),left:f$(o)}},Ix=(e,t,n)=>{let{top:r,height:o,width:i}=t;const s=e.left-(i-e.width);return{height:o,width:s<0?e.width:u$(e.left,e.width,i,n),top:kx(r),left:f$(s)}},Nx=(e,t,n)=>{let{top:r,left:o,height:i,width:s}=t;return{width:s,left:o,height:d$(r,e.height,i),top:kx(r)}},Sz=function(){return Mx(arguments.length<=0?void 0:arguments[0],Ax(...arguments))},Cz=function(){return Mx(arguments.length<=0?void 0:arguments[0],Ix(...arguments))},Ez=function(){return Nx(arguments.length<=0?void 0:arguments[0],Ax(...arguments))},Rz=function(){return Nx(arguments.length<=0?void 0:arguments[0],Ix(...arguments))},Pz={n:Mx,ne:Sz,e:Ax,se:Ez,s:Nx,sw:Rz,w:Ix,nw:Cz};function Oz(e,t,n,r){const o=Pz[e];return o?o(t,{...t,...n},r):n}function $z(e){let{top:t,left:n,width:r,height:o}=e;const i="translate(".concat(n,"px,").concat(t,"px)");return{transform:i,WebkitTransform:i,MozTransform:i,msTransform:i,OTransform:i,width:"".concat(r,"px"),height:"".concat(o,"px"),position:"absolute"}}function Dz(e){let{top:t,left:n,width:r,height:o}=e;return{top:"".concat(t,"px"),left:"".concat(n,"px"),width:"".concat(r,"px"),height:"".concat(o,"px"),position:"absolute"}}function Lx(e,t){return t==="horizontal"?p$(e):t==="vertical"?h$(e):e}function h$(e){return e.slice(0).sort(function(t,n){return t.y>n.y||t.y===n.y&&t.x>n.x?1:t.y===n.y&&t.x===n.x?0:-1})}function p$(e){return e.slice(0).sort(function(t,n){return t.x>n.x||t.x===n.x&&t.y>n.y?1:-1})}function Tz(e,t,n,r,o){e=e||[];const i=[];Eu.default.Children.forEach(t,a=>{if((a==null?void 0:a.key)==null)return;const l=Dx(e,String(a.key)),c=a.props["data-grid"];l&&c==null?i.push(Aa(l)):c?(mz||g$([c],"ReactGridLayout.children"),i.push(Aa({...c,i:a.key}))):i.push(Aa({w:1,h:1,x:0,y:$x(i),i:String(a.key)}))});const s=l$(i,{cols:n});return o?s:s$(s,r,n)}function g$(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"Layout";const n=["x","y","w","h"];if(!Array.isArray(e))throw new Error(t+" must be an array!");for(let r=0,o=e.length;r<o;r++){const i=e[r];for(let s=0;s<n.length;s++)if(typeof i[n[s]]!="number")throw new Error("ReactGridLayout: "+t+"["+r+"]."+n[s]+" must be a number!")}}function kz(e){const{verticalCompact:t,compactType:n}=e||{};return t===!1?null:n}const Mz=()=>{};wt.noop=Mz;var li={};Object.defineProperty(li,"__esModule",{value:!0});li.calcGridColWidth=Og;li.calcGridItemPosition=Az;li.calcGridItemWHPx=q0;li.calcWH=Nz;li.calcXY=Iz;li.clamp=Sa;function Og(e){const{margin:t,containerPadding:n,containerWidth:r,cols:o}=e;return(r-t[0]*(o-1)-n[0]*2)/o}function q0(e,t,n){return Number.isFinite(e)?Math.round(t*e+Math.max(0,e-1)*n):e}function Az(e,t,n,r,o,i){const{margin:s,containerPadding:a,rowHeight:l}=e,c=Og(e),u={};return i&&i.resizing?(u.width=Math.round(i.resizing.width),u.height=Math.round(i.resizing.height)):(u.width=q0(r,c,s[0]),u.height=q0(o,l,s[1])),i&&i.dragging?(u.top=Math.round(i.dragging.top),u.left=Math.round(i.dragging.left)):i&&i.resizing&&typeof i.resizing.top=="number"&&typeof i.resizing.left=="number"?(u.top=Math.round(i.resizing.top),u.left=Math.round(i.resizing.left)):(u.top=Math.round((l+s[1])*n+a[1]),u.left=Math.round((c+s[0])*t+a[0])),u}function Iz(e,t,n,r,o){const{margin:i,cols:s,rowHeight:a,maxRows:l}=e,c=Og(e);let u=Math.round((n-i[0])/(c+i[0])),f=Math.round((t-i[1])/(a+i[1]));return u=Sa(u,0,s-r),f=Sa(f,0,l-o),{x:u,y:f}}function Nz(e,t,n,r,o,i){const{margin:s,maxRows:a,cols:l,rowHeight:c}=e,u=Og(e);let f=Math.round((t+s[0])/(u+s[0])),p=Math.round((n+s[1])/(c+s[1])),g=Sa(f,0,l-r),v=Sa(p,0,a-o);return["sw","w","nw"].indexOf(i)!==-1&&(g=Sa(f,0,l)),["nw","n","ne"].indexOf(i)!==-1&&(v=Sa(p,0,a)),{w:g,h:v}}function Sa(e,t,n){return Math.max(Math.min(e,n),t)}var $g={},G0={exports:{}},Yv,KC;function Fx(){if(KC)return Yv;KC=1;var e="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return Yv=e,Yv}var Kv,XC;function Lz(){if(XC)return Kv;XC=1;var e=Fx();function t(){}function n(){}return n.resetWarningCache=t,Kv=function(){function r(s,a,l,c,u,f){if(f!==e){var p=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw p.name="Invariant Violation",p}}r.isRequired=r;function o(){return r}var i={array:r,bigint:r,bool:r,func:r,number:r,object:r,string:r,symbol:r,any:r,arrayOf:o,element:r,elementType:r,instanceOf:o,node:r,objectOf:o,oneOf:o,oneOfType:o,shape:o,exact:o,checkPropTypes:n,resetWarningCache:t};return i.PropTypes=i,i},Kv}var mh={exports:{}},Ft={};/** @license React v16.13.1
89
89
  * react-is.development.js
90
90
  *
91
91
  * Copyright (c) Facebook, Inc. and its affiliates.
@@ -8506,7 +8506,7 @@ const Ne = sR()(
8506
8506
  selectedCard: null,
8507
8507
  showFilters: !1,
8508
8508
  //This should be false by default
8509
- isDashboardEditing: !0,
8509
+ isDashboardEditing: !1,
8510
8510
  // This should be false by defaultdashboard.
8511
8511
  isVisualEditing: !1,
8512
8512
  // This should be false by defaultdashboard.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../chunks/index-4uv99fdq.js");require("react");require("react-dom");exports.Dashboard=e.Dashboard;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../chunks/index-WpPvkxrt.js");require("react");require("react-dom");exports.Dashboard=e.Dashboard;
@@ -1,4 +1,4 @@
1
- import { D as p } from "../chunks/index-XM_hhHm4.js";
1
+ import { D as p } from "../chunks/index-zzQRnCNa.js";
2
2
  import "react";
3
3
  import "react-dom";
4
4
  export {
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./chunks/index-4uv99fdq.js"),d=require("./chunks/dashboard-plus-n4IK-8PG.js"),I=require("react");require("react-dom");function N({card:t,footer:u,className:m,...c}){const{customCards:r}=e.useSemaphorContext(),h=I.useRef(null),{isError:p,isLoading:n,isFetching:i,cfg:x,visualKey:C,handleDatapointClick:f}=e.useDashboardCard(t),a=e.useDashboardStore(s=>s.themeStyle),l=e.useDashboardStore(s=>s.selectedSheetId),E=e.useDashboardStore(s=>s.selectedCardId),j=e.useDashboardStore(s=>s.isDashboardEditing),{setCardTitle:g,setCardDescription:D,setSelectedCardId:b}=e.useDashboardActions();function S(s){s.stopPropagation(),b(l,t.id)}function T(){if(r&&r.length>0){const s=r.find(o=>o.cardId===t.id);if(s&&s.replaceDefault){const o=s.content;if(o)return e.jsxRuntimeExports.jsx(o,{card:t})}}return t.type==="kpi"?t.data&&t.data.length>0&&e.jsxRuntimeExports.jsx(e.KPICard,{isLoading:n||i,card:t}):y}function R(){if(p)return e.jsxRuntimeExports.jsx("p",{className:"text-sm",children:"Oops! It seems like something went wrong. Please review your connection or filters."});if(t.type==="table"&&t.data&&t.data.length>0)return e.jsxRuntimeExports.jsxs(e.ScrollArea,{children:[e.jsxRuntimeExports.jsx(e.TableVisual,{card:t,data:t.data}),e.jsxRuntimeExports.jsx(e.ScrollBar,{orientation:"horizontal"})]});if(r&&r.length>0){const s=r.find(o=>o.cardId===t.id);if(s&&s.content){const o=s.content;return e.jsxRuntimeExports.jsx(o,{card:t})}}if(x)return e.jsxRuntimeExports.jsx(e.ChartJsVisual,{cfg:x,onDatapointClick:f},C)}function A(){if(r&&r.length>0){const s=r.find(o=>o.cardId===t.id);if(s&&s.footer){const o=s.footer;if(o)return e.jsxRuntimeExports.jsx(o,{card:t})}}return u||null}if(!t.id)return null;const y=e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs(e.CardHeader,{className:"pb-4",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Editable,{text:t.title,onSave:s=>g(l,t.id,s),children:e.jsxRuntimeExports.jsx(e.CardTitle,{className:"text-base",children:t.title})}),t.refreshInterval&&e.jsxRuntimeExports.jsxs(e.Tooltip,{children:[e.jsxRuntimeExports.jsx(e.TooltipTrigger,{className:"pr-1",children:e.jsxRuntimeExports.jsx("div",{className:e.cn("h-2 w-2 rounded-full bg-green-500 transition-opacity",{"opacity-10":n||i})})}),e.jsxRuntimeExports.jsx(e.TooltipContent,{side:"right",align:"center",children:e.jsxRuntimeExports.jsx("p",{className:"text-xs",children:`Realtime (${t==null?void 0:t.refreshInterval})`})})]}),!t.refreshInterval&&(n||i)&&e.jsxRuntimeExports.jsx(e.LoaderCircle,{className:"h-4 w-4 animate-spin text-muted-foreground"})]}),e.jsxRuntimeExports.jsx(e.Editable,{text:(t==null?void 0:t.description)||"",onSave:s=>D(l,t.id,s),children:e.jsxRuntimeExports.jsxs(e.CardDescription,{children:[" ",t.description]})})]}),e.jsxRuntimeExports.jsx(e.CardContent,{className:"relative flex grow flex-col overflow-auto pb-0",children:R()}),e.jsxRuntimeExports.jsx(e.CardFooter,{children:A()})]});return e.jsxRuntimeExports.jsx(e.Card,{tabIndex:-1,ref:h,role:"dashboard-card",onClick:S,className:e.cn("relative flex h-full flex-col rounded-sm",{"border-dashed border-foreground/50":E===t.id&&j},a==null?void 0:a.dashboardCard,m),...c,children:T()})}exports.BOOLEAN_DATA_TYPES=e.BOOLEAN_DATA_TYPES;exports.DATE_DATA_TYPES=e.DATE_DATA_TYPES;exports.Dashboard=e.Dashboard;exports.DashboardWC=e.DashboardWC;exports.NUMBER_DATA_TYPES=e.NUMBER_DATA_TYPES;exports.SemaphorQueryClient=e.SemaphorQueryClient;exports.TEXT_DATA_TYPES=e.TEXT_DATA_TYPES;exports.cleanCard=e.cleanCard;exports.createSqlGenConfig=e.createSqlGenConfig;exports.fmt=e.fmt;exports.getBookmarkKey=e.getBookmarkKey;exports.getColumnDataType=e.getColumnDataType;exports.getDashbaordStateWithoutData=e.getDashbaordStateWithoutData;exports.getFilterValueType=e.getFilterValueType;exports.getQualifiedTableName=e.getQualifiedTableName;exports.getSql=e.getSql;exports.isColumnInSqlGen=e.isColumnInSqlGen;exports.resolveDataType=e.resolveDataType;exports.useCard=e.useCard;exports.useDashboardActions=e.useDashboardActions;exports.useDashboardStore=e.useDashboardStore;exports.useEditorActions=e.useEditorActions;exports.useEditorStore=e.useEditorStore;exports.SelectComponent=d.SelectComponent;exports.Surfboard=d.DashboardPlus;exports.useEditorAside=d.useEditorAside;exports.DashboardCard=N;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./chunks/index-WpPvkxrt.js"),d=require("./chunks/dashboard-plus-aAmpwfpf.js"),I=require("react");require("react-dom");function N({card:t,footer:u,className:m,...c}){const{customCards:r}=e.useSemaphorContext(),h=I.useRef(null),{isError:p,isLoading:n,isFetching:i,cfg:x,visualKey:C,handleDatapointClick:f}=e.useDashboardCard(t),a=e.useDashboardStore(s=>s.themeStyle),l=e.useDashboardStore(s=>s.selectedSheetId),E=e.useDashboardStore(s=>s.selectedCardId),j=e.useDashboardStore(s=>s.isDashboardEditing),{setCardTitle:g,setCardDescription:D,setSelectedCardId:b}=e.useDashboardActions();function S(s){s.stopPropagation(),b(l,t.id)}function T(){if(r&&r.length>0){const s=r.find(o=>o.cardId===t.id);if(s&&s.replaceDefault){const o=s.content;if(o)return e.jsxRuntimeExports.jsx(o,{card:t})}}return t.type==="kpi"?t.data&&t.data.length>0&&e.jsxRuntimeExports.jsx(e.KPICard,{isLoading:n||i,card:t}):y}function R(){if(p)return e.jsxRuntimeExports.jsx("p",{className:"text-sm",children:"Oops! It seems like something went wrong. Please review your connection or filters."});if(t.type==="table"&&t.data&&t.data.length>0)return e.jsxRuntimeExports.jsxs(e.ScrollArea,{children:[e.jsxRuntimeExports.jsx(e.TableVisual,{card:t,data:t.data}),e.jsxRuntimeExports.jsx(e.ScrollBar,{orientation:"horizontal"})]});if(r&&r.length>0){const s=r.find(o=>o.cardId===t.id);if(s&&s.content){const o=s.content;return e.jsxRuntimeExports.jsx(o,{card:t})}}if(x)return e.jsxRuntimeExports.jsx(e.ChartJsVisual,{cfg:x,onDatapointClick:f},C)}function A(){if(r&&r.length>0){const s=r.find(o=>o.cardId===t.id);if(s&&s.footer){const o=s.footer;if(o)return e.jsxRuntimeExports.jsx(o,{card:t})}}return u||null}if(!t.id)return null;const y=e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs(e.CardHeader,{className:"pb-4",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Editable,{text:t.title,onSave:s=>g(l,t.id,s),children:e.jsxRuntimeExports.jsx(e.CardTitle,{className:"text-base",children:t.title})}),t.refreshInterval&&e.jsxRuntimeExports.jsxs(e.Tooltip,{children:[e.jsxRuntimeExports.jsx(e.TooltipTrigger,{className:"pr-1",children:e.jsxRuntimeExports.jsx("div",{className:e.cn("h-2 w-2 rounded-full bg-green-500 transition-opacity",{"opacity-10":n||i})})}),e.jsxRuntimeExports.jsx(e.TooltipContent,{side:"right",align:"center",children:e.jsxRuntimeExports.jsx("p",{className:"text-xs",children:`Realtime (${t==null?void 0:t.refreshInterval})`})})]}),!t.refreshInterval&&(n||i)&&e.jsxRuntimeExports.jsx(e.LoaderCircle,{className:"h-4 w-4 animate-spin text-muted-foreground"})]}),e.jsxRuntimeExports.jsx(e.Editable,{text:(t==null?void 0:t.description)||"",onSave:s=>D(l,t.id,s),children:e.jsxRuntimeExports.jsxs(e.CardDescription,{children:[" ",t.description]})})]}),e.jsxRuntimeExports.jsx(e.CardContent,{className:"relative flex grow flex-col overflow-auto pb-0",children:R()}),e.jsxRuntimeExports.jsx(e.CardFooter,{children:A()})]});return e.jsxRuntimeExports.jsx(e.Card,{tabIndex:-1,ref:h,role:"dashboard-card",onClick:S,className:e.cn("relative flex h-full flex-col rounded-sm",{"border-dashed border-foreground/50":E===t.id&&j},a==null?void 0:a.dashboardCard,m),...c,children:T()})}exports.BOOLEAN_DATA_TYPES=e.BOOLEAN_DATA_TYPES;exports.DATE_DATA_TYPES=e.DATE_DATA_TYPES;exports.Dashboard=e.Dashboard;exports.DashboardWC=e.DashboardWC;exports.NUMBER_DATA_TYPES=e.NUMBER_DATA_TYPES;exports.SemaphorQueryClient=e.SemaphorQueryClient;exports.TEXT_DATA_TYPES=e.TEXT_DATA_TYPES;exports.cleanCard=e.cleanCard;exports.createSqlGenConfig=e.createSqlGenConfig;exports.fmt=e.fmt;exports.getBookmarkKey=e.getBookmarkKey;exports.getColumnDataType=e.getColumnDataType;exports.getDashbaordStateWithoutData=e.getDashbaordStateWithoutData;exports.getFilterValueType=e.getFilterValueType;exports.getQualifiedTableName=e.getQualifiedTableName;exports.getSql=e.getSql;exports.isColumnInSqlGen=e.isColumnInSqlGen;exports.resolveDataType=e.resolveDataType;exports.useCard=e.useCard;exports.useDashboardActions=e.useDashboardActions;exports.useDashboardStore=e.useDashboardStore;exports.useEditorActions=e.useEditorActions;exports.useEditorStore=e.useEditorStore;exports.SelectComponent=d.SelectComponent;exports.Surfboard=d.DashboardPlus;exports.useEditorAside=d.useEditorAside;exports.DashboardCard=N;
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
- import { u as _, a as k, b as n, c as w, j as s, C as F, E as f, d as P, T as R, e as B, f as h, g as L, L as q, h as K, i as O, k as Y, l as G, K as V, S as z, m as H, n as J, o as M } from "./chunks/index-XM_hhHm4.js";
2
- import { B as se, s as te, D as ae, q as oe, N as ne, I as re, r as ie, M as le, w as de, t as ue, O as ce, y as fe, J as he, x as Ce, A as xe, v as me, z as pe, F as ge, p as je, H as De, G as be } from "./chunks/index-XM_hhHm4.js";
3
- import { S as Te, D as Ee, u as Ie } from "./chunks/dashboard-plus-oYj43ewZ.js";
1
+ import { u as _, a as k, b as n, c as w, j as s, C as F, E as f, d as P, T as R, e as B, f as h, g as L, L as q, h as K, i as O, k as Y, l as G, K as V, S as z, m as H, n as J, o as M } from "./chunks/index-zzQRnCNa.js";
2
+ import { B as se, s as te, D as ae, q as oe, N as ne, I as re, r as ie, M as le, w as de, t as ue, O as ce, y as fe, J as he, x as Ce, A as xe, v as me, z as pe, F as ge, p as je, H as De, G as be } from "./chunks/index-zzQRnCNa.js";
3
+ import { S as Te, D as Ee, u as Ie } from "./chunks/dashboard-plus-ZO8Dy4tB.js";
4
4
  import Q from "react";
5
5
  import "react-dom";
6
6
  function $({
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../chunks/dashboard-plus-n4IK-8PG.js");require("../chunks/index-4uv99fdq.js");require("react");require("react-dom");exports.Surfboard=r.DashboardPlus;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../chunks/dashboard-plus-aAmpwfpf.js");require("../chunks/index-WpPvkxrt.js");require("react");require("react-dom");exports.Surfboard=r.DashboardPlus;
@@ -1,5 +1,5 @@
1
- import { D as i } from "../chunks/dashboard-plus-oYj43ewZ.js";
2
- import "../chunks/index-XM_hhHm4.js";
1
+ import { D as i } from "../chunks/dashboard-plus-ZO8Dy4tB.js";
2
+ import "../chunks/index-zzQRnCNa.js";
3
3
  import "react";
4
4
  import "react-dom";
5
5
  export {
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "email": "support@semaphor.cloud"
6
6
  },
7
7
  "license": "MIT",
8
- "version": "0.0.184",
8
+ "version": "0.0.186",
9
9
  "description": "Fully interactive and customizable dashboards for your apps.",
10
10
  "keywords": [
11
11
  "react",