@dataramen/cli 0.0.71-beta.4 → 0.0.71
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import{r as l,a as qr,S as ca,p as Co,b as ke,s as es,c as bn,n as ts,i as Ms,d as jo,t as Ur,e as Wn,f as Wr,g as Hr,h as No,j as is,k as _o,l as zr,m as Vr,o as So,q as Qr,u as s,v as Vs,w as K,x as O,A as Qs,y as Kr,z as Gr,B as A,C as jn,D as ne,E as Re,F as Yr,G as Jr,R as Ze,H as Xr,I as Zr}from"./index-VGcygI3P.js";var ko="popstate";function ei(e={}){function t(o,a){let{pathname:r,search:i,hash:c}=o.location;return Ds("",{pathname:r,search:i,hash:c},a.state&&a.state.usr||null,a.state&&a.state.key||"default")}function n(o,a){return typeof a=="string"?a:yn(a)}return ni(t,n,null,e)}function z(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 ti(){return Math.random().toString(36).substring(2,10)}function Eo(e,t){return{usr:e.state,key:e.key,idx:t}}function Ds(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||ti()}}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 ni(e,t,n,o={}){let{window:a=document.defaultView,v5Compat:r=!1}=o,i=a.history,c="POP",u=null,d=m();d==null&&(d=0,i.replaceState({...i.state,idx:d},""));function m(){return(i.state||{idx:null}).idx}function h(){c="POP";let v=m(),y=v==null?null:v-d;d=v,u&&u({action:c,location:x.location,delta:y})}function p(v,y){c="PUSH";let f=Ds(x.location,v,y);d=m()+1;let w=Eo(f,d),C=x.createHref(f);try{i.pushState(w,"",C)}catch(_){if(_ instanceof DOMException&&_.name==="DataCloneError")throw _;a.location.assign(C)}r&&u&&u({action:c,location:x.location,delta:1})}function g(v,y){c="REPLACE";let f=Ds(x.location,v,y);d=m();let w=Eo(f,d),C=x.createHref(f);i.replaceState(w,"",C),r&&u&&u({action:c,location:x.location,delta:0})}function b(v){return si(v)}let x={get action(){return c},get location(){return e(a,i)},listen(v){if(u)throw new Error("A history only accepts one active listener");return a.addEventListener(ko,h),u=v,()=>{a.removeEventListener(ko,h),u=null}},createHref(v){return t(a,v)},createURL:b,encodeLocation(v){let y=b(v);return{pathname:y.pathname,search:y.search,hash:y.hash}},push:p,replace:g,go(v){return i.go(v)}};return x}function si(e,t=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),z(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 ua(e,t,n="/"){return oi(e,t,n,!1)}function oi(e,t,n,o){let a=typeof t=="string"?Gt(t):t,r=Ye(a.pathname||"/",n);if(r==null)return null;let i=da(e);ai(i);let c=null;for(let u=0;c==null&&u<i.length;++u){let d=gi(r);c=fi(i[u],d,o)}return c}function da(e,t=[],n=[],o="",a=!1){let r=(i,c,u=a,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;z(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&&(z(i.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${h}".`),da(i.children,t,p,h,u)),!(i.path==null&&!i.index)&&t.push({path:h,score:hi(h,i.index),routesMeta:p})};return e.forEach((i,c)=>{if(i.path===""||!i.path?.includes("?"))r(i,c);else for(let u of ha(i.path))r(i,c,!0,u)}),t}function ha(e){let t=e.split("/");if(t.length===0)return[];let[n,...o]=t,a=n.endsWith("?"),r=n.replace(/\?$/,"");if(o.length===0)return a?[r,""]:[r];let i=ha(o.join("/")),c=[];return c.push(...i.map(u=>u===""?r:[r,u].join("/"))),a&&c.push(...i),c.map(u=>e.startsWith("/")&&u===""?"/":u)}function ai(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:mi(t.routesMeta.map(o=>o.childrenIndex),n.routesMeta.map(o=>o.childrenIndex)))}var ri=/^:[\w-]+$/,ii=3,li=2,ci=1,ui=10,di=-2,Ro=e=>e==="*";function hi(e,t){let n=e.split("/"),o=n.length;return n.some(Ro)&&(o+=di),t&&(o+=li),n.filter(a=>!Ro(a)).reduce((a,r)=>a+(ri.test(r)?ii:r===""?ci:ui),o)}function mi(e,t){return e.length===t.length&&e.slice(0,-1).every((o,a)=>o===t[a])?e[e.length-1]-t[t.length-1]:0}function fi(e,t,n=!1){let{routesMeta:o}=e,a={},r="/",i=[];for(let c=0;c<o.length;++c){let u=o[c],d=c===o.length-1,m=r==="/"?t:t.slice(r.length)||"/",h=zt({path:u.relativePath,caseSensitive:u.caseSensitive,end:d},m),p=u.route;if(!h&&d&&n&&!o[o.length-1].route.index&&(h=zt({path:u.relativePath,caseSensitive:u.caseSensitive,end:!1},m)),!h)return null;Object.assign(a,h.params),i.push({params:a,pathname:Qe([r,h.pathname]),pathnameBase:yi(Qe([r,h.pathnameBase])),route:p}),h.pathnameBase!=="/"&&(r=Qe([r,h.pathnameBase]))}return i}function zt(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[n,o]=pi(e.path,e.caseSensitive,e.end),a=t.match(n);if(!a)return null;let r=a[0],i=r.replace(/(.)\/+$/,"$1"),c=a.slice(1);return{params:o.reduce((d,{paramName:m,isOptional:h},p)=>{if(m==="*"){let b=c[p]||"";i=r.slice(0,r.length-b.length).replace(/(.)\/+$/,"$1")}const g=c[p];return h&&!g?d[m]=void 0:d[m]=(g||"").replace(/%2F/g,"/"),d},{}),pathname:r,pathnameBase:i,pattern:e}}function pi(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=[],a="^"+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:"*"}),a+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?a+="\\/*$":e!==""&&e!=="/"&&(a+="(?:(?=\\/|$))"),[new RegExp(a,t?void 0:"i"),o]}function gi(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 ma=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,xi=e=>ma.test(e);function bi(e,t="/"){let{pathname:n,search:o="",hash:a=""}=typeof e=="string"?Gt(e):e,r;if(n)if(xi(n))r=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("/")?r=To(n.substring(1),"/"):r=To(n,t)}else r=t;return{pathname:r,search:wi(o),hash:Ci(a)}}function To(e,t){let n=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(a=>{a===".."?n.length>1&&n.pop():a!=="."&&n.push(a)}),n.length>1?n.join("/"):"/"}function js(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 vi(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function fa(e){let t=vi(e);return t.map((n,o)=>o===t.length-1?n.pathname:n.pathnameBase)}function pa(e,t,n,o=!1){let a;typeof e=="string"?a=Gt(e):(a={...e},z(!a.pathname||!a.pathname.includes("?"),js("?","pathname","search",a)),z(!a.pathname||!a.pathname.includes("#"),js("#","pathname","hash",a)),z(!a.search||!a.search.includes("#"),js("#","search","hash",a)));let r=e===""||a.pathname==="",i=r?"/":a.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;a.pathname=p.join("/")}c=h>=0?t[h]:"/"}let u=bi(a,c),d=i&&i!=="/"&&i.endsWith("/"),m=(r||i===".")&&n.endsWith("/");return!u.pathname.endsWith("/")&&(d||m)&&(u.pathname+="/"),u}var Qe=e=>e.join("/").replace(/\/\/+/g,"/"),yi=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),wi=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,Ci=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,ji=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 Ni(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function _i(e){return e.map(t=>t.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var ga=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function xa(e,t){let n=e;if(typeof n!="string"||!ma.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let o=n,a=!1;if(ga)try{let r=new URL(window.location.href),i=n.startsWith("//")?new URL(r.protocol+n):new URL(n),c=Ye(i.pathname,t);i.origin===r.origin&&c!=null?n=c+i.search+i.hash:a=!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:a,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var ba=["POST","PUT","PATCH","DELETE"];new Set(ba);var Si=["GET",...ba];new Set(Si);var Yt=l.createContext(null);Yt.displayName="DataRouter";var ls=l.createContext(null);ls.displayName="DataRouterState";var ki=l.createContext(!1),va=l.createContext({isTransitioning:!1});va.displayName="ViewTransition";var Ei=l.createContext(new Map);Ei.displayName="Fetchers";var Ri=l.createContext(null);Ri.displayName="Await";var Ne=l.createContext(null);Ne.displayName="Navigation";var Nn=l.createContext(null);Nn.displayName="Location";var Be=l.createContext({outlet:null,matches:[],isDataRoute:!1});Be.displayName="Route";var Ks=l.createContext(null);Ks.displayName="RouteError";var ya="REACT_ROUTER_ERROR",Ti="REDIRECT",Li="ROUTE_ERROR_RESPONSE";function Ai(e){if(e.startsWith(`${ya}:${Ti}:{`))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 Pi(e){if(e.startsWith(`${ya}:${Li}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string")return new ji(t.status,t.statusText,t.data)}catch{}}function Ii(e,{relative:t}={}){z(_n(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:o}=l.useContext(Ne),{hash:a,pathname:r,search:i}=Sn(e,{relative:t}),c=r;return n!=="/"&&(c=r==="/"?n:Qe([n,r])),o.createHref({pathname:c,search:i,hash:a})}function _n(){return l.useContext(Nn)!=null}function le(){return z(_n(),"useLocation() may be used only in the context of a <Router> component."),l.useContext(Nn).location}var wa="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Ca(e){l.useContext(Ne).static||l.useLayoutEffect(e)}function Y(){let{isDataRoute:e}=l.useContext(Be);return e?Ki():Oi()}function Oi(){z(_n(),"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:a}=le(),r=JSON.stringify(fa(o)),i=l.useRef(!1);return Ca(()=>{i.current=!0}),l.useCallback((u,d={})=>{if(je(i.current,wa),!i.current)return;if(typeof u=="number"){n.go(u);return}let m=pa(u,JSON.parse(r),a,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,r,a,e])}l.createContext(null);function Mi(){let{matches:e}=l.useContext(Be),t=e[e.length-1];return t?t.params:{}}function Sn(e,{relative:t}={}){let{matches:n}=l.useContext(Be),{pathname:o}=le(),a=JSON.stringify(fa(n));return l.useMemo(()=>pa(e,JSON.parse(a),o,t==="path"),[e,a,o,t])}function Di(e,t){return ja(e,t)}function ja(e,t,n,o,a){z(_n(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:r}=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||"";_a(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
2
|
|
|
3
|
-
Please change the parent <Route path="${f}"> to <Route path="${f==="/"?"*":`${f}/*`}">.`)}let p=le(),g;if(t){let f=typeof t=="string"?Gt(t):t;z(m==="/"||f.pathname?.startsWith(m),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${m}" but pathname "${f.pathname}" was given in the \`location\` prop.`),g=f}else g=p;let b=g.pathname||"/",x=b;if(m!=="/"){let f=m.replace(/^\//,"").split("/");x="/"+b.replace(/^\//,"").split("/").slice(f.length).join("/")}let v=ua(e,{pathname:x});je(h||v!=null,`No routes matched location "${g.pathname}${g.search}${g.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 "${g.pathname}${g.search}${g.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let y=Ui(v&&v.map(f=>Object.assign({},f,{params:Object.assign({},u,f.params),pathname:Qe([m,r.encodeLocation?r.encodeLocation(f.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:f.pathname]),pathnameBase:f.pathnameBase==="/"?m:Qe([m,r.encodeLocation?r.encodeLocation(f.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:f.pathnameBase])})),i,n,o,a);return t&&y?l.createElement(Nn.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...g},navigationType:"POP"}},y):y}function $i(){let e=Qi(),t=Ni(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)",a={padding:"0.5rem",backgroundColor:o},r={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:r},"ErrorBoundary")," or"," ",l.createElement("code",{style:r},"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:a},n):null,i)}var Fi=l.createElement($i,null),Na=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=Pi(e.digest);n&&(e=n)}let t=e!==void 0?l.createElement(Be.Provider,{value:this.props.routeContext},l.createElement(Ks.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?l.createElement(Bi,{error:e},t):t}};Na.contextType=ki;var Ns=new WeakMap;function Bi({children:e,error:t}){let{basename:n}=l.useContext(Ne);if(typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){let o=Ai(t.digest);if(o){let a=Ns.get(t);if(a)throw a;let r=xa(o.location,n);if(ga&&!Ns.get(t))if(r.isExternal||o.reloadDocument)window.location.href=r.absoluteURL||r.to;else{const i=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(r.to,{replace:o.replace}));throw Ns.set(t,i),i}return l.createElement("meta",{httpEquiv:"refresh",content:`0;url=${r.absoluteURL||r.to}`})}}return e}function qi({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 Ui(e,t=[],n=null,o=null,a=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 r=e,i=n?.errors;if(i!=null){let m=r.findIndex(h=>h.route.id&&i?.[h.route.id]!==void 0);z(m>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(i).join(",")}`),r=r.slice(0,Math.min(r.length,m+1))}let c=!1,u=-1;if(n)for(let m=0;m<r.length;m++){let h=r[m];if((h.route.HydrateFallback||h.route.hydrateFallbackElement)&&(u=m),h.route.id){let{loaderData:p,errors:g}=n,b=h.route.loader&&!p.hasOwnProperty(h.route.id)&&(!g||g[h.route.id]===void 0);if(h.route.lazy||b){c=!0,u>=0?r=r.slice(0,u+1):r=[r[0]];break}}}let d=n&&o?(m,h)=>{o(m,{location:n.location,params:n.matches?.[0]?.params??{},unstable_pattern:_i(n.matches),errorInfo:h})}:void 0;return r.reduceRight((m,h,p)=>{let g,b=!1,x=null,v=null;n&&(g=i&&h.route.id?i[h.route.id]:void 0,x=h.route.errorElement||Fi,c&&(u<0&&p===0?(_a("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),b=!0,v=null):u===p&&(b=!0,v=h.route.hydrateFallbackElement||null)));let y=t.concat(r.slice(0,p+1)),f=()=>{let w;return g?w=x:b?w=v:h.route.Component?w=l.createElement(h.route.Component,null):h.route.element?w=h.route.element:w=m,l.createElement(qi,{match:h,routeContext:{outlet:m,matches:y,isDataRoute:n!=null},children:w})};return n&&(h.route.ErrorBoundary||h.route.errorElement||p===0)?l.createElement(Na,{location:n.location,revalidation:n.revalidation,component:x,error:g,children:f(),routeContext:{outlet:null,matches:y,isDataRoute:!0},onError:d}):f()},null)}function Gs(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Wi(e){let t=l.useContext(Yt);return z(t,Gs(e)),t}function Hi(e){let t=l.useContext(ls);return z(t,Gs(e)),t}function zi(e){let t=l.useContext(Be);return z(t,Gs(e)),t}function Ys(e){let t=zi(e),n=t.matches[t.matches.length-1];return z(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function Vi(){return Ys("useRouteId")}function Qi(){let e=l.useContext(Ks),t=Hi("useRouteError"),n=Ys("useRouteError");return e!==void 0?e:t.errors?.[n]}function Ki(){let{router:e}=Wi("useNavigate"),t=Ys("useNavigate"),n=l.useRef(!1);return Ca(()=>{n.current=!0}),l.useCallback(async(a,r={})=>{je(n.current,wa),n.current&&(typeof a=="number"?await e.navigate(a):await e.navigate(a,{fromRouteId:t,...r}))},[e,t])}var Lo={};function _a(e,t,n){!t&&!Lo[e]&&(Lo[e]=!0,je(!1,n))}l.memo(Gi);function Gi({routes:e,future:t,state:n,onError:o}){return ja(e,void 0,n,o,t)}function vt(e){z(!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 Yi({basename:e="/",children:t=null,location:n,navigationType:o="POP",navigator:a,static:r=!1,unstable_useTransitions:i}){z(!_n(),"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:a,static:r,unstable_useTransitions:i,future:{}}),[c,a,r,i]);typeof n=="string"&&(n=Gt(n));let{pathname:d="/",search:m="",hash:h="",state:p=null,key:g="default"}=n,b=l.useMemo(()=>{let x=Ye(d,c);return x==null?null:{location:{pathname:x,search:m,hash:h,state:p,key:g},navigationType:o}},[c,d,m,h,p,g,o]);return je(b!=null,`<Router basename="${c}"> is not able to match the URL "${d}${m}${h}" because it does not start with the basename, so the <Router> won't render anything.`),b==null?null:l.createElement(Ne.Provider,{value:u},l.createElement(Nn.Provider,{children:t,value:b}))}function Ji({children:e,location:t}){return Di($s(e),t)}function $s(e,t=[]){let n=[];return l.Children.forEach(e,(o,a)=>{if(!l.isValidElement(o))return;let r=[...t,a];if(o.type===l.Fragment){n.push.apply(n,$s(o.props.children,r));return}z(o.type===vt,`[${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>`),z(!o.props.index||!o.props.children,"An index route cannot have child routes.");let i={id:o.props.id||r.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=$s(o.props.children,r)),n.push(i)}),n}var Kn="get",Gn="application/x-www-form-urlencoded";function cs(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function Xi(e){return cs(e)&&e.tagName.toLowerCase()==="button"}function Zi(e){return cs(e)&&e.tagName.toLowerCase()==="form"}function el(e){return cs(e)&&e.tagName.toLowerCase()==="input"}function tl(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function nl(e,t){return e.button===0&&(!t||t==="_self")&&!tl(e)}function Fs(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(a=>[n,a]):[[n,o]])},[]))}function sl(e,t){let n=Fs(e);return t&&t.forEach((o,a)=>{n.has(a)||t.getAll(a).forEach(r=>{n.append(a,r)})}),n}var Hn=null;function ol(){if(Hn===null)try{new FormData(document.createElement("form"),0),Hn=!1}catch{Hn=!0}return Hn}var al=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function _s(e){return e!=null&&!al.has(e)?(je(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Gn}"`),null):e}function rl(e,t){let n,o,a,r,i;if(Zi(e)){let c=e.getAttribute("action");o=c?Ye(c,t):null,n=e.getAttribute("method")||Kn,a=_s(e.getAttribute("enctype"))||Gn,r=new FormData(e)}else if(Xi(e)||el(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")||Kn,a=_s(e.getAttribute("formenctype"))||_s(c.getAttribute("enctype"))||Gn,r=new FormData(c,e),!ol()){let{name:d,type:m,value:h}=e;if(m==="image"){let p=d?`${d}.`:"";r.append(`${p}x`,"0"),r.append(`${p}y`,"0")}else d&&r.append(d,h)}}else{if(cs(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=Kn,o=null,a=Gn,i=e}return r&&a==="text/plain"&&(i=r,r=void 0),{action:o,method:n.toLowerCase(),encType:a,formData:r,body:i}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function Js(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function il(e,t,n,o){let a=typeof e=="string"?new URL(e,typeof window>"u"?"server://singlefetch/":window.location.origin):e;return n?a.pathname.endsWith("/")?a.pathname=`${a.pathname}_.${o}`:a.pathname=`${a.pathname}.${o}`:a.pathname==="/"?a.pathname=`_root.${o}`:t&&Ye(a.pathname,t)==="/"?a.pathname=`${t.replace(/\/$/,"")}/_root.${o}`:a.pathname=`${a.pathname.replace(/\/$/,"")}.${o}`,a}async function ll(e,t){if(e.id in t)return t[e.id];try{let n=await import(e.module);return t[e.id]=n,n}catch(n){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(n),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function cl(e){return e==null?!1:e.href==null?e.rel==="preload"&&typeof e.imageSrcSet=="string"&&typeof e.imageSizes=="string":typeof e.rel=="string"&&typeof e.href=="string"}async function ul(e,t,n){let o=await Promise.all(e.map(async a=>{let r=t.routes[a.route.id];if(r){let i=await ll(r,n);return i.links?i.links():[]}return[]}));return fl(o.flat(1).filter(cl).filter(a=>a.rel==="stylesheet"||a.rel==="preload").map(a=>a.rel==="stylesheet"?{...a,rel:"prefetch",as:"style"}:{...a,rel:"prefetch"}))}function Ao(e,t,n,o,a,r){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 r==="assets"?t.filter((u,d)=>i(u,d)||c(u,d)):r==="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(a.pathname+a.search+a.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 dl(e,t,{includeHydrateFallback:n}={}){return hl(e.map(o=>{let a=t.routes[o.route.id];if(!a)return[];let r=[a.module];return a.clientActionModule&&(r=r.concat(a.clientActionModule)),a.clientLoaderModule&&(r=r.concat(a.clientLoaderModule)),n&&a.hydrateFallbackModule&&(r=r.concat(a.hydrateFallbackModule)),a.imports&&(r=r.concat(a.imports)),r}).flat(1))}function hl(e){return[...new Set(e)]}function ml(e){let t={},n=Object.keys(e).sort();for(let o of n)t[o]=e[o];return t}function fl(e,t){let n=new Set;return new Set(t),e.reduce((o,a)=>{let r=JSON.stringify(ml(a));return n.has(r)||(n.add(r),o.push({key:r,link:a})),o},[])}function Sa(){let e=l.useContext(Yt);return Js(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function pl(){let e=l.useContext(ls);return Js(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var Xs=l.createContext(void 0);Xs.displayName="FrameworkContext";function ka(){let e=l.useContext(Xs);return Js(e,"You must render this element inside a <HydratedRouter> element"),e}function gl(e,t){let n=l.useContext(Xs),[o,a]=l.useState(!1),[r,i]=l.useState(!1),{onFocus:c,onBlur:u,onMouseEnter:d,onMouseLeave:m,onTouchStart:h}=t,p=l.useRef(null);l.useEffect(()=>{if(e==="render"&&i(!0),e==="viewport"){let x=y=>{y.forEach(f=>{i(f.isIntersecting)})},v=new IntersectionObserver(x,{threshold:.5});return p.current&&v.observe(p.current),()=>{v.disconnect()}}},[e]),l.useEffect(()=>{if(o){let x=setTimeout(()=>{i(!0)},100);return()=>{clearTimeout(x)}}},[o]);let g=()=>{a(!0)},b=()=>{a(!1),i(!1)};return n?e!=="intent"?[r,p,{}]:[r,p,{onFocus:fn(c,g),onBlur:fn(u,b),onMouseEnter:fn(d,g),onMouseLeave:fn(m,b),onTouchStart:fn(h,g)}]:[!1,p,{}]}function fn(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function xl({page:e,...t}){let{router:n}=Sa(),o=l.useMemo(()=>ua(n.routes,e,n.basename),[n.routes,e,n.basename]);return o?l.createElement(vl,{page:e,matches:o,...t}):null}function bl(e){let{manifest:t,routeModules:n}=ka(),[o,a]=l.useState([]);return l.useEffect(()=>{let r=!1;return ul(e,t,n).then(i=>{r||a(i)}),()=>{r=!0}},[e,t,n]),o}function vl({page:e,matches:t,...n}){let o=le(),{future:a,manifest:r,routeModules:i}=ka(),{basename:c}=Sa(),{loaderData:u,matches:d}=pl(),m=l.useMemo(()=>Ao(e,t,d,r,o,"data"),[e,t,d,r,o]),h=l.useMemo(()=>Ao(e,t,d,r,o,"assets"),[e,t,d,r,o]),p=l.useMemo(()=>{if(e===o.pathname+o.search+o.hash)return[];let x=new Set,v=!1;if(t.forEach(f=>{let w=r.routes[f.route.id];!w||!w.hasLoader||(!m.some(C=>C.route.id===f.route.id)&&f.route.id in u&&i[f.route.id]?.shouldRevalidate||w.hasClientLoader?v=!0:x.add(f.route.id))}),x.size===0)return[];let y=il(e,c,a.unstable_trailingSlashAwareDataRequests,"data");return v&&x.size>0&&y.searchParams.set("_routes",t.filter(f=>x.has(f.route.id)).map(f=>f.route.id).join(",")),[y.pathname+y.search]},[c,a.unstable_trailingSlashAwareDataRequests,u,o,r,m,t,e,i]),g=l.useMemo(()=>dl(h,r),[h,r]),b=bl(h);return l.createElement(l.Fragment,null,p.map(x=>l.createElement("link",{key:x,rel:"prefetch",as:"fetch",href:x,...n})),g.map(x=>l.createElement("link",{key:x,rel:"modulepreload",href:x,...n})),b.map(({key:x,link:v})=>l.createElement("link",{key:x,nonce:n.nonce,...v})))}function yl(...e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}var wl=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{wl&&(window.__reactRouterVersion="7.12.0")}catch{}function Cl({basename:e,children:t,unstable_useTransitions:n,window:o}){let a=l.useRef();a.current==null&&(a.current=ei({window:o,v5Compat:!0}));let r=a.current,[i,c]=l.useState({action:r.action,location:r.location}),u=l.useCallback(d=>{n===!1?c(d):l.startTransition(()=>c(d))},[n]);return l.useLayoutEffect(()=>r.listen(u),[r,u]),l.createElement(Yi,{basename:e,children:t,location:i.location,navigationType:i.action,navigator:r,unstable_useTransitions:n})}var Ea=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Ra=l.forwardRef(function({onClick:t,discover:n="render",prefetch:o="none",relative:a,reloadDocument:r,replace:i,state:c,target:u,to:d,preventScrollReset:m,viewTransition:h,unstable_defaultShouldRevalidate:p,...g},b){let{basename:x,unstable_useTransitions:v}=l.useContext(Ne),y=typeof d=="string"&&Ea.test(d),f=xa(d,x);d=f.to;let w=Ii(d,{relative:a}),[C,_,k]=gl(o,g),j=Sl(d,{replace:i,state:c,target:u,preventScrollReset:m,relative:a,viewTransition:h,unstable_defaultShouldRevalidate:p,unstable_useTransitions:v});function S(F){t&&t(F),F.defaultPrevented||j(F)}let I=l.createElement("a",{...g,...k,href:f.absoluteURL||w,onClick:f.isExternal||r?t:S,ref:yl(b,_),target:u,"data-discover":!y&&n==="render"?"true":void 0});return C&&!y?l.createElement(l.Fragment,null,I,l.createElement(xl,{page:w})):I});Ra.displayName="Link";var jl=l.forwardRef(function({"aria-current":t="page",caseSensitive:n=!1,className:o="",end:a=!1,style:r,to:i,viewTransition:c,children:u,...d},m){let h=Sn(i,{relative:d.relative}),p=le(),g=l.useContext(ls),{navigator:b,basename:x}=l.useContext(Ne),v=g!=null&&Al(h)&&c===!0,y=b.encodeLocation?b.encodeLocation(h).pathname:h.pathname,f=p.pathname,w=g&&g.navigation&&g.navigation.location?g.navigation.location.pathname:null;n||(f=f.toLowerCase(),w=w?w.toLowerCase():null,y=y.toLowerCase()),w&&x&&(w=Ye(w,x)||w);const C=y!=="/"&&y.endsWith("/")?y.length-1:y.length;let _=f===y||!a&&f.startsWith(y)&&f.charAt(C)==="/",k=w!=null&&(w===y||!a&&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 F=typeof r=="function"?r(j):r;return l.createElement(Ra,{...d,"aria-current":S,className:I,ref:m,style:F,to:i,viewTransition:c},typeof u=="function"?u(j):u)});jl.displayName="NavLink";var Nl=l.forwardRef(({discover:e="render",fetcherKey:t,navigate:n,reloadDocument:o,replace:a,state:r,method:i=Kn,action:c,onSubmit:u,relative:d,preventScrollReset:m,viewTransition:h,unstable_defaultShouldRevalidate:p,...g},b)=>{let{unstable_useTransitions:x}=l.useContext(Ne),v=Tl(),y=Ll(c,{relative:d}),f=i.toLowerCase()==="get"?"get":"post",w=typeof c=="string"&&Ea.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:a,state:r,relative:d,preventScrollReset:m,viewTransition:h,unstable_defaultShouldRevalidate:p});x&&n!==!1?l.startTransition(()=>S()):S()};return l.createElement("form",{ref:b,method:f,action:y,onSubmit:o?u:C,...g,"data-discover":!w&&e==="render"?"true":void 0})});Nl.displayName="Form";function _l(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Ta(e){let t=l.useContext(Yt);return z(t,_l(e)),t}function Sl(e,{target:t,replace:n,state:o,preventScrollReset:a,relative:r,viewTransition:i,unstable_defaultShouldRevalidate:c,unstable_useTransitions:u}={}){let d=Y(),m=le(),h=Sn(e,{relative:r});return l.useCallback(p=>{if(nl(p,t)){p.preventDefault();let g=n!==void 0?n:yn(m)===yn(h),b=()=>d(e,{replace:g,state:o,preventScrollReset:a,relative:r,viewTransition:i,unstable_defaultShouldRevalidate:c});u?l.startTransition(()=>b()):b()}},[m,d,h,n,o,t,e,a,r,i,c,u])}function kl(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(Fs(e)),n=l.useRef(!1),o=le(),a=l.useMemo(()=>sl(o.search,n.current?null:t.current),[o.search]),r=Y(),i=l.useCallback((c,u)=>{const d=Fs(typeof c=="function"?c(new URLSearchParams(a)):c);n.current=!0,r("?"+d,u)},[r,a]);return[a,i]}var El=0,Rl=()=>`__${String(++El)}__`;function Tl(){let{router:e}=Ta("useSubmit"),{basename:t}=l.useContext(Ne),n=Vi(),o=e.fetch,a=e.navigate;return l.useCallback(async(r,i={})=>{let{action:c,method:u,encType:d,formData:m,body:h}=rl(r,t);if(i.navigate===!1){let p=i.fetcherKey||Rl();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 a(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,a,t,n])}function Ll(e,{relative:t}={}){let{basename:n}=l.useContext(Ne),o=l.useContext(Be);z(o,"useFormAction must be used inside a RouteContext");let[a]=o.matches.slice(-1),r={...Sn(e||".",{relative:t})},i=le();if(e==null){r.search=i.search;let c=new URLSearchParams(r.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();r.search=m?`?${m}`:""}}return(!e||e===".")&&a.route.index&&(r.search=r.search?r.search.replace(/^\?/,"?index&"):"?index"),n!=="/"&&(r.pathname=r.pathname==="/"?n:Qe([n,r.pathname])),yn(r)}function Al(e,{relative:t}={}){let n=l.useContext(va);z(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:o}=Ta("useViewTransitionState"),a=Sn(e,{relative:t});if(!n.isTransitioning)return!1;let r=Ye(n.currentLocation.pathname,o)||n.currentLocation.pathname,i=Ye(n.nextLocation.pathname,o)||n.nextLocation.pathname;return zt(a.pathname,i)!=null||zt(a.pathname,r)!=null}var La=qr(),Aa=class extends ca{constructor(e,t){super(),this.options=t,this.#n=e,this.#i=null,this.#r=Co(),this.bindMethods(),this.setOptions(t)}#n;#e=void 0;#s=void 0;#t=void 0;#o;#a;#r;#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),Po(this.#e,this.options)?this.#d():this.updateResult(),this.#v())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Bs(this.#e,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Bs(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&&!es(this.options,t)&&this.#n.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#e,observer:this});const o=this.hasListeners();o&&Io(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)||bn(this.options.staleTime,this.#e)!==bn(t.staleTime,this.#e))&&this.#g();const a=this.#x();o&&(this.#e!==n||ke(this.options.enabled,this.#e)!==ke(t.enabled,this.#e)||a!==this.#l)&&this.#b(a)}getOptimisticResult(e){const t=this.#n.getQueryCache().build(this.#n,e),n=this.createResult(t,e);return Il(this,n)&&(this.#t=n,this.#a=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.#r.status==="pending"&&this.#r.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(ts)),t}#g(){this.#y();const e=bn(this.options.staleTime,this.#e);if(Ms||this.#t.isStale||!jo(e))return;const n=Ur(this.#t.dataUpdatedAt,e)+1;this.#c=Wn.setTimeout(()=>{this.#t.isStale||this.updateResult()},n)}#x(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#e):this.options.refetchInterval)??!1}#b(e){this.#w(),this.#l=e,!(Ms||ke(this.options.enabled,this.#e)===!1||!jo(this.#l)||this.#l===0)&&(this.#u=Wn.setInterval(()=>{(this.options.refetchIntervalInBackground||Wr.isFocused())&&this.#d()},this.#l))}#v(){this.#g(),this.#b(this.#x())}#y(){this.#c&&(Wn.clearTimeout(this.#c),this.#c=void 0)}#w(){this.#u&&(Wn.clearInterval(this.#u),this.#u=void 0)}createResult(e,t){const n=this.#e,o=this.options,a=this.#t,r=this.#o,i=this.#a,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&&Po(e,t),F=S&&Io(e,n,t,o);(I||F)&&(m={...m,...Hr(d.data,e.options)}),t._optimisticResults==="isRestoring"&&(m.fetchStatus="idle")}let{error:g,errorUpdatedAt:b,status:x}=m;p=m.data;let v=!1;if(t.placeholderData!==void 0&&p===void 0&&x==="pending"){let S;a?.isPlaceholderData&&t.placeholderData===i?.placeholderData?(S=a.data,v=!0):S=typeof t.placeholderData=="function"?t.placeholderData(this.#m?.state.data,this.#m):t.placeholderData,S!==void 0&&(x="success",p=No(a?.data,S,t),h=!0)}if(t.select&&p!==void 0&&!v)if(a&&p===r?.data&&t.select===this.#p)p=this.#h;else try{this.#p=t.select,p=t.select(p),p=No(a?.data,p,t),this.#h=p,this.#i=null}catch(S){this.#i=S}this.#i&&(g=this.#i,p=this.#h,b=Date.now(),x="error");const y=m.fetchStatus==="fetching",f=x==="pending",w=x==="error",C=f&&y,_=p!==void 0,j={status:x,fetchStatus:m.fetchStatus,isPending:f,isSuccess:x==="success",isError:w,isInitialLoading:C,isLoading:C,data:p,dataUpdatedAt:m.dataUpdatedAt,error:g,errorUpdatedAt:b,failureCount:m.fetchFailureCount,failureReason:m.fetchFailureReason,errorUpdateCount:m.errorUpdateCount,isFetched:m.dataUpdateCount>0||m.errorUpdateCount>0,isFetchedAfterMount:m.dataUpdateCount>u.dataUpdateCount||m.errorUpdateCount>u.errorUpdateCount,isFetching:y,isRefetching:y&&!f,isLoadingError:w&&!_,isPaused:m.fetchStatus==="paused",isPlaceholderData:h,isRefetchError:w&&_,isStale:Zs(e,t),refetch:this.refetch,promise:this.#r,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.#r=j.promise=Co();S(se)},F=this.#r;switch(F.status){case"pending":e.queryHash===n.queryHash&&S(F);break;case"fulfilled":(j.status==="error"||j.data!==F.value)&&I();break;case"rejected":(j.status!=="error"||j.error!==F.reason)&&I();break}}return j}updateResult(){const e=this.#t,t=this.createResult(this.#e,this.options);if(this.#o=this.#e.state,this.#a=this.options,this.#o.data!==void 0&&(this.#m=this.#e),es(t,e))return;this.#t=t;const n=()=>{if(!e)return!0;const{notifyOnChangeProps:o}=this.options,a=typeof o=="function"?o():o;if(a==="all"||!a&&!this.#f.size)return!0;const r=new Set(a??this.#f);return this.options.throwOnError&&r.add("error"),Object.keys(this.#t).some(i=>{const c=i;return this.#t[c]!==e[c]&&r.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){is.batch(()=>{e.listeners&&this.listeners.forEach(t=>{t(this.#t)}),this.#n.getQueryCache().notify({query:this.#e,type:"observerResultsUpdated"})})}};function Pl(e,t){return ke(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function Po(e,t){return Pl(e,t)||e.state.data!==void 0&&Bs(e,t,t.refetchOnMount)}function Bs(e,t,n){if(ke(t.enabled,e)!==!1&&bn(t.staleTime,e)!=="static"){const o=typeof n=="function"?n(e):n;return o==="always"||o!==!1&&Zs(e,t)}return!1}function Io(e,t,n,o){return(e!==t||ke(o.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&Zs(e,n)}function Zs(e,t){return ke(t.enabled,e)!==!1&&e.isStaleByTime(bn(t.staleTime,e))}function Il(e,t){return!es(e.getCurrentResult(),t)}var Ol=class extends Aa{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:_o()})}getOptimisticResult(e){return e.behavior=_o(),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:a,isRefetching:r,isError:i,isRefetchError:c}=o,u=n.fetchMeta?.fetchMore?.direction,d=i&&u==="forward",m=a&&u==="forward",h=i&&u==="backward",p=a&&u==="backward";return{...o,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:Vr(t,n.data),hasPreviousPage:zr(t,n.data),isFetchNextPageError:d,isFetchingNextPage:m,isFetchPreviousPageError:h,isFetchingPreviousPage:p,isRefetchError:c&&!d&&!h,isRefetching:r&&!m&&!p}}},Ml=class extends ca{#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),es(this.options,n)||this.#n.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#s,observer:this}),n?.mutationKey&&this.options.mutationKey&&So(n.mutationKey)!==So(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.#a(t)}getCurrentResult(){return this.#e}reset(){this.#s?.removeObserver(this),this.#s=void 0,this.#o(),this.#a()}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??Qr();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}}#a(t){is.batch(()=>{if(this.#t&&this.hasListeners()){const n=this.#e.variables,o=this.#e.context,a={client:this.#n,meta:this.options.meta,mutationKey:this.options.mutationKey};if(t?.type==="success"){try{this.#t.onSuccess?.(t.data,n,o,a)}catch(r){Promise.reject(r)}try{this.#t.onSettled?.(t.data,null,n,o,a)}catch(r){Promise.reject(r)}}else if(t?.type==="error"){try{this.#t.onError?.(t.error,n,o,a)}catch(r){Promise.reject(r)}try{this.#t.onSettled?.(void 0,t.error,n,o,a)}catch(r){Promise.reject(r)}}}this.listeners.forEach(n=>{n(this.#e)})})}},Pa=l.createContext(void 0),Ia=e=>{const t=l.useContext(Pa);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},Dl=({client:e,children:t})=>(l.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),s.jsx(Pa.Provider,{value:e,children:t})),Oa=l.createContext(!1),$l=()=>l.useContext(Oa);Oa.Provider;function Fl(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var Bl=l.createContext(Fl()),ql=()=>l.useContext(Bl),Ul=(e,t,n)=>{const o=n?.state.error&&typeof e.throwOnError=="function"?Vs(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||o)&&(t.isReset()||(e.retryOnMount=!1))},Wl=e=>{l.useEffect(()=>{e.clearReset()},[e])},Hl=({result:e,errorResetBoundary:t,throwOnError:n,query:o,suspense:a})=>e.isError&&!t.isReset()&&!e.isFetching&&o&&(a&&e.data===void 0||Vs(n,[e.error,o])),zl=e=>{if(e.suspense){const n=a=>a==="static"?a:Math.max(a??1e3,1e3),o=e.staleTime;e.staleTime=typeof o=="function"?(...a)=>n(o(...a)):n(o),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},Vl=(e,t)=>e.isLoading&&e.isFetching&&!t,Ql=(e,t)=>e?.suspense&&t.isPending,Oo=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function Ma(e,t,n){const o=$l(),a=ql(),r=Ia(),i=r.defaultQueryOptions(e);r.getDefaultOptions().queries?._experimental_beforeQuery?.(i);const c=r.getQueryCache().get(i.queryHash);i._optimisticResults=o?"isRestoring":"optimistic",zl(i),Ul(i,a,c),Wl(a);const u=!r.getQueryCache().get(i.queryHash),[d]=l.useState(()=>new t(r,i)),m=d.getOptimisticResult(i),h=!o&&e.subscribed!==!1;if(l.useSyncExternalStore(l.useCallback(p=>{const g=h?d.subscribe(is.batchCalls(p)):ts;return d.updateResult(),g},[d,h]),()=>d.getCurrentResult(),()=>d.getCurrentResult()),l.useEffect(()=>{d.setOptions(i)},[i,d]),Ql(i,m))throw Oo(i,d,a);if(Hl({result:m,errorResetBoundary:a,throwOnError:i.throwOnError,query:c,suspense:i.suspense}))throw m.error;return r.getDefaultOptions().queries?._experimental_afterQuery?.(i,m),i.experimental_prefetchInRender&&!Ms&&Vl(m,o)&&(u?Oo(i,d,a):c?.promise)?.catch(ts).finally(()=>{d.updateResult()}),i.notifyOnChangeProps?m:d.trackResult(m)}function ce(e,t){return Ma(e,Aa)}function X(e,t){const n=Ia(),[o]=l.useState(()=>new Ml(n,e));l.useEffect(()=>{o.setOptions(e)},[o,e]);const a=l.useSyncExternalStore(l.useCallback(i=>o.subscribe(is.batchCalls(i)),[o]),()=>o.getCurrentResult(),()=>o.getCurrentResult()),r=l.useCallback((i,c)=>{o.mutate(i,c).catch(ts)},[o]);if(a.error&&Vs(o.options.throwOnError,[a.error]))throw a.error;return{...a,mutate:r,mutateAsync:a.mutate}}function Da(e,t){return Ma(e,Ol)}const at="data-sources",$a="auth-user",Kl=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})])},Gl=e=>{const t=["trash","team"];return K.invalidateQueries({queryKey:t})},Yl=(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}),Jl=(e,t=30,n)=>Da({queryKey:["project","tabs-history",e,t,n],queryFn:async({pageParam:o})=>{const{data:r}=await O.get(`/project/team/${e}/tabs-history?page=${o}&size=${t}`);return r},select:({pages:o})=>o.flatMap(a=>a.data),enabled:!!e,initialPageParam:0,getNextPageParam:(o,a)=>{if(o.hasMore)return a.length},staleTime:0}),Xl=(e,t="",n=20)=>Da({queryKey:["project","saved-queries",e,t,n],queryFn:async({pageParam:o})=>{const a=new URLSearchParams;a.set("nameFilter",t),a.set("size",n.toString()),a.set("page",o.toString());const{data:r}=await O.get(`/project/team/${e}/queries?${a.toString()}`);return r},enabled:!!e,initialPageParam:0,select:({pages:o})=>o.flatMap(a=>a.data),getNextPageParam:(o,a)=>{if(o.hasMore)return a.length}}),Zl=(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}),ec=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}}),tc=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}}),nc=()=>Promise.all([K.invalidateQueries({queryKey:["project","tabs-history"]}),K.invalidateQueries({queryKey:["project","recent-tabs"]})]),Fa=()=>K.invalidateQueries({queryKey:["project","count-saved-queries"]}),sc=(e,t)=>{},oc=()=>{},ac={event:sc,pageView:oc},us=e=>ce({queryKey:[at,e],queryFn:async()=>{const{data:t}=await O.get("/data-sources/"+e);return t.data},enabled:!!e}),eo=e=>ce({queryKey:[at,e.teamId],queryFn:async()=>{const{data:t}=await O.get("/data-sources",{params:e});return t.data},enabled:e.teamId!==void 0}),kn=e=>ce({queryKey:[at,e,"inspections"],queryFn:async()=>{const{data:t}=await O.get(`/data-sources/${e}/inspections`);return t.data},enabled:!!e}),rc=()=>X({mutationFn:async e=>{const{data:t}=await O.post("/data-sources",e);return t.data},onSuccess:()=>{K.invalidateQueries({queryKey:[at]}),Jt()},onError:()=>{}}),ic=()=>X({mutationFn:async({dataSource:e,id:t})=>{const{data:n}=await O.put(`/data-sources/${t}`,e);return n.data},onSuccess:()=>{K.invalidateQueries({queryKey:[at]}),Jt()}}),Ba=()=>X({mutationFn:async e=>{await O.post(`/data-sources/${e}/inspect`)},onSuccess:()=>{K.invalidateQueries({queryKey:[at]})}}),lc=()=>X({mutationFn:async e=>{await O.delete(`/data-sources/${e}`)},onSuccess:()=>{K.invalidateQueries({queryKey:[at]}),Jt()}}),qa=()=>ce({queryKey:["accessToken"],queryFn:Qs.get}),ue=()=>{const{data:e}=qa();return ce({queryKey:[$a],queryFn:async()=>{const{data:t}=await O.get("/users");return t.data},enabled:!!e,retry:(t,n)=>Kr(n)&&n.code==="ERR_NETWORK"?!1:t<3})},cc=()=>X({mutationFn:async e=>{const{data:t}=await O.patch("/users",e);return t.data},onSuccess:async e=>{K.setQueryData([$a],e)}}),uc=()=>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)),a=c=>(t.forEach(u=>u(c)),!0),r=c=>{n=typeof c=="function"?c(n):c,a(n)},i=c=>()=>c?c(n):n;return[c=>l.useSyncExternalStore(o,i(c),i(c)),r,{get:()=>n,subscribe:c=>(c(n),o(c))}]};function dc(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 hc=e=>ce({queryKey:["hooks",e],queryFn:async()=>{const t=await K.fetchQuery({queryKey:[at,e,"inspections"],queryFn:async()=>{const{data:n}=await O.get(`/data-sources/${e}/inspections`);return n.data}});return dc(t)},enabled:!!e}),Ua=[{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"}],mc=Ua.reduce((e,t)=>(e[t.value]=t.label,e),{});Ua.reduce((e,t)=>(e[t.label]=t.value,e),{});const Xt=e=>e.map(t=>({label:mc[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 fc=["char","varchar","binary","varbinary","blob","text","enum","set","character","character varying","text","citext","uuid","xml","json","jsonb"];new Set(fc);const pc=["integer","smallint","decimal","numeric","float","real","double precision","int","smallint","integer","bigint","decimal","numeric","real","double precision","serial","bigserial","money"];new Set(pc);const gc=["date","datetime","timestamp","timestamptz"].reduce((e,t)=>(e[t]=!0,e),{}),Wa=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 Mo={[pe.READ_ONLY]:10,[pe.EDITOR]:20,[pe.ADMIN]:30,[pe.OWNER]:40};function xc(e,t){if(!e||!t)return{};const n=new Set;for(const a of t)a.table&&n.add(a.table);const o={};for(const a of n){const r=e.find(i=>i.tableName===a);if(r){o[a]=[];const i=r.columns.filter(c=>c.isPrimary);for(const c of i)if(t.find(d=>d.table===a&&d.column===c.name))o[a].push(c.name);else{delete o[a];break}}}return o}function bc(e,t,n,o){const{data:a}=hc(t),{data:r}=kn(t);return l.useMemo(()=>{const i=xc(r,e?.result.columns);return{name:n,tabId:o,hooks:(()=>{const c=[];if(!a||!e||!e.result.columns)return c;for(const u of a)(e.result.tables.includes(u.on.toTable)||e.result.tables.includes(u.on.fromTable))&&c.push(u);return c})(),availableJoins:(()=>{const c=[];if(!a||!e||!e.result.columns)return c;for(const u of a)!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=Wa(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,a,r,n])}function vc(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 yc(e,t){return{name:e,path:t,build:a=>{if(typeof a=="object"){let r=t;for(const[i,c]of Object.entries(a))r=r.replace(":"+i,c);return r}return t},check:a=>!!zt({path:t,end:!0},a)}}function En(e,t){return{name:e,path:t,build:()=>t,check:n=>n===t}}const wc=En("Home","/"),Cc=En("Workbench","/workbench"),jc=En("Share query","/share"),Nc=En("Login","/login"),_c=En("Saved queries","/saved-queries"),Sc=yc("Workbench tab","/workbench/tab/:id"),P={home:wc,workbench:Cc,share:jc,login:Nc,savedQueries:_c,workbenchTab:Sc},to=e=>{K.setQueryData(["workbench-tabs"],t=>e(t||[]))},kc=(e,t)=>{K.setQueryData(["workbench-tabs",e],n=>n&&t(n))},ds=()=>ce({queryKey:["workbench-tabs"],queryFn:async()=>{const{data:e}=await O.get("/workbench-tabs");return e.data}}),Ec=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=>{to(t=>[...t,e])}}),Rc=()=>X({mutationFn:async e=>(await O.patch(`/workbench-tabs/${e}`,{archived:!0}),e),onMutate:e=>{to(t=>t.filter(n=>n.id!==e))}}),Ha=()=>X({mutationFn:async e=>(await O.patch(`/workbench-tabs/${e}`,{archived:!1}),e),onSuccess:()=>Va()}),Tc=()=>X({mutationFn:async({id:e,payload:t})=>(await O.patch(`/workbench-tabs/${e}`,t),!0),onMutate:({id:e,payload:t})=>{kc(e,n=>({...n,...t})),to(n=>n.map(o=>o.id!==e?o:{...o,name:t.name||o.name}))}}),Lc=(e,t)=>{const{dataSourceId:n,searchAll:o,table:a,filters:r,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,a,h,p,r,m,i,c,u,d,o],queryFn:async()=>{const{data:g}=await O.post(`/workbench-tabs/${e}/run`,t);return g.data},retry:1,enabled:!!a&&!!n,placeholderData:Gr})},Ac=()=>X({mutationFn:async e=>{await O.delete(`/workbench-tabs/${e}`)},onSuccess:()=>{Va(),nc()}}),za=e=>K.invalidateQueries({queryKey:["workbench-tab-runner",e]}),Va=()=>K.invalidateQueries({queryKey:["workbench-tabs"]}),[Pc,Ss,Ic]=_e(void 0),Oc=async()=>new Promise(e=>{Ss({onCancel:()=>{Ss(void 0),e(void 0)},onConfirm:(t,n,o)=>{Ss(void 0),e({dsId:o,id:n,type:t})}})}),Rn=e=>{const t=Y(),n=en(),o=Ha();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(()=>{Ic.get()||Oc().then(r=>{r?.type==="table"?n.mutate({name:r.id,opts:Zt({table:r.id,dataSourceId:r.dsId})}):r?.type==="query"?n.mutate({queryId:r.id}):r?.type==="tab"&&o.mutate(r.id)})},[t,e])},Tn=e=>{const{data:t}=ue();return l.useMemo(()=>t?Mo[t.teamRole]>=Mo[e]:!1,[t,e])},Mc="_input_1hufc_2",Dc="_label_1hufc_2",$c="_content_1hufc_2",Fc="_form_1hufc_2",Bc="_mode-select_1hufc_2",yt={input:Mc,label:Dc,content:$c,form:Fc,switch:"_switch_1hufc_2",modeSelect:Bc},qc="_modal_1t5ps_2",Uc="_modal-visible_1t5ps_2",Wc="_modal-invisible_1t5ps_2",Hc="_backdrop_1t5ps_2",zc="_modal-container_1t5ps_2",Vc="_close-button_1t5ps_2",Wt={modal:qc,modalVisible:Uc,modalInvisible:Wc,backdrop:Hc,modalContainer:zc,closeButton:Vc},jt=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32,d:"M368 368L144 144M368 144L144 368"}));let Yn=[];const Qc=e=>{const t=Symbol();return Yn.push({id:t,listener:e}),()=>{Yn=Yn.filter(n=>n.id!==t)}};window.addEventListener("keydown",e=>{if(e.key!=="Escape")return;const t=Yn.pop();t&&(e.preventDefault(),e.stopPropagation(),t.listener())});const hs=e=>{const t=l.useRef(e.onClose);t.current=e.onClose,l.useEffect(()=>{if(e.enabled)return Qc(()=>{t.current()})},[e.enabled])},ve=({children:e,backdropClose:t,isVisible:n,onClose:o,onClosed:a,noPadding:r=!1,portal:i=!1})=>{const[c,u]=l.useState(!1),d=()=>{t&&o()},m=p=>{n||getComputedStyle(p.currentTarget).opacity==="0"&&(u(!1),a&&a())};l.useEffect(()=>{n&&u(!0)},[n]),hs({onClose:d,enabled:n&&t===!0});const h=s.jsxs("div",{onTransitionEnd:m,className:A(Wt.modal,n?Wt.modalVisible:Wt.modalInvisible),children:[s.jsx("div",{onClick:d,className:Wt.backdrop}),s.jsx("div",{className:A(Wt.modalContainer,r!==!0&&"p-4"),children:c&&e})]});return i?La.createPortal(h,document.body):h},rt=({onClick:e})=>{const t=l.useRef(e);return t.current=e,s.jsx("button",{className:Wt.closeButton,onClick:e,children:s.jsx(jt,{width:20,height:20})})},Qa=({children:e})=>s.jsx("h2",{className:"text-xl font-semibold",children:e}),Kc=({form:e,change:t,shape:n})=>s.jsx("div",{className:yt.form,children:n.fields.map(o=>s.jsxs("label",{className:yt.input,children:[s.jsx("p",{className:yt.label,children:o.label}),s.jsx("input",{value:e[o.name],onChange:t(o.name),type:o.type})]},o.name))}),Ft=[{label:"PostgreSQL",tag:"postgres"},{label:"MySQL",tag:"mysql"}],Gc={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"}]},Yc={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"}]},Jc=({show:e,onClose:t,dbType:n="postgres"})=>{const o=rc(),a=Ba(),{data:r}=ue(),[i,{change:c,set:u}]=jn({name:"",dbType:n,dbUrl:"",dbUser:"",dbPassword:"",dbDatabase:"",dbSchema:"",dbPort:5432,teamId:"",ownerId:"",description:"",allowInsert:!1,allowUpdate:!1}),d=async()=>{const b=await o.mutateAsync({...i,dbPort:Number(i.dbPort),teamId:r.teamId,ownerId:r.id});await a.mutateAsync(b.id),t(),ac.event("Create Datasource",{dbType:i.dbType})},m=b=>{u("allowInsert",!b),u("allowUpdate",!b)},h=()=>{t()},p=o.isPending||a.isPending,g=!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"}),a.isPending&&s.jsx(ne,{className:"mb-2",variant:"info",children:"Inspecting connection"}),s.jsxs("div",{className:yt.switch,children:[s.jsxs("label",{className:"button tertiary",children:[s.jsx("input",{type:"radio",name:"bdType",className:"mr-2",checked:i.dbType===Ft[0].tag,onChange:()=>u("dbType",Ft[0].tag)}),s.jsx("span",{children:Ft[0].label})]}),s.jsxs("label",{className:"button tertiary",children:[s.jsx("input",{type:"radio",name:"bdType",className:"mr-2",checked:i.dbType===Ft[1].tag,onChange:()=>u("dbType",Ft[1].tag)}),s.jsx("span",{children:Ft[1].label})]})]}),s.jsxs("div",{className:"mt-2",children:[s.jsxs("div",{className:yt.content,children:[s.jsx(Kc,{form:i,change:c,shape:i.dbType==="mysql"?Gc:Yc}),s.jsxs("div",{className:"flex flex-col",children:[s.jsx("label",{className:"text-sm font-semibold",children:"Name"}),s.jsx("input",{value:i.name,onChange:c("name"),className:"input"})]})]}),s.jsxs("div",{className:"mt-4",children:[s.jsxs("label",{className:yt.modeSelect,children:[s.jsxs("div",{children:[s.jsx("input",{type:"radio",name:"production-mode",className:"mr-2",checked:g,onChange:()=>m(!0)}),s.jsx("span",{className:"text-sm font-semibold",children:"Production mode"})]}),s.jsxs("p",{className:"text-xs mt-1 text-gray-600",children:["Mutation operations (such as INSERT or UPDATE) are ",s.jsx("strong",{children:"forbidden"}),". You won't be able to insert new rows or edit existing data. Tables in this data source are read-only."]})]}),s.jsxs("label",{className:yt.modeSelect,children:[s.jsxs("div",{children:[s.jsx("input",{type:"radio",name:"production-mode",className:"mr-2",checked:!g,onChange:()=>m(!1)}),s.jsx("span",{className:"text-sm font-semibold",children:"Dev mode"})]}),s.jsxs("p",{className:"text-xs mt-1 text-gray-600",children:["Mutation operations (such as INSERT or UPDATE) are ",s.jsx("strong",{children:"allowed"}),". You will be able to insert new rows and edit existing data."]})]})]})]})]}),s.jsxs("div",{className:"flex justify-end gap-1 mt-2",children:[s.jsx("button",{onClick:h,className:"button tertiary",disabled:p,children:"Cancel"}),s.jsx("button",{onClick:d,className:"button primary",disabled:p,children:"Create"})]})]})},Xc="_data-source-entry_1f8pw_2",Zc="_action-title_1f8pw_2",eu="_dev-tag_1f8pw_2",tu="_prod-tag_1f8pw_2",nu="_recent-tabs-container_1f8pw_2",su="_recent-tabs-entry_1f8pw_2",ou="_home-action-button_1f8pw_2",au="_home-gray-card_1f8pw_2",ru="_home-card-title_1f8pw_2",iu="_home-card-grid-content_1f8pw_2",lu="_useful-links_1f8pw_2",Q={dataSourceEntry:Xc,actionTitle:Zc,devTag:eu,prodTag:tu,recentTabsContainer:nu,recentTabsEntry:su,homeActionButton:ou,homeGrayCard:au,homeCardTitle:ru,homeCardGridContent:iu,usefulLinks:lu},cu=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"})),uu=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(cu,{width:e,height:e}):s.jsx(uu,{width:e,height:e}),[du,Vt]=_e(void 0),hu=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{d:"M256 32C132.3 32 32 134.9 32 261.7c0 101.5 64.2 187.5 153.2 217.9a17.56 17.56 0 003.8.4c8.3 0 11.5-6.1 11.5-11.4 0-5.5-.2-19.9-.3-39.1a102.4 102.4 0 01-22.6 2.7c-43.1 0-52.9-33.5-52.9-33.5-10.2-26.5-24.9-33.6-24.9-33.6-19.5-13.7-.1-14.1 1.4-14.1h.1c22.5 2 34.3 23.8 34.3 23.8 11.2 19.6 26.2 25.1 39.6 25.1a63 63 0 0025.6-6c2-14.8 7.8-24.9 14.2-30.7-49.7-5.8-102-25.5-102-113.5 0-25.1 8.7-45.6 23-61.6-2.3-5.8-10-29.2 2.2-60.8a18.64 18.64 0 015-.5c8.1 0 26.4 3.1 56.6 24.1a208.21 208.21 0 01112.2 0c30.2-21 48.5-24.1 56.6-24.1a18.64 18.64 0 015 .5c12.2 31.6 4.5 55 2.2 60.8 14.3 16.1 23 36.6 23 61.6 0 88.2-52.4 107.6-102.3 113.3 8 7.1 15.2 21.1 15.2 42.5 0 30.7-.3 55.5-.3 63 0 5.4 3.1 11.5 11.4 11.5a19.35 19.35 0 004-.4C415.9 449.2 480 363.1 480 261.7 480 134.9 379.7 32 256 32z"})),mu=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{d:"M227.6 213.1H256v57.1h-28.4z"}),l.createElement("path",{d:"M0 156v171.4h142.2V356H256v-28.6h256V156zm142.2 142.9h-28.4v-85.7H85.3v85.7H28.4V184.6h113.8zm142.2 0h-56.9v28.6h-56.9V184.6h113.8zm199.2 0h-28.4v-85.7h-28.4v85.7h-28.4v-85.7H370v85.7h-56.9V184.6h170.7v114.3z"})),fu=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{d:"M416 221.25V416a48 48 0 01-48 48H144a48 48 0 01-48-48V96a48 48 0 0148-48h98.75a32 32 0 0122.62 9.37l141.26 141.26a32 32 0 019.37 22.62z",fill:"none",stroke:"currentColor",strokeLinejoin:"round",strokeWidth:32}),l.createElement("path",{d:"M256 56v120a32 32 0 0032 32h120M176 288h160M176 368h160",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32})),pu=()=>{const e=Rn("Home");return s.jsx("div",{className:Q.homeActionButton,onClick:e,children:s.jsxs("h2",{className:Q.actionTitle,children:[s.jsx("span",{className:"truncate",children:"🔎 Start new query"}),s.jsx("span",{className:"hotkey",children:"N"})]})})},gu=()=>{const e=Y();return s.jsx("div",{className:Q.homeActionButton,onClick:()=>e(P.savedQueries.build()),children:s.jsx("h2",{className:Q.actionTitle,children:s.jsx("span",{className:"truncate",children:"💾 Saved queries"})})})},xu=()=>{const[e,t]=l.useState(void 0),n=Tn(pe.EDITOR),o=a=>{n?t(a):Re.error("You don't have permission to connect new data sources in this team")};return s.jsxs("div",{children:[e&&s.jsx(Jc,{show:!0,dbType:e,onClose:()=>t(void 0)}),s.jsx("div",{className:Q.homeActionButton,onClick:()=>o("postgres"),children:s.jsx("p",{className:Q.actionTitle,children:"🧙♂️ Connection wizard"})})]})},bu=()=>{const e=Y(),{data:t}=ds(),n=Rn("Home"),o=()=>{t&&t.length>0?e(P.workbenchTab.build({id:t[0].id})):n()};return s.jsx("div",{className:Q.homeActionButton,onClick:o,children:s.jsxs("h2",{className:Q.actionTitle,children:[s.jsx("span",{children:"🛠️ Workbench"}),s.jsx("span",{className:"hotkey",children:"W"})]})})},vu=()=>{const{data:e}=ue(),{data:t}=eo({teamId:e?.teamId}),n=o=>{Vt(o)};return!t||t.length===0?null:s.jsxs("div",{className:Q.homeGrayCard,children:[s.jsx("h2",{className:Q.homeCardTitle,children:"Data sources"}),s.jsx("div",{className:Q.homeCardGridContent,children:t?.map(o=>s.jsxs("div",{className:Q.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:Q.actionTitle,children:o.name}),o.allowInsert?s.jsx("span",{className:Q.devTag,children:"dev"}):s.jsx("span",{className:Q.prodTag,children:"prod"})]})]},o.id))})]})},Bt=24,yu=()=>s.jsxs("div",{className:Q.usefulLinks,children:[s.jsxs("a",{href:"https://dataramen.xyz/",target:"_blank",children:[s.jsx(fu,{width:Bt,height:Bt}),s.jsx("span",{children:"Docs"})]}),s.jsxs("a",{href:"https://github.com/OleksandrDemian/dataramen",target:"_blank",children:[s.jsx(hu,{width:Bt,height:Bt}),s.jsx("span",{children:"GitHub"})]}),s.jsxs("a",{href:"https://www.npmjs.com/package/@dataramen/cli",target:"_blank",children:[s.jsx(mu,{width:Bt,height:Bt}),s.jsx("span",{children:"NPM"})]})]}),wu=()=>{const{data:e}=ue(),{data:t,isLoading:n}=Zl(e?.teamId),o=Y();if(n||!t?.length)return null;const a=r=>{o(P.workbenchTab.build({id:r}))};return s.jsxs("div",{className:Q.recentTabsContainer,children:[s.jsx("h2",{className:Q.homeCardTitle+" px-4 mb-4",children:"Recent tabs"}),t.map(r=>s.jsxs("div",{className:Q.recentTabsEntry,onClick:()=>a(r.id),children:[s.jsx("p",{className:"text-(--text-color-primary) truncate",children:r.name}),s.jsxs("p",{className:"flex items-center gap-2",children:[s.jsx(it,{size:20,type:r.dataSourceType}),s.jsx("span",{className:"text-sm text-(--text-color-secondary) truncate",children:r.dataSourceName})]})]},r.id))]})},Cu=()=>{const{data:e}=ue(),{data:t}=eo({teamId:e?.teamId}),n=!!t&&t.length>0,o=!!e;return s.jsx("div",{className:"page-container h-screen max-h-screen overflow-y-auto no-scrollbar",children:s.jsxs("div",{className:"page-content",children:[s.jsxs("div",{className:"py-10 text-center w-full sticky top-0 z-0",children:[s.jsx("h1",{className:"comfortaa text-3xl font-semibold text-(--text-color-primary) mb-4",children:"DataRamen"}),s.jsx(yu,{})]}),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:Q.homeGrayCard,children:[s.jsx("h2",{className:Q.homeCardTitle,children:"Quick actions"}),s.jsxs("div",{className:Q.homeCardGridContent,children:[s.jsx(pu,{}),s.jsx(xu,{}),o&&s.jsx(bu,{}),s.jsx(gu,{})]})]}),o&&s.jsx(vu,{}),s.jsx(wu,{})]})]})})},[ju,no]=_e(void 0),Nu=()=>no(void 0);function wt(e,t){if(e==null)return"";switch(t){case"json":case"jsonb":return JSON.stringify(e,null,2)}if(e===0||e===!1)return e.toString();switch(typeof e){case"string":return e;case"number":case"boolean":return e.toString();default:return JSON.stringify(e)}}const Jn=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},_u="_container_d92uy_2",Su="_header_d92uy_2",ku="_fields-container_d92uy_2",Eu="_field-label_d92uy_2",Ru="_actions_d92uy_2",pn={container:_u,header:Su,fieldsContainer:ku,fieldLabel:Eu,actions:Ru},Tu=(e,t,n)=>ce({queryKey:["entity",e,t,n],queryFn:async()=>{const{data:o}=await O.get(`/runner/${e}/entity/${t}`,{params:n?.reduce((a,r)=>(a[r[0]]=r[1],a),{})});return o.data},retry:1,enabled:!!t&&!!e&&!!n,staleTime:0}),Lu=()=>X({mutationFn:async e=>{const{data:t}=await O.post(`/runner/${e.datasourceId}/update`,e);return t.data}}),Au=()=>X({mutationFn:async e=>{const{data:t}=await O.post(`/runner/${e.datasourceId}/insert`,e);return t.data}}),so=e=>l.useMemo(()=>{if(e)return e instanceof Yr?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]),oo=()=>{const{pathname:e}=le();return l.useMemo(()=>zt({path:P.workbenchTab.path,end:!1},e)?.params.id,[e])},Pu=({data:e})=>{const[t,{change:n,touched:o}]=jn({}),a=oo(),{mutateAsync:r,error:i}=Au(),c=so(i),{data:u}=kn(e.dataSourceId),[d,m]=l.useState(""),h=l.useMemo(()=>u?.find(b=>b.tableName===e.table),[u,e.table]),p=l.useMemo(()=>{if(!h)return[];if(!d)return h.columns.map(x=>({...x,label:et(x.name)}));const b=d.toLowerCase();return h.columns.filter(x=>x.name.toLowerCase().includes(b)).map(x=>({...x,label:et(x.name)}))},[d,h]),g=()=>{const b={};for(const x of o)b[x]=t[x];r({datasourceId:e.dataSourceId,table:e.table,values:b}).then(()=>{Nu(),a&&za(a)})};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(b=>s.jsxs("label",{className:pn.fieldLabel,children:[s.jsxs("div",{className:"flex justify-between",children:[s.jsxs("p",{children:[b.isPrimary?"🔐":"🏷️"," ",b.label]}),s.jsxs("p",{className:"text-blue-800 text-sm",children:["[",b.name,": ",b.type,"]"]})]}),s.jsx("input",{className:"input w-full",value:wt(t[b.name]),onChange:n(b.name),placeholder:b.name})]},b.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:b=>m(b.target.value),placeholder:"Filter columns"})]}),s.jsx("span",{className:"flex-1"}),s.jsx("button",{disabled:!o.length,className:"button primary",onClick:g,children:"Run insert"})]})]})},Iu=()=>{const e=ju(),[t,n]=l.useState(void 0);l.useEffect(()=>{e&&n(e)},[e]);const o=()=>no(void 0);return s.jsxs(ve,{isVisible:e!=null,onClose:o,onClosed:()=>n(void 0),noPadding:!0,children:[s.jsx(rt,{onClick:o}),t&&s.jsx(Pu,{data:t})]})},[Ou,ms]=_e(void 0),Mu=()=>ms(void 0),Du="_container_vcea9_2",$u="_header_vcea9_2",Fu="_key_vcea9_2",Bu="_fields-container_vcea9_2",qu="_field-label_vcea9_2",Uu="_actions_vcea9_2",qt={container:Du,header:$u,key:Fu,fieldsContainer:Bu,fieldLabel:qu,actions:Uu},st=()=>Date.now().toString(36)+Math.random().toString(36).substring(2),Wu=({data:e})=>{const[t,{change:n,set:o,reset:a,touched:r}]=jn({}),i=oo(),[c,u]=l.useState(""),{data:d,isLoading:m}=Tu(e.dataSourceId,e.tableName,e.entityId),{mutateAsync:h,error:p}=Lu(),g=so(p),b=Tn(pe.EDITOR),{data:x}=kn(e.dataSourceId),{data:v}=us(e.dataSourceId),y=l.useMemo(()=>x?.find(k=>k.tableName===e.tableName),[e.tableName,x]),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(a(),k&&d?.columns)for(let j=0;j<d.columns.length;j++){const S=d.columns[j];o(S.column,wt(k[j]))}},[d,o,a]);const w=()=>{const k={};for(const j of r)k[j]=t[j];h({datasourceId:e.dataSourceId,table:e.tableName,filters:e.entityId.map(j=>({id:st(),value:j[1],column:j[0]})),values:k}).then(()=>{Mu(),i&&za(i)})},C=e.entityId.map(([k,j])=>`${k} = ${j}`).join(", ")||"",_=!v?.allowUpdate||!b;return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:qt.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:qt.key,children:C}),g&&s.jsx(ne,{variant:"danger",children:s.jsx("p",{children:g})})]}),!_&&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:qt.container,children:s.jsx("div",{className:qt.fieldsContainer,children:f.map(k=>s.jsxs("label",{className:qt.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:wt(t[k.name]),onChange:n(k.name),placeholder:k.name})]},k.name))})}),s.jsxs("div",{className:qt.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:!r.length,className:"button primary",onClick:w,children:"Run update"})]})]})},Hu=()=>{const e=Ou(),[t,n]=l.useState(void 0);l.useEffect(()=>{e&&n(e)},[e]);const o=()=>ms(void 0);return s.jsxs(ve,{isVisible:e!=null,onClose:o,onClosed:()=>n(void 0),noPadding:!0,children:[s.jsx(rt,{onClick:o}),t&&s.jsx(Wu,{data:t})]})},[zu,ks]=_e(void 0),Ka=async e=>new Promise(t=>{ks({message:e,onCancel:()=>{t(!1),ks(void 0)},onConfirm:()=>{t(!0),ks(void 0)}})}),Vu=({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=zu(),[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(Vu,{confirm:t})})},[Ku,Xn]=_e(void 0),Ln=async(e,t,n)=>new Promise(o=>{Xn({message:e,defaultValue:t,alert:n,onCancel:()=>{Xn(void 0),o(void 0)},onConfirm:a=>{Xn(void 0),o(a)}})}),Gu="_root_ng9lp_1",Yu={root:Gu},Ju=({data:e})=>{const[t,n]=l.useState("");l.useEffect(()=>{e.defaultValue&&n(e.defaultValue)},[e]);const o=r=>{n(r.target.value)},a=r=>{r.key==="Enter"&&(r.preventDefault(),e.onConfirm(t)),r.key==="Escape"&&(r.preventDefault(),e.onCancel())};return s.jsxs("div",{className:Yu.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:a}),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"})]})]})},Xu=()=>{const e=Ku(),[t,n]=l.useState(void 0);return l.useEffect(()=>{e&&n(e)},[e]),s.jsx(ve,{isVisible:!!e,onClose:()=>Xn(void 0),onClosed:()=>n(void 0),children:t&&s.jsx(Ju,{data:t})})},[Zu,ed]=_e(void 0),Ga=e=>{ed(e)},td="_textarea_68vbf_2",nd={textarea:td},sd=()=>{const e=Zu(),t=()=>{e&&(navigator.clipboard.writeText(e.toString()),Re.success("Copied!"))},n=()=>Ga(void 0);return s.jsxs(ve,{isVisible:!!e,onClose:n,backdropClose:!0,children:[s.jsx("textarea",{className:nd.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"})]})]})},od="_tabs_i8v6j_2",ad="_mobile_i8v6j_2",rd="_tab_i8v6j_2",id="_active_i8v6j_2",ld="_close-button_i8v6j_2",gn={tabs:od,mobile:ad,tab:rd,active:id,closeButton:ld},Do=e=>window.matchMedia(e).matches;function Ya(e,{defaultValue:t=!1,initializeWithValue:n=!0}={}){const[o,a]=l.useState(()=>n?Do(e):t);return l.useLayoutEffect(()=>{const r=window.matchMedia(e);function i(){a(()=>Do(e))}return i(),r.addListener?r.addListener(i):r.addEventListener("change",i),()=>{r.removeListener?r.removeListener(i):r.removeEventListener("change",i)}},[e]),o}const ao={laptop:"(min-width: 1024px)"},Ja=()=>window.matchMedia(ao.laptop).matches,cd="_table_fvjm8_2",ud="_row-index-btn_fvjm8_2",dd="_semi-transparent_fvjm8_2",hd="_table-loading_fvjm8_2",md="_table-empty_fvjm8_2",fd="_table-row-cells_fvjm8_2",pd="_header-cell_fvjm8_2",gd="_header-actions_fvjm8_2",xd="_cell_fvjm8_2",bd="_value_fvjm8_2",vd="_table-config_fvjm8_2",yd="_table-action_fvjm8_2",wd="_green-fixed_fvjm8_2",Cd="_gray_fvjm8_2",jd="_modal_fvjm8_2",Nd="_selected-size_fvjm8_2",_d="_pagination-indicator_fvjm8_2",T={table:cd,rowIndexBtn:ud,semiTransparent:dd,tableLoading:hd,tableEmpty:md,tableRowCells:fd,headerCell:pd,headerActions:gd,cell:xd,value:bd,tableConfig:vd,tableAction:yd,greenFixed:wd,gray:Cd,modal:jd,selectedSize:Nd,paginationIndicator:_d},qe=l.createContext({name:"No name",hooks:[],availableJoins:[],allColumns:[],dataSourceId:"",entities:[],getValue:()=>{},getColumnType:()=>{},getEntityKey:()=>[],getEntityKeyByRowIndex:()=>[]}),ge=l.createContext({state:Zt({}),setState:()=>{}}),Ae=l.createContext({}),Xa={ON_ANIMATION_END:Symbol("ON_TRANSITION_END")},Za=()=>{const[e,t]=l.useState(),[n,o]=l.useState("hidden");return l.useMemo(()=>{const a=c=>{c.preventDefault(),o("in"),t({x:c.clientX-1,y:c.clientY-1})},r=()=>{o("out")},i=()=>{n==="in"?o("visible"):n==="out"&&(t(void 0),o("hidden"))};return{show:!!e,position:e,state:n,open:a,close:r,[Xa.ON_ANIMATION_END]:i}},[e,n])},Sd=e=>{if(e==="ASC")return"DESC";if(e!=="DESC")return"ASC"},kd=()=>{const{state:e,setState:t}=l.useContext(ge),n=l.useCallback(o=>{t(a=>{const r=a.orderBy[0];if(r&&r.column===o){const i=Sd(r.direction);return i?{...a,orderBy:[{column:o,direction:i}]}:{...a,orderBy:[]}}return{...a,orderBy:[{column:o,direction:"ASC"}]}})},[t]);return{orderBy:e.orderBy,updateOrderBy:n}},Ed="_options-container_fboyw_2",Rd="_filter-input_fboyw_2",Td="_option-item_fboyw_2",Ld="_list_fboyw_2",Ad="_empty-text_fboyw_2",Ke={optionsContainer:Ed,filterInput:Rd,optionItem:Td,list:Ld,emptyText:Ad},Pd="_container_14l7a_2",Id="_animate-show_14l7a_2",Od="_animate-hide_14l7a_2",Md="_content_14l7a_2",Dd="_backdrop_14l7a_2",ft={container:Pd,animateShow:Id,animateHide:Od,content:Md,backdrop:Dd},er=({children:e,handler:t})=>{const n=l.useRef(t.close);n.current=t.close;const o=l.useMemo(()=>{if(!t.position)return;const a={};if(typeof window<"u"){const r=t.position.y>window.innerHeight/2,i=t.position.x>window.innerWidth/2;r?a.bottom=window.innerHeight-t.position.y:a.top=t.position.y,Ja()?i?a.right=window.innerWidth-t.position.x:a.left=t.position.x:(a.right=36,a.left=36)}return a},[t.position]);return hs({enabled:!!o,onClose:t.close}),o?s.jsxs("div",{className:A(ft.container,t.state==="out"&&ft.animateHide,t.state==="in"&&ft.animateShow),onAnimationEnd:t[Xa.ON_ANIMATION_END],children:[s.jsx("div",{className:ft.backdrop,onClick:a=>{a.stopPropagation(),a.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},$e=(e,t)=>e!=null&&e>t,$d=(e,t)=>e!=null&&e<t,Fd="_root_ki4vr_2",Bd="_content_ki4vr_2",qd="_table-name_ki4vr_2",Ud="_sub_ki4vr_2",zn={root:Fd,content:Bd,tableName:qd,sub:Ud},tr=({hook:e,onClick:t})=>s.jsxs("button",{className:zn.root,onClick:t,children:[s.jsx("span",{children:"📄"}),s.jsxs("div",{className:zn.content,children:[s.jsx("span",{className:zn.tableName,children:e.on.toTable}),s.jsxs("span",{className:zn.sub,children:[e.on.toColumn," = ",e.on.fromTable,".",e.on.fromColumn]})]})]},e.where),Wd=A("input",Ke.filterInput);function Hd(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 nr=({rowIndex:e,onClose:t,className:n})=>{const[o,a]=l.useState(""),{hooks:r,dataSourceId:i,getValue:c}=l.useContext(qe),{state:u}=l.useContext(ge),{data:d}=l.useContext(Ae),m=l.useMemo(()=>d?.result.rows[e],[d,e]),h=en(),p=Y(),g=l.useMemo(()=>{if(!d)return[];const f=o.toLowerCase();return r.filter(w=>d.result.columns.some(_=>_.column===w.on.fromColumn&&_.table===w.on.fromTable)?w.on.toTable.toLowerCase().includes(f):!1)},[o,r,d]),b=f=>{m&&h.mutateAsync(Hd(f,i,c(m,{value:`${f.on.fromTable}.${f.on.fromColumn}`}))).then(w=>{p(P.workbenchTab.build({id:w.id})),t?.()})},x=()=>{!m||!u||h.mutateAsync({name:`${u.table} > [${u.joins.map(f=>f.table).join()}]`,opts:Zt({joins:u.joins,table:u.table,dataSourceId:u.dataSourceId,filters:[...u.filters.filter(f=>f.isEnabled),...u.groupBy.map(f=>({id: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=$e(g.length,0);return s.jsxs("div",{className:n,children:[s.jsx("input",{autoFocus:!0,className:Wd,placeholder:"Filter",value:o,onChange:f=>a(f.target.value)}),s.jsxs("div",{className:Ke.list,children:[v&&s.jsx("button",{onClick:x,className:Ke.optionItem,children:"🎯 Underlying rows"}),y&&g.map(f=>s.jsx(tr,{hook:f,onClick:()=>b(f)},f.where)),!v&&!y&&s.jsx("p",{className:Ke.emptyText,children:"Empty"})]})]})},zd=({handler:e,rowIndex:t})=>s.jsx(er,{handler:e,children:s.jsx("div",{className:Ke.optionsContainer,children:s.jsx(nr,{rowIndex:t,className:"p-2",onClose:()=>{e.close()}})})}),ro=()=>{const{state:e,setState:t}=l.useContext(ge),n=l.useCallback((a,r=!1)=>{t(i=>({...i,page:r?0:i.page,filters:a}))},[t]),o=l.useCallback(a=>{t(r=>({...r,filters:r.filters.filter(i=>i.id!==a)}))},[t]);return{filters:e.filters,removeFilter:o,setFilters:n}},Vd=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"})),io=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"})),Kd="_container_flyao_2",Gd="_animate-show_flyao_2",Yd="_animate-hide_flyao_2",Jd="_backdrop_flyao_2",Xd="_content_flyao_2",pt={container:Kd,animateShow:Gd,animateHide:Yd,backdrop:Jd,content:Xd},sr=({children:e,ref:t,onClosed:n})=>{const[o,a]=l.useState(void 0),[r,i]=l.useState("hidden"),c=l.useRef(null);if(l.useImperativeHandle(t,()=>({open:(m,h=!0)=>{h||(m.preventDefault(),m.stopPropagation());const p={},g=m.clientY>window.innerHeight/2,b=m.clientX>window.innerWidth/2;g?p.bottom=window.innerHeight-m.clientY:p.top=m.clientY,Ja()?b?p.right=window.innerWidth-m.clientX:p.left=m.clientX:(p.right=36,p.left=36),a(p),i("in")},close:()=>{i("out")}}),[]),hs({enabled:r==="in"||r==="visible",onClose:()=>{i("out")}}),!o)return null;const u=()=>{r==="in"?i("visible"):r==="out"&&(a(void 0),i("hidden"),n?.())},d=s.jsxs("div",{className:A(pt.container,r==="out"&&pt.animateHide,r==="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,r==="out"&&pt.animateHide,r==="in"&&pt.animateShow),children:e})]});return La.createPortal(d,document.body)};function Es(e,t,n){const o=e?.rows?.[t]?.[n],a=e?.columns?.[n];return{value:o,column:a}}const Zd=({ref:e})=>{const{data:t}=l.useContext(Ae),{getColumnType:n}=l.useContext(qe),{setState:o}=l.useContext(ge);return{copyValue:(c,u)=>{const{value:d,column:m}=Es(t?.result,c,u);if(m){const h=wt(d,n(m.full));navigator.clipboard.writeText(h),Re.success("Copied!"),e.current?.close()}},showValue:(c,u)=>{const{value:d,column:m}=Es(t?.result,c,u);if(m){const h=wt(d,n(m.full));Ga(h),e.current?.close()}},filterValue:(c,u)=>{const{value:d,column:m}=Es(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 g=wt(d,n(h));p={id:st(),isEnabled:!0,column:h,value:g,fn:m?.fn}}o(g=>({...g,filters:[...g.filters,p]})),Re.success(`Added new filter on column ${m?.alias}`),e.current?.close()}}}},or=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})),eh=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})),th="_section-name_2c7gu_2",nh="_item_2c7gu_2",gt={sectionName:th,item:nh},ar=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"})),sh=A("input",Ke.filterInput),oh=({onClose:e,rowIndex:t,className:n})=>{const[o,a]=l.useState(""),{entities:r,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?r.filter(p=>p.includes(o)):r,[r,o]),h=p=>{if(!d)return;const g=c(p,d);ms({tableName:p,dataSourceId:i,entityId:g}),e?.()};return s.jsxs("div",{className:n,children:[s.jsx("input",{autoFocus:!0,className:sh,placeholder:"Filter",value:o,onChange:p=>a(p.target.value)}),s.jsx("div",{className:Ke.list,children:$e(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"})})]})},ah=({ref:e,row:t,col:n,onClosed:o})=>{const a=Zd({ref:e}),[r,i]=l.useState("cell"),{entities:c,dataSourceId:u,getEntityKeyByRowIndex:d}=l.useContext(qe),m=()=>a.copyValue(t,n),h=()=>a.showValue(t,n),p=()=>a.filterValue(t,n),g=()=>{if(c.length===1){const x=d(c[0],t);ms({tableName:c[0],dataSourceId:u,entityId:x}),e.current?.close()}else i("expand")},b=()=>{o?.(),i("cell")};return s.jsx(sr,{ref:e,onClosed:b,children:s.jsxs("div",{className:"w-full lg:w-sm",children:[r==="cell"&&s.jsxs(s.Fragment,{children:[s.jsx("p",{className:gt.sectionName,children:"Cell actions"}),s.jsxs("button",{className:gt.item,onClick:m,children:[s.jsx(or,{width:14,height:14}),"Copy"]}),s.jsxs("button",{className:gt.item,onClick:h,children:[s.jsx(eh,{width:14,height:14}),"View"]}),s.jsxs("button",{className:gt.item,onClick:p,children:[s.jsx(io,{width:14,height:14}),"Filter"]}),s.jsx("p",{className:gt.sectionName,children:"Row actions"}),s.jsxs("button",{className:gt.item,onClick:()=>i("drill"),children:[s.jsx(Ge,{width:14,height:14}),"Drill down"]}),c?.length>0&&s.jsxs("button",{className:gt.item,onClick:g,children:[s.jsx(ar,{width:14,height:14}),"Edit row"]})]}),r==="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(nr,{rowIndex:t,onClose:()=>e.current?.close()})]}),r==="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(oh,{rowIndex:t,onClose:()=>e.current?.close()})]})]})})},rh={DESC:"",ASC:"rotate-180"},ih=(e,{column:t,value:n,fn:o})=>{const a=e.map(r=>({...r,isEnabled:r.column===t?!1:r.isEnabled}));return a.push({id:st(),column:t,isEnabled:!0,value:n,fn:o,isAdvanced:!1}),a},lh=()=>{const{data:e}=l.useContext(Ae),{orderBy:t,updateOrderBy:n}=kd(),{setFilters:o,filters:a}=ro(),r=e?.result.columns||[],i=t[0],c=$e(e?.result.tables.length,1),u=(d,m)=>{Ln("Filter value","").then(h=>{h&&o(ih(a,{column:d,value:h,fn:m}))})};return s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("td",{children:"🥢"}),r.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.alias),children:i?.column===d.alias?s.jsx(Vd,{className:rh[i.direction],width:16,height:16}):s.jsx(Qd,{width:16,height:16})}),s.jsx("button",{onClick:()=>u(d.full,d.fn),children:s.jsx(io,{width:16,height:16})})]})]},d.full))]})})};function ch({value:e}){if(e==="")return s.jsx("span",{className:"pointer-events-none text-black/30 truncate",children:"<EMPTY STRING>"});if(e==null)return s.jsx("span",{className:"pointer-events-none text-black/30",children:"<NULL>"});const t=wt(e);return s.jsx("span",{className:T.value,children:t})}const uh=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((a,r)=>s.jsx("td",{className:T.cell,"data-row":n,"data-col":r,children:s.jsx(ch,{value:a})},r))]})),dh=()=>{const{data:e,error:t,isLoading:n,isFetching:o}=l.useContext(Ae),{state:{page:a,size:r}}=l.useContext(ge),i=l.useRef(null),c=so(t),u=Za(),[d,m]=l.useState(void 0),[h,p]=l.useState(void 0),g=v=>{const f=v.target?.dataset?.rowAction;f!=null&&(m(parseInt(f)),u.open(v))},b=v=>{const y=v.target?.dataset,f=y?.row,w=y?.col;f!=null&&w!=null&&(m(parseInt(f)),p(parseInt(w)),i.current?.open(v),v.preventDefault(),v.stopPropagation())},x=a*r;return s.jsxs(s.Fragment,{children:[d!=null&&u.show&&s.jsx(zd,{handler:u,rowIndex:d}),s.jsx(ah,{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:g,onContextMenu:b,children:[s.jsx(lh,{}),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(uh,{index:y,offset:x,row:v,isLastRow:y===e.result.rows.length-1},y))]})]})]})},rr=()=>{const{state:e,setState:t}=l.useContext(ge),n=l.useCallback(a=>{t(r=>({...r,page:a}))},[t]),o=l.useCallback((a,r=!1)=>{t(i=>({...i,size:a,page:r?0:i.page}))},[t]);return{page:e.page,size:e.size,setSize:o,setPage:n}},hh=()=>X({mutationFn:async e=>{const{data:t}=await O.post("/saved-queries",e);return t.data},onSuccess:()=>{K.invalidateQueries({queryKey:["queries"]}),Jt(),Fa()}}),mh=()=>X({mutationFn:async e=>O.delete("/saved-queries/"+e),onSuccess:()=>{Jt(),Fa()}}),fh=()=>X({mutationFn:async({id:e,payload:t})=>{const{data:n}=await O.patch("/saved-queries/"+e,t);return n.data},onSuccess:()=>{Jt(),Gl()}}),[fs,lo]=_e({filters:!1,joins:!1,columns:!1,groupBy:!1,aggregate:!1}),Me=e=>lo(t=>({...t,[e]:!0})),ps=e=>lo(t=>({...t,[e]:!1})),ns=e=>lo(t=>({...t,[e]:!t[e]})),Qt=Math.min,Ct=Math.max,ss=Math.round,Vn=Math.floor,De=e=>({x:e,y:e}),ph={left:"right",right:"left",bottom:"top",top:"bottom"},gh={start:"end",end:"start"};function qs(e,t,n){return Ct(e,Qt(t,n))}function An(e,t){return typeof e=="function"?e(t):e}function Nt(e){return e.split("-")[0]}function Pn(e){return e.split("-")[1]}function ir(e){return e==="x"?"y":"x"}function co(e){return e==="y"?"height":"width"}const xh=new Set(["top","bottom"]);function tt(e){return xh.has(Nt(e))?"y":"x"}function uo(e){return ir(tt(e))}function bh(e,t,n){n===void 0&&(n=!1);const o=Pn(e),a=uo(e),r=co(a);let i=a==="x"?o===(n?"end":"start")?"right":"left":o==="start"?"bottom":"top";return t.reference[r]>t.floating[r]&&(i=os(i)),[i,os(i)]}function vh(e){const t=os(e);return[Us(e),t,Us(t)]}function Us(e){return e.replace(/start|end/g,t=>gh[t])}const $o=["left","right"],Fo=["right","left"],yh=["top","bottom"],wh=["bottom","top"];function Ch(e,t,n){switch(e){case"top":case"bottom":return n?t?Fo:$o:t?$o:Fo;case"left":case"right":return t?yh:wh;default:return[]}}function jh(e,t,n,o){const a=Pn(e);let r=Ch(Nt(e),n==="start",o);return a&&(r=r.map(i=>i+"-"+a),t&&(r=r.concat(r.map(Us)))),r}function os(e){return e.replace(/left|right|bottom|top/g,t=>ph[t])}function Nh(e){return{top:0,right:0,bottom:0,left:0,...e}}function lr(e){return typeof e!="number"?Nh(e):{top:e,right:e,bottom:e,left:e}}function as(e){const{x:t,y:n,width:o,height:a}=e;return{width:o,height:a,top:n,left:t,right:t+o,bottom:n+a,x:t,y:n}}function Bo(e,t,n){let{reference:o,floating:a}=e;const r=tt(t),i=uo(t),c=co(i),u=Nt(t),d=r==="y",m=o.x+o.width/2-a.width/2,h=o.y+o.height/2-a.height/2,p=o[c]/2-a[c]/2;let g;switch(u){case"top":g={x:m,y:o.y-a.height};break;case"bottom":g={x:m,y:o.y+o.height};break;case"right":g={x:o.x+o.width,y:h};break;case"left":g={x:o.x-a.width,y:h};break;default:g={x:o.x,y:o.y}}switch(Pn(t)){case"start":g[i]-=p*(n&&d?-1:1);break;case"end":g[i]+=p*(n&&d?-1:1);break}return g}const _h=async(e,t,n)=>{const{placement:o="bottom",strategy:a="absolute",middleware:r=[],platform:i}=n,c=r.filter(Boolean),u=await(i.isRTL==null?void 0:i.isRTL(t));let d=await i.getElementRects({reference:e,floating:t,strategy:a}),{x:m,y:h}=Bo(d,o,u),p=o,g={},b=0;for(let x=0;x<c.length;x++){const{name:v,fn:y}=c[x],{x:f,y:w,data:C,reset:_}=await y({x:m,y:h,initialPlacement:o,placement:p,strategy:a,middlewareData:g,rects:d,platform:i,elements:{reference:e,floating:t}});m=f??m,h=w??h,g={...g,[v]:{...g[v],...C}},_&&b<=50&&(b++,typeof _=="object"&&(_.placement&&(p=_.placement),_.rects&&(d=_.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:a}):_.rects),{x:m,y:h}=Bo(d,p,u)),x=-1)}return{x:m,y:h,placement:p,strategy:a,middlewareData:g}};async function cr(e,t){var n;t===void 0&&(t={});const{x:o,y:a,platform:r,rects:i,elements:c,strategy:u}=e,{boundary:d="clippingAncestors",rootBoundary:m="viewport",elementContext:h="floating",altBoundary:p=!1,padding:g=0}=An(t,e),b=lr(g),v=c[p?h==="floating"?"reference":"floating":h],y=as(await r.getClippingRect({element:(n=await(r.isElement==null?void 0:r.isElement(v)))==null||n?v:v.contextElement||await(r.getDocumentElement==null?void 0:r.getDocumentElement(c.floating)),boundary:d,rootBoundary:m,strategy:u})),f=h==="floating"?{x:o,y:a,width:i.floating.width,height:i.floating.height}:i.reference,w=await(r.getOffsetParent==null?void 0:r.getOffsetParent(c.floating)),C=await(r.isElement==null?void 0:r.isElement(w))?await(r.getScale==null?void 0:r.getScale(w))||{x:1,y:1}:{x:1,y:1},_=as(r.convertOffsetParentRelativeRectToViewportRelativeRect?await r.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:f,offsetParent:w,strategy:u}):f);return{top:(y.top-_.top+b.top)/C.y,bottom:(_.bottom-y.bottom+b.bottom)/C.y,left:(y.left-_.left+b.left)/C.x,right:(_.right-y.right+b.right)/C.x}}const Sh=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:o,placement:a,rects:r,platform:i,elements:c,middlewareData:u}=t,{element:d,padding:m=0}=An(e,t)||{};if(d==null)return{};const h=lr(m),p={x:n,y:o},g=uo(a),b=co(g),x=await i.getDimensions(d),v=g==="y",y=v?"top":"left",f=v?"bottom":"right",w=v?"clientHeight":"clientWidth",C=r.reference[b]+r.reference[g]-p[g]-r.floating[b],_=p[g]-r.reference[g],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]||r.floating[b]);const S=C/2-_/2,I=j/2-x[b]/2-1,F=Qt(h[y],I),se=Qt(h[f],I),ye=F,Pe=j-x[b]-se,q=j/2-x[b]/2+S,de=qs(ye,q,Pe),oe=!u.arrow&&Pn(a)!=null&&q!==de&&r.reference[b]/2-(q<ye?F:se)-x[b]/2<0,J=oe?q<ye?q-ye:q-Pe:0;return{[g]:p[g]+J,data:{[g]:de,centerOffset:q-de-J,...oe&&{alignmentOffset:J}},reset:oe}}}),kh=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,o;const{placement:a,middlewareData:r,rects:i,initialPlacement:c,platform:u,elements:d}=t,{mainAxis:m=!0,crossAxis:h=!0,fallbackPlacements:p,fallbackStrategy:g="bestFit",fallbackAxisSideDirection:b="none",flipAlignment:x=!0,...v}=An(e,t);if((n=r.arrow)!=null&&n.alignmentOffset)return{};const y=Nt(a),f=tt(c),w=Nt(c)===c,C=await(u.isRTL==null?void 0:u.isRTL(d.floating)),_=p||(w||!x?[os(c)]:vh(c)),k=b!=="none";!p&&k&&_.push(...jh(c,x,b,C));const j=[c,..._],S=await cr(t,v),I=[];let F=((o=r.flip)==null?void 0:o.overflows)||[];if(m&&I.push(S[y]),h){const q=bh(a,i,C);I.push(S[q[0]],S[q[1]])}if(F=[...F,{placement:a,overflows:I}],!I.every(q=>q<=0)){var se,ye;const q=(((se=r.flip)==null?void 0:se.index)||0)+1,de=j[q];if(de&&(!(h==="alignment"?f!==tt(de):!1)||F.every(H=>tt(H.placement)===f?H.overflows[0]>0:!0)))return{data:{index:q,overflows:F},reset:{placement:de}};let oe=(ye=F.filter(J=>J.overflows[0]<=0).sort((J,H)=>J.overflows[1]-H.overflows[1])[0])==null?void 0:ye.placement;if(!oe)switch(g){case"bestFit":{var Pe;const J=(Pe=F.filter(H=>{if(k){const ae=tt(H.placement);return ae===f||ae==="y"}return!0}).map(H=>[H.placement,H.overflows.filter(ae=>ae>0).reduce((ae,We)=>ae+We,0)]).sort((H,ae)=>H[1]-ae[1])[0])==null?void 0:Pe[0];J&&(oe=J);break}case"initialPlacement":oe=c;break}if(a!==oe)return{reset:{placement:oe}}}return{}}}},Eh=new Set(["left","top"]);async function Rh(e,t){const{placement:n,platform:o,elements:a}=e,r=await(o.isRTL==null?void 0:o.isRTL(a.floating)),i=Nt(n),c=Pn(n),u=tt(n)==="y",d=Eh.has(i)?-1:1,m=r&&u?-1:1,h=An(t,e);let{mainAxis:p,crossAxis:g,alignmentAxis:b}=typeof h=="number"?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};return c&&typeof b=="number"&&(g=c==="end"?b*-1:b),u?{x:g*m,y:p*d}:{x:p*d,y:g*m}}const Th=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,o;const{x:a,y:r,placement:i,middlewareData:c}=t,u=await Rh(t,e);return i===((n=c.offset)==null?void 0:n.placement)&&(o=c.arrow)!=null&&o.alignmentOffset?{}:{x:a+u.x,y:r+u.y,data:{...u,placement:i}}}}},Lh=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:o,placement:a}=t,{mainAxis:r=!0,crossAxis:i=!1,limiter:c={fn:v=>{let{x:y,y:f}=v;return{x:y,y:f}}},...u}=An(e,t),d={x:n,y:o},m=await cr(t,u),h=tt(Nt(a)),p=ir(h);let g=d[p],b=d[h];if(r){const v=p==="y"?"top":"left",y=p==="y"?"bottom":"right",f=g+m[v],w=g-m[y];g=qs(f,g,w)}if(i){const v=h==="y"?"top":"left",y=h==="y"?"bottom":"right",f=b+m[v],w=b-m[y];b=qs(f,b,w)}const x=c.fn({...t,[p]:g,[h]:b});return{...x,data:{x:x.x-n,y:x.y-o,enabled:{[p]:r,[h]:i}}}}}};function gs(){return typeof window<"u"}function tn(e){return ur(e)?(e.nodeName||"").toLowerCase():"#document"}function be(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Ue(e){var t;return(t=(ur(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function ur(e){return gs()?e instanceof Node||e instanceof be(e).Node:!1}function Te(e){return gs()?e instanceof Element||e instanceof be(e).Element:!1}function Fe(e){return gs()?e instanceof HTMLElement||e instanceof be(e).HTMLElement:!1}function qo(e){return!gs()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof be(e).ShadowRoot}const Ah=new Set(["inline","contents"]);function In(e){const{overflow:t,overflowX:n,overflowY:o,display:a}=Le(e);return/auto|scroll|overlay|hidden|clip/.test(t+o+n)&&!Ah.has(a)}const Ph=new Set(["table","td","th"]);function Ih(e){return Ph.has(tn(e))}const Oh=[":popover-open",":modal"];function xs(e){return Oh.some(t=>{try{return e.matches(t)}catch{return!1}})}const Mh=["transform","translate","scale","rotate","perspective"],Dh=["transform","translate","scale","rotate","perspective","filter"],$h=["paint","layout","strict","content"];function ho(e){const t=mo(),n=Te(e)?Le(e):e;return Mh.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)||Dh.some(o=>(n.willChange||"").includes(o))||$h.some(o=>(n.contain||"").includes(o))}function Fh(e){let t=ot(e);for(;Fe(t)&&!Kt(t);){if(ho(t))return t;if(xs(t))return null;t=ot(t)}return null}function mo(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Bh=new Set(["html","body","#document"]);function Kt(e){return Bh.has(tn(e))}function Le(e){return be(e).getComputedStyle(e)}function bs(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||qo(e)&&e.host||Ue(e);return qo(t)?t.host:t}function dr(e){const t=ot(e);return Kt(t)?e.ownerDocument?e.ownerDocument.body:e.body:Fe(t)&&In(t)?t:dr(t)}function wn(e,t,n){var o;t===void 0&&(t=[]),n===void 0&&(n=!0);const a=dr(e),r=a===((o=e.ownerDocument)==null?void 0:o.body),i=be(a);if(r){const c=Ws(i);return t.concat(i,i.visualViewport||[],In(a)?a:[],c&&n?wn(c):[])}return t.concat(a,wn(a,[],n))}function Ws(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function hr(e){const t=Le(e);let n=parseFloat(t.width)||0,o=parseFloat(t.height)||0;const a=Fe(e),r=a?e.offsetWidth:n,i=a?e.offsetHeight:o,c=ss(n)!==r||ss(o)!==i;return c&&(n=r,o=i),{width:n,height:o,$:c}}function fo(e){return Te(e)?e:e.contextElement}function Ht(e){const t=fo(e);if(!Fe(t))return De(1);const n=t.getBoundingClientRect(),{width:o,height:a,$:r}=hr(t);let i=(r?ss(n.width):n.width)/o,c=(r?ss(n.height):n.height)/a;return(!i||!Number.isFinite(i))&&(i=1),(!c||!Number.isFinite(c))&&(c=1),{x:i,y:c}}const qh=De(0);function mr(e){const t=be(e);return!mo()||!t.visualViewport?qh:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Uh(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==be(e)?!1:t}function _t(e,t,n,o){t===void 0&&(t=!1),n===void 0&&(n=!1);const a=e.getBoundingClientRect(),r=fo(e);let i=De(1);t&&(o?Te(o)&&(i=Ht(o)):i=Ht(e));const c=Uh(r,n,o)?mr(r):De(0);let u=(a.left+c.x)/i.x,d=(a.top+c.y)/i.y,m=a.width/i.x,h=a.height/i.y;if(r){const p=be(r),g=o&&Te(o)?be(o):o;let b=p,x=Ws(b);for(;x&&o&&g!==b;){const v=Ht(x),y=x.getBoundingClientRect(),f=Le(x),w=y.left+(x.clientLeft+parseFloat(f.paddingLeft))*v.x,C=y.top+(x.clientTop+parseFloat(f.paddingTop))*v.y;u*=v.x,d*=v.y,m*=v.x,h*=v.y,u+=w,d+=C,b=be(x),x=Ws(b)}}return as({width:m,height:h,x:u,y:d})}function vs(e,t){const n=bs(e).scrollLeft;return t?t.left+n:_t(Ue(e)).left+n}function fr(e,t){const n=e.getBoundingClientRect(),o=n.left+t.scrollLeft-vs(e,n),a=n.top+t.scrollTop;return{x:o,y:a}}function Wh(e){let{elements:t,rect:n,offsetParent:o,strategy:a}=e;const r=a==="fixed",i=Ue(o),c=t?xs(t.floating):!1;if(o===i||c&&r)return n;let u={scrollLeft:0,scrollTop:0},d=De(1);const m=De(0),h=Fe(o);if((h||!h&&!r)&&((tn(o)!=="body"||In(i))&&(u=bs(o)),Fe(o))){const g=_t(o);d=Ht(o),m.x=g.x+o.clientLeft,m.y=g.y+o.clientTop}const p=i&&!h&&!r?fr(i,u):De(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 Hh(e){return Array.from(e.getClientRects())}function zh(e){const t=Ue(e),n=bs(e),o=e.ownerDocument.body,a=Ct(t.scrollWidth,t.clientWidth,o.scrollWidth,o.clientWidth),r=Ct(t.scrollHeight,t.clientHeight,o.scrollHeight,o.clientHeight);let i=-n.scrollLeft+vs(e);const c=-n.scrollTop;return Le(o).direction==="rtl"&&(i+=Ct(t.clientWidth,o.clientWidth)-a),{width:a,height:r,x:i,y:c}}const Uo=25;function Vh(e,t){const n=be(e),o=Ue(e),a=n.visualViewport;let r=o.clientWidth,i=o.clientHeight,c=0,u=0;if(a){r=a.width,i=a.height;const m=mo();(!m||m&&t==="fixed")&&(c=a.offsetLeft,u=a.offsetTop)}const d=vs(o);if(d<=0){const m=o.ownerDocument,h=m.body,p=getComputedStyle(h),g=m.compatMode==="CSS1Compat"&&parseFloat(p.marginLeft)+parseFloat(p.marginRight)||0,b=Math.abs(o.clientWidth-h.clientWidth-g);b<=Uo&&(r-=b)}else d<=Uo&&(r+=d);return{width:r,height:i,x:c,y:u}}const Qh=new Set(["absolute","fixed"]);function Kh(e,t){const n=_t(e,!0,t==="fixed"),o=n.top+e.clientTop,a=n.left+e.clientLeft,r=Fe(e)?Ht(e):De(1),i=e.clientWidth*r.x,c=e.clientHeight*r.y,u=a*r.x,d=o*r.y;return{width:i,height:c,x:u,y:d}}function Wo(e,t,n){let o;if(t==="viewport")o=Vh(e,n);else if(t==="document")o=zh(Ue(e));else if(Te(t))o=Kh(t,n);else{const a=mr(e);o={x:t.x-a.x,y:t.y-a.y,width:t.width,height:t.height}}return as(o)}function pr(e,t){const n=ot(e);return n===t||!Te(n)||Kt(n)?!1:Le(n).position==="fixed"||pr(n,t)}function Gh(e,t){const n=t.get(e);if(n)return n;let o=wn(e,[],!1).filter(c=>Te(c)&&tn(c)!=="body"),a=null;const r=Le(e).position==="fixed";let i=r?ot(e):e;for(;Te(i)&&!Kt(i);){const c=Le(i),u=ho(i);!u&&c.position==="fixed"&&(a=null),(r?!u&&!a:!u&&c.position==="static"&&!!a&&Qh.has(a.position)||In(i)&&!u&&pr(e,i))?o=o.filter(m=>m!==i):a=c,i=ot(i)}return t.set(e,o),o}function Yh(e){let{element:t,boundary:n,rootBoundary:o,strategy:a}=e;const i=[...n==="clippingAncestors"?xs(t)?[]:Gh(t,this._c):[].concat(n),o],c=i[0],u=i.reduce((d,m)=>{const h=Wo(t,m,a);return d.top=Ct(h.top,d.top),d.right=Qt(h.right,d.right),d.bottom=Qt(h.bottom,d.bottom),d.left=Ct(h.left,d.left),d},Wo(t,c,a));return{width:u.right-u.left,height:u.bottom-u.top,x:u.left,y:u.top}}function Jh(e){const{width:t,height:n}=hr(e);return{width:t,height:n}}function Xh(e,t,n){const o=Fe(t),a=Ue(t),r=n==="fixed",i=_t(e,!0,r,t);let c={scrollLeft:0,scrollTop:0};const u=De(0);function d(){u.x=vs(a)}if(o||!o&&!r)if((tn(t)!=="body"||In(a))&&(c=bs(t)),o){const g=_t(t,!0,r,t);u.x=g.x+t.clientLeft,u.y=g.y+t.clientTop}else a&&d();r&&!o&&a&&d();const m=a&&!o&&!r?fr(a,c):De(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 Rs(e){return Le(e).position==="static"}function Ho(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 gr(e,t){const n=be(e);if(xs(e))return n;if(!Fe(e)){let a=ot(e);for(;a&&!Kt(a);){if(Te(a)&&!Rs(a))return a;a=ot(a)}return n}let o=Ho(e,t);for(;o&&Ih(o)&&Rs(o);)o=Ho(o,t);return o&&Kt(o)&&Rs(o)&&!ho(o)?n:o||Fh(e)||n}const Zh=async function(e){const t=this.getOffsetParent||gr,n=this.getDimensions,o=await n(e.floating);return{reference:Xh(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}};function em(e){return Le(e).direction==="rtl"}const tm={convertOffsetParentRelativeRectToViewportRelativeRect:Wh,getDocumentElement:Ue,getClippingRect:Yh,getOffsetParent:gr,getElementRects:Zh,getClientRects:Hh,getDimensions:Jh,getScale:Ht,isElement:Te,isRTL:em};function xr(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function nm(e,t){let n=null,o;const a=Ue(e);function r(){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),r();const d=e.getBoundingClientRect(),{left:m,top:h,width:p,height:g}=d;if(c||t(),!p||!g)return;const b=Vn(h),x=Vn(a.clientWidth-(m+p)),v=Vn(a.clientHeight-(h+g)),y=Vn(m),w={rootMargin:-b+"px "+-x+"px "+-v+"px "+-y+"px",threshold:Ct(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&&!xr(d,e.getBoundingClientRect())&&i(),C=!1}try{n=new IntersectionObserver(_,{...w,root:a.ownerDocument})}catch{n=new IntersectionObserver(_,w)}n.observe(e)}return i(!0),r}function sm(e,t,n,o){o===void 0&&(o={});const{ancestorScroll:a=!0,ancestorResize:r=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:c=typeof IntersectionObserver=="function",animationFrame:u=!1}=o,d=fo(e),m=a||r?[...d?wn(d):[],...wn(t)]:[];m.forEach(y=>{a&&y.addEventListener("scroll",n,{passive:!0}),r&&y.addEventListener("resize",n)});const h=d&&c?nm(d,n):null;let p=-1,g=null;i&&(g=new ResizeObserver(y=>{let[f]=y;f&&f.target===d&&g&&(g.unobserve(t),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var w;(w=g)==null||w.observe(t)})),n()}),d&&!u&&g.observe(d),g.observe(t));let b,x=u?_t(e):null;u&&v();function v(){const y=_t(e);x&&!xr(x,y)&&n(),x=y,b=requestAnimationFrame(v)}return n(),()=>{var y;m.forEach(f=>{a&&f.removeEventListener("scroll",n),r&&f.removeEventListener("resize",n)}),h?.(),(y=g)==null||y.disconnect(),g=null,u&&cancelAnimationFrame(b)}}const om=Th,am=Lh,rm=kh,im=Sh,zo=(e,t,n)=>{const o=new Map,a={platform:tm,...n},r={...a.platform,_c:o};return _h(e,t,{...a,platform:r})};var Ts={exports:{}};var Vo;function lm(){return Vo||(Vo=1,(function(e){(function(){var t={}.hasOwnProperty;function n(){for(var r="",i=0;i<arguments.length;i++){var c=arguments[i];c&&(r=a(r,o(c)))}return r}function o(r){if(typeof r=="string"||typeof r=="number")return r;if(typeof r!="object")return"";if(Array.isArray(r))return n.apply(null,r);if(r.toString!==Object.prototype.toString&&!r.toString.toString().includes("[native code]"))return r.toString();var i="";for(var c in r)t.call(r,c)&&r[c]&&(i=a(i,c));return i}function a(r,i){return i?r?r+" "+i:r+i:r}e.exports?(n.default=n,e.exports=n):window.classNames=n})()})(Ts)),Ts.exports}var cm=lm();const Hs=Jr(cm);var Qo={};const um="react-tooltip-core-styles",dm="react-tooltip-base-styles",Ko={core:!1,base:!1};function Go({css:e,id:t=dm,type:n="base",ref:o}){var a,r;if(!e||typeof document>"u"||Ko[n]||n==="core"&&typeof process<"u"&&(!((a=process==null?void 0:Qo)===null||a===void 0)&&a.REACT_TOOLTIP_DISABLE_CORE_STYLES)||n!=="base"&&typeof process<"u"&&(!((r=process==null?void 0:Qo)===null||r===void 0)&&r.REACT_TOOLTIP_DISABLE_BASE_STYLES))return;n==="core"&&(t=um),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)),Ko[n]=!0}const Yo=async({elementReference:e=null,tooltipReference:t=null,tooltipArrowReference:n=null,place:o="top",offset:a=10,strategy:r="absolute",middlewares:i=[om(Number(a)),rm({fallbackAxisSideDirection:"start"}),am({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(im({element:n,padding:5})),zo(e,t,{placement:o,strategy:r,middleware:d}).then((({x:m,y:h,placement:p,middlewareData:g})=>{var b,x;const v={left:`${m}px`,top:`${h}px`,border:c},{x:y,y:f}=(b=g.arrow)!==null&&b!==void 0?b:{x:0,y:0},w=(x={top:"bottom",right:"left",bottom:"top",left:"right"}[p.split("-")[0]])!==null&&x!==void 0?x:"bottom",C=c&&{borderBottom:c,borderRight:c};let _=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}}))):zo(e,t,{placement:"bottom",strategy:r,middleware:d}).then((({x:m,y:h,placement:p})=>({tooltipStyles:{left:`${m}px`,top:`${h}px`},tooltipArrowStyles:{},place:p})))},Jo=(e,t)=>!("CSS"in window&&"supports"in window.CSS)||window.CSS.supports(e,t),Xo=(e,t,n)=>{let o=null;const a=function(...r){const i=()=>{o=null};!o&&(e.apply(this,r),o=setTimeout(i,t))};return a.cancel=()=>{o&&(clearTimeout(o),o=null)},a},Zo=e=>e!==null&&!Array.isArray(e)&&typeof e=="object",zs=(e,t)=>{if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every(((a,r)=>zs(a,t[r])));if(Array.isArray(e)!==Array.isArray(t))return!1;if(!Zo(e)||!Zo(t))return e===t;const n=Object.keys(e),o=Object.keys(t);return n.length===o.length&&n.every((a=>zs(e[a],t[a])))},hm=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"}))},ea=e=>{if(!e)return null;let t=e.parentElement;for(;t;){if(hm(t))return t;t=t.parentElement}return document.scrollingElement||document.documentElement},mm=typeof window<"u"?l.useLayoutEffect:l.useEffect,Ce=e=>{e.current&&(clearTimeout(e.current),e.current=null)},fm="DEFAULT_TOOLTIP_ID",pm={anchorRefs:new Set,activeAnchor:{current:null},attach:()=>{},detach:()=>{},setActiveAnchor:()=>{}},gm=l.createContext({getTooltipData:()=>pm});function br(e=fm){return l.useContext(gm).getTooltipData(e)}var Ut={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"},Ls={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 xm=({forwardRef:e,id:t,className:n,classNameArrow:o,variant:a="dark",anchorId:r,anchorSelect:i,place:c="top",offset:u=10,events:d=["hover"],openOnClick:m=!1,positionStrategy:h="absolute",middlewares:p,wrapper:g,delayShow:b=0,delayHide:x=0,float:v=!1,hidden:y=!1,noArrow:f=!1,clickable:w=!1,closeOnEsc:C=!1,closeOnScroll:_=!1,closeOnResize:k=!1,openEvents:j,closeEvents:S,globalCloseEvents:I,imperativeModeOnly:F,style:se,position:ye,afterShow:Pe,afterHide:q,disableTooltip:de,content:oe,contentWrapperRef:J,isOpen:H,defaultIsOpen:ae=!1,setIsOpen:We,previousActiveAnchor:nn,activeAnchor:U,setActiveAnchor:St,border:On,opacity:Mn,arrowColor:Dn,arrowSize:kt=8,role:ys="tooltip"})=>{var lt;const he=l.useRef(null),Et=l.useRef(null),Se=l.useRef(null),ct=l.useRef(null),Rt=l.useRef(null),[ut,$n]=l.useState({tooltipStyles:{},tooltipArrowStyles:{},place:c}),[me,sn]=l.useState(!1),[Tt,Je]=l.useState(!1),[V,Lt]=l.useState(null),Fn=l.useRef(!1),At=l.useRef(null),{anchorRefs:Bn,setActiveAnchor:on}=br(t),an=l.useRef(!1),[Xe,rn]=l.useState([]),dt=l.useRef(!1),Pt=m||d.includes("click"),qn=Pt||j?.click||j?.dblclick||j?.mousedown,ln=j?{...j}:{mouseover:!0,focus:!0,mouseenter:!1,click:!1,dblclick:!1,mousedown:!1};!j&&Pt&&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&&Pt&&Object.assign(ht,{mouseleave:!1,blur:!1,mouseout:!1});const ee=I?{...I}:{escape:C||!1,scroll:_||!1,resize:k||!1,clickOutsideAnchor:qn||!1};F&&(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})),mm((()=>(dt.current=!0,()=>{dt.current=!1})),[]);const fe=N=>{dt.current&&(N&&Je(!0),setTimeout((()=>{dt.current&&(We?.(N),H===void 0&&sn(N))}),10))};l.useEffect((()=>{if(t){if(me){R(nn);const E=N(U),B=[...new Set([...E,t])].filter(Boolean).join(" ");U?.setAttribute("aria-describedby",B)}else R(U);return()=>{R(U),R(nn)}}function N(E){var B;return((B=E?.getAttribute("aria-describedby"))===null||B===void 0?void 0:B.split(" "))||[]}function R(E){const B=N(E).filter((Z=>Z!==t));B.length?E?.setAttribute("aria-describedby",B.join(" ")):E?.removeAttribute("aria-describedby")}}),[U,me,t,nn]),l.useEffect((()=>{if(H===void 0)return()=>null;H&&Je(!0);const N=setTimeout((()=>{sn(H)}),10);return()=>{clearTimeout(N)}}),[H]),l.useEffect((()=>{if(me!==Fn.current)if(Ce(Rt),Fn.current=me,me)Pe?.();else{const N=(R=>{const E=R.match(/^([\d.]+)(ms|s)$/);if(!E)return 0;const[,B,Z]=E;return Number(B)*(Z==="ms"?1:1e3)})(getComputedStyle(document.body).getPropertyValue("--rt-transition-show-delay"));Rt.current=setTimeout((()=>{Je(!1),Lt(null),q?.()}),N+25)}}),[me]);const cn=N=>{$n((R=>zs(R,N)?R:N))},un=(N=b)=>{Ce(Se),Tt?fe(!0):Se.current=setTimeout((()=>{fe(!0)}),N)},It=(N=x)=>{Ce(ct),ct.current=setTimeout((()=>{an.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 St(null),void on({current:null});b?un():fe(!0),St(E),on({current:E}),Ce(ct)},Ot=()=>{w?It(x||100):x?It():fe(!1),Ce(Se)},Mt=({x:N,y:R})=>{var E;const B={getBoundingClientRect:()=>({x:N,y:R,width:0,height:0,top:R,left:N,right:N,bottom:R})};Yo({place:(E=V?.place)!==null&&E!==void 0?E:c,offset:u,elementReference:B,tooltipReference:he.current,tooltipArrowReference:Et.current,strategy:h,middlewares:p,border:On,arrowSize:kt}).then((Z=>{cn(Z)}))},Dt=N=>{if(!N)return;const R=N,E={x:R.clientX,y:R.clientY};Mt(E),At.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='${r}']`),...Xe].some((B=>B?.contains(E)))||(fe(!1),Ce(Se)))},Un=Xo(dn,50),G=Xo(Ot,50),re=N=>{G.cancel(),Un(N)},L=()=>{Un.cancel(),G()},M=l.useCallback((()=>{var N,R;const E=(N=V?.position)!==null&&N!==void 0?N:ye;E?Mt(E):v?At.current&&Mt(At.current):U?.isConnected&&Yo({place:(R=V?.place)!==null&&R!==void 0?R:c,offset:u,elementReference:U,tooltipReference:he.current,tooltipArrowReference:Et.current,strategy:h,middlewares:p,border:On,arrowSize:kt}).then((B=>{dt.current&&cn(B)}))}),[me,U,oe,se,c,V?.place,u,h,ye,V?.position,v,kt]);l.useEffect((()=>{var N,R;const E=new Set(Bn);Xe.forEach(($=>{de?.($)||E.add({current:$})}));const B=document.querySelector(`[id='${r}']`);B&&!de?.(B)&&E.add({current:B});const Z=()=>{fe(!1)},Ie=ea(U),Oe=ea(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):U&&he.current&&(ie=sm(U,he.current,M,{ancestorResize:!0,elementResize:!0,layoutShift:!0}));const we=$=>{$.key==="Escape"&&fe(!1)};ee.escape&&window.addEventListener("keydown",we),ee.clickOutsideAnchor&&window.addEventListener("click",hn);const W=[],$t=$=>!!($?.target&&U?.contains($.target)),$r=$=>{me&&$t($)||dn($)},Fr=$=>{me&&$t($)&&Ot()},xo=["mouseover","mouseout","mouseenter","mouseleave","focus","blur"],bo=["click","dblclick","mousedown","mouseup"];Object.entries(ln).forEach((([$,He])=>{He&&(xo.includes($)?W.push({event:$,listener:re}):bo.includes($)&&W.push({event:$,listener:$r}))})),Object.entries(ht).forEach((([$,He])=>{He&&(xo.includes($)?W.push({event:$,listener:L}):bo.includes($)&&W.push({event:$,listener:Fr}))})),v&&W.push({event:"pointermove",listener:Dt});const vo=()=>{an.current=!0},yo=()=>{an.current=!1,Ot()},wo=w&&(ht.mouseout||ht.mouseleave);return wo&&((N=he.current)===null||N===void 0||N.addEventListener("mouseover",vo),(R=he.current)===null||R===void 0||R.addEventListener("mouseout",yo)),W.forEach((({event:$,listener:He})=>{E.forEach((ws=>{var mn;(mn=ws.current)===null||mn===void 0||mn.addEventListener($,He)}))})),()=>{var $,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),wo&&(($=he.current)===null||$===void 0||$.removeEventListener("mouseover",vo),(He=he.current)===null||He===void 0||He.removeEventListener("mouseout",yo)),W.forEach((({event:ws,listener:mn})=>{E.forEach((Br=>{var Cs;(Cs=Br.current)===null||Cs===void 0||Cs.removeEventListener(ws,mn)}))}))}}),[U,M,Tt,Bn,Xe,j,S,I,Pt,b,x]),l.useEffect((()=>{var N,R;let E=(R=(N=V?.anchorSelect)!==null&&N!==void 0?N:i)!==null&&R!==void 0?R:"";!E&&t&&(E=`[data-tooltip-id='${t.replace(/'/g,"\\'")}']`);const B=new MutationObserver((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(U){const we=[...ie.removedNodes].filter((W=>W.nodeType===1));if(E)try{Oe.push(...we.filter((W=>W.matches(E)))),Oe.push(...we.flatMap((W=>[...W.querySelectorAll(E)])))}catch{}we.some((W=>{var $t;return!!(!(($t=W?.contains)===null||$t===void 0)&&$t.call(W,U))&&(Je(!1),fe(!1),St(null),Ce(Se),Ce(ct),!0)}))}if(E)try{const we=[...ie.addedNodes].filter((W=>W.nodeType===1));Ie.push(...we.filter((W=>W.matches(E)))),Ie.push(...we.flatMap((W=>[...W.querySelectorAll(E)])))}catch{}}})),(Ie.length||Oe.length)&&rn((ie=>[...ie.filter((we=>!Oe.includes(we))),...Ie]))}));return B.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-tooltip-id"],attributeOldValue:!0}),()=>{B.disconnect()}}),[t,i,V?.anchorSelect,U]),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='${r}']`),E=[...Xe,R];U&&E.includes(U)||St((N=Xe[0])!==null&&N!==void 0?N:R)}),[r,Xe,U]),l.useEffect((()=>(ae&&fe(!0),()=>{Ce(Se),Ce(ct)})),[]),l.useEffect((()=>{var N;let R=(N=V?.anchorSelect)!==null&&N!==void 0?N:i;if(!R&&t&&(R=`[data-tooltip-id='${t.replace(/'/g,"\\'")}']`),R)try{const E=Array.from(document.querySelectorAll(R));rn(E)}catch{rn([])}}),[t,i,V?.anchorSelect]),l.useEffect((()=>{Se.current&&(Ce(Se),un(b))}),[b]);const xe=(lt=V?.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`)}Lt(N??null),N?.delay?un(N.delay):fe(!0)},close:N=>{N?.delay?It(N.delay):fe(!1)},activeAnchor:U,place:ut.place,isOpen:!!(Tt&&!y&&xe&&mt)}))),Tt&&!y&&xe?Ze.createElement(g,{id:t,role:ys,className:Hs("react-tooltip",Ut.tooltip,Ls.tooltip,Ls[a],n,`react-tooltip__place-${ut.place}`,Ut[mt?"show":"closing"],mt?"react-tooltip__show":"react-tooltip__closing",h==="fixed"&&Ut.fixed,w&&Ut.clickable),onTransitionEnd:N=>{Ce(Rt),me||N.propertyName!=="opacity"||(Je(!1),Lt(null),q?.())},style:{...se,...ut.tooltipStyles,opacity:Mn!==void 0&&mt?Mn:void 0},ref:he},xe,Ze.createElement(g,{className:Hs("react-tooltip-arrow",Ut.arrow,Ls.arrow,o,f&&Ut.noArrow),style:{...ut.tooltipArrowStyles,background:Dn?`linear-gradient(to right bottom, transparent 50%, ${Dn} 50%)`:void 0,"--rt-arrow-size":`${kt}px`},ref:Et})):null},bm=({content:e})=>Ze.createElement("span",{dangerouslySetInnerHTML:{__html:e}}),rs=Ze.forwardRef((({id:e,anchorId:t,anchorSelect:n,content:o,html:a,render:r,className:i,classNameArrow:c,variant:u="dark",place:d="top",offset:m=10,wrapper:h="div",children:p=null,events:g=["hover"],openOnClick:b=!1,positionStrategy:x="absolute",middlewares:v,delayShow:y=0,delayHide:f=0,float:w=!1,hidden:C=!1,noArrow:_=!1,clickable:k=!1,closeOnEsc:j=!1,closeOnScroll:S=!1,closeOnResize:I=!1,openEvents:F,closeEvents:se,globalCloseEvents:ye,imperativeModeOnly:Pe=!1,style:q,position:de,isOpen:oe,defaultIsOpen:J=!1,disableStyleInjection:H=!1,border:ae,opacity:We,arrowColor:nn,arrowSize:U,setIsOpen:St,afterShow:On,afterHide:Mn,disableTooltip:Dn,role:kt="tooltip"},ys)=>{const[lt,he]=l.useState(o),[Et,Se]=l.useState(a),[ct,Rt]=l.useState(d),[ut,$n]=l.useState(u),[me,sn]=l.useState(m),[Tt,Je]=l.useState(y),[V,Lt]=l.useState(f),[Fn,At]=l.useState(w),[Bn,on]=l.useState(C),[an,Xe]=l.useState(h),[rn,dt]=l.useState(g),[Pt,qn]=l.useState(x),[ln,ht]=l.useState(null),[ee,fe]=l.useState(null),cn=l.useRef(null),un=l.useRef(H),{anchorRefs:It,activeAnchor:dn}=br(e),Ot=G=>G?.getAttributeNames().reduce(((re,L)=>{var M;return L.startsWith("data-tooltip-")&&(re[L.replace(/^data-tooltip-/,"")]=(M=G?.getAttribute(L))!==null&&M!==void 0?M:null),re}),{}),Mt=G=>{const re={place:L=>{var M;Rt((M=L)!==null&&M!==void 0?M:d)},content:L=>{he(L??o)},html:L=>{Se(L??a)},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??g)},"position-strategy":L=>{var M;qn((M=L)!==null&&M!==void 0?M:x)},"delay-show":L=>{Je(L===null?y:Number(L))},"delay-hide":L=>{Lt(L===null?f:Number(L))},float:L=>{At(L===null?w:L==="true")},hidden:L=>{on(L===null?C:L==="true")},"class-name":L=>{ht(L)}};Object.values(re).forEach((L=>L(null))),Object.entries(G).forEach((([L,M])=>{var xe;(xe=re[L])===null||xe===void 0||xe.call(re,M)}))};l.useEffect((()=>{he(o)}),[o]),l.useEffect((()=>{Se(a)}),[a]),l.useEffect((()=>{Rt(d)}),[d]),l.useEffect((()=>{$n(u)}),[u]),l.useEffect((()=>{sn(m)}),[m]),l.useEffect((()=>{Je(y)}),[y]),l.useEffect((()=>{Lt(f)}),[f]),l.useEffect((()=>{At(w)}),[w]),l.useEffect((()=>{on(C)}),[C]),l.useEffect((()=>{qn(x)}),[x]),l.useEffect((()=>{un.current!==H&&console.warn("[react-tooltip] Do not change `disableStyleInjection` dynamically.")}),[H]),l.useEffect((()=>{typeof window<"u"&&window.dispatchEvent(new CustomEvent("react-tooltip-inject-styles",{detail:{disableCore:H==="core",disableBase:H}}))}),[]),l.useEffect((()=>{var G;const re=new Set(It);let L=n;if(!L&&e&&(L=`[data-tooltip-id='${e.replace(/'/g,"\\'")}']`),L)try{document.querySelectorAll(L).forEach((R=>{re.add({current:R})}))}catch{console.warn(`[react-tooltip] "${L}" is not a valid CSS selector`)}const M=document.querySelector(`[id='${t}']`);if(M&&re.add({current:M}),!re.size)return()=>null;const xe=(G=ee??M)!==null&&G!==void 0?G:dn.current,mt=new MutationObserver((R=>{R.forEach((E=>{var B;if(!xe||E.type!=="attributes"||!(!((B=E.attributeName)===null||B===void 0)&&B.startsWith("data-tooltip-")))return;const Z=Ot(xe);Mt(Z)}))})),N={attributes:!0,childList:!1,subtree:!1};if(xe){const R=Ot(xe);Mt(R),mt.observe(xe,N)}return()=>{mt.disconnect()}}),[It,dn,ee,t,n]),l.useEffect((()=>{q?.border&&console.warn("[react-tooltip] Do not set `style.border`. Use `border` prop instead."),ae&&!Jo("border",`${ae}`)&&console.warn(`[react-tooltip] "${ae}" is not a valid \`border\`.`),q?.opacity&&console.warn("[react-tooltip] Do not set `style.opacity`. Use `opacity` prop instead."),We&&!Jo("opacity",`${We}`)&&console.warn(`[react-tooltip] "${We}" is not a valid \`opacity\`.`)}),[]);let Dt=p;const hn=l.useRef(null);if(r){const G=r({content:ee?.getAttribute("data-tooltip-content")||lt||null,activeAnchor:ee});Dt=G?Ze.createElement("div",{ref:hn,className:"react-tooltip-content-wrapper"},G):null}else lt&&(Dt=lt);Et&&(Dt=Ze.createElement(bm,{content:Et}));const Un={forwardRef:ys,id:e,anchorId:t,anchorSelect:n,className:Hs(i,ln),classNameArrow:c,content:Dt,contentWrapperRef:hn,place:ct,variant:ut,offset:me,wrapper:an,events:rn,openOnClick:b,positionStrategy:Pt,middlewares:v,delayShow:Tt,delayHide:V,float:Fn,hidden:Bn,noArrow:_,clickable:k,closeOnEsc:j,closeOnScroll:S,closeOnResize:I,openEvents:F,closeEvents:se,globalCloseEvents:ye,imperativeModeOnly:Pe,style:q,position:de,isOpen:oe,defaultIsOpen:J,border:ae,opacity:We,arrowColor:nn,arrowSize:U,setIsOpen:St,afterShow:On,afterHide:Mn,disableTooltip:Dn,activeAnchor:ee,previousActiveAnchor:cn.current,setActiveAnchor:G=>{fe((re=>(G?.isSameNode(re)||(cn.current=re),G)))},role:kt};return Ze.createElement(xm,{...Un})}));typeof window<"u"&&window.addEventListener("react-tooltip-inject-styles",(e=>{e.detail.disableCore||Go({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||Go({css:`
|
|
3
|
+
Please change the parent <Route path="${f}"> to <Route path="${f==="/"?"*":`${f}/*`}">.`)}let p=le(),g;if(t){let f=typeof t=="string"?Gt(t):t;z(m==="/"||f.pathname?.startsWith(m),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${m}" but pathname "${f.pathname}" was given in the \`location\` prop.`),g=f}else g=p;let b=g.pathname||"/",x=b;if(m!=="/"){let f=m.replace(/^\//,"").split("/");x="/"+b.replace(/^\//,"").split("/").slice(f.length).join("/")}let v=ua(e,{pathname:x});je(h||v!=null,`No routes matched location "${g.pathname}${g.search}${g.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 "${g.pathname}${g.search}${g.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let y=Ui(v&&v.map(f=>Object.assign({},f,{params:Object.assign({},u,f.params),pathname:Qe([m,r.encodeLocation?r.encodeLocation(f.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:f.pathname]),pathnameBase:f.pathnameBase==="/"?m:Qe([m,r.encodeLocation?r.encodeLocation(f.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:f.pathnameBase])})),i,n,o,a);return t&&y?l.createElement(Nn.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...g},navigationType:"POP"}},y):y}function $i(){let e=Qi(),t=Ni(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)",a={padding:"0.5rem",backgroundColor:o},r={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:r},"ErrorBoundary")," or"," ",l.createElement("code",{style:r},"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:a},n):null,i)}var Fi=l.createElement($i,null),Na=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=Pi(e.digest);n&&(e=n)}let t=e!==void 0?l.createElement(Be.Provider,{value:this.props.routeContext},l.createElement(Ks.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?l.createElement(Bi,{error:e},t):t}};Na.contextType=ki;var Ns=new WeakMap;function Bi({children:e,error:t}){let{basename:n}=l.useContext(Ne);if(typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){let o=Ai(t.digest);if(o){let a=Ns.get(t);if(a)throw a;let r=xa(o.location,n);if(ga&&!Ns.get(t))if(r.isExternal||o.reloadDocument)window.location.href=r.absoluteURL||r.to;else{const i=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(r.to,{replace:o.replace}));throw Ns.set(t,i),i}return l.createElement("meta",{httpEquiv:"refresh",content:`0;url=${r.absoluteURL||r.to}`})}}return e}function qi({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 Ui(e,t=[],n=null,o=null,a=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 r=e,i=n?.errors;if(i!=null){let m=r.findIndex(h=>h.route.id&&i?.[h.route.id]!==void 0);z(m>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(i).join(",")}`),r=r.slice(0,Math.min(r.length,m+1))}let c=!1,u=-1;if(n)for(let m=0;m<r.length;m++){let h=r[m];if((h.route.HydrateFallback||h.route.hydrateFallbackElement)&&(u=m),h.route.id){let{loaderData:p,errors:g}=n,b=h.route.loader&&!p.hasOwnProperty(h.route.id)&&(!g||g[h.route.id]===void 0);if(h.route.lazy||b){c=!0,u>=0?r=r.slice(0,u+1):r=[r[0]];break}}}let d=n&&o?(m,h)=>{o(m,{location:n.location,params:n.matches?.[0]?.params??{},unstable_pattern:_i(n.matches),errorInfo:h})}:void 0;return r.reduceRight((m,h,p)=>{let g,b=!1,x=null,v=null;n&&(g=i&&h.route.id?i[h.route.id]:void 0,x=h.route.errorElement||Fi,c&&(u<0&&p===0?(_a("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),b=!0,v=null):u===p&&(b=!0,v=h.route.hydrateFallbackElement||null)));let y=t.concat(r.slice(0,p+1)),f=()=>{let w;return g?w=x:b?w=v:h.route.Component?w=l.createElement(h.route.Component,null):h.route.element?w=h.route.element:w=m,l.createElement(qi,{match:h,routeContext:{outlet:m,matches:y,isDataRoute:n!=null},children:w})};return n&&(h.route.ErrorBoundary||h.route.errorElement||p===0)?l.createElement(Na,{location:n.location,revalidation:n.revalidation,component:x,error:g,children:f(),routeContext:{outlet:null,matches:y,isDataRoute:!0},onError:d}):f()},null)}function Gs(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Wi(e){let t=l.useContext(Yt);return z(t,Gs(e)),t}function Hi(e){let t=l.useContext(ls);return z(t,Gs(e)),t}function zi(e){let t=l.useContext(Be);return z(t,Gs(e)),t}function Ys(e){let t=zi(e),n=t.matches[t.matches.length-1];return z(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function Vi(){return Ys("useRouteId")}function Qi(){let e=l.useContext(Ks),t=Hi("useRouteError"),n=Ys("useRouteError");return e!==void 0?e:t.errors?.[n]}function Ki(){let{router:e}=Wi("useNavigate"),t=Ys("useNavigate"),n=l.useRef(!1);return Ca(()=>{n.current=!0}),l.useCallback(async(a,r={})=>{je(n.current,wa),n.current&&(typeof a=="number"?await e.navigate(a):await e.navigate(a,{fromRouteId:t,...r}))},[e,t])}var Lo={};function _a(e,t,n){!t&&!Lo[e]&&(Lo[e]=!0,je(!1,n))}l.memo(Gi);function Gi({routes:e,future:t,state:n,onError:o}){return ja(e,void 0,n,o,t)}function vt(e){z(!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 Yi({basename:e="/",children:t=null,location:n,navigationType:o="POP",navigator:a,static:r=!1,unstable_useTransitions:i}){z(!_n(),"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:a,static:r,unstable_useTransitions:i,future:{}}),[c,a,r,i]);typeof n=="string"&&(n=Gt(n));let{pathname:d="/",search:m="",hash:h="",state:p=null,key:g="default"}=n,b=l.useMemo(()=>{let x=Ye(d,c);return x==null?null:{location:{pathname:x,search:m,hash:h,state:p,key:g},navigationType:o}},[c,d,m,h,p,g,o]);return je(b!=null,`<Router basename="${c}"> is not able to match the URL "${d}${m}${h}" because it does not start with the basename, so the <Router> won't render anything.`),b==null?null:l.createElement(Ne.Provider,{value:u},l.createElement(Nn.Provider,{children:t,value:b}))}function Ji({children:e,location:t}){return Di($s(e),t)}function $s(e,t=[]){let n=[];return l.Children.forEach(e,(o,a)=>{if(!l.isValidElement(o))return;let r=[...t,a];if(o.type===l.Fragment){n.push.apply(n,$s(o.props.children,r));return}z(o.type===vt,`[${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>`),z(!o.props.index||!o.props.children,"An index route cannot have child routes.");let i={id:o.props.id||r.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=$s(o.props.children,r)),n.push(i)}),n}var Kn="get",Gn="application/x-www-form-urlencoded";function cs(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function Xi(e){return cs(e)&&e.tagName.toLowerCase()==="button"}function Zi(e){return cs(e)&&e.tagName.toLowerCase()==="form"}function el(e){return cs(e)&&e.tagName.toLowerCase()==="input"}function tl(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function nl(e,t){return e.button===0&&(!t||t==="_self")&&!tl(e)}function Fs(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(a=>[n,a]):[[n,o]])},[]))}function sl(e,t){let n=Fs(e);return t&&t.forEach((o,a)=>{n.has(a)||t.getAll(a).forEach(r=>{n.append(a,r)})}),n}var Hn=null;function ol(){if(Hn===null)try{new FormData(document.createElement("form"),0),Hn=!1}catch{Hn=!0}return Hn}var al=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function _s(e){return e!=null&&!al.has(e)?(je(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Gn}"`),null):e}function rl(e,t){let n,o,a,r,i;if(Zi(e)){let c=e.getAttribute("action");o=c?Ye(c,t):null,n=e.getAttribute("method")||Kn,a=_s(e.getAttribute("enctype"))||Gn,r=new FormData(e)}else if(Xi(e)||el(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")||Kn,a=_s(e.getAttribute("formenctype"))||_s(c.getAttribute("enctype"))||Gn,r=new FormData(c,e),!ol()){let{name:d,type:m,value:h}=e;if(m==="image"){let p=d?`${d}.`:"";r.append(`${p}x`,"0"),r.append(`${p}y`,"0")}else d&&r.append(d,h)}}else{if(cs(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=Kn,o=null,a=Gn,i=e}return r&&a==="text/plain"&&(i=r,r=void 0),{action:o,method:n.toLowerCase(),encType:a,formData:r,body:i}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function Js(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function il(e,t,n,o){let a=typeof e=="string"?new URL(e,typeof window>"u"?"server://singlefetch/":window.location.origin):e;return n?a.pathname.endsWith("/")?a.pathname=`${a.pathname}_.${o}`:a.pathname=`${a.pathname}.${o}`:a.pathname==="/"?a.pathname=`_root.${o}`:t&&Ye(a.pathname,t)==="/"?a.pathname=`${t.replace(/\/$/,"")}/_root.${o}`:a.pathname=`${a.pathname.replace(/\/$/,"")}.${o}`,a}async function ll(e,t){if(e.id in t)return t[e.id];try{let n=await import(e.module);return t[e.id]=n,n}catch(n){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(n),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function cl(e){return e==null?!1:e.href==null?e.rel==="preload"&&typeof e.imageSrcSet=="string"&&typeof e.imageSizes=="string":typeof e.rel=="string"&&typeof e.href=="string"}async function ul(e,t,n){let o=await Promise.all(e.map(async a=>{let r=t.routes[a.route.id];if(r){let i=await ll(r,n);return i.links?i.links():[]}return[]}));return fl(o.flat(1).filter(cl).filter(a=>a.rel==="stylesheet"||a.rel==="preload").map(a=>a.rel==="stylesheet"?{...a,rel:"prefetch",as:"style"}:{...a,rel:"prefetch"}))}function Ao(e,t,n,o,a,r){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 r==="assets"?t.filter((u,d)=>i(u,d)||c(u,d)):r==="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(a.pathname+a.search+a.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 dl(e,t,{includeHydrateFallback:n}={}){return hl(e.map(o=>{let a=t.routes[o.route.id];if(!a)return[];let r=[a.module];return a.clientActionModule&&(r=r.concat(a.clientActionModule)),a.clientLoaderModule&&(r=r.concat(a.clientLoaderModule)),n&&a.hydrateFallbackModule&&(r=r.concat(a.hydrateFallbackModule)),a.imports&&(r=r.concat(a.imports)),r}).flat(1))}function hl(e){return[...new Set(e)]}function ml(e){let t={},n=Object.keys(e).sort();for(let o of n)t[o]=e[o];return t}function fl(e,t){let n=new Set;return new Set(t),e.reduce((o,a)=>{let r=JSON.stringify(ml(a));return n.has(r)||(n.add(r),o.push({key:r,link:a})),o},[])}function Sa(){let e=l.useContext(Yt);return Js(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function pl(){let e=l.useContext(ls);return Js(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var Xs=l.createContext(void 0);Xs.displayName="FrameworkContext";function ka(){let e=l.useContext(Xs);return Js(e,"You must render this element inside a <HydratedRouter> element"),e}function gl(e,t){let n=l.useContext(Xs),[o,a]=l.useState(!1),[r,i]=l.useState(!1),{onFocus:c,onBlur:u,onMouseEnter:d,onMouseLeave:m,onTouchStart:h}=t,p=l.useRef(null);l.useEffect(()=>{if(e==="render"&&i(!0),e==="viewport"){let x=y=>{y.forEach(f=>{i(f.isIntersecting)})},v=new IntersectionObserver(x,{threshold:.5});return p.current&&v.observe(p.current),()=>{v.disconnect()}}},[e]),l.useEffect(()=>{if(o){let x=setTimeout(()=>{i(!0)},100);return()=>{clearTimeout(x)}}},[o]);let g=()=>{a(!0)},b=()=>{a(!1),i(!1)};return n?e!=="intent"?[r,p,{}]:[r,p,{onFocus:fn(c,g),onBlur:fn(u,b),onMouseEnter:fn(d,g),onMouseLeave:fn(m,b),onTouchStart:fn(h,g)}]:[!1,p,{}]}function fn(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function xl({page:e,...t}){let{router:n}=Sa(),o=l.useMemo(()=>ua(n.routes,e,n.basename),[n.routes,e,n.basename]);return o?l.createElement(vl,{page:e,matches:o,...t}):null}function bl(e){let{manifest:t,routeModules:n}=ka(),[o,a]=l.useState([]);return l.useEffect(()=>{let r=!1;return ul(e,t,n).then(i=>{r||a(i)}),()=>{r=!0}},[e,t,n]),o}function vl({page:e,matches:t,...n}){let o=le(),{future:a,manifest:r,routeModules:i}=ka(),{basename:c}=Sa(),{loaderData:u,matches:d}=pl(),m=l.useMemo(()=>Ao(e,t,d,r,o,"data"),[e,t,d,r,o]),h=l.useMemo(()=>Ao(e,t,d,r,o,"assets"),[e,t,d,r,o]),p=l.useMemo(()=>{if(e===o.pathname+o.search+o.hash)return[];let x=new Set,v=!1;if(t.forEach(f=>{let w=r.routes[f.route.id];!w||!w.hasLoader||(!m.some(C=>C.route.id===f.route.id)&&f.route.id in u&&i[f.route.id]?.shouldRevalidate||w.hasClientLoader?v=!0:x.add(f.route.id))}),x.size===0)return[];let y=il(e,c,a.unstable_trailingSlashAwareDataRequests,"data");return v&&x.size>0&&y.searchParams.set("_routes",t.filter(f=>x.has(f.route.id)).map(f=>f.route.id).join(",")),[y.pathname+y.search]},[c,a.unstable_trailingSlashAwareDataRequests,u,o,r,m,t,e,i]),g=l.useMemo(()=>dl(h,r),[h,r]),b=bl(h);return l.createElement(l.Fragment,null,p.map(x=>l.createElement("link",{key:x,rel:"prefetch",as:"fetch",href:x,...n})),g.map(x=>l.createElement("link",{key:x,rel:"modulepreload",href:x,...n})),b.map(({key:x,link:v})=>l.createElement("link",{key:x,nonce:n.nonce,...v})))}function yl(...e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}var wl=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{wl&&(window.__reactRouterVersion="7.12.0")}catch{}function Cl({basename:e,children:t,unstable_useTransitions:n,window:o}){let a=l.useRef();a.current==null&&(a.current=ei({window:o,v5Compat:!0}));let r=a.current,[i,c]=l.useState({action:r.action,location:r.location}),u=l.useCallback(d=>{n===!1?c(d):l.startTransition(()=>c(d))},[n]);return l.useLayoutEffect(()=>r.listen(u),[r,u]),l.createElement(Yi,{basename:e,children:t,location:i.location,navigationType:i.action,navigator:r,unstable_useTransitions:n})}var Ea=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Ra=l.forwardRef(function({onClick:t,discover:n="render",prefetch:o="none",relative:a,reloadDocument:r,replace:i,state:c,target:u,to:d,preventScrollReset:m,viewTransition:h,unstable_defaultShouldRevalidate:p,...g},b){let{basename:x,unstable_useTransitions:v}=l.useContext(Ne),y=typeof d=="string"&&Ea.test(d),f=xa(d,x);d=f.to;let w=Ii(d,{relative:a}),[C,_,k]=gl(o,g),j=Sl(d,{replace:i,state:c,target:u,preventScrollReset:m,relative:a,viewTransition:h,unstable_defaultShouldRevalidate:p,unstable_useTransitions:v});function S(F){t&&t(F),F.defaultPrevented||j(F)}let I=l.createElement("a",{...g,...k,href:f.absoluteURL||w,onClick:f.isExternal||r?t:S,ref:yl(b,_),target:u,"data-discover":!y&&n==="render"?"true":void 0});return C&&!y?l.createElement(l.Fragment,null,I,l.createElement(xl,{page:w})):I});Ra.displayName="Link";var jl=l.forwardRef(function({"aria-current":t="page",caseSensitive:n=!1,className:o="",end:a=!1,style:r,to:i,viewTransition:c,children:u,...d},m){let h=Sn(i,{relative:d.relative}),p=le(),g=l.useContext(ls),{navigator:b,basename:x}=l.useContext(Ne),v=g!=null&&Al(h)&&c===!0,y=b.encodeLocation?b.encodeLocation(h).pathname:h.pathname,f=p.pathname,w=g&&g.navigation&&g.navigation.location?g.navigation.location.pathname:null;n||(f=f.toLowerCase(),w=w?w.toLowerCase():null,y=y.toLowerCase()),w&&x&&(w=Ye(w,x)||w);const C=y!=="/"&&y.endsWith("/")?y.length-1:y.length;let _=f===y||!a&&f.startsWith(y)&&f.charAt(C)==="/",k=w!=null&&(w===y||!a&&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 F=typeof r=="function"?r(j):r;return l.createElement(Ra,{...d,"aria-current":S,className:I,ref:m,style:F,to:i,viewTransition:c},typeof u=="function"?u(j):u)});jl.displayName="NavLink";var Nl=l.forwardRef(({discover:e="render",fetcherKey:t,navigate:n,reloadDocument:o,replace:a,state:r,method:i=Kn,action:c,onSubmit:u,relative:d,preventScrollReset:m,viewTransition:h,unstable_defaultShouldRevalidate:p,...g},b)=>{let{unstable_useTransitions:x}=l.useContext(Ne),v=Tl(),y=Ll(c,{relative:d}),f=i.toLowerCase()==="get"?"get":"post",w=typeof c=="string"&&Ea.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:a,state:r,relative:d,preventScrollReset:m,viewTransition:h,unstable_defaultShouldRevalidate:p});x&&n!==!1?l.startTransition(()=>S()):S()};return l.createElement("form",{ref:b,method:f,action:y,onSubmit:o?u:C,...g,"data-discover":!w&&e==="render"?"true":void 0})});Nl.displayName="Form";function _l(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Ta(e){let t=l.useContext(Yt);return z(t,_l(e)),t}function Sl(e,{target:t,replace:n,state:o,preventScrollReset:a,relative:r,viewTransition:i,unstable_defaultShouldRevalidate:c,unstable_useTransitions:u}={}){let d=Y(),m=le(),h=Sn(e,{relative:r});return l.useCallback(p=>{if(nl(p,t)){p.preventDefault();let g=n!==void 0?n:yn(m)===yn(h),b=()=>d(e,{replace:g,state:o,preventScrollReset:a,relative:r,viewTransition:i,unstable_defaultShouldRevalidate:c});u?l.startTransition(()=>b()):b()}},[m,d,h,n,o,t,e,a,r,i,c,u])}function kl(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(Fs(e)),n=l.useRef(!1),o=le(),a=l.useMemo(()=>sl(o.search,n.current?null:t.current),[o.search]),r=Y(),i=l.useCallback((c,u)=>{const d=Fs(typeof c=="function"?c(new URLSearchParams(a)):c);n.current=!0,r("?"+d,u)},[r,a]);return[a,i]}var El=0,Rl=()=>`__${String(++El)}__`;function Tl(){let{router:e}=Ta("useSubmit"),{basename:t}=l.useContext(Ne),n=Vi(),o=e.fetch,a=e.navigate;return l.useCallback(async(r,i={})=>{let{action:c,method:u,encType:d,formData:m,body:h}=rl(r,t);if(i.navigate===!1){let p=i.fetcherKey||Rl();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 a(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,a,t,n])}function Ll(e,{relative:t}={}){let{basename:n}=l.useContext(Ne),o=l.useContext(Be);z(o,"useFormAction must be used inside a RouteContext");let[a]=o.matches.slice(-1),r={...Sn(e||".",{relative:t})},i=le();if(e==null){r.search=i.search;let c=new URLSearchParams(r.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();r.search=m?`?${m}`:""}}return(!e||e===".")&&a.route.index&&(r.search=r.search?r.search.replace(/^\?/,"?index&"):"?index"),n!=="/"&&(r.pathname=r.pathname==="/"?n:Qe([n,r.pathname])),yn(r)}function Al(e,{relative:t}={}){let n=l.useContext(va);z(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:o}=Ta("useViewTransitionState"),a=Sn(e,{relative:t});if(!n.isTransitioning)return!1;let r=Ye(n.currentLocation.pathname,o)||n.currentLocation.pathname,i=Ye(n.nextLocation.pathname,o)||n.nextLocation.pathname;return zt(a.pathname,i)!=null||zt(a.pathname,r)!=null}var La=qr(),Aa=class extends ca{constructor(e,t){super(),this.options=t,this.#n=e,this.#i=null,this.#r=Co(),this.bindMethods(),this.setOptions(t)}#n;#e=void 0;#s=void 0;#t=void 0;#o;#a;#r;#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),Po(this.#e,this.options)?this.#d():this.updateResult(),this.#v())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Bs(this.#e,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Bs(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&&!es(this.options,t)&&this.#n.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#e,observer:this});const o=this.hasListeners();o&&Io(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)||bn(this.options.staleTime,this.#e)!==bn(t.staleTime,this.#e))&&this.#g();const a=this.#x();o&&(this.#e!==n||ke(this.options.enabled,this.#e)!==ke(t.enabled,this.#e)||a!==this.#l)&&this.#b(a)}getOptimisticResult(e){const t=this.#n.getQueryCache().build(this.#n,e),n=this.createResult(t,e);return Il(this,n)&&(this.#t=n,this.#a=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.#r.status==="pending"&&this.#r.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(ts)),t}#g(){this.#y();const e=bn(this.options.staleTime,this.#e);if(Ms||this.#t.isStale||!jo(e))return;const n=Ur(this.#t.dataUpdatedAt,e)+1;this.#c=Wn.setTimeout(()=>{this.#t.isStale||this.updateResult()},n)}#x(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#e):this.options.refetchInterval)??!1}#b(e){this.#w(),this.#l=e,!(Ms||ke(this.options.enabled,this.#e)===!1||!jo(this.#l)||this.#l===0)&&(this.#u=Wn.setInterval(()=>{(this.options.refetchIntervalInBackground||Wr.isFocused())&&this.#d()},this.#l))}#v(){this.#g(),this.#b(this.#x())}#y(){this.#c&&(Wn.clearTimeout(this.#c),this.#c=void 0)}#w(){this.#u&&(Wn.clearInterval(this.#u),this.#u=void 0)}createResult(e,t){const n=this.#e,o=this.options,a=this.#t,r=this.#o,i=this.#a,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&&Po(e,t),F=S&&Io(e,n,t,o);(I||F)&&(m={...m,...Hr(d.data,e.options)}),t._optimisticResults==="isRestoring"&&(m.fetchStatus="idle")}let{error:g,errorUpdatedAt:b,status:x}=m;p=m.data;let v=!1;if(t.placeholderData!==void 0&&p===void 0&&x==="pending"){let S;a?.isPlaceholderData&&t.placeholderData===i?.placeholderData?(S=a.data,v=!0):S=typeof t.placeholderData=="function"?t.placeholderData(this.#m?.state.data,this.#m):t.placeholderData,S!==void 0&&(x="success",p=No(a?.data,S,t),h=!0)}if(t.select&&p!==void 0&&!v)if(a&&p===r?.data&&t.select===this.#p)p=this.#h;else try{this.#p=t.select,p=t.select(p),p=No(a?.data,p,t),this.#h=p,this.#i=null}catch(S){this.#i=S}this.#i&&(g=this.#i,p=this.#h,b=Date.now(),x="error");const y=m.fetchStatus==="fetching",f=x==="pending",w=x==="error",C=f&&y,_=p!==void 0,j={status:x,fetchStatus:m.fetchStatus,isPending:f,isSuccess:x==="success",isError:w,isInitialLoading:C,isLoading:C,data:p,dataUpdatedAt:m.dataUpdatedAt,error:g,errorUpdatedAt:b,failureCount:m.fetchFailureCount,failureReason:m.fetchFailureReason,errorUpdateCount:m.errorUpdateCount,isFetched:m.dataUpdateCount>0||m.errorUpdateCount>0,isFetchedAfterMount:m.dataUpdateCount>u.dataUpdateCount||m.errorUpdateCount>u.errorUpdateCount,isFetching:y,isRefetching:y&&!f,isLoadingError:w&&!_,isPaused:m.fetchStatus==="paused",isPlaceholderData:h,isRefetchError:w&&_,isStale:Zs(e,t),refetch:this.refetch,promise:this.#r,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.#r=j.promise=Co();S(se)},F=this.#r;switch(F.status){case"pending":e.queryHash===n.queryHash&&S(F);break;case"fulfilled":(j.status==="error"||j.data!==F.value)&&I();break;case"rejected":(j.status!=="error"||j.error!==F.reason)&&I();break}}return j}updateResult(){const e=this.#t,t=this.createResult(this.#e,this.options);if(this.#o=this.#e.state,this.#a=this.options,this.#o.data!==void 0&&(this.#m=this.#e),es(t,e))return;this.#t=t;const n=()=>{if(!e)return!0;const{notifyOnChangeProps:o}=this.options,a=typeof o=="function"?o():o;if(a==="all"||!a&&!this.#f.size)return!0;const r=new Set(a??this.#f);return this.options.throwOnError&&r.add("error"),Object.keys(this.#t).some(i=>{const c=i;return this.#t[c]!==e[c]&&r.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){is.batch(()=>{e.listeners&&this.listeners.forEach(t=>{t(this.#t)}),this.#n.getQueryCache().notify({query:this.#e,type:"observerResultsUpdated"})})}};function Pl(e,t){return ke(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function Po(e,t){return Pl(e,t)||e.state.data!==void 0&&Bs(e,t,t.refetchOnMount)}function Bs(e,t,n){if(ke(t.enabled,e)!==!1&&bn(t.staleTime,e)!=="static"){const o=typeof n=="function"?n(e):n;return o==="always"||o!==!1&&Zs(e,t)}return!1}function Io(e,t,n,o){return(e!==t||ke(o.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&Zs(e,n)}function Zs(e,t){return ke(t.enabled,e)!==!1&&e.isStaleByTime(bn(t.staleTime,e))}function Il(e,t){return!es(e.getCurrentResult(),t)}var Ol=class extends Aa{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:_o()})}getOptimisticResult(e){return e.behavior=_o(),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:a,isRefetching:r,isError:i,isRefetchError:c}=o,u=n.fetchMeta?.fetchMore?.direction,d=i&&u==="forward",m=a&&u==="forward",h=i&&u==="backward",p=a&&u==="backward";return{...o,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:Vr(t,n.data),hasPreviousPage:zr(t,n.data),isFetchNextPageError:d,isFetchingNextPage:m,isFetchPreviousPageError:h,isFetchingPreviousPage:p,isRefetchError:c&&!d&&!h,isRefetching:r&&!m&&!p}}},Ml=class extends ca{#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),es(this.options,n)||this.#n.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#s,observer:this}),n?.mutationKey&&this.options.mutationKey&&So(n.mutationKey)!==So(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.#a(t)}getCurrentResult(){return this.#e}reset(){this.#s?.removeObserver(this),this.#s=void 0,this.#o(),this.#a()}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??Qr();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}}#a(t){is.batch(()=>{if(this.#t&&this.hasListeners()){const n=this.#e.variables,o=this.#e.context,a={client:this.#n,meta:this.options.meta,mutationKey:this.options.mutationKey};if(t?.type==="success"){try{this.#t.onSuccess?.(t.data,n,o,a)}catch(r){Promise.reject(r)}try{this.#t.onSettled?.(t.data,null,n,o,a)}catch(r){Promise.reject(r)}}else if(t?.type==="error"){try{this.#t.onError?.(t.error,n,o,a)}catch(r){Promise.reject(r)}try{this.#t.onSettled?.(void 0,t.error,n,o,a)}catch(r){Promise.reject(r)}}}this.listeners.forEach(n=>{n(this.#e)})})}},Pa=l.createContext(void 0),Ia=e=>{const t=l.useContext(Pa);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},Dl=({client:e,children:t})=>(l.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),s.jsx(Pa.Provider,{value:e,children:t})),Oa=l.createContext(!1),$l=()=>l.useContext(Oa);Oa.Provider;function Fl(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var Bl=l.createContext(Fl()),ql=()=>l.useContext(Bl),Ul=(e,t,n)=>{const o=n?.state.error&&typeof e.throwOnError=="function"?Vs(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||o)&&(t.isReset()||(e.retryOnMount=!1))},Wl=e=>{l.useEffect(()=>{e.clearReset()},[e])},Hl=({result:e,errorResetBoundary:t,throwOnError:n,query:o,suspense:a})=>e.isError&&!t.isReset()&&!e.isFetching&&o&&(a&&e.data===void 0||Vs(n,[e.error,o])),zl=e=>{if(e.suspense){const n=a=>a==="static"?a:Math.max(a??1e3,1e3),o=e.staleTime;e.staleTime=typeof o=="function"?(...a)=>n(o(...a)):n(o),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},Vl=(e,t)=>e.isLoading&&e.isFetching&&!t,Ql=(e,t)=>e?.suspense&&t.isPending,Oo=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function Ma(e,t,n){const o=$l(),a=ql(),r=Ia(),i=r.defaultQueryOptions(e);r.getDefaultOptions().queries?._experimental_beforeQuery?.(i);const c=r.getQueryCache().get(i.queryHash);i._optimisticResults=o?"isRestoring":"optimistic",zl(i),Ul(i,a,c),Wl(a);const u=!r.getQueryCache().get(i.queryHash),[d]=l.useState(()=>new t(r,i)),m=d.getOptimisticResult(i),h=!o&&e.subscribed!==!1;if(l.useSyncExternalStore(l.useCallback(p=>{const g=h?d.subscribe(is.batchCalls(p)):ts;return d.updateResult(),g},[d,h]),()=>d.getCurrentResult(),()=>d.getCurrentResult()),l.useEffect(()=>{d.setOptions(i)},[i,d]),Ql(i,m))throw Oo(i,d,a);if(Hl({result:m,errorResetBoundary:a,throwOnError:i.throwOnError,query:c,suspense:i.suspense}))throw m.error;return r.getDefaultOptions().queries?._experimental_afterQuery?.(i,m),i.experimental_prefetchInRender&&!Ms&&Vl(m,o)&&(u?Oo(i,d,a):c?.promise)?.catch(ts).finally(()=>{d.updateResult()}),i.notifyOnChangeProps?m:d.trackResult(m)}function ce(e,t){return Ma(e,Aa)}function X(e,t){const n=Ia(),[o]=l.useState(()=>new Ml(n,e));l.useEffect(()=>{o.setOptions(e)},[o,e]);const a=l.useSyncExternalStore(l.useCallback(i=>o.subscribe(is.batchCalls(i)),[o]),()=>o.getCurrentResult(),()=>o.getCurrentResult()),r=l.useCallback((i,c)=>{o.mutate(i,c).catch(ts)},[o]);if(a.error&&Vs(o.options.throwOnError,[a.error]))throw a.error;return{...a,mutate:r,mutateAsync:a.mutate}}function Da(e,t){return Ma(e,Ol)}const at="data-sources",$a="auth-user",Kl=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})])},Gl=e=>{const t=["trash","team"];return K.invalidateQueries({queryKey:t})},Yl=(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}),Jl=(e,t=30,n)=>Da({queryKey:["project","tabs-history",e,t,n],queryFn:async({pageParam:o})=>{const{data:r}=await O.get(`/project/team/${e}/tabs-history?page=${o}&size=${t}`);return r},select:({pages:o})=>o.flatMap(a=>a.data),enabled:!!e,initialPageParam:0,getNextPageParam:(o,a)=>{if(o.hasMore)return a.length},staleTime:0}),Xl=(e,t="",n=20)=>Da({queryKey:["project","saved-queries",e,t,n],queryFn:async({pageParam:o})=>{const a=new URLSearchParams;a.set("nameFilter",t),a.set("size",n.toString()),a.set("page",o.toString());const{data:r}=await O.get(`/project/team/${e}/queries?${a.toString()}`);return r},enabled:!!e,initialPageParam:0,select:({pages:o})=>o.flatMap(a=>a.data),getNextPageParam:(o,a)=>{if(o.hasMore)return a.length}}),Zl=(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}),ec=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}}),tc=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}}),nc=()=>Promise.all([K.invalidateQueries({queryKey:["project","tabs-history"]}),K.invalidateQueries({queryKey:["project","recent-tabs"]})]),Fa=()=>K.invalidateQueries({queryKey:["project","count-saved-queries"]}),sc=(e,t)=>{},oc=()=>{},ac={event:sc,pageView:oc},us=e=>ce({queryKey:[at,e],queryFn:async()=>{const{data:t}=await O.get("/data-sources/"+e);return t.data},enabled:!!e}),eo=e=>ce({queryKey:[at,e.teamId],queryFn:async()=>{const{data:t}=await O.get("/data-sources",{params:e});return t.data},enabled:e.teamId!==void 0}),kn=e=>ce({queryKey:[at,e,"inspections"],queryFn:async()=>{const{data:t}=await O.get(`/data-sources/${e}/inspections`);return t.data},enabled:!!e}),rc=()=>X({mutationFn:async e=>{const{data:t}=await O.post("/data-sources",e);return t.data},onSuccess:()=>{K.invalidateQueries({queryKey:[at]}),Jt()},onError:()=>{}}),ic=()=>X({mutationFn:async({dataSource:e,id:t})=>{const{data:n}=await O.put(`/data-sources/${t}`,e);return n.data},onSuccess:()=>{K.invalidateQueries({queryKey:[at]}),Jt()}}),Ba=()=>X({mutationFn:async e=>{await O.post(`/data-sources/${e}/inspect`)},onSuccess:()=>{K.invalidateQueries({queryKey:[at]})}}),lc=()=>X({mutationFn:async e=>{await O.delete(`/data-sources/${e}`)},onSuccess:()=>{K.invalidateQueries({queryKey:[at]}),Jt()}}),qa=()=>ce({queryKey:["accessToken"],queryFn:Qs.get}),ue=()=>{const{data:e}=qa();return ce({queryKey:[$a],queryFn:async()=>{const{data:t}=await O.get("/users");return t.data},enabled:!!e,retry:(t,n)=>Kr(n)&&n.code==="ERR_NETWORK"?!1:t<3})},cc=()=>X({mutationFn:async e=>{const{data:t}=await O.patch("/users",e);return t.data},onSuccess:async e=>{K.setQueryData([$a],e)}}),uc=()=>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)),a=c=>(t.forEach(u=>u(c)),!0),r=c=>{n=typeof c=="function"?c(n):c,a(n)},i=c=>()=>c?c(n):n;return[c=>l.useSyncExternalStore(o,i(c),i(c)),r,{get:()=>n,subscribe:c=>(c(n),o(c))}]};function dc(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 hc=e=>ce({queryKey:["hooks",e],queryFn:async()=>{const t=await K.fetchQuery({queryKey:[at,e,"inspections"],queryFn:async()=>{const{data:n}=await O.get(`/data-sources/${e}/inspections`);return n.data}});return dc(t)},enabled:!!e}),Ua=[{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"}],mc=Ua.reduce((e,t)=>(e[t.value]=t.label,e),{});Ua.reduce((e,t)=>(e[t.label]=t.value,e),{});const Xt=e=>e.map(t=>({label:mc[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 fc=["char","varchar","binary","varbinary","blob","text","enum","set","character","character varying","text","citext","uuid","xml","json","jsonb"];new Set(fc);const pc=["integer","smallint","decimal","numeric","float","real","double precision","int","smallint","integer","bigint","decimal","numeric","real","double precision","serial","bigserial","money"];new Set(pc);const gc=["date","datetime","timestamp","timestamptz"].reduce((e,t)=>(e[t]=!0,e),{}),Wa=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 Mo={[pe.READ_ONLY]:10,[pe.EDITOR]:20,[pe.ADMIN]:30,[pe.OWNER]:40};function xc(e,t){if(!e||!t)return{};const n=new Set;for(const a of t)a.table&&n.add(a.table);const o={};for(const a of n){const r=e.find(i=>i.tableName===a);if(r){o[a]=[];const i=r.columns.filter(c=>c.isPrimary);for(const c of i)if(t.find(d=>d.table===a&&d.column===c.name))o[a].push(c.name);else{delete o[a];break}}}return o}function bc(e,t,n,o){const{data:a}=hc(t),{data:r}=kn(t);return l.useMemo(()=>{const i=xc(r,e?.result.columns);return{name:n,tabId:o,hooks:(()=>{const c=[];if(!a||!e||!e.result.columns)return c;for(const u of a)(e.result.tables.includes(u.on.toTable)||e.result.tables.includes(u.on.fromTable))&&c.push(u);return c})(),availableJoins:(()=>{const c=[];if(!a||!e||!e.result.columns)return c;for(const u of a)!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=Wa(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,a,r,n])}function vc(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 yc(e,t){return{name:e,path:t,build:a=>{if(typeof a=="object"){let r=t;for(const[i,c]of Object.entries(a))r=r.replace(":"+i,c);return r}return t},check:a=>!!zt({path:t,end:!0},a)}}function En(e,t){return{name:e,path:t,build:()=>t,check:n=>n===t}}const wc=En("Home","/"),Cc=En("Workbench","/workbench"),jc=En("Share query","/share"),Nc=En("Login","/login"),_c=En("Saved queries","/saved-queries"),Sc=yc("Workbench tab","/workbench/tab/:id"),P={home:wc,workbench:Cc,share:jc,login:Nc,savedQueries:_c,workbenchTab:Sc},to=e=>{K.setQueryData(["workbench-tabs"],t=>e(t||[]))},kc=(e,t)=>{K.setQueryData(["workbench-tabs",e],n=>n&&t(n))},ds=()=>ce({queryKey:["workbench-tabs"],queryFn:async()=>{const{data:e}=await O.get("/workbench-tabs");return e.data}}),Ec=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=>{to(t=>[...t,e])}}),Rc=()=>X({mutationFn:async e=>(await O.patch(`/workbench-tabs/${e}`,{archived:!0}),e),onMutate:e=>{to(t=>t.filter(n=>n.id!==e))}}),Ha=()=>X({mutationFn:async e=>(await O.patch(`/workbench-tabs/${e}`,{archived:!1}),e),onSuccess:()=>Va()}),Tc=()=>X({mutationFn:async({id:e,payload:t})=>(await O.patch(`/workbench-tabs/${e}`,t),!0),onMutate:({id:e,payload:t})=>{kc(e,n=>({...n,...t})),to(n=>n.map(o=>o.id!==e?o:{...o,name:t.name||o.name}))}}),Lc=(e,t)=>{const{dataSourceId:n,searchAll:o,table:a,filters:r,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,a,h,p,r,m,i,c,u,d,o],queryFn:async()=>{const{data:g}=await O.post(`/workbench-tabs/${e}/run`,t);return g.data},retry:1,enabled:!!a&&!!n,placeholderData:Gr})},Ac=()=>X({mutationFn:async e=>{await O.delete(`/workbench-tabs/${e}`)},onSuccess:()=>{Va(),nc()}}),za=e=>K.invalidateQueries({queryKey:["workbench-tab-runner",e]}),Va=()=>K.invalidateQueries({queryKey:["workbench-tabs"]}),[Pc,Ss,Ic]=_e(void 0),Oc=async()=>new Promise(e=>{Ss({onCancel:()=>{Ss(void 0),e(void 0)},onConfirm:(t,n,o)=>{Ss(void 0),e({dsId:o,id:n,type:t})}})}),Rn=e=>{const t=Y(),n=en(),o=Ha();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(()=>{Ic.get()||Oc().then(r=>{r?.type==="table"?n.mutate({name:r.id,opts:Zt({table:r.id,dataSourceId:r.dsId})}):r?.type==="query"?n.mutate({queryId:r.id}):r?.type==="tab"&&o.mutate(r.id)})},[t,e])},Tn=e=>{const{data:t}=ue();return l.useMemo(()=>t?Mo[t.teamRole]>=Mo[e]:!1,[t,e])},Mc="_input_1hufc_2",Dc="_label_1hufc_2",$c="_content_1hufc_2",Fc="_form_1hufc_2",Bc="_mode-select_1hufc_2",yt={input:Mc,label:Dc,content:$c,form:Fc,switch:"_switch_1hufc_2",modeSelect:Bc},qc="_modal_1t5ps_2",Uc="_modal-visible_1t5ps_2",Wc="_modal-invisible_1t5ps_2",Hc="_backdrop_1t5ps_2",zc="_modal-container_1t5ps_2",Vc="_close-button_1t5ps_2",Wt={modal:qc,modalVisible:Uc,modalInvisible:Wc,backdrop:Hc,modalContainer:zc,closeButton:Vc},jt=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32,d:"M368 368L144 144M368 144L144 368"}));let Yn=[];const Qc=e=>{const t=Symbol();return Yn.push({id:t,listener:e}),()=>{Yn=Yn.filter(n=>n.id!==t)}};window.addEventListener("keydown",e=>{if(e.key!=="Escape")return;const t=Yn.pop();t&&(e.preventDefault(),e.stopPropagation(),t.listener())});const hs=e=>{const t=l.useRef(e.onClose);t.current=e.onClose,l.useEffect(()=>{if(e.enabled)return Qc(()=>{t.current()})},[e.enabled])},ve=({children:e,backdropClose:t,isVisible:n,onClose:o,onClosed:a,noPadding:r=!1,portal:i=!1})=>{const[c,u]=l.useState(!1),d=()=>{t&&o()},m=p=>{n||getComputedStyle(p.currentTarget).opacity==="0"&&(u(!1),a&&a())};l.useEffect(()=>{n&&u(!0)},[n]),hs({onClose:d,enabled:n&&t===!0});const h=s.jsxs("div",{onTransitionEnd:m,className:A(Wt.modal,n?Wt.modalVisible:Wt.modalInvisible),children:[s.jsx("div",{onClick:d,className:Wt.backdrop}),s.jsx("div",{className:A(Wt.modalContainer,r!==!0&&"p-4"),children:c&&e})]});return i?La.createPortal(h,document.body):h},rt=({onClick:e})=>{const t=l.useRef(e);return t.current=e,s.jsx("button",{className:Wt.closeButton,onClick:e,children:s.jsx(jt,{width:20,height:20})})},Qa=({children:e})=>s.jsx("h2",{className:"text-xl font-semibold",children:e}),Kc=({form:e,change:t,shape:n})=>s.jsx("div",{className:yt.form,children:n.fields.map(o=>s.jsxs("label",{className:yt.input,children:[s.jsx("p",{className:yt.label,children:o.label}),s.jsx("input",{value:e[o.name],onChange:t(o.name),type:o.type})]},o.name))}),Ft=[{label:"PostgreSQL",tag:"postgres"},{label:"MySQL",tag:"mysql"}],Gc={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"}]},Yc={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"}]},Jc=({show:e,onClose:t,dbType:n="postgres"})=>{const o=rc(),a=Ba(),{data:r}=ue(),[i,{change:c,set:u}]=jn({name:"",dbType:n,dbUrl:"",dbUser:"",dbPassword:"",dbDatabase:"",dbSchema:"",dbPort:5432,teamId:"",ownerId:"",description:"",allowInsert:!1,allowUpdate:!1}),d=async()=>{const b=await o.mutateAsync({...i,dbPort:Number(i.dbPort),teamId:r.teamId,ownerId:r.id});await a.mutateAsync(b.id),t(),ac.event("Create Datasource",{dbType:i.dbType})},m=b=>{u("allowInsert",!b),u("allowUpdate",!b)},h=()=>{t()},p=o.isPending||a.isPending,g=!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"}),a.isPending&&s.jsx(ne,{className:"mb-2",variant:"info",children:"Inspecting connection"}),s.jsxs("div",{className:yt.switch,children:[s.jsxs("label",{className:"button tertiary",children:[s.jsx("input",{type:"radio",name:"bdType",className:"mr-2",checked:i.dbType===Ft[0].tag,onChange:()=>u("dbType",Ft[0].tag)}),s.jsx("span",{children:Ft[0].label})]}),s.jsxs("label",{className:"button tertiary",children:[s.jsx("input",{type:"radio",name:"bdType",className:"mr-2",checked:i.dbType===Ft[1].tag,onChange:()=>u("dbType",Ft[1].tag)}),s.jsx("span",{children:Ft[1].label})]})]}),s.jsxs("div",{className:"mt-2",children:[s.jsxs("div",{className:yt.content,children:[s.jsx(Kc,{form:i,change:c,shape:i.dbType==="mysql"?Gc:Yc}),s.jsxs("div",{className:"flex flex-col",children:[s.jsx("label",{className:"text-sm font-semibold",children:"Name"}),s.jsx("input",{value:i.name,onChange:c("name"),className:"input"})]})]}),s.jsxs("div",{className:"mt-4",children:[s.jsxs("label",{className:yt.modeSelect,children:[s.jsxs("div",{children:[s.jsx("input",{type:"radio",name:"production-mode",className:"mr-2",checked:g,onChange:()=>m(!0)}),s.jsx("span",{className:"text-sm font-semibold",children:"Production mode"})]}),s.jsxs("p",{className:"text-xs mt-1 text-gray-600",children:["Mutation operations (such as INSERT or UPDATE) are ",s.jsx("strong",{children:"forbidden"}),". You won't be able to insert new rows or edit existing data. Tables in this data source are read-only."]})]}),s.jsxs("label",{className:yt.modeSelect,children:[s.jsxs("div",{children:[s.jsx("input",{type:"radio",name:"production-mode",className:"mr-2",checked:!g,onChange:()=>m(!1)}),s.jsx("span",{className:"text-sm font-semibold",children:"Dev mode"})]}),s.jsxs("p",{className:"text-xs mt-1 text-gray-600",children:["Mutation operations (such as INSERT or UPDATE) are ",s.jsx("strong",{children:"allowed"}),". You will be able to insert new rows and edit existing data."]})]})]})]})]}),s.jsxs("div",{className:"flex justify-end gap-1 mt-2",children:[s.jsx("button",{onClick:h,className:"button tertiary",disabled:p,children:"Cancel"}),s.jsx("button",{onClick:d,className:"button primary",disabled:p,children:"Create"})]})]})},Xc="_data-source-entry_1f8pw_2",Zc="_action-title_1f8pw_2",eu="_dev-tag_1f8pw_2",tu="_prod-tag_1f8pw_2",nu="_recent-tabs-container_1f8pw_2",su="_recent-tabs-entry_1f8pw_2",ou="_home-action-button_1f8pw_2",au="_home-gray-card_1f8pw_2",ru="_home-card-title_1f8pw_2",iu="_home-card-grid-content_1f8pw_2",lu="_useful-links_1f8pw_2",Q={dataSourceEntry:Xc,actionTitle:Zc,devTag:eu,prodTag:tu,recentTabsContainer:nu,recentTabsEntry:su,homeActionButton:ou,homeGrayCard:au,homeCardTitle:ru,homeCardGridContent:iu,usefulLinks:lu},cu=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"})),uu=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(cu,{width:e,height:e}):s.jsx(uu,{width:e,height:e}),[du,Vt]=_e(void 0),hu=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{d:"M256 32C132.3 32 32 134.9 32 261.7c0 101.5 64.2 187.5 153.2 217.9a17.56 17.56 0 003.8.4c8.3 0 11.5-6.1 11.5-11.4 0-5.5-.2-19.9-.3-39.1a102.4 102.4 0 01-22.6 2.7c-43.1 0-52.9-33.5-52.9-33.5-10.2-26.5-24.9-33.6-24.9-33.6-19.5-13.7-.1-14.1 1.4-14.1h.1c22.5 2 34.3 23.8 34.3 23.8 11.2 19.6 26.2 25.1 39.6 25.1a63 63 0 0025.6-6c2-14.8 7.8-24.9 14.2-30.7-49.7-5.8-102-25.5-102-113.5 0-25.1 8.7-45.6 23-61.6-2.3-5.8-10-29.2 2.2-60.8a18.64 18.64 0 015-.5c8.1 0 26.4 3.1 56.6 24.1a208.21 208.21 0 01112.2 0c30.2-21 48.5-24.1 56.6-24.1a18.64 18.64 0 015 .5c12.2 31.6 4.5 55 2.2 60.8 14.3 16.1 23 36.6 23 61.6 0 88.2-52.4 107.6-102.3 113.3 8 7.1 15.2 21.1 15.2 42.5 0 30.7-.3 55.5-.3 63 0 5.4 3.1 11.5 11.4 11.5a19.35 19.35 0 004-.4C415.9 449.2 480 363.1 480 261.7 480 134.9 379.7 32 256 32z"})),mu=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{d:"M227.6 213.1H256v57.1h-28.4z"}),l.createElement("path",{d:"M0 156v171.4h142.2V356H256v-28.6h256V156zm142.2 142.9h-28.4v-85.7H85.3v85.7H28.4V184.6h113.8zm142.2 0h-56.9v28.6h-56.9V184.6h113.8zm199.2 0h-28.4v-85.7h-28.4v85.7h-28.4v-85.7H370v85.7h-56.9V184.6h170.7v114.3z"})),fu=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{d:"M416 221.25V416a48 48 0 01-48 48H144a48 48 0 01-48-48V96a48 48 0 0148-48h98.75a32 32 0 0122.62 9.37l141.26 141.26a32 32 0 019.37 22.62z",fill:"none",stroke:"currentColor",strokeLinejoin:"round",strokeWidth:32}),l.createElement("path",{d:"M256 56v120a32 32 0 0032 32h120M176 288h160M176 368h160",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32})),pu=()=>{const e=Rn("Home");return s.jsx("div",{className:Q.homeActionButton,onClick:e,children:s.jsxs("h2",{className:Q.actionTitle,children:[s.jsx("span",{className:"truncate",children:"🔎 Start new query"}),s.jsx("span",{className:"hotkey",children:"N"})]})})},gu=()=>{const e=Y();return s.jsx("div",{className:Q.homeActionButton,onClick:()=>e(P.savedQueries.build()),children:s.jsx("h2",{className:Q.actionTitle,children:s.jsx("span",{className:"truncate",children:"💾 Saved queries"})})})},xu=()=>{const[e,t]=l.useState(void 0),n=Tn(pe.EDITOR),o=a=>{n?t(a):Re.error("You don't have permission to connect new data sources in this team")};return s.jsxs("div",{children:[e&&s.jsx(Jc,{show:!0,dbType:e,onClose:()=>t(void 0)}),s.jsx("div",{className:Q.homeActionButton,onClick:()=>o("postgres"),children:s.jsx("p",{className:Q.actionTitle,children:"🧙♂️ Connection wizard"})})]})},bu=()=>{const e=Y(),{data:t}=ds(),n=Rn("Home"),o=()=>{t&&t.length>0?e(P.workbenchTab.build({id:t[0].id})):n()};return s.jsx("div",{className:Q.homeActionButton,onClick:o,children:s.jsxs("h2",{className:Q.actionTitle,children:[s.jsx("span",{children:"🛠️ Workbench"}),s.jsx("span",{className:"hotkey",children:"W"})]})})},vu=()=>{const{data:e}=ue(),{data:t}=eo({teamId:e?.teamId}),n=o=>{Vt(o)};return!t||t.length===0?null:s.jsxs("div",{className:Q.homeGrayCard,children:[s.jsx("h2",{className:Q.homeCardTitle,children:"Data sources"}),s.jsx("div",{className:Q.homeCardGridContent,children:t?.map(o=>s.jsxs("div",{className:Q.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:Q.actionTitle,children:o.name}),o.allowInsert?s.jsx("span",{className:Q.devTag,children:"dev"}):s.jsx("span",{className:Q.prodTag,children:"prod"})]})]},o.id))})]})},Bt=24,yu=()=>s.jsxs("div",{className:Q.usefulLinks,children:[s.jsxs("a",{href:"https://dataramen.xyz/",target:"_blank",children:[s.jsx(fu,{width:Bt,height:Bt}),s.jsx("span",{children:"Docs"})]}),s.jsxs("a",{href:"https://github.com/OleksandrDemian/dataramen",target:"_blank",children:[s.jsx(hu,{width:Bt,height:Bt}),s.jsx("span",{children:"GitHub"})]}),s.jsxs("a",{href:"https://www.npmjs.com/package/@dataramen/cli",target:"_blank",children:[s.jsx(mu,{width:Bt,height:Bt}),s.jsx("span",{children:"NPM"})]})]}),wu=()=>{const{data:e}=ue(),{data:t,isLoading:n}=Zl(e?.teamId),o=Y();if(n||!t?.length)return null;const a=r=>{o(P.workbenchTab.build({id:r}))};return s.jsxs("div",{className:Q.recentTabsContainer,children:[s.jsx("h2",{className:Q.homeCardTitle+" px-4 mb-4",children:"Recent tabs"}),t.map(r=>s.jsxs("div",{className:Q.recentTabsEntry,onClick:()=>a(r.id),children:[s.jsx("p",{className:"text-(--text-color-primary) truncate",children:r.name}),s.jsxs("p",{className:"flex items-center gap-2",children:[s.jsx(it,{size:20,type:r.dataSourceType}),s.jsx("span",{className:"text-sm text-(--text-color-secondary) truncate",children:r.dataSourceName})]})]},r.id))]})},Cu=()=>{const{data:e}=ue(),{data:t}=eo({teamId:e?.teamId}),n=!!t&&t.length>0,o=!!e;return s.jsx("div",{className:"page-container h-screen max-h-screen overflow-y-auto no-scrollbar",children:s.jsxs("div",{className:"page-content",children:[s.jsxs("div",{className:"py-10 text-center w-full sticky top-0 z-0",children:[s.jsx("h1",{className:"comfortaa text-3xl font-semibold text-(--text-color-primary) mb-4",children:"DataRamen"}),s.jsx(yu,{})]}),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:Q.homeGrayCard,children:[s.jsx("h2",{className:Q.homeCardTitle,children:"Quick actions"}),s.jsxs("div",{className:Q.homeCardGridContent,children:[s.jsx(pu,{}),s.jsx(xu,{}),o&&s.jsx(bu,{}),s.jsx(gu,{})]})]}),o&&s.jsx(vu,{}),s.jsx(wu,{})]})]})})},[ju,no]=_e(void 0),Nu=()=>no(void 0);function wt(e,t){if(e==null)return"";switch(t){case"json":case"jsonb":return JSON.stringify(e,null,2)}if(e===0||e===!1)return e.toString();switch(typeof e){case"string":return e;case"number":case"boolean":return e.toString();default:return JSON.stringify(e)}}const Jn=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},_u="_container_d92uy_2",Su="_header_d92uy_2",ku="_fields-container_d92uy_2",Eu="_field-label_d92uy_2",Ru="_actions_d92uy_2",pn={container:_u,header:Su,fieldsContainer:ku,fieldLabel:Eu,actions:Ru},Tu=(e,t,n)=>ce({queryKey:["entity",e,t,n],queryFn:async()=>{const{data:o}=await O.get(`/runner/${e}/entity/${t}`,{params:n?.reduce((a,r)=>(a[r[0]]=r[1],a),{})});return o.data},retry:1,enabled:!!t&&!!e&&!!n,staleTime:0}),Lu=()=>X({mutationFn:async e=>{const{data:t}=await O.post(`/runner/${e.datasourceId}/update`,e);return t.data}}),Au=()=>X({mutationFn:async e=>{const{data:t}=await O.post(`/runner/${e.datasourceId}/insert`,e);return t.data}}),so=e=>l.useMemo(()=>{if(e)return e instanceof Yr?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]),oo=()=>{const{pathname:e}=le();return l.useMemo(()=>zt({path:P.workbenchTab.path,end:!1},e)?.params.id,[e])},Pu=({data:e})=>{const[t,{change:n,touched:o}]=jn({}),a=oo(),{mutateAsync:r,error:i}=Au(),c=so(i),{data:u}=kn(e.dataSourceId),[d,m]=l.useState(""),h=l.useMemo(()=>u?.find(b=>b.tableName===e.table),[u,e.table]),p=l.useMemo(()=>{if(!h)return[];if(!d)return h.columns.map(x=>({...x,label:et(x.name)}));const b=d.toLowerCase();return h.columns.filter(x=>x.name.toLowerCase().includes(b)).map(x=>({...x,label:et(x.name)}))},[d,h]),g=()=>{const b={};for(const x of o)b[x]=t[x];r({datasourceId:e.dataSourceId,table:e.table,values:b}).then(()=>{Nu(),a&&za(a)})};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(b=>s.jsxs("label",{className:pn.fieldLabel,children:[s.jsxs("div",{className:"flex justify-between",children:[s.jsxs("p",{children:[b.isPrimary?"🔐":"🏷️"," ",b.label]}),s.jsxs("p",{className:"text-blue-800 text-sm",children:["[",b.name,": ",b.type,"]"]})]}),s.jsx("input",{className:"input w-full",value:wt(t[b.name]),onChange:n(b.name),placeholder:b.name})]},b.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:b=>m(b.target.value),placeholder:"Filter columns"})]}),s.jsx("span",{className:"flex-1"}),s.jsx("button",{disabled:!o.length,className:"button primary",onClick:g,children:"Run insert"})]})]})},Iu=()=>{const e=ju(),[t,n]=l.useState(void 0);l.useEffect(()=>{e&&n(e)},[e]);const o=()=>no(void 0);return s.jsxs(ve,{isVisible:e!=null,onClose:o,onClosed:()=>n(void 0),noPadding:!0,children:[s.jsx(rt,{onClick:o}),t&&s.jsx(Pu,{data:t})]})},[Ou,ms]=_e(void 0),Mu=()=>ms(void 0),Du="_container_vcea9_2",$u="_header_vcea9_2",Fu="_key_vcea9_2",Bu="_fields-container_vcea9_2",qu="_field-label_vcea9_2",Uu="_actions_vcea9_2",qt={container:Du,header:$u,key:Fu,fieldsContainer:Bu,fieldLabel:qu,actions:Uu},st=()=>Date.now().toString(36)+Math.random().toString(36).substring(2),Wu=({data:e})=>{const[t,{change:n,set:o,reset:a,touched:r}]=jn({}),i=oo(),[c,u]=l.useState(""),{data:d,isLoading:m}=Tu(e.dataSourceId,e.tableName,e.entityId),{mutateAsync:h,error:p}=Lu(),g=so(p),b=Tn(pe.EDITOR),{data:x}=kn(e.dataSourceId),{data:v}=us(e.dataSourceId),y=l.useMemo(()=>x?.find(k=>k.tableName===e.tableName),[e.tableName,x]),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(a(),k&&d?.columns)for(let j=0;j<d.columns.length;j++){const S=d.columns[j];o(S.column,wt(k[j]))}},[d,o,a]);const w=()=>{const k={};for(const j of r)k[j]=t[j];h({datasourceId:e.dataSourceId,table:e.tableName,filters:e.entityId.map(j=>({id:st(),value:j[1],column:j[0]})),values:k}).then(()=>{Mu(),i&&za(i)})},C=e.entityId.map(([k,j])=>`${k} = ${j}`).join(", ")||"",_=!v?.allowUpdate||!b;return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:qt.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:qt.key,children:C}),g&&s.jsx(ne,{variant:"danger",children:s.jsx("p",{children:g})})]}),!_&&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:qt.container,children:s.jsx("div",{className:qt.fieldsContainer,children:f.map(k=>s.jsxs("label",{className:qt.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:wt(t[k.name]),onChange:n(k.name),placeholder:k.name})]},k.name))})}),s.jsxs("div",{className:qt.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:!r.length,className:"button primary",onClick:w,children:"Run update"})]})]})},Hu=()=>{const e=Ou(),[t,n]=l.useState(void 0);l.useEffect(()=>{e&&n(e)},[e]);const o=()=>ms(void 0);return s.jsxs(ve,{isVisible:e!=null,onClose:o,onClosed:()=>n(void 0),noPadding:!0,children:[s.jsx(rt,{onClick:o}),t&&s.jsx(Wu,{data:t})]})},[zu,ks]=_e(void 0),Ka=async e=>new Promise(t=>{ks({message:e,onCancel:()=>{t(!1),ks(void 0)},onConfirm:()=>{t(!0),ks(void 0)}})}),Vu=({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=zu(),[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(Vu,{confirm:t})})},[Ku,Xn]=_e(void 0),Ln=async(e,t,n)=>new Promise(o=>{Xn({message:e,defaultValue:t,alert:n,onCancel:()=>{Xn(void 0),o(void 0)},onConfirm:a=>{Xn(void 0),o(a)}})}),Gu="_root_ng9lp_1",Yu={root:Gu},Ju=({data:e})=>{const[t,n]=l.useState("");l.useEffect(()=>{e.defaultValue&&n(e.defaultValue)},[e]);const o=r=>{n(r.target.value)},a=r=>{r.key==="Enter"&&(r.preventDefault(),e.onConfirm(t)),r.key==="Escape"&&(r.preventDefault(),e.onCancel())};return s.jsxs("div",{className:Yu.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:a}),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"})]})]})},Xu=()=>{const e=Ku(),[t,n]=l.useState(void 0);return l.useEffect(()=>{e&&n(e)},[e]),s.jsx(ve,{isVisible:!!e,onClose:()=>Xn(void 0),onClosed:()=>n(void 0),children:t&&s.jsx(Ju,{data:t})})},[Zu,ed]=_e(void 0),Ga=e=>{ed(e)},td="_textarea_68vbf_2",nd={textarea:td},sd=()=>{const e=Zu(),t=()=>{e&&(navigator.clipboard.writeText(e.toString()),Re.success("Copied!"))},n=()=>Ga(void 0);return s.jsxs(ve,{isVisible:!!e,onClose:n,backdropClose:!0,children:[s.jsx("textarea",{className:nd.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"})]})]})},od="_tabs_i8v6j_2",ad="_mobile_i8v6j_2",rd="_tab_i8v6j_2",id="_active_i8v6j_2",ld="_close-button_i8v6j_2",gn={tabs:od,mobile:ad,tab:rd,active:id,closeButton:ld},Do=e=>window.matchMedia(e).matches;function Ya(e,{defaultValue:t=!1,initializeWithValue:n=!0}={}){const[o,a]=l.useState(()=>n?Do(e):t);return l.useLayoutEffect(()=>{const r=window.matchMedia(e);function i(){a(()=>Do(e))}return i(),r.addListener?r.addListener(i):r.addEventListener("change",i),()=>{r.removeListener?r.removeListener(i):r.removeEventListener("change",i)}},[e]),o}const ao={laptop:"(min-width: 1024px)"},Ja=()=>window.matchMedia(ao.laptop).matches,cd="_table_ianwb_2",ud="_row-index-btn_ianwb_2",dd="_semi-transparent_ianwb_2",hd="_table-loading_ianwb_2",md="_table-empty_ianwb_2",fd="_table-row-cells_ianwb_2",pd="_header-cell_ianwb_2",gd="_header-actions_ianwb_2",xd="_cell_ianwb_2",bd="_value_ianwb_2",vd="_table-config_ianwb_2",yd="_table-action_ianwb_2",wd="_green-fixed_ianwb_2",Cd="_gray_ianwb_2",jd="_modal_ianwb_2",Nd="_selected-size_ianwb_2",_d="_pagination-indicator_ianwb_2",T={table:cd,rowIndexBtn:ud,semiTransparent:dd,tableLoading:hd,tableEmpty:md,tableRowCells:fd,headerCell:pd,headerActions:gd,cell:xd,value:bd,tableConfig:vd,tableAction:yd,greenFixed:wd,gray:Cd,modal:jd,selectedSize:Nd,paginationIndicator:_d},qe=l.createContext({name:"No name",hooks:[],availableJoins:[],allColumns:[],dataSourceId:"",entities:[],getValue:()=>{},getColumnType:()=>{},getEntityKey:()=>[],getEntityKeyByRowIndex:()=>[]}),ge=l.createContext({state:Zt({}),setState:()=>{}}),Ae=l.createContext({}),Xa={ON_ANIMATION_END:Symbol("ON_TRANSITION_END")},Za=()=>{const[e,t]=l.useState(),[n,o]=l.useState("hidden");return l.useMemo(()=>{const a=c=>{c.preventDefault(),o("in"),t({x:c.clientX-1,y:c.clientY-1})},r=()=>{o("out")},i=()=>{n==="in"?o("visible"):n==="out"&&(t(void 0),o("hidden"))};return{show:!!e,position:e,state:n,open:a,close:r,[Xa.ON_ANIMATION_END]:i}},[e,n])},Sd=e=>{if(e==="ASC")return"DESC";if(e!=="DESC")return"ASC"},kd=()=>{const{state:e,setState:t}=l.useContext(ge),n=l.useCallback(o=>{t(a=>{const r=a.orderBy[0];if(r&&r.column===o){const i=Sd(r.direction);return i?{...a,orderBy:[{column:o,direction:i}]}:{...a,orderBy:[]}}return{...a,orderBy:[{column:o,direction:"ASC"}]}})},[t]);return{orderBy:e.orderBy,updateOrderBy:n}},Ed="_options-container_fboyw_2",Rd="_filter-input_fboyw_2",Td="_option-item_fboyw_2",Ld="_list_fboyw_2",Ad="_empty-text_fboyw_2",Ke={optionsContainer:Ed,filterInput:Rd,optionItem:Td,list:Ld,emptyText:Ad},Pd="_container_14l7a_2",Id="_animate-show_14l7a_2",Od="_animate-hide_14l7a_2",Md="_content_14l7a_2",Dd="_backdrop_14l7a_2",ft={container:Pd,animateShow:Id,animateHide:Od,content:Md,backdrop:Dd},er=({children:e,handler:t})=>{const n=l.useRef(t.close);n.current=t.close;const o=l.useMemo(()=>{if(!t.position)return;const a={};if(typeof window<"u"){const r=t.position.y>window.innerHeight/2,i=t.position.x>window.innerWidth/2;r?a.bottom=window.innerHeight-t.position.y:a.top=t.position.y,Ja()?i?a.right=window.innerWidth-t.position.x:a.left=t.position.x:(a.right=36,a.left=36)}return a},[t.position]);return hs({enabled:!!o,onClose:t.close}),o?s.jsxs("div",{className:A(ft.container,t.state==="out"&&ft.animateHide,t.state==="in"&&ft.animateShow),onAnimationEnd:t[Xa.ON_ANIMATION_END],children:[s.jsx("div",{className:ft.backdrop,onClick:a=>{a.stopPropagation(),a.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},$e=(e,t)=>e!=null&&e>t,$d=(e,t)=>e!=null&&e<t,Fd="_root_ki4vr_2",Bd="_content_ki4vr_2",qd="_table-name_ki4vr_2",Ud="_sub_ki4vr_2",zn={root:Fd,content:Bd,tableName:qd,sub:Ud},tr=({hook:e,onClick:t})=>s.jsxs("button",{className:zn.root,onClick:t,children:[s.jsx("span",{children:"📄"}),s.jsxs("div",{className:zn.content,children:[s.jsx("span",{className:zn.tableName,children:e.on.toTable}),s.jsxs("span",{className:zn.sub,children:[e.on.toColumn," = ",e.on.fromTable,".",e.on.fromColumn]})]})]},e.where),Wd=A("input",Ke.filterInput);function Hd(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 nr=({rowIndex:e,onClose:t,className:n})=>{const[o,a]=l.useState(""),{hooks:r,dataSourceId:i,getValue:c}=l.useContext(qe),{state:u}=l.useContext(ge),{data:d}=l.useContext(Ae),m=l.useMemo(()=>d?.result.rows[e],[d,e]),h=en(),p=Y(),g=l.useMemo(()=>{if(!d)return[];const f=o.toLowerCase();return r.filter(w=>d.result.columns.some(_=>_.column===w.on.fromColumn&&_.table===w.on.fromTable)?w.on.toTable.toLowerCase().includes(f):!1)},[o,r,d]),b=f=>{m&&h.mutateAsync(Hd(f,i,c(m,{value:`${f.on.fromTable}.${f.on.fromColumn}`}))).then(w=>{p(P.workbenchTab.build({id:w.id})),t?.()})},x=()=>{!m||!u||h.mutateAsync({name:`${u.table} > [${u.joins.map(f=>f.table).join()}]`,opts:Zt({joins:u.joins,table:u.table,dataSourceId:u.dataSourceId,filters:[...u.filters.filter(f=>f.isEnabled),...u.groupBy.map(f=>({id: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=$e(g.length,0);return s.jsxs("div",{className:n,children:[s.jsx("input",{autoFocus:!0,className:Wd,placeholder:"Filter",value:o,onChange:f=>a(f.target.value)}),s.jsxs("div",{className:Ke.list,children:[v&&s.jsx("button",{onClick:x,className:Ke.optionItem,children:"🎯 Underlying rows"}),y&&g.map(f=>s.jsx(tr,{hook:f,onClick:()=>b(f)},f.where)),!v&&!y&&s.jsx("p",{className:Ke.emptyText,children:"Empty"})]})]})},zd=({handler:e,rowIndex:t})=>s.jsx(er,{handler:e,children:s.jsx("div",{className:Ke.optionsContainer,children:s.jsx(nr,{rowIndex:t,className:"p-2",onClose:()=>{e.close()}})})}),ro=()=>{const{state:e,setState:t}=l.useContext(ge),n=l.useCallback((a,r=!1)=>{t(i=>({...i,page:r?0:i.page,filters:a}))},[t]),o=l.useCallback(a=>{t(r=>({...r,filters:r.filters.filter(i=>i.id!==a)}))},[t]);return{filters:e.filters,removeFilter:o,setFilters:n}},Vd=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"})),io=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"})),Kd="_container_flyao_2",Gd="_animate-show_flyao_2",Yd="_animate-hide_flyao_2",Jd="_backdrop_flyao_2",Xd="_content_flyao_2",pt={container:Kd,animateShow:Gd,animateHide:Yd,backdrop:Jd,content:Xd},sr=({children:e,ref:t,onClosed:n})=>{const[o,a]=l.useState(void 0),[r,i]=l.useState("hidden"),c=l.useRef(null);if(l.useImperativeHandle(t,()=>({open:(m,h=!0)=>{h||(m.preventDefault(),m.stopPropagation());const p={},g=m.clientY>window.innerHeight/2,b=m.clientX>window.innerWidth/2;g?p.bottom=window.innerHeight-m.clientY:p.top=m.clientY,Ja()?b?p.right=window.innerWidth-m.clientX:p.left=m.clientX:(p.right=36,p.left=36),a(p),i("in")},close:()=>{i("out")}}),[]),hs({enabled:r==="in"||r==="visible",onClose:()=>{i("out")}}),!o)return null;const u=()=>{r==="in"?i("visible"):r==="out"&&(a(void 0),i("hidden"),n?.())},d=s.jsxs("div",{className:A(pt.container,r==="out"&&pt.animateHide,r==="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,r==="out"&&pt.animateHide,r==="in"&&pt.animateShow),children:e})]});return La.createPortal(d,document.body)};function Es(e,t,n){const o=e?.rows?.[t]?.[n],a=e?.columns?.[n];return{value:o,column:a}}const Zd=({ref:e})=>{const{data:t}=l.useContext(Ae),{getColumnType:n}=l.useContext(qe),{setState:o}=l.useContext(ge);return{copyValue:(c,u)=>{const{value:d,column:m}=Es(t?.result,c,u);if(m){const h=wt(d,n(m.full));navigator.clipboard.writeText(h),Re.success("Copied!"),e.current?.close()}},showValue:(c,u)=>{const{value:d,column:m}=Es(t?.result,c,u);if(m){const h=wt(d,n(m.full));Ga(h),e.current?.close()}},filterValue:(c,u)=>{const{value:d,column:m}=Es(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 g=wt(d,n(h));p={id:st(),isEnabled:!0,column:h,value:g,fn:m?.fn}}o(g=>({...g,filters:[...g.filters,p]})),Re.success(`Added new filter on column ${m?.alias}`),e.current?.close()}}}},or=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})),eh=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})),th="_section-name_2c7gu_2",nh="_item_2c7gu_2",gt={sectionName:th,item:nh},ar=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"})),sh=A("input",Ke.filterInput),oh=({onClose:e,rowIndex:t,className:n})=>{const[o,a]=l.useState(""),{entities:r,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?r.filter(p=>p.includes(o)):r,[r,o]),h=p=>{if(!d)return;const g=c(p,d);ms({tableName:p,dataSourceId:i,entityId:g}),e?.()};return s.jsxs("div",{className:n,children:[s.jsx("input",{autoFocus:!0,className:sh,placeholder:"Filter",value:o,onChange:p=>a(p.target.value)}),s.jsx("div",{className:Ke.list,children:$e(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"})})]})},ah=({ref:e,row:t,col:n,onClosed:o})=>{const a=Zd({ref:e}),[r,i]=l.useState("cell"),{entities:c,dataSourceId:u,getEntityKeyByRowIndex:d}=l.useContext(qe),m=()=>a.copyValue(t,n),h=()=>a.showValue(t,n),p=()=>a.filterValue(t,n),g=()=>{if(c.length===1){const x=d(c[0],t);ms({tableName:c[0],dataSourceId:u,entityId:x}),e.current?.close()}else i("expand")},b=()=>{o?.(),i("cell")};return s.jsx(sr,{ref:e,onClosed:b,children:s.jsxs("div",{className:"w-full lg:w-sm",children:[r==="cell"&&s.jsxs(s.Fragment,{children:[s.jsx("p",{className:gt.sectionName,children:"Cell actions"}),s.jsxs("button",{className:gt.item,onClick:m,children:[s.jsx(or,{width:14,height:14}),"Copy"]}),s.jsxs("button",{className:gt.item,onClick:h,children:[s.jsx(eh,{width:14,height:14}),"View"]}),s.jsxs("button",{className:gt.item,onClick:p,children:[s.jsx(io,{width:14,height:14}),"Filter"]}),s.jsx("p",{className:gt.sectionName,children:"Row actions"}),s.jsxs("button",{className:gt.item,onClick:()=>i("drill"),children:[s.jsx(Ge,{width:14,height:14}),"Drill down"]}),c?.length>0&&s.jsxs("button",{className:gt.item,onClick:g,children:[s.jsx(ar,{width:14,height:14}),"Edit row"]})]}),r==="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(nr,{rowIndex:t,onClose:()=>e.current?.close()})]}),r==="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(oh,{rowIndex:t,onClose:()=>e.current?.close()})]})]})})},rh={DESC:"",ASC:"rotate-180"},ih=(e,{column:t,value:n,fn:o})=>{const a=e.map(r=>({...r,isEnabled:r.column===t?!1:r.isEnabled}));return a.push({id:st(),column:t,isEnabled:!0,value:n,fn:o,isAdvanced:!1}),a},lh=()=>{const{data:e}=l.useContext(Ae),{orderBy:t,updateOrderBy:n}=kd(),{setFilters:o,filters:a}=ro(),r=e?.result.columns||[],i=t[0],c=$e(e?.result.tables.length,1),u=(d,m)=>{Ln("Filter value","").then(h=>{h&&o(ih(a,{column:d,value:h,fn:m}))})};return s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("td",{children:"🥢"}),r.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 text-(--text-color-primary)",children:d.table||"-"}),s.jsx("p",{className:"text-sm font-semibold truncate text-(--text-color-primary)",children:d.column})]}),s.jsxs("div",{className:T.headerActions,children:[s.jsx("button",{onClick:()=>n(d.alias),children:i?.column===d.alias?s.jsx(Vd,{className:rh[i.direction],width:16,height:16}):s.jsx(Qd,{width:16,height:16})}),s.jsx("button",{onClick:()=>u(d.full,d.fn),children:s.jsx(io,{width:16,height:16})})]})]},d.full))]})})};function ch({value:e}){if(e==="")return s.jsx("span",{className:"pointer-events-none text-black/30 truncate",children:"<EMPTY STRING>"});if(e==null)return s.jsx("span",{className:"pointer-events-none text-black/30",children:"<NULL>"});const t=wt(e);return s.jsx("span",{className:T.value,children:t})}const uh=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((a,r)=>s.jsx("td",{className:T.cell,"data-row":n,"data-col":r,children:s.jsx(ch,{value:a})},r))]})),dh=()=>{const{data:e,error:t,isLoading:n,isFetching:o}=l.useContext(Ae),{state:{page:a,size:r}}=l.useContext(ge),i=l.useRef(null),c=so(t),u=Za(),[d,m]=l.useState(void 0),[h,p]=l.useState(void 0),g=v=>{const f=v.target?.dataset?.rowAction;f!=null&&(m(parseInt(f)),u.open(v))},b=v=>{const y=v.target?.dataset,f=y?.row,w=y?.col;f!=null&&w!=null&&(m(parseInt(f)),p(parseInt(w)),i.current?.open(v),v.preventDefault(),v.stopPropagation())},x=a*r;return s.jsxs(s.Fragment,{children:[d!=null&&u.show&&s.jsx(zd,{handler:u,rowIndex:d}),s.jsx(ah,{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:g,onContextMenu:b,children:[s.jsx(lh,{}),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(uh,{index:y,offset:x,row:v,isLastRow:y===e.result.rows.length-1},y))]})]})]})},rr=()=>{const{state:e,setState:t}=l.useContext(ge),n=l.useCallback(a=>{t(r=>({...r,page:a}))},[t]),o=l.useCallback((a,r=!1)=>{t(i=>({...i,size:a,page:r?0:i.page}))},[t]);return{page:e.page,size:e.size,setSize:o,setPage:n}},hh=()=>X({mutationFn:async e=>{const{data:t}=await O.post("/saved-queries",e);return t.data},onSuccess:()=>{K.invalidateQueries({queryKey:["queries"]}),Jt(),Fa()}}),mh=()=>X({mutationFn:async e=>O.delete("/saved-queries/"+e),onSuccess:()=>{Jt(),Fa()}}),fh=()=>X({mutationFn:async({id:e,payload:t})=>{const{data:n}=await O.patch("/saved-queries/"+e,t);return n.data},onSuccess:()=>{Jt(),Gl()}}),[fs,lo]=_e({filters:!1,joins:!1,columns:!1,groupBy:!1,aggregate:!1}),Me=e=>lo(t=>({...t,[e]:!0})),ps=e=>lo(t=>({...t,[e]:!1})),ns=e=>lo(t=>({...t,[e]:!t[e]})),Qt=Math.min,Ct=Math.max,ss=Math.round,Vn=Math.floor,De=e=>({x:e,y:e}),ph={left:"right",right:"left",bottom:"top",top:"bottom"},gh={start:"end",end:"start"};function qs(e,t,n){return Ct(e,Qt(t,n))}function An(e,t){return typeof e=="function"?e(t):e}function Nt(e){return e.split("-")[0]}function Pn(e){return e.split("-")[1]}function ir(e){return e==="x"?"y":"x"}function co(e){return e==="y"?"height":"width"}const xh=new Set(["top","bottom"]);function tt(e){return xh.has(Nt(e))?"y":"x"}function uo(e){return ir(tt(e))}function bh(e,t,n){n===void 0&&(n=!1);const o=Pn(e),a=uo(e),r=co(a);let i=a==="x"?o===(n?"end":"start")?"right":"left":o==="start"?"bottom":"top";return t.reference[r]>t.floating[r]&&(i=os(i)),[i,os(i)]}function vh(e){const t=os(e);return[Us(e),t,Us(t)]}function Us(e){return e.replace(/start|end/g,t=>gh[t])}const $o=["left","right"],Fo=["right","left"],yh=["top","bottom"],wh=["bottom","top"];function Ch(e,t,n){switch(e){case"top":case"bottom":return n?t?Fo:$o:t?$o:Fo;case"left":case"right":return t?yh:wh;default:return[]}}function jh(e,t,n,o){const a=Pn(e);let r=Ch(Nt(e),n==="start",o);return a&&(r=r.map(i=>i+"-"+a),t&&(r=r.concat(r.map(Us)))),r}function os(e){return e.replace(/left|right|bottom|top/g,t=>ph[t])}function Nh(e){return{top:0,right:0,bottom:0,left:0,...e}}function lr(e){return typeof e!="number"?Nh(e):{top:e,right:e,bottom:e,left:e}}function as(e){const{x:t,y:n,width:o,height:a}=e;return{width:o,height:a,top:n,left:t,right:t+o,bottom:n+a,x:t,y:n}}function Bo(e,t,n){let{reference:o,floating:a}=e;const r=tt(t),i=uo(t),c=co(i),u=Nt(t),d=r==="y",m=o.x+o.width/2-a.width/2,h=o.y+o.height/2-a.height/2,p=o[c]/2-a[c]/2;let g;switch(u){case"top":g={x:m,y:o.y-a.height};break;case"bottom":g={x:m,y:o.y+o.height};break;case"right":g={x:o.x+o.width,y:h};break;case"left":g={x:o.x-a.width,y:h};break;default:g={x:o.x,y:o.y}}switch(Pn(t)){case"start":g[i]-=p*(n&&d?-1:1);break;case"end":g[i]+=p*(n&&d?-1:1);break}return g}const _h=async(e,t,n)=>{const{placement:o="bottom",strategy:a="absolute",middleware:r=[],platform:i}=n,c=r.filter(Boolean),u=await(i.isRTL==null?void 0:i.isRTL(t));let d=await i.getElementRects({reference:e,floating:t,strategy:a}),{x:m,y:h}=Bo(d,o,u),p=o,g={},b=0;for(let x=0;x<c.length;x++){const{name:v,fn:y}=c[x],{x:f,y:w,data:C,reset:_}=await y({x:m,y:h,initialPlacement:o,placement:p,strategy:a,middlewareData:g,rects:d,platform:i,elements:{reference:e,floating:t}});m=f??m,h=w??h,g={...g,[v]:{...g[v],...C}},_&&b<=50&&(b++,typeof _=="object"&&(_.placement&&(p=_.placement),_.rects&&(d=_.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:a}):_.rects),{x:m,y:h}=Bo(d,p,u)),x=-1)}return{x:m,y:h,placement:p,strategy:a,middlewareData:g}};async function cr(e,t){var n;t===void 0&&(t={});const{x:o,y:a,platform:r,rects:i,elements:c,strategy:u}=e,{boundary:d="clippingAncestors",rootBoundary:m="viewport",elementContext:h="floating",altBoundary:p=!1,padding:g=0}=An(t,e),b=lr(g),v=c[p?h==="floating"?"reference":"floating":h],y=as(await r.getClippingRect({element:(n=await(r.isElement==null?void 0:r.isElement(v)))==null||n?v:v.contextElement||await(r.getDocumentElement==null?void 0:r.getDocumentElement(c.floating)),boundary:d,rootBoundary:m,strategy:u})),f=h==="floating"?{x:o,y:a,width:i.floating.width,height:i.floating.height}:i.reference,w=await(r.getOffsetParent==null?void 0:r.getOffsetParent(c.floating)),C=await(r.isElement==null?void 0:r.isElement(w))?await(r.getScale==null?void 0:r.getScale(w))||{x:1,y:1}:{x:1,y:1},_=as(r.convertOffsetParentRelativeRectToViewportRelativeRect?await r.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:f,offsetParent:w,strategy:u}):f);return{top:(y.top-_.top+b.top)/C.y,bottom:(_.bottom-y.bottom+b.bottom)/C.y,left:(y.left-_.left+b.left)/C.x,right:(_.right-y.right+b.right)/C.x}}const Sh=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:o,placement:a,rects:r,platform:i,elements:c,middlewareData:u}=t,{element:d,padding:m=0}=An(e,t)||{};if(d==null)return{};const h=lr(m),p={x:n,y:o},g=uo(a),b=co(g),x=await i.getDimensions(d),v=g==="y",y=v?"top":"left",f=v?"bottom":"right",w=v?"clientHeight":"clientWidth",C=r.reference[b]+r.reference[g]-p[g]-r.floating[b],_=p[g]-r.reference[g],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]||r.floating[b]);const S=C/2-_/2,I=j/2-x[b]/2-1,F=Qt(h[y],I),se=Qt(h[f],I),ye=F,Pe=j-x[b]-se,q=j/2-x[b]/2+S,de=qs(ye,q,Pe),oe=!u.arrow&&Pn(a)!=null&&q!==de&&r.reference[b]/2-(q<ye?F:se)-x[b]/2<0,J=oe?q<ye?q-ye:q-Pe:0;return{[g]:p[g]+J,data:{[g]:de,centerOffset:q-de-J,...oe&&{alignmentOffset:J}},reset:oe}}}),kh=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,o;const{placement:a,middlewareData:r,rects:i,initialPlacement:c,platform:u,elements:d}=t,{mainAxis:m=!0,crossAxis:h=!0,fallbackPlacements:p,fallbackStrategy:g="bestFit",fallbackAxisSideDirection:b="none",flipAlignment:x=!0,...v}=An(e,t);if((n=r.arrow)!=null&&n.alignmentOffset)return{};const y=Nt(a),f=tt(c),w=Nt(c)===c,C=await(u.isRTL==null?void 0:u.isRTL(d.floating)),_=p||(w||!x?[os(c)]:vh(c)),k=b!=="none";!p&&k&&_.push(...jh(c,x,b,C));const j=[c,..._],S=await cr(t,v),I=[];let F=((o=r.flip)==null?void 0:o.overflows)||[];if(m&&I.push(S[y]),h){const q=bh(a,i,C);I.push(S[q[0]],S[q[1]])}if(F=[...F,{placement:a,overflows:I}],!I.every(q=>q<=0)){var se,ye;const q=(((se=r.flip)==null?void 0:se.index)||0)+1,de=j[q];if(de&&(!(h==="alignment"?f!==tt(de):!1)||F.every(H=>tt(H.placement)===f?H.overflows[0]>0:!0)))return{data:{index:q,overflows:F},reset:{placement:de}};let oe=(ye=F.filter(J=>J.overflows[0]<=0).sort((J,H)=>J.overflows[1]-H.overflows[1])[0])==null?void 0:ye.placement;if(!oe)switch(g){case"bestFit":{var Pe;const J=(Pe=F.filter(H=>{if(k){const ae=tt(H.placement);return ae===f||ae==="y"}return!0}).map(H=>[H.placement,H.overflows.filter(ae=>ae>0).reduce((ae,We)=>ae+We,0)]).sort((H,ae)=>H[1]-ae[1])[0])==null?void 0:Pe[0];J&&(oe=J);break}case"initialPlacement":oe=c;break}if(a!==oe)return{reset:{placement:oe}}}return{}}}},Eh=new Set(["left","top"]);async function Rh(e,t){const{placement:n,platform:o,elements:a}=e,r=await(o.isRTL==null?void 0:o.isRTL(a.floating)),i=Nt(n),c=Pn(n),u=tt(n)==="y",d=Eh.has(i)?-1:1,m=r&&u?-1:1,h=An(t,e);let{mainAxis:p,crossAxis:g,alignmentAxis:b}=typeof h=="number"?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};return c&&typeof b=="number"&&(g=c==="end"?b*-1:b),u?{x:g*m,y:p*d}:{x:p*d,y:g*m}}const Th=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,o;const{x:a,y:r,placement:i,middlewareData:c}=t,u=await Rh(t,e);return i===((n=c.offset)==null?void 0:n.placement)&&(o=c.arrow)!=null&&o.alignmentOffset?{}:{x:a+u.x,y:r+u.y,data:{...u,placement:i}}}}},Lh=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:o,placement:a}=t,{mainAxis:r=!0,crossAxis:i=!1,limiter:c={fn:v=>{let{x:y,y:f}=v;return{x:y,y:f}}},...u}=An(e,t),d={x:n,y:o},m=await cr(t,u),h=tt(Nt(a)),p=ir(h);let g=d[p],b=d[h];if(r){const v=p==="y"?"top":"left",y=p==="y"?"bottom":"right",f=g+m[v],w=g-m[y];g=qs(f,g,w)}if(i){const v=h==="y"?"top":"left",y=h==="y"?"bottom":"right",f=b+m[v],w=b-m[y];b=qs(f,b,w)}const x=c.fn({...t,[p]:g,[h]:b});return{...x,data:{x:x.x-n,y:x.y-o,enabled:{[p]:r,[h]:i}}}}}};function gs(){return typeof window<"u"}function tn(e){return ur(e)?(e.nodeName||"").toLowerCase():"#document"}function be(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Ue(e){var t;return(t=(ur(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function ur(e){return gs()?e instanceof Node||e instanceof be(e).Node:!1}function Te(e){return gs()?e instanceof Element||e instanceof be(e).Element:!1}function Fe(e){return gs()?e instanceof HTMLElement||e instanceof be(e).HTMLElement:!1}function qo(e){return!gs()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof be(e).ShadowRoot}const Ah=new Set(["inline","contents"]);function In(e){const{overflow:t,overflowX:n,overflowY:o,display:a}=Le(e);return/auto|scroll|overlay|hidden|clip/.test(t+o+n)&&!Ah.has(a)}const Ph=new Set(["table","td","th"]);function Ih(e){return Ph.has(tn(e))}const Oh=[":popover-open",":modal"];function xs(e){return Oh.some(t=>{try{return e.matches(t)}catch{return!1}})}const Mh=["transform","translate","scale","rotate","perspective"],Dh=["transform","translate","scale","rotate","perspective","filter"],$h=["paint","layout","strict","content"];function ho(e){const t=mo(),n=Te(e)?Le(e):e;return Mh.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)||Dh.some(o=>(n.willChange||"").includes(o))||$h.some(o=>(n.contain||"").includes(o))}function Fh(e){let t=ot(e);for(;Fe(t)&&!Kt(t);){if(ho(t))return t;if(xs(t))return null;t=ot(t)}return null}function mo(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Bh=new Set(["html","body","#document"]);function Kt(e){return Bh.has(tn(e))}function Le(e){return be(e).getComputedStyle(e)}function bs(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||qo(e)&&e.host||Ue(e);return qo(t)?t.host:t}function dr(e){const t=ot(e);return Kt(t)?e.ownerDocument?e.ownerDocument.body:e.body:Fe(t)&&In(t)?t:dr(t)}function wn(e,t,n){var o;t===void 0&&(t=[]),n===void 0&&(n=!0);const a=dr(e),r=a===((o=e.ownerDocument)==null?void 0:o.body),i=be(a);if(r){const c=Ws(i);return t.concat(i,i.visualViewport||[],In(a)?a:[],c&&n?wn(c):[])}return t.concat(a,wn(a,[],n))}function Ws(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function hr(e){const t=Le(e);let n=parseFloat(t.width)||0,o=parseFloat(t.height)||0;const a=Fe(e),r=a?e.offsetWidth:n,i=a?e.offsetHeight:o,c=ss(n)!==r||ss(o)!==i;return c&&(n=r,o=i),{width:n,height:o,$:c}}function fo(e){return Te(e)?e:e.contextElement}function Ht(e){const t=fo(e);if(!Fe(t))return De(1);const n=t.getBoundingClientRect(),{width:o,height:a,$:r}=hr(t);let i=(r?ss(n.width):n.width)/o,c=(r?ss(n.height):n.height)/a;return(!i||!Number.isFinite(i))&&(i=1),(!c||!Number.isFinite(c))&&(c=1),{x:i,y:c}}const qh=De(0);function mr(e){const t=be(e);return!mo()||!t.visualViewport?qh:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Uh(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==be(e)?!1:t}function _t(e,t,n,o){t===void 0&&(t=!1),n===void 0&&(n=!1);const a=e.getBoundingClientRect(),r=fo(e);let i=De(1);t&&(o?Te(o)&&(i=Ht(o)):i=Ht(e));const c=Uh(r,n,o)?mr(r):De(0);let u=(a.left+c.x)/i.x,d=(a.top+c.y)/i.y,m=a.width/i.x,h=a.height/i.y;if(r){const p=be(r),g=o&&Te(o)?be(o):o;let b=p,x=Ws(b);for(;x&&o&&g!==b;){const v=Ht(x),y=x.getBoundingClientRect(),f=Le(x),w=y.left+(x.clientLeft+parseFloat(f.paddingLeft))*v.x,C=y.top+(x.clientTop+parseFloat(f.paddingTop))*v.y;u*=v.x,d*=v.y,m*=v.x,h*=v.y,u+=w,d+=C,b=be(x),x=Ws(b)}}return as({width:m,height:h,x:u,y:d})}function vs(e,t){const n=bs(e).scrollLeft;return t?t.left+n:_t(Ue(e)).left+n}function fr(e,t){const n=e.getBoundingClientRect(),o=n.left+t.scrollLeft-vs(e,n),a=n.top+t.scrollTop;return{x:o,y:a}}function Wh(e){let{elements:t,rect:n,offsetParent:o,strategy:a}=e;const r=a==="fixed",i=Ue(o),c=t?xs(t.floating):!1;if(o===i||c&&r)return n;let u={scrollLeft:0,scrollTop:0},d=De(1);const m=De(0),h=Fe(o);if((h||!h&&!r)&&((tn(o)!=="body"||In(i))&&(u=bs(o)),Fe(o))){const g=_t(o);d=Ht(o),m.x=g.x+o.clientLeft,m.y=g.y+o.clientTop}const p=i&&!h&&!r?fr(i,u):De(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 Hh(e){return Array.from(e.getClientRects())}function zh(e){const t=Ue(e),n=bs(e),o=e.ownerDocument.body,a=Ct(t.scrollWidth,t.clientWidth,o.scrollWidth,o.clientWidth),r=Ct(t.scrollHeight,t.clientHeight,o.scrollHeight,o.clientHeight);let i=-n.scrollLeft+vs(e);const c=-n.scrollTop;return Le(o).direction==="rtl"&&(i+=Ct(t.clientWidth,o.clientWidth)-a),{width:a,height:r,x:i,y:c}}const Uo=25;function Vh(e,t){const n=be(e),o=Ue(e),a=n.visualViewport;let r=o.clientWidth,i=o.clientHeight,c=0,u=0;if(a){r=a.width,i=a.height;const m=mo();(!m||m&&t==="fixed")&&(c=a.offsetLeft,u=a.offsetTop)}const d=vs(o);if(d<=0){const m=o.ownerDocument,h=m.body,p=getComputedStyle(h),g=m.compatMode==="CSS1Compat"&&parseFloat(p.marginLeft)+parseFloat(p.marginRight)||0,b=Math.abs(o.clientWidth-h.clientWidth-g);b<=Uo&&(r-=b)}else d<=Uo&&(r+=d);return{width:r,height:i,x:c,y:u}}const Qh=new Set(["absolute","fixed"]);function Kh(e,t){const n=_t(e,!0,t==="fixed"),o=n.top+e.clientTop,a=n.left+e.clientLeft,r=Fe(e)?Ht(e):De(1),i=e.clientWidth*r.x,c=e.clientHeight*r.y,u=a*r.x,d=o*r.y;return{width:i,height:c,x:u,y:d}}function Wo(e,t,n){let o;if(t==="viewport")o=Vh(e,n);else if(t==="document")o=zh(Ue(e));else if(Te(t))o=Kh(t,n);else{const a=mr(e);o={x:t.x-a.x,y:t.y-a.y,width:t.width,height:t.height}}return as(o)}function pr(e,t){const n=ot(e);return n===t||!Te(n)||Kt(n)?!1:Le(n).position==="fixed"||pr(n,t)}function Gh(e,t){const n=t.get(e);if(n)return n;let o=wn(e,[],!1).filter(c=>Te(c)&&tn(c)!=="body"),a=null;const r=Le(e).position==="fixed";let i=r?ot(e):e;for(;Te(i)&&!Kt(i);){const c=Le(i),u=ho(i);!u&&c.position==="fixed"&&(a=null),(r?!u&&!a:!u&&c.position==="static"&&!!a&&Qh.has(a.position)||In(i)&&!u&&pr(e,i))?o=o.filter(m=>m!==i):a=c,i=ot(i)}return t.set(e,o),o}function Yh(e){let{element:t,boundary:n,rootBoundary:o,strategy:a}=e;const i=[...n==="clippingAncestors"?xs(t)?[]:Gh(t,this._c):[].concat(n),o],c=i[0],u=i.reduce((d,m)=>{const h=Wo(t,m,a);return d.top=Ct(h.top,d.top),d.right=Qt(h.right,d.right),d.bottom=Qt(h.bottom,d.bottom),d.left=Ct(h.left,d.left),d},Wo(t,c,a));return{width:u.right-u.left,height:u.bottom-u.top,x:u.left,y:u.top}}function Jh(e){const{width:t,height:n}=hr(e);return{width:t,height:n}}function Xh(e,t,n){const o=Fe(t),a=Ue(t),r=n==="fixed",i=_t(e,!0,r,t);let c={scrollLeft:0,scrollTop:0};const u=De(0);function d(){u.x=vs(a)}if(o||!o&&!r)if((tn(t)!=="body"||In(a))&&(c=bs(t)),o){const g=_t(t,!0,r,t);u.x=g.x+t.clientLeft,u.y=g.y+t.clientTop}else a&&d();r&&!o&&a&&d();const m=a&&!o&&!r?fr(a,c):De(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 Rs(e){return Le(e).position==="static"}function Ho(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 gr(e,t){const n=be(e);if(xs(e))return n;if(!Fe(e)){let a=ot(e);for(;a&&!Kt(a);){if(Te(a)&&!Rs(a))return a;a=ot(a)}return n}let o=Ho(e,t);for(;o&&Ih(o)&&Rs(o);)o=Ho(o,t);return o&&Kt(o)&&Rs(o)&&!ho(o)?n:o||Fh(e)||n}const Zh=async function(e){const t=this.getOffsetParent||gr,n=this.getDimensions,o=await n(e.floating);return{reference:Xh(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}};function em(e){return Le(e).direction==="rtl"}const tm={convertOffsetParentRelativeRectToViewportRelativeRect:Wh,getDocumentElement:Ue,getClippingRect:Yh,getOffsetParent:gr,getElementRects:Zh,getClientRects:Hh,getDimensions:Jh,getScale:Ht,isElement:Te,isRTL:em};function xr(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function nm(e,t){let n=null,o;const a=Ue(e);function r(){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),r();const d=e.getBoundingClientRect(),{left:m,top:h,width:p,height:g}=d;if(c||t(),!p||!g)return;const b=Vn(h),x=Vn(a.clientWidth-(m+p)),v=Vn(a.clientHeight-(h+g)),y=Vn(m),w={rootMargin:-b+"px "+-x+"px "+-v+"px "+-y+"px",threshold:Ct(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&&!xr(d,e.getBoundingClientRect())&&i(),C=!1}try{n=new IntersectionObserver(_,{...w,root:a.ownerDocument})}catch{n=new IntersectionObserver(_,w)}n.observe(e)}return i(!0),r}function sm(e,t,n,o){o===void 0&&(o={});const{ancestorScroll:a=!0,ancestorResize:r=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:c=typeof IntersectionObserver=="function",animationFrame:u=!1}=o,d=fo(e),m=a||r?[...d?wn(d):[],...wn(t)]:[];m.forEach(y=>{a&&y.addEventListener("scroll",n,{passive:!0}),r&&y.addEventListener("resize",n)});const h=d&&c?nm(d,n):null;let p=-1,g=null;i&&(g=new ResizeObserver(y=>{let[f]=y;f&&f.target===d&&g&&(g.unobserve(t),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var w;(w=g)==null||w.observe(t)})),n()}),d&&!u&&g.observe(d),g.observe(t));let b,x=u?_t(e):null;u&&v();function v(){const y=_t(e);x&&!xr(x,y)&&n(),x=y,b=requestAnimationFrame(v)}return n(),()=>{var y;m.forEach(f=>{a&&f.removeEventListener("scroll",n),r&&f.removeEventListener("resize",n)}),h?.(),(y=g)==null||y.disconnect(),g=null,u&&cancelAnimationFrame(b)}}const om=Th,am=Lh,rm=kh,im=Sh,zo=(e,t,n)=>{const o=new Map,a={platform:tm,...n},r={...a.platform,_c:o};return _h(e,t,{...a,platform:r})};var Ts={exports:{}};var Vo;function lm(){return Vo||(Vo=1,(function(e){(function(){var t={}.hasOwnProperty;function n(){for(var r="",i=0;i<arguments.length;i++){var c=arguments[i];c&&(r=a(r,o(c)))}return r}function o(r){if(typeof r=="string"||typeof r=="number")return r;if(typeof r!="object")return"";if(Array.isArray(r))return n.apply(null,r);if(r.toString!==Object.prototype.toString&&!r.toString.toString().includes("[native code]"))return r.toString();var i="";for(var c in r)t.call(r,c)&&r[c]&&(i=a(i,c));return i}function a(r,i){return i?r?r+" "+i:r+i:r}e.exports?(n.default=n,e.exports=n):window.classNames=n})()})(Ts)),Ts.exports}var cm=lm();const Hs=Jr(cm);var Qo={};const um="react-tooltip-core-styles",dm="react-tooltip-base-styles",Ko={core:!1,base:!1};function Go({css:e,id:t=dm,type:n="base",ref:o}){var a,r;if(!e||typeof document>"u"||Ko[n]||n==="core"&&typeof process<"u"&&(!((a=process==null?void 0:Qo)===null||a===void 0)&&a.REACT_TOOLTIP_DISABLE_CORE_STYLES)||n!=="base"&&typeof process<"u"&&(!((r=process==null?void 0:Qo)===null||r===void 0)&&r.REACT_TOOLTIP_DISABLE_BASE_STYLES))return;n==="core"&&(t=um),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)),Ko[n]=!0}const Yo=async({elementReference:e=null,tooltipReference:t=null,tooltipArrowReference:n=null,place:o="top",offset:a=10,strategy:r="absolute",middlewares:i=[om(Number(a)),rm({fallbackAxisSideDirection:"start"}),am({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(im({element:n,padding:5})),zo(e,t,{placement:o,strategy:r,middleware:d}).then((({x:m,y:h,placement:p,middlewareData:g})=>{var b,x;const v={left:`${m}px`,top:`${h}px`,border:c},{x:y,y:f}=(b=g.arrow)!==null&&b!==void 0?b:{x:0,y:0},w=(x={top:"bottom",right:"left",bottom:"top",left:"right"}[p.split("-")[0]])!==null&&x!==void 0?x:"bottom",C=c&&{borderBottom:c,borderRight:c};let _=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}}))):zo(e,t,{placement:"bottom",strategy:r,middleware:d}).then((({x:m,y:h,placement:p})=>({tooltipStyles:{left:`${m}px`,top:`${h}px`},tooltipArrowStyles:{},place:p})))},Jo=(e,t)=>!("CSS"in window&&"supports"in window.CSS)||window.CSS.supports(e,t),Xo=(e,t,n)=>{let o=null;const a=function(...r){const i=()=>{o=null};!o&&(e.apply(this,r),o=setTimeout(i,t))};return a.cancel=()=>{o&&(clearTimeout(o),o=null)},a},Zo=e=>e!==null&&!Array.isArray(e)&&typeof e=="object",zs=(e,t)=>{if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every(((a,r)=>zs(a,t[r])));if(Array.isArray(e)!==Array.isArray(t))return!1;if(!Zo(e)||!Zo(t))return e===t;const n=Object.keys(e),o=Object.keys(t);return n.length===o.length&&n.every((a=>zs(e[a],t[a])))},hm=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"}))},ea=e=>{if(!e)return null;let t=e.parentElement;for(;t;){if(hm(t))return t;t=t.parentElement}return document.scrollingElement||document.documentElement},mm=typeof window<"u"?l.useLayoutEffect:l.useEffect,Ce=e=>{e.current&&(clearTimeout(e.current),e.current=null)},fm="DEFAULT_TOOLTIP_ID",pm={anchorRefs:new Set,activeAnchor:{current:null},attach:()=>{},detach:()=>{},setActiveAnchor:()=>{}},gm=l.createContext({getTooltipData:()=>pm});function br(e=fm){return l.useContext(gm).getTooltipData(e)}var Ut={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"},Ls={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 xm=({forwardRef:e,id:t,className:n,classNameArrow:o,variant:a="dark",anchorId:r,anchorSelect:i,place:c="top",offset:u=10,events:d=["hover"],openOnClick:m=!1,positionStrategy:h="absolute",middlewares:p,wrapper:g,delayShow:b=0,delayHide:x=0,float:v=!1,hidden:y=!1,noArrow:f=!1,clickable:w=!1,closeOnEsc:C=!1,closeOnScroll:_=!1,closeOnResize:k=!1,openEvents:j,closeEvents:S,globalCloseEvents:I,imperativeModeOnly:F,style:se,position:ye,afterShow:Pe,afterHide:q,disableTooltip:de,content:oe,contentWrapperRef:J,isOpen:H,defaultIsOpen:ae=!1,setIsOpen:We,previousActiveAnchor:nn,activeAnchor:U,setActiveAnchor:St,border:On,opacity:Mn,arrowColor:Dn,arrowSize:kt=8,role:ys="tooltip"})=>{var lt;const he=l.useRef(null),Et=l.useRef(null),Se=l.useRef(null),ct=l.useRef(null),Rt=l.useRef(null),[ut,$n]=l.useState({tooltipStyles:{},tooltipArrowStyles:{},place:c}),[me,sn]=l.useState(!1),[Tt,Je]=l.useState(!1),[V,Lt]=l.useState(null),Fn=l.useRef(!1),At=l.useRef(null),{anchorRefs:Bn,setActiveAnchor:on}=br(t),an=l.useRef(!1),[Xe,rn]=l.useState([]),dt=l.useRef(!1),Pt=m||d.includes("click"),qn=Pt||j?.click||j?.dblclick||j?.mousedown,ln=j?{...j}:{mouseover:!0,focus:!0,mouseenter:!1,click:!1,dblclick:!1,mousedown:!1};!j&&Pt&&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&&Pt&&Object.assign(ht,{mouseleave:!1,blur:!1,mouseout:!1});const ee=I?{...I}:{escape:C||!1,scroll:_||!1,resize:k||!1,clickOutsideAnchor:qn||!1};F&&(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})),mm((()=>(dt.current=!0,()=>{dt.current=!1})),[]);const fe=N=>{dt.current&&(N&&Je(!0),setTimeout((()=>{dt.current&&(We?.(N),H===void 0&&sn(N))}),10))};l.useEffect((()=>{if(t){if(me){R(nn);const E=N(U),B=[...new Set([...E,t])].filter(Boolean).join(" ");U?.setAttribute("aria-describedby",B)}else R(U);return()=>{R(U),R(nn)}}function N(E){var B;return((B=E?.getAttribute("aria-describedby"))===null||B===void 0?void 0:B.split(" "))||[]}function R(E){const B=N(E).filter((Z=>Z!==t));B.length?E?.setAttribute("aria-describedby",B.join(" ")):E?.removeAttribute("aria-describedby")}}),[U,me,t,nn]),l.useEffect((()=>{if(H===void 0)return()=>null;H&&Je(!0);const N=setTimeout((()=>{sn(H)}),10);return()=>{clearTimeout(N)}}),[H]),l.useEffect((()=>{if(me!==Fn.current)if(Ce(Rt),Fn.current=me,me)Pe?.();else{const N=(R=>{const E=R.match(/^([\d.]+)(ms|s)$/);if(!E)return 0;const[,B,Z]=E;return Number(B)*(Z==="ms"?1:1e3)})(getComputedStyle(document.body).getPropertyValue("--rt-transition-show-delay"));Rt.current=setTimeout((()=>{Je(!1),Lt(null),q?.()}),N+25)}}),[me]);const cn=N=>{$n((R=>zs(R,N)?R:N))},un=(N=b)=>{Ce(Se),Tt?fe(!0):Se.current=setTimeout((()=>{fe(!0)}),N)},It=(N=x)=>{Ce(ct),ct.current=setTimeout((()=>{an.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 St(null),void on({current:null});b?un():fe(!0),St(E),on({current:E}),Ce(ct)},Ot=()=>{w?It(x||100):x?It():fe(!1),Ce(Se)},Mt=({x:N,y:R})=>{var E;const B={getBoundingClientRect:()=>({x:N,y:R,width:0,height:0,top:R,left:N,right:N,bottom:R})};Yo({place:(E=V?.place)!==null&&E!==void 0?E:c,offset:u,elementReference:B,tooltipReference:he.current,tooltipArrowReference:Et.current,strategy:h,middlewares:p,border:On,arrowSize:kt}).then((Z=>{cn(Z)}))},Dt=N=>{if(!N)return;const R=N,E={x:R.clientX,y:R.clientY};Mt(E),At.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='${r}']`),...Xe].some((B=>B?.contains(E)))||(fe(!1),Ce(Se)))},Un=Xo(dn,50),G=Xo(Ot,50),re=N=>{G.cancel(),Un(N)},L=()=>{Un.cancel(),G()},M=l.useCallback((()=>{var N,R;const E=(N=V?.position)!==null&&N!==void 0?N:ye;E?Mt(E):v?At.current&&Mt(At.current):U?.isConnected&&Yo({place:(R=V?.place)!==null&&R!==void 0?R:c,offset:u,elementReference:U,tooltipReference:he.current,tooltipArrowReference:Et.current,strategy:h,middlewares:p,border:On,arrowSize:kt}).then((B=>{dt.current&&cn(B)}))}),[me,U,oe,se,c,V?.place,u,h,ye,V?.position,v,kt]);l.useEffect((()=>{var N,R;const E=new Set(Bn);Xe.forEach(($=>{de?.($)||E.add({current:$})}));const B=document.querySelector(`[id='${r}']`);B&&!de?.(B)&&E.add({current:B});const Z=()=>{fe(!1)},Ie=ea(U),Oe=ea(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):U&&he.current&&(ie=sm(U,he.current,M,{ancestorResize:!0,elementResize:!0,layoutShift:!0}));const we=$=>{$.key==="Escape"&&fe(!1)};ee.escape&&window.addEventListener("keydown",we),ee.clickOutsideAnchor&&window.addEventListener("click",hn);const W=[],$t=$=>!!($?.target&&U?.contains($.target)),$r=$=>{me&&$t($)||dn($)},Fr=$=>{me&&$t($)&&Ot()},xo=["mouseover","mouseout","mouseenter","mouseleave","focus","blur"],bo=["click","dblclick","mousedown","mouseup"];Object.entries(ln).forEach((([$,He])=>{He&&(xo.includes($)?W.push({event:$,listener:re}):bo.includes($)&&W.push({event:$,listener:$r}))})),Object.entries(ht).forEach((([$,He])=>{He&&(xo.includes($)?W.push({event:$,listener:L}):bo.includes($)&&W.push({event:$,listener:Fr}))})),v&&W.push({event:"pointermove",listener:Dt});const vo=()=>{an.current=!0},yo=()=>{an.current=!1,Ot()},wo=w&&(ht.mouseout||ht.mouseleave);return wo&&((N=he.current)===null||N===void 0||N.addEventListener("mouseover",vo),(R=he.current)===null||R===void 0||R.addEventListener("mouseout",yo)),W.forEach((({event:$,listener:He})=>{E.forEach((ws=>{var mn;(mn=ws.current)===null||mn===void 0||mn.addEventListener($,He)}))})),()=>{var $,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),wo&&(($=he.current)===null||$===void 0||$.removeEventListener("mouseover",vo),(He=he.current)===null||He===void 0||He.removeEventListener("mouseout",yo)),W.forEach((({event:ws,listener:mn})=>{E.forEach((Br=>{var Cs;(Cs=Br.current)===null||Cs===void 0||Cs.removeEventListener(ws,mn)}))}))}}),[U,M,Tt,Bn,Xe,j,S,I,Pt,b,x]),l.useEffect((()=>{var N,R;let E=(R=(N=V?.anchorSelect)!==null&&N!==void 0?N:i)!==null&&R!==void 0?R:"";!E&&t&&(E=`[data-tooltip-id='${t.replace(/'/g,"\\'")}']`);const B=new MutationObserver((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(U){const we=[...ie.removedNodes].filter((W=>W.nodeType===1));if(E)try{Oe.push(...we.filter((W=>W.matches(E)))),Oe.push(...we.flatMap((W=>[...W.querySelectorAll(E)])))}catch{}we.some((W=>{var $t;return!!(!(($t=W?.contains)===null||$t===void 0)&&$t.call(W,U))&&(Je(!1),fe(!1),St(null),Ce(Se),Ce(ct),!0)}))}if(E)try{const we=[...ie.addedNodes].filter((W=>W.nodeType===1));Ie.push(...we.filter((W=>W.matches(E)))),Ie.push(...we.flatMap((W=>[...W.querySelectorAll(E)])))}catch{}}})),(Ie.length||Oe.length)&&rn((ie=>[...ie.filter((we=>!Oe.includes(we))),...Ie]))}));return B.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-tooltip-id"],attributeOldValue:!0}),()=>{B.disconnect()}}),[t,i,V?.anchorSelect,U]),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='${r}']`),E=[...Xe,R];U&&E.includes(U)||St((N=Xe[0])!==null&&N!==void 0?N:R)}),[r,Xe,U]),l.useEffect((()=>(ae&&fe(!0),()=>{Ce(Se),Ce(ct)})),[]),l.useEffect((()=>{var N;let R=(N=V?.anchorSelect)!==null&&N!==void 0?N:i;if(!R&&t&&(R=`[data-tooltip-id='${t.replace(/'/g,"\\'")}']`),R)try{const E=Array.from(document.querySelectorAll(R));rn(E)}catch{rn([])}}),[t,i,V?.anchorSelect]),l.useEffect((()=>{Se.current&&(Ce(Se),un(b))}),[b]);const xe=(lt=V?.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`)}Lt(N??null),N?.delay?un(N.delay):fe(!0)},close:N=>{N?.delay?It(N.delay):fe(!1)},activeAnchor:U,place:ut.place,isOpen:!!(Tt&&!y&&xe&&mt)}))),Tt&&!y&&xe?Ze.createElement(g,{id:t,role:ys,className:Hs("react-tooltip",Ut.tooltip,Ls.tooltip,Ls[a],n,`react-tooltip__place-${ut.place}`,Ut[mt?"show":"closing"],mt?"react-tooltip__show":"react-tooltip__closing",h==="fixed"&&Ut.fixed,w&&Ut.clickable),onTransitionEnd:N=>{Ce(Rt),me||N.propertyName!=="opacity"||(Je(!1),Lt(null),q?.())},style:{...se,...ut.tooltipStyles,opacity:Mn!==void 0&&mt?Mn:void 0},ref:he},xe,Ze.createElement(g,{className:Hs("react-tooltip-arrow",Ut.arrow,Ls.arrow,o,f&&Ut.noArrow),style:{...ut.tooltipArrowStyles,background:Dn?`linear-gradient(to right bottom, transparent 50%, ${Dn} 50%)`:void 0,"--rt-arrow-size":`${kt}px`},ref:Et})):null},bm=({content:e})=>Ze.createElement("span",{dangerouslySetInnerHTML:{__html:e}}),rs=Ze.forwardRef((({id:e,anchorId:t,anchorSelect:n,content:o,html:a,render:r,className:i,classNameArrow:c,variant:u="dark",place:d="top",offset:m=10,wrapper:h="div",children:p=null,events:g=["hover"],openOnClick:b=!1,positionStrategy:x="absolute",middlewares:v,delayShow:y=0,delayHide:f=0,float:w=!1,hidden:C=!1,noArrow:_=!1,clickable:k=!1,closeOnEsc:j=!1,closeOnScroll:S=!1,closeOnResize:I=!1,openEvents:F,closeEvents:se,globalCloseEvents:ye,imperativeModeOnly:Pe=!1,style:q,position:de,isOpen:oe,defaultIsOpen:J=!1,disableStyleInjection:H=!1,border:ae,opacity:We,arrowColor:nn,arrowSize:U,setIsOpen:St,afterShow:On,afterHide:Mn,disableTooltip:Dn,role:kt="tooltip"},ys)=>{const[lt,he]=l.useState(o),[Et,Se]=l.useState(a),[ct,Rt]=l.useState(d),[ut,$n]=l.useState(u),[me,sn]=l.useState(m),[Tt,Je]=l.useState(y),[V,Lt]=l.useState(f),[Fn,At]=l.useState(w),[Bn,on]=l.useState(C),[an,Xe]=l.useState(h),[rn,dt]=l.useState(g),[Pt,qn]=l.useState(x),[ln,ht]=l.useState(null),[ee,fe]=l.useState(null),cn=l.useRef(null),un=l.useRef(H),{anchorRefs:It,activeAnchor:dn}=br(e),Ot=G=>G?.getAttributeNames().reduce(((re,L)=>{var M;return L.startsWith("data-tooltip-")&&(re[L.replace(/^data-tooltip-/,"")]=(M=G?.getAttribute(L))!==null&&M!==void 0?M:null),re}),{}),Mt=G=>{const re={place:L=>{var M;Rt((M=L)!==null&&M!==void 0?M:d)},content:L=>{he(L??o)},html:L=>{Se(L??a)},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??g)},"position-strategy":L=>{var M;qn((M=L)!==null&&M!==void 0?M:x)},"delay-show":L=>{Je(L===null?y:Number(L))},"delay-hide":L=>{Lt(L===null?f:Number(L))},float:L=>{At(L===null?w:L==="true")},hidden:L=>{on(L===null?C:L==="true")},"class-name":L=>{ht(L)}};Object.values(re).forEach((L=>L(null))),Object.entries(G).forEach((([L,M])=>{var xe;(xe=re[L])===null||xe===void 0||xe.call(re,M)}))};l.useEffect((()=>{he(o)}),[o]),l.useEffect((()=>{Se(a)}),[a]),l.useEffect((()=>{Rt(d)}),[d]),l.useEffect((()=>{$n(u)}),[u]),l.useEffect((()=>{sn(m)}),[m]),l.useEffect((()=>{Je(y)}),[y]),l.useEffect((()=>{Lt(f)}),[f]),l.useEffect((()=>{At(w)}),[w]),l.useEffect((()=>{on(C)}),[C]),l.useEffect((()=>{qn(x)}),[x]),l.useEffect((()=>{un.current!==H&&console.warn("[react-tooltip] Do not change `disableStyleInjection` dynamically.")}),[H]),l.useEffect((()=>{typeof window<"u"&&window.dispatchEvent(new CustomEvent("react-tooltip-inject-styles",{detail:{disableCore:H==="core",disableBase:H}}))}),[]),l.useEffect((()=>{var G;const re=new Set(It);let L=n;if(!L&&e&&(L=`[data-tooltip-id='${e.replace(/'/g,"\\'")}']`),L)try{document.querySelectorAll(L).forEach((R=>{re.add({current:R})}))}catch{console.warn(`[react-tooltip] "${L}" is not a valid CSS selector`)}const M=document.querySelector(`[id='${t}']`);if(M&&re.add({current:M}),!re.size)return()=>null;const xe=(G=ee??M)!==null&&G!==void 0?G:dn.current,mt=new MutationObserver((R=>{R.forEach((E=>{var B;if(!xe||E.type!=="attributes"||!(!((B=E.attributeName)===null||B===void 0)&&B.startsWith("data-tooltip-")))return;const Z=Ot(xe);Mt(Z)}))})),N={attributes:!0,childList:!1,subtree:!1};if(xe){const R=Ot(xe);Mt(R),mt.observe(xe,N)}return()=>{mt.disconnect()}}),[It,dn,ee,t,n]),l.useEffect((()=>{q?.border&&console.warn("[react-tooltip] Do not set `style.border`. Use `border` prop instead."),ae&&!Jo("border",`${ae}`)&&console.warn(`[react-tooltip] "${ae}" is not a valid \`border\`.`),q?.opacity&&console.warn("[react-tooltip] Do not set `style.opacity`. Use `opacity` prop instead."),We&&!Jo("opacity",`${We}`)&&console.warn(`[react-tooltip] "${We}" is not a valid \`opacity\`.`)}),[]);let Dt=p;const hn=l.useRef(null);if(r){const G=r({content:ee?.getAttribute("data-tooltip-content")||lt||null,activeAnchor:ee});Dt=G?Ze.createElement("div",{ref:hn,className:"react-tooltip-content-wrapper"},G):null}else lt&&(Dt=lt);Et&&(Dt=Ze.createElement(bm,{content:Et}));const Un={forwardRef:ys,id:e,anchorId:t,anchorSelect:n,className:Hs(i,ln),classNameArrow:c,content:Dt,contentWrapperRef:hn,place:ct,variant:ut,offset:me,wrapper:an,events:rn,openOnClick:b,positionStrategy:Pt,middlewares:v,delayShow:Tt,delayHide:V,float:Fn,hidden:Bn,noArrow:_,clickable:k,closeOnEsc:j,closeOnScroll:S,closeOnResize:I,openEvents:F,closeEvents:se,globalCloseEvents:ye,imperativeModeOnly:Pe,style:q,position:de,isOpen:oe,defaultIsOpen:J,border:ae,opacity:We,arrowColor:nn,arrowSize:U,setIsOpen:St,afterShow:On,afterHide:Mn,disableTooltip:Dn,activeAnchor:ee,previousActiveAnchor:cn.current,setActiveAnchor:G=>{fe((re=>(G?.isSameNode(re)||(cn.current=re),G)))},role:kt};return Ze.createElement(xm,{...Un})}));typeof window<"u"&&window.addEventListener("react-tooltip-inject-styles",(e=>{e.detail.disableCore||Go({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||Go({css:`
|
|
4
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 vm=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})),vr=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"})),ym=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})),wm=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"})),yr=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"})),wr=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"})),Cm=()=>{const e=oo(),t=Tc();return{rename:async o=>{if(e){const a=await Ln("New tab name",o);a&&await t.mutateAsync({id:e,payload:{name:a}})}return Promise.resolve()}}},Cr=["shift","alt","meta","mod","ctrl","control"],jm={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(jm[e.trim()]||e.trim()).toLowerCase().replace(/key|digit|numpad/,"")}function jr(e){return Cr.includes(e)}function As(e,t=","){return e.toLowerCase().split(t)}function Ps(e,t="+",n=">",o=!1,a){let r=[],i=!1;e=e.trim(),e.includes(n)?(i=!0,r=e.toLocaleLowerCase().split(n).map(d=>nt(d))):r=e.toLocaleLowerCase().split(t).map(d=>nt(d));const c={alt:r.includes("alt"),ctrl:r.includes("ctrl")||r.includes("control"),shift:r.includes("shift"),meta:r.includes("meta"),mod:r.includes("mod"),useKey:o},u=r.filter(d=>!Cr.includes(d));return{...c,keys:u,description:a,isSequence:i,hotkey:e}}typeof document<"u"&&(document.addEventListener("keydown",e=>{e.code!==void 0&&Nr([nt(e.code)])}),document.addEventListener("keyup",e=>{e.code!==void 0&&_r([nt(e.code)])})),typeof window<"u"&&(window.addEventListener("blur",()=>{Ve.clear()}),window.addEventListener("contextmenu",()=>{setTimeout(()=>{Ve.clear()},0)}));const Ve=new Set;function po(e){return Array.isArray(e)}function Nm(e,t=","){return(po(e)?e:e.split(t)).every(n=>Ve.has(n.trim().toLowerCase()))}function Nr(e){const t=Array.isArray(e)?e:[e];Ve.has("meta")&&Ve.forEach(n=>!jr(n)&&Ve.delete(n.toLowerCase())),t.forEach(n=>Ve.add(n.toLowerCase()))}function _r(e){const t=Array.isArray(e)?e:[e];e==="meta"?Ve.clear():t.forEach(n=>Ve.delete(n.toLowerCase()))}function _m(e,t,n){(typeof n=="function"&&n(e,t)||n===!0)&&e.preventDefault()}function Sm(e,t,n){return typeof n=="function"?n(e,t):n===!0||n===void 0}const km=["input","textarea","select","searchbox","slider","spinbutton","menuitem","menuitemcheckbox","menuitemradio","option","radio","textbox"];function Em(e){return Sr(e,km)}function Sr(e,t=!1){const{target:n,composed:o}=e;let a,r;return Rm(n)&&o?(a=e.composedPath()[0]&&e.composedPath()[0].tagName,r=e.composedPath()[0]&&e.composedPath()[0].role):(a=n&&n.tagName,r=n&&n.role),po(t)?!!(a&&t&&t.some(i=>i.toLowerCase()===a.toLowerCase()||i===r)):!!(a&&t&&t)}function Rm(e){return!!e.tagName&&!e.tagName.startsWith("-")&&e.tagName.includes("-")}function Tm(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 Lm=(e,t,n=!1)=>{const{alt:o,meta:a,mod:r,shift:i,ctrl:c,keys:u,useKey:d}=t,{code:m,key:h,ctrlKey:p,metaKey:g,shiftKey:b,altKey:x}=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!==x&&v!=="alt"||i!==b&&v!=="shift")return!1;if(r){if(!g&&!p)return!1}else if(a!==g&&v!=="meta"&&v!=="os"||c!==p&&v!=="ctrl"&&v!=="control")return!1}return u&&u.length===1&&u.includes(v)?!0:u?Nm(u):!u},Am=l.createContext(void 0),Pm=()=>l.useContext(Am);function kr(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&&kr(e[o],t[o]),!0):e===t}const Im=l.createContext({hotkeys:[],activeScopes:[],toggleScope:()=>{},enableScope:()=>{},disableScope:()=>{}}),Om=()=>l.useContext(Im);function Mm(e){const t=l.useRef(void 0);return kr(t.current,e)||(t.current=e),t.current}const ta=e=>{e.stopPropagation(),e.preventDefault(),e.stopImmediatePropagation()},Dm=typeof window<"u"?l.useLayoutEffect:l.useEffect;function Ee(e,t,n,o){const a=l.useRef(null),r=l.useRef(!1),i=Array.isArray(n)?Array.isArray(o)?void 0:o:n,c=po(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=Mm(i),{activeScopes:p}=Om(),g=Pm();return Dm(()=>{if(h?.enabled===!1||!Tm(p,h?.scopes))return;let b=[],x;const v=(C,_=!1)=>{if(!(Em(C)&&!Sr(C,h?.enableOnFormTags))){if(a.current!==null){const k=a.current.getRootNode();if((k instanceof Document||k instanceof ShadowRoot)&&k.activeElement!==a.current&&!a.current.contains(k.activeElement)){ta(C);return}}C.target?.isContentEditable&&!h?.enableOnContentEditable||As(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=Ps(k,h?.splitKey,h?.sequenceSplitKey,h?.useKey,h?.description);if(j.isSequence){x=setTimeout(()=>{b=[]},h?.sequenceTimeoutMs??1e3);const S=j.useKey?C.key:nt(C.code);if(jr(S.toLowerCase()))return;b.push(S);const I=j.keys?.[b.length-1];if(S!==I){b=[],x&&clearTimeout(x);return}b.length===j.keys?.length&&(m.current(C,j),x&&clearTimeout(x),b=[])}else if(Lm(C,j,h?.ignoreModifiers)||j.keys?.includes("*")){if(h?.ignoreEventWhen?.(C)||_&&r.current)return;if(_m(C,j,h?.preventDefault),!Sm(C,j,h?.enabled)){ta(C);return}m.current(C,j),_||(r.current=!0)}})}},y=C=>{C.code!==void 0&&(Nr(nt(C.code)),(h?.keydown===void 0&&h?.keyup!==!0||h?.keydown)&&v(C))},f=C=>{C.code!==void 0&&(_r(nt(C.code)),r.current=!1,h?.keyup&&v(C,!0))},w=a.current||i?.document||document;return w.addEventListener("keyup",f,i?.eventListenerOptions),w.addEventListener("keydown",y,i?.eventListenerOptions),g&&As(c,h?.delimiter).forEach(C=>g.addHotkey(Ps(C,h?.splitKey,h?.sequenceSplitKey,h?.useKey,h?.description))),()=>{w.removeEventListener("keyup",f,i?.eventListenerOptions),w.removeEventListener("keydown",y,i?.eventListenerOptions),g&&As(c,h?.delimiter).forEach(C=>g.removeHotkey(Ps(C,h?.splitKey,h?.sequenceSplitKey,h?.useKey,h?.description))),b=[],x&&clearTimeout(x)}},[c,h,p]),a}function $m(){return s.jsxs("div",{className:"flex md:grid md:grid-cols-3 items-center bg-white overflow-auto no-scrollbar",children:[s.jsx(Fm,{}),s.jsx(Bm,{}),s.jsx(Wm,{})]})}function Fm(){const{dataSourceId:e}=l.useContext(qe),{data:t}=us(e),{state:{table:n}}=l.useContext(ge);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 Bm(){const{page:e,size:t,setPage:n}=rr(),{data:o,isFetching:a}=l.useContext(Ae),r=e*t,i=!a&&!!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:[r+1," - ",r+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 qm=[5,10,20,50,100,200],Um=!__CLIENT_CONFIG__.skipAuth;function Wm(){const{dataSourceId:e,name:t}=l.useContext(qe),{data:n}=us(e),{data:o,refetch:a}=l.useContext(Ae),r=Tn(pe.EDITOR),i=hh(),{rename:c}=Cm(),{size:u,setSize:d}=rr(),{state:m}=l.useContext(ge),h=en(),p=Y(),g=()=>{h.mutateAsync({name:t,opts:m}).then(f=>{p(P.workbenchTab.build({id:f.id}))})},b=()=>{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")}},x=()=>{o?.result.columns?.[0].table&&no({table:o?.result.columns?.[0].table,dataSourceId:e})},v=async()=>{const f=await Ln("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",g),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(yr,{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(wr,{width:16,height:16})}),s.jsx("span",{"data-tooltip-content":"Refresh data","data-tooltip-id":"default",className:A(T.tableAction,T.gray),onClick:()=>a(),role:"button",children:s.jsx(vr,{width:16,height:16})}),Um&&s.jsx("span",{"data-tooltip-content":"Share query","data-tooltip-id":"default",className:A(T.tableAction,T.gray),onClick:b,role:"button",children:s.jsx(wm,{width:16,height:16})}),s.jsx("span",{"data-tooltip-content":"Duplicate tab","data-tooltip-id":"default",className:A(T.tableAction,T.gray),onClick:g,role:"button",children:s.jsx(ym,{width:16,height:16})}),s.jsx(rs,{id:"rows-num",className:"z-10 shadow-md flex gap-1",clickable:!0,variant:"light",opacity:1,children:qm.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(vm,{width:16,height:16})}),s.jsxs(rs,{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"})]}),r&&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:x,className:A(T.tableAction,T.modal,T.gray),children:"Insert new row"})]})]})]})}const Hm="_drop-container_1x8ce_2",zm="_item_1x8ce_2",na={dropContainer:Hm,item:zm},Er=({dataSourceId:e,inputClassName:t,focusId:n,placeholder:o="Column",onChange:a,value:r,autoFocus:i,allowTables:c})=>{const{data:u}=kn(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=r.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,r]),[p,g]=l.useState(!1),[b,x]=l.useState(0),v=f=>{if(f.key==="ArrowDown")f.preventDefault(),x(w=>(w+1)%h.length);else if(f.key==="ArrowUp")f.preventDefault(),x(w=>(w-1+h.length)%h.length);else if(f.key==="Enter"&&b>=0&&b<h.length){f.preventDefault();const w=h[b].value;g(!1);const C=m.findIndex(_=>_.value===w)>-1;a(h[b]?.value||w,C,!0)}};l.useEffect(()=>{const f=d.current?.querySelector('[data-is-active="true"]');f&&f.scrollIntoView({behavior:"smooth",block:"nearest"})},[b]);const y=f=>{const w=f.currentTarget.value,C=m.findIndex(_=>_.value===w)>-1;a(w,C,!1)};return s.jsxs("div",{className:"relative",onFocus:()=>g(!0),onBlur:()=>g(!1),children:[s.jsx("input",{autoFocus:i,onKeyDown:v,value:r,onChange:y,className:t,placeholder:o,"data-focus":n}),p&&h.length>0&&s.jsx("div",{className:na.dropContainer,ref:d,tabIndex:-1,children:h.map((f,w)=>s.jsxs("div",{className:na.item,"data-is-active":b===w,onMouseDownCapture:C=>{C.preventDefault(),g(!1),a(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))})]})},Vm="_actions_1js4i_2",Qm="_filter-actions_1js4i_2",Km="_advanced-filter-icon_1js4i_2",Gm="_filters-container_1js4i_2",Ym="_filter-container_1js4i_2",vn={actions:Vm,filterActions:Qm,advancedFilterIcon:Km,filtersContainer:Gm,filterContainer:Ym},Jm=({filter:e,dataSourceId:t,allowedTables:n,autoFocus:o,onChangeColumn:a,onChangeValue:r,onRemoveFilter:i,onChangeAdvancedFilter:c,triggerIsEnabled:u,onSubmit:d})=>{const m=p=>{const g=p.target.value;g.charAt(0)===":"?c(e.id,!0):(!e.isAdvanced&&["=","<",">"].includes(g.charAt(0))&&c(e.id,!0),r(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(Er,{dataSourceId:t,onChange:p=>a(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(yr,{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(jt,{width:20,height:20,className:"text-red-600"})})})]})},Xm=()=>{const{state:e}=l.useContext(ge),{refetch:t}=l.useContext(Ae),{setFilters:n}=ro(),o=fs(x=>x.filters),a=l.useMemo(()=>[e.table,...e.joins.map(x=>x.table)],[e.table,e.joins]),[r,i]=l.useState([]),c=(x,v)=>{i(y=>[...y.map(f=>f.id===x?{...f,column:v}:f)])},u=(x,v)=>{i(y=>[...y.map(f=>f.id===x?{...f,value:v}:f)])},d=()=>{i(x=>[...x,{id:st(),value:"",column:"",isEnabled:!0}])},m=x=>{i(v=>v.filter(y=>y.id!==x))},h=(x,v)=>{i(y=>y.map(f=>f.id===x?{...f,isAdvanced:v}:f))},p=()=>ps("filters"),g=()=>{try{n(r.filter(x=>x.value.length>0&&x.column.length>0)),setTimeout(t,1),p()}catch(x){x instanceof Error?Re.error(x.message):Re.error("Error during parsing, check you filters")}},b=x=>{i(v=>v.map(y=>y.id===x?{...y,isEnabled:!y.isEnabled}:y))};return l.useEffect(()=>{o&&i(()=>[...e.filters,{id:st(),value:"",column:"",isEnabled:!0}])},[o]),Ee("f",()=>{ns("filters")}),s.jsxs(ve,{isVisible:o,onClose:p,portal:!0,onClosed:()=>i([]),noPadding:!0,backdropClose:!0,children:[s.jsx(rt,{onClick:p}),s.jsx("h2",{className:"text-lg font-semibold m-2",children:"Filters"}),s.jsxs("div",{className:vn.filtersContainer,children:[r.length<1&&s.jsx("p",{className:"p-1 text-center rounded-lg bg-gray-50 border border-gray-200",children:"No filters"}),r.map((x,v)=>s.jsx(Jm,{filter:x,dataSourceId:e.dataSourceId,allowedTables:a,onChangeColumn:c,onChangeValue:u,onRemoveFilter:m,onChangeAdvancedFilter:h,triggerIsEnabled:b,onSubmit:g,autoFocus:v===r.length-1},x.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(wr,{width:20,height:20}),s.jsx("span",{children:"Add filter"})]}),s.jsx("button",{className:"button primary text-sm",onClick:g,children:"Apply filters"})]})]})},Zm="_join-modal_1pj2b_2",ef={joinModal:Zm},tf=(e,t)=>e.type!==t.type||e.on!==t.on||e.table!==t.table,nf=(e,t)=>e.type===t.type&&e.on===t.on&&e.table===t.table,Rr=()=>{const{state:e,setState:t}=l.useContext(ge),n=l.useCallback(o=>{t(a=>{const r=a.joins;if(r.some(c=>nf(c,o))){const c=o.table+".";return{...a,joins:r.filter(u=>tf(u,o)),columns:a.columns.filter(u=>!u.value.startsWith(c)),groupBy:a.groupBy.filter(u=>!u.value.startsWith(c)),orderBy:a.orderBy.filter(u=>!u.column.startsWith(c)),aggregations:a.aggregations.filter(u=>!u.value.startsWith(c)),filters:a.filters.filter(u=>!u.column.startsWith(c))}}return{...a,joins:[...r,o]}})},[t]);return{joins:e.joins,toggle:n}},sf=()=>{const{isFetching:e}=l.useContext(Ae),t=fs(u=>u.joins),{toggle:n}=Rr(),{availableJoins:o}=l.useContext(qe),[a,r]=l.useState(""),i=l.useMemo(()=>{const u=a.toLowerCase();return o.filter(d=>d.on.toTable.toLowerCase().includes(u))},[o,a]),c=()=>ps("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,backdropClose:!0,children:[s.jsx(rt,{onClick:c}),s.jsxs("div",{className:ef.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=>r(u.target.value),value:a,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(tr,{hook:u,onClick:()=>{e||(n({table:u.on.toTable,type:"LEFT",on:u.where}),r(""),c())}},u.where))})]})]})};function of(e){return e.reduce((t,n)=>(t[n]=!0,t),{})}function sa(e){return e.reduce((t,n)=>(t[n]=!0,t),{})}const af="_container_hkce7_2",rf="_column-label_hkce7_2",lf="_not-active_hkce7_2",Zn={container:af,columnLabel:rf,notActive:lf};function cf(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}],gc[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,a])=>(n.push({name:et(o),columns:a}),n),[])}function uf(e,t){const n=t.toLowerCase();return e.map(o=>{const a=o.columns.filter(r=>r.label.toLowerCase().includes(n)||r.ogColumn.toLowerCase().includes(n));return{...o,columns:a}}).filter(o=>o.columns.length>0)}const df=({column:e,selected:t,onCheck:n})=>s.jsxs("label",{className:A(Zn.columnLabel,t?Zn.active:Zn.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),hf={columns:"c",groupBy:"g"},oa=({mode:e})=>{const t=fs(f=>f[e]),{allColumns:n}=l.useContext(qe),{state:o,setState:a}=l.useContext(ge),[r,i]=l.useState({}),[c,u]=l.useState(""),d=l.useMemo(()=>cf(n),[n]),m=o.aggregations.length>0||o.groupBy.length>0,h=l.useMemo(()=>c?uf(d,c):d,[c,d]),p=f=>{i(w=>({...w,[f.target.name]:f.target.checked}))},g=f=>{const w=f.target.checked;i(C=>{for(const _ of n)C[_.full]=w;return{...C}})},b=()=>{ps(e)},x=()=>{const f=[];for(const[w,C]of Object.entries(r))if(C){const[_,k]=w.split(" ");f.push({value:k||_,fn:k?_:void 0})}a(w=>({...w,[e]:f})),b()},v=l.useMemo(()=>{for(const f of n)if(!r[f.full])return!1;return!0},[r,n]);Ee(hf[e],()=>{e==="columns"?m?Re.error("Columns are ignored when there is at least one aggregation or group by"):ns("columns"):ns("groupBy")}),l.useEffect(()=>{t&&i(()=>of(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:b,portal:!0,onClosed:y,backdropClose:!0,children:[s.jsx(rt,{onClick:b}),s.jsxs("div",{className:Zn.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(df,{column:w,selected:r,onCheck:p},w.value))]},f.name))}),s.jsxs("div",{className:"flex justify-end gap-2 mt-2",children:[s.jsxs("label",{className:"button tertiary flex gap-2 items-center",children:[s.jsx("input",{type:"checkbox",checked:v,onChange:g}),s.jsx("span",{children:"Select all"})]}),s.jsx("span",{className:"flex-1"}),s.jsx("button",{className:"button tertiary",onClick:b,children:"Cancel"}),s.jsx("button",{className:"button primary",onClick:x,children:"Apply"})]})]})]})},mf="_options-container_1wdge_2",ff={optionsContainer:mf},Is="COUNT all",pf=()=>{const e=fs(b=>b.aggregate),{dataSourceId:t}=l.useContext(qe),{setState:n,state:o}=l.useContext(ge),{data:a}=l.useContext(Ae),[r,i]=l.useState({fn:"",col:""}),c=b=>i({...r,fn:b.currentTarget.value}),u=b=>i({...r,col:b}),d=()=>ps("aggregate"),m=()=>{const b=r.fn===Is?{value:"*",fn:"COUNT"}:{fn:r.fn,value:r.col,distinct:r.fn==="COUNT"};n(x=>({...x,aggregations:[...x.aggregations,b]}))},h=r.fn===Is,p=h?!1:!r.col||!r.fn,g=b=>{const x=Wa(b);n(v=>({...v,aggregations:v.aggregations.filter(y=>y.fn!==b.fn||y.value!==b.value),orderBy:v.orderBy.filter(y=>y.column!==x)}))};return Ee("a",()=>{ns("aggregate")}),s.jsxs(ve,{isVisible:e,onClose:d,backdropClose:!0,portal:!0,children:[s.jsx(rt,{onClick:d}),s.jsxs("div",{children:[s.jsx("h2",{className:"text-lg font-semibold",children:"Aggregate"}),$e(o.aggregations.length,0)&&s.jsx("div",{className:"flex flex-col gap-1 mt-4",children:o.aggregations.map((b,x)=>s.jsxs("p",{className:"p-2 rounded-md bg-gray-50 flex items-center justify-between",children:[s.jsx("span",{children:Jn(b)}),s.jsx("button",{tabIndex:-1,"data-tooltip-id":"default","data-tooltip-content":"Remove aggregation",className:"p-0.5 text-sm cursor-pointer",onClick:()=>g(b),children:s.jsx(jt,{width:20,height:20,className:"text-red-600"})})]},x))}),s.jsxs("div",{className:ff.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:r.fn,onChange:c,autoFocus:!0,children:[s.jsx("option",{value:"",disabled:!0,children:"Select function"}),s.jsx("option",{value:Is,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(Er,{inputClassName:"input w-full",dataSourceId:t,allowTables:a?.result.tables||[],onChange:u,value:r.col})]}),s.jsx("button",{className:"button primary",disabled:p,onClick:m,children:"Add"})]})]})]})},gf="_container_1291a_2",xf="_yellow-pill_1291a_2 _pill_1291a_2",bf="_blue-pill_1291a_2 _pill_1291a_2",vf="_purple-pill_1291a_2 _pill_1291a_2",yf="_red-pill_1291a_2 _pill_1291a_2",wf="_black-pill_1291a_2 _pill_1291a_2",Cf="_disabled-pill_1291a_2",xt={container:gf,yellowPill:xf,bluePill:bf,purplePill:vf,redPill:yf,blackPill:wf,disabledPill:Cf};function Tr(e,t=500,n){const[o,a]=l.useState(e),r=l.useRef(n);return r.current=n,l.useEffect(()=>{const i=setTimeout(()=>{a(e),r.current&&r.current(e)},t);return()=>clearTimeout(i)},[e,t]),o}function jf(e){return!(e===!0||e===void 0)}const Nf=()=>{const{state:{aggregations:e,columns:t,groupBy:n}}=l.useContext(ge),{toggle:o,joins:a}=Rr(),{filters:r,setFilters:i,removeFilter:c}=ro(),u=()=>Me("joins"),d=()=>Me("aggregate"),m=()=>Me("columns"),h=()=>Me("groupBy"),p=x=>{x.preventDefault(),x.stopPropagation(),o(a[a.length-1])},g=x=>{i(r.map(v=>({...v,isEnabled:x===v.id?jf(v.isEnabled):v.isEnabled})),!0)},b=x=>v=>{v.preventDefault(),v.stopPropagation(),c(x)};return r.length>0||a.length>0||n.length>0||t.length>0||e.length>0?s.jsxs("div",{className:xt.container,children:[a.map((x,v)=>s.jsxs("button",{onClick:u,className:xt.yellowPill,"data-tooltip-id":"default","data-tooltip-content":`Joins ${x.table} on ${x.on}`,children:[s.jsx("p",{className:"text-sm",children:x.table}),v===a.length-1&&s.jsx(jt,{onClick:p,width:18,height:18})]},x.table)),r.map(x=>s.jsxs("button",{onClick:()=>g(x.id),onAuxClick:()=>c(x.id),className:A(xt.bluePill,x.isEnabled===!1&&xt.disabledPill),"data-tooltip-id":"default","data-tooltip-content":`${x.column} ${x.value}`,children:[s.jsx("p",{className:"text-sm",children:x.column}),s.jsx("p",{className:"text-sm",children:x.value}),s.jsx(jt,{onClick:b(x.id),width:18,height:18})]},x.id)),e.map(x=>s.jsx("button",{onClick:d,className:A(xt.purplePill),"data-tooltip-id":"default","data-tooltip-content":Jn(x),children:s.jsx("p",{className:"text-sm",children:Jn(x)})},Jn(x))),t.length>0&&s.jsx("button",{onClick:m,className:A(xt.redPill),"data-tooltip-id":"default","data-tooltip-content":"Has hidden columns",children:s.jsx("p",{className:"text-sm",children:"Hidden columns"})}),n.length>0&&s.jsx("button",{onClick:h,className:A(xt.blackPill),"data-tooltip-id":"default","data-tooltip-content":"Has GROUP BY",children:s.jsx("p",{className:"text-sm",children:"Grouped columns"})}),!1]}):null},_f=({options:e,updater:t,name:n,tabId:o})=>{const a=vc(e,t),r=Lc(o,a.state),i=bc(r.data,a.state.dataSourceId,n,o);return s.jsx(qe,{value:i,children:s.jsx(ge,{value:a,children:s.jsxs(Ae,{value:r,children:[s.jsx($m,{}),s.jsx(Nf,{}),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(dh,{})}),s.jsx(Xm,{}),s.jsx(sf,{}),s.jsx(oa,{mode:"columns"}),s.jsx(oa,{mode:"groupBy"}),s.jsx(pf,{})]})]})})})},go=()=>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..."})]}),Sf=({id:e})=>{const{data:t}=Ec(e),n=l.useCallback(o=>{if(!t)return;const a=o(Zt(t.opts));K.setQueryData(["workbench-tabs",t.id],{...t,opts:{...t.opts,...a}})},[t]);return t?s.jsx(_f,{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(go,{})})},kf=e=>{setTimeout(t=>{const n=document.querySelector(`[data-tab-id="${t}"]`);n&&n.scrollIntoView({behavior:"smooth"})},50,e)},Ef=()=>{const{id:e}=Mi(),t=Y(),{data:n}=ds(),o=Rc(),a=Ya(ao.laptop),r=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),r(d))},c=u=>{o.mutate(u),r(u)};return l.useEffect(()=>{e&&kf(e)},[e,n]),s.jsxs("div",{className:"h-screen max-h-screen bg-(--bg) flex flex-col",children:[e?s.jsx(Sf,{id:e}):s.jsx("div",{className:"flex-1"}),s.jsx("div",{className:A(gn.tabs,"no-scrollbar",!a&&gn.mobile),children:n?.map(u=>s.jsxs("div",{onClick:()=>t(P.workbenchTab.build({id:u.id})),className:A(gn.tab,u.id===e&&gn.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:gn.closeButton,onClick:i,children:s.jsx(jt,{width:20,height:20})})]},u.id))})]})},Rf="_root_m02v8_2",Tf="_up_m02v8_2",Lf="_down_m02v8_2",Af="_chevron_m02v8_2",Pf="_table-name-container_m02v8_2",If="_link_m02v8_2",Of="_table-name_m02v8_2",Mf="_ul_m02v8_2",Df="_column-type_m02v8_2",$f="_action-blue_m02v8_2 _action_m02v8_2",Ff="_action-red_m02v8_2 _action_m02v8_2",Bf="_db-header-container_m02v8_2",qf="_db-header_m02v8_2",Uf="_db-subheader_m02v8_2 _db-header_m02v8_2",te={root:Rf,up:Tf,down:Lf,chevron:Af,tableNameContainer:Pf,link:If,tableName:Of,ul:Mf,columnType:Df,actionBlue:$f,actionRed:Ff,dbHeaderContainer:Bf,dbHeader:qf,dbSubheader:Uf},Wf="_sidebar_9itzl_2",Hf="_sidebar-visible_9itzl_2",zf="_sidebar-container_9itzl_2",Vf="_sidebar-invisible_9itzl_2",Qf="_backdrop_9itzl_2",xn={sidebar:Wf,sidebarVisible:Hf,sidebarContainer:zf,sidebarInvisible:Vf,backdrop:Qf},Lr=({children:e,backdropClose:t,isVisible:n,onClose:o,onClosed:a,contentClassName:r})=>{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),a&&a())};return l.useEffect(()=>{n&&c(!0)},[n]),hs({onClose:d,enabled:n&&t===!0}),s.jsxs("div",{onTransitionEnd:m,className:A(xn.sidebar,n?xn.sidebarVisible:xn.sidebarInvisible),children:[s.jsx("div",{onClick:d,className:xn.backdrop}),s.jsx("div",{className:A(xn.sidebarContainer,r),children:i&&e})]})},Kf=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})),Gf=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"})),Ar=(e,t=!0)=>{const n=navigator.clipboard.writeText(e);t&&n.then(()=>{Re.success(`Copied "${e}"`)})},Yf=new Intl.DateTimeFormat("en",{dateStyle:"full",timeStyle:"long"}),Qn=18;function Jf(e,t){return t&&e.toLowerCase().includes(t)?"bg-yellow-200 cursor-pointer":"cursor-pointer"}const Xf=({insp:e,filter:t,expanded:n})=>{const o=l.useMemo(()=>n?e.columns:t.length<1?[]:e.columns.filter(a=>a.name.toLowerCase().includes(t)),[e,t,n]);return s.jsx("ul",{className:te.ul,children:o.map(a=>s.jsx(s.Fragment,{children:s.jsxs("li",{children:[a.isPrimary?"🔐":"🏷️"," ",s.jsx("span",{onClick:()=>Ar(a.name),className:Jf(a.name,t),children:a.name})," ",s.jsxs("span",{className:te.columnType,children:["[",a.type,"]"]}),a.ref&&s.jsxs("span",{children:[" ➡️ ",s.jsx("span",{className:te.columnType,children:a.ref.table}),".",a.ref.field]})]},a.name+a.type)}))},e.id)};function Zf({id:e}){const{data:t}=us(e),{data:n}=kn(e),o=Y(),a=ic(),r=Ba(),i=lc(),c=en(),u=l.useMemo(()=>t?.lastInspected?Yf.format(new Date(t.lastInspected)):"--",[t]),[d,m]=l.useState({}),[h,p]=l.useState(""),[g,b]=l.useState("table"),x=Tn(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}g!=="table"&&I.columns.findIndex(F=>F.name.toLowerCase().includes(v))>=0&&S.push(I)}return S},[v,n,g]),f=S=>{m(I=>({...I,[S]:!I[S]}))},w=S=>{c.mutateAsync({name:S,opts:Zt({table:S,dataSourceId:e})}).then(I=>{Vt(void 0),o(P.workbenchTab.build({id:I.id}))})},C=()=>{r.mutate(e)},_=async()=>{const S=await Ln("Enter name",t?.name);S&&a.mutate({id:e,dataSource:{name:S}})},k=async()=>{await Ka("Are you sure you want to delete this data source?")&&(i.mutate(e),Vt(void 0))},j=g==="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}),x&&s.jsxs("div",{className:"flex justify-end",children:[s.jsx("button",{disabled:r.isPending,onClick:C,className:te.actionBlue,"data-tooltip-id":"default-xs","data-tooltip-content":"Refresh schema",children:s.jsx(vr,{width:16,height:16})}),s.jsx("button",{disabled:r.isPending,onClick:_,className:te.actionBlue,"data-tooltip-id":"default-xs","data-tooltip-content":"Update name",children:s.jsx(ar,{width:16,height:16})}),s.jsx("button",{disabled:r.isPending,onClick:k,className:te.actionRed,"data-tooltip-id":"default-xs","data-tooltip-content":"Delete data source",children:s.jsx(Gf,{width:16,height:16})})]})]})]}),s.jsxs("div",{className:"flex gap-2 items-center mt-2",children:[s.jsxs("select",{className:"input",value:g,onChange:S=>b(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(Kf,{width:Qn,height:Qn})}),s.jsx("button",{className:te.link,onClick:()=>Ar(S.tableName),"data-tooltip-id":"default-xs","data-tooltip-content":"Copy table name",children:s.jsx(or,{width:Qn,height:Qn})})]}),(d[S.id]||h.length>0)&&s.jsx(Xf,{insp:S,filter:j?v:"",expanded:d[S.id]})]},S.id))})]})}const ep=()=>{const e=du(),[t,n]=l.useState(void 0);l.useEffect(()=>{e&&n(e)},[e]);const o=()=>Vt(void 0);return s.jsx(Lr,{isVisible:e!=null,onClose:o,onClosed:()=>n(void 0),backdropClose:!0,children:t&&s.jsx(Zf,{id:t})})},tp="_search-container_ig228_2",np="_search_ig228_2",sp="_entry_ig228_2",op="_ds_ig228_2",ap="_ds-container_ig228_2",rp="_ds-entry_ig228_2",ip="_enabled_ig228_2",bt={searchContainer:tp,search:np,entry:sp,ds:op,dsContainer:ap,dsEntry:rp,enabled:ip};function lp(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 cp=({storage:e=localStorage,localStorageKey:t,initialData:n})=>{const o=_e(lp(t,n,e));return o[2].subscribe(a=>{e.setItem(t,JSON.stringify(a))}),o},[up,dp]=cp({initialData:[],localStorageKey:"selected-data-sources-v1"}),hp=e=>dp(t=>{const n=t.indexOf(e);return n>-1?(t.splice(n,1),[...t]):[...t,e]}),mp={table:"📄",query:"📖",tab:"🛠️"},fp=({onTable:e,onQuery:t,onWorkbenchTab:n,autoFocus:o})=>{const[a,r]=l.useState(""),[i,c]=l.useState(-1),u=Tr(a,200),d=up(),{data:m}=ue(),{data:h}=eo({teamId:m?.teamId}),p=l.useMemo(()=>{const f=[],w=sa(d);if(!h||h.length===0)return[];for(const C of h)w[C.id]&&f.push(C.id);return f},[d,h]),{data:g}=Yl(u,{teamId:m?.teamId,selectedDataSources:p}),b=f=>{f.type==="table"?e(f.name,f.dataSourceId):f.type==="query"?t(f.id,f.dataSourceId):f.type==="tab"&&n(f.id,f.dataSourceId)},x=f=>{g&&(f.key==="ArrowDown"?(f.preventDefault(),c(w=>(w+1)%g.length)):f.key==="ArrowUp"?(f.preventDefault(),c(w=>(w-1+g.length)%g.length)):f.key==="Enter"&&i>=0&&g[i]?.name&&(f.preventDefault(),b(g[i])))},v=f=>{const w=f.currentTarget.dataset.tableId,C=g?.find(_=>_.id===w);C&&b(C)},y=l.useMemo(()=>sa(d),[d]);return s.jsxs("div",{className:"overflow-hidden flex flex-col w-full lg:w-lg",children:[$e(h?.length,0)?s.jsx("div",{className:bt.dsContainer+" no-scrollbar",children:h.map(f=>s.jsxs("button",{className:A(bt.dsEntry,y[f.id]&&bt.enabled),onClick:()=>hp(f.id),"data-tooltip-id":"default","data-tooltip-content":f.name,children:[s.jsx(it,{size:18,type:f.dbType}),s.jsx("span",{children:f.name})]},f.id))}):s.jsx(ne,{variant:"warning",className:"mb-4",children:"Connect at least one data source to start using DataRamen"}),s.jsxs("div",{className:bt.searchContainer,children:[s.jsx(io,{className:"text-(--text-color-secondary)",width:18,height:18}),s.jsx("input",{className:bt.search,placeholder:"Search table or saved query to start from",value:a,onChange:f=>r(f.target.value),onKeyDown:x,autoFocus:o})]}),$e(g?.length,0)&&s.jsx("div",{className:"overflow-y-auto max-h-full mt-2",children:g.map((f,w)=>s.jsxs("button",{className:bt.entry,"data-is-active":i===w,"data-table-id":f.id,onClick:v,children:[s.jsxs("p",{className:"truncate",children:[mp[f.type]," ",f.name]}),s.jsxs("p",{className:bt.ds,children:["📦 ",f.dataSourceName]})]},f.id))})]})},pp=()=>{const e=Pc(),t=(r,i)=>{e?.onConfirm("table",r,i)},n=(r,i)=>{e?.onConfirm("query",r,i)},o=(r,i)=>{e?.onConfirm("tab",r,i)},a=()=>{e?.onCancel()};return s.jsx(ve,{isVisible:!!e,onClose:a,backdropClose:!0,children:s.jsx(fp,{autoFocus:!0,onTable:t,onQuery:n,onWorkbenchTab:o})})},[gp,Cn]=_e({show:!1}),xp=()=>{const e=Rn("Hotkey"),t=Y(),{pathname:n}=le(),{data:o}=ue(),{data:a}=ds(),r=P.home.check(n);Ee("n",()=>{o&&e()}),Ee("w",()=>{o&&(a&&a.length>0?t(P.workbenchTab.build({id:a[0].id})):e())},{enabled:r}),Ee("h",()=>{Cn({show:!0})})},bp=()=>{const e=le();l.useEffect(()=>{},[e.pathname])},[vp,Pr]=_e(!1),Os=()=>Pr(!1),Ir=()=>Pr(!0),yp=({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,wp=()=>{const e=vp(),{data:t}=ue(),{mutateAsync:n,isPending:o}=cc(),a=Y(),[{password:r,repeatPassword:i},{change:c,touched:u,reset:d}]=jn({password:"",repeatPassword:""}),m=()=>{a("/"),Qs.logout().then(()=>{Os()})},h=()=>{n({password:r}).then(()=>{d(),Re.success("Password successfully updated!")})},p=r.length<8||r!==i||o,g=u.includes("password");return s.jsxs(ve,{isVisible:e,onClose:Os,children:[s.jsx(rt,{onClick:Os}),s.jsxs("div",{className:"w-full lg:w-lg flex flex-col gap-2",children:[s.jsx(Qa,{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:r,onChange:c("password")})]}),s.jsxs("label",{children:[s.jsx("p",{className:"text-xs font-semibold mb-1",children:"Repeat password"}),s.jsx("input",{className:"input w-full",type:"password",value:i,onChange:c("repeatPassword")})]})]}),g&&s.jsx(yp,{password:r,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"})]})]})]})},[Cp,Or]=_e(!1),Mr=()=>Or(!0),aa=()=>Or(!1),jp=e=>ce({queryKey:["team-users"],queryFn:async()=>{const{data:t}=await O.get("/teams/"+e+"/users");return t.data},enabled:!!e}),Np=()=>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"]})}}),_p=()=>X({mutationFn:async({teamId:e,userId:t})=>(await O.delete("/teams/"+e,{params:{userId:t}}),!0),onSuccess:()=>{K.invalidateQueries({queryKey:["team-users"]})}}),Sp="_user-entry_o919l_2",kp="_select-container_o919l_2",ra={userEntry:Sp,selectContainer:kp},Ep=()=>{const e=Cp(),{data:t}=ue(),{data:n}=jp(t?.teamId),{mutate:o,isPending:a}=uc(),{mutate:r,isPending:i}=Np(),{mutate:c,isPending:u}=_p(),[d,{change:m,reset:h}]=jn({password:"",username:""}),p=()=>{o({username:d.username,password:d.password,teamId:t?.teamId||""}),h()},g=(y,f)=>{r({teamId:t.teamId,role:f,userId:y})},b=y=>{Ka("Are you sure you want to remove this user?").then(f=>{f&&c({userId:y,teamId:t.teamId})})},x=Tn(pe.ADMIN),v=a||i||u;return s.jsxs(ve,{isVisible:e,onClose:aa,backdropClose:!0,children:[s.jsx(rt,{onClick:aa}),s.jsxs("div",{className:"w-full lg:w-lg flex flex-col overflow-hidden",children:[s.jsx(Qa,{children:"Manage users"}),$e(n?.length,0)&&s.jsx("div",{className:"mt-4 overflow-y-auto flex-1",children:n.map(y=>s.jsxs("div",{className:ra.userEntry,children:[s.jsx("div",{className:ra.selectContainer,children:s.jsxs("select",{value:y.role,disabled:!x||v,onChange:f=>g(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}),x&&s.jsx("button",{className:"p-1 cursor-pointer text-red-500 text-sm",onClick:()=>b(y.id),children:"❌"})]},y.id))}),x&&s.jsxs("div",{className:"mt-4",children:[s.jsx("p",{className:"font-semibold",children:"Create new user"}),s.jsxs("div",{className:"flex flex-col lg:flex-row gap-2 lg:items-center mt-2",children:[s.jsx("input",{className:"input flex-1",onChange:m("username"),value:d.username,placeholder:"Username",disabled:v}),s.jsx("input",{className:"input",onChange:m("password"),value:d.password,type:"password",name:"newPassword",autoComplete:"new-password",placeholder:"Password",disabled:v}),s.jsx("button",{className:"button primary",onClick:p,disabled:v,children:"Create user"})]}),s.jsx("p",{className:"text-xs mt-1 text-gray-600",children:"You should create default password for the new account. The user should change it after the first login."})]})]})]})},Rp=()=>{const[e,t]=l.useState(""),[n,o]=l.useState(""),[a,r]=l.useState(),[i,c]=l.useState(!1),u=Y(),d=m=>{m.preventDefault(),r(void 0),Qs.login({password:n,username:e}).then(()=>{u("/",{replace:!0})}).catch(r)};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"}),a&&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?"})]})})})},Tp=()=>{const e=Y(),{pathname:t}=le(),{data:n,isLoading:o}=qa();l.useEffect(()=>{!n&&!o&&!P.login.check(t)&&e(P.login.build())},[n,o,e,t])},Lp=()=>{},Ap=__CLIENT_CONFIG__.skipAuth?Lp:Tp,Pp=()=>{const[e]=kl(),t=Y(),n=en(),o=e.get("shareId");return l.useEffect(()=>{o&&n.mutateAsync({queryId:o}).then(a=>{t(P.workbenchTab.build({id:a.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(go,{}),s.jsx("p",{children:"Fetching query information"})]}),n.isError&&s.jsx(ne,{variant:"danger",children:"Failed to load query information"})]})},Ip="_container_wvlsy_2",Op="_header_wvlsy_2",Mp="_close-button_wvlsy_2",Dp="_tab-container_wvlsy_2",$p="_tab-name_wvlsy_2",Fp="_archived-badge_wvlsy_2 _badge_wvlsy_2",Bp="_active-badge_wvlsy_2 _badge_wvlsy_2",qp="_delete-action_wvlsy_2",Up="_load-more-btn_wvlsy_2",ze={container:Ip,header:Op,closeButton:Mp,tabContainer:Dp,tabName:$p,archivedBadge:Fp,activeBadge:Bp,deleteAction:qp,loadMoreBtn:Up},Wp=new Intl.DateTimeFormat,Hp=()=>{const{data:e}=ue(),{data:t,fetchNextPage:n,hasNextPage:o,isFetching:a}=Jl(e?.teamId,25),r=Y(),i=Ha(),c=Ac(),u=l.useRef(null),d=l.useRef(null),m=g=>{i.mutate(g),Cn({show:!1}),r(P.workbenchTab.build({id:g}))},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:()=>Cn({show:!1}),children:s.jsx(jt,{width:24,height:24})})]}),!p&&s.jsx(ne,{variant:"warning",children:"History is empty."}),t?.map(g=>s.jsxs("div",{className:ze.tabContainer,onClick:()=>m(g.id),onContextMenu:b=>{d.current=g.id,u.current?.open(b,!1)},children:[s.jsxs("div",{className:"flex gap-2 items-center",children:[s.jsx("p",{className:ze.tabName,children:g.name}),g.dataSourceType&&s.jsx(it,{size:16,type:g.dataSourceType}),s.jsx("p",{className:"text-xs text-(--text-color-secondary)",children:g.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:Wp.format(new Date(g.updatedAt))}),g.archived?s.jsx("span",{className:ze.archivedBadge,children:"Archived"}):s.jsx("span",{className:ze.activeBadge,children:"Active"})]})]},g.id)),s.jsx(sr,{ref:u,children:s.jsx("button",{onClick:h,className:ze.deleteAction,children:"🗑 Delete"})}),o&&!a&&s.jsx("div",{className:"flex justify-center my-2",children:s.jsx("button",{className:ze.loadMoreBtn,onClick:()=>n(),children:"Load more"})})]})},zp=()=>{const e=gp(t=>t.show);return s.jsx(Lr,{isVisible:e,onClose:()=>Cn({show:!1}),backdropClose:!0,children:s.jsx(Hp,{})})},Vp="_queries-container_cnd4g_2",Qp="_query-entry_cnd4g_2",ia={queriesContainer:Vp,queryEntry:Qp},Kp=()=>{const{data:e}=ue(),[t,n]=l.useState(""),o=Tr(t),{data:a,isLoading:r,fetchNextPage:i,hasNextPage:c}=Xl(e?.teamId,o),u=l.useRef(void 0),d=Y(),m=fh(),h=en(),p=mh(),g=Za(),b=y=>{h.mutateAsync({queryId:y}).then(f=>{d(P.workbenchTab.build({id:f.id}))})},x=async y=>{const f=a?.find(C=>C.id===y);if(!f)return;const w=await Ln("New name?",f?.name);w&&m.mutate({id:f.savedQueryId,payload:{name:w}})},v=y=>{const f=a?.find(w=>w.id===y)?.savedQueryId;f&&p.mutate(f)};return s.jsxs("div",{className:ia.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)})}),$e(a?.length,0)&&a.map(y=>s.jsxs("button",{className:ia.queryEntry,onClick:()=>b(y.id),onContextMenu:f=>{u.current=y.id,g.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"}),!r&&$d(a?.length,1)&&s.jsx("p",{className:"text-center text-sm text-(--text-color-secondary)",children:"Empty"}),s.jsx(er,{handler:g,children:s.jsxs("div",{className:"context-menu-container",children:[s.jsx("button",{onClick:y=>{y.preventDefault(),y.stopPropagation(),g.close(),x(u.current)},className:"context-menu-item",children:"✏️ Rename"}),s.jsx("button",{onClick:y=>{y.preventDefault(),y.stopPropagation(),g.close(),v(u.current)},className:"context-menu-item",children:"🗑️ Delete"})]})})]})},Gp=()=>{const{data:e}=ue(),{data:t,isLoading:n}=tc(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(Kp,{}):s.jsx(s.Fragment,{children:n?s.jsx(go,{}):s.jsx(ne,{variant:"warning",children:"You don't have saved queries."})})]})})},Yp=()=>{const{data:e}=ue(),t=ec(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 Jp(){return xp(),bp(),Ap(),s.jsxs(s.Fragment,{children:[s.jsxs(Ji,{children:[s.jsx(vt,{path:P.home.path,element:s.jsx(Cu,{})}),s.jsx(vt,{path:P.workbench.path,element:s.jsx(Yp,{})}),s.jsx(vt,{path:P.workbenchTab.path,element:s.jsx(Ef,{})}),s.jsx(vt,{path:P.login.path,element:s.jsx(Rp,{})}),s.jsx(vt,{path:P.share.path,element:s.jsx(Pp,{})}),s.jsx(vt,{path:P.savedQueries.path,element:s.jsx(Gp,{})})]}),s.jsx(Iu,{}),s.jsx(Hu,{}),s.jsx(sd,{}),s.jsx(ep,{}),s.jsx(pp,{}),s.jsx(wp,{}),s.jsx(Ep,{}),s.jsx(zp,{}),s.jsx(Xu,{}),s.jsx(Qu,{})]})}const Xp="_hidden_7arb0_2",Zp="_desktop-layout_7arb0_2",e0="_mobile-layout_7arb0_2",t0="_nav_7arb0_2",n0="_shown_7arb0_2",s0="_main_7arb0_2",o0="_header_7arb0_2",a0="_expand_7arb0_2",r0="_show_7arb0_2",i0="_hide_7arb0_2",l0="_icon_7arb0_2",c0="_nav-item_7arb0_2",u0="_project-wrapper_7arb0_2",D={hidden:Xp,desktopLayout:Zp,mobileLayout:e0,nav:t0,shown:n0,main:s0,header:o0,expand:a0,show:r0,hide:i0,icon:l0,navItem:c0,projectWrapper:u0},d0="_container_i6lsu_2",h0={container:d0},m0=({dataSource:e,index:t})=>{const n=()=>{Vt(e.id)};return Ee(t.toString(),()=>{Vt(o=>{if(o!==e.id)return e.id})}),s.jsxs("button",{className:D.navItem,onClick:n,children:[s.jsx("span",{className:D.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})]})},f0=()=>{const{data:e}=ue(),{data:t}=Kl(e?.teamId);return s.jsx("div",{className:h0.container,children:$e(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(m0,{dataSource:n,index:o+1},n.id))]})})},p0=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"})),g0=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"})),x0=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"})),b0=!__CLIENT_CONFIG__.skipAuth,la=(()=>{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 v0(){switch(__CLIENT_CONFIG__.modeName){case"docker":return s.jsx(p0,{className:"text-(--text-color-secondary)",width:20,height:20});case"cli":return s.jsx(g0,{className:"text-(--text-color-secondary)",width:20,height:20});default:return s.jsx(x0,{className:"text-(--text-color-secondary)",width:20,height:20})}}const y0=()=>{const e=Y(),{pathname:t}=le(),{data:n}=ue(),o=Rn("Desktop nav"),[a,r]=l.useState(!1),{data:i}=ds(),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=()=>Cn({show:!0}),h=a?void 0:"default";return s.jsxs("nav",{className:A(D.nav,a?D.shown:D.hidden),children:[n&&s.jsxs("div",{className:D.header,children:[s.jsxs("button",{onClick:c,className:D.navItem,"data-tooltip-id":h,"data-tooltip-content":"Home",children:[s.jsx("span",{className:D.icon,children:"🏠"}),s.jsx("span",{className:"truncate",children:"Home"})]}),s.jsxs("button",{onClick:o,className:D.navItem,"data-tooltip-id":h,"data-tooltip-content":"New query",children:[s.jsx("span",{className:D.icon,children:"🔎"}),s.jsx("span",{className:"truncate",children:"New query"}),s.jsx("span",{className:"hotkey secondary",children:"N"})]}),s.jsxs("button",{onClick:m,className:D.navItem,"data-tooltip-id":h,"data-tooltip-content":"Recent tabs",children:[s.jsx("span",{className:D.icon,children:"⌛"}),s.jsx("span",{className:"truncate",children:"Recent tabs"}),s.jsx("span",{className:"hotkey secondary",children:"H"})]}),s.jsxs("button",{onClick:d,className:D.navItem,"data-tooltip-id":h,"data-tooltip-content":"Saved queries",children:[s.jsx("span",{className:D.icon,children:"💾"}),s.jsx("span",{className:"truncate",children:"Saved queries"})]}),$e(i?.length,0)&&s.jsxs("button",{onClick:()=>u(i[0].id),className:D.navItem,"data-tooltip-id":h,"data-tooltip-content":"Workbench",children:[s.jsx("span",{className:D.icon,children:"🛠️"}),s.jsx("span",{className:"truncate",children:"Workbench"})]}),b0&&s.jsxs(s.Fragment,{children:[s.jsxs("button",{onClick:Ir,className:D.navItem,"data-tooltip-id":h,"data-tooltip-content":"User settings",children:[s.jsx("span",{className:D.icon,children:"🪪"}),s.jsx("span",{className:"truncate",children:n.username})]}),s.jsxs("button",{onClick:Mr,className:D.navItem,"data-tooltip-id":h,"data-tooltip-content":"Manage users",children:[s.jsx("span",{className:D.icon,children:"👥"}),s.jsx("span",{className:"truncate",children:"Manage users"})]})]})]}),s.jsx("div",{className:A(D.projectWrapper,a?D.show:D.hide),children:s.jsx(f0,{})}),s.jsxs("button",{onClick:()=>r(!a),className:`${D.navItem} mx-2`,children:[s.jsx("span",{className:A(D.icon,D.expand,a?D.show:D.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:`${D.navItem} mx-2 mb-2`,"data-tooltip-id":h,"data-tooltip-content":la,children:[s.jsx("span",{className:D.icon,children:s.jsx(v0,{})}),s.jsx("span",{className:"truncate text-sm text-(--text-color-secondary)",children:la})]})]})},w0="_root_r5ahz_2",C0={root:w0},Dr=!__CLIENT_CONFIG__.skipAuth,j0=`${C0.root} ${Dr?"grid-cols-4":"grid-cols-2"}`,N0=()=>{const{pathname:e}=le(),t=Y(),n=Rn("Mobile nav"),o=()=>{P.home.check(e)||t(P.home.build())};return s.jsxs("div",{className:j0,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"})]}),Dr&&s.jsxs(s.Fragment,{children:[s.jsxs("button",{onClick:Ir,children:[s.jsx("p",{children:"🪪"}),s.jsx("p",{className:"text-xs font-semibold text-gray-600",children:"Account"})]}),s.jsxs("button",{onClick:Mr,children:[s.jsx("p",{children:"👥"}),s.jsx("p",{className:"text-xs font-semibold text-gray-600",children:"Users"})]})]})]})},_0=({children:e,isLogin:t})=>s.jsxs("div",{className:D.desktopLayout,children:[s.jsx(rs,{id:"default",className:"z-100"}),s.jsx(rs,{id:"default-xs",className:"z-100 text-xs!"}),!t&&s.jsx(y0,{}),s.jsx("main",{className:D.main,children:e})]}),S0=({children:e,isLogin:t})=>s.jsxs("div",{className:D.mobileLayout,children:[s.jsx("main",{className:D.main,children:e}),!t&&s.jsx(N0,{})]}),k0=({children:e})=>{const t=Ya(ao.laptop),{pathname:n}=le(),o=P.login.check(n);return t?s.jsx(_0,{isLogin:o,children:e}):s.jsx(S0,{isLogin:o,children:e})};Xr.createRoot(document.getElementById("root")).render(s.jsxs(Ze.StrictMode,{children:[s.jsx(Zr,{}),s.jsx(Dl,{client:K,children:s.jsx(Cl,{children:s.jsx(k0,{children:s.jsx(Jp,{})})})})]}));
|