@dataramen/cli 0.0.71-beta.1 → 0.0.71-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/code/server.js +7 -7
- package/dist/code/web/assets/main-DQVes_07.css +1 -0
- package/dist/code/web/assets/main-DgslLyfr.js +4 -0
- package/dist/code/web/index.html +2 -2
- package/dist/package.json +1 -1
- package/package.json +1 -1
- package/dist/README.md +0 -75
- package/dist/code/web/assets/main-D6h5BZfN.css +0 -1
- package/dist/code/web/assets/main-DMw81JVl.js +0 -4
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{r as l,a as Da,S as rr,p as go,b as ke,s as Xn,c as gn,n as Zn,i as Ps,d as vo,t as Fa,e as Un,f as Ba,g as qa,h as yo,j as rs,k as wo,l as Ua,m as Wa,o as Co,q as Ha,u as s,v as Ws,w as K,x as O,A as Hs,y as za,z as Va,B as A,C as Cn,D as ne,E as Re,F as Qa,G as Ka,R as Ze,H as Ga,I as Ya}from"./index-VGcygI3P.js";var jo="popstate";function Ja(e={}){function t(o,r){let{pathname:a,search:i,hash:c}=o.location;return Is("",{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:yn(r)}return Za(t,n,null,e)}function V(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function je(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function Xa(){return Math.random().toString(36).substring(2,10)}function No(e,t){return{usr:e.state,key:e.key,idx:t}}function Is(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||Xa()}}function yn({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 Za(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:b.location,delta:y})}function p(v,y){c="PUSH";let f=Is(b.location,v,y);d=m()+1;let w=No(f,d),C=b.createHref(f);try{i.pushState(w,"",C)}catch(_){if(_ instanceof DOMException&&_.name==="DataCloneError")throw _;r.location.assign(C)}a&&u&&u({action:c,location:b.location,delta:1})}function x(v,y){c="REPLACE";let f=Is(b.location,v,y);d=m();let w=No(f,d),C=b.createHref(f);i.replaceState(w,"",C),a&&u&&u({action:c,location:b.location,delta:0})}function g(v){return ei(v)}let b={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(jo,h),u=v,()=>{r.removeEventListener(jo,h),u=null}},createHref(v){return t(r,v)},createURL:g,encodeLocation(v){let y=g(v);return{pathname:y.pathname,search:y.search,hash:y.hash}},push:p,replace:x,go(v){return i.go(v)}};return b}function ei(e,t=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),V(n,"No window.location.(origin|href) available to create URL");let o=typeof e=="string"?e:yn(e);return o=o.replace(/ $/,"%20"),!t&&o.startsWith("//")&&(o=n+o),new URL(o,n)}function ar(e,t,n="/"){return ti(e,t,n,!1)}function ti(e,t,n,o){let r=typeof t=="string"?Gt(t):t,a=Ye(r.pathname||"/",n);if(a==null)return null;let i=ir(e);ni(i);let c=null;for(let u=0;c==null&&u<i.length;++u){let d=mi(a);c=di(i[u],d,o)}return c}function ir(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;V(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=Qe([o,m.relativePath]),p=n.concat(m);i.children&&i.children.length>0&&(V(i.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${h}".`),ir(i.children,t,p,h,u)),!(i.path==null&&!i.index)&&t.push({path:h,score:ci(h,i.index),routesMeta:p})};return e.forEach((i,c)=>{if(i.path===""||!i.path?.includes("?"))a(i,c);else for(let u of lr(i.path))a(i,c,!0,u)}),t}function lr(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=lr(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 ni(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:ui(t.routesMeta.map(o=>o.childrenIndex),n.routesMeta.map(o=>o.childrenIndex)))}var si=/^:[\w-]+$/,oi=3,ri=2,ai=1,ii=10,li=-2,_o=e=>e==="*";function ci(e,t){let n=e.split("/"),o=n.length;return n.some(_o)&&(o+=li),t&&(o+=ri),n.filter(r=>!_o(r)).reduce((r,a)=>r+(si.test(a)?oi:a===""?ai:ii),o)}function ui(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 di(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=Ht({path:u.relativePath,caseSensitive:u.caseSensitive,end:d},m),p=u.route;if(!h&&d&&n&&!o[o.length-1].route.index&&(h=Ht({path:u.relativePath,caseSensitive:u.caseSensitive,end:!1},m)),!h)return null;Object.assign(r,h.params),i.push({params:r,pathname:Qe([a,h.pathname]),pathnameBase:bi(Qe([a,h.pathnameBase])),route:p}),h.pathnameBase!=="/"&&(a=Qe([a,h.pathnameBase]))}return i}function Ht(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[n,o]=hi(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 g=c[p]||"";i=a.slice(0,a.length-g.length).replace(/(.)\/+$/,"$1")}const x=c[p];return h&&!x?d[m]=void 0:d[m]=(x||"").replace(/%2F/g,"/"),d},{}),pathname:a,pathnameBase:i,pattern:e}}function hi(e,t=!1,n=!0){je(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 mi(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return je(!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 Ye(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 cr=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,fi=e=>cr.test(e);function pi(e,t="/"){let{pathname:n,search:o="",hash:r=""}=typeof e=="string"?Gt(e):e,a;if(n)if(fi(n))a=n;else{if(n.includes("//")){let i=n;n=n.replace(/\/\/+/g,"/"),je(!1,`Pathnames cannot have embedded double slashes - normalizing ${i} -> ${n}`)}n.startsWith("/")?a=So(n.substring(1),"/"):a=So(n,t)}else a=t;return{pathname:a,search:gi(o),hash:vi(r)}}function So(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 ys(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 xi(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function ur(e){let t=xi(e);return t.map((n,o)=>o===t.length-1?n.pathname:n.pathnameBase)}function dr(e,t,n,o=!1){let r;typeof e=="string"?r=Gt(e):(r={...e},V(!r.pathname||!r.pathname.includes("?"),ys("?","pathname","search",r)),V(!r.pathname||!r.pathname.includes("#"),ys("#","pathname","hash",r)),V(!r.search||!r.search.includes("#"),ys("#","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=pi(r,c),d=i&&i!=="/"&&i.endsWith("/"),m=(a||i===".")&&n.endsWith("/");return!u.pathname.endsWith("/")&&(d||m)&&(u.pathname+="/"),u}var Qe=e=>e.join("/").replace(/\/\/+/g,"/"),bi=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),gi=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,vi=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,yi=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 wi(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function Ci(e){return e.map(t=>t.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var hr=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function mr(e,t){let n=e;if(typeof n!="string"||!cr.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let o=n,r=!1;if(hr)try{let a=new URL(window.location.href),i=n.startsWith("//")?new URL(a.protocol+n):new URL(n),c=Ye(i.pathname,t);i.origin===a.origin&&c!=null?n=c+i.search+i.hash:r=!0}catch{je(!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 fr=["POST","PUT","PATCH","DELETE"];new Set(fr);var ji=["GET",...fr];new Set(ji);var Yt=l.createContext(null);Yt.displayName="DataRouter";var as=l.createContext(null);as.displayName="DataRouterState";var Ni=l.createContext(!1),pr=l.createContext({isTransitioning:!1});pr.displayName="ViewTransition";var _i=l.createContext(new Map);_i.displayName="Fetchers";var Si=l.createContext(null);Si.displayName="Await";var Ne=l.createContext(null);Ne.displayName="Navigation";var jn=l.createContext(null);jn.displayName="Location";var Be=l.createContext({outlet:null,matches:[],isDataRoute:!1});Be.displayName="Route";var zs=l.createContext(null);zs.displayName="RouteError";var xr="REACT_ROUTER_ERROR",ki="REDIRECT",Ei="ROUTE_ERROR_RESPONSE";function Ri(e){if(e.startsWith(`${xr}:${ki}:{`))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 Ti(e){if(e.startsWith(`${xr}:${Ei}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string")return new yi(t.status,t.statusText,t.data)}catch{}}function Li(e,{relative:t}={}){V(Nn(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:o}=l.useContext(Ne),{hash:r,pathname:a,search:i}=_n(e,{relative:t}),c=a;return n!=="/"&&(c=a==="/"?n:Qe([n,a])),o.createHref({pathname:c,search:i,hash:r})}function Nn(){return l.useContext(jn)!=null}function le(){return V(Nn(),"useLocation() may be used only in the context of a <Router> component."),l.useContext(jn).location}var br="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function gr(e){l.useContext(Ne).static||l.useLayoutEffect(e)}function Y(){let{isDataRoute:e}=l.useContext(Be);return e?zi():Ai()}function Ai(){V(Nn(),"useNavigate() may be used only in the context of a <Router> component.");let e=l.useContext(Yt),{basename:t,navigator:n}=l.useContext(Ne),{matches:o}=l.useContext(Be),{pathname:r}=le(),a=JSON.stringify(ur(o)),i=l.useRef(!1);return gr(()=>{i.current=!0}),l.useCallback((u,d={})=>{if(je(i.current,br),!i.current)return;if(typeof u=="number"){n.go(u);return}let m=dr(u,JSON.parse(a),r,d.relative==="path");e==null&&t!=="/"&&(m.pathname=m.pathname==="/"?t:Qe([t,m.pathname])),(d.replace?n.replace:n.push)(m,d.state,d)},[t,n,a,r,e])}l.createContext(null);function Pi(){let{matches:e}=l.useContext(Be),t=e[e.length-1];return t?t.params:{}}function _n(e,{relative:t}={}){let{matches:n}=l.useContext(Be),{pathname:o}=le(),r=JSON.stringify(ur(n));return l.useMemo(()=>dr(e,JSON.parse(r),o,t==="path"),[e,r,o,t])}function Ii(e,t){return vr(e,t)}function vr(e,t,n,o,r){V(Nn(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:a}=l.useContext(Ne),{matches:i}=l.useContext(Be),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||"";wr(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(),x;if(t){let f=typeof t=="string"?Gt(t):t;V(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.`),x=f}else x=p;let g=x.pathname||"/",b=g;if(m!=="/"){let f=m.replace(/^\//,"").split("/");b="/"+g.replace(/^\//,"").split("/").slice(f.length).join("/")}let v=ar(e,{pathname:b});je(h||v!=null,`No routes matched location "${x.pathname}${x.search}${x.hash}" `),je(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 "${x.pathname}${x.search}${x.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=Fi(v&&v.map(f=>Object.assign({},f,{params:Object.assign({},u,f.params),pathname:Qe([m,a.encodeLocation?a.encodeLocation(f.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:f.pathname]),pathnameBase:f.pathnameBase==="/"?m:Qe([m,a.encodeLocation?a.encodeLocation(f.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:f.pathnameBase])})),i,n,o,r);return t&&y?l.createElement(jn.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...x},navigationType:"POP"}},y):y}function Oi(){let e=Hi(),t=wi(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 Mi=l.createElement(Oi,null),yr=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=Ti(e.digest);n&&(e=n)}let t=e!==void 0?l.createElement(Be.Provider,{value:this.props.routeContext},l.createElement(zs.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?l.createElement($i,{error:e},t):t}};yr.contextType=Ni;var ws=new WeakMap;function $i({children:e,error:t}){let{basename:n}=l.useContext(Ne);if(typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){let o=Ri(t.digest);if(o){let r=ws.get(t);if(r)throw r;let a=mr(o.location,n);if(hr&&!ws.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 ws.set(t,i),i}return l.createElement("meta",{httpEquiv:"refresh",content:`0;url=${a.absoluteURL||a.to}`})}}return e}function Di({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(Be.Provider,{value:e},n)}function Fi(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);V(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:x}=n,g=h.route.loader&&!p.hasOwnProperty(h.route.id)&&(!x||x[h.route.id]===void 0);if(h.route.lazy||g){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:Ci(n.matches),errorInfo:h})}:void 0;return a.reduceRight((m,h,p)=>{let x,g=!1,b=null,v=null;n&&(x=i&&h.route.id?i[h.route.id]:void 0,b=h.route.errorElement||Mi,c&&(u<0&&p===0?(wr("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),g=!0,v=null):u===p&&(g=!0,v=h.route.hydrateFallbackElement||null)));let y=t.concat(a.slice(0,p+1)),f=()=>{let w;return x?w=b:g?w=v:h.route.Component?w=l.createElement(h.route.Component,null):h.route.element?w=h.route.element:w=m,l.createElement(Di,{match:h,routeContext:{outlet:m,matches:y,isDataRoute:n!=null},children:w})};return n&&(h.route.ErrorBoundary||h.route.errorElement||p===0)?l.createElement(yr,{location:n.location,revalidation:n.revalidation,component:b,error:x,children:f(),routeContext:{outlet:null,matches:y,isDataRoute:!0},onError:d}):f()},null)}function Vs(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Bi(e){let t=l.useContext(Yt);return V(t,Vs(e)),t}function qi(e){let t=l.useContext(as);return V(t,Vs(e)),t}function Ui(e){let t=l.useContext(Be);return V(t,Vs(e)),t}function Qs(e){let t=Ui(e),n=t.matches[t.matches.length-1];return V(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function Wi(){return Qs("useRouteId")}function Hi(){let e=l.useContext(zs),t=qi("useRouteError"),n=Qs("useRouteError");return e!==void 0?e:t.errors?.[n]}function zi(){let{router:e}=Bi("useNavigate"),t=Qs("useNavigate"),n=l.useRef(!1);return gr(()=>{n.current=!0}),l.useCallback(async(r,a={})=>{je(n.current,br),n.current&&(typeof r=="number"?await e.navigate(r):await e.navigate(r,{fromRouteId:t,...a}))},[e,t])}var ko={};function wr(e,t,n){!t&&!ko[e]&&(ko[e]=!0,je(!1,n))}l.memo(Vi);function Vi({routes:e,future:t,state:n,onError:o}){return vr(e,void 0,n,o,t)}function gt(e){V(!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 Qi({basename:e="/",children:t=null,location:n,navigationType:o="POP",navigator:r,static:a=!1,unstable_useTransitions:i}){V(!Nn(),"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:x="default"}=n,g=l.useMemo(()=>{let b=Ye(d,c);return b==null?null:{location:{pathname:b,search:m,hash:h,state:p,key:x},navigationType:o}},[c,d,m,h,p,x,o]);return je(g!=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.`),g==null?null:l.createElement(Ne.Provider,{value:u},l.createElement(jn.Provider,{children:t,value:g}))}function Ki({children:e,location:t}){return Ii(Os(e),t)}function Os(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,Os(o.props.children,a));return}V(o.type===gt,`[${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>`),V(!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=Os(o.props.children,a)),n.push(i)}),n}var Qn="get",Kn="application/x-www-form-urlencoded";function is(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function Gi(e){return is(e)&&e.tagName.toLowerCase()==="button"}function Yi(e){return is(e)&&e.tagName.toLowerCase()==="form"}function Ji(e){return is(e)&&e.tagName.toLowerCase()==="input"}function Xi(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function Zi(e,t){return e.button===0&&(!t||t==="_self")&&!Xi(e)}function Ms(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 el(e,t){let n=Ms(e);return t&&t.forEach((o,r)=>{n.has(r)||t.getAll(r).forEach(a=>{n.append(r,a)})}),n}var Wn=null;function tl(){if(Wn===null)try{new FormData(document.createElement("form"),0),Wn=!1}catch{Wn=!0}return Wn}var nl=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Cs(e){return e!=null&&!nl.has(e)?(je(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Kn}"`),null):e}function sl(e,t){let n,o,r,a,i;if(Yi(e)){let c=e.getAttribute("action");o=c?Ye(c,t):null,n=e.getAttribute("method")||Qn,r=Cs(e.getAttribute("enctype"))||Kn,a=new FormData(e)}else if(Gi(e)||Ji(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?Ye(u,t):null,n=e.getAttribute("formmethod")||c.getAttribute("method")||Qn,r=Cs(e.getAttribute("formenctype"))||Cs(c.getAttribute("enctype"))||Kn,a=new FormData(c,e),!tl()){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(is(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=Qn,o=null,r=Kn,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 Ks(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function ol(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&&Ye(r.pathname,t)==="/"?r.pathname=`${t.replace(/\/$/,"")}/_root.${o}`:r.pathname=`${r.pathname.replace(/\/$/,"")}.${o}`,r}async function rl(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 al(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 il(e,t,n){let o=await Promise.all(e.map(async r=>{let a=t.routes[r.route.id];if(a){let i=await rl(a,n);return i.links?i.links():[]}return[]}));return dl(o.flat(1).filter(al).filter(r=>r.rel==="stylesheet"||r.rel==="preload").map(r=>r.rel==="stylesheet"?{...r,rel:"prefetch",as:"style"}:{...r,rel:"prefetch"}))}function Eo(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 ll(e,t,{includeHydrateFallback:n}={}){return cl(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 cl(e){return[...new Set(e)]}function ul(e){let t={},n=Object.keys(e).sort();for(let o of n)t[o]=e[o];return t}function dl(e,t){let n=new Set;return new Set(t),e.reduce((o,r)=>{let a=JSON.stringify(ul(r));return n.has(a)||(n.add(a),o.push({key:a,link:r})),o},[])}function Cr(){let e=l.useContext(Yt);return Ks(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function hl(){let e=l.useContext(as);return Ks(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var Gs=l.createContext(void 0);Gs.displayName="FrameworkContext";function jr(){let e=l.useContext(Gs);return Ks(e,"You must render this element inside a <HydratedRouter> element"),e}function ml(e,t){let n=l.useContext(Gs),[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 b=y=>{y.forEach(f=>{i(f.isIntersecting)})},v=new IntersectionObserver(b,{threshold:.5});return p.current&&v.observe(p.current),()=>{v.disconnect()}}},[e]),l.useEffect(()=>{if(o){let b=setTimeout(()=>{i(!0)},100);return()=>{clearTimeout(b)}}},[o]);let x=()=>{r(!0)},g=()=>{r(!1),i(!1)};return n?e!=="intent"?[a,p,{}]:[a,p,{onFocus:fn(c,x),onBlur:fn(u,g),onMouseEnter:fn(d,x),onMouseLeave:fn(m,g),onTouchStart:fn(h,x)}]:[!1,p,{}]}function fn(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function fl({page:e,...t}){let{router:n}=Cr(),o=l.useMemo(()=>ar(n.routes,e,n.basename),[n.routes,e,n.basename]);return o?l.createElement(xl,{page:e,matches:o,...t}):null}function pl(e){let{manifest:t,routeModules:n}=jr(),[o,r]=l.useState([]);return l.useEffect(()=>{let a=!1;return il(e,t,n).then(i=>{a||r(i)}),()=>{a=!0}},[e,t,n]),o}function xl({page:e,matches:t,...n}){let o=le(),{future:r,manifest:a,routeModules:i}=jr(),{basename:c}=Cr(),{loaderData:u,matches:d}=hl(),m=l.useMemo(()=>Eo(e,t,d,a,o,"data"),[e,t,d,a,o]),h=l.useMemo(()=>Eo(e,t,d,a,o,"assets"),[e,t,d,a,o]),p=l.useMemo(()=>{if(e===o.pathname+o.search+o.hash)return[];let b=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:b.add(f.route.id))}),b.size===0)return[];let y=ol(e,c,r.unstable_trailingSlashAwareDataRequests,"data");return v&&b.size>0&&y.searchParams.set("_routes",t.filter(f=>b.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]),x=l.useMemo(()=>ll(h,a),[h,a]),g=pl(h);return l.createElement(l.Fragment,null,p.map(b=>l.createElement("link",{key:b,rel:"prefetch",as:"fetch",href:b,...n})),x.map(b=>l.createElement("link",{key:b,rel:"modulepreload",href:b,...n})),g.map(({key:b,link:v})=>l.createElement("link",{key:b,nonce:n.nonce,...v})))}function bl(...e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}var gl=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{gl&&(window.__reactRouterVersion="7.12.0")}catch{}function vl({basename:e,children:t,unstable_useTransitions:n,window:o}){let r=l.useRef();r.current==null&&(r.current=Ja({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(Qi,{basename:e,children:t,location:i.location,navigationType:i.action,navigator:a,unstable_useTransitions:n})}var Nr=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,_r=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,...x},g){let{basename:b,unstable_useTransitions:v}=l.useContext(Ne),y=typeof d=="string"&&Nr.test(d),f=mr(d,b);d=f.to;let w=Li(d,{relative:r}),[C,_,k]=ml(o,x),j=jl(d,{replace:i,state:c,target:u,preventScrollReset:m,relative:r,viewTransition:h,unstable_defaultShouldRevalidate:p,unstable_useTransitions:v});function S(B){t&&t(B),B.defaultPrevented||j(B)}let I=l.createElement("a",{...x,...k,href:f.absoluteURL||w,onClick:f.isExternal||a?t:S,ref:bl(g,_),target:u,"data-discover":!y&&n==="render"?"true":void 0});return C&&!y?l.createElement(l.Fragment,null,I,l.createElement(fl,{page:w})):I});_r.displayName="Link";var yl=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=_n(i,{relative:d.relative}),p=le(),x=l.useContext(as),{navigator:g,basename:b}=l.useContext(Ne),v=x!=null&&Rl(h)&&c===!0,y=g.encodeLocation?g.encodeLocation(h).pathname:h.pathname,f=p.pathname,w=x&&x.navigation&&x.navigation.location?x.navigation.location.pathname:null;n||(f=f.toLowerCase(),w=w?w.toLowerCase():null,y=y.toLowerCase()),w&&b&&(w=Ye(w,b)||w);const C=y!=="/"&&y.endsWith("/")?y.length-1:y.length;let _=f===y||!r&&f.startsWith(y)&&f.charAt(C)==="/",k=w!=null&&(w===y||!r&&w.startsWith(y)&&w.charAt(y.length)==="/"),j={isActive:_,isPending:k,isTransitioning:v},S=_?t:void 0,I;typeof o=="function"?I=o(j):I=[o,_?"active":null,k?"pending":null,v?"transitioning":null].filter(Boolean).join(" ");let B=typeof a=="function"?a(j):a;return l.createElement(_r,{...d,"aria-current":S,className:I,ref:m,style:B,to:i,viewTransition:c},typeof u=="function"?u(j):u)});yl.displayName="NavLink";var wl=l.forwardRef(({discover:e="render",fetcherKey:t,navigate:n,reloadDocument:o,replace:r,state:a,method:i=Qn,action:c,onSubmit:u,relative:d,preventScrollReset:m,viewTransition:h,unstable_defaultShouldRevalidate:p,...x},g)=>{let{unstable_useTransitions:b}=l.useContext(Ne),v=kl(),y=El(c,{relative:d}),f=i.toLowerCase()==="get"?"get":"post",w=typeof c=="string"&&Nr.test(c),C=_=>{if(u&&u(_),_.defaultPrevented)return;_.preventDefault();let k=_.nativeEvent.submitter,j=k?.getAttribute("formmethod")||i,S=()=>v(k||_.currentTarget,{fetcherKey:t,method:j,navigate:n,replace:r,state:a,relative:d,preventScrollReset:m,viewTransition:h,unstable_defaultShouldRevalidate:p});b&&n!==!1?l.startTransition(()=>S()):S()};return l.createElement("form",{ref:g,method:f,action:y,onSubmit:o?u:C,...x,"data-discover":!w&&e==="render"?"true":void 0})});wl.displayName="Form";function Cl(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Sr(e){let t=l.useContext(Yt);return V(t,Cl(e)),t}function jl(e,{target:t,replace:n,state:o,preventScrollReset:r,relative:a,viewTransition:i,unstable_defaultShouldRevalidate:c,unstable_useTransitions:u}={}){let d=Y(),m=le(),h=_n(e,{relative:a});return l.useCallback(p=>{if(Zi(p,t)){p.preventDefault();let x=n!==void 0?n:yn(m)===yn(h),g=()=>d(e,{replace:x,state:o,preventScrollReset:r,relative:a,viewTransition:i,unstable_defaultShouldRevalidate:c});u?l.startTransition(()=>g()):g()}},[m,d,h,n,o,t,e,r,a,i,c,u])}function Nl(e){je(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(Ms(e)),n=l.useRef(!1),o=le(),r=l.useMemo(()=>el(o.search,n.current?null:t.current),[o.search]),a=Y(),i=l.useCallback((c,u)=>{const d=Ms(typeof c=="function"?c(new URLSearchParams(r)):c);n.current=!0,a("?"+d,u)},[a,r]);return[r,i]}var _l=0,Sl=()=>`__${String(++_l)}__`;function kl(){let{router:e}=Sr("useSubmit"),{basename:t}=l.useContext(Ne),n=Wi(),o=e.fetch,r=e.navigate;return l.useCallback(async(a,i={})=>{let{action:c,method:u,encType:d,formData:m,body:h}=sl(a,t);if(i.navigate===!1){let p=i.fetcherKey||Sl();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 El(e,{relative:t}={}){let{basename:n}=l.useContext(Ne),o=l.useContext(Be);V(o,"useFormAction must be used inside a RouteContext");let[r]=o.matches.slice(-1),a={..._n(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:Qe([n,a.pathname])),yn(a)}function Rl(e,{relative:t}={}){let n=l.useContext(pr);V(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:o}=Sr("useViewTransitionState"),r=_n(e,{relative:t});if(!n.isTransitioning)return!1;let a=Ye(n.currentLocation.pathname,o)||n.currentLocation.pathname,i=Ye(n.nextLocation.pathname,o)||n.nextLocation.pathname;return Ht(r.pathname,i)!=null||Ht(r.pathname,a)!=null}var kr=Da(),Er=class extends rr{constructor(e,t){super(),this.options=t,this.#n=e,this.#i=null,this.#a=go(),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),Ro(this.#e,this.options)?this.#d():this.updateResult(),this.#v())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return $s(this.#e,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return $s(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 ke(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&&!Xn(this.options,t)&&this.#n.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#e,observer:this});const o=this.hasListeners();o&&To(this.#e,n,this.options,t)&&this.#d(),this.updateResult(),o&&(this.#e!==n||ke(this.options.enabled,this.#e)!==ke(t.enabled,this.#e)||gn(this.options.staleTime,this.#e)!==gn(t.staleTime,this.#e))&&this.#x();const r=this.#b();o&&(this.#e!==n||ke(this.options.enabled,this.#e)!==ke(t.enabled,this.#e)||r!==this.#l)&&this.#g(r)}getOptimisticResult(e){const t=this.#n.getQueryCache().build(this.#n,e),n=this.createResult(t,e);return Ll(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(Zn)),t}#x(){this.#y();const e=gn(this.options.staleTime,this.#e);if(Ps||this.#t.isStale||!vo(e))return;const n=Fa(this.#t.dataUpdatedAt,e)+1;this.#c=Un.setTimeout(()=>{this.#t.isStale||this.updateResult()},n)}#b(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#e):this.options.refetchInterval)??!1}#g(e){this.#w(),this.#l=e,!(Ps||ke(this.options.enabled,this.#e)===!1||!vo(this.#l)||this.#l===0)&&(this.#u=Un.setInterval(()=>{(this.options.refetchIntervalInBackground||Ba.isFocused())&&this.#d()},this.#l))}#v(){this.#x(),this.#g(this.#b())}#y(){this.#c&&(Un.clearTimeout(this.#c),this.#c=void 0)}#w(){this.#u&&(Un.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 S=this.hasListeners(),I=!S&&Ro(e,t),B=S&&To(e,n,t,o);(I||B)&&(m={...m,...qa(d.data,e.options)}),t._optimisticResults==="isRestoring"&&(m.fetchStatus="idle")}let{error:x,errorUpdatedAt:g,status:b}=m;p=m.data;let v=!1;if(t.placeholderData!==void 0&&p===void 0&&b==="pending"){let S;r?.isPlaceholderData&&t.placeholderData===i?.placeholderData?(S=r.data,v=!0):S=typeof t.placeholderData=="function"?t.placeholderData(this.#m?.state.data,this.#m):t.placeholderData,S!==void 0&&(b="success",p=yo(r?.data,S,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=yo(r?.data,p,t),this.#h=p,this.#i=null}catch(S){this.#i=S}this.#i&&(x=this.#i,p=this.#h,g=Date.now(),b="error");const y=m.fetchStatus==="fetching",f=b==="pending",w=b==="error",C=f&&y,_=p!==void 0,j={status:b,fetchStatus:m.fetchStatus,isPending:f,isSuccess:b==="success",isError:w,isInitialLoading:C,isLoading:C,data:p,dataUpdatedAt:m.dataUpdatedAt,error:x,errorUpdatedAt:g,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&&!_,isPaused:m.fetchStatus==="paused",isPlaceholderData:h,isRefetchError:w&&_,isStale:Ys(e,t),refetch:this.refetch,promise:this.#a,isEnabled:ke(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){const S=se=>{j.status==="error"?se.reject(j.error):j.data!==void 0&&se.resolve(j.data)},I=()=>{const se=this.#a=j.promise=go();S(se)},B=this.#a;switch(B.status){case"pending":e.queryHash===n.queryHash&&S(B);break;case"fulfilled":(j.status==="error"||j.data!==B.value)&&I();break;case"rejected":(j.status!=="error"||j.error!==B.reason)&&I();break}}return j}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),Xn(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){rs.batch(()=>{e.listeners&&this.listeners.forEach(t=>{t(this.#t)}),this.#n.getQueryCache().notify({query:this.#e,type:"observerResultsUpdated"})})}};function Tl(e,t){return ke(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function Ro(e,t){return Tl(e,t)||e.state.data!==void 0&&$s(e,t,t.refetchOnMount)}function $s(e,t,n){if(ke(t.enabled,e)!==!1&&gn(t.staleTime,e)!=="static"){const o=typeof n=="function"?n(e):n;return o==="always"||o!==!1&&Ys(e,t)}return!1}function To(e,t,n,o){return(e!==t||ke(o.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&Ys(e,n)}function Ys(e,t){return ke(t.enabled,e)!==!1&&e.isStaleByTime(gn(t.staleTime,e))}function Ll(e,t){return!Xn(e.getCurrentResult(),t)}var Al=class extends Er{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:wo()})}getOptimisticResult(e){return e.behavior=wo(),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:Wa(t,n.data),hasPreviousPage:Ua(t,n.data),isFetchNextPageError:d,isFetchingNextPage:m,isFetchPreviousPageError:h,isFetchingPreviousPage:p,isRefetchError:c&&!d&&!h,isRefetching:a&&!m&&!p}}},Pl=class extends rr{#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),Xn(this.options,n)||this.#n.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#s,observer:this}),n?.mutationKey&&this.options.mutationKey&&Co(n.mutationKey)!==Co(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??Ha();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){rs.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)})})}},Rr=l.createContext(void 0),Tr=e=>{const t=l.useContext(Rr);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},Il=({client:e,children:t})=>(l.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),s.jsx(Rr.Provider,{value:e,children:t})),Lr=l.createContext(!1),Ol=()=>l.useContext(Lr);Lr.Provider;function Ml(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var $l=l.createContext(Ml()),Dl=()=>l.useContext($l),Fl=(e,t,n)=>{const o=n?.state.error&&typeof e.throwOnError=="function"?Ws(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||o)&&(t.isReset()||(e.retryOnMount=!1))},Bl=e=>{l.useEffect(()=>{e.clearReset()},[e])},ql=({result:e,errorResetBoundary:t,throwOnError:n,query:o,suspense:r})=>e.isError&&!t.isReset()&&!e.isFetching&&o&&(r&&e.data===void 0||Ws(n,[e.error,o])),Ul=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))}},Wl=(e,t)=>e.isLoading&&e.isFetching&&!t,Hl=(e,t)=>e?.suspense&&t.isPending,Lo=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function Ar(e,t,n){const o=Ol(),r=Dl(),a=Tr(),i=a.defaultQueryOptions(e);a.getDefaultOptions().queries?._experimental_beforeQuery?.(i);const c=a.getQueryCache().get(i.queryHash);i._optimisticResults=o?"isRestoring":"optimistic",Ul(i),Fl(i,r,c),Bl(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 x=h?d.subscribe(rs.batchCalls(p)):Zn;return d.updateResult(),x},[d,h]),()=>d.getCurrentResult(),()=>d.getCurrentResult()),l.useEffect(()=>{d.setOptions(i)},[i,d]),Hl(i,m))throw Lo(i,d,r);if(ql({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&&!Ps&&Wl(m,o)&&(u?Lo(i,d,r):c?.promise)?.catch(Zn).finally(()=>{d.updateResult()}),i.notifyOnChangeProps?m:d.trackResult(m)}function ce(e,t){return Ar(e,Er)}function X(e,t){const n=Tr(),[o]=l.useState(()=>new Pl(n,e));l.useEffect(()=>{o.setOptions(e)},[o,e]);const r=l.useSyncExternalStore(l.useCallback(i=>o.subscribe(rs.batchCalls(i)),[o]),()=>o.getCurrentResult(),()=>o.getCurrentResult()),a=l.useCallback((i,c)=>{o.mutate(i,c).catch(Zn)},[o]);if(r.error&&Ws(o.options.throwOnError,[r.error]))throw r.error;return{...r,mutate:a,mutateAsync:r.mutate}}function Pr(e,t){return Ar(e,Al)}const rt="data-sources",Ir="auth-user",zl=e=>ce({queryKey:["project","datasources",e],queryFn:async()=>{const{data:t}=await O.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})])},Vl=e=>{const t=["trash","team"];return K.invalidateQueries({queryKey:t})},Ql=(e,t)=>ce({queryKey:["project",t.teamId,"tables",e,t.selectedDataSources],queryFn:async()=>{const{data:n}=await O.get(`/project/team/${t.teamId}/query`,{params:{size:30,search:e,selectedDataSources:t.selectedDataSources}});return n.data},enabled:!!t.teamId,staleTime:0}),Kl=(e,t=30,n)=>Pr({queryKey:["project","tabs-history",e,t,n],queryFn:async({pageParam:o})=>{const{data:a}=await O.get(`/project/team/${e}/tabs-history?page=${o}&size=${t}`);return a},select:({pages:o})=>o.flatMap(r=>r.data),enabled:!!e,initialPageParam:0,getNextPageParam:(o,r)=>{if(o.hasMore)return r.length},staleTime:0}),Gl=(e,t="",n=20)=>Pr({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 O.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}}),Yl=(e,t=10,n=!1)=>ce({queryKey:["project","recent-tabs",e,t,n],queryFn:async()=>{const{data:o}=await O.get(`/project/team/${e}/tabs-history?page=0&size=${t}&archived=${n}`);return o.data},enabled:!!e,staleTime:0}),Jl=e=>X({mutationFn:async()=>{const{data:t}=await O.get(`/project/team/${e}/tabs-history?page=0&size=1&archived=false`);return t.data?.length?t.data[0]:void 0}}),Xl=e=>ce({queryKey:["project","count-saved-queries",e],queryFn:async()=>{const{data:t}=await O.get(`/project/team/${e}/count-saved-queries`);return t.data}}),Zl=()=>Promise.all([K.invalidateQueries({queryKey:["project","tabs-history"]}),K.invalidateQueries({queryKey:["project","recent-tabs"]})]),Or=()=>K.invalidateQueries({queryKey:["project","count-saved-queries"]}),ec=(e,t)=>{},tc=()=>{},nc={event:ec,pageView:tc},ls=e=>ce({queryKey:[rt,e],queryFn:async()=>{const{data:t}=await O.get("/data-sources/"+e);return t.data},enabled:!!e}),Js=e=>ce({queryKey:[rt,e.teamId],queryFn:async()=>{const{data:t}=await O.get("/data-sources",{params:e});return t.data},enabled:e.teamId!==void 0}),Sn=e=>ce({queryKey:[rt,e,"inspections"],queryFn:async()=>{const{data:t}=await O.get(`/data-sources/${e}/inspections`);return t.data},enabled:!!e}),sc=()=>X({mutationFn:async e=>{const{data:t}=await O.post("/data-sources",e);return t.data},onSuccess:()=>{K.invalidateQueries({queryKey:[rt]}),Jt()},onError:()=>{}}),oc=()=>X({mutationFn:async({dataSource:e,id:t})=>{const{data:n}=await O.put(`/data-sources/${t}`,e);return n.data},onSuccess:()=>{K.invalidateQueries({queryKey:[rt]}),Jt()}}),Mr=()=>X({mutationFn:async e=>{await O.post(`/data-sources/${e}/inspect`)},onSuccess:()=>{K.invalidateQueries({queryKey:[rt]})}}),rc=()=>X({mutationFn:async e=>{await O.delete(`/data-sources/${e}`)},onSuccess:()=>{K.invalidateQueries({queryKey:[rt]}),Jt()}}),$r=()=>ce({queryKey:["accessToken"],queryFn:Hs.get}),ue=()=>{const{data:e}=$r();return ce({queryKey:[Ir],queryFn:async()=>{const{data:t}=await O.get("/users");return t.data},enabled:!!e,retry:(t,n)=>za(n)&&n.code==="ERR_NETWORK"?!1:t<3})},ac=()=>X({mutationFn:async e=>{const{data:t}=await O.patch("/users",e);return t.data},onSuccess:async e=>{K.setQueryData([Ir],e)}}),ic=()=>X({mutationFn:async e=>(await O.post("/users",e),!0),onSuccess:()=>{K.invalidateQueries({queryKey:["team-users"]})}}),_e=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 lc(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=>ce({queryKey:["hooks",e],queryFn:async()=>{const t=await K.fetchQuery({queryKey:[rt,e,"inspections"],queryFn:async()=>{const{data:n}=await O.get(`/data-sources/${e}/inspections`);return n.data}});return lc(t)},enabled:!!e}),Dr=[{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"}],uc=Dr.reduce((e,t)=>(e[t.value]=t.label,e),{});Dr.reduce((e,t)=>(e[t.label]=t.value,e),{});const Xt=e=>e.map(t=>({label:uc[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 dc=["char","varchar","binary","varbinary","blob","text","enum","set","character","character varying","text","citext","uuid","xml","json","jsonb"];new Set(dc);const hc=["integer","smallint","decimal","numeric","float","real","double precision","int","smallint","integer","bigint","decimal","numeric","real","double precision","serial","bigserial","money"];new Set(hc);const mc=["date","datetime","timestamp","timestamptz"].reduce((e,t)=>(e[t]=!0,e),{}),Fr=e=>e.fn?e.distinct===!0?`${e.fn} distinct ${e.value}`:`${e.fn} ${e.value}`:e.value;var pe=(e=>(e.OWNER="owner",e.ADMIN="admin",e.EDITOR="editor",e.READ_ONLY="read_only",e))(pe||{});const Ao={[pe.READ_ONLY]:10,[pe.EDITOR]:20,[pe.ADMIN]:30,[pe.OWNER]:40};function fc(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 pc(e,t,n,o){const{data:r}=cc(t),{data:a}=Sn(t);return l.useMemo(()=>{const i=fc(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=Fr(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 xc(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 bc(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=>!!Ht({path:t,end:!0},r)}}function kn(e,t){return{name:e,path:t,build:()=>t,check:n=>n===t}}const gc=kn("Home","/"),vc=kn("Workbench","/workbench"),yc=kn("Share query","/share"),wc=kn("Login","/login"),Cc=kn("Saved queries","/saved-queries"),jc=bc("Workbench tab","/workbench/tab/:id"),P={home:gc,workbench:vc,share:yc,login:wc,savedQueries:Cc,workbenchTab:jc},Xs=e=>{K.setQueryData(["workbench-tabs"],t=>e(t||[]))},Nc=(e,t)=>{K.setQueryData(["workbench-tabs",e],n=>n&&t(n))},cs=()=>ce({queryKey:["workbench-tabs"],queryFn:async()=>{const{data:e}=await O.get("/workbench-tabs");return e.data}}),_c=e=>ce({queryKey:["workbench-tabs",e],queryFn:async()=>{const{data:t}=await O.get(`/workbench-tabs/${e}`);return t.data}}),en=()=>X({mutationFn:async e=>{const{data:t}=await O.post("/workbench-tabs",e);return t.data},onSuccess:async e=>{Xs(t=>[...t,e])}}),Sc=()=>X({mutationFn:async e=>(await O.patch(`/workbench-tabs/${e}`,{archived:!0}),e),onMutate:e=>{Xs(t=>t.filter(n=>n.id!==e))}}),Br=()=>X({mutationFn:async e=>(await O.patch(`/workbench-tabs/${e}`,{archived:!1}),e),onSuccess:()=>Ur()}),kc=()=>X({mutationFn:async({id:e,payload:t})=>(await O.patch(`/workbench-tabs/${e}`,t),!0),onMutate:({id:e,payload:t})=>{Nc(e,n=>({...n,...t})),Xs(n=>n.map(o=>o.id!==e?o:{...o,name:t.name||o.name}))}}),Ec=(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 ce({queryKey:["workbench-tab-runner",e,n,r,h,p,a,m,i,c,u,d,o],queryFn:async()=>{const{data:x}=await O.post(`/workbench-tabs/${e}/run`,t);return x.data},retry:1,enabled:!!r&&!!n,placeholderData:Va})},Rc=()=>X({mutationFn:async e=>{await O.delete(`/workbench-tabs/${e}`)},onSuccess:()=>{Ur(),Zl()}}),qr=e=>K.invalidateQueries({queryKey:["workbench-tab-runner",e]}),Ur=()=>K.invalidateQueries({queryKey:["workbench-tabs"]}),[Tc,js,Lc]=_e(void 0),Ac=async()=>new Promise(e=>{js({onCancel:()=>{js(void 0),e(void 0)},onConfirm:(t,n,o)=>{js(void 0),e({dsId:o,id:n,type:t})}})}),En=e=>{const t=Y(),n=en(),o=Br();return l.useEffect(()=>{n?.data?.id&&t(P.workbenchTab.build({id:n.data.id})),o?.data&&t(P.workbenchTab.build({id:o.data}))},[n.data,o.data]),l.useCallback(()=>{Lc.get()||Ac().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])},Rn=e=>{const{data:t}=ue();return l.useMemo(()=>t?Ao[t.teamRole]>=Ao[e]:!1,[t,e])},Pc="_input_1hufc_2",Ic="_label_1hufc_2",Oc="_content_1hufc_2",Mc="_form_1hufc_2",$c="_mode-select_1hufc_2",vt={input:Pc,label:Ic,content:Oc,form:Mc,switch:"_switch_1hufc_2",modeSelect:$c},Dc="_modal_1t5ps_2",Fc="_modal-visible_1t5ps_2",Bc="_modal-invisible_1t5ps_2",qc="_backdrop_1t5ps_2",Uc="_modal-container_1t5ps_2",Wc="_close-button_1t5ps_2",Ut={modal:Dc,modalVisible:Fc,modalInvisible:Bc,backdrop:qc,modalContainer:Uc,closeButton:Wc},Ct=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"})),ve=({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]);const h=s.jsxs("div",{onTransitionEnd:m,className:A(Ut.modal,n?Ut.modalVisible:Ut.modalInvisible),children:[s.jsx("div",{onClick:d,className:Ut.backdrop}),s.jsx("div",{className:A(Ut.modalContainer,a!==!0&&"p-4"),children:c&&e})]});return i?kr.createPortal(h,document.body):h},at=({onClick:e})=>{const t=l.useRef(e);return t.current=e,l.useEffect(()=>{const n=o=>{o.key==="Escape"&&t.current?.()};return window.addEventListener("keyup",n),()=>{window.removeEventListener("keyup",n)}},[]),s.jsx("button",{className:Ut.closeButton,onClick:e,children:s.jsx(Ct,{width:20,height:20})})},Wr=({children:e})=>s.jsx("h2",{className:"text-xl font-semibold",children:e}),Hc=({form:e,change:t,shape:n})=>s.jsx("div",{className:vt.form,children:n.fields.map(o=>s.jsxs("label",{className:vt.input,children:[s.jsx("p",{className:vt.label,children:o.label}),s.jsx("input",{value:e[o.name],onChange:t(o.name),type:o.type})]},o.name))}),Dt=[{label:"PostgreSQL",tag:"postgres"},{label:"MySQL",tag:"mysql"}],zc={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"}]},Vc={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"}]},Qc=({show:e,onClose:t,dbType:n="postgres"})=>{const o=sc(),r=Mr(),{data:a}=ue(),[i,{change:c,set:u}]=Cn({name:"",dbType:n,dbUrl:"",dbUser:"",dbPassword:"",dbDatabase:"",dbSchema:"",dbPort:5432,teamId:"",ownerId:"",description:"",allowInsert:!1,allowUpdate:!1}),d=async()=>{const g=await o.mutateAsync({...i,dbPort:Number(i.dbPort),teamId:a.teamId,ownerId:a.id});await r.mutateAsync(g.id),t(),nc.event("Create Datasource",{dbType:i.dbType})},m=g=>{u("allowInsert",!g),u("allowUpdate",!g)},h=()=>{t()},p=o.isPending||r.isPending,x=!i.allowInsert&&!i.allowUpdate;return s.jsxs(ve,{isVisible:e,onClose:h,portal:!0,children:[s.jsxs("div",{className:"max-w-xl mx-auto overflow-y-auto",children:[o.isError&&s.jsx(ne,{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(ne,{className:"mb-2",variant:"info",children:"Creating connection"}),r.isPending&&s.jsx(ne,{className:"mb-2",variant:"info",children:"Inspecting connection"}),s.jsxs("div",{className:vt.switch,children:[s.jsxs("label",{className:"button tertiary",children:[s.jsx("input",{type:"radio",name:"bdType",className:"mr-2",checked:i.dbType===Dt[0].tag,onChange:()=>u("dbType",Dt[0].tag)}),s.jsx("span",{children:Dt[0].label})]}),s.jsxs("label",{className:"button tertiary",children:[s.jsx("input",{type:"radio",name:"bdType",className:"mr-2",checked:i.dbType===Dt[1].tag,onChange:()=>u("dbType",Dt[1].tag)}),s.jsx("span",{children:Dt[1].label})]})]}),s.jsxs("div",{className:"mt-2",children:[s.jsxs("div",{className:vt.content,children:[s.jsx(Hc,{form:i,change:c,shape:i.dbType==="mysql"?zc:Vc}),s.jsxs("div",{className:"flex flex-col",children:[s.jsx("label",{className:"text-sm font-semibold",children:"Name"}),s.jsx("input",{value:i.name,onChange:c("name"),className:"input"})]})]}),s.jsxs("div",{className:"mt-4",children:[s.jsxs("label",{className:vt.modeSelect,children:[s.jsxs("div",{children:[s.jsx("input",{type:"radio",name:"production-mode",className:"mr-2",checked:x,onChange:()=>m(!0)}),s.jsx("span",{className:"text-sm font-semibold",children:"Production mode"})]}),s.jsxs("p",{className:"text-xs mt-1 text-gray-600",children:["Mutation operations (such as INSERT or UPDATE) are ",s.jsx("strong",{children:"forbidden"}),". You won't be able to insert new rows or edit existing data. Tables in this data source are read-only."]})]}),s.jsxs("label",{className:vt.modeSelect,children:[s.jsxs("div",{children:[s.jsx("input",{type:"radio",name:"production-mode",className:"mr-2",checked:!x,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"})]})]})},Kc="_data-source-entry_14xie_2",Gc="_action-title_14xie_2",Yc="_action-subtext_14xie_2",Jc="_dev-tag_14xie_2",Xc="_prod-tag_14xie_2",Zc="_recent-tabs-container_14xie_2",eu="_recent-tabs-entry_14xie_2",tu="_home-action-button_14xie_2",nu="_home-gray-card_14xie_2",su="_home-card-title_14xie_2",ou="_home-card-grid-content_14xie_2",D={dataSourceEntry:Kc,actionTitle:Gc,actionSubtext:Yc,devTag:Jc,prodTag:Xc,recentTabsContainer:Zc,recentTabsEntry:eu,homeActionButton:tu,homeGrayCard:nu,homeCardTitle:su,homeCardGridContent:ou},ru=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"})),au=e=>l.createElement("svg",{width:"800px",height:"800px",viewBox:"0 0 32 32",xmlns:"http://www.w3.org/2000/svg",...e},l.createElement("title",null,"file_type_pgsql"),l.createElement("path",{d:"M29.507,18.773a1.378,1.378,0,0,0-1.144-.921,2.619,2.619,0,0,0-.913.051,8.2,8.2,0,0,1-1.406.185,27.125,27.125,0,0,0,2.872-6.83c.953-3.689.444-5.369-.151-6.13A8.239,8.239,0,0,0,22.121,2a11.773,11.773,0,0,0-3.453.484A12.858,12.858,0,0,0,16.648,2.3a6.565,6.565,0,0,0-3.518.867,16.039,16.039,0,0,0-2.484-.624,7.694,7.694,0,0,0-5.819.924C3.093,4.691,2.289,6.819,2.438,9.792A36.351,36.351,0,0,0,3.844,16.33a22.579,22.579,0,0,0,1.514,3.863A4.786,4.786,0,0,0,7.8,22.742a2.4,2.4,0,0,0,2.379-.516,2.08,2.08,0,0,0,.5.43,3.328,3.328,0,0,0,.944.4,5.069,5.069,0,0,0,3.3-.2c.006.171.011.335.014.477.006.229.013.454.021.665a11.641,11.641,0,0,0,.441,3.3c.016.043.037.107.059.176a3.975,3.975,0,0,0,.991,1.745,2.955,2.955,0,0,0,2.09.777,4.7,4.7,0,0,0,.977-.109A4.592,4.592,0,0,0,22.607,28.1c.811-1.155,1.206-2.894,1.277-5.635.009-.078.018-.152.026-.222l.017-.145.191.017.049,0a7.562,7.562,0,0,0,3.163-.548c.631-.293,2.654-1.361,2.177-2.8"}),l.createElement("path",{d:"M27.689,19.053c-3.163.652-3.38-.418-3.38-.418C27.648,13.68,29.044,7.39,27.839,5.851c-3.286-4.2-8.975-2.213-9.07-2.162l-.031.006a11.28,11.28,0,0,0-2.11-.22,5.212,5.212,0,0,0-3.34,1S3.14.294,3.612,9.733c.1,2.008,2.878,15.194,6.191,11.211,1.211-1.456,2.381-2.688,2.381-2.688a3.071,3.071,0,0,0,2.006.512l.057-.048a2.21,2.21,0,0,0,.023.567c-.854.954-.6,1.121-2.309,1.472-1.726.356-.712.989-.05,1.155a3.508,3.508,0,0,0,3.915-1.272l-.05.2c.334.268.569,1.742.53,3.079a8.481,8.481,0,0,0,.2,2.971c.264.717.526,2.329,2.769,1.849a3.307,3.307,0,0,0,2.98-3.179c.1-1.234.313-1.052.326-2.155l.174-.522c.2-1.673.032-2.213,1.186-1.962l.281.025a6.4,6.4,0,0,0,2.615-.44c1.406-.652,2.239-1.742.853-1.455h0",style:{fill:"#336791"}}),l.createElement("path",{d:"M13.882,10.631a.981.981,0,0,0-.674.1.247.247,0,0,0-.1.164.48.48,0,0,0,.117.314.881.881,0,0,0,.559.349.637.637,0,0,0,.09.006.725.725,0,0,0,.687-.467c.035-.248-.326-.414-.676-.463m9.442.008c-.027-.195-.374-.25-.7-.2s-.647.194-.62.389a.667.667,0,0,0,.62.411.592.592,0,0,0,.083-.006.8.8,0,0,0,.451-.247.5.5,0,0,0,.169-.343",style:{fill:"#fff"}}),l.createElement("path",{d:"M28.741,18.979c-.121-.365-.509-.482-1.154-.349-1.915.4-2.6.121-2.826-.044a26.327,26.327,0,0,0,3.373-7.565,14.374,14.374,0,0,0,.5-3.253,3.513,3.513,0,0,0-.509-2.2,7.482,7.482,0,0,0-6.049-2.825,10.363,10.363,0,0,0-3.5.551,8.717,8.717,0,0,0-1.968-.253,5.684,5.684,0,0,0-3.372.929,15.051,15.051,0,0,0-2.74-.718,6.978,6.978,0,0,0-5.242.805c-1.5,1.064-2.2,2.966-2.061,5.653a35.489,35.489,0,0,0,1.373,6.348c1.07,3.505,2.233,5.49,3.457,5.9a1.548,1.548,0,0,0,.491.081,2.049,2.049,0,0,0,1.563-.886q1.042-1.25,2.155-2.438a3.472,3.472,0,0,0,1.55.417l0,.042q-.14.166-.273.338c-.375.475-.452.574-1.658.823-.343.071-1.254.259-1.267.9-.014.7,1.077.991,1.2,1.022a5.144,5.144,0,0,0,1.249.162,3.634,3.634,0,0,0,2.5-.934,23.674,23.674,0,0,0,.381,5.684,2.854,2.854,0,0,0,2.729,2.1,4.378,4.378,0,0,0,.917-.1,3.462,3.462,0,0,0,3.156-3.212c.177-1.026.481-3.475.624-4.789a3.859,3.859,0,0,0,1.11.137,6.6,6.6,0,0,0,2.519-.48c.712-.331,2-1.141,1.763-1.846ZM24.051,10.1a7.968,7.968,0,0,1-.116,1.107,10.229,10.229,0,0,0-.14,1.3,9.859,9.859,0,0,0,.1,1.47,5.236,5.236,0,0,1-.229,2.986,3.882,3.882,0,0,1-.207-.426c-.058-.141-.185-.368-.359-.681-.68-1.22-2.274-4.078-1.458-5.244.243-.347.86-.7,2.408-.512ZM22.174,3.531a6.617,6.617,0,0,1,5.334,2.522c.975,1.245-.1,6.912-3.205,11.8l-.094-.119-.039-.049a5.524,5.524,0,0,0,.506-3.8,9.114,9.114,0,0,1-.1-1.352,9.572,9.572,0,0,1,.131-1.206,7.614,7.614,0,0,0,.123-1.493.619.619,0,0,0,.013-.21,8.381,8.381,0,0,0-1.912-3.6,8.61,8.61,0,0,0-3.039-2.284,10.246,10.246,0,0,1,2.28-.214ZM9.479,20.654c-.627.754-1.061.61-1.2.562-.928-.31-2.006-2.272-2.955-5.384a35.167,35.167,0,0,1-1.34-6.159c-.12-2.4.462-4.074,1.73-4.974,2.063-1.463,5.456-.587,6.819-.143-.02.019-.04.037-.059.057-2.237,2.259-2.184,6.119-2.178,6.355,0,.091.007.22.018.4a15.969,15.969,0,0,1-.081,3.226A4.08,4.08,0,0,0,11.3,18.007q.133.138.278.262c-.383.41-1.216,1.318-2.1,2.385Zm2.39-3.19a3.3,3.3,0,0,1-.865-2.764,16.7,16.7,0,0,0,.087-3.381c-.006-.095-.011-.178-.014-.243A4.3,4.3,0,0,1,14,10.223a1.188,1.188,0,0,1,.918,1.026c.646,2.989.085,4.234-.365,5.235-.093.206-.181.4-.255.6l-.058.156a10.218,10.218,0,0,0-.368,1.109,2.788,2.788,0,0,1-2-.887Zm.113,4.03a1.733,1.733,0,0,1-.523-.225,2.553,2.553,0,0,1,.557-.166c1.418-.292,1.637-.5,2.116-1.105.11-.139.234-.3.406-.489h0c.256-.287.374-.238.586-.15a.829.829,0,0,1,.408.525.585.585,0,0,1-.05.491A3.1,3.1,0,0,1,11.983,21.495ZM19.406,28.4a2.113,2.113,0,0,1-2.754-1.526,31.129,31.129,0,0,1-.3-6.853.392.392,0,0,0-.017-.124,1.643,1.643,0,0,0-.048-.23,1.589,1.589,0,0,0-.862-1.034,1.216,1.216,0,0,0-.793-.1,9.586,9.586,0,0,1,.342-1.022l.058-.157c.066-.177.148-.36.235-.554.471-1.047,1.117-2.482.416-5.722a2.044,2.044,0,0,0-2.468-1.669A5.694,5.694,0,0,0,11.328,10c-.078.04-.15.078-.216.115A8.244,8.244,0,0,1,13.03,5.163,4.711,4.711,0,0,1,16.6,3.827,7.567,7.567,0,0,1,22.381,6.59,8.774,8.774,0,0,1,23.963,9.3c-1.463-.149-2.458.14-2.962.861-1.1,1.568.6,4.612,1.416,6.075.15.268.279.5.319.6a5.432,5.432,0,0,0,.861,1.387c.077.1.152.189.208.271-.443.128-1.239.423-1.166,1.9-.058.74-.474,4.205-.686,5.43-.279,1.617-.874,2.22-2.548,2.579Zm7.242-8.288a5.714,5.714,0,0,1-1.931.4,2.422,2.422,0,0,1-1.3-.167c-.045-.919.3-1.015.66-1.117.057-.016.112-.032.166-.05a1.353,1.353,0,0,0,.11.08c.639.422,1.78.467,3.39.135l.018,0a4.334,4.334,0,0,1-1.116.72Z",style:{fill:"#fff"}})),it=({size:e,type:t})=>t==="mysql"?s.jsx(ru,{width:e,height:e}):s.jsx(au,{width:e,height:e}),[iu,zt]=_e(void 0),[lu,Vt]=_e({show:!1}),cu=()=>{const e=En("Home");return s.jsx("div",{className:D.homeActionButton,onClick:e,children:s.jsxs("h2",{className:D.actionTitle,children:[s.jsx("span",{className:"truncate",children:"🔎 Start new query"}),s.jsx("span",{className:"hotkey",children:"N"})]})})},uu=()=>{const e=Y();return s.jsx("div",{className:D.homeActionButton,onClick:()=>e(P.savedQueries.build()),children:s.jsx("h2",{className:D.actionTitle,children:s.jsx("span",{className:"truncate",children:"💾 Saved queries"})})})},du=()=>{const[e,t]=l.useState(void 0),n=Rn(pe.EDITOR),o=r=>{n?t(r):Re.error("You don't have permission to connect new data sources in this team")};return s.jsxs("div",{children:[e&&s.jsx(Qc,{show:!0,dbType:e,onClose:()=>t(void 0)}),s.jsx("div",{className:D.homeActionButton,onClick:()=>o("postgres"),children:s.jsx("p",{className:D.actionTitle,children:"🧙♂️ Connection wizard"})})]})},hu=()=>{const e=Y(),{data:t}=cs(),n=En("Home"),o=()=>{t&&t.length>0?e(P.workbenchTab.build({id:t[0].id})):n()};return s.jsx("div",{className:D.homeActionButton,onClick:o,children:s.jsxs("h2",{className:D.actionTitle,children:[s.jsx("span",{children:"🛠️ Workbench"}),s.jsx("span",{className:"hotkey",children:"W"})]})})},mu=()=>{const{data:e}=ue(),{data:t}=Js({teamId:e?.teamId}),n=o=>{zt(o)};return!t||t.length===0?null:s.jsxs("div",{className:D.homeGrayCard,children:[s.jsx("h2",{className:D.homeCardTitle,children:"Data sources"}),s.jsx("div",{className:D.homeCardGridContent,children:t?.map(o=>s.jsxs("div",{className:D.dataSourceEntry,onClick:()=>n(o.id),tabIndex:0,children:[s.jsx(it,{size:32,type:o.dbType}),s.jsxs("div",{className:"overflow-hidden",children:[s.jsx("p",{className:D.actionTitle,children:o.name}),o.allowInsert?s.jsx("span",{className:D.devTag,children:"dev"}):s.jsx("span",{className:D.prodTag,children:"prod"})]})]},o.id))})]})},fu=()=>s.jsxs("div",{className:D.homeGrayCard,children:[s.jsx("h2",{className:D.homeCardTitle,children:"Useful links"}),s.jsxs("div",{className:D.homeCardGridContent,children:[s.jsxs("a",{className:D.homeActionButton,href:"https://dataramen.xyz/",target:"_blank",children:[s.jsx("h2",{className:D.actionTitle,children:"↗️ Documentation"}),s.jsx("p",{className:D.actionSubtext,children:"Learn how to use DataRamen"})]}),s.jsxs("a",{className:D.homeActionButton,href:"https://github.com/OleksandrDemian/dataramen",target:"_blank",children:[s.jsx("h2",{className:D.actionTitle,children:"↗️ Github"}),s.jsx("p",{className:D.actionSubtext,children:"Codebase is open source"})]}),s.jsxs("a",{className:D.homeActionButton,href:"#",onClick:()=>Vt({show:!0}),children:[s.jsxs("h2",{className:D.actionTitle,children:[s.jsx("span",{children:"⌛ Recent tabs"}),s.jsx("span",{className:"hotkey",children:"H"})]}),s.jsx("p",{className:D.actionSubtext,children:"Manage recent tabs"})]})]})]}),pu=()=>{const{data:e}=ue(),{data:t,isLoading:n}=Yl(e?.teamId),o=Y();if(n||!t?.length)return null;const r=a=>{o(P.workbenchTab.build({id:a}))};return s.jsxs("div",{className:D.recentTabsContainer,children:[s.jsx("h2",{className:D.homeCardTitle+" px-4 mb-4",children:"Recent tabs"}),t.map(a=>s.jsxs("div",{className:D.recentTabsEntry,onClick:()=>r(a.id),children:[s.jsx("p",{className:"text-(--text-color-primary) truncate",children:a.name}),s.jsxs("p",{className:"flex items-center gap-2",children:[s.jsx(it,{size:20,type:a.dataSourceType}),s.jsx("span",{className:"text-sm text-(--text-color-secondary) truncate",children:a.dataSourceName})]})]},a.id))]})},xu=()=>{const{data:e}=ue(),{data:t}=Js({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.jsx("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)",children:"DataRamen"})}),s.jsxs("div",{className:"flex flex-col gap-8 mt-8 bg-(--bg) z-1",children:[o&&!n&&s.jsx(ne,{variant:"warning",className:"font-semibold",children:"Connect at least one data source to start using DataRamen"}),s.jsxs("div",{className:D.homeGrayCard,children:[s.jsx("h2",{className:D.homeCardTitle,children:"Quick actions"}),s.jsxs("div",{className:D.homeCardGridContent,children:[s.jsx(cu,{}),s.jsx(du,{}),o&&s.jsx(hu,{}),s.jsx(uu,{})]})]}),o&&s.jsx(mu,{}),s.jsx(pu,{}),s.jsx(fu,{})]})]})})},[bu,Zs]=_e(void 0),gu=()=>Zs(void 0);function yt(e,t){if(e==null)return"";switch(t){case"json":case"jsonb":return JSON.stringify(e,null,2)}if(e===0||e===!1)return e.toString();switch(typeof e){case"string":return e;case"number":case"boolean":return e.toString();default:return JSON.stringify(e)}}const Gn=e=>e.distinct?[e.fn,"DISTINCT",e.value].join(" "):[e.fn,e.value].join(" "),et=e=>{let t=e.replace(/[_-]+/g," ");return t=t.replace(/([a-z0-9])([A-Z])/g,"$1 $2"),t=t.toLowerCase().replace(/\b\w/g,n=>n.toUpperCase()),t},vu="_container_d92uy_2",yu="_header_d92uy_2",wu="_fields-container_d92uy_2",Cu="_field-label_d92uy_2",ju="_actions_d92uy_2",pn={container:vu,header:yu,fieldsContainer:wu,fieldLabel:Cu,actions:ju},Nu=(e,t,n)=>ce({queryKey:["entity",e,t,n],queryFn:async()=>{const{data:o}=await O.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}),_u=()=>X({mutationFn:async e=>{const{data:t}=await O.post(`/runner/${e.datasourceId}/update`,e);return t.data}}),Su=()=>X({mutationFn:async e=>{const{data:t}=await O.post(`/runner/${e.datasourceId}/insert`,e);return t.data}}),eo=e=>l.useMemo(()=>{if(e)return e instanceof Qa?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]),to=()=>{const{pathname:e}=le();return l.useMemo(()=>Ht({path:P.workbenchTab.path,end:!1},e)?.params.id,[e])},ku=({data:e})=>{const[t,{change:n,touched:o}]=Cn({}),r=to(),{mutateAsync:a,error:i}=Su(),c=eo(i),{data:u}=Sn(e.dataSourceId),[d,m]=l.useState(""),h=l.useMemo(()=>u?.find(g=>g.tableName===e.table),[u,e.table]),p=l.useMemo(()=>{if(!h)return[];if(!d)return h.columns.map(b=>({...b,label:et(b.name)}));const g=d.toLowerCase();return h.columns.filter(b=>b.name.toLowerCase().includes(g)).map(b=>({...b,label:et(b.name)}))},[d,h]),x=()=>{const g=[];for(const b of o)g.push({value:t[b],column:b});a({datasourceId:e.dataSourceId,table:e.table,values:g}).then(()=>{gu(),r&&qr(r)})};return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:pn.header,children:[s.jsxs("p",{className:"text-lg font-semibold",children:["Insert new row in ",s.jsx("span",{className:"underline",children:e.table})]}),c&&s.jsx(ne,{variant:"danger",children:s.jsx("p",{children:c})})]}),s.jsx("div",{className:"bg-gray-50 py-1 px-4 border-y border-gray-200",children:s.jsx("p",{className:"text-xs text-gray-800",children:"Tip: use = to write raw SQL. Ex: =NULL or =NOW()"})}),s.jsx("div",{className:pn.container,children:s.jsx("div",{className:pn.fieldsContainer,children:p.map(g=>s.jsxs("label",{className:pn.fieldLabel,children:[s.jsxs("div",{className:"flex justify-between",children:[s.jsxs("p",{children:[g.isPrimary?"🔐":"🏷️"," ",g.label]}),s.jsxs("p",{className:"text-blue-800 text-sm",children:["[",g.name,": ",g.type,"]"]})]}),s.jsx("input",{className:"input w-full",value:yt(t[g.name]),onChange:n(g.name),placeholder:g.name})]},g.name))})}),s.jsxs("div",{className:pn.actions,children:[s.jsxs("label",{children:[s.jsx("span",{className:"mr-2",children:"🔎"}),s.jsx("input",{className:"input bg-white!",value:d,onChange:g=>m(g.target.value),placeholder:"Filter columns"})]}),s.jsx("span",{className:"flex-1"}),s.jsx("button",{disabled:!o.length,className:"button primary",onClick:x,children:"Run insert"})]})]})},Eu=()=>{const e=bu(),[t,n]=l.useState(void 0);l.useEffect(()=>{e&&n(e)},[e]);const o=()=>Zs(void 0);return s.jsxs(ve,{isVisible:e!=null,onClose:o,onClosed:()=>n(void 0),noPadding:!0,children:[s.jsx(at,{onClick:o}),t&&s.jsx(ku,{data:t})]})},[Ru,us]=_e(void 0),Tu=()=>us(void 0),Lu="_container_vcea9_2",Au="_header_vcea9_2",Pu="_key_vcea9_2",Iu="_fields-container_vcea9_2",Ou="_field-label_vcea9_2",Mu="_actions_vcea9_2",Ft={container:Lu,header:Au,key:Pu,fieldsContainer:Iu,fieldLabel:Ou,actions:Mu},st=()=>Date.now().toString(36)+Math.random().toString(36).substring(2),$u=({data:e})=>{const[t,{change:n,set:o,reset:r,touched:a}]=Cn({}),i=to(),[c,u]=l.useState(""),{data:d,isLoading:m}=Nu(e.dataSourceId,e.tableName,e.entityId),{mutateAsync:h,error:p}=_u(),x=eo(p),g=Rn(pe.EDITOR),{data:b}=Sn(e.dataSourceId),{data:v}=ls(e.dataSourceId),y=l.useMemo(()=>b?.find(k=>k.tableName===e.tableName),[e.tableName,b]),f=l.useMemo(()=>{if(!y)return[];if(!c)return y.columns.map(j=>({...j,label:et(j.name)}));const k=c.toLowerCase();return y.columns.filter(j=>j.name.toLowerCase().includes(k)).map(j=>({...j,label:et(j.name)}))},[c,y]);l.useEffect(()=>{const k=d?.entity;if(r(),k&&d?.columns)for(let j=0;j<d.columns.length;j++){const S=d.columns[j];o(S.column,yt(k[j]))}},[d,o,r]);const w=()=>{const k=[];for(const j of a)k.push({value:t[j],column:j});h({datasourceId:e.dataSourceId,table:e.tableName,filters:e.entityId.map(j=>({id:st(),value:j[1],column:j[0]})),values:k}).then(()=>{Tu(),i&&qr(i)})},C=e.entityId.map(([k,j])=>`${k} = ${j}`).join(", ")||"",_=!v?.allowUpdate||!g;return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:Ft.header,children:[s.jsxs("p",{className:"text-lg font-semibold",children:[_?"View":"Edit"," row in ",s.jsx("span",{className:"underline",children:e?.tableName})]}),s.jsx("span",{className:Ft.key,children:C}),x&&s.jsx(ne,{variant:"danger",children:s.jsx("p",{children:x})})]}),!_&&s.jsx("div",{className:"bg-gray-50 py-1 px-4 border-y border-gray-200",children:s.jsx("p",{className:"text-xs text-gray-800",children:"Tip: use = to write raw SQL. Ex: =NULL or =NOW()"})}),s.jsx("div",{className:Ft.container,children:s.jsx("div",{className:Ft.fieldsContainer,children:f.map(k=>s.jsxs("label",{className:Ft.fieldLabel,children:[s.jsxs("div",{className:"flex justify-between",children:[s.jsxs("p",{children:[k.isPrimary?"🔐":"🏷️"," ",k.label]}),s.jsxs("p",{className:"text-blue-800 text-sm",children:["[",k.name,": ",k.type,"]"]})]}),s.jsx("input",{disabled:k.isPrimary||m||_,className:"input w-full",value:yt(t[k.name]),onChange:n(k.name),placeholder:k.name})]},k.name))})}),s.jsxs("div",{className:Ft.actions,children:[s.jsxs("label",{children:[s.jsx("span",{className:"mr-2",children:"🔎"}),s.jsx("input",{className:"input bg-white!",value:c,onChange:k=>u(k.target.value),placeholder:"Filter columns"})]}),s.jsx("span",{className:"flex-1"}),!_&&s.jsx("button",{disabled:!a.length,className:"button primary",onClick:w,children:"Run update"})]})]})},Du=()=>{const e=Ru(),[t,n]=l.useState(void 0);l.useEffect(()=>{e&&n(e)},[e]);const o=()=>us(void 0);return s.jsxs(ve,{isVisible:e!=null,onClose:o,onClosed:()=>n(void 0),noPadding:!0,children:[s.jsx(at,{onClick:o}),t&&s.jsx($u,{data:t})]})},[Fu,Ns]=_e(void 0),Hr=async e=>new Promise(t=>{Ns({message:e,onCancel:()=>{t(!1),Ns(void 0)},onConfirm:()=>{t(!0),Ns(void 0)}})}),Bu=({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"})]})]}),qu=()=>{const e=Fu(),[t,n]=l.useState(void 0);return l.useEffect(()=>{e&&n(e)},[e]),s.jsx(ve,{isVisible:!!e,onClose:()=>e?.onCancel(),onClosed:()=>n(void 0),children:t&&s.jsx(Bu,{confirm:t})})},[Uu,Yn]=_e(void 0),Tn=async(e,t,n)=>new Promise(o=>{Yn({message:e,defaultValue:t,alert:n,onCancel:()=>{Yn(void 0),o(void 0)},onConfirm:r=>{Yn(void 0),o(r)}})}),Wu="_root_ng9lp_1",Hu={root:Wu},zu=({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:Hu.root,children:[s.jsx("h2",{className:"text-xl font-semibold",children:e.message}),e.alert&&s.jsx(ne,{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"})]})]})},Vu=()=>{const e=Uu(),[t,n]=l.useState(void 0);return l.useEffect(()=>{e&&n(e)},[e]),s.jsx(ve,{isVisible:!!e,onClose:()=>Yn(void 0),onClosed:()=>n(void 0),children:t&&s.jsx(zu,{data:t})})},[Qu,Ku]=_e(void 0),zr=e=>{Ku(e)},Gu="_textarea_68vbf_2",Yu={textarea:Gu},Ju=()=>{const e=Qu(),t=()=>{e&&(navigator.clipboard.writeText(e.toString()),Re.success("Copied!"))},n=()=>zr(void 0);return s.jsxs(ve,{isVisible:!!e,onClose:n,backdropClose:!0,children:[s.jsx("textarea",{className:Yu.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"})]})]})},Xu="_tabs_i8v6j_2",Zu="_mobile_i8v6j_2",ed="_tab_i8v6j_2",td="_active_i8v6j_2",nd="_close-button_i8v6j_2",xn={tabs:Xu,mobile:Zu,tab:ed,active:td,closeButton:nd},Po=e=>window.matchMedia(e).matches;function Vr(e,{defaultValue:t=!1,initializeWithValue:n=!0}={}){const[o,r]=l.useState(()=>n?Po(e):t);return l.useLayoutEffect(()=>{const a=window.matchMedia(e);function i(){r(()=>Po(e))}return i(),a.addListener?a.addListener(i):a.addEventListener("change",i),()=>{a.removeListener?a.removeListener(i):a.removeEventListener("change",i)}},[e]),o}const no={laptop:"(min-width: 1024px)"},Qr=()=>window.matchMedia(no.laptop).matches,sd="_table_56tu0_2",od="_row-index-btn_56tu0_2",rd="_semi-transparent_56tu0_2",ad="_table-loading_56tu0_2",id="_table-empty_56tu0_2",ld="_table-row-cells_56tu0_2",cd="_header-cell_56tu0_2",ud="_header-actions_56tu0_2",dd="_cell_56tu0_2",hd="_value_56tu0_2",md="_table-config_56tu0_2",fd="_table-action_56tu0_2",pd="_green-fixed_56tu0_2",xd="_gray_56tu0_2",bd="_modal_56tu0_2",gd="_selected-size_56tu0_2",vd="_pagination-indicator_56tu0_2",T={table:sd,rowIndexBtn:od,semiTransparent:rd,tableLoading:ad,tableEmpty:id,tableRowCells:ld,headerCell:cd,headerActions:ud,cell:dd,value:hd,tableConfig:md,tableAction:fd,greenFixed:pd,gray:xd,modal:bd,selectedSize:gd,paginationIndicator:vd},qe=l.createContext({name:"No name",hooks:[],availableJoins:[],allColumns:[],dataSourceId:"",entities:[],getValue:()=>{},getColumnType:()=>{},getEntityKey:()=>[],getEntityKeyByRowIndex:()=>[]}),xe=l.createContext({state:Zt({}),setState:()=>{}}),Ae=l.createContext({}),Kr={ON_ANIMATION_END:Symbol("ON_TRANSITION_END")},Gr=()=>{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,[Kr.ON_ANIMATION_END]:i}},[e,n])},yd=e=>{if(e==="ASC")return"DESC";if(e!=="DESC")return"ASC"},wd=()=>{const{state:e,setState:t}=l.useContext(xe),n=l.useCallback(o=>{t(r=>{const a=r.orderBy[0];if(a&&a.column===o){const i=yd(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}},Cd="_options-container_fboyw_2",jd="_filter-input_fboyw_2",Nd="_option-item_fboyw_2",_d="_list_fboyw_2",Sd="_empty-text_fboyw_2",Ke={optionsContainer:Cd,filterInput:jd,optionItem:Nd,list:_d,emptyText:Sd},kd="_container_14l7a_2",Ed="_animate-show_14l7a_2",Rd="_animate-hide_14l7a_2",Td="_content_14l7a_2",Ld="_backdrop_14l7a_2",ft={container:kd,animateShow:Ed,animateHide:Rd,content:Td,backdrop:Ld},Yr=({children:e,handler:t})=>{const n=l.useRef(t.close);n.current=t.close;const o=l.useMemo(()=>{if(!t.position)return;const r={};if(typeof window<"u"){const a=t.position.y>window.innerHeight/2,i=t.position.x>window.innerWidth/2;a?r.bottom=window.innerHeight-t.position.y:r.top=t.position.y,Qr()?i?r.right=window.innerWidth-t.position.x:r.left=t.position.x:(r.right=36,r.left=36)}return r},[t.position]);return l.useEffect(()=>{const r=a=>{a.code==="Escape"&&n.current()};return window.addEventListener("keyup",r),()=>{window.removeEventListener("keyup",r)}},[]),o?s.jsxs("div",{className:A(ft.container,t.state==="out"&&ft.animateHide,t.state==="in"&&ft.animateShow),onAnimationEnd:t[Kr.ON_ANIMATION_END],children:[s.jsx("div",{className:ft.backdrop,onClick:r=>{r.stopPropagation(),r.preventDefault(),t.close()}}),s.jsx("div",{className:A(ft.content,t.state==="out"&&ft.animateHide,t.state==="in"&&ft.animateShow),style:o,children:e})]}):null},De=(e,t)=>e!=null&&e>t,Ad=(e,t)=>e!=null&&e<t,Pd="_root_ki4vr_2",Id="_content_ki4vr_2",Od="_table-name_ki4vr_2",Md="_sub_ki4vr_2",Hn={root:Pd,content:Id,tableName:Od,sub:Md},Jr=({hook:e,onClick:t})=>s.jsxs("button",{className:Hn.root,onClick:t,children:[s.jsx("span",{children:"📄"}),s.jsxs("div",{className:Hn.content,children:[s.jsx("span",{className:Hn.tableName,children:e.on.toTable}),s.jsxs("span",{className:Hn.sub,children:[e.on.toColumn," = ",e.on.fromTable,".",e.on.fromColumn]})]})]},e.where),$d=A("input",Ke.filterInput);function Dd(e,t,n){return{name:`${e.on.toTable} ${e.on.toColumn} equals ${n}`,opts:Zt({table:e.on.toTable,dataSourceId:t,filters:[{id:st(),column:`${e.on.toTable}.${e.on.toColumn}`,value:n==null?"IS NULL":`${n}`,isEnabled:!0}]})}}const Xr=({rowIndex:e,onClose:t,className:n})=>{const[o,r]=l.useState(""),{hooks:a,dataSourceId:i,getValue:c}=l.useContext(qe),{state:u}=l.useContext(xe),{data:d}=l.useContext(Ae),m=l.useMemo(()=>d?.result.rows[e],[d,e]),h=en(),p=Y(),x=l.useMemo(()=>{if(!d)return[];const f=o.toLowerCase();return a.filter(w=>d.result.columns.some(_=>_.column===w.on.fromColumn&&_.table===w.on.fromTable)?w.on.toTable.toLowerCase().includes(f):!1)},[o,a,d]),g=f=>{m&&h.mutateAsync(Dd(f,i,c(m,{value:`${f.on.fromTable}.${f.on.fromColumn}`}))).then(w=>{p(P.workbenchTab.build({id:w.id})),t?.()})},b=()=>{!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:st(),column:f.value,value:`${c(m,f)}`,isEnabled:!0}))]})}).then(f=>{p(P.workbenchTab.build({id:f.id})),t?.()})},v=u.groupBy.length>0,y=De(x.length,0);return s.jsxs("div",{className:n,children:[s.jsx("input",{className:$d,placeholder:"Filter",value:o,onChange:f=>r(f.target.value)}),s.jsxs("div",{className:Ke.list,children:[v&&s.jsx("button",{onClick:b,className:Ke.optionItem,children:"🎯 Underlying rows"}),y&&x.map(f=>s.jsx(Jr,{hook:f,onClick:()=>g(f)},f.where)),!v&&!y&&s.jsx("p",{className:Ke.emptyText,children:"Empty"})]})]})},Fd=({handler:e,rowIndex:t})=>s.jsx(Yr,{handler:e,children:s.jsx("div",{className:Ke.optionsContainer,children:s.jsx(Xr,{rowIndex:t,className:"p-2",onClose:()=>{e.close()}})})}),so=()=>{const{state:e,setState:t}=l.useContext(xe),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}},Bd=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"})),Ge=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"})),qd=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"})),Zr=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"})),Ud="_container_flyao_2",Wd="_animate-show_flyao_2",Hd="_animate-hide_flyao_2",zd="_backdrop_flyao_2",Vd="_content_flyao_2",pt={container:Ud,animateShow:Wd,animateHide:Hd,backdrop:zd,content:Vd},ea=({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={},x=m.clientY>window.innerHeight/2,g=m.clientX>window.innerWidth/2;x?p.bottom=window.innerHeight-m.clientY:p.top=m.clientY,Qr()?g?p.right=window.innerWidth-m.clientX:p.left=m.clientX:(p.right=36,p.left=36),r(p),i("in")},close:()=>{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(pt.container,a==="out"&&pt.animateHide,a==="in"&&pt.animateShow),onAnimationEnd:u,children:[s.jsx("div",{className:pt.backdrop,onClick:()=>i("out")}),s.jsx("div",{ref:c,style:o,className:A(pt.content,a==="out"&&pt.animateHide,a==="in"&&pt.animateShow),children:e})]});return kr.createPortal(d,document.body)};function _s(e,t,n){const o=e?.rows?.[t]?.[n],r=e?.columns?.[n];return{value:o,column:r}}const Qd=({ref:e})=>{const{data:t}=l.useContext(Ae),{getColumnType:n}=l.useContext(qe),{setState:o}=l.useContext(xe);return{copyValue:(c,u)=>{const{value:d,column:m}=_s(t?.result,c,u);if(m){const h=yt(d,n(m.full));navigator.clipboard.writeText(h),Re.success("Copied!"),e.current?.close()}},showValue:(c,u)=>{const{value:d,column:m}=_s(t?.result,c,u);if(m){const h=yt(d,n(m.full));zr(h),e.current?.close()}},filterValue:(c,u)=>{const{value:d,column:m}=_s(t?.result,c,u),h=m?.full||"";if(h){let p;if(d==null)p={id:st(),isEnabled:!0,isAdvanced:!0,column:h,value:"IS NULL"};else{const x=yt(d,n(h));p={id:st(),isEnabled:!0,column:h,value:x,fn:m?.fn}}o(x=>({...x,filters:[...x.filters,p]})),Re.success(`Added new filter on column ${m?.alias}`),e.current?.close()}}}},ta=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})),Kd=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})),Gd="_section-name_2c7gu_2",Yd="_item_2c7gu_2",xt={sectionName:Gd,item:Yd},na=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"})),Jd=A("input",Ke.filterInput),Xd=({onClose:e,rowIndex:t,className:n})=>{const[o,r]=l.useState(""),{entities:a,dataSourceId:i,getEntityKey:c}=l.useContext(qe),{data:u}=l.useContext(Ae),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 x=c(p,d);us({tableName:p,dataSourceId:i,entityId:x}),e?.()};return s.jsxs("div",{className:n,children:[s.jsx("input",{className:Jd,placeholder:"Filter",value:o,onChange:p=>r(p.target.value)}),s.jsx("div",{className:Ke.list,children:De(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"})})]})},Zd=({ref:e,row:t,col:n,onClosed:o})=>{const r=Qd({ref:e}),[a,i]=l.useState("cell"),{entities:c,dataSourceId:u,getEntityKeyByRowIndex:d}=l.useContext(qe),m=()=>r.copyValue(t,n),h=()=>r.showValue(t,n),p=()=>r.filterValue(t,n),x=()=>{if(c.length===1){const b=d(c[0],t);us({tableName:c[0],dataSourceId:u,entityId:b}),e.current?.close()}else i("expand")},g=()=>{o?.(),i("cell")};return s.jsx(ea,{ref:e,onClosed:g,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(ta,{width:14,height:14}),"Copy"]}),s.jsxs("button",{className:xt.item,onClick:h,children:[s.jsx(Kd,{width:14,height:14}),"View"]}),s.jsxs("button",{className:xt.item,onClick:p,children:[s.jsx(Zr,{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(Ge,{width:14,height:14}),"Drill down"]}),c?.length>0&&s.jsxs("button",{className:xt.item,onClick:x,children:[s.jsx(na,{width:14,height:14}),"Edit row"]})]}),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(Ge,{className:"rotate-180",width:16,height:16}),"Drill down"]}),s.jsx(Xr,{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(Ge,{className:"rotate-180",width:16,height:16}),"Select entity"]}),s.jsx(Xd,{rowIndex:t,onClose:()=>e.current?.close()})]})]})})},eh={DESC:"",ASC:"rotate-180"},th=(e,{column:t,value:n})=>{const o=e.map(r=>({...r,isEnabled:r.column===t?!1:r.isEnabled}));return o.push({id:st(),column:t,isEnabled:!0,value:n,isAdvanced:!1}),o},nh=()=>{const{data:e}=l.useContext(Ae),{orderBy:t,updateOrderBy:n}=wd(),{setFilters:o,filters:r}=so(),a=e?.result.columns||[],i=t[0],c=De(e?.result.tables.length,1),u=d=>{Tn("Filter value","").then(m=>{m&&o(th(r,{column:d,value:m}))})};return s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("td",{children:"🥢"}),a.map(d=>s.jsxs("td",{className:T.headerCell,children:[s.jsxs("div",{className:"overflow-hidden",children:[c&&s.jsx("p",{className:"text-xs truncate italic",children:d.table||"-"}),s.jsx("p",{className:"text-sm font-semibold truncate",children:d.column})]}),s.jsxs("div",{className:T.headerActions,children:[s.jsx("button",{onClick:()=>n(d.full),children:i?.column===d.full?s.jsx(Bd,{className:eh[i.direction],width:16,height:16}):s.jsx(qd,{width:16,height:16})}),d.table&&s.jsx("button",{onClick:()=>u(d.full),children:s.jsx(Zr,{width:16,height:16})})]})]},d.full))]})})};function sh({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=yt(e);return s.jsx("span",{className:T.value,children:t})}const oh=l.memo(({row:e,isLastRow:t,index:n,offset:o})=>s.jsxs("tr",{className:A(T.tableRowCells,t&&"rounded-b-lg"),children:[s.jsx("td",{children:s.jsxs("button",{"data-row-action":n,className:T.rowIndexBtn,children:[s.jsx(Ge,{className:"pointer-events-none",width:16,height:16}),n+1+o]})}),e.map((r,a)=>s.jsx("td",{className:T.cell,"data-row":n,"data-col":a,children:s.jsx(sh,{value:r})},a))]})),rh=()=>{const{data:e,error:t,isLoading:n,isFetching:o}=l.useContext(Ae),{state:{page:r,size:a}}=l.useContext(xe),i=l.useRef(null),c=eo(t),u=Gr(),[d,m]=l.useState(void 0),[h,p]=l.useState(void 0),x=v=>{const f=v.target?.dataset?.rowAction;f!=null&&(m(parseInt(f)),u.open(v))},g=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())},b=r*a;return s.jsxs(s.Fragment,{children:[d!=null&&u.show&&s.jsx(Fd,{handler:u,rowIndex:d}),s.jsx(Zd,{ref:i,col:h,row:d,onClosed:()=>{m(void 0),p(void 0)}}),c&&s.jsx(ne,{variant:"danger",children:c}),n&&s.jsx("div",{className:T.tableLoading,children:"Loading data"}),e&&s.jsxs("table",{className:A(T.table,o&&T.semiTransparent),onClick:x,onContextMenu:g,children:[s.jsx(nh,{}),s.jsxs("tbody",{children:[e.result.rows?.length<1&&s.jsx("tr",{className:T.tableEmpty,children:s.jsx("td",{colSpan:e.result.columns.length+1,children:"No data"})}),e.result.rows?.map((v,y)=>s.jsx(oh,{index:y,offset:b,row:v,isLastRow:y===e.result.rows.length-1},y))]})]})]})},sa=()=>{const{state:e,setState:t}=l.useContext(xe),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}},ah=()=>X({mutationFn:async e=>{const{data:t}=await O.post("/saved-queries",e);return t.data},onSuccess:()=>{K.invalidateQueries({queryKey:["queries"]}),Jt(),Or()}}),ih=()=>X({mutationFn:async e=>O.delete("/saved-queries/"+e),onSuccess:()=>{Jt(),Or()}}),lh=()=>X({mutationFn:async({id:e,payload:t})=>{const{data:n}=await O.patch("/saved-queries/"+e,t);return n.data},onSuccess:()=>{Jt(),Vl()}}),[ds,oo]=_e({filters:!1,joins:!1,columns:!1,groupBy:!1,aggregate:!1}),Me=e=>oo(t=>({...t,[e]:!0})),hs=e=>oo(t=>({...t,[e]:!1})),es=e=>oo(t=>({...t,[e]:!t[e]})),Qt=Math.min,wt=Math.max,ts=Math.round,zn=Math.floor,$e=e=>({x:e,y:e}),ch={left:"right",right:"left",bottom:"top",top:"bottom"},uh={start:"end",end:"start"};function Ds(e,t,n){return wt(e,Qt(t,n))}function Ln(e,t){return typeof e=="function"?e(t):e}function jt(e){return e.split("-")[0]}function An(e){return e.split("-")[1]}function oa(e){return e==="x"?"y":"x"}function ro(e){return e==="y"?"height":"width"}const dh=new Set(["top","bottom"]);function tt(e){return dh.has(jt(e))?"y":"x"}function ao(e){return oa(tt(e))}function hh(e,t,n){n===void 0&&(n=!1);const o=An(e),r=ao(e),a=ro(r);let i=r==="x"?o===(n?"end":"start")?"right":"left":o==="start"?"bottom":"top";return t.reference[a]>t.floating[a]&&(i=ns(i)),[i,ns(i)]}function mh(e){const t=ns(e);return[Fs(e),t,Fs(t)]}function Fs(e){return e.replace(/start|end/g,t=>uh[t])}const Io=["left","right"],Oo=["right","left"],fh=["top","bottom"],ph=["bottom","top"];function xh(e,t,n){switch(e){case"top":case"bottom":return n?t?Oo:Io:t?Io:Oo;case"left":case"right":return t?fh:ph;default:return[]}}function bh(e,t,n,o){const r=An(e);let a=xh(jt(e),n==="start",o);return r&&(a=a.map(i=>i+"-"+r),t&&(a=a.concat(a.map(Fs)))),a}function ns(e){return e.replace(/left|right|bottom|top/g,t=>ch[t])}function gh(e){return{top:0,right:0,bottom:0,left:0,...e}}function ra(e){return typeof e!="number"?gh(e):{top:e,right:e,bottom:e,left:e}}function ss(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 Mo(e,t,n){let{reference:o,floating:r}=e;const a=tt(t),i=ao(t),c=ro(i),u=jt(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 x;switch(u){case"top":x={x:m,y:o.y-r.height};break;case"bottom":x={x:m,y:o.y+o.height};break;case"right":x={x:o.x+o.width,y:h};break;case"left":x={x:o.x-r.width,y:h};break;default:x={x:o.x,y:o.y}}switch(An(t)){case"start":x[i]-=p*(n&&d?-1:1);break;case"end":x[i]+=p*(n&&d?-1:1);break}return x}const vh=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}=Mo(d,o,u),p=o,x={},g=0;for(let b=0;b<c.length;b++){const{name:v,fn:y}=c[b],{x:f,y:w,data:C,reset:_}=await y({x:m,y:h,initialPlacement:o,placement:p,strategy:r,middlewareData:x,rects:d,platform:i,elements:{reference:e,floating:t}});m=f??m,h=w??h,x={...x,[v]:{...x[v],...C}},_&&g<=50&&(g++,typeof _=="object"&&(_.placement&&(p=_.placement),_.rects&&(d=_.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:r}):_.rects),{x:m,y:h}=Mo(d,p,u)),b=-1)}return{x:m,y:h,placement:p,strategy:r,middlewareData:x}};async function aa(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:x=0}=Ln(t,e),g=ra(x),v=c[p?h==="floating"?"reference":"floating":h],y=ss(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},_=ss(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:f,offsetParent:w,strategy:u}):f);return{top:(y.top-_.top+g.top)/C.y,bottom:(_.bottom-y.bottom+g.bottom)/C.y,left:(y.left-_.left+g.left)/C.x,right:(_.right-y.right+g.right)/C.x}}const yh=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}=Ln(e,t)||{};if(d==null)return{};const h=ra(m),p={x:n,y:o},x=ao(r),g=ro(x),b=await i.getDimensions(d),v=x==="y",y=v?"top":"left",f=v?"bottom":"right",w=v?"clientHeight":"clientWidth",C=a.reference[g]+a.reference[x]-p[x]-a.floating[g],_=p[x]-a.reference[x],k=await(i.getOffsetParent==null?void 0:i.getOffsetParent(d));let j=k?k[w]:0;(!j||!await(i.isElement==null?void 0:i.isElement(k)))&&(j=c.floating[w]||a.floating[g]);const S=C/2-_/2,I=j/2-b[g]/2-1,B=Qt(h[y],I),se=Qt(h[f],I),ye=B,Pe=j-b[g]-se,U=j/2-b[g]/2+S,de=Ds(ye,U,Pe),oe=!u.arrow&&An(r)!=null&&U!==de&&a.reference[g]/2-(U<ye?B:se)-b[g]/2<0,J=oe?U<ye?U-ye:U-Pe:0;return{[x]:p[x]+J,data:{[x]:de,centerOffset:U-de-J,...oe&&{alignmentOffset:J}},reset:oe}}}),wh=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:x="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:b=!0,...v}=Ln(e,t);if((n=a.arrow)!=null&&n.alignmentOffset)return{};const y=jt(r),f=tt(c),w=jt(c)===c,C=await(u.isRTL==null?void 0:u.isRTL(d.floating)),_=p||(w||!b?[ns(c)]:mh(c)),k=g!=="none";!p&&k&&_.push(...bh(c,b,g,C));const j=[c,..._],S=await aa(t,v),I=[];let B=((o=a.flip)==null?void 0:o.overflows)||[];if(m&&I.push(S[y]),h){const U=hh(r,i,C);I.push(S[U[0]],S[U[1]])}if(B=[...B,{placement:r,overflows:I}],!I.every(U=>U<=0)){var se,ye;const U=(((se=a.flip)==null?void 0:se.index)||0)+1,de=j[U];if(de&&(!(h==="alignment"?f!==tt(de):!1)||B.every(z=>tt(z.placement)===f?z.overflows[0]>0:!0)))return{data:{index:U,overflows:B},reset:{placement:de}};let oe=(ye=B.filter(J=>J.overflows[0]<=0).sort((J,z)=>J.overflows[1]-z.overflows[1])[0])==null?void 0:ye.placement;if(!oe)switch(x){case"bestFit":{var Pe;const J=(Pe=B.filter(z=>{if(k){const re=tt(z.placement);return re===f||re==="y"}return!0}).map(z=>[z.placement,z.overflows.filter(re=>re>0).reduce((re,We)=>re+We,0)]).sort((z,re)=>z[1]-re[1])[0])==null?void 0:Pe[0];J&&(oe=J);break}case"initialPlacement":oe=c;break}if(r!==oe)return{reset:{placement:oe}}}return{}}}},Ch=new Set(["left","top"]);async function jh(e,t){const{placement:n,platform:o,elements:r}=e,a=await(o.isRTL==null?void 0:o.isRTL(r.floating)),i=jt(n),c=An(n),u=tt(n)==="y",d=Ch.has(i)?-1:1,m=a&&u?-1:1,h=Ln(t,e);let{mainAxis:p,crossAxis:x,alignmentAxis:g}=typeof h=="number"?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};return c&&typeof g=="number"&&(x=c==="end"?g*-1:g),u?{x:x*m,y:p*d}:{x:p*d,y:x*m}}const Nh=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 jh(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}}}}},_h=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}=Ln(e,t),d={x:n,y:o},m=await aa(t,u),h=tt(jt(r)),p=oa(h);let x=d[p],g=d[h];if(a){const v=p==="y"?"top":"left",y=p==="y"?"bottom":"right",f=x+m[v],w=x-m[y];x=Ds(f,x,w)}if(i){const v=h==="y"?"top":"left",y=h==="y"?"bottom":"right",f=g+m[v],w=g-m[y];g=Ds(f,g,w)}const b=c.fn({...t,[p]:x,[h]:g});return{...b,data:{x:b.x-n,y:b.y-o,enabled:{[p]:a,[h]:i}}}}}};function ms(){return typeof window<"u"}function tn(e){return ia(e)?(e.nodeName||"").toLowerCase():"#document"}function ge(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Ue(e){var t;return(t=(ia(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function ia(e){return ms()?e instanceof Node||e instanceof ge(e).Node:!1}function Te(e){return ms()?e instanceof Element||e instanceof ge(e).Element:!1}function Fe(e){return ms()?e instanceof HTMLElement||e instanceof ge(e).HTMLElement:!1}function $o(e){return!ms()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof ge(e).ShadowRoot}const Sh=new Set(["inline","contents"]);function Pn(e){const{overflow:t,overflowX:n,overflowY:o,display:r}=Le(e);return/auto|scroll|overlay|hidden|clip/.test(t+o+n)&&!Sh.has(r)}const kh=new Set(["table","td","th"]);function Eh(e){return kh.has(tn(e))}const Rh=[":popover-open",":modal"];function fs(e){return Rh.some(t=>{try{return e.matches(t)}catch{return!1}})}const Th=["transform","translate","scale","rotate","perspective"],Lh=["transform","translate","scale","rotate","perspective","filter"],Ah=["paint","layout","strict","content"];function io(e){const t=lo(),n=Te(e)?Le(e):e;return Th.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)||Lh.some(o=>(n.willChange||"").includes(o))||Ah.some(o=>(n.contain||"").includes(o))}function Ph(e){let t=ot(e);for(;Fe(t)&&!Kt(t);){if(io(t))return t;if(fs(t))return null;t=ot(t)}return null}function lo(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Ih=new Set(["html","body","#document"]);function Kt(e){return Ih.has(tn(e))}function Le(e){return ge(e).getComputedStyle(e)}function ps(e){return Te(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function ot(e){if(tn(e)==="html")return e;const t=e.assignedSlot||e.parentNode||$o(e)&&e.host||Ue(e);return $o(t)?t.host:t}function la(e){const t=ot(e);return Kt(t)?e.ownerDocument?e.ownerDocument.body:e.body:Fe(t)&&Pn(t)?t:la(t)}function wn(e,t,n){var o;t===void 0&&(t=[]),n===void 0&&(n=!0);const r=la(e),a=r===((o=e.ownerDocument)==null?void 0:o.body),i=ge(r);if(a){const c=Bs(i);return t.concat(i,i.visualViewport||[],Pn(r)?r:[],c&&n?wn(c):[])}return t.concat(r,wn(r,[],n))}function Bs(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function ca(e){const t=Le(e);let n=parseFloat(t.width)||0,o=parseFloat(t.height)||0;const r=Fe(e),a=r?e.offsetWidth:n,i=r?e.offsetHeight:o,c=ts(n)!==a||ts(o)!==i;return c&&(n=a,o=i),{width:n,height:o,$:c}}function co(e){return Te(e)?e:e.contextElement}function Wt(e){const t=co(e);if(!Fe(t))return $e(1);const n=t.getBoundingClientRect(),{width:o,height:r,$:a}=ca(t);let i=(a?ts(n.width):n.width)/o,c=(a?ts(n.height):n.height)/r;return(!i||!Number.isFinite(i))&&(i=1),(!c||!Number.isFinite(c))&&(c=1),{x:i,y:c}}const Oh=$e(0);function ua(e){const t=ge(e);return!lo()||!t.visualViewport?Oh:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Mh(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==ge(e)?!1:t}function Nt(e,t,n,o){t===void 0&&(t=!1),n===void 0&&(n=!1);const r=e.getBoundingClientRect(),a=co(e);let i=$e(1);t&&(o?Te(o)&&(i=Wt(o)):i=Wt(e));const c=Mh(a,n,o)?ua(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=ge(a),x=o&&Te(o)?ge(o):o;let g=p,b=Bs(g);for(;b&&o&&x!==g;){const v=Wt(b),y=b.getBoundingClientRect(),f=Le(b),w=y.left+(b.clientLeft+parseFloat(f.paddingLeft))*v.x,C=y.top+(b.clientTop+parseFloat(f.paddingTop))*v.y;u*=v.x,d*=v.y,m*=v.x,h*=v.y,u+=w,d+=C,g=ge(b),b=Bs(g)}}return ss({width:m,height:h,x:u,y:d})}function xs(e,t){const n=ps(e).scrollLeft;return t?t.left+n:Nt(Ue(e)).left+n}function da(e,t){const n=e.getBoundingClientRect(),o=n.left+t.scrollLeft-xs(e,n),r=n.top+t.scrollTop;return{x:o,y:r}}function $h(e){let{elements:t,rect:n,offsetParent:o,strategy:r}=e;const a=r==="fixed",i=Ue(o),c=t?fs(t.floating):!1;if(o===i||c&&a)return n;let u={scrollLeft:0,scrollTop:0},d=$e(1);const m=$e(0),h=Fe(o);if((h||!h&&!a)&&((tn(o)!=="body"||Pn(i))&&(u=ps(o)),Fe(o))){const x=Nt(o);d=Wt(o),m.x=x.x+o.clientLeft,m.y=x.y+o.clientTop}const p=i&&!h&&!a?da(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 Dh(e){return Array.from(e.getClientRects())}function Fh(e){const t=Ue(e),n=ps(e),o=e.ownerDocument.body,r=wt(t.scrollWidth,t.clientWidth,o.scrollWidth,o.clientWidth),a=wt(t.scrollHeight,t.clientHeight,o.scrollHeight,o.clientHeight);let i=-n.scrollLeft+xs(e);const c=-n.scrollTop;return Le(o).direction==="rtl"&&(i+=wt(t.clientWidth,o.clientWidth)-r),{width:r,height:a,x:i,y:c}}const Do=25;function Bh(e,t){const n=ge(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=lo();(!m||m&&t==="fixed")&&(c=r.offsetLeft,u=r.offsetTop)}const d=xs(o);if(d<=0){const m=o.ownerDocument,h=m.body,p=getComputedStyle(h),x=m.compatMode==="CSS1Compat"&&parseFloat(p.marginLeft)+parseFloat(p.marginRight)||0,g=Math.abs(o.clientWidth-h.clientWidth-x);g<=Do&&(a-=g)}else d<=Do&&(a+=d);return{width:a,height:i,x:c,y:u}}const qh=new Set(["absolute","fixed"]);function Uh(e,t){const n=Nt(e,!0,t==="fixed"),o=n.top+e.clientTop,r=n.left+e.clientLeft,a=Fe(e)?Wt(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 Fo(e,t,n){let o;if(t==="viewport")o=Bh(e,n);else if(t==="document")o=Fh(Ue(e));else if(Te(t))o=Uh(t,n);else{const r=ua(e);o={x:t.x-r.x,y:t.y-r.y,width:t.width,height:t.height}}return ss(o)}function ha(e,t){const n=ot(e);return n===t||!Te(n)||Kt(n)?!1:Le(n).position==="fixed"||ha(n,t)}function Wh(e,t){const n=t.get(e);if(n)return n;let o=wn(e,[],!1).filter(c=>Te(c)&&tn(c)!=="body"),r=null;const a=Le(e).position==="fixed";let i=a?ot(e):e;for(;Te(i)&&!Kt(i);){const c=Le(i),u=io(i);!u&&c.position==="fixed"&&(r=null),(a?!u&&!r:!u&&c.position==="static"&&!!r&&qh.has(r.position)||Pn(i)&&!u&&ha(e,i))?o=o.filter(m=>m!==i):r=c,i=ot(i)}return t.set(e,o),o}function Hh(e){let{element:t,boundary:n,rootBoundary:o,strategy:r}=e;const i=[...n==="clippingAncestors"?fs(t)?[]:Wh(t,this._c):[].concat(n),o],c=i[0],u=i.reduce((d,m)=>{const h=Fo(t,m,r);return d.top=wt(h.top,d.top),d.right=Qt(h.right,d.right),d.bottom=Qt(h.bottom,d.bottom),d.left=wt(h.left,d.left),d},Fo(t,c,r));return{width:u.right-u.left,height:u.bottom-u.top,x:u.left,y:u.top}}function zh(e){const{width:t,height:n}=ca(e);return{width:t,height:n}}function Vh(e,t,n){const o=Fe(t),r=Ue(t),a=n==="fixed",i=Nt(e,!0,a,t);let c={scrollLeft:0,scrollTop:0};const u=$e(0);function d(){u.x=xs(r)}if(o||!o&&!a)if((tn(t)!=="body"||Pn(r))&&(c=ps(t)),o){const x=Nt(t,!0,a,t);u.x=x.x+t.clientLeft,u.y=x.y+t.clientTop}else r&&d();a&&!o&&r&&d();const m=r&&!o&&!a?da(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 Ss(e){return Le(e).position==="static"}function Bo(e,t){if(!Fe(e)||Le(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Ue(e)===n&&(n=n.ownerDocument.body),n}function ma(e,t){const n=ge(e);if(fs(e))return n;if(!Fe(e)){let r=ot(e);for(;r&&!Kt(r);){if(Te(r)&&!Ss(r))return r;r=ot(r)}return n}let o=Bo(e,t);for(;o&&Eh(o)&&Ss(o);)o=Bo(o,t);return o&&Kt(o)&&Ss(o)&&!io(o)?n:o||Ph(e)||n}const Qh=async function(e){const t=this.getOffsetParent||ma,n=this.getDimensions,o=await n(e.floating);return{reference:Vh(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}};function Kh(e){return Le(e).direction==="rtl"}const Gh={convertOffsetParentRelativeRectToViewportRelativeRect:$h,getDocumentElement:Ue,getClippingRect:Hh,getOffsetParent:ma,getElementRects:Qh,getClientRects:Dh,getDimensions:zh,getScale:Wt,isElement:Te,isRTL:Kh};function fa(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Yh(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:x}=d;if(c||t(),!p||!x)return;const g=zn(h),b=zn(r.clientWidth-(m+p)),v=zn(r.clientHeight-(h+x)),y=zn(m),w={rootMargin:-g+"px "+-b+"px "+-v+"px "+-y+"px",threshold:wt(0,Qt(1,u))||1};let C=!0;function _(k){const j=k[0].intersectionRatio;if(j!==u){if(!C)return i();j?i(!1,j):o=setTimeout(()=>{i(!1,1e-7)},1e3)}j===1&&!fa(d,e.getBoundingClientRect())&&i(),C=!1}try{n=new IntersectionObserver(_,{...w,root:r.ownerDocument})}catch{n=new IntersectionObserver(_,w)}n.observe(e)}return i(!0),a}function Jh(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=co(e),m=r||a?[...d?wn(d):[],...wn(t)]:[];m.forEach(y=>{r&&y.addEventListener("scroll",n,{passive:!0}),a&&y.addEventListener("resize",n)});const h=d&&c?Yh(d,n):null;let p=-1,x=null;i&&(x=new ResizeObserver(y=>{let[f]=y;f&&f.target===d&&x&&(x.unobserve(t),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var w;(w=x)==null||w.observe(t)})),n()}),d&&!u&&x.observe(d),x.observe(t));let g,b=u?Nt(e):null;u&&v();function v(){const y=Nt(e);b&&!fa(b,y)&&n(),b=y,g=requestAnimationFrame(v)}return n(),()=>{var y;m.forEach(f=>{r&&f.removeEventListener("scroll",n),a&&f.removeEventListener("resize",n)}),h?.(),(y=x)==null||y.disconnect(),x=null,u&&cancelAnimationFrame(g)}}const Xh=Nh,Zh=_h,em=wh,tm=yh,qo=(e,t,n)=>{const o=new Map,r={platform:Gh,...n},a={...r.platform,_c:o};return vh(e,t,{...r,platform:a})};var ks={exports:{}};var Uo;function nm(){return Uo||(Uo=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})()})(ks)),ks.exports}var sm=nm();const qs=Ka(sm);var Wo={};const om="react-tooltip-core-styles",rm="react-tooltip-base-styles",Ho={core:!1,base:!1};function zo({css:e,id:t=rm,type:n="base",ref:o}){var r,a;if(!e||typeof document>"u"||Ho[n]||n==="core"&&typeof process<"u"&&(!((r=process==null?void 0:Wo)===null||r===void 0)&&r.REACT_TOOLTIP_DISABLE_CORE_STYLES)||n!=="base"&&typeof process<"u"&&(!((a=process==null?void 0:Wo)===null||a===void 0)&&a.REACT_TOOLTIP_DISABLE_BASE_STYLES))return;n==="core"&&(t=om),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)),Ho[n]=!0}const Vo=async({elementReference:e=null,tooltipReference:t=null,tooltipArrowReference:n=null,place:o="top",offset:r=10,strategy:a="absolute",middlewares:i=[Xh(Number(r)),em({fallbackAxisSideDirection:"start"}),Zh({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(tm({element:n,padding:5})),qo(e,t,{placement:o,strategy:a,middleware:d}).then((({x:m,y:h,placement:p,middlewareData:x})=>{var g,b;const v={left:`${m}px`,top:`${h}px`,border:c},{x:y,y:f}=(g=x.arrow)!==null&&g!==void 0?g:{x:0,y:0},w=(b={top:"bottom",right:"left",bottom:"top",left:"right"}[p.split("-")[0]])!==null&&b!==void 0?b:"bottom",C=c&&{borderBottom:c,borderRight:c};let _=0;if(c){const k=`${c}`.match(/(\d+)px/);_=k?.[1]?Number(k[1]):1}return{tooltipStyles:v,tooltipArrowStyles:{left:y!=null?`${y}px`:"",top:f!=null?`${f}px`:"",right:"",bottom:"",...C,[w]:`-${u/2+_}px`},place:p}}))):qo(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})))},Qo=(e,t)=>!("CSS"in window&&"supports"in window.CSS)||window.CSS.supports(e,t),Ko=(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},Go=e=>e!==null&&!Array.isArray(e)&&typeof e=="object",Us=(e,t)=>{if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every(((r,a)=>Us(r,t[a])));if(Array.isArray(e)!==Array.isArray(t))return!1;if(!Go(e)||!Go(t))return e===t;const n=Object.keys(e),o=Object.keys(t);return n.length===o.length&&n.every((r=>Us(e[r],t[r])))},am=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"}))},Yo=e=>{if(!e)return null;let t=e.parentElement;for(;t;){if(am(t))return t;t=t.parentElement}return document.scrollingElement||document.documentElement},im=typeof window<"u"?l.useLayoutEffect:l.useEffect,Ce=e=>{e.current&&(clearTimeout(e.current),e.current=null)},lm="DEFAULT_TOOLTIP_ID",cm={anchorRefs:new Set,activeAnchor:{current:null},attach:()=>{},detach:()=>{},setActiveAnchor:()=>{}},um=l.createContext({getTooltipData:()=>cm});function pa(e=lm){return l.useContext(um).getTooltipData(e)}var Bt={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"},Es={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 dm=({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:x,delayShow:g=0,delayHide:b=0,float:v=!1,hidden:y=!1,noArrow:f=!1,clickable:w=!1,closeOnEsc:C=!1,closeOnScroll:_=!1,closeOnResize:k=!1,openEvents:j,closeEvents:S,globalCloseEvents:I,imperativeModeOnly:B,style:se,position:ye,afterShow:Pe,afterHide:U,disableTooltip:de,content:oe,contentWrapperRef:J,isOpen:z,defaultIsOpen:re=!1,setIsOpen:We,previousActiveAnchor:nn,activeAnchor:W,setActiveAnchor:_t,border:In,opacity:On,arrowColor:Mn,arrowSize:St=8,role:bs="tooltip"})=>{var lt;const he=l.useRef(null),kt=l.useRef(null),Se=l.useRef(null),ct=l.useRef(null),Et=l.useRef(null),[ut,$n]=l.useState({tooltipStyles:{},tooltipArrowStyles:{},place:c}),[me,sn]=l.useState(!1),[Rt,Je]=l.useState(!1),[Q,Tt]=l.useState(null),Dn=l.useRef(!1),Lt=l.useRef(null),{anchorRefs:Fn,setActiveAnchor:on}=pa(t),rn=l.useRef(!1),[Xe,an]=l.useState([]),dt=l.useRef(!1),At=m||d.includes("click"),Bn=At||j?.click||j?.dblclick||j?.mousedown,ln=j?{...j}:{mouseover:!0,focus:!0,mouseenter:!1,click:!1,dblclick:!1,mousedown:!1};!j&&At&&Object.assign(ln,{mouseenter:!1,focus:!1,mouseover:!1,click:!0});const ht=S?{...S}:{mouseout:!0,blur:!0,mouseleave:!1,click:!1,dblclick:!1,mouseup:!1};!S&&At&&Object.assign(ht,{mouseleave:!1,blur:!1,mouseout:!1});const ee=I?{...I}:{escape:C||!1,scroll:_||!1,resize:k||!1,clickOutsideAnchor:Bn||!1};B&&(Object.assign(ln,{mouseover:!1,focus:!1,mouseenter:!1,click:!1,dblclick:!1,mousedown:!1}),Object.assign(ht,{mouseout:!1,blur:!1,mouseleave:!1,click:!1,dblclick:!1,mouseup:!1}),Object.assign(ee,{escape:!1,scroll:!1,resize:!1,clickOutsideAnchor:!1})),im((()=>(dt.current=!0,()=>{dt.current=!1})),[]);const fe=N=>{dt.current&&(N&&Je(!0),setTimeout((()=>{dt.current&&(We?.(N),z===void 0&&sn(N))}),10))};l.useEffect((()=>{if(t){if(me){R(nn);const E=N(W),q=[...new Set([...E,t])].filter(Boolean).join(" ");W?.setAttribute("aria-describedby",q)}else R(W);return()=>{R(W),R(nn)}}function N(E){var q;return((q=E?.getAttribute("aria-describedby"))===null||q===void 0?void 0:q.split(" "))||[]}function R(E){const q=N(E).filter((Z=>Z!==t));q.length?E?.setAttribute("aria-describedby",q.join(" ")):E?.removeAttribute("aria-describedby")}}),[W,me,t,nn]),l.useEffect((()=>{if(z===void 0)return()=>null;z&&Je(!0);const N=setTimeout((()=>{sn(z)}),10);return()=>{clearTimeout(N)}}),[z]),l.useEffect((()=>{if(me!==Dn.current)if(Ce(Et),Dn.current=me,me)Pe?.();else{const N=(R=>{const E=R.match(/^([\d.]+)(ms|s)$/);if(!E)return 0;const[,q,Z]=E;return Number(q)*(Z==="ms"?1:1e3)})(getComputedStyle(document.body).getPropertyValue("--rt-transition-show-delay"));Et.current=setTimeout((()=>{Je(!1),Tt(null),U?.()}),N+25)}}),[me]);const cn=N=>{$n((R=>Us(R,N)?R:N))},un=(N=g)=>{Ce(Se),Rt?fe(!0):Se.current=setTimeout((()=>{fe(!0)}),N)},Pt=(N=b)=>{Ce(ct),ct.current=setTimeout((()=>{rn.current||fe(!1)}),N)},dn=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 on({current:null});g?un():fe(!0),_t(E),on({current:E}),Ce(ct)},It=()=>{w?Pt(b||100):b?Pt():fe(!1),Ce(Se)},Ot=({x:N,y:R})=>{var E;const q={getBoundingClientRect:()=>({x:N,y:R,width:0,height:0,top:R,left:N,right:N,bottom:R})};Vo({place:(E=Q?.place)!==null&&E!==void 0?E:c,offset:u,elementReference:q,tooltipReference:he.current,tooltipArrowReference:kt.current,strategy:h,middlewares:p,border:In,arrowSize:St}).then((Z=>{cn(Z)}))},Mt=N=>{if(!N)return;const R=N,E={x:R.clientX,y:R.clientY};Ot(E),Lt.current=E},hn=N=>{var R;if(!me)return;const E=N.target;E.isConnected&&(!((R=he.current)===null||R===void 0)&&R.contains(E)||[document.querySelector(`[id='${a}']`),...Xe].some((q=>q?.contains(E)))||(fe(!1),Ce(Se)))},qn=Ko(dn,50),G=Ko(It,50),ae=N=>{G.cancel(),qn(N)},L=()=>{qn.cancel(),G()},M=l.useCallback((()=>{var N,R;const E=(N=Q?.position)!==null&&N!==void 0?N:ye;E?Ot(E):v?Lt.current&&Ot(Lt.current):W?.isConnected&&Vo({place:(R=Q?.place)!==null&&R!==void 0?R:c,offset:u,elementReference:W,tooltipReference:he.current,tooltipArrowReference:kt.current,strategy:h,middlewares:p,border:In,arrowSize:St}).then((q=>{dt.current&&cn(q)}))}),[me,W,oe,se,c,Q?.place,u,h,ye,Q?.position,v,St]);l.useEffect((()=>{var N,R;const E=new Set(Fn);Xe.forEach((F=>{de?.(F)||E.add({current:F})}));const q=document.querySelector(`[id='${a}']`);q&&!de?.(q)&&E.add({current:q});const Z=()=>{fe(!1)},Ie=Yo(W),Oe=Yo(he.current);ee.scroll&&(window.addEventListener("scroll",Z),Ie?.addEventListener("scroll",Z),Oe?.addEventListener("scroll",Z));let ie=null;ee.resize?window.addEventListener("resize",Z):W&&he.current&&(ie=Jh(W,he.current,M,{ancestorResize:!0,elementResize:!0,layoutShift:!0}));const we=F=>{F.key==="Escape"&&fe(!1)};ee.escape&&window.addEventListener("keydown",we),ee.clickOutsideAnchor&&window.addEventListener("click",hn);const H=[],$t=F=>!!(F?.target&&W?.contains(F.target)),Oa=F=>{me&&$t(F)||dn(F)},Ma=F=>{me&&$t(F)&&It()},mo=["mouseover","mouseout","mouseenter","mouseleave","focus","blur"],fo=["click","dblclick","mousedown","mouseup"];Object.entries(ln).forEach((([F,He])=>{He&&(mo.includes(F)?H.push({event:F,listener:ae}):fo.includes(F)&&H.push({event:F,listener:Oa}))})),Object.entries(ht).forEach((([F,He])=>{He&&(mo.includes(F)?H.push({event:F,listener:L}):fo.includes(F)&&H.push({event:F,listener:Ma}))})),v&&H.push({event:"pointermove",listener:Mt});const po=()=>{rn.current=!0},xo=()=>{rn.current=!1,It()},bo=w&&(ht.mouseout||ht.mouseleave);return bo&&((N=he.current)===null||N===void 0||N.addEventListener("mouseover",po),(R=he.current)===null||R===void 0||R.addEventListener("mouseout",xo)),H.forEach((({event:F,listener:He})=>{E.forEach((gs=>{var mn;(mn=gs.current)===null||mn===void 0||mn.addEventListener(F,He)}))})),()=>{var F,He;ee.scroll&&(window.removeEventListener("scroll",Z),Ie?.removeEventListener("scroll",Z),Oe?.removeEventListener("scroll",Z)),ee.resize?window.removeEventListener("resize",Z):ie?.(),ee.clickOutsideAnchor&&window.removeEventListener("click",hn),ee.escape&&window.removeEventListener("keydown",we),bo&&((F=he.current)===null||F===void 0||F.removeEventListener("mouseover",po),(He=he.current)===null||He===void 0||He.removeEventListener("mouseout",xo)),H.forEach((({event:gs,listener:mn})=>{E.forEach(($a=>{var vs;(vs=$a.current)===null||vs===void 0||vs.removeEventListener(gs,mn)}))}))}}),[W,M,Rt,Fn,Xe,j,S,I,At,g,b]),l.useEffect((()=>{var N,R;let E=(R=(N=Q?.anchorSelect)!==null&&N!==void 0?N:i)!==null&&R!==void 0?R:"";!E&&t&&(E=`[data-tooltip-id='${t.replace(/'/g,"\\'")}']`);const q=new MutationObserver((Z=>{const Ie=[],Oe=[];Z.forEach((ie=>{if(ie.type==="attributes"&&ie.attributeName==="data-tooltip-id"&&(ie.target.getAttribute("data-tooltip-id")===t?Ie.push(ie.target):ie.oldValue===t&&Oe.push(ie.target)),ie.type==="childList"){if(W){const we=[...ie.removedNodes].filter((H=>H.nodeType===1));if(E)try{Oe.push(...we.filter((H=>H.matches(E)))),Oe.push(...we.flatMap((H=>[...H.querySelectorAll(E)])))}catch{}we.some((H=>{var $t;return!!(!(($t=H?.contains)===null||$t===void 0)&&$t.call(H,W))&&(Je(!1),fe(!1),_t(null),Ce(Se),Ce(ct),!0)}))}if(E)try{const we=[...ie.addedNodes].filter((H=>H.nodeType===1));Ie.push(...we.filter((H=>H.matches(E)))),Ie.push(...we.flatMap((H=>[...H.querySelectorAll(E)])))}catch{}}})),(Ie.length||Oe.length)&&an((ie=>[...ie.filter((we=>!Oe.includes(we))),...Ie]))}));return q.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-tooltip-id"],attributeOldValue:!0}),()=>{q.disconnect()}}),[t,i,Q?.anchorSelect,W]),l.useEffect((()=>{M()}),[M]),l.useEffect((()=>{if(!J?.current)return()=>null;const N=new ResizeObserver((()=>{setTimeout((()=>M()))}));return N.observe(J.current),()=>{N.disconnect()}}),[oe,J?.current]),l.useEffect((()=>{var N;const R=document.querySelector(`[id='${a}']`),E=[...Xe,R];W&&E.includes(W)||_t((N=Xe[0])!==null&&N!==void 0?N:R)}),[a,Xe,W]),l.useEffect((()=>(re&&fe(!0),()=>{Ce(Se),Ce(ct)})),[]),l.useEffect((()=>{var N;let R=(N=Q?.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));an(E)}catch{an([])}}),[t,i,Q?.anchorSelect]),l.useEffect((()=>{Se.current&&(Ce(Se),un(g))}),[g]);const be=(lt=Q?.content)!==null&<!==void 0?lt:oe,mt=me&&Object.keys(ut.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?un(N.delay):fe(!0)},close:N=>{N?.delay?Pt(N.delay):fe(!1)},activeAnchor:W,place:ut.place,isOpen:!!(Rt&&!y&&be&&mt)}))),Rt&&!y&&be?Ze.createElement(x,{id:t,role:bs,className:qs("react-tooltip",Bt.tooltip,Es.tooltip,Es[r],n,`react-tooltip__place-${ut.place}`,Bt[mt?"show":"closing"],mt?"react-tooltip__show":"react-tooltip__closing",h==="fixed"&&Bt.fixed,w&&Bt.clickable),onTransitionEnd:N=>{Ce(Et),me||N.propertyName!=="opacity"||(Je(!1),Tt(null),U?.())},style:{...se,...ut.tooltipStyles,opacity:On!==void 0&&mt?On:void 0},ref:he},be,Ze.createElement(x,{className:qs("react-tooltip-arrow",Bt.arrow,Es.arrow,o,f&&Bt.noArrow),style:{...ut.tooltipArrowStyles,background:Mn?`linear-gradient(to right bottom, transparent 50%, ${Mn} 50%)`:void 0,"--rt-arrow-size":`${St}px`},ref:kt})):null},hm=({content:e})=>Ze.createElement("span",{dangerouslySetInnerHTML:{__html:e}}),os=Ze.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:x=["hover"],openOnClick:g=!1,positionStrategy:b="absolute",middlewares:v,delayShow:y=0,delayHide:f=0,float:w=!1,hidden:C=!1,noArrow:_=!1,clickable:k=!1,closeOnEsc:j=!1,closeOnScroll:S=!1,closeOnResize:I=!1,openEvents:B,closeEvents:se,globalCloseEvents:ye,imperativeModeOnly:Pe=!1,style:U,position:de,isOpen:oe,defaultIsOpen:J=!1,disableStyleInjection:z=!1,border:re,opacity:We,arrowColor:nn,arrowSize:W,setIsOpen:_t,afterShow:In,afterHide:On,disableTooltip:Mn,role:St="tooltip"},bs)=>{const[lt,he]=l.useState(o),[kt,Se]=l.useState(r),[ct,Et]=l.useState(d),[ut,$n]=l.useState(u),[me,sn]=l.useState(m),[Rt,Je]=l.useState(y),[Q,Tt]=l.useState(f),[Dn,Lt]=l.useState(w),[Fn,on]=l.useState(C),[rn,Xe]=l.useState(h),[an,dt]=l.useState(x),[At,Bn]=l.useState(b),[ln,ht]=l.useState(null),[ee,fe]=l.useState(null),cn=l.useRef(null),un=l.useRef(z),{anchorRefs:Pt,activeAnchor:dn}=pa(e),It=G=>G?.getAttributeNames().reduce(((ae,L)=>{var M;return L.startsWith("data-tooltip-")&&(ae[L.replace(/^data-tooltip-/,"")]=(M=G?.getAttribute(L))!==null&&M!==void 0?M:null),ae}),{}),Ot=G=>{const ae={place:L=>{var M;Et((M=L)!==null&&M!==void 0?M:d)},content:L=>{he(L??o)},html:L=>{Se(L??r)},variant:L=>{var M;$n((M=L)!==null&&M!==void 0?M:u)},offset:L=>{sn(L===null?m:Number(L))},wrapper:L=>{var M;Xe((M=L)!==null&&M!==void 0?M:h)},events:L=>{const M=L?.split(" ");dt(M??x)},"position-strategy":L=>{var M;Bn((M=L)!==null&&M!==void 0?M:b)},"delay-show":L=>{Je(L===null?y:Number(L))},"delay-hide":L=>{Tt(L===null?f:Number(L))},float:L=>{Lt(L===null?w:L==="true")},hidden:L=>{on(L===null?C:L==="true")},"class-name":L=>{ht(L)}};Object.values(ae).forEach((L=>L(null))),Object.entries(G).forEach((([L,M])=>{var be;(be=ae[L])===null||be===void 0||be.call(ae,M)}))};l.useEffect((()=>{he(o)}),[o]),l.useEffect((()=>{Se(r)}),[r]),l.useEffect((()=>{Et(d)}),[d]),l.useEffect((()=>{$n(u)}),[u]),l.useEffect((()=>{sn(m)}),[m]),l.useEffect((()=>{Je(y)}),[y]),l.useEffect((()=>{Tt(f)}),[f]),l.useEffect((()=>{Lt(w)}),[w]),l.useEffect((()=>{on(C)}),[C]),l.useEffect((()=>{Bn(b)}),[b]),l.useEffect((()=>{un.current!==z&&console.warn("[react-tooltip] Do not change `disableStyleInjection` dynamically.")}),[z]),l.useEffect((()=>{typeof window<"u"&&window.dispatchEvent(new CustomEvent("react-tooltip-inject-styles",{detail:{disableCore:z==="core",disableBase:z}}))}),[]),l.useEffect((()=>{var G;const ae=new Set(Pt);let L=n;if(!L&&e&&(L=`[data-tooltip-id='${e.replace(/'/g,"\\'")}']`),L)try{document.querySelectorAll(L).forEach((R=>{ae.add({current:R})}))}catch{console.warn(`[react-tooltip] "${L}" is not a valid CSS selector`)}const M=document.querySelector(`[id='${t}']`);if(M&&ae.add({current:M}),!ae.size)return()=>null;const be=(G=ee??M)!==null&&G!==void 0?G:dn.current,mt=new MutationObserver((R=>{R.forEach((E=>{var q;if(!be||E.type!=="attributes"||!(!((q=E.attributeName)===null||q===void 0)&&q.startsWith("data-tooltip-")))return;const Z=It(be);Ot(Z)}))})),N={attributes:!0,childList:!1,subtree:!1};if(be){const R=It(be);Ot(R),mt.observe(be,N)}return()=>{mt.disconnect()}}),[Pt,dn,ee,t,n]),l.useEffect((()=>{U?.border&&console.warn("[react-tooltip] Do not set `style.border`. Use `border` prop instead."),re&&!Qo("border",`${re}`)&&console.warn(`[react-tooltip] "${re}" is not a valid \`border\`.`),U?.opacity&&console.warn("[react-tooltip] Do not set `style.opacity`. Use `opacity` prop instead."),We&&!Qo("opacity",`${We}`)&&console.warn(`[react-tooltip] "${We}" is not a valid \`opacity\`.`)}),[]);let Mt=p;const hn=l.useRef(null);if(a){const G=a({content:ee?.getAttribute("data-tooltip-content")||lt||null,activeAnchor:ee});Mt=G?Ze.createElement("div",{ref:hn,className:"react-tooltip-content-wrapper"},G):null}else lt&&(Mt=lt);kt&&(Mt=Ze.createElement(hm,{content:kt}));const qn={forwardRef:bs,id:e,anchorId:t,anchorSelect:n,className:qs(i,ln),classNameArrow:c,content:Mt,contentWrapperRef:hn,place:ct,variant:ut,offset:me,wrapper:rn,events:an,openOnClick:g,positionStrategy:At,middlewares:v,delayShow:Rt,delayHide:Q,float:Dn,hidden:Fn,noArrow:_,clickable:k,closeOnEsc:j,closeOnScroll:S,closeOnResize:I,openEvents:B,closeEvents:se,globalCloseEvents:ye,imperativeModeOnly:Pe,style:U,position:de,isOpen:oe,defaultIsOpen:J,border:re,opacity:We,arrowColor:nn,arrowSize:W,setIsOpen:_t,afterShow:In,afterHide:On,disableTooltip:Mn,activeAnchor:ee,previousActiveAnchor:cn.current,setActiveAnchor:G=>{fe((ae=>(G?.isSameNode(ae)||(cn.current=ae),G)))},role:St};return Ze.createElement(dm,{...qn})}));typeof window<"u"&&window.addEventListener("react-tooltip-inject-styles",(e=>{e.detail.disableCore||zo({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||zo({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 mm=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})),xa=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"})),fm=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})),pm=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"})),ba=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"})),ga=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"})),xm=()=>{const e=to(),t=kc();return{rename:async o=>{if(e){const r=await Tn("New tab name",o);r&&await t.mutateAsync({id:e,payload:{name:r}})}return Promise.resolve()}}},va=["shift","alt","meta","mod","ctrl","control"],bm={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 nt(e){return(bm[e.trim()]||e.trim()).toLowerCase().replace(/key|digit|numpad/,"")}function ya(e){return va.includes(e)}function Rs(e,t=","){return e.toLowerCase().split(t)}function Ts(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=>nt(d))):a=e.toLocaleLowerCase().split(t).map(d=>nt(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=>!va.includes(d));return{...c,keys:u,description:r,isSequence:i,hotkey:e}}typeof document<"u"&&(document.addEventListener("keydown",e=>{e.code!==void 0&&wa([nt(e.code)])}),document.addEventListener("keyup",e=>{e.code!==void 0&&Ca([nt(e.code)])})),typeof window<"u"&&(window.addEventListener("blur",()=>{Ve.clear()}),window.addEventListener("contextmenu",()=>{setTimeout(()=>{Ve.clear()},0)}));const Ve=new Set;function uo(e){return Array.isArray(e)}function gm(e,t=","){return(uo(e)?e:e.split(t)).every(n=>Ve.has(n.trim().toLowerCase()))}function wa(e){const t=Array.isArray(e)?e:[e];Ve.has("meta")&&Ve.forEach(n=>!ya(n)&&Ve.delete(n.toLowerCase())),t.forEach(n=>Ve.add(n.toLowerCase()))}function Ca(e){const t=Array.isArray(e)?e:[e];e==="meta"?Ve.clear():t.forEach(n=>Ve.delete(n.toLowerCase()))}function vm(e,t,n){(typeof n=="function"&&n(e,t)||n===!0)&&e.preventDefault()}function ym(e,t,n){return typeof n=="function"?n(e,t):n===!0||n===void 0}const wm=["input","textarea","select","searchbox","slider","spinbutton","menuitem","menuitemcheckbox","menuitemradio","option","radio","textbox"];function Cm(e){return ja(e,wm)}function ja(e,t=!1){const{target:n,composed:o}=e;let r,a;return jm(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),uo(t)?!!(r&&t&&t.some(i=>i.toLowerCase()===r.toLowerCase()||i===a)):!!(r&&t&&t)}function jm(e){return!!e.tagName&&!e.tagName.startsWith("-")&&e.tagName.includes("-")}function Nm(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 _m=(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:x,shiftKey:g,altKey:b}=e,v=nt(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!==b&&v!=="alt"||i!==g&&v!=="shift")return!1;if(a){if(!x&&!p)return!1}else if(r!==x&&v!=="meta"&&v!=="os"||c!==p&&v!=="ctrl"&&v!=="control")return!1}return u&&u.length===1&&u.includes(v)?!0:u?gm(u):!u},Sm=l.createContext(void 0),km=()=>l.useContext(Sm);function Na(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&&Na(e[o],t[o]),!0):e===t}const Em=l.createContext({hotkeys:[],activeScopes:[],toggleScope:()=>{},enableScope:()=>{},disableScope:()=>{}}),Rm=()=>l.useContext(Em);function Tm(e){const t=l.useRef(void 0);return Na(t.current,e)||(t.current=e),t.current}const Jo=e=>{e.stopPropagation(),e.preventDefault(),e.stopImmediatePropagation()},Lm=typeof window<"u"?l.useLayoutEffect:l.useEffect;function Ee(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=uo(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=Tm(i),{activeScopes:p}=Rm(),x=km();return Lm(()=>{if(h?.enabled===!1||!Nm(p,h?.scopes))return;let g=[],b;const v=(C,_=!1)=>{if(!(Cm(C)&&!ja(C,h?.enableOnFormTags))){if(r.current!==null){const k=r.current.getRootNode();if((k instanceof Document||k instanceof ShadowRoot)&&k.activeElement!==r.current&&!r.current.contains(k.activeElement)){Jo(C);return}}C.target?.isContentEditable&&!h?.enableOnContentEditable||Rs(c,h?.delimiter).forEach(k=>{if(k.includes(h?.splitKey??"+")&&k.includes(h?.sequenceSplitKey??">")){console.warn(`Hotkey ${k} contains both ${h?.splitKey??"+"} and ${h?.sequenceSplitKey??">"} which is not supported.`);return}const j=Ts(k,h?.splitKey,h?.sequenceSplitKey,h?.useKey,h?.description);if(j.isSequence){b=setTimeout(()=>{g=[]},h?.sequenceTimeoutMs??1e3);const S=j.useKey?C.key:nt(C.code);if(ya(S.toLowerCase()))return;g.push(S);const I=j.keys?.[g.length-1];if(S!==I){g=[],b&&clearTimeout(b);return}g.length===j.keys?.length&&(m.current(C,j),b&&clearTimeout(b),g=[])}else if(_m(C,j,h?.ignoreModifiers)||j.keys?.includes("*")){if(h?.ignoreEventWhen?.(C)||_&&a.current)return;if(vm(C,j,h?.preventDefault),!ym(C,j,h?.enabled)){Jo(C);return}m.current(C,j),_||(a.current=!0)}})}},y=C=>{C.code!==void 0&&(wa(nt(C.code)),(h?.keydown===void 0&&h?.keyup!==!0||h?.keydown)&&v(C))},f=C=>{C.code!==void 0&&(Ca(nt(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),x&&Rs(c,h?.delimiter).forEach(C=>x.addHotkey(Ts(C,h?.splitKey,h?.sequenceSplitKey,h?.useKey,h?.description))),()=>{w.removeEventListener("keyup",f,i?.eventListenerOptions),w.removeEventListener("keydown",y,i?.eventListenerOptions),x&&Rs(c,h?.delimiter).forEach(C=>x.removeHotkey(Ts(C,h?.splitKey,h?.sequenceSplitKey,h?.useKey,h?.description))),g=[],b&&clearTimeout(b)}},[c,h,p]),r}function Am(){return s.jsxs("div",{className:"flex md:grid md:grid-cols-3 items-center bg-white overflow-auto no-scrollbar",children:[s.jsx(Pm,{}),s.jsx(Im,{}),s.jsx($m,{})]})}function Pm(){const{dataSourceId:e}=l.useContext(qe),{data:t}=ls(e),{state:{table:n}}=l.useContext(xe);return s.jsx("div",{className:T.tableConfig,children:t&&s.jsxs("div",{className:A(T.tableAction,T.greenFixed),"data-tooltip-id":"default","data-tooltip-content":n,children:[s.jsx(it,{size:18,type:t.dbType}),s.jsx("p",{className:"text-sm",children:t.name}),s.jsx(Ge,{width:12,height:12}),s.jsx("p",{className:"text-sm",children:n})]})})}function Im(){const{page:e,size:t,setPage:n}=sa(),{data:o,isFetching:r}=l.useContext(Ae),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(T.tableConfig,"justify-self-center"),children:[s.jsx("span",{"data-tooltip-content":"Previous page","data-tooltip-id":"default",className:A(T.tableAction,T.gray,e<1&&"opacity-30"),onClick:u,role:"button",children:s.jsx(Ge,{width:16,height:16,className:"rotate-180"})}),s.jsxs("span",{"data-tooltip-id":"rows-num",className:T.paginationIndicator,children:[a+1," - ",a+c,i&&"+"]}),s.jsx("span",{"data-tooltip-content":"Next page","data-tooltip-id":"default",className:A(T.tableAction,i?T.gray:"opacity-30"),onClick:d,role:"button",children:s.jsx(Ge,{width:16,height:16})})]})}const Om=[5,10,20,50,100,200],Mm=!__CLIENT_CONFIG__.skipAuth;function $m(){const{dataSourceId:e,name:t}=l.useContext(qe),{data:n}=ls(e),{data:o,refetch:r}=l.useContext(Ae),a=Rn(pe.EDITOR),i=ah(),{rename:c}=xm(),{size:u,setSize:d}=sa(),{state:m}=l.useContext(xe),h=en(),p=Y(),x=()=>{h.mutateAsync({name:t,opts:m}).then(f=>{p(P.workbenchTab.build({id:f.id}))})},g=()=>{if(o?.result.queryHistoryId){const f=new URL(window.location.href);f.pathname=P.share.build(),f.searchParams.set("shareId",o.result.queryHistoryId),navigator.clipboard.writeText(f.toString()),Re.success("Share link copied to clipboard")}},b=()=>{o?.result.columns?.[0].table&&Zs({table:o?.result.columns?.[0].table,dataSourceId:e})},v=async()=>{const f=await Tn("Query name",t);!f||!o?.result.queryHistoryId||i.mutate({name:f,queryId:o.result.queryHistoryId})},y=()=>c(t);return Ee("s",v),Ee("r",y),Ee("d",x),s.jsxs("div",{className:"flex justify-self-end",children:[s.jsx("span",{"data-tooltip-content":"Show filters","data-tooltip-id":"default",className:A(T.tableAction,T.gray),onClick:()=>Me("filters"),role:"button",children:s.jsx(ba,{width:16,height:16})}),s.jsx("span",{"data-tooltip-content":"Join table","data-tooltip-id":"default",className:A(T.tableAction,T.gray),onClick:()=>Me("joins"),role:"button",children:s.jsx(ga,{width:16,height:16})}),s.jsx("span",{"data-tooltip-content":"Refresh data","data-tooltip-id":"default",className:A(T.tableAction,T.gray),onClick:()=>r(),role:"button",children:s.jsx(xa,{width:16,height:16})}),Mm&&s.jsx("span",{"data-tooltip-content":"Share query","data-tooltip-id":"default",className:A(T.tableAction,T.gray),onClick:g,role:"button",children:s.jsx(pm,{width:16,height:16})}),s.jsx("span",{"data-tooltip-content":"Duplicate tab","data-tooltip-id":"default",className:A(T.tableAction,T.gray),onClick:x,role:"button",children:s.jsx(fm,{width:16,height:16})}),s.jsx(os,{id:"rows-num",className:"z-10 shadow-md flex gap-1",clickable:!0,variant:"light",opacity:1,children:Om.map(f=>s.jsx("button",{onClick:()=>d(f,!0),className:A(T.tableAction,T.gray,f===u&&T.selectedSize),children:s.jsx("span",{children:f})},f))}),s.jsx("button",{"data-tooltip-id":"explorer-more-actions",className:A(T.tableAction,T.gray),children:s.jsx(mm,{width:16,height:16})}),s.jsxs(os,{id:"explorer-more-actions",className:"z-10 shadow-md flex flex-col",clickable:!0,variant:"light",opacity:1,children:[s.jsxs("button",{onClick:()=>Me("columns"),className:A(T.tableAction,T.modal,T.gray,"justify-between"),children:[s.jsx("span",{children:"Columns"}),s.jsx("span",{className:"hotkey",children:"C"})]}),s.jsxs("button",{onClick:()=>Me("groupBy"),className:A(T.tableAction,T.modal,T.gray,"justify-between"),children:[s.jsx("span",{children:"Group by"}),s.jsx("span",{className:"hotkey",children:"G"})]}),s.jsxs("button",{onClick:()=>Me("aggregate"),className:A(T.tableAction,T.modal,T.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(T.tableAction,T.modal,T.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(T.tableAction,T.modal,T.gray),children:[s.jsx("span",{children:"Save query"}),s.jsx("span",{className:"hotkey",children:"S"})]}),n?.allowInsert===!0&&s.jsx("button",{onClick:b,className:A(T.tableAction,T.modal,T.gray),children:"Insert new row"})]})]})]})}const Dm="_drop-container_1x8ce_2",Fm="_item_1x8ce_2",Xo={dropContainer:Dm,item:Fm},_a=({dataSourceId:e,inputClassName:t,focusId:n,placeholder:o="Column",onChange:r,value:a,autoFocus:i,allowTables:c})=>{const{data:u}=Sn(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,x]=l.useState(!1),[g,b]=l.useState(0),v=f=>{if(f.key==="ArrowDown")f.preventDefault(),b(w=>(w+1)%h.length);else if(f.key==="ArrowUp")f.preventDefault(),b(w=>(w-1+h.length)%h.length);else if(f.key==="Enter"&&g>=0&&g<h.length){f.preventDefault();const w=h[g].value;x(!1);const C=m.findIndex(_=>_.value===w)>-1;r(h[g]?.value||w,C,!0)}};l.useEffect(()=>{const f=d.current?.querySelector('[data-is-active="true"]');f&&f.scrollIntoView({behavior:"smooth",block:"nearest"})},[g]);const y=f=>{const w=f.currentTarget.value,C=m.findIndex(_=>_.value===w)>-1;r(w,C,!1)};return s.jsxs("div",{className:"relative",onFocus:()=>x(!0),onBlur:()=>x(!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:Xo.dropContainer,ref:d,tabIndex:-1,children:h.map((f,w)=>s.jsxs("div",{className:Xo.item,"data-is-active":g===w,onMouseDownCapture:C=>{C.preventDefault(),x(!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))})]})},Bm="_actions_1js4i_2",qm="_filter-actions_1js4i_2",Um="_advanced-filter-icon_1js4i_2",Wm="_filters-container_1js4i_2",Hm="_filter-container_1js4i_2",vn={actions:Bm,filterActions:qm,advancedFilterIcon:Um,filtersContainer:Wm,filterContainer:Hm},zm=({filter:e,dataSourceId:t,allowedTables:n,autoFocus:o,onChangeColumn:r,onChangeValue:a,onRemoveFilter:i,onChangeAdvancedFilter:c,triggerIsEnabled:u,onSubmit:d})=>{const m=p=>{const x=p.target.value;x.charAt(0)===":"?c(e.id,!0):(!e.isAdvanced&&["=","<",">"].includes(x.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:vn.filterContainer,children:[s.jsx("input",{type:"checkbox",checked:e.isEnabled!==!1,onClick:()=>u(e.id)}),s.jsx(_a,{dataSourceId:t,onChange:p=>r(e.id,p),value:e.column,allowTables:n,focusId:"column",inputClassName:"input w-full",autoFocus:o}),s.jsxs("div",{className:"flex items-center",children:[e.isAdvanced&&s.jsx("span",{className:vn.advancedFilterIcon,children:s.jsx(ba,{width:14,height:14})}),s.jsx("input",{placeholder:"Filter value",value:e.value,onChange:m,onKeyDown:h,"data-focus":"value",className:"input flex-1"},e.id)]}),s.jsx("div",{className:vn.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",onClick:()=>i(e.id),children:s.jsx(Ct,{width:20,height:20,className:"text-red-600"})})})]})},Vm=()=>{const{state:e}=l.useContext(xe),{refetch:t}=l.useContext(Ae),{setFilters:n}=so(),o=ds(b=>b.filters),r=l.useMemo(()=>[e.table,...e.joins.map(b=>b.table)],[e.table,e.joins]),[a,i]=l.useState([]),c=(b,v)=>{i(y=>[...y.map(f=>f.id===b?{...f,column:v}:f)])},u=(b,v)=>{i(y=>[...y.map(f=>f.id===b?{...f,value:v}:f)])},d=()=>{i(b=>[...b,{id:st(),value:"",column:"",isEnabled:!0}])},m=b=>{i(v=>v.filter(y=>y.id!==b))},h=(b,v)=>{i(y=>y.map(f=>f.id===b?{...f,isAdvanced:v}:f))},p=()=>hs("filters"),x=()=>{try{n(a.filter(b=>b.value.length>0&&b.column.length>0)),setTimeout(t,1),p()}catch(b){b instanceof Error?Re.error(b.message):Re.error("Error during parsing, check you filters")}},g=b=>{i(v=>v.map(y=>y.id===b?{...y,isEnabled:!y.isEnabled}:y))};return l.useEffect(()=>{o&&i(()=>[...e.filters,{id:st(),value:"",column:"",isEnabled:!0}])},[o]),Ee("f",()=>{es("filters")}),s.jsxs(ve,{isVisible:o,onClose:p,portal:!0,onClosed:()=>i([]),noPadding:!0,children:[s.jsx(at,{onClick:p}),s.jsx("h2",{className:"text-lg font-semibold m-2",children:"Filters"}),s.jsxs("div",{className:vn.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((b,v)=>s.jsx(zm,{filter:b,dataSourceId:e.dataSourceId,allowedTables:r,onChangeColumn:c,onChangeValue:u,onRemoveFilter:m,onChangeAdvancedFilter:h,triggerIsEnabled:g,onSubmit:x,autoFocus:v===a.length-1},b.id))]}),s.jsxs("div",{className:vn.actions,children:[s.jsxs("button",{className:"button tertiary flex items-center gap-1 text-sm",onClick:d,children:[s.jsx(ga,{width:20,height:20}),s.jsx("span",{children:"Add filter"})]}),s.jsx("button",{className:"button primary text-sm",onClick:x,children:"Apply filters"})]})]})},Qm="_join-modal_1pj2b_2",Km={joinModal:Qm},Gm=(e,t)=>e.type!==t.type||e.on!==t.on||e.table!==t.table,Ym=(e,t)=>e.type===t.type&&e.on===t.on&&e.table===t.table,Sa=()=>{const{state:e,setState:t}=l.useContext(xe),n=l.useCallback(o=>{t(r=>{const a=r.joins;if(a.some(c=>Ym(c,o))){const c=o.table+".";return{...r,joins:a.filter(u=>Gm(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}},Jm=()=>{const{isFetching:e}=l.useContext(Ae),t=ds(u=>u.joins),{toggle:n}=Sa(),{availableJoins:o}=l.useContext(qe),[r,a]=l.useState(""),i=l.useMemo(()=>{const u=r.toLowerCase();return o.filter(d=>d.on.toTable.toLowerCase().includes(u))},[o,r]),c=()=>hs("joins");return Ee("j",()=>{o.length>0?Me("joins"):Re.error("No available tables to join")}),s.jsxs(ve,{isVisible:t,onClose:c,portal:!0,children:[s.jsx(at,{onClick:c}),s.jsxs("div",{className:Km.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(ne,{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(Jr,{hook:u,onClick:()=>{e||(n({table:u.on.toTable,type:"LEFT",on:u.where}),a(""),c())}},u.where))})]})]})};function Xm(e){return e.reduce((t,n)=>(t[n]=!0,t),{})}function Zo(e){return e.reduce((t,n)=>(t[n]=!0,t),{})}const Zm="_container_hkce7_2",ef="_column-label_hkce7_2",tf="_not-active_hkce7_2",Jn={container:Zm,columnLabel:ef,notActive:tf};function nf(e){if(!e)return[];const t={};return e.forEach(n=>{t[n.table]?t[n.table].push({value:n.full,ogColumn:n.column,label:et(n.column),type:n.type}):t[n.table]=[{value:n.full,ogColumn:n.column,label:et(n.column),type:n.type}],mc[n.type]&&["YEAR","MONTH","DAY"].forEach(o=>{t[n.table].push({value:o+" "+n.full,ogColumn:n.column,label:o+" "+et(n.column),type:"number",nested:!0})})}),Object.entries(t).reduce((n,[o,r])=>(n.push({name:et(o),columns:r}),n),[])}function sf(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 of=({column:e,selected:t,onCheck:n})=>s.jsxs("label",{className:A(Jn.columnLabel,t?Jn.active:Jn.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),rf={columns:"c",groupBy:"g"},er=({mode:e})=>{const t=ds(f=>f[e]),{allColumns:n}=l.useContext(qe),{state:o,setState:r}=l.useContext(xe),[a,i]=l.useState({}),[c,u]=l.useState(""),d=l.useMemo(()=>nf(n),[n]),m=o.aggregations.length>0||o.groupBy.length>0,h=l.useMemo(()=>c?sf(d,c):d,[c,d]),p=f=>{i(w=>({...w,[f.target.name]:f.target.checked}))},x=f=>{const w=f.target.checked;i(C=>{for(const _ of n)C[_.full]=w;return{...C}})},g=()=>{hs(e)},b=()=>{const f=[];for(const[w,C]of Object.entries(a))if(C){const[_,k]=w.split(" ");f.push({value:k||_,fn:k?_:void 0})}r(w=>({...w,[e]:f})),g()},v=l.useMemo(()=>{for(const f of n)if(!a[f.full])return!1;return!0},[a,n]);Ee(rf[e],()=>{e==="columns"?m?Re.error("Columns are ignored when there is at least one aggregation or group by"):es("columns"):es("groupBy")}),l.useEffect(()=>{t&&i(()=>Xm(o[e].map(f=>f.fn?f.fn+" "+f.value:f.value)))},[t,i]);const y=()=>{u(""),i({})};return s.jsxs(ve,{isVisible:t,onClose:g,portal:!0,onClosed:y,children:[s.jsx(at,{onClick:g}),s.jsxs("div",{className:Jn.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(of,{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:x}),s.jsx("span",{children:"Select all"})]}),s.jsx("span",{className:"flex-1"}),s.jsx("button",{className:"button tertiary",onClick:g,children:"Cancel"}),s.jsx("button",{className:"button primary",onClick:b,children:"Apply"})]})]})]})},af="_options-container_1wdge_2",lf={optionsContainer:af},Ls="COUNT all",cf=()=>{const e=ds(g=>g.aggregate),{dataSourceId:t}=l.useContext(qe),{setState:n,state:o}=l.useContext(xe),{data:r}=l.useContext(Ae),[a,i]=l.useState({fn:"",col:""}),c=g=>i({...a,fn:g.currentTarget.value}),u=g=>i({...a,col:g}),d=()=>hs("aggregate"),m=()=>{const g=a.fn===Ls?{value:"*",fn:"COUNT"}:{fn:a.fn,value:a.col,distinct:a.fn==="COUNT"};n(b=>({...b,aggregations:[...b.aggregations,g]}))},h=a.fn===Ls,p=h?!1:!a.col||!a.fn,x=g=>{const b=Fr(g);n(v=>({...v,aggregations:v.aggregations.filter(y=>y.fn!==g.fn||y.value!==g.value),orderBy:v.orderBy.filter(y=>y.column!==b)}))};return Ee("a",()=>{es("aggregate")}),s.jsxs(ve,{isVisible:e,onClose:d,backdropClose:!0,portal:!0,children:[s.jsx(at,{onClick:d}),s.jsxs("div",{children:[s.jsx("h2",{className:"text-lg font-semibold",children:"Aggregate"}),De(o.aggregations.length,0)&&s.jsx("div",{className:"flex flex-col gap-1 mt-4",children:o.aggregations.map((g,b)=>s.jsxs("p",{className:"p-2 rounded-md bg-gray-50 flex items-center justify-between",children:[s.jsx("span",{children:Gn(g)}),s.jsx("button",{tabIndex:-1,"data-tooltip-id":"default","data-tooltip-content":"Remove aggregation",className:"p-0.5 text-sm cursor-pointer",onClick:()=>x(g),children:s.jsx(Ct,{width:20,height:20,className:"text-red-600"})})]},b))}),s.jsxs("div",{className:lf.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:Ls,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(_a,{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"})]})]})]})},uf="_container_1291a_2",df="_yellow-pill_1291a_2 _pill_1291a_2",hf="_blue-pill_1291a_2 _pill_1291a_2",mf="_purple-pill_1291a_2 _pill_1291a_2",ff="_red-pill_1291a_2 _pill_1291a_2",pf="_black-pill_1291a_2 _pill_1291a_2",xf="_disabled-pill_1291a_2",bt={container:uf,yellowPill:df,bluePill:hf,purplePill:mf,redPill:ff,blackPill:pf,disabledPill:xf};function ka(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 bf(e){return!(e===!0||e===void 0)}const gf=()=>{const{state:{aggregations:e,columns:t,groupBy:n}}=l.useContext(xe),{toggle:o,joins:r}=Sa(),{filters:a,setFilters:i,removeFilter:c}=so(),u=()=>Me("joins"),d=()=>Me("aggregate"),m=()=>Me("columns"),h=()=>Me("groupBy"),p=b=>{b.preventDefault(),b.stopPropagation(),o(r[r.length-1])},x=b=>{i(a.map(v=>({...v,isEnabled:b===v.id?bf(v.isEnabled):v.isEnabled})),!0)},g=b=>v=>{v.preventDefault(),v.stopPropagation(),c(b)};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((b,v)=>s.jsxs("button",{onClick:u,className:bt.yellowPill,"data-tooltip-id":"default","data-tooltip-content":`Joins ${b.table} on ${b.on}`,children:[s.jsx("p",{className:"text-sm",children:b.table}),v===r.length-1&&s.jsx(Ct,{onClick:p,width:18,height:18})]},b.table)),a.map(b=>s.jsxs("button",{onClick:()=>x(b.id),onAuxClick:()=>c(b.id),className:A(bt.bluePill,b.isEnabled===!1&&bt.disabledPill),"data-tooltip-id":"default","data-tooltip-content":`${b.column} ${b.value}`,children:[s.jsx("p",{className:"text-sm",children:b.column}),s.jsx("p",{className:"text-sm",children:b.value}),s.jsx(Ct,{onClick:g(b.id),width:18,height:18})]},b.id)),e.map(b=>s.jsx("button",{onClick:d,className:A(bt.purplePill),"data-tooltip-id":"default","data-tooltip-content":Gn(b),children:s.jsx("p",{className:"text-sm",children:Gn(b)})},Gn(b))),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},vf=({options:e,updater:t,name:n,tabId:o})=>{const r=xc(e,t),a=Ec(o,r.state),i=pc(a.data,r.state.dataSourceId,n,o);return s.jsx(qe,{value:i,children:s.jsx(xe,{value:r,children:s.jsxs(Ae,{value:a,children:[s.jsx(Am,{}),s.jsx(gf,{}),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(rh,{})}),s.jsx(Vm,{}),s.jsx(Jm,{}),s.jsx(er,{mode:"columns"}),s.jsx(er,{mode:"groupBy"}),s.jsx(cf,{})]})]})})})},ho=()=>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..."})]}),yf=({id:e})=>{const{data:t}=_c(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(vf,{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(ho,{})})},wf=e=>{setTimeout(t=>{const n=document.querySelector(`[data-tab-id="${t}"]`);n&&n.scrollIntoView({behavior:"smooth"})},50,e)},Cf=()=>{const{id:e}=Pi(),t=Y(),{data:n}=cs(),o=Sc(),r=Vr(no.laptop),a=u=>{if(u===e&&n){if(n.length===1)return t(P.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&&wf(e)},[e,n]),s.jsxs("div",{className:"h-screen max-h-screen bg-(--bg) flex flex-col",children:[e?s.jsx(yf,{id:e}):s.jsx("div",{className:"flex-1"}),s.jsx("div",{className:A(xn.tabs,"no-scrollbar",!r&&xn.mobile),children:n?.map(u=>s.jsxs("div",{onClick:()=>t(P.workbenchTab.build({id:u.id})),className:A(xn.tab,u.id===e&&xn.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:xn.closeButton,onClick:i,children:s.jsx(Ct,{width:20,height:20})})]},u.id))})]})},jf="_root_m02v8_2",Nf="_up_m02v8_2",_f="_down_m02v8_2",Sf="_chevron_m02v8_2",kf="_table-name-container_m02v8_2",Ef="_link_m02v8_2",Rf="_table-name_m02v8_2",Tf="_ul_m02v8_2",Lf="_column-type_m02v8_2",Af="_action-blue_m02v8_2 _action_m02v8_2",Pf="_action-red_m02v8_2 _action_m02v8_2",If="_db-header-container_m02v8_2",Of="_db-header_m02v8_2",Mf="_db-subheader_m02v8_2 _db-header_m02v8_2",te={root:jf,up:Nf,down:_f,chevron:Sf,tableNameContainer:kf,link:Ef,tableName:Rf,ul:Tf,columnType:Lf,actionBlue:Af,actionRed:Pf,dbHeaderContainer:If,dbHeader:Of,dbSubheader:Mf},$f="_sidebar_9itzl_2",Df="_sidebar-visible_9itzl_2",Ff="_sidebar-container_9itzl_2",Bf="_sidebar-invisible_9itzl_2",qf="_backdrop_9itzl_2",bn={sidebar:$f,sidebarVisible:Df,sidebarContainer:Ff,sidebarInvisible:Bf,backdrop:qf},Ea=({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]),l.useEffect(()=>{const h=p=>{n&&p.key==="Escape"&&u.current()};return window.addEventListener("keydown",h),()=>{window.removeEventListener("keydown",h)}},[n]),s.jsxs("div",{onTransitionEnd:m,className:A(bn.sidebar,n?bn.sidebarVisible:bn.sidebarInvisible),children:[s.jsx("div",{onClick:d,className:bn.backdrop}),s.jsx("div",{className:A(bn.sidebarContainer,a),children:i&&e})]})},Uf=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})),Wf=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"})),Ra=(e,t=!0)=>{const n=navigator.clipboard.writeText(e);t&&n.then(()=>{Re.success(`Copied "${e}"`)})},Hf=new Intl.DateTimeFormat("en",{dateStyle:"full",timeStyle:"long"}),Vn=18;function zf(e,t){return t&&e.toLowerCase().includes(t)?"bg-yellow-200 cursor-pointer":"cursor-pointer"}const Vf=({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:te.ul,children:o.map(r=>s.jsx(s.Fragment,{children:s.jsxs("li",{children:[r.isPrimary?"🔐":"🏷️"," ",s.jsx("span",{onClick:()=>Ra(r.name),className:zf(r.name,t),children:r.name})," ",s.jsxs("span",{className:te.columnType,children:["[",r.type,"]"]}),r.ref&&s.jsxs("span",{children:[" ➡️ ",s.jsx("span",{className:te.columnType,children:r.ref.table}),".",r.ref.field]})]},r.name+r.type)}))},e.id)};function Qf({id:e}){const{data:t}=ls(e),{data:n}=Sn(e),o=Y(),r=oc(),a=Mr(),i=rc(),c=en(),u=l.useMemo(()=>t?.lastInspected?Hf.format(new Date(t.lastInspected)):"--",[t]),[d,m]=l.useState({}),[h,p]=l.useState(""),[x,g]=l.useState("table"),b=Rn(pe.EDITOR),v=h.toLowerCase(),y=l.useMemo(()=>{if(!v||!n)return n||[];const S=[];for(const I of n){if(I.tableName.toLowerCase().includes(v)){S.push(I);continue}x!=="table"&&I.columns.findIndex(B=>B.name.toLowerCase().includes(v))>=0&&S.push(I)}return S},[v,n,x]),f=S=>{m(I=>({...I,[S]:!I[S]}))},w=S=>{c.mutateAsync({name:S,opts:Zt({table:S,dataSourceId:e})}).then(I=>{zt(void 0),o(P.workbenchTab.build({id:I.id}))})},C=()=>{a.mutate(e)},_=async()=>{const S=await Tn("Enter name",t?.name);S&&r.mutate({id:e,dataSource:{name:S}})},k=async()=>{await Hr("Are you sure you want to delete this data source?")&&(i.mutate(e),zt(void 0))},j=x==="column";return s.jsxs("div",{className:te.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:te.dbHeaderContainer,children:[s.jsxs("div",{className:te.dbHeader,children:[t&&s.jsx(it,{size:24,type:t.dbType}),s.jsx("p",{className:"truncate text-(--text-color-primary) text-lg",children:t?.name})]}),s.jsxs("div",{className:te.dbSubheader,children:[s.jsx("p",{className:"text-xs text-(--text-color-secondary) truncate",children:u}),b&&s.jsxs("div",{className:"flex justify-end",children:[s.jsx("button",{disabled:a.isPending,onClick:C,className:te.actionBlue,"data-tooltip-id":"default-xs","data-tooltip-content":"Refresh schema",children:s.jsx(xa,{width:16,height:16})}),s.jsx("button",{disabled:a.isPending,onClick:_,className:te.actionBlue,"data-tooltip-id":"default-xs","data-tooltip-content":"Update name",children:s.jsx(na,{width:16,height:16})}),s.jsx("button",{disabled:a.isPending,onClick:k,className:te.actionRed,"data-tooltip-id":"default-xs","data-tooltip-content":"Delete data source",children:s.jsx(Wf,{width:16,height:16})})]})]})]}),s.jsxs("div",{className:"flex gap-2 items-center mt-2",children:[s.jsxs("select",{className:"input",value:x,onChange:S=>g(S.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:j?"Search column":"Search table",value:h,onChange:S=>p(S.target.value),autoFocus:!0})]})]}),s.jsx("div",{className:"overflow-y-auto p-4",children:y?.map(S=>s.jsxs("div",{children:[s.jsxs("div",{className:te.tableNameContainer,children:[s.jsx("button",{className:A(te.chevron,d[S.id]?te.down:te.up),onClick:()=>f(S.id),children:s.jsx(Ge,{width:16,height:16})}),s.jsx("button",{className:A(te.tableName,"flex-1"),onClick:()=>f(S.id),children:S.tableName}),s.jsx("button",{className:te.link,onClick:()=>w(S.tableName),"data-tooltip-id":"default-xs","data-tooltip-content":"Explore table data",children:s.jsx(Uf,{width:Vn,height:Vn})}),s.jsx("button",{className:te.link,onClick:()=>Ra(S.tableName),"data-tooltip-id":"default-xs","data-tooltip-content":"Copy table name",children:s.jsx(ta,{width:Vn,height:Vn})})]}),(d[S.id]||h.length>0)&&s.jsx(Vf,{insp:S,filter:j?v:"",expanded:d[S.id]})]},S.id))})]})}const Kf=()=>{const e=iu(),[t,n]=l.useState(void 0);l.useEffect(()=>{e&&n(e)},[e]);const o=()=>zt(void 0);return s.jsx(Ea,{isVisible:e!=null,onClose:o,onClosed:()=>n(void 0),backdropClose:!0,children:t&&s.jsx(Qf,{id:t})})},Gf="_search_j0hbg_2",Yf="_entry_j0hbg_2",Jf="_ds_j0hbg_2",Xf="_ds-container_j0hbg_2",Zf="_ds-entry_j0hbg_2",ep="_enabled_j0hbg_2",qt={search:Gf,entry:Yf,ds:Jf,dsContainer:Xf,dsEntry:Zf,enabled:ep};function tp(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 np=({storage:e=localStorage,localStorageKey:t,initialData:n})=>{const o=_e(tp(t,n,e));return o[2].subscribe(r=>{e.setItem(t,JSON.stringify(r))}),o},[sp,op]=np({initialData:[],localStorageKey:"selected-data-sources-v1"}),rp=e=>op(t=>{const n=t.indexOf(e);return n>-1?(t.splice(n,1),[...t]):[...t,e]}),ap={table:"📄",query:"📖",tab:"🛠️"},ip=({onTable:e,onQuery:t,onWorkbenchTab:n,autoFocus:o})=>{const[r,a]=l.useState(""),[i,c]=l.useState(-1),u=ka(r,200),d=sp(),{data:m}=ue(),{data:h}=Js({teamId:m?.teamId}),p=l.useMemo(()=>{const f=[],w=Zo(d);if(!h||h.length===0)return[];for(const C of h)w[C.id]&&f.push(C.id);return f},[d,h]),{data:x}=Ql(u,{teamId:m?.teamId,selectedDataSources:p}),g=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)},b=f=>{x&&(f.key==="ArrowDown"?(f.preventDefault(),c(w=>(w+1)%x.length)):f.key==="ArrowUp"?(f.preventDefault(),c(w=>(w-1+x.length)%x.length)):f.key==="Enter"&&i>=0&&x[i]?.name&&(f.preventDefault(),g(x[i])))},v=f=>{const w=f.currentTarget.dataset.tableId,C=x?.find(_=>_.id===w);C&&g(C)},y=l.useMemo(()=>Zo(d),[d]);return s.jsxs("div",{className:"overflow-hidden flex flex-col w-full lg:w-lg",children:[De(h?.length,0)?s.jsx("div",{className:qt.dsContainer+" no-scrollbar",children:h.map(f=>s.jsxs("button",{className:A(qt.dsEntry,y[f.id]&&qt.enabled),onClick:()=>rp(f.id),children:[s.jsx(it,{size:24,type:f.dbType}),s.jsx("span",{children:f.name})]},f.id))}):s.jsx(ne,{variant:"warning",className:"mb-4",children:"Connect at least one data source to start using DataRamen"}),s.jsx("input",{className:qt.search,placeholder:"Search table or saved query to start from",value:r,onChange:f=>a(f.target.value),onKeyDown:b,autoFocus:o}),De(x?.length,0)&&s.jsx("div",{className:"overflow-y-auto max-h-full mt-2",children:x.map((f,w)=>s.jsxs("button",{className:qt.entry,"data-is-active":i===w,"data-table-id":f.id,onClick:v,children:[s.jsxs("p",{className:"font-semibold truncate",children:[ap[f.type]," ",f.name]}),s.jsxs("p",{className:qt.ds,children:["📦 ",f.dataSourceName]})]},f.id))})]})},lp=()=>{const e=Tc(),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(ve,{isVisible:!!e,onClose:r,backdropClose:!0,children:s.jsx(ip,{autoFocus:!0,onTable:t,onQuery:n,onWorkbenchTab:o})})},cp=()=>{const e=En("Hotkey"),t=Y(),{pathname:n}=le(),{data:o}=ue(),{data:r}=cs(),a=P.home.check(n);Ee("n",()=>{o&&e()}),Ee("w",()=>{o&&(r&&r.length>0?t(P.workbenchTab.build({id:r[0].id})):e())},{enabled:a}),Ee("h",()=>{Vt({show:!0})})},up=()=>{const e=le();l.useEffect(()=>{},[e.pathname])},[dp,Ta]=_e(!1),As=()=>Ta(!1),La=()=>Ta(!0),hp=({repeatPassword:e,password:t})=>t.length<1?null:t.length<8?s.jsx(ne,{variant:"warning",children:"New password should be at least 8 characters long"}):t!==e?s.jsx(ne,{variant:"warning",children:"Repeat password should match new password"}):null,mp=()=>{const e=dp(),{data:t}=ue(),{mutateAsync:n,isPending:o}=ac(),r=Y(),[{password:a,repeatPassword:i},{change:c,touched:u,reset:d}]=Cn({password:"",repeatPassword:""}),m=()=>{r("/"),Hs.logout().then(()=>{As()})},h=()=>{n({password:a}).then(()=>{d(),Re.success("Password successfully updated!")})},p=a.length<8||a!==i||o,x=u.includes("password");return s.jsxs(ve,{isVisible:e,onClose:As,children:[s.jsx(at,{onClick:As}),s.jsxs("div",{className:"w-full lg:w-lg flex flex-col gap-2",children:[s.jsx(Wr,{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")})]})]}),x&&s.jsx(hp,{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"})]})]})]})},[fp,Aa]=_e(!1),Pa=()=>Aa(!0),tr=()=>Aa(!1),pp=e=>ce({queryKey:["team-users"],queryFn:async()=>{const{data:t}=await O.get("/teams/"+e+"/users");return t.data},enabled:!!e}),xp=()=>X({mutationFn:async({role:e,teamId:t,userId:n})=>(await O.patch("/teams/"+t+"/user-role",{role:e,userId:n}),!0),onSuccess:()=>{K.invalidateQueries({queryKey:["team-users"]})}}),bp=()=>X({mutationFn:async({teamId:e,userId:t})=>(await O.delete("/teams/"+e,{params:{userId:t}}),!0),onSuccess:()=>{K.invalidateQueries({queryKey:["team-users"]})}}),gp="_user-entry_o919l_2",vp="_select-container_o919l_2",nr={userEntry:gp,selectContainer:vp},yp=()=>{const e=fp(),{data:t}=ue(),{data:n}=pp(t?.teamId),{mutate:o,isPending:r}=ic(),{mutate:a,isPending:i}=xp(),{mutate:c,isPending:u}=bp(),[d,{change:m,reset:h}]=Cn({password:"",username:""}),p=()=>{o({username:d.username,password:d.password,teamId:t?.teamId||""}),h()},x=(y,f)=>{a({teamId:t.teamId,role:f,userId:y})},g=y=>{Hr("Are you sure you want to remove this user?").then(f=>{f&&c({userId:y,teamId:t.teamId})})},b=Rn(pe.ADMIN),v=r||i||u;return s.jsxs(ve,{isVisible:e,onClose:tr,backdropClose:!0,children:[s.jsx(at,{onClick:tr}),s.jsxs("div",{className:"w-full lg:w-lg flex flex-col overflow-hidden",children:[s.jsx(Wr,{children:"Manage users"}),De(n?.length,0)&&s.jsx("div",{className:"mt-4 overflow-y-auto flex-1",children:n.map(y=>s.jsxs("div",{className:nr.userEntry,children:[s.jsx("div",{className:nr.selectContainer,children:s.jsxs("select",{value:y.role,disabled:!b||v,onChange:f=>x(y.id,f.currentTarget.value),children:[s.jsx("option",{value:pe.OWNER,children:"Owner"}),s.jsx("option",{value:pe.ADMIN,children:"Admin"}),s.jsx("option",{value:pe.EDITOR,children:"Editor"}),s.jsx("option",{value:pe.READ_ONLY,children:"Reader"})]})}),s.jsx("p",{className:"flex-1 mx-2",children:y.name}),b&&s.jsx("button",{className:"p-1 cursor-pointer text-red-500 text-sm",onClick:()=>g(y.id),children:"❌"})]},y.id))}),b&&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."})]})]})]})},wp=()=>{const[e,t]=l.useState(""),[n,o]=l.useState(""),[r,a]=l.useState(),[i,c]=l.useState(!1),u=Y(),d=m=>{m.preventDefault(),a(void 0),Hs.login({password:n,username:e}).then(()=>{u("/",{replace:!0})}).catch(a)};return s.jsx("div",{className:"page-container bg-(--bg) h-screen",children:s.jsx("div",{className:"page-content items-center",children:s.jsxs("form",{className:"flex flex-col gap-2 w-full lg:w-lg",onSubmit:d,children:[s.jsx("p",{className:"font-semibold text-xl min-w-md",children:"Login"}),r&&s.jsx(ne,{variant:"danger",children:"Failed to login. Please verify your credentials"}),s.jsx("input",{value:e,onChange:m=>t(m.currentTarget.value),className:"input",placeholder:"User name"}),s.jsx("input",{value:n,onChange:m=>o(m.currentTarget.value),className:"input",type:"password",placeholder:"Password"}),s.jsx("button",{type:"submit",className:"button primary",children:"Login"}),i?s.jsxs(ne,{className:"w-full border border-blue-500",children:[s.jsx("p",{children:"If this is your first login, the default credentials are:"}),s.jsxs("ul",{className:"mt-2",children:[s.jsxs("li",{children:["Username: ",s.jsx("strong",{children:"admin"})]}),s.jsxs("li",{children:["Password: ",s.jsx("strong",{children:"admin"})]})]}),s.jsx("p",{className:"mt-2",children:"Please make sure to change the default password to a secure one."})]}):s.jsx("button",{className:"button tertiary",onClick:()=>c(!0),children:"First login?"})]})})})},Cp=()=>{const e=Y(),{pathname:t}=le(),{data:n,isLoading:o}=$r();l.useEffect(()=>{!n&&!o&&!P.login.check(t)&&e(P.login.build())},[n,o,e,t])},jp=()=>{},Np=__CLIENT_CONFIG__.skipAuth?jp:Cp,_p=()=>{const[e]=Nl(),t=Y(),n=en(),o=e.get("shareId");return l.useEffect(()=>{o&&n.mutateAsync({queryId:o}).then(r=>{t(P.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(ho,{}),s.jsx("p",{children:"Fetching query information"})]}),n.isError&&s.jsx(ne,{variant:"danger",children:"Failed to load query information"})]})},Sp="_container_wvlsy_2",kp="_header_wvlsy_2",Ep="_close-button_wvlsy_2",Rp="_tab-container_wvlsy_2",Tp="_tab-name_wvlsy_2",Lp="_archived-badge_wvlsy_2 _badge_wvlsy_2",Ap="_active-badge_wvlsy_2 _badge_wvlsy_2",Pp="_delete-action_wvlsy_2",Ip="_load-more-btn_wvlsy_2",ze={container:Sp,header:kp,closeButton:Ep,tabContainer:Rp,tabName:Tp,archivedBadge:Lp,activeBadge:Ap,deleteAction:Pp,loadMoreBtn:Ip},Op=new Intl.DateTimeFormat,Mp=()=>{const{data:e}=ue(),{data:t,fetchNextPage:n,hasNextPage:o,isFetching:r}=Kl(e?.teamId,25),a=Y(),i=Br(),c=Rc(),u=l.useRef(null),d=l.useRef(null),m=x=>{i.mutate(x),Vt({show:!1}),a(P.workbenchTab.build({id:x}))},h=()=>{u.current?.close(),c.mutate(d.current)},p=t&&t?.length>0;return s.jsxs("div",{className:ze.container,children:[s.jsxs("div",{className:ze.header,children:[s.jsx("h3",{className:"text-lg",children:"Recent tabs"}),s.jsx("button",{className:ze.closeButton,onClick:()=>Vt({show:!1}),children:s.jsx(Ct,{width:24,height:24})})]}),!p&&s.jsx(ne,{variant:"warning",children:"History is empty."}),t?.map(x=>s.jsxs("div",{className:ze.tabContainer,onClick:()=>m(x.id),onContextMenu:g=>{d.current=x.id,u.current?.open(g,!1)},children:[s.jsxs("div",{className:"flex gap-2 items-center",children:[s.jsx("p",{className:ze.tabName,children:x.name}),x.dataSourceType&&s.jsx(it,{size:16,type:x.dataSourceType}),s.jsx("p",{className:"text-xs text-(--text-color-secondary)",children:x.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:Op.format(new Date(x.updatedAt))}),x.archived?s.jsx("span",{className:ze.archivedBadge,children:"Archived"}):s.jsx("span",{className:ze.activeBadge,children:"Active"})]})]},x.id)),s.jsx(ea,{ref:u,children:s.jsx("button",{onClick:h,className:ze.deleteAction,children:"🗑 Delete"})}),o&&!r&&s.jsx("div",{className:"flex justify-center my-2",children:s.jsx("button",{className:ze.loadMoreBtn,onClick:()=>n(),children:"Load more"})})]})},$p=()=>{const e=lu(t=>t.show);return s.jsx(Ea,{isVisible:e,onClose:()=>Vt({show:!1}),backdropClose:!0,children:s.jsx(Mp,{})})},Dp="_queries-container_cnd4g_2",Fp="_query-entry_cnd4g_2",sr={queriesContainer:Dp,queryEntry:Fp},Bp=()=>{const{data:e}=ue(),[t,n]=l.useState(""),o=ka(t),{data:r,isLoading:a,fetchNextPage:i,hasNextPage:c}=Gl(e?.teamId,o),u=l.useRef(void 0),d=Y(),m=lh(),h=en(),p=ih(),x=Gr(),g=y=>{h.mutateAsync({queryId:y}).then(f=>{d(P.workbenchTab.build({id:f.id}))})},b=async y=>{const f=r?.find(C=>C.id===y);if(!f)return;const w=await Tn("New name?",f?.name);w&&m.mutate({id:f.savedQueryId,payload:{name:w}})},v=y=>{const f=r?.find(w=>w.id===y)?.savedQueryId;f&&p.mutate(f)};return s.jsxs("div",{className:sr.queriesContainer,children:[s.jsx("div",{className:"sticky top-0 p-4 bg-(--bg)",children:s.jsx("input",{className:"input w-full",placeholder:"Filter",value:t,onChange:y=>n(y.target.value)})}),De(r?.length,0)&&r.map(y=>s.jsxs("button",{className:sr.queryEntry,onClick:()=>g(y.id),onContextMenu:f=>{u.current=y.id,x.open(f)},children:[s.jsxs("p",{className:"text-left",children:["📖 ",y.name]}),s.jsxs("p",{className:"flex gap-2 items-center",children:[s.jsx(it,{size:20,type:y.datasourceType}),s.jsx("span",{className:"truncate text-sm text-(--text-color-secondary)",children:y.datasourceName})]})]},y.savedQueryId)),c&&s.jsx("button",{className:"button primary mx-auto mt-4",onClick:()=>i(),children:"Load more"}),!a&&Ad(r?.length,1)&&s.jsx("p",{className:"text-center text-sm text-(--text-color-secondary)",children:"Empty"}),s.jsx(Yr,{handler:x,children:s.jsxs("div",{className:"context-menu-container",children:[s.jsx("button",{onClick:y=>{y.preventDefault(),y.stopPropagation(),x.close(),b(u.current)},className:"context-menu-item",children:"✏️ Rename"}),s.jsx("button",{onClick:y=>{y.preventDefault(),y.stopPropagation(),x.close(),v(u.current)},className:"context-menu-item",children:"🗑️ Delete"})]})})]})},qp=()=>{const{data:e}=ue(),{data:t,isLoading:n}=Xl(e?.teamId);return s.jsx("div",{className:"page-container h-screen max-h-screen",children:s.jsxs("div",{className:"page-content max-h-full",children:[s.jsx("div",{className:"py-10 text-center w-full",children:s.jsx("h1",{className:"comfortaa text-3xl font-semibold text-(--text-color-primary)",children:P.savedQueries.name})}),t?s.jsx(Bp,{}):s.jsx(s.Fragment,{children:n?s.jsx(ho,{}):s.jsx(ne,{variant:"warning",children:"You don't have saved queries."})})]})})},Up=()=>{const{data:e}=ue(),t=Jl(e?.teamId),n=Y();return l.useEffect(()=>{t.mutateAsync().then(o=>{o?n(P.workbenchTab.build({id:o.id}),{replace:!0}):n(P.home.build(),{replace:!0})})},[]),null};function Wp(){return cp(),up(),Np(),s.jsxs(s.Fragment,{children:[s.jsxs(Ki,{children:[s.jsx(gt,{path:P.home.path,element:s.jsx(xu,{})}),s.jsx(gt,{path:P.workbench.path,element:s.jsx(Up,{})}),s.jsx(gt,{path:P.workbenchTab.path,element:s.jsx(Cf,{})}),s.jsx(gt,{path:P.login.path,element:s.jsx(wp,{})}),s.jsx(gt,{path:P.share.path,element:s.jsx(_p,{})}),s.jsx(gt,{path:P.savedQueries.path,element:s.jsx(qp,{})})]}),s.jsx(Eu,{}),s.jsx(Du,{}),s.jsx(Ju,{}),s.jsx(Kf,{}),s.jsx(lp,{}),s.jsx(mp,{}),s.jsx(yp,{}),s.jsx($p,{}),s.jsx(Vu,{}),s.jsx(qu,{})]})}const Hp="_hidden_7arb0_2",zp="_desktop-layout_7arb0_2",Vp="_mobile-layout_7arb0_2",Qp="_nav_7arb0_2",Kp="_shown_7arb0_2",Gp="_main_7arb0_2",Yp="_header_7arb0_2",Jp="_expand_7arb0_2",Xp="_show_7arb0_2",Zp="_hide_7arb0_2",e0="_icon_7arb0_2",t0="_nav-item_7arb0_2",n0="_project-wrapper_7arb0_2",$={hidden:Hp,desktopLayout:zp,mobileLayout:Vp,nav:Qp,shown:Kp,main:Gp,header:Yp,expand:Jp,show:Xp,hide:Zp,icon:e0,navItem:t0,projectWrapper:n0},s0="_container_i6lsu_2",o0={container:s0},r0=({dataSource:e,index:t})=>{const n=()=>{zt(e.id)};return Ee(t.toString(),()=>{zt(o=>{if(o!==e.id)return e.id})}),s.jsxs("button",{className:$.navItem,onClick:n,children:[s.jsx("span",{className:$.icon,children:s.jsx(it,{size:20,type:e.dbType})}),s.jsx("span",{className:"truncate",children:e.name}),s.jsx("span",{className:"hotkey secondary",children:t})]})},a0=()=>{const{data:e}=ue(),{data:t}=zl(e?.teamId);return s.jsx("div",{className:o0.container,children:De(t?.length,0)&&s.jsxs("div",{className:"mt-4 flex flex-col",children:[s.jsx("p",{className:"font-semibold truncate text-(--text-color-secondary) mb-2",children:"Data sources"}),t.map((n,o)=>s.jsx(r0,{dataSource:n,index:o+1},n.id))]})})},i0=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{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",{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"})),l0=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"})),c0=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"})),u0=!__CLIENT_CONFIG__.skipAuth,or=(()=>{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`}})();function d0(){switch(__CLIENT_CONFIG__.modeName){case"docker":return s.jsx(i0,{className:"text-(--text-color-secondary)",width:20,height:20});case"cli":return s.jsx(l0,{className:"text-(--text-color-secondary)",width:20,height:20});default:return s.jsx(c0,{className:"text-(--text-color-secondary)",width:20,height:20})}}const h0=()=>{const e=Y(),{pathname:t}=le(),{data:n}=ue(),o=En("Desktop nav"),[r,a]=l.useState(!1),{data:i}=cs(),c=()=>{P.home.check(t)||e(P.home.build())},u=p=>{P.workbenchTab.check(t)||e(P.workbenchTab.build({id:p}))},d=()=>{P.savedQueries.check(t)||e(P.savedQueries.build())},m=()=>Vt({show:!0}),h=r?void 0:"default";return s.jsxs("nav",{className:A($.nav,r?$.shown:$.hidden),children:[n&&s.jsxs("div",{className:$.header,children:[s.jsxs("button",{onClick:c,className:$.navItem,"data-tooltip-id":h,"data-tooltip-content":"Home",children:[s.jsx("span",{className:$.icon,children:"🏠"}),s.jsx("span",{className:"truncate",children:"Home"})]}),s.jsxs("button",{onClick:o,className:$.navItem,"data-tooltip-id":h,"data-tooltip-content":"New query",children:[s.jsx("span",{className:$.icon,children:"🔎"}),s.jsx("span",{className:"truncate",children:"New query"}),s.jsx("span",{className:"hotkey secondary",children:"N"})]}),s.jsxs("button",{onClick:m,className:$.navItem,"data-tooltip-id":h,"data-tooltip-content":"Recent tabs",children:[s.jsx("span",{className:$.icon,children:"⌛"}),s.jsx("span",{className:"truncate",children:"Recent tabs"}),s.jsx("span",{className:"hotkey secondary",children:"H"})]}),s.jsxs("button",{onClick:d,className:$.navItem,"data-tooltip-id":h,"data-tooltip-content":"Saved queries",children:[s.jsx("span",{className:$.icon,children:"💾"}),s.jsx("span",{className:"truncate",children:"Saved queries"})]}),De(i?.length,0)&&s.jsxs("button",{onClick:()=>u(i[0].id),className:$.navItem,"data-tooltip-id":h,"data-tooltip-content":"Workbench",children:[s.jsx("span",{className:$.icon,children:"🛠️"}),s.jsx("span",{className:"truncate",children:"Workbench"})]}),u0&&s.jsxs(s.Fragment,{children:[s.jsxs("button",{onClick:La,className:$.navItem,"data-tooltip-id":h,"data-tooltip-content":"User settings",children:[s.jsx("span",{className:$.icon,children:"🪪"}),s.jsx("span",{className:"truncate",children:n.username})]}),s.jsxs("button",{onClick:Pa,className:$.navItem,"data-tooltip-id":h,"data-tooltip-content":"Manage users",children:[s.jsx("span",{className:$.icon,children:"👥"}),s.jsx("span",{className:"truncate",children:"Manage users"})]})]})]}),s.jsx("div",{className:A($.projectWrapper,r?$.show:$.hide),children:s.jsx(a0,{})}),s.jsxs("button",{onClick:()=>a(!r),className:`${$.navItem} mx-2`,children:[s.jsx("span",{className:A($.icon,$.expand,r?$.show:$.hide),children:s.jsx(Ge,{className:"text-(--text-color-secondary)",width:20,height:20})}),s.jsx("span",{className:"truncate text-sm text-(--text-color-secondary)",children:"Collapse menu"})]}),s.jsxs("div",{className:`${$.navItem} mx-2 mb-2`,"data-tooltip-id":h,"data-tooltip-content":or,children:[s.jsx("span",{className:$.icon,children:s.jsx(d0,{})}),s.jsx("span",{className:"truncate text-sm text-(--text-color-secondary)",children:or})]})]})},m0="_root_r5ahz_2",f0={root:m0},Ia=!__CLIENT_CONFIG__.skipAuth,p0=`${f0.root} ${Ia?"grid-cols-4":"grid-cols-2"}`,x0=()=>{const{pathname:e}=le(),t=Y(),n=En("Mobile nav"),o=()=>{P.home.check(e)||t(P.home.build())};return s.jsxs("div",{className:p0,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"})]}),Ia&&s.jsxs(s.Fragment,{children:[s.jsxs("button",{onClick:La,children:[s.jsx("p",{children:"🪪"}),s.jsx("p",{className:"text-xs font-semibold text-gray-600",children:"Account"})]}),s.jsxs("button",{onClick:Pa,children:[s.jsx("p",{children:"👥"}),s.jsx("p",{className:"text-xs font-semibold text-gray-600",children:"Users"})]})]})]})},b0=({children:e,isLogin:t})=>s.jsxs("div",{className:$.desktopLayout,children:[s.jsx(os,{id:"default",className:"z-100"}),s.jsx(os,{id:"default-xs",className:"z-100 text-xs!"}),!t&&s.jsx(h0,{}),s.jsx("main",{className:$.main,children:e})]}),g0=({children:e,isLogin:t})=>s.jsxs("div",{className:$.mobileLayout,children:[s.jsx("main",{className:$.main,children:e}),!t&&s.jsx(x0,{})]}),v0=({children:e})=>{const t=Vr(no.laptop),{pathname:n}=le(),o=P.login.check(n);return t?s.jsx(b0,{isLogin:o,children:e}):s.jsx(g0,{isLogin:o,children:e})};Ga.createRoot(document.getElementById("root")).render(s.jsxs(Ze.StrictMode,{children:[s.jsx(Ya,{}),s.jsx(Il,{client:K,children:s.jsx(vl,{children:s.jsx(v0,{children:s.jsx(Wp,{})})})})]}));
|