@dataramen/cli 0.0.74 → 0.0.75-beta.2

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 +0,0 @@
1
- import{r as l,a as ei,S as Cr,p as Ao,b as Te,s as os,c as Cn,n as rs,i as zs,d as Oo,t as ti,e as Kn,f as ni,g as si,h as Po,j as ds,k as Mo,l as oi,m as ri,o as Io,q as ai,u as s,v as Zs,w as Q,x as $,A as hs,y as ii,z as li,B as P,C as Sn,D as fe,E as Se,F as ci,G as ui,R as Ze,H as di,I as hi}from"./index-B6sZXGsY.js";var Do="popstate";function mi(e={}){function t(o,r){let{pathname:a,search:i,hash:c}=o.location;return qs("",{pathname:a,search:i,hash:c},r.state&&r.state.usr||null,r.state&&r.state.key||"default")}function n(o,r){return typeof r=="string"?r:jn(r)}return pi(t,n,null,e)}function H(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function Ee(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function fi(){return Math.random().toString(36).substring(2,10)}function $o(e,t){return{usr:e.state,key:e.key,idx:t}}function qs(e,t,n=null,o){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?Jt(t):t,state:n,key:t&&t.key||o||fi()}}function jn({pathname:e="/",search:t="",hash:n=""}){return t&&t!=="?"&&(e+=t.charAt(0)==="?"?t:"?"+t),n&&n!=="#"&&(e+=n.charAt(0)==="#"?n:"#"+n),e}function Jt(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let o=e.indexOf("?");o>=0&&(t.search=e.substring(o),e=e.substring(0,o)),e&&(t.pathname=e)}return t}function pi(e,t,n,o={}){let{window:r=document.defaultView,v5Compat:a=!1}=o,i=r.history,c="POP",u=null,h=m();h==null&&(h=0,i.replaceState({...i.state,idx:h},""));function m(){return(i.state||{idx:null}).idx}function d(){c="POP";let v=m(),y=v==null?null:v-h;h=v,u&&u({action:c,location:x.location,delta:y})}function g(v,y){c="PUSH";let f=qs(x.location,v,y);h=m()+1;let w=$o(f,h),C=x.createHref(f);try{i.pushState(w,"",C)}catch(N){if(N instanceof DOMException&&N.name==="DataCloneError")throw N;r.location.assign(C)}a&&u&&u({action:c,location:x.location,delta:1})}function p(v,y){c="REPLACE";let f=qs(x.location,v,y);h=m();let w=$o(f,h),C=x.createHref(f);i.replaceState(w,"",C),a&&u&&u({action:c,location:x.location,delta:0})}function b(v){return gi(v)}let x={get action(){return c},get location(){return e(r,i)},listen(v){if(u)throw new Error("A history only accepts one active listener");return r.addEventListener(Do,d),u=v,()=>{r.removeEventListener(Do,d),u=null}},createHref(v){return t(r,v)},createURL:b,encodeLocation(v){let y=b(v);return{pathname:y.pathname,search:y.search,hash:y.hash}},push:g,replace:p,go(v){return i.go(v)}};return x}function gi(e,t=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),H(n,"No window.location.(origin|href) available to create URL");let o=typeof e=="string"?e:jn(e);return o=o.replace(/ $/,"%20"),!t&&o.startsWith("//")&&(o=n+o),new URL(o,n)}function jr(e,t,n="/"){return xi(e,t,n,!1)}function xi(e,t,n,o){let r=typeof t=="string"?Jt(t):t,a=Ke(r.pathname||"/",n);if(a==null)return null;let i=Nr(e);bi(i);let c=null;for(let u=0;c==null&&u<i.length;++u){let h=Ri(a);c=Si(i[u],h,o)}return c}function Nr(e,t=[],n=[],o="",r=!1){let a=(i,c,u=r,h)=>{let m={relativePath:h===void 0?i.path||"":h,caseSensitive:i.caseSensitive===!0,childrenIndex:c,route:i};if(m.relativePath.startsWith("/")){if(!m.relativePath.startsWith(o)&&u)return;H(m.relativePath.startsWith(o),`Absolute route path "${m.relativePath}" nested under path "${o}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),m.relativePath=m.relativePath.slice(o.length)}let d=Qe([o,m.relativePath]),g=n.concat(m);i.children&&i.children.length>0&&(H(i.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${d}".`),Nr(i.children,t,g,d,u)),!(i.path==null&&!i.index)&&t.push({path:d,score:_i(d,i.index),routesMeta:g})};return e.forEach((i,c)=>{if(i.path===""||!i.path?.includes("?"))a(i,c);else for(let u of _r(i.path))a(i,c,!0,u)}),t}function _r(e){let t=e.split("/");if(t.length===0)return[];let[n,...o]=t,r=n.endsWith("?"),a=n.replace(/\?$/,"");if(o.length===0)return r?[a,""]:[a];let i=_r(o.join("/")),c=[];return c.push(...i.map(u=>u===""?a:[a,u].join("/"))),r&&c.push(...i),c.map(u=>e.startsWith("/")&&u===""?"/":u)}function bi(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:ki(t.routesMeta.map(o=>o.childrenIndex),n.routesMeta.map(o=>o.childrenIndex)))}var vi=/^:[\w-]+$/,yi=3,wi=2,Ci=1,ji=10,Ni=-2,Fo=e=>e==="*";function _i(e,t){let n=e.split("/"),o=n.length;return n.some(Fo)&&(o+=Ni),t&&(o+=wi),n.filter(r=>!Fo(r)).reduce((r,a)=>r+(vi.test(a)?yi:a===""?Ci:ji),o)}function ki(e,t){return e.length===t.length&&e.slice(0,-1).every((o,r)=>o===t[r])?e[e.length-1]-t[t.length-1]:0}function Si(e,t,n=!1){let{routesMeta:o}=e,r={},a="/",i=[];for(let c=0;c<o.length;++c){let u=o[c],h=c===o.length-1,m=a==="/"?t:t.slice(a.length)||"/",d=Kt({path:u.relativePath,caseSensitive:u.caseSensitive,end:h},m),g=u.route;if(!d&&h&&n&&!o[o.length-1].route.index&&(d=Kt({path:u.relativePath,caseSensitive:u.caseSensitive,end:!1},m)),!d)return null;Object.assign(r,d.params),i.push({params:r,pathname:Qe([a,d.pathname]),pathnameBase:Oi(Qe([a,d.pathnameBase])),route:g}),d.pathnameBase!=="/"&&(a=Qe([a,d.pathnameBase]))}return i}function Kt(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[n,o]=Ei(e.path,e.caseSensitive,e.end),r=t.match(n);if(!r)return null;let a=r[0],i=a.replace(/(.)\/+$/,"$1"),c=r.slice(1);return{params:o.reduce((h,{paramName:m,isOptional:d},g)=>{if(m==="*"){let b=c[g]||"";i=a.slice(0,a.length-b.length).replace(/(.)\/+$/,"$1")}const p=c[g];return d&&!p?h[m]=void 0:h[m]=(p||"").replace(/%2F/g,"/"),h},{}),pathname:a,pathnameBase:i,pattern:e}}function Ei(e,t=!1,n=!0){Ee(e==="*"||!e.endsWith("*")||e.endsWith("/*"),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,"/*")}".`);let o=[],r="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(i,c,u)=>(o.push({paramName:c,isOptional:u!=null}),u?"/?([^\\/]+)?":"/([^\\/]+)")).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(o.push({paramName:"*"}),r+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?r+="\\/*$":e!==""&&e!=="/"&&(r+="(?:(?=\\/|$))"),[new RegExp(r,t?void 0:"i"),o]}function Ri(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return Ee(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function Ke(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,o=e.charAt(n);return o&&o!=="/"?null:e.slice(n)||"/"}var kr=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Li=e=>kr.test(e);function Ti(e,t="/"){let{pathname:n,search:o="",hash:r=""}=typeof e=="string"?Jt(e):e,a;if(n)if(Li(n))a=n;else{if(n.includes("//")){let i=n;n=n.replace(/\/\/+/g,"/"),Ee(!1,`Pathnames cannot have embedded double slashes - normalizing ${i} -> ${n}`)}n.startsWith("/")?a=Bo(n.substring(1),"/"):a=Bo(n,t)}else a=t;return{pathname:a,search:Pi(o),hash:Mi(r)}}function Bo(e,t){let n=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(r=>{r===".."?n.length>1&&n.pop():r!=="."&&n.push(r)}),n.length>1?n.join("/"):"/"}function Rs(e,t,n,o){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(o)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function Ai(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function Sr(e){let t=Ai(e);return t.map((n,o)=>o===t.length-1?n.pathname:n.pathnameBase)}function Er(e,t,n,o=!1){let r;typeof e=="string"?r=Jt(e):(r={...e},H(!r.pathname||!r.pathname.includes("?"),Rs("?","pathname","search",r)),H(!r.pathname||!r.pathname.includes("#"),Rs("#","pathname","hash",r)),H(!r.search||!r.search.includes("#"),Rs("#","search","hash",r)));let a=e===""||r.pathname==="",i=a?"/":r.pathname,c;if(i==null)c=n;else{let d=t.length-1;if(!o&&i.startsWith("..")){let g=i.split("/");for(;g[0]==="..";)g.shift(),d-=1;r.pathname=g.join("/")}c=d>=0?t[d]:"/"}let u=Ti(r,c),h=i&&i!=="/"&&i.endsWith("/"),m=(a||i===".")&&n.endsWith("/");return!u.pathname.endsWith("/")&&(h||m)&&(u.pathname+="/"),u}var Qe=e=>e.join("/").replace(/\/\/+/g,"/"),Oi=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),Pi=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,Mi=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,Ii=class{constructor(e,t,n,o=!1){this.status=e,this.statusText=t||"",this.internal=o,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function Di(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function $i(e){return e.map(t=>t.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var Rr=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Lr(e,t){let n=e;if(typeof n!="string"||!kr.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let o=n,r=!1;if(Rr)try{let a=new URL(window.location.href),i=n.startsWith("//")?new URL(a.protocol+n):new URL(n),c=Ke(i.pathname,t);i.origin===a.origin&&c!=null?n=c+i.search+i.hash:r=!0}catch{Ee(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:o,isExternal:r,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var Tr=["POST","PUT","PATCH","DELETE"];new Set(Tr);var Fi=["GET",...Tr];new Set(Fi);var Xt=l.createContext(null);Xt.displayName="DataRouter";var ms=l.createContext(null);ms.displayName="DataRouterState";var Bi=l.createContext(!1),Ar=l.createContext({isTransitioning:!1});Ar.displayName="ViewTransition";var Wi=l.createContext(new Map);Wi.displayName="Fetchers";var zi=l.createContext(null);zi.displayName="Await";var Re=l.createContext(null);Re.displayName="Navigation";var En=l.createContext(null);En.displayName="Location";var ze=l.createContext({outlet:null,matches:[],isDataRoute:!1});ze.displayName="Route";var eo=l.createContext(null);eo.displayName="RouteError";var Or="REACT_ROUTER_ERROR",qi="REDIRECT",Ui="ROUTE_ERROR_RESPONSE";function Hi(e){if(e.startsWith(`${Or}:${qi}:{`))try{let t=JSON.parse(e.slice(28));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.location=="string"&&typeof t.reloadDocument=="boolean"&&typeof t.replace=="boolean")return t}catch{}}function Vi(e){if(e.startsWith(`${Or}:${Ui}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string")return new Ii(t.status,t.statusText,t.data)}catch{}}function Qi(e,{relative:t}={}){H(Rn(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:o}=l.useContext(Re),{hash:r,pathname:a,search:i}=Ln(e,{relative:t}),c=a;return n!=="/"&&(c=a==="/"?n:Qe([n,a])),o.createHref({pathname:c,search:i,hash:r})}function Rn(){return l.useContext(En)!=null}function le(){return H(Rn(),"useLocation() may be used only in the context of a <Router> component."),l.useContext(En).location}var Pr="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Mr(e){l.useContext(Re).static||l.useLayoutEffect(e)}function Y(){let{isDataRoute:e}=l.useContext(ze);return e?il():Ki()}function Ki(){H(Rn(),"useNavigate() may be used only in the context of a <Router> component.");let e=l.useContext(Xt),{basename:t,navigator:n}=l.useContext(Re),{matches:o}=l.useContext(ze),{pathname:r}=le(),a=JSON.stringify(Sr(o)),i=l.useRef(!1);return Mr(()=>{i.current=!0}),l.useCallback((u,h={})=>{if(Ee(i.current,Pr),!i.current)return;if(typeof u=="number"){n.go(u);return}let m=Er(u,JSON.parse(a),r,h.relative==="path");e==null&&t!=="/"&&(m.pathname=m.pathname==="/"?t:Qe([t,m.pathname])),(h.replace?n.replace:n.push)(m,h.state,h)},[t,n,a,r,e])}l.createContext(null);function Gi(){let{matches:e}=l.useContext(ze),t=e[e.length-1];return t?t.params:{}}function Ln(e,{relative:t}={}){let{matches:n}=l.useContext(ze),{pathname:o}=le(),r=JSON.stringify(Sr(n));return l.useMemo(()=>Er(e,JSON.parse(r),o,t==="path"),[e,r,o,t])}function Yi(e,t){return Ir(e,t)}function Ir(e,t,n,o,r){H(Rn(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:a}=l.useContext(Re),{matches:i}=l.useContext(ze),c=i[i.length-1],u=c?c.params:{},h=c?c.pathname:"/",m=c?c.pathnameBase:"/",d=c&&c.route;{let f=d&&d.path||"";$r(h,!d||f.endsWith("*")||f.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${h}" (under <Route path="${f}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
2
-
3
- Please change the parent <Route path="${f}"> to <Route path="${f==="/"?"*":`${f}/*`}">.`)}let g=le(),p;if(t){let f=typeof t=="string"?Jt(t):t;H(m==="/"||f.pathname?.startsWith(m),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${m}" but pathname "${f.pathname}" was given in the \`location\` prop.`),p=f}else p=g;let b=p.pathname||"/",x=b;if(m!=="/"){let f=m.replace(/^\//,"").split("/");x="/"+b.replace(/^\//,"").split("/").slice(f.length).join("/")}let v=jr(e,{pathname:x});Ee(d||v!=null,`No routes matched location "${p.pathname}${p.search}${p.hash}" `),Ee(v==null||v[v.length-1].route.element!==void 0||v[v.length-1].route.Component!==void 0||v[v.length-1].route.lazy!==void 0,`Matched leaf route at location "${p.pathname}${p.search}${p.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let y=tl(v&&v.map(f=>Object.assign({},f,{params:Object.assign({},u,f.params),pathname:Qe([m,a.encodeLocation?a.encodeLocation(f.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:f.pathname]),pathnameBase:f.pathnameBase==="/"?m:Qe([m,a.encodeLocation?a.encodeLocation(f.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:f.pathnameBase])})),i,n,o,r);return t&&y?l.createElement(En.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...p},navigationType:"POP"}},y):y}function Ji(){let e=al(),t=Di(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,o="rgba(200,200,200, 0.5)",r={padding:"0.5rem",backgroundColor:o},a={padding:"2px 4px",backgroundColor:o},i=null;return console.error("Error handled by React Router default ErrorBoundary:",e),i=l.createElement(l.Fragment,null,l.createElement("p",null,"💿 Hey developer 👋"),l.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",l.createElement("code",{style:a},"ErrorBoundary")," or"," ",l.createElement("code",{style:a},"errorElement")," prop on your route.")),l.createElement(l.Fragment,null,l.createElement("h2",null,"Unexpected Application Error!"),l.createElement("h3",{style:{fontStyle:"italic"}},t),n?l.createElement("pre",{style:r},n):null,i)}var Xi=l.createElement(Ji,null),Dr=class extends l.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||t.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:t.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){this.props.onError?this.props.onError(e,t):console.error("React Router caught the following error during render",e)}render(){let e=this.state.error;if(this.context&&typeof e=="object"&&e&&"digest"in e&&typeof e.digest=="string"){const n=Vi(e.digest);n&&(e=n)}let t=e!==void 0?l.createElement(ze.Provider,{value:this.props.routeContext},l.createElement(eo.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?l.createElement(Zi,{error:e},t):t}};Dr.contextType=Bi;var Ls=new WeakMap;function Zi({children:e,error:t}){let{basename:n}=l.useContext(Re);if(typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){let o=Hi(t.digest);if(o){let r=Ls.get(t);if(r)throw r;let a=Lr(o.location,n);if(Rr&&!Ls.get(t))if(a.isExternal||o.reloadDocument)window.location.href=a.absoluteURL||a.to;else{const i=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(a.to,{replace:o.replace}));throw Ls.set(t,i),i}return l.createElement("meta",{httpEquiv:"refresh",content:`0;url=${a.absoluteURL||a.to}`})}}return e}function el({routeContext:e,match:t,children:n}){let o=l.useContext(Xt);return o&&o.static&&o.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(o.staticContext._deepestRenderedBoundaryId=t.route.id),l.createElement(ze.Provider,{value:e},n)}function tl(e,t=[],n=null,o=null,r=null){if(e==null){if(!n)return null;if(n.errors)e=n.matches;else if(t.length===0&&!n.initialized&&n.matches.length>0)e=n.matches;else return null}let a=e,i=n?.errors;if(i!=null){let m=a.findIndex(d=>d.route.id&&i?.[d.route.id]!==void 0);H(m>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(i).join(",")}`),a=a.slice(0,Math.min(a.length,m+1))}let c=!1,u=-1;if(n)for(let m=0;m<a.length;m++){let d=a[m];if((d.route.HydrateFallback||d.route.hydrateFallbackElement)&&(u=m),d.route.id){let{loaderData:g,errors:p}=n,b=d.route.loader&&!g.hasOwnProperty(d.route.id)&&(!p||p[d.route.id]===void 0);if(d.route.lazy||b){c=!0,u>=0?a=a.slice(0,u+1):a=[a[0]];break}}}let h=n&&o?(m,d)=>{o(m,{location:n.location,params:n.matches?.[0]?.params??{},unstable_pattern:$i(n.matches),errorInfo:d})}:void 0;return a.reduceRight((m,d,g)=>{let p,b=!1,x=null,v=null;n&&(p=i&&d.route.id?i[d.route.id]:void 0,x=d.route.errorElement||Xi,c&&(u<0&&g===0?($r("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),b=!0,v=null):u===g&&(b=!0,v=d.route.hydrateFallbackElement||null)));let y=t.concat(a.slice(0,g+1)),f=()=>{let w;return p?w=x:b?w=v:d.route.Component?w=l.createElement(d.route.Component,null):d.route.element?w=d.route.element:w=m,l.createElement(el,{match:d,routeContext:{outlet:m,matches:y,isDataRoute:n!=null},children:w})};return n&&(d.route.ErrorBoundary||d.route.errorElement||g===0)?l.createElement(Dr,{location:n.location,revalidation:n.revalidation,component:x,error:p,children:f(),routeContext:{outlet:null,matches:y,isDataRoute:!0},onError:h}):f()},null)}function to(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function nl(e){let t=l.useContext(Xt);return H(t,to(e)),t}function sl(e){let t=l.useContext(ms);return H(t,to(e)),t}function ol(e){let t=l.useContext(ze);return H(t,to(e)),t}function no(e){let t=ol(e),n=t.matches[t.matches.length-1];return H(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function rl(){return no("useRouteId")}function al(){let e=l.useContext(eo),t=sl("useRouteError"),n=no("useRouteError");return e!==void 0?e:t.errors?.[n]}function il(){let{router:e}=nl("useNavigate"),t=no("useNavigate"),n=l.useRef(!1);return Mr(()=>{n.current=!0}),l.useCallback(async(r,a={})=>{Ee(n.current,Pr),n.current&&(typeof r=="number"?await e.navigate(r):await e.navigate(r,{fromRouteId:t,...a}))},[e,t])}var Wo={};function $r(e,t,n){!t&&!Wo[e]&&(Wo[e]=!0,Ee(!1,n))}l.memo(ll);function ll({routes:e,future:t,state:n,onError:o}){return Ir(e,void 0,n,o,t)}function Ut(e){H(!1,"A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.")}function cl({basename:e="/",children:t=null,location:n,navigationType:o="POP",navigator:r,static:a=!1,unstable_useTransitions:i}){H(!Rn(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let c=e.replace(/^\/*/,"/"),u=l.useMemo(()=>({basename:c,navigator:r,static:a,unstable_useTransitions:i,future:{}}),[c,r,a,i]);typeof n=="string"&&(n=Jt(n));let{pathname:h="/",search:m="",hash:d="",state:g=null,key:p="default"}=n,b=l.useMemo(()=>{let x=Ke(h,c);return x==null?null:{location:{pathname:x,search:m,hash:d,state:g,key:p},navigationType:o}},[c,h,m,d,g,p,o]);return Ee(b!=null,`<Router basename="${c}"> is not able to match the URL "${h}${m}${d}" because it does not start with the basename, so the <Router> won't render anything.`),b==null?null:l.createElement(Re.Provider,{value:u},l.createElement(En.Provider,{children:t,value:b}))}function ul({children:e,location:t}){return Yi(Us(e),t)}function Us(e,t=[]){let n=[];return l.Children.forEach(e,(o,r)=>{if(!l.isValidElement(o))return;let a=[...t,r];if(o.type===l.Fragment){n.push.apply(n,Us(o.props.children,a));return}H(o.type===Ut,`[${typeof o.type=="string"?o.type:o.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),H(!o.props.index||!o.props.children,"An index route cannot have child routes.");let i={id:o.props.id||a.join("-"),caseSensitive:o.props.caseSensitive,element:o.props.element,Component:o.props.Component,index:o.props.index,path:o.props.path,middleware:o.props.middleware,loader:o.props.loader,action:o.props.action,hydrateFallbackElement:o.props.hydrateFallbackElement,HydrateFallback:o.props.HydrateFallback,errorElement:o.props.errorElement,ErrorBoundary:o.props.ErrorBoundary,hasErrorBoundary:o.props.hasErrorBoundary===!0||o.props.ErrorBoundary!=null||o.props.errorElement!=null,shouldRevalidate:o.props.shouldRevalidate,handle:o.props.handle,lazy:o.props.lazy};o.props.children&&(i.children=Us(o.props.children,a)),n.push(i)}),n}var Xn="get",Zn="application/x-www-form-urlencoded";function fs(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function dl(e){return fs(e)&&e.tagName.toLowerCase()==="button"}function hl(e){return fs(e)&&e.tagName.toLowerCase()==="form"}function ml(e){return fs(e)&&e.tagName.toLowerCase()==="input"}function fl(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function pl(e,t){return e.button===0&&(!t||t==="_self")&&!fl(e)}function Hs(e=""){return new URLSearchParams(typeof e=="string"||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,n)=>{let o=e[n];return t.concat(Array.isArray(o)?o.map(r=>[n,r]):[[n,o]])},[]))}function gl(e,t){let n=Hs(e);return t&&t.forEach((o,r)=>{n.has(r)||t.getAll(r).forEach(a=>{n.append(r,a)})}),n}var Gn=null;function xl(){if(Gn===null)try{new FormData(document.createElement("form"),0),Gn=!1}catch{Gn=!0}return Gn}var bl=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Ts(e){return e!=null&&!bl.has(e)?(Ee(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Zn}"`),null):e}function vl(e,t){let n,o,r,a,i;if(hl(e)){let c=e.getAttribute("action");o=c?Ke(c,t):null,n=e.getAttribute("method")||Xn,r=Ts(e.getAttribute("enctype"))||Zn,a=new FormData(e)}else if(dl(e)||ml(e)&&(e.type==="submit"||e.type==="image")){let c=e.form;if(c==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let u=e.getAttribute("formaction")||c.getAttribute("action");if(o=u?Ke(u,t):null,n=e.getAttribute("formmethod")||c.getAttribute("method")||Xn,r=Ts(e.getAttribute("formenctype"))||Ts(c.getAttribute("enctype"))||Zn,a=new FormData(c,e),!xl()){let{name:h,type:m,value:d}=e;if(m==="image"){let g=h?`${h}.`:"";a.append(`${g}x`,"0"),a.append(`${g}y`,"0")}else h&&a.append(h,d)}}else{if(fs(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=Xn,o=null,r=Zn,i=e}return a&&r==="text/plain"&&(i=a,a=void 0),{action:o,method:n.toLowerCase(),encType:r,formData:a,body:i}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function so(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function yl(e,t,n,o){let r=typeof e=="string"?new URL(e,typeof window>"u"?"server://singlefetch/":window.location.origin):e;return n?r.pathname.endsWith("/")?r.pathname=`${r.pathname}_.${o}`:r.pathname=`${r.pathname}.${o}`:r.pathname==="/"?r.pathname=`_root.${o}`:t&&Ke(r.pathname,t)==="/"?r.pathname=`${t.replace(/\/$/,"")}/_root.${o}`:r.pathname=`${r.pathname.replace(/\/$/,"")}.${o}`,r}async function wl(e,t){if(e.id in t)return t[e.id];try{let n=await import(e.module);return t[e.id]=n,n}catch(n){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(n),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function Cl(e){return e==null?!1:e.href==null?e.rel==="preload"&&typeof e.imageSrcSet=="string"&&typeof e.imageSizes=="string":typeof e.rel=="string"&&typeof e.href=="string"}async function jl(e,t,n){let o=await Promise.all(e.map(async r=>{let a=t.routes[r.route.id];if(a){let i=await wl(a,n);return i.links?i.links():[]}return[]}));return Sl(o.flat(1).filter(Cl).filter(r=>r.rel==="stylesheet"||r.rel==="preload").map(r=>r.rel==="stylesheet"?{...r,rel:"prefetch",as:"style"}:{...r,rel:"prefetch"}))}function zo(e,t,n,o,r,a){let i=(u,h)=>n[h]?u.route.id!==n[h].route.id:!0,c=(u,h)=>n[h].pathname!==u.pathname||n[h].route.path?.endsWith("*")&&n[h].params["*"]!==u.params["*"];return a==="assets"?t.filter((u,h)=>i(u,h)||c(u,h)):a==="data"?t.filter((u,h)=>{let m=o.routes[u.route.id];if(!m||!m.hasLoader)return!1;if(i(u,h)||c(u,h))return!0;if(u.route.shouldRevalidate){let d=u.route.shouldRevalidate({currentUrl:new URL(r.pathname+r.search+r.hash,window.origin),currentParams:n[0]?.params||{},nextUrl:new URL(e,window.origin),nextParams:u.params,defaultShouldRevalidate:!0});if(typeof d=="boolean")return d}return!0}):[]}function Nl(e,t,{includeHydrateFallback:n}={}){return _l(e.map(o=>{let r=t.routes[o.route.id];if(!r)return[];let a=[r.module];return r.clientActionModule&&(a=a.concat(r.clientActionModule)),r.clientLoaderModule&&(a=a.concat(r.clientLoaderModule)),n&&r.hydrateFallbackModule&&(a=a.concat(r.hydrateFallbackModule)),r.imports&&(a=a.concat(r.imports)),a}).flat(1))}function _l(e){return[...new Set(e)]}function kl(e){let t={},n=Object.keys(e).sort();for(let o of n)t[o]=e[o];return t}function Sl(e,t){let n=new Set;return new Set(t),e.reduce((o,r)=>{let a=JSON.stringify(kl(r));return n.has(a)||(n.add(a),o.push({key:a,link:r})),o},[])}function Fr(){let e=l.useContext(Xt);return so(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function El(){let e=l.useContext(ms);return so(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var oo=l.createContext(void 0);oo.displayName="FrameworkContext";function Br(){let e=l.useContext(oo);return so(e,"You must render this element inside a <HydratedRouter> element"),e}function Rl(e,t){let n=l.useContext(oo),[o,r]=l.useState(!1),[a,i]=l.useState(!1),{onFocus:c,onBlur:u,onMouseEnter:h,onMouseLeave:m,onTouchStart:d}=t,g=l.useRef(null);l.useEffect(()=>{if(e==="render"&&i(!0),e==="viewport"){let x=y=>{y.forEach(f=>{i(f.isIntersecting)})},v=new IntersectionObserver(x,{threshold:.5});return g.current&&v.observe(g.current),()=>{v.disconnect()}}},[e]),l.useEffect(()=>{if(o){let x=setTimeout(()=>{i(!0)},100);return()=>{clearTimeout(x)}}},[o]);let p=()=>{r(!0)},b=()=>{r(!1),i(!1)};return n?e!=="intent"?[a,g,{}]:[a,g,{onFocus:gn(c,p),onBlur:gn(u,b),onMouseEnter:gn(h,p),onMouseLeave:gn(m,b),onTouchStart:gn(d,p)}]:[!1,g,{}]}function gn(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function Ll({page:e,...t}){let{router:n}=Fr(),o=l.useMemo(()=>jr(n.routes,e,n.basename),[n.routes,e,n.basename]);return o?l.createElement(Al,{page:e,matches:o,...t}):null}function Tl(e){let{manifest:t,routeModules:n}=Br(),[o,r]=l.useState([]);return l.useEffect(()=>{let a=!1;return jl(e,t,n).then(i=>{a||r(i)}),()=>{a=!0}},[e,t,n]),o}function Al({page:e,matches:t,...n}){let o=le(),{future:r,manifest:a,routeModules:i}=Br(),{basename:c}=Fr(),{loaderData:u,matches:h}=El(),m=l.useMemo(()=>zo(e,t,h,a,o,"data"),[e,t,h,a,o]),d=l.useMemo(()=>zo(e,t,h,a,o,"assets"),[e,t,h,a,o]),g=l.useMemo(()=>{if(e===o.pathname+o.search+o.hash)return[];let x=new Set,v=!1;if(t.forEach(f=>{let w=a.routes[f.route.id];!w||!w.hasLoader||(!m.some(C=>C.route.id===f.route.id)&&f.route.id in u&&i[f.route.id]?.shouldRevalidate||w.hasClientLoader?v=!0:x.add(f.route.id))}),x.size===0)return[];let y=yl(e,c,r.unstable_trailingSlashAwareDataRequests,"data");return v&&x.size>0&&y.searchParams.set("_routes",t.filter(f=>x.has(f.route.id)).map(f=>f.route.id).join(",")),[y.pathname+y.search]},[c,r.unstable_trailingSlashAwareDataRequests,u,o,a,m,t,e,i]),p=l.useMemo(()=>Nl(d,a),[d,a]),b=Tl(d);return l.createElement(l.Fragment,null,g.map(x=>l.createElement("link",{key:x,rel:"prefetch",as:"fetch",href:x,...n})),p.map(x=>l.createElement("link",{key:x,rel:"modulepreload",href:x,...n})),b.map(({key:x,link:v})=>l.createElement("link",{key:x,nonce:n.nonce,...v})))}function Ol(...e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}var Pl=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{Pl&&(window.__reactRouterVersion="7.12.0")}catch{}function Ml({basename:e,children:t,unstable_useTransitions:n,window:o}){let r=l.useRef();r.current==null&&(r.current=mi({window:o,v5Compat:!0}));let a=r.current,[i,c]=l.useState({action:a.action,location:a.location}),u=l.useCallback(h=>{n===!1?c(h):l.startTransition(()=>c(h))},[n]);return l.useLayoutEffect(()=>a.listen(u),[a,u]),l.createElement(cl,{basename:e,children:t,location:i.location,navigationType:i.action,navigator:a,unstable_useTransitions:n})}var Wr=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,zr=l.forwardRef(function({onClick:t,discover:n="render",prefetch:o="none",relative:r,reloadDocument:a,replace:i,state:c,target:u,to:h,preventScrollReset:m,viewTransition:d,unstable_defaultShouldRevalidate:g,...p},b){let{basename:x,unstable_useTransitions:v}=l.useContext(Re),y=typeof h=="string"&&Wr.test(h),f=Lr(h,x);h=f.to;let w=Qi(h,{relative:r}),[C,N,O]=Rl(o,p),S=Fl(h,{replace:i,state:c,target:u,preventScrollReset:m,relative:r,viewTransition:d,unstable_defaultShouldRevalidate:g,unstable_useTransitions:v});function _(E){t&&t(E),E.defaultPrevented||S(E)}let k=l.createElement("a",{...p,...O,href:f.absoluteURL||w,onClick:f.isExternal||a?t:_,ref:Ol(b,N),target:u,"data-discover":!y&&n==="render"?"true":void 0});return C&&!y?l.createElement(l.Fragment,null,k,l.createElement(Ll,{page:w})):k});zr.displayName="Link";var Il=l.forwardRef(function({"aria-current":t="page",caseSensitive:n=!1,className:o="",end:r=!1,style:a,to:i,viewTransition:c,children:u,...h},m){let d=Ln(i,{relative:h.relative}),g=le(),p=l.useContext(ms),{navigator:b,basename:x}=l.useContext(Re),v=p!=null&&Hl(d)&&c===!0,y=b.encodeLocation?b.encodeLocation(d).pathname:d.pathname,f=g.pathname,w=p&&p.navigation&&p.navigation.location?p.navigation.location.pathname:null;n||(f=f.toLowerCase(),w=w?w.toLowerCase():null,y=y.toLowerCase()),w&&x&&(w=Ke(w,x)||w);const C=y!=="/"&&y.endsWith("/")?y.length-1:y.length;let N=f===y||!r&&f.startsWith(y)&&f.charAt(C)==="/",O=w!=null&&(w===y||!r&&w.startsWith(y)&&w.charAt(y.length)==="/"),S={isActive:N,isPending:O,isTransitioning:v},_=N?t:void 0,k;typeof o=="function"?k=o(S):k=[o,N?"active":null,O?"pending":null,v?"transitioning":null].filter(Boolean).join(" ");let E=typeof a=="function"?a(S):a;return l.createElement(zr,{...h,"aria-current":_,className:k,ref:m,style:E,to:i,viewTransition:c},typeof u=="function"?u(S):u)});Il.displayName="NavLink";var Dl=l.forwardRef(({discover:e="render",fetcherKey:t,navigate:n,reloadDocument:o,replace:r,state:a,method:i=Xn,action:c,onSubmit:u,relative:h,preventScrollReset:m,viewTransition:d,unstable_defaultShouldRevalidate:g,...p},b)=>{let{unstable_useTransitions:x}=l.useContext(Re),v=ql(),y=Ul(c,{relative:h}),f=i.toLowerCase()==="get"?"get":"post",w=typeof c=="string"&&Wr.test(c),C=N=>{if(u&&u(N),N.defaultPrevented)return;N.preventDefault();let O=N.nativeEvent.submitter,S=O?.getAttribute("formmethod")||i,_=()=>v(O||N.currentTarget,{fetcherKey:t,method:S,navigate:n,replace:r,state:a,relative:h,preventScrollReset:m,viewTransition:d,unstable_defaultShouldRevalidate:g});x&&n!==!1?l.startTransition(()=>_()):_()};return l.createElement("form",{ref:b,method:f,action:y,onSubmit:o?u:C,...p,"data-discover":!w&&e==="render"?"true":void 0})});Dl.displayName="Form";function $l(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function qr(e){let t=l.useContext(Xt);return H(t,$l(e)),t}function Fl(e,{target:t,replace:n,state:o,preventScrollReset:r,relative:a,viewTransition:i,unstable_defaultShouldRevalidate:c,unstable_useTransitions:u}={}){let h=Y(),m=le(),d=Ln(e,{relative:a});return l.useCallback(g=>{if(pl(g,t)){g.preventDefault();let p=n!==void 0?n:jn(m)===jn(d),b=()=>h(e,{replace:p,state:o,preventScrollReset:r,relative:a,viewTransition:i,unstable_defaultShouldRevalidate:c});u?l.startTransition(()=>b()):b()}},[m,h,d,n,o,t,e,r,a,i,c,u])}function Bl(e){Ee(typeof URLSearchParams<"u","You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.");let t=l.useRef(Hs(e)),n=l.useRef(!1),o=le(),r=l.useMemo(()=>gl(o.search,n.current?null:t.current),[o.search]),a=Y(),i=l.useCallback((c,u)=>{const h=Hs(typeof c=="function"?c(new URLSearchParams(r)):c);n.current=!0,a("?"+h,u)},[a,r]);return[r,i]}var Wl=0,zl=()=>`__${String(++Wl)}__`;function ql(){let{router:e}=qr("useSubmit"),{basename:t}=l.useContext(Re),n=rl(),o=e.fetch,r=e.navigate;return l.useCallback(async(a,i={})=>{let{action:c,method:u,encType:h,formData:m,body:d}=vl(a,t);if(i.navigate===!1){let g=i.fetcherKey||zl();await o(g,n,i.action||c,{unstable_defaultShouldRevalidate:i.unstable_defaultShouldRevalidate,preventScrollReset:i.preventScrollReset,formData:m,body:d,formMethod:i.method||u,formEncType:i.encType||h,flushSync:i.flushSync})}else await r(i.action||c,{unstable_defaultShouldRevalidate:i.unstable_defaultShouldRevalidate,preventScrollReset:i.preventScrollReset,formData:m,body:d,formMethod:i.method||u,formEncType:i.encType||h,replace:i.replace,state:i.state,fromRouteId:n,flushSync:i.flushSync,viewTransition:i.viewTransition})},[o,r,t,n])}function Ul(e,{relative:t}={}){let{basename:n}=l.useContext(Re),o=l.useContext(ze);H(o,"useFormAction must be used inside a RouteContext");let[r]=o.matches.slice(-1),a={...Ln(e||".",{relative:t})},i=le();if(e==null){a.search=i.search;let c=new URLSearchParams(a.search),u=c.getAll("index");if(u.some(m=>m==="")){c.delete("index"),u.filter(d=>d).forEach(d=>c.append("index",d));let m=c.toString();a.search=m?`?${m}`:""}}return(!e||e===".")&&r.route.index&&(a.search=a.search?a.search.replace(/^\?/,"?index&"):"?index"),n!=="/"&&(a.pathname=a.pathname==="/"?n:Qe([n,a.pathname])),jn(a)}function Hl(e,{relative:t}={}){let n=l.useContext(Ar);H(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:o}=qr("useViewTransitionState"),r=Ln(e,{relative:t});if(!n.isTransitioning)return!1;let a=Ke(n.currentLocation.pathname,o)||n.currentLocation.pathname,i=Ke(n.nextLocation.pathname,o)||n.nextLocation.pathname;return Kt(r.pathname,i)!=null||Kt(r.pathname,a)!=null}var ro=ei(),Ur=class extends Cr{constructor(e,t){super(),this.options=t,this.#n=e,this.#i=null,this.#a=Ao(),this.bindMethods(),this.setOptions(t)}#n;#e=void 0;#s=void 0;#t=void 0;#o;#r;#a;#i;#p;#h;#m;#c;#u;#l;#f=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#e.addObserver(this),qo(this.#e,this.options)?this.#d():this.updateResult(),this.#v())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Vs(this.#e,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Vs(this.#e,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#y(),this.#w(),this.#e.removeObserver(this)}setOptions(e){const t=this.options,n=this.#e;if(this.options=this.#n.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Te(this.options.enabled,this.#e)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#C(),this.#e.setOptions(this.options),t._defaulted&&!os(this.options,t)&&this.#n.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#e,observer:this});const o=this.hasListeners();o&&Uo(this.#e,n,this.options,t)&&this.#d(),this.updateResult(),o&&(this.#e!==n||Te(this.options.enabled,this.#e)!==Te(t.enabled,this.#e)||Cn(this.options.staleTime,this.#e)!==Cn(t.staleTime,this.#e))&&this.#g();const r=this.#x();o&&(this.#e!==n||Te(this.options.enabled,this.#e)!==Te(t.enabled,this.#e)||r!==this.#l)&&this.#b(r)}getOptimisticResult(e){const t=this.#n.getQueryCache().build(this.#n,e),n=this.createResult(t,e);return Ql(this,n)&&(this.#t=n,this.#r=this.options,this.#o=this.#e.state),n}getCurrentResult(){return this.#t}trackResult(e,t){return new Proxy(e,{get:(n,o)=>(this.trackProp(o),t?.(o),o==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&this.#a.status==="pending"&&this.#a.reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(n,o))})}trackProp(e){this.#f.add(e)}getCurrentQuery(){return this.#e}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const t=this.#n.defaultQueryOptions(e),n=this.#n.getQueryCache().build(this.#n,t);return n.fetch().then(()=>this.createResult(n,t))}fetch(e){return this.#d({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#t))}#d(e){this.#C();let t=this.#e.fetch(this.options,e);return e?.throwOnError||(t=t.catch(rs)),t}#g(){this.#y();const e=Cn(this.options.staleTime,this.#e);if(zs||this.#t.isStale||!Oo(e))return;const n=ti(this.#t.dataUpdatedAt,e)+1;this.#c=Kn.setTimeout(()=>{this.#t.isStale||this.updateResult()},n)}#x(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#e):this.options.refetchInterval)??!1}#b(e){this.#w(),this.#l=e,!(zs||Te(this.options.enabled,this.#e)===!1||!Oo(this.#l)||this.#l===0)&&(this.#u=Kn.setInterval(()=>{(this.options.refetchIntervalInBackground||ni.isFocused())&&this.#d()},this.#l))}#v(){this.#g(),this.#b(this.#x())}#y(){this.#c&&(Kn.clearTimeout(this.#c),this.#c=void 0)}#w(){this.#u&&(Kn.clearInterval(this.#u),this.#u=void 0)}createResult(e,t){const n=this.#e,o=this.options,r=this.#t,a=this.#o,i=this.#r,u=e!==n?e.state:this.#s,{state:h}=e;let m={...h},d=!1,g;if(t._optimisticResults){const _=this.hasListeners(),k=!_&&qo(e,t),E=_&&Uo(e,n,t,o);(k||E)&&(m={...m,...si(h.data,e.options)}),t._optimisticResults==="isRestoring"&&(m.fetchStatus="idle")}let{error:p,errorUpdatedAt:b,status:x}=m;g=m.data;let v=!1;if(t.placeholderData!==void 0&&g===void 0&&x==="pending"){let _;r?.isPlaceholderData&&t.placeholderData===i?.placeholderData?(_=r.data,v=!0):_=typeof t.placeholderData=="function"?t.placeholderData(this.#m?.state.data,this.#m):t.placeholderData,_!==void 0&&(x="success",g=Po(r?.data,_,t),d=!0)}if(t.select&&g!==void 0&&!v)if(r&&g===a?.data&&t.select===this.#p)g=this.#h;else try{this.#p=t.select,g=t.select(g),g=Po(r?.data,g,t),this.#h=g,this.#i=null}catch(_){this.#i=_}this.#i&&(p=this.#i,g=this.#h,b=Date.now(),x="error");const y=m.fetchStatus==="fetching",f=x==="pending",w=x==="error",C=f&&y,N=g!==void 0,S={status:x,fetchStatus:m.fetchStatus,isPending:f,isSuccess:x==="success",isError:w,isInitialLoading:C,isLoading:C,data:g,dataUpdatedAt:m.dataUpdatedAt,error:p,errorUpdatedAt:b,failureCount:m.fetchFailureCount,failureReason:m.fetchFailureReason,errorUpdateCount:m.errorUpdateCount,isFetched:m.dataUpdateCount>0||m.errorUpdateCount>0,isFetchedAfterMount:m.dataUpdateCount>u.dataUpdateCount||m.errorUpdateCount>u.errorUpdateCount,isFetching:y,isRefetching:y&&!f,isLoadingError:w&&!N,isPaused:m.fetchStatus==="paused",isPlaceholderData:d,isRefetchError:w&&N,isStale:ao(e,t),refetch:this.refetch,promise:this.#a,isEnabled:Te(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){const _=te=>{S.status==="error"?te.reject(S.error):S.data!==void 0&&te.resolve(S.data)},k=()=>{const te=this.#a=S.promise=Ao();_(te)},E=this.#a;switch(E.status){case"pending":e.queryHash===n.queryHash&&_(E);break;case"fulfilled":(S.status==="error"||S.data!==E.value)&&k();break;case"rejected":(S.status!=="error"||S.error!==E.reason)&&k();break}}return S}updateResult(){const e=this.#t,t=this.createResult(this.#e,this.options);if(this.#o=this.#e.state,this.#r=this.options,this.#o.data!==void 0&&(this.#m=this.#e),os(t,e))return;this.#t=t;const n=()=>{if(!e)return!0;const{notifyOnChangeProps:o}=this.options,r=typeof o=="function"?o():o;if(r==="all"||!r&&!this.#f.size)return!0;const a=new Set(r??this.#f);return this.options.throwOnError&&a.add("error"),Object.keys(this.#t).some(i=>{const c=i;return this.#t[c]!==e[c]&&a.has(c)})};this.#j({listeners:n()})}#C(){const e=this.#n.getQueryCache().build(this.#n,this.options);if(e===this.#e)return;const t=this.#e;this.#e=e,this.#s=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#v()}#j(e){ds.batch(()=>{e.listeners&&this.listeners.forEach(t=>{t(this.#t)}),this.#n.getQueryCache().notify({query:this.#e,type:"observerResultsUpdated"})})}};function Vl(e,t){return Te(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function qo(e,t){return Vl(e,t)||e.state.data!==void 0&&Vs(e,t,t.refetchOnMount)}function Vs(e,t,n){if(Te(t.enabled,e)!==!1&&Cn(t.staleTime,e)!=="static"){const o=typeof n=="function"?n(e):n;return o==="always"||o!==!1&&ao(e,t)}return!1}function Uo(e,t,n,o){return(e!==t||Te(o.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&ao(e,n)}function ao(e,t){return Te(t.enabled,e)!==!1&&e.isStaleByTime(Cn(t.staleTime,e))}function Ql(e,t){return!os(e.getCurrentResult(),t)}var Kl=class extends Ur{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){super.setOptions({...e,behavior:Mo()})}getOptimisticResult(e){return e.behavior=Mo(),super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"backward"}}})}createResult(e,t){const{state:n}=e,o=super.createResult(e,t),{isFetching:r,isRefetching:a,isError:i,isRefetchError:c}=o,u=n.fetchMeta?.fetchMore?.direction,h=i&&u==="forward",m=r&&u==="forward",d=i&&u==="backward",g=r&&u==="backward";return{...o,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:ri(t,n.data),hasPreviousPage:oi(t,n.data),isFetchNextPageError:h,isFetchingNextPage:m,isFetchPreviousPageError:d,isFetchingPreviousPage:g,isRefetchError:c&&!h&&!d,isRefetching:a&&!m&&!g}}},Gl=class extends Cr{#n;#e=void 0;#s;#t;constructor(t,n){super(),this.#n=t,this.setOptions(n),this.bindMethods(),this.#o()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){const n=this.options;this.options=this.#n.defaultMutationOptions(t),os(this.options,n)||this.#n.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#s,observer:this}),n?.mutationKey&&this.options.mutationKey&&Io(n.mutationKey)!==Io(this.options.mutationKey)?this.reset():this.#s?.state.status==="pending"&&this.#s.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#s?.removeObserver(this)}onMutationUpdate(t){this.#o(),this.#r(t)}getCurrentResult(){return this.#e}reset(){this.#s?.removeObserver(this),this.#s=void 0,this.#o(),this.#r()}mutate(t,n){return this.#t=n,this.#s?.removeObserver(this),this.#s=this.#n.getMutationCache().build(this.#n,this.options),this.#s.addObserver(this),this.#s.execute(t)}#o(){const t=this.#s?.state??ai();this.#e={...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset}}#r(t){ds.batch(()=>{if(this.#t&&this.hasListeners()){const n=this.#e.variables,o=this.#e.context,r={client:this.#n,meta:this.options.meta,mutationKey:this.options.mutationKey};if(t?.type==="success"){try{this.#t.onSuccess?.(t.data,n,o,r)}catch(a){Promise.reject(a)}try{this.#t.onSettled?.(t.data,null,n,o,r)}catch(a){Promise.reject(a)}}else if(t?.type==="error"){try{this.#t.onError?.(t.error,n,o,r)}catch(a){Promise.reject(a)}try{this.#t.onSettled?.(void 0,t.error,n,o,r)}catch(a){Promise.reject(a)}}}this.listeners.forEach(n=>{n(this.#e)})})}},Hr=l.createContext(void 0),Vr=e=>{const t=l.useContext(Hr);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},Yl=({client:e,children:t})=>(l.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),s.jsx(Hr.Provider,{value:e,children:t})),Qr=l.createContext(!1),Jl=()=>l.useContext(Qr);Qr.Provider;function Xl(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var Zl=l.createContext(Xl()),ec=()=>l.useContext(Zl),tc=(e,t,n)=>{const o=n?.state.error&&typeof e.throwOnError=="function"?Zs(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||o)&&(t.isReset()||(e.retryOnMount=!1))},nc=e=>{l.useEffect(()=>{e.clearReset()},[e])},sc=({result:e,errorResetBoundary:t,throwOnError:n,query:o,suspense:r})=>e.isError&&!t.isReset()&&!e.isFetching&&o&&(r&&e.data===void 0||Zs(n,[e.error,o])),oc=e=>{if(e.suspense){const n=r=>r==="static"?r:Math.max(r??1e3,1e3),o=e.staleTime;e.staleTime=typeof o=="function"?(...r)=>n(o(...r)):n(o),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},rc=(e,t)=>e.isLoading&&e.isFetching&&!t,ac=(e,t)=>e?.suspense&&t.isPending,Ho=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function Kr(e,t,n){const o=Jl(),r=ec(),a=Vr(),i=a.defaultQueryOptions(e);a.getDefaultOptions().queries?._experimental_beforeQuery?.(i);const c=a.getQueryCache().get(i.queryHash);i._optimisticResults=o?"isRestoring":"optimistic",oc(i),tc(i,r,c),nc(r);const u=!a.getQueryCache().get(i.queryHash),[h]=l.useState(()=>new t(a,i)),m=h.getOptimisticResult(i),d=!o&&e.subscribed!==!1;if(l.useSyncExternalStore(l.useCallback(g=>{const p=d?h.subscribe(ds.batchCalls(g)):rs;return h.updateResult(),p},[h,d]),()=>h.getCurrentResult(),()=>h.getCurrentResult()),l.useEffect(()=>{h.setOptions(i)},[i,h]),ac(i,m))throw Ho(i,h,r);if(sc({result:m,errorResetBoundary:r,throwOnError:i.throwOnError,query:c,suspense:i.suspense}))throw m.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(i,m),i.experimental_prefetchInRender&&!zs&&rc(m,o)&&(u?Ho(i,h,r):c?.promise)?.catch(rs).finally(()=>{h.updateResult()}),i.notifyOnChangeProps?m:h.trackResult(m)}function be(e,t){return Kr(e,Ur)}function Z(e,t){const n=Vr(),[o]=l.useState(()=>new Gl(n,e));l.useEffect(()=>{o.setOptions(e)},[o,e]);const r=l.useSyncExternalStore(l.useCallback(i=>o.subscribe(ds.batchCalls(i)),[o]),()=>o.getCurrentResult(),()=>o.getCurrentResult()),a=l.useCallback((i,c)=>{o.mutate(i,c).catch(rs)},[o]);if(r.error&&Zs(o.options.throwOnError,[r.error]))throw r.error;return{...r,mutate:a,mutateAsync:r.mutate}}function Gr(e,t){return Kr(e,Kl)}const kt="data-sources",Yr="auth-user",ic=e=>be({queryKey:["project","datasources",e],queryFn:async()=>{const{data:t}=await $.get(`/project/team/${e}/datasources`);return t.data},enabled:!!e}),Zt=e=>{const t=["project","datasources"],n=["project","saved-queries"];return Promise.all([Q.invalidateQueries({queryKey:t}),Q.invalidateQueries({queryKey:n})])},lc=e=>{const t=["trash","team"];return Q.invalidateQueries({queryKey:t})},cc=(e,t)=>be({queryKey:["project",t.teamId,"tables",e,t.selectedDataSources],queryFn:async()=>{const{data:n}=await $.get(`/project/team/${t.teamId}/query`,{params:{size:30,search:e,selectedDataSources:t.selectedDataSources}});return n.data},enabled:!!t.teamId,staleTime:0}),uc=(e,t="",n=30,o)=>Gr({queryKey:["project","tabs-history",e,n,o,t],queryFn:async({pageParam:r})=>{const a=new URLSearchParams;a.set("nameFilter",t),a.set("size",n.toString()),a.set("page",r.toString());const{data:i}=await $.get(`/project/team/${e}/tabs-history?${a.toString()}`);return i},select:({pages:r})=>r.flatMap(a=>a.data),enabled:!!e,initialPageParam:0,getNextPageParam:(r,a)=>{if(r.hasMore)return a.length},staleTime:0}),dc=(e,t="",n=20)=>Gr({queryKey:["project","saved-queries",e,t,n],queryFn:async({pageParam:o})=>{const r=new URLSearchParams;r.set("nameFilter",t),r.set("size",n.toString()),r.set("page",o.toString());const{data:a}=await $.get(`/project/team/${e}/queries?${r.toString()}`);return a},enabled:!!e,initialPageParam:0,select:({pages:o})=>o.flatMap(r=>r.data),getNextPageParam:(o,r)=>{if(o.hasMore)return r.length}}),hc=(e,t=10,n=!1)=>be({queryKey:["project","recent-tabs",e,t,n],queryFn:async()=>{const{data:o}=await $.get(`/project/team/${e}/tabs-history?page=0&size=${t}&archived=${n}`);return o.data},enabled:!!e,staleTime:0}),mc=e=>Z({mutationFn:async()=>{const{data:t}=await $.get(`/project/team/${e}/tabs-history?page=0&size=1&archived=false`);return t.data?.length?t.data[0]:void 0}}),fc=()=>Promise.all([Q.invalidateQueries({queryKey:["project","tabs-history"]}),Q.invalidateQueries({queryKey:["project","recent-tabs"]})]),Jr=()=>Q.invalidateQueries({queryKey:["project","count-saved-queries"]}),pc=(e,t)=>{},gc=()=>{},xc={event:pc,pageView:gc},ps=e=>be({queryKey:[kt,e],queryFn:async()=>{const{data:t}=await $.get("/data-sources/"+e);return t.data},enabled:!!e}),io=e=>be({queryKey:[kt,e.teamId],queryFn:async()=>{const{data:t}=await $.get("/data-sources",{params:e});return t.data},enabled:e.teamId!==void 0}),gs=e=>be({queryKey:[kt,e,"inspections"],queryFn:async()=>{const{data:t}=await $.get(`/data-sources/${e}/inspections`);return t.data},enabled:!!e}),bc=()=>Z({mutationFn:async e=>{const{data:t}=await $.post("/data-sources",e);return t.data},onSuccess:()=>{Q.invalidateQueries({queryKey:[kt]}),Zt()},onError:()=>{}}),vc=()=>Z({mutationFn:async({dataSource:e,id:t})=>{const{data:n}=await $.put(`/data-sources/${t}`,e);return n.data},onSuccess:()=>{Q.invalidateQueries({queryKey:[kt]}),Zt()}}),Xr=()=>Z({mutationFn:async e=>{await $.post(`/data-sources/${e}/inspect`)},onSuccess:()=>{Q.invalidateQueries({queryKey:[kt]})}}),yc=()=>Z({mutationFn:async e=>{await $.delete(`/data-sources/${e}`)},onSuccess:()=>{Q.invalidateQueries({queryKey:[kt]}),Zt()}}),Zr=()=>be({queryKey:["accessToken"],queryFn:hs.get}),ve=()=>{const{data:e}=Zr();return be({queryKey:[Yr],queryFn:async()=>{const{data:t}=await $.get("/users");return t.data},enabled:!!e,retry:(t,n)=>ii(n)&&n.code==="ERR_NETWORK"?!1:t<3})},wc=()=>Z({mutationFn:async e=>{const{data:t}=await $.patch("/users",e);return t.data},onSuccess:async e=>{Q.setQueryData([Yr],e)}}),Cc=()=>Z({mutationFn:async e=>(await $.post("/users",e),!0),onSuccess:()=>{Q.invalidateQueries({queryKey:["team-users"]})}}),ye=e=>{const t=new Set;let n=e;const o=c=>(t.add(c),()=>t.delete(c)),r=c=>(t.forEach(u=>u(c)),!0),a=c=>{n=typeof c=="function"?c(n):c,r(n)},i=c=>()=>c?c(n):n;return[c=>l.useSyncExternalStore(o,i(c),i(c)),a,{get:()=>n,subscribe:c=>(c(n),o(c))}]};function jc(e,t,n,o){return l.useMemo(()=>({name:n,tabId:o,hooks:e?.result.availableHooks||[],availableJoins:e?.result?.availableJoins||[],allColumns:e?.result.allColumns||[],dataSourceId:t,entities:e?.result.availableEntities||[],getValue:(r,a,i)=>{const c=e?.result.columns?.findIndex(u=>u.table===a&&u.column===i);if(c!=null&&c>-1)return e?.result?.rows[r][c]},getColumnByIndex:r=>e?.result?.columns?.[r],getValueByIndex:(r,a)=>e?.result?.rows[r]?.[a],getColumnType:r=>{const a=e?.result.allColumns.find(i=>i.full===r);if(a)return a.type}}),[e,t,n,o])}function Nc(e,t){return l.useMemo(()=>({state:e,setState:t}),[e,t])}function en(e){return{dataSourceId:e.dataSourceId||"",page:e?.page||0,size:e?.size||50,table:e.table||"",filters:e?.filters||[],joins:e?.joins??[],orderBy:e?.orderBy??[],columns:e?.columns??[],groupBy:e?.groupBy??[],aggregations:e?.aggregations??[]}}function _c(e,t){return{name:e,path:t,build:r=>{if(typeof r=="object"){let a=t;for(const[i,c]of Object.entries(r))a=a.replace(":"+i,c);return a}return t},check:r=>!!Kt({path:t,end:!0},r)}}function xs(e,t){return{name:e,path:t,build:()=>t,check:n=>n===t}}const kc=xs("Home","/"),Sc=xs("Workbench","/workbench"),Ec=xs("Share query","/share"),Rc=xs("Login","/login"),Lc=_c("Workbench tab","/workbench/tab/:id"),D={home:kc,workbench:Sc,share:Ec,login:Rc,workbenchTab:Lc},lo=e=>{Q.setQueryData(["workbench-tabs"],t=>e(t||[]))},Tc=(e,t)=>{Q.setQueryData(["workbench-tabs",e],n=>n&&t(n))},bs=()=>be({queryKey:["workbench-tabs"],queryFn:async()=>{const{data:e}=await $.get("/workbench-tabs");return e.data}}),Ac=e=>be({queryKey:["workbench-tabs",e],queryFn:async()=>{const{data:t}=await $.get(`/workbench-tabs/${e}`);return t.data}}),St=()=>Z({mutationFn:async e=>{const{data:t}=await $.post("/workbench-tabs",e);return t.data},onSuccess:async e=>{lo(t=>[...t,e])}}),Oc=()=>Z({mutationFn:async e=>(await $.patch(`/workbench-tabs/${e}`,{archived:!0}),e),onMutate:e=>{lo(t=>t.filter(n=>n.id!==e))}}),ea=()=>Z({mutationFn:async e=>(await $.patch(`/workbench-tabs/${e}`,{archived:!1}),e),onSuccess:()=>na()}),Pc=()=>Z({mutationFn:async({id:e,payload:t})=>(await $.patch(`/workbench-tabs/${e}`,t),!0),onMutate:({id:e,payload:t})=>{Tc(e,n=>({...n,...t})),lo(n=>n.map(o=>o.id!==e?o:{...o,name:t.name||o.name}))}}),Mc=(e,t)=>{const{dataSourceId:n,searchAll:o,table:r,filters:a,joins:i,orderBy:c,groupBy:u,columns:h,aggregations:m,page:d=0,size:g=20}=t;return be({queryKey:["workbench-tab-runner",e,n,r,d,g,a,m,i,c,u,h,o],queryFn:async()=>{const{data:p}=await $.post(`/workbench-tabs/${e}/run`,t);return p.data},retry:1,enabled:!!r&&!!n,placeholderData:li})},Ic=()=>Z({mutationFn:async e=>{await $.delete(`/workbench-tabs/${e}`)},onSuccess:()=>{na(),fc()}}),ta=e=>Q.invalidateQueries({queryKey:["workbench-tab-runner",e]}),na=()=>Q.invalidateQueries({queryKey:["workbench-tabs"]}),[Dc,As,$c]=ye(void 0),Fc=async()=>new Promise(e=>{As({onCancel:()=>{As(void 0),e(void 0)},onConfirm:(t,n,o)=>{As(void 0),e({dsId:o,id:n,type:t})}})}),Tn=e=>{const t=Y(),n=St(),o=ea();return l.useEffect(()=>{n?.data?.id&&t(D.workbenchTab.build({id:n.data.id})),o?.data&&t(D.workbenchTab.build({id:o.data}))},[n.data,o.data]),l.useCallback(()=>{$c.get()||Fc().then(a=>{a?.type==="table"?n.mutate({name:a.id,opts:en({table:a.id,dataSourceId:a.dsId})}):a?.type==="query"?n.mutate({queryId:a.id}):a?.type==="tab"&&o.mutate(a.id)})},[t,e])},sa=[{value:"=",label:"equals"},{value:"<>",label:"not equal"},{value:">",label:"greater than"},{value:">=",label:"greater than or equal"},{value:"<",label:"less than"},{value:"<=",label:"less than or equal"},{value:"LIKE",label:"like"},{value:"NOT LIKE",label:"not like"},{value:"CONTAINS",label:"contains"},{value:"NOT CONTAINS",label:"not contains"},{value:"IN",label:"in list"},{value:"NOT IN",label:"not in list"},{value:"IS NULL",label:"is null"},{value:"IS NOT NULL",label:"is not null"}],Bc=sa.reduce((e,t)=>(e[t.value]=t.label,e),{});sa.reduce((e,t)=>(e[t.label]=t.value,e),{});const tn=e=>e.map(t=>({label:Bc[t],value:t}));tn(["=","<>",">",">=","<","<=","IN","NOT IN","IS NULL","IS NOT NULL"]);tn(["=","<>","LIKE","NOT LIKE","IN","NOT IN","IS NULL","IS NOT NULL","CONTAINS","NOT CONTAINS"]);tn(["=","<>","IS NULL","IS NOT NULL"]);tn(["=","<>",">",">=","<","<=","IS NULL","IS NOT NULL"]);tn(["IS NULL","IS NOT NULL"]);tn(["IN","NOT IN"]);const Wc=["char","varchar","binary","varbinary","blob","text","enum","set","character","character varying","text","citext","uuid","xml","json","jsonb"];new Set(Wc);const zc=["integer","smallint","decimal","numeric","float","real","double precision","int","smallint","integer","bigint","decimal","numeric","real","double precision","serial","bigserial","money"];new Set(zc);const qc=["date","datetime","timestamp","timestamptz"].reduce((e,t)=>(e[t]=!0,e),{}),Uc=e=>e.fn?e.distinct===!0?`${e.fn} distinct ${e.value}`:`${e.fn} ${e.value}`:e.value;var me=(e=>(e.OWNER="owner",e.ADMIN="admin",e.EDITOR="editor",e.READ_ONLY="read_only",e))(me||{});const Vo={[me.READ_ONLY]:10,[me.EDITOR]:20,[me.ADMIN]:30,[me.OWNER]:40},Hc=e=>`${e.fromTable}.${e.fromColumn} = ${e.toTable}.${e.toColumn}`,An=e=>{const{data:t}=ve();return l.useMemo(()=>t?Vo[t.teamRole]>=Vo[e]:!1,[t,e])},Vc="_input_1t0h6_2",Qc="_label_1t0h6_2",Kc="_content_1t0h6_2",Gc="_form_1t0h6_2",Yc="_mode-select_1t0h6_2",vt={input:Vc,label:Qc,content:Kc,form:Gc,switch:"_switch_1t0h6_2",modeSelect:Yc},Jc="_modal_i89bs_2",Xc="_modal-visible_i89bs_2",Zc="_modal-invisible_i89bs_2",eu="_backdrop_i89bs_2",tu="_modal-container_i89bs_2",nu="_close-button_i89bs_2",Ht={modal:Jc,modalVisible:Xc,modalInvisible:Zc,backdrop:eu,modalContainer:tu,closeButton:nu},jt=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32,d:"M368 368L144 144M368 144L144 368"}));let es=[];const su=e=>{const t=Symbol();return es.push({id:t,listener:e}),()=>{es=es.filter(n=>n.id!==t)}};window.addEventListener("keydown",e=>{if(e.key!=="Escape")return;const t=es.pop();t&&(e.preventDefault(),e.stopPropagation(),t.listener())});const vs=e=>{const t=l.useRef(e.onClose);t.current=e.onClose,l.useEffect(()=>{if(e.enabled)return su(()=>{t.current()})},[e.enabled])},we=({children:e,backdropClose:t,isVisible:n,onClose:o,onClosed:r,noPadding:a=!1,portal:i=!1})=>{const[c,u]=l.useState(!1),h=()=>{t&&o()},m=g=>{n||getComputedStyle(g.currentTarget).opacity==="0"&&(u(!1),r&&r())};l.useEffect(()=>{n&&u(!0)},[n]),vs({onClose:h,enabled:n&&t===!0});const d=s.jsxs("div",{onTransitionEnd:m,className:P(Ht.modal,n?Ht.modalVisible:Ht.modalInvisible),children:[s.jsx("div",{onClick:h,className:Ht.backdrop}),s.jsx("div",{className:P(Ht.modalContainer,a!==!0&&"p-4"),children:c&&e})]});return i?ro.createPortal(d,document.body):d},at=({onClick:e})=>{const t=l.useRef(e);return t.current=e,s.jsx("button",{className:Ht.closeButton,onClick:e,children:s.jsx(jt,{width:20,height:20})})},oa=({children:e})=>s.jsx("h2",{className:"text-xl font-semibold",children:e}),ou=({form:e,change:t,shape:n})=>s.jsx("div",{className:vt.form,children:n.fields.map(o=>s.jsxs("label",{className:vt.input,children:[s.jsx("p",{className:vt.label,children:o.label}),s.jsx("input",{value:e[o.name],onChange:t(o.name),type:o.type})]},o.name))}),Wt=[{label:"PostgreSQL",tag:"postgres"},{label:"MySQL",tag:"mysql"}],ru={fields:[{label:"Database URL",name:"dbUrl",type:"text"},{label:"Database port",name:"dbPort",type:"number"},{label:"Username",name:"dbUser",type:"text"},{label:"Password",name:"dbPassword",type:"password"},{label:"Database",name:"dbDatabase",type:"text"}]},au={fields:[{label:"Database URL",name:"dbUrl",type:"text"},{label:"Database port",name:"dbPort",type:"number"},{label:"Username",name:"dbUser",type:"text"},{label:"Password",name:"dbPassword",type:"password"},{label:"Database",name:"dbDatabase",type:"text"},{label:"Schema",name:"dbSchema",type:"text"}]},iu=({show:e,onClose:t,dbType:n="postgres"})=>{const o=bc(),r=Xr(),{data:a}=ve(),[i,{change:c,set:u}]=Sn({name:"",dbType:n,dbUrl:"",dbUser:"",dbPassword:"",dbDatabase:"",dbSchema:"",dbPort:5432,teamId:"",ownerId:"",description:"",allowInsert:!1,allowUpdate:!1}),h=async()=>{const b=await o.mutateAsync({...i,dbPort:Number(i.dbPort),teamId:a.teamId,ownerId:a.id});await r.mutateAsync(b.id),t(),xc.event("Create Datasource",{dbType:i.dbType})},m=b=>{u("allowInsert",!b),u("allowUpdate",!b)},d=()=>{t()},g=o.isPending||r.isPending,p=!i.allowInsert&&!i.allowUpdate;return s.jsxs(we,{isVisible:e,onClose:d,portal:!0,children:[s.jsxs("div",{className:"max-w-xl mx-auto overflow-y-auto",children:[o.isError&&s.jsx(fe,{variant:"danger",className:"mb-2",children:s.jsx("span",{children:"Failed to connect to the database. Please check if the data are correct and retry."})}),o.isPending&&s.jsx(fe,{className:"mb-2",variant:"info",children:"Creating connection"}),r.isPending&&s.jsx(fe,{className:"mb-2",variant:"info",children:"Inspecting connection"}),s.jsxs("div",{className:vt.switch,children:[s.jsxs("label",{className:"button tertiary",children:[s.jsx("input",{type:"radio",name:"bdType",className:"mr-2",checked:i.dbType===Wt[0].tag,onChange:()=>u("dbType",Wt[0].tag)}),s.jsx("span",{children:Wt[0].label})]}),s.jsxs("label",{className:"button tertiary",children:[s.jsx("input",{type:"radio",name:"bdType",className:"mr-2",checked:i.dbType===Wt[1].tag,onChange:()=>u("dbType",Wt[1].tag)}),s.jsx("span",{children:Wt[1].label})]})]}),s.jsxs("div",{className:"mt-2",children:[s.jsxs("div",{className:vt.content,children:[s.jsx(ou,{form:i,change:c,shape:i.dbType==="mysql"?ru:au}),s.jsxs("div",{className:"flex flex-col",children:[s.jsx("label",{className:"text-sm font-semibold",children:"Name"}),s.jsx("input",{value:i.name,onChange:c("name"),className:"input"})]})]}),s.jsxs("div",{className:"mt-4",children:[s.jsxs("label",{className:vt.modeSelect,children:[s.jsxs("div",{children:[s.jsx("input",{type:"radio",name:"production-mode",className:"mr-2",checked:p,onChange:()=>m(!0)}),s.jsx("span",{className:"text-sm font-semibold",children:"Production mode"})]}),s.jsxs("p",{className:"text-xs mt-1 text-gray-600",children:["Mutation operations (such as INSERT or UPDATE) are ",s.jsx("strong",{children:"forbidden"}),". You won't be able to insert new rows or edit existing data. Tables in this data source are read-only."]})]}),s.jsxs("label",{className:vt.modeSelect,children:[s.jsxs("div",{children:[s.jsx("input",{type:"radio",name:"production-mode",className:"mr-2",checked:!p,onChange:()=>m(!1)}),s.jsx("span",{className:"text-sm font-semibold",children:"Dev mode"})]}),s.jsxs("p",{className:"text-xs mt-1 text-gray-600",children:["Mutation operations (such as INSERT or UPDATE) are ",s.jsx("strong",{children:"allowed"}),". You will be able to insert new rows and edit existing data."]})]})]})]})]}),s.jsxs("div",{className:"flex justify-end gap-1 mt-2",children:[s.jsx("button",{onClick:d,className:"button tertiary",disabled:g,children:"Cancel"}),s.jsx("button",{onClick:h,className:"button primary",disabled:g,children:"Create"})]})]})},lu="_data-source-entry_4bkbg_2",cu="_action-title_4bkbg_2",uu="_recent-tabs-container_4bkbg_2",du="_recent-tabs-entry_4bkbg_2",hu="_home-action-button_4bkbg_2",mu="_home-gray-card_4bkbg_2",fu="_home-card-title_4bkbg_2",pu="_home-card-grid-content_4bkbg_2",gu="_useful-links_4bkbg_2",X={dataSourceEntry:lu,actionTitle:cu,recentTabsContainer:uu,recentTabsEntry:du,homeActionButton:hu,homeGrayCard:mu,homeCardTitle:fu,homeCardGridContent:pu,usefulLinks:gu},xu=e=>l.createElement("svg",{fill:"#000000",width:"800px",height:"800px",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",...e},l.createElement("path",{d:"m24.129 23.412-.508-.484c-.251-.331-.518-.624-.809-.891l-.005-.004q-.448-.407-.931-.774-.387-.266-1.064-.641c-.371-.167-.661-.46-.818-.824l-.004-.01-.048-.024c.212-.021.406-.06.592-.115l-.023.006.57-.157c.236-.074.509-.122.792-.133h.006c.298-.012.579-.06.847-.139l-.025.006q.194-.048.399-.109t.351-.109v-.169q-.145-.217-.351-.496c-.131-.178-.278-.333-.443-.468l-.005-.004q-.629-.556-1.303-1.076c-.396-.309-.845-.624-1.311-.916l-.068-.04c-.246-.162-.528-.312-.825-.435l-.034-.012q-.448-.182-.883-.399c-.097-.048-.21-.09-.327-.119l-.011-.002c-.117-.024-.217-.084-.29-.169l-.001-.001c-.138-.182-.259-.389-.355-.609l-.008-.02q-.145-.339-.314-.651-.363-.702-.702-1.427t-.651-1.452q-.217-.484-.399-.967c-.134-.354-.285-.657-.461-.942l.013.023c-.432-.736-.863-1.364-1.331-1.961l.028.038c-.463-.584-.943-1.106-1.459-1.59l-.008-.007c-.509-.478-1.057-.934-1.632-1.356l-.049-.035q-.896-.651-1.96-1.282c-.285-.168-.616-.305-.965-.393l-.026-.006-1.113-.278-.629-.048q-.314-.024-.629-.024c-.148-.078-.275-.171-.387-.279-.11-.105-.229-.204-.353-.295l-.01-.007c-.605-.353-1.308-.676-2.043-.93l-.085-.026c-.193-.113-.425-.179-.672-.179-.176 0-.345.034-.499.095l.009-.003c-.38.151-.67.458-.795.84l-.003.01c-.073.172-.115.371-.115.581 0 .368.13.705.347.968l-.002-.003q.544.725.834 1.14.217.291.448.605c.141.188.266.403.367.63l.008.021c.056.119.105.261.141.407l.003.016q.048.206.121.448.217.556.411 1.14c.141.425.297.785.478 1.128l-.019-.04q.145.266.291.52t.314.496c.065.098.147.179.241.242l.003.002c.099.072.164.185.169.313v.001c-.114.168-.191.369-.217.586l-.001.006c-.035.253-.085.478-.153.695l.008-.03c-.223.666-.351 1.434-.351 2.231 0 .258.013.512.04.763l-.003-.031c.06.958.349 1.838.812 2.6l-.014-.025c.197.295.408.552.641.787.168.188.412.306.684.306.152 0 .296-.037.422-.103l-.005.002c.35-.126.599-.446.617-.827v-.002c.048-.474.12-.898.219-1.312l-.013.067c.024-.063.038-.135.038-.211 0-.015-.001-.03-.002-.045v.002q-.012-.109.133-.206v.048q.145.339.302.677t.326.677c.295.449.608.841.952 1.202l-.003-.003c.345.372.721.706 1.127 1.001l.022.015c.212.162.398.337.566.528l.004.004c.158.186.347.339.56.454l.01.005v-.024h.048c-.039-.087-.102-.157-.18-.205l-.002-.001c-.079-.044-.147-.088-.211-.136l.005.003q-.217-.217-.448-.484t-.423-.508q-.508-.702-.969-1.467t-.871-1.555q-.194-.387-.375-.798t-.351-.798c-.049-.099-.083-.213-.096-.334v-.005c-.006-.115-.072-.214-.168-.265l-.002-.001c-.121.206-.255.384-.408.545l.001-.001c-.159.167-.289.364-.382.58l-.005.013c-.141.342-.244.739-.289 1.154l-.002.019q-.072.641-.145 1.318l-.048.024-.024.024c-.26-.053-.474-.219-.59-.443l-.002-.005q-.182-.351-.326-.69c-.248-.637-.402-1.374-.423-2.144v-.009c-.009-.122-.013-.265-.013-.408 0-.666.105-1.308.299-1.91l-.012.044q.072-.266.314-.896t.097-.871c-.05-.165-.143-.304-.265-.41l-.001-.001c-.122-.106-.233-.217-.335-.335l-.003-.004q-.169-.244-.326-.52t-.278-.544c-.165-.382-.334-.861-.474-1.353l-.022-.089c-.159-.565-.336-1.043-.546-1.503l.026.064c-.111-.252-.24-.47-.39-.669l.006.008q-.244-.326-.436-.617-.244-.314-.484-.605c-.163-.197-.308-.419-.426-.657l-.009-.02c-.048-.097-.09-.21-.119-.327l-.002-.011c-.011-.035-.017-.076-.017-.117 0-.082.024-.159.066-.223l-.001.002c.011-.056.037-.105.073-.145.039-.035.089-.061.143-.072h.002c.085-.055.188-.088.3-.088.084 0 .165.019.236.053l-.003-.001c.219.062.396.124.569.195l-.036-.013q.459.194.847.375c.298.142.552.292.792.459l-.018-.012q.194.121.387.266t.411.291h.339q.387 0 .822.037c.293.023.564.078.822.164l-.024-.007c.481.143.894.312 1.286.515l-.041-.019q.593.302 1.125.641c.589.367 1.098.743 1.577 1.154l-.017-.014c.5.428.954.867 1.38 1.331l.01.012c.416.454.813.947 1.176 1.464l.031.047c.334.472.671 1.018.974 1.584l.042.085c.081.154.163.343.234.536l.011.033q.097.278.217.57.266.605.57 1.221t.57 1.198l.532 1.161c.187.406.396.756.639 1.079l-.011-.015c.203.217.474.369.778.422l.008.001c.368.092.678.196.978.319l-.047-.017c.143.065.327.134.516.195l.04.011c.212.065.396.151.565.259l-.009-.005c.327.183.604.363.868.559l-.021-.015q.411.302.822.57.194.145.651.423t.484.52c-.114-.004-.249-.007-.384-.007-.492 0-.976.032-1.45.094l.056-.006c-.536.072-1.022.203-1.479.39l.04-.014c-.113.049-.248.094-.388.129l-.019.004c-.142.021-.252.135-.266.277v.001c.061.076.11.164.143.26l.002.006c.034.102.075.19.125.272l-.003-.006c.119.211.247.393.391.561l-.004-.005c.141.174.3.325.476.454l.007.005q.244.194.508.399c.161.126.343.25.532.362l.024.013c.284.174.614.34.958.479l.046.016c.374.15.695.324.993.531l-.016-.011q.291.169.58.375t.556.399c.073.072.137.152.191.239l.003.005c.091.104.217.175.36.193h.003v-.048c-.088-.067-.153-.16-.184-.267l-.001-.004c-.025-.102-.062-.191-.112-.273l.002.004zm-18.576-19.205q-.194 0-.363.012c-.115.008-.222.029-.323.063l.009-.003v.024h.048q.097.145.244.326t.266.351l.387.798.048-.024c.113-.082.2-.192.252-.321l.002-.005c.052-.139.082-.301.082-.469 0-.018 0-.036-.001-.054v.003c-.045-.044-.082-.096-.108-.154l-.001-.003-.081-.182c-.053-.084-.127-.15-.214-.192l-.003-.001c-.094-.045-.174-.102-.244-.169z"})),bu=e=>l.createElement("svg",{width:"800px",height:"800px",viewBox:"0 0 32 32",xmlns:"http://www.w3.org/2000/svg",...e},l.createElement("title",null,"file_type_pgsql"),l.createElement("path",{d:"M29.507,18.773a1.378,1.378,0,0,0-1.144-.921,2.619,2.619,0,0,0-.913.051,8.2,8.2,0,0,1-1.406.185,27.125,27.125,0,0,0,2.872-6.83c.953-3.689.444-5.369-.151-6.13A8.239,8.239,0,0,0,22.121,2a11.773,11.773,0,0,0-3.453.484A12.858,12.858,0,0,0,16.648,2.3a6.565,6.565,0,0,0-3.518.867,16.039,16.039,0,0,0-2.484-.624,7.694,7.694,0,0,0-5.819.924C3.093,4.691,2.289,6.819,2.438,9.792A36.351,36.351,0,0,0,3.844,16.33a22.579,22.579,0,0,0,1.514,3.863A4.786,4.786,0,0,0,7.8,22.742a2.4,2.4,0,0,0,2.379-.516,2.08,2.08,0,0,0,.5.43,3.328,3.328,0,0,0,.944.4,5.069,5.069,0,0,0,3.3-.2c.006.171.011.335.014.477.006.229.013.454.021.665a11.641,11.641,0,0,0,.441,3.3c.016.043.037.107.059.176a3.975,3.975,0,0,0,.991,1.745,2.955,2.955,0,0,0,2.09.777,4.7,4.7,0,0,0,.977-.109A4.592,4.592,0,0,0,22.607,28.1c.811-1.155,1.206-2.894,1.277-5.635.009-.078.018-.152.026-.222l.017-.145.191.017.049,0a7.562,7.562,0,0,0,3.163-.548c.631-.293,2.654-1.361,2.177-2.8"}),l.createElement("path",{d:"M27.689,19.053c-3.163.652-3.38-.418-3.38-.418C27.648,13.68,29.044,7.39,27.839,5.851c-3.286-4.2-8.975-2.213-9.07-2.162l-.031.006a11.28,11.28,0,0,0-2.11-.22,5.212,5.212,0,0,0-3.34,1S3.14.294,3.612,9.733c.1,2.008,2.878,15.194,6.191,11.211,1.211-1.456,2.381-2.688,2.381-2.688a3.071,3.071,0,0,0,2.006.512l.057-.048a2.21,2.21,0,0,0,.023.567c-.854.954-.6,1.121-2.309,1.472-1.726.356-.712.989-.05,1.155a3.508,3.508,0,0,0,3.915-1.272l-.05.2c.334.268.569,1.742.53,3.079a8.481,8.481,0,0,0,.2,2.971c.264.717.526,2.329,2.769,1.849a3.307,3.307,0,0,0,2.98-3.179c.1-1.234.313-1.052.326-2.155l.174-.522c.2-1.673.032-2.213,1.186-1.962l.281.025a6.4,6.4,0,0,0,2.615-.44c1.406-.652,2.239-1.742.853-1.455h0",style:{fill:"#336791"}}),l.createElement("path",{d:"M13.882,10.631a.981.981,0,0,0-.674.1.247.247,0,0,0-.1.164.48.48,0,0,0,.117.314.881.881,0,0,0,.559.349.637.637,0,0,0,.09.006.725.725,0,0,0,.687-.467c.035-.248-.326-.414-.676-.463m9.442.008c-.027-.195-.374-.25-.7-.2s-.647.194-.62.389a.667.667,0,0,0,.62.411.592.592,0,0,0,.083-.006.8.8,0,0,0,.451-.247.5.5,0,0,0,.169-.343",style:{fill:"#fff"}}),l.createElement("path",{d:"M28.741,18.979c-.121-.365-.509-.482-1.154-.349-1.915.4-2.6.121-2.826-.044a26.327,26.327,0,0,0,3.373-7.565,14.374,14.374,0,0,0,.5-3.253,3.513,3.513,0,0,0-.509-2.2,7.482,7.482,0,0,0-6.049-2.825,10.363,10.363,0,0,0-3.5.551,8.717,8.717,0,0,0-1.968-.253,5.684,5.684,0,0,0-3.372.929,15.051,15.051,0,0,0-2.74-.718,6.978,6.978,0,0,0-5.242.805c-1.5,1.064-2.2,2.966-2.061,5.653a35.489,35.489,0,0,0,1.373,6.348c1.07,3.505,2.233,5.49,3.457,5.9a1.548,1.548,0,0,0,.491.081,2.049,2.049,0,0,0,1.563-.886q1.042-1.25,2.155-2.438a3.472,3.472,0,0,0,1.55.417l0,.042q-.14.166-.273.338c-.375.475-.452.574-1.658.823-.343.071-1.254.259-1.267.9-.014.7,1.077.991,1.2,1.022a5.144,5.144,0,0,0,1.249.162,3.634,3.634,0,0,0,2.5-.934,23.674,23.674,0,0,0,.381,5.684,2.854,2.854,0,0,0,2.729,2.1,4.378,4.378,0,0,0,.917-.1,3.462,3.462,0,0,0,3.156-3.212c.177-1.026.481-3.475.624-4.789a3.859,3.859,0,0,0,1.11.137,6.6,6.6,0,0,0,2.519-.48c.712-.331,2-1.141,1.763-1.846ZM24.051,10.1a7.968,7.968,0,0,1-.116,1.107,10.229,10.229,0,0,0-.14,1.3,9.859,9.859,0,0,0,.1,1.47,5.236,5.236,0,0,1-.229,2.986,3.882,3.882,0,0,1-.207-.426c-.058-.141-.185-.368-.359-.681-.68-1.22-2.274-4.078-1.458-5.244.243-.347.86-.7,2.408-.512ZM22.174,3.531a6.617,6.617,0,0,1,5.334,2.522c.975,1.245-.1,6.912-3.205,11.8l-.094-.119-.039-.049a5.524,5.524,0,0,0,.506-3.8,9.114,9.114,0,0,1-.1-1.352,9.572,9.572,0,0,1,.131-1.206,7.614,7.614,0,0,0,.123-1.493.619.619,0,0,0,.013-.21,8.381,8.381,0,0,0-1.912-3.6,8.61,8.61,0,0,0-3.039-2.284,10.246,10.246,0,0,1,2.28-.214ZM9.479,20.654c-.627.754-1.061.61-1.2.562-.928-.31-2.006-2.272-2.955-5.384a35.167,35.167,0,0,1-1.34-6.159c-.12-2.4.462-4.074,1.73-4.974,2.063-1.463,5.456-.587,6.819-.143-.02.019-.04.037-.059.057-2.237,2.259-2.184,6.119-2.178,6.355,0,.091.007.22.018.4a15.969,15.969,0,0,1-.081,3.226A4.08,4.08,0,0,0,11.3,18.007q.133.138.278.262c-.383.41-1.216,1.318-2.1,2.385Zm2.39-3.19a3.3,3.3,0,0,1-.865-2.764,16.7,16.7,0,0,0,.087-3.381c-.006-.095-.011-.178-.014-.243A4.3,4.3,0,0,1,14,10.223a1.188,1.188,0,0,1,.918,1.026c.646,2.989.085,4.234-.365,5.235-.093.206-.181.4-.255.6l-.058.156a10.218,10.218,0,0,0-.368,1.109,2.788,2.788,0,0,1-2-.887Zm.113,4.03a1.733,1.733,0,0,1-.523-.225,2.553,2.553,0,0,1,.557-.166c1.418-.292,1.637-.5,2.116-1.105.11-.139.234-.3.406-.489h0c.256-.287.374-.238.586-.15a.829.829,0,0,1,.408.525.585.585,0,0,1-.05.491A3.1,3.1,0,0,1,11.983,21.495ZM19.406,28.4a2.113,2.113,0,0,1-2.754-1.526,31.129,31.129,0,0,1-.3-6.853.392.392,0,0,0-.017-.124,1.643,1.643,0,0,0-.048-.23,1.589,1.589,0,0,0-.862-1.034,1.216,1.216,0,0,0-.793-.1,9.586,9.586,0,0,1,.342-1.022l.058-.157c.066-.177.148-.36.235-.554.471-1.047,1.117-2.482.416-5.722a2.044,2.044,0,0,0-2.468-1.669A5.694,5.694,0,0,0,11.328,10c-.078.04-.15.078-.216.115A8.244,8.244,0,0,1,13.03,5.163,4.711,4.711,0,0,1,16.6,3.827,7.567,7.567,0,0,1,22.381,6.59,8.774,8.774,0,0,1,23.963,9.3c-1.463-.149-2.458.14-2.962.861-1.1,1.568.6,4.612,1.416,6.075.15.268.279.5.319.6a5.432,5.432,0,0,0,.861,1.387c.077.1.152.189.208.271-.443.128-1.239.423-1.166,1.9-.058.74-.474,4.205-.686,5.43-.279,1.617-.874,2.22-2.548,2.579Zm7.242-8.288a5.714,5.714,0,0,1-1.931.4,2.422,2.422,0,0,1-1.3-.167c-.045-.919.3-1.015.66-1.117.057-.016.112-.032.166-.05a1.353,1.353,0,0,0,.11.08c.639.422,1.78.467,3.39.135l.018,0a4.334,4.334,0,0,1-1.116.72Z",style:{fill:"#fff"}})),it=({size:e,type:t})=>t==="mysql"?s.jsx(xu,{width:e,height:e}):s.jsx(bu,{width:e,height:e}),[vu,On]=ye({show:!1}),[yu,Nn]=ye({show:!1}),[wu,_n]=ye(void 0),Cu=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{d:"M256 32C132.3 32 32 134.9 32 261.7c0 101.5 64.2 187.5 153.2 217.9a17.56 17.56 0 003.8.4c8.3 0 11.5-6.1 11.5-11.4 0-5.5-.2-19.9-.3-39.1a102.4 102.4 0 01-22.6 2.7c-43.1 0-52.9-33.5-52.9-33.5-10.2-26.5-24.9-33.6-24.9-33.6-19.5-13.7-.1-14.1 1.4-14.1h.1c22.5 2 34.3 23.8 34.3 23.8 11.2 19.6 26.2 25.1 39.6 25.1a63 63 0 0025.6-6c2-14.8 7.8-24.9 14.2-30.7-49.7-5.8-102-25.5-102-113.5 0-25.1 8.7-45.6 23-61.6-2.3-5.8-10-29.2 2.2-60.8a18.64 18.64 0 015-.5c8.1 0 26.4 3.1 56.6 24.1a208.21 208.21 0 01112.2 0c30.2-21 48.5-24.1 56.6-24.1a18.64 18.64 0 015 .5c12.2 31.6 4.5 55 2.2 60.8 14.3 16.1 23 36.6 23 61.6 0 88.2-52.4 107.6-102.3 113.3 8 7.1 15.2 21.1 15.2 42.5 0 30.7-.3 55.5-.3 63 0 5.4 3.1 11.5 11.4 11.5a19.35 19.35 0 004-.4C415.9 449.2 480 363.1 480 261.7 480 134.9 379.7 32 256 32z"})),ju=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{d:"M227.6 213.1H256v57.1h-28.4z"}),l.createElement("path",{d:"M0 156v171.4h142.2V356H256v-28.6h256V156zm142.2 142.9h-28.4v-85.7H85.3v85.7H28.4V184.6h113.8zm142.2 0h-56.9v28.6h-56.9V184.6h113.8zm199.2 0h-28.4v-85.7h-28.4v85.7h-28.4v-85.7H370v85.7h-56.9V184.6h170.7v114.3z"})),Nu=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{d:"M416 221.25V416a48 48 0 01-48 48H144a48 48 0 01-48-48V96a48 48 0 0148-48h98.75a32 32 0 0122.62 9.37l141.26 141.26a32 32 0 019.37 22.62z",fill:"none",stroke:"currentColor",strokeLinejoin:"round",strokeWidth:32}),l.createElement("path",{d:"M256 56v120a32 32 0 0032 32h120M176 288h160M176 368h160",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32})),_u=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{d:"M336 208v-95a80 80 0 00-160 0v95",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32}),l.createElement("rect",{x:96,y:208,width:320,height:272,rx:48,ry:48,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32})),nn=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("title",null,"Search"),l.createElement("path",{d:"M221.09 64a157.09 157.09 0 10157.09 157.09A157.1 157.1 0 00221.09 64z",fill:"none",stroke:"currentColor",strokeMiterlimit:10,strokeWidth:32}),l.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeMiterlimit:10,strokeWidth:32,d:"M338.29 338.29L448 448"})),ra=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{d:"M145.61 464h220.78c19.8 0 35.55-16.29 33.42-35.06C386.06 308 304 310 304 256s83.11-51 95.8-172.94c2-18.78-13.61-35.06-33.41-35.06H145.61c-19.8 0-35.37 16.28-33.41 35.06C124.89 205 208 201 208 256s-82.06 52-95.8 172.94c-2.14 18.77 13.61 35.06 33.41 35.06z",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32}),l.createElement("path",{d:"M343.3 432H169.13c-15.6 0-20-18-9.06-29.16C186.55 376 240 356.78 240 326V224c0-19.85-38-35-61.51-67.2-3.88-5.31-3.49-12.8 6.37-12.8h142.73c8.41 0 10.23 7.43 6.4 12.75C310.82 189 272 204.05 272 224v102c0 30.53 55.71 47 80.4 76.87 9.95 12.04 6.47 29.13-9.1 29.13z",fill:"currentColor"})),aa=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{d:"M436.67 184.11a27.17 27.17 0 01-38.3 0l-22.48-22.49a27.15 27.15 0 010-38.29l50.89-50.89a.85.85 0 00-.26-1.38C393.68 57 351.09 64.15 324.05 91c-25.88 25.69-27.35 64.27-17.87 98a27 27 0 01-7.67 27.14l-173 160.76a40.76 40.76 0 1057.57 57.54l162.15-173.3a27 27 0 0126.77-7.7c33.46 8.94 71.49 7.26 97.07-17.94 27.49-27.08 33.42-74.94 20.1-102.33a.85.85 0 00-1.36-.22z",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeMiterlimit:10,strokeWidth:32}),l.createElement("path",{d:"M224 284c-17.48-17-25.49-24.91-31-30.29a18.24 18.24 0 01-3.33-21.35 20.76 20.76 0 013.5-4.62l15.68-15.29a18.66 18.66 0 015.63-3.87 18.11 18.11 0 0120 3.62c5.45 5.29 15.43 15 33.41 32.52M317.07 291.3c40.95 38.1 90.62 83.27 110 99.41a13.46 13.46 0 01.94 19.92L394.63 444a14 14 0 01-20.29-.76c-16.53-19.18-61.09-67.11-99.27-107",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32}),l.createElement("path",{d:"M17.34 193.5l29.41-28.74a4.71 4.71 0 013.41-1.35 4.85 4.85 0 013.41 1.35h0a9.86 9.86 0 008.19 2.77c3.83-.42 7.92-1.6 10.57-4.12 6-5.8-.94-17.23 4.34-24.54a207 207 0 0119.78-22.6c6-5.88 29.84-28.32 69.9-44.45A107.31 107.31 0 01206.67 64c22.59 0 40 10 46.26 15.67a89.54 89.54 0 0110.28 11.64 78.92 78.92 0 00-9.21-2.77 68.82 68.82 0 00-20-1.26c-13.33 1.09-29.41 7.26-38 14-13.9 11-19.87 25.72-20.81 44.71-.68 14.12 2.72 22.1 36.1 55.49a6.6 6.6 0 01-.34 9.16l-18.22 18a6.88 6.88 0 01-9.54.09c-21.94-21.94-36.65-33.09-45-38.16s-15.07-6.5-18.3-6.85a30.85 30.85 0 00-18.27 3.87 11.39 11.39 0 00-2.64 2 14.14 14.14 0 00.42 20.08l1.71 1.6a4.63 4.63 0 010 6.64L71.73 246.6a4.71 4.71 0 01-3.41 1.4 4.86 4.86 0 01-3.41-1.35l-47.57-46.43a4.88 4.88 0 010-6.72z",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32})),Qo=20,co="text-(--text-color-primary)",ku=()=>{const e=Tn("Home");return s.jsxs("div",{className:X.homeActionButton,onClick:e,children:[s.jsx(nn,{width:Qo,height:Qo,className:co}),s.jsx("h2",{className:X.actionTitle,children:"Start new query"})]})},Su=()=>s.jsxs("div",{className:X.homeActionButton,onClick:()=>On({show:!0}),children:[s.jsx(ra,{width:20,height:20,className:co}),s.jsx("h2",{className:X.actionTitle,children:"Saved queries"})]}),Eu=()=>{const[e,t]=l.useState(void 0),n=An(me.EDITOR),o=r=>{n?t(r):Se.error("You don't have permission to connect new data sources in this team")};return s.jsxs("div",{children:[e&&s.jsx(iu,{show:!0,dbType:e,onClose:()=>t(void 0)}),s.jsx("div",{className:X.homeActionButton,onClick:()=>o("postgres"),children:s.jsx("p",{className:X.actionTitle,children:"🧙‍♂️ Connection wizard"})})]})},Ru=()=>{const e=Y(),{data:t}=bs(),n=Tn("Home"),o=()=>{t&&t.length>0?e(D.workbenchTab.build({id:t[0].id})):n()};return s.jsxs("div",{className:X.homeActionButton,onClick:o,children:[s.jsx(aa,{width:20,height:20,className:co}),s.jsx("h2",{className:X.actionTitle,children:"Workbench"})]})},Lu=()=>{const{data:e}=ve(),{data:t}=io({teamId:e?.teamId}),n=o=>{_n(o)};return!t||t.length===0?null:s.jsxs("div",{className:X.homeGrayCard,children:[s.jsx("h2",{className:X.homeCardTitle,children:"Data sources"}),s.jsx("div",{className:X.homeCardGridContent,children:t?.map(o=>s.jsxs("div",{className:X.dataSourceEntry,onClick:()=>n(o.id),tabIndex:0,children:[!o.allowInsert&&s.jsx(_u,{"data-tooltip-id":"default","data-tooltip-content":"This datasource is read-only",width:18,height:18,className:"absolute top-2 right-2"}),s.jsx(it,{size:32,type:o.dbType}),s.jsxs("div",{className:"overflow-hidden",children:[s.jsx("p",{className:"text-(--text-color-primary) font-semibold truncate",children:o.name}),s.jsxs("p",{className:"text-sm text-(--text-color-secondary) truncate",children:[o.dbUrl,":",o.dbPort]})]})]},o.id))})]})},zt=24,ia=()=>s.jsxs("div",{className:X.usefulLinks,children:[s.jsxs("a",{href:"https://dataramen.xyz/",target:"_blank",children:[s.jsx(Nu,{width:zt,height:zt}),s.jsx("span",{children:"Docs"})]}),s.jsxs("a",{href:"https://github.com/OleksandrDemian/dataramen",target:"_blank",children:[s.jsx(Cu,{width:zt,height:zt}),s.jsx("span",{children:"GitHub"})]}),s.jsxs("a",{href:"https://www.npmjs.com/package/@dataramen/cli",target:"_blank",children:[s.jsx(ju,{width:zt,height:zt}),s.jsx("span",{children:"NPM"})]})]}),Tu=()=>{const{data:e}=ve(),{data:t,isLoading:n}=hc(e?.teamId),o=Y();if(n||!t?.length)return null;const r=a=>{o(D.workbenchTab.build({id:a}))};return s.jsxs("div",{className:X.recentTabsContainer,children:[s.jsx("h2",{className:X.homeCardTitle+" px-4 mb-4",children:"Recent tabs"}),t.map(a=>s.jsxs("div",{className:X.recentTabsEntry,onClick:()=>r(a.id),children:[s.jsx("p",{className:"text-(--text-color-primary) truncate",children:a.name}),s.jsxs("p",{className:"flex items-center gap-2",children:[s.jsx(it,{size:20,type:a.dataSourceType}),s.jsx("span",{className:"text-sm text-(--text-color-secondary) truncate",children:a.dataSourceName})]})]},a.id))]})},Au=()=>{const{data:e}=ve(),{data:t}=io({teamId:e?.teamId}),n=!!t&&t.length>0,o=!!e;return s.jsx("div",{className:"page-container h-screen max-h-screen overflow-y-auto no-scrollbar",children:s.jsxs("div",{className:"page-content",children:[s.jsxs("div",{className:"py-10 text-center w-full sticky top-0 z-0",children:[s.jsx("h1",{className:"comfortaa text-3xl font-semibold text-(--text-color-primary) mb-4",children:"DataRamen"}),s.jsx(ia,{})]}),s.jsxs("div",{className:"flex flex-col gap-8 mt-8 bg-(--bg) z-1",children:[o&&!n&&s.jsx(fe,{variant:"warning",className:"font-semibold",children:"Connect at least one data source to start using DataRamen"}),s.jsxs("div",{className:X.homeGrayCard,children:[s.jsx("h2",{className:X.homeCardTitle,children:"Quick actions"}),s.jsxs("div",{className:X.homeCardGridContent,children:[s.jsx(ku,{}),s.jsx(Eu,{}),o&&s.jsx(Ru,{}),s.jsx(Su,{})]})]}),o&&s.jsx(Lu,{}),s.jsx(Tu,{})]})]})})},[Ou,uo]=ye(void 0),Pu=()=>uo(void 0);function yt(e,t){if(e==null)return"";switch(t){case"json":case"jsonb":return JSON.stringify(e,null,2)}if(e===0||e===!1)return e.toString();switch(typeof e){case"string":return e;case"number":case"boolean":return e.toString();default:return JSON.stringify(e)}}const ts=e=>e.distinct?[e.fn,"DISTINCT",e.value].join(" "):[e.fn,e.value].join(" "),et=e=>{let t=e.replace(/[_-]+/g," ");return t=t.replace(/([a-z0-9])([A-Z])/g,"$1 $2"),t=t.toLowerCase().replace(/\b\w/g,n=>n.toUpperCase()),t},Mu="_container_1i3n1_2",Iu="_header_1i3n1_2",Du="_fields-container_1i3n1_2",$u="_field-label_1i3n1_2",Fu="_actions_1i3n1_2",xn={container:Mu,header:Iu,fieldsContainer:Du,fieldLabel:$u,actions:Fu},Bu=(e,t,n)=>be({queryKey:["entity",e,t,n],queryFn:async()=>{const{data:o}=await $.get(`/runner/${e}/entity/${t}`,{params:n?.reduce((r,a)=>(r[a[0]]=a[1],r),{})});return o.data},retry:1,enabled:!!t&&!!e&&!!n,staleTime:0}),Wu=()=>Z({mutationFn:async e=>{const{data:t}=await $.post(`/runner/${e.datasourceId}/update`,e);return t.data}}),zu=()=>Z({mutationFn:async e=>{const{data:t}=await $.post(`/runner/${e.datasourceId}/insert`,e);return t.data}}),ho=e=>l.useMemo(()=>{if(e)return e instanceof ci?e.response?.data.error?e.response.data.error:e.response?.data?.message?e.response.data.message:e.message:e instanceof Error?e.message:"Undefined error"},[e]),mo=()=>{const{pathname:e}=le();return l.useMemo(()=>Kt({path:D.workbenchTab.path,end:!1},e)?.params.id,[e])},la=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{d:"M248 64C146.39 64 64 146.39 64 248s82.39 184 184 184 184-82.39 184-184S349.61 64 248 64z",fill:"none",stroke:"currentColor",strokeMiterlimit:10,strokeWidth:32}),l.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32,d:"M220 220h32v116"}),l.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeMiterlimit:10,strokeWidth:32,d:"M208 340h88"}),l.createElement("path",{d:"M248 130a26 26 0 1026 26 26 26 0 00-26-26z",fill:"currentColor"})),qu="_container_1n8wr_2",Uu={container:qu},Pn=({containerClassName:e,className:t,...n})=>s.jsxs("label",{className:P(Uu.container,e),children:[s.jsx(nn,{width:16,height:16}),s.jsx("input",{className:P("flex-1 outline-none",t),...n})]}),Hu=({data:e})=>{const[t,{change:n,touched:o}]=Sn({}),r=mo(),{mutateAsync:a,error:i}=zu(),c=ho(i),{data:u}=gs(e.dataSourceId),[h,m]=l.useState(""),d=l.useMemo(()=>u?.find(b=>b.tableName===e.table),[u,e.table]),g=l.useMemo(()=>{if(!d)return[];if(!h)return d.columns.map(x=>({...x,label:et(x.name)}));const b=h.toLowerCase();return d.columns.filter(x=>x.name.toLowerCase().includes(b)).map(x=>({...x,label:et(x.name)}))},[h,d]),p=()=>{const b={};for(const x of o)b[x]=t[x];a({datasourceId:e.dataSourceId,table:e.table,values:b}).then(()=>{Pu(),r&&ta(r)})};return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:xn.header,children:[s.jsxs("p",{className:"text-lg font-semibold",children:["Insert new record in ",s.jsx("span",{className:"underline",children:e.table})]}),c&&s.jsx(fe,{variant:"danger",children:s.jsx("p",{children:c})}),s.jsx(Pn,{containerClassName:"mt-2",className:"text-sm",value:h,onChange:b=>m(b.target.value),placeholder:"Filter columns",autoFocus:!0})]}),s.jsx("div",{className:xn.container,children:s.jsx("div",{className:xn.fieldsContainer,children:g.map(b=>s.jsxs("label",{className:xn.fieldLabel,children:[s.jsxs("div",{className:"flex justify-between mb-0.5",children:[s.jsxs("p",{children:[b.isPrimary?"🔐":"🏷️"," ",b.label]}),s.jsxs("p",{className:"text-blue-800 text-sm",children:["[",b.name,": ",b.type,"]"]})]}),s.jsx("input",{className:"input w-full",value:yt(t[b.name]),onChange:n(b.name)})]},b.name))})}),s.jsxs("div",{className:xn.actions,children:[s.jsx("span",{"data-tooltip-id":"default","data-tooltip-content":"Tip: use = to write raw SQL. Ex: =NULL or =NOW()",children:s.jsx(la,{className:"text-(--text-color-secondary)",width:22,height:22})}),s.jsx("span",{className:"flex-1"}),s.jsx("button",{disabled:!o.length,className:"button primary",onClick:p,children:"Run insert"})]})]})},Vu=()=>{const e=Ou(),[t,n]=l.useState(void 0);l.useEffect(()=>{e&&n(e)},[e]);const o=()=>uo(void 0);return s.jsxs(we,{isVisible:e!=null,onClose:o,onClosed:()=>n(void 0),noPadding:!0,children:[s.jsx(at,{onClick:o}),t&&s.jsx(Hu,{data:t})]})},[Qu,Mn]=ye(void 0),Ku=()=>Mn(void 0),Gu="_container_1mjjd_2",Yu="_header_1mjjd_2",Ju="_fields-container_1mjjd_2",Xu="_field-label_1mjjd_2",Zu="_actions_1mjjd_2",bn={container:Gu,header:Yu,fieldsContainer:Ju,fieldLabel:Xu,actions:Zu},ot=()=>Date.now().toString(36)+Math.random().toString(36).substring(2),ca=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{d:"M384 224v184a40 40 0 01-40 40H104a40 40 0 01-40-40V168a40 40 0 0140-40h167.48M336 64h112v112M224 288L440 72",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32})),ed=e=>{if(e==null)return"<NULL>"},td=({data:e})=>{const[t,{change:n,set:o,reset:r,touched:a}]=Sn({}),i=mo(),c=Y(),[u,h]=l.useState(""),{data:m,isLoading:d}=Bu(e.dataSourceId,e.tableName,e.entityId),{mutateAsync:g,error:p}=Wu(),{mutateAsync:b}=St(),x=ho(p),v=An(me.EDITOR),{data:y}=gs(e.dataSourceId),{data:f}=ps(e.dataSourceId),w=l.useMemo(()=>y?.find(k=>k.tableName===e.tableName),[e.tableName,y]),C=l.useMemo(()=>{if(!w)return[];if(!u)return w.columns.map(E=>({...E,label:et(E.name)}));const k=u.toLowerCase();return w.columns.filter(E=>E.name.toLowerCase().includes(k)).map(E=>({...E,label:et(E.name)}))},[u,w]),N=l.useMemo(()=>{const k={};if(!m?.entity)return k;for(let E=0;E<m.columns.length;E++)k[m.columns[E]?.column]=ed(m.entity[E]);return k},[m]);l.useEffect(()=>{const k=m?.entity;if(r(),k&&m?.columns)for(let E=0;E<m.columns.length;E++){const te=m.columns[E];o(te.column,yt(k[E]))}},[m,o,r]);const O=()=>{const k={};for(const E of a)k[E]=t[E];g({datasourceId:e.dataSourceId,table:e.tableName,filters:e.entityId.map(E=>({id:ot(),value:""+E[1],column:E[0],isEnabled:!0})),values:k}).then(()=>{Ku(),i&&ta(i)})},S=()=>{b({name:e.tableName,opts:en({dataSourceId:e.dataSourceId,table:e.tableName,filters:e.entityId.map(([k,E])=>({value:`${E}`,column:`${e.tableName}.${k}`,id:ot(),isEnabled:!0}))})}).then(({id:k})=>{c(D.workbenchTab.build({id:k})),Mn(void 0)})},_=!f?.allowUpdate||!v;return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:bn.header,children:[s.jsxs("p",{className:"text-lg font-semibold",children:[_?"View":"Edit"," row in ",s.jsx("span",{className:"underline",children:e?.tableName})]}),x&&s.jsx(fe,{variant:"danger",children:s.jsx("p",{children:x})}),s.jsx(Pn,{containerClassName:"mt-2",className:"text-sm",value:u,onChange:k=>h(k.target.value),placeholder:"Filter columns",autoFocus:!0})]}),s.jsx("div",{className:bn.container,children:s.jsx("div",{className:bn.fieldsContainer,children:C.map(k=>s.jsxs("label",{className:bn.fieldLabel,children:[s.jsxs("div",{className:"flex justify-between mb-0.5",children:[s.jsxs("p",{children:[k.isPrimary?"🔐":"🏷️"," ",k.label]}),s.jsxs("p",{className:"text-blue-800 text-sm",children:["[",k.name,": ",k.type,"]"]})]}),s.jsx("input",{disabled:k.isPrimary||d||_,className:"input w-full secondary",value:yt(t[k.name]),onChange:n(k.name),placeholder:N[k.name]})]},k.name))})}),s.jsxs("div",{className:bn.actions,children:[!_&&s.jsx("span",{"data-tooltip-id":"default","data-tooltip-content":"Tip: use = to write raw SQL. Ex: =NULL or =NOW()",children:s.jsx(la,{className:"text-(--text-color-secondary)",width:22,height:22})}),s.jsx("span",{className:"flex-1"}),s.jsxs("button",{className:"button tertiary flex gap-2 items-center",onClick:S,children:[s.jsx(ca,{width:16,height:16}),s.jsx("span",{children:"Open in new tab"})]}),!_&&s.jsx("button",{disabled:!a.length,className:"button primary",onClick:O,children:"Update"})]})]})},nd=()=>{const e=Qu(),[t,n]=l.useState(void 0);l.useEffect(()=>{e&&n(e)},[e]);const o=()=>Mn(void 0);return s.jsxs(we,{isVisible:e!=null,onClose:o,onClosed:()=>n(void 0),noPadding:!0,children:[s.jsx(at,{onClick:o}),t&&s.jsx(td,{data:t})]})},[sd,Os]=ye(void 0),fo=async e=>new Promise(t=>{Os({message:e,onCancel:()=>{t(!1),Os(void 0)},onConfirm:()=>{t(!0),Os(void 0)}})}),od=({confirm:e})=>s.jsxs("div",{children:[s.jsx("p",{children:e.message}),s.jsxs("div",{className:"flex gap-2 justify-end mt-4",children:[s.jsx("button",{className:"button tertiary",onClick:e.onCancel,children:"Cancel"}),s.jsx("button",{className:"button primary",onClick:e.onConfirm,children:"Confirm"})]})]}),rd=()=>{const e=sd(),[t,n]=l.useState(void 0);return l.useEffect(()=>{e&&n(e)},[e]),s.jsx(we,{isVisible:!!e,onClose:()=>e?.onCancel(),onClosed:()=>n(void 0),children:t&&s.jsx(od,{confirm:t})})},[ad,ns]=ye(void 0),In=async(e,t,n)=>new Promise(o=>{ns({message:e,defaultValue:t,alert:n,onCancel:()=>{ns(void 0),o(void 0)},onConfirm:r=>{ns(void 0),o(r)}})}),id="_root_ng9lp_1",ld={root:id},cd=({data:e})=>{const[t,n]=l.useState("");l.useEffect(()=>{e.defaultValue&&n(e.defaultValue)},[e]);const o=a=>{n(a.target.value)},r=a=>{a.key==="Enter"&&(a.preventDefault(),e.onConfirm(t)),a.key==="Escape"&&(a.preventDefault(),e.onCancel())};return s.jsxs("div",{className:ld.root,children:[s.jsx("h2",{className:"text-xl font-semibold",children:e.message}),e.alert&&s.jsx(fe,{variant:e.alert.type,className:"mt-2",children:e.alert.message}),s.jsx("input",{autoFocus:!0,className:"w-full input my-2",value:t,onChange:o,onKeyDown:r}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx("button",{className:"button tertiary",onClick:e.onCancel,children:"Cancel"}),s.jsx("button",{className:"button primary",onClick:()=>e.onConfirm(t),children:"Confirm"})]})]})},ud=()=>{const e=ad(),[t,n]=l.useState(void 0);return l.useEffect(()=>{e&&n(e)},[e]),s.jsx(we,{isVisible:!!e,onClose:()=>ns(void 0),onClosed:()=>n(void 0),children:t&&s.jsx(cd,{data:t})})},[dd,hd]=ye(void 0),ua=e=>{hd(e)},md="_textarea_vairh_2",fd={textarea:md},pd=()=>{const e=dd(),t=()=>{e&&(navigator.clipboard.writeText(e.toString()),Se.success("Copied!"))},n=()=>ua(void 0);return s.jsxs(we,{isVisible:!!e,onClose:n,backdropClose:!0,children:[s.jsx("textarea",{className:fd.textarea,readOnly:!0,defaultValue:e?.toString()}),s.jsxs("div",{className:"mt-2 flex gap-1 justify-end",children:[s.jsx("button",{className:"button primary",onClick:t,children:"Copy"}),s.jsx("button",{className:"button tertiary",onClick:n,children:"Close"})]})]})},gd="_tabs_7l589_2",xd="_mobile_7l589_2",bd="_tab_7l589_2",vd="_active_7l589_2",yd="_close-button_7l589_2",vn={tabs:gd,mobile:xd,tab:bd,active:vd,closeButton:yd},Ko=e=>window.matchMedia(e).matches;function da(e,{defaultValue:t=!1,initializeWithValue:n=!0}={}){const[o,r]=l.useState(()=>n?Ko(e):t);return l.useLayoutEffect(()=>{const a=window.matchMedia(e);function i(){r(()=>Ko(e))}return i(),a.addListener?a.addListener(i):a.addEventListener("change",i),()=>{a.removeListener?a.removeListener(i):a.removeEventListener("change",i)}},[e]),o}const po={laptop:"(min-width: 1024px)"},ha=()=>window.matchMedia(po.laptop).matches,wd="_table_z2h6l_2",Cd="_row-index-btn_z2h6l_2",jd="_semi-transparent_z2h6l_2",Nd="_table-loading_z2h6l_2",_d="_table-empty_z2h6l_2",kd="_table-row-cells_z2h6l_2",Sd="_header-cell_z2h6l_2",Ed="_header-actions_z2h6l_2",Rd="_cell_z2h6l_2",Ld="_value_z2h6l_2",Td="_table-config_z2h6l_2",Ad="_table-action_z2h6l_2",Od="_green-fixed_z2h6l_2",Pd="_gray_z2h6l_2",Md="_modal_z2h6l_2",Id="_selected-size_z2h6l_2",Dd="_pagination-indicator_z2h6l_2",L={table:wd,rowIndexBtn:Cd,semiTransparent:jd,tableLoading:Nd,tableEmpty:_d,tableRowCells:kd,headerCell:Sd,headerActions:Ed,cell:Rd,value:Ld,tableConfig:Td,tableAction:Ad,greenFixed:Od,gray:Pd,modal:Md,selectedSize:Id,paginationIndicator:Dd},Pe=l.createContext({name:"No name",hooks:[],availableJoins:[],allColumns:[],dataSourceId:"",entities:[],getValue:()=>{},getValueByIndex:()=>{},getColumnByIndex:()=>{},getColumnType:()=>{}}),Ce=l.createContext({state:en({}),setState:()=>{}}),Ge=l.createContext({}),ma={ON_ANIMATION_END:Symbol("ON_TRANSITION_END")},fa=()=>{const[e,t]=l.useState(),[n,o]=l.useState("hidden");return l.useMemo(()=>{const r=c=>{c.preventDefault(),o("in"),t({x:c.clientX-1,y:c.clientY-1})},a=()=>{o("out")},i=()=>{n==="in"?o("visible"):n==="out"&&(t(void 0),o("hidden"))};return{show:!!e,position:e,state:n,open:r,close:a,[ma.ON_ANIMATION_END]:i}},[e,n])},$d=e=>{if(e!=="ASC")return e==="DESC"?"ASC":"DESC"},Fd=()=>{const{state:e,setState:t}=l.useContext(Ce),n=l.useCallback(o=>{t(r=>{const a=r.orderBy[0];if(a&&a.column===o){const i=$d(a.direction);return i?{...r,orderBy:[{column:o,direction:i}]}:{...r,orderBy:[]}}return{...r,orderBy:[{column:o,direction:"DESC"}]}})},[t]);return{orderBy:e.orderBy,updateOrderBy:n}},Bd="_options-container_zqhnt_2",Wd="_filter-input_zqhnt_2",zd="_list_zqhnt_2",qd="_empty-text_zqhnt_2",wt={optionsContainer:Bd,filterInput:Wd,list:zd,emptyText:qd},Ud="_container_1209x_2",Hd="_animate-show_1209x_2",Vd="_animate-hide_1209x_2",Qd="_content_1209x_2",Kd="_backdrop_1209x_2",ft={container:Ud,animateShow:Hd,animateHide:Vd,content:Qd,backdrop:Kd},pa=({children:e,handler:t})=>{const n=l.useRef(t.close);n.current=t.close;const o=l.useMemo(()=>{if(!t.position)return;const a={};if(typeof window<"u"){const i=t.position.y>window.innerHeight/2,c=t.position.x>window.innerWidth/2;i?a.bottom=window.innerHeight-t.position.y:a.top=t.position.y,ha()?c?a.right=window.innerWidth-t.position.x:a.left=t.position.x:(a.right=36,a.left=36)}return a},[t.position]);if(vs({enabled:!!o,onClose:t.close}),!o)return null;const r=s.jsxs("div",{className:P(ft.container,t.state==="out"&&ft.animateHide,t.state==="in"&&ft.animateShow),onAnimationEnd:t[ma.ON_ANIMATION_END],children:[s.jsx("div",{className:ft.backdrop,onClick:a=>{a.stopPropagation(),a.preventDefault(),t.close()}}),s.jsx("div",{className:P(ft.content,t.state==="out"&&ft.animateHide,t.state==="in"&&ft.animateShow),style:o,children:e})]});return ro.createPortal(r,document.body)},xe=(e,t)=>e!=null&&e>t,Gd=(e,t)=>e!=null&&e<t,Yd="_root_1kihe_2",Jd="_content_1kihe_2",Xd="_table-name_1kihe_2",Zd="_sub_1kihe_2",Xe={root:Yd,content:Jd,tableName:Xd,sub:Zd},go=({hook:e,onClick:t})=>e.direction==="out"?s.jsx("button",{className:Xe.root,onClick:t,children:s.jsxs("div",{className:Xe.content,children:[s.jsx("p",{className:Xe.tableName,children:e.toTable}),s.jsxs("p",{className:Xe.sub,children:[e.toColumn," = ",e.fromTable,".",e.fromColumn]})]})},e.id):s.jsx("button",{className:Xe.root,onClick:t,children:s.jsxs("div",{className:Xe.content,children:[s.jsx("p",{className:Xe.tableName,children:e.fromTable}),s.jsxs("p",{className:Xe.sub,children:[e.fromColumn," = ",e.toTable,".",e.toColumn]})]})},e.id);function eh(e,t,n){return{name:`${e.fromTable} ${e.fromColumn} equals ${n}`,opts:en({table:e.fromTable,dataSourceId:t,filters:[{id:ot(),column:`${e.fromTable}.${e.fromColumn}`,value:n==null?"IS NULL":`${n}`,isEnabled:!0}]})}}const ga=({rowIndex:e,colIndex:t,onClose:n,className:o})=>{const[r,a]=l.useState(""),{dataSourceId:i,hooks:c,getColumnByIndex:u,getValue:h}=l.useContext(Pe),m=l.useMemo(()=>{if(t===void 0)return c;const v=u(t);return v?c.filter(y=>y.toColumn===v.column&&y.toTable===v.table):[]},[t,c,u]),d=St(),g=Y(),p=l.useMemo(()=>{const v=r.toLowerCase();return m.filter(y=>y.fromTable.toLowerCase().includes(v))},[r,m]),b=v=>{d.mutateAsync(eh(v,i,h(e,v.toTable,v.toColumn))).then(y=>{g(D.workbenchTab.build({id:y.id})),n?.()})},x=xe(p.length,0);return s.jsxs("div",{className:o,children:[s.jsx(Pn,{autoFocus:!0,className:wt.filterInput,placeholder:"Filter",value:r,onChange:v=>a(v.target.value)}),s.jsxs("div",{className:wt.list,children:[x&&p.map(v=>s.jsx(go,{hook:v,onClick:()=>b(v)},v.id)),!x&&s.jsx("p",{className:wt.emptyText,children:"Empty"})]})]})},th=({handler:e,rowIndex:t,colIndex:n})=>s.jsx(pa,{handler:e,children:s.jsx("div",{className:wt.optionsContainer,children:s.jsx(ga,{rowIndex:t,colIndex:n,className:"p-2",onClose:()=>{e.close()}})})}),xo=()=>{const{state:e,setState:t}=l.useContext(Ce),n=l.useCallback((r,a=!1)=>{t(i=>({...i,page:a?0:i.page,filters:r}))},[t]),o=l.useCallback(r=>{t(a=>({...a,filters:a.filters.filter(i=>i.id!==r)}))},[t]);return{filters:e.filters,removeFilter:o,setFilters:n}},nh=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:48,d:"M112 244l144-144 144 144M256 120v292"})),sh=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32,d:"M464 208L352 96 240 208M352 113.13V416M48 304l112 112 112-112M160 398V96"})),oh="_container_16nsh_2",rh="_animate-show_16nsh_2",ah="_animate-hide_16nsh_2",ih="_backdrop_16nsh_2",lh="_content_16nsh_2",pt={container:oh,animateShow:rh,animateHide:ah,backdrop:ih,content:lh},xa=({children:e,ref:t,onClosed:n})=>{const[o,r]=l.useState(void 0),[a,i]=l.useState("hidden"),c=l.useRef(null);if(l.useImperativeHandle(t,()=>({open:(m,d=!0)=>{d||(m.preventDefault(),m.stopPropagation());const g={},p=m.clientY>window.innerHeight/2,b=m.clientX>window.innerWidth/2;p?g.bottom=window.innerHeight-m.clientY:g.top=m.clientY,ha()?b?g.right=window.innerWidth-m.clientX:g.left=m.clientX:(g.right=36,g.left=36),r(g),i("in")},close:()=>{i("out")}}),[]),vs({enabled:a==="in"||a==="visible",onClose:()=>{i("out")}}),!o)return null;const u=()=>{a==="in"?i("visible"):a==="out"&&(r(void 0),i("hidden"),n?.())},h=s.jsxs("div",{className:P(pt.container,a==="out"&&pt.animateHide,a==="in"&&pt.animateShow),onAnimationEnd:u,children:[s.jsx("div",{className:pt.backdrop,onClick:()=>i("out")}),s.jsx("div",{ref:c,style:o,className:P(pt.content,a==="out"&&pt.animateHide,a==="in"&&pt.animateShow),children:e})]});return ro.createPortal(h,document.body)};function Ps(e,t,n){const o=e?.rows?.[t]?.[n],r=e?.columns?.[n];return{value:o,column:r}}const ch=({ref:e})=>{const{data:t}=l.useContext(Ge),{getColumnType:n}=l.useContext(Pe),{setState:o}=l.useContext(Ce);return{copyValue:(c,u)=>{const{value:h,column:m}=Ps(t?.result,c,u);if(m){const d=yt(h,n(m.full));navigator.clipboard.writeText(d),Se.success("Copied!"),e.current?.close()}},showValue:(c,u)=>{const{value:h,column:m}=Ps(t?.result,c,u);if(m){const d=yt(h,n(m.full));ua(d),e.current?.close()}},filterValue:(c,u)=>{const{value:h,column:m}=Ps(t?.result,c,u),d=m?.full||"";if(d){let g;if(h==null)g={id:ot(),isEnabled:!0,isAdvanced:!0,column:d,value:"IS NULL"};else{const p=yt(h,n(d));g={id:ot(),isEnabled:!0,column:d,value:p,fn:m?.fn}}o(p=>({...p,filters:[...p.filters,g]})),Se.success(`Added new filter on column ${m?.alias}`),e.current?.close()}}}},ba=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("rect",{x:128,y:128,width:336,height:336,rx:57,ry:57,fill:"none",stroke:"currentColor",strokeLinejoin:"round",strokeWidth:32}),l.createElement("path",{d:"M383.5 128l.5-24a56.16 56.16 0 00-56-56H112a64.19 64.19 0 00-64 64v216a56.16 56.16 0 0056 56h24",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32})),uh=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{d:"M255.66 112c-77.94 0-157.89 45.11-220.83 135.33a16 16 0 00-.27 17.77C82.92 340.8 161.8 400 255.66 400c92.84 0 173.34-59.38 221.79-135.25a16.14 16.14 0 000-17.47C428.89 172.28 347.8 112 255.66 112z",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32}),l.createElement("circle",{cx:256,cy:256,r:80,fill:"none",stroke:"currentColor",strokeMiterlimit:10,strokeWidth:32})),dh="_section-name_13huy_2",hh="_item_13huy_2",gt={sectionName:dh,item:hh},nt=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:48,d:"M184 112l144 144-144 144"})),va=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32,d:"M364.13 125.25L87 403l-23 45 44.99-23 277.76-277.13-22.62-22.62zM420.69 68.69l-22.62 22.62 22.62 22.63 22.62-22.63a16 16 0 000-22.62h0a16 16 0 00-22.62 0z"})),mh=({onClose:e,rowIndex:t,className:n})=>{const[o,r]=l.useState(""),{entities:a,dataSourceId:i,getValue:c}=l.useContext(Pe),u=l.useMemo(()=>{if(!o)return a;const m=o.toLowerCase();return a.filter(d=>d.toTable.toLowerCase().includes(m))},[a,o]),h=m=>{const d=c(t,m.fromTable,m.fromColumn);d?Mn({tableName:m.toTable,dataSourceId:i,entityId:[[m.toColumn,""+d]]}):Se.error(`Cannot open ${m.toTable} record. ${m.fromTable}.${m.fromColumn} is NULL`),e?.()};return s.jsxs("div",{className:n,children:[s.jsx(Pn,{autoFocus:!0,className:wt.filterInput,placeholder:"Filter",value:o,onChange:m=>r(m.target.value)}),s.jsx("div",{className:wt.list,children:xe(u.length,0)?u.map(m=>s.jsx(go,{hook:m,onClick:()=>h(m)},m.id)):s.jsx("p",{className:wt.emptyText,children:"Empty"})})]})},fh=({ref:e,row:t,col:n,onClosed:o})=>{const r=ch({ref:e}),[a,i]=l.useState("cell"),{hooks:c,entities:u}=l.useContext(Pe),h=()=>r.copyValue(t,n),m=()=>r.showValue(t,n),d=()=>r.filterValue(t,n),g=()=>{i("show-record")},p=()=>{o?.(),i("cell")},b=xe(c?.length,0),x=xe(u?.length,0);return s.jsx(xa,{ref:e,onClosed:p,children:s.jsxs("div",{className:"w-full lg:w-sm",children:[a==="cell"&&s.jsxs(s.Fragment,{children:[s.jsx("p",{className:gt.sectionName,children:"Cell actions"}),s.jsxs("button",{className:gt.item,onClick:h,children:[s.jsx(ba,{width:14,height:14}),"Copy"]}),s.jsxs("button",{className:gt.item,onClick:m,children:[s.jsx(uh,{width:14,height:14}),"View"]}),s.jsxs("button",{className:gt.item,onClick:d,children:[s.jsx(nn,{width:14,height:14}),"Filter"]}),(x||b)&&s.jsx("p",{className:gt.sectionName,children:"Row actions"}),b&&s.jsxs("button",{className:gt.item,onClick:()=>i("drill"),children:[s.jsx(nt,{width:14,height:14}),"Drill down"]}),x&&s.jsxs("button",{className:gt.item,onClick:g,children:[s.jsx(va,{width:14,height:14}),"Show record"]})]}),a==="drill"&&s.jsxs(s.Fragment,{children:[s.jsxs("button",{className:"flex gap-1 items-center cursor-pointer px-2 py-1 text-sm rounded-lg bg-gray-50 hover:bg-gray-100 mb-2",onClick:()=>i("cell"),children:[s.jsx(nt,{className:"rotate-180",width:16,height:16}),"Drill down"]}),s.jsx(ga,{rowIndex:t,onClose:()=>e.current?.close()})]}),a==="show-record"&&s.jsxs(s.Fragment,{children:[s.jsxs("button",{className:"flex gap-1 items-center cursor-pointer px-2 py-1 text-sm rounded-lg bg-gray-50 hover:bg-gray-100 mb-2",onClick:()=>i("cell"),children:[s.jsx(nt,{className:"rotate-180",width:16,height:16}),"Show record"]}),s.jsx(mh,{rowIndex:t,onClose:()=>e.current?.close()})]})]})})},Qs=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{d:"M414 321.94L274.22 158.82a24 24 0 00-36.44 0L98 321.94c-13.34 15.57-2.28 39.62 18.22 39.62h279.6c20.5 0 31.56-24.05 18.18-39.62z",fill:"currentColor"})),ph={DESC:"",ASC:"rotate-180"},gh=(e,{column:t,value:n,fn:o})=>{const r=e.map(a=>({...a,isEnabled:a.column===t?!1:a.isEnabled}));return r.push({id:ot(),column:t,isEnabled:!0,value:n,fn:o,isAdvanced:!1}),r},xh=()=>{const{data:e}=l.useContext(Ge),{orderBy:t,updateOrderBy:n}=Fd(),{setFilters:o,filters:r}=xo(),a=e?.result.columns||[],i=t[0],c=xe(e?.result.tables.length,1),u=(h,m)=>{In("Filter value","").then(d=>{d&&o(gh(r,{column:h,value:d,fn:m}))})};return s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("td",{children:"🥢"}),a.map(h=>s.jsxs("td",{className:L.headerCell,children:[s.jsxs("div",{className:"overflow-hidden",children:[c&&s.jsx("p",{className:"text-xs truncate italic text-(--text-color-primary)",children:h.table||"-"}),s.jsx("p",{className:"text-sm font-semibold truncate text-(--text-color-primary)",children:h.column})]}),s.jsxs("div",{className:L.headerActions,children:[s.jsx("button",{onClick:()=>n(h.alias),children:i?.column===h.alias?s.jsx(nh,{className:ph[i.direction],width:16,height:16}):s.jsx(sh,{width:16,height:16})}),s.jsx("button",{onClick:()=>u(h.full,h.fn),children:s.jsx(nn,{width:16,height:16})})]})]},h.full))]})})};function bh({value:e,actions:t}){if(e==="")return s.jsx("span",{className:"pointer-events-none text-black/30 truncate",children:"<EMPTY STRING>"});if(e==null)return s.jsx("span",{className:"pointer-events-none text-black/30",children:"<NULL>"});const n=yt(e);return t?.hasRecord||t?.hasDrill?s.jsxs("div",{className:"flex gap-1 items-center justify-between pointer-events-none",children:[s.jsx("span",{className:L.value,children:n}),s.jsxs("div",{className:"flex",children:[t.hasDrill&&s.jsx("span",{className:"text-gray-300 hover:text-blue-600 hover:bg-gray-100 rounded p-0.5 cursor-pointer pointer-events-auto","data-cell-action":"drill","data-tooltip-id":"default-xs","data-tooltip-content":"Show related rows",children:s.jsx(Qs,{className:"pointer-events-none rotate-180",width:16,height:16})}),t.hasRecord&&s.jsx("span",{className:"text-gray-300 hover:text-green-600 hover:bg-gray-100 rounded p-0.5 cursor-pointer pointer-events-auto","data-cell-action":"ref","data-tooltip-id":"default-xs","data-tooltip-content":"Show record",children:s.jsx(Qs,{className:"pointer-events-none",width:16,height:16})})]})]}):s.jsx("span",{className:L.value,children:n})}const vh=l.memo(({row:e,isLastRow:t,index:n,offset:o,colMeta:r})=>s.jsxs("tr",{className:P(L.tableRowCells,t&&"rounded-b-lg"),children:[s.jsx("td",{"data-row":n,children:s.jsxs("button",{"data-cell-action":"drill-all",className:L.rowIndexBtn,children:[s.jsx(Qs,{className:"rotate-180 pointer-events-none",width:16,height:16}),s.jsx("span",{children:n+1+o})]})}),e.map((a,i)=>s.jsx("td",{className:L.cell,"data-row":n,"data-col":i,children:s.jsx(bh,{value:a,actions:r.get(i)})},i))]})),yh=e=>{if(e.tagName==="TD")return e;let t=e.parentElement,n=5;for(;t&&n>=0;){if(t.tagName==="TD")return t;t=t.parentElement,n--}},Go=e=>{const t=yh(e);if(!t)return;const n=parseInt(t.dataset.row,10),o=parseInt(t.dataset.col,10);return{row:n,col:Number.isNaN(o)?void 0:o}},wh=()=>{const{data:e,error:t,isLoading:n,isFetching:o}=l.useContext(Ge),{dataSourceId:r,getColumnByIndex:a,getValueByIndex:i}=l.useContext(Pe),{state:{page:c,size:u}}=l.useContext(Ce),h=l.useRef(null),m=ho(t),d=fa(),[g,p]=l.useState(),b=f=>{const w=f.target,C=w.dataset?.cellAction,N=Go(w);if(C==="ref"&&xe(N?.col,-1)){const O=i(N.row,N.col),S=a(N.col);S&&Mn({tableName:S.ref.table,dataSourceId:r,entityId:[[S.ref.field,O]]})}else(C==="drill"||C==="drill-all")&&(p(N),d.open(f))},x=f=>{const w=Go(f.target);w&&(p(w),h.current?.open(f),f.preventDefault(),f.stopPropagation())},v=c*u,y=l.useMemo(()=>{const f=new Map;return e&&e.result.columns.forEach((w,C)=>{f.set(C,{hasRecord:!!w.ref,hasDrill:!!w.referencedBy})}),f},[e]);return s.jsxs(s.Fragment,{children:[g&&d.show&&s.jsx(th,{handler:d,rowIndex:g.row,colIndex:g.col}),s.jsx(fh,{ref:h,col:g?.col,row:g?.row,onClosed:()=>{p(void 0)}}),m&&s.jsx(fe,{variant:"danger",children:m}),n&&s.jsx("div",{className:L.tableLoading,children:"Loading data"}),e&&s.jsxs("table",{className:P(L.table,o&&L.semiTransparent),onClick:b,onContextMenu:x,children:[s.jsx(xh,{}),s.jsxs("tbody",{children:[e.result.rows?.length<1&&s.jsx("tr",{className:L.tableEmpty,children:s.jsx("td",{colSpan:e.result.columns.length+1,children:"No data"})}),e.result.rows?.map((f,w)=>s.jsx(vh,{index:w,offset:v,row:f,colMeta:y,isLastRow:w===e.result.rows.length-1},w))]})]})]})},ya=()=>{const{state:e,setState:t}=l.useContext(Ce),n=l.useCallback(r=>{t(a=>({...a,page:r}))},[t]),o=l.useCallback((r,a=!1)=>{t(i=>({...i,size:r,page:a?0:i.page}))},[t]);return{page:e.page,size:e.size,setSize:o,setPage:n}},Ch=()=>Z({mutationFn:async e=>{const{data:t}=await $.post("/saved-queries",e);return t.data},onSuccess:()=>{Q.invalidateQueries({queryKey:["queries"]}),Zt(),Jr()}}),jh=()=>Z({mutationFn:async e=>$.delete("/saved-queries/"+e),onSuccess:()=>{Zt(),Jr()}}),Nh=()=>Z({mutationFn:async({id:e,payload:t})=>{const{data:n}=await $.patch("/saved-queries/"+e,t);return n.data},onSuccess:()=>{Zt(),lc()}}),[ys,bo]=ye({filters:!1,joins:!1,columns:!1,groupBy:!1,aggregate:!1}),$e=e=>bo(t=>({...t,[e]:!0})),ws=e=>bo(t=>({...t,[e]:!1})),as=e=>bo(t=>({...t,[e]:!t[e]})),Gt=Math.min,Ct=Math.max,is=Math.round,Yn=Math.floor,Fe=e=>({x:e,y:e}),_h={left:"right",right:"left",bottom:"top",top:"bottom"},kh={start:"end",end:"start"};function Ks(e,t,n){return Ct(e,Gt(t,n))}function Dn(e,t){return typeof e=="function"?e(t):e}function Nt(e){return e.split("-")[0]}function $n(e){return e.split("-")[1]}function wa(e){return e==="x"?"y":"x"}function vo(e){return e==="y"?"height":"width"}const Sh=new Set(["top","bottom"]);function tt(e){return Sh.has(Nt(e))?"y":"x"}function yo(e){return wa(tt(e))}function Eh(e,t,n){n===void 0&&(n=!1);const o=$n(e),r=yo(e),a=vo(r);let i=r==="x"?o===(n?"end":"start")?"right":"left":o==="start"?"bottom":"top";return t.reference[a]>t.floating[a]&&(i=ls(i)),[i,ls(i)]}function Rh(e){const t=ls(e);return[Gs(e),t,Gs(t)]}function Gs(e){return e.replace(/start|end/g,t=>kh[t])}const Yo=["left","right"],Jo=["right","left"],Lh=["top","bottom"],Th=["bottom","top"];function Ah(e,t,n){switch(e){case"top":case"bottom":return n?t?Jo:Yo:t?Yo:Jo;case"left":case"right":return t?Lh:Th;default:return[]}}function Oh(e,t,n,o){const r=$n(e);let a=Ah(Nt(e),n==="start",o);return r&&(a=a.map(i=>i+"-"+r),t&&(a=a.concat(a.map(Gs)))),a}function ls(e){return e.replace(/left|right|bottom|top/g,t=>_h[t])}function Ph(e){return{top:0,right:0,bottom:0,left:0,...e}}function Ca(e){return typeof e!="number"?Ph(e):{top:e,right:e,bottom:e,left:e}}function cs(e){const{x:t,y:n,width:o,height:r}=e;return{width:o,height:r,top:n,left:t,right:t+o,bottom:n+r,x:t,y:n}}function Xo(e,t,n){let{reference:o,floating:r}=e;const a=tt(t),i=yo(t),c=vo(i),u=Nt(t),h=a==="y",m=o.x+o.width/2-r.width/2,d=o.y+o.height/2-r.height/2,g=o[c]/2-r[c]/2;let p;switch(u){case"top":p={x:m,y:o.y-r.height};break;case"bottom":p={x:m,y:o.y+o.height};break;case"right":p={x:o.x+o.width,y:d};break;case"left":p={x:o.x-r.width,y:d};break;default:p={x:o.x,y:o.y}}switch($n(t)){case"start":p[i]-=g*(n&&h?-1:1);break;case"end":p[i]+=g*(n&&h?-1:1);break}return p}const Mh=async(e,t,n)=>{const{placement:o="bottom",strategy:r="absolute",middleware:a=[],platform:i}=n,c=a.filter(Boolean),u=await(i.isRTL==null?void 0:i.isRTL(t));let h=await i.getElementRects({reference:e,floating:t,strategy:r}),{x:m,y:d}=Xo(h,o,u),g=o,p={},b=0;for(let x=0;x<c.length;x++){const{name:v,fn:y}=c[x],{x:f,y:w,data:C,reset:N}=await y({x:m,y:d,initialPlacement:o,placement:g,strategy:r,middlewareData:p,rects:h,platform:i,elements:{reference:e,floating:t}});m=f??m,d=w??d,p={...p,[v]:{...p[v],...C}},N&&b<=50&&(b++,typeof N=="object"&&(N.placement&&(g=N.placement),N.rects&&(h=N.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:r}):N.rects),{x:m,y:d}=Xo(h,g,u)),x=-1)}return{x:m,y:d,placement:g,strategy:r,middlewareData:p}};async function ja(e,t){var n;t===void 0&&(t={});const{x:o,y:r,platform:a,rects:i,elements:c,strategy:u}=e,{boundary:h="clippingAncestors",rootBoundary:m="viewport",elementContext:d="floating",altBoundary:g=!1,padding:p=0}=Dn(t,e),b=Ca(p),v=c[g?d==="floating"?"reference":"floating":d],y=cs(await a.getClippingRect({element:(n=await(a.isElement==null?void 0:a.isElement(v)))==null||n?v:v.contextElement||await(a.getDocumentElement==null?void 0:a.getDocumentElement(c.floating)),boundary:h,rootBoundary:m,strategy:u})),f=d==="floating"?{x:o,y:r,width:i.floating.width,height:i.floating.height}:i.reference,w=await(a.getOffsetParent==null?void 0:a.getOffsetParent(c.floating)),C=await(a.isElement==null?void 0:a.isElement(w))?await(a.getScale==null?void 0:a.getScale(w))||{x:1,y:1}:{x:1,y:1},N=cs(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:f,offsetParent:w,strategy:u}):f);return{top:(y.top-N.top+b.top)/C.y,bottom:(N.bottom-y.bottom+b.bottom)/C.y,left:(y.left-N.left+b.left)/C.x,right:(N.right-y.right+b.right)/C.x}}const Ih=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:o,placement:r,rects:a,platform:i,elements:c,middlewareData:u}=t,{element:h,padding:m=0}=Dn(e,t)||{};if(h==null)return{};const d=Ca(m),g={x:n,y:o},p=yo(r),b=vo(p),x=await i.getDimensions(h),v=p==="y",y=v?"top":"left",f=v?"bottom":"right",w=v?"clientHeight":"clientWidth",C=a.reference[b]+a.reference[p]-g[p]-a.floating[b],N=g[p]-a.reference[p],O=await(i.getOffsetParent==null?void 0:i.getOffsetParent(h));let S=O?O[w]:0;(!S||!await(i.isElement==null?void 0:i.isElement(O)))&&(S=c.floating[w]||a.floating[b]);const _=C/2-N/2,k=S/2-x[b]/2-1,E=Gt(d[y],k),te=Gt(d[f],k),je=E,Me=S-x[b]-te,W=S/2-x[b]/2+_,ce=Ks(je,W,Me),oe=!u.arrow&&$n(r)!=null&&W!==ce&&a.reference[b]/2-(W<je?E:te)-x[b]/2<0,J=oe?W<je?W-je:W-Me:0;return{[p]:g[p]+J,data:{[p]:ce,centerOffset:W-ce-J,...oe&&{alignmentOffset:J}},reset:oe}}}),Dh=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,o;const{placement:r,middlewareData:a,rects:i,initialPlacement:c,platform:u,elements:h}=t,{mainAxis:m=!0,crossAxis:d=!0,fallbackPlacements:g,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:b="none",flipAlignment:x=!0,...v}=Dn(e,t);if((n=a.arrow)!=null&&n.alignmentOffset)return{};const y=Nt(r),f=tt(c),w=Nt(c)===c,C=await(u.isRTL==null?void 0:u.isRTL(h.floating)),N=g||(w||!x?[ls(c)]:Rh(c)),O=b!=="none";!g&&O&&N.push(...Oh(c,x,b,C));const S=[c,...N],_=await ja(t,v),k=[];let E=((o=a.flip)==null?void 0:o.overflows)||[];if(m&&k.push(_[y]),d){const W=Eh(r,i,C);k.push(_[W[0]],_[W[1]])}if(E=[...E,{placement:r,overflows:k}],!k.every(W=>W<=0)){var te,je;const W=(((te=a.flip)==null?void 0:te.index)||0)+1,ce=S[W];if(ce&&(!(d==="alignment"?f!==tt(ce):!1)||E.every(U=>tt(U.placement)===f?U.overflows[0]>0:!0)))return{data:{index:W,overflows:E},reset:{placement:ce}};let oe=(je=E.filter(J=>J.overflows[0]<=0).sort((J,U)=>J.overflows[1]-U.overflows[1])[0])==null?void 0:je.placement;if(!oe)switch(p){case"bestFit":{var Me;const J=(Me=E.filter(U=>{if(O){const re=tt(U.placement);return re===f||re==="y"}return!0}).map(U=>[U.placement,U.overflows.filter(re=>re>0).reduce((re,Ue)=>re+Ue,0)]).sort((U,re)=>U[1]-re[1])[0])==null?void 0:Me[0];J&&(oe=J);break}case"initialPlacement":oe=c;break}if(r!==oe)return{reset:{placement:oe}}}return{}}}},$h=new Set(["left","top"]);async function Fh(e,t){const{placement:n,platform:o,elements:r}=e,a=await(o.isRTL==null?void 0:o.isRTL(r.floating)),i=Nt(n),c=$n(n),u=tt(n)==="y",h=$h.has(i)?-1:1,m=a&&u?-1:1,d=Dn(t,e);let{mainAxis:g,crossAxis:p,alignmentAxis:b}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return c&&typeof b=="number"&&(p=c==="end"?b*-1:b),u?{x:p*m,y:g*h}:{x:g*h,y:p*m}}const Bh=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,o;const{x:r,y:a,placement:i,middlewareData:c}=t,u=await Fh(t,e);return i===((n=c.offset)==null?void 0:n.placement)&&(o=c.arrow)!=null&&o.alignmentOffset?{}:{x:r+u.x,y:a+u.y,data:{...u,placement:i}}}}},Wh=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:o,placement:r}=t,{mainAxis:a=!0,crossAxis:i=!1,limiter:c={fn:v=>{let{x:y,y:f}=v;return{x:y,y:f}}},...u}=Dn(e,t),h={x:n,y:o},m=await ja(t,u),d=tt(Nt(r)),g=wa(d);let p=h[g],b=h[d];if(a){const v=g==="y"?"top":"left",y=g==="y"?"bottom":"right",f=p+m[v],w=p-m[y];p=Ks(f,p,w)}if(i){const v=d==="y"?"top":"left",y=d==="y"?"bottom":"right",f=b+m[v],w=b-m[y];b=Ks(f,b,w)}const x=c.fn({...t,[g]:p,[d]:b});return{...x,data:{x:x.x-n,y:x.y-o,enabled:{[g]:a,[d]:i}}}}}};function Cs(){return typeof window<"u"}function sn(e){return Na(e)?(e.nodeName||"").toLowerCase():"#document"}function ge(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function qe(e){var t;return(t=(Na(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Na(e){return Cs()?e instanceof Node||e instanceof ge(e).Node:!1}function Ae(e){return Cs()?e instanceof Element||e instanceof ge(e).Element:!1}function We(e){return Cs()?e instanceof HTMLElement||e instanceof ge(e).HTMLElement:!1}function Zo(e){return!Cs()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof ge(e).ShadowRoot}const zh=new Set(["inline","contents"]);function Fn(e){const{overflow:t,overflowX:n,overflowY:o,display:r}=Oe(e);return/auto|scroll|overlay|hidden|clip/.test(t+o+n)&&!zh.has(r)}const qh=new Set(["table","td","th"]);function Uh(e){return qh.has(sn(e))}const Hh=[":popover-open",":modal"];function js(e){return Hh.some(t=>{try{return e.matches(t)}catch{return!1}})}const Vh=["transform","translate","scale","rotate","perspective"],Qh=["transform","translate","scale","rotate","perspective","filter"],Kh=["paint","layout","strict","content"];function wo(e){const t=Co(),n=Ae(e)?Oe(e):e;return Vh.some(o=>n[o]?n[o]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||Qh.some(o=>(n.willChange||"").includes(o))||Kh.some(o=>(n.contain||"").includes(o))}function Gh(e){let t=rt(e);for(;We(t)&&!Yt(t);){if(wo(t))return t;if(js(t))return null;t=rt(t)}return null}function Co(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Yh=new Set(["html","body","#document"]);function Yt(e){return Yh.has(sn(e))}function Oe(e){return ge(e).getComputedStyle(e)}function Ns(e){return Ae(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function rt(e){if(sn(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Zo(e)&&e.host||qe(e);return Zo(t)?t.host:t}function _a(e){const t=rt(e);return Yt(t)?e.ownerDocument?e.ownerDocument.body:e.body:We(t)&&Fn(t)?t:_a(t)}function kn(e,t,n){var o;t===void 0&&(t=[]),n===void 0&&(n=!0);const r=_a(e),a=r===((o=e.ownerDocument)==null?void 0:o.body),i=ge(r);if(a){const c=Ys(i);return t.concat(i,i.visualViewport||[],Fn(r)?r:[],c&&n?kn(c):[])}return t.concat(r,kn(r,[],n))}function Ys(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function ka(e){const t=Oe(e);let n=parseFloat(t.width)||0,o=parseFloat(t.height)||0;const r=We(e),a=r?e.offsetWidth:n,i=r?e.offsetHeight:o,c=is(n)!==a||is(o)!==i;return c&&(n=a,o=i),{width:n,height:o,$:c}}function jo(e){return Ae(e)?e:e.contextElement}function Vt(e){const t=jo(e);if(!We(t))return Fe(1);const n=t.getBoundingClientRect(),{width:o,height:r,$:a}=ka(t);let i=(a?is(n.width):n.width)/o,c=(a?is(n.height):n.height)/r;return(!i||!Number.isFinite(i))&&(i=1),(!c||!Number.isFinite(c))&&(c=1),{x:i,y:c}}const Jh=Fe(0);function Sa(e){const t=ge(e);return!Co()||!t.visualViewport?Jh:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Xh(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==ge(e)?!1:t}function _t(e,t,n,o){t===void 0&&(t=!1),n===void 0&&(n=!1);const r=e.getBoundingClientRect(),a=jo(e);let i=Fe(1);t&&(o?Ae(o)&&(i=Vt(o)):i=Vt(e));const c=Xh(a,n,o)?Sa(a):Fe(0);let u=(r.left+c.x)/i.x,h=(r.top+c.y)/i.y,m=r.width/i.x,d=r.height/i.y;if(a){const g=ge(a),p=o&&Ae(o)?ge(o):o;let b=g,x=Ys(b);for(;x&&o&&p!==b;){const v=Vt(x),y=x.getBoundingClientRect(),f=Oe(x),w=y.left+(x.clientLeft+parseFloat(f.paddingLeft))*v.x,C=y.top+(x.clientTop+parseFloat(f.paddingTop))*v.y;u*=v.x,h*=v.y,m*=v.x,d*=v.y,u+=w,h+=C,b=ge(x),x=Ys(b)}}return cs({width:m,height:d,x:u,y:h})}function _s(e,t){const n=Ns(e).scrollLeft;return t?t.left+n:_t(qe(e)).left+n}function Ea(e,t){const n=e.getBoundingClientRect(),o=n.left+t.scrollLeft-_s(e,n),r=n.top+t.scrollTop;return{x:o,y:r}}function Zh(e){let{elements:t,rect:n,offsetParent:o,strategy:r}=e;const a=r==="fixed",i=qe(o),c=t?js(t.floating):!1;if(o===i||c&&a)return n;let u={scrollLeft:0,scrollTop:0},h=Fe(1);const m=Fe(0),d=We(o);if((d||!d&&!a)&&((sn(o)!=="body"||Fn(i))&&(u=Ns(o)),We(o))){const p=_t(o);h=Vt(o),m.x=p.x+o.clientLeft,m.y=p.y+o.clientTop}const g=i&&!d&&!a?Ea(i,u):Fe(0);return{width:n.width*h.x,height:n.height*h.y,x:n.x*h.x-u.scrollLeft*h.x+m.x+g.x,y:n.y*h.y-u.scrollTop*h.y+m.y+g.y}}function em(e){return Array.from(e.getClientRects())}function tm(e){const t=qe(e),n=Ns(e),o=e.ownerDocument.body,r=Ct(t.scrollWidth,t.clientWidth,o.scrollWidth,o.clientWidth),a=Ct(t.scrollHeight,t.clientHeight,o.scrollHeight,o.clientHeight);let i=-n.scrollLeft+_s(e);const c=-n.scrollTop;return Oe(o).direction==="rtl"&&(i+=Ct(t.clientWidth,o.clientWidth)-r),{width:r,height:a,x:i,y:c}}const er=25;function nm(e,t){const n=ge(e),o=qe(e),r=n.visualViewport;let a=o.clientWidth,i=o.clientHeight,c=0,u=0;if(r){a=r.width,i=r.height;const m=Co();(!m||m&&t==="fixed")&&(c=r.offsetLeft,u=r.offsetTop)}const h=_s(o);if(h<=0){const m=o.ownerDocument,d=m.body,g=getComputedStyle(d),p=m.compatMode==="CSS1Compat"&&parseFloat(g.marginLeft)+parseFloat(g.marginRight)||0,b=Math.abs(o.clientWidth-d.clientWidth-p);b<=er&&(a-=b)}else h<=er&&(a+=h);return{width:a,height:i,x:c,y:u}}const sm=new Set(["absolute","fixed"]);function om(e,t){const n=_t(e,!0,t==="fixed"),o=n.top+e.clientTop,r=n.left+e.clientLeft,a=We(e)?Vt(e):Fe(1),i=e.clientWidth*a.x,c=e.clientHeight*a.y,u=r*a.x,h=o*a.y;return{width:i,height:c,x:u,y:h}}function tr(e,t,n){let o;if(t==="viewport")o=nm(e,n);else if(t==="document")o=tm(qe(e));else if(Ae(t))o=om(t,n);else{const r=Sa(e);o={x:t.x-r.x,y:t.y-r.y,width:t.width,height:t.height}}return cs(o)}function Ra(e,t){const n=rt(e);return n===t||!Ae(n)||Yt(n)?!1:Oe(n).position==="fixed"||Ra(n,t)}function rm(e,t){const n=t.get(e);if(n)return n;let o=kn(e,[],!1).filter(c=>Ae(c)&&sn(c)!=="body"),r=null;const a=Oe(e).position==="fixed";let i=a?rt(e):e;for(;Ae(i)&&!Yt(i);){const c=Oe(i),u=wo(i);!u&&c.position==="fixed"&&(r=null),(a?!u&&!r:!u&&c.position==="static"&&!!r&&sm.has(r.position)||Fn(i)&&!u&&Ra(e,i))?o=o.filter(m=>m!==i):r=c,i=rt(i)}return t.set(e,o),o}function am(e){let{element:t,boundary:n,rootBoundary:o,strategy:r}=e;const i=[...n==="clippingAncestors"?js(t)?[]:rm(t,this._c):[].concat(n),o],c=i[0],u=i.reduce((h,m)=>{const d=tr(t,m,r);return h.top=Ct(d.top,h.top),h.right=Gt(d.right,h.right),h.bottom=Gt(d.bottom,h.bottom),h.left=Ct(d.left,h.left),h},tr(t,c,r));return{width:u.right-u.left,height:u.bottom-u.top,x:u.left,y:u.top}}function im(e){const{width:t,height:n}=ka(e);return{width:t,height:n}}function lm(e,t,n){const o=We(t),r=qe(t),a=n==="fixed",i=_t(e,!0,a,t);let c={scrollLeft:0,scrollTop:0};const u=Fe(0);function h(){u.x=_s(r)}if(o||!o&&!a)if((sn(t)!=="body"||Fn(r))&&(c=Ns(t)),o){const p=_t(t,!0,a,t);u.x=p.x+t.clientLeft,u.y=p.y+t.clientTop}else r&&h();a&&!o&&r&&h();const m=r&&!o&&!a?Ea(r,c):Fe(0),d=i.left+c.scrollLeft-u.x-m.x,g=i.top+c.scrollTop-u.y-m.y;return{x:d,y:g,width:i.width,height:i.height}}function Ms(e){return Oe(e).position==="static"}function nr(e,t){if(!We(e)||Oe(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return qe(e)===n&&(n=n.ownerDocument.body),n}function La(e,t){const n=ge(e);if(js(e))return n;if(!We(e)){let r=rt(e);for(;r&&!Yt(r);){if(Ae(r)&&!Ms(r))return r;r=rt(r)}return n}let o=nr(e,t);for(;o&&Uh(o)&&Ms(o);)o=nr(o,t);return o&&Yt(o)&&Ms(o)&&!wo(o)?n:o||Gh(e)||n}const cm=async function(e){const t=this.getOffsetParent||La,n=this.getDimensions,o=await n(e.floating);return{reference:lm(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}};function um(e){return Oe(e).direction==="rtl"}const dm={convertOffsetParentRelativeRectToViewportRelativeRect:Zh,getDocumentElement:qe,getClippingRect:am,getOffsetParent:La,getElementRects:cm,getClientRects:em,getDimensions:im,getScale:Vt,isElement:Ae,isRTL:um};function Ta(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function hm(e,t){let n=null,o;const r=qe(e);function a(){var c;clearTimeout(o),(c=n)==null||c.disconnect(),n=null}function i(c,u){c===void 0&&(c=!1),u===void 0&&(u=1),a();const h=e.getBoundingClientRect(),{left:m,top:d,width:g,height:p}=h;if(c||t(),!g||!p)return;const b=Yn(d),x=Yn(r.clientWidth-(m+g)),v=Yn(r.clientHeight-(d+p)),y=Yn(m),w={rootMargin:-b+"px "+-x+"px "+-v+"px "+-y+"px",threshold:Ct(0,Gt(1,u))||1};let C=!0;function N(O){const S=O[0].intersectionRatio;if(S!==u){if(!C)return i();S?i(!1,S):o=setTimeout(()=>{i(!1,1e-7)},1e3)}S===1&&!Ta(h,e.getBoundingClientRect())&&i(),C=!1}try{n=new IntersectionObserver(N,{...w,root:r.ownerDocument})}catch{n=new IntersectionObserver(N,w)}n.observe(e)}return i(!0),a}function mm(e,t,n,o){o===void 0&&(o={});const{ancestorScroll:r=!0,ancestorResize:a=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:c=typeof IntersectionObserver=="function",animationFrame:u=!1}=o,h=jo(e),m=r||a?[...h?kn(h):[],...kn(t)]:[];m.forEach(y=>{r&&y.addEventListener("scroll",n,{passive:!0}),a&&y.addEventListener("resize",n)});const d=h&&c?hm(h,n):null;let g=-1,p=null;i&&(p=new ResizeObserver(y=>{let[f]=y;f&&f.target===h&&p&&(p.unobserve(t),cancelAnimationFrame(g),g=requestAnimationFrame(()=>{var w;(w=p)==null||w.observe(t)})),n()}),h&&!u&&p.observe(h),p.observe(t));let b,x=u?_t(e):null;u&&v();function v(){const y=_t(e);x&&!Ta(x,y)&&n(),x=y,b=requestAnimationFrame(v)}return n(),()=>{var y;m.forEach(f=>{r&&f.removeEventListener("scroll",n),a&&f.removeEventListener("resize",n)}),d?.(),(y=p)==null||y.disconnect(),p=null,u&&cancelAnimationFrame(b)}}const fm=Bh,pm=Wh,gm=Dh,xm=Ih,sr=(e,t,n)=>{const o=new Map,r={platform:dm,...n},a={...r.platform,_c:o};return Mh(e,t,{...r,platform:a})};var Is={exports:{}};var or;function bm(){return or||(or=1,(function(e){(function(){var t={}.hasOwnProperty;function n(){for(var a="",i=0;i<arguments.length;i++){var c=arguments[i];c&&(a=r(a,o(c)))}return a}function o(a){if(typeof a=="string"||typeof a=="number")return a;if(typeof a!="object")return"";if(Array.isArray(a))return n.apply(null,a);if(a.toString!==Object.prototype.toString&&!a.toString.toString().includes("[native code]"))return a.toString();var i="";for(var c in a)t.call(a,c)&&a[c]&&(i=r(i,c));return i}function r(a,i){return i?a?a+" "+i:a+i:a}e.exports?(n.default=n,e.exports=n):window.classNames=n})()})(Is)),Is.exports}var vm=bm();const Js=ui(vm);var rr={};const ym="react-tooltip-core-styles",wm="react-tooltip-base-styles",ar={core:!1,base:!1};function ir({css:e,id:t=wm,type:n="base",ref:o}){var r,a;if(!e||typeof document>"u"||ar[n]||n==="core"&&typeof process<"u"&&(!((r=process==null?void 0:rr)===null||r===void 0)&&r.REACT_TOOLTIP_DISABLE_CORE_STYLES)||n!=="base"&&typeof process<"u"&&(!((a=process==null?void 0:rr)===null||a===void 0)&&a.REACT_TOOLTIP_DISABLE_BASE_STYLES))return;n==="core"&&(t=ym),o||(o={});const{insertAt:i}=o;if(document.getElementById(t))return;const c=document.head||document.getElementsByTagName("head")[0],u=document.createElement("style");u.id=t,u.type="text/css",i==="top"&&c.firstChild?c.insertBefore(u,c.firstChild):c.appendChild(u),u.styleSheet?u.styleSheet.cssText=e:u.appendChild(document.createTextNode(e)),ar[n]=!0}const lr=async({elementReference:e=null,tooltipReference:t=null,tooltipArrowReference:n=null,place:o="top",offset:r=10,strategy:a="absolute",middlewares:i=[fm(Number(r)),gm({fallbackAxisSideDirection:"start"}),pm({padding:5})],border:c,arrowSize:u=8})=>{if(!e)return{tooltipStyles:{},tooltipArrowStyles:{},place:o};if(t===null)return{tooltipStyles:{},tooltipArrowStyles:{},place:o};const h=i;return n?(h.push(xm({element:n,padding:5})),sr(e,t,{placement:o,strategy:a,middleware:h}).then((({x:m,y:d,placement:g,middlewareData:p})=>{var b,x;const v={left:`${m}px`,top:`${d}px`,border:c},{x:y,y:f}=(b=p.arrow)!==null&&b!==void 0?b:{x:0,y:0},w=(x={top:"bottom",right:"left",bottom:"top",left:"right"}[g.split("-")[0]])!==null&&x!==void 0?x:"bottom",C=c&&{borderBottom:c,borderRight:c};let N=0;if(c){const O=`${c}`.match(/(\d+)px/);N=O?.[1]?Number(O[1]):1}return{tooltipStyles:v,tooltipArrowStyles:{left:y!=null?`${y}px`:"",top:f!=null?`${f}px`:"",right:"",bottom:"",...C,[w]:`-${u/2+N}px`},place:g}}))):sr(e,t,{placement:"bottom",strategy:a,middleware:h}).then((({x:m,y:d,placement:g})=>({tooltipStyles:{left:`${m}px`,top:`${d}px`},tooltipArrowStyles:{},place:g})))},cr=(e,t)=>!("CSS"in window&&"supports"in window.CSS)||window.CSS.supports(e,t),ur=(e,t,n)=>{let o=null;const r=function(...a){const i=()=>{o=null};!o&&(e.apply(this,a),o=setTimeout(i,t))};return r.cancel=()=>{o&&(clearTimeout(o),o=null)},r},dr=e=>e!==null&&!Array.isArray(e)&&typeof e=="object",Xs=(e,t)=>{if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every(((r,a)=>Xs(r,t[a])));if(Array.isArray(e)!==Array.isArray(t))return!1;if(!dr(e)||!dr(t))return e===t;const n=Object.keys(e),o=Object.keys(t);return n.length===o.length&&n.every((r=>Xs(e[r],t[r])))},Cm=e=>{if(!(e instanceof HTMLElement||e instanceof SVGElement))return!1;const t=getComputedStyle(e);return["overflow","overflow-x","overflow-y"].some((n=>{const o=t.getPropertyValue(n);return o==="auto"||o==="scroll"}))},hr=e=>{if(!e)return null;let t=e.parentElement;for(;t;){if(Cm(t))return t;t=t.parentElement}return document.scrollingElement||document.documentElement},jm=typeof window<"u"?l.useLayoutEffect:l.useEffect,_e=e=>{e.current&&(clearTimeout(e.current),e.current=null)},Nm="DEFAULT_TOOLTIP_ID",_m={anchorRefs:new Set,activeAnchor:{current:null},attach:()=>{},detach:()=>{},setActiveAnchor:()=>{}},km=l.createContext({getTooltipData:()=>_m});function Aa(e=Nm){return l.useContext(km).getTooltipData(e)}var qt={tooltip:"core-styles-module_tooltip__3vRRp",fixed:"core-styles-module_fixed__pcSol",arrow:"core-styles-module_arrow__cvMwQ",noArrow:"core-styles-module_noArrow__xock6",clickable:"core-styles-module_clickable__ZuTTB",show:"core-styles-module_show__Nt9eE",closing:"core-styles-module_closing__sGnxF"},Ds={tooltip:"styles-module_tooltip__mnnfp",arrow:"styles-module_arrow__K0L3T",dark:"styles-module_dark__xNqje",light:"styles-module_light__Z6W-X",success:"styles-module_success__A2AKt",warning:"styles-module_warning__SCK0X",error:"styles-module_error__JvumD",info:"styles-module_info__BWdHW"};const Sm=({forwardRef:e,id:t,className:n,classNameArrow:o,variant:r="dark",anchorId:a,anchorSelect:i,place:c="top",offset:u=10,events:h=["hover"],openOnClick:m=!1,positionStrategy:d="absolute",middlewares:g,wrapper:p,delayShow:b=0,delayHide:x=0,float:v=!1,hidden:y=!1,noArrow:f=!1,clickable:w=!1,closeOnEsc:C=!1,closeOnScroll:N=!1,closeOnResize:O=!1,openEvents:S,closeEvents:_,globalCloseEvents:k,imperativeModeOnly:E,style:te,position:je,afterShow:Me,afterHide:W,disableTooltip:ce,content:oe,contentWrapperRef:J,isOpen:U,defaultIsOpen:re=!1,setIsOpen:Ue,previousActiveAnchor:on,activeAnchor:z,setActiveAnchor:Et,border:Bn,opacity:Wn,arrowColor:zn,arrowSize:Rt=8,role:ks="tooltip"})=>{var lt;const ue=l.useRef(null),Lt=l.useRef(null),Le=l.useRef(null),ct=l.useRef(null),Tt=l.useRef(null),[ut,qn]=l.useState({tooltipStyles:{},tooltipArrowStyles:{},place:c}),[de,rn]=l.useState(!1),[At,Ye]=l.useState(!1),[V,Ot]=l.useState(null),Un=l.useRef(!1),Pt=l.useRef(null),{anchorRefs:Hn,setActiveAnchor:an}=Aa(t),ln=l.useRef(!1),[Je,cn]=l.useState([]),dt=l.useRef(!1),Mt=m||h.includes("click"),Vn=Mt||S?.click||S?.dblclick||S?.mousedown,un=S?{...S}:{mouseover:!0,focus:!0,mouseenter:!1,click:!1,dblclick:!1,mousedown:!1};!S&&Mt&&Object.assign(un,{mouseenter:!1,focus:!1,mouseover:!1,click:!0});const ht=_?{..._}:{mouseout:!0,blur:!0,mouseleave:!1,click:!1,dblclick:!1,mouseup:!1};!_&&Mt&&Object.assign(ht,{mouseleave:!1,blur:!1,mouseout:!1});const ne=k?{...k}:{escape:C||!1,scroll:N||!1,resize:O||!1,clickOutsideAnchor:Vn||!1};E&&(Object.assign(un,{mouseover:!1,focus:!1,mouseenter:!1,click:!1,dblclick:!1,mousedown:!1}),Object.assign(ht,{mouseout:!1,blur:!1,mouseleave:!1,click:!1,dblclick:!1,mouseup:!1}),Object.assign(ne,{escape:!1,scroll:!1,resize:!1,clickOutsideAnchor:!1})),jm((()=>(dt.current=!0,()=>{dt.current=!1})),[]);const he=j=>{dt.current&&(j&&Ye(!0),setTimeout((()=>{dt.current&&(Ue?.(j),U===void 0&&rn(j))}),10))};l.useEffect((()=>{if(t){if(de){T(on);const R=j(z),B=[...new Set([...R,t])].filter(Boolean).join(" ");z?.setAttribute("aria-describedby",B)}else T(z);return()=>{T(z),T(on)}}function j(R){var B;return((B=R?.getAttribute("aria-describedby"))===null||B===void 0?void 0:B.split(" "))||[]}function T(R){const B=j(R).filter((ee=>ee!==t));B.length?R?.setAttribute("aria-describedby",B.join(" ")):R?.removeAttribute("aria-describedby")}}),[z,de,t,on]),l.useEffect((()=>{if(U===void 0)return()=>null;U&&Ye(!0);const j=setTimeout((()=>{rn(U)}),10);return()=>{clearTimeout(j)}}),[U]),l.useEffect((()=>{if(de!==Un.current)if(_e(Tt),Un.current=de,de)Me?.();else{const j=(T=>{const R=T.match(/^([\d.]+)(ms|s)$/);if(!R)return 0;const[,B,ee]=R;return Number(B)*(ee==="ms"?1:1e3)})(getComputedStyle(document.body).getPropertyValue("--rt-transition-show-delay"));Tt.current=setTimeout((()=>{Ye(!1),Ot(null),W?.()}),j+25)}}),[de]);const dn=j=>{qn((T=>Xs(T,j)?T:j))},hn=(j=b)=>{_e(Le),At?he(!0):Le.current=setTimeout((()=>{he(!0)}),j)},It=(j=x)=>{_e(ct),ct.current=setTimeout((()=>{ln.current||he(!1)}),j)},mn=j=>{var T;if(!j)return;const R=(T=j.currentTarget)!==null&&T!==void 0?T:j.target;if(!R?.isConnected)return Et(null),void an({current:null});b?hn():he(!0),Et(R),an({current:R}),_e(ct)},Dt=()=>{w?It(x||100):x?It():he(!1),_e(Le)},$t=({x:j,y:T})=>{var R;const B={getBoundingClientRect:()=>({x:j,y:T,width:0,height:0,top:T,left:j,right:j,bottom:T})};lr({place:(R=V?.place)!==null&&R!==void 0?R:c,offset:u,elementReference:B,tooltipReference:ue.current,tooltipArrowReference:Lt.current,strategy:d,middlewares:g,border:Bn,arrowSize:Rt}).then((ee=>{dn(ee)}))},Ft=j=>{if(!j)return;const T=j,R={x:T.clientX,y:T.clientY};$t(R),Pt.current=R},fn=j=>{var T;if(!de)return;const R=j.target;R.isConnected&&(!((T=ue.current)===null||T===void 0)&&T.contains(R)||[document.querySelector(`[id='${a}']`),...Je].some((B=>B?.contains(R)))||(he(!1),_e(Le)))},Qn=ur(mn,50),K=ur(Dt,50),ae=j=>{K.cancel(),Qn(j)},A=()=>{Qn.cancel(),K()},M=l.useCallback((()=>{var j,T;const R=(j=V?.position)!==null&&j!==void 0?j:je;R?$t(R):v?Pt.current&&$t(Pt.current):z?.isConnected&&lr({place:(T=V?.place)!==null&&T!==void 0?T:c,offset:u,elementReference:z,tooltipReference:ue.current,tooltipArrowReference:Lt.current,strategy:d,middlewares:g,border:Bn,arrowSize:Rt}).then((B=>{dt.current&&dn(B)}))}),[de,z,oe,te,c,V?.place,u,d,je,V?.position,v,Rt]);l.useEffect((()=>{var j,T;const R=new Set(Hn);Je.forEach((F=>{ce?.(F)||R.add({current:F})}));const B=document.querySelector(`[id='${a}']`);B&&!ce?.(B)&&R.add({current:B});const ee=()=>{he(!1)},Ie=hr(z),De=hr(ue.current);ne.scroll&&(window.addEventListener("scroll",ee),Ie?.addEventListener("scroll",ee),De?.addEventListener("scroll",ee));let ie=null;ne.resize?window.addEventListener("resize",ee):z&&ue.current&&(ie=mm(z,ue.current,M,{ancestorResize:!0,elementResize:!0,layoutShift:!0}));const Ne=F=>{F.key==="Escape"&&he(!1)};ne.escape&&window.addEventListener("keydown",Ne),ne.clickOutsideAnchor&&window.addEventListener("click",fn);const q=[],Bt=F=>!!(F?.target&&z?.contains(F.target)),Ja=F=>{de&&Bt(F)||mn(F)},Xa=F=>{de&&Bt(F)&&Dt()},So=["mouseover","mouseout","mouseenter","mouseleave","focus","blur"],Eo=["click","dblclick","mousedown","mouseup"];Object.entries(un).forEach((([F,He])=>{He&&(So.includes(F)?q.push({event:F,listener:ae}):Eo.includes(F)&&q.push({event:F,listener:Ja}))})),Object.entries(ht).forEach((([F,He])=>{He&&(So.includes(F)?q.push({event:F,listener:A}):Eo.includes(F)&&q.push({event:F,listener:Xa}))})),v&&q.push({event:"pointermove",listener:Ft});const Ro=()=>{ln.current=!0},Lo=()=>{ln.current=!1,Dt()},To=w&&(ht.mouseout||ht.mouseleave);return To&&((j=ue.current)===null||j===void 0||j.addEventListener("mouseover",Ro),(T=ue.current)===null||T===void 0||T.addEventListener("mouseout",Lo)),q.forEach((({event:F,listener:He})=>{R.forEach((Ss=>{var pn;(pn=Ss.current)===null||pn===void 0||pn.addEventListener(F,He)}))})),()=>{var F,He;ne.scroll&&(window.removeEventListener("scroll",ee),Ie?.removeEventListener("scroll",ee),De?.removeEventListener("scroll",ee)),ne.resize?window.removeEventListener("resize",ee):ie?.(),ne.clickOutsideAnchor&&window.removeEventListener("click",fn),ne.escape&&window.removeEventListener("keydown",Ne),To&&((F=ue.current)===null||F===void 0||F.removeEventListener("mouseover",Ro),(He=ue.current)===null||He===void 0||He.removeEventListener("mouseout",Lo)),q.forEach((({event:Ss,listener:pn})=>{R.forEach((Za=>{var Es;(Es=Za.current)===null||Es===void 0||Es.removeEventListener(Ss,pn)}))}))}}),[z,M,At,Hn,Je,S,_,k,Mt,b,x]),l.useEffect((()=>{var j,T;let R=(T=(j=V?.anchorSelect)!==null&&j!==void 0?j:i)!==null&&T!==void 0?T:"";!R&&t&&(R=`[data-tooltip-id='${t.replace(/'/g,"\\'")}']`);const B=new MutationObserver((ee=>{const Ie=[],De=[];ee.forEach((ie=>{if(ie.type==="attributes"&&ie.attributeName==="data-tooltip-id"&&(ie.target.getAttribute("data-tooltip-id")===t?Ie.push(ie.target):ie.oldValue===t&&De.push(ie.target)),ie.type==="childList"){if(z){const Ne=[...ie.removedNodes].filter((q=>q.nodeType===1));if(R)try{De.push(...Ne.filter((q=>q.matches(R)))),De.push(...Ne.flatMap((q=>[...q.querySelectorAll(R)])))}catch{}Ne.some((q=>{var Bt;return!!(!((Bt=q?.contains)===null||Bt===void 0)&&Bt.call(q,z))&&(Ye(!1),he(!1),Et(null),_e(Le),_e(ct),!0)}))}if(R)try{const Ne=[...ie.addedNodes].filter((q=>q.nodeType===1));Ie.push(...Ne.filter((q=>q.matches(R)))),Ie.push(...Ne.flatMap((q=>[...q.querySelectorAll(R)])))}catch{}}})),(Ie.length||De.length)&&cn((ie=>[...ie.filter((Ne=>!De.includes(Ne))),...Ie]))}));return B.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-tooltip-id"],attributeOldValue:!0}),()=>{B.disconnect()}}),[t,i,V?.anchorSelect,z]),l.useEffect((()=>{M()}),[M]),l.useEffect((()=>{if(!J?.current)return()=>null;const j=new ResizeObserver((()=>{setTimeout((()=>M()))}));return j.observe(J.current),()=>{j.disconnect()}}),[oe,J?.current]),l.useEffect((()=>{var j;const T=document.querySelector(`[id='${a}']`),R=[...Je,T];z&&R.includes(z)||Et((j=Je[0])!==null&&j!==void 0?j:T)}),[a,Je,z]),l.useEffect((()=>(re&&he(!0),()=>{_e(Le),_e(ct)})),[]),l.useEffect((()=>{var j;let T=(j=V?.anchorSelect)!==null&&j!==void 0?j:i;if(!T&&t&&(T=`[data-tooltip-id='${t.replace(/'/g,"\\'")}']`),T)try{const R=Array.from(document.querySelectorAll(T));cn(R)}catch{cn([])}}),[t,i,V?.anchorSelect]),l.useEffect((()=>{Le.current&&(_e(Le),hn(b))}),[b]);const pe=(lt=V?.content)!==null&&lt!==void 0?lt:oe,mt=de&&Object.keys(ut.tooltipStyles).length>0;return l.useImperativeHandle(e,(()=>({open:j=>{if(j?.anchorSelect)try{document.querySelector(j.anchorSelect)}catch{return void console.warn(`[react-tooltip] "${j.anchorSelect}" is not a valid CSS selector`)}Ot(j??null),j?.delay?hn(j.delay):he(!0)},close:j=>{j?.delay?It(j.delay):he(!1)},activeAnchor:z,place:ut.place,isOpen:!!(At&&!y&&pe&&mt)}))),At&&!y&&pe?Ze.createElement(p,{id:t,role:ks,className:Js("react-tooltip",qt.tooltip,Ds.tooltip,Ds[r],n,`react-tooltip__place-${ut.place}`,qt[mt?"show":"closing"],mt?"react-tooltip__show":"react-tooltip__closing",d==="fixed"&&qt.fixed,w&&qt.clickable),onTransitionEnd:j=>{_e(Tt),de||j.propertyName!=="opacity"||(Ye(!1),Ot(null),W?.())},style:{...te,...ut.tooltipStyles,opacity:Wn!==void 0&&mt?Wn:void 0},ref:ue},pe,Ze.createElement(p,{className:Js("react-tooltip-arrow",qt.arrow,Ds.arrow,o,f&&qt.noArrow),style:{...ut.tooltipArrowStyles,background:zn?`linear-gradient(to right bottom, transparent 50%, ${zn} 50%)`:void 0,"--rt-arrow-size":`${Rt}px`},ref:Lt})):null},Em=({content:e})=>Ze.createElement("span",{dangerouslySetInnerHTML:{__html:e}}),us=Ze.forwardRef((({id:e,anchorId:t,anchorSelect:n,content:o,html:r,render:a,className:i,classNameArrow:c,variant:u="dark",place:h="top",offset:m=10,wrapper:d="div",children:g=null,events:p=["hover"],openOnClick:b=!1,positionStrategy:x="absolute",middlewares:v,delayShow:y=0,delayHide:f=0,float:w=!1,hidden:C=!1,noArrow:N=!1,clickable:O=!1,closeOnEsc:S=!1,closeOnScroll:_=!1,closeOnResize:k=!1,openEvents:E,closeEvents:te,globalCloseEvents:je,imperativeModeOnly:Me=!1,style:W,position:ce,isOpen:oe,defaultIsOpen:J=!1,disableStyleInjection:U=!1,border:re,opacity:Ue,arrowColor:on,arrowSize:z,setIsOpen:Et,afterShow:Bn,afterHide:Wn,disableTooltip:zn,role:Rt="tooltip"},ks)=>{const[lt,ue]=l.useState(o),[Lt,Le]=l.useState(r),[ct,Tt]=l.useState(h),[ut,qn]=l.useState(u),[de,rn]=l.useState(m),[At,Ye]=l.useState(y),[V,Ot]=l.useState(f),[Un,Pt]=l.useState(w),[Hn,an]=l.useState(C),[ln,Je]=l.useState(d),[cn,dt]=l.useState(p),[Mt,Vn]=l.useState(x),[un,ht]=l.useState(null),[ne,he]=l.useState(null),dn=l.useRef(null),hn=l.useRef(U),{anchorRefs:It,activeAnchor:mn}=Aa(e),Dt=K=>K?.getAttributeNames().reduce(((ae,A)=>{var M;return A.startsWith("data-tooltip-")&&(ae[A.replace(/^data-tooltip-/,"")]=(M=K?.getAttribute(A))!==null&&M!==void 0?M:null),ae}),{}),$t=K=>{const ae={place:A=>{var M;Tt((M=A)!==null&&M!==void 0?M:h)},content:A=>{ue(A??o)},html:A=>{Le(A??r)},variant:A=>{var M;qn((M=A)!==null&&M!==void 0?M:u)},offset:A=>{rn(A===null?m:Number(A))},wrapper:A=>{var M;Je((M=A)!==null&&M!==void 0?M:d)},events:A=>{const M=A?.split(" ");dt(M??p)},"position-strategy":A=>{var M;Vn((M=A)!==null&&M!==void 0?M:x)},"delay-show":A=>{Ye(A===null?y:Number(A))},"delay-hide":A=>{Ot(A===null?f:Number(A))},float:A=>{Pt(A===null?w:A==="true")},hidden:A=>{an(A===null?C:A==="true")},"class-name":A=>{ht(A)}};Object.values(ae).forEach((A=>A(null))),Object.entries(K).forEach((([A,M])=>{var pe;(pe=ae[A])===null||pe===void 0||pe.call(ae,M)}))};l.useEffect((()=>{ue(o)}),[o]),l.useEffect((()=>{Le(r)}),[r]),l.useEffect((()=>{Tt(h)}),[h]),l.useEffect((()=>{qn(u)}),[u]),l.useEffect((()=>{rn(m)}),[m]),l.useEffect((()=>{Ye(y)}),[y]),l.useEffect((()=>{Ot(f)}),[f]),l.useEffect((()=>{Pt(w)}),[w]),l.useEffect((()=>{an(C)}),[C]),l.useEffect((()=>{Vn(x)}),[x]),l.useEffect((()=>{hn.current!==U&&console.warn("[react-tooltip] Do not change `disableStyleInjection` dynamically.")}),[U]),l.useEffect((()=>{typeof window<"u"&&window.dispatchEvent(new CustomEvent("react-tooltip-inject-styles",{detail:{disableCore:U==="core",disableBase:U}}))}),[]),l.useEffect((()=>{var K;const ae=new Set(It);let A=n;if(!A&&e&&(A=`[data-tooltip-id='${e.replace(/'/g,"\\'")}']`),A)try{document.querySelectorAll(A).forEach((T=>{ae.add({current:T})}))}catch{console.warn(`[react-tooltip] "${A}" is not a valid CSS selector`)}const M=document.querySelector(`[id='${t}']`);if(M&&ae.add({current:M}),!ae.size)return()=>null;const pe=(K=ne??M)!==null&&K!==void 0?K:mn.current,mt=new MutationObserver((T=>{T.forEach((R=>{var B;if(!pe||R.type!=="attributes"||!(!((B=R.attributeName)===null||B===void 0)&&B.startsWith("data-tooltip-")))return;const ee=Dt(pe);$t(ee)}))})),j={attributes:!0,childList:!1,subtree:!1};if(pe){const T=Dt(pe);$t(T),mt.observe(pe,j)}return()=>{mt.disconnect()}}),[It,mn,ne,t,n]),l.useEffect((()=>{W?.border&&console.warn("[react-tooltip] Do not set `style.border`. Use `border` prop instead."),re&&!cr("border",`${re}`)&&console.warn(`[react-tooltip] "${re}" is not a valid \`border\`.`),W?.opacity&&console.warn("[react-tooltip] Do not set `style.opacity`. Use `opacity` prop instead."),Ue&&!cr("opacity",`${Ue}`)&&console.warn(`[react-tooltip] "${Ue}" is not a valid \`opacity\`.`)}),[]);let Ft=g;const fn=l.useRef(null);if(a){const K=a({content:ne?.getAttribute("data-tooltip-content")||lt||null,activeAnchor:ne});Ft=K?Ze.createElement("div",{ref:fn,className:"react-tooltip-content-wrapper"},K):null}else lt&&(Ft=lt);Lt&&(Ft=Ze.createElement(Em,{content:Lt}));const Qn={forwardRef:ks,id:e,anchorId:t,anchorSelect:n,className:Js(i,un),classNameArrow:c,content:Ft,contentWrapperRef:fn,place:ct,variant:ut,offset:de,wrapper:ln,events:cn,openOnClick:b,positionStrategy:Mt,middlewares:v,delayShow:At,delayHide:V,float:Un,hidden:Hn,noArrow:N,clickable:O,closeOnEsc:S,closeOnScroll:_,closeOnResize:k,openEvents:E,closeEvents:te,globalCloseEvents:je,imperativeModeOnly:Me,style:W,position:ce,isOpen:oe,defaultIsOpen:J,border:re,opacity:Ue,arrowColor:on,arrowSize:z,setIsOpen:Et,afterShow:Bn,afterHide:Wn,disableTooltip:zn,activeAnchor:ne,previousActiveAnchor:dn.current,setActiveAnchor:K=>{he((ae=>(K?.isSameNode(ae)||(dn.current=ae),K)))},role:Rt};return Ze.createElement(Sm,{...Qn})}));typeof window<"u"&&window.addEventListener("react-tooltip-inject-styles",(e=>{e.detail.disableCore||ir({css:":root{--rt-color-white:#fff;--rt-color-dark:#222;--rt-color-success:#8dc572;--rt-color-error:#be6464;--rt-color-warning:#f0ad4e;--rt-color-info:#337ab7;--rt-opacity:0.9;--rt-transition-show-delay:0.15s;--rt-transition-closing-delay:0.15s;--rt-arrow-size:8px}.core-styles-module_tooltip__3vRRp{position:absolute;top:0;left:0;pointer-events:none;opacity:0;will-change:opacity}.core-styles-module_fixed__pcSol{position:fixed}.core-styles-module_arrow__cvMwQ{position:absolute;background:inherit;z-index:-1}.core-styles-module_noArrow__xock6{display:none}.core-styles-module_clickable__ZuTTB{pointer-events:auto}.core-styles-module_show__Nt9eE{opacity:var(--rt-opacity);transition:opacity var(--rt-transition-show-delay)ease-out}.core-styles-module_closing__sGnxF{opacity:0;transition:opacity var(--rt-transition-closing-delay)ease-in}",type:"core"}),e.detail.disableBase||ir({css:`
4
- .styles-module_tooltip__mnnfp{padding:8px 16px;border-radius:3px;font-size:90%;width:max-content}.styles-module_arrow__K0L3T{width:var(--rt-arrow-size);height:var(--rt-arrow-size)}[class*='react-tooltip__place-top']>.styles-module_arrow__K0L3T{transform:rotate(45deg)}[class*='react-tooltip__place-right']>.styles-module_arrow__K0L3T{transform:rotate(135deg)}[class*='react-tooltip__place-bottom']>.styles-module_arrow__K0L3T{transform:rotate(225deg)}[class*='react-tooltip__place-left']>.styles-module_arrow__K0L3T{transform:rotate(315deg)}.styles-module_dark__xNqje{background:var(--rt-color-dark);color:var(--rt-color-white)}.styles-module_light__Z6W-X{background-color:var(--rt-color-white);color:var(--rt-color-dark)}.styles-module_success__A2AKt{background-color:var(--rt-color-success);color:var(--rt-color-white)}.styles-module_warning__SCK0X{background-color:var(--rt-color-warning);color:var(--rt-color-white)}.styles-module_error__JvumD{background-color:var(--rt-color-error);color:var(--rt-color-white)}.styles-module_info__BWdHW{background-color:var(--rt-color-info);color:var(--rt-color-white)}`,type:"base"})}));const Rm=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("circle",{cx:256,cy:256,r:32,fill:"none",stroke:"currentColor",strokeMiterlimit:10,strokeWidth:32}),l.createElement("circle",{cx:256,cy:416,r:32,fill:"none",stroke:"currentColor",strokeMiterlimit:10,strokeWidth:32}),l.createElement("circle",{cx:256,cy:96,r:32,fill:"none",stroke:"currentColor",strokeMiterlimit:10,strokeWidth:32})),Oa=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{d:"M320 146s24.36-12-64-12a160 160 0 10160 160",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeMiterlimit:10,strokeWidth:32}),l.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32,d:"M256 58l80 80-80 80"})),Lm=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("rect",{x:128,y:128,width:336,height:336,rx:57,ry:57,fill:"none",stroke:"currentColor",strokeLinejoin:"round",strokeWidth:32}),l.createElement("path",{d:"M383.5 128l.5-24a56.16 56.16 0 00-56-56H112a64.19 64.19 0 00-64 64v216a56.16 56.16 0 0056 56h24M296 216v160M376 296H216",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32})),Tm=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("circle",{cx:128,cy:256,r:48,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32}),l.createElement("circle",{cx:384,cy:112,r:48,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32}),l.createElement("circle",{cx:384,cy:400,r:48,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32}),l.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32,d:"M169.83 279.53l172.34 96.94M342.17 135.53l-172.34 96.94"})),Am=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32,d:"M32 144h448M112 256h288M208 368h96"})),Pa=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32,d:"M256 112v288M400 256H112"})),Om=()=>{const e=mo(),t=Pc();return{rename:async o=>{if(e){const r=await In("New tab name",o);r&&await t.mutateAsync({id:e,payload:{name:r}})}return Promise.resolve()}}},Ma=["shift","alt","meta","mod","ctrl","control"],Pm={esc:"escape",return:"enter",left:"arrowleft",right:"arrowright",up:"arrowup",down:"arrowdown",ShiftLeft:"shift",ShiftRight:"shift",AltLeft:"alt",AltRight:"alt",MetaLeft:"meta",MetaRight:"meta",OSLeft:"meta",OSRight:"meta",ControlLeft:"ctrl",ControlRight:"ctrl"};function st(e){return(Pm[e.trim()]||e.trim()).toLowerCase().replace(/key|digit|numpad/,"")}function Ia(e){return Ma.includes(e)}function $s(e,t=","){return e.toLowerCase().split(t)}function Fs(e,t="+",n=">",o=!1,r){let a=[],i=!1;e=e.trim(),e.includes(n)?(i=!0,a=e.toLocaleLowerCase().split(n).map(h=>st(h))):a=e.toLocaleLowerCase().split(t).map(h=>st(h));const c={alt:a.includes("alt"),ctrl:a.includes("ctrl")||a.includes("control"),shift:a.includes("shift"),meta:a.includes("meta"),mod:a.includes("mod"),useKey:o},u=a.filter(h=>!Ma.includes(h));return{...c,keys:u,description:r,isSequence:i,hotkey:e}}typeof document<"u"&&(document.addEventListener("keydown",e=>{e.code!==void 0&&Da([st(e.code)])}),document.addEventListener("keyup",e=>{e.code!==void 0&&$a([st(e.code)])})),typeof window<"u"&&(window.addEventListener("blur",()=>{Ve.clear()}),window.addEventListener("contextmenu",()=>{setTimeout(()=>{Ve.clear()},0)}));const Ve=new Set;function No(e){return Array.isArray(e)}function Mm(e,t=","){return(No(e)?e:e.split(t)).every(n=>Ve.has(n.trim().toLowerCase()))}function Da(e){const t=Array.isArray(e)?e:[e];Ve.has("meta")&&Ve.forEach(n=>!Ia(n)&&Ve.delete(n.toLowerCase())),t.forEach(n=>Ve.add(n.toLowerCase()))}function $a(e){const t=Array.isArray(e)?e:[e];e==="meta"?Ve.clear():t.forEach(n=>Ve.delete(n.toLowerCase()))}function Im(e,t,n){(typeof n=="function"&&n(e,t)||n===!0)&&e.preventDefault()}function Dm(e,t,n){return typeof n=="function"?n(e,t):n===!0||n===void 0}const $m=["input","textarea","select","searchbox","slider","spinbutton","menuitem","menuitemcheckbox","menuitemradio","option","radio","textbox"];function Fm(e){return Fa(e,$m)}function Fa(e,t=!1){const{target:n,composed:o}=e;let r,a;return Bm(n)&&o?(r=e.composedPath()[0]&&e.composedPath()[0].tagName,a=e.composedPath()[0]&&e.composedPath()[0].role):(r=n&&n.tagName,a=n&&n.role),No(t)?!!(r&&t&&t.some(i=>i.toLowerCase()===r.toLowerCase()||i===a)):!!(r&&t&&t)}function Bm(e){return!!e.tagName&&!e.tagName.startsWith("-")&&e.tagName.includes("-")}function Wm(e,t){return e.length===0&&t?(console.warn('A hotkey has the "scopes" option set, however no active scopes were found. If you want to use the global scopes feature, you need to wrap your app in a <HotkeysProvider>'),!0):t?e.some(n=>t.includes(n))||e.includes("*"):!0}const zm=(e,t,n=!1)=>{const{alt:o,meta:r,mod:a,shift:i,ctrl:c,keys:u,useKey:h}=t,{code:m,key:d,ctrlKey:g,metaKey:p,shiftKey:b,altKey:x}=e,v=st(m);if(h&&u?.length===1&&u.includes(d))return!0;if(!u?.includes(v)&&!["ctrl","control","unknown","meta","alt","shift","os"].includes(v))return!1;if(!n){if(o!==x&&v!=="alt"||i!==b&&v!=="shift")return!1;if(a){if(!p&&!g)return!1}else if(r!==p&&v!=="meta"&&v!=="os"||c!==g&&v!=="ctrl"&&v!=="control")return!1}return u&&u.length===1&&u.includes(v)?!0:u?Mm(u):!u},qm=l.createContext(void 0),Um=()=>l.useContext(qm);function Ba(e,t){return e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(e).length===Object.keys(t).length&&Object.keys(e).reduce((n,o)=>n&&Ba(e[o],t[o]),!0):e===t}const Hm=l.createContext({hotkeys:[],activeScopes:[],toggleScope:()=>{},enableScope:()=>{},disableScope:()=>{}}),Vm=()=>l.useContext(Hm);function Qm(e){const t=l.useRef(void 0);return Ba(t.current,e)||(t.current=e),t.current}const mr=e=>{e.stopPropagation(),e.preventDefault(),e.stopImmediatePropagation()},Km=typeof window<"u"?l.useLayoutEffect:l.useEffect;function Be(e,t,n,o){const r=l.useRef(null),a=l.useRef(!1),i=Array.isArray(n)?Array.isArray(o)?void 0:o:n,c=No(e)?e.join(i?.delimiter):e,u=Array.isArray(n)?n:Array.isArray(o)?o:void 0,h=l.useCallback(t,u??[]),m=l.useRef(h);u?m.current=h:m.current=t;const d=Qm(i),{activeScopes:g}=Vm(),p=Um();return Km(()=>{if(d?.enabled===!1||!Wm(g,d?.scopes))return;let b=[],x;const v=(C,N=!1)=>{if(!(Fm(C)&&!Fa(C,d?.enableOnFormTags))){if(r.current!==null){const O=r.current.getRootNode();if((O instanceof Document||O instanceof ShadowRoot)&&O.activeElement!==r.current&&!r.current.contains(O.activeElement)){mr(C);return}}C.target?.isContentEditable&&!d?.enableOnContentEditable||$s(c,d?.delimiter).forEach(O=>{if(O.includes(d?.splitKey??"+")&&O.includes(d?.sequenceSplitKey??">")){console.warn(`Hotkey ${O} contains both ${d?.splitKey??"+"} and ${d?.sequenceSplitKey??">"} which is not supported.`);return}const S=Fs(O,d?.splitKey,d?.sequenceSplitKey,d?.useKey,d?.description);if(S.isSequence){x=setTimeout(()=>{b=[]},d?.sequenceTimeoutMs??1e3);const _=S.useKey?C.key:st(C.code);if(Ia(_.toLowerCase()))return;b.push(_);const k=S.keys?.[b.length-1];if(_!==k){b=[],x&&clearTimeout(x);return}b.length===S.keys?.length&&(m.current(C,S),x&&clearTimeout(x),b=[])}else if(zm(C,S,d?.ignoreModifiers)||S.keys?.includes("*")){if(d?.ignoreEventWhen?.(C)||N&&a.current)return;if(Im(C,S,d?.preventDefault),!Dm(C,S,d?.enabled)){mr(C);return}m.current(C,S),N||(a.current=!0)}})}},y=C=>{C.code!==void 0&&(Da(st(C.code)),(d?.keydown===void 0&&d?.keyup!==!0||d?.keydown)&&v(C))},f=C=>{C.code!==void 0&&($a(st(C.code)),a.current=!1,d?.keyup&&v(C,!0))},w=r.current||i?.document||document;return w.addEventListener("keyup",f,i?.eventListenerOptions),w.addEventListener("keydown",y,i?.eventListenerOptions),p&&$s(c,d?.delimiter).forEach(C=>p.addHotkey(Fs(C,d?.splitKey,d?.sequenceSplitKey,d?.useKey,d?.description))),()=>{w.removeEventListener("keyup",f,i?.eventListenerOptions),w.removeEventListener("keydown",y,i?.eventListenerOptions),p&&$s(c,d?.delimiter).forEach(C=>p.removeHotkey(Fs(C,d?.splitKey,d?.sequenceSplitKey,d?.useKey,d?.description))),b=[],x&&clearTimeout(x)}},[c,d,g]),r}function Gm(){return s.jsxs("div",{className:"flex md:grid md:grid-cols-3 items-center bg-white overflow-auto no-scrollbar",children:[s.jsx(Ym,{}),s.jsx(Jm,{}),s.jsx(ef,{})]})}function Ym(){const{dataSourceId:e}=l.useContext(Pe),{data:t}=ps(e),{state:{table:n}}=l.useContext(Ce);return s.jsx("div",{className:L.tableConfig,children:t&&s.jsxs("div",{className:P(L.tableAction,L.greenFixed),"data-tooltip-id":"default","data-tooltip-content":n,children:[s.jsx(it,{size:18,type:t.dbType}),s.jsx("p",{className:"text-sm",children:t.name}),s.jsx(nt,{width:12,height:12}),s.jsx("p",{className:"text-sm",children:n})]})})}function Jm(){const{page:e,size:t,setPage:n}=ya(),{data:o,isFetching:r}=l.useContext(Ge),a=e*t,i=!r&&!!o?.result.hasMore,c=o?.result.rows.length||0,u=()=>{e>0&&n(e-1)},h=()=>{i&&n(e+1)};return s.jsxs("div",{className:P(L.tableConfig,"justify-self-center"),children:[s.jsx("span",{"data-tooltip-content":"Previous page","data-tooltip-id":"default",className:P(L.tableAction,L.gray,e<1&&"opacity-30"),onClick:u,role:"button",children:s.jsx(nt,{width:16,height:16,className:"rotate-180"})}),s.jsxs("span",{"data-tooltip-id":"rows-num",className:L.paginationIndicator,children:[a+1," - ",a+c,i&&"+"]}),s.jsx("span",{"data-tooltip-content":"Next page","data-tooltip-id":"default",className:P(L.tableAction,i?L.gray:"opacity-30"),onClick:h,role:"button",children:s.jsx(nt,{width:16,height:16})})]})}const Xm=[5,10,20,50,100,200],Zm=!__CLIENT_CONFIG__.skipAuth;function ef(){const{dataSourceId:e,name:t}=l.useContext(Pe),{data:n}=ps(e),{data:o,refetch:r}=l.useContext(Ge),a=An(me.EDITOR),i=Ch(),{rename:c}=Om(),{size:u,setSize:h}=ya(),{state:m}=l.useContext(Ce),d=St(),g=Y(),p=()=>{d.mutateAsync({name:t,opts:m}).then(f=>{g(D.workbenchTab.build({id:f.id}))})},b=()=>{if(o?.result.queryHistoryId){const f=new URL(window.location.href);f.pathname=D.share.build(),f.searchParams.set("shareId",o.result.queryHistoryId),navigator.clipboard.writeText(f.toString()),Se.success("Share link copied to clipboard")}},x=()=>{o?.result.columns?.[0].table&&uo({table:o?.result.columns?.[0].table,dataSourceId:e})},v=async()=>{const f=await In("Query name",t);!f||!o?.result.queryHistoryId||i.mutate({name:f,queryId:o.result.queryHistoryId})},y=()=>c(t);return Be("s",v),Be("r",y),Be("d",p),s.jsxs("div",{className:"flex justify-self-end",children:[s.jsx("span",{"data-tooltip-content":"Show filters","data-tooltip-id":"default",className:P(L.tableAction,L.gray),onClick:()=>$e("filters"),role:"button",children:s.jsx(Am,{width:16,height:16})}),s.jsx("span",{"data-tooltip-content":"Join table","data-tooltip-id":"default",className:P(L.tableAction,L.gray),onClick:()=>$e("joins"),role:"button",children:s.jsx(Pa,{width:16,height:16})}),s.jsx("span",{"data-tooltip-content":"Refresh data","data-tooltip-id":"default",className:P(L.tableAction,L.gray),onClick:()=>r(),role:"button",children:s.jsx(Oa,{width:16,height:16})}),Zm&&s.jsx("span",{"data-tooltip-content":"Share query","data-tooltip-id":"default",className:P(L.tableAction,L.gray),onClick:b,role:"button",children:s.jsx(Tm,{width:16,height:16})}),s.jsx("span",{"data-tooltip-content":"Duplicate tab","data-tooltip-id":"default",className:P(L.tableAction,L.gray),onClick:p,role:"button",children:s.jsx(Lm,{width:16,height:16})}),s.jsx(us,{id:"rows-num",className:"z-10 shadow-md flex gap-1",clickable:!0,variant:"light",opacity:1,children:Xm.map(f=>s.jsx("button",{onClick:()=>h(f,!0),className:P(L.tableAction,L.gray,f===u&&L.selectedSize),children:s.jsx("span",{children:f})},f))}),s.jsx("button",{"data-tooltip-id":"explorer-more-actions",className:P(L.tableAction,L.gray),children:s.jsx(Rm,{width:16,height:16})}),s.jsxs(us,{id:"explorer-more-actions",className:"z-10 shadow-md flex flex-col",clickable:!0,variant:"light",opacity:1,children:[s.jsxs("button",{onClick:()=>$e("columns"),className:P(L.tableAction,L.modal,L.gray,"justify-between"),children:[s.jsx("span",{children:"Columns"}),s.jsx("span",{className:"hotkey",children:"C"})]}),s.jsxs("button",{onClick:()=>$e("groupBy"),className:P(L.tableAction,L.modal,L.gray,"justify-between"),children:[s.jsx("span",{children:"Group by"}),s.jsx("span",{className:"hotkey",children:"G"})]}),s.jsxs("button",{onClick:()=>$e("aggregate"),className:P(L.tableAction,L.modal,L.gray,"justify-between"),children:[s.jsx("span",{children:"Aggregate"}),s.jsx("span",{className:"hotkey",children:"A"})]}),s.jsx("div",{className:"h-0.5 my-2 bg-gray-100"}),s.jsxs("button",{onClick:y,className:P(L.tableAction,L.modal,L.gray,"justify-between"),children:[s.jsx("span",{children:"Rename tab"}),s.jsx("span",{className:"hotkey",children:"R"})]}),a&&s.jsxs(s.Fragment,{children:[s.jsxs("button",{onClick:v,className:P(L.tableAction,L.modal,L.gray),children:[s.jsx("span",{children:"Save query"}),s.jsx("span",{className:"hotkey",children:"S"})]}),n?.allowInsert===!0&&s.jsx("button",{onClick:x,className:P(L.tableAction,L.modal,L.gray),children:"Insert new row"})]})]})]})}const tf="_drop-container_wz0bw_2",nf="_item_wz0bw_2",fr={dropContainer:tf,item:nf},Wa=({dataSourceId:e,inputClassName:t,focusId:n,placeholder:o="Column",onChange:r,value:a,autoFocus:i,allowTables:c})=>{const{data:u}=gs(e),h=l.useRef(null),m=l.useMemo(()=>{if(!u)return[];let f=u;return c&&(f=u.filter(w=>c.includes(w.tableName))),f.flatMap(w=>w.columns.map(C=>({value:w.tableName+"."+C.name,label:C.name,table:w.tableName,searchValue:C.name.toLowerCase()})))},[u,c]),d=l.useMemo(()=>{const f=a.toLowerCase()||"",w=[];for(let C=0;C<m.length&&w.length<10;C++)m[C].searchValue.includes(f)&&w.push(m[C]);return w},[m,a]),[g,p]=l.useState(!1),[b,x]=l.useState(0),v=f=>{if(f.key==="ArrowDown")f.preventDefault(),x(w=>(w+1)%d.length);else if(f.key==="ArrowUp")f.preventDefault(),x(w=>(w-1+d.length)%d.length);else if(f.key==="Enter"&&b>=0&&b<d.length){f.preventDefault();const w=d[b].value;p(!1);const C=m.findIndex(N=>N.value===w)>-1;r(d[b]?.value||w,C,!0)}};l.useEffect(()=>{const f=h.current?.querySelector('[data-is-active="true"]');f&&f.scrollIntoView({behavior:"smooth",block:"nearest"})},[b]);const y=f=>{const w=f.currentTarget.value,C=m.findIndex(N=>N.value===w)>-1;r(w,C,!1)};return s.jsxs("div",{className:"relative",onFocus:()=>p(!0),onBlur:()=>p(!1),children:[s.jsx("input",{autoFocus:i,onKeyDown:v,value:a,onChange:y,className:t,placeholder:o,"data-focus":n}),g&&d.length>0&&s.jsx("div",{className:fr.dropContainer,ref:h,tabIndex:-1,children:d.map((f,w)=>s.jsxs("div",{className:fr.item,"data-is-active":b===w,onMouseDownCapture:C=>{C.preventDefault(),p(!1),r(f.value,!0,!0)},children:[s.jsx("span",{className:"text-xs font-semibold truncate",children:f.table}),s.jsx("p",{className:"truncate text-sm",children:f.label})]},w))})]})},sf="_actions_16qhw_2",of="_filter-actions_16qhw_2",rf="_filter-badge_16qhw_2",af="_filters-container_16qhw_2",lf="_filter-container_16qhw_2",cf="_filter-value_16qhw_2",Qt={actions:sf,filterActions:of,filterBadge:rf,filtersContainer:af,filterContainer:lf,filterValue:cf},uf=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{d:"M315.27 33L96 304h128l-31.51 173.23a2.36 2.36 0 002.33 2.77h0a2.36 2.36 0 001.89-.95L416 208H288l31.66-173.25a2.45 2.45 0 00-2.44-2.75h0a2.42 2.42 0 00-1.95 1z",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32})),df=({isAdvanced:e})=>e?s.jsx("span",{"data-tooltip-id":"default","data-tooltip-content":"Advanced mode: parameters and operator will be extracted from the input",className:Qt.filterBadge,children:s.jsx(uf,{width:20,height:20})}):null,hf=({filter:e,dataSourceId:t,allowedTables:n,autoFocus:o,onChangeColumn:r,onChangeValue:a,onRemoveFilter:i,onChangeAdvancedFilter:c,triggerIsEnabled:u,onSubmit:h})=>{const m=g=>{const p=g.target.value;p.charAt(0)===":"?c(e.id,!0):(!e.isAdvanced&&["=","<",">"].includes(p.charAt(0))&&c(e.id,!0),a(e.id,g.currentTarget.value))},d=g=>{g.key==="Backspace"?(e.value.length===0||g.currentTarget.selectionEnd===0)&&c(e.id,!1):g.key==="Enter"&&h()};return s.jsxs("div",{className:Qt.filterContainer,children:[s.jsx("input",{className:"mr-1",type:"checkbox",checked:e.isEnabled!==!1,onClick:()=>u(e.id)}),s.jsx(Wa,{dataSourceId:t,onChange:g=>r(e.id,g),value:e.column,allowTables:n,focusId:"column",inputClassName:"input w-full rounded-r-none!",autoFocus:o}),s.jsxs("div",{className:Qt.filterValue,children:[s.jsx(df,{isAdvanced:e.isAdvanced}),s.jsx("input",{placeholder:"Filter value",value:e.value,onChange:m,onKeyDown:d,"data-focus":"value",className:"flex-1 outline-none"},e.id)]}),s.jsx("div",{className:Qt.filterActions,children:s.jsx("button",{tabIndex:-1,"data-tooltip-id":"default","data-tooltip-content":"Remove filter",className:"p-0.5 text-sm cursor-pointer rounded-md ml-1",onClick:()=>i(e.id),children:s.jsx(jt,{width:20,height:20,className:"text-red-600"})})})]})},mf=()=>{const{state:e}=l.useContext(Ce),{refetch:t}=l.useContext(Ge),{setFilters:n}=xo(),o=ys(x=>x.filters),r=l.useMemo(()=>[e.table,...e.joins.map(x=>x.table)],[e.table,e.joins]),[a,i]=l.useState([]),c=(x,v)=>{i(y=>[...y.map(f=>f.id===x?{...f,column:v}:f)])},u=(x,v)=>{i(y=>[...y.map(f=>f.id===x?{...f,value:v}:f)])},h=()=>{i(x=>[...x,{id:ot(),value:"",column:"",isEnabled:!0}])},m=x=>{i(v=>v.filter(y=>y.id!==x))},d=(x,v)=>{i(y=>y.map(f=>f.id===x?{...f,isAdvanced:v}:f))},g=()=>ws("filters"),p=()=>{try{n(a.filter(x=>x.value.length>0&&x.column.length>0)),setTimeout(t,1),g()}catch(x){x instanceof Error?Se.error(x.message):Se.error("Error during parsing, check you filters")}},b=x=>{i(v=>v.map(y=>y.id===x?{...y,isEnabled:!y.isEnabled}:y))};return l.useEffect(()=>{o&&i(()=>[...e.filters,{id:ot(),value:"",column:"",isEnabled:!0}])},[o]),Be("f",()=>{as("filters")}),s.jsxs(we,{isVisible:o,onClose:g,portal:!0,onClosed:()=>i([]),noPadding:!0,backdropClose:!0,children:[s.jsx(at,{onClick:g}),s.jsx("h2",{className:"text-lg font-semibold m-2",children:"Filters"}),s.jsxs("div",{className:Qt.filtersContainer,children:[a.length<1&&s.jsx("p",{className:"p-1 text-center rounded-lg bg-gray-50 border border-gray-200",children:"No filters"}),a.map((x,v)=>s.jsx(hf,{filter:x,dataSourceId:e.dataSourceId,allowedTables:r,onChangeColumn:c,onChangeValue:u,onRemoveFilter:m,onChangeAdvancedFilter:d,triggerIsEnabled:b,onSubmit:p,autoFocus:v===a.length-1},x.id))]}),s.jsxs("div",{className:Qt.actions,children:[s.jsxs("button",{className:"button tertiary flex items-center gap-1 text-sm",onClick:h,children:[s.jsx(Pa,{width:20,height:20}),s.jsx("span",{children:"Add filter"})]}),s.jsx("button",{className:"button primary text-sm",onClick:p,children:"Apply filters"})]})]})},ff="_join-modal_2chva_2",pf={joinModal:ff},gf=(e,t)=>e.type!==t.type||e.on!==t.on||e.table!==t.table,xf=(e,t)=>e.type===t.type&&e.on===t.on&&e.table===t.table,za=()=>{const{state:e,setState:t}=l.useContext(Ce),n=l.useCallback(o=>{t(r=>{const a=r.joins;if(a.some(c=>xf(c,o))){const c=o.table+".";return{...r,joins:a.filter(u=>gf(u,o)),columns:r.columns.filter(u=>!u.value.startsWith(c)),groupBy:r.groupBy.filter(u=>!u.value.startsWith(c)),orderBy:r.orderBy.filter(u=>!u.column.startsWith(c)),aggregations:r.aggregations.filter(u=>!u.value.startsWith(c)),filters:r.filters.filter(u=>!u.column.startsWith(c))}}return{...r,joins:[...a,o]}})},[t]);return{joins:e.joins,toggle:n}},bf=()=>{const{isFetching:e}=l.useContext(Ge),t=ys(u=>u.joins),{toggle:n}=za(),{availableJoins:o}=l.useContext(Pe),[r,a]=l.useState(""),i=l.useMemo(()=>{const u=r.toLowerCase();return o.filter(h=>h.fromTable.toLowerCase().includes(u))},[o,r]),c=()=>ws("joins");return Be("j",()=>{o.length>0?$e("joins"):Se.error("No available tables to join")}),s.jsxs(we,{isVisible:t,onClose:c,portal:!0,backdropClose:!0,children:[s.jsx(at,{onClick:c}),s.jsxs("div",{className:pf.joinModal,children:[s.jsx("h2",{className:"text-lg font-semibold mb-4",children:"Join table"}),o.length>0?s.jsx("input",{className:"input w-full",placeholder:"Filter",autoFocus:!0,onChange:u=>a(u.target.value),value:r,disabled:e}):s.jsx(fe,{variant:"warning",children:s.jsx("p",{className:"text-sm truncate",children:"There is nothing else to join"})}),s.jsx("div",{className:`flex flex-col mt-2 overflow-y-auto ${e?"opacity-40":""}`,children:i.map(u=>s.jsx(go,{hook:u,onClick:()=>{e||(n({table:u.direction==="in"?u.fromTable:u.toTable,type:"LEFT",on:Hc(u)}),a(""),c())}},u.id))})]})]})};function vf(e){return e.reduce((t,n)=>(t[n]=!0,t),{})}function pr(e){return e.reduce((t,n)=>(t[n]=!0,t),{})}const yf="_container_122yr_2",wf="_column-label_122yr_2",Cf="_not-active_122yr_2",ss={container:yf,columnLabel:wf,notActive:Cf};function jf(e){if(!e)return[];const t={};return e.forEach(n=>{t[n.table]?t[n.table].push({value:n.full,ogColumn:n.column,label:et(n.column),type:n.type}):t[n.table]=[{value:n.full,ogColumn:n.column,label:et(n.column),type:n.type}],qc[n.type]&&["YEAR","MONTH","DAY"].forEach(o=>{t[n.table].push({value:o+" "+n.full,ogColumn:n.column,label:o+" "+et(n.column),type:"number",nested:!0})})}),Object.entries(t).reduce((n,[o,r])=>(n.push({name:et(o),columns:r}),n),[])}function Nf(e,t){const n=t.toLowerCase();return e.map(o=>{const r=o.columns.filter(a=>a.label.toLowerCase().includes(n)||a.ogColumn.toLowerCase().includes(n));return{...o,columns:r}}).filter(o=>o.columns.length>0)}const _f=({column:e,selected:t,onCheck:n})=>s.jsxs("label",{className:P(ss.columnLabel,t?ss.active:ss.notActive,e.nested&&"pl-5!"),children:[s.jsx("input",{type:"checkbox",checked:t[e.value],name:e.value,onChange:n}),s.jsxs("p",{className:"flex justify-between w-full",children:[s.jsx("span",{"data-tooltip-content":e.value,"data-tooltip-id":"default",children:e.label}),s.jsx("span",{className:"text-blue-600",children:e.type})]})]},e.value),kf={columns:"c",groupBy:"g"},gr=({mode:e})=>{const t=ys(f=>f[e]),{allColumns:n}=l.useContext(Pe),{state:o,setState:r}=l.useContext(Ce),[a,i]=l.useState({}),[c,u]=l.useState(""),h=l.useMemo(()=>jf(n),[n]),m=o.aggregations.length>0||o.groupBy.length>0,d=l.useMemo(()=>c?Nf(h,c):h,[c,h]),g=f=>{i(w=>({...w,[f.target.name]:f.target.checked}))},p=f=>{const w=f.target.checked;i(C=>{for(const N of n)C[N.full]=w;return{...C}})},b=()=>{ws(e)},x=()=>{const f=[];for(const[w,C]of Object.entries(a))if(C){const[N,O]=w.split(" ");f.push({value:O||N,fn:O?N:void 0})}r(w=>({...w,[e]:f})),b()},v=l.useMemo(()=>{for(const f of n)if(!a[f.full])return!1;return!0},[a,n]);Be(kf[e],()=>{e==="columns"?m?Se.error("Columns are ignored when there is at least one aggregation or group by"):as("columns"):as("groupBy")}),l.useEffect(()=>{t&&i(()=>vf(o[e].map(f=>f.fn?f.fn+" "+f.value:f.value)))},[t,i]);const y=()=>{u(""),i({})};return s.jsxs(we,{isVisible:t,onClose:b,portal:!0,onClosed:y,backdropClose:!0,children:[s.jsx(at,{onClick:b}),s.jsxs("div",{className:ss.container,children:[s.jsx("h2",{className:"text-lg font-semibold",children:e==="groupBy"?"Group by":"Show columns"}),s.jsx("input",{autoFocus:!0,className:"input my-2",placeholder:"Filter",value:c,onChange:f=>u(f.target.value)}),s.jsx("div",{className:"overflow-y-auto",children:d.map(f=>s.jsxs("div",{className:"my-2",children:[s.jsxs("p",{className:"font-semibold sticky top-0 bg-white p-1 z-1",children:["📄 ",f.name]}),f.columns.map(w=>s.jsx(_f,{column:w,selected:a,onCheck:g},w.value))]},f.name))}),s.jsxs("div",{className:"flex justify-end gap-2 mt-2",children:[s.jsxs("label",{className:"button tertiary flex gap-2 items-center",children:[s.jsx("input",{type:"checkbox",checked:v,onChange:p}),s.jsx("span",{children:"Select all"})]}),s.jsx("span",{className:"flex-1"}),s.jsx("button",{className:"button tertiary",onClick:b,children:"Cancel"}),s.jsx("button",{className:"button primary",onClick:x,children:"Apply"})]})]})]})},Sf="_options-container_1904u_2",Ef={optionsContainer:Sf},Bs="COUNT all",Rf=()=>{const e=ys(b=>b.aggregate),{dataSourceId:t}=l.useContext(Pe),{setState:n,state:o}=l.useContext(Ce),{data:r}=l.useContext(Ge),[a,i]=l.useState({fn:"",col:""}),c=b=>i({...a,fn:b.currentTarget.value}),u=b=>i({...a,col:b}),h=()=>ws("aggregate"),m=()=>{const b=a.fn===Bs?{value:"*",fn:"COUNT"}:{fn:a.fn,value:a.col,distinct:a.fn==="COUNT"};n(x=>({...x,aggregations:[...x.aggregations,b]}))},d=a.fn===Bs,g=d?!1:!a.col||!a.fn,p=b=>{const x=Uc(b);n(v=>({...v,aggregations:v.aggregations.filter(y=>y.fn!==b.fn||y.value!==b.value),orderBy:v.orderBy.filter(y=>y.column!==x)}))};return Be("a",()=>{as("aggregate")}),s.jsxs(we,{isVisible:e,onClose:h,backdropClose:!0,portal:!0,children:[s.jsx(at,{onClick:h}),s.jsxs("div",{children:[s.jsx("h2",{className:"text-lg font-semibold",children:"Aggregate"}),xe(o.aggregations.length,0)&&s.jsx("div",{className:"flex flex-col gap-1 mt-4",children:o.aggregations.map((b,x)=>s.jsxs("p",{className:"p-2 rounded-md bg-gray-50 flex items-center justify-between",children:[s.jsx("span",{children:ts(b)}),s.jsx("button",{tabIndex:-1,"data-tooltip-id":"default","data-tooltip-content":"Remove aggregation",className:"p-0.5 text-sm cursor-pointer",onClick:()=>p(b),children:s.jsx(jt,{width:20,height:20,className:"text-red-600"})})]},x))}),s.jsxs("div",{className:Ef.optionsContainer,children:[s.jsxs("label",{className:P(d&&"col-span-2"),children:[s.jsx("p",{className:"font-semibold text-xs",children:"Function"}),s.jsxs("select",{className:"input w-full",value:a.fn,onChange:c,autoFocus:!0,children:[s.jsx("option",{value:"",disabled:!0,children:"Select function"}),s.jsx("option",{value:Bs,children:"Count all rows"}),s.jsx("option",{value:"COUNT",children:"Count"}),s.jsx("option",{value:"SUM",children:"Sum"}),s.jsx("option",{value:"MAX",children:"Max"}),s.jsx("option",{value:"MIN",children:"Min"}),s.jsx("option",{value:"AVG",children:"Avg"})]})]}),!d&&s.jsxs("label",{children:[s.jsx("p",{className:"font-semibold text-xs",children:"Column"}),s.jsx(Wa,{inputClassName:"input w-full",dataSourceId:t,allowTables:r?.result.tables||[],onChange:u,value:a.col})]}),s.jsx("button",{className:"button primary",disabled:g,onClick:m,children:"Add"})]})]})]})},Lf="_container_7k3xb_2",Tf="_yellow-pill_7k3xb_2 _pill_7k3xb_2",Af="_blue-pill_7k3xb_2 _pill_7k3xb_2",Of="_purple-pill_7k3xb_2 _pill_7k3xb_2",Pf="_red-pill_7k3xb_2 _pill_7k3xb_2",Mf="_black-pill_7k3xb_2 _pill_7k3xb_2",If="_disabled-pill_7k3xb_2",xt={container:Lf,yellowPill:Tf,bluePill:Af,purplePill:Of,redPill:Pf,blackPill:Mf,disabledPill:If};function _o(e,t=500,n){const[o,r]=l.useState(e),a=l.useRef(n);return a.current=n,l.useEffect(()=>{const i=setTimeout(()=>{r(e),a.current&&a.current(e)},t);return()=>clearTimeout(i)},[e,t]),o}function Df(e){return!(e===!0||e===void 0)}const $f=()=>{const{state:{aggregations:e,columns:t,groupBy:n}}=l.useContext(Ce),{toggle:o,joins:r}=za(),{filters:a,setFilters:i,removeFilter:c}=xo(),u=()=>$e("joins"),h=()=>$e("aggregate"),m=()=>$e("columns"),d=()=>$e("groupBy"),g=x=>{x.preventDefault(),x.stopPropagation(),o(r[r.length-1])},p=x=>{i(a.map(v=>({...v,isEnabled:x===v.id?Df(v.isEnabled):v.isEnabled})),!0)},b=x=>v=>{v.preventDefault(),v.stopPropagation(),c(x)};return a.length>0||r.length>0||n.length>0||t.length>0||e.length>0?s.jsxs("div",{className:xt.container,children:[r.map((x,v)=>s.jsxs("button",{onClick:u,className:xt.yellowPill,"data-tooltip-id":"default","data-tooltip-content":`Joins ${x.table} on ${x.on}`,children:[s.jsx("p",{className:"text-sm",children:x.table}),v===r.length-1&&s.jsx(jt,{onClick:g,width:18,height:18})]},x.table)),a.map(x=>s.jsxs("button",{onClick:()=>p(x.id),onAuxClick:()=>c(x.id),className:P(xt.bluePill,x.isEnabled===!1&&xt.disabledPill),"data-tooltip-id":"default","data-tooltip-content":`${x.column} ${x.value}`,children:[s.jsx("p",{className:"text-sm",children:x.column}),s.jsx("p",{className:"text-sm",children:x.value}),s.jsx(jt,{onClick:b(x.id),width:18,height:18})]},x.id)),e.map(x=>s.jsx("button",{onClick:h,className:P(xt.purplePill),"data-tooltip-id":"default","data-tooltip-content":ts(x),children:s.jsx("p",{className:"text-sm",children:ts(x)})},ts(x))),t.length>0&&s.jsx("button",{onClick:m,className:P(xt.redPill),"data-tooltip-id":"default","data-tooltip-content":"Has hidden columns",children:s.jsx("p",{className:"text-sm",children:"Hidden columns"})}),n.length>0&&s.jsx("button",{onClick:d,className:P(xt.blackPill),"data-tooltip-id":"default","data-tooltip-content":"Has GROUP BY",children:s.jsx("p",{className:"text-sm",children:"Grouped columns"})}),!1]}):null},Ff=({options:e,updater:t,name:n,tabId:o})=>{const r=Nc(e,t),a=Mc(o,r.state),i=jc(a.data,r.state.dataSourceId,n,o);return s.jsx(Pe,{value:i,children:s.jsx(Ce,{value:r,children:s.jsxs(Ge,{value:a,children:[s.jsx(Gm,{}),s.jsx($f,{}),s.jsxs("div",{className:"flex-1 flex overflow-hidden border-t border-t-gray-200",children:[s.jsx("div",{className:"flex-1 overflow-auto pb-24 lg:pb-12 no-scrollbar",children:s.jsx(wh,{})}),s.jsx(mf,{}),s.jsx(bf,{}),s.jsx(gr,{mode:"columns"}),s.jsx(gr,{mode:"groupBy"}),s.jsx(Rf,{})]})]})})})},qa=()=>s.jsxs("div",{role:"status",children:[s.jsxs("svg",{"aria-hidden":"true",className:"w-8 h-8 text-gray-200 animate-spin dark:text-gray-600 fill-blue-600",viewBox:"0 0 100 101",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("path",{d:"M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z",fill:"currentColor"}),s.jsx("path",{d:"M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z",fill:"currentFill"})]}),s.jsx("span",{className:"sr-only",children:"Loading..."})]}),Bf=({id:e})=>{const{data:t}=Ac(e),n=l.useCallback(o=>{if(!t)return;const r=o(en(t.opts));Q.setQueryData(["workbench-tabs",t.id],{...t,opts:{...t.opts,...r}})},[t]);return t?s.jsx(Ff,{updater:n,options:t.opts,name:t.name,tabId:t.id}):s.jsx("div",{className:"flex-1 flex justify-center items-center",children:s.jsx(qa,{})})},Wf=e=>{setTimeout(t=>{const n=document.querySelector(`[data-tab-id="${t}"]`);n&&n.scrollIntoView({behavior:"smooth"})},50,e)},zf=()=>{const{id:e}=Gi(),t=Y(),{data:n}=bs(),o=Oc(),r=da(po.laptop),a=u=>{if(u===e&&n){if(n.length===1)return t(D.home.build());if(n.length>1){const h=n.find(m=>m.id!==u);if(h)return t(`/workbench/tab/${h.id}`)}}},i=u=>{u.stopPropagation(),u.preventDefault();const h=u.currentTarget.getAttribute("data-tab-id");h&&(o.mutate(h),a(h))},c=u=>{o.mutate(u),a(u)};return l.useEffect(()=>{e&&Wf(e)},[e,n]),s.jsxs("div",{className:"h-screen max-h-screen bg-(--bg) flex flex-col",children:[e?s.jsx(Bf,{id:e}):s.jsx("div",{className:"flex-1"}),s.jsx("div",{className:P(vn.tabs,"no-scrollbar",!r&&vn.mobile),children:n?.map(u=>s.jsxs("div",{onClick:()=>t(D.workbenchTab.build({id:u.id})),className:P(vn.tab,u.id===e&&vn.active),"data-tooltip-id":"default","data-tab-id":u.id,"data-tooltip-content":u.name,onAuxClick:()=>c(u.id),children:[s.jsxs("span",{className:"truncate w-full",children:["🛠️ ",u.name]}),s.jsx("button",{"data-tab-id":u.id,className:vn.closeButton,onClick:i,children:s.jsx(jt,{width:20,height:20})})]},u.id))})]})},qf="_root_nzy7t_2",Uf="_up_nzy7t_2",Hf="_down_nzy7t_2",Vf="_chevron_nzy7t_2",Qf="_table-name-container_nzy7t_2",Kf="_link_nzy7t_2",Gf="_table-name_nzy7t_2",Yf="_ul_nzy7t_2",Jf="_column-type_nzy7t_2",Xf="_action-blue_nzy7t_2 _action_nzy7t_2",Zf="_action-red_nzy7t_2 _action_nzy7t_2",e0="_db-header-container_nzy7t_2",t0="_db-header_nzy7t_2",n0="_db-subheader_nzy7t_2 _db-header_nzy7t_2",se={root:qf,up:Uf,down:Hf,chevron:Vf,tableNameContainer:Qf,link:Kf,tableName:Gf,ul:Yf,columnType:Jf,actionBlue:Xf,actionRed:Zf,dbHeaderContainer:e0,dbHeader:t0,dbSubheader:n0},s0="_sidebar_ejwjv_2",o0="_sidebar-visible_ejwjv_2",r0="_sidebar-container_ejwjv_2",a0="_sidebar-invisible_ejwjv_2",i0="_backdrop_ejwjv_2",yn={sidebar:s0,sidebarVisible:o0,sidebarContainer:r0,sidebarInvisible:a0,backdrop:i0},ko=({children:e,backdropClose:t,isVisible:n,onClose:o,onClosed:r,contentClassName:a})=>{const[i,c]=l.useState(!1),u=l.useRef(o);u.current=o;const h=()=>{t&&o()},m=d=>{n||getComputedStyle(d.currentTarget).opacity==="0"&&(c(!1),r&&r())};return l.useEffect(()=>{n&&c(!0)},[n]),vs({onClose:h,enabled:n&&t===!0}),s.jsxs("div",{onTransitionEnd:m,className:P(yn.sidebar,n?yn.sidebarVisible:yn.sidebarInvisible),children:[s.jsx("div",{onClick:h,className:yn.backdrop}),s.jsx("div",{className:P(yn.sidebarContainer,a),children:i&&e})]})},l0=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{d:"M432 144l-28.67 275.74A32 32 0 01371.55 448H140.46a32 32 0 01-31.78-28.26L80 144",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32}),l.createElement("rect",{x:32,y:64,width:448,height:80,rx:16,ry:16,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32}),l.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32,d:"M312 240L200 352M312 352L200 240"})),Ua=(e,t=!0)=>{const n=navigator.clipboard.writeText(e);t&&n.then(()=>{Se.success(`Copied "${e}"`)})},c0=new Intl.DateTimeFormat("en",{dateStyle:"full",timeStyle:"long"}),Jn=18;function u0(e,t){return t&&e.toLowerCase().includes(t)?"bg-yellow-200 cursor-pointer":"cursor-pointer"}const d0=({insp:e,filter:t,expanded:n})=>{const o=l.useMemo(()=>n?e.columns:t.length<1?[]:e.columns.filter(r=>r.name.toLowerCase().includes(t)),[e,t,n]);return s.jsx("ul",{className:se.ul,children:o.map(r=>s.jsx(s.Fragment,{children:s.jsxs("li",{children:[r.isPrimary?"🔐":"🏷️"," ",s.jsx("span",{onClick:()=>Ua(r.name),className:u0(r.name,t),children:r.name})," ",s.jsxs("span",{className:se.columnType,children:["[",r.type,"]"]}),r.ref&&s.jsxs("span",{children:[" ➡️ ",s.jsx("span",{className:se.columnType,children:r.ref.table}),".",r.ref.field]})]},r.name+r.type)}))},e.id)};function h0({id:e}){const{data:t}=ps(e),{data:n}=gs(e),o=Y(),r=vc(),a=Xr(),i=yc(),c=St(),u=l.useMemo(()=>t?.lastInspected?c0.format(new Date(t.lastInspected)):"--",[t]),[h,m]=l.useState({}),[d,g]=l.useState(""),[p,b]=l.useState("table"),x=An(me.EDITOR),v=d.toLowerCase(),y=l.useMemo(()=>{if(!v||!n)return n||[];const _=[];for(const k of n){if(k.tableName.toLowerCase().includes(v)){_.push(k);continue}p!=="table"&&k.columns.findIndex(E=>E.name.toLowerCase().includes(v))>=0&&_.push(k)}return _},[v,n,p]),f=_=>{m(k=>({...k,[_]:!k[_]}))},w=_=>{c.mutateAsync({name:_,opts:en({table:_,dataSourceId:e})}).then(k=>{_n(void 0),o(D.workbenchTab.build({id:k.id}))})},C=()=>{a.mutate(e)},N=async()=>{const _=await In("Enter name",t?.name);_&&r.mutate({id:e,dataSource:{name:_}})},O=async()=>{await fo("Are you sure you want to delete this data source?")&&(i.mutate(e),_n(void 0))},S=p==="column";return s.jsxs("div",{className:se.root,children:[s.jsxs("div",{className:"sticky top-0 bg-white border-b border-gray-200 px-4 py-2 z-1",children:[s.jsxs("div",{className:se.dbHeaderContainer,children:[s.jsxs("div",{className:se.dbHeader,children:[t&&s.jsx(it,{size:24,type:t.dbType}),s.jsx("p",{className:"truncate text-(--text-color-primary) text-lg",children:t?.name})]}),s.jsxs("div",{className:se.dbSubheader,children:[s.jsx("p",{className:"text-xs text-(--text-color-secondary) truncate",children:u}),x&&s.jsxs("div",{className:"flex justify-end",children:[s.jsx("button",{disabled:a.isPending,onClick:C,className:se.actionBlue,"data-tooltip-id":"default-xs","data-tooltip-content":"Refresh schema",children:s.jsx(Oa,{width:16,height:16})}),s.jsx("button",{disabled:a.isPending,onClick:N,className:se.actionBlue,"data-tooltip-id":"default-xs","data-tooltip-content":"Update name",children:s.jsx(va,{width:16,height:16})}),s.jsx("button",{disabled:a.isPending,onClick:O,className:se.actionRed,"data-tooltip-id":"default-xs","data-tooltip-content":"Delete data source",children:s.jsx(l0,{width:16,height:16})})]})]})]}),s.jsxs("div",{className:"flex gap-2 items-center mt-2",children:[s.jsxs("select",{className:"input",value:p,onChange:_=>b(_.currentTarget.value),children:[s.jsx("option",{value:"table",children:"Table"}),s.jsx("option",{value:"column",children:"Column"})]}),s.jsx("input",{className:"input flex-1 bg-gray-50",placeholder:S?"Search column":"Search table",value:d,onChange:_=>g(_.target.value),autoFocus:!0})]})]}),s.jsx("div",{className:"overflow-y-auto p-4",children:y?.map(_=>s.jsxs("div",{children:[s.jsxs("div",{className:se.tableNameContainer,children:[s.jsx("button",{className:P(se.chevron,h[_.id]?se.down:se.up),onClick:()=>f(_.id),children:s.jsx(nt,{width:16,height:16})}),s.jsx("button",{className:P(se.tableName,"flex-1"),onClick:()=>f(_.id),children:_.tableName}),s.jsx("button",{className:se.link,onClick:()=>w(_.tableName),"data-tooltip-id":"default-xs","data-tooltip-content":"Explore table data",children:s.jsx(ca,{width:Jn,height:Jn})}),s.jsx("button",{className:se.link,onClick:()=>Ua(_.tableName),"data-tooltip-id":"default-xs","data-tooltip-content":"Copy table name",children:s.jsx(ba,{width:Jn,height:Jn})})]}),(h[_.id]||d.length>0)&&s.jsx(d0,{insp:_,filter:S?v:"",expanded:h[_.id]})]},_.id))})]})}const m0=()=>{const e=wu(),[t,n]=l.useState(void 0);l.useEffect(()=>{e&&n(e)},[e]);const o=()=>_n(void 0);return s.jsx(ko,{isVisible:e!=null,onClose:o,onClosed:()=>n(void 0),backdropClose:!0,children:t&&s.jsx(h0,{id:t})})},f0="_search-container_2kdj7_2",p0="_search_2kdj7_2",g0="_entry_2kdj7_2",x0="_ds_2kdj7_2",b0="_ds-container_2kdj7_2",v0="_ds-entry_2kdj7_2",y0="_enabled_2kdj7_2",bt={searchContainer:f0,search:p0,entry:g0,ds:x0,dsContainer:b0,dsEntry:v0,enabled:y0};function w0(e,t,n){try{const o=n.getItem(e);if(o)return JSON.parse(o)}catch(o){console.warn("Failed to restore tabs",o)}return t}const C0=({storage:e=localStorage,localStorageKey:t,initialData:n})=>{const o=ye(w0(t,n,e));return o[2].subscribe(r=>{e.setItem(t,JSON.stringify(r))}),o},[j0,N0]=C0({initialData:[],localStorageKey:"selected-data-sources-v1"}),_0=e=>N0(t=>{const n=t.indexOf(e);return n>-1?(t.splice(n,1),[...t]):[...t,e]}),k0={table:"📄",query:"📖",tab:"🛠️"},S0=({onTable:e,onQuery:t,onWorkbenchTab:n,autoFocus:o})=>{const[r,a]=l.useState(""),[i,c]=l.useState(-1),u=_o(r,200),h=j0(),{data:m}=ve(),{data:d}=io({teamId:m?.teamId}),g=l.useMemo(()=>{const f=[],w=pr(h);if(!d||d.length===0)return[];for(const C of d)w[C.id]&&f.push(C.id);return f},[h,d]),{data:p}=cc(u,{teamId:m?.teamId,selectedDataSources:g}),b=f=>{f.type==="table"?e(f.name,f.dataSourceId):f.type==="query"?t(f.id,f.dataSourceId):f.type==="tab"&&n(f.id,f.dataSourceId)},x=f=>{p&&(f.key==="ArrowDown"?(f.preventDefault(),c(w=>(w+1)%p.length)):f.key==="ArrowUp"?(f.preventDefault(),c(w=>(w-1+p.length)%p.length)):f.key==="Enter"&&i>=0&&p[i]?.name&&(f.preventDefault(),b(p[i])))},v=f=>{const w=f.currentTarget.dataset.tableId,C=p?.find(N=>N.id===w);C&&b(C)},y=l.useMemo(()=>pr(h),[h]);return s.jsxs("div",{className:"overflow-hidden flex flex-col w-full lg:w-lg",children:[xe(d?.length,0)?s.jsx("div",{className:bt.dsContainer+" no-scrollbar",children:d.map(f=>s.jsxs("button",{className:P(bt.dsEntry,y[f.id]&&bt.enabled),onClick:()=>_0(f.id),"data-tooltip-id":"default","data-tooltip-content":f.name,children:[s.jsx(it,{size:18,type:f.dbType}),s.jsx("span",{children:f.name})]},f.id))}):s.jsx(fe,{variant:"warning",className:"mb-4",children:"Connect at least one data source to start using DataRamen"}),s.jsxs("div",{className:bt.searchContainer,children:[s.jsx(nn,{className:"text-(--text-color-secondary)",width:18,height:18}),s.jsx("input",{className:bt.search,placeholder:"Search table or saved query to start from",value:r,onChange:f=>a(f.target.value),onKeyDown:x,autoFocus:o})]}),xe(p?.length,0)&&s.jsx("div",{className:"overflow-y-auto max-h-full mt-2",children:p.map((f,w)=>s.jsxs("button",{className:bt.entry,"data-is-active":i===w,"data-table-id":f.id,onClick:v,children:[s.jsxs("p",{className:"truncate",children:[k0[f.type]," ",f.name]}),s.jsxs("p",{className:bt.ds,children:["📦 ",f.dataSourceName]})]},f.id))})]})},E0=()=>{const e=Dc(),t=(a,i)=>{e?.onConfirm("table",a,i)},n=(a,i)=>{e?.onConfirm("query",a,i)},o=(a,i)=>{e?.onConfirm("tab",a,i)},r=()=>{e?.onCancel()};return s.jsx(we,{isVisible:!!e,onClose:r,backdropClose:!0,children:s.jsx(S0,{autoFocus:!0,onTable:t,onQuery:n,onWorkbenchTab:o})})},R0=()=>{const e=Tn("Hotkey"),t=Y(),{pathname:n}=le(),{data:o}=ve(),{data:r}=bs(),a=D.home.check(n);Be("n",()=>{o&&e()}),Be("w",()=>{o&&(r&&r.length>0?t(D.workbenchTab.build({id:r[0].id})):e())},{enabled:a}),Be("h",()=>{Nn({show:!0})})},L0=()=>{const e=le();l.useEffect(()=>{},[e.pathname])},[T0,Ha]=ye(!1),Ws=()=>Ha(!1),Va=()=>Ha(!0),A0=({repeatPassword:e,password:t})=>t.length<1?null:t.length<8?s.jsx(fe,{variant:"warning",children:"New password should be at least 8 characters long"}):t!==e?s.jsx(fe,{variant:"warning",children:"Repeat password should match new password"}):null,O0=()=>{const e=T0(),{data:t}=ve(),{mutateAsync:n,isPending:o}=wc(),r=Y(),[{password:a,repeatPassword:i},{change:c,touched:u,reset:h}]=Sn({password:"",repeatPassword:""}),m=()=>{r("/"),hs.logout().then(()=>{Ws()})},d=()=>{n({password:a}).then(()=>{h(),Se.success("Password successfully updated!")})},g=a.length<8||a!==i||o,p=u.includes("password");return s.jsxs(we,{isVisible:e,onClose:Ws,children:[s.jsx(at,{onClick:Ws}),s.jsxs("div",{className:"w-full lg:w-lg flex flex-col gap-2",children:[s.jsx(oa,{children:"Account settings"}),s.jsxs("label",{children:[s.jsx("p",{className:"text-xs font-semibold mb-1",children:"Username"}),s.jsx("input",{className:"input w-full",readOnly:!0,disabled:!0,value:t?.username})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsxs("label",{children:[s.jsx("p",{className:"text-xs font-semibold mb-1",children:"Change password"}),s.jsx("input",{className:"input w-full",type:"password",name:"newPassword",autoComplete:"new-password",value:a,onChange:c("password")})]}),s.jsxs("label",{children:[s.jsx("p",{className:"text-xs font-semibold mb-1",children:"Repeat password"}),s.jsx("input",{className:"input w-full",type:"password",value:i,onChange:c("repeatPassword")})]})]}),p&&s.jsx(A0,{password:a,repeatPassword:i}),s.jsxs("div",{className:"flex justify-end gap-2 mt-2",children:[s.jsx("button",{className:"button tertiary",disabled:g,onClick:d,children:"Update password"}),s.jsx("button",{className:"button danger",onClick:m,children:"Log out"})]})]})]})},[P0,Qa]=ye(!1),Ka=()=>Qa(!0),xr=()=>Qa(!1),M0=e=>be({queryKey:["team-users"],queryFn:async()=>{const{data:t}=await $.get("/teams/"+e+"/users");return t.data},enabled:!!e}),I0=()=>Z({mutationFn:async({role:e,teamId:t,userId:n})=>(await $.patch("/teams/"+t+"/user-role",{role:e,userId:n}),!0),onSuccess:()=>{Q.invalidateQueries({queryKey:["team-users"]})}}),D0=()=>Z({mutationFn:async({teamId:e,userId:t})=>(await $.delete("/teams/"+e,{params:{userId:t}}),!0),onSuccess:()=>{Q.invalidateQueries({queryKey:["team-users"]})}}),$0="_user-entry_14yaw_2",F0="_select-container_14yaw_2",br={userEntry:$0,selectContainer:F0},B0=()=>{const e=P0(),{data:t}=ve(),{data:n}=M0(t?.teamId),{mutate:o,isPending:r}=Cc(),{mutate:a,isPending:i}=I0(),{mutate:c,isPending:u}=D0(),[h,{change:m,reset:d}]=Sn({password:"",username:""}),g=()=>{o({username:h.username,password:h.password,teamId:t?.teamId||""}),d()},p=(y,f)=>{a({teamId:t.teamId,role:f,userId:y})},b=y=>{fo("Are you sure you want to remove this user?").then(f=>{f&&c({userId:y,teamId:t.teamId})})},x=An(me.ADMIN),v=r||i||u;return s.jsxs(we,{isVisible:e,onClose:xr,backdropClose:!0,children:[s.jsx(at,{onClick:xr}),s.jsxs("div",{className:"w-full lg:w-lg flex flex-col overflow-hidden",children:[s.jsx(oa,{children:"Manage users"}),xe(n?.length,0)&&s.jsx("div",{className:"mt-4 overflow-y-auto flex-1",children:n.map(y=>s.jsxs("div",{className:br.userEntry,children:[s.jsx("div",{className:br.selectContainer,children:s.jsxs("select",{value:y.role,disabled:!x||v,onChange:f=>p(y.id,f.currentTarget.value),children:[s.jsx("option",{value:me.OWNER,children:"Owner"}),s.jsx("option",{value:me.ADMIN,children:"Admin"}),s.jsx("option",{value:me.EDITOR,children:"Editor"}),s.jsx("option",{value:me.READ_ONLY,children:"Reader"})]})}),s.jsx("p",{className:"flex-1 mx-2",children:y.name}),x&&s.jsx("button",{className:"p-1 cursor-pointer text-red-500 text-sm",onClick:()=>b(y.id),children:"❌"})]},y.id))}),x&&s.jsxs("div",{className:"mt-4",children:[s.jsx("p",{className:"font-semibold",children:"Create new user"}),s.jsxs("div",{className:"flex flex-col lg:flex-row gap-2 lg:items-center mt-2",children:[s.jsx("input",{className:"input flex-1",onChange:m("username"),value:h.username,placeholder:"Username",disabled:v}),s.jsx("input",{className:"input",onChange:m("password"),value:h.password,type:"password",name:"newPassword",autoComplete:"new-password",placeholder:"Password",disabled:v}),s.jsx("button",{className:"button primary",onClick:g,disabled:v,children:"Create user"})]}),s.jsx("p",{className:"text-xs mt-1 text-gray-600",children:"You should create default password for the new account. The user should change it after the first login."})]})]})]})},W0="_gray-card_1ctz5_2",z0="_login-label_1ctz5_2",vr={grayCard:W0,loginLabel:z0},q0=()=>{const[e,t]=l.useState(""),[n,o]=l.useState(""),[r,a]=l.useState(),i=Y(),c=u=>{u.preventDefault(),a(void 0),hs.login({password:n,username:e}).then(()=>{i("/",{replace:!0})}).catch(a)};return s.jsx("div",{className:"page-container bg-(--bg) h-screen",children:s.jsxs("div",{className:"page-content items-center",children:[s.jsxs("div",{className:"py-10 text-center w-full sticky top-0 z-0",children:[s.jsx("h1",{className:"comfortaa text-3xl font-semibold text-(--text-color-primary) mb-4",children:"Welcome to DataRamen!"}),s.jsx(ia,{})]}),s.jsxs("form",{className:vr.grayCard,onSubmit:c,children:[s.jsx("h2",{className:vr.loginLabel,children:"Login"}),r&&s.jsx(fe,{className:"border border-red-600",variant:"danger",children:"Failed to login. Please verify your credentials"}),s.jsx("input",{value:e,onChange:u=>t(u.currentTarget.value),className:"input secondary",placeholder:"User name"}),s.jsx("input",{value:n,onChange:u=>o(u.currentTarget.value),className:"input secondary",type:"password",placeholder:"Password"}),s.jsx("div",{className:"flex justify-end",children:s.jsx("button",{type:"submit",className:"button primary",children:"Login"})})]})]})})},U0=()=>{const e=Y(),{pathname:t}=le(),{data:n,isLoading:o}=Zr();l.useEffect(()=>{!n&&!o&&!D.login.check(t)&&e(D.login.build())},[n,o,e,t])},H0=()=>{},V0=__CLIENT_CONFIG__.skipAuth?H0:U0,Q0=()=>{const[e]=Bl(),t=Y(),n=St(),o=e.get("shareId");return l.useEffect(()=>{o&&n.mutateAsync({queryId:o}).then(r=>{t(D.workbenchTab.build({id:r.id}),{replace:!0})})},[o]),s.jsxs("div",{className:"page-container flex items-center justify-center h-screen",children:[n.isPending&&s.jsxs("div",{className:"flex items-center flex-col gap-2",children:[s.jsx(qa,{}),s.jsx("p",{children:"Fetching query information"})]}),n.isError&&s.jsx(fe,{variant:"danger",children:"Failed to load query information"})]})},K0="_tab-container_1pgck_2",G0="_tab-name_1pgck_2",Y0="_archived-badge_1pgck_2 _badge_1pgck_2",J0="_active-badge_1pgck_2 _badge_1pgck_2",X0="_delete-action_1pgck_2",wn={tabContainer:K0,tabName:G0,archivedBadge:Y0,activeBadge:J0,deleteAction:X0},Ga=({onLoadMore:e,children:t,onClose:n,hasMore:o,onSearchValue:r,searchValue:a})=>s.jsxs("aside",{className:"w-full lg:w-md no-scrollbar",children:[s.jsxs("div",{className:"sticky top-0 px-4 py-2 border-b border-gray-200 bg-white",children:[s.jsxs("h3",{className:"text-lg flex justify-between items-center",children:["Recent tabs",n&&s.jsx("button",{className:"cursor-pointer hover:bg-(--bg-ter) rounded-full p-1",onClick:n,children:s.jsx(jt,{width:24,height:24})})]}),s.jsx(Pn,{containerClassName:"mt-2",className:"text-sm",placeholder:"Filter",value:a,autoFocus:!0,onChange:i=>r(i.target.value)})]}),t,o&&s.jsx("div",{className:"flex justify-center my-2",children:s.jsx("button",{className:"text-blue-800 text-sm p-2 cursor-pointer",onClick:e,children:"Load more"})})]}),Z0=new Intl.DateTimeFormat,ep=()=>{const[e,t]=l.useState(""),n=_o(e),{data:o}=ve(),{data:r,fetchNextPage:a,hasNextPage:i}=uc(o?.teamId,n,25),c=Y(),u=ea(),h=Ic(),m=l.useRef(null),d=l.useRef(null),g=b=>{u.mutate(b),Nn({show:!1}),c(D.workbenchTab.build({id:b}))},p=()=>{m.current?.close(),h.mutate(d.current)};return s.jsxs(Ga,{hasMore:i,onLoadMore:a,onClose:()=>Nn({show:!1}),searchValue:e,onSearchValue:t,children:[r?.map(b=>s.jsxs("div",{className:wn.tabContainer,onClick:()=>g(b.id),onContextMenu:x=>{d.current=b.id,m.current?.open(x,!1)},children:[s.jsxs("div",{className:"flex gap-2 items-center",children:[s.jsx("p",{className:wn.tabName,children:b.name}),b.dataSourceType&&s.jsx(it,{size:16,type:b.dataSourceType}),s.jsx("p",{className:"text-xs text-(--text-color-secondary)",children:b.dataSourceName})]}),s.jsxs("div",{className:"flex gap-2 items-center mt-1",children:[s.jsx("p",{className:"text-xs text-(--text-color-secondary) italic",children:Z0.format(new Date(b.updatedAt))}),b.archived?s.jsx("span",{className:wn.archivedBadge,children:"Archived"}):s.jsx("span",{className:wn.activeBadge,children:"Active"})]})]},b.id)),s.jsx(xa,{ref:m,children:s.jsx("button",{onClick:p,className:wn.deleteAction,children:"🗑 Delete"})})]})},tp=()=>{const e=yu(t=>t.show);return s.jsx(ko,{isVisible:e,onClose:()=>Nn({show:!1}),backdropClose:!0,children:s.jsx(ep,{})})},np=()=>{const{data:e}=ve(),t=mc(e?.teamId),n=Y();return l.useEffect(()=>{t.mutateAsync().then(o=>{o?n(D.workbenchTab.build({id:o.id}),{replace:!0}):n(D.home.build(),{replace:!0})})},[]),null},sp="_query-entry_1t0f8_2",op={queryEntry:sp},rp=new Intl.DateTimeFormat,ap=({projectQueries:e,isLoading:t})=>{const n=l.useRef(void 0),o=Y(),r=Nh(),a=St(),i=jh(),c=fa(),u=d=>{a.mutateAsync({queryId:d}).then(g=>{On({show:!1}),o(D.workbenchTab.build({id:g.id}))})},h=async d=>{const g=e?.find(b=>b.id===d);if(!g)return;const p=await In("New name?",g?.name);p&&r.mutate({id:g.savedQueryId,payload:{name:p}})},m=d=>{const g=e?.find(p=>p.id===d)?.savedQueryId;g&&i.mutate(g)};return s.jsxs("div",{className:"flex flex-col px-2",children:[xe(e?.length,0)&&e.map(d=>s.jsxs("button",{className:op.queryEntry,onClick:()=>u(d.id),onContextMenu:g=>{n.current=d.id,c.open(g)},children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-left text-sm font-semibold text-(--text-color-primary)",children:d.name}),s.jsx("p",{className:"text-left text-xs text-(--text-color-secondary) italic",children:rp.format(new Date(d.updatedAt))})]}),s.jsxs("p",{className:"flex gap-2 items-center",children:[s.jsx(it,{size:16,type:d.datasourceType}),s.jsx("span",{className:"truncate text-xs text-(--text-color-secondary)",children:d.datasourceName})]})]},d.savedQueryId)),!t&&Gd(e?.length,1)&&s.jsx("p",{className:"text-center text-sm text-(--text-color-secondary) mt-2",children:"Empty"}),s.jsx(pa,{handler:c,children:s.jsxs("div",{className:"context-menu-container",children:[s.jsx("button",{onClick:d=>{d.preventDefault(),d.stopPropagation(),c.close(),h(n.current)},className:"context-menu-item",children:"✏️ Rename"}),s.jsx("button",{onClick:d=>{d.preventDefault(),d.stopPropagation(),c.close(),m(n.current)},className:"context-menu-item",children:"🗑️ Delete"})]})})]})},ip=()=>{const{data:e}=ve(),[t,n]=l.useState(""),o=_o(t),{data:r,isLoading:a,fetchNextPage:i,hasNextPage:c}=dc(e?.teamId,o);return s.jsx(Ga,{hasMore:c,onClose:()=>On({show:!1}),onLoadMore:i,searchValue:t,onSearchValue:n,children:s.jsx(ap,{isLoading:a,projectQueries:r||[]})})},lp=()=>{const e=vu(t=>t.show);return s.jsx(ko,{isVisible:e,onClose:()=>On({show:!1}),backdropClose:!0,children:s.jsx(ip,{})})};function cp(){return R0(),L0(),V0(),s.jsxs(s.Fragment,{children:[s.jsxs(ul,{children:[s.jsx(Ut,{path:D.home.path,element:s.jsx(Au,{})}),s.jsx(Ut,{path:D.workbench.path,element:s.jsx(np,{})}),s.jsx(Ut,{path:D.workbenchTab.path,element:s.jsx(zf,{})}),s.jsx(Ut,{path:D.login.path,element:s.jsx(q0,{})}),s.jsx(Ut,{path:D.share.path,element:s.jsx(Q0,{})})]}),s.jsx(Vu,{}),s.jsx(nd,{}),s.jsx(pd,{}),s.jsx(m0,{}),s.jsx(E0,{}),s.jsx(O0,{}),s.jsx(B0,{}),s.jsx(tp,{}),s.jsx(lp,{}),s.jsx(ud,{}),s.jsx(rd,{})]})}const up="_hidden_1gupx_2",dp="_desktop-layout_1gupx_2",hp="_mobile-layout_1gupx_2",mp="_nav_1gupx_2",fp="_shown_1gupx_2",pp="_main_1gupx_2",gp="_header_1gupx_2",xp="_expand_1gupx_2",bp="_show_1gupx_2",vp="_hide_1gupx_2",yp="_icon_1gupx_2",wp="_nav-item_1gupx_2",Cp="_project-wrapper_1gupx_2",I={hidden:up,desktopLayout:dp,mobileLayout:hp,nav:mp,shown:fp,main:pp,header:gp,expand:xp,show:bp,hide:vp,icon:yp,navItem:wp,projectWrapper:Cp},jp=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{fill:"currentColor",d:"M507 211.16c-1.42-1.19-14.25-10.94-41.79-10.94a132.55 132.55 0 00-21.61 1.9c-5.22-36.4-35.38-54-36.57-55l-7.36-4.28-4.75 6.9a101.65 101.65 0 00-13.06 30.45c-5 20.7-1.9 40.2 8.55 56.85-12.59 7.14-33 8.8-37.28 9H15.94A15.93 15.93 0 000 262.07a241.25 241.25 0 0014.75 86.83C26.39 379.35 43.72 402 66 415.74 91.22 431.2 132.3 440 178.6 440a344.23 344.23 0 0062.45-5.71 257.44 257.44 0 0081.69-29.73 223.55 223.55 0 0055.57-45.67c26.83-30.21 42.74-64 54.38-94h4.75c29.21 0 47.26-11.66 57.23-21.65a63.31 63.31 0 0015.2-22.36l2.14-6.18z"}),l.createElement("path",{fill:"currentColor",d:"M47.29 236.37H92.4a4 4 0 004-4v-40.48a4 4 0 00-4-4H47.29a4 4 0 00-4 4v40.44a4.16 4.16 0 004 4M109.5 236.37h45.12a4 4 0 004-4v-40.48a4 4 0 00-4-4H109.5a4 4 0 00-4 4v40.44a4.16 4.16 0 004 4M172.9 236.37H218a4 4 0 004-4v-40.48a4 4 0 00-4-4h-45.1a4 4 0 00-4 4v40.44a3.87 3.87 0 004 4M235.36 236.37h45.12a4 4 0 004-4v-40.48a4 4 0 00-4-4h-45.12a4 4 0 00-4 4v40.44a4 4 0 004 4M109.5 178.57h45.12a4.16 4.16 0 004-4v-40.48a4 4 0 00-4-4H109.5a4 4 0 00-4 4v40.44a4.34 4.34 0 004 4M172.9 178.57H218a4.16 4.16 0 004-4v-40.48a4 4 0 00-4-4h-45.1a4 4 0 00-4 4v40.44a4 4 0 004 4M235.36 178.57h45.12a4.16 4.16 0 004-4v-40.48a4.16 4.16 0 00-4-4h-45.12a4 4 0 00-4 4v40.44a4.16 4.16 0 004 4M235.36 120.53h45.12a4 4 0 004-4V76a4.16 4.16 0 00-4-4h-45.12a4 4 0 00-4 4v40.44a4.17 4.17 0 004 4M298.28 236.37h45.12a4 4 0 004-4v-40.48a4 4 0 00-4-4h-45.12a4 4 0 00-4 4v40.44a4.16 4.16 0 004 4"})),Np=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("rect",{x:32,y:48,width:448,height:416,rx:48,ry:48,fill:"none",stroke:"currentColor",strokeLinejoin:"round",strokeWidth:32}),l.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32,d:"M96 112l80 64-80 64M192 240h64"})),_p=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{d:"M448 341.37V170.61A32 32 0 00432.11 143l-152-88.46a47.94 47.94 0 00-48.24 0L79.89 143A32 32 0 0064 170.61v170.76A32 32 0 0079.89 369l152 88.46a48 48 0 0048.24 0l152-88.46A32 32 0 00448 341.37z",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32}),l.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32,d:"M69 153.99l187 110 187-110M256 463.99v-200"})),kp=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{d:"M304 336v40a40 40 0 01-40 40H104a40 40 0 01-40-40V136a40 40 0 0140-40h152c22.09 0 48 17.91 48 40v40M368 336l80-80-80-80M176 256h256",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32})),Sp=e=>l.createElement("svg",{className:"ionicon",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg",...e},l.createElement("path",{d:"m 266.89,52 c -5,-5.28 -16.69,-5.34 -21.78,0 L 80,212 v 236 c 0,8.83656 7.163444,16 16,16 h 96 V 328 c 0,-13.25483 10.74517,-24 24,-24 h 80 c 13.25483,0 24,10.74517 24,24 v 136 h 96 c 8.83656,0 16,-7.16344 16,-16 l -0.16428,-236.06357 z",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32})),Ep=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{d:"M344 144c-3.92 52.87-44 96-88 96s-84.15-43.12-88-96c-4-55 35-96 88-96s92 42 88 96z",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32}),l.createElement("path",{d:"M256 304c-87 0-175.3 48-191.64 138.6C62.39 453.52 68.57 464 80 464h352c11.44 0 17.62-10.48 15.65-21.4C431.3 352 343 304 256 304z",fill:"none",stroke:"currentColor",strokeMiterlimit:10,strokeWidth:32})),Rp=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{d:"M402 168c-2.93 40.67-33.1 72-66 72s-63.12-31.32-66-72c-3-42.31 26.37-72 66-72s69 30.46 66 72z",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32}),l.createElement("path",{d:"M336 304c-65.17 0-127.84 32.37-143.54 95.41-2.08 8.34 3.15 16.59 11.72 16.59h263.65c8.57 0 13.77-8.25 11.72-16.59C463.85 335.36 401.18 304 336 304z",fill:"none",stroke:"currentColor",strokeMiterlimit:10,strokeWidth:32}),l.createElement("path",{d:"M200 185.94c-2.34 32.48-26.72 58.06-53 58.06s-50.7-25.57-53-58.06C91.61 152.15 115.34 128 147 128s55.39 24.77 53 57.94z",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32}),l.createElement("path",{d:"M206 306c-18.05-8.27-37.93-11.45-59-11.45-52 0-102.1 25.85-114.65 76.2-1.65 6.66 2.53 13.25 9.37 13.25H154",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeMiterlimit:10,strokeWidth:32})),Lp=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{d:"M380.93 57.37A32 32 0 00358.3 48H94.22A46.21 46.21 0 0048 94.22v323.56A46.21 46.21 0 0094.22 464h323.56A46.36 46.36 0 00464 417.78V153.7a32 32 0 00-9.37-22.63zM256 416a64 64 0 1164-64 63.92 63.92 0 01-64 64zm48-224H112a16 16 0 01-16-16v-64a16 16 0 0116-16h192a16 16 0 0116 16v64a16 16 0 01-16 16z",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32})),yr=!__CLIENT_CONFIG__.skipAuth,wr=(()=>{const e=__CLIENT_CONFIG__.serverVersion||"--";switch(__CLIENT_CONFIG__.modeName){case"docker":return`v${e} | Docker`;case"cli":return`v${e} | CLI`;case"dev":return`v${e} | DEV`;default:return`v${e} | Custom`}})(),G=20,ke="text-(--text-color-primary)";function Tp(){switch(__CLIENT_CONFIG__.modeName){case"docker":return s.jsx(jp,{className:ke,width:G,height:G});case"cli":return s.jsx(Np,{className:ke,width:G,height:G});default:return s.jsx(_p,{className:ke,width:G,height:G})}}const Ap=({dataSource:e})=>s.jsxs("button",{className:I.navItem,onClick:()=>_n(e.id),"data-tooltip-id":"default","data-tooltip-content":e.name,"data-tooltip-place":"right",children:[s.jsx("span",{className:I.icon,children:s.jsx(it,{size:20,type:e.dbType})}),s.jsx("span",{className:"truncate",children:e.name})]}),Op=()=>{const e=Y(),{pathname:t}=le(),{data:n}=ve(),o=Tn("Desktop nav"),[r,a]=l.useState(!1),{data:i}=bs(),{data:c}=ic(n?.teamId),u=()=>{D.home.check(t)||e(D.home.build())},h=b=>{D.workbenchTab.check(t)||e(D.workbenchTab.build({id:b}))},m=()=>{On({show:!0})},d=()=>{fo("Are you sure you want to logout?").then(b=>{b&&(e("/"),hs.logout())})},g=()=>Nn({show:!0}),p=r?void 0:"default";return s.jsxs("nav",{className:P(I.nav,r?I.shown:I.hidden),children:[n&&s.jsxs("div",{className:I.header,children:[s.jsxs("button",{onClick:u,className:I.navItem,"data-tooltip-id":p,"data-tooltip-content":"Home",children:[s.jsx("span",{className:I.icon,children:s.jsx(Sp,{className:ke,width:G,height:G})}),s.jsx("span",{className:"truncate",children:"Home"})]}),s.jsxs("button",{onClick:o,className:I.navItem,"data-tooltip-id":p,"data-tooltip-content":"New query",children:[s.jsx("span",{className:I.icon,children:s.jsx(nn,{className:ke,width:G,height:G})}),s.jsx("span",{className:"truncate",children:"New query"}),s.jsx("span",{className:"hotkey secondary",children:"N"})]}),s.jsxs("button",{onClick:g,className:I.navItem,"data-tooltip-id":p,"data-tooltip-content":"Recent tabs",children:[s.jsx("span",{className:I.icon,children:s.jsx(ra,{className:ke,width:G,height:G})}),s.jsx("span",{className:"truncate",children:"Recent tabs"}),s.jsx("span",{className:"hotkey secondary",children:"H"})]}),s.jsxs("button",{onClick:m,className:I.navItem,"data-tooltip-id":p,"data-tooltip-content":"Saved queries",children:[s.jsx("span",{className:I.icon,children:s.jsx(Lp,{className:ke,width:G,height:G})}),s.jsx("span",{className:"truncate",children:"Saved queries"})]}),xe(i?.length,0)&&s.jsxs("button",{onClick:()=>h(i[0].id),className:I.navItem,"data-tooltip-id":p,"data-tooltip-content":"Workbench",children:[s.jsx("span",{className:I.icon,children:s.jsx(aa,{className:ke,width:G,height:G})}),s.jsx("span",{className:"truncate",children:"Workbench"}),s.jsx("span",{className:"hotkey secondary",children:"W"})]}),yr&&s.jsxs(s.Fragment,{children:[s.jsxs("button",{onClick:Va,className:I.navItem,"data-tooltip-id":p,"data-tooltip-content":"User settings",children:[s.jsx("span",{className:I.icon,children:s.jsx(Ep,{className:ke,width:G,height:G})}),s.jsx("span",{className:"truncate",children:n.username})]}),s.jsxs("button",{onClick:Ka,className:I.navItem,"data-tooltip-id":p,"data-tooltip-content":"Manage users",children:[s.jsx("span",{className:I.icon,children:s.jsx(Rp,{className:ke,width:G,height:G})}),s.jsx("span",{className:"truncate",children:"Manage users"})]})]})]}),s.jsx("div",{className:P(I.projectWrapper),children:xe(c?.length,0)&&s.jsx("div",{className:"mt-4 flex flex-col",children:c.map(b=>s.jsx(Ap,{dataSource:b},b.id))})}),yr&&s.jsxs("button",{onClick:d,"data-tooltip-id":p,"data-tooltip-content":"Logout",className:`${I.navItem} mx-1`,children:[s.jsx("span",{className:I.icon,children:s.jsx(kp,{className:ke,width:20,height:20})}),s.jsx("span",{className:"truncate text-sm text-(--text-color-primary)",children:"Logout"})]}),s.jsxs("div",{className:`${I.navItem} mx-1 cursor-auto!`,"data-tooltip-id":p,"data-tooltip-content":wr,children:[s.jsx("span",{className:I.icon,children:s.jsx(Tp,{})}),s.jsx("span",{className:"truncate text-sm text-(--text-color-primary)",children:wr})]}),s.jsxs("button",{onClick:()=>a(!r),"data-tooltip-id":"default","data-tooltip-content":"Expand sidebar","data-tooltip-hidden":r,"data-tooltip-place":"right",className:`${I.navItem} mx-1`,children:[s.jsx("span",{className:P(I.icon,I.expand,r?I.show:I.hide),children:s.jsx(nt,{className:ke,width:20,height:20})}),s.jsx("span",{className:"truncate text-sm text-(--text-color-primary)",children:"Collapse menu"})]})]})},Pp="_root_15eo2_2",Mp={root:Pp},Ya=!__CLIENT_CONFIG__.skipAuth,Ip=`${Mp.root} ${Ya?"grid-cols-4":"grid-cols-2"}`,Dp=()=>{const{pathname:e}=le(),t=Y(),n=Tn("Mobile nav"),o=()=>{D.home.check(e)||t(D.home.build())};return s.jsxs("div",{className:Ip,children:[s.jsxs("button",{onClick:o,children:[s.jsx("p",{children:"🏠"}),s.jsx("p",{className:"text-xs font-semibold text-gray-600",children:"Home"})]}),s.jsxs("button",{onClick:n,children:[s.jsx("p",{children:"🔎"}),s.jsx("p",{className:"text-xs font-semibold text-gray-600",children:"New query"})]}),Ya&&s.jsxs(s.Fragment,{children:[s.jsxs("button",{onClick:Va,children:[s.jsx("p",{children:"🪪"}),s.jsx("p",{className:"text-xs font-semibold text-gray-600",children:"Account"})]}),s.jsxs("button",{onClick:Ka,children:[s.jsx("p",{children:"👥"}),s.jsx("p",{className:"text-xs font-semibold text-gray-600",children:"Users"})]})]})]})},$p=({children:e,isLogin:t})=>s.jsxs("div",{className:I.desktopLayout,children:[s.jsx(us,{id:"default",className:"z-100"}),s.jsx(us,{id:"default-xs",className:"z-100 text-xs!"}),!t&&s.jsx(Op,{}),s.jsx("main",{className:I.main,children:e})]}),Fp=({children:e,isLogin:t})=>s.jsxs("div",{className:I.mobileLayout,children:[s.jsx("main",{className:I.main,children:e}),!t&&s.jsx(Dp,{})]}),Bp=({children:e})=>{const t=da(po.laptop),{pathname:n}=le(),o=D.login.check(n);return t?s.jsx($p,{isLogin:o,children:e}):s.jsx(Fp,{isLogin:o,children:e})};di.createRoot(document.getElementById("root")).render(s.jsxs(Ze.StrictMode,{children:[s.jsx(hi,{}),s.jsx(Yl,{client:Q,children:s.jsx(Ml,{children:s.jsx(Bp,{children:s.jsx(cp,{})})})})]}));