@dataramen/cli 0.0.73 → 0.0.74

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 Xa,S as vr,p as Lo,b as Re,s as os,c as wn,n as rs,i as Ws,d as To,t as Za,e as Kn,f as ei,g as ti,h as Ao,j as ds,k as Po,l as ni,m as si,o as Oo,q as oi,u as s,v as Xs,w as K,x as I,A as hs,y as ri,z as ai,B as A,C as _n,D as fe,E as Le,F as ii,G as li,R as et,H as ci,I as ui}from"./index-CTun7vf0.js";var Mo="popstate";function di(e={}){function t(o,r){let{pathname:a,search:i,hash:c}=o.location;return zs("",{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:Cn(r)}return mi(t,n,null,e)}function H(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function _e(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function hi(){return Math.random().toString(36).substring(2,10)}function Io(e,t){return{usr:e.state,key:e.key,idx:t}}function zs(e,t,n=null,o){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?Gt(t):t,state:n,key:t&&t.key||o||hi()}}function Cn({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 Gt(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 mi(e,t,n,o={}){let{window:r=document.defaultView,v5Compat:a=!1}=o,i=r.history,c="POP",u=null,d=m();d==null&&(d=0,i.replaceState({...i.state,idx:d},""));function m(){return(i.state||{idx:null}).idx}function h(){c="POP";let v=m(),y=v==null?null:v-d;d=v,u&&u({action:c,location:x.location,delta:y})}function p(v,y){c="PUSH";let f=zs(x.location,v,y);d=m()+1;let w=Io(f,d),C=x.createHref(f);try{i.pushState(w,"",C)}catch(j){if(j instanceof DOMException&&j.name==="DataCloneError")throw j;r.location.assign(C)}a&&u&&u({action:c,location:x.location,delta:1})}function g(v,y){c="REPLACE";let f=zs(x.location,v,y);d=m();let w=Io(f,d),C=x.createHref(f);i.replaceState(w,"",C),a&&u&&u({action:c,location:x.location,delta:0})}function b(v){return fi(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(Mo,h),u=v,()=>{r.removeEventListener(Mo,h),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:p,replace:g,go(v){return i.go(v)}};return x}function fi(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:Cn(e);return o=o.replace(/ $/,"%20"),!t&&o.startsWith("//")&&(o=n+o),new URL(o,n)}function yr(e,t,n="/"){return pi(e,t,n,!1)}function pi(e,t,n,o){let r=typeof t=="string"?Gt(t):t,a=Je(r.pathname||"/",n);if(a==null)return null;let i=wr(e);gi(i);let c=null;for(let u=0;c==null&&u<i.length;++u){let d=Si(a);c=ki(i[u],d,o)}return c}function wr(e,t=[],n=[],o="",r=!1){let a=(i,c,u=r,d)=>{let m={relativePath:d===void 0?i.path||"":d,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 h=Ge([o,m.relativePath]),p=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 "${h}".`),wr(i.children,t,p,h,u)),!(i.path==null&&!i.index)&&t.push({path:h,score:ji(h,i.index),routesMeta:p})};return e.forEach((i,c)=>{if(i.path===""||!i.path?.includes("?"))a(i,c);else for(let u of Cr(i.path))a(i,c,!0,u)}),t}function Cr(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=Cr(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 gi(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:Ni(t.routesMeta.map(o=>o.childrenIndex),n.routesMeta.map(o=>o.childrenIndex)))}var xi=/^:[\w-]+$/,bi=3,vi=2,yi=1,wi=10,Ci=-2,Do=e=>e==="*";function ji(e,t){let n=e.split("/"),o=n.length;return n.some(Do)&&(o+=Ci),t&&(o+=vi),n.filter(r=>!Do(r)).reduce((r,a)=>r+(xi.test(a)?bi:a===""?yi:wi),o)}function Ni(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 ki(e,t,n=!1){let{routesMeta:o}=e,r={},a="/",i=[];for(let c=0;c<o.length;++c){let u=o[c],d=c===o.length-1,m=a==="/"?t:t.slice(a.length)||"/",h=Vt({path:u.relativePath,caseSensitive:u.caseSensitive,end:d},m),p=u.route;if(!h&&d&&n&&!o[o.length-1].route.index&&(h=Vt({path:u.relativePath,caseSensitive:u.caseSensitive,end:!1},m)),!h)return null;Object.assign(r,h.params),i.push({params:r,pathname:Ge([a,h.pathname]),pathnameBase:Ti(Ge([a,h.pathnameBase])),route:p}),h.pathnameBase!=="/"&&(a=Ge([a,h.pathnameBase]))}return i}function Vt(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[n,o]=_i(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((d,{paramName:m,isOptional:h},p)=>{if(m==="*"){let b=c[p]||"";i=a.slice(0,a.length-b.length).replace(/(.)\/+$/,"$1")}const g=c[p];return h&&!g?d[m]=void 0:d[m]=(g||"").replace(/%2F/g,"/"),d},{}),pathname:a,pathnameBase:i,pattern:e}}function _i(e,t=!1,n=!0){_e(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 Si(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return _e(!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 Je(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 jr=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Ei=e=>jr.test(e);function Ri(e,t="/"){let{pathname:n,search:o="",hash:r=""}=typeof e=="string"?Gt(e):e,a;if(n)if(Ei(n))a=n;else{if(n.includes("//")){let i=n;n=n.replace(/\/\/+/g,"/"),_e(!1,`Pathnames cannot have embedded double slashes - normalizing ${i} -> ${n}`)}n.startsWith("/")?a=$o(n.substring(1),"/"):a=$o(n,t)}else a=t;return{pathname:a,search:Ai(o),hash:Pi(r)}}function $o(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 Li(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function Nr(e){let t=Li(e);return t.map((n,o)=>o===t.length-1?n.pathname:n.pathnameBase)}function kr(e,t,n,o=!1){let r;typeof e=="string"?r=Gt(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 h=t.length-1;if(!o&&i.startsWith("..")){let p=i.split("/");for(;p[0]==="..";)p.shift(),h-=1;r.pathname=p.join("/")}c=h>=0?t[h]:"/"}let u=Ri(r,c),d=i&&i!=="/"&&i.endsWith("/"),m=(a||i===".")&&n.endsWith("/");return!u.pathname.endsWith("/")&&(d||m)&&(u.pathname+="/"),u}var Ge=e=>e.join("/").replace(/\/\/+/g,"/"),Ti=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),Ai=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,Pi=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,Oi=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 Mi(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function Ii(e){return e.map(t=>t.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var _r=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Sr(e,t){let n=e;if(typeof n!="string"||!jr.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let o=n,r=!1;if(_r)try{let a=new URL(window.location.href),i=n.startsWith("//")?new URL(a.protocol+n):new URL(n),c=Je(i.pathname,t);i.origin===a.origin&&c!=null?n=c+i.search+i.hash:r=!0}catch{_e(!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 Er=["POST","PUT","PATCH","DELETE"];new Set(Er);var Di=["GET",...Er];new Set(Di);var Yt=l.createContext(null);Yt.displayName="DataRouter";var ms=l.createContext(null);ms.displayName="DataRouterState";var $i=l.createContext(!1),Rr=l.createContext({isTransitioning:!1});Rr.displayName="ViewTransition";var Fi=l.createContext(new Map);Fi.displayName="Fetchers";var Bi=l.createContext(null);Bi.displayName="Await";var Se=l.createContext(null);Se.displayName="Navigation";var Sn=l.createContext(null);Sn.displayName="Location";var We=l.createContext({outlet:null,matches:[],isDataRoute:!1});We.displayName="Route";var Zs=l.createContext(null);Zs.displayName="RouteError";var Lr="REACT_ROUTER_ERROR",qi="REDIRECT",Wi="ROUTE_ERROR_RESPONSE";function zi(e){if(e.startsWith(`${Lr}:${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 Ui(e){if(e.startsWith(`${Lr}:${Wi}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string")return new Oi(t.status,t.statusText,t.data)}catch{}}function Hi(e,{relative:t}={}){H(En(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:o}=l.useContext(Se),{hash:r,pathname:a,search:i}=Rn(e,{relative:t}),c=a;return n!=="/"&&(c=a==="/"?n:Ge([n,a])),o.createHref({pathname:c,search:i,hash:r})}function En(){return l.useContext(Sn)!=null}function le(){return H(En(),"useLocation() may be used only in the context of a <Router> component."),l.useContext(Sn).location}var Tr="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Ar(e){l.useContext(Se).static||l.useLayoutEffect(e)}function X(){let{isDataRoute:e}=l.useContext(We);return e?rl():Vi()}function Vi(){H(En(),"useNavigate() may be used only in the context of a <Router> component.");let e=l.useContext(Yt),{basename:t,navigator:n}=l.useContext(Se),{matches:o}=l.useContext(We),{pathname:r}=le(),a=JSON.stringify(Nr(o)),i=l.useRef(!1);return Ar(()=>{i.current=!0}),l.useCallback((u,d={})=>{if(_e(i.current,Tr),!i.current)return;if(typeof u=="number"){n.go(u);return}let m=kr(u,JSON.parse(a),r,d.relative==="path");e==null&&t!=="/"&&(m.pathname=m.pathname==="/"?t:Ge([t,m.pathname])),(d.replace?n.replace:n.push)(m,d.state,d)},[t,n,a,r,e])}l.createContext(null);function Ki(){let{matches:e}=l.useContext(We),t=e[e.length-1];return t?t.params:{}}function Rn(e,{relative:t}={}){let{matches:n}=l.useContext(We),{pathname:o}=le(),r=JSON.stringify(Nr(n));return l.useMemo(()=>kr(e,JSON.parse(r),o,t==="path"),[e,r,o,t])}function Qi(e,t){return Pr(e,t)}function Pr(e,t,n,o,r){H(En(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:a}=l.useContext(Se),{matches:i}=l.useContext(We),c=i[i.length-1],u=c?c.params:{},d=c?c.pathname:"/",m=c?c.pathnameBase:"/",h=c&&c.route;{let f=h&&h.path||"";Mr(d,!h||f.endsWith("*")||f.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${d}" (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 p=le(),g;if(t){let f=typeof t=="string"?Gt(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.`),g=f}else g=p;let b=g.pathname||"/",x=b;if(m!=="/"){let f=m.replace(/^\//,"").split("/");x="/"+b.replace(/^\//,"").split("/").slice(f.length).join("/")}let v=yr(e,{pathname:x});_e(h||v!=null,`No routes matched location "${g.pathname}${g.search}${g.hash}" `),_e(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 "${g.pathname}${g.search}${g.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=Zi(v&&v.map(f=>Object.assign({},f,{params:Object.assign({},u,f.params),pathname:Ge([m,a.encodeLocation?a.encodeLocation(f.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:f.pathname]),pathnameBase:f.pathnameBase==="/"?m:Ge([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(Sn.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...g},navigationType:"POP"}},y):y}function Gi(){let e=ol(),t=Mi(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 Yi=l.createElement(Gi,null),Or=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=Ui(e.digest);n&&(e=n)}let t=e!==void 0?l.createElement(We.Provider,{value:this.props.routeContext},l.createElement(Zs.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?l.createElement(Ji,{error:e},t):t}};Or.contextType=$i;var Ls=new WeakMap;function Ji({children:e,error:t}){let{basename:n}=l.useContext(Se);if(typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){let o=zi(t.digest);if(o){let r=Ls.get(t);if(r)throw r;let a=Sr(o.location,n);if(_r&&!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 Xi({routeContext:e,match:t,children:n}){let o=l.useContext(Yt);return o&&o.static&&o.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(o.staticContext._deepestRenderedBoundaryId=t.route.id),l.createElement(We.Provider,{value:e},n)}function Zi(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(h=>h.route.id&&i?.[h.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 h=a[m];if((h.route.HydrateFallback||h.route.hydrateFallbackElement)&&(u=m),h.route.id){let{loaderData:p,errors:g}=n,b=h.route.loader&&!p.hasOwnProperty(h.route.id)&&(!g||g[h.route.id]===void 0);if(h.route.lazy||b){c=!0,u>=0?a=a.slice(0,u+1):a=[a[0]];break}}}let d=n&&o?(m,h)=>{o(m,{location:n.location,params:n.matches?.[0]?.params??{},unstable_pattern:Ii(n.matches),errorInfo:h})}:void 0;return a.reduceRight((m,h,p)=>{let g,b=!1,x=null,v=null;n&&(g=i&&h.route.id?i[h.route.id]:void 0,x=h.route.errorElement||Yi,c&&(u<0&&p===0?(Mr("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),b=!0,v=null):u===p&&(b=!0,v=h.route.hydrateFallbackElement||null)));let y=t.concat(a.slice(0,p+1)),f=()=>{let w;return g?w=x:b?w=v:h.route.Component?w=l.createElement(h.route.Component,null):h.route.element?w=h.route.element:w=m,l.createElement(Xi,{match:h,routeContext:{outlet:m,matches:y,isDataRoute:n!=null},children:w})};return n&&(h.route.ErrorBoundary||h.route.errorElement||p===0)?l.createElement(Or,{location:n.location,revalidation:n.revalidation,component:x,error:g,children:f(),routeContext:{outlet:null,matches:y,isDataRoute:!0},onError:d}):f()},null)}function eo(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function el(e){let t=l.useContext(Yt);return H(t,eo(e)),t}function tl(e){let t=l.useContext(ms);return H(t,eo(e)),t}function nl(e){let t=l.useContext(We);return H(t,eo(e)),t}function to(e){let t=nl(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 sl(){return to("useRouteId")}function ol(){let e=l.useContext(Zs),t=tl("useRouteError"),n=to("useRouteError");return e!==void 0?e:t.errors?.[n]}function rl(){let{router:e}=el("useNavigate"),t=to("useNavigate"),n=l.useRef(!1);return Ar(()=>{n.current=!0}),l.useCallback(async(r,a={})=>{_e(n.current,Tr),n.current&&(typeof r=="number"?await e.navigate(r):await e.navigate(r,{fromRouteId:t,...a}))},[e,t])}var Fo={};function Mr(e,t,n){!t&&!Fo[e]&&(Fo[e]=!0,_e(!1,n))}l.memo(al);function al({routes:e,future:t,state:n,onError:o}){return Pr(e,void 0,n,o,t)}function Wt(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 il({basename:e="/",children:t=null,location:n,navigationType:o="POP",navigator:r,static:a=!1,unstable_useTransitions:i}){H(!En(),"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=Gt(n));let{pathname:d="/",search:m="",hash:h="",state:p=null,key:g="default"}=n,b=l.useMemo(()=>{let x=Je(d,c);return x==null?null:{location:{pathname:x,search:m,hash:h,state:p,key:g},navigationType:o}},[c,d,m,h,p,g,o]);return _e(b!=null,`<Router basename="${c}"> is not able to match the URL "${d}${m}${h}" because it does not start with the basename, so the <Router> won't render anything.`),b==null?null:l.createElement(Se.Provider,{value:u},l.createElement(Sn.Provider,{children:t,value:b}))}function ll({children:e,location:t}){return Qi(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===Wt,`[${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 cl(e){return fs(e)&&e.tagName.toLowerCase()==="button"}function ul(e){return fs(e)&&e.tagName.toLowerCase()==="form"}function dl(e){return fs(e)&&e.tagName.toLowerCase()==="input"}function hl(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function ml(e,t){return e.button===0&&(!t||t==="_self")&&!hl(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 fl(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 Qn=null;function pl(){if(Qn===null)try{new FormData(document.createElement("form"),0),Qn=!1}catch{Qn=!0}return Qn}var gl=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Ts(e){return e!=null&&!gl.has(e)?(_e(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Zn}"`),null):e}function xl(e,t){let n,o,r,a,i;if(ul(e)){let c=e.getAttribute("action");o=c?Je(c,t):null,n=e.getAttribute("method")||Xn,r=Ts(e.getAttribute("enctype"))||Zn,a=new FormData(e)}else if(cl(e)||dl(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?Je(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),!pl()){let{name:d,type:m,value:h}=e;if(m==="image"){let p=d?`${d}.`:"";a.append(`${p}x`,"0"),a.append(`${p}y`,"0")}else d&&a.append(d,h)}}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 no(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function bl(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&&Je(r.pathname,t)==="/"?r.pathname=`${t.replace(/\/$/,"")}/_root.${o}`:r.pathname=`${r.pathname.replace(/\/$/,"")}.${o}`,r}async function vl(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 yl(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 wl(e,t,n){let o=await Promise.all(e.map(async r=>{let a=t.routes[r.route.id];if(a){let i=await vl(a,n);return i.links?i.links():[]}return[]}));return kl(o.flat(1).filter(yl).filter(r=>r.rel==="stylesheet"||r.rel==="preload").map(r=>r.rel==="stylesheet"?{...r,rel:"prefetch",as:"style"}:{...r,rel:"prefetch"}))}function Bo(e,t,n,o,r,a){let i=(u,d)=>n[d]?u.route.id!==n[d].route.id:!0,c=(u,d)=>n[d].pathname!==u.pathname||n[d].route.path?.endsWith("*")&&n[d].params["*"]!==u.params["*"];return a==="assets"?t.filter((u,d)=>i(u,d)||c(u,d)):a==="data"?t.filter((u,d)=>{let m=o.routes[u.route.id];if(!m||!m.hasLoader)return!1;if(i(u,d)||c(u,d))return!0;if(u.route.shouldRevalidate){let h=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 h=="boolean")return h}return!0}):[]}function Cl(e,t,{includeHydrateFallback:n}={}){return jl(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 jl(e){return[...new Set(e)]}function Nl(e){let t={},n=Object.keys(e).sort();for(let o of n)t[o]=e[o];return t}function kl(e,t){let n=new Set;return new Set(t),e.reduce((o,r)=>{let a=JSON.stringify(Nl(r));return n.has(a)||(n.add(a),o.push({key:a,link:r})),o},[])}function Ir(){let e=l.useContext(Yt);return no(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function _l(){let e=l.useContext(ms);return no(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var so=l.createContext(void 0);so.displayName="FrameworkContext";function Dr(){let e=l.useContext(so);return no(e,"You must render this element inside a <HydratedRouter> element"),e}function Sl(e,t){let n=l.useContext(so),[o,r]=l.useState(!1),[a,i]=l.useState(!1),{onFocus:c,onBlur:u,onMouseEnter:d,onMouseLeave:m,onTouchStart:h}=t,p=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 p.current&&v.observe(p.current),()=>{v.disconnect()}}},[e]),l.useEffect(()=>{if(o){let x=setTimeout(()=>{i(!0)},100);return()=>{clearTimeout(x)}}},[o]);let g=()=>{r(!0)},b=()=>{r(!1),i(!1)};return n?e!=="intent"?[a,p,{}]:[a,p,{onFocus:pn(c,g),onBlur:pn(u,b),onMouseEnter:pn(d,g),onMouseLeave:pn(m,b),onTouchStart:pn(h,g)}]:[!1,p,{}]}function pn(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function El({page:e,...t}){let{router:n}=Ir(),o=l.useMemo(()=>yr(n.routes,e,n.basename),[n.routes,e,n.basename]);return o?l.createElement(Ll,{page:e,matches:o,...t}):null}function Rl(e){let{manifest:t,routeModules:n}=Dr(),[o,r]=l.useState([]);return l.useEffect(()=>{let a=!1;return wl(e,t,n).then(i=>{a||r(i)}),()=>{a=!0}},[e,t,n]),o}function Ll({page:e,matches:t,...n}){let o=le(),{future:r,manifest:a,routeModules:i}=Dr(),{basename:c}=Ir(),{loaderData:u,matches:d}=_l(),m=l.useMemo(()=>Bo(e,t,d,a,o,"data"),[e,t,d,a,o]),h=l.useMemo(()=>Bo(e,t,d,a,o,"assets"),[e,t,d,a,o]),p=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=bl(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]),g=l.useMemo(()=>Cl(h,a),[h,a]),b=Rl(h);return l.createElement(l.Fragment,null,p.map(x=>l.createElement("link",{key:x,rel:"prefetch",as:"fetch",href:x,...n})),g.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 Tl(...e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}var Al=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{Al&&(window.__reactRouterVersion="7.12.0")}catch{}function Pl({basename:e,children:t,unstable_useTransitions:n,window:o}){let r=l.useRef();r.current==null&&(r.current=di({window:o,v5Compat:!0}));let a=r.current,[i,c]=l.useState({action:a.action,location:a.location}),u=l.useCallback(d=>{n===!1?c(d):l.startTransition(()=>c(d))},[n]);return l.useLayoutEffect(()=>a.listen(u),[a,u]),l.createElement(il,{basename:e,children:t,location:i.location,navigationType:i.action,navigator:a,unstable_useTransitions:n})}var $r=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Fr=l.forwardRef(function({onClick:t,discover:n="render",prefetch:o="none",relative:r,reloadDocument:a,replace:i,state:c,target:u,to:d,preventScrollReset:m,viewTransition:h,unstable_defaultShouldRevalidate:p,...g},b){let{basename:x,unstable_useTransitions:v}=l.useContext(Se),y=typeof d=="string"&&$r.test(d),f=Sr(d,x);d=f.to;let w=Hi(d,{relative:r}),[C,j,_]=Sl(o,g),S=Dl(d,{replace:i,state:c,target:u,preventScrollReset:m,relative:r,viewTransition:h,unstable_defaultShouldRevalidate:p,unstable_useTransitions:v});function k(F){t&&t(F),F.defaultPrevented||S(F)}let P=l.createElement("a",{...g,..._,href:f.absoluteURL||w,onClick:f.isExternal||a?t:k,ref:Tl(b,j),target:u,"data-discover":!y&&n==="render"?"true":void 0});return C&&!y?l.createElement(l.Fragment,null,P,l.createElement(El,{page:w})):P});Fr.displayName="Link";var Ol=l.forwardRef(function({"aria-current":t="page",caseSensitive:n=!1,className:o="",end:r=!1,style:a,to:i,viewTransition:c,children:u,...d},m){let h=Rn(i,{relative:d.relative}),p=le(),g=l.useContext(ms),{navigator:b,basename:x}=l.useContext(Se),v=g!=null&&zl(h)&&c===!0,y=b.encodeLocation?b.encodeLocation(h).pathname:h.pathname,f=p.pathname,w=g&&g.navigation&&g.navigation.location?g.navigation.location.pathname:null;n||(f=f.toLowerCase(),w=w?w.toLowerCase():null,y=y.toLowerCase()),w&&x&&(w=Je(w,x)||w);const C=y!=="/"&&y.endsWith("/")?y.length-1:y.length;let j=f===y||!r&&f.startsWith(y)&&f.charAt(C)==="/",_=w!=null&&(w===y||!r&&w.startsWith(y)&&w.charAt(y.length)==="/"),S={isActive:j,isPending:_,isTransitioning:v},k=j?t:void 0,P;typeof o=="function"?P=o(S):P=[o,j?"active":null,_?"pending":null,v?"transitioning":null].filter(Boolean).join(" ");let F=typeof a=="function"?a(S):a;return l.createElement(Fr,{...d,"aria-current":k,className:P,ref:m,style:F,to:i,viewTransition:c},typeof u=="function"?u(S):u)});Ol.displayName="NavLink";var Ml=l.forwardRef(({discover:e="render",fetcherKey:t,navigate:n,reloadDocument:o,replace:r,state:a,method:i=Xn,action:c,onSubmit:u,relative:d,preventScrollReset:m,viewTransition:h,unstable_defaultShouldRevalidate:p,...g},b)=>{let{unstable_useTransitions:x}=l.useContext(Se),v=ql(),y=Wl(c,{relative:d}),f=i.toLowerCase()==="get"?"get":"post",w=typeof c=="string"&&$r.test(c),C=j=>{if(u&&u(j),j.defaultPrevented)return;j.preventDefault();let _=j.nativeEvent.submitter,S=_?.getAttribute("formmethod")||i,k=()=>v(_||j.currentTarget,{fetcherKey:t,method:S,navigate:n,replace:r,state:a,relative:d,preventScrollReset:m,viewTransition:h,unstable_defaultShouldRevalidate:p});x&&n!==!1?l.startTransition(()=>k()):k()};return l.createElement("form",{ref:b,method:f,action:y,onSubmit:o?u:C,...g,"data-discover":!w&&e==="render"?"true":void 0})});Ml.displayName="Form";function Il(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Br(e){let t=l.useContext(Yt);return H(t,Il(e)),t}function Dl(e,{target:t,replace:n,state:o,preventScrollReset:r,relative:a,viewTransition:i,unstable_defaultShouldRevalidate:c,unstable_useTransitions:u}={}){let d=X(),m=le(),h=Rn(e,{relative:a});return l.useCallback(p=>{if(ml(p,t)){p.preventDefault();let g=n!==void 0?n:Cn(m)===Cn(h),b=()=>d(e,{replace:g,state:o,preventScrollReset:r,relative:a,viewTransition:i,unstable_defaultShouldRevalidate:c});u?l.startTransition(()=>b()):b()}},[m,d,h,n,o,t,e,r,a,i,c,u])}function $l(e){_e(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(()=>fl(o.search,n.current?null:t.current),[o.search]),a=X(),i=l.useCallback((c,u)=>{const d=Hs(typeof c=="function"?c(new URLSearchParams(r)):c);n.current=!0,a("?"+d,u)},[a,r]);return[r,i]}var Fl=0,Bl=()=>`__${String(++Fl)}__`;function ql(){let{router:e}=Br("useSubmit"),{basename:t}=l.useContext(Se),n=sl(),o=e.fetch,r=e.navigate;return l.useCallback(async(a,i={})=>{let{action:c,method:u,encType:d,formData:m,body:h}=xl(a,t);if(i.navigate===!1){let p=i.fetcherKey||Bl();await o(p,n,i.action||c,{unstable_defaultShouldRevalidate:i.unstable_defaultShouldRevalidate,preventScrollReset:i.preventScrollReset,formData:m,body:h,formMethod:i.method||u,formEncType:i.encType||d,flushSync:i.flushSync})}else await r(i.action||c,{unstable_defaultShouldRevalidate:i.unstable_defaultShouldRevalidate,preventScrollReset:i.preventScrollReset,formData:m,body:h,formMethod:i.method||u,formEncType:i.encType||d,replace:i.replace,state:i.state,fromRouteId:n,flushSync:i.flushSync,viewTransition:i.viewTransition})},[o,r,t,n])}function Wl(e,{relative:t}={}){let{basename:n}=l.useContext(Se),o=l.useContext(We);H(o,"useFormAction must be used inside a RouteContext");let[r]=o.matches.slice(-1),a={...Rn(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(h=>h).forEach(h=>c.append("index",h));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:Ge([n,a.pathname])),Cn(a)}function zl(e,{relative:t}={}){let n=l.useContext(Rr);H(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:o}=Br("useViewTransitionState"),r=Rn(e,{relative:t});if(!n.isTransitioning)return!1;let a=Je(n.currentLocation.pathname,o)||n.currentLocation.pathname,i=Je(n.nextLocation.pathname,o)||n.nextLocation.pathname;return Vt(r.pathname,i)!=null||Vt(r.pathname,a)!=null}var oo=Xa(),qr=class extends vr{constructor(e,t){super(),this.options=t,this.#n=e,this.#i=null,this.#a=Lo(),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 Re(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&&Wo(this.#e,n,this.options,t)&&this.#d(),this.updateResult(),o&&(this.#e!==n||Re(this.options.enabled,this.#e)!==Re(t.enabled,this.#e)||wn(this.options.staleTime,this.#e)!==wn(t.staleTime,this.#e))&&this.#g();const r=this.#x();o&&(this.#e!==n||Re(this.options.enabled,this.#e)!==Re(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 Hl(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=wn(this.options.staleTime,this.#e);if(Ws||this.#t.isStale||!To(e))return;const n=Za(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,!(Ws||Re(this.options.enabled,this.#e)===!1||!To(this.#l)||this.#l===0)&&(this.#u=Kn.setInterval(()=>{(this.options.refetchIntervalInBackground||ei.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:d}=e;let m={...d},h=!1,p;if(t._optimisticResults){const k=this.hasListeners(),P=!k&&qo(e,t),F=k&&Wo(e,n,t,o);(P||F)&&(m={...m,...ti(d.data,e.options)}),t._optimisticResults==="isRestoring"&&(m.fetchStatus="idle")}let{error:g,errorUpdatedAt:b,status:x}=m;p=m.data;let v=!1;if(t.placeholderData!==void 0&&p===void 0&&x==="pending"){let k;r?.isPlaceholderData&&t.placeholderData===i?.placeholderData?(k=r.data,v=!0):k=typeof t.placeholderData=="function"?t.placeholderData(this.#m?.state.data,this.#m):t.placeholderData,k!==void 0&&(x="success",p=Ao(r?.data,k,t),h=!0)}if(t.select&&p!==void 0&&!v)if(r&&p===a?.data&&t.select===this.#p)p=this.#h;else try{this.#p=t.select,p=t.select(p),p=Ao(r?.data,p,t),this.#h=p,this.#i=null}catch(k){this.#i=k}this.#i&&(g=this.#i,p=this.#h,b=Date.now(),x="error");const y=m.fetchStatus==="fetching",f=x==="pending",w=x==="error",C=f&&y,j=p!==void 0,S={status:x,fetchStatus:m.fetchStatus,isPending:f,isSuccess:x==="success",isError:w,isInitialLoading:C,isLoading:C,data:p,dataUpdatedAt:m.dataUpdatedAt,error:g,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&&!j,isPaused:m.fetchStatus==="paused",isPlaceholderData:h,isRefetchError:w&&j,isStale:ro(e,t),refetch:this.refetch,promise:this.#a,isEnabled:Re(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){const k=se=>{S.status==="error"?se.reject(S.error):S.data!==void 0&&se.resolve(S.data)},P=()=>{const se=this.#a=S.promise=Lo();k(se)},F=this.#a;switch(F.status){case"pending":e.queryHash===n.queryHash&&k(F);break;case"fulfilled":(S.status==="error"||S.data!==F.value)&&P();break;case"rejected":(S.status!=="error"||S.error!==F.reason)&&P();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 Ul(e,t){return Re(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function qo(e,t){return Ul(e,t)||e.state.data!==void 0&&Vs(e,t,t.refetchOnMount)}function Vs(e,t,n){if(Re(t.enabled,e)!==!1&&wn(t.staleTime,e)!=="static"){const o=typeof n=="function"?n(e):n;return o==="always"||o!==!1&&ro(e,t)}return!1}function Wo(e,t,n,o){return(e!==t||Re(o.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&ro(e,n)}function ro(e,t){return Re(t.enabled,e)!==!1&&e.isStaleByTime(wn(t.staleTime,e))}function Hl(e,t){return!os(e.getCurrentResult(),t)}var Vl=class extends qr{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:Po()})}getOptimisticResult(e){return e.behavior=Po(),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,d=i&&u==="forward",m=r&&u==="forward",h=i&&u==="backward",p=r&&u==="backward";return{...o,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:si(t,n.data),hasPreviousPage:ni(t,n.data),isFetchNextPageError:d,isFetchingNextPage:m,isFetchPreviousPageError:h,isFetchingPreviousPage:p,isRefetchError:c&&!d&&!h,isRefetching:a&&!m&&!p}}},Kl=class extends vr{#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&&Oo(n.mutationKey)!==Oo(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??oi();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)})})}},Wr=l.createContext(void 0),zr=e=>{const t=l.useContext(Wr);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},Ql=({client:e,children:t})=>(l.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),s.jsx(Wr.Provider,{value:e,children:t})),Ur=l.createContext(!1),Gl=()=>l.useContext(Ur);Ur.Provider;function Yl(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var Jl=l.createContext(Yl()),Xl=()=>l.useContext(Jl),Zl=(e,t,n)=>{const o=n?.state.error&&typeof e.throwOnError=="function"?Xs(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||o)&&(t.isReset()||(e.retryOnMount=!1))},ec=e=>{l.useEffect(()=>{e.clearReset()},[e])},tc=({result:e,errorResetBoundary:t,throwOnError:n,query:o,suspense:r})=>e.isError&&!t.isReset()&&!e.isFetching&&o&&(r&&e.data===void 0||Xs(n,[e.error,o])),nc=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))}},sc=(e,t)=>e.isLoading&&e.isFetching&&!t,oc=(e,t)=>e?.suspense&&t.isPending,zo=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function Hr(e,t,n){const o=Gl(),r=Xl(),a=zr(),i=a.defaultQueryOptions(e);a.getDefaultOptions().queries?._experimental_beforeQuery?.(i);const c=a.getQueryCache().get(i.queryHash);i._optimisticResults=o?"isRestoring":"optimistic",nc(i),Zl(i,r,c),ec(r);const u=!a.getQueryCache().get(i.queryHash),[d]=l.useState(()=>new t(a,i)),m=d.getOptimisticResult(i),h=!o&&e.subscribed!==!1;if(l.useSyncExternalStore(l.useCallback(p=>{const g=h?d.subscribe(ds.batchCalls(p)):rs;return d.updateResult(),g},[d,h]),()=>d.getCurrentResult(),()=>d.getCurrentResult()),l.useEffect(()=>{d.setOptions(i)},[i,d]),oc(i,m))throw zo(i,d,r);if(tc({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&&!Ws&&sc(m,o)&&(u?zo(i,d,r):c?.promise)?.catch(rs).finally(()=>{d.updateResult()}),i.notifyOnChangeProps?m:d.trackResult(m)}function pe(e,t){return Hr(e,qr)}function Z(e,t){const n=zr(),[o]=l.useState(()=>new Kl(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&&Xs(o.options.throwOnError,[r.error]))throw r.error;return{...r,mutate:a,mutateAsync:r.mutate}}function Vr(e,t){return Hr(e,Vl)}const at="data-sources",Kr="auth-user",rc=e=>pe({queryKey:["project","datasources",e],queryFn:async()=>{const{data:t}=await I.get(`/project/team/${e}/datasources`);return t.data},enabled:!!e}),Jt=e=>{const t=["project","datasources"],n=["project","saved-queries"];return Promise.all([K.invalidateQueries({queryKey:t}),K.invalidateQueries({queryKey:n})])},ac=e=>{const t=["trash","team"];return K.invalidateQueries({queryKey:t})},ic=(e,t)=>pe({queryKey:["project",t.teamId,"tables",e,t.selectedDataSources],queryFn:async()=>{const{data:n}=await I.get(`/project/team/${t.teamId}/query`,{params:{size:30,search:e,selectedDataSources:t.selectedDataSources}});return n.data},enabled:!!t.teamId,staleTime:0}),lc=(e,t="",n=30,o)=>Vr({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 I.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}),cc=(e,t="",n=20)=>Vr({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 I.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}}),uc=(e,t=10,n=!1)=>pe({queryKey:["project","recent-tabs",e,t,n],queryFn:async()=>{const{data:o}=await I.get(`/project/team/${e}/tabs-history?page=0&size=${t}&archived=${n}`);return o.data},enabled:!!e,staleTime:0}),dc=e=>Z({mutationFn:async()=>{const{data:t}=await I.get(`/project/team/${e}/tabs-history?page=0&size=1&archived=false`);return t.data?.length?t.data[0]:void 0}}),hc=()=>Promise.all([K.invalidateQueries({queryKey:["project","tabs-history"]}),K.invalidateQueries({queryKey:["project","recent-tabs"]})]),Qr=()=>K.invalidateQueries({queryKey:["project","count-saved-queries"]}),mc=(e,t)=>{},fc=()=>{},pc={event:mc,pageView:fc},ps=e=>pe({queryKey:[at,e],queryFn:async()=>{const{data:t}=await I.get("/data-sources/"+e);return t.data},enabled:!!e}),ao=e=>pe({queryKey:[at,e.teamId],queryFn:async()=>{const{data:t}=await I.get("/data-sources",{params:e});return t.data},enabled:e.teamId!==void 0}),Ln=e=>pe({queryKey:[at,e,"inspections"],queryFn:async()=>{const{data:t}=await I.get(`/data-sources/${e}/inspections`);return t.data},enabled:!!e}),gc=()=>Z({mutationFn:async e=>{const{data:t}=await I.post("/data-sources",e);return t.data},onSuccess:()=>{K.invalidateQueries({queryKey:[at]}),Jt()},onError:()=>{}}),xc=()=>Z({mutationFn:async({dataSource:e,id:t})=>{const{data:n}=await I.put(`/data-sources/${t}`,e);return n.data},onSuccess:()=>{K.invalidateQueries({queryKey:[at]}),Jt()}}),Gr=()=>Z({mutationFn:async e=>{await I.post(`/data-sources/${e}/inspect`)},onSuccess:()=>{K.invalidateQueries({queryKey:[at]})}}),bc=()=>Z({mutationFn:async e=>{await I.delete(`/data-sources/${e}`)},onSuccess:()=>{K.invalidateQueries({queryKey:[at]}),Jt()}}),Yr=()=>pe({queryKey:["accessToken"],queryFn:hs.get}),ve=()=>{const{data:e}=Yr();return pe({queryKey:[Kr],queryFn:async()=>{const{data:t}=await I.get("/users");return t.data},enabled:!!e,retry:(t,n)=>ri(n)&&n.code==="ERR_NETWORK"?!1:t<3})},vc=()=>Z({mutationFn:async e=>{const{data:t}=await I.patch("/users",e);return t.data},onSuccess:async e=>{K.setQueryData([Kr],e)}}),yc=()=>Z({mutationFn:async e=>(await I.post("/users",e),!0),onSuccess:()=>{K.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 wc(e){const t=[];for(const n of e)for(const o of n.columns)o.ref&&(t.push({id:`${n.tableName}->${o.ref.table}.${o.ref.field}`,name:`${n.tableName} in ${o.ref.table}`,where:`${n.tableName}.${o.name} = ${o.ref.table}.${o.ref.field}`,on:{fromTable:o.ref.table,toTable:n.tableName,fromColumn:o.ref.field,toColumn:o.name}}),t.push({id:`${o.ref.table}->${n.tableName}.${o.name}`,name:`${o.ref.table} in ${n.tableName}`,where:`${o.ref.table}.${o.ref.field} = ${n.tableName}.${o.name}`,on:{fromTable:n.tableName,toTable:o.ref.table,fromColumn:o.name,toColumn:o.ref.field}}));return t}const Cc=e=>pe({queryKey:["hooks",e],queryFn:async()=>{const t=await K.fetchQuery({queryKey:[at,e,"inspections"],queryFn:async()=>{const{data:n}=await I.get(`/data-sources/${e}/inspections`);return n.data}});return wc(t)},enabled:!!e}),Jr=[{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"}],jc=Jr.reduce((e,t)=>(e[t.value]=t.label,e),{});Jr.reduce((e,t)=>(e[t.label]=t.value,e),{});const Xt=e=>e.map(t=>({label:jc[t],value:t}));Xt(["=","<>",">",">=","<","<=","IN","NOT IN","IS NULL","IS NOT NULL"]);Xt(["=","<>","LIKE","NOT LIKE","IN","NOT IN","IS NULL","IS NOT NULL","CONTAINS","NOT CONTAINS"]);Xt(["=","<>","IS NULL","IS NOT NULL"]);Xt(["=","<>",">",">=","<","<=","IS NULL","IS NOT NULL"]);Xt(["IS NULL","IS NOT NULL"]);Xt(["IN","NOT IN"]);const Nc=["char","varchar","binary","varbinary","blob","text","enum","set","character","character varying","text","citext","uuid","xml","json","jsonb"];new Set(Nc);const kc=["integer","smallint","decimal","numeric","float","real","double precision","int","smallint","integer","bigint","decimal","numeric","real","double precision","serial","bigserial","money"];new Set(kc);const _c=["date","datetime","timestamp","timestamptz"].reduce((e,t)=>(e[t]=!0,e),{}),Xr=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 Uo={[me.READ_ONLY]:10,[me.EDITOR]:20,[me.ADMIN]:30,[me.OWNER]:40};function Sc(e,t){if(!e||!t)return{};const n=new Set;for(const r of t)r.table&&n.add(r.table);const o={};for(const r of n){const a=e.find(i=>i.tableName===r);if(a){o[r]=[];const i=a.columns.filter(c=>c.isPrimary);for(const c of i)if(t.find(d=>d.table===r&&d.column===c.name))o[r].push(c.name);else{delete o[r];break}}}return o}function Ec(e,t,n,o){const{data:r}=Cc(t),{data:a}=Ln(t);return l.useMemo(()=>{const i=Sc(a,e?.result.columns);return{name:n,tabId:o,hooks:(()=>{const c=[];if(!r||!e||!e.result.columns)return c;for(const u of r)(e.result.tables.includes(u.on.toTable)||e.result.tables.includes(u.on.fromTable))&&c.push(u);return c})(),availableJoins:(()=>{const c=[];if(!r||!e||!e.result.columns)return c;for(const u of r)!e.result.tables.includes(u.on.toTable)&&e.result.tables.includes(u.on.fromTable)&&c.push(u);return c})(),allColumns:e?.result.allColumns||[],dataSourceId:t,entities:Object.keys(i),getValue:(c,u)=>{const d=Xr(u),m=e?.result.columns?.findIndex(h=>h.full===d);if(m!=null&&m>-1)return c[m]},getEntityKey:(c,u)=>i[c].reduce((d,m)=>{const h=e?.result.columns?.findIndex(p=>p.column===m&&p.table===c);if(h!=null&&h>-1){const p=u[h]?.toString();p&&d.push([m,p])}return d},[]),getEntityKeyByRowIndex:(c,u)=>i[c].reduce((d,m)=>{const h=e?.result.columns?.findIndex(p=>p.column===m&&p.table===c);if(h!=null&&h>-1){const p=e?.result.rows[u][h]?.toString();p&&d.push([m,p])}return d},[]),getColumnType:c=>{const u=e?.result.allColumns.find(d=>d.full===c);if(u)return u.type}}},[e,t,r,a,n])}function Rc(e,t){return l.useMemo(()=>({state:e,setState:t}),[e,t])}function Zt(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 Lc(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=>!!Vt({path:t,end:!0},r)}}function gs(e,t){return{name:e,path:t,build:()=>t,check:n=>n===t}}const Tc=gs("Home","/"),Ac=gs("Workbench","/workbench"),Pc=gs("Share query","/share"),Oc=gs("Login","/login"),Mc=Lc("Workbench tab","/workbench/tab/:id"),D={home:Tc,workbench:Ac,share:Pc,login:Oc,workbenchTab:Mc},io=e=>{K.setQueryData(["workbench-tabs"],t=>e(t||[]))},Ic=(e,t)=>{K.setQueryData(["workbench-tabs",e],n=>n&&t(n))},xs=()=>pe({queryKey:["workbench-tabs"],queryFn:async()=>{const{data:e}=await I.get("/workbench-tabs");return e.data}}),Dc=e=>pe({queryKey:["workbench-tabs",e],queryFn:async()=>{const{data:t}=await I.get(`/workbench-tabs/${e}`);return t.data}}),en=()=>Z({mutationFn:async e=>{const{data:t}=await I.post("/workbench-tabs",e);return t.data},onSuccess:async e=>{io(t=>[...t,e])}}),$c=()=>Z({mutationFn:async e=>(await I.patch(`/workbench-tabs/${e}`,{archived:!0}),e),onMutate:e=>{io(t=>t.filter(n=>n.id!==e))}}),Zr=()=>Z({mutationFn:async e=>(await I.patch(`/workbench-tabs/${e}`,{archived:!1}),e),onSuccess:()=>ta()}),Fc=()=>Z({mutationFn:async({id:e,payload:t})=>(await I.patch(`/workbench-tabs/${e}`,t),!0),onMutate:({id:e,payload:t})=>{Ic(e,n=>({...n,...t})),io(n=>n.map(o=>o.id!==e?o:{...o,name:t.name||o.name}))}}),Bc=(e,t)=>{const{dataSourceId:n,searchAll:o,table:r,filters:a,joins:i,orderBy:c,groupBy:u,columns:d,aggregations:m,page:h=0,size:p=20}=t;return pe({queryKey:["workbench-tab-runner",e,n,r,h,p,a,m,i,c,u,d,o],queryFn:async()=>{const{data:g}=await I.post(`/workbench-tabs/${e}/run`,t);return g.data},retry:1,enabled:!!r&&!!n,placeholderData:ai})},qc=()=>Z({mutationFn:async e=>{await I.delete(`/workbench-tabs/${e}`)},onSuccess:()=>{ta(),hc()}}),ea=e=>K.invalidateQueries({queryKey:["workbench-tab-runner",e]}),ta=()=>K.invalidateQueries({queryKey:["workbench-tabs"]}),[Wc,As,zc]=ye(void 0),Uc=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=X(),n=en(),o=Zr();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(()=>{zc.get()||Uc().then(a=>{a?.type==="table"?n.mutate({name:a.id,opts:Zt({table:a.id,dataSourceId:a.dsId})}):a?.type==="query"?n.mutate({queryId:a.id}):a?.type==="tab"&&o.mutate(a.id)})},[t,e])},An=e=>{const{data:t}=ve();return l.useMemo(()=>t?Uo[t.teamRole]>=Uo[e]:!1,[t,e])},Hc="_input_1m4ex_2",Vc="_label_1m4ex_2",Kc="_content_1m4ex_2",Qc="_form_1m4ex_2",Gc="_mode-select_1m4ex_2",yt={input:Hc,label:Vc,content:Kc,form:Qc,switch:"_switch_1m4ex_2",modeSelect:Gc},Yc="_modal_8yoe6_2",Jc="_modal-visible_8yoe6_2",Xc="_modal-invisible_8yoe6_2",Zc="_backdrop_8yoe6_2",eu="_modal-container_8yoe6_2",tu="_close-button_8yoe6_2",zt={modal:Yc,modalVisible:Jc,modalInvisible:Xc,backdrop:Zc,modalContainer:eu,closeButton:tu},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 nu=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 bs=e=>{const t=l.useRef(e.onClose);t.current=e.onClose,l.useEffect(()=>{if(e.enabled)return nu(()=>{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),d=()=>{t&&o()},m=p=>{n||getComputedStyle(p.currentTarget).opacity==="0"&&(u(!1),r&&r())};l.useEffect(()=>{n&&u(!0)},[n]),bs({onClose:d,enabled:n&&t===!0});const h=s.jsxs("div",{onTransitionEnd:m,className:A(zt.modal,n?zt.modalVisible:zt.modalInvisible),children:[s.jsx("div",{onClick:d,className:zt.backdrop}),s.jsx("div",{className:A(zt.modalContainer,a!==!0&&"p-4"),children:c&&e})]});return i?oo.createPortal(h,document.body):h},it=({onClick:e})=>{const t=l.useRef(e);return t.current=e,s.jsx("button",{className:zt.closeButton,onClick:e,children:s.jsx(jt,{width:20,height:20})})},na=({children:e})=>s.jsx("h2",{className:"text-xl font-semibold",children:e}),su=({form:e,change:t,shape:n})=>s.jsx("div",{className:yt.form,children:n.fields.map(o=>s.jsxs("label",{className:yt.input,children:[s.jsx("p",{className:yt.label,children:o.label}),s.jsx("input",{value:e[o.name],onChange:t(o.name),type:o.type})]},o.name))}),Ft=[{label:"PostgreSQL",tag:"postgres"},{label:"MySQL",tag:"mysql"}],ou={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"}]},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"},{label:"Schema",name:"dbSchema",type:"text"}]},au=({show:e,onClose:t,dbType:n="postgres"})=>{const o=gc(),r=Gr(),{data:a}=ve(),[i,{change:c,set:u}]=_n({name:"",dbType:n,dbUrl:"",dbUser:"",dbPassword:"",dbDatabase:"",dbSchema:"",dbPort:5432,teamId:"",ownerId:"",description:"",allowInsert:!1,allowUpdate:!1}),d=async()=>{const b=await o.mutateAsync({...i,dbPort:Number(i.dbPort),teamId:a.teamId,ownerId:a.id});await r.mutateAsync(b.id),t(),pc.event("Create Datasource",{dbType:i.dbType})},m=b=>{u("allowInsert",!b),u("allowUpdate",!b)},h=()=>{t()},p=o.isPending||r.isPending,g=!i.allowInsert&&!i.allowUpdate;return s.jsxs(we,{isVisible:e,onClose:h,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:yt.switch,children:[s.jsxs("label",{className:"button tertiary",children:[s.jsx("input",{type:"radio",name:"bdType",className:"mr-2",checked:i.dbType===Ft[0].tag,onChange:()=>u("dbType",Ft[0].tag)}),s.jsx("span",{children:Ft[0].label})]}),s.jsxs("label",{className:"button tertiary",children:[s.jsx("input",{type:"radio",name:"bdType",className:"mr-2",checked:i.dbType===Ft[1].tag,onChange:()=>u("dbType",Ft[1].tag)}),s.jsx("span",{children:Ft[1].label})]})]}),s.jsxs("div",{className:"mt-2",children:[s.jsxs("div",{className:yt.content,children:[s.jsx(su,{form:i,change:c,shape:i.dbType==="mysql"?ou:ru}),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:yt.modeSelect,children:[s.jsxs("div",{children:[s.jsx("input",{type:"radio",name:"production-mode",className:"mr-2",checked:g,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:yt.modeSelect,children:[s.jsxs("div",{children:[s.jsx("input",{type:"radio",name:"production-mode",className:"mr-2",checked:!g,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:h,className:"button tertiary",disabled:p,children:"Cancel"}),s.jsx("button",{onClick:d,className:"button primary",disabled:p,children:"Create"})]})]})},iu="_data-source-entry_9ltef_2",lu="_action-title_9ltef_2",cu="_recent-tabs-container_9ltef_2",uu="_recent-tabs-entry_9ltef_2",du="_home-action-button_9ltef_2",hu="_home-gray-card_9ltef_2",mu="_home-card-title_9ltef_2",fu="_home-card-grid-content_9ltef_2",pu="_useful-links_9ltef_2",J={dataSourceEntry:iu,actionTitle:lu,recentTabsContainer:cu,recentTabsEntry:uu,homeActionButton:du,homeGrayCard:hu,homeCardTitle:mu,homeCardGridContent:fu,usefulLinks:pu},gu=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"})),xu=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"}})),lt=({size:e,type:t})=>t==="mysql"?s.jsx(gu,{width:e,height:e}):s.jsx(xu,{width:e,height:e}),[bu,Pn]=ye({show:!1}),[vu,jn]=ye({show:!1}),[yu,Nn]=ye(void 0),wu=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"})),Cu=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"})),ju=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})),Nu=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})),tn=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"})),sa=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"})),oa=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})),Ho=20,lo="text-(--text-color-primary)",ku=()=>{const e=Tn("Home");return s.jsxs("div",{className:J.homeActionButton,onClick:e,children:[s.jsx(tn,{width:Ho,height:Ho,className:lo}),s.jsx("h2",{className:J.actionTitle,children:"Start new query"})]})},_u=()=>s.jsxs("div",{className:J.homeActionButton,onClick:()=>Pn({show:!0}),children:[s.jsx(sa,{width:20,height:20,className:lo}),s.jsx("h2",{className:J.actionTitle,children:"Saved queries"})]}),Su=()=>{const[e,t]=l.useState(void 0),n=An(me.EDITOR),o=r=>{n?t(r):Le.error("You don't have permission to connect new data sources in this team")};return s.jsxs("div",{children:[e&&s.jsx(au,{show:!0,dbType:e,onClose:()=>t(void 0)}),s.jsx("div",{className:J.homeActionButton,onClick:()=>o("postgres"),children:s.jsx("p",{className:J.actionTitle,children:"🧙‍♂️ Connection wizard"})})]})},Eu=()=>{const e=X(),{data:t}=xs(),n=Tn("Home"),o=()=>{t&&t.length>0?e(D.workbenchTab.build({id:t[0].id})):n()};return s.jsxs("div",{className:J.homeActionButton,onClick:o,children:[s.jsx(oa,{width:20,height:20,className:lo}),s.jsx("h2",{className:J.actionTitle,children:"Workbench"})]})},Ru=()=>{const{data:e}=ve(),{data:t}=ao({teamId:e?.teamId}),n=o=>{Nn(o)};return!t||t.length===0?null:s.jsxs("div",{className:J.homeGrayCard,children:[s.jsx("h2",{className:J.homeCardTitle,children:"Data sources"}),s.jsx("div",{className:J.homeCardGridContent,children:t?.map(o=>s.jsxs("div",{className:J.dataSourceEntry,onClick:()=>n(o.id),tabIndex:0,children:[!o.allowInsert&&s.jsx(Nu,{"data-tooltip-id":"default","data-tooltip-content":"This datasource is read-only",width:18,height:18,className:"absolute top-2 right-2"}),s.jsx(lt,{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))})]})},Bt=24,ra=()=>s.jsxs("div",{className:J.usefulLinks,children:[s.jsxs("a",{href:"https://dataramen.xyz/",target:"_blank",children:[s.jsx(ju,{width:Bt,height:Bt}),s.jsx("span",{children:"Docs"})]}),s.jsxs("a",{href:"https://github.com/OleksandrDemian/dataramen",target:"_blank",children:[s.jsx(wu,{width:Bt,height:Bt}),s.jsx("span",{children:"GitHub"})]}),s.jsxs("a",{href:"https://www.npmjs.com/package/@dataramen/cli",target:"_blank",children:[s.jsx(Cu,{width:Bt,height:Bt}),s.jsx("span",{children:"NPM"})]})]}),Lu=()=>{const{data:e}=ve(),{data:t,isLoading:n}=uc(e?.teamId),o=X();if(n||!t?.length)return null;const r=a=>{o(D.workbenchTab.build({id:a}))};return s.jsxs("div",{className:J.recentTabsContainer,children:[s.jsx("h2",{className:J.homeCardTitle+" px-4 mb-4",children:"Recent tabs"}),t.map(a=>s.jsxs("div",{className:J.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(lt,{size:20,type:a.dataSourceType}),s.jsx("span",{className:"text-sm text-(--text-color-secondary) truncate",children:a.dataSourceName})]})]},a.id))]})},Tu=()=>{const{data:e}=ve(),{data:t}=ao({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(ra,{})]}),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:J.homeGrayCard,children:[s.jsx("h2",{className:J.homeCardTitle,children:"Quick actions"}),s.jsxs("div",{className:J.homeCardGridContent,children:[s.jsx(ku,{}),s.jsx(Su,{}),o&&s.jsx(Eu,{}),s.jsx(_u,{})]})]}),o&&s.jsx(Ru,{}),s.jsx(Lu,{})]})]})})},[Au,co]=ye(void 0),Pu=()=>co(void 0);function wt(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(" "),tt=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},Ou="_container_kylos_2",Mu="_header_kylos_2",Iu="_fields-container_kylos_2",Du="_field-label_kylos_2",$u="_actions_kylos_2",gn={container:Ou,header:Mu,fieldsContainer:Iu,fieldLabel:Du,actions:$u},Fu=(e,t,n)=>pe({queryKey:["entity",e,t,n],queryFn:async()=>{const{data:o}=await I.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}),Bu=()=>Z({mutationFn:async e=>{const{data:t}=await I.post(`/runner/${e.datasourceId}/update`,e);return t.data}}),qu=()=>Z({mutationFn:async e=>{const{data:t}=await I.post(`/runner/${e.datasourceId}/insert`,e);return t.data}}),uo=e=>l.useMemo(()=>{if(e)return e instanceof ii?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]),ho=()=>{const{pathname:e}=le();return l.useMemo(()=>Vt({path:D.workbenchTab.path,end:!1},e)?.params.id,[e])},aa=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"})),Wu="_container_qea8y_2",zu={container:Wu},On=({containerClassName:e,className:t,...n})=>s.jsxs("label",{className:A(zu.container,e),children:[s.jsx(tn,{width:16,height:16}),s.jsx("input",{className:A("flex-1 outline-none",t),...n})]}),Uu=({data:e})=>{const[t,{change:n,touched:o}]=_n({}),r=ho(),{mutateAsync:a,error:i}=qu(),c=uo(i),{data:u}=Ln(e.dataSourceId),[d,m]=l.useState(""),h=l.useMemo(()=>u?.find(b=>b.tableName===e.table),[u,e.table]),p=l.useMemo(()=>{if(!h)return[];if(!d)return h.columns.map(x=>({...x,label:tt(x.name)}));const b=d.toLowerCase();return h.columns.filter(x=>x.name.toLowerCase().includes(b)).map(x=>({...x,label:tt(x.name)}))},[d,h]),g=()=>{const b={};for(const x of o)b[x]=t[x];a({datasourceId:e.dataSourceId,table:e.table,values:b}).then(()=>{Pu(),r&&ea(r)})};return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:gn.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(On,{containerClassName:"mt-2",className:"text-sm",value:d,onChange:b=>m(b.target.value),placeholder:"Filter columns"})]}),s.jsx("div",{className:gn.container,children:s.jsx("div",{className:gn.fieldsContainer,children:p.map(b=>s.jsxs("label",{className:gn.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:wt(t[b.name]),onChange:n(b.name)})]},b.name))})}),s.jsxs("div",{className:gn.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(aa,{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:g,children:"Run insert"})]})]})},Hu=()=>{const e=Au(),[t,n]=l.useState(void 0);l.useEffect(()=>{e&&n(e)},[e]);const o=()=>co(void 0);return s.jsxs(we,{isVisible:e!=null,onClose:o,onClosed:()=>n(void 0),noPadding:!0,children:[s.jsx(it,{onClick:o}),t&&s.jsx(Uu,{data:t})]})},[Vu,vs]=ye(void 0),Ku=()=>vs(void 0),Qu="_container_1wbts_2",Gu="_header_1wbts_2",Yu="_fields-container_1wbts_2",Ju="_field-label_1wbts_2",Xu="_actions_1wbts_2",xn={container:Qu,header:Gu,fieldsContainer:Yu,fieldLabel:Ju,actions:Xu},ot=()=>Date.now().toString(36)+Math.random().toString(36).substring(2),Zu=({data:e})=>{const[t,{change:n,set:o,reset:r,touched:a}]=_n({}),i=ho(),[c,u]=l.useState(""),{data:d,isLoading:m}=Fu(e.dataSourceId,e.tableName,e.entityId),{mutateAsync:h,error:p}=Bu(),g=uo(p),b=An(me.EDITOR),{data:x}=Ln(e.dataSourceId),{data:v}=ps(e.dataSourceId),y=l.useMemo(()=>x?.find(j=>j.tableName===e.tableName),[e.tableName,x]),f=l.useMemo(()=>{if(!y)return[];if(!c)return y.columns.map(_=>({..._,label:tt(_.name)}));const j=c.toLowerCase();return y.columns.filter(_=>_.name.toLowerCase().includes(j)).map(_=>({..._,label:tt(_.name)}))},[c,y]);l.useEffect(()=>{const j=d?.entity;if(r(),j&&d?.columns)for(let _=0;_<d.columns.length;_++){const S=d.columns[_];o(S.column,wt(j[_]))}},[d,o,r]);const w=()=>{const j={};for(const _ of a)j[_]=t[_];h({datasourceId:e.dataSourceId,table:e.tableName,filters:e.entityId.map(_=>({id:ot(),value:_[1],column:_[0]})),values:j}).then(()=>{Ku(),i&&ea(i)})},C=!v?.allowUpdate||!b;return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:xn.header,children:[s.jsxs("p",{className:"text-lg font-semibold",children:[C?"View":"Edit"," row in ",s.jsx("span",{className:"underline",children:e?.tableName})]}),g&&s.jsx(fe,{variant:"danger",children:s.jsx("p",{children:g})}),s.jsx(On,{containerClassName:"mt-2",className:"text-sm",value:c,onChange:j=>u(j.target.value),placeholder:"Filter columns"})]}),s.jsx("div",{className:xn.container,children:s.jsx("div",{className:xn.fieldsContainer,children:f.map(j=>s.jsxs("label",{className:xn.fieldLabel,children:[s.jsxs("div",{className:"flex justify-between mb-0.5",children:[s.jsxs("p",{children:[j.isPrimary?"🔐":"🏷️"," ",j.label]}),s.jsxs("p",{className:"text-blue-800 text-sm",children:["[",j.name,": ",j.type,"]"]})]}),s.jsx("input",{disabled:j.isPrimary||m||C,className:"input w-full secondary",value:wt(t[j.name]),onChange:n(j.name)})]},j.name))})}),s.jsxs("div",{className:xn.actions,children:[!C&&s.jsx("span",{"data-tooltip-id":"default","data-tooltip-content":"Tip: use = to write raw SQL. Ex: =NULL or =NOW()",children:s.jsx(aa,{className:"text-(--text-color-secondary)",width:22,height:22})}),s.jsx("span",{className:"flex-1"}),!C&&s.jsx("button",{disabled:!a.length,className:"button primary",onClick:w,children:"Run update"})]})]})},ed=()=>{const e=Vu(),[t,n]=l.useState(void 0);l.useEffect(()=>{e&&n(e)},[e]);const o=()=>vs(void 0);return s.jsxs(we,{isVisible:e!=null,onClose:o,onClosed:()=>n(void 0),noPadding:!0,children:[s.jsx(it,{onClick:o}),t&&s.jsx(Zu,{data:t})]})},[td,Ps]=ye(void 0),mo=async e=>new Promise(t=>{Ps({message:e,onCancel:()=>{t(!1),Ps(void 0)},onConfirm:()=>{t(!0),Ps(void 0)}})}),nd=({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"})]})]}),sd=()=>{const e=td(),[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(nd,{confirm:t})})},[od,ns]=ye(void 0),Mn=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)}})}),rd="_root_ng9lp_1",ad={root:rd},id=({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:ad.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"})]})]})},ld=()=>{const e=od(),[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(id,{data:t})})},[cd,ud]=ye(void 0),ia=e=>{ud(e)},dd="_textarea_18qkb_2",hd={textarea:dd},md=()=>{const e=cd(),t=()=>{e&&(navigator.clipboard.writeText(e.toString()),Le.success("Copied!"))},n=()=>ia(void 0);return s.jsxs(we,{isVisible:!!e,onClose:n,backdropClose:!0,children:[s.jsx("textarea",{className:hd.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"})]})]})},fd="_tabs_1cjkw_2",pd="_mobile_1cjkw_2",gd="_tab_1cjkw_2",xd="_active_1cjkw_2",bd="_close-button_1cjkw_2",bn={tabs:fd,mobile:pd,tab:gd,active:xd,closeButton:bd},Vo=e=>window.matchMedia(e).matches;function la(e,{defaultValue:t=!1,initializeWithValue:n=!0}={}){const[o,r]=l.useState(()=>n?Vo(e):t);return l.useLayoutEffect(()=>{const a=window.matchMedia(e);function i(){r(()=>Vo(e))}return i(),a.addListener?a.addListener(i):a.addEventListener("change",i),()=>{a.removeListener?a.removeListener(i):a.removeEventListener("change",i)}},[e]),o}const fo={laptop:"(min-width: 1024px)"},ca=()=>window.matchMedia(fo.laptop).matches,vd="_table_1hwq6_2",yd="_row-index-btn_1hwq6_2",wd="_semi-transparent_1hwq6_2",Cd="_table-loading_1hwq6_2",jd="_table-empty_1hwq6_2",Nd="_table-row-cells_1hwq6_2",kd="_header-cell_1hwq6_2",_d="_header-actions_1hwq6_2",Sd="_cell_1hwq6_2",Ed="_value_1hwq6_2",Rd="_table-config_1hwq6_2",Ld="_table-action_1hwq6_2",Td="_green-fixed_1hwq6_2",Ad="_gray_1hwq6_2",Pd="_modal_1hwq6_2",Od="_selected-size_1hwq6_2",Md="_pagination-indicator_1hwq6_2",L={table:vd,rowIndexBtn:yd,semiTransparent:wd,tableLoading:Cd,tableEmpty:jd,tableRowCells:Nd,headerCell:kd,headerActions:_d,cell:Sd,value:Ed,tableConfig:Rd,tableAction:Ld,greenFixed:Td,gray:Ad,modal:Pd,selectedSize:Od,paginationIndicator:Md},ze=l.createContext({name:"No name",hooks:[],availableJoins:[],allColumns:[],dataSourceId:"",entities:[],getValue:()=>{},getColumnType:()=>{},getEntityKey:()=>[],getEntityKeyByRowIndex:()=>[]}),ge=l.createContext({state:Zt({}),setState:()=>{}}),Pe=l.createContext({}),ua={ON_ANIMATION_END:Symbol("ON_TRANSITION_END")},da=()=>{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,[ua.ON_ANIMATION_END]:i}},[e,n])},Id=e=>{if(e==="ASC")return"DESC";if(e!=="DESC")return"ASC"},Dd=()=>{const{state:e,setState:t}=l.useContext(ge),n=l.useCallback(o=>{t(r=>{const a=r.orderBy[0];if(a&&a.column===o){const i=Id(a.direction);return i?{...r,orderBy:[{column:o,direction:i}]}:{...r,orderBy:[]}}return{...r,orderBy:[{column:o,direction:"ASC"}]}})},[t]);return{orderBy:e.orderBy,updateOrderBy:n}},$d="_options-container_1t6nt_2",Fd="_filter-input_1t6nt_2",Bd="_option-item_1t6nt_2",qd="_list_1t6nt_2",Wd="_empty-text_1t6nt_2",Ke={optionsContainer:$d,filterInput:Fd,optionItem:Bd,list:qd,emptyText:Wd},zd="_container_153rj_2",Ud="_animate-show_153rj_2",Hd="_animate-hide_153rj_2",Vd="_content_153rj_2",Kd="_backdrop_153rj_2",pt={container:zd,animateShow:Ud,animateHide:Hd,content:Vd,backdrop:Kd},ha=({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,ca()?c?a.right=window.innerWidth-t.position.x:a.left=t.position.x:(a.right=36,a.left=36)}return a},[t.position]);if(bs({enabled:!!o,onClose:t.close}),!o)return null;const r=s.jsxs("div",{className:A(pt.container,t.state==="out"&&pt.animateHide,t.state==="in"&&pt.animateShow),onAnimationEnd:t[ua.ON_ANIMATION_END],children:[s.jsx("div",{className:pt.backdrop,onClick:a=>{a.stopPropagation(),a.preventDefault(),t.close()}}),s.jsx("div",{className:A(pt.content,t.state==="out"&&pt.animateHide,t.state==="in"&&pt.animateShow),style:o,children:e})]});return oo.createPortal(r,document.body)},Be=(e,t)=>e!=null&&e>t,Qd=(e,t)=>e!=null&&e<t,Gd="_root_u118k_2",Yd="_content_u118k_2",Jd="_table-name_u118k_2",Xd="_sub_u118k_2",Gn={root:Gd,content:Yd,tableName:Jd,sub:Xd},ma=({hook:e,onClick:t})=>s.jsx("button",{className:Gn.root,onClick:t,children:s.jsxs("div",{className:Gn.content,children:[s.jsx("span",{className:Gn.tableName,children:e.on.toTable}),s.jsxs("span",{className:Gn.sub,children:[e.on.toColumn," = ",e.on.fromTable,".",e.on.fromColumn]})]})},e.where);function Zd(e,t,n){return{name:`${e.on.toTable} ${e.on.toColumn} equals ${n}`,opts:Zt({table:e.on.toTable,dataSourceId:t,filters:[{id:ot(),column:`${e.on.toTable}.${e.on.toColumn}`,value:n==null?"IS NULL":`${n}`,isEnabled:!0}]})}}const fa=({rowIndex:e,onClose:t,className:n})=>{const[o,r]=l.useState(""),{hooks:a,dataSourceId:i,getValue:c}=l.useContext(ze),{state:u}=l.useContext(ge),{data:d}=l.useContext(Pe),m=l.useMemo(()=>d?.result.rows[e],[d,e]),h=en(),p=X(),g=l.useMemo(()=>{if(!d)return[];const f=o.toLowerCase();return a.filter(w=>d.result.columns.some(j=>j.column===w.on.fromColumn&&j.table===w.on.fromTable)?w.on.toTable.toLowerCase().includes(f):!1)},[o,a,d]),b=f=>{m&&h.mutateAsync(Zd(f,i,c(m,{value:`${f.on.fromTable}.${f.on.fromColumn}`}))).then(w=>{p(D.workbenchTab.build({id:w.id})),t?.()})},x=()=>{!m||!u||h.mutateAsync({name:`${u.table} > [${u.joins.map(f=>f.table).join()}]`,opts:Zt({joins:u.joins,table:u.table,dataSourceId:u.dataSourceId,filters:[...u.filters.filter(f=>f.isEnabled),...u.groupBy.map(f=>({id:ot(),column:f.value,value:`${c(m,f)}`,isEnabled:!0}))]})}).then(f=>{p(D.workbenchTab.build({id:f.id})),t?.()})},v=u.groupBy.length>0,y=Be(g.length,0);return s.jsxs("div",{className:n,children:[s.jsx(On,{autoFocus:!0,className:Ke.filterInput,placeholder:"Filter",value:o,onChange:f=>r(f.target.value)}),s.jsxs("div",{className:Ke.list,children:[v&&s.jsx("button",{onClick:x,className:Ke.optionItem,children:"Underlying rows"}),y&&g.map(f=>s.jsx(ma,{hook:f,onClick:()=>b(f)},f.where)),!v&&!y&&s.jsx("p",{className:Ke.emptyText,children:"Empty"})]})]})},eh=({handler:e,rowIndex:t})=>s.jsx(ha,{handler:e,children:s.jsx("div",{className:Ke.optionsContainer,children:s.jsx(fa,{rowIndex:t,className:"p-2",onClose:()=>{e.close()}})})}),po=()=>{const{state:e,setState:t}=l.useContext(ge),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}},th=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"})),Ye=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"})),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:32,d:"M464 208L352 96 240 208M352 113.13V416M48 304l112 112 112-112M160 398V96"})),sh="_container_thz3c_2",oh="_animate-show_thz3c_2",rh="_animate-hide_thz3c_2",ah="_backdrop_thz3c_2",ih="_content_thz3c_2",gt={container:sh,animateShow:oh,animateHide:rh,backdrop:ah,content:ih},pa=({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,h=!0)=>{h||(m.preventDefault(),m.stopPropagation());const p={},g=m.clientY>window.innerHeight/2,b=m.clientX>window.innerWidth/2;g?p.bottom=window.innerHeight-m.clientY:p.top=m.clientY,ca()?b?p.right=window.innerWidth-m.clientX:p.left=m.clientX:(p.right=36,p.left=36),r(p),i("in")},close:()=>{i("out")}}),[]),bs({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?.())},d=s.jsxs("div",{className:A(gt.container,a==="out"&&gt.animateHide,a==="in"&&gt.animateShow),onAnimationEnd:u,children:[s.jsx("div",{className:gt.backdrop,onClick:()=>i("out")}),s.jsx("div",{ref:c,style:o,className:A(gt.content,a==="out"&&gt.animateHide,a==="in"&&gt.animateShow),children:e})]});return oo.createPortal(d,document.body)};function Os(e,t,n){const o=e?.rows?.[t]?.[n],r=e?.columns?.[n];return{value:o,column:r}}const lh=({ref:e})=>{const{data:t}=l.useContext(Pe),{getColumnType:n}=l.useContext(ze),{setState:o}=l.useContext(ge);return{copyValue:(c,u)=>{const{value:d,column:m}=Os(t?.result,c,u);if(m){const h=wt(d,n(m.full));navigator.clipboard.writeText(h),Le.success("Copied!"),e.current?.close()}},showValue:(c,u)=>{const{value:d,column:m}=Os(t?.result,c,u);if(m){const h=wt(d,n(m.full));ia(h),e.current?.close()}},filterValue:(c,u)=>{const{value:d,column:m}=Os(t?.result,c,u),h=m?.full||"";if(h){let p;if(d==null)p={id:ot(),isEnabled:!0,isAdvanced:!0,column:h,value:"IS NULL"};else{const g=wt(d,n(h));p={id:ot(),isEnabled:!0,column:h,value:g,fn:m?.fn}}o(g=>({...g,filters:[...g.filters,p]})),Le.success(`Added new filter on column ${m?.alias}`),e.current?.close()}}}},ga=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})),ch=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})),uh="_section-name_1tdzv_2",dh="_item_1tdzv_2",xt={sectionName:uh,item:dh},xa=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"})),hh=({onClose:e,rowIndex:t,className:n})=>{const[o,r]=l.useState(""),{entities:a,dataSourceId:i,getEntityKey:c}=l.useContext(ze),{data:u}=l.useContext(Pe),d=l.useMemo(()=>u?.result.rows[t],[u,t]),m=l.useMemo(()=>o?a.filter(p=>p.includes(o)):a,[a,o]),h=p=>{if(!d)return;const g=c(p,d);vs({tableName:p,dataSourceId:i,entityId:g}),e?.()};return s.jsxs("div",{className:n,children:[s.jsx(On,{autoFocus:!0,className:Ke.filterInput,placeholder:"Filter",value:o,onChange:p=>r(p.target.value)}),s.jsx("div",{className:Ke.list,children:Be(m.length,0)?m.map(p=>s.jsx("button",{className:Ke.optionItem,onClick:()=>h(p),children:s.jsxs("span",{children:["📄 ",p]})},p)):s.jsx("p",{className:Ke.emptyText,children:"Empty"})})]})},mh=({ref:e,row:t,col:n,onClosed:o})=>{const r=lh({ref:e}),[a,i]=l.useState("cell"),{entities:c,dataSourceId:u,getEntityKeyByRowIndex:d}=l.useContext(ze),m=()=>r.copyValue(t,n),h=()=>r.showValue(t,n),p=()=>r.filterValue(t,n),g=()=>{if(c.length===1){const x=d(c[0],t);vs({tableName:c[0],dataSourceId:u,entityId:x}),e.current?.close()}else i("expand")},b=()=>{o?.(),i("cell")};return s.jsx(pa,{ref:e,onClosed:b,children:s.jsxs("div",{className:"w-full lg:w-sm",children:[a==="cell"&&s.jsxs(s.Fragment,{children:[s.jsx("p",{className:xt.sectionName,children:"Cell actions"}),s.jsxs("button",{className:xt.item,onClick:m,children:[s.jsx(ga,{width:14,height:14}),"Copy"]}),s.jsxs("button",{className:xt.item,onClick:h,children:[s.jsx(ch,{width:14,height:14}),"View"]}),s.jsxs("button",{className:xt.item,onClick:p,children:[s.jsx(tn,{width:14,height:14}),"Filter"]}),s.jsx("p",{className:xt.sectionName,children:"Row actions"}),s.jsxs("button",{className:xt.item,onClick:()=>i("drill"),children:[s.jsx(Ye,{width:14,height:14}),"Drill down"]}),c?.length>0&&s.jsxs("button",{className:xt.item,onClick:g,children:[s.jsx(xa,{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(Ye,{className:"rotate-180",width:16,height:16}),"Drill down"]}),s.jsx(fa,{rowIndex:t,onClose:()=>e.current?.close()})]}),a==="expand"&&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(Ye,{className:"rotate-180",width:16,height:16}),"Select entity"]}),s.jsx(hh,{rowIndex:t,onClose:()=>e.current?.close()})]})]})})},fh={DESC:"",ASC:"rotate-180"},ph=(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},gh=()=>{const{data:e}=l.useContext(Pe),{orderBy:t,updateOrderBy:n}=Dd(),{setFilters:o,filters:r}=po(),a=e?.result.columns||[],i=t[0],c=Be(e?.result.tables.length,1),u=(d,m)=>{Mn("Filter value","").then(h=>{h&&o(ph(r,{column:d,value:h,fn:m}))})};return s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("td",{children:"🥢"}),a.map(d=>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:d.table||"-"}),s.jsx("p",{className:"text-sm font-semibold truncate text-(--text-color-primary)",children:d.column})]}),s.jsxs("div",{className:L.headerActions,children:[s.jsx("button",{onClick:()=>n(d.alias),children:i?.column===d.alias?s.jsx(th,{className:fh[i.direction],width:16,height:16}):s.jsx(nh,{width:16,height:16})}),s.jsx("button",{onClick:()=>u(d.full,d.fn),children:s.jsx(tn,{width:16,height:16})})]})]},d.full))]})})};function xh({value:e}){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 t=wt(e);return s.jsx("span",{className:L.value,children:t})}const bh=l.memo(({row:e,isLastRow:t,index:n,offset:o})=>s.jsxs("tr",{className:A(L.tableRowCells,t&&"rounded-b-lg"),children:[s.jsx("td",{children:s.jsxs("button",{"data-row-action":n,className:L.rowIndexBtn,children:[s.jsx(Ye,{className:"pointer-events-none",width:16,height:16}),n+1+o]})}),e.map((r,a)=>s.jsx("td",{className:L.cell,"data-row":n,"data-col":a,children:s.jsx(xh,{value:r})},a))]})),vh=()=>{const{data:e,error:t,isLoading:n,isFetching:o}=l.useContext(Pe),{state:{page:r,size:a}}=l.useContext(ge),i=l.useRef(null),c=uo(t),u=da(),[d,m]=l.useState(void 0),[h,p]=l.useState(void 0),g=v=>{const f=v.target?.dataset?.rowAction;f!=null&&(m(parseInt(f)),u.open(v))},b=v=>{const y=v.target?.dataset,f=y?.row,w=y?.col;f!=null&&w!=null&&(m(parseInt(f)),p(parseInt(w)),i.current?.open(v),v.preventDefault(),v.stopPropagation())},x=r*a;return s.jsxs(s.Fragment,{children:[d!=null&&u.show&&s.jsx(eh,{handler:u,rowIndex:d}),s.jsx(mh,{ref:i,col:h,row:d,onClosed:()=>{m(void 0),p(void 0)}}),c&&s.jsx(fe,{variant:"danger",children:c}),n&&s.jsx("div",{className:L.tableLoading,children:"Loading data"}),e&&s.jsxs("table",{className:A(L.table,o&&L.semiTransparent),onClick:g,onContextMenu:b,children:[s.jsx(gh,{}),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((v,y)=>s.jsx(bh,{index:y,offset:x,row:v,isLastRow:y===e.result.rows.length-1},y))]})]})]})},ba=()=>{const{state:e,setState:t}=l.useContext(ge),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}},yh=()=>Z({mutationFn:async e=>{const{data:t}=await I.post("/saved-queries",e);return t.data},onSuccess:()=>{K.invalidateQueries({queryKey:["queries"]}),Jt(),Qr()}}),wh=()=>Z({mutationFn:async e=>I.delete("/saved-queries/"+e),onSuccess:()=>{Jt(),Qr()}}),Ch=()=>Z({mutationFn:async({id:e,payload:t})=>{const{data:n}=await I.patch("/saved-queries/"+e,t);return n.data},onSuccess:()=>{Jt(),ac()}}),[ys,go]=ye({filters:!1,joins:!1,columns:!1,groupBy:!1,aggregate:!1}),De=e=>go(t=>({...t,[e]:!0})),ws=e=>go(t=>({...t,[e]:!1})),as=e=>go(t=>({...t,[e]:!t[e]})),Kt=Math.min,Ct=Math.max,is=Math.round,Yn=Math.floor,$e=e=>({x:e,y:e}),jh={left:"right",right:"left",bottom:"top",top:"bottom"},Nh={start:"end",end:"start"};function Ks(e,t,n){return Ct(e,Kt(t,n))}function In(e,t){return typeof e=="function"?e(t):e}function Nt(e){return e.split("-")[0]}function Dn(e){return e.split("-")[1]}function va(e){return e==="x"?"y":"x"}function xo(e){return e==="y"?"height":"width"}const kh=new Set(["top","bottom"]);function nt(e){return kh.has(Nt(e))?"y":"x"}function bo(e){return va(nt(e))}function _h(e,t,n){n===void 0&&(n=!1);const o=Dn(e),r=bo(e),a=xo(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 Sh(e){const t=ls(e);return[Qs(e),t,Qs(t)]}function Qs(e){return e.replace(/start|end/g,t=>Nh[t])}const Ko=["left","right"],Qo=["right","left"],Eh=["top","bottom"],Rh=["bottom","top"];function Lh(e,t,n){switch(e){case"top":case"bottom":return n?t?Qo:Ko:t?Ko:Qo;case"left":case"right":return t?Eh:Rh;default:return[]}}function Th(e,t,n,o){const r=Dn(e);let a=Lh(Nt(e),n==="start",o);return r&&(a=a.map(i=>i+"-"+r),t&&(a=a.concat(a.map(Qs)))),a}function ls(e){return e.replace(/left|right|bottom|top/g,t=>jh[t])}function Ah(e){return{top:0,right:0,bottom:0,left:0,...e}}function ya(e){return typeof e!="number"?Ah(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 Go(e,t,n){let{reference:o,floating:r}=e;const a=nt(t),i=bo(t),c=xo(i),u=Nt(t),d=a==="y",m=o.x+o.width/2-r.width/2,h=o.y+o.height/2-r.height/2,p=o[c]/2-r[c]/2;let g;switch(u){case"top":g={x:m,y:o.y-r.height};break;case"bottom":g={x:m,y:o.y+o.height};break;case"right":g={x:o.x+o.width,y:h};break;case"left":g={x:o.x-r.width,y:h};break;default:g={x:o.x,y:o.y}}switch(Dn(t)){case"start":g[i]-=p*(n&&d?-1:1);break;case"end":g[i]+=p*(n&&d?-1:1);break}return g}const Ph=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 d=await i.getElementRects({reference:e,floating:t,strategy:r}),{x:m,y:h}=Go(d,o,u),p=o,g={},b=0;for(let x=0;x<c.length;x++){const{name:v,fn:y}=c[x],{x:f,y:w,data:C,reset:j}=await y({x:m,y:h,initialPlacement:o,placement:p,strategy:r,middlewareData:g,rects:d,platform:i,elements:{reference:e,floating:t}});m=f??m,h=w??h,g={...g,[v]:{...g[v],...C}},j&&b<=50&&(b++,typeof j=="object"&&(j.placement&&(p=j.placement),j.rects&&(d=j.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:r}):j.rects),{x:m,y:h}=Go(d,p,u)),x=-1)}return{x:m,y:h,placement:p,strategy:r,middlewareData:g}};async function wa(e,t){var n;t===void 0&&(t={});const{x:o,y:r,platform:a,rects:i,elements:c,strategy:u}=e,{boundary:d="clippingAncestors",rootBoundary:m="viewport",elementContext:h="floating",altBoundary:p=!1,padding:g=0}=In(t,e),b=ya(g),v=c[p?h==="floating"?"reference":"floating":h],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:d,rootBoundary:m,strategy:u})),f=h==="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},j=cs(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:f,offsetParent:w,strategy:u}):f);return{top:(y.top-j.top+b.top)/C.y,bottom:(j.bottom-y.bottom+b.bottom)/C.y,left:(y.left-j.left+b.left)/C.x,right:(j.right-y.right+b.right)/C.x}}const Oh=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:d,padding:m=0}=In(e,t)||{};if(d==null)return{};const h=ya(m),p={x:n,y:o},g=bo(r),b=xo(g),x=await i.getDimensions(d),v=g==="y",y=v?"top":"left",f=v?"bottom":"right",w=v?"clientHeight":"clientWidth",C=a.reference[b]+a.reference[g]-p[g]-a.floating[b],j=p[g]-a.reference[g],_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(d));let S=_?_[w]:0;(!S||!await(i.isElement==null?void 0:i.isElement(_)))&&(S=c.floating[w]||a.floating[b]);const k=C/2-j/2,P=S/2-x[b]/2-1,F=Kt(h[y],P),se=Kt(h[f],P),Ce=F,Oe=S-x[b]-se,q=S/2-x[b]/2+k,ce=Ks(Ce,q,Oe),oe=!u.arrow&&Dn(r)!=null&&q!==ce&&a.reference[b]/2-(q<Ce?F:se)-x[b]/2<0,Y=oe?q<Ce?q-Ce:q-Oe:0;return{[g]:p[g]+Y,data:{[g]:ce,centerOffset:q-ce-Y,...oe&&{alignmentOffset:Y}},reset:oe}}}),Mh=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:d}=t,{mainAxis:m=!0,crossAxis:h=!0,fallbackPlacements:p,fallbackStrategy:g="bestFit",fallbackAxisSideDirection:b="none",flipAlignment:x=!0,...v}=In(e,t);if((n=a.arrow)!=null&&n.alignmentOffset)return{};const y=Nt(r),f=nt(c),w=Nt(c)===c,C=await(u.isRTL==null?void 0:u.isRTL(d.floating)),j=p||(w||!x?[ls(c)]:Sh(c)),_=b!=="none";!p&&_&&j.push(...Th(c,x,b,C));const S=[c,...j],k=await wa(t,v),P=[];let F=((o=a.flip)==null?void 0:o.overflows)||[];if(m&&P.push(k[y]),h){const q=_h(r,i,C);P.push(k[q[0]],k[q[1]])}if(F=[...F,{placement:r,overflows:P}],!P.every(q=>q<=0)){var se,Ce;const q=(((se=a.flip)==null?void 0:se.index)||0)+1,ce=S[q];if(ce&&(!(h==="alignment"?f!==nt(ce):!1)||F.every(U=>nt(U.placement)===f?U.overflows[0]>0:!0)))return{data:{index:q,overflows:F},reset:{placement:ce}};let oe=(Ce=F.filter(Y=>Y.overflows[0]<=0).sort((Y,U)=>Y.overflows[1]-U.overflows[1])[0])==null?void 0:Ce.placement;if(!oe)switch(g){case"bestFit":{var Oe;const Y=(Oe=F.filter(U=>{if(_){const re=nt(U.placement);return re===f||re==="y"}return!0}).map(U=>[U.placement,U.overflows.filter(re=>re>0).reduce((re,He)=>re+He,0)]).sort((U,re)=>U[1]-re[1])[0])==null?void 0:Oe[0];Y&&(oe=Y);break}case"initialPlacement":oe=c;break}if(r!==oe)return{reset:{placement:oe}}}return{}}}},Ih=new Set(["left","top"]);async function Dh(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=Dn(n),u=nt(n)==="y",d=Ih.has(i)?-1:1,m=a&&u?-1:1,h=In(t,e);let{mainAxis:p,crossAxis:g,alignmentAxis:b}=typeof h=="number"?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};return c&&typeof b=="number"&&(g=c==="end"?b*-1:b),u?{x:g*m,y:p*d}:{x:p*d,y:g*m}}const $h=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 Dh(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}}}}},Fh=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}=In(e,t),d={x:n,y:o},m=await wa(t,u),h=nt(Nt(r)),p=va(h);let g=d[p],b=d[h];if(a){const v=p==="y"?"top":"left",y=p==="y"?"bottom":"right",f=g+m[v],w=g-m[y];g=Ks(f,g,w)}if(i){const v=h==="y"?"top":"left",y=h==="y"?"bottom":"right",f=b+m[v],w=b-m[y];b=Ks(f,b,w)}const x=c.fn({...t,[p]:g,[h]:b});return{...x,data:{x:x.x-n,y:x.y-o,enabled:{[p]:a,[h]:i}}}}}};function Cs(){return typeof window<"u"}function nn(e){return Ca(e)?(e.nodeName||"").toLowerCase():"#document"}function be(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Ue(e){var t;return(t=(Ca(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Ca(e){return Cs()?e instanceof Node||e instanceof be(e).Node:!1}function Te(e){return Cs()?e instanceof Element||e instanceof be(e).Element:!1}function qe(e){return Cs()?e instanceof HTMLElement||e instanceof be(e).HTMLElement:!1}function Yo(e){return!Cs()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof be(e).ShadowRoot}const Bh=new Set(["inline","contents"]);function $n(e){const{overflow:t,overflowX:n,overflowY:o,display:r}=Ae(e);return/auto|scroll|overlay|hidden|clip/.test(t+o+n)&&!Bh.has(r)}const qh=new Set(["table","td","th"]);function Wh(e){return qh.has(nn(e))}const zh=[":popover-open",":modal"];function js(e){return zh.some(t=>{try{return e.matches(t)}catch{return!1}})}const Uh=["transform","translate","scale","rotate","perspective"],Hh=["transform","translate","scale","rotate","perspective","filter"],Vh=["paint","layout","strict","content"];function vo(e){const t=yo(),n=Te(e)?Ae(e):e;return Uh.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)||Hh.some(o=>(n.willChange||"").includes(o))||Vh.some(o=>(n.contain||"").includes(o))}function Kh(e){let t=rt(e);for(;qe(t)&&!Qt(t);){if(vo(t))return t;if(js(t))return null;t=rt(t)}return null}function yo(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Qh=new Set(["html","body","#document"]);function Qt(e){return Qh.has(nn(e))}function Ae(e){return be(e).getComputedStyle(e)}function Ns(e){return Te(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function rt(e){if(nn(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Yo(e)&&e.host||Ue(e);return Yo(t)?t.host:t}function ja(e){const t=rt(e);return Qt(t)?e.ownerDocument?e.ownerDocument.body:e.body:qe(t)&&$n(t)?t:ja(t)}function kn(e,t,n){var o;t===void 0&&(t=[]),n===void 0&&(n=!0);const r=ja(e),a=r===((o=e.ownerDocument)==null?void 0:o.body),i=be(r);if(a){const c=Gs(i);return t.concat(i,i.visualViewport||[],$n(r)?r:[],c&&n?kn(c):[])}return t.concat(r,kn(r,[],n))}function Gs(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Na(e){const t=Ae(e);let n=parseFloat(t.width)||0,o=parseFloat(t.height)||0;const r=qe(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 wo(e){return Te(e)?e:e.contextElement}function Ut(e){const t=wo(e);if(!qe(t))return $e(1);const n=t.getBoundingClientRect(),{width:o,height:r,$:a}=Na(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 Gh=$e(0);function ka(e){const t=be(e);return!yo()||!t.visualViewport?Gh:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Yh(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==be(e)?!1:t}function kt(e,t,n,o){t===void 0&&(t=!1),n===void 0&&(n=!1);const r=e.getBoundingClientRect(),a=wo(e);let i=$e(1);t&&(o?Te(o)&&(i=Ut(o)):i=Ut(e));const c=Yh(a,n,o)?ka(a):$e(0);let u=(r.left+c.x)/i.x,d=(r.top+c.y)/i.y,m=r.width/i.x,h=r.height/i.y;if(a){const p=be(a),g=o&&Te(o)?be(o):o;let b=p,x=Gs(b);for(;x&&o&&g!==b;){const v=Ut(x),y=x.getBoundingClientRect(),f=Ae(x),w=y.left+(x.clientLeft+parseFloat(f.paddingLeft))*v.x,C=y.top+(x.clientTop+parseFloat(f.paddingTop))*v.y;u*=v.x,d*=v.y,m*=v.x,h*=v.y,u+=w,d+=C,b=be(x),x=Gs(b)}}return cs({width:m,height:h,x:u,y:d})}function ks(e,t){const n=Ns(e).scrollLeft;return t?t.left+n:kt(Ue(e)).left+n}function _a(e,t){const n=e.getBoundingClientRect(),o=n.left+t.scrollLeft-ks(e,n),r=n.top+t.scrollTop;return{x:o,y:r}}function Jh(e){let{elements:t,rect:n,offsetParent:o,strategy:r}=e;const a=r==="fixed",i=Ue(o),c=t?js(t.floating):!1;if(o===i||c&&a)return n;let u={scrollLeft:0,scrollTop:0},d=$e(1);const m=$e(0),h=qe(o);if((h||!h&&!a)&&((nn(o)!=="body"||$n(i))&&(u=Ns(o)),qe(o))){const g=kt(o);d=Ut(o),m.x=g.x+o.clientLeft,m.y=g.y+o.clientTop}const p=i&&!h&&!a?_a(i,u):$e(0);return{width:n.width*d.x,height:n.height*d.y,x:n.x*d.x-u.scrollLeft*d.x+m.x+p.x,y:n.y*d.y-u.scrollTop*d.y+m.y+p.y}}function Xh(e){return Array.from(e.getClientRects())}function Zh(e){const t=Ue(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+ks(e);const c=-n.scrollTop;return Ae(o).direction==="rtl"&&(i+=Ct(t.clientWidth,o.clientWidth)-r),{width:r,height:a,x:i,y:c}}const Jo=25;function em(e,t){const n=be(e),o=Ue(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=yo();(!m||m&&t==="fixed")&&(c=r.offsetLeft,u=r.offsetTop)}const d=ks(o);if(d<=0){const m=o.ownerDocument,h=m.body,p=getComputedStyle(h),g=m.compatMode==="CSS1Compat"&&parseFloat(p.marginLeft)+parseFloat(p.marginRight)||0,b=Math.abs(o.clientWidth-h.clientWidth-g);b<=Jo&&(a-=b)}else d<=Jo&&(a+=d);return{width:a,height:i,x:c,y:u}}const tm=new Set(["absolute","fixed"]);function nm(e,t){const n=kt(e,!0,t==="fixed"),o=n.top+e.clientTop,r=n.left+e.clientLeft,a=qe(e)?Ut(e):$e(1),i=e.clientWidth*a.x,c=e.clientHeight*a.y,u=r*a.x,d=o*a.y;return{width:i,height:c,x:u,y:d}}function Xo(e,t,n){let o;if(t==="viewport")o=em(e,n);else if(t==="document")o=Zh(Ue(e));else if(Te(t))o=nm(t,n);else{const r=ka(e);o={x:t.x-r.x,y:t.y-r.y,width:t.width,height:t.height}}return cs(o)}function Sa(e,t){const n=rt(e);return n===t||!Te(n)||Qt(n)?!1:Ae(n).position==="fixed"||Sa(n,t)}function sm(e,t){const n=t.get(e);if(n)return n;let o=kn(e,[],!1).filter(c=>Te(c)&&nn(c)!=="body"),r=null;const a=Ae(e).position==="fixed";let i=a?rt(e):e;for(;Te(i)&&!Qt(i);){const c=Ae(i),u=vo(i);!u&&c.position==="fixed"&&(r=null),(a?!u&&!r:!u&&c.position==="static"&&!!r&&tm.has(r.position)||$n(i)&&!u&&Sa(e,i))?o=o.filter(m=>m!==i):r=c,i=rt(i)}return t.set(e,o),o}function om(e){let{element:t,boundary:n,rootBoundary:o,strategy:r}=e;const i=[...n==="clippingAncestors"?js(t)?[]:sm(t,this._c):[].concat(n),o],c=i[0],u=i.reduce((d,m)=>{const h=Xo(t,m,r);return d.top=Ct(h.top,d.top),d.right=Kt(h.right,d.right),d.bottom=Kt(h.bottom,d.bottom),d.left=Ct(h.left,d.left),d},Xo(t,c,r));return{width:u.right-u.left,height:u.bottom-u.top,x:u.left,y:u.top}}function rm(e){const{width:t,height:n}=Na(e);return{width:t,height:n}}function am(e,t,n){const o=qe(t),r=Ue(t),a=n==="fixed",i=kt(e,!0,a,t);let c={scrollLeft:0,scrollTop:0};const u=$e(0);function d(){u.x=ks(r)}if(o||!o&&!a)if((nn(t)!=="body"||$n(r))&&(c=Ns(t)),o){const g=kt(t,!0,a,t);u.x=g.x+t.clientLeft,u.y=g.y+t.clientTop}else r&&d();a&&!o&&r&&d();const m=r&&!o&&!a?_a(r,c):$e(0),h=i.left+c.scrollLeft-u.x-m.x,p=i.top+c.scrollTop-u.y-m.y;return{x:h,y:p,width:i.width,height:i.height}}function Ms(e){return Ae(e).position==="static"}function Zo(e,t){if(!qe(e)||Ae(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Ue(e)===n&&(n=n.ownerDocument.body),n}function Ea(e,t){const n=be(e);if(js(e))return n;if(!qe(e)){let r=rt(e);for(;r&&!Qt(r);){if(Te(r)&&!Ms(r))return r;r=rt(r)}return n}let o=Zo(e,t);for(;o&&Wh(o)&&Ms(o);)o=Zo(o,t);return o&&Qt(o)&&Ms(o)&&!vo(o)?n:o||Kh(e)||n}const im=async function(e){const t=this.getOffsetParent||Ea,n=this.getDimensions,o=await n(e.floating);return{reference:am(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}};function lm(e){return Ae(e).direction==="rtl"}const cm={convertOffsetParentRelativeRectToViewportRelativeRect:Jh,getDocumentElement:Ue,getClippingRect:om,getOffsetParent:Ea,getElementRects:im,getClientRects:Xh,getDimensions:rm,getScale:Ut,isElement:Te,isRTL:lm};function Ra(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function um(e,t){let n=null,o;const r=Ue(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 d=e.getBoundingClientRect(),{left:m,top:h,width:p,height:g}=d;if(c||t(),!p||!g)return;const b=Yn(h),x=Yn(r.clientWidth-(m+p)),v=Yn(r.clientHeight-(h+g)),y=Yn(m),w={rootMargin:-b+"px "+-x+"px "+-v+"px "+-y+"px",threshold:Ct(0,Kt(1,u))||1};let C=!0;function j(_){const S=_[0].intersectionRatio;if(S!==u){if(!C)return i();S?i(!1,S):o=setTimeout(()=>{i(!1,1e-7)},1e3)}S===1&&!Ra(d,e.getBoundingClientRect())&&i(),C=!1}try{n=new IntersectionObserver(j,{...w,root:r.ownerDocument})}catch{n=new IntersectionObserver(j,w)}n.observe(e)}return i(!0),a}function dm(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,d=wo(e),m=r||a?[...d?kn(d):[],...kn(t)]:[];m.forEach(y=>{r&&y.addEventListener("scroll",n,{passive:!0}),a&&y.addEventListener("resize",n)});const h=d&&c?um(d,n):null;let p=-1,g=null;i&&(g=new ResizeObserver(y=>{let[f]=y;f&&f.target===d&&g&&(g.unobserve(t),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var w;(w=g)==null||w.observe(t)})),n()}),d&&!u&&g.observe(d),g.observe(t));let b,x=u?kt(e):null;u&&v();function v(){const y=kt(e);x&&!Ra(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)}),h?.(),(y=g)==null||y.disconnect(),g=null,u&&cancelAnimationFrame(b)}}const hm=$h,mm=Fh,fm=Mh,pm=Oh,er=(e,t,n)=>{const o=new Map,r={platform:cm,...n},a={...r.platform,_c:o};return Ph(e,t,{...r,platform:a})};var Is={exports:{}};var tr;function gm(){return tr||(tr=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 xm=gm();const Ys=li(xm);var nr={};const bm="react-tooltip-core-styles",vm="react-tooltip-base-styles",sr={core:!1,base:!1};function or({css:e,id:t=vm,type:n="base",ref:o}){var r,a;if(!e||typeof document>"u"||sr[n]||n==="core"&&typeof process<"u"&&(!((r=process==null?void 0:nr)===null||r===void 0)&&r.REACT_TOOLTIP_DISABLE_CORE_STYLES)||n!=="base"&&typeof process<"u"&&(!((a=process==null?void 0:nr)===null||a===void 0)&&a.REACT_TOOLTIP_DISABLE_BASE_STYLES))return;n==="core"&&(t=bm),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)),sr[n]=!0}const rr=async({elementReference:e=null,tooltipReference:t=null,tooltipArrowReference:n=null,place:o="top",offset:r=10,strategy:a="absolute",middlewares:i=[hm(Number(r)),fm({fallbackAxisSideDirection:"start"}),mm({padding:5})],border:c,arrowSize:u=8})=>{if(!e)return{tooltipStyles:{},tooltipArrowStyles:{},place:o};if(t===null)return{tooltipStyles:{},tooltipArrowStyles:{},place:o};const d=i;return n?(d.push(pm({element:n,padding:5})),er(e,t,{placement:o,strategy:a,middleware:d}).then((({x:m,y:h,placement:p,middlewareData:g})=>{var b,x;const v={left:`${m}px`,top:`${h}px`,border:c},{x:y,y:f}=(b=g.arrow)!==null&&b!==void 0?b:{x:0,y:0},w=(x={top:"bottom",right:"left",bottom:"top",left:"right"}[p.split("-")[0]])!==null&&x!==void 0?x:"bottom",C=c&&{borderBottom:c,borderRight:c};let j=0;if(c){const _=`${c}`.match(/(\d+)px/);j=_?.[1]?Number(_[1]):1}return{tooltipStyles:v,tooltipArrowStyles:{left:y!=null?`${y}px`:"",top:f!=null?`${f}px`:"",right:"",bottom:"",...C,[w]:`-${u/2+j}px`},place:p}}))):er(e,t,{placement:"bottom",strategy:a,middleware:d}).then((({x:m,y:h,placement:p})=>({tooltipStyles:{left:`${m}px`,top:`${h}px`},tooltipArrowStyles:{},place:p})))},ar=(e,t)=>!("CSS"in window&&"supports"in window.CSS)||window.CSS.supports(e,t),ir=(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},lr=e=>e!==null&&!Array.isArray(e)&&typeof e=="object",Js=(e,t)=>{if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every(((r,a)=>Js(r,t[a])));if(Array.isArray(e)!==Array.isArray(t))return!1;if(!lr(e)||!lr(t))return e===t;const n=Object.keys(e),o=Object.keys(t);return n.length===o.length&&n.every((r=>Js(e[r],t[r])))},ym=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"}))},cr=e=>{if(!e)return null;let t=e.parentElement;for(;t;){if(ym(t))return t;t=t.parentElement}return document.scrollingElement||document.documentElement},wm=typeof window<"u"?l.useLayoutEffect:l.useEffect,Ne=e=>{e.current&&(clearTimeout(e.current),e.current=null)},Cm="DEFAULT_TOOLTIP_ID",jm={anchorRefs:new Set,activeAnchor:{current:null},attach:()=>{},detach:()=>{},setActiveAnchor:()=>{}},Nm=l.createContext({getTooltipData:()=>jm});function La(e=Cm){return l.useContext(Nm).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 km=({forwardRef:e,id:t,className:n,classNameArrow:o,variant:r="dark",anchorId:a,anchorSelect:i,place:c="top",offset:u=10,events:d=["hover"],openOnClick:m=!1,positionStrategy:h="absolute",middlewares:p,wrapper:g,delayShow:b=0,delayHide:x=0,float:v=!1,hidden:y=!1,noArrow:f=!1,clickable:w=!1,closeOnEsc:C=!1,closeOnScroll:j=!1,closeOnResize:_=!1,openEvents:S,closeEvents:k,globalCloseEvents:P,imperativeModeOnly:F,style:se,position:Ce,afterShow:Oe,afterHide:q,disableTooltip:ce,content:oe,contentWrapperRef:Y,isOpen:U,defaultIsOpen:re=!1,setIsOpen:He,previousActiveAnchor:sn,activeAnchor:W,setActiveAnchor:_t,border:Fn,opacity:Bn,arrowColor:qn,arrowSize:St=8,role:_s="tooltip"})=>{var ct;const ue=l.useRef(null),Et=l.useRef(null),Ee=l.useRef(null),ut=l.useRef(null),Rt=l.useRef(null),[dt,Wn]=l.useState({tooltipStyles:{},tooltipArrowStyles:{},place:c}),[de,on]=l.useState(!1),[Lt,Xe]=l.useState(!1),[V,Tt]=l.useState(null),zn=l.useRef(!1),At=l.useRef(null),{anchorRefs:Un,setActiveAnchor:rn}=La(t),an=l.useRef(!1),[Ze,ln]=l.useState([]),ht=l.useRef(!1),Pt=m||d.includes("click"),Hn=Pt||S?.click||S?.dblclick||S?.mousedown,cn=S?{...S}:{mouseover:!0,focus:!0,mouseenter:!1,click:!1,dblclick:!1,mousedown:!1};!S&&Pt&&Object.assign(cn,{mouseenter:!1,focus:!1,mouseover:!1,click:!0});const mt=k?{...k}:{mouseout:!0,blur:!0,mouseleave:!1,click:!1,dblclick:!1,mouseup:!1};!k&&Pt&&Object.assign(mt,{mouseleave:!1,blur:!1,mouseout:!1});const te=P?{...P}:{escape:C||!1,scroll:j||!1,resize:_||!1,clickOutsideAnchor:Hn||!1};F&&(Object.assign(cn,{mouseover:!1,focus:!1,mouseenter:!1,click:!1,dblclick:!1,mousedown:!1}),Object.assign(mt,{mouseout:!1,blur:!1,mouseleave:!1,click:!1,dblclick:!1,mouseup:!1}),Object.assign(te,{escape:!1,scroll:!1,resize:!1,clickOutsideAnchor:!1})),wm((()=>(ht.current=!0,()=>{ht.current=!1})),[]);const he=N=>{ht.current&&(N&&Xe(!0),setTimeout((()=>{ht.current&&(He?.(N),U===void 0&&on(N))}),10))};l.useEffect((()=>{if(t){if(de){R(sn);const E=N(W),B=[...new Set([...E,t])].filter(Boolean).join(" ");W?.setAttribute("aria-describedby",B)}else R(W);return()=>{R(W),R(sn)}}function N(E){var B;return((B=E?.getAttribute("aria-describedby"))===null||B===void 0?void 0:B.split(" "))||[]}function R(E){const B=N(E).filter((ee=>ee!==t));B.length?E?.setAttribute("aria-describedby",B.join(" ")):E?.removeAttribute("aria-describedby")}}),[W,de,t,sn]),l.useEffect((()=>{if(U===void 0)return()=>null;U&&Xe(!0);const N=setTimeout((()=>{on(U)}),10);return()=>{clearTimeout(N)}}),[U]),l.useEffect((()=>{if(de!==zn.current)if(Ne(Rt),zn.current=de,de)Oe?.();else{const N=(R=>{const E=R.match(/^([\d.]+)(ms|s)$/);if(!E)return 0;const[,B,ee]=E;return Number(B)*(ee==="ms"?1:1e3)})(getComputedStyle(document.body).getPropertyValue("--rt-transition-show-delay"));Rt.current=setTimeout((()=>{Xe(!1),Tt(null),q?.()}),N+25)}}),[de]);const un=N=>{Wn((R=>Js(R,N)?R:N))},dn=(N=b)=>{Ne(Ee),Lt?he(!0):Ee.current=setTimeout((()=>{he(!0)}),N)},Ot=(N=x)=>{Ne(ut),ut.current=setTimeout((()=>{an.current||he(!1)}),N)},hn=N=>{var R;if(!N)return;const E=(R=N.currentTarget)!==null&&R!==void 0?R:N.target;if(!E?.isConnected)return _t(null),void rn({current:null});b?dn():he(!0),_t(E),rn({current:E}),Ne(ut)},Mt=()=>{w?Ot(x||100):x?Ot():he(!1),Ne(Ee)},It=({x:N,y:R})=>{var E;const B={getBoundingClientRect:()=>({x:N,y:R,width:0,height:0,top:R,left:N,right:N,bottom:R})};rr({place:(E=V?.place)!==null&&E!==void 0?E:c,offset:u,elementReference:B,tooltipReference:ue.current,tooltipArrowReference:Et.current,strategy:h,middlewares:p,border:Fn,arrowSize:St}).then((ee=>{un(ee)}))},Dt=N=>{if(!N)return;const R=N,E={x:R.clientX,y:R.clientY};It(E),At.current=E},mn=N=>{var R;if(!de)return;const E=N.target;E.isConnected&&(!((R=ue.current)===null||R===void 0)&&R.contains(E)||[document.querySelector(`[id='${a}']`),...Ze].some((B=>B?.contains(E)))||(he(!1),Ne(Ee)))},Vn=ir(hn,50),Q=ir(Mt,50),ae=N=>{Q.cancel(),Vn(N)},T=()=>{Vn.cancel(),Q()},O=l.useCallback((()=>{var N,R;const E=(N=V?.position)!==null&&N!==void 0?N:Ce;E?It(E):v?At.current&&It(At.current):W?.isConnected&&rr({place:(R=V?.place)!==null&&R!==void 0?R:c,offset:u,elementReference:W,tooltipReference:ue.current,tooltipArrowReference:Et.current,strategy:h,middlewares:p,border:Fn,arrowSize:St}).then((B=>{ht.current&&un(B)}))}),[de,W,oe,se,c,V?.place,u,h,Ce,V?.position,v,St]);l.useEffect((()=>{var N,R;const E=new Set(Un);Ze.forEach(($=>{ce?.($)||E.add({current:$})}));const B=document.querySelector(`[id='${a}']`);B&&!ce?.(B)&&E.add({current:B});const ee=()=>{he(!1)},Me=cr(W),Ie=cr(ue.current);te.scroll&&(window.addEventListener("scroll",ee),Me?.addEventListener("scroll",ee),Ie?.addEventListener("scroll",ee));let ie=null;te.resize?window.addEventListener("resize",ee):W&&ue.current&&(ie=dm(W,ue.current,O,{ancestorResize:!0,elementResize:!0,layoutShift:!0}));const je=$=>{$.key==="Escape"&&he(!1)};te.escape&&window.addEventListener("keydown",je),te.clickOutsideAnchor&&window.addEventListener("click",mn);const z=[],$t=$=>!!($?.target&&W?.contains($.target)),Ga=$=>{de&&$t($)||hn($)},Ya=$=>{de&&$t($)&&Mt()},ko=["mouseover","mouseout","mouseenter","mouseleave","focus","blur"],_o=["click","dblclick","mousedown","mouseup"];Object.entries(cn).forEach((([$,Ve])=>{Ve&&(ko.includes($)?z.push({event:$,listener:ae}):_o.includes($)&&z.push({event:$,listener:Ga}))})),Object.entries(mt).forEach((([$,Ve])=>{Ve&&(ko.includes($)?z.push({event:$,listener:T}):_o.includes($)&&z.push({event:$,listener:Ya}))})),v&&z.push({event:"pointermove",listener:Dt});const So=()=>{an.current=!0},Eo=()=>{an.current=!1,Mt()},Ro=w&&(mt.mouseout||mt.mouseleave);return Ro&&((N=ue.current)===null||N===void 0||N.addEventListener("mouseover",So),(R=ue.current)===null||R===void 0||R.addEventListener("mouseout",Eo)),z.forEach((({event:$,listener:Ve})=>{E.forEach((Ss=>{var fn;(fn=Ss.current)===null||fn===void 0||fn.addEventListener($,Ve)}))})),()=>{var $,Ve;te.scroll&&(window.removeEventListener("scroll",ee),Me?.removeEventListener("scroll",ee),Ie?.removeEventListener("scroll",ee)),te.resize?window.removeEventListener("resize",ee):ie?.(),te.clickOutsideAnchor&&window.removeEventListener("click",mn),te.escape&&window.removeEventListener("keydown",je),Ro&&(($=ue.current)===null||$===void 0||$.removeEventListener("mouseover",So),(Ve=ue.current)===null||Ve===void 0||Ve.removeEventListener("mouseout",Eo)),z.forEach((({event:Ss,listener:fn})=>{E.forEach((Ja=>{var Es;(Es=Ja.current)===null||Es===void 0||Es.removeEventListener(Ss,fn)}))}))}}),[W,O,Lt,Un,Ze,S,k,P,Pt,b,x]),l.useEffect((()=>{var N,R;let E=(R=(N=V?.anchorSelect)!==null&&N!==void 0?N:i)!==null&&R!==void 0?R:"";!E&&t&&(E=`[data-tooltip-id='${t.replace(/'/g,"\\'")}']`);const B=new MutationObserver((ee=>{const Me=[],Ie=[];ee.forEach((ie=>{if(ie.type==="attributes"&&ie.attributeName==="data-tooltip-id"&&(ie.target.getAttribute("data-tooltip-id")===t?Me.push(ie.target):ie.oldValue===t&&Ie.push(ie.target)),ie.type==="childList"){if(W){const je=[...ie.removedNodes].filter((z=>z.nodeType===1));if(E)try{Ie.push(...je.filter((z=>z.matches(E)))),Ie.push(...je.flatMap((z=>[...z.querySelectorAll(E)])))}catch{}je.some((z=>{var $t;return!!(!(($t=z?.contains)===null||$t===void 0)&&$t.call(z,W))&&(Xe(!1),he(!1),_t(null),Ne(Ee),Ne(ut),!0)}))}if(E)try{const je=[...ie.addedNodes].filter((z=>z.nodeType===1));Me.push(...je.filter((z=>z.matches(E)))),Me.push(...je.flatMap((z=>[...z.querySelectorAll(E)])))}catch{}}})),(Me.length||Ie.length)&&ln((ie=>[...ie.filter((je=>!Ie.includes(je))),...Me]))}));return B.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-tooltip-id"],attributeOldValue:!0}),()=>{B.disconnect()}}),[t,i,V?.anchorSelect,W]),l.useEffect((()=>{O()}),[O]),l.useEffect((()=>{if(!Y?.current)return()=>null;const N=new ResizeObserver((()=>{setTimeout((()=>O()))}));return N.observe(Y.current),()=>{N.disconnect()}}),[oe,Y?.current]),l.useEffect((()=>{var N;const R=document.querySelector(`[id='${a}']`),E=[...Ze,R];W&&E.includes(W)||_t((N=Ze[0])!==null&&N!==void 0?N:R)}),[a,Ze,W]),l.useEffect((()=>(re&&he(!0),()=>{Ne(Ee),Ne(ut)})),[]),l.useEffect((()=>{var N;let R=(N=V?.anchorSelect)!==null&&N!==void 0?N:i;if(!R&&t&&(R=`[data-tooltip-id='${t.replace(/'/g,"\\'")}']`),R)try{const E=Array.from(document.querySelectorAll(R));ln(E)}catch{ln([])}}),[t,i,V?.anchorSelect]),l.useEffect((()=>{Ee.current&&(Ne(Ee),dn(b))}),[b]);const xe=(ct=V?.content)!==null&&ct!==void 0?ct:oe,ft=de&&Object.keys(dt.tooltipStyles).length>0;return l.useImperativeHandle(e,(()=>({open:N=>{if(N?.anchorSelect)try{document.querySelector(N.anchorSelect)}catch{return void console.warn(`[react-tooltip] "${N.anchorSelect}" is not a valid CSS selector`)}Tt(N??null),N?.delay?dn(N.delay):he(!0)},close:N=>{N?.delay?Ot(N.delay):he(!1)},activeAnchor:W,place:dt.place,isOpen:!!(Lt&&!y&&xe&&ft)}))),Lt&&!y&&xe?et.createElement(g,{id:t,role:_s,className:Ys("react-tooltip",qt.tooltip,Ds.tooltip,Ds[r],n,`react-tooltip__place-${dt.place}`,qt[ft?"show":"closing"],ft?"react-tooltip__show":"react-tooltip__closing",h==="fixed"&&qt.fixed,w&&qt.clickable),onTransitionEnd:N=>{Ne(Rt),de||N.propertyName!=="opacity"||(Xe(!1),Tt(null),q?.())},style:{...se,...dt.tooltipStyles,opacity:Bn!==void 0&&ft?Bn:void 0},ref:ue},xe,et.createElement(g,{className:Ys("react-tooltip-arrow",qt.arrow,Ds.arrow,o,f&&qt.noArrow),style:{...dt.tooltipArrowStyles,background:qn?`linear-gradient(to right bottom, transparent 50%, ${qn} 50%)`:void 0,"--rt-arrow-size":`${St}px`},ref:Et})):null},_m=({content:e})=>et.createElement("span",{dangerouslySetInnerHTML:{__html:e}}),us=et.forwardRef((({id:e,anchorId:t,anchorSelect:n,content:o,html:r,render:a,className:i,classNameArrow:c,variant:u="dark",place:d="top",offset:m=10,wrapper:h="div",children:p=null,events:g=["hover"],openOnClick:b=!1,positionStrategy:x="absolute",middlewares:v,delayShow:y=0,delayHide:f=0,float:w=!1,hidden:C=!1,noArrow:j=!1,clickable:_=!1,closeOnEsc:S=!1,closeOnScroll:k=!1,closeOnResize:P=!1,openEvents:F,closeEvents:se,globalCloseEvents:Ce,imperativeModeOnly:Oe=!1,style:q,position:ce,isOpen:oe,defaultIsOpen:Y=!1,disableStyleInjection:U=!1,border:re,opacity:He,arrowColor:sn,arrowSize:W,setIsOpen:_t,afterShow:Fn,afterHide:Bn,disableTooltip:qn,role:St="tooltip"},_s)=>{const[ct,ue]=l.useState(o),[Et,Ee]=l.useState(r),[ut,Rt]=l.useState(d),[dt,Wn]=l.useState(u),[de,on]=l.useState(m),[Lt,Xe]=l.useState(y),[V,Tt]=l.useState(f),[zn,At]=l.useState(w),[Un,rn]=l.useState(C),[an,Ze]=l.useState(h),[ln,ht]=l.useState(g),[Pt,Hn]=l.useState(x),[cn,mt]=l.useState(null),[te,he]=l.useState(null),un=l.useRef(null),dn=l.useRef(U),{anchorRefs:Ot,activeAnchor:hn}=La(e),Mt=Q=>Q?.getAttributeNames().reduce(((ae,T)=>{var O;return T.startsWith("data-tooltip-")&&(ae[T.replace(/^data-tooltip-/,"")]=(O=Q?.getAttribute(T))!==null&&O!==void 0?O:null),ae}),{}),It=Q=>{const ae={place:T=>{var O;Rt((O=T)!==null&&O!==void 0?O:d)},content:T=>{ue(T??o)},html:T=>{Ee(T??r)},variant:T=>{var O;Wn((O=T)!==null&&O!==void 0?O:u)},offset:T=>{on(T===null?m:Number(T))},wrapper:T=>{var O;Ze((O=T)!==null&&O!==void 0?O:h)},events:T=>{const O=T?.split(" ");ht(O??g)},"position-strategy":T=>{var O;Hn((O=T)!==null&&O!==void 0?O:x)},"delay-show":T=>{Xe(T===null?y:Number(T))},"delay-hide":T=>{Tt(T===null?f:Number(T))},float:T=>{At(T===null?w:T==="true")},hidden:T=>{rn(T===null?C:T==="true")},"class-name":T=>{mt(T)}};Object.values(ae).forEach((T=>T(null))),Object.entries(Q).forEach((([T,O])=>{var xe;(xe=ae[T])===null||xe===void 0||xe.call(ae,O)}))};l.useEffect((()=>{ue(o)}),[o]),l.useEffect((()=>{Ee(r)}),[r]),l.useEffect((()=>{Rt(d)}),[d]),l.useEffect((()=>{Wn(u)}),[u]),l.useEffect((()=>{on(m)}),[m]),l.useEffect((()=>{Xe(y)}),[y]),l.useEffect((()=>{Tt(f)}),[f]),l.useEffect((()=>{At(w)}),[w]),l.useEffect((()=>{rn(C)}),[C]),l.useEffect((()=>{Hn(x)}),[x]),l.useEffect((()=>{dn.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 Q;const ae=new Set(Ot);let T=n;if(!T&&e&&(T=`[data-tooltip-id='${e.replace(/'/g,"\\'")}']`),T)try{document.querySelectorAll(T).forEach((R=>{ae.add({current:R})}))}catch{console.warn(`[react-tooltip] "${T}" is not a valid CSS selector`)}const O=document.querySelector(`[id='${t}']`);if(O&&ae.add({current:O}),!ae.size)return()=>null;const xe=(Q=te??O)!==null&&Q!==void 0?Q:hn.current,ft=new MutationObserver((R=>{R.forEach((E=>{var B;if(!xe||E.type!=="attributes"||!(!((B=E.attributeName)===null||B===void 0)&&B.startsWith("data-tooltip-")))return;const ee=Mt(xe);It(ee)}))})),N={attributes:!0,childList:!1,subtree:!1};if(xe){const R=Mt(xe);It(R),ft.observe(xe,N)}return()=>{ft.disconnect()}}),[Ot,hn,te,t,n]),l.useEffect((()=>{q?.border&&console.warn("[react-tooltip] Do not set `style.border`. Use `border` prop instead."),re&&!ar("border",`${re}`)&&console.warn(`[react-tooltip] "${re}" is not a valid \`border\`.`),q?.opacity&&console.warn("[react-tooltip] Do not set `style.opacity`. Use `opacity` prop instead."),He&&!ar("opacity",`${He}`)&&console.warn(`[react-tooltip] "${He}" is not a valid \`opacity\`.`)}),[]);let Dt=p;const mn=l.useRef(null);if(a){const Q=a({content:te?.getAttribute("data-tooltip-content")||ct||null,activeAnchor:te});Dt=Q?et.createElement("div",{ref:mn,className:"react-tooltip-content-wrapper"},Q):null}else ct&&(Dt=ct);Et&&(Dt=et.createElement(_m,{content:Et}));const Vn={forwardRef:_s,id:e,anchorId:t,anchorSelect:n,className:Ys(i,cn),classNameArrow:c,content:Dt,contentWrapperRef:mn,place:ut,variant:dt,offset:de,wrapper:an,events:ln,openOnClick:b,positionStrategy:Pt,middlewares:v,delayShow:Lt,delayHide:V,float:zn,hidden:Un,noArrow:j,clickable:_,closeOnEsc:S,closeOnScroll:k,closeOnResize:P,openEvents:F,closeEvents:se,globalCloseEvents:Ce,imperativeModeOnly:Oe,style:q,position:ce,isOpen:oe,defaultIsOpen:Y,border:re,opacity:He,arrowColor:sn,arrowSize:W,setIsOpen:_t,afterShow:Fn,afterHide:Bn,disableTooltip:qn,activeAnchor:te,previousActiveAnchor:un.current,setActiveAnchor:Q=>{he((ae=>(Q?.isSameNode(ae)||(un.current=ae),Q)))},role:St};return et.createElement(km,{...Vn})}));typeof window<"u"&&window.addEventListener("react-tooltip-inject-styles",(e=>{e.detail.disableCore||or({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||or({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 Sm=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})),Ta=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"})),Em=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})),Rm=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"})),Lm=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"})),Aa=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"})),Tm=()=>{const e=ho(),t=Fc();return{rename:async o=>{if(e){const r=await Mn("New tab name",o);r&&await t.mutateAsync({id:e,payload:{name:r}})}return Promise.resolve()}}},Pa=["shift","alt","meta","mod","ctrl","control"],Am={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(Am[e.trim()]||e.trim()).toLowerCase().replace(/key|digit|numpad/,"")}function Oa(e){return Pa.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(d=>st(d))):a=e.toLocaleLowerCase().split(t).map(d=>st(d));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(d=>!Pa.includes(d));return{...c,keys:u,description:r,isSequence:i,hotkey:e}}typeof document<"u"&&(document.addEventListener("keydown",e=>{e.code!==void 0&&Ma([st(e.code)])}),document.addEventListener("keyup",e=>{e.code!==void 0&&Ia([st(e.code)])})),typeof window<"u"&&(window.addEventListener("blur",()=>{Qe.clear()}),window.addEventListener("contextmenu",()=>{setTimeout(()=>{Qe.clear()},0)}));const Qe=new Set;function Co(e){return Array.isArray(e)}function Pm(e,t=","){return(Co(e)?e:e.split(t)).every(n=>Qe.has(n.trim().toLowerCase()))}function Ma(e){const t=Array.isArray(e)?e:[e];Qe.has("meta")&&Qe.forEach(n=>!Oa(n)&&Qe.delete(n.toLowerCase())),t.forEach(n=>Qe.add(n.toLowerCase()))}function Ia(e){const t=Array.isArray(e)?e:[e];e==="meta"?Qe.clear():t.forEach(n=>Qe.delete(n.toLowerCase()))}function Om(e,t,n){(typeof n=="function"&&n(e,t)||n===!0)&&e.preventDefault()}function Mm(e,t,n){return typeof n=="function"?n(e,t):n===!0||n===void 0}const Im=["input","textarea","select","searchbox","slider","spinbutton","menuitem","menuitemcheckbox","menuitemradio","option","radio","textbox"];function Dm(e){return Da(e,Im)}function Da(e,t=!1){const{target:n,composed:o}=e;let r,a;return $m(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),Co(t)?!!(r&&t&&t.some(i=>i.toLowerCase()===r.toLowerCase()||i===a)):!!(r&&t&&t)}function $m(e){return!!e.tagName&&!e.tagName.startsWith("-")&&e.tagName.includes("-")}function Fm(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 Bm=(e,t,n=!1)=>{const{alt:o,meta:r,mod:a,shift:i,ctrl:c,keys:u,useKey:d}=t,{code:m,key:h,ctrlKey:p,metaKey:g,shiftKey:b,altKey:x}=e,v=st(m);if(d&&u?.length===1&&u.includes(h))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(!g&&!p)return!1}else if(r!==g&&v!=="meta"&&v!=="os"||c!==p&&v!=="ctrl"&&v!=="control")return!1}return u&&u.length===1&&u.includes(v)?!0:u?Pm(u):!u},qm=l.createContext(void 0),Wm=()=>l.useContext(qm);function $a(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&&$a(e[o],t[o]),!0):e===t}const zm=l.createContext({hotkeys:[],activeScopes:[],toggleScope:()=>{},enableScope:()=>{},disableScope:()=>{}}),Um=()=>l.useContext(zm);function Hm(e){const t=l.useRef(void 0);return $a(t.current,e)||(t.current=e),t.current}const ur=e=>{e.stopPropagation(),e.preventDefault(),e.stopImmediatePropagation()},Vm=typeof window<"u"?l.useLayoutEffect:l.useEffect;function Fe(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=Co(e)?e.join(i?.delimiter):e,u=Array.isArray(n)?n:Array.isArray(o)?o:void 0,d=l.useCallback(t,u??[]),m=l.useRef(d);u?m.current=d:m.current=t;const h=Hm(i),{activeScopes:p}=Um(),g=Wm();return Vm(()=>{if(h?.enabled===!1||!Fm(p,h?.scopes))return;let b=[],x;const v=(C,j=!1)=>{if(!(Dm(C)&&!Da(C,h?.enableOnFormTags))){if(r.current!==null){const _=r.current.getRootNode();if((_ instanceof Document||_ instanceof ShadowRoot)&&_.activeElement!==r.current&&!r.current.contains(_.activeElement)){ur(C);return}}C.target?.isContentEditable&&!h?.enableOnContentEditable||$s(c,h?.delimiter).forEach(_=>{if(_.includes(h?.splitKey??"+")&&_.includes(h?.sequenceSplitKey??">")){console.warn(`Hotkey ${_} contains both ${h?.splitKey??"+"} and ${h?.sequenceSplitKey??">"} which is not supported.`);return}const S=Fs(_,h?.splitKey,h?.sequenceSplitKey,h?.useKey,h?.description);if(S.isSequence){x=setTimeout(()=>{b=[]},h?.sequenceTimeoutMs??1e3);const k=S.useKey?C.key:st(C.code);if(Oa(k.toLowerCase()))return;b.push(k);const P=S.keys?.[b.length-1];if(k!==P){b=[],x&&clearTimeout(x);return}b.length===S.keys?.length&&(m.current(C,S),x&&clearTimeout(x),b=[])}else if(Bm(C,S,h?.ignoreModifiers)||S.keys?.includes("*")){if(h?.ignoreEventWhen?.(C)||j&&a.current)return;if(Om(C,S,h?.preventDefault),!Mm(C,S,h?.enabled)){ur(C);return}m.current(C,S),j||(a.current=!0)}})}},y=C=>{C.code!==void 0&&(Ma(st(C.code)),(h?.keydown===void 0&&h?.keyup!==!0||h?.keydown)&&v(C))},f=C=>{C.code!==void 0&&(Ia(st(C.code)),a.current=!1,h?.keyup&&v(C,!0))},w=r.current||i?.document||document;return w.addEventListener("keyup",f,i?.eventListenerOptions),w.addEventListener("keydown",y,i?.eventListenerOptions),g&&$s(c,h?.delimiter).forEach(C=>g.addHotkey(Fs(C,h?.splitKey,h?.sequenceSplitKey,h?.useKey,h?.description))),()=>{w.removeEventListener("keyup",f,i?.eventListenerOptions),w.removeEventListener("keydown",y,i?.eventListenerOptions),g&&$s(c,h?.delimiter).forEach(C=>g.removeHotkey(Fs(C,h?.splitKey,h?.sequenceSplitKey,h?.useKey,h?.description))),b=[],x&&clearTimeout(x)}},[c,h,p]),r}function Km(){return s.jsxs("div",{className:"flex md:grid md:grid-cols-3 items-center bg-white overflow-auto no-scrollbar",children:[s.jsx(Qm,{}),s.jsx(Gm,{}),s.jsx(Xm,{})]})}function Qm(){const{dataSourceId:e}=l.useContext(ze),{data:t}=ps(e),{state:{table:n}}=l.useContext(ge);return s.jsx("div",{className:L.tableConfig,children:t&&s.jsxs("div",{className:A(L.tableAction,L.greenFixed),"data-tooltip-id":"default","data-tooltip-content":n,children:[s.jsx(lt,{size:18,type:t.dbType}),s.jsx("p",{className:"text-sm",children:t.name}),s.jsx(Ye,{width:12,height:12}),s.jsx("p",{className:"text-sm",children:n})]})})}function Gm(){const{page:e,size:t,setPage:n}=ba(),{data:o,isFetching:r}=l.useContext(Pe),a=e*t,i=!r&&!!o?.result.hasMore,c=o?.result.rows.length||0,u=()=>{e>0&&n(e-1)},d=()=>{i&&n(e+1)};return s.jsxs("div",{className:A(L.tableConfig,"justify-self-center"),children:[s.jsx("span",{"data-tooltip-content":"Previous page","data-tooltip-id":"default",className:A(L.tableAction,L.gray,e<1&&"opacity-30"),onClick:u,role:"button",children:s.jsx(Ye,{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:A(L.tableAction,i?L.gray:"opacity-30"),onClick:d,role:"button",children:s.jsx(Ye,{width:16,height:16})})]})}const Ym=[5,10,20,50,100,200],Jm=!__CLIENT_CONFIG__.skipAuth;function Xm(){const{dataSourceId:e,name:t}=l.useContext(ze),{data:n}=ps(e),{data:o,refetch:r}=l.useContext(Pe),a=An(me.EDITOR),i=yh(),{rename:c}=Tm(),{size:u,setSize:d}=ba(),{state:m}=l.useContext(ge),h=en(),p=X(),g=()=>{h.mutateAsync({name:t,opts:m}).then(f=>{p(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()),Le.success("Share link copied to clipboard")}},x=()=>{o?.result.columns?.[0].table&&co({table:o?.result.columns?.[0].table,dataSourceId:e})},v=async()=>{const f=await Mn("Query name",t);!f||!o?.result.queryHistoryId||i.mutate({name:f,queryId:o.result.queryHistoryId})},y=()=>c(t);return Fe("s",v),Fe("r",y),Fe("d",g),s.jsxs("div",{className:"flex justify-self-end",children:[s.jsx("span",{"data-tooltip-content":"Show filters","data-tooltip-id":"default",className:A(L.tableAction,L.gray),onClick:()=>De("filters"),role:"button",children:s.jsx(Lm,{width:16,height:16})}),s.jsx("span",{"data-tooltip-content":"Join table","data-tooltip-id":"default",className:A(L.tableAction,L.gray),onClick:()=>De("joins"),role:"button",children:s.jsx(Aa,{width:16,height:16})}),s.jsx("span",{"data-tooltip-content":"Refresh data","data-tooltip-id":"default",className:A(L.tableAction,L.gray),onClick:()=>r(),role:"button",children:s.jsx(Ta,{width:16,height:16})}),Jm&&s.jsx("span",{"data-tooltip-content":"Share query","data-tooltip-id":"default",className:A(L.tableAction,L.gray),onClick:b,role:"button",children:s.jsx(Rm,{width:16,height:16})}),s.jsx("span",{"data-tooltip-content":"Duplicate tab","data-tooltip-id":"default",className:A(L.tableAction,L.gray),onClick:g,role:"button",children:s.jsx(Em,{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:Ym.map(f=>s.jsx("button",{onClick:()=>d(f,!0),className:A(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:A(L.tableAction,L.gray),children:s.jsx(Sm,{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:()=>De("columns"),className:A(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:()=>De("groupBy"),className:A(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:()=>De("aggregate"),className:A(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:A(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:A(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:A(L.tableAction,L.modal,L.gray),children:"Insert new row"})]})]})]})}const Zm="_drop-container_1j8wa_2",ef="_item_1j8wa_2",dr={dropContainer:Zm,item:ef},Fa=({dataSourceId:e,inputClassName:t,focusId:n,placeholder:o="Column",onChange:r,value:a,autoFocus:i,allowTables:c})=>{const{data:u}=Ln(e),d=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]),h=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]),[p,g]=l.useState(!1),[b,x]=l.useState(0),v=f=>{if(f.key==="ArrowDown")f.preventDefault(),x(w=>(w+1)%h.length);else if(f.key==="ArrowUp")f.preventDefault(),x(w=>(w-1+h.length)%h.length);else if(f.key==="Enter"&&b>=0&&b<h.length){f.preventDefault();const w=h[b].value;g(!1);const C=m.findIndex(j=>j.value===w)>-1;r(h[b]?.value||w,C,!0)}};l.useEffect(()=>{const f=d.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(j=>j.value===w)>-1;r(w,C,!1)};return s.jsxs("div",{className:"relative",onFocus:()=>g(!0),onBlur:()=>g(!1),children:[s.jsx("input",{autoFocus:i,onKeyDown:v,value:a,onChange:y,className:t,placeholder:o,"data-focus":n}),p&&h.length>0&&s.jsx("div",{className:dr.dropContainer,ref:d,tabIndex:-1,children:h.map((f,w)=>s.jsxs("div",{className:dr.item,"data-is-active":b===w,onMouseDownCapture:C=>{C.preventDefault(),g(!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))})]})},tf="_actions_j55wm_2",nf="_filter-actions_j55wm_2",sf="_filter-badge_j55wm_2",of="_filters-container_j55wm_2",rf="_filter-container_j55wm_2",af="_filter-value_j55wm_2",Ht={actions:tf,filterActions:nf,filterBadge:sf,filtersContainer:of,filterContainer:rf,filterValue:af},lf=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})),cf=({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:Ht.filterBadge,children:s.jsx(lf,{width:20,height:20})}):null,uf=({filter:e,dataSourceId:t,allowedTables:n,autoFocus:o,onChangeColumn:r,onChangeValue:a,onRemoveFilter:i,onChangeAdvancedFilter:c,triggerIsEnabled:u,onSubmit:d})=>{const m=p=>{const g=p.target.value;g.charAt(0)===":"?c(e.id,!0):(!e.isAdvanced&&["=","<",">"].includes(g.charAt(0))&&c(e.id,!0),a(e.id,p.currentTarget.value))},h=p=>{p.key==="Backspace"?(e.value.length===0||p.currentTarget.selectionEnd===0)&&c(e.id,!1):p.key==="Enter"&&d()};return s.jsxs("div",{className:Ht.filterContainer,children:[s.jsx("input",{className:"mr-1",type:"checkbox",checked:e.isEnabled!==!1,onClick:()=>u(e.id)}),s.jsx(Fa,{dataSourceId:t,onChange:p=>r(e.id,p),value:e.column,allowTables:n,focusId:"column",inputClassName:"input w-full rounded-r-none!",autoFocus:o}),s.jsxs("div",{className:Ht.filterValue,children:[s.jsx(cf,{isAdvanced:e.isAdvanced}),s.jsx("input",{placeholder:"Filter value",value:e.value,onChange:m,onKeyDown:h,"data-focus":"value",className:"flex-1 outline-none"},e.id)]}),s.jsx("div",{className:Ht.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"})})})]})},df=()=>{const{state:e}=l.useContext(ge),{refetch:t}=l.useContext(Pe),{setFilters:n}=po(),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)])},d=()=>{i(x=>[...x,{id:ot(),value:"",column:"",isEnabled:!0}])},m=x=>{i(v=>v.filter(y=>y.id!==x))},h=(x,v)=>{i(y=>y.map(f=>f.id===x?{...f,isAdvanced:v}:f))},p=()=>ws("filters"),g=()=>{try{n(a.filter(x=>x.value.length>0&&x.column.length>0)),setTimeout(t,1),p()}catch(x){x instanceof Error?Le.error(x.message):Le.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]),Fe("f",()=>{as("filters")}),s.jsxs(we,{isVisible:o,onClose:p,portal:!0,onClosed:()=>i([]),noPadding:!0,backdropClose:!0,children:[s.jsx(it,{onClick:p}),s.jsx("h2",{className:"text-lg font-semibold m-2",children:"Filters"}),s.jsxs("div",{className:Ht.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(uf,{filter:x,dataSourceId:e.dataSourceId,allowedTables:r,onChangeColumn:c,onChangeValue:u,onRemoveFilter:m,onChangeAdvancedFilter:h,triggerIsEnabled:b,onSubmit:g,autoFocus:v===a.length-1},x.id))]}),s.jsxs("div",{className:Ht.actions,children:[s.jsxs("button",{className:"button tertiary flex items-center gap-1 text-sm",onClick:d,children:[s.jsx(Aa,{width:20,height:20}),s.jsx("span",{children:"Add filter"})]}),s.jsx("button",{className:"button primary text-sm",onClick:g,children:"Apply filters"})]})]})},hf="_join-modal_1u5sd_2",mf={joinModal:hf},ff=(e,t)=>e.type!==t.type||e.on!==t.on||e.table!==t.table,pf=(e,t)=>e.type===t.type&&e.on===t.on&&e.table===t.table,Ba=()=>{const{state:e,setState:t}=l.useContext(ge),n=l.useCallback(o=>{t(r=>{const a=r.joins;if(a.some(c=>pf(c,o))){const c=o.table+".";return{...r,joins:a.filter(u=>ff(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}},gf=()=>{const{isFetching:e}=l.useContext(Pe),t=ys(u=>u.joins),{toggle:n}=Ba(),{availableJoins:o}=l.useContext(ze),[r,a]=l.useState(""),i=l.useMemo(()=>{const u=r.toLowerCase();return o.filter(d=>d.on.toTable.toLowerCase().includes(u))},[o,r]),c=()=>ws("joins");return Fe("j",()=>{o.length>0?De("joins"):Le.error("No available tables to join")}),s.jsxs(we,{isVisible:t,onClose:c,portal:!0,backdropClose:!0,children:[s.jsx(it,{onClick:c}),s.jsxs("div",{className:mf.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(ma,{hook:u,onClick:()=>{e||(n({table:u.on.toTable,type:"LEFT",on:u.where}),a(""),c())}},u.where))})]})]})};function xf(e){return e.reduce((t,n)=>(t[n]=!0,t),{})}function hr(e){return e.reduce((t,n)=>(t[n]=!0,t),{})}const bf="_container_1e4tt_2",vf="_column-label_1e4tt_2",yf="_not-active_1e4tt_2",ss={container:bf,columnLabel:vf,notActive:yf};function wf(e){if(!e)return[];const t={};return e.forEach(n=>{t[n.table]?t[n.table].push({value:n.full,ogColumn:n.column,label:tt(n.column),type:n.type}):t[n.table]=[{value:n.full,ogColumn:n.column,label:tt(n.column),type:n.type}],_c[n.type]&&["YEAR","MONTH","DAY"].forEach(o=>{t[n.table].push({value:o+" "+n.full,ogColumn:n.column,label:o+" "+tt(n.column),type:"number",nested:!0})})}),Object.entries(t).reduce((n,[o,r])=>(n.push({name:tt(o),columns:r}),n),[])}function Cf(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 jf=({column:e,selected:t,onCheck:n})=>s.jsxs("label",{className:A(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),Nf={columns:"c",groupBy:"g"},mr=({mode:e})=>{const t=ys(f=>f[e]),{allColumns:n}=l.useContext(ze),{state:o,setState:r}=l.useContext(ge),[a,i]=l.useState({}),[c,u]=l.useState(""),d=l.useMemo(()=>wf(n),[n]),m=o.aggregations.length>0||o.groupBy.length>0,h=l.useMemo(()=>c?Cf(d,c):d,[c,d]),p=f=>{i(w=>({...w,[f.target.name]:f.target.checked}))},g=f=>{const w=f.target.checked;i(C=>{for(const j of n)C[j.full]=w;return{...C}})},b=()=>{ws(e)},x=()=>{const f=[];for(const[w,C]of Object.entries(a))if(C){const[j,_]=w.split(" ");f.push({value:_||j,fn:_?j: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]);Fe(Nf[e],()=>{e==="columns"?m?Le.error("Columns are ignored when there is at least one aggregation or group by"):as("columns"):as("groupBy")}),l.useEffect(()=>{t&&i(()=>xf(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(it,{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:h.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(jf,{column:w,selected:a,onCheck:p},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:g}),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"})]})]})]})},kf="_options-container_lbjii_2",_f={optionsContainer:kf},Bs="COUNT all",Sf=()=>{const e=ys(b=>b.aggregate),{dataSourceId:t}=l.useContext(ze),{setState:n,state:o}=l.useContext(ge),{data:r}=l.useContext(Pe),[a,i]=l.useState({fn:"",col:""}),c=b=>i({...a,fn:b.currentTarget.value}),u=b=>i({...a,col:b}),d=()=>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]}))},h=a.fn===Bs,p=h?!1:!a.col||!a.fn,g=b=>{const x=Xr(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 Fe("a",()=>{as("aggregate")}),s.jsxs(we,{isVisible:e,onClose:d,backdropClose:!0,portal:!0,children:[s.jsx(it,{onClick:d}),s.jsxs("div",{children:[s.jsx("h2",{className:"text-lg font-semibold",children:"Aggregate"}),Be(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:()=>g(b),children:s.jsx(jt,{width:20,height:20,className:"text-red-600"})})]},x))}),s.jsxs("div",{className:_f.optionsContainer,children:[s.jsxs("label",{className:A(h&&"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"})]})]}),!h&&s.jsxs("label",{children:[s.jsx("p",{className:"font-semibold text-xs",children:"Column"}),s.jsx(Fa,{inputClassName:"input w-full",dataSourceId:t,allowTables:r?.result.tables||[],onChange:u,value:a.col})]}),s.jsx("button",{className:"button primary",disabled:p,onClick:m,children:"Add"})]})]})]})},Ef="_container_k50cn_2",Rf="_yellow-pill_k50cn_2 _pill_k50cn_2",Lf="_blue-pill_k50cn_2 _pill_k50cn_2",Tf="_purple-pill_k50cn_2 _pill_k50cn_2",Af="_red-pill_k50cn_2 _pill_k50cn_2",Pf="_black-pill_k50cn_2 _pill_k50cn_2",Of="_disabled-pill_k50cn_2",bt={container:Ef,yellowPill:Rf,bluePill:Lf,purplePill:Tf,redPill:Af,blackPill:Pf,disabledPill:Of};function jo(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 Mf(e){return!(e===!0||e===void 0)}const If=()=>{const{state:{aggregations:e,columns:t,groupBy:n}}=l.useContext(ge),{toggle:o,joins:r}=Ba(),{filters:a,setFilters:i,removeFilter:c}=po(),u=()=>De("joins"),d=()=>De("aggregate"),m=()=>De("columns"),h=()=>De("groupBy"),p=x=>{x.preventDefault(),x.stopPropagation(),o(r[r.length-1])},g=x=>{i(a.map(v=>({...v,isEnabled:x===v.id?Mf(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:bt.container,children:[r.map((x,v)=>s.jsxs("button",{onClick:u,className:bt.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:p,width:18,height:18})]},x.table)),a.map(x=>s.jsxs("button",{onClick:()=>g(x.id),onAuxClick:()=>c(x.id),className:A(bt.bluePill,x.isEnabled===!1&&bt.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:d,className:A(bt.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:A(bt.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:h,className:A(bt.blackPill),"data-tooltip-id":"default","data-tooltip-content":"Has GROUP BY",children:s.jsx("p",{className:"text-sm",children:"Grouped columns"})}),!1]}):null},Df=({options:e,updater:t,name:n,tabId:o})=>{const r=Rc(e,t),a=Bc(o,r.state),i=Ec(a.data,r.state.dataSourceId,n,o);return s.jsx(ze,{value:i,children:s.jsx(ge,{value:r,children:s.jsxs(Pe,{value:a,children:[s.jsx(Km,{}),s.jsx(If,{}),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(vh,{})}),s.jsx(df,{}),s.jsx(gf,{}),s.jsx(mr,{mode:"columns"}),s.jsx(mr,{mode:"groupBy"}),s.jsx(Sf,{})]})]})})})},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..."})]}),$f=({id:e})=>{const{data:t}=Dc(e),n=l.useCallback(o=>{if(!t)return;const r=o(Zt(t.opts));K.setQueryData(["workbench-tabs",t.id],{...t,opts:{...t.opts,...r}})},[t]);return t?s.jsx(Df,{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,{})})},Ff=e=>{setTimeout(t=>{const n=document.querySelector(`[data-tab-id="${t}"]`);n&&n.scrollIntoView({behavior:"smooth"})},50,e)},Bf=()=>{const{id:e}=Ki(),t=X(),{data:n}=xs(),o=$c(),r=la(fo.laptop),a=u=>{if(u===e&&n){if(n.length===1)return t(D.home.build());if(n.length>1){const d=n.find(m=>m.id!==u);if(d)return t(`/workbench/tab/${d.id}`)}}},i=u=>{u.stopPropagation(),u.preventDefault();const d=u.currentTarget.getAttribute("data-tab-id");d&&(o.mutate(d),a(d))},c=u=>{o.mutate(u),a(u)};return l.useEffect(()=>{e&&Ff(e)},[e,n]),s.jsxs("div",{className:"h-screen max-h-screen bg-(--bg) flex flex-col",children:[e?s.jsx($f,{id:e}):s.jsx("div",{className:"flex-1"}),s.jsx("div",{className:A(bn.tabs,"no-scrollbar",!r&&bn.mobile),children:n?.map(u=>s.jsxs("div",{onClick:()=>t(D.workbenchTab.build({id:u.id})),className:A(bn.tab,u.id===e&&bn.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:bn.closeButton,onClick:i,children:s.jsx(jt,{width:20,height:20})})]},u.id))})]})},qf="_root_c1v3s_2",Wf="_up_c1v3s_2",zf="_down_c1v3s_2",Uf="_chevron_c1v3s_2",Hf="_table-name-container_c1v3s_2",Vf="_link_c1v3s_2",Kf="_table-name_c1v3s_2",Qf="_ul_c1v3s_2",Gf="_column-type_c1v3s_2",Yf="_action-blue_c1v3s_2 _action_c1v3s_2",Jf="_action-red_c1v3s_2 _action_c1v3s_2",Xf="_db-header-container_c1v3s_2",Zf="_db-header_c1v3s_2",e0="_db-subheader_c1v3s_2 _db-header_c1v3s_2",ne={root:qf,up:Wf,down:zf,chevron:Uf,tableNameContainer:Hf,link:Vf,tableName:Kf,ul:Qf,columnType:Gf,actionBlue:Yf,actionRed:Jf,dbHeaderContainer:Xf,dbHeader:Zf,dbSubheader:e0},t0="_sidebar_koe7a_2",n0="_sidebar-visible_koe7a_2",s0="_sidebar-container_koe7a_2",o0="_sidebar-invisible_koe7a_2",r0="_backdrop_koe7a_2",vn={sidebar:t0,sidebarVisible:n0,sidebarContainer:s0,sidebarInvisible:o0,backdrop:r0},No=({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 d=()=>{t&&o()},m=h=>{n||getComputedStyle(h.currentTarget).opacity==="0"&&(c(!1),r&&r())};return l.useEffect(()=>{n&&c(!0)},[n]),bs({onClose:d,enabled:n&&t===!0}),s.jsxs("div",{onTransitionEnd:m,className:A(vn.sidebar,n?vn.sidebarVisible:vn.sidebarInvisible),children:[s.jsx("div",{onClick:d,className:vn.backdrop}),s.jsx("div",{className:A(vn.sidebarContainer,a),children:i&&e})]})},a0=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})),i0=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"})),Wa=(e,t=!0)=>{const n=navigator.clipboard.writeText(e);t&&n.then(()=>{Le.success(`Copied "${e}"`)})},l0=new Intl.DateTimeFormat("en",{dateStyle:"full",timeStyle:"long"}),Jn=18;function c0(e,t){return t&&e.toLowerCase().includes(t)?"bg-yellow-200 cursor-pointer":"cursor-pointer"}const u0=({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:ne.ul,children:o.map(r=>s.jsx(s.Fragment,{children:s.jsxs("li",{children:[r.isPrimary?"🔐":"🏷️"," ",s.jsx("span",{onClick:()=>Wa(r.name),className:c0(r.name,t),children:r.name})," ",s.jsxs("span",{className:ne.columnType,children:["[",r.type,"]"]}),r.ref&&s.jsxs("span",{children:[" ➡️ ",s.jsx("span",{className:ne.columnType,children:r.ref.table}),".",r.ref.field]})]},r.name+r.type)}))},e.id)};function d0({id:e}){const{data:t}=ps(e),{data:n}=Ln(e),o=X(),r=xc(),a=Gr(),i=bc(),c=en(),u=l.useMemo(()=>t?.lastInspected?l0.format(new Date(t.lastInspected)):"--",[t]),[d,m]=l.useState({}),[h,p]=l.useState(""),[g,b]=l.useState("table"),x=An(me.EDITOR),v=h.toLowerCase(),y=l.useMemo(()=>{if(!v||!n)return n||[];const k=[];for(const P of n){if(P.tableName.toLowerCase().includes(v)){k.push(P);continue}g!=="table"&&P.columns.findIndex(F=>F.name.toLowerCase().includes(v))>=0&&k.push(P)}return k},[v,n,g]),f=k=>{m(P=>({...P,[k]:!P[k]}))},w=k=>{c.mutateAsync({name:k,opts:Zt({table:k,dataSourceId:e})}).then(P=>{Nn(void 0),o(D.workbenchTab.build({id:P.id}))})},C=()=>{a.mutate(e)},j=async()=>{const k=await Mn("Enter name",t?.name);k&&r.mutate({id:e,dataSource:{name:k}})},_=async()=>{await mo("Are you sure you want to delete this data source?")&&(i.mutate(e),Nn(void 0))},S=g==="column";return s.jsxs("div",{className:ne.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:ne.dbHeaderContainer,children:[s.jsxs("div",{className:ne.dbHeader,children:[t&&s.jsx(lt,{size:24,type:t.dbType}),s.jsx("p",{className:"truncate text-(--text-color-primary) text-lg",children:t?.name})]}),s.jsxs("div",{className:ne.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:ne.actionBlue,"data-tooltip-id":"default-xs","data-tooltip-content":"Refresh schema",children:s.jsx(Ta,{width:16,height:16})}),s.jsx("button",{disabled:a.isPending,onClick:j,className:ne.actionBlue,"data-tooltip-id":"default-xs","data-tooltip-content":"Update name",children:s.jsx(xa,{width:16,height:16})}),s.jsx("button",{disabled:a.isPending,onClick:_,className:ne.actionRed,"data-tooltip-id":"default-xs","data-tooltip-content":"Delete data source",children:s.jsx(i0,{width:16,height:16})})]})]})]}),s.jsxs("div",{className:"flex gap-2 items-center mt-2",children:[s.jsxs("select",{className:"input",value:g,onChange:k=>b(k.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:h,onChange:k=>p(k.target.value),autoFocus:!0})]})]}),s.jsx("div",{className:"overflow-y-auto p-4",children:y?.map(k=>s.jsxs("div",{children:[s.jsxs("div",{className:ne.tableNameContainer,children:[s.jsx("button",{className:A(ne.chevron,d[k.id]?ne.down:ne.up),onClick:()=>f(k.id),children:s.jsx(Ye,{width:16,height:16})}),s.jsx("button",{className:A(ne.tableName,"flex-1"),onClick:()=>f(k.id),children:k.tableName}),s.jsx("button",{className:ne.link,onClick:()=>w(k.tableName),"data-tooltip-id":"default-xs","data-tooltip-content":"Explore table data",children:s.jsx(a0,{width:Jn,height:Jn})}),s.jsx("button",{className:ne.link,onClick:()=>Wa(k.tableName),"data-tooltip-id":"default-xs","data-tooltip-content":"Copy table name",children:s.jsx(ga,{width:Jn,height:Jn})})]}),(d[k.id]||h.length>0)&&s.jsx(u0,{insp:k,filter:S?v:"",expanded:d[k.id]})]},k.id))})]})}const h0=()=>{const e=yu(),[t,n]=l.useState(void 0);l.useEffect(()=>{e&&n(e)},[e]);const o=()=>Nn(void 0);return s.jsx(No,{isVisible:e!=null,onClose:o,onClosed:()=>n(void 0),backdropClose:!0,children:t&&s.jsx(d0,{id:t})})},m0="_search-container_y20i1_2",f0="_search_y20i1_2",p0="_entry_y20i1_2",g0="_ds_y20i1_2",x0="_ds-container_y20i1_2",b0="_ds-entry_y20i1_2",v0="_enabled_y20i1_2",vt={searchContainer:m0,search:f0,entry:p0,ds:g0,dsContainer:x0,dsEntry:b0,enabled:v0};function y0(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 w0=({storage:e=localStorage,localStorageKey:t,initialData:n})=>{const o=ye(y0(t,n,e));return o[2].subscribe(r=>{e.setItem(t,JSON.stringify(r))}),o},[C0,j0]=w0({initialData:[],localStorageKey:"selected-data-sources-v1"}),N0=e=>j0(t=>{const n=t.indexOf(e);return n>-1?(t.splice(n,1),[...t]):[...t,e]}),k0={table:"📄",query:"📖",tab:"🛠️"},_0=({onTable:e,onQuery:t,onWorkbenchTab:n,autoFocus:o})=>{const[r,a]=l.useState(""),[i,c]=l.useState(-1),u=jo(r,200),d=C0(),{data:m}=ve(),{data:h}=ao({teamId:m?.teamId}),p=l.useMemo(()=>{const f=[],w=hr(d);if(!h||h.length===0)return[];for(const C of h)w[C.id]&&f.push(C.id);return f},[d,h]),{data:g}=ic(u,{teamId:m?.teamId,selectedDataSources:p}),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=>{g&&(f.key==="ArrowDown"?(f.preventDefault(),c(w=>(w+1)%g.length)):f.key==="ArrowUp"?(f.preventDefault(),c(w=>(w-1+g.length)%g.length)):f.key==="Enter"&&i>=0&&g[i]?.name&&(f.preventDefault(),b(g[i])))},v=f=>{const w=f.currentTarget.dataset.tableId,C=g?.find(j=>j.id===w);C&&b(C)},y=l.useMemo(()=>hr(d),[d]);return s.jsxs("div",{className:"overflow-hidden flex flex-col w-full lg:w-lg",children:[Be(h?.length,0)?s.jsx("div",{className:vt.dsContainer+" no-scrollbar",children:h.map(f=>s.jsxs("button",{className:A(vt.dsEntry,y[f.id]&&vt.enabled),onClick:()=>N0(f.id),"data-tooltip-id":"default","data-tooltip-content":f.name,children:[s.jsx(lt,{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:vt.searchContainer,children:[s.jsx(tn,{className:"text-(--text-color-secondary)",width:18,height:18}),s.jsx("input",{className:vt.search,placeholder:"Search table or saved query to start from",value:r,onChange:f=>a(f.target.value),onKeyDown:x,autoFocus:o})]}),Be(g?.length,0)&&s.jsx("div",{className:"overflow-y-auto max-h-full mt-2",children:g.map((f,w)=>s.jsxs("button",{className:vt.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:vt.ds,children:["📦 ",f.dataSourceName]})]},f.id))})]})},S0=()=>{const e=Wc(),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(_0,{autoFocus:!0,onTable:t,onQuery:n,onWorkbenchTab:o})})},E0=()=>{const e=Tn("Hotkey"),t=X(),{pathname:n}=le(),{data:o}=ve(),{data:r}=xs(),a=D.home.check(n);Fe("n",()=>{o&&e()}),Fe("w",()=>{o&&(r&&r.length>0?t(D.workbenchTab.build({id:r[0].id})):e())},{enabled:a}),Fe("h",()=>{jn({show:!0})})},R0=()=>{const e=le();l.useEffect(()=>{},[e.pathname])},[L0,za]=ye(!1),qs=()=>za(!1),Ua=()=>za(!0),T0=({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,A0=()=>{const e=L0(),{data:t}=ve(),{mutateAsync:n,isPending:o}=vc(),r=X(),[{password:a,repeatPassword:i},{change:c,touched:u,reset:d}]=_n({password:"",repeatPassword:""}),m=()=>{r("/"),hs.logout().then(()=>{qs()})},h=()=>{n({password:a}).then(()=>{d(),Le.success("Password successfully updated!")})},p=a.length<8||a!==i||o,g=u.includes("password");return s.jsxs(we,{isVisible:e,onClose:qs,children:[s.jsx(it,{onClick:qs}),s.jsxs("div",{className:"w-full lg:w-lg flex flex-col gap-2",children:[s.jsx(na,{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")})]})]}),g&&s.jsx(T0,{password:a,repeatPassword:i}),s.jsxs("div",{className:"flex justify-end gap-2 mt-2",children:[s.jsx("button",{className:"button tertiary",disabled:p,onClick:h,children:"Update password"}),s.jsx("button",{className:"button danger",onClick:m,children:"Log out"})]})]})]})},[P0,Ha]=ye(!1),Va=()=>Ha(!0),fr=()=>Ha(!1),O0=e=>pe({queryKey:["team-users"],queryFn:async()=>{const{data:t}=await I.get("/teams/"+e+"/users");return t.data},enabled:!!e}),M0=()=>Z({mutationFn:async({role:e,teamId:t,userId:n})=>(await I.patch("/teams/"+t+"/user-role",{role:e,userId:n}),!0),onSuccess:()=>{K.invalidateQueries({queryKey:["team-users"]})}}),I0=()=>Z({mutationFn:async({teamId:e,userId:t})=>(await I.delete("/teams/"+e,{params:{userId:t}}),!0),onSuccess:()=>{K.invalidateQueries({queryKey:["team-users"]})}}),D0="_user-entry_vz9go_2",$0="_select-container_vz9go_2",pr={userEntry:D0,selectContainer:$0},F0=()=>{const e=P0(),{data:t}=ve(),{data:n}=O0(t?.teamId),{mutate:o,isPending:r}=yc(),{mutate:a,isPending:i}=M0(),{mutate:c,isPending:u}=I0(),[d,{change:m,reset:h}]=_n({password:"",username:""}),p=()=>{o({username:d.username,password:d.password,teamId:t?.teamId||""}),h()},g=(y,f)=>{a({teamId:t.teamId,role:f,userId:y})},b=y=>{mo("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:fr,backdropClose:!0,children:[s.jsx(it,{onClick:fr}),s.jsxs("div",{className:"w-full lg:w-lg flex flex-col overflow-hidden",children:[s.jsx(na,{children:"Manage users"}),Be(n?.length,0)&&s.jsx("div",{className:"mt-4 overflow-y-auto flex-1",children:n.map(y=>s.jsxs("div",{className:pr.userEntry,children:[s.jsx("div",{className:pr.selectContainer,children:s.jsxs("select",{value:y.role,disabled:!x||v,onChange:f=>g(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:d.username,placeholder:"Username",disabled:v}),s.jsx("input",{className:"input",onChange:m("password"),value:d.password,type:"password",name:"newPassword",autoComplete:"new-password",placeholder:"Password",disabled:v}),s.jsx("button",{className:"button primary",onClick:p,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."})]})]})]})},B0="_gray-card_13jst_2",q0="_login-label_13jst_2",gr={grayCard:B0,loginLabel:q0},W0=()=>{const[e,t]=l.useState(""),[n,o]=l.useState(""),[r,a]=l.useState(),i=X(),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(ra,{})]}),s.jsxs("form",{className:gr.grayCard,onSubmit:c,children:[s.jsx("h2",{className:gr.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"})})]})]})})},z0=()=>{const e=X(),{pathname:t}=le(),{data:n,isLoading:o}=Yr();l.useEffect(()=>{!n&&!o&&!D.login.check(t)&&e(D.login.build())},[n,o,e,t])},U0=()=>{},H0=__CLIENT_CONFIG__.skipAuth?U0:z0,V0=()=>{const[e]=$l(),t=X(),n=en(),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_pjz7z_2",Q0="_tab-name_pjz7z_2",G0="_archived-badge_pjz7z_2 _badge_pjz7z_2",Y0="_active-badge_pjz7z_2 _badge_pjz7z_2",J0="_delete-action_pjz7z_2",yn={tabContainer:K0,tabName:Q0,archivedBadge:G0,activeBadge:Y0,deleteAction:J0},Ka=({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(On,{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"})})]}),X0=new Intl.DateTimeFormat,Z0=()=>{const[e,t]=l.useState(""),n=jo(e),{data:o}=ve(),{data:r,fetchNextPage:a,hasNextPage:i}=lc(o?.teamId,n,25),c=X(),u=Zr(),d=qc(),m=l.useRef(null),h=l.useRef(null),p=b=>{u.mutate(b),jn({show:!1}),c(D.workbenchTab.build({id:b}))},g=()=>{m.current?.close(),d.mutate(h.current)};return s.jsxs(Ka,{hasMore:i,onLoadMore:a,onClose:()=>jn({show:!1}),searchValue:e,onSearchValue:t,children:[r?.map(b=>s.jsxs("div",{className:yn.tabContainer,onClick:()=>p(b.id),onContextMenu:x=>{h.current=b.id,m.current?.open(x,!1)},children:[s.jsxs("div",{className:"flex gap-2 items-center",children:[s.jsx("p",{className:yn.tabName,children:b.name}),b.dataSourceType&&s.jsx(lt,{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:X0.format(new Date(b.updatedAt))}),b.archived?s.jsx("span",{className:yn.archivedBadge,children:"Archived"}):s.jsx("span",{className:yn.activeBadge,children:"Active"})]})]},b.id)),s.jsx(pa,{ref:m,children:s.jsx("button",{onClick:g,className:yn.deleteAction,children:"🗑 Delete"})})]})},ep=()=>{const e=vu(t=>t.show);return s.jsx(No,{isVisible:e,onClose:()=>jn({show:!1}),backdropClose:!0,children:s.jsx(Z0,{})})},tp=()=>{const{data:e}=ve(),t=dc(e?.teamId),n=X();return l.useEffect(()=>{t.mutateAsync().then(o=>{o?n(D.workbenchTab.build({id:o.id}),{replace:!0}):n(D.home.build(),{replace:!0})})},[]),null},np="_query-entry_u1esh_2",sp={queryEntry:np},op=new Intl.DateTimeFormat,rp=({projectQueries:e,isLoading:t})=>{const n=l.useRef(void 0),o=X(),r=Ch(),a=en(),i=wh(),c=da(),u=h=>{a.mutateAsync({queryId:h}).then(p=>{Pn({show:!1}),o(D.workbenchTab.build({id:p.id}))})},d=async h=>{const p=e?.find(b=>b.id===h);if(!p)return;const g=await Mn("New name?",p?.name);g&&r.mutate({id:p.savedQueryId,payload:{name:g}})},m=h=>{const p=e?.find(g=>g.id===h)?.savedQueryId;p&&i.mutate(p)};return s.jsxs("div",{className:"flex flex-col px-2",children:[Be(e?.length,0)&&e.map(h=>s.jsxs("button",{className:sp.queryEntry,onClick:()=>u(h.id),onContextMenu:p=>{n.current=h.id,c.open(p)},children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-left text-sm font-semibold text-(--text-color-primary)",children:h.name}),s.jsx("p",{className:"text-left text-xs text-(--text-color-secondary) italic",children:op.format(new Date(h.updatedAt))})]}),s.jsxs("p",{className:"flex gap-2 items-center",children:[s.jsx(lt,{size:16,type:h.datasourceType}),s.jsx("span",{className:"truncate text-xs text-(--text-color-secondary)",children:h.datasourceName})]})]},h.savedQueryId)),!t&&Qd(e?.length,1)&&s.jsx("p",{className:"text-center text-sm text-(--text-color-secondary) mt-2",children:"Empty"}),s.jsx(ha,{handler:c,children:s.jsxs("div",{className:"context-menu-container",children:[s.jsx("button",{onClick:h=>{h.preventDefault(),h.stopPropagation(),c.close(),d(n.current)},className:"context-menu-item",children:"✏️ Rename"}),s.jsx("button",{onClick:h=>{h.preventDefault(),h.stopPropagation(),c.close(),m(n.current)},className:"context-menu-item",children:"🗑️ Delete"})]})})]})},ap=()=>{const{data:e}=ve(),[t,n]=l.useState(""),o=jo(t),{data:r,isLoading:a,fetchNextPage:i,hasNextPage:c}=cc(e?.teamId,o);return s.jsx(Ka,{hasMore:c,onClose:()=>Pn({show:!1}),onLoadMore:i,searchValue:t,onSearchValue:n,children:s.jsx(rp,{isLoading:a,projectQueries:r||[]})})},ip=()=>{const e=bu(t=>t.show);return s.jsx(No,{isVisible:e,onClose:()=>Pn({show:!1}),backdropClose:!0,children:s.jsx(ap,{})})};function lp(){return E0(),R0(),H0(),s.jsxs(s.Fragment,{children:[s.jsxs(ll,{children:[s.jsx(Wt,{path:D.home.path,element:s.jsx(Tu,{})}),s.jsx(Wt,{path:D.workbench.path,element:s.jsx(tp,{})}),s.jsx(Wt,{path:D.workbenchTab.path,element:s.jsx(Bf,{})}),s.jsx(Wt,{path:D.login.path,element:s.jsx(W0,{})}),s.jsx(Wt,{path:D.share.path,element:s.jsx(V0,{})})]}),s.jsx(Hu,{}),s.jsx(ed,{}),s.jsx(md,{}),s.jsx(h0,{}),s.jsx(S0,{}),s.jsx(A0,{}),s.jsx(F0,{}),s.jsx(ep,{}),s.jsx(ip,{}),s.jsx(ld,{}),s.jsx(sd,{})]})}const cp="_hidden_1azw1_2",up="_desktop-layout_1azw1_2",dp="_mobile-layout_1azw1_2",hp="_nav_1azw1_2",mp="_shown_1azw1_2",fp="_main_1azw1_2",pp="_header_1azw1_2",gp="_expand_1azw1_2",xp="_show_1azw1_2",bp="_hide_1azw1_2",vp="_icon_1azw1_2",yp="_nav-item_1azw1_2",wp="_project-wrapper_1azw1_2",M={hidden:cp,desktopLayout:up,mobileLayout:dp,nav:hp,shown:mp,main:fp,header:pp,expand:gp,show:xp,hide:bp,icon:vp,navItem:yp,projectWrapper:wp},Cp=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"})),jp=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"})),Np=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})),_p=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})),Sp=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})),Ep=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})),Rp=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})),xr=!__CLIENT_CONFIG__.skipAuth,br=(()=>{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 Lp(){switch(__CLIENT_CONFIG__.modeName){case"docker":return s.jsx(Cp,{className:ke,width:G,height:G});case"cli":return s.jsx(jp,{className:ke,width:G,height:G});default:return s.jsx(Np,{className:ke,width:G,height:G})}}const Tp=({dataSource:e})=>s.jsxs("button",{className:M.navItem,onClick:()=>Nn(e.id),"data-tooltip-id":"default","data-tooltip-content":e.name,"data-tooltip-place":"right",children:[s.jsx("span",{className:M.icon,children:s.jsx(lt,{size:20,type:e.dbType})}),s.jsx("span",{className:"truncate",children:e.name})]}),Ap=()=>{const e=X(),{pathname:t}=le(),{data:n}=ve(),o=Tn("Desktop nav"),[r,a]=l.useState(!1),{data:i}=xs(),{data:c}=rc(n?.teamId),u=()=>{D.home.check(t)||e(D.home.build())},d=b=>{D.workbenchTab.check(t)||e(D.workbenchTab.build({id:b}))},m=()=>{Pn({show:!0})},h=()=>{mo("Are you sure you want to logout?").then(b=>{b&&(e("/"),hs.logout())})},p=()=>jn({show:!0}),g=r?void 0:"default";return s.jsxs("nav",{className:A(M.nav,r?M.shown:M.hidden),children:[n&&s.jsxs("div",{className:M.header,children:[s.jsxs("button",{onClick:u,className:M.navItem,"data-tooltip-id":g,"data-tooltip-content":"Home",children:[s.jsx("span",{className:M.icon,children:s.jsx(_p,{className:ke,width:G,height:G})}),s.jsx("span",{className:"truncate",children:"Home"})]}),s.jsxs("button",{onClick:o,className:M.navItem,"data-tooltip-id":g,"data-tooltip-content":"New query",children:[s.jsx("span",{className:M.icon,children:s.jsx(tn,{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:p,className:M.navItem,"data-tooltip-id":g,"data-tooltip-content":"Recent tabs",children:[s.jsx("span",{className:M.icon,children:s.jsx(sa,{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:M.navItem,"data-tooltip-id":g,"data-tooltip-content":"Saved queries",children:[s.jsx("span",{className:M.icon,children:s.jsx(Rp,{className:ke,width:G,height:G})}),s.jsx("span",{className:"truncate",children:"Saved queries"})]}),Be(i?.length,0)&&s.jsxs("button",{onClick:()=>d(i[0].id),className:M.navItem,"data-tooltip-id":g,"data-tooltip-content":"Workbench",children:[s.jsx("span",{className:M.icon,children:s.jsx(oa,{className:ke,width:G,height:G})}),s.jsx("span",{className:"truncate",children:"Workbench"}),s.jsx("span",{className:"hotkey secondary",children:"W"})]}),xr&&s.jsxs(s.Fragment,{children:[s.jsxs("button",{onClick:Ua,className:M.navItem,"data-tooltip-id":g,"data-tooltip-content":"User settings",children:[s.jsx("span",{className:M.icon,children:s.jsx(Sp,{className:ke,width:G,height:G})}),s.jsx("span",{className:"truncate",children:n.username})]}),s.jsxs("button",{onClick:Va,className:M.navItem,"data-tooltip-id":g,"data-tooltip-content":"Manage users",children:[s.jsx("span",{className:M.icon,children:s.jsx(Ep,{className:ke,width:G,height:G})}),s.jsx("span",{className:"truncate",children:"Manage users"})]})]})]}),s.jsx("div",{className:A(M.projectWrapper),children:Be(c?.length,0)&&s.jsx("div",{className:"mt-4 flex flex-col",children:c.map(b=>s.jsx(Tp,{dataSource:b},b.id))})}),xr&&s.jsxs("button",{onClick:h,"data-tooltip-id":g,"data-tooltip-content":"Logout",className:`${M.navItem} mx-1`,children:[s.jsx("span",{className:M.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:`${M.navItem} mx-1 cursor-auto!`,"data-tooltip-id":g,"data-tooltip-content":br,children:[s.jsx("span",{className:M.icon,children:s.jsx(Lp,{})}),s.jsx("span",{className:"truncate text-sm text-(--text-color-primary)",children:br})]}),s.jsxs("button",{onClick:()=>a(!r),"data-tooltip-id":"default","data-tooltip-content":"Expand sidebar","data-tooltip-hidden":r,"data-tooltip-place":"right",className:`${M.navItem} mx-1`,children:[s.jsx("span",{className:A(M.icon,M.expand,r?M.show:M.hide),children:s.jsx(Ye,{className:ke,width:20,height:20})}),s.jsx("span",{className:"truncate text-sm text-(--text-color-primary)",children:"Collapse menu"})]})]})},Pp="_root_17k32_2",Op={root:Pp},Qa=!__CLIENT_CONFIG__.skipAuth,Mp=`${Op.root} ${Qa?"grid-cols-4":"grid-cols-2"}`,Ip=()=>{const{pathname:e}=le(),t=X(),n=Tn("Mobile nav"),o=()=>{D.home.check(e)||t(D.home.build())};return s.jsxs("div",{className:Mp,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"})]}),Qa&&s.jsxs(s.Fragment,{children:[s.jsxs("button",{onClick:Ua,children:[s.jsx("p",{children:"🪪"}),s.jsx("p",{className:"text-xs font-semibold text-gray-600",children:"Account"})]}),s.jsxs("button",{onClick:Va,children:[s.jsx("p",{children:"👥"}),s.jsx("p",{className:"text-xs font-semibold text-gray-600",children:"Users"})]})]})]})},Dp=({children:e,isLogin:t})=>s.jsxs("div",{className:M.desktopLayout,children:[s.jsx(us,{id:"default",className:"z-100"}),s.jsx(us,{id:"default-xs",className:"z-100 text-xs!"}),!t&&s.jsx(Ap,{}),s.jsx("main",{className:M.main,children:e})]}),$p=({children:e,isLogin:t})=>s.jsxs("div",{className:M.mobileLayout,children:[s.jsx("main",{className:M.main,children:e}),!t&&s.jsx(Ip,{})]}),Fp=({children:e})=>{const t=la(fo.laptop),{pathname:n}=le(),o=D.login.check(n);return t?s.jsx(Dp,{isLogin:o,children:e}):s.jsx($p,{isLogin:o,children:e})};ci.createRoot(document.getElementById("root")).render(s.jsxs(et.StrictMode,{children:[s.jsx(ui,{}),s.jsx(Ql,{client:K,children:s.jsx(Pl,{children:s.jsx(Fp,{children:s.jsx(lp,{})})})})]}));