@dataramen/cli 0.0.76 → 0.0.77-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import{r as l,a as Xa,S as jr,p as Ao,b as Te,s as os,c as wn,n as rs,i as qs,d as Io,t as Za,e as Kn,f as ei,g as ti,h as Po,j as ds,k as Mo,l as ni,m as si,o as Oo,q as oi,u as s,v as Xs,w as K,x as $,A as hs,y as ri,z as ai,B as I,C as kn,D as me,E as ke,F as ii,G as li,R as nt,H as ci,I as ui}from"./index-S0ueSkRi.js";var Do="popstate";function di(e={}){function t(o,a){let{pathname:r,search:i,hash:c}=o.location;return Us("",{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:Cn(a)}return mi(t,n,null,e)}function z(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function Ee(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function hi(){return Math.random().toString(36).substring(2,10)}function $o(e,t){return{usr:e.state,key:e.key,idx:t}}function Us(e,t,n=null,o){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?Jt(t):t,state:n,key:t&&t.key||o||hi()}}function Cn({pathname:e="/",search:t="",hash:n=""}){return t&&t!=="?"&&(e+=t.charAt(0)==="?"?t:"?"+t),n&&n!=="#"&&(e+=n.charAt(0)==="#"?n:"#"+n),e}function Jt(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let o=e.indexOf("?");o>=0&&(t.search=e.substring(o),e=e.substring(0,o)),e&&(t.pathname=e)}return t}function mi(e,t,n,o={}){let{window:a=document.defaultView,v5Compat:r=!1}=o,i=a.history,c="POP",u=null,h=m();h==null&&(h=0,i.replaceState({...i.state,idx:h},""));function m(){return(i.state||{idx:null}).idx}function d(){c="POP";let v=m(),y=v==null?null:v-h;h=v,u&&u({action:c,location:g.location,delta:y})}function x(v,y){c="PUSH";let f=Us(g.location,v,y);h=m()+1;let w=$o(f,h),C=g.createHref(f);try{i.pushState(w,"",C)}catch(_){if(_ instanceof DOMException&&_.name==="DataCloneError")throw _;a.location.assign(C)}r&&u&&u({action:c,location:g.location,delta:1})}function p(v,y){c="REPLACE";let f=Us(g.location,v,y);h=m();let w=$o(f,h),C=g.createHref(f);i.replaceState(w,"",C),r&&u&&u({action:c,location:g.location,delta:0})}function b(v){return fi(v)}let g={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(Do,d),u=v,()=>{a.removeEventListener(Do,d),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:x,replace:p,go(v){return i.go(v)}};return g}function fi(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:Cn(e);return o=o.replace(/ $/,"%20"),!t&&o.startsWith("//")&&(o=n+o),new URL(o,n)}function Nr(e,t,n="/"){return pi(e,t,n,!1)}function pi(e,t,n,o){let a=typeof t=="string"?Jt(t):t,r=Ye(a.pathname||"/",n);if(r==null)return null;let i=_r(e);xi(i);let c=null;for(let u=0;c==null&&u<i.length;++u){let h=ki(r);c=_i(i[u],h,o)}return c}function _r(e,t=[],n=[],o="",a=!1){let r=(i,c,u=a,h)=>{let m={relativePath:h===void 0?i.path||"":h,caseSensitive:i.caseSensitive===!0,childrenIndex:c,route:i};if(m.relativePath.startsWith("/")){if(!m.relativePath.startsWith(o)&&u)return;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 d=Ge([o,m.relativePath]),x=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 "${d}".`),_r(i.children,t,x,d,u)),!(i.path==null&&!i.index)&&t.push({path:d,score:ji(d,i.index),routesMeta:x})};return e.forEach((i,c)=>{if(i.path===""||!i.path?.includes("?"))r(i,c);else for(let u of Sr(i.path))r(i,c,!0,u)}),t}function Sr(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=Sr(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 xi(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:Ni(t.routesMeta.map(o=>o.childrenIndex),n.routesMeta.map(o=>o.childrenIndex)))}var gi=/^:[\w-]+$/,bi=3,vi=2,yi=1,wi=10,Ci=-2,Fo=e=>e==="*";function ji(e,t){let n=e.split("/"),o=n.length;return n.some(Fo)&&(o+=Ci),t&&(o+=vi),n.filter(a=>!Fo(a)).reduce((a,r)=>a+(gi.test(r)?bi:r===""?yi:wi),o)}function Ni(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 _i(e,t,n=!1){let{routesMeta:o}=e,a={},r="/",i=[];for(let c=0;c<o.length;++c){let u=o[c],h=c===o.length-1,m=r==="/"?t:t.slice(r.length)||"/",d=Kt({path:u.relativePath,caseSensitive:u.caseSensitive,end:h},m),x=u.route;if(!d&&h&&n&&!o[o.length-1].route.index&&(d=Kt({path:u.relativePath,caseSensitive:u.caseSensitive,end:!1},m)),!d)return null;Object.assign(a,d.params),i.push({params:a,pathname:Ge([r,d.pathname]),pathnameBase:Ti(Ge([r,d.pathnameBase])),route:x}),d.pathnameBase!=="/"&&(r=Ge([r,d.pathnameBase]))}return i}function Kt(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[n,o]=Si(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((h,{paramName:m,isOptional:d},x)=>{if(m==="*"){let b=c[x]||"";i=r.slice(0,r.length-b.length).replace(/(.)\/+$/,"$1")}const p=c[x];return d&&!p?h[m]=void 0:h[m]=(p||"").replace(/%2F/g,"/"),h},{}),pathname:r,pathnameBase:i,pattern:e}}function Si(e,t=!1,n=!0){Ee(e==="*"||!e.endsWith("*")||e.endsWith("/*"),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,"/*")}".`);let o=[],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 ki(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return Ee(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function 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 kr=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Ei=e=>kr.test(e);function Ri(e,t="/"){let{pathname:n,search:o="",hash:a=""}=typeof e=="string"?Jt(e):e,r;if(n)if(Ei(n))r=n;else{if(n.includes("//")){let i=n;n=n.replace(/\/\/+/g,"/"),Ee(!1,`Pathnames cannot have embedded double slashes - normalizing ${i} -> ${n}`)}n.startsWith("/")?r=Bo(n.substring(1),"/"):r=Bo(n,t)}else r=t;return{pathname:r,search:Ai(o),hash:Ii(a)}}function Bo(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 Rs(e,t,n,o){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(o)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function Li(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function Er(e){let t=Li(e);return t.map((n,o)=>o===t.length-1?n.pathname:n.pathnameBase)}function Rr(e,t,n,o=!1){let a;typeof e=="string"?a=Jt(e):(a={...e},z(!a.pathname||!a.pathname.includes("?"),Rs("?","pathname","search",a)),z(!a.pathname||!a.pathname.includes("#"),Rs("#","pathname","hash",a)),z(!a.search||!a.search.includes("#"),Rs("#","search","hash",a)));let r=e===""||a.pathname==="",i=r?"/":a.pathname,c;if(i==null)c=n;else{let d=t.length-1;if(!o&&i.startsWith("..")){let x=i.split("/");for(;x[0]==="..";)x.shift(),d-=1;a.pathname=x.join("/")}c=d>=0?t[d]:"/"}let u=Ri(a,c),h=i&&i!=="/"&&i.endsWith("/"),m=(r||i===".")&&n.endsWith("/");return!u.pathname.endsWith("/")&&(h||m)&&(u.pathname+="/"),u}var Ge=e=>e.join("/").replace(/\/\/+/g,"/"),Ti=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),Ai=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,Ii=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,Pi=class{constructor(e,t,n,o=!1){this.status=e,this.statusText=t||"",this.internal=o,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function Mi(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function Oi(e){return e.map(t=>t.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var Lr=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Tr(e,t){let n=e;if(typeof n!="string"||!kr.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let o=n,a=!1;if(Lr)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{Ee(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:o,isExternal:a,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var Ar=["POST","PUT","PATCH","DELETE"];new Set(Ar);var Di=["GET",...Ar];new Set(Di);var Xt=l.createContext(null);Xt.displayName="DataRouter";var ms=l.createContext(null);ms.displayName="DataRouterState";var $i=l.createContext(!1),Ir=l.createContext({isTransitioning:!1});Ir.displayName="ViewTransition";var Fi=l.createContext(new Map);Fi.displayName="Fetchers";var Bi=l.createContext(null);Bi.displayName="Await";var Re=l.createContext(null);Re.displayName="Navigation";var En=l.createContext(null);En.displayName="Location";var Ue=l.createContext({outlet:null,matches:[],isDataRoute:!1});Ue.displayName="Route";var Zs=l.createContext(null);Zs.displayName="RouteError";var Pr="REACT_ROUTER_ERROR",Wi="REDIRECT",qi="ROUTE_ERROR_RESPONSE";function Ui(e){if(e.startsWith(`${Pr}:${Wi}:{`))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 Hi(e){if(e.startsWith(`${Pr}:${qi}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string")return new Pi(t.status,t.statusText,t.data)}catch{}}function zi(e,{relative:t}={}){z(Rn(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:o}=l.useContext(Re),{hash:a,pathname:r,search:i}=Ln(e,{relative:t}),c=r;return n!=="/"&&(c=r==="/"?n:Ge([n,r])),o.createHref({pathname:c,search:i,hash:a})}function Rn(){return l.useContext(En)!=null}function fe(){return z(Rn(),"useLocation() may be used only in the context of a <Router> component."),l.useContext(En).location}var Mr="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Or(e){l.useContext(Re).static||l.useLayoutEffect(e)}function J(){let{isDataRoute:e}=l.useContext(Ue);return e?rl():Vi()}function Vi(){z(Rn(),"useNavigate() may be used only in the context of a <Router> component.");let e=l.useContext(Xt),{basename:t,navigator:n}=l.useContext(Re),{matches:o}=l.useContext(Ue),{pathname:a}=fe(),r=JSON.stringify(Er(o)),i=l.useRef(!1);return Or(()=>{i.current=!0}),l.useCallback((u,h={})=>{if(Ee(i.current,Mr),!i.current)return;if(typeof u=="number"){n.go(u);return}let m=Rr(u,JSON.parse(r),a,h.relative==="path");e==null&&t!=="/"&&(m.pathname=m.pathname==="/"?t:Ge([t,m.pathname])),(h.replace?n.replace:n.push)(m,h.state,h)},[t,n,r,a,e])}l.createContext(null);function Qi(){let{matches:e}=l.useContext(Ue),t=e[e.length-1];return t?t.params:{}}function Ln(e,{relative:t}={}){let{matches:n}=l.useContext(Ue),{pathname:o}=fe(),a=JSON.stringify(Er(n));return l.useMemo(()=>Rr(e,JSON.parse(a),o,t==="path"),[e,a,o,t])}function Ki(e,t){return Dr(e,t)}function Dr(e,t,n,o,a){z(Rn(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:r}=l.useContext(Re),{matches:i}=l.useContext(Ue),c=i[i.length-1],u=c?c.params:{},h=c?c.pathname:"/",m=c?c.pathnameBase:"/",d=c&&c.route;{let f=d&&d.path||"";Fr(h,!d||f.endsWith("*")||f.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${h}" (under <Route path="${f}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
1
+ import{r as l,a as Xa,S as jr,p as Ao,b as Te,s as os,c as wn,n as rs,i as Ws,d as Io,t as Za,e as Kn,f as ei,g as ti,h as Po,j as ds,k as Mo,l as ni,m as si,o as Oo,q as oi,u as s,v as Xs,w as K,x as $,A as hs,y as ri,z as ai,B as I,C as kn,D as me,E as ke,F as ii,G as li,R as nt,H as ci,I as ui}from"./index-B0tXrAXl.js";var Do="popstate";function di(e={}){function t(o,a){let{pathname:r,search:i,hash:c}=o.location;return Us("",{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:Cn(a)}return mi(t,n,null,e)}function z(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function Ee(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function hi(){return Math.random().toString(36).substring(2,10)}function $o(e,t){return{usr:e.state,key:e.key,idx:t}}function Us(e,t,n=null,o){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?Jt(t):t,state:n,key:t&&t.key||o||hi()}}function Cn({pathname:e="/",search:t="",hash:n=""}){return t&&t!=="?"&&(e+=t.charAt(0)==="?"?t:"?"+t),n&&n!=="#"&&(e+=n.charAt(0)==="#"?n:"#"+n),e}function Jt(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let o=e.indexOf("?");o>=0&&(t.search=e.substring(o),e=e.substring(0,o)),e&&(t.pathname=e)}return t}function mi(e,t,n,o={}){let{window:a=document.defaultView,v5Compat:r=!1}=o,i=a.history,c="POP",u=null,h=m();h==null&&(h=0,i.replaceState({...i.state,idx:h},""));function m(){return(i.state||{idx:null}).idx}function d(){c="POP";let v=m(),y=v==null?null:v-h;h=v,u&&u({action:c,location:g.location,delta:y})}function x(v,y){c="PUSH";let f=Us(g.location,v,y);h=m()+1;let w=$o(f,h),C=g.createHref(f);try{i.pushState(w,"",C)}catch(_){if(_ instanceof DOMException&&_.name==="DataCloneError")throw _;a.location.assign(C)}r&&u&&u({action:c,location:g.location,delta:1})}function p(v,y){c="REPLACE";let f=Us(g.location,v,y);h=m();let w=$o(f,h),C=g.createHref(f);i.replaceState(w,"",C),r&&u&&u({action:c,location:g.location,delta:0})}function b(v){return fi(v)}let g={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(Do,d),u=v,()=>{a.removeEventListener(Do,d),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:x,replace:p,go(v){return i.go(v)}};return g}function fi(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:Cn(e);return o=o.replace(/ $/,"%20"),!t&&o.startsWith("//")&&(o=n+o),new URL(o,n)}function Nr(e,t,n="/"){return pi(e,t,n,!1)}function pi(e,t,n,o){let a=typeof t=="string"?Jt(t):t,r=Ye(a.pathname||"/",n);if(r==null)return null;let i=_r(e);xi(i);let c=null;for(let u=0;c==null&&u<i.length;++u){let h=ki(r);c=_i(i[u],h,o)}return c}function _r(e,t=[],n=[],o="",a=!1){let r=(i,c,u=a,h)=>{let m={relativePath:h===void 0?i.path||"":h,caseSensitive:i.caseSensitive===!0,childrenIndex:c,route:i};if(m.relativePath.startsWith("/")){if(!m.relativePath.startsWith(o)&&u)return;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 d=Ge([o,m.relativePath]),x=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 "${d}".`),_r(i.children,t,x,d,u)),!(i.path==null&&!i.index)&&t.push({path:d,score:ji(d,i.index),routesMeta:x})};return e.forEach((i,c)=>{if(i.path===""||!i.path?.includes("?"))r(i,c);else for(let u of Sr(i.path))r(i,c,!0,u)}),t}function Sr(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=Sr(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 xi(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:Ni(t.routesMeta.map(o=>o.childrenIndex),n.routesMeta.map(o=>o.childrenIndex)))}var gi=/^:[\w-]+$/,bi=3,vi=2,yi=1,wi=10,Ci=-2,Fo=e=>e==="*";function ji(e,t){let n=e.split("/"),o=n.length;return n.some(Fo)&&(o+=Ci),t&&(o+=vi),n.filter(a=>!Fo(a)).reduce((a,r)=>a+(gi.test(r)?bi:r===""?yi:wi),o)}function Ni(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 _i(e,t,n=!1){let{routesMeta:o}=e,a={},r="/",i=[];for(let c=0;c<o.length;++c){let u=o[c],h=c===o.length-1,m=r==="/"?t:t.slice(r.length)||"/",d=Kt({path:u.relativePath,caseSensitive:u.caseSensitive,end:h},m),x=u.route;if(!d&&h&&n&&!o[o.length-1].route.index&&(d=Kt({path:u.relativePath,caseSensitive:u.caseSensitive,end:!1},m)),!d)return null;Object.assign(a,d.params),i.push({params:a,pathname:Ge([r,d.pathname]),pathnameBase:Ti(Ge([r,d.pathnameBase])),route:x}),d.pathnameBase!=="/"&&(r=Ge([r,d.pathnameBase]))}return i}function Kt(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[n,o]=Si(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((h,{paramName:m,isOptional:d},x)=>{if(m==="*"){let b=c[x]||"";i=r.slice(0,r.length-b.length).replace(/(.)\/+$/,"$1")}const p=c[x];return d&&!p?h[m]=void 0:h[m]=(p||"").replace(/%2F/g,"/"),h},{}),pathname:r,pathnameBase:i,pattern:e}}function Si(e,t=!1,n=!0){Ee(e==="*"||!e.endsWith("*")||e.endsWith("/*"),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,"/*")}".`);let o=[],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 ki(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return Ee(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function 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 kr=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Ei=e=>kr.test(e);function Ri(e,t="/"){let{pathname:n,search:o="",hash:a=""}=typeof e=="string"?Jt(e):e,r;if(n)if(Ei(n))r=n;else{if(n.includes("//")){let i=n;n=n.replace(/\/\/+/g,"/"),Ee(!1,`Pathnames cannot have embedded double slashes - normalizing ${i} -> ${n}`)}n.startsWith("/")?r=Bo(n.substring(1),"/"):r=Bo(n,t)}else r=t;return{pathname:r,search:Ai(o),hash:Ii(a)}}function Bo(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 Rs(e,t,n,o){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(o)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function Li(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function Er(e){let t=Li(e);return t.map((n,o)=>o===t.length-1?n.pathname:n.pathnameBase)}function Rr(e,t,n,o=!1){let a;typeof e=="string"?a=Jt(e):(a={...e},z(!a.pathname||!a.pathname.includes("?"),Rs("?","pathname","search",a)),z(!a.pathname||!a.pathname.includes("#"),Rs("#","pathname","hash",a)),z(!a.search||!a.search.includes("#"),Rs("#","search","hash",a)));let r=e===""||a.pathname==="",i=r?"/":a.pathname,c;if(i==null)c=n;else{let d=t.length-1;if(!o&&i.startsWith("..")){let x=i.split("/");for(;x[0]==="..";)x.shift(),d-=1;a.pathname=x.join("/")}c=d>=0?t[d]:"/"}let u=Ri(a,c),h=i&&i!=="/"&&i.endsWith("/"),m=(r||i===".")&&n.endsWith("/");return!u.pathname.endsWith("/")&&(h||m)&&(u.pathname+="/"),u}var Ge=e=>e.join("/").replace(/\/\/+/g,"/"),Ti=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),Ai=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,Ii=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,Pi=class{constructor(e,t,n,o=!1){this.status=e,this.statusText=t||"",this.internal=o,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function Mi(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function Oi(e){return e.map(t=>t.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var Lr=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Tr(e,t){let n=e;if(typeof n!="string"||!kr.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let o=n,a=!1;if(Lr)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{Ee(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:o,isExternal:a,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var Ar=["POST","PUT","PATCH","DELETE"];new Set(Ar);var Di=["GET",...Ar];new Set(Di);var Xt=l.createContext(null);Xt.displayName="DataRouter";var ms=l.createContext(null);ms.displayName="DataRouterState";var $i=l.createContext(!1),Ir=l.createContext({isTransitioning:!1});Ir.displayName="ViewTransition";var Fi=l.createContext(new Map);Fi.displayName="Fetchers";var Bi=l.createContext(null);Bi.displayName="Await";var Re=l.createContext(null);Re.displayName="Navigation";var En=l.createContext(null);En.displayName="Location";var Ue=l.createContext({outlet:null,matches:[],isDataRoute:!1});Ue.displayName="Route";var Zs=l.createContext(null);Zs.displayName="RouteError";var Pr="REACT_ROUTER_ERROR",qi="REDIRECT",Wi="ROUTE_ERROR_RESPONSE";function Ui(e){if(e.startsWith(`${Pr}:${qi}:{`))try{let t=JSON.parse(e.slice(28));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.location=="string"&&typeof t.reloadDocument=="boolean"&&typeof t.replace=="boolean")return t}catch{}}function Hi(e){if(e.startsWith(`${Pr}:${Wi}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string")return new Pi(t.status,t.statusText,t.data)}catch{}}function zi(e,{relative:t}={}){z(Rn(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:o}=l.useContext(Re),{hash:a,pathname:r,search:i}=Ln(e,{relative:t}),c=r;return n!=="/"&&(c=r==="/"?n:Ge([n,r])),o.createHref({pathname:c,search:i,hash:a})}function Rn(){return l.useContext(En)!=null}function fe(){return z(Rn(),"useLocation() may be used only in the context of a <Router> component."),l.useContext(En).location}var Mr="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Or(e){l.useContext(Re).static||l.useLayoutEffect(e)}function J(){let{isDataRoute:e}=l.useContext(Ue);return e?rl():Vi()}function Vi(){z(Rn(),"useNavigate() may be used only in the context of a <Router> component.");let e=l.useContext(Xt),{basename:t,navigator:n}=l.useContext(Re),{matches:o}=l.useContext(Ue),{pathname:a}=fe(),r=JSON.stringify(Er(o)),i=l.useRef(!1);return Or(()=>{i.current=!0}),l.useCallback((u,h={})=>{if(Ee(i.current,Mr),!i.current)return;if(typeof u=="number"){n.go(u);return}let m=Rr(u,JSON.parse(r),a,h.relative==="path");e==null&&t!=="/"&&(m.pathname=m.pathname==="/"?t:Ge([t,m.pathname])),(h.replace?n.replace:n.push)(m,h.state,h)},[t,n,r,a,e])}l.createContext(null);function Qi(){let{matches:e}=l.useContext(Ue),t=e[e.length-1];return t?t.params:{}}function Ln(e,{relative:t}={}){let{matches:n}=l.useContext(Ue),{pathname:o}=fe(),a=JSON.stringify(Er(n));return l.useMemo(()=>Rr(e,JSON.parse(a),o,t==="path"),[e,a,o,t])}function Ki(e,t){return Dr(e,t)}function Dr(e,t,n,o,a){z(Rn(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:r}=l.useContext(Re),{matches:i}=l.useContext(Ue),c=i[i.length-1],u=c?c.params:{},h=c?c.pathname:"/",m=c?c.pathnameBase:"/",d=c&&c.route;{let f=d&&d.path||"";Fr(h,!d||f.endsWith("*")||f.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${h}" (under <Route path="${f}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
2
2
 
3
- Please change the parent <Route path="${f}"> to <Route path="${f==="/"?"*":`${f}/*`}">.`)}let x=fe(),p;if(t){let f=typeof t=="string"?Jt(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.`),p=f}else p=x;let b=p.pathname||"/",g=b;if(m!=="/"){let f=m.replace(/^\//,"").split("/");g="/"+b.replace(/^\//,"").split("/").slice(f.length).join("/")}let v=Nr(e,{pathname:g});Ee(d||v!=null,`No routes matched location "${p.pathname}${p.search}${p.hash}" `),Ee(v==null||v[v.length-1].route.element!==void 0||v[v.length-1].route.Component!==void 0||v[v.length-1].route.lazy!==void 0,`Matched leaf route at location "${p.pathname}${p.search}${p.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let y=Zi(v&&v.map(f=>Object.assign({},f,{params:Object.assign({},u,f.params),pathname:Ge([m,r.encodeLocation?r.encodeLocation(f.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:f.pathname]),pathnameBase:f.pathnameBase==="/"?m:Ge([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(En.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...p},navigationType:"POP"}},y):y}function Gi(){let e=ol(),t=Mi(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,o="rgba(200,200,200, 0.5)",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 Yi=l.createElement(Gi,null),$r=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=Hi(e.digest);n&&(e=n)}let t=e!==void 0?l.createElement(Ue.Provider,{value:this.props.routeContext},l.createElement(Zs.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?l.createElement(Ji,{error:e},t):t}};$r.contextType=$i;var Ls=new WeakMap;function Ji({children:e,error:t}){let{basename:n}=l.useContext(Re);if(typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){let o=Ui(t.digest);if(o){let a=Ls.get(t);if(a)throw a;let r=Tr(o.location,n);if(Lr&&!Ls.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 Ls.set(t,i),i}return l.createElement("meta",{httpEquiv:"refresh",content:`0;url=${r.absoluteURL||r.to}`})}}return e}function Xi({routeContext:e,match:t,children:n}){let o=l.useContext(Xt);return o&&o.static&&o.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(o.staticContext._deepestRenderedBoundaryId=t.route.id),l.createElement(Ue.Provider,{value:e},n)}function Zi(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(d=>d.route.id&&i?.[d.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 d=r[m];if((d.route.HydrateFallback||d.route.hydrateFallbackElement)&&(u=m),d.route.id){let{loaderData:x,errors:p}=n,b=d.route.loader&&!x.hasOwnProperty(d.route.id)&&(!p||p[d.route.id]===void 0);if(d.route.lazy||b){c=!0,u>=0?r=r.slice(0,u+1):r=[r[0]];break}}}let h=n&&o?(m,d)=>{o(m,{location:n.location,params:n.matches?.[0]?.params??{},unstable_pattern:Oi(n.matches),errorInfo:d})}:void 0;return r.reduceRight((m,d,x)=>{let p,b=!1,g=null,v=null;n&&(p=i&&d.route.id?i[d.route.id]:void 0,g=d.route.errorElement||Yi,c&&(u<0&&x===0?(Fr("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),b=!0,v=null):u===x&&(b=!0,v=d.route.hydrateFallbackElement||null)));let y=t.concat(r.slice(0,x+1)),f=()=>{let w;return p?w=g:b?w=v:d.route.Component?w=l.createElement(d.route.Component,null):d.route.element?w=d.route.element:w=m,l.createElement(Xi,{match:d,routeContext:{outlet:m,matches:y,isDataRoute:n!=null},children:w})};return n&&(d.route.ErrorBoundary||d.route.errorElement||x===0)?l.createElement($r,{location:n.location,revalidation:n.revalidation,component:g,error:p,children:f(),routeContext:{outlet:null,matches:y,isDataRoute:!0},onError:h}):f()},null)}function eo(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function el(e){let t=l.useContext(Xt);return z(t,eo(e)),t}function tl(e){let t=l.useContext(ms);return z(t,eo(e)),t}function nl(e){let t=l.useContext(Ue);return z(t,eo(e)),t}function to(e){let t=nl(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 sl(){return to("useRouteId")}function ol(){let e=l.useContext(Zs),t=tl("useRouteError"),n=to("useRouteError");return e!==void 0?e:t.errors?.[n]}function rl(){let{router:e}=el("useNavigate"),t=to("useNavigate"),n=l.useRef(!1);return Or(()=>{n.current=!0}),l.useCallback(async(a,r={})=>{Ee(n.current,Mr),n.current&&(typeof a=="number"?await e.navigate(a):await e.navigate(a,{fromRouteId:t,...r}))},[e,t])}var Wo={};function Fr(e,t,n){!t&&!Wo[e]&&(Wo[e]=!0,Ee(!1,n))}l.memo(al);function al({routes:e,future:t,state:n,onError:o}){return Dr(e,void 0,n,o,t)}function Ht(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 il({basename:e="/",children:t=null,location:n,navigationType:o="POP",navigator:a,static:r=!1,unstable_useTransitions:i}){z(!Rn(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let c=e.replace(/^\/*/,"/"),u=l.useMemo(()=>({basename:c,navigator:a,static:r,unstable_useTransitions:i,future:{}}),[c,a,r,i]);typeof n=="string"&&(n=Jt(n));let{pathname:h="/",search:m="",hash:d="",state:x=null,key:p="default"}=n,b=l.useMemo(()=>{let g=Ye(h,c);return g==null?null:{location:{pathname:g,search:m,hash:d,state:x,key:p},navigationType:o}},[c,h,m,d,x,p,o]);return Ee(b!=null,`<Router basename="${c}"> is not able to match the URL "${h}${m}${d}" because it does not start with the basename, so the <Router> won't render anything.`),b==null?null:l.createElement(Re.Provider,{value:u},l.createElement(En.Provider,{children:t,value:b}))}function ll({children:e,location:t}){return Ki(Hs(e),t)}function Hs(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,Hs(o.props.children,r));return}z(o.type===Ht,`[${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=Hs(o.props.children,r)),n.push(i)}),n}var Xn="get",Zn="application/x-www-form-urlencoded";function fs(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function cl(e){return fs(e)&&e.tagName.toLowerCase()==="button"}function ul(e){return fs(e)&&e.tagName.toLowerCase()==="form"}function dl(e){return fs(e)&&e.tagName.toLowerCase()==="input"}function hl(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function ml(e,t){return e.button===0&&(!t||t==="_self")&&!hl(e)}function zs(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 fl(e,t){let n=zs(e);return t&&t.forEach((o,a)=>{n.has(a)||t.getAll(a).forEach(r=>{n.append(a,r)})}),n}var Gn=null;function pl(){if(Gn===null)try{new FormData(document.createElement("form"),0),Gn=!1}catch{Gn=!0}return Gn}var xl=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Ts(e){return e!=null&&!xl.has(e)?(Ee(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Zn}"`),null):e}function gl(e,t){let n,o,a,r,i;if(ul(e)){let c=e.getAttribute("action");o=c?Ye(c,t):null,n=e.getAttribute("method")||Xn,a=Ts(e.getAttribute("enctype"))||Zn,r=new FormData(e)}else if(cl(e)||dl(e)&&(e.type==="submit"||e.type==="image")){let c=e.form;if(c==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let u=e.getAttribute("formaction")||c.getAttribute("action");if(o=u?Ye(u,t):null,n=e.getAttribute("formmethod")||c.getAttribute("method")||Xn,a=Ts(e.getAttribute("formenctype"))||Ts(c.getAttribute("enctype"))||Zn,r=new FormData(c,e),!pl()){let{name:h,type:m,value:d}=e;if(m==="image"){let x=h?`${h}.`:"";r.append(`${x}x`,"0"),r.append(`${x}y`,"0")}else h&&r.append(h,d)}}else{if(fs(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=Xn,o=null,a=Zn,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 no(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function bl(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 vl(e,t){if(e.id in t)return t[e.id];try{let n=await import(e.module);return t[e.id]=n,n}catch(n){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(n),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function yl(e){return e==null?!1:e.href==null?e.rel==="preload"&&typeof e.imageSrcSet=="string"&&typeof e.imageSizes=="string":typeof e.rel=="string"&&typeof e.href=="string"}async function wl(e,t,n){let o=await Promise.all(e.map(async a=>{let r=t.routes[a.route.id];if(r){let i=await vl(r,n);return i.links?i.links():[]}return[]}));return _l(o.flat(1).filter(yl).filter(a=>a.rel==="stylesheet"||a.rel==="preload").map(a=>a.rel==="stylesheet"?{...a,rel:"prefetch",as:"style"}:{...a,rel:"prefetch"}))}function qo(e,t,n,o,a,r){let i=(u,h)=>n[h]?u.route.id!==n[h].route.id:!0,c=(u,h)=>n[h].pathname!==u.pathname||n[h].route.path?.endsWith("*")&&n[h].params["*"]!==u.params["*"];return r==="assets"?t.filter((u,h)=>i(u,h)||c(u,h)):r==="data"?t.filter((u,h)=>{let m=o.routes[u.route.id];if(!m||!m.hasLoader)return!1;if(i(u,h)||c(u,h))return!0;if(u.route.shouldRevalidate){let d=u.route.shouldRevalidate({currentUrl:new URL(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 d=="boolean")return d}return!0}):[]}function Cl(e,t,{includeHydrateFallback:n}={}){return jl(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 jl(e){return[...new Set(e)]}function Nl(e){let t={},n=Object.keys(e).sort();for(let o of n)t[o]=e[o];return t}function _l(e,t){let n=new Set;return new Set(t),e.reduce((o,a)=>{let r=JSON.stringify(Nl(a));return n.has(r)||(n.add(r),o.push({key:r,link:a})),o},[])}function Br(){let e=l.useContext(Xt);return no(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function Sl(){let e=l.useContext(ms);return no(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var so=l.createContext(void 0);so.displayName="FrameworkContext";function Wr(){let e=l.useContext(so);return no(e,"You must render this element inside a <HydratedRouter> element"),e}function kl(e,t){let n=l.useContext(so),[o,a]=l.useState(!1),[r,i]=l.useState(!1),{onFocus:c,onBlur:u,onMouseEnter:h,onMouseLeave:m,onTouchStart:d}=t,x=l.useRef(null);l.useEffect(()=>{if(e==="render"&&i(!0),e==="viewport"){let g=y=>{y.forEach(f=>{i(f.isIntersecting)})},v=new IntersectionObserver(g,{threshold:.5});return x.current&&v.observe(x.current),()=>{v.disconnect()}}},[e]),l.useEffect(()=>{if(o){let g=setTimeout(()=>{i(!0)},100);return()=>{clearTimeout(g)}}},[o]);let p=()=>{a(!0)},b=()=>{a(!1),i(!1)};return n?e!=="intent"?[r,x,{}]:[r,x,{onFocus:pn(c,p),onBlur:pn(u,b),onMouseEnter:pn(h,p),onMouseLeave:pn(m,b),onTouchStart:pn(d,p)}]:[!1,x,{}]}function pn(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function El({page:e,...t}){let{router:n}=Br(),o=l.useMemo(()=>Nr(n.routes,e,n.basename),[n.routes,e,n.basename]);return o?l.createElement(Ll,{page:e,matches:o,...t}):null}function Rl(e){let{manifest:t,routeModules:n}=Wr(),[o,a]=l.useState([]);return l.useEffect(()=>{let r=!1;return wl(e,t,n).then(i=>{r||a(i)}),()=>{r=!0}},[e,t,n]),o}function Ll({page:e,matches:t,...n}){let o=fe(),{future:a,manifest:r,routeModules:i}=Wr(),{basename:c}=Br(),{loaderData:u,matches:h}=Sl(),m=l.useMemo(()=>qo(e,t,h,r,o,"data"),[e,t,h,r,o]),d=l.useMemo(()=>qo(e,t,h,r,o,"assets"),[e,t,h,r,o]),x=l.useMemo(()=>{if(e===o.pathname+o.search+o.hash)return[];let g=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:g.add(f.route.id))}),g.size===0)return[];let y=bl(e,c,a.unstable_trailingSlashAwareDataRequests,"data");return v&&g.size>0&&y.searchParams.set("_routes",t.filter(f=>g.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]),p=l.useMemo(()=>Cl(d,r),[d,r]),b=Rl(d);return l.createElement(l.Fragment,null,x.map(g=>l.createElement("link",{key:g,rel:"prefetch",as:"fetch",href:g,...n})),p.map(g=>l.createElement("link",{key:g,rel:"modulepreload",href:g,...n})),b.map(({key:g,link:v})=>l.createElement("link",{key:g,nonce:n.nonce,...v})))}function Tl(...e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}var Al=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{Al&&(window.__reactRouterVersion="7.12.0")}catch{}function Il({basename:e,children:t,unstable_useTransitions:n,window:o}){let a=l.useRef();a.current==null&&(a.current=di({window:o,v5Compat:!0}));let r=a.current,[i,c]=l.useState({action:r.action,location:r.location}),u=l.useCallback(h=>{n===!1?c(h):l.startTransition(()=>c(h))},[n]);return l.useLayoutEffect(()=>r.listen(u),[r,u]),l.createElement(il,{basename:e,children:t,location:i.location,navigationType:i.action,navigator:r,unstable_useTransitions:n})}var qr=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Ur=l.forwardRef(function({onClick:t,discover:n="render",prefetch:o="none",relative:a,reloadDocument:r,replace:i,state:c,target:u,to:h,preventScrollReset:m,viewTransition:d,unstable_defaultShouldRevalidate:x,...p},b){let{basename:g,unstable_useTransitions:v}=l.useContext(Re),y=typeof h=="string"&&qr.test(h),f=Tr(h,g);h=f.to;let w=zi(h,{relative:a}),[C,_,A]=kl(o,p),S=Dl(h,{replace:i,state:c,target:u,preventScrollReset:m,relative:a,viewTransition:d,unstable_defaultShouldRevalidate:x,unstable_useTransitions:v});function P(k){t&&t(k),k.defaultPrevented||S(k)}let j=l.createElement("a",{...p,...A,href:f.absoluteURL||w,onClick:f.isExternal||r?t:P,ref:Tl(b,_),target:u,"data-discover":!y&&n==="render"?"true":void 0});return C&&!y?l.createElement(l.Fragment,null,j,l.createElement(El,{page:w})):j});Ur.displayName="Link";var Pl=l.forwardRef(function({"aria-current":t="page",caseSensitive:n=!1,className:o="",end:a=!1,style:r,to:i,viewTransition:c,children:u,...h},m){let d=Ln(i,{relative:h.relative}),x=fe(),p=l.useContext(ms),{navigator:b,basename:g}=l.useContext(Re),v=p!=null&&Ul(d)&&c===!0,y=b.encodeLocation?b.encodeLocation(d).pathname:d.pathname,f=x.pathname,w=p&&p.navigation&&p.navigation.location?p.navigation.location.pathname:null;n||(f=f.toLowerCase(),w=w?w.toLowerCase():null,y=y.toLowerCase()),w&&g&&(w=Ye(w,g)||w);const C=y!=="/"&&y.endsWith("/")?y.length-1:y.length;let _=f===y||!a&&f.startsWith(y)&&f.charAt(C)==="/",A=w!=null&&(w===y||!a&&w.startsWith(y)&&w.charAt(y.length)==="/"),S={isActive:_,isPending:A,isTransitioning:v},P=_?t:void 0,j;typeof o=="function"?j=o(S):j=[o,_?"active":null,A?"pending":null,v?"transitioning":null].filter(Boolean).join(" ");let k=typeof r=="function"?r(S):r;return l.createElement(Ur,{...h,"aria-current":P,className:j,ref:m,style:k,to:i,viewTransition:c},typeof u=="function"?u(S):u)});Pl.displayName="NavLink";var Ml=l.forwardRef(({discover:e="render",fetcherKey:t,navigate:n,reloadDocument:o,replace:a,state:r,method:i=Xn,action:c,onSubmit:u,relative:h,preventScrollReset:m,viewTransition:d,unstable_defaultShouldRevalidate:x,...p},b)=>{let{unstable_useTransitions:g}=l.useContext(Re),v=Wl(),y=ql(c,{relative:h}),f=i.toLowerCase()==="get"?"get":"post",w=typeof c=="string"&&qr.test(c),C=_=>{if(u&&u(_),_.defaultPrevented)return;_.preventDefault();let A=_.nativeEvent.submitter,S=A?.getAttribute("formmethod")||i,P=()=>v(A||_.currentTarget,{fetcherKey:t,method:S,navigate:n,replace:a,state:r,relative:h,preventScrollReset:m,viewTransition:d,unstable_defaultShouldRevalidate:x});g&&n!==!1?l.startTransition(()=>P()):P()};return l.createElement("form",{ref:b,method:f,action:y,onSubmit:o?u:C,...p,"data-discover":!w&&e==="render"?"true":void 0})});Ml.displayName="Form";function Ol(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Hr(e){let t=l.useContext(Xt);return z(t,Ol(e)),t}function Dl(e,{target:t,replace:n,state:o,preventScrollReset:a,relative:r,viewTransition:i,unstable_defaultShouldRevalidate:c,unstable_useTransitions:u}={}){let h=J(),m=fe(),d=Ln(e,{relative:r});return l.useCallback(x=>{if(ml(x,t)){x.preventDefault();let p=n!==void 0?n:Cn(m)===Cn(d),b=()=>h(e,{replace:p,state:o,preventScrollReset:a,relative:r,viewTransition:i,unstable_defaultShouldRevalidate:c});u?l.startTransition(()=>b()):b()}},[m,h,d,n,o,t,e,a,r,i,c,u])}function $l(e){Ee(typeof URLSearchParams<"u","You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.");let t=l.useRef(zs(e)),n=l.useRef(!1),o=fe(),a=l.useMemo(()=>fl(o.search,n.current?null:t.current),[o.search]),r=J(),i=l.useCallback((c,u)=>{const h=zs(typeof c=="function"?c(new URLSearchParams(a)):c);n.current=!0,r("?"+h,u)},[r,a]);return[a,i]}var Fl=0,Bl=()=>`__${String(++Fl)}__`;function Wl(){let{router:e}=Hr("useSubmit"),{basename:t}=l.useContext(Re),n=sl(),o=e.fetch,a=e.navigate;return l.useCallback(async(r,i={})=>{let{action:c,method:u,encType:h,formData:m,body:d}=gl(r,t);if(i.navigate===!1){let x=i.fetcherKey||Bl();await o(x,n,i.action||c,{unstable_defaultShouldRevalidate:i.unstable_defaultShouldRevalidate,preventScrollReset:i.preventScrollReset,formData:m,body:d,formMethod:i.method||u,formEncType:i.encType||h,flushSync:i.flushSync})}else await a(i.action||c,{unstable_defaultShouldRevalidate:i.unstable_defaultShouldRevalidate,preventScrollReset:i.preventScrollReset,formData:m,body:d,formMethod:i.method||u,formEncType:i.encType||h,replace:i.replace,state:i.state,fromRouteId:n,flushSync:i.flushSync,viewTransition:i.viewTransition})},[o,a,t,n])}function ql(e,{relative:t}={}){let{basename:n}=l.useContext(Re),o=l.useContext(Ue);z(o,"useFormAction must be used inside a RouteContext");let[a]=o.matches.slice(-1),r={...Ln(e||".",{relative:t})},i=fe();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(d=>d).forEach(d=>c.append("index",d));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:Ge([n,r.pathname])),Cn(r)}function Ul(e,{relative:t}={}){let n=l.useContext(Ir);z(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:o}=Hr("useViewTransitionState"),a=Ln(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 Kt(a.pathname,i)!=null||Kt(a.pathname,r)!=null}var oo=Xa(),zr=class extends jr{constructor(e,t){super(),this.options=t,this.#n=e,this.#i=null,this.#a=Ao(),this.bindMethods(),this.setOptions(t)}#n;#e=void 0;#s=void 0;#t=void 0;#o;#r;#a;#i;#p;#h;#m;#c;#u;#l;#f=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#e.addObserver(this),Uo(this.#e,this.options)?this.#d():this.updateResult(),this.#v())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Vs(this.#e,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Vs(this.#e,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#y(),this.#w(),this.#e.removeObserver(this)}setOptions(e){const t=this.options,n=this.#e;if(this.options=this.#n.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Te(this.options.enabled,this.#e)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#C(),this.#e.setOptions(this.options),t._defaulted&&!os(this.options,t)&&this.#n.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#e,observer:this});const o=this.hasListeners();o&&Ho(this.#e,n,this.options,t)&&this.#d(),this.updateResult(),o&&(this.#e!==n||Te(this.options.enabled,this.#e)!==Te(t.enabled,this.#e)||wn(this.options.staleTime,this.#e)!==wn(t.staleTime,this.#e))&&this.#x();const a=this.#g();o&&(this.#e!==n||Te(this.options.enabled,this.#e)!==Te(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 zl(this,n)&&(this.#t=n,this.#r=this.options,this.#o=this.#e.state),n}getCurrentResult(){return this.#t}trackResult(e,t){return new Proxy(e,{get:(n,o)=>(this.trackProp(o),t?.(o),o==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&this.#a.status==="pending"&&this.#a.reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(n,o))})}trackProp(e){this.#f.add(e)}getCurrentQuery(){return this.#e}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const t=this.#n.defaultQueryOptions(e),n=this.#n.getQueryCache().build(this.#n,t);return n.fetch().then(()=>this.createResult(n,t))}fetch(e){return this.#d({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#t))}#d(e){this.#C();let t=this.#e.fetch(this.options,e);return e?.throwOnError||(t=t.catch(rs)),t}#x(){this.#y();const e=wn(this.options.staleTime,this.#e);if(qs||this.#t.isStale||!Io(e))return;const n=Za(this.#t.dataUpdatedAt,e)+1;this.#c=Kn.setTimeout(()=>{this.#t.isStale||this.updateResult()},n)}#g(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#e):this.options.refetchInterval)??!1}#b(e){this.#w(),this.#l=e,!(qs||Te(this.options.enabled,this.#e)===!1||!Io(this.#l)||this.#l===0)&&(this.#u=Kn.setInterval(()=>{(this.options.refetchIntervalInBackground||ei.isFocused())&&this.#d()},this.#l))}#v(){this.#x(),this.#b(this.#g())}#y(){this.#c&&(Kn.clearTimeout(this.#c),this.#c=void 0)}#w(){this.#u&&(Kn.clearInterval(this.#u),this.#u=void 0)}createResult(e,t){const n=this.#e,o=this.options,a=this.#t,r=this.#o,i=this.#r,u=e!==n?e.state:this.#s,{state:h}=e;let m={...h},d=!1,x;if(t._optimisticResults){const P=this.hasListeners(),j=!P&&Uo(e,t),k=P&&Ho(e,n,t,o);(j||k)&&(m={...m,...ti(h.data,e.options)}),t._optimisticResults==="isRestoring"&&(m.fetchStatus="idle")}let{error:p,errorUpdatedAt:b,status:g}=m;x=m.data;let v=!1;if(t.placeholderData!==void 0&&x===void 0&&g==="pending"){let P;a?.isPlaceholderData&&t.placeholderData===i?.placeholderData?(P=a.data,v=!0):P=typeof t.placeholderData=="function"?t.placeholderData(this.#m?.state.data,this.#m):t.placeholderData,P!==void 0&&(g="success",x=Po(a?.data,P,t),d=!0)}if(t.select&&x!==void 0&&!v)if(a&&x===r?.data&&t.select===this.#p)x=this.#h;else try{this.#p=t.select,x=t.select(x),x=Po(a?.data,x,t),this.#h=x,this.#i=null}catch(P){this.#i=P}this.#i&&(p=this.#i,x=this.#h,b=Date.now(),g="error");const y=m.fetchStatus==="fetching",f=g==="pending",w=g==="error",C=f&&y,_=x!==void 0,S={status:g,fetchStatus:m.fetchStatus,isPending:f,isSuccess:g==="success",isError:w,isInitialLoading:C,isLoading:C,data:x,dataUpdatedAt:m.dataUpdatedAt,error:p,errorUpdatedAt:b,failureCount:m.fetchFailureCount,failureReason:m.fetchFailureReason,errorUpdateCount:m.errorUpdateCount,isFetched:m.dataUpdateCount>0||m.errorUpdateCount>0,isFetchedAfterMount:m.dataUpdateCount>u.dataUpdateCount||m.errorUpdateCount>u.errorUpdateCount,isFetching:y,isRefetching:y&&!f,isLoadingError:w&&!_,isPaused:m.fetchStatus==="paused",isPlaceholderData:d,isRefetchError:w&&_,isStale:ro(e,t),refetch:this.refetch,promise:this.#a,isEnabled:Te(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){const P=X=>{S.status==="error"?X.reject(S.error):S.data!==void 0&&X.resolve(S.data)},j=()=>{const X=this.#a=S.promise=Ao();P(X)},k=this.#a;switch(k.status){case"pending":e.queryHash===n.queryHash&&P(k);break;case"fulfilled":(S.status==="error"||S.data!==k.value)&&j();break;case"rejected":(S.status!=="error"||S.error!==k.reason)&&j();break}}return S}updateResult(){const e=this.#t,t=this.createResult(this.#e,this.options);if(this.#o=this.#e.state,this.#r=this.options,this.#o.data!==void 0&&(this.#m=this.#e),os(t,e))return;this.#t=t;const n=()=>{if(!e)return!0;const{notifyOnChangeProps:o}=this.options,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){ds.batch(()=>{e.listeners&&this.listeners.forEach(t=>{t(this.#t)}),this.#n.getQueryCache().notify({query:this.#e,type:"observerResultsUpdated"})})}};function Hl(e,t){return Te(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function Uo(e,t){return Hl(e,t)||e.state.data!==void 0&&Vs(e,t,t.refetchOnMount)}function Vs(e,t,n){if(Te(t.enabled,e)!==!1&&wn(t.staleTime,e)!=="static"){const o=typeof n=="function"?n(e):n;return o==="always"||o!==!1&&ro(e,t)}return!1}function Ho(e,t,n,o){return(e!==t||Te(o.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&ro(e,n)}function ro(e,t){return Te(t.enabled,e)!==!1&&e.isStaleByTime(wn(t.staleTime,e))}function zl(e,t){return!os(e.getCurrentResult(),t)}var Vl=class extends zr{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){super.setOptions({...e,behavior:Mo()})}getOptimisticResult(e){return e.behavior=Mo(),super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"backward"}}})}createResult(e,t){const{state:n}=e,o=super.createResult(e,t),{isFetching:a,isRefetching:r,isError:i,isRefetchError:c}=o,u=n.fetchMeta?.fetchMore?.direction,h=i&&u==="forward",m=a&&u==="forward",d=i&&u==="backward",x=a&&u==="backward";return{...o,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:si(t,n.data),hasPreviousPage:ni(t,n.data),isFetchNextPageError:h,isFetchingNextPage:m,isFetchPreviousPageError:d,isFetchingPreviousPage:x,isRefetchError:c&&!h&&!d,isRefetching:r&&!m&&!x}}},Ql=class extends jr{#n;#e=void 0;#s;#t;constructor(t,n){super(),this.#n=t,this.setOptions(n),this.bindMethods(),this.#o()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){const n=this.options;this.options=this.#n.defaultMutationOptions(t),os(this.options,n)||this.#n.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#s,observer:this}),n?.mutationKey&&this.options.mutationKey&&Oo(n.mutationKey)!==Oo(this.options.mutationKey)?this.reset():this.#s?.state.status==="pending"&&this.#s.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#s?.removeObserver(this)}onMutationUpdate(t){this.#o(),this.#r(t)}getCurrentResult(){return this.#e}reset(){this.#s?.removeObserver(this),this.#s=void 0,this.#o(),this.#r()}mutate(t,n){return this.#t=n,this.#s?.removeObserver(this),this.#s=this.#n.getMutationCache().build(this.#n,this.options),this.#s.addObserver(this),this.#s.execute(t)}#o(){const t=this.#s?.state??oi();this.#e={...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset}}#r(t){ds.batch(()=>{if(this.#t&&this.hasListeners()){const n=this.#e.variables,o=this.#e.context,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)})})}},Vr=l.createContext(void 0),Qr=e=>{const t=l.useContext(Vr);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},Kl=({client:e,children:t})=>(l.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),s.jsx(Vr.Provider,{value:e,children:t})),Kr=l.createContext(!1),Gl=()=>l.useContext(Kr);Kr.Provider;function Yl(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var Jl=l.createContext(Yl()),Xl=()=>l.useContext(Jl),Zl=(e,t,n)=>{const o=n?.state.error&&typeof e.throwOnError=="function"?Xs(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||o)&&(t.isReset()||(e.retryOnMount=!1))},ec=e=>{l.useEffect(()=>{e.clearReset()},[e])},tc=({result:e,errorResetBoundary:t,throwOnError:n,query:o,suspense:a})=>e.isError&&!t.isReset()&&!e.isFetching&&o&&(a&&e.data===void 0||Xs(n,[e.error,o])),nc=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))}},sc=(e,t)=>e.isLoading&&e.isFetching&&!t,oc=(e,t)=>e?.suspense&&t.isPending,zo=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function Gr(e,t,n){const o=Gl(),a=Xl(),r=Qr(),i=r.defaultQueryOptions(e);r.getDefaultOptions().queries?._experimental_beforeQuery?.(i);const c=r.getQueryCache().get(i.queryHash);i._optimisticResults=o?"isRestoring":"optimistic",nc(i),Zl(i,a,c),ec(a);const u=!r.getQueryCache().get(i.queryHash),[h]=l.useState(()=>new t(r,i)),m=h.getOptimisticResult(i),d=!o&&e.subscribed!==!1;if(l.useSyncExternalStore(l.useCallback(x=>{const p=d?h.subscribe(ds.batchCalls(x)):rs;return h.updateResult(),p},[h,d]),()=>h.getCurrentResult(),()=>h.getCurrentResult()),l.useEffect(()=>{h.setOptions(i)},[i,h]),oc(i,m))throw zo(i,h,a);if(tc({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&&!qs&&sc(m,o)&&(u?zo(i,h,a):c?.promise)?.catch(rs).finally(()=>{h.updateResult()}),i.notifyOnChangeProps?m:h.trackResult(m)}function be(e,t){return Gr(e,zr)}function ee(e,t){const n=Qr(),[o]=l.useState(()=>new Ql(n,e));l.useEffect(()=>{o.setOptions(e)},[o,e]);const a=l.useSyncExternalStore(l.useCallback(i=>o.subscribe(ds.batchCalls(i)),[o]),()=>o.getCurrentResult(),()=>o.getCurrentResult()),r=l.useCallback((i,c)=>{o.mutate(i,c).catch(rs)},[o]);if(a.error&&Xs(o.options.throwOnError,[a.error]))throw a.error;return{...a,mutate:r,mutateAsync:a.mutate}}function Yr(e,t){return Gr(e,Vl)}const it="data-sources",Jr="auth-user",rc=e=>be({queryKey:["project","datasources",e],queryFn:async()=>{const{data:t}=await $.get(`/project/team/${e}/datasources`);return t.data},enabled:!!e}),Zt=e=>{const t=["project","datasources"],n=["project","saved-queries"];return Promise.all([K.invalidateQueries({queryKey:t}),K.invalidateQueries({queryKey:n})])},ac=e=>{const t=["trash","team"];return K.invalidateQueries({queryKey:t})},ic=(e,t)=>be({queryKey:["project",t.teamId,"tables",e,t.selectedDataSources],queryFn:async()=>{const{data:n}=await $.get(`/project/team/${t.teamId}/query`,{params:{size:30,search:e,selectedDataSources:t.selectedDataSources}});return n.data},enabled:!!t.teamId,staleTime:0}),lc=(e,t="",n=30,o)=>Yr({queryKey:["project","tabs-history",e,n,o,t],queryFn:async({pageParam:a})=>{const r=new URLSearchParams;r.set("nameFilter",t),r.set("size",n.toString()),r.set("page",a.toString());const{data:i}=await $.get(`/project/team/${e}/tabs-history?${r.toString()}`);return i},select:({pages:a})=>a.flatMap(r=>r.data),enabled:!!e,initialPageParam:0,getNextPageParam:(a,r)=>{if(a.hasMore)return r.length},staleTime:0}),cc=(e,t="",n=20)=>Yr({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 $.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}}),uc=(e,t=10,n=!1)=>be({queryKey:["project","recent-tabs",e,t,n],queryFn:async()=>{const{data:o}=await $.get(`/project/team/${e}/tabs-history?page=0&size=${t}&archived=${n}`);return o.data},enabled:!!e,staleTime:0}),dc=e=>ee({mutationFn:async()=>{const{data:t}=await $.get(`/project/team/${e}/tabs-history?page=0&size=1&archived=false`);return t.data?.length?t.data[0]:void 0}}),hc=()=>Promise.all([K.invalidateQueries({queryKey:["project","tabs-history"]}),K.invalidateQueries({queryKey:["project","recent-tabs"]})]),mc=4e3,ps=e=>be({queryKey:[it,e],queryFn:async()=>{const{data:t}=await $.get("/data-sources/"+e);return t.data},enabled:!!e,refetchInterval:t=>t.state?.data?.status==="INSPECTING"?mc:!1}),ao=e=>be({queryKey:[it,e.teamId],queryFn:async()=>{const{data:t}=await $.get("/data-sources",{params:e});return t.data},enabled:e.teamId!==void 0}),xs=e=>be({queryKey:[it,e,"inspections"],queryFn:async()=>{const{data:t}=await $.get(`/data-sources/${e}/inspections`);return t.data},enabled:!!e}),fc=e=>K.invalidateQueries({queryKey:[it,e,"inspections"]}),pc=()=>ee({mutationFn:async e=>{const{data:t}=await $.post("/data-sources",e);return t.data},onSuccess:()=>{K.invalidateQueries({queryKey:[it]}),Zt()}}),xc=()=>ee({mutationFn:async({dataSource:e,id:t})=>{const{data:n}=await $.put(`/data-sources/${t}`,e);return n.data},onSuccess:()=>{K.invalidateQueries({queryKey:[it]}),Zt()}}),Xr=()=>ee({mutationFn:async e=>{await $.post(`/data-sources/${e}/inspect`)},onSuccess:(e,t)=>{K.invalidateQueries({queryKey:[it,t]})}}),gc=()=>ee({mutationFn:async e=>{await $.delete(`/data-sources/${e}`)},onSuccess:()=>{K.invalidateQueries({queryKey:[it]}),Zt()}}),Zr=()=>be({queryKey:["accessToken"],queryFn:hs.get}),ve=()=>{const{data:e}=Zr();return be({queryKey:[Jr],queryFn:async()=>{const{data:t}=await $.get("/users");return t.data},enabled:!!e,retry:(t,n)=>ri(n)&&n.code==="ERR_NETWORK"?!1:t<3})},bc=()=>ee({mutationFn:async e=>{const{data:t}=await $.patch("/users",e);return t.data},onSuccess:async e=>{K.setQueryData([Jr],e)}}),vc=()=>ee({mutationFn:async e=>(await $.post("/users",e),!0),onSuccess:()=>{K.invalidateQueries({queryKey:["team-users"]})}}),ye=e=>{const t=new Set;let n=e;const o=c=>(t.add(c),()=>t.delete(c)),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 yc(e,t,n,o){return l.useMemo(()=>({name:n,tabId:o,hooks:e?.result.availableHooks||[],availableJoins:e?.result?.availableJoins||[],allColumns:e?.result.allColumns||[],dataSourceId:t,entities:e?.result.availableEntities||[],getValue:(a,r,i)=>{const c=e?.result.columns?.findIndex(u=>u.table===r&&u.column===i);if(c!=null&&c>-1)return e?.result?.rows[a][c]},getColumnByIndex:a=>e?.result?.columns?.[a],getValueByIndex:(a,r)=>e?.result?.rows[a]?.[r],getColumnType:a=>{const r=e?.result.allColumns.find(i=>i.full===a);if(r)return r.type}}),[e,t,n,o])}function wc(e,t){return l.useMemo(()=>({state:e,setState:t}),[e,t])}function Nt(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 Cc(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=>!!Kt({path:t,end:!0},a)}}function gs(e,t){return{name:e,path:t,build:()=>t,check:n=>n===t}}const jc=gs("Home","/"),Nc=gs("Workbench","/workbench"),_c=gs("Share query","/share"),Sc=gs("Login","/login"),kc=Cc("Workbench tab","/workbench/tab/:id"),D={home:jc,workbench:Nc,share:_c,login:Sc,workbenchTab:kc},io=e=>{K.setQueryData(["workbench-tabs"],t=>e(t||[]))},Ec=(e,t)=>{K.setQueryData(["workbench-tabs",e],n=>n&&t(n))},bs=()=>be({queryKey:["workbench-tabs"],queryFn:async()=>{const{data:e}=await $.get("/workbench-tabs");return e.data}}),Rc=e=>be({queryKey:["workbench-tabs",e],queryFn:async()=>{const{data:t}=await $.get(`/workbench-tabs/${e}`);return t.data}}),Et=()=>ee({mutationFn:async e=>{const{data:t}=await $.post("/workbench-tabs",e);return t.data},onSuccess:async e=>{io(t=>[...t,e])}}),Lc=()=>ee({mutationFn:async e=>(await $.patch(`/workbench-tabs/${e}`,{archived:!0}),e),onMutate:e=>{io(t=>t.filter(n=>n.id!==e))}}),ea=()=>ee({mutationFn:async e=>(await $.patch(`/workbench-tabs/${e}`,{archived:!1}),e),onSuccess:()=>na()}),Tc=()=>ee({mutationFn:async({id:e,payload:t})=>(await $.patch(`/workbench-tabs/${e}`,t),!0),onMutate:({id:e,payload:t})=>{Ec(e,n=>({...n,...t})),io(n=>n.map(o=>o.id!==e?o:{...o,name:t.name||o.name}))}}),Ac=(e,t)=>{const{dataSourceId:n,searchAll:o,table:a,filters:r,joins:i,orderBy:c,groupBy:u,columns:h,aggregations:m,page:d=0,size:x=20}=t;return be({queryKey:["workbench-tab-runner",e,n,a,d,x,r,m,i,c,u,h,o],queryFn:async()=>{const{data:p}=await $.post(`/workbench-tabs/${e}/run`,t);return p.data},retry:1,enabled:!!a&&!!n,placeholderData:ai})},Ic=()=>ee({mutationFn:async e=>{await $.delete(`/workbench-tabs/${e}`)},onSuccess:()=>{na(),hc()}}),ta=e=>K.invalidateQueries({queryKey:["workbench-tab-runner",e]}),na=()=>K.invalidateQueries({queryKey:["workbench-tabs"]}),[Pc,As,Mc]=ye(void 0),Oc=async()=>new Promise(e=>{As({onCancel:()=>{As(void 0),e(void 0)},onConfirm:(t,n,o)=>{As(void 0),e({dsId:o,id:n,type:t})}})}),Tn=e=>{const t=J(),n=Et(),o=ea();return l.useEffect(()=>{n?.data?.id&&t(D.workbenchTab.build({id:n.data.id})),o?.data&&t(D.workbenchTab.build({id:o.data}))},[n.data,o.data]),l.useCallback(()=>{Mc.get()||Oc().then(r=>{r?.type==="table"?n.mutate({name:r.id,opts:Nt({table:r.id,dataSourceId:r.dsId})}):r?.type==="query"?n.mutate({queryId:r.id}):r?.type==="tab"&&o.mutate(r.id)})},[t,e])},sa=[{value:"=",label:"equals"},{value:"<>",label:"not equal"},{value:">",label:"greater than"},{value:">=",label:"greater than or equal"},{value:"<",label:"less than"},{value:"<=",label:"less than or equal"},{value:"LIKE",label:"like"},{value:"NOT LIKE",label:"not like"},{value:"CONTAINS",label:"contains"},{value:"NOT CONTAINS",label:"not contains"},{value:"IN",label:"in list"},{value:"NOT IN",label:"not in list"},{value:"IS NULL",label:"is null"},{value:"IS NOT NULL",label:"is not null"}],Dc=sa.reduce((e,t)=>(e[t.value]=t.label,e),{});sa.reduce((e,t)=>(e[t.label]=t.value,e),{});const en=e=>e.map(t=>({label:Dc[t],value:t}));en(["=","<>",">",">=","<","<=","IN","NOT IN","IS NULL","IS NOT NULL"]);en(["=","<>","LIKE","NOT LIKE","IN","NOT IN","IS NULL","IS NOT NULL","CONTAINS","NOT CONTAINS"]);en(["=","<>","IS NULL","IS NOT NULL"]);en(["=","<>",">",">=","<","<=","IS NULL","IS NOT NULL"]);en(["IS NULL","IS NOT NULL"]);en(["IN","NOT IN"]);const $c=["char","varchar","binary","varbinary","blob","text","enum","set","character","character varying","text","citext","uuid","xml","json","jsonb"];new Set($c);const Fc=["integer","smallint","decimal","numeric","float","real","double precision","int","smallint","integer","bigint","decimal","numeric","real","double precision","serial","bigserial","money"];new Set(Fc);const Bc=["date","datetime","timestamp","timestamptz"].reduce((e,t)=>(e[t]=!0,e),{}),Wc=e=>e.fn?e.distinct===!0?`${e.fn} distinct ${e.value}`:`${e.fn} ${e.value}`:e.value;var he=(e=>(e.OWNER="owner",e.ADMIN="admin",e.EDITOR="editor",e.READ_ONLY="read_only",e))(he||{});const Vo={[he.READ_ONLY]:10,[he.EDITOR]:20,[he.ADMIN]:30,[he.OWNER]:40},qc=e=>`${e.fromTable}.${e.fromColumn} = ${e.toTable}.${e.toColumn}`,An=e=>{const{data:t}=ve();return l.useMemo(()=>t?Vo[t.teamRole]>=Vo[e]:!1,[t,e])},Uc="_input_b0ftk_2",Hc="_label_b0ftk_2",zc="_content_b0ftk_2",Vc="_form_b0ftk_2",Qc="_header_b0ftk_2",Kc="_mode-select_b0ftk_2",Gc="_selected_b0ftk_2",Yc="_mode-container_b0ftk_2",$e={input:Uc,label:Hc,content:zc,form:Vc,header:Qc,modeSelect:Kc,selected:Gc,modeContainer:Yc},Jc="_modal_12a1j_2",Xc="_modal-visible_12a1j_2",Zc="_modal-invisible_12a1j_2",eu="_backdrop_12a1j_2",tu="_modal-container_12a1j_2",nu="_close-button_12a1j_2",zt={modal:Jc,modalVisible:Xc,modalInvisible:Zc,backdrop:eu,modalContainer:tu,closeButton:nu},_t=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32,d:"M368 368L144 144M368 144L144 368"}));let es=[];const su=e=>{const t=Symbol();return es.push({id:t,listener:e}),()=>{es=es.filter(n=>n.id!==t)}};window.addEventListener("keydown",e=>{if(e.key!=="Escape")return;const t=es.pop();t&&(e.preventDefault(),e.stopPropagation(),t.listener())});const vs=e=>{const t=l.useRef(e.onClose);t.current=e.onClose,l.useEffect(()=>{if(e.enabled)return su(()=>{t.current()})},[e.enabled])},we=({children:e,backdropClose:t,isVisible:n,onClose:o,onClosed:a,noPadding:r=!1,portal:i=!1})=>{const[c,u]=l.useState(!1),h=()=>{t&&o()},m=x=>{n||getComputedStyle(x.currentTarget).opacity==="0"&&(u(!1),a&&a())};l.useEffect(()=>{n&&u(!0)},[n]),vs({onClose:h,enabled:n&&t===!0});const d=s.jsxs("div",{onTransitionEnd:m,className:I(zt.modal,n?zt.modalVisible:zt.modalInvisible),children:[s.jsx("div",{onClick:h,className:zt.backdrop}),s.jsx("div",{className:I(zt.modalContainer,r!==!0&&"p-4"),children:c&&e})]});return i?oo.createPortal(d,document.body):d},lt=({onClick:e})=>{const t=l.useRef(e);return t.current=e,s.jsx("button",{className:zt.closeButton,onClick:e,children:s.jsx(_t,{width:20,height:20})})},oa=({children:e})=>s.jsx("h2",{className:"text-xl font-semibold",children:e}),ou=({form:e,change:t,shape:n})=>s.jsx("div",{className:$e.form,children:n.fields.map(o=>s.jsxs("label",{className:$e.input,children:[s.jsx("p",{className:$e.label,children:o.label}),s.jsx("input",{value:e[o.name],onChange:t(o.name),type:o.type})]},o.name))}),ru=e=>l.createElement("svg",{fill:"#000000",width:"800px",height:"800px",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",...e},l.createElement("path",{d:"m24.129 23.412-.508-.484c-.251-.331-.518-.624-.809-.891l-.005-.004q-.448-.407-.931-.774-.387-.266-1.064-.641c-.371-.167-.661-.46-.818-.824l-.004-.01-.048-.024c.212-.021.406-.06.592-.115l-.023.006.57-.157c.236-.074.509-.122.792-.133h.006c.298-.012.579-.06.847-.139l-.025.006q.194-.048.399-.109t.351-.109v-.169q-.145-.217-.351-.496c-.131-.178-.278-.333-.443-.468l-.005-.004q-.629-.556-1.303-1.076c-.396-.309-.845-.624-1.311-.916l-.068-.04c-.246-.162-.528-.312-.825-.435l-.034-.012q-.448-.182-.883-.399c-.097-.048-.21-.09-.327-.119l-.011-.002c-.117-.024-.217-.084-.29-.169l-.001-.001c-.138-.182-.259-.389-.355-.609l-.008-.02q-.145-.339-.314-.651-.363-.702-.702-1.427t-.651-1.452q-.217-.484-.399-.967c-.134-.354-.285-.657-.461-.942l.013.023c-.432-.736-.863-1.364-1.331-1.961l.028.038c-.463-.584-.943-1.106-1.459-1.59l-.008-.007c-.509-.478-1.057-.934-1.632-1.356l-.049-.035q-.896-.651-1.96-1.282c-.285-.168-.616-.305-.965-.393l-.026-.006-1.113-.278-.629-.048q-.314-.024-.629-.024c-.148-.078-.275-.171-.387-.279-.11-.105-.229-.204-.353-.295l-.01-.007c-.605-.353-1.308-.676-2.043-.93l-.085-.026c-.193-.113-.425-.179-.672-.179-.176 0-.345.034-.499.095l.009-.003c-.38.151-.67.458-.795.84l-.003.01c-.073.172-.115.371-.115.581 0 .368.13.705.347.968l-.002-.003q.544.725.834 1.14.217.291.448.605c.141.188.266.403.367.63l.008.021c.056.119.105.261.141.407l.003.016q.048.206.121.448.217.556.411 1.14c.141.425.297.785.478 1.128l-.019-.04q.145.266.291.52t.314.496c.065.098.147.179.241.242l.003.002c.099.072.164.185.169.313v.001c-.114.168-.191.369-.217.586l-.001.006c-.035.253-.085.478-.153.695l.008-.03c-.223.666-.351 1.434-.351 2.231 0 .258.013.512.04.763l-.003-.031c.06.958.349 1.838.812 2.6l-.014-.025c.197.295.408.552.641.787.168.188.412.306.684.306.152 0 .296-.037.422-.103l-.005.002c.35-.126.599-.446.617-.827v-.002c.048-.474.12-.898.219-1.312l-.013.067c.024-.063.038-.135.038-.211 0-.015-.001-.03-.002-.045v.002q-.012-.109.133-.206v.048q.145.339.302.677t.326.677c.295.449.608.841.952 1.202l-.003-.003c.345.372.721.706 1.127 1.001l.022.015c.212.162.398.337.566.528l.004.004c.158.186.347.339.56.454l.01.005v-.024h.048c-.039-.087-.102-.157-.18-.205l-.002-.001c-.079-.044-.147-.088-.211-.136l.005.003q-.217-.217-.448-.484t-.423-.508q-.508-.702-.969-1.467t-.871-1.555q-.194-.387-.375-.798t-.351-.798c-.049-.099-.083-.213-.096-.334v-.005c-.006-.115-.072-.214-.168-.265l-.002-.001c-.121.206-.255.384-.408.545l.001-.001c-.159.167-.289.364-.382.58l-.005.013c-.141.342-.244.739-.289 1.154l-.002.019q-.072.641-.145 1.318l-.048.024-.024.024c-.26-.053-.474-.219-.59-.443l-.002-.005q-.182-.351-.326-.69c-.248-.637-.402-1.374-.423-2.144v-.009c-.009-.122-.013-.265-.013-.408 0-.666.105-1.308.299-1.91l-.012.044q.072-.266.314-.896t.097-.871c-.05-.165-.143-.304-.265-.41l-.001-.001c-.122-.106-.233-.217-.335-.335l-.003-.004q-.169-.244-.326-.52t-.278-.544c-.165-.382-.334-.861-.474-1.353l-.022-.089c-.159-.565-.336-1.043-.546-1.503l.026.064c-.111-.252-.24-.47-.39-.669l.006.008q-.244-.326-.436-.617-.244-.314-.484-.605c-.163-.197-.308-.419-.426-.657l-.009-.02c-.048-.097-.09-.21-.119-.327l-.002-.011c-.011-.035-.017-.076-.017-.117 0-.082.024-.159.066-.223l-.001.002c.011-.056.037-.105.073-.145.039-.035.089-.061.143-.072h.002c.085-.055.188-.088.3-.088.084 0 .165.019.236.053l-.003-.001c.219.062.396.124.569.195l-.036-.013q.459.194.847.375c.298.142.552.292.792.459l-.018-.012q.194.121.387.266t.411.291h.339q.387 0 .822.037c.293.023.564.078.822.164l-.024-.007c.481.143.894.312 1.286.515l-.041-.019q.593.302 1.125.641c.589.367 1.098.743 1.577 1.154l-.017-.014c.5.428.954.867 1.38 1.331l.01.012c.416.454.813.947 1.176 1.464l.031.047c.334.472.671 1.018.974 1.584l.042.085c.081.154.163.343.234.536l.011.033q.097.278.217.57.266.605.57 1.221t.57 1.198l.532 1.161c.187.406.396.756.639 1.079l-.011-.015c.203.217.474.369.778.422l.008.001c.368.092.678.196.978.319l-.047-.017c.143.065.327.134.516.195l.04.011c.212.065.396.151.565.259l-.009-.005c.327.183.604.363.868.559l-.021-.015q.411.302.822.57.194.145.651.423t.484.52c-.114-.004-.249-.007-.384-.007-.492 0-.976.032-1.45.094l.056-.006c-.536.072-1.022.203-1.479.39l.04-.014c-.113.049-.248.094-.388.129l-.019.004c-.142.021-.252.135-.266.277v.001c.061.076.11.164.143.26l.002.006c.034.102.075.19.125.272l-.003-.006c.119.211.247.393.391.561l-.004-.005c.141.174.3.325.476.454l.007.005q.244.194.508.399c.161.126.343.25.532.362l.024.013c.284.174.614.34.958.479l.046.016c.374.15.695.324.993.531l-.016-.011q.291.169.58.375t.556.399c.073.072.137.152.191.239l.003.005c.091.104.217.175.36.193h.003v-.048c-.088-.067-.153-.16-.184-.267l-.001-.004c-.025-.102-.062-.191-.112-.273l.002.004zm-18.576-19.205q-.194 0-.363.012c-.115.008-.222.029-.323.063l.009-.003v.024h.048q.097.145.244.326t.266.351l.387.798.048-.024c.113-.082.2-.192.252-.321l.002-.005c.052-.139.082-.301.082-.469 0-.018 0-.036-.001-.054v.003c-.045-.044-.082-.096-.108-.154l-.001-.003-.081-.182c-.053-.084-.127-.15-.214-.192l-.003-.001c-.094-.045-.174-.102-.244-.169z"})),au=e=>l.createElement("svg",{width:"800px",height:"800px",viewBox:"0 0 32 32",xmlns:"http://www.w3.org/2000/svg",...e},l.createElement("title",null,"file_type_pgsql"),l.createElement("path",{d:"M29.507,18.773a1.378,1.378,0,0,0-1.144-.921,2.619,2.619,0,0,0-.913.051,8.2,8.2,0,0,1-1.406.185,27.125,27.125,0,0,0,2.872-6.83c.953-3.689.444-5.369-.151-6.13A8.239,8.239,0,0,0,22.121,2a11.773,11.773,0,0,0-3.453.484A12.858,12.858,0,0,0,16.648,2.3a6.565,6.565,0,0,0-3.518.867,16.039,16.039,0,0,0-2.484-.624,7.694,7.694,0,0,0-5.819.924C3.093,4.691,2.289,6.819,2.438,9.792A36.351,36.351,0,0,0,3.844,16.33a22.579,22.579,0,0,0,1.514,3.863A4.786,4.786,0,0,0,7.8,22.742a2.4,2.4,0,0,0,2.379-.516,2.08,2.08,0,0,0,.5.43,3.328,3.328,0,0,0,.944.4,5.069,5.069,0,0,0,3.3-.2c.006.171.011.335.014.477.006.229.013.454.021.665a11.641,11.641,0,0,0,.441,3.3c.016.043.037.107.059.176a3.975,3.975,0,0,0,.991,1.745,2.955,2.955,0,0,0,2.09.777,4.7,4.7,0,0,0,.977-.109A4.592,4.592,0,0,0,22.607,28.1c.811-1.155,1.206-2.894,1.277-5.635.009-.078.018-.152.026-.222l.017-.145.191.017.049,0a7.562,7.562,0,0,0,3.163-.548c.631-.293,2.654-1.361,2.177-2.8"}),l.createElement("path",{d:"M27.689,19.053c-3.163.652-3.38-.418-3.38-.418C27.648,13.68,29.044,7.39,27.839,5.851c-3.286-4.2-8.975-2.213-9.07-2.162l-.031.006a11.28,11.28,0,0,0-2.11-.22,5.212,5.212,0,0,0-3.34,1S3.14.294,3.612,9.733c.1,2.008,2.878,15.194,6.191,11.211,1.211-1.456,2.381-2.688,2.381-2.688a3.071,3.071,0,0,0,2.006.512l.057-.048a2.21,2.21,0,0,0,.023.567c-.854.954-.6,1.121-2.309,1.472-1.726.356-.712.989-.05,1.155a3.508,3.508,0,0,0,3.915-1.272l-.05.2c.334.268.569,1.742.53,3.079a8.481,8.481,0,0,0,.2,2.971c.264.717.526,2.329,2.769,1.849a3.307,3.307,0,0,0,2.98-3.179c.1-1.234.313-1.052.326-2.155l.174-.522c.2-1.673.032-2.213,1.186-1.962l.281.025a6.4,6.4,0,0,0,2.615-.44c1.406-.652,2.239-1.742.853-1.455h0",style:{fill:"#336791"}}),l.createElement("path",{d:"M13.882,10.631a.981.981,0,0,0-.674.1.247.247,0,0,0-.1.164.48.48,0,0,0,.117.314.881.881,0,0,0,.559.349.637.637,0,0,0,.09.006.725.725,0,0,0,.687-.467c.035-.248-.326-.414-.676-.463m9.442.008c-.027-.195-.374-.25-.7-.2s-.647.194-.62.389a.667.667,0,0,0,.62.411.592.592,0,0,0,.083-.006.8.8,0,0,0,.451-.247.5.5,0,0,0,.169-.343",style:{fill:"#fff"}}),l.createElement("path",{d:"M28.741,18.979c-.121-.365-.509-.482-1.154-.349-1.915.4-2.6.121-2.826-.044a26.327,26.327,0,0,0,3.373-7.565,14.374,14.374,0,0,0,.5-3.253,3.513,3.513,0,0,0-.509-2.2,7.482,7.482,0,0,0-6.049-2.825,10.363,10.363,0,0,0-3.5.551,8.717,8.717,0,0,0-1.968-.253,5.684,5.684,0,0,0-3.372.929,15.051,15.051,0,0,0-2.74-.718,6.978,6.978,0,0,0-5.242.805c-1.5,1.064-2.2,2.966-2.061,5.653a35.489,35.489,0,0,0,1.373,6.348c1.07,3.505,2.233,5.49,3.457,5.9a1.548,1.548,0,0,0,.491.081,2.049,2.049,0,0,0,1.563-.886q1.042-1.25,2.155-2.438a3.472,3.472,0,0,0,1.55.417l0,.042q-.14.166-.273.338c-.375.475-.452.574-1.658.823-.343.071-1.254.259-1.267.9-.014.7,1.077.991,1.2,1.022a5.144,5.144,0,0,0,1.249.162,3.634,3.634,0,0,0,2.5-.934,23.674,23.674,0,0,0,.381,5.684,2.854,2.854,0,0,0,2.729,2.1,4.378,4.378,0,0,0,.917-.1,3.462,3.462,0,0,0,3.156-3.212c.177-1.026.481-3.475.624-4.789a3.859,3.859,0,0,0,1.11.137,6.6,6.6,0,0,0,2.519-.48c.712-.331,2-1.141,1.763-1.846ZM24.051,10.1a7.968,7.968,0,0,1-.116,1.107,10.229,10.229,0,0,0-.14,1.3,9.859,9.859,0,0,0,.1,1.47,5.236,5.236,0,0,1-.229,2.986,3.882,3.882,0,0,1-.207-.426c-.058-.141-.185-.368-.359-.681-.68-1.22-2.274-4.078-1.458-5.244.243-.347.86-.7,2.408-.512ZM22.174,3.531a6.617,6.617,0,0,1,5.334,2.522c.975,1.245-.1,6.912-3.205,11.8l-.094-.119-.039-.049a5.524,5.524,0,0,0,.506-3.8,9.114,9.114,0,0,1-.1-1.352,9.572,9.572,0,0,1,.131-1.206,7.614,7.614,0,0,0,.123-1.493.619.619,0,0,0,.013-.21,8.381,8.381,0,0,0-1.912-3.6,8.61,8.61,0,0,0-3.039-2.284,10.246,10.246,0,0,1,2.28-.214ZM9.479,20.654c-.627.754-1.061.61-1.2.562-.928-.31-2.006-2.272-2.955-5.384a35.167,35.167,0,0,1-1.34-6.159c-.12-2.4.462-4.074,1.73-4.974,2.063-1.463,5.456-.587,6.819-.143-.02.019-.04.037-.059.057-2.237,2.259-2.184,6.119-2.178,6.355,0,.091.007.22.018.4a15.969,15.969,0,0,1-.081,3.226A4.08,4.08,0,0,0,11.3,18.007q.133.138.278.262c-.383.41-1.216,1.318-2.1,2.385Zm2.39-3.19a3.3,3.3,0,0,1-.865-2.764,16.7,16.7,0,0,0,.087-3.381c-.006-.095-.011-.178-.014-.243A4.3,4.3,0,0,1,14,10.223a1.188,1.188,0,0,1,.918,1.026c.646,2.989.085,4.234-.365,5.235-.093.206-.181.4-.255.6l-.058.156a10.218,10.218,0,0,0-.368,1.109,2.788,2.788,0,0,1-2-.887Zm.113,4.03a1.733,1.733,0,0,1-.523-.225,2.553,2.553,0,0,1,.557-.166c1.418-.292,1.637-.5,2.116-1.105.11-.139.234-.3.406-.489h0c.256-.287.374-.238.586-.15a.829.829,0,0,1,.408.525.585.585,0,0,1-.05.491A3.1,3.1,0,0,1,11.983,21.495ZM19.406,28.4a2.113,2.113,0,0,1-2.754-1.526,31.129,31.129,0,0,1-.3-6.853.392.392,0,0,0-.017-.124,1.643,1.643,0,0,0-.048-.23,1.589,1.589,0,0,0-.862-1.034,1.216,1.216,0,0,0-.793-.1,9.586,9.586,0,0,1,.342-1.022l.058-.157c.066-.177.148-.36.235-.554.471-1.047,1.117-2.482.416-5.722a2.044,2.044,0,0,0-2.468-1.669A5.694,5.694,0,0,0,11.328,10c-.078.04-.15.078-.216.115A8.244,8.244,0,0,1,13.03,5.163,4.711,4.711,0,0,1,16.6,3.827,7.567,7.567,0,0,1,22.381,6.59,8.774,8.774,0,0,1,23.963,9.3c-1.463-.149-2.458.14-2.962.861-1.1,1.568.6,4.612,1.416,6.075.15.268.279.5.319.6a5.432,5.432,0,0,0,.861,1.387c.077.1.152.189.208.271-.443.128-1.239.423-1.166,1.9-.058.74-.474,4.205-.686,5.43-.279,1.617-.874,2.22-2.548,2.579Zm7.242-8.288a5.714,5.714,0,0,1-1.931.4,2.422,2.422,0,0,1-1.3-.167c-.045-.919.3-1.015.66-1.117.057-.016.112-.032.166-.05a1.353,1.353,0,0,0,.11.08c.639.422,1.78.467,3.39.135l.018,0a4.334,4.334,0,0,1-1.116.72Z",style:{fill:"#fff"}})),He=({size:e,type:t})=>t==="mysql"?s.jsx(ru,{width:e,height:e}):s.jsx(au,{width:e,height:e}),iu={mysql:"MySQL",postgres:"PostgreSQL"},lu={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"}]},cu={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"}]},uu=({show:e,onClose:t,dbType:n="postgres"})=>{const o=pc(),a=Xr(),{data:r}=ve(),[i,{change:c,set:u}]=kn({name:"",dbType:n,dbUrl:"",dbUser:"",dbPassword:"",dbDatabase:"",dbSchema:"",dbPort:n==="mysql"?3306:5432,teamId:"",ownerId:"",description:"",allowInsert:!1,allowUpdate:!1}),h=async()=>{const p=await o.mutateAsync({...i,dbPort:Number(i.dbPort),teamId:r.teamId,ownerId:r.id});await a.mutateAsync(p.id),t()},m=p=>{u("allowInsert",!p),u("allowUpdate",!p)},d=o.isPending||a.isPending,x=!i.allowInsert&&!i.allowUpdate;return s.jsxs(we,{isVisible:e,onClose:t,portal:!0,children:[s.jsxs("div",{className:"max-w-xl mx-auto overflow-y-auto",children:[s.jsxs("div",{className:$e.header,children:[s.jsx(He,{size:24,type:n}),s.jsx("p",{className:"text-(--text-color-primary) font-semibold",children:iu[n]})]}),o.isError&&s.jsx(me,{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(me,{className:"mb-2",variant:"info",children:"Creating connection"}),a.isPending&&s.jsx(me,{className:"mb-2",variant:"info",children:"Inspecting connection"}),s.jsxs("div",{className:"mt-2",children:[s.jsxs("div",{className:$e.content,children:[s.jsxs("div",{className:"flex flex-col",children:[s.jsx("label",{className:"text-sm font-semibold mb-2",htmlFor:"datasource-name",children:"Name"}),s.jsx("input",{value:i.name,onChange:c("name"),id:"datasource-name",className:"input",placeholder:"Data source name",disabled:d})]}),s.jsx("p",{className:"text-sm font-semibold mt-2",children:"Configuration"}),s.jsx(ou,{form:i,change:c,shape:i.dbType==="mysql"?lu:cu})]}),s.jsx("p",{className:"text-sm font-semibold mt-4",children:"Connection mode"}),s.jsxs("div",{className:$e.modeContainer,children:[s.jsxs("label",{onClick:()=>m(!0),className:I($e.modeSelect,x&&$e.selected),children:[s.jsxs("span",{className:"text-sm font-semibold text-(--text-color-primary)",children:[s.jsx("input",{type:"radio",disabled:d,checked:x,className:"mr-2"}),"Read-only mode"]}),s.jsxs("p",{className:"text-sm mt-1 text-(--text-color-primary)",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",{onClick:()=>m(!1),className:I($e.modeSelect,!x&&$e.selected),children:[s.jsxs("span",{className:"text-sm font-semibold text-(--text-color-primary)",children:[s.jsx("input",{type:"radio",disabled:d,checked:!x,className:"mr-2"}),"Read/Write mode"]}),s.jsxs("p",{className:"text-sm mt-1 text-(--text-color-primary)",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:t,className:"button tertiary",disabled:d,children:"Cancel"}),s.jsx("button",{onClick:h,className:"button primary",disabled:d,children:"Create"})]})]})},du="_data-source-entry_eol0c_2",hu="_action-title_eol0c_2",mu="_recent-tabs-container_eol0c_2",fu="_recent-tabs-entry_eol0c_2",pu="_home-action-button_eol0c_2",xu="_home-gray-card_eol0c_2",gu="_home-card-title_eol0c_2",bu="_home-card-grid-content_eol0c_2",vu="_useful-links_eol0c_2",Q={dataSourceEntry:du,actionTitle:hu,recentTabsContainer:mu,recentTabsEntry:fu,homeActionButton:pu,homeGrayCard:xu,homeCardTitle:gu,homeCardGridContent:bu,usefulLinks:vu},[yu,In]=ye({show:!1}),[wu,jn]=ye({show:!1}),[Cu,Nn]=ye(void 0),ju=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"})),Nu=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"})),_u=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})),Su=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{d:"M336 208v-95a80 80 0 00-160 0v95",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32}),l.createElement("rect",{x:96,y:208,width:320,height:272,rx:48,ry:48,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32})),tn=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("title",null,"Search"),l.createElement("path",{d:"M221.09 64a157.09 157.09 0 10157.09 157.09A157.1 157.1 0 00221.09 64z",fill:"none",stroke:"currentColor",strokeMiterlimit:10,strokeWidth:32}),l.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeMiterlimit:10,strokeWidth:32,d:"M338.29 338.29L448 448"})),ra=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{d:"M145.61 464h220.78c19.8 0 35.55-16.29 33.42-35.06C386.06 308 304 310 304 256s83.11-51 95.8-172.94c2-18.78-13.61-35.06-33.41-35.06H145.61c-19.8 0-35.37 16.28-33.41 35.06C124.89 205 208 201 208 256s-82.06 52-95.8 172.94c-2.14 18.77 13.61 35.06 33.41 35.06z",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32}),l.createElement("path",{d:"M343.3 432H169.13c-15.6 0-20-18-9.06-29.16C186.55 376 240 356.78 240 326V224c0-19.85-38-35-61.51-67.2-3.88-5.31-3.49-12.8 6.37-12.8h142.73c8.41 0 10.23 7.43 6.4 12.75C310.82 189 272 204.05 272 224v102c0 30.53 55.71 47 80.4 76.87 9.95 12.04 6.47 29.13-9.1 29.13z",fill:"currentColor"})),aa=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{d:"M436.67 184.11a27.17 27.17 0 01-38.3 0l-22.48-22.49a27.15 27.15 0 010-38.29l50.89-50.89a.85.85 0 00-.26-1.38C393.68 57 351.09 64.15 324.05 91c-25.88 25.69-27.35 64.27-17.87 98a27 27 0 01-7.67 27.14l-173 160.76a40.76 40.76 0 1057.57 57.54l162.15-173.3a27 27 0 0126.77-7.7c33.46 8.94 71.49 7.26 97.07-17.94 27.49-27.08 33.42-74.94 20.1-102.33a.85.85 0 00-1.36-.22z",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeMiterlimit:10,strokeWidth:32}),l.createElement("path",{d:"M224 284c-17.48-17-25.49-24.91-31-30.29a18.24 18.24 0 01-3.33-21.35 20.76 20.76 0 013.5-4.62l15.68-15.29a18.66 18.66 0 015.63-3.87 18.11 18.11 0 0120 3.62c5.45 5.29 15.43 15 33.41 32.52M317.07 291.3c40.95 38.1 90.62 83.27 110 99.41a13.46 13.46 0 01.94 19.92L394.63 444a14 14 0 01-20.29-.76c-16.53-19.18-61.09-67.11-99.27-107",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32}),l.createElement("path",{d:"M17.34 193.5l29.41-28.74a4.71 4.71 0 013.41-1.35 4.85 4.85 0 013.41 1.35h0a9.86 9.86 0 008.19 2.77c3.83-.42 7.92-1.6 10.57-4.12 6-5.8-.94-17.23 4.34-24.54a207 207 0 0119.78-22.6c6-5.88 29.84-28.32 69.9-44.45A107.31 107.31 0 01206.67 64c22.59 0 40 10 46.26 15.67a89.54 89.54 0 0110.28 11.64 78.92 78.92 0 00-9.21-2.77 68.82 68.82 0 00-20-1.26c-13.33 1.09-29.41 7.26-38 14-13.9 11-19.87 25.72-20.81 44.71-.68 14.12 2.72 22.1 36.1 55.49a6.6 6.6 0 01-.34 9.16l-18.22 18a6.88 6.88 0 01-9.54.09c-21.94-21.94-36.65-33.09-45-38.16s-15.07-6.5-18.3-6.85a30.85 30.85 0 00-18.27 3.87 11.39 11.39 0 00-2.64 2 14.14 14.14 0 00.42 20.08l1.71 1.6a4.63 4.63 0 010 6.64L71.73 246.6a4.71 4.71 0 01-3.41 1.4 4.86 4.86 0 01-3.41-1.35l-47.57-46.43a4.88 4.88 0 010-6.72z",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32})),Qo=20,lo="text-(--text-color-primary)",ku=()=>{const e=Tn("Home");return s.jsxs("div",{className:Q.homeActionButton,onClick:e,children:[s.jsx(tn,{width:Qo,height:Qo,className:lo}),s.jsx("h2",{className:Q.actionTitle,children:"Start new query"})]})},Eu=()=>s.jsxs("div",{className:Q.homeActionButton,onClick:()=>In({show:!0}),children:[s.jsx(ra,{width:20,height:20,className:lo}),s.jsx("h2",{className:Q.actionTitle,children:"Saved queries"})]}),Ru={mysql:"MySQL",postgres:"PostgreSQL"},Ko=({dbType:e})=>{const[t,n]=l.useState(void 0),o=An(he.EDITOR),a=r=>{o?n(r):ke.error("You don't have permission to connect new data sources in this team")};return s.jsxs("div",{children:[t&&s.jsx(uu,{show:!0,dbType:t,onClose:()=>n(void 0)}),s.jsxs("div",{className:Q.homeActionButton,onClick:()=>a(e),children:[s.jsx(He,{size:24,type:e}),s.jsx("p",{className:Q.actionTitle,children:Ru[e]})]})]})},Lu=()=>s.jsxs("div",{className:Q.homeGrayCard,children:[s.jsx("h2",{className:Q.homeCardTitle,children:"Connect new data source"}),s.jsxs("div",{className:Q.homeCardGridContent,children:[s.jsx(Ko,{dbType:"mysql"}),s.jsx(Ko,{dbType:"postgres"})]})]}),Tu=()=>{const e=J(),{data:t}=bs(),n=Tn("Home"),o=()=>{t&&t.length>0?e(D.workbenchTab.build({id:t[0].id})):n()};return s.jsxs("div",{className:Q.homeActionButton,onClick:o,children:[s.jsx(aa,{width:20,height:20,className:lo}),s.jsx("h2",{className:Q.actionTitle,children:"Workbench"})]})},Au=()=>{const{data:e}=ve(),{data:t}=ao({teamId:e?.teamId});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(n=>s.jsxs("div",{className:Q.dataSourceEntry,onClick:()=>Nn(n.id),tabIndex:0,children:[!n.allowInsert&&s.jsx(Su,{"data-tooltip-id":"default","data-tooltip-content":"This datasource is read-only",width:18,height:18,className:"absolute top-2 right-2"}),s.jsx(He,{size:32,type:n.dbType}),s.jsxs("div",{className:"overflow-hidden",children:[s.jsx("p",{className:"text-(--text-color-primary) font-semibold truncate",children:n.name}),s.jsxs("p",{className:"text-sm text-(--text-color-secondary) truncate",children:[n.dbUrl,":",n.dbPort]})]})]},n.id))})]})},qt=24,ia=()=>s.jsxs("div",{className:Q.usefulLinks,children:[s.jsxs("a",{href:"https://dataramen.xyz/",target:"_blank",children:[s.jsx(_u,{width:qt,height:qt}),s.jsx("span",{children:"Docs"})]}),s.jsxs("a",{href:"https://github.com/OleksandrDemian/dataramen",target:"_blank",children:[s.jsx(ju,{width:qt,height:qt}),s.jsx("span",{children:"GitHub"})]}),s.jsxs("a",{href:"https://www.npmjs.com/package/@dataramen/cli",target:"_blank",children:[s.jsx(Nu,{width:qt,height:qt}),s.jsx("span",{children:"NPM"})]})]}),Iu=()=>{const{data:e}=ve(),{data:t,isLoading:n}=uc(e?.teamId),o=J();if(n||!t?.length)return null;const a=r=>{o(D.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(He,{size:20,type:r.dataSourceType}),s.jsx("span",{className:"text-sm text-(--text-color-secondary) truncate",children:r.dataSourceName})]})]},r.id))]})},Pu=()=>{const{data:e}=ve(),{data:t}=ao({teamId:e?.teamId}),n=!!t&&t.length>0,o=!!e;return s.jsx("div",{className:"page-container h-screen max-h-screen overflow-y-auto no-scrollbar",children:s.jsxs("div",{className:"page-content",children:[s.jsxs("div",{className:"py-10 text-center w-full sticky top-0 z-0",children:[s.jsx("h1",{className:"comfortaa text-3xl font-semibold text-(--text-color-primary) mb-4",children:"DataRamen"}),s.jsx(ia,{})]}),s.jsxs("div",{className:"flex flex-col gap-8 mt-8 bg-(--bg) z-1",children:[o&&!n&&s.jsx(me,{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(ku,{}),o&&s.jsx(Tu,{}),s.jsx(Eu,{})]})]}),o&&s.jsx(Au,{}),s.jsx(Lu,{}),s.jsx(Iu,{})]})]})})},[Mu,co]=ye(void 0),Ou=()=>co(void 0);function wt(e,t){if(e==null)return"";switch(t){case"json":case"jsonb":return JSON.stringify(e,null,2)}if(e===0||e===!1)return e.toString();switch(typeof e){case"string":return e;case"number":case"boolean":return e.toString();default:return JSON.stringify(e)}}const ts=e=>e.distinct?[e.fn,"DISTINCT",e.value].join(" "):[e.fn,e.value].join(" "),st=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},Du="_container_vv7za_2",$u="_header_vv7za_2",Fu="_fields-container_vv7za_2",Bu="_field-label_vv7za_2",Wu="_actions_vv7za_2",xn={container:Du,header:$u,fieldsContainer:Fu,fieldLabel:Bu,actions:Wu},qu=(e,t,n)=>be({queryKey:["entity",e,t,n],queryFn:async()=>{const{data:o}=await $.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}),Uu=()=>ee({mutationFn:async e=>{const{data:t}=await $.post(`/runner/${e.datasourceId}/update`,e);return t.data}}),Hu=()=>ee({mutationFn:async e=>{const{data:t}=await $.post(`/runner/${e.datasourceId}/insert`,e);return t.data}}),uo=e=>l.useMemo(()=>{if(e)return e instanceof ii?e.response?.data.error?e.response.data.error:e.response?.data?.message?e.response.data.message:e.message:e instanceof Error?e.message:"Undefined error"},[e]),ho=()=>{const{pathname:e}=fe();return l.useMemo(()=>Kt({path:D.workbenchTab.path,end:!1},e)?.params.id,[e])},la=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{d:"M248 64C146.39 64 64 146.39 64 248s82.39 184 184 184 184-82.39 184-184S349.61 64 248 64z",fill:"none",stroke:"currentColor",strokeMiterlimit:10,strokeWidth:32}),l.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32,d:"M220 220h32v116"}),l.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeMiterlimit:10,strokeWidth:32,d:"M208 340h88"}),l.createElement("path",{d:"M248 130a26 26 0 1026 26 26 26 0 00-26-26z",fill:"currentColor"})),zu="_container_2j1dh_2",Vu={container:zu},Pn=({containerClassName:e,className:t,...n})=>s.jsxs("label",{className:I(Vu.container,e),children:[s.jsx(tn,{width:16,height:16}),s.jsx("input",{className:I("flex-1 outline-none",t),...n})]}),Qu=({data:e})=>{const[t,{change:n,touched:o}]=kn({}),a=ho(),{mutateAsync:r,error:i}=Hu(),c=uo(i),{data:u}=xs(e.dataSourceId),[h,m]=l.useState(""),d=l.useMemo(()=>u?.find(b=>b.tableName===e.table),[u,e.table]),x=l.useMemo(()=>{if(!d)return[];if(!h)return d.columns.map(g=>({...g,label:st(g.name)}));const b=h.toLowerCase();return d.columns.filter(g=>g.name.toLowerCase().includes(b)).map(g=>({...g,label:st(g.name)}))},[h,d]),p=()=>{const b={};for(const g of o)b[g]=t[g];r({datasourceId:e.dataSourceId,table:e.table,values:b}).then(()=>{Ou(),a&&ta(a)})};return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:xn.header,children:[s.jsxs("p",{className:"text-lg font-semibold",children:["Insert new record in ",s.jsx("span",{className:"underline",children:e.table})]}),c&&s.jsx(me,{variant:"danger",children:s.jsx("p",{children:c})}),s.jsx(Pn,{containerClassName:"mt-2",className:"text-sm",value:h,onChange:b=>m(b.target.value),placeholder:"Filter columns",autoFocus:!0})]}),s.jsx("div",{className:xn.container,children:s.jsx("div",{className:xn.fieldsContainer,children:x.map(b=>s.jsxs("label",{className:xn.fieldLabel,children:[s.jsxs("div",{className:"flex justify-between mb-0.5",children:[s.jsxs("p",{children:[b.isPrimary?"🔐":"🏷️"," ",b.label]}),s.jsxs("p",{className:"text-blue-800 text-sm",children:["[",b.name,": ",b.type,"]"]})]}),s.jsx("input",{className:"input w-full",value:wt(t[b.name]),onChange:n(b.name)})]},b.name))})}),s.jsxs("div",{className:xn.actions,children:[s.jsx("span",{"data-tooltip-id":"default","data-tooltip-content":"Tip: use = to write raw SQL. Ex: =NULL or =NOW()",children:s.jsx(la,{className:"text-(--text-color-secondary)",width:22,height:22})}),s.jsx("span",{className:"flex-1"}),s.jsx("button",{disabled:!o.length,className:"button primary",onClick:p,children:"Run insert"})]})]})},Ku=()=>{const e=Mu(),[t,n]=l.useState(void 0);l.useEffect(()=>{e&&n(e)},[e]);const o=()=>co(void 0);return s.jsxs(we,{isVisible:e!=null,onClose:o,onClosed:()=>n(void 0),noPadding:!0,children:[s.jsx(lt,{onClick:o}),t&&s.jsx(Qu,{data:t})]})},[Gu,Mn]=ye(void 0),Yu=()=>Mn(void 0),Ju="_container_d1krb_2",Xu="_header_d1krb_2",Zu="_fields-container_d1krb_2",ed="_field-label_d1krb_2",td="_actions_d1krb_2",gn={container:Ju,header:Xu,fieldsContainer:Zu,fieldLabel:ed,actions:td},Je=()=>Date.now().toString(36)+Math.random().toString(36).substring(2),ca=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{d:"M384 224v184a40 40 0 01-40 40H104a40 40 0 01-40-40V168a40 40 0 0140-40h167.48M336 64h112v112M224 288L440 72",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32})),nd=e=>{if(e==null)return"<NULL>";if(e==="")return"<EMPTY STRING>"},sd=({data:e})=>{const[t,{change:n,set:o,reset:a,touched:r}]=kn({}),i=ho(),c=J(),[u,h]=l.useState(""),{data:m,isLoading:d}=qu(e.dataSourceId,e.tableName,e.entityId),{mutateAsync:x,error:p}=Uu(),{mutateAsync:b}=Et(),g=uo(p),v=An(he.EDITOR),{data:y}=xs(e.dataSourceId),{data:f}=ps(e.dataSourceId),w=l.useMemo(()=>y?.find(j=>j.tableName===e.tableName),[e.tableName,y]),C=l.useMemo(()=>{if(!w)return[];if(!u)return w.columns.map(k=>({...k,label:st(k.name)}));const j=u.toLowerCase();return w.columns.filter(k=>k.name.toLowerCase().includes(j)).map(k=>({...k,label:st(k.name)}))},[u,w]),_=l.useMemo(()=>{const j={};if(!m?.entity)return j;for(let k=0;k<m.columns.length;k++)j[m.columns[k]?.column]=nd(m.entity[k]);return j},[m]);l.useEffect(()=>{const j=m?.entity;if(a(),j&&m?.columns)for(let k=0;k<m.columns.length;k++){const X=m.columns[k];o(X.column,wt(j[k]))}},[m,o,a]);const A=()=>{const j={};for(const k of r)j[k]=t[k];x({datasourceId:e.dataSourceId,table:e.tableName,filters:e.entityId.map(k=>({id:Je(),value:""+k[1],column:k[0],isEnabled:!0})),values:j}).then(()=>{Yu(),i&&ta(i)})},S=()=>{b({name:e.tableName,opts:Nt({dataSourceId:e.dataSourceId,table:e.tableName,filters:e.entityId.map(([j,k])=>({value:`${k}`,column:`${e.tableName}.${j}`,id:Je(),isEnabled:!0}))})}).then(({id:j})=>{c(D.workbenchTab.build({id:j})),Mn(void 0)})},P=!f?.allowUpdate||!v;return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:gn.header,children:[s.jsxs("p",{className:"text-lg font-semibold",children:[P?"View":"Edit"," row in ",s.jsx("span",{className:"underline",children:e?.tableName})]}),g&&s.jsx(me,{variant:"danger",children:s.jsx("p",{children:g})}),s.jsx(Pn,{containerClassName:"mt-2",className:"text-sm",value:u,onChange:j=>h(j.target.value),placeholder:"Filter columns",autoFocus:!0})]}),s.jsx("div",{className:gn.container,children:s.jsx("div",{className:gn.fieldsContainer,children:C.map(j=>s.jsxs("label",{className:gn.fieldLabel,children:[s.jsxs("div",{className:"flex justify-between mb-0.5",children:[s.jsxs("p",{children:[j.isPrimary?"🔐":"🏷️"," ",j.label]}),s.jsxs("p",{className:"text-blue-800 text-sm",children:["[",j.name,": ",j.type,"]"]})]}),s.jsx("input",{disabled:j.isPrimary||d||P,className:"input w-full secondary",value:wt(t[j.name]),onChange:n(j.name),placeholder:_[j.name]})]},j.name))})}),s.jsxs("div",{className:gn.actions,children:[!P&&s.jsx("span",{"data-tooltip-id":"default","data-tooltip-content":"Tip: use = to write raw SQL. Ex: =NULL or =NOW()",children:s.jsx(la,{className:"text-(--text-color-secondary)",width:22,height:22})}),s.jsx("span",{className:"flex-1"}),s.jsxs("button",{className:"button tertiary flex gap-2 items-center",onClick:S,children:[s.jsx(ca,{width:16,height:16}),s.jsx("span",{children:"Open in new tab"})]}),!P&&s.jsx("button",{disabled:!r.length,className:"button primary",onClick:A,children:"Update"})]})]})},od=()=>{const e=Gu(),[t,n]=l.useState(void 0);l.useEffect(()=>{e&&n(e)},[e]);const o=()=>Mn(void 0);return s.jsxs(we,{isVisible:e!=null,onClose:o,onClosed:()=>n(void 0),noPadding:!0,children:[s.jsx(lt,{onClick:o}),t&&s.jsx(sd,{data:t})]})},[rd,Is]=ye(void 0),mo=async e=>new Promise(t=>{Is({message:e,onCancel:()=>{t(!1),Is(void 0)},onConfirm:()=>{t(!0),Is(void 0)}})}),ad=({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"})]})]}),id=()=>{const e=rd(),[t,n]=l.useState(void 0);return l.useEffect(()=>{e&&n(e)},[e]),s.jsx(we,{isVisible:!!e,onClose:()=>e?.onCancel(),onClosed:()=>n(void 0),children:t&&s.jsx(ad,{confirm:t})})},[ld,ns]=ye(void 0),On=async(e,t,n)=>new Promise(o=>{ns({message:e,defaultValue:t,alert:n,onCancel:()=>{ns(void 0),o(void 0)},onConfirm:a=>{ns(void 0),o(a)}})}),cd="_root_ng9lp_1",ud={root:cd},dd=({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:ud.root,children:[s.jsx("h2",{className:"text-xl font-semibold",children:e.message}),e.alert&&s.jsx(me,{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"})]})]})},hd=()=>{const e=ld(),[t,n]=l.useState(void 0);return l.useEffect(()=>{e&&n(e)},[e]),s.jsx(we,{isVisible:!!e,onClose:()=>ns(void 0),onClosed:()=>n(void 0),children:t&&s.jsx(dd,{data:t})})},[md,fd]=ye(void 0),ua=e=>{fd(e)},pd="_textarea_hnrhc_2",xd={textarea:pd},gd=()=>{const e=md(),t=()=>{e&&(navigator.clipboard.writeText(e.toString()),ke.success("Copied!"))},n=()=>ua(void 0);return s.jsxs(we,{isVisible:!!e,onClose:n,backdropClose:!0,children:[s.jsx("textarea",{className:xd.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"})]})]})},bd="_tabs_10dyn_2",vd="_mobile_10dyn_2",yd="_tab_10dyn_2",wd="_active_10dyn_2",Cd="_close-button_10dyn_2",bn={tabs:bd,mobile:vd,tab:yd,active:wd,closeButton:Cd},Go=e=>window.matchMedia(e).matches;function da(e,{defaultValue:t=!1,initializeWithValue:n=!0}={}){const[o,a]=l.useState(()=>n?Go(e):t);return l.useLayoutEffect(()=>{const r=window.matchMedia(e);function i(){a(()=>Go(e))}return i(),r.addListener?r.addListener(i):r.addEventListener("change",i),()=>{r.removeListener?r.removeListener(i):r.removeEventListener("change",i)}},[e]),o}const fo={laptop:"(min-width: 1024px)"},ha=()=>window.matchMedia(fo.laptop).matches,jd="_table_b7t0v_2",Nd="_row-index-btn_b7t0v_2",_d="_semi-transparent_b7t0v_2",Sd="_table-loading_b7t0v_2",kd="_table-empty_b7t0v_2",Ed="_table-row-cells_b7t0v_2",Rd="_header-cell_b7t0v_2",Ld="_header-actions_b7t0v_2",Td="_cell_b7t0v_2",Ad="_value_b7t0v_2",Id="_table-config_b7t0v_2",Pd="_table-action_b7t0v_2",Md="_green-fixed_b7t0v_2",Od="_gray_b7t0v_2",Dd="_modal_b7t0v_2",$d="_selected-size_b7t0v_2",Fd="_pagination-indicator_b7t0v_2",R={table:jd,rowIndexBtn:Nd,semiTransparent:_d,tableLoading:Sd,tableEmpty:kd,tableRowCells:Ed,headerCell:Rd,headerActions:Ld,cell:Td,value:Ad,tableConfig:Id,tableAction:Pd,greenFixed:Md,gray:Od,modal:Dd,selectedSize:$d,paginationIndicator:Fd},Pe=l.createContext({name:"No name",hooks:[],availableJoins:[],allColumns:[],dataSourceId:"",entities:[],getValue:()=>{},getValueByIndex:()=>{},getColumnByIndex:()=>{},getColumnType:()=>{}}),Ce=l.createContext({state:Nt({}),setState:()=>{}}),Xe=l.createContext({}),ma={ON_ANIMATION_END:Symbol("ON_TRANSITION_END")},fa=()=>{const[e,t]=l.useState(),[n,o]=l.useState("hidden");return l.useMemo(()=>{const 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,[ma.ON_ANIMATION_END]:i}},[e,n])},Bd=e=>{if(e!=="ASC")return e==="DESC"?"ASC":"DESC"},Wd=()=>{const{state:e,setState:t}=l.useContext(Ce),n=l.useCallback(o=>{t(a=>{const r=a.orderBy[0];if(r&&r.column===o){const i=Bd(r.direction);return i?{...a,orderBy:[{column:o,direction:i}]}:{...a,orderBy:[]}}return{...a,orderBy:[{column:o,direction:"DESC"}]}})},[t]);return{orderBy:e.orderBy,updateOrderBy:n}},qd="_options-container_1a3vk_2",Ud="_filter-input_1a3vk_2",Hd="_list_1a3vk_2",zd="_empty-text_1a3vk_2",Ct={optionsContainer:qd,filterInput:Ud,list:Hd,emptyText:zd},Vd="_container_4c3jl_2",Qd="_animate-show_4c3jl_2",Kd="_animate-hide_4c3jl_2",Gd="_content_4c3jl_2",Yd="_backdrop_4c3jl_2",pt={container:Vd,animateShow:Qd,animateHide:Kd,content:Gd,backdrop:Yd},pa=({children:e,handler:t})=>{const n=l.useRef(t.close);n.current=t.close;const o=l.useMemo(()=>{if(!t.position)return;const r={};if(typeof window<"u"){const i=t.position.y>window.innerHeight/2,c=t.position.x>window.innerWidth/2;i?r.bottom=window.innerHeight-t.position.y:r.top=t.position.y,ha()?c?r.right=window.innerWidth-t.position.x:r.left=t.position.x:(r.right=36,r.left=36)}return r},[t.position]);if(vs({enabled:!!o,onClose:t.close}),!o)return null;const a=s.jsxs("div",{className:I(pt.container,t.state==="out"&&pt.animateHide,t.state==="in"&&pt.animateShow),onAnimationEnd:t[ma.ON_ANIMATION_END],children:[s.jsx("div",{className:pt.backdrop,onClick:r=>{r.stopPropagation(),r.preventDefault(),t.close()}}),s.jsx("div",{className:I(pt.content,t.state==="out"&&pt.animateHide,t.state==="in"&&pt.animateShow),style:o,children:e})]});return oo.createPortal(a,document.body)},ge=(e,t)=>e!=null&&e>t,Jd=(e,t)=>e!=null&&e<t,Xd="_root_1xtbh_2",Zd="_content_1xtbh_2",eh="_table-name_1xtbh_2",th="_sub_1xtbh_2",tt={root:Xd,content:Zd,tableName:eh,sub:th},po=({hook:e,onClick:t})=>e.direction==="out"?s.jsx("button",{className:tt.root,onClick:t,children:s.jsxs("div",{className:tt.content,children:[s.jsx("p",{className:tt.tableName,children:e.toTable}),s.jsxs("p",{className:tt.sub,children:[e.toColumn," = ",e.fromTable,".",e.fromColumn]})]})},e.id):s.jsx("button",{className:tt.root,onClick:t,children:s.jsxs("div",{className:tt.content,children:[s.jsx("p",{className:tt.tableName,children:e.fromTable}),s.jsxs("p",{className:tt.sub,children:[e.fromColumn," = ",e.toTable,".",e.toColumn]})]})},e.id);function nh(e,t,n,o){if(e.direction==="out"){const r=o(n,e.fromTable,e.fromColumn);return{name:`${e.toTable} ${e.toColumn} equals ${r}`,opts:Nt({table:e.toTable,dataSourceId:t,filters:[{id:Je(),column:`${e.toTable}.${e.toColumn}`,value:r==null?"IS NULL":`${r}`,isEnabled:!0}]})}}const a=o(n,e.toTable,e.toColumn);return{name:`${e.fromTable} ${e.fromColumn} equals ${a}`,opts:Nt({table:e.fromTable,dataSourceId:t,filters:[{id:Je(),column:`${e.fromTable}.${e.fromColumn}`,value:a==null?"IS NULL":`${a}`,isEnabled:!0}]})}}const xa=({rowIndex:e,colIndex:t,onClose:n,className:o})=>{const[a,r]=l.useState(""),{dataSourceId:i,hooks:c,getColumnByIndex:u,getValue:h}=l.useContext(Pe),m=l.useMemo(()=>{if(t===void 0)return c;const v=u(t);return v?c.filter(y=>y.toColumn===v.column&&y.toTable===v.table):[]},[t,c,u]),d=Et(),x=J(),p=l.useMemo(()=>{const v=a.toLowerCase();return m.filter(y=>y.fromTable.toLowerCase().includes(v))},[a,m]),b=v=>{d.mutateAsync(nh(v,i,e,h)).then(y=>{x(D.workbenchTab.build({id:y.id})),n?.()})},g=ge(p.length,0);return s.jsxs("div",{className:o,children:[s.jsx(Pn,{autoFocus:!0,className:Ct.filterInput,placeholder:"Filter",value:a,onChange:v=>r(v.target.value)}),s.jsxs("div",{className:Ct.list,children:[g&&p.map(v=>s.jsx(po,{hook:v,onClick:()=>b(v)},v.id)),!g&&s.jsx("p",{className:Ct.emptyText,children:"Empty"})]})]})},sh=({handler:e,rowIndex:t,colIndex:n})=>s.jsx(pa,{handler:e,children:s.jsx("div",{className:Ct.optionsContainer,children:s.jsx(xa,{rowIndex:t,colIndex:n,className:"p-2",onClose:()=>{e.close()}})})}),xo=()=>{const{state:e,setState:t}=l.useContext(Ce),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}},oh=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"})),rh=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"})),ah="_container_1muii_2",ih="_animate-show_1muii_2",lh="_animate-hide_1muii_2",ch="_backdrop_1muii_2",uh="_content_1muii_2",xt={container:ah,animateShow:ih,animateHide:lh,backdrop:ch,content:uh},ga=({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,d=!0)=>{d||(m.preventDefault(),m.stopPropagation());const x={},p=m.clientY>window.innerHeight/2,b=m.clientX>window.innerWidth/2;p?x.bottom=window.innerHeight-m.clientY:x.top=m.clientY,ha()?b?x.right=window.innerWidth-m.clientX:x.left=m.clientX:(x.right=36,x.left=36),a(x),i("in")},close:()=>{i("out")}}),[]),vs({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?.())},h=s.jsxs("div",{className:I(xt.container,r==="out"&&xt.animateHide,r==="in"&&xt.animateShow),onAnimationEnd:u,children:[s.jsx("div",{className:xt.backdrop,onClick:()=>i("out")}),s.jsx("div",{ref:c,style:o,className:I(xt.content,r==="out"&&xt.animateHide,r==="in"&&xt.animateShow),children:e})]});return oo.createPortal(h,document.body)};function Ps(e,t,n){const o=e?.rows?.[t]?.[n],a=e?.columns?.[n];return{value:o,column:a}}const dh=({ref:e})=>{const{data:t}=l.useContext(Xe),{getColumnType:n}=l.useContext(Pe),{setState:o}=l.useContext(Ce);return{copyValue:(c,u)=>{const{value:h,column:m}=Ps(t?.result,c,u);if(m){const d=wt(h,n(m.full));navigator.clipboard.writeText(d),ke.success("Copied!"),e.current?.close()}},showValue:(c,u)=>{const{value:h,column:m}=Ps(t?.result,c,u);if(m){const d=wt(h,n(m.full));ua(d),e.current?.close()}},filterValue:(c,u)=>{const{value:h,column:m}=Ps(t?.result,c,u),d=m?.full||"";if(d){let x;if(h==null)x={id:Je(),isEnabled:!0,isAdvanced:!0,column:d,value:"IS NULL"};else{const p=wt(h,n(d));x={id:Je(),isEnabled:!0,column:d,value:p,fn:m?.fn}}o(p=>({...p,filters:[...p.filters,x]})),ke.success(`Added new filter on column ${m?.alias}`),e.current?.close()}}}},ba=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("rect",{x:128,y:128,width:336,height:336,rx:57,ry:57,fill:"none",stroke:"currentColor",strokeLinejoin:"round",strokeWidth:32}),l.createElement("path",{d:"M383.5 128l.5-24a56.16 56.16 0 00-56-56H112a64.19 64.19 0 00-64 64v216a56.16 56.16 0 0056 56h24",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32})),hh=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})),mh="_section-name_oxp30_2",fh="_item_oxp30_2",gt={sectionName:mh,item:fh},yt=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{d:"M414 321.94L274.22 158.82a24 24 0 00-36.44 0L98 321.94c-13.34 15.57-2.28 39.62 18.22 39.62h279.6c20.5 0 31.56-24.05 18.18-39.62z",fill:"currentColor"})),ph=({onClose:e,rowIndex:t,className:n})=>{const[o,a]=l.useState(""),{entities:r,dataSourceId:i,getValue:c}=l.useContext(Pe),u=l.useMemo(()=>{if(!o)return r;const m=o.toLowerCase();return r.filter(d=>d.toTable.toLowerCase().includes(m))},[r,o]),h=m=>{const d=c(t,m.fromTable,m.fromColumn);d?Mn({tableName:m.toTable,dataSourceId:i,entityId:[[m.toColumn,""+d]]}):ke.error(`Cannot open ${m.toTable} record. ${m.fromTable}.${m.fromColumn} is NULL`),e?.()};return s.jsxs("div",{className:n,children:[s.jsx(Pn,{autoFocus:!0,className:Ct.filterInput,placeholder:"Filter",value:o,onChange:m=>a(m.target.value)}),s.jsx("div",{className:Ct.list,children:ge(u.length,0)?u.map(m=>s.jsx(po,{hook:m,onClick:()=>h(m)},m.id)):s.jsx("p",{className:Ct.emptyText,children:"Empty"})})]})},xh=({ref:e,row:t,col:n,onClosed:o})=>{const a=dh({ref:e}),[r,i]=l.useState("cell"),{hooks:c,entities:u}=l.useContext(Pe),h=()=>a.copyValue(t,n),m=()=>a.showValue(t,n),d=()=>a.filterValue(t,n),x=()=>{i("show-record")},p=()=>{o?.(),i("cell")},b=ge(c?.length,0),g=ge(u?.length,0);return s.jsx(ga,{ref:e,onClosed:p,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:h,children:[s.jsx(ba,{width:14,height:14}),"Copy"]}),s.jsxs("button",{className:gt.item,onClick:m,children:[s.jsx(hh,{width:14,height:14}),"View"]}),s.jsxs("button",{className:gt.item,onClick:d,children:[s.jsx(tn,{width:14,height:14}),"Filter"]}),(g||b)&&s.jsx("p",{className:gt.sectionName,children:"Row actions"}),g&&s.jsxs("button",{className:gt.item,onClick:x,children:[s.jsx(yt,{className:"text-green-600",width:14,height:14}),"Show record"]}),b&&s.jsxs("button",{className:gt.item,onClick:()=>i("drill"),children:[s.jsx(yt,{className:"text-blue-600 rotate-180",width:14,height:14}),"Drill down"]})]}),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(yt,{className:"text-(--text-color-secondary) rotate-270",width:16,height:16}),"Drill down"]}),s.jsx(xa,{rowIndex:t,onClose:()=>e.current?.close()})]}),r==="show-record"&&s.jsxs(s.Fragment,{children:[s.jsxs("button",{className:"flex gap-1 items-center cursor-pointer px-2 py-1 text-sm rounded-lg bg-gray-50 hover:bg-gray-100 mb-2",onClick:()=>i("cell"),children:[s.jsx(yt,{className:"text-(--text-color-secondary) rotate-270",width:16,height:16}),"Show record"]}),s.jsx(ph,{rowIndex:t,onClose:()=>e.current?.close()})]})]})})},gh={DESC:"",ASC:"rotate-180"},bh=(e,{column:t,value:n,fn:o})=>{const a=e.map(r=>({...r,isEnabled:r.column===t?!1:r.isEnabled}));return a.push({id:Je(),column:t,isEnabled:!0,value:n,fn:o,isAdvanced:!1}),a},vh=()=>{const{data:e}=l.useContext(Xe),{orderBy:t,updateOrderBy:n}=Wd(),{setFilters:o,filters:a}=xo(),r=e?.result.columns||[],i=t[0],c=ge(e?.result.tables.length,1),u=(h,m)=>{On("Filter value","").then(d=>{d&&o(bh(a,{column:h,value:d,fn:m}))})};return s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("td",{children:"🥢"}),r.map(h=>s.jsxs("td",{className:R.headerCell,children:[s.jsxs("div",{className:"overflow-hidden",children:[c&&s.jsx("p",{className:"text-xs truncate italic text-(--text-color-primary)",children:h.table||"-"}),s.jsx("p",{className:"text-sm font-semibold truncate text-(--text-color-primary)",children:h.column})]}),s.jsxs("div",{className:R.headerActions,children:[s.jsx("button",{onClick:()=>n(h.alias),children:i?.column===h.alias?s.jsx(oh,{className:gh[i.direction],width:16,height:16}):s.jsx(rh,{width:16,height:16})}),s.jsx("button",{onClick:()=>u(h.full,h.fn),children:s.jsx(tn,{width:16,height:16})})]})]},h.full))]})})};function yh({value:e,actions:t}){if(e==="")return s.jsx("span",{className:"pointer-events-none text-black/30 truncate",children:"<EMPTY STRING>"});if(e==null)return s.jsx("span",{className:"pointer-events-none text-black/30",children:"<NULL>"});const n=wt(e);return t?.hasRecord||t?.hasDrill?s.jsxs("div",{className:"flex gap-1 items-center justify-between pointer-events-none",children:[s.jsx("span",{className:R.value,children:n}),s.jsxs("div",{className:"flex",children:[t.hasRecord&&s.jsx("span",{className:"text-gray-300 hover:text-green-600 hover:bg-gray-100 rounded p-0.5 cursor-pointer pointer-events-auto","data-cell-action":"ref","data-tooltip-id":"default-xs","data-tooltip-content":"Show record",children:s.jsx(yt,{className:"pointer-events-none",width:16,height:16})}),t.hasDrill&&s.jsx("span",{className:"text-gray-300 hover:text-blue-600 hover:bg-gray-100 rounded p-0.5 cursor-pointer pointer-events-auto","data-cell-action":"drill","data-tooltip-id":"default-xs","data-tooltip-content":"Show related rows",children:s.jsx(yt,{className:"pointer-events-none rotate-180",width:16,height:16})})]})]}):s.jsx("span",{className:R.value,children:n})}const wh=l.memo(({row:e,isLastRow:t,index:n,offset:o,colMeta:a})=>s.jsxs("tr",{className:I(R.tableRowCells,t&&"rounded-b-lg"),children:[s.jsx("td",{"data-row":n,children:s.jsxs("button",{"data-cell-action":"drill-all",className:R.rowIndexBtn,children:[s.jsx(yt,{className:"rotate-180 pointer-events-none",width:16,height:16}),s.jsx("span",{children:n+1+o})]})}),e.map((r,i)=>s.jsx("td",{className:R.cell,"data-row":n,"data-col":i,children:s.jsx(yh,{value:r,actions:a.get(i)})},i))]})),Ch=e=>{if(e.tagName==="TD")return e;let t=e.parentElement,n=5;for(;t&&n>=0;){if(t.tagName==="TD")return t;t=t.parentElement,n--}},Yo=e=>{const t=Ch(e);if(!t)return;const n=parseInt(t.dataset.row,10),o=parseInt(t.dataset.col,10);return{row:n,col:Number.isNaN(o)?void 0:o}},jh=()=>{const{data:e,error:t,isLoading:n,isFetching:o}=l.useContext(Xe),{dataSourceId:a,getColumnByIndex:r,getValueByIndex:i}=l.useContext(Pe),{state:{page:c,size:u}}=l.useContext(Ce),h=l.useRef(null),m=uo(t),d=fa(),[x,p]=l.useState(),b=f=>{const w=f.target,C=w.dataset?.cellAction,_=Yo(w);if(C==="ref"&&ge(_?.col,-1)){const A=i(_.row,_.col),S=r(_.col);S&&Mn({tableName:S.ref.table,dataSourceId:a,entityId:[[S.ref.field,A]]})}else(C==="drill"||C==="drill-all")&&(p(_),d.open(f))},g=f=>{const w=Yo(f.target);w&&(p(w),h.current?.open(f),f.preventDefault(),f.stopPropagation())},v=c*u,y=l.useMemo(()=>{const f=new Map;return e&&e.result.columns.forEach((w,C)=>{f.set(C,{hasRecord:!!w.ref,hasDrill:!!w.referencedBy})}),f},[e]);return s.jsxs(s.Fragment,{children:[x&&d.show&&s.jsx(sh,{handler:d,rowIndex:x.row,colIndex:x.col}),s.jsx(xh,{ref:h,col:x?.col,row:x?.row,onClosed:()=>{p(void 0)}}),m&&s.jsx(me,{variant:"danger",children:m}),n&&s.jsx("div",{className:R.tableLoading,children:"Loading data"}),e&&s.jsxs("table",{className:I(R.table,o&&R.semiTransparent),onClick:b,onContextMenu:g,children:[s.jsx(vh,{}),s.jsxs("tbody",{children:[e.result.rows?.length<1&&s.jsx("tr",{className:R.tableEmpty,children:s.jsx("td",{colSpan:e.result.columns.length+1,children:"No data"})}),e.result.rows?.map((f,w)=>s.jsx(wh,{index:w,offset:v,row:f,colMeta:y,isLastRow:w===e.result.rows.length-1},w))]})]})]})},va=()=>{const{state:e,setState:t}=l.useContext(Ce),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}},Nh=()=>ee({mutationFn:async e=>{const{data:t}=await $.post("/saved-queries",e);return t.data},onSuccess:()=>{K.invalidateQueries({queryKey:["queries"]}),Zt()}}),_h=()=>ee({mutationFn:async e=>$.delete("/saved-queries/"+e),onSuccess:()=>{Zt()}}),Sh=()=>ee({mutationFn:async({id:e,payload:t})=>{const{data:n}=await $.patch("/saved-queries/"+e,t);return n.data},onSuccess:()=>{Zt(),ac()}}),[ys,go]=ye({filters:!1,joins:!1,columns:!1,groupBy:!1,aggregate:!1}),Fe=e=>go(t=>({...t,[e]:!0})),ws=e=>go(t=>({...t,[e]:!1})),as=e=>go(t=>({...t,[e]:!t[e]})),Gt=Math.min,jt=Math.max,is=Math.round,Yn=Math.floor,Be=e=>({x:e,y:e}),kh={left:"right",right:"left",bottom:"top",top:"bottom"},Eh={start:"end",end:"start"};function Qs(e,t,n){return jt(e,Gt(t,n))}function Dn(e,t){return typeof e=="function"?e(t):e}function St(e){return e.split("-")[0]}function $n(e){return e.split("-")[1]}function ya(e){return e==="x"?"y":"x"}function bo(e){return e==="y"?"height":"width"}const Rh=new Set(["top","bottom"]);function ot(e){return Rh.has(St(e))?"y":"x"}function vo(e){return ya(ot(e))}function Lh(e,t,n){n===void 0&&(n=!1);const o=$n(e),a=vo(e),r=bo(a);let i=a==="x"?o===(n?"end":"start")?"right":"left":o==="start"?"bottom":"top";return t.reference[r]>t.floating[r]&&(i=ls(i)),[i,ls(i)]}function Th(e){const t=ls(e);return[Ks(e),t,Ks(t)]}function Ks(e){return e.replace(/start|end/g,t=>Eh[t])}const Jo=["left","right"],Xo=["right","left"],Ah=["top","bottom"],Ih=["bottom","top"];function Ph(e,t,n){switch(e){case"top":case"bottom":return n?t?Xo:Jo:t?Jo:Xo;case"left":case"right":return t?Ah:Ih;default:return[]}}function Mh(e,t,n,o){const a=$n(e);let r=Ph(St(e),n==="start",o);return a&&(r=r.map(i=>i+"-"+a),t&&(r=r.concat(r.map(Ks)))),r}function ls(e){return e.replace(/left|right|bottom|top/g,t=>kh[t])}function Oh(e){return{top:0,right:0,bottom:0,left:0,...e}}function wa(e){return typeof e!="number"?Oh(e):{top:e,right:e,bottom:e,left:e}}function cs(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 Zo(e,t,n){let{reference:o,floating:a}=e;const r=ot(t),i=vo(t),c=bo(i),u=St(t),h=r==="y",m=o.x+o.width/2-a.width/2,d=o.y+o.height/2-a.height/2,x=o[c]/2-a[c]/2;let p;switch(u){case"top":p={x:m,y:o.y-a.height};break;case"bottom":p={x:m,y:o.y+o.height};break;case"right":p={x:o.x+o.width,y:d};break;case"left":p={x:o.x-a.width,y:d};break;default:p={x:o.x,y:o.y}}switch($n(t)){case"start":p[i]-=x*(n&&h?-1:1);break;case"end":p[i]+=x*(n&&h?-1:1);break}return p}const Dh=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 h=await i.getElementRects({reference:e,floating:t,strategy:a}),{x:m,y:d}=Zo(h,o,u),x=o,p={},b=0;for(let g=0;g<c.length;g++){const{name:v,fn:y}=c[g],{x:f,y:w,data:C,reset:_}=await y({x:m,y:d,initialPlacement:o,placement:x,strategy:a,middlewareData:p,rects:h,platform:i,elements:{reference:e,floating:t}});m=f??m,d=w??d,p={...p,[v]:{...p[v],...C}},_&&b<=50&&(b++,typeof _=="object"&&(_.placement&&(x=_.placement),_.rects&&(h=_.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:a}):_.rects),{x:m,y:d}=Zo(h,x,u)),g=-1)}return{x:m,y:d,placement:x,strategy:a,middlewareData:p}};async function Ca(e,t){var n;t===void 0&&(t={});const{x:o,y:a,platform:r,rects:i,elements:c,strategy:u}=e,{boundary:h="clippingAncestors",rootBoundary:m="viewport",elementContext:d="floating",altBoundary:x=!1,padding:p=0}=Dn(t,e),b=wa(p),v=c[x?d==="floating"?"reference":"floating":d],y=cs(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:h,rootBoundary:m,strategy:u})),f=d==="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},_=cs(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 $h=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:h,padding:m=0}=Dn(e,t)||{};if(h==null)return{};const d=wa(m),x={x:n,y:o},p=vo(a),b=bo(p),g=await i.getDimensions(h),v=p==="y",y=v?"top":"left",f=v?"bottom":"right",w=v?"clientHeight":"clientWidth",C=r.reference[b]+r.reference[p]-x[p]-r.floating[b],_=x[p]-r.reference[p],A=await(i.getOffsetParent==null?void 0:i.getOffsetParent(h));let S=A?A[w]:0;(!S||!await(i.isElement==null?void 0:i.isElement(A)))&&(S=c.floating[w]||r.floating[b]);const P=C/2-_/2,j=S/2-g[b]/2-1,k=Gt(d[y],j),X=Gt(d[f],j),je=k,Me=S-g[b]-X,W=S/2-g[b]/2+P,le=Qs(je,W,Me),oe=!u.arrow&&$n(a)!=null&&W!==le&&r.reference[b]/2-(W<je?k:X)-g[b]/2<0,Z=oe?W<je?W-je:W-Me:0;return{[p]:x[p]+Z,data:{[p]:le,centerOffset:W-le-Z,...oe&&{alignmentOffset:Z}},reset:oe}}}),Fh=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:h}=t,{mainAxis:m=!0,crossAxis:d=!0,fallbackPlacements:x,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:b="none",flipAlignment:g=!0,...v}=Dn(e,t);if((n=r.arrow)!=null&&n.alignmentOffset)return{};const y=St(a),f=ot(c),w=St(c)===c,C=await(u.isRTL==null?void 0:u.isRTL(h.floating)),_=x||(w||!g?[ls(c)]:Th(c)),A=b!=="none";!x&&A&&_.push(...Mh(c,g,b,C));const S=[c,..._],P=await Ca(t,v),j=[];let k=((o=r.flip)==null?void 0:o.overflows)||[];if(m&&j.push(P[y]),d){const W=Lh(a,i,C);j.push(P[W[0]],P[W[1]])}if(k=[...k,{placement:a,overflows:j}],!j.every(W=>W<=0)){var X,je;const W=(((X=r.flip)==null?void 0:X.index)||0)+1,le=S[W];if(le&&(!(d==="alignment"?f!==ot(le):!1)||k.every(H=>ot(H.placement)===f?H.overflows[0]>0:!0)))return{data:{index:W,overflows:k},reset:{placement:le}};let oe=(je=k.filter(Z=>Z.overflows[0]<=0).sort((Z,H)=>Z.overflows[1]-H.overflows[1])[0])==null?void 0:je.placement;if(!oe)switch(p){case"bestFit":{var Me;const Z=(Me=k.filter(H=>{if(A){const re=ot(H.placement);return re===f||re==="y"}return!0}).map(H=>[H.placement,H.overflows.filter(re=>re>0).reduce((re,Ve)=>re+Ve,0)]).sort((H,re)=>H[1]-re[1])[0])==null?void 0:Me[0];Z&&(oe=Z);break}case"initialPlacement":oe=c;break}if(a!==oe)return{reset:{placement:oe}}}return{}}}},Bh=new Set(["left","top"]);async function Wh(e,t){const{placement:n,platform:o,elements:a}=e,r=await(o.isRTL==null?void 0:o.isRTL(a.floating)),i=St(n),c=$n(n),u=ot(n)==="y",h=Bh.has(i)?-1:1,m=r&&u?-1:1,d=Dn(t,e);let{mainAxis:x,crossAxis:p,alignmentAxis:b}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return c&&typeof b=="number"&&(p=c==="end"?b*-1:b),u?{x:p*m,y:x*h}:{x:x*h,y:p*m}}const qh=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 Wh(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}}}}},Uh=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}=Dn(e,t),h={x:n,y:o},m=await Ca(t,u),d=ot(St(a)),x=ya(d);let p=h[x],b=h[d];if(r){const v=x==="y"?"top":"left",y=x==="y"?"bottom":"right",f=p+m[v],w=p-m[y];p=Qs(f,p,w)}if(i){const v=d==="y"?"top":"left",y=d==="y"?"bottom":"right",f=b+m[v],w=b-m[y];b=Qs(f,b,w)}const g=c.fn({...t,[x]:p,[d]:b});return{...g,data:{x:g.x-n,y:g.y-o,enabled:{[x]:r,[d]:i}}}}}};function Cs(){return typeof window<"u"}function nn(e){return ja(e)?(e.nodeName||"").toLowerCase():"#document"}function xe(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function ze(e){var t;return(t=(ja(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function ja(e){return Cs()?e instanceof Node||e instanceof xe(e).Node:!1}function Ae(e){return Cs()?e instanceof Element||e instanceof xe(e).Element:!1}function qe(e){return Cs()?e instanceof HTMLElement||e instanceof xe(e).HTMLElement:!1}function er(e){return!Cs()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof xe(e).ShadowRoot}const Hh=new Set(["inline","contents"]);function Fn(e){const{overflow:t,overflowX:n,overflowY:o,display:a}=Ie(e);return/auto|scroll|overlay|hidden|clip/.test(t+o+n)&&!Hh.has(a)}const zh=new Set(["table","td","th"]);function Vh(e){return zh.has(nn(e))}const Qh=[":popover-open",":modal"];function js(e){return Qh.some(t=>{try{return e.matches(t)}catch{return!1}})}const Kh=["transform","translate","scale","rotate","perspective"],Gh=["transform","translate","scale","rotate","perspective","filter"],Yh=["paint","layout","strict","content"];function yo(e){const t=wo(),n=Ae(e)?Ie(e):e;return Kh.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)||Gh.some(o=>(n.willChange||"").includes(o))||Yh.some(o=>(n.contain||"").includes(o))}function Jh(e){let t=at(e);for(;qe(t)&&!Yt(t);){if(yo(t))return t;if(js(t))return null;t=at(t)}return null}function wo(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Xh=new Set(["html","body","#document"]);function Yt(e){return Xh.has(nn(e))}function Ie(e){return xe(e).getComputedStyle(e)}function Ns(e){return Ae(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function at(e){if(nn(e)==="html")return e;const t=e.assignedSlot||e.parentNode||er(e)&&e.host||ze(e);return er(t)?t.host:t}function Na(e){const t=at(e);return Yt(t)?e.ownerDocument?e.ownerDocument.body:e.body:qe(t)&&Fn(t)?t:Na(t)}function _n(e,t,n){var o;t===void 0&&(t=[]),n===void 0&&(n=!0);const a=Na(e),r=a===((o=e.ownerDocument)==null?void 0:o.body),i=xe(a);if(r){const c=Gs(i);return t.concat(i,i.visualViewport||[],Fn(a)?a:[],c&&n?_n(c):[])}return t.concat(a,_n(a,[],n))}function Gs(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function _a(e){const t=Ie(e);let n=parseFloat(t.width)||0,o=parseFloat(t.height)||0;const a=qe(e),r=a?e.offsetWidth:n,i=a?e.offsetHeight:o,c=is(n)!==r||is(o)!==i;return c&&(n=r,o=i),{width:n,height:o,$:c}}function Co(e){return Ae(e)?e:e.contextElement}function Vt(e){const t=Co(e);if(!qe(t))return Be(1);const n=t.getBoundingClientRect(),{width:o,height:a,$:r}=_a(t);let i=(r?is(n.width):n.width)/o,c=(r?is(n.height):n.height)/a;return(!i||!Number.isFinite(i))&&(i=1),(!c||!Number.isFinite(c))&&(c=1),{x:i,y:c}}const Zh=Be(0);function Sa(e){const t=xe(e);return!wo()||!t.visualViewport?Zh:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function em(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==xe(e)?!1:t}function kt(e,t,n,o){t===void 0&&(t=!1),n===void 0&&(n=!1);const a=e.getBoundingClientRect(),r=Co(e);let i=Be(1);t&&(o?Ae(o)&&(i=Vt(o)):i=Vt(e));const c=em(r,n,o)?Sa(r):Be(0);let u=(a.left+c.x)/i.x,h=(a.top+c.y)/i.y,m=a.width/i.x,d=a.height/i.y;if(r){const x=xe(r),p=o&&Ae(o)?xe(o):o;let b=x,g=Gs(b);for(;g&&o&&p!==b;){const v=Vt(g),y=g.getBoundingClientRect(),f=Ie(g),w=y.left+(g.clientLeft+parseFloat(f.paddingLeft))*v.x,C=y.top+(g.clientTop+parseFloat(f.paddingTop))*v.y;u*=v.x,h*=v.y,m*=v.x,d*=v.y,u+=w,h+=C,b=xe(g),g=Gs(b)}}return cs({width:m,height:d,x:u,y:h})}function _s(e,t){const n=Ns(e).scrollLeft;return t?t.left+n:kt(ze(e)).left+n}function ka(e,t){const n=e.getBoundingClientRect(),o=n.left+t.scrollLeft-_s(e,n),a=n.top+t.scrollTop;return{x:o,y:a}}function tm(e){let{elements:t,rect:n,offsetParent:o,strategy:a}=e;const r=a==="fixed",i=ze(o),c=t?js(t.floating):!1;if(o===i||c&&r)return n;let u={scrollLeft:0,scrollTop:0},h=Be(1);const m=Be(0),d=qe(o);if((d||!d&&!r)&&((nn(o)!=="body"||Fn(i))&&(u=Ns(o)),qe(o))){const p=kt(o);h=Vt(o),m.x=p.x+o.clientLeft,m.y=p.y+o.clientTop}const x=i&&!d&&!r?ka(i,u):Be(0);return{width:n.width*h.x,height:n.height*h.y,x:n.x*h.x-u.scrollLeft*h.x+m.x+x.x,y:n.y*h.y-u.scrollTop*h.y+m.y+x.y}}function nm(e){return Array.from(e.getClientRects())}function sm(e){const t=ze(e),n=Ns(e),o=e.ownerDocument.body,a=jt(t.scrollWidth,t.clientWidth,o.scrollWidth,o.clientWidth),r=jt(t.scrollHeight,t.clientHeight,o.scrollHeight,o.clientHeight);let i=-n.scrollLeft+_s(e);const c=-n.scrollTop;return Ie(o).direction==="rtl"&&(i+=jt(t.clientWidth,o.clientWidth)-a),{width:a,height:r,x:i,y:c}}const tr=25;function om(e,t){const n=xe(e),o=ze(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=wo();(!m||m&&t==="fixed")&&(c=a.offsetLeft,u=a.offsetTop)}const h=_s(o);if(h<=0){const m=o.ownerDocument,d=m.body,x=getComputedStyle(d),p=m.compatMode==="CSS1Compat"&&parseFloat(x.marginLeft)+parseFloat(x.marginRight)||0,b=Math.abs(o.clientWidth-d.clientWidth-p);b<=tr&&(r-=b)}else h<=tr&&(r+=h);return{width:r,height:i,x:c,y:u}}const rm=new Set(["absolute","fixed"]);function am(e,t){const n=kt(e,!0,t==="fixed"),o=n.top+e.clientTop,a=n.left+e.clientLeft,r=qe(e)?Vt(e):Be(1),i=e.clientWidth*r.x,c=e.clientHeight*r.y,u=a*r.x,h=o*r.y;return{width:i,height:c,x:u,y:h}}function nr(e,t,n){let o;if(t==="viewport")o=om(e,n);else if(t==="document")o=sm(ze(e));else if(Ae(t))o=am(t,n);else{const a=Sa(e);o={x:t.x-a.x,y:t.y-a.y,width:t.width,height:t.height}}return cs(o)}function Ea(e,t){const n=at(e);return n===t||!Ae(n)||Yt(n)?!1:Ie(n).position==="fixed"||Ea(n,t)}function im(e,t){const n=t.get(e);if(n)return n;let o=_n(e,[],!1).filter(c=>Ae(c)&&nn(c)!=="body"),a=null;const r=Ie(e).position==="fixed";let i=r?at(e):e;for(;Ae(i)&&!Yt(i);){const c=Ie(i),u=yo(i);!u&&c.position==="fixed"&&(a=null),(r?!u&&!a:!u&&c.position==="static"&&!!a&&rm.has(a.position)||Fn(i)&&!u&&Ea(e,i))?o=o.filter(m=>m!==i):a=c,i=at(i)}return t.set(e,o),o}function lm(e){let{element:t,boundary:n,rootBoundary:o,strategy:a}=e;const i=[...n==="clippingAncestors"?js(t)?[]:im(t,this._c):[].concat(n),o],c=i[0],u=i.reduce((h,m)=>{const d=nr(t,m,a);return h.top=jt(d.top,h.top),h.right=Gt(d.right,h.right),h.bottom=Gt(d.bottom,h.bottom),h.left=jt(d.left,h.left),h},nr(t,c,a));return{width:u.right-u.left,height:u.bottom-u.top,x:u.left,y:u.top}}function cm(e){const{width:t,height:n}=_a(e);return{width:t,height:n}}function um(e,t,n){const o=qe(t),a=ze(t),r=n==="fixed",i=kt(e,!0,r,t);let c={scrollLeft:0,scrollTop:0};const u=Be(0);function h(){u.x=_s(a)}if(o||!o&&!r)if((nn(t)!=="body"||Fn(a))&&(c=Ns(t)),o){const p=kt(t,!0,r,t);u.x=p.x+t.clientLeft,u.y=p.y+t.clientTop}else a&&h();r&&!o&&a&&h();const m=a&&!o&&!r?ka(a,c):Be(0),d=i.left+c.scrollLeft-u.x-m.x,x=i.top+c.scrollTop-u.y-m.y;return{x:d,y:x,width:i.width,height:i.height}}function Ms(e){return Ie(e).position==="static"}function sr(e,t){if(!qe(e)||Ie(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return ze(e)===n&&(n=n.ownerDocument.body),n}function Ra(e,t){const n=xe(e);if(js(e))return n;if(!qe(e)){let a=at(e);for(;a&&!Yt(a);){if(Ae(a)&&!Ms(a))return a;a=at(a)}return n}let o=sr(e,t);for(;o&&Vh(o)&&Ms(o);)o=sr(o,t);return o&&Yt(o)&&Ms(o)&&!yo(o)?n:o||Jh(e)||n}const dm=async function(e){const t=this.getOffsetParent||Ra,n=this.getDimensions,o=await n(e.floating);return{reference:um(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}};function hm(e){return Ie(e).direction==="rtl"}const mm={convertOffsetParentRelativeRectToViewportRelativeRect:tm,getDocumentElement:ze,getClippingRect:lm,getOffsetParent:Ra,getElementRects:dm,getClientRects:nm,getDimensions:cm,getScale:Vt,isElement:Ae,isRTL:hm};function La(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function fm(e,t){let n=null,o;const a=ze(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 h=e.getBoundingClientRect(),{left:m,top:d,width:x,height:p}=h;if(c||t(),!x||!p)return;const b=Yn(d),g=Yn(a.clientWidth-(m+x)),v=Yn(a.clientHeight-(d+p)),y=Yn(m),w={rootMargin:-b+"px "+-g+"px "+-v+"px "+-y+"px",threshold:jt(0,Gt(1,u))||1};let C=!0;function _(A){const S=A[0].intersectionRatio;if(S!==u){if(!C)return i();S?i(!1,S):o=setTimeout(()=>{i(!1,1e-7)},1e3)}S===1&&!La(h,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 pm(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,h=Co(e),m=a||r?[...h?_n(h):[],..._n(t)]:[];m.forEach(y=>{a&&y.addEventListener("scroll",n,{passive:!0}),r&&y.addEventListener("resize",n)});const d=h&&c?fm(h,n):null;let x=-1,p=null;i&&(p=new ResizeObserver(y=>{let[f]=y;f&&f.target===h&&p&&(p.unobserve(t),cancelAnimationFrame(x),x=requestAnimationFrame(()=>{var w;(w=p)==null||w.observe(t)})),n()}),h&&!u&&p.observe(h),p.observe(t));let b,g=u?kt(e):null;u&&v();function v(){const y=kt(e);g&&!La(g,y)&&n(),g=y,b=requestAnimationFrame(v)}return n(),()=>{var y;m.forEach(f=>{a&&f.removeEventListener("scroll",n),r&&f.removeEventListener("resize",n)}),d?.(),(y=p)==null||y.disconnect(),p=null,u&&cancelAnimationFrame(b)}}const xm=qh,gm=Uh,bm=Fh,vm=$h,or=(e,t,n)=>{const o=new Map,a={platform:mm,...n},r={...a.platform,_c:o};return Dh(e,t,{...a,platform:r})};var Os={exports:{}};var rr;function ym(){return rr||(rr=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})()})(Os)),Os.exports}var wm=ym();const Ys=li(wm);var ar={};const Cm="react-tooltip-core-styles",jm="react-tooltip-base-styles",ir={core:!1,base:!1};function lr({css:e,id:t=jm,type:n="base",ref:o}){var a,r;if(!e||typeof document>"u"||ir[n]||n==="core"&&typeof process<"u"&&(!((a=process==null?void 0:ar)===null||a===void 0)&&a.REACT_TOOLTIP_DISABLE_CORE_STYLES)||n!=="base"&&typeof process<"u"&&(!((r=process==null?void 0:ar)===null||r===void 0)&&r.REACT_TOOLTIP_DISABLE_BASE_STYLES))return;n==="core"&&(t=Cm),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)),ir[n]=!0}const cr=async({elementReference:e=null,tooltipReference:t=null,tooltipArrowReference:n=null,place:o="top",offset:a=10,strategy:r="absolute",middlewares:i=[xm(Number(a)),bm({fallbackAxisSideDirection:"start"}),gm({padding:5})],border:c,arrowSize:u=8})=>{if(!e)return{tooltipStyles:{},tooltipArrowStyles:{},place:o};if(t===null)return{tooltipStyles:{},tooltipArrowStyles:{},place:o};const h=i;return n?(h.push(vm({element:n,padding:5})),or(e,t,{placement:o,strategy:r,middleware:h}).then((({x:m,y:d,placement:x,middlewareData:p})=>{var b,g;const v={left:`${m}px`,top:`${d}px`,border:c},{x:y,y:f}=(b=p.arrow)!==null&&b!==void 0?b:{x:0,y:0},w=(g={top:"bottom",right:"left",bottom:"top",left:"right"}[x.split("-")[0]])!==null&&g!==void 0?g:"bottom",C=c&&{borderBottom:c,borderRight:c};let _=0;if(c){const A=`${c}`.match(/(\d+)px/);_=A?.[1]?Number(A[1]):1}return{tooltipStyles:v,tooltipArrowStyles:{left:y!=null?`${y}px`:"",top:f!=null?`${f}px`:"",right:"",bottom:"",...C,[w]:`-${u/2+_}px`},place:x}}))):or(e,t,{placement:"bottom",strategy:r,middleware:h}).then((({x:m,y:d,placement:x})=>({tooltipStyles:{left:`${m}px`,top:`${d}px`},tooltipArrowStyles:{},place:x})))},ur=(e,t)=>!("CSS"in window&&"supports"in window.CSS)||window.CSS.supports(e,t),dr=(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},hr=e=>e!==null&&!Array.isArray(e)&&typeof e=="object",Js=(e,t)=>{if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every(((a,r)=>Js(a,t[r])));if(Array.isArray(e)!==Array.isArray(t))return!1;if(!hr(e)||!hr(t))return e===t;const n=Object.keys(e),o=Object.keys(t);return n.length===o.length&&n.every((a=>Js(e[a],t[a])))},Nm=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"}))},mr=e=>{if(!e)return null;let t=e.parentElement;for(;t;){if(Nm(t))return t;t=t.parentElement}return document.scrollingElement||document.documentElement},_m=typeof window<"u"?l.useLayoutEffect:l.useEffect,_e=e=>{e.current&&(clearTimeout(e.current),e.current=null)},Sm="DEFAULT_TOOLTIP_ID",km={anchorRefs:new Set,activeAnchor:{current:null},attach:()=>{},detach:()=>{},setActiveAnchor:()=>{}},Em=l.createContext({getTooltipData:()=>km});function Ta(e=Sm){return l.useContext(Em).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"},Ds={tooltip:"styles-module_tooltip__mnnfp",arrow:"styles-module_arrow__K0L3T",dark:"styles-module_dark__xNqje",light:"styles-module_light__Z6W-X",success:"styles-module_success__A2AKt",warning:"styles-module_warning__SCK0X",error:"styles-module_error__JvumD",info:"styles-module_info__BWdHW"};const Rm=({forwardRef:e,id:t,className:n,classNameArrow:o,variant:a="dark",anchorId:r,anchorSelect:i,place:c="top",offset:u=10,events:h=["hover"],openOnClick:m=!1,positionStrategy:d="absolute",middlewares:x,wrapper:p,delayShow:b=0,delayHide:g=0,float:v=!1,hidden:y=!1,noArrow:f=!1,clickable:w=!1,closeOnEsc:C=!1,closeOnScroll:_=!1,closeOnResize:A=!1,openEvents:S,closeEvents:P,globalCloseEvents:j,imperativeModeOnly:k,style:X,position:je,afterShow:Me,afterHide:W,disableTooltip:le,content:oe,contentWrapperRef:Z,isOpen:H,defaultIsOpen:re=!1,setIsOpen:Ve,previousActiveAnchor:sn,activeAnchor:q,setActiveAnchor:Rt,border:Bn,opacity:Wn,arrowColor:qn,arrowSize:Lt=8,role:Ss="tooltip"})=>{var ct;const ce=l.useRef(null),Tt=l.useRef(null),Le=l.useRef(null),ut=l.useRef(null),At=l.useRef(null),[dt,Un]=l.useState({tooltipStyles:{},tooltipArrowStyles:{},place:c}),[ue,on]=l.useState(!1),[It,Ze]=l.useState(!1),[V,Pt]=l.useState(null),Hn=l.useRef(!1),Mt=l.useRef(null),{anchorRefs:zn,setActiveAnchor:rn}=Ta(t),an=l.useRef(!1),[et,ln]=l.useState([]),ht=l.useRef(!1),Ot=m||h.includes("click"),Vn=Ot||S?.click||S?.dblclick||S?.mousedown,cn=S?{...S}:{mouseover:!0,focus:!0,mouseenter:!1,click:!1,dblclick:!1,mousedown:!1};!S&&Ot&&Object.assign(cn,{mouseenter:!1,focus:!1,mouseover:!1,click:!0});const mt=P?{...P}:{mouseout:!0,blur:!0,mouseleave:!1,click:!1,dblclick:!1,mouseup:!1};!P&&Ot&&Object.assign(mt,{mouseleave:!1,blur:!1,mouseout:!1});const ne=j?{...j}:{escape:C||!1,scroll:_||!1,resize:A||!1,clickOutsideAnchor:Vn||!1};k&&(Object.assign(cn,{mouseover:!1,focus:!1,mouseenter:!1,click:!1,dblclick:!1,mousedown:!1}),Object.assign(mt,{mouseout:!1,blur:!1,mouseleave:!1,click:!1,dblclick:!1,mouseup:!1}),Object.assign(ne,{escape:!1,scroll:!1,resize:!1,clickOutsideAnchor:!1})),_m((()=>(ht.current=!0,()=>{ht.current=!1})),[]);const de=N=>{ht.current&&(N&&Ze(!0),setTimeout((()=>{ht.current&&(Ve?.(N),H===void 0&&on(N))}),10))};l.useEffect((()=>{if(t){if(ue){L(sn);const E=N(q),B=[...new Set([...E,t])].filter(Boolean).join(" ");q?.setAttribute("aria-describedby",B)}else L(q);return()=>{L(q),L(sn)}}function N(E){var B;return((B=E?.getAttribute("aria-describedby"))===null||B===void 0?void 0:B.split(" "))||[]}function L(E){const B=N(E).filter((te=>te!==t));B.length?E?.setAttribute("aria-describedby",B.join(" ")):E?.removeAttribute("aria-describedby")}}),[q,ue,t,sn]),l.useEffect((()=>{if(H===void 0)return()=>null;H&&Ze(!0);const N=setTimeout((()=>{on(H)}),10);return()=>{clearTimeout(N)}}),[H]),l.useEffect((()=>{if(ue!==Hn.current)if(_e(At),Hn.current=ue,ue)Me?.();else{const N=(L=>{const E=L.match(/^([\d.]+)(ms|s)$/);if(!E)return 0;const[,B,te]=E;return Number(B)*(te==="ms"?1:1e3)})(getComputedStyle(document.body).getPropertyValue("--rt-transition-show-delay"));At.current=setTimeout((()=>{Ze(!1),Pt(null),W?.()}),N+25)}}),[ue]);const un=N=>{Un((L=>Js(L,N)?L:N))},dn=(N=b)=>{_e(Le),It?de(!0):Le.current=setTimeout((()=>{de(!0)}),N)},Dt=(N=g)=>{_e(ut),ut.current=setTimeout((()=>{an.current||de(!1)}),N)},hn=N=>{var L;if(!N)return;const E=(L=N.currentTarget)!==null&&L!==void 0?L:N.target;if(!E?.isConnected)return Rt(null),void rn({current:null});b?dn():de(!0),Rt(E),rn({current:E}),_e(ut)},$t=()=>{w?Dt(g||100):g?Dt():de(!1),_e(Le)},Ft=({x:N,y:L})=>{var E;const B={getBoundingClientRect:()=>({x:N,y:L,width:0,height:0,top:L,left:N,right:N,bottom:L})};cr({place:(E=V?.place)!==null&&E!==void 0?E:c,offset:u,elementReference:B,tooltipReference:ce.current,tooltipArrowReference:Tt.current,strategy:d,middlewares:x,border:Bn,arrowSize:Lt}).then((te=>{un(te)}))},Bt=N=>{if(!N)return;const L=N,E={x:L.clientX,y:L.clientY};Ft(E),Mt.current=E},mn=N=>{var L;if(!ue)return;const E=N.target;E.isConnected&&(!((L=ce.current)===null||L===void 0)&&L.contains(E)||[document.querySelector(`[id='${r}']`),...et].some((B=>B?.contains(E)))||(de(!1),_e(Le)))},Qn=dr(hn,50),G=dr($t,50),ae=N=>{G.cancel(),Qn(N)},T=()=>{Qn.cancel(),G()},M=l.useCallback((()=>{var N,L;const E=(N=V?.position)!==null&&N!==void 0?N:je;E?Ft(E):v?Mt.current&&Ft(Mt.current):q?.isConnected&&cr({place:(L=V?.place)!==null&&L!==void 0?L:c,offset:u,elementReference:q,tooltipReference:ce.current,tooltipArrowReference:Tt.current,strategy:d,middlewares:x,border:Bn,arrowSize:Lt}).then((B=>{ht.current&&un(B)}))}),[ue,q,oe,X,c,V?.place,u,d,je,V?.position,v,Lt]);l.useEffect((()=>{var N,L;const E=new Set(zn);et.forEach((F=>{le?.(F)||E.add({current:F})}));const B=document.querySelector(`[id='${r}']`);B&&!le?.(B)&&E.add({current:B});const te=()=>{de(!1)},Oe=mr(q),De=mr(ce.current);ne.scroll&&(window.addEventListener("scroll",te),Oe?.addEventListener("scroll",te),De?.addEventListener("scroll",te));let ie=null;ne.resize?window.addEventListener("resize",te):q&&ce.current&&(ie=pm(q,ce.current,M,{ancestorResize:!0,elementResize:!0,layoutShift:!0}));const Ne=F=>{F.key==="Escape"&&de(!1)};ne.escape&&window.addEventListener("keydown",Ne),ne.clickOutsideAnchor&&window.addEventListener("click",mn);const U=[],Wt=F=>!!(F?.target&&q?.contains(F.target)),Ga=F=>{ue&&Wt(F)||hn(F)},Ya=F=>{ue&&Wt(F)&&$t()},ko=["mouseover","mouseout","mouseenter","mouseleave","focus","blur"],Eo=["click","dblclick","mousedown","mouseup"];Object.entries(cn).forEach((([F,Qe])=>{Qe&&(ko.includes(F)?U.push({event:F,listener:ae}):Eo.includes(F)&&U.push({event:F,listener:Ga}))})),Object.entries(mt).forEach((([F,Qe])=>{Qe&&(ko.includes(F)?U.push({event:F,listener:T}):Eo.includes(F)&&U.push({event:F,listener:Ya}))})),v&&U.push({event:"pointermove",listener:Bt});const Ro=()=>{an.current=!0},Lo=()=>{an.current=!1,$t()},To=w&&(mt.mouseout||mt.mouseleave);return To&&((N=ce.current)===null||N===void 0||N.addEventListener("mouseover",Ro),(L=ce.current)===null||L===void 0||L.addEventListener("mouseout",Lo)),U.forEach((({event:F,listener:Qe})=>{E.forEach((ks=>{var fn;(fn=ks.current)===null||fn===void 0||fn.addEventListener(F,Qe)}))})),()=>{var F,Qe;ne.scroll&&(window.removeEventListener("scroll",te),Oe?.removeEventListener("scroll",te),De?.removeEventListener("scroll",te)),ne.resize?window.removeEventListener("resize",te):ie?.(),ne.clickOutsideAnchor&&window.removeEventListener("click",mn),ne.escape&&window.removeEventListener("keydown",Ne),To&&((F=ce.current)===null||F===void 0||F.removeEventListener("mouseover",Ro),(Qe=ce.current)===null||Qe===void 0||Qe.removeEventListener("mouseout",Lo)),U.forEach((({event:ks,listener:fn})=>{E.forEach((Ja=>{var Es;(Es=Ja.current)===null||Es===void 0||Es.removeEventListener(ks,fn)}))}))}}),[q,M,It,zn,et,S,P,j,Ot,b,g]),l.useEffect((()=>{var N,L;let E=(L=(N=V?.anchorSelect)!==null&&N!==void 0?N:i)!==null&&L!==void 0?L:"";!E&&t&&(E=`[data-tooltip-id='${t.replace(/'/g,"\\'")}']`);const B=new MutationObserver((te=>{const Oe=[],De=[];te.forEach((ie=>{if(ie.type==="attributes"&&ie.attributeName==="data-tooltip-id"&&(ie.target.getAttribute("data-tooltip-id")===t?Oe.push(ie.target):ie.oldValue===t&&De.push(ie.target)),ie.type==="childList"){if(q){const Ne=[...ie.removedNodes].filter((U=>U.nodeType===1));if(E)try{De.push(...Ne.filter((U=>U.matches(E)))),De.push(...Ne.flatMap((U=>[...U.querySelectorAll(E)])))}catch{}Ne.some((U=>{var Wt;return!!(!((Wt=U?.contains)===null||Wt===void 0)&&Wt.call(U,q))&&(Ze(!1),de(!1),Rt(null),_e(Le),_e(ut),!0)}))}if(E)try{const Ne=[...ie.addedNodes].filter((U=>U.nodeType===1));Oe.push(...Ne.filter((U=>U.matches(E)))),Oe.push(...Ne.flatMap((U=>[...U.querySelectorAll(E)])))}catch{}}})),(Oe.length||De.length)&&ln((ie=>[...ie.filter((Ne=>!De.includes(Ne))),...Oe]))}));return B.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-tooltip-id"],attributeOldValue:!0}),()=>{B.disconnect()}}),[t,i,V?.anchorSelect,q]),l.useEffect((()=>{M()}),[M]),l.useEffect((()=>{if(!Z?.current)return()=>null;const N=new ResizeObserver((()=>{setTimeout((()=>M()))}));return N.observe(Z.current),()=>{N.disconnect()}}),[oe,Z?.current]),l.useEffect((()=>{var N;const L=document.querySelector(`[id='${r}']`),E=[...et,L];q&&E.includes(q)||Rt((N=et[0])!==null&&N!==void 0?N:L)}),[r,et,q]),l.useEffect((()=>(re&&de(!0),()=>{_e(Le),_e(ut)})),[]),l.useEffect((()=>{var N;let L=(N=V?.anchorSelect)!==null&&N!==void 0?N:i;if(!L&&t&&(L=`[data-tooltip-id='${t.replace(/'/g,"\\'")}']`),L)try{const E=Array.from(document.querySelectorAll(L));ln(E)}catch{ln([])}}),[t,i,V?.anchorSelect]),l.useEffect((()=>{Le.current&&(_e(Le),dn(b))}),[b]);const pe=(ct=V?.content)!==null&&ct!==void 0?ct:oe,ft=ue&&Object.keys(dt.tooltipStyles).length>0;return l.useImperativeHandle(e,(()=>({open:N=>{if(N?.anchorSelect)try{document.querySelector(N.anchorSelect)}catch{return void console.warn(`[react-tooltip] "${N.anchorSelect}" is not a valid CSS selector`)}Pt(N??null),N?.delay?dn(N.delay):de(!0)},close:N=>{N?.delay?Dt(N.delay):de(!1)},activeAnchor:q,place:dt.place,isOpen:!!(It&&!y&&pe&&ft)}))),It&&!y&&pe?nt.createElement(p,{id:t,role:Ss,className:Ys("react-tooltip",Ut.tooltip,Ds.tooltip,Ds[a],n,`react-tooltip__place-${dt.place}`,Ut[ft?"show":"closing"],ft?"react-tooltip__show":"react-tooltip__closing",d==="fixed"&&Ut.fixed,w&&Ut.clickable),onTransitionEnd:N=>{_e(At),ue||N.propertyName!=="opacity"||(Ze(!1),Pt(null),W?.())},style:{...X,...dt.tooltipStyles,opacity:Wn!==void 0&&ft?Wn:void 0},ref:ce},pe,nt.createElement(p,{className:Ys("react-tooltip-arrow",Ut.arrow,Ds.arrow,o,f&&Ut.noArrow),style:{...dt.tooltipArrowStyles,background:qn?`linear-gradient(to right bottom, transparent 50%, ${qn} 50%)`:void 0,"--rt-arrow-size":`${Lt}px`},ref:Tt})):null},Lm=({content:e})=>nt.createElement("span",{dangerouslySetInnerHTML:{__html:e}}),us=nt.forwardRef((({id:e,anchorId:t,anchorSelect:n,content:o,html:a,render:r,className:i,classNameArrow:c,variant:u="dark",place:h="top",offset:m=10,wrapper:d="div",children:x=null,events:p=["hover"],openOnClick:b=!1,positionStrategy:g="absolute",middlewares:v,delayShow:y=0,delayHide:f=0,float:w=!1,hidden:C=!1,noArrow:_=!1,clickable:A=!1,closeOnEsc:S=!1,closeOnScroll:P=!1,closeOnResize:j=!1,openEvents:k,closeEvents:X,globalCloseEvents:je,imperativeModeOnly:Me=!1,style:W,position:le,isOpen:oe,defaultIsOpen:Z=!1,disableStyleInjection:H=!1,border:re,opacity:Ve,arrowColor:sn,arrowSize:q,setIsOpen:Rt,afterShow:Bn,afterHide:Wn,disableTooltip:qn,role:Lt="tooltip"},Ss)=>{const[ct,ce]=l.useState(o),[Tt,Le]=l.useState(a),[ut,At]=l.useState(h),[dt,Un]=l.useState(u),[ue,on]=l.useState(m),[It,Ze]=l.useState(y),[V,Pt]=l.useState(f),[Hn,Mt]=l.useState(w),[zn,rn]=l.useState(C),[an,et]=l.useState(d),[ln,ht]=l.useState(p),[Ot,Vn]=l.useState(g),[cn,mt]=l.useState(null),[ne,de]=l.useState(null),un=l.useRef(null),dn=l.useRef(H),{anchorRefs:Dt,activeAnchor:hn}=Ta(e),$t=G=>G?.getAttributeNames().reduce(((ae,T)=>{var M;return T.startsWith("data-tooltip-")&&(ae[T.replace(/^data-tooltip-/,"")]=(M=G?.getAttribute(T))!==null&&M!==void 0?M:null),ae}),{}),Ft=G=>{const ae={place:T=>{var M;At((M=T)!==null&&M!==void 0?M:h)},content:T=>{ce(T??o)},html:T=>{Le(T??a)},variant:T=>{var M;Un((M=T)!==null&&M!==void 0?M:u)},offset:T=>{on(T===null?m:Number(T))},wrapper:T=>{var M;et((M=T)!==null&&M!==void 0?M:d)},events:T=>{const M=T?.split(" ");ht(M??p)},"position-strategy":T=>{var M;Vn((M=T)!==null&&M!==void 0?M:g)},"delay-show":T=>{Ze(T===null?y:Number(T))},"delay-hide":T=>{Pt(T===null?f:Number(T))},float:T=>{Mt(T===null?w:T==="true")},hidden:T=>{rn(T===null?C:T==="true")},"class-name":T=>{mt(T)}};Object.values(ae).forEach((T=>T(null))),Object.entries(G).forEach((([T,M])=>{var pe;(pe=ae[T])===null||pe===void 0||pe.call(ae,M)}))};l.useEffect((()=>{ce(o)}),[o]),l.useEffect((()=>{Le(a)}),[a]),l.useEffect((()=>{At(h)}),[h]),l.useEffect((()=>{Un(u)}),[u]),l.useEffect((()=>{on(m)}),[m]),l.useEffect((()=>{Ze(y)}),[y]),l.useEffect((()=>{Pt(f)}),[f]),l.useEffect((()=>{Mt(w)}),[w]),l.useEffect((()=>{rn(C)}),[C]),l.useEffect((()=>{Vn(g)}),[g]),l.useEffect((()=>{dn.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 ae=new Set(Dt);let T=n;if(!T&&e&&(T=`[data-tooltip-id='${e.replace(/'/g,"\\'")}']`),T)try{document.querySelectorAll(T).forEach((L=>{ae.add({current:L})}))}catch{console.warn(`[react-tooltip] "${T}" is not a valid CSS selector`)}const M=document.querySelector(`[id='${t}']`);if(M&&ae.add({current:M}),!ae.size)return()=>null;const pe=(G=ne??M)!==null&&G!==void 0?G:hn.current,ft=new MutationObserver((L=>{L.forEach((E=>{var B;if(!pe||E.type!=="attributes"||!(!((B=E.attributeName)===null||B===void 0)&&B.startsWith("data-tooltip-")))return;const te=$t(pe);Ft(te)}))})),N={attributes:!0,childList:!1,subtree:!1};if(pe){const L=$t(pe);Ft(L),ft.observe(pe,N)}return()=>{ft.disconnect()}}),[Dt,hn,ne,t,n]),l.useEffect((()=>{W?.border&&console.warn("[react-tooltip] Do not set `style.border`. Use `border` prop instead."),re&&!ur("border",`${re}`)&&console.warn(`[react-tooltip] "${re}" is not a valid \`border\`.`),W?.opacity&&console.warn("[react-tooltip] Do not set `style.opacity`. Use `opacity` prop instead."),Ve&&!ur("opacity",`${Ve}`)&&console.warn(`[react-tooltip] "${Ve}" is not a valid \`opacity\`.`)}),[]);let Bt=x;const mn=l.useRef(null);if(r){const G=r({content:ne?.getAttribute("data-tooltip-content")||ct||null,activeAnchor:ne});Bt=G?nt.createElement("div",{ref:mn,className:"react-tooltip-content-wrapper"},G):null}else ct&&(Bt=ct);Tt&&(Bt=nt.createElement(Lm,{content:Tt}));const Qn={forwardRef:Ss,id:e,anchorId:t,anchorSelect:n,className:Ys(i,cn),classNameArrow:c,content:Bt,contentWrapperRef:mn,place:ut,variant:dt,offset:ue,wrapper:an,events:ln,openOnClick:b,positionStrategy:Ot,middlewares:v,delayShow:It,delayHide:V,float:Hn,hidden:zn,noArrow:_,clickable:A,closeOnEsc:S,closeOnScroll:P,closeOnResize:j,openEvents:k,closeEvents:X,globalCloseEvents:je,imperativeModeOnly:Me,style:W,position:le,isOpen:oe,defaultIsOpen:Z,border:re,opacity:Ve,arrowColor:sn,arrowSize:q,setIsOpen:Rt,afterShow:Bn,afterHide:Wn,disableTooltip:qn,activeAnchor:ne,previousActiveAnchor:un.current,setActiveAnchor:G=>{de((ae=>(G?.isSameNode(ae)||(un.current=ae),G)))},role:Lt};return nt.createElement(Rm,{...Qn})}));typeof window<"u"&&window.addEventListener("react-tooltip-inject-styles",(e=>{e.detail.disableCore||lr({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||lr({css:`
4
- .styles-module_tooltip__mnnfp{padding:8px 16px;border-radius:3px;font-size:90%;width:max-content}.styles-module_arrow__K0L3T{width:var(--rt-arrow-size);height:var(--rt-arrow-size)}[class*='react-tooltip__place-top']>.styles-module_arrow__K0L3T{transform:rotate(45deg)}[class*='react-tooltip__place-right']>.styles-module_arrow__K0L3T{transform:rotate(135deg)}[class*='react-tooltip__place-bottom']>.styles-module_arrow__K0L3T{transform:rotate(225deg)}[class*='react-tooltip__place-left']>.styles-module_arrow__K0L3T{transform:rotate(315deg)}.styles-module_dark__xNqje{background:var(--rt-color-dark);color:var(--rt-color-white)}.styles-module_light__Z6W-X{background-color:var(--rt-color-white);color:var(--rt-color-dark)}.styles-module_success__A2AKt{background-color:var(--rt-color-success);color:var(--rt-color-white)}.styles-module_warning__SCK0X{background-color:var(--rt-color-warning);color:var(--rt-color-white)}.styles-module_error__JvumD{background-color:var(--rt-color-error);color:var(--rt-color-white)}.styles-module_info__BWdHW{background-color:var(--rt-color-info);color:var(--rt-color-white)}`,type:"base"})}));const Sn=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"})),Tm=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})),Aa=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"})),Am=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})),Im=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"})),Pm=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"})),Ia=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"})),Mm=()=>{const e=ho(),t=Tc();return{rename:async o=>{if(e){const a=await On("New tab name",o);a&&await t.mutateAsync({id:e,payload:{name:a}})}return Promise.resolve()}}},Pa=["shift","alt","meta","mod","ctrl","control"],Om={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 rt(e){return(Om[e.trim()]||e.trim()).toLowerCase().replace(/key|digit|numpad/,"")}function Ma(e){return Pa.includes(e)}function $s(e,t=","){return e.toLowerCase().split(t)}function Fs(e,t="+",n=">",o=!1,a){let r=[],i=!1;e=e.trim(),e.includes(n)?(i=!0,r=e.toLocaleLowerCase().split(n).map(h=>rt(h))):r=e.toLocaleLowerCase().split(t).map(h=>rt(h));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(h=>!Pa.includes(h));return{...c,keys:u,description:a,isSequence:i,hotkey:e}}typeof document<"u"&&(document.addEventListener("keydown",e=>{e.code!==void 0&&Oa([rt(e.code)])}),document.addEventListener("keyup",e=>{e.code!==void 0&&Da([rt(e.code)])})),typeof window<"u"&&(window.addEventListener("blur",()=>{Ke.clear()}),window.addEventListener("contextmenu",()=>{setTimeout(()=>{Ke.clear()},0)}));const Ke=new Set;function jo(e){return Array.isArray(e)}function Dm(e,t=","){return(jo(e)?e:e.split(t)).every(n=>Ke.has(n.trim().toLowerCase()))}function Oa(e){const t=Array.isArray(e)?e:[e];Ke.has("meta")&&Ke.forEach(n=>!Ma(n)&&Ke.delete(n.toLowerCase())),t.forEach(n=>Ke.add(n.toLowerCase()))}function Da(e){const t=Array.isArray(e)?e:[e];e==="meta"?Ke.clear():t.forEach(n=>Ke.delete(n.toLowerCase()))}function $m(e,t,n){(typeof n=="function"&&n(e,t)||n===!0)&&e.preventDefault()}function Fm(e,t,n){return typeof n=="function"?n(e,t):n===!0||n===void 0}const Bm=["input","textarea","select","searchbox","slider","spinbutton","menuitem","menuitemcheckbox","menuitemradio","option","radio","textbox"];function Wm(e){return $a(e,Bm)}function $a(e,t=!1){const{target:n,composed:o}=e;let a,r;return qm(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),jo(t)?!!(a&&t&&t.some(i=>i.toLowerCase()===a.toLowerCase()||i===r)):!!(a&&t&&t)}function qm(e){return!!e.tagName&&!e.tagName.startsWith("-")&&e.tagName.includes("-")}function Um(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 Hm=(e,t,n=!1)=>{const{alt:o,meta:a,mod:r,shift:i,ctrl:c,keys:u,useKey:h}=t,{code:m,key:d,ctrlKey:x,metaKey:p,shiftKey:b,altKey:g}=e,v=rt(m);if(h&&u?.length===1&&u.includes(d))return!0;if(!u?.includes(v)&&!["ctrl","control","unknown","meta","alt","shift","os"].includes(v))return!1;if(!n){if(o!==g&&v!=="alt"||i!==b&&v!=="shift")return!1;if(r){if(!p&&!x)return!1}else if(a!==p&&v!=="meta"&&v!=="os"||c!==x&&v!=="ctrl"&&v!=="control")return!1}return u&&u.length===1&&u.includes(v)?!0:u?Dm(u):!u},zm=l.createContext(void 0),Vm=()=>l.useContext(zm);function Fa(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&&Fa(e[o],t[o]),!0):e===t}const Qm=l.createContext({hotkeys:[],activeScopes:[],toggleScope:()=>{},enableScope:()=>{},disableScope:()=>{}}),Km=()=>l.useContext(Qm);function Gm(e){const t=l.useRef(void 0);return Fa(t.current,e)||(t.current=e),t.current}const fr=e=>{e.stopPropagation(),e.preventDefault(),e.stopImmediatePropagation()},Ym=typeof window<"u"?l.useLayoutEffect:l.useEffect;function We(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=jo(e)?e.join(i?.delimiter):e,u=Array.isArray(n)?n:Array.isArray(o)?o:void 0,h=l.useCallback(t,u??[]),m=l.useRef(h);u?m.current=h:m.current=t;const d=Gm(i),{activeScopes:x}=Km(),p=Vm();return Ym(()=>{if(d?.enabled===!1||!Um(x,d?.scopes))return;let b=[],g;const v=(C,_=!1)=>{if(!(Wm(C)&&!$a(C,d?.enableOnFormTags))){if(a.current!==null){const A=a.current.getRootNode();if((A instanceof Document||A instanceof ShadowRoot)&&A.activeElement!==a.current&&!a.current.contains(A.activeElement)){fr(C);return}}C.target?.isContentEditable&&!d?.enableOnContentEditable||$s(c,d?.delimiter).forEach(A=>{if(A.includes(d?.splitKey??"+")&&A.includes(d?.sequenceSplitKey??">")){console.warn(`Hotkey ${A} contains both ${d?.splitKey??"+"} and ${d?.sequenceSplitKey??">"} which is not supported.`);return}const S=Fs(A,d?.splitKey,d?.sequenceSplitKey,d?.useKey,d?.description);if(S.isSequence){g=setTimeout(()=>{b=[]},d?.sequenceTimeoutMs??1e3);const P=S.useKey?C.key:rt(C.code);if(Ma(P.toLowerCase()))return;b.push(P);const j=S.keys?.[b.length-1];if(P!==j){b=[],g&&clearTimeout(g);return}b.length===S.keys?.length&&(m.current(C,S),g&&clearTimeout(g),b=[])}else if(Hm(C,S,d?.ignoreModifiers)||S.keys?.includes("*")){if(d?.ignoreEventWhen?.(C)||_&&r.current)return;if($m(C,S,d?.preventDefault),!Fm(C,S,d?.enabled)){fr(C);return}m.current(C,S),_||(r.current=!0)}})}},y=C=>{C.code!==void 0&&(Oa(rt(C.code)),(d?.keydown===void 0&&d?.keyup!==!0||d?.keydown)&&v(C))},f=C=>{C.code!==void 0&&(Da(rt(C.code)),r.current=!1,d?.keyup&&v(C,!0))},w=a.current||i?.document||document;return w.addEventListener("keyup",f,i?.eventListenerOptions),w.addEventListener("keydown",y,i?.eventListenerOptions),p&&$s(c,d?.delimiter).forEach(C=>p.addHotkey(Fs(C,d?.splitKey,d?.sequenceSplitKey,d?.useKey,d?.description))),()=>{w.removeEventListener("keyup",f,i?.eventListenerOptions),w.removeEventListener("keydown",y,i?.eventListenerOptions),p&&$s(c,d?.delimiter).forEach(C=>p.removeHotkey(Fs(C,d?.splitKey,d?.sequenceSplitKey,d?.useKey,d?.description))),b=[],g&&clearTimeout(g)}},[c,d,x]),a}function Jm(){return s.jsxs("div",{className:"flex md:grid md:grid-cols-3 items-center bg-white overflow-auto no-scrollbar",children:[s.jsx(Xm,{}),s.jsx(Zm,{}),s.jsx(nf,{})]})}function Xm(){const{dataSourceId:e}=l.useContext(Pe),{data:t}=ps(e),{state:{table:n}}=l.useContext(Ce);return s.jsx("div",{className:R.tableConfig,children:t&&s.jsxs("div",{className:I(R.tableAction,R.greenFixed),"data-tooltip-id":"default","data-tooltip-content":n,children:[s.jsx(He,{size:18,type:t.dbType}),s.jsx("p",{className:"text-sm",children:t.name}),s.jsx(Sn,{width:12,height:12}),s.jsx("p",{className:"text-sm",children:n})]})})}function Zm(){const{page:e,size:t,setPage:n}=va(),{data:o,isFetching:a}=l.useContext(Xe),r=e*t,i=!a&&!!o?.result.hasMore,c=o?.result.rows.length||0,u=()=>{e>0&&n(e-1)},h=()=>{i&&n(e+1)};return s.jsxs("div",{className:I(R.tableConfig,"justify-self-center"),children:[s.jsx("span",{"data-tooltip-content":"Previous page","data-tooltip-id":"default",className:I(R.tableAction,R.gray,e<1&&"opacity-30"),onClick:u,role:"button",children:s.jsx(Sn,{width:16,height:16,className:"rotate-180"})}),s.jsxs("span",{"data-tooltip-id":"rows-num",className:R.paginationIndicator,children:[r+1," - ",r+c,i&&"+"]}),s.jsx("span",{"data-tooltip-content":"Next page","data-tooltip-id":"default",className:I(R.tableAction,i?R.gray:"opacity-30"),onClick:h,role:"button",children:s.jsx(Sn,{width:16,height:16})})]})}const ef=[5,10,20,50,100,200],tf=!__CLIENT_CONFIG__.skipAuth;function nf(){const{dataSourceId:e,name:t}=l.useContext(Pe),{data:n}=ps(e),{data:o,refetch:a}=l.useContext(Xe),r=An(he.EDITOR),i=Nh(),{rename:c}=Mm(),{size:u,setSize:h}=va(),{state:m}=l.useContext(Ce),d=Et(),x=J(),p=()=>{d.mutateAsync({name:t,opts:m}).then(f=>{x(D.workbenchTab.build({id:f.id}))})},b=()=>{if(o?.result.queryHistoryId){const f=new URL(window.location.href);f.pathname=D.share.build(),f.searchParams.set("shareId",o.result.queryHistoryId),navigator.clipboard.writeText(f.toString()),ke.success("Share link copied to clipboard")}},g=()=>{o?.result.columns?.[0].table&&co({table:o?.result.columns?.[0].table,dataSourceId:e})},v=async()=>{const f=await On("Query name",t);!f||!o?.result.queryHistoryId||i.mutate({name:f,queryId:o.result.queryHistoryId})},y=()=>c(t);return We("s",v),We("r",y),We("d",p),s.jsxs("div",{className:"flex justify-self-end",children:[s.jsx("span",{"data-tooltip-content":"Show filters","data-tooltip-id":"default",className:I(R.tableAction,R.gray),onClick:()=>Fe("filters"),role:"button",children:s.jsx(Pm,{width:16,height:16})}),s.jsx("span",{"data-tooltip-content":"Join table","data-tooltip-id":"default",className:I(R.tableAction,R.gray),onClick:()=>Fe("joins"),role:"button",children:s.jsx(Ia,{width:16,height:16})}),s.jsx("span",{"data-tooltip-content":"Refresh data","data-tooltip-id":"default",className:I(R.tableAction,R.gray),onClick:()=>a(),role:"button",children:s.jsx(Aa,{width:16,height:16})}),tf&&s.jsx("span",{"data-tooltip-content":"Share query","data-tooltip-id":"default",className:I(R.tableAction,R.gray),onClick:b,role:"button",children:s.jsx(Im,{width:16,height:16})}),s.jsx("span",{"data-tooltip-content":"Duplicate tab","data-tooltip-id":"default",className:I(R.tableAction,R.gray),onClick:p,role:"button",children:s.jsx(Am,{width:16,height:16})}),s.jsx(us,{id:"rows-num",className:"z-10 shadow-md flex gap-1",clickable:!0,variant:"light",opacity:1,children:ef.map(f=>s.jsx("button",{onClick:()=>h(f,!0),className:I(R.tableAction,R.gray,f===u&&R.selectedSize),children:s.jsx("span",{children:f})},f))}),s.jsx("button",{"data-tooltip-id":"explorer-more-actions",className:I(R.tableAction,R.gray),children:s.jsx(Tm,{width:16,height:16})}),s.jsxs(us,{id:"explorer-more-actions",className:"z-10 shadow-md flex flex-col",clickable:!0,variant:"light",opacity:1,children:[s.jsxs("button",{onClick:()=>Fe("columns"),className:I(R.tableAction,R.modal,R.gray,"justify-between"),children:[s.jsx("span",{children:"Columns"}),s.jsx("span",{className:"hotkey",children:"C"})]}),s.jsxs("button",{onClick:()=>Fe("groupBy"),className:I(R.tableAction,R.modal,R.gray,"justify-between"),children:[s.jsx("span",{children:"Group by"}),s.jsx("span",{className:"hotkey",children:"G"})]}),s.jsxs("button",{onClick:()=>Fe("aggregate"),className:I(R.tableAction,R.modal,R.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:I(R.tableAction,R.modal,R.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:I(R.tableAction,R.modal,R.gray),children:[s.jsx("span",{children:"Save query"}),s.jsx("span",{className:"hotkey",children:"S"})]}),n?.allowInsert===!0&&s.jsx("button",{onClick:g,className:I(R.tableAction,R.modal,R.gray),children:"Insert new row"})]})]})]})}const sf="_drop-container_p8ktx_2",of="_item_p8ktx_2",pr={dropContainer:sf,item:of},Ba=({dataSourceId:e,inputClassName:t,focusId:n,placeholder:o="Column",onChange:a,value:r,autoFocus:i,allowTables:c})=>{const{data:u}=xs(e),h=l.useRef(null),m=l.useMemo(()=>{if(!u)return[];let f=u;return c&&(f=u.filter(w=>c.includes(w.tableName))),f.flatMap(w=>w.columns.map(C=>({value:w.tableName+"."+C.name,label:C.name,table:w.tableName,searchValue:C.name.toLowerCase()})))},[u,c]),d=l.useMemo(()=>{const f=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]),[x,p]=l.useState(!1),[b,g]=l.useState(0),v=f=>{if(f.key==="ArrowDown")f.preventDefault(),g(w=>(w+1)%d.length);else if(f.key==="ArrowUp")f.preventDefault(),g(w=>(w-1+d.length)%d.length);else if(f.key==="Enter"&&b>=0&&b<d.length){f.preventDefault();const w=d[b].value;p(!1);const C=m.findIndex(_=>_.value===w)>-1;a(d[b]?.value||w,C,!0)}};l.useEffect(()=>{const f=h.current?.querySelector('[data-is-active="true"]');f&&f.scrollIntoView({behavior:"smooth",block:"nearest"})},[b]);const y=f=>{const w=f.currentTarget.value,C=m.findIndex(_=>_.value===w)>-1;a(w,C,!1)};return s.jsxs("div",{className:"relative",onFocus:()=>p(!0),onBlur:()=>p(!1),children:[s.jsx("input",{autoFocus:i,onKeyDown:v,value:r,onChange:y,className:t,placeholder:o,"data-focus":n}),x&&d.length>0&&s.jsx("div",{className:pr.dropContainer,ref:h,tabIndex:-1,children:d.map((f,w)=>s.jsxs("div",{className:pr.item,"data-is-active":b===w,onMouseDownCapture:C=>{C.preventDefault(),p(!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))})]})},rf="_actions_1k5yp_2",af="_filter-actions_1k5yp_2",lf="_filter-badge_1k5yp_2",cf="_filters-container_1k5yp_2",uf="_filter-container_1k5yp_2",df="_filter-value_1k5yp_2",Qt={actions:rf,filterActions:af,filterBadge:lf,filtersContainer:cf,filterContainer:uf,filterValue:df},hf=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{d:"M315.27 33L96 304h128l-31.51 173.23a2.36 2.36 0 002.33 2.77h0a2.36 2.36 0 001.89-.95L416 208H288l31.66-173.25a2.45 2.45 0 00-2.44-2.75h0a2.42 2.42 0 00-1.95 1z",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32})),mf=({isAdvanced:e})=>e?s.jsx("span",{"data-tooltip-id":"default","data-tooltip-content":"Advanced mode: parameters and operator will be extracted from the input",className:Qt.filterBadge,children:s.jsx(hf,{width:20,height:20})}):null,ff=({filter:e,dataSourceId:t,allowedTables:n,autoFocus:o,onChangeColumn:a,onChangeValue:r,onRemoveFilter:i,onChangeAdvancedFilter:c,triggerIsEnabled:u,onSubmit:h})=>{const m=x=>{const p=x.target.value;p.charAt(0)===":"?c(e.id,!0):(!e.isAdvanced&&["=","<",">"].includes(p.charAt(0))&&c(e.id,!0),r(e.id,x.currentTarget.value))},d=x=>{x.key==="Backspace"?(e.value.length===0||x.currentTarget.selectionEnd===0)&&c(e.id,!1):x.key==="Enter"&&h()};return s.jsxs("div",{className:Qt.filterContainer,children:[s.jsx("input",{className:"mr-1",type:"checkbox",checked:e.isEnabled!==!1,onClick:()=>u(e.id)}),s.jsx(Ba,{dataSourceId:t,onChange:x=>a(e.id,x),value:e.column,allowTables:n,focusId:"column",inputClassName:"input w-full rounded-r-none!",autoFocus:o}),s.jsxs("div",{className:Qt.filterValue,children:[s.jsx(mf,{isAdvanced:e.isAdvanced}),s.jsx("input",{placeholder:"Filter value",value:e.value,onChange:m,onKeyDown:d,"data-focus":"value",className:"flex-1 outline-none"},e.id)]}),s.jsx("div",{className:Qt.filterActions,children:s.jsx("button",{tabIndex:-1,"data-tooltip-id":"default","data-tooltip-content":"Remove filter",className:"p-0.5 text-sm cursor-pointer rounded-md ml-1",onClick:()=>i(e.id),children:s.jsx(_t,{width:20,height:20,className:"text-red-600"})})})]})},pf=()=>{const{state:e}=l.useContext(Ce),{refetch:t}=l.useContext(Xe),{setFilters:n}=xo(),o=ys(g=>g.filters),a=l.useMemo(()=>[e.table,...e.joins.map(g=>g.table)],[e.table,e.joins]),[r,i]=l.useState([]),c=(g,v)=>{i(y=>[...y.map(f=>f.id===g?{...f,column:v}:f)])},u=(g,v)=>{i(y=>[...y.map(f=>f.id===g?{...f,value:v}:f)])},h=()=>{i(g=>[...g,{id:Je(),value:"",column:"",isEnabled:!0}])},m=g=>{i(v=>v.filter(y=>y.id!==g))},d=(g,v)=>{i(y=>y.map(f=>f.id===g?{...f,isAdvanced:v}:f))},x=()=>ws("filters"),p=()=>{try{n(r.filter(g=>g.value.length>0&&g.column.length>0)),setTimeout(t,1),x()}catch(g){g instanceof Error?ke.error(g.message):ke.error("Error during parsing, check you filters")}},b=g=>{i(v=>v.map(y=>y.id===g?{...y,isEnabled:!y.isEnabled}:y))};return l.useEffect(()=>{o&&i(()=>[...e.filters,{id:Je(),value:"",column:"",isEnabled:!0}])},[o]),We("f",()=>{as("filters")}),s.jsxs(we,{isVisible:o,onClose:x,portal:!0,onClosed:()=>i([]),noPadding:!0,backdropClose:!0,children:[s.jsx(lt,{onClick:x}),s.jsx("h2",{className:"text-lg font-semibold m-2",children:"Filters"}),s.jsxs("div",{className:Qt.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((g,v)=>s.jsx(ff,{filter:g,dataSourceId:e.dataSourceId,allowedTables:a,onChangeColumn:c,onChangeValue:u,onRemoveFilter:m,onChangeAdvancedFilter:d,triggerIsEnabled:b,onSubmit:p,autoFocus:v===r.length-1},g.id))]}),s.jsxs("div",{className:Qt.actions,children:[s.jsxs("button",{className:"button tertiary flex items-center gap-1 text-sm",onClick:h,children:[s.jsx(Ia,{width:20,height:20}),s.jsx("span",{children:"Add filter"})]}),s.jsx("button",{className:"button primary text-sm",onClick:p,children:"Apply filters"})]})]})},xf="_join-modal_qos8k_2",gf={joinModal:xf},bf=(e,t)=>e.type!==t.type||e.on!==t.on||e.table!==t.table,vf=(e,t)=>e.type===t.type&&e.on===t.on&&e.table===t.table,Wa=()=>{const{state:e,setState:t}=l.useContext(Ce),n=l.useCallback(o=>{t(a=>{const r=a.joins;if(r.some(c=>vf(c,o))){const c=o.table+".";return{...a,joins:r.filter(u=>bf(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}},yf=()=>{const{isFetching:e}=l.useContext(Xe),t=ys(u=>u.joins),{toggle:n}=Wa(),{availableJoins:o}=l.useContext(Pe),[a,r]=l.useState(""),i=l.useMemo(()=>{const u=a.toLowerCase();return o.filter(h=>h.fromTable.toLowerCase().includes(u))},[o,a]),c=()=>ws("joins");return We("j",()=>{o.length>0?Fe("joins"):ke.error("No available tables to join")}),s.jsxs(we,{isVisible:t,onClose:c,portal:!0,backdropClose:!0,children:[s.jsx(lt,{onClick:c}),s.jsxs("div",{className:gf.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(me,{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(po,{hook:u,onClick:()=>{e||(n({table:u.direction==="in"?u.fromTable:u.toTable,type:"LEFT",on:qc(u)}),r(""),c())}},u.id))})]})]})};function wf(e){return e.reduce((t,n)=>(t[n]=!0,t),{})}function xr(e){return e.reduce((t,n)=>(t[n]=!0,t),{})}const Cf="_container_fw5ag_2",jf="_column-label_fw5ag_2",Nf="_not-active_fw5ag_2",ss={container:Cf,columnLabel:jf,notActive:Nf};function _f(e){if(!e)return[];const t={};return e.forEach(n=>{t[n.table]?t[n.table].push({value:n.full,ogColumn:n.column,label:st(n.column),type:n.type}):t[n.table]=[{value:n.full,ogColumn:n.column,label:st(n.column),type:n.type}],Bc[n.type]&&["YEAR","MONTH","DAY"].forEach(o=>{t[n.table].push({value:o+" "+n.full,ogColumn:n.column,label:o+" "+st(n.column),type:"number",nested:!0})})}),Object.entries(t).reduce((n,[o,a])=>(n.push({name:st(o),columns:a}),n),[])}function Sf(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 kf=({column:e,selected:t,onCheck:n})=>s.jsxs("label",{className:I(ss.columnLabel,t?ss.active:ss.notActive,e.nested&&"pl-5!"),children:[s.jsx("input",{type:"checkbox",checked:t[e.value],name:e.value,onChange:n}),s.jsxs("p",{className:"flex justify-between w-full",children:[s.jsx("span",{"data-tooltip-content":e.value,"data-tooltip-id":"default",children:e.label}),s.jsx("span",{className:"text-blue-600",children:e.type})]})]},e.value),Ef={columns:"c",groupBy:"g"},gr=({mode:e})=>{const t=ys(f=>f[e]),{allColumns:n}=l.useContext(Pe),{state:o,setState:a}=l.useContext(Ce),[r,i]=l.useState({}),[c,u]=l.useState(""),h=l.useMemo(()=>_f(n),[n]),m=o.aggregations.length>0||o.groupBy.length>0,d=l.useMemo(()=>c?Sf(h,c):h,[c,h]),x=f=>{i(w=>({...w,[f.target.name]:f.target.checked}))},p=f=>{const w=f.target.checked;i(C=>{for(const _ of n)C[_.full]=w;return{...C}})},b=()=>{ws(e)},g=()=>{const f=[];for(const[w,C]of Object.entries(r))if(C){const[_,A]=w.split(" ");f.push({value:A||_,fn:A?_: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]);We(Ef[e],()=>{e==="columns"?m?ke.error("Columns are ignored when there is at least one aggregation or group by"):as("columns"):as("groupBy")}),l.useEffect(()=>{t&&i(()=>wf(o[e].map(f=>f.fn?f.fn+" "+f.value:f.value)))},[t,i]);const y=()=>{u(""),i({})};return s.jsxs(we,{isVisible:t,onClose:b,portal:!0,onClosed:y,backdropClose:!0,children:[s.jsx(lt,{onClick:b}),s.jsxs("div",{className:ss.container,children:[s.jsx("h2",{className:"text-lg font-semibold",children:e==="groupBy"?"Group by":"Show columns"}),s.jsx("input",{autoFocus:!0,className:"input my-2",placeholder:"Filter",value:c,onChange:f=>u(f.target.value)}),s.jsx("div",{className:"overflow-y-auto",children:d.map(f=>s.jsxs("div",{className:"my-2",children:[s.jsxs("p",{className:"font-semibold sticky top-0 bg-white p-1 z-1",children:["📄 ",f.name]}),f.columns.map(w=>s.jsx(kf,{column:w,selected:r,onCheck:x},w.value))]},f.name))}),s.jsxs("div",{className:"flex justify-end gap-2 mt-2",children:[s.jsxs("label",{className:"button tertiary flex gap-2 items-center",children:[s.jsx("input",{type:"checkbox",checked:v,onChange:p}),s.jsx("span",{children:"Select all"})]}),s.jsx("span",{className:"flex-1"}),s.jsx("button",{className:"button tertiary",onClick:b,children:"Cancel"}),s.jsx("button",{className:"button primary",onClick:g,children:"Apply"})]})]})]})},Rf="_options-container_1wgsg_2",Lf={optionsContainer:Rf},Bs="COUNT all",Tf=()=>{const e=ys(b=>b.aggregate),{dataSourceId:t}=l.useContext(Pe),{setState:n,state:o}=l.useContext(Ce),{data:a}=l.useContext(Xe),[r,i]=l.useState({fn:"",col:""}),c=b=>i({...r,fn:b.currentTarget.value}),u=b=>i({...r,col:b}),h=()=>ws("aggregate"),m=()=>{const b=r.fn===Bs?{value:"*",fn:"COUNT"}:{fn:r.fn,value:r.col,distinct:r.fn==="COUNT"};n(g=>({...g,aggregations:[...g.aggregations,b]}))},d=r.fn===Bs,x=d?!1:!r.col||!r.fn,p=b=>{const g=Wc(b);n(v=>({...v,aggregations:v.aggregations.filter(y=>y.fn!==b.fn||y.value!==b.value),orderBy:v.orderBy.filter(y=>y.column!==g)}))};return We("a",()=>{as("aggregate")}),s.jsxs(we,{isVisible:e,onClose:h,backdropClose:!0,portal:!0,children:[s.jsx(lt,{onClick:h}),s.jsxs("div",{children:[s.jsx("h2",{className:"text-lg font-semibold",children:"Aggregate"}),ge(o.aggregations.length,0)&&s.jsx("div",{className:"flex flex-col gap-1 mt-4",children:o.aggregations.map((b,g)=>s.jsxs("p",{className:"p-2 rounded-md bg-gray-50 flex items-center justify-between",children:[s.jsx("span",{children:ts(b)}),s.jsx("button",{tabIndex:-1,"data-tooltip-id":"default","data-tooltip-content":"Remove aggregation",className:"p-0.5 text-sm cursor-pointer",onClick:()=>p(b),children:s.jsx(_t,{width:20,height:20,className:"text-red-600"})})]},g))}),s.jsxs("div",{className:Lf.optionsContainer,children:[s.jsxs("label",{className:I(d&&"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:Bs,children:"Count all rows"}),s.jsx("option",{value:"COUNT",children:"Count"}),s.jsx("option",{value:"SUM",children:"Sum"}),s.jsx("option",{value:"MAX",children:"Max"}),s.jsx("option",{value:"MIN",children:"Min"}),s.jsx("option",{value:"AVG",children:"Avg"})]})]}),!d&&s.jsxs("label",{children:[s.jsx("p",{className:"font-semibold text-xs",children:"Column"}),s.jsx(Ba,{inputClassName:"input w-full",dataSourceId:t,allowTables:a?.result.tables||[],onChange:u,value:r.col})]}),s.jsx("button",{className:"button primary",disabled:x,onClick:m,children:"Add"})]})]})]})},Af="_container_1jwjo_2",If="_yellow-pill_1jwjo_2 _pill_1jwjo_2",Pf="_blue-pill_1jwjo_2 _pill_1jwjo_2",Mf="_purple-pill_1jwjo_2 _pill_1jwjo_2",Of="_red-pill_1jwjo_2 _pill_1jwjo_2",Df="_black-pill_1jwjo_2 _pill_1jwjo_2",$f="_disabled-pill_1jwjo_2",bt={container:Af,yellowPill:If,bluePill:Pf,purplePill:Mf,redPill:Of,blackPill:Df,disabledPill:$f};function No(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 Ff(e){return!(e===!0||e===void 0)}const Bf=()=>{const{state:{aggregations:e,columns:t,groupBy:n}}=l.useContext(Ce),{toggle:o,joins:a}=Wa(),{filters:r,setFilters:i,removeFilter:c}=xo(),u=()=>Fe("joins"),h=()=>Fe("aggregate"),m=()=>Fe("columns"),d=()=>Fe("groupBy"),x=g=>{g.preventDefault(),g.stopPropagation(),o(a[a.length-1])},p=g=>{i(r.map(v=>({...v,isEnabled:g===v.id?Ff(v.isEnabled):v.isEnabled})),!0)},b=g=>v=>{v.preventDefault(),v.stopPropagation(),c(g)};return r.length>0||a.length>0||n.length>0||t.length>0||e.length>0?s.jsxs("div",{className:bt.container,children:[a.map((g,v)=>s.jsxs("button",{onClick:u,className:bt.yellowPill,"data-tooltip-id":"default","data-tooltip-content":`Joins ${g.table} on ${g.on}`,children:[s.jsx("p",{className:"text-sm",children:g.table}),v===a.length-1&&s.jsx(_t,{onClick:x,width:18,height:18})]},g.table)),r.map(g=>s.jsxs("button",{onClick:()=>p(g.id),onAuxClick:()=>c(g.id),className:I(bt.bluePill,g.isEnabled===!1&&bt.disabledPill),"data-tooltip-id":"default","data-tooltip-content":`${g.column} ${g.value}`,children:[s.jsx("p",{className:"text-sm",children:g.column}),s.jsx("p",{className:"text-sm",children:g.value}),s.jsx(_t,{onClick:b(g.id),width:18,height:18})]},g.id)),e.map(g=>s.jsx("button",{onClick:h,className:I(bt.purplePill),"data-tooltip-id":"default","data-tooltip-content":ts(g),children:s.jsx("p",{className:"text-sm",children:ts(g)})},ts(g))),t.length>0&&s.jsx("button",{onClick:m,className:I(bt.redPill),"data-tooltip-id":"default","data-tooltip-content":"Has hidden columns",children:s.jsx("p",{className:"text-sm",children:"Hidden columns"})}),n.length>0&&s.jsx("button",{onClick:d,className:I(bt.blackPill),"data-tooltip-id":"default","data-tooltip-content":"Has GROUP BY",children:s.jsx("p",{className:"text-sm",children:"Grouped columns"})}),!1]}):null},Wf=({options:e,updater:t,name:n,tabId:o})=>{const a=wc(e,t),r=Ac(o,a.state),i=yc(r.data,a.state.dataSourceId,n,o);return s.jsx(Pe,{value:i,children:s.jsx(Ce,{value:a,children:s.jsxs(Xe,{value:r,children:[s.jsx(Jm,{}),s.jsx(Bf,{}),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(jh,{})}),s.jsx(pf,{}),s.jsx(yf,{}),s.jsx(gr,{mode:"columns"}),s.jsx(gr,{mode:"groupBy"}),s.jsx(Tf,{})]})]})})})},_o=({size:e=32})=>s.jsxs("div",{role:"status",children:[s.jsxs("svg",{"aria-hidden":"true",width:e,height:e,className:"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..."})]}),qf=({id:e})=>{const{data:t}=Rc(e),n=l.useCallback(o=>{if(!t)return;const a=o(Nt(t.opts));K.setQueryData(["workbench-tabs",t.id],{...t,opts:{...t.opts,...a}})},[t]);return t?s.jsx(Wf,{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(_o,{})})},Uf=e=>{setTimeout(t=>{const n=document.querySelector(`[data-tab-id="${t}"]`);n&&n.scrollIntoView({behavior:"smooth"})},50,e)},Hf=()=>{const{id:e}=Qi(),t=J(),{data:n}=bs(),o=Lc(),a=da(fo.laptop),r=u=>{if(u===e&&n){if(n.length===1)return t(D.home.build());if(n.length>1){const h=n.find(m=>m.id!==u);if(h)return t(`/workbench/tab/${h.id}`)}}},i=u=>{u.stopPropagation(),u.preventDefault();const h=u.currentTarget.getAttribute("data-tab-id");h&&(o.mutate(h),r(h))},c=u=>{o.mutate(u),r(u)};return l.useEffect(()=>{e&&Uf(e)},[e,n]),s.jsxs("div",{className:"h-screen max-h-screen bg-(--bg) flex flex-col",children:[e?s.jsx(qf,{id:e}):s.jsx("div",{className:"flex-1"}),s.jsx("div",{className:I(bn.tabs,"no-scrollbar",!a&&bn.mobile),children:n?.map(u=>s.jsxs("div",{onClick:()=>t(D.workbenchTab.build({id:u.id})),className:I(bn.tab,u.id===e&&bn.active),"data-tooltip-id":"default","data-tab-id":u.id,"data-tooltip-content":u.name,onAuxClick:()=>c(u.id),children:[s.jsxs("span",{className:"truncate w-full",children:["🛠️ ",u.name]}),s.jsx("button",{"data-tab-id":u.id,className:bn.closeButton,onClick:i,children:s.jsx(_t,{width:20,height:20})})]},u.id))})]})},zf="_root_kyh68_2",Vf="_up_kyh68_2",Qf="_down_kyh68_2",Kf="_chevron_kyh68_2",Gf="_table-name-container_kyh68_2",Yf="_link_kyh68_2",Jf="_table-name_kyh68_2",Xf="_ul_kyh68_2",Zf="_column-type_kyh68_2",e0="_action-blue_kyh68_2 _action_kyh68_2",t0="_action-red_kyh68_2 _action_kyh68_2",n0="_db-header-container_kyh68_2",s0="_db-header_kyh68_2",o0="_db-subheader_kyh68_2 _db-header_kyh68_2",se={root:zf,up:Vf,down:Qf,chevron:Kf,tableNameContainer:Gf,link:Yf,tableName:Jf,ul:Xf,columnType:Zf,actionBlue:e0,actionRed:t0,dbHeaderContainer:n0,dbHeader:s0,dbSubheader:o0},r0="_sidebar_13oy6_2",a0="_sidebar-visible_13oy6_2",i0="_sidebar-container_13oy6_2",l0="_sidebar-invisible_13oy6_2",c0="_backdrop_13oy6_2",vn={sidebar:r0,sidebarVisible:a0,sidebarContainer:i0,sidebarInvisible:l0,backdrop:c0},So=({children:e,backdropClose:t,isVisible:n,onClose:o,onClosed:a,contentClassName:r})=>{const[i,c]=l.useState(!1),u=()=>{t&&o()},h=m=>{n||getComputedStyle(m.currentTarget).opacity==="0"&&(c(!1),a&&a())};return l.useEffect(()=>{n&&c(!0)},[n]),vs({onClose:u,enabled:n&&t===!0}),s.jsxs("div",{onTransitionEnd:h,className:I(vn.sidebar,n?vn.sidebarVisible:vn.sidebarInvisible),children:[s.jsx("div",{onClick:u,className:vn.backdrop}),s.jsx("div",{className:I(vn.sidebarContainer,r),children:i&&e})]})},u0=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"})),d0=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"})),qa=(e,t=!0)=>{const n=navigator.clipboard.writeText(e);t&&n.then(()=>{ke.success(`Copied "${e}"`)})},h0=e=>{const t=l.useRef(!1);l.useEffect(()=>{e&&(e.status==="INSPECTING"?t.current=!0:e.status==="READY"&&t.current&&(fc(e.id),t.current=!1))},[e])},m0=new Intl.DateTimeFormat("en",{dateStyle:"full",timeStyle:"long"}),Jn=18;function f0(e,t){return t&&e.toLowerCase().includes(t)?"bg-yellow-200 cursor-pointer":"cursor-pointer"}const p0=({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:se.ul,children:o.map(a=>s.jsx(s.Fragment,{children:s.jsxs("li",{children:[a.isPrimary?"🔐":"🏷️"," ",s.jsx("span",{onClick:()=>qa(a.name),className:f0(a.name,t),children:a.name})," ",s.jsxs("span",{className:se.columnType,children:["[",a.type,"]"]}),a.ref&&s.jsxs("span",{children:[" ➡️ ",s.jsx("span",{className:se.columnType,children:a.ref.table}),".",a.ref.field]})]},a.name+a.type)}))},e.id)};function x0({id:e}){const{data:t}=ps(e),{data:n}=xs(e),o=J(),a=xc(),r=Xr(),i=gc(),c=Et(),u=l.useMemo(()=>t?.lastInspected?m0.format(new Date(t.lastInspected)):"--",[t]),[h,m]=l.useState({}),[d,x]=l.useState(""),[p,b]=l.useState("table"),g=An(he.EDITOR),v=d.toLowerCase(),y=l.useMemo(()=>{if(!v||!n)return n||[];const j=[];for(const k of n){if(k.tableName.toLowerCase().includes(v)){j.push(k);continue}p!=="table"&&k.columns.findIndex(X=>X.name.toLowerCase().includes(v))>=0&&j.push(k)}return j},[v,n,p]),f=j=>{m(k=>({...k,[j]:!k[j]}))},w=j=>{c.mutateAsync({name:j,opts:Nt({table:j,dataSourceId:e})}).then(k=>{Nn(void 0),o(D.workbenchTab.build({id:k.id}))})},C=()=>{r.mutate(e)},_=async()=>{const j=await On("Enter name",t?.name);j&&a.mutate({id:e,dataSource:{name:j}})},A=async()=>{await mo("Are you sure you want to delete this data source?")&&(i.mutate(e),Nn(void 0))};h0(t);const S=p==="column",P=t?.status==="INSPECTING";return s.jsxs("div",{className:se.root,children:[s.jsxs("div",{className:"sticky top-0 bg-white border-b border-gray-200 px-4 py-2 z-1",children:[s.jsxs("div",{className:se.dbHeaderContainer,children:[s.jsxs("div",{className:se.dbHeader,children:[t&&s.jsx(He,{size:24,type:t.dbType}),s.jsx("p",{className:"truncate text-(--text-color-primary) text-lg",children:t?.name})]}),s.jsxs("div",{className:se.dbSubheader,children:[s.jsx("p",{className:"text-xs text-(--text-color-secondary) truncate",children:u}),g&&s.jsxs("div",{className:"flex justify-end",children:[s.jsx("button",{disabled:r.isPending||P,onClick:C,className:se.actionBlue,"data-tooltip-id":"default-xs","data-tooltip-content":"Refresh schema",children:s.jsx(Aa,{width:16,height:16})}),s.jsx("button",{disabled:r.isPending,onClick:_,className:se.actionBlue,"data-tooltip-id":"default-xs","data-tooltip-content":"Update name",children:s.jsx(u0,{width:16,height:16})}),s.jsx("button",{disabled:r.isPending,onClick:A,className:se.actionRed,"data-tooltip-id":"default-xs","data-tooltip-content":"Delete data source",children:s.jsx(d0,{width:16,height:16})})]})]})]}),s.jsxs("div",{className:"flex gap-2 items-center mt-2",children:[s.jsxs("select",{className:"input text-sm",value:p,onChange:j=>b(j.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 text-sm",placeholder:S?"Search column":"Search table",value:d,onChange:j=>x(j.target.value),autoFocus:!0})]})]}),P&&s.jsxs("div",{className:"flex justify-center gap-2 items-center bg-blue-50 p-4 rounded",children:[s.jsx(_o,{size:16}),s.jsx("p",{className:"text-xs text-blue-800",children:"Inspecting schema"})]}),t?.status==="FAILED"&&s.jsx("div",{className:"flex justify-center gap-2 items-center bg-red-50 p-4 rounded",children:s.jsx("p",{className:"text-xs text-red-800",children:"Latest inspection failed"})}),s.jsx("div",{className:I("overflow-y-auto p-4",P&&"opacity-30"),children:y?.map(j=>s.jsxs("div",{children:[s.jsxs("div",{className:se.tableNameContainer,children:[s.jsx("button",{className:I(se.chevron,h[j.id]?se.down:se.up),onClick:()=>f(j.id),children:s.jsx(Sn,{width:16,height:16})}),s.jsx("button",{className:I(se.tableName,"flex-1"),onClick:()=>f(j.id),children:j.tableName}),s.jsx("button",{className:se.link,onClick:()=>w(j.tableName),"data-tooltip-id":"default-xs","data-tooltip-content":"Explore table data",children:s.jsx(ca,{width:Jn,height:Jn})}),s.jsx("button",{className:se.link,onClick:()=>qa(j.tableName),"data-tooltip-id":"default-xs","data-tooltip-content":"Copy table name",children:s.jsx(ba,{width:Jn,height:Jn})})]}),(h[j.id]||d.length>0)&&s.jsx(p0,{insp:j,filter:S?v:"",expanded:h[j.id]})]},j.id))})]})}const g0=()=>{const e=Cu(),[t,n]=l.useState(void 0);l.useEffect(()=>{e&&n(e)},[e]);const o=()=>Nn(void 0);return s.jsx(So,{isVisible:e!=null,onClose:o,onClosed:()=>n(void 0),backdropClose:!0,children:t&&s.jsx(x0,{id:t})})},b0="_search-container_11928_2",v0="_search_11928_2",y0="_entry_11928_2",w0="_ds_11928_2",C0="_ds-container_11928_2",j0="_ds-entry_11928_2",N0="_enabled_11928_2",vt={searchContainer:b0,search:v0,entry:y0,ds:w0,dsContainer:C0,dsEntry:j0,enabled:N0};function _0(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 S0=({storage:e=localStorage,localStorageKey:t,initialData:n})=>{const o=ye(_0(t,n,e));return o[2].subscribe(a=>{e.setItem(t,JSON.stringify(a))}),o},[k0,E0]=S0({initialData:[],localStorageKey:"selected-data-sources-v1"}),R0=e=>E0(t=>{const n=t.indexOf(e);return n>-1?(t.splice(n,1),[...t]):[...t,e]}),L0={table:"📄",query:"📖",tab:"🛠️"},T0=({onTable:e,onQuery:t,onWorkbenchTab:n,autoFocus:o})=>{const[a,r]=l.useState(""),[i,c]=l.useState(-1),u=No(a,200),h=k0(),{data:m}=ve(),{data:d}=ao({teamId:m?.teamId}),x=l.useMemo(()=>{const f=[],w=xr(h);if(!d||d.length===0)return[];for(const C of d)w[C.id]&&f.push(C.id);return f},[h,d]),{data:p}=ic(u,{teamId:m?.teamId,selectedDataSources:x}),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)},g=f=>{p&&(f.key==="ArrowDown"?(f.preventDefault(),c(w=>(w+1)%p.length)):f.key==="ArrowUp"?(f.preventDefault(),c(w=>(w-1+p.length)%p.length)):f.key==="Enter"&&i>=0&&p[i]?.name&&(f.preventDefault(),b(p[i])))},v=f=>{const w=f.currentTarget.dataset.tableId,C=p?.find(_=>_.id===w);C&&b(C)},y=l.useMemo(()=>xr(h),[h]);return s.jsxs("div",{className:"overflow-hidden flex flex-col w-full lg:w-lg",children:[ge(d?.length,0)?s.jsx("div",{className:vt.dsContainer+" no-scrollbar",children:d.map(f=>s.jsxs("button",{className:I(vt.dsEntry,y[f.id]&&vt.enabled),onClick:()=>R0(f.id),"data-tooltip-id":"default","data-tooltip-content":f.name,children:[s.jsx(He,{size:18,type:f.dbType}),s.jsx("span",{children:f.name})]},f.id))}):s.jsx(me,{variant:"warning",className:"mb-4",children:"Connect at least one data source to start using DataRamen"}),s.jsxs("div",{className:vt.searchContainer,children:[s.jsx(tn,{className:"text-(--text-color-secondary)",width:18,height:18}),s.jsx("input",{className:vt.search,placeholder:"Search table or saved query to start from",value:a,onChange:f=>r(f.target.value),onKeyDown:g,autoFocus:o})]}),ge(p?.length,0)&&s.jsx("div",{className:"overflow-y-auto max-h-full mt-2",children:p.map((f,w)=>s.jsxs("button",{className:vt.entry,"data-is-active":i===w,"data-table-id":f.id,onClick:v,children:[s.jsxs("p",{className:"truncate",children:[L0[f.type]," ",f.name]}),s.jsxs("p",{className:vt.ds,children:["📦 ",f.dataSourceName]})]},f.id))})]})},A0=()=>{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(we,{isVisible:!!e,onClose:a,backdropClose:!0,children:s.jsx(T0,{autoFocus:!0,onTable:t,onQuery:n,onWorkbenchTab:o})})},I0=()=>{const e=Tn("Hotkey"),t=J(),{pathname:n}=fe(),{data:o}=ve(),{data:a}=bs(),r=D.home.check(n);We("n",()=>{o&&e()}),We("w",()=>{o&&(a&&a.length>0?t(D.workbenchTab.build({id:a[0].id})):e())},{enabled:r}),We("h",()=>{jn({show:!0})})},[P0,Ua]=ye(!1),Ws=()=>Ua(!1),Ha=()=>Ua(!0),M0=({repeatPassword:e,password:t})=>t.length<1?null:t.length<8?s.jsx(me,{variant:"warning",children:"New password should be at least 8 characters long"}):t!==e?s.jsx(me,{variant:"warning",children:"Repeat password should match new password"}):null,O0=()=>{const e=P0(),{data:t}=ve(),{mutateAsync:n,isPending:o}=bc(),a=J(),[{password:r,repeatPassword:i},{change:c,touched:u,reset:h}]=kn({password:"",repeatPassword:""}),m=()=>{a("/"),hs.logout().then(()=>{Ws()})},d=()=>{n({password:r}).then(()=>{h(),ke.success("Password successfully updated!")})},x=r.length<8||r!==i||o,p=u.includes("password");return s.jsxs(we,{isVisible:e,onClose:Ws,children:[s.jsx(lt,{onClick:Ws}),s.jsxs("div",{className:"w-full lg:w-lg flex flex-col gap-2",children:[s.jsx(oa,{children:"Account settings"}),s.jsxs("label",{children:[s.jsx("p",{className:"text-xs font-semibold mb-1",children:"Username"}),s.jsx("input",{className:"input w-full",readOnly:!0,disabled:!0,value:t?.username})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsxs("label",{children:[s.jsx("p",{className:"text-xs font-semibold mb-1",children:"Change password"}),s.jsx("input",{className:"input w-full",type:"password",name:"newPassword",autoComplete:"new-password",value: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")})]})]}),p&&s.jsx(M0,{password:r,repeatPassword:i}),s.jsxs("div",{className:"flex justify-end gap-2 mt-2",children:[s.jsx("button",{className:"button tertiary",disabled:x,onClick:d,children:"Update password"}),s.jsx("button",{className:"button danger",onClick:m,children:"Log out"})]})]})]})},[D0,za]=ye(!1),Va=()=>za(!0),br=()=>za(!1),$0=e=>be({queryKey:["team-users"],queryFn:async()=>{const{data:t}=await $.get("/teams/"+e+"/users");return t.data},enabled:!!e}),F0=()=>ee({mutationFn:async({role:e,teamId:t,userId:n})=>(await $.patch("/teams/"+t+"/user-role",{role:e,userId:n}),!0),onSuccess:()=>{K.invalidateQueries({queryKey:["team-users"]})}}),B0=()=>ee({mutationFn:async({teamId:e,userId:t})=>(await $.delete("/teams/"+e,{params:{userId:t}}),!0),onSuccess:()=>{K.invalidateQueries({queryKey:["team-users"]})}}),W0="_user-entry_19car_2",q0="_select-container_19car_2",vr={userEntry:W0,selectContainer:q0},U0=()=>{const e=D0(),{data:t}=ve(),{data:n}=$0(t?.teamId),{mutate:o,isPending:a}=vc(),{mutate:r,isPending:i}=F0(),{mutate:c,isPending:u}=B0(),[h,{change:m,reset:d}]=kn({password:"",username:""}),x=()=>{o({username:h.username,password:h.password,teamId:t?.teamId||""}),d()},p=(y,f)=>{r({teamId:t.teamId,role:f,userId:y})},b=y=>{mo("Are you sure you want to remove this user?").then(f=>{f&&c({userId:y,teamId:t.teamId})})},g=An(he.ADMIN),v=a||i||u;return s.jsxs(we,{isVisible:e,onClose:br,backdropClose:!0,children:[s.jsx(lt,{onClick:br}),s.jsxs("div",{className:"w-full lg:w-lg flex flex-col overflow-hidden",children:[s.jsx(oa,{children:"Manage users"}),ge(n?.length,0)&&s.jsx("div",{className:"mt-4 overflow-y-auto flex-1",children:n.map(y=>s.jsxs("div",{className:vr.userEntry,children:[s.jsx("div",{className:vr.selectContainer,children:s.jsxs("select",{value:y.role,disabled:!g||v,onChange:f=>p(y.id,f.currentTarget.value),children:[s.jsx("option",{value:he.OWNER,children:"Owner"}),s.jsx("option",{value:he.ADMIN,children:"Admin"}),s.jsx("option",{value:he.EDITOR,children:"Editor"}),s.jsx("option",{value:he.READ_ONLY,children:"Reader"})]})}),s.jsx("p",{className:"flex-1 mx-2",children:y.name}),g&&s.jsx("button",{className:"p-1 cursor-pointer text-red-500 text-sm",onClick:()=>b(y.id),children:"❌"})]},y.id))}),g&&s.jsxs("div",{className:"mt-4",children:[s.jsx("p",{className:"font-semibold",children:"Create new user"}),s.jsxs("div",{className:"flex flex-col lg:flex-row gap-2 lg:items-center mt-2",children:[s.jsx("input",{className:"input flex-1",onChange:m("username"),value:h.username,placeholder:"Username",disabled:v}),s.jsx("input",{className:"input",onChange:m("password"),value:h.password,type:"password",name:"newPassword",autoComplete:"new-password",placeholder:"Password",disabled:v}),s.jsx("button",{className:"button primary",onClick:x,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."})]})]})]})},H0="_gray-card_1823b_2",z0="_login-label_1823b_2",yr={grayCard:H0,loginLabel:z0},V0=()=>{const[e,t]=l.useState(""),[n,o]=l.useState(""),[a,r]=l.useState(),i=J(),c=u=>{u.preventDefault(),r(void 0),hs.login({password:n,username:e}).then(()=>{i("/",{replace:!0})}).catch(r)};return s.jsx("div",{className:"page-container bg-(--bg) h-screen",children:s.jsxs("div",{className:"page-content items-center",children:[s.jsxs("div",{className:"py-10 text-center w-full sticky top-0 z-0",children:[s.jsx("h1",{className:"comfortaa text-3xl font-semibold text-(--text-color-primary) mb-4",children:"Welcome to DataRamen!"}),s.jsx(ia,{})]}),s.jsxs("form",{className:yr.grayCard,onSubmit:c,children:[s.jsx("h2",{className:yr.loginLabel,children:"Login"}),a&&s.jsx(me,{className:"border border-red-600",variant:"danger",children:"Failed to login. Please verify your credentials"}),s.jsx("input",{value:e,onChange:u=>t(u.currentTarget.value),className:"input secondary",placeholder:"User name"}),s.jsx("input",{value:n,onChange:u=>o(u.currentTarget.value),className:"input secondary",type:"password",placeholder:"Password"}),s.jsx("div",{className:"flex justify-end",children:s.jsx("button",{type:"submit",className:"button primary",children:"Login"})})]})]})})},Q0=()=>{const e=J(),{pathname:t}=fe(),{data:n,isLoading:o}=Zr();l.useEffect(()=>{!n&&!o&&!D.login.check(t)&&e(D.login.build())},[n,o,e,t])},K0=()=>{},G0=__CLIENT_CONFIG__.skipAuth?K0:Q0,Y0=()=>{const[e]=$l(),t=J(),n=Et(),o=e.get("shareId");return l.useEffect(()=>{o&&n.mutateAsync({queryId:o}).then(a=>{t(D.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(_o,{}),s.jsx("p",{children:"Fetching query information"})]}),n.isError&&s.jsx(me,{variant:"danger",children:"Failed to load query information"})]})},J0="_tab-container_1qdgb_2",X0="_tab-name_1qdgb_2",Z0="_archived-badge_1qdgb_2 _badge_1qdgb_2",ep="_active-badge_1qdgb_2 _badge_1qdgb_2",tp="_delete-action_1qdgb_2",yn={tabContainer:J0,tabName:X0,archivedBadge:Z0,activeBadge:ep,deleteAction:tp},Qa=({onLoadMore:e,children:t,onClose:n,hasMore:o,onSearchValue:a,searchValue:r})=>s.jsxs("aside",{className:"w-full lg:w-md no-scrollbar",children:[s.jsxs("div",{className:"sticky top-0 px-4 py-2 border-b border-gray-200 bg-white",children:[s.jsxs("h3",{className:"text-lg flex justify-between items-center",children:["Recent tabs",n&&s.jsx("button",{className:"cursor-pointer hover:bg-(--bg-ter) rounded-full p-1",onClick:n,children:s.jsx(_t,{width:24,height:24})})]}),s.jsx(Pn,{containerClassName:"mt-2",className:"text-sm",placeholder:"Filter",value:r,autoFocus:!0,onChange:i=>a(i.target.value)})]}),t,o&&s.jsx("div",{className:"flex justify-center my-2",children:s.jsx("button",{className:"text-blue-800 text-sm p-2 cursor-pointer",onClick:e,children:"Load more"})})]}),np=new Intl.DateTimeFormat,sp=()=>{const[e,t]=l.useState(""),n=No(e),{data:o}=ve(),{data:a,fetchNextPage:r,hasNextPage:i}=lc(o?.teamId,n,25),c=J(),u=ea(),h=Ic(),m=l.useRef(null),d=l.useRef(null),x=b=>{u.mutate(b),jn({show:!1}),c(D.workbenchTab.build({id:b}))},p=()=>{m.current?.close(),h.mutate(d.current)};return s.jsxs(Qa,{hasMore:i,onLoadMore:r,onClose:()=>jn({show:!1}),searchValue:e,onSearchValue:t,children:[a?.map(b=>s.jsxs("div",{className:yn.tabContainer,onClick:()=>x(b.id),onContextMenu:g=>{d.current=b.id,m.current?.open(g,!1)},children:[s.jsxs("div",{className:"flex gap-2 items-center",children:[s.jsx("p",{className:yn.tabName,children:b.name}),b.dataSourceType&&s.jsx(He,{size:16,type:b.dataSourceType}),s.jsx("p",{className:"text-xs text-(--text-color-secondary)",children:b.dataSourceName})]}),s.jsxs("div",{className:"flex gap-2 items-center mt-1",children:[s.jsx("p",{className:"text-xs text-(--text-color-secondary) italic",children:np.format(new Date(b.updatedAt))}),b.archived?s.jsx("span",{className:yn.archivedBadge,children:"Archived"}):s.jsx("span",{className:yn.activeBadge,children:"Active"})]})]},b.id)),s.jsx(ga,{ref:m,children:s.jsx("button",{onClick:p,className:yn.deleteAction,children:"🗑 Delete"})})]})},op=()=>{const e=wu(t=>t.show);return s.jsx(So,{isVisible:e,onClose:()=>jn({show:!1}),backdropClose:!0,children:s.jsx(sp,{})})},rp=()=>{const{data:e}=ve(),t=dc(e?.teamId),n=J();return l.useEffect(()=>{t.mutateAsync().then(o=>{o?n(D.workbenchTab.build({id:o.id}),{replace:!0}):n(D.home.build(),{replace:!0})})},[]),null},ap="_query-entry_diunk_2",ip={queryEntry:ap},lp=new Intl.DateTimeFormat,cp=({projectQueries:e,isLoading:t})=>{const n=l.useRef(void 0),o=J(),a=Sh(),r=Et(),i=_h(),c=fa(),u=d=>{r.mutateAsync({queryId:d}).then(x=>{In({show:!1}),o(D.workbenchTab.build({id:x.id}))})},h=async d=>{const x=e?.find(b=>b.id===d);if(!x)return;const p=await On("New name?",x?.name);p&&a.mutate({id:x.savedQueryId,payload:{name:p}})},m=d=>{const x=e?.find(p=>p.id===d)?.savedQueryId;x&&i.mutate(x)};return s.jsxs("div",{className:"flex flex-col px-2",children:[ge(e?.length,0)&&e.map(d=>s.jsxs("button",{className:ip.queryEntry,onClick:()=>u(d.id),onContextMenu:x=>{n.current=d.id,c.open(x)},children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-left text-sm font-semibold text-(--text-color-primary)",children:d.name}),s.jsx("p",{className:"text-left text-xs text-(--text-color-secondary) italic",children:lp.format(new Date(d.updatedAt))})]}),s.jsxs("p",{className:"flex gap-2 items-center",children:[s.jsx(He,{size:16,type:d.datasourceType}),s.jsx("span",{className:"truncate text-xs text-(--text-color-secondary)",children:d.datasourceName})]})]},d.savedQueryId)),!t&&Jd(e?.length,1)&&s.jsx("p",{className:"text-center text-sm text-(--text-color-secondary) mt-2",children:"Empty"}),s.jsx(pa,{handler:c,children:s.jsxs("div",{className:"context-menu-container",children:[s.jsx("button",{onClick:d=>{d.preventDefault(),d.stopPropagation(),c.close(),h(n.current)},className:"context-menu-item",children:"✏️ Rename"}),s.jsx("button",{onClick:d=>{d.preventDefault(),d.stopPropagation(),c.close(),m(n.current)},className:"context-menu-item",children:"🗑️ Delete"})]})})]})},up=()=>{const{data:e}=ve(),[t,n]=l.useState(""),o=No(t),{data:a,isLoading:r,fetchNextPage:i,hasNextPage:c}=cc(e?.teamId,o);return s.jsx(Qa,{hasMore:c,onClose:()=>In({show:!1}),onLoadMore:i,searchValue:t,onSearchValue:n,children:s.jsx(cp,{isLoading:r,projectQueries:a||[]})})},dp=()=>{const e=yu(t=>t.show);return s.jsx(So,{isVisible:e,onClose:()=>In({show:!1}),backdropClose:!0,children:s.jsx(up,{})})};function hp(){return I0(),G0(),s.jsxs(s.Fragment,{children:[s.jsxs(ll,{children:[s.jsx(Ht,{path:D.home.path,element:s.jsx(Pu,{})}),s.jsx(Ht,{path:D.workbench.path,element:s.jsx(rp,{})}),s.jsx(Ht,{path:D.workbenchTab.path,element:s.jsx(Hf,{})}),s.jsx(Ht,{path:D.login.path,element:s.jsx(V0,{})}),s.jsx(Ht,{path:D.share.path,element:s.jsx(Y0,{})})]}),s.jsx(Ku,{}),s.jsx(od,{}),s.jsx(gd,{}),s.jsx(g0,{}),s.jsx(A0,{}),s.jsx(O0,{}),s.jsx(U0,{}),s.jsx(op,{}),s.jsx(dp,{}),s.jsx(hd,{}),s.jsx(id,{})]})}const mp="_hidden_vlbrl_2",fp="_desktop-layout_vlbrl_2",pp="_mobile-layout_vlbrl_2",xp="_nav_vlbrl_2",gp="_shown_vlbrl_2",bp="_main_vlbrl_2",vp="_header_vlbrl_2",yp="_expand_vlbrl_2",wp="_show_vlbrl_2",Cp="_hide_vlbrl_2",jp="_icon_vlbrl_2",Np="_nav-item_vlbrl_2",_p="_project-wrapper_vlbrl_2",O={hidden:mp,desktopLayout:fp,mobileLayout:pp,nav:xp,shown:gp,main:bp,header:vp,expand:yp,show:wp,hide:Cp,icon:jp,navItem:Np,projectWrapper:_p},Sp=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{fill:"currentColor",d:"M507 211.16c-1.42-1.19-14.25-10.94-41.79-10.94a132.55 132.55 0 00-21.61 1.9c-5.22-36.4-35.38-54-36.57-55l-7.36-4.28-4.75 6.9a101.65 101.65 0 00-13.06 30.45c-5 20.7-1.9 40.2 8.55 56.85-12.59 7.14-33 8.8-37.28 9H15.94A15.93 15.93 0 000 262.07a241.25 241.25 0 0014.75 86.83C26.39 379.35 43.72 402 66 415.74 91.22 431.2 132.3 440 178.6 440a344.23 344.23 0 0062.45-5.71 257.44 257.44 0 0081.69-29.73 223.55 223.55 0 0055.57-45.67c26.83-30.21 42.74-64 54.38-94h4.75c29.21 0 47.26-11.66 57.23-21.65a63.31 63.31 0 0015.2-22.36l2.14-6.18z"}),l.createElement("path",{fill:"currentColor",d:"M47.29 236.37H92.4a4 4 0 004-4v-40.48a4 4 0 00-4-4H47.29a4 4 0 00-4 4v40.44a4.16 4.16 0 004 4M109.5 236.37h45.12a4 4 0 004-4v-40.48a4 4 0 00-4-4H109.5a4 4 0 00-4 4v40.44a4.16 4.16 0 004 4M172.9 236.37H218a4 4 0 004-4v-40.48a4 4 0 00-4-4h-45.1a4 4 0 00-4 4v40.44a3.87 3.87 0 004 4M235.36 236.37h45.12a4 4 0 004-4v-40.48a4 4 0 00-4-4h-45.12a4 4 0 00-4 4v40.44a4 4 0 004 4M109.5 178.57h45.12a4.16 4.16 0 004-4v-40.48a4 4 0 00-4-4H109.5a4 4 0 00-4 4v40.44a4.34 4.34 0 004 4M172.9 178.57H218a4.16 4.16 0 004-4v-40.48a4 4 0 00-4-4h-45.1a4 4 0 00-4 4v40.44a4 4 0 004 4M235.36 178.57h45.12a4.16 4.16 0 004-4v-40.48a4.16 4.16 0 00-4-4h-45.12a4 4 0 00-4 4v40.44a4.16 4.16 0 004 4M235.36 120.53h45.12a4 4 0 004-4V76a4.16 4.16 0 00-4-4h-45.12a4 4 0 00-4 4v40.44a4.17 4.17 0 004 4M298.28 236.37h45.12a4 4 0 004-4v-40.48a4 4 0 00-4-4h-45.12a4 4 0 00-4 4v40.44a4.16 4.16 0 004 4"})),kp=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"})),Ep=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"})),Rp=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{d:"M304 336v40a40 40 0 01-40 40H104a40 40 0 01-40-40V136a40 40 0 0140-40h152c22.09 0 48 17.91 48 40v40M368 336l80-80-80-80M176 256h256",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32})),Lp=e=>l.createElement("svg",{className:"ionicon",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg",...e},l.createElement("path",{d:"m 266.89,52 c -5,-5.28 -16.69,-5.34 -21.78,0 L 80,212 v 236 c 0,8.83656 7.163444,16 16,16 h 96 V 328 c 0,-13.25483 10.74517,-24 24,-24 h 80 c 13.25483,0 24,10.74517 24,24 v 136 h 96 c 8.83656,0 16,-7.16344 16,-16 l -0.16428,-236.06357 z",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32})),Tp=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{d:"M344 144c-3.92 52.87-44 96-88 96s-84.15-43.12-88-96c-4-55 35-96 88-96s92 42 88 96z",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32}),l.createElement("path",{d:"M256 304c-87 0-175.3 48-191.64 138.6C62.39 453.52 68.57 464 80 464h352c11.44 0 17.62-10.48 15.65-21.4C431.3 352 343 304 256 304z",fill:"none",stroke:"currentColor",strokeMiterlimit:10,strokeWidth:32})),Ap=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{d:"M402 168c-2.93 40.67-33.1 72-66 72s-63.12-31.32-66-72c-3-42.31 26.37-72 66-72s69 30.46 66 72z",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32}),l.createElement("path",{d:"M336 304c-65.17 0-127.84 32.37-143.54 95.41-2.08 8.34 3.15 16.59 11.72 16.59h263.65c8.57 0 13.77-8.25 11.72-16.59C463.85 335.36 401.18 304 336 304z",fill:"none",stroke:"currentColor",strokeMiterlimit:10,strokeWidth:32}),l.createElement("path",{d:"M200 185.94c-2.34 32.48-26.72 58.06-53 58.06s-50.7-25.57-53-58.06C91.61 152.15 115.34 128 147 128s55.39 24.77 53 57.94z",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32}),l.createElement("path",{d:"M206 306c-18.05-8.27-37.93-11.45-59-11.45-52 0-102.1 25.85-114.65 76.2-1.65 6.66 2.53 13.25 9.37 13.25H154",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeMiterlimit:10,strokeWidth:32})),Ip=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{d:"M380.93 57.37A32 32 0 00358.3 48H94.22A46.21 46.21 0 0048 94.22v323.56A46.21 46.21 0 0094.22 464h323.56A46.36 46.36 0 00464 417.78V153.7a32 32 0 00-9.37-22.63zM256 416a64 64 0 1164-64 63.92 63.92 0 01-64 64zm48-224H112a16 16 0 01-16-16v-64a16 16 0 0116-16h192a16 16 0 0116 16v64a16 16 0 01-16 16z",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32})),wr=!__CLIENT_CONFIG__.skipAuth,Cr=(()=>{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`}})(),Y=20,Se="text-(--text-color-primary)";function Pp(){switch(__CLIENT_CONFIG__.modeName){case"docker":return s.jsx(Sp,{className:Se,width:Y,height:Y});case"cli":return s.jsx(kp,{className:Se,width:Y,height:Y});default:return s.jsx(Ep,{className:Se,width:Y,height:Y})}}const Mp=({dataSource:e})=>s.jsxs("button",{className:O.navItem,onClick:()=>Nn(e.id),"data-tooltip-id":"default","data-tooltip-content":e.name,"data-tooltip-place":"right",children:[s.jsx("span",{className:O.icon,children:s.jsx(He,{size:20,type:e.dbType})}),s.jsx("span",{className:"truncate",children:e.name})]}),Op=()=>{const e=J(),{pathname:t}=fe(),{data:n}=ve(),o=Tn("Desktop nav"),[a,r]=l.useState(!1),{data:i}=bs(),{data:c}=rc(n?.teamId),u=()=>{D.home.check(t)||e(D.home.build())},h=b=>{D.workbenchTab.check(t)||e(D.workbenchTab.build({id:b}))},m=()=>{In({show:!0})},d=()=>{mo("Are you sure you want to logout?").then(b=>{b&&(e("/"),hs.logout())})},x=()=>jn({show:!0}),p=a?void 0:"default";return s.jsxs("nav",{className:I(O.nav,a?O.shown:O.hidden),children:[n&&s.jsxs("div",{className:O.header,children:[s.jsxs("button",{onClick:u,className:O.navItem,"data-tooltip-id":p,"data-tooltip-content":"Home",children:[s.jsx("span",{className:O.icon,children:s.jsx(Lp,{className:Se,width:Y,height:Y})}),s.jsx("span",{className:"truncate",children:"Home"})]}),s.jsxs("button",{onClick:o,className:O.navItem,"data-tooltip-id":p,"data-tooltip-content":"New query",children:[s.jsx("span",{className:O.icon,children:s.jsx(tn,{className:Se,width:Y,height:Y})}),s.jsx("span",{className:"truncate",children:"New query"}),s.jsx("span",{className:"hotkey secondary",children:"N"})]}),s.jsxs("button",{onClick:x,className:O.navItem,"data-tooltip-id":p,"data-tooltip-content":"Recent tabs",children:[s.jsx("span",{className:O.icon,children:s.jsx(ra,{className:Se,width:Y,height:Y})}),s.jsx("span",{className:"truncate",children:"Recent tabs"}),s.jsx("span",{className:"hotkey secondary",children:"H"})]}),s.jsxs("button",{onClick:m,className:O.navItem,"data-tooltip-id":p,"data-tooltip-content":"Saved queries",children:[s.jsx("span",{className:O.icon,children:s.jsx(Ip,{className:Se,width:Y,height:Y})}),s.jsx("span",{className:"truncate",children:"Saved queries"})]}),ge(i?.length,0)&&s.jsxs("button",{onClick:()=>h(i[0].id),className:O.navItem,"data-tooltip-id":p,"data-tooltip-content":"Workbench",children:[s.jsx("span",{className:O.icon,children:s.jsx(aa,{className:Se,width:Y,height:Y})}),s.jsx("span",{className:"truncate",children:"Workbench"}),s.jsx("span",{className:"hotkey secondary",children:"W"})]}),wr&&s.jsxs(s.Fragment,{children:[s.jsxs("button",{onClick:Ha,className:O.navItem,"data-tooltip-id":p,"data-tooltip-content":"User settings",children:[s.jsx("span",{className:O.icon,children:s.jsx(Tp,{className:Se,width:Y,height:Y})}),s.jsx("span",{className:"truncate",children:n.username})]}),s.jsxs("button",{onClick:Va,className:O.navItem,"data-tooltip-id":p,"data-tooltip-content":"Manage users",children:[s.jsx("span",{className:O.icon,children:s.jsx(Ap,{className:Se,width:Y,height:Y})}),s.jsx("span",{className:"truncate",children:"Manage users"})]})]})]}),s.jsx("div",{className:I(O.projectWrapper),children:ge(c?.length,0)&&s.jsx("div",{className:"mt-4 flex flex-col",children:c.map(b=>s.jsx(Mp,{dataSource:b},b.id))})}),wr&&s.jsxs("button",{onClick:d,"data-tooltip-id":p,"data-tooltip-content":"Logout",className:`${O.navItem} mx-1`,children:[s.jsx("span",{className:O.icon,children:s.jsx(Rp,{className:Se,width:20,height:20})}),s.jsx("span",{className:"truncate text-sm text-(--text-color-primary)",children:"Logout"})]}),s.jsxs("div",{className:`${O.navItem} mx-1 cursor-auto!`,"data-tooltip-id":p,"data-tooltip-content":Cr,children:[s.jsx("span",{className:O.icon,children:s.jsx(Pp,{})}),s.jsx("span",{className:"truncate text-sm text-(--text-color-primary)",children:Cr})]}),s.jsxs("button",{onClick:()=>r(!a),"data-tooltip-id":"default","data-tooltip-content":"Expand sidebar","data-tooltip-hidden":a,"data-tooltip-place":"right",className:`${O.navItem} mx-1`,children:[s.jsx("span",{className:I(O.icon,O.expand,a?O.show:O.hide),children:s.jsx(Sn,{className:Se,width:20,height:20})}),s.jsx("span",{className:"truncate text-sm text-(--text-color-primary)",children:"Collapse menu"})]})]})},Dp="_root_1odkp_2",$p={root:Dp},Ka=!__CLIENT_CONFIG__.skipAuth,Fp=`${$p.root} ${Ka?"grid-cols-4":"grid-cols-2"}`,Bp=()=>{const{pathname:e}=fe(),t=J(),n=Tn("Mobile nav"),o=()=>{D.home.check(e)||t(D.home.build())};return s.jsxs("div",{className:Fp,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"})]}),Ka&&s.jsxs(s.Fragment,{children:[s.jsxs("button",{onClick:Ha,children:[s.jsx("p",{children:"🪪"}),s.jsx("p",{className:"text-xs font-semibold text-gray-600",children:"Account"})]}),s.jsxs("button",{onClick:Va,children:[s.jsx("p",{children:"👥"}),s.jsx("p",{className:"text-xs font-semibold text-gray-600",children:"Users"})]})]})]})},Wp=({children:e,isLogin:t})=>s.jsxs("div",{className:O.desktopLayout,children:[s.jsx(us,{id:"default",className:"z-100"}),s.jsx(us,{id:"default-xs",className:"z-100 text-xs!"}),!t&&s.jsx(Op,{}),s.jsx("main",{className:O.main,children:e})]}),qp=({children:e,isLogin:t})=>s.jsxs("div",{className:O.mobileLayout,children:[s.jsx("main",{className:O.main,children:e}),!t&&s.jsx(Bp,{})]}),Up=({children:e})=>{const t=da(fo.laptop),{pathname:n}=fe(),o=D.login.check(n);return t?s.jsx(Wp,{isLogin:o,children:e}):s.jsx(qp,{isLogin:o,children:e})};ci.createRoot(document.getElementById("root")).render(s.jsxs(nt.StrictMode,{children:[s.jsx(ui,{}),s.jsx(Kl,{client:K,children:s.jsx(Il,{children:s.jsx(Up,{children:s.jsx(hp,{})})})})]}));
3
+ Please change the parent <Route path="${f}"> to <Route path="${f==="/"?"*":`${f}/*`}">.`)}let x=fe(),p;if(t){let f=typeof t=="string"?Jt(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.`),p=f}else p=x;let b=p.pathname||"/",g=b;if(m!=="/"){let f=m.replace(/^\//,"").split("/");g="/"+b.replace(/^\//,"").split("/").slice(f.length).join("/")}let v=Nr(e,{pathname:g});Ee(d||v!=null,`No routes matched location "${p.pathname}${p.search}${p.hash}" `),Ee(v==null||v[v.length-1].route.element!==void 0||v[v.length-1].route.Component!==void 0||v[v.length-1].route.lazy!==void 0,`Matched leaf route at location "${p.pathname}${p.search}${p.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let y=Zi(v&&v.map(f=>Object.assign({},f,{params:Object.assign({},u,f.params),pathname:Ge([m,r.encodeLocation?r.encodeLocation(f.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:f.pathname]),pathnameBase:f.pathnameBase==="/"?m:Ge([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(En.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...p},navigationType:"POP"}},y):y}function Gi(){let e=ol(),t=Mi(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,o="rgba(200,200,200, 0.5)",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 Yi=l.createElement(Gi,null),$r=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=Hi(e.digest);n&&(e=n)}let t=e!==void 0?l.createElement(Ue.Provider,{value:this.props.routeContext},l.createElement(Zs.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?l.createElement(Ji,{error:e},t):t}};$r.contextType=$i;var Ls=new WeakMap;function Ji({children:e,error:t}){let{basename:n}=l.useContext(Re);if(typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){let o=Ui(t.digest);if(o){let a=Ls.get(t);if(a)throw a;let r=Tr(o.location,n);if(Lr&&!Ls.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 Ls.set(t,i),i}return l.createElement("meta",{httpEquiv:"refresh",content:`0;url=${r.absoluteURL||r.to}`})}}return e}function Xi({routeContext:e,match:t,children:n}){let o=l.useContext(Xt);return o&&o.static&&o.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(o.staticContext._deepestRenderedBoundaryId=t.route.id),l.createElement(Ue.Provider,{value:e},n)}function Zi(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(d=>d.route.id&&i?.[d.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 d=r[m];if((d.route.HydrateFallback||d.route.hydrateFallbackElement)&&(u=m),d.route.id){let{loaderData:x,errors:p}=n,b=d.route.loader&&!x.hasOwnProperty(d.route.id)&&(!p||p[d.route.id]===void 0);if(d.route.lazy||b){c=!0,u>=0?r=r.slice(0,u+1):r=[r[0]];break}}}let h=n&&o?(m,d)=>{o(m,{location:n.location,params:n.matches?.[0]?.params??{},unstable_pattern:Oi(n.matches),errorInfo:d})}:void 0;return r.reduceRight((m,d,x)=>{let p,b=!1,g=null,v=null;n&&(p=i&&d.route.id?i[d.route.id]:void 0,g=d.route.errorElement||Yi,c&&(u<0&&x===0?(Fr("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),b=!0,v=null):u===x&&(b=!0,v=d.route.hydrateFallbackElement||null)));let y=t.concat(r.slice(0,x+1)),f=()=>{let w;return p?w=g:b?w=v:d.route.Component?w=l.createElement(d.route.Component,null):d.route.element?w=d.route.element:w=m,l.createElement(Xi,{match:d,routeContext:{outlet:m,matches:y,isDataRoute:n!=null},children:w})};return n&&(d.route.ErrorBoundary||d.route.errorElement||x===0)?l.createElement($r,{location:n.location,revalidation:n.revalidation,component:g,error:p,children:f(),routeContext:{outlet:null,matches:y,isDataRoute:!0},onError:h}):f()},null)}function eo(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function el(e){let t=l.useContext(Xt);return z(t,eo(e)),t}function tl(e){let t=l.useContext(ms);return z(t,eo(e)),t}function nl(e){let t=l.useContext(Ue);return z(t,eo(e)),t}function to(e){let t=nl(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 sl(){return to("useRouteId")}function ol(){let e=l.useContext(Zs),t=tl("useRouteError"),n=to("useRouteError");return e!==void 0?e:t.errors?.[n]}function rl(){let{router:e}=el("useNavigate"),t=to("useNavigate"),n=l.useRef(!1);return Or(()=>{n.current=!0}),l.useCallback(async(a,r={})=>{Ee(n.current,Mr),n.current&&(typeof a=="number"?await e.navigate(a):await e.navigate(a,{fromRouteId:t,...r}))},[e,t])}var qo={};function Fr(e,t,n){!t&&!qo[e]&&(qo[e]=!0,Ee(!1,n))}l.memo(al);function al({routes:e,future:t,state:n,onError:o}){return Dr(e,void 0,n,o,t)}function Ht(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 il({basename:e="/",children:t=null,location:n,navigationType:o="POP",navigator:a,static:r=!1,unstable_useTransitions:i}){z(!Rn(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let c=e.replace(/^\/*/,"/"),u=l.useMemo(()=>({basename:c,navigator:a,static:r,unstable_useTransitions:i,future:{}}),[c,a,r,i]);typeof n=="string"&&(n=Jt(n));let{pathname:h="/",search:m="",hash:d="",state:x=null,key:p="default"}=n,b=l.useMemo(()=>{let g=Ye(h,c);return g==null?null:{location:{pathname:g,search:m,hash:d,state:x,key:p},navigationType:o}},[c,h,m,d,x,p,o]);return Ee(b!=null,`<Router basename="${c}"> is not able to match the URL "${h}${m}${d}" because it does not start with the basename, so the <Router> won't render anything.`),b==null?null:l.createElement(Re.Provider,{value:u},l.createElement(En.Provider,{children:t,value:b}))}function ll({children:e,location:t}){return Ki(Hs(e),t)}function Hs(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,Hs(o.props.children,r));return}z(o.type===Ht,`[${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=Hs(o.props.children,r)),n.push(i)}),n}var Xn="get",Zn="application/x-www-form-urlencoded";function fs(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function cl(e){return fs(e)&&e.tagName.toLowerCase()==="button"}function ul(e){return fs(e)&&e.tagName.toLowerCase()==="form"}function dl(e){return fs(e)&&e.tagName.toLowerCase()==="input"}function hl(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function ml(e,t){return e.button===0&&(!t||t==="_self")&&!hl(e)}function zs(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 fl(e,t){let n=zs(e);return t&&t.forEach((o,a)=>{n.has(a)||t.getAll(a).forEach(r=>{n.append(a,r)})}),n}var Gn=null;function pl(){if(Gn===null)try{new FormData(document.createElement("form"),0),Gn=!1}catch{Gn=!0}return Gn}var xl=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Ts(e){return e!=null&&!xl.has(e)?(Ee(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Zn}"`),null):e}function gl(e,t){let n,o,a,r,i;if(ul(e)){let c=e.getAttribute("action");o=c?Ye(c,t):null,n=e.getAttribute("method")||Xn,a=Ts(e.getAttribute("enctype"))||Zn,r=new FormData(e)}else if(cl(e)||dl(e)&&(e.type==="submit"||e.type==="image")){let c=e.form;if(c==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let u=e.getAttribute("formaction")||c.getAttribute("action");if(o=u?Ye(u,t):null,n=e.getAttribute("formmethod")||c.getAttribute("method")||Xn,a=Ts(e.getAttribute("formenctype"))||Ts(c.getAttribute("enctype"))||Zn,r=new FormData(c,e),!pl()){let{name:h,type:m,value:d}=e;if(m==="image"){let x=h?`${h}.`:"";r.append(`${x}x`,"0"),r.append(`${x}y`,"0")}else h&&r.append(h,d)}}else{if(fs(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=Xn,o=null,a=Zn,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 no(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function bl(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 vl(e,t){if(e.id in t)return t[e.id];try{let n=await import(e.module);return t[e.id]=n,n}catch(n){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(n),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function yl(e){return e==null?!1:e.href==null?e.rel==="preload"&&typeof e.imageSrcSet=="string"&&typeof e.imageSizes=="string":typeof e.rel=="string"&&typeof e.href=="string"}async function wl(e,t,n){let o=await Promise.all(e.map(async a=>{let r=t.routes[a.route.id];if(r){let i=await vl(r,n);return i.links?i.links():[]}return[]}));return _l(o.flat(1).filter(yl).filter(a=>a.rel==="stylesheet"||a.rel==="preload").map(a=>a.rel==="stylesheet"?{...a,rel:"prefetch",as:"style"}:{...a,rel:"prefetch"}))}function Wo(e,t,n,o,a,r){let i=(u,h)=>n[h]?u.route.id!==n[h].route.id:!0,c=(u,h)=>n[h].pathname!==u.pathname||n[h].route.path?.endsWith("*")&&n[h].params["*"]!==u.params["*"];return r==="assets"?t.filter((u,h)=>i(u,h)||c(u,h)):r==="data"?t.filter((u,h)=>{let m=o.routes[u.route.id];if(!m||!m.hasLoader)return!1;if(i(u,h)||c(u,h))return!0;if(u.route.shouldRevalidate){let d=u.route.shouldRevalidate({currentUrl:new URL(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 d=="boolean")return d}return!0}):[]}function Cl(e,t,{includeHydrateFallback:n}={}){return jl(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 jl(e){return[...new Set(e)]}function Nl(e){let t={},n=Object.keys(e).sort();for(let o of n)t[o]=e[o];return t}function _l(e,t){let n=new Set;return new Set(t),e.reduce((o,a)=>{let r=JSON.stringify(Nl(a));return n.has(r)||(n.add(r),o.push({key:r,link:a})),o},[])}function Br(){let e=l.useContext(Xt);return no(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function Sl(){let e=l.useContext(ms);return no(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var so=l.createContext(void 0);so.displayName="FrameworkContext";function qr(){let e=l.useContext(so);return no(e,"You must render this element inside a <HydratedRouter> element"),e}function kl(e,t){let n=l.useContext(so),[o,a]=l.useState(!1),[r,i]=l.useState(!1),{onFocus:c,onBlur:u,onMouseEnter:h,onMouseLeave:m,onTouchStart:d}=t,x=l.useRef(null);l.useEffect(()=>{if(e==="render"&&i(!0),e==="viewport"){let g=y=>{y.forEach(f=>{i(f.isIntersecting)})},v=new IntersectionObserver(g,{threshold:.5});return x.current&&v.observe(x.current),()=>{v.disconnect()}}},[e]),l.useEffect(()=>{if(o){let g=setTimeout(()=>{i(!0)},100);return()=>{clearTimeout(g)}}},[o]);let p=()=>{a(!0)},b=()=>{a(!1),i(!1)};return n?e!=="intent"?[r,x,{}]:[r,x,{onFocus:pn(c,p),onBlur:pn(u,b),onMouseEnter:pn(h,p),onMouseLeave:pn(m,b),onTouchStart:pn(d,p)}]:[!1,x,{}]}function pn(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function El({page:e,...t}){let{router:n}=Br(),o=l.useMemo(()=>Nr(n.routes,e,n.basename),[n.routes,e,n.basename]);return o?l.createElement(Ll,{page:e,matches:o,...t}):null}function Rl(e){let{manifest:t,routeModules:n}=qr(),[o,a]=l.useState([]);return l.useEffect(()=>{let r=!1;return wl(e,t,n).then(i=>{r||a(i)}),()=>{r=!0}},[e,t,n]),o}function Ll({page:e,matches:t,...n}){let o=fe(),{future:a,manifest:r,routeModules:i}=qr(),{basename:c}=Br(),{loaderData:u,matches:h}=Sl(),m=l.useMemo(()=>Wo(e,t,h,r,o,"data"),[e,t,h,r,o]),d=l.useMemo(()=>Wo(e,t,h,r,o,"assets"),[e,t,h,r,o]),x=l.useMemo(()=>{if(e===o.pathname+o.search+o.hash)return[];let g=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:g.add(f.route.id))}),g.size===0)return[];let y=bl(e,c,a.unstable_trailingSlashAwareDataRequests,"data");return v&&g.size>0&&y.searchParams.set("_routes",t.filter(f=>g.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]),p=l.useMemo(()=>Cl(d,r),[d,r]),b=Rl(d);return l.createElement(l.Fragment,null,x.map(g=>l.createElement("link",{key:g,rel:"prefetch",as:"fetch",href:g,...n})),p.map(g=>l.createElement("link",{key:g,rel:"modulepreload",href:g,...n})),b.map(({key:g,link:v})=>l.createElement("link",{key:g,nonce:n.nonce,...v})))}function Tl(...e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}var Al=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{Al&&(window.__reactRouterVersion="7.12.0")}catch{}function Il({basename:e,children:t,unstable_useTransitions:n,window:o}){let a=l.useRef();a.current==null&&(a.current=di({window:o,v5Compat:!0}));let r=a.current,[i,c]=l.useState({action:r.action,location:r.location}),u=l.useCallback(h=>{n===!1?c(h):l.startTransition(()=>c(h))},[n]);return l.useLayoutEffect(()=>r.listen(u),[r,u]),l.createElement(il,{basename:e,children:t,location:i.location,navigationType:i.action,navigator:r,unstable_useTransitions:n})}var Wr=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Ur=l.forwardRef(function({onClick:t,discover:n="render",prefetch:o="none",relative:a,reloadDocument:r,replace:i,state:c,target:u,to:h,preventScrollReset:m,viewTransition:d,unstable_defaultShouldRevalidate:x,...p},b){let{basename:g,unstable_useTransitions:v}=l.useContext(Re),y=typeof h=="string"&&Wr.test(h),f=Tr(h,g);h=f.to;let w=zi(h,{relative:a}),[C,_,A]=kl(o,p),S=Dl(h,{replace:i,state:c,target:u,preventScrollReset:m,relative:a,viewTransition:d,unstable_defaultShouldRevalidate:x,unstable_useTransitions:v});function P(k){t&&t(k),k.defaultPrevented||S(k)}let j=l.createElement("a",{...p,...A,href:f.absoluteURL||w,onClick:f.isExternal||r?t:P,ref:Tl(b,_),target:u,"data-discover":!y&&n==="render"?"true":void 0});return C&&!y?l.createElement(l.Fragment,null,j,l.createElement(El,{page:w})):j});Ur.displayName="Link";var Pl=l.forwardRef(function({"aria-current":t="page",caseSensitive:n=!1,className:o="",end:a=!1,style:r,to:i,viewTransition:c,children:u,...h},m){let d=Ln(i,{relative:h.relative}),x=fe(),p=l.useContext(ms),{navigator:b,basename:g}=l.useContext(Re),v=p!=null&&Ul(d)&&c===!0,y=b.encodeLocation?b.encodeLocation(d).pathname:d.pathname,f=x.pathname,w=p&&p.navigation&&p.navigation.location?p.navigation.location.pathname:null;n||(f=f.toLowerCase(),w=w?w.toLowerCase():null,y=y.toLowerCase()),w&&g&&(w=Ye(w,g)||w);const C=y!=="/"&&y.endsWith("/")?y.length-1:y.length;let _=f===y||!a&&f.startsWith(y)&&f.charAt(C)==="/",A=w!=null&&(w===y||!a&&w.startsWith(y)&&w.charAt(y.length)==="/"),S={isActive:_,isPending:A,isTransitioning:v},P=_?t:void 0,j;typeof o=="function"?j=o(S):j=[o,_?"active":null,A?"pending":null,v?"transitioning":null].filter(Boolean).join(" ");let k=typeof r=="function"?r(S):r;return l.createElement(Ur,{...h,"aria-current":P,className:j,ref:m,style:k,to:i,viewTransition:c},typeof u=="function"?u(S):u)});Pl.displayName="NavLink";var Ml=l.forwardRef(({discover:e="render",fetcherKey:t,navigate:n,reloadDocument:o,replace:a,state:r,method:i=Xn,action:c,onSubmit:u,relative:h,preventScrollReset:m,viewTransition:d,unstable_defaultShouldRevalidate:x,...p},b)=>{let{unstable_useTransitions:g}=l.useContext(Re),v=ql(),y=Wl(c,{relative:h}),f=i.toLowerCase()==="get"?"get":"post",w=typeof c=="string"&&Wr.test(c),C=_=>{if(u&&u(_),_.defaultPrevented)return;_.preventDefault();let A=_.nativeEvent.submitter,S=A?.getAttribute("formmethod")||i,P=()=>v(A||_.currentTarget,{fetcherKey:t,method:S,navigate:n,replace:a,state:r,relative:h,preventScrollReset:m,viewTransition:d,unstable_defaultShouldRevalidate:x});g&&n!==!1?l.startTransition(()=>P()):P()};return l.createElement("form",{ref:b,method:f,action:y,onSubmit:o?u:C,...p,"data-discover":!w&&e==="render"?"true":void 0})});Ml.displayName="Form";function Ol(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Hr(e){let t=l.useContext(Xt);return z(t,Ol(e)),t}function Dl(e,{target:t,replace:n,state:o,preventScrollReset:a,relative:r,viewTransition:i,unstable_defaultShouldRevalidate:c,unstable_useTransitions:u}={}){let h=J(),m=fe(),d=Ln(e,{relative:r});return l.useCallback(x=>{if(ml(x,t)){x.preventDefault();let p=n!==void 0?n:Cn(m)===Cn(d),b=()=>h(e,{replace:p,state:o,preventScrollReset:a,relative:r,viewTransition:i,unstable_defaultShouldRevalidate:c});u?l.startTransition(()=>b()):b()}},[m,h,d,n,o,t,e,a,r,i,c,u])}function $l(e){Ee(typeof URLSearchParams<"u","You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.");let t=l.useRef(zs(e)),n=l.useRef(!1),o=fe(),a=l.useMemo(()=>fl(o.search,n.current?null:t.current),[o.search]),r=J(),i=l.useCallback((c,u)=>{const h=zs(typeof c=="function"?c(new URLSearchParams(a)):c);n.current=!0,r("?"+h,u)},[r,a]);return[a,i]}var Fl=0,Bl=()=>`__${String(++Fl)}__`;function ql(){let{router:e}=Hr("useSubmit"),{basename:t}=l.useContext(Re),n=sl(),o=e.fetch,a=e.navigate;return l.useCallback(async(r,i={})=>{let{action:c,method:u,encType:h,formData:m,body:d}=gl(r,t);if(i.navigate===!1){let x=i.fetcherKey||Bl();await o(x,n,i.action||c,{unstable_defaultShouldRevalidate:i.unstable_defaultShouldRevalidate,preventScrollReset:i.preventScrollReset,formData:m,body:d,formMethod:i.method||u,formEncType:i.encType||h,flushSync:i.flushSync})}else await a(i.action||c,{unstable_defaultShouldRevalidate:i.unstable_defaultShouldRevalidate,preventScrollReset:i.preventScrollReset,formData:m,body:d,formMethod:i.method||u,formEncType:i.encType||h,replace:i.replace,state:i.state,fromRouteId:n,flushSync:i.flushSync,viewTransition:i.viewTransition})},[o,a,t,n])}function Wl(e,{relative:t}={}){let{basename:n}=l.useContext(Re),o=l.useContext(Ue);z(o,"useFormAction must be used inside a RouteContext");let[a]=o.matches.slice(-1),r={...Ln(e||".",{relative:t})},i=fe();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(d=>d).forEach(d=>c.append("index",d));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:Ge([n,r.pathname])),Cn(r)}function Ul(e,{relative:t}={}){let n=l.useContext(Ir);z(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:o}=Hr("useViewTransitionState"),a=Ln(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 Kt(a.pathname,i)!=null||Kt(a.pathname,r)!=null}var oo=Xa(),zr=class extends jr{constructor(e,t){super(),this.options=t,this.#n=e,this.#i=null,this.#a=Ao(),this.bindMethods(),this.setOptions(t)}#n;#e=void 0;#s=void 0;#t=void 0;#o;#r;#a;#i;#p;#h;#m;#c;#u;#l;#f=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#e.addObserver(this),Uo(this.#e,this.options)?this.#d():this.updateResult(),this.#v())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Vs(this.#e,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Vs(this.#e,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#y(),this.#w(),this.#e.removeObserver(this)}setOptions(e){const t=this.options,n=this.#e;if(this.options=this.#n.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Te(this.options.enabled,this.#e)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#C(),this.#e.setOptions(this.options),t._defaulted&&!os(this.options,t)&&this.#n.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#e,observer:this});const o=this.hasListeners();o&&Ho(this.#e,n,this.options,t)&&this.#d(),this.updateResult(),o&&(this.#e!==n||Te(this.options.enabled,this.#e)!==Te(t.enabled,this.#e)||wn(this.options.staleTime,this.#e)!==wn(t.staleTime,this.#e))&&this.#x();const a=this.#g();o&&(this.#e!==n||Te(this.options.enabled,this.#e)!==Te(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 zl(this,n)&&(this.#t=n,this.#r=this.options,this.#o=this.#e.state),n}getCurrentResult(){return this.#t}trackResult(e,t){return new Proxy(e,{get:(n,o)=>(this.trackProp(o),t?.(o),o==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&this.#a.status==="pending"&&this.#a.reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(n,o))})}trackProp(e){this.#f.add(e)}getCurrentQuery(){return this.#e}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const t=this.#n.defaultQueryOptions(e),n=this.#n.getQueryCache().build(this.#n,t);return n.fetch().then(()=>this.createResult(n,t))}fetch(e){return this.#d({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#t))}#d(e){this.#C();let t=this.#e.fetch(this.options,e);return e?.throwOnError||(t=t.catch(rs)),t}#x(){this.#y();const e=wn(this.options.staleTime,this.#e);if(Ws||this.#t.isStale||!Io(e))return;const n=Za(this.#t.dataUpdatedAt,e)+1;this.#c=Kn.setTimeout(()=>{this.#t.isStale||this.updateResult()},n)}#g(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#e):this.options.refetchInterval)??!1}#b(e){this.#w(),this.#l=e,!(Ws||Te(this.options.enabled,this.#e)===!1||!Io(this.#l)||this.#l===0)&&(this.#u=Kn.setInterval(()=>{(this.options.refetchIntervalInBackground||ei.isFocused())&&this.#d()},this.#l))}#v(){this.#x(),this.#b(this.#g())}#y(){this.#c&&(Kn.clearTimeout(this.#c),this.#c=void 0)}#w(){this.#u&&(Kn.clearInterval(this.#u),this.#u=void 0)}createResult(e,t){const n=this.#e,o=this.options,a=this.#t,r=this.#o,i=this.#r,u=e!==n?e.state:this.#s,{state:h}=e;let m={...h},d=!1,x;if(t._optimisticResults){const P=this.hasListeners(),j=!P&&Uo(e,t),k=P&&Ho(e,n,t,o);(j||k)&&(m={...m,...ti(h.data,e.options)}),t._optimisticResults==="isRestoring"&&(m.fetchStatus="idle")}let{error:p,errorUpdatedAt:b,status:g}=m;x=m.data;let v=!1;if(t.placeholderData!==void 0&&x===void 0&&g==="pending"){let P;a?.isPlaceholderData&&t.placeholderData===i?.placeholderData?(P=a.data,v=!0):P=typeof t.placeholderData=="function"?t.placeholderData(this.#m?.state.data,this.#m):t.placeholderData,P!==void 0&&(g="success",x=Po(a?.data,P,t),d=!0)}if(t.select&&x!==void 0&&!v)if(a&&x===r?.data&&t.select===this.#p)x=this.#h;else try{this.#p=t.select,x=t.select(x),x=Po(a?.data,x,t),this.#h=x,this.#i=null}catch(P){this.#i=P}this.#i&&(p=this.#i,x=this.#h,b=Date.now(),g="error");const y=m.fetchStatus==="fetching",f=g==="pending",w=g==="error",C=f&&y,_=x!==void 0,S={status:g,fetchStatus:m.fetchStatus,isPending:f,isSuccess:g==="success",isError:w,isInitialLoading:C,isLoading:C,data:x,dataUpdatedAt:m.dataUpdatedAt,error:p,errorUpdatedAt:b,failureCount:m.fetchFailureCount,failureReason:m.fetchFailureReason,errorUpdateCount:m.errorUpdateCount,isFetched:m.dataUpdateCount>0||m.errorUpdateCount>0,isFetchedAfterMount:m.dataUpdateCount>u.dataUpdateCount||m.errorUpdateCount>u.errorUpdateCount,isFetching:y,isRefetching:y&&!f,isLoadingError:w&&!_,isPaused:m.fetchStatus==="paused",isPlaceholderData:d,isRefetchError:w&&_,isStale:ro(e,t),refetch:this.refetch,promise:this.#a,isEnabled:Te(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){const P=X=>{S.status==="error"?X.reject(S.error):S.data!==void 0&&X.resolve(S.data)},j=()=>{const X=this.#a=S.promise=Ao();P(X)},k=this.#a;switch(k.status){case"pending":e.queryHash===n.queryHash&&P(k);break;case"fulfilled":(S.status==="error"||S.data!==k.value)&&j();break;case"rejected":(S.status!=="error"||S.error!==k.reason)&&j();break}}return S}updateResult(){const e=this.#t,t=this.createResult(this.#e,this.options);if(this.#o=this.#e.state,this.#r=this.options,this.#o.data!==void 0&&(this.#m=this.#e),os(t,e))return;this.#t=t;const n=()=>{if(!e)return!0;const{notifyOnChangeProps:o}=this.options,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){ds.batch(()=>{e.listeners&&this.listeners.forEach(t=>{t(this.#t)}),this.#n.getQueryCache().notify({query:this.#e,type:"observerResultsUpdated"})})}};function Hl(e,t){return Te(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function Uo(e,t){return Hl(e,t)||e.state.data!==void 0&&Vs(e,t,t.refetchOnMount)}function Vs(e,t,n){if(Te(t.enabled,e)!==!1&&wn(t.staleTime,e)!=="static"){const o=typeof n=="function"?n(e):n;return o==="always"||o!==!1&&ro(e,t)}return!1}function Ho(e,t,n,o){return(e!==t||Te(o.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&ro(e,n)}function ro(e,t){return Te(t.enabled,e)!==!1&&e.isStaleByTime(wn(t.staleTime,e))}function zl(e,t){return!os(e.getCurrentResult(),t)}var Vl=class extends zr{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){super.setOptions({...e,behavior:Mo()})}getOptimisticResult(e){return e.behavior=Mo(),super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"backward"}}})}createResult(e,t){const{state:n}=e,o=super.createResult(e,t),{isFetching:a,isRefetching:r,isError:i,isRefetchError:c}=o,u=n.fetchMeta?.fetchMore?.direction,h=i&&u==="forward",m=a&&u==="forward",d=i&&u==="backward",x=a&&u==="backward";return{...o,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:si(t,n.data),hasPreviousPage:ni(t,n.data),isFetchNextPageError:h,isFetchingNextPage:m,isFetchPreviousPageError:d,isFetchingPreviousPage:x,isRefetchError:c&&!h&&!d,isRefetching:r&&!m&&!x}}},Ql=class extends jr{#n;#e=void 0;#s;#t;constructor(t,n){super(),this.#n=t,this.setOptions(n),this.bindMethods(),this.#o()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){const n=this.options;this.options=this.#n.defaultMutationOptions(t),os(this.options,n)||this.#n.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#s,observer:this}),n?.mutationKey&&this.options.mutationKey&&Oo(n.mutationKey)!==Oo(this.options.mutationKey)?this.reset():this.#s?.state.status==="pending"&&this.#s.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#s?.removeObserver(this)}onMutationUpdate(t){this.#o(),this.#r(t)}getCurrentResult(){return this.#e}reset(){this.#s?.removeObserver(this),this.#s=void 0,this.#o(),this.#r()}mutate(t,n){return this.#t=n,this.#s?.removeObserver(this),this.#s=this.#n.getMutationCache().build(this.#n,this.options),this.#s.addObserver(this),this.#s.execute(t)}#o(){const t=this.#s?.state??oi();this.#e={...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset}}#r(t){ds.batch(()=>{if(this.#t&&this.hasListeners()){const n=this.#e.variables,o=this.#e.context,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)})})}},Vr=l.createContext(void 0),Qr=e=>{const t=l.useContext(Vr);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},Kl=({client:e,children:t})=>(l.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),s.jsx(Vr.Provider,{value:e,children:t})),Kr=l.createContext(!1),Gl=()=>l.useContext(Kr);Kr.Provider;function Yl(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var Jl=l.createContext(Yl()),Xl=()=>l.useContext(Jl),Zl=(e,t,n)=>{const o=n?.state.error&&typeof e.throwOnError=="function"?Xs(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||o)&&(t.isReset()||(e.retryOnMount=!1))},ec=e=>{l.useEffect(()=>{e.clearReset()},[e])},tc=({result:e,errorResetBoundary:t,throwOnError:n,query:o,suspense:a})=>e.isError&&!t.isReset()&&!e.isFetching&&o&&(a&&e.data===void 0||Xs(n,[e.error,o])),nc=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))}},sc=(e,t)=>e.isLoading&&e.isFetching&&!t,oc=(e,t)=>e?.suspense&&t.isPending,zo=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function Gr(e,t,n){const o=Gl(),a=Xl(),r=Qr(),i=r.defaultQueryOptions(e);r.getDefaultOptions().queries?._experimental_beforeQuery?.(i);const c=r.getQueryCache().get(i.queryHash);i._optimisticResults=o?"isRestoring":"optimistic",nc(i),Zl(i,a,c),ec(a);const u=!r.getQueryCache().get(i.queryHash),[h]=l.useState(()=>new t(r,i)),m=h.getOptimisticResult(i),d=!o&&e.subscribed!==!1;if(l.useSyncExternalStore(l.useCallback(x=>{const p=d?h.subscribe(ds.batchCalls(x)):rs;return h.updateResult(),p},[h,d]),()=>h.getCurrentResult(),()=>h.getCurrentResult()),l.useEffect(()=>{h.setOptions(i)},[i,h]),oc(i,m))throw zo(i,h,a);if(tc({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&&!Ws&&sc(m,o)&&(u?zo(i,h,a):c?.promise)?.catch(rs).finally(()=>{h.updateResult()}),i.notifyOnChangeProps?m:h.trackResult(m)}function be(e,t){return Gr(e,zr)}function ee(e,t){const n=Qr(),[o]=l.useState(()=>new Ql(n,e));l.useEffect(()=>{o.setOptions(e)},[o,e]);const a=l.useSyncExternalStore(l.useCallback(i=>o.subscribe(ds.batchCalls(i)),[o]),()=>o.getCurrentResult(),()=>o.getCurrentResult()),r=l.useCallback((i,c)=>{o.mutate(i,c).catch(rs)},[o]);if(a.error&&Xs(o.options.throwOnError,[a.error]))throw a.error;return{...a,mutate:r,mutateAsync:a.mutate}}function Yr(e,t){return Gr(e,Vl)}const it="data-sources",Jr="auth-user",rc=e=>be({queryKey:["project","datasources",e],queryFn:async()=>{const{data:t}=await $.get(`/project/team/${e}/datasources`);return t.data},enabled:!!e}),Zt=e=>{const t=["project","datasources"],n=["project","saved-queries"];return Promise.all([K.invalidateQueries({queryKey:t}),K.invalidateQueries({queryKey:n})])},ac=e=>{const t=["trash","team"];return K.invalidateQueries({queryKey:t})},ic=(e,t)=>be({queryKey:["project",t.teamId,"tables",e,t.selectedDataSources],queryFn:async()=>{const{data:n}=await $.get(`/project/team/${t.teamId}/query`,{params:{size:30,search:e,selectedDataSources:t.selectedDataSources}});return n.data},enabled:!!t.teamId,staleTime:0}),lc=(e,t="",n=30,o)=>Yr({queryKey:["project","tabs-history",e,n,o,t],queryFn:async({pageParam:a})=>{const r=new URLSearchParams;r.set("nameFilter",t),r.set("size",n.toString()),r.set("page",a.toString());const{data:i}=await $.get(`/project/team/${e}/tabs-history?${r.toString()}`);return i},select:({pages:a})=>a.flatMap(r=>r.data),enabled:!!e,initialPageParam:0,getNextPageParam:(a,r)=>{if(a.hasMore)return r.length},staleTime:0}),cc=(e,t="",n=20)=>Yr({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 $.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}}),uc=(e,t=10,n=!1)=>be({queryKey:["project","recent-tabs",e,t,n],queryFn:async()=>{const{data:o}=await $.get(`/project/team/${e}/tabs-history?page=0&size=${t}&archived=${n}`);return o.data},enabled:!!e,staleTime:0}),dc=e=>ee({mutationFn:async()=>{const{data:t}=await $.get(`/project/team/${e}/tabs-history?page=0&size=1&archived=false`);return t.data?.length?t.data[0]:void 0}}),hc=()=>Promise.all([K.invalidateQueries({queryKey:["project","tabs-history"]}),K.invalidateQueries({queryKey:["project","recent-tabs"]})]),mc=4e3,ps=e=>be({queryKey:[it,e],queryFn:async()=>{const{data:t}=await $.get("/data-sources/"+e);return t.data},enabled:!!e,refetchInterval:t=>t.state?.data?.status==="INSPECTING"?mc:!1}),ao=e=>be({queryKey:[it,e.teamId],queryFn:async()=>{const{data:t}=await $.get("/data-sources",{params:e});return t.data},enabled:e.teamId!==void 0}),xs=e=>be({queryKey:[it,e,"inspections"],queryFn:async()=>{const{data:t}=await $.get(`/data-sources/${e}/inspections`);return t.data},enabled:!!e}),fc=e=>K.invalidateQueries({queryKey:[it,e,"inspections"]}),pc=()=>ee({mutationFn:async e=>{const{data:t}=await $.post("/data-sources",e);return t.data},onSuccess:()=>{K.invalidateQueries({queryKey:[it]}),Zt()}}),xc=()=>ee({mutationFn:async({dataSource:e,id:t})=>{const{data:n}=await $.put(`/data-sources/${t}`,e);return n.data},onSuccess:()=>{K.invalidateQueries({queryKey:[it]}),Zt()}}),Xr=()=>ee({mutationFn:async e=>{await $.post(`/data-sources/${e}/inspect`)},onSuccess:(e,t)=>{K.invalidateQueries({queryKey:[it,t]})}}),gc=()=>ee({mutationFn:async e=>{await $.delete(`/data-sources/${e}`)},onSuccess:()=>{K.invalidateQueries({queryKey:[it]}),Zt()}}),Zr=()=>be({queryKey:["accessToken"],queryFn:hs.get}),ve=()=>{const{data:e}=Zr();return be({queryKey:[Jr],queryFn:async()=>{const{data:t}=await $.get("/users");return t.data},enabled:!!e,retry:(t,n)=>ri(n)&&n.code==="ERR_NETWORK"?!1:t<3})},bc=()=>ee({mutationFn:async e=>{const{data:t}=await $.patch("/users",e);return t.data},onSuccess:async e=>{K.setQueryData([Jr],e)}}),vc=()=>ee({mutationFn:async e=>(await $.post("/users",e),!0),onSuccess:()=>{K.invalidateQueries({queryKey:["team-users"]})}}),ye=e=>{const t=new Set;let n=e;const o=c=>(t.add(c),()=>t.delete(c)),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 yc(e,t,n,o){return l.useMemo(()=>({name:n,tabId:o,hooks:e?.result.availableHooks||[],availableJoins:e?.result?.availableJoins||[],allColumns:e?.result.allColumns||[],dataSourceId:t,entities:e?.result.availableEntities||[],getValue:(a,r,i)=>{const c=e?.result.columns?.findIndex(u=>u.table===r&&u.column===i);if(c!=null&&c>-1)return e?.result?.rows[a][c]},getColumnByIndex:a=>e?.result?.columns?.[a],getValueByIndex:(a,r)=>e?.result?.rows[a]?.[r],getColumnType:a=>{const r=e?.result.allColumns.find(i=>i.full===a);if(r)return r.type}}),[e,t,n,o])}function wc(e,t){return l.useMemo(()=>({state:e,setState:t}),[e,t])}function Nt(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 Cc(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=>!!Kt({path:t,end:!0},a)}}function gs(e,t){return{name:e,path:t,build:()=>t,check:n=>n===t}}const jc=gs("Home","/"),Nc=gs("Workbench","/workbench"),_c=gs("Share query","/share"),Sc=gs("Login","/login"),kc=Cc("Workbench tab","/workbench/tab/:id"),D={home:jc,workbench:Nc,share:_c,login:Sc,workbenchTab:kc},io=e=>{K.setQueryData(["workbench-tabs"],t=>e(t||[]))},Ec=(e,t)=>{K.setQueryData(["workbench-tabs",e],n=>n&&t(n))},bs=()=>be({queryKey:["workbench-tabs"],queryFn:async()=>{const{data:e}=await $.get("/workbench-tabs");return e.data}}),Rc=e=>be({queryKey:["workbench-tabs",e],queryFn:async()=>{const{data:t}=await $.get(`/workbench-tabs/${e}`);return t.data}}),Et=()=>ee({mutationFn:async e=>{const{data:t}=await $.post("/workbench-tabs",e);return t.data},onSuccess:async e=>{io(t=>[...t,e])}}),Lc=()=>ee({mutationFn:async e=>(await $.patch(`/workbench-tabs/${e}`,{archived:!0}),e),onMutate:e=>{io(t=>t.filter(n=>n.id!==e))}}),ea=()=>ee({mutationFn:async e=>(await $.patch(`/workbench-tabs/${e}`,{archived:!1}),e),onSuccess:()=>na()}),Tc=()=>ee({mutationFn:async({id:e,payload:t})=>(await $.patch(`/workbench-tabs/${e}`,t),!0),onMutate:({id:e,payload:t})=>{Ec(e,n=>({...n,...t})),io(n=>n.map(o=>o.id!==e?o:{...o,name:t.name||o.name}))}}),Ac=(e,t)=>{const{dataSourceId:n,searchAll:o,table:a,filters:r,joins:i,orderBy:c,groupBy:u,columns:h,aggregations:m,page:d=0,size:x=20}=t;return be({queryKey:["workbench-tab-runner",e,n,a,d,x,r,m,i,c,u,h,o],queryFn:async()=>{const{data:p}=await $.post(`/workbench-tabs/${e}/run`,t);return p.data},retry:1,enabled:!!a&&!!n,placeholderData:ai})},Ic=()=>ee({mutationFn:async e=>{await $.delete(`/workbench-tabs/${e}`)},onSuccess:()=>{na(),hc()}}),ta=e=>K.invalidateQueries({queryKey:["workbench-tab-runner",e]}),na=()=>K.invalidateQueries({queryKey:["workbench-tabs"]}),[Pc,As,Mc]=ye(void 0),Oc=async()=>new Promise(e=>{As({onCancel:()=>{As(void 0),e(void 0)},onConfirm:(t,n,o)=>{As(void 0),e({dsId:o,id:n,type:t})}})}),Tn=e=>{const t=J(),n=Et(),o=ea();return l.useEffect(()=>{n?.data?.id&&t(D.workbenchTab.build({id:n.data.id})),o?.data&&t(D.workbenchTab.build({id:o.data}))},[n.data,o.data]),l.useCallback(()=>{Mc.get()||Oc().then(r=>{r?.type==="table"?n.mutate({name:r.id,opts:Nt({table:r.id,dataSourceId:r.dsId})}):r?.type==="query"?n.mutate({queryId:r.id}):r?.type==="tab"&&o.mutate(r.id)})},[t,e])},sa=[{value:"=",label:"equals"},{value:"<>",label:"not equal"},{value:">",label:"greater than"},{value:">=",label:"greater than or equal"},{value:"<",label:"less than"},{value:"<=",label:"less than or equal"},{value:"LIKE",label:"like"},{value:"NOT LIKE",label:"not like"},{value:"CONTAINS",label:"contains"},{value:"NOT CONTAINS",label:"not contains"},{value:"IN",label:"in list"},{value:"NOT IN",label:"not in list"},{value:"IS NULL",label:"is null"},{value:"IS NOT NULL",label:"is not null"}],Dc=sa.reduce((e,t)=>(e[t.value]=t.label,e),{});sa.reduce((e,t)=>(e[t.label]=t.value,e),{});const en=e=>e.map(t=>({label:Dc[t],value:t}));en(["=","<>",">",">=","<","<=","IN","NOT IN","IS NULL","IS NOT NULL"]);en(["=","<>","LIKE","NOT LIKE","IN","NOT IN","IS NULL","IS NOT NULL","CONTAINS","NOT CONTAINS"]);en(["=","<>","IS NULL","IS NOT NULL"]);en(["=","<>",">",">=","<","<=","IS NULL","IS NOT NULL"]);en(["IS NULL","IS NOT NULL"]);en(["IN","NOT IN"]);const $c=["char","varchar","binary","varbinary","blob","text","enum","set","character","character varying","text","citext","uuid","xml","json","jsonb"];new Set($c);const Fc=["integer","smallint","decimal","numeric","float","real","double precision","int","smallint","integer","bigint","decimal","numeric","real","double precision","serial","bigserial","money"];new Set(Fc);const Bc=["date","datetime","timestamp","timestamptz"].reduce((e,t)=>(e[t]=!0,e),{}),qc=e=>e.fn?e.distinct===!0?`${e.fn} distinct ${e.value}`:`${e.fn} ${e.value}`:e.value;var he=(e=>(e.OWNER="owner",e.ADMIN="admin",e.EDITOR="editor",e.READ_ONLY="read_only",e))(he||{});const Vo={[he.READ_ONLY]:10,[he.EDITOR]:20,[he.ADMIN]:30,[he.OWNER]:40},Wc=e=>`${e.fromTable}.${e.fromColumn} = ${e.toTable}.${e.toColumn}`,An=e=>{const{data:t}=ve();return l.useMemo(()=>t?Vo[t.teamRole]>=Vo[e]:!1,[t,e])},Uc="_input_hm1wo_2",Hc="_label_hm1wo_2",zc="_content_hm1wo_2",Vc="_form_hm1wo_2",Qc="_header_hm1wo_2",Kc="_mode-select_hm1wo_2",Gc="_selected_hm1wo_2",Yc="_mode-container_hm1wo_2",$e={input:Uc,label:Hc,content:zc,form:Vc,header:Qc,modeSelect:Kc,selected:Gc,modeContainer:Yc},Jc="_modal_k3yac_2",Xc="_modal-visible_k3yac_2",Zc="_modal-invisible_k3yac_2",eu="_backdrop_k3yac_2",tu="_modal-container_k3yac_2",nu="_close-button_k3yac_2",zt={modal:Jc,modalVisible:Xc,modalInvisible:Zc,backdrop:eu,modalContainer:tu,closeButton:nu},_t=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32,d:"M368 368L144 144M368 144L144 368"}));let es=[];const su=e=>{const t=Symbol();return es.push({id:t,listener:e}),()=>{es=es.filter(n=>n.id!==t)}};window.addEventListener("keydown",e=>{if(e.key!=="Escape")return;const t=es.pop();t&&(e.preventDefault(),e.stopPropagation(),t.listener())});const vs=e=>{const t=l.useRef(e.onClose);t.current=e.onClose,l.useEffect(()=>{if(e.enabled)return su(()=>{t.current()})},[e.enabled])},we=({children:e,backdropClose:t,isVisible:n,onClose:o,onClosed:a,noPadding:r=!1,portal:i=!1})=>{const[c,u]=l.useState(!1),h=()=>{t&&o()},m=x=>{n||getComputedStyle(x.currentTarget).opacity==="0"&&(u(!1),a&&a())};l.useEffect(()=>{n&&u(!0)},[n]),vs({onClose:h,enabled:n&&t===!0});const d=s.jsxs("div",{onTransitionEnd:m,className:I(zt.modal,n?zt.modalVisible:zt.modalInvisible),children:[s.jsx("div",{onClick:h,className:zt.backdrop}),s.jsx("div",{className:I(zt.modalContainer,r!==!0&&"p-4"),children:c&&e})]});return i?oo.createPortal(d,document.body):d},lt=({onClick:e})=>{const t=l.useRef(e);return t.current=e,s.jsx("button",{className:zt.closeButton,onClick:e,children:s.jsx(_t,{width:20,height:20})})},oa=({children:e})=>s.jsx("h2",{className:"text-xl font-semibold",children:e}),ou=({form:e,change:t,shape:n})=>s.jsx("div",{className:$e.form,children:n.fields.map(o=>s.jsxs("label",{className:$e.input,children:[s.jsx("p",{className:$e.label,children:o.label}),s.jsx("input",{value:e[o.name],onChange:t(o.name),type:o.type})]},o.name))}),ru=e=>l.createElement("svg",{fill:"#000000",width:"800px",height:"800px",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",...e},l.createElement("path",{d:"m24.129 23.412-.508-.484c-.251-.331-.518-.624-.809-.891l-.005-.004q-.448-.407-.931-.774-.387-.266-1.064-.641c-.371-.167-.661-.46-.818-.824l-.004-.01-.048-.024c.212-.021.406-.06.592-.115l-.023.006.57-.157c.236-.074.509-.122.792-.133h.006c.298-.012.579-.06.847-.139l-.025.006q.194-.048.399-.109t.351-.109v-.169q-.145-.217-.351-.496c-.131-.178-.278-.333-.443-.468l-.005-.004q-.629-.556-1.303-1.076c-.396-.309-.845-.624-1.311-.916l-.068-.04c-.246-.162-.528-.312-.825-.435l-.034-.012q-.448-.182-.883-.399c-.097-.048-.21-.09-.327-.119l-.011-.002c-.117-.024-.217-.084-.29-.169l-.001-.001c-.138-.182-.259-.389-.355-.609l-.008-.02q-.145-.339-.314-.651-.363-.702-.702-1.427t-.651-1.452q-.217-.484-.399-.967c-.134-.354-.285-.657-.461-.942l.013.023c-.432-.736-.863-1.364-1.331-1.961l.028.038c-.463-.584-.943-1.106-1.459-1.59l-.008-.007c-.509-.478-1.057-.934-1.632-1.356l-.049-.035q-.896-.651-1.96-1.282c-.285-.168-.616-.305-.965-.393l-.026-.006-1.113-.278-.629-.048q-.314-.024-.629-.024c-.148-.078-.275-.171-.387-.279-.11-.105-.229-.204-.353-.295l-.01-.007c-.605-.353-1.308-.676-2.043-.93l-.085-.026c-.193-.113-.425-.179-.672-.179-.176 0-.345.034-.499.095l.009-.003c-.38.151-.67.458-.795.84l-.003.01c-.073.172-.115.371-.115.581 0 .368.13.705.347.968l-.002-.003q.544.725.834 1.14.217.291.448.605c.141.188.266.403.367.63l.008.021c.056.119.105.261.141.407l.003.016q.048.206.121.448.217.556.411 1.14c.141.425.297.785.478 1.128l-.019-.04q.145.266.291.52t.314.496c.065.098.147.179.241.242l.003.002c.099.072.164.185.169.313v.001c-.114.168-.191.369-.217.586l-.001.006c-.035.253-.085.478-.153.695l.008-.03c-.223.666-.351 1.434-.351 2.231 0 .258.013.512.04.763l-.003-.031c.06.958.349 1.838.812 2.6l-.014-.025c.197.295.408.552.641.787.168.188.412.306.684.306.152 0 .296-.037.422-.103l-.005.002c.35-.126.599-.446.617-.827v-.002c.048-.474.12-.898.219-1.312l-.013.067c.024-.063.038-.135.038-.211 0-.015-.001-.03-.002-.045v.002q-.012-.109.133-.206v.048q.145.339.302.677t.326.677c.295.449.608.841.952 1.202l-.003-.003c.345.372.721.706 1.127 1.001l.022.015c.212.162.398.337.566.528l.004.004c.158.186.347.339.56.454l.01.005v-.024h.048c-.039-.087-.102-.157-.18-.205l-.002-.001c-.079-.044-.147-.088-.211-.136l.005.003q-.217-.217-.448-.484t-.423-.508q-.508-.702-.969-1.467t-.871-1.555q-.194-.387-.375-.798t-.351-.798c-.049-.099-.083-.213-.096-.334v-.005c-.006-.115-.072-.214-.168-.265l-.002-.001c-.121.206-.255.384-.408.545l.001-.001c-.159.167-.289.364-.382.58l-.005.013c-.141.342-.244.739-.289 1.154l-.002.019q-.072.641-.145 1.318l-.048.024-.024.024c-.26-.053-.474-.219-.59-.443l-.002-.005q-.182-.351-.326-.69c-.248-.637-.402-1.374-.423-2.144v-.009c-.009-.122-.013-.265-.013-.408 0-.666.105-1.308.299-1.91l-.012.044q.072-.266.314-.896t.097-.871c-.05-.165-.143-.304-.265-.41l-.001-.001c-.122-.106-.233-.217-.335-.335l-.003-.004q-.169-.244-.326-.52t-.278-.544c-.165-.382-.334-.861-.474-1.353l-.022-.089c-.159-.565-.336-1.043-.546-1.503l.026.064c-.111-.252-.24-.47-.39-.669l.006.008q-.244-.326-.436-.617-.244-.314-.484-.605c-.163-.197-.308-.419-.426-.657l-.009-.02c-.048-.097-.09-.21-.119-.327l-.002-.011c-.011-.035-.017-.076-.017-.117 0-.082.024-.159.066-.223l-.001.002c.011-.056.037-.105.073-.145.039-.035.089-.061.143-.072h.002c.085-.055.188-.088.3-.088.084 0 .165.019.236.053l-.003-.001c.219.062.396.124.569.195l-.036-.013q.459.194.847.375c.298.142.552.292.792.459l-.018-.012q.194.121.387.266t.411.291h.339q.387 0 .822.037c.293.023.564.078.822.164l-.024-.007c.481.143.894.312 1.286.515l-.041-.019q.593.302 1.125.641c.589.367 1.098.743 1.577 1.154l-.017-.014c.5.428.954.867 1.38 1.331l.01.012c.416.454.813.947 1.176 1.464l.031.047c.334.472.671 1.018.974 1.584l.042.085c.081.154.163.343.234.536l.011.033q.097.278.217.57.266.605.57 1.221t.57 1.198l.532 1.161c.187.406.396.756.639 1.079l-.011-.015c.203.217.474.369.778.422l.008.001c.368.092.678.196.978.319l-.047-.017c.143.065.327.134.516.195l.04.011c.212.065.396.151.565.259l-.009-.005c.327.183.604.363.868.559l-.021-.015q.411.302.822.57.194.145.651.423t.484.52c-.114-.004-.249-.007-.384-.007-.492 0-.976.032-1.45.094l.056-.006c-.536.072-1.022.203-1.479.39l.04-.014c-.113.049-.248.094-.388.129l-.019.004c-.142.021-.252.135-.266.277v.001c.061.076.11.164.143.26l.002.006c.034.102.075.19.125.272l-.003-.006c.119.211.247.393.391.561l-.004-.005c.141.174.3.325.476.454l.007.005q.244.194.508.399c.161.126.343.25.532.362l.024.013c.284.174.614.34.958.479l.046.016c.374.15.695.324.993.531l-.016-.011q.291.169.58.375t.556.399c.073.072.137.152.191.239l.003.005c.091.104.217.175.36.193h.003v-.048c-.088-.067-.153-.16-.184-.267l-.001-.004c-.025-.102-.062-.191-.112-.273l.002.004zm-18.576-19.205q-.194 0-.363.012c-.115.008-.222.029-.323.063l.009-.003v.024h.048q.097.145.244.326t.266.351l.387.798.048-.024c.113-.082.2-.192.252-.321l.002-.005c.052-.139.082-.301.082-.469 0-.018 0-.036-.001-.054v.003c-.045-.044-.082-.096-.108-.154l-.001-.003-.081-.182c-.053-.084-.127-.15-.214-.192l-.003-.001c-.094-.045-.174-.102-.244-.169z"})),au=e=>l.createElement("svg",{width:"800px",height:"800px",viewBox:"0 0 32 32",xmlns:"http://www.w3.org/2000/svg",...e},l.createElement("title",null,"file_type_pgsql"),l.createElement("path",{d:"M29.507,18.773a1.378,1.378,0,0,0-1.144-.921,2.619,2.619,0,0,0-.913.051,8.2,8.2,0,0,1-1.406.185,27.125,27.125,0,0,0,2.872-6.83c.953-3.689.444-5.369-.151-6.13A8.239,8.239,0,0,0,22.121,2a11.773,11.773,0,0,0-3.453.484A12.858,12.858,0,0,0,16.648,2.3a6.565,6.565,0,0,0-3.518.867,16.039,16.039,0,0,0-2.484-.624,7.694,7.694,0,0,0-5.819.924C3.093,4.691,2.289,6.819,2.438,9.792A36.351,36.351,0,0,0,3.844,16.33a22.579,22.579,0,0,0,1.514,3.863A4.786,4.786,0,0,0,7.8,22.742a2.4,2.4,0,0,0,2.379-.516,2.08,2.08,0,0,0,.5.43,3.328,3.328,0,0,0,.944.4,5.069,5.069,0,0,0,3.3-.2c.006.171.011.335.014.477.006.229.013.454.021.665a11.641,11.641,0,0,0,.441,3.3c.016.043.037.107.059.176a3.975,3.975,0,0,0,.991,1.745,2.955,2.955,0,0,0,2.09.777,4.7,4.7,0,0,0,.977-.109A4.592,4.592,0,0,0,22.607,28.1c.811-1.155,1.206-2.894,1.277-5.635.009-.078.018-.152.026-.222l.017-.145.191.017.049,0a7.562,7.562,0,0,0,3.163-.548c.631-.293,2.654-1.361,2.177-2.8"}),l.createElement("path",{d:"M27.689,19.053c-3.163.652-3.38-.418-3.38-.418C27.648,13.68,29.044,7.39,27.839,5.851c-3.286-4.2-8.975-2.213-9.07-2.162l-.031.006a11.28,11.28,0,0,0-2.11-.22,5.212,5.212,0,0,0-3.34,1S3.14.294,3.612,9.733c.1,2.008,2.878,15.194,6.191,11.211,1.211-1.456,2.381-2.688,2.381-2.688a3.071,3.071,0,0,0,2.006.512l.057-.048a2.21,2.21,0,0,0,.023.567c-.854.954-.6,1.121-2.309,1.472-1.726.356-.712.989-.05,1.155a3.508,3.508,0,0,0,3.915-1.272l-.05.2c.334.268.569,1.742.53,3.079a8.481,8.481,0,0,0,.2,2.971c.264.717.526,2.329,2.769,1.849a3.307,3.307,0,0,0,2.98-3.179c.1-1.234.313-1.052.326-2.155l.174-.522c.2-1.673.032-2.213,1.186-1.962l.281.025a6.4,6.4,0,0,0,2.615-.44c1.406-.652,2.239-1.742.853-1.455h0",style:{fill:"#336791"}}),l.createElement("path",{d:"M13.882,10.631a.981.981,0,0,0-.674.1.247.247,0,0,0-.1.164.48.48,0,0,0,.117.314.881.881,0,0,0,.559.349.637.637,0,0,0,.09.006.725.725,0,0,0,.687-.467c.035-.248-.326-.414-.676-.463m9.442.008c-.027-.195-.374-.25-.7-.2s-.647.194-.62.389a.667.667,0,0,0,.62.411.592.592,0,0,0,.083-.006.8.8,0,0,0,.451-.247.5.5,0,0,0,.169-.343",style:{fill:"#fff"}}),l.createElement("path",{d:"M28.741,18.979c-.121-.365-.509-.482-1.154-.349-1.915.4-2.6.121-2.826-.044a26.327,26.327,0,0,0,3.373-7.565,14.374,14.374,0,0,0,.5-3.253,3.513,3.513,0,0,0-.509-2.2,7.482,7.482,0,0,0-6.049-2.825,10.363,10.363,0,0,0-3.5.551,8.717,8.717,0,0,0-1.968-.253,5.684,5.684,0,0,0-3.372.929,15.051,15.051,0,0,0-2.74-.718,6.978,6.978,0,0,0-5.242.805c-1.5,1.064-2.2,2.966-2.061,5.653a35.489,35.489,0,0,0,1.373,6.348c1.07,3.505,2.233,5.49,3.457,5.9a1.548,1.548,0,0,0,.491.081,2.049,2.049,0,0,0,1.563-.886q1.042-1.25,2.155-2.438a3.472,3.472,0,0,0,1.55.417l0,.042q-.14.166-.273.338c-.375.475-.452.574-1.658.823-.343.071-1.254.259-1.267.9-.014.7,1.077.991,1.2,1.022a5.144,5.144,0,0,0,1.249.162,3.634,3.634,0,0,0,2.5-.934,23.674,23.674,0,0,0,.381,5.684,2.854,2.854,0,0,0,2.729,2.1,4.378,4.378,0,0,0,.917-.1,3.462,3.462,0,0,0,3.156-3.212c.177-1.026.481-3.475.624-4.789a3.859,3.859,0,0,0,1.11.137,6.6,6.6,0,0,0,2.519-.48c.712-.331,2-1.141,1.763-1.846ZM24.051,10.1a7.968,7.968,0,0,1-.116,1.107,10.229,10.229,0,0,0-.14,1.3,9.859,9.859,0,0,0,.1,1.47,5.236,5.236,0,0,1-.229,2.986,3.882,3.882,0,0,1-.207-.426c-.058-.141-.185-.368-.359-.681-.68-1.22-2.274-4.078-1.458-5.244.243-.347.86-.7,2.408-.512ZM22.174,3.531a6.617,6.617,0,0,1,5.334,2.522c.975,1.245-.1,6.912-3.205,11.8l-.094-.119-.039-.049a5.524,5.524,0,0,0,.506-3.8,9.114,9.114,0,0,1-.1-1.352,9.572,9.572,0,0,1,.131-1.206,7.614,7.614,0,0,0,.123-1.493.619.619,0,0,0,.013-.21,8.381,8.381,0,0,0-1.912-3.6,8.61,8.61,0,0,0-3.039-2.284,10.246,10.246,0,0,1,2.28-.214ZM9.479,20.654c-.627.754-1.061.61-1.2.562-.928-.31-2.006-2.272-2.955-5.384a35.167,35.167,0,0,1-1.34-6.159c-.12-2.4.462-4.074,1.73-4.974,2.063-1.463,5.456-.587,6.819-.143-.02.019-.04.037-.059.057-2.237,2.259-2.184,6.119-2.178,6.355,0,.091.007.22.018.4a15.969,15.969,0,0,1-.081,3.226A4.08,4.08,0,0,0,11.3,18.007q.133.138.278.262c-.383.41-1.216,1.318-2.1,2.385Zm2.39-3.19a3.3,3.3,0,0,1-.865-2.764,16.7,16.7,0,0,0,.087-3.381c-.006-.095-.011-.178-.014-.243A4.3,4.3,0,0,1,14,10.223a1.188,1.188,0,0,1,.918,1.026c.646,2.989.085,4.234-.365,5.235-.093.206-.181.4-.255.6l-.058.156a10.218,10.218,0,0,0-.368,1.109,2.788,2.788,0,0,1-2-.887Zm.113,4.03a1.733,1.733,0,0,1-.523-.225,2.553,2.553,0,0,1,.557-.166c1.418-.292,1.637-.5,2.116-1.105.11-.139.234-.3.406-.489h0c.256-.287.374-.238.586-.15a.829.829,0,0,1,.408.525.585.585,0,0,1-.05.491A3.1,3.1,0,0,1,11.983,21.495ZM19.406,28.4a2.113,2.113,0,0,1-2.754-1.526,31.129,31.129,0,0,1-.3-6.853.392.392,0,0,0-.017-.124,1.643,1.643,0,0,0-.048-.23,1.589,1.589,0,0,0-.862-1.034,1.216,1.216,0,0,0-.793-.1,9.586,9.586,0,0,1,.342-1.022l.058-.157c.066-.177.148-.36.235-.554.471-1.047,1.117-2.482.416-5.722a2.044,2.044,0,0,0-2.468-1.669A5.694,5.694,0,0,0,11.328,10c-.078.04-.15.078-.216.115A8.244,8.244,0,0,1,13.03,5.163,4.711,4.711,0,0,1,16.6,3.827,7.567,7.567,0,0,1,22.381,6.59,8.774,8.774,0,0,1,23.963,9.3c-1.463-.149-2.458.14-2.962.861-1.1,1.568.6,4.612,1.416,6.075.15.268.279.5.319.6a5.432,5.432,0,0,0,.861,1.387c.077.1.152.189.208.271-.443.128-1.239.423-1.166,1.9-.058.74-.474,4.205-.686,5.43-.279,1.617-.874,2.22-2.548,2.579Zm7.242-8.288a5.714,5.714,0,0,1-1.931.4,2.422,2.422,0,0,1-1.3-.167c-.045-.919.3-1.015.66-1.117.057-.016.112-.032.166-.05a1.353,1.353,0,0,0,.11.08c.639.422,1.78.467,3.39.135l.018,0a4.334,4.334,0,0,1-1.116.72Z",style:{fill:"#fff"}})),He=({size:e,type:t})=>t==="mysql"?s.jsx(ru,{width:e,height:e}):s.jsx(au,{width:e,height:e}),iu={mysql:"MySQL",postgres:"PostgreSQL"},lu={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"}]},cu={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"}]},uu=({show:e,onClose:t,dbType:n="postgres"})=>{const o=pc(),a=Xr(),{data:r}=ve(),[i,{change:c,set:u}]=kn({name:"",dbType:n,dbUrl:"",dbUser:"",dbPassword:"",dbDatabase:"",dbSchema:"",dbPort:n==="mysql"?3306:5432,teamId:"",ownerId:"",description:"",allowInsert:!1,allowUpdate:!1}),h=async()=>{const p=await o.mutateAsync({...i,dbPort:Number(i.dbPort),teamId:r.teamId,ownerId:r.id});await a.mutateAsync(p.id),t()},m=p=>{u("allowInsert",!p),u("allowUpdate",!p)},d=o.isPending||a.isPending,x=!i.allowInsert&&!i.allowUpdate;return s.jsxs(we,{isVisible:e,onClose:t,portal:!0,children:[s.jsxs("div",{className:"max-w-xl mx-auto overflow-y-auto",children:[s.jsxs("div",{className:$e.header,children:[s.jsx(He,{size:24,type:n}),s.jsx("p",{className:"text-(--text-color-primary) font-semibold",children:iu[n]})]}),o.isError&&s.jsx(me,{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(me,{className:"mb-2",variant:"info",children:"Creating connection"}),a.isPending&&s.jsx(me,{className:"mb-2",variant:"info",children:"Inspecting connection"}),s.jsxs("div",{className:"mt-2",children:[s.jsxs("div",{className:$e.content,children:[s.jsxs("div",{className:"flex flex-col",children:[s.jsx("label",{className:"text-sm font-semibold mb-2",htmlFor:"datasource-name",children:"Name"}),s.jsx("input",{value:i.name,onChange:c("name"),id:"datasource-name",className:"input",placeholder:"Data source name",disabled:d})]}),s.jsx("p",{className:"text-sm font-semibold mt-2",children:"Configuration"}),s.jsx(ou,{form:i,change:c,shape:i.dbType==="mysql"?lu:cu})]}),s.jsx("p",{className:"text-sm font-semibold mt-4",children:"Connection mode"}),s.jsxs("div",{className:$e.modeContainer,children:[s.jsxs("label",{onClick:()=>m(!0),className:I($e.modeSelect,x&&$e.selected),children:[s.jsxs("span",{className:"text-sm font-semibold text-(--text-color-primary)",children:[s.jsx("input",{type:"radio",disabled:d,checked:x,className:"mr-2"}),"Read-only mode"]}),s.jsxs("p",{className:"text-sm mt-1 text-(--text-color-primary)",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",{onClick:()=>m(!1),className:I($e.modeSelect,!x&&$e.selected),children:[s.jsxs("span",{className:"text-sm font-semibold text-(--text-color-primary)",children:[s.jsx("input",{type:"radio",disabled:d,checked:!x,className:"mr-2"}),"Read/Write mode"]}),s.jsxs("p",{className:"text-sm mt-1 text-(--text-color-primary)",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:t,className:"button tertiary",disabled:d,children:"Cancel"}),s.jsx("button",{onClick:h,className:"button primary",disabled:d,children:"Create"})]})]})},du="_data-source-entry_8cjh9_2",hu="_action-title_8cjh9_2",mu="_recent-tabs-container_8cjh9_2",fu="_recent-tabs-entry_8cjh9_2",pu="_home-action-button_8cjh9_2",xu="_home-gray-card_8cjh9_2",gu="_home-card-title_8cjh9_2",bu="_home-card-grid-content_8cjh9_2",vu="_useful-links_8cjh9_2",Q={dataSourceEntry:du,actionTitle:hu,recentTabsContainer:mu,recentTabsEntry:fu,homeActionButton:pu,homeGrayCard:xu,homeCardTitle:gu,homeCardGridContent:bu,usefulLinks:vu},[yu,In]=ye({show:!1}),[wu,jn]=ye({show:!1}),[Cu,Nn]=ye(void 0),ju=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"})),Nu=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"})),_u=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})),Su=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{d:"M336 208v-95a80 80 0 00-160 0v95",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32}),l.createElement("rect",{x:96,y:208,width:320,height:272,rx:48,ry:48,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32})),tn=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("title",null,"Search"),l.createElement("path",{d:"M221.09 64a157.09 157.09 0 10157.09 157.09A157.1 157.1 0 00221.09 64z",fill:"none",stroke:"currentColor",strokeMiterlimit:10,strokeWidth:32}),l.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeMiterlimit:10,strokeWidth:32,d:"M338.29 338.29L448 448"})),ra=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{d:"M145.61 464h220.78c19.8 0 35.55-16.29 33.42-35.06C386.06 308 304 310 304 256s83.11-51 95.8-172.94c2-18.78-13.61-35.06-33.41-35.06H145.61c-19.8 0-35.37 16.28-33.41 35.06C124.89 205 208 201 208 256s-82.06 52-95.8 172.94c-2.14 18.77 13.61 35.06 33.41 35.06z",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32}),l.createElement("path",{d:"M343.3 432H169.13c-15.6 0-20-18-9.06-29.16C186.55 376 240 356.78 240 326V224c0-19.85-38-35-61.51-67.2-3.88-5.31-3.49-12.8 6.37-12.8h142.73c8.41 0 10.23 7.43 6.4 12.75C310.82 189 272 204.05 272 224v102c0 30.53 55.71 47 80.4 76.87 9.95 12.04 6.47 29.13-9.1 29.13z",fill:"currentColor"})),aa=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{d:"M436.67 184.11a27.17 27.17 0 01-38.3 0l-22.48-22.49a27.15 27.15 0 010-38.29l50.89-50.89a.85.85 0 00-.26-1.38C393.68 57 351.09 64.15 324.05 91c-25.88 25.69-27.35 64.27-17.87 98a27 27 0 01-7.67 27.14l-173 160.76a40.76 40.76 0 1057.57 57.54l162.15-173.3a27 27 0 0126.77-7.7c33.46 8.94 71.49 7.26 97.07-17.94 27.49-27.08 33.42-74.94 20.1-102.33a.85.85 0 00-1.36-.22z",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeMiterlimit:10,strokeWidth:32}),l.createElement("path",{d:"M224 284c-17.48-17-25.49-24.91-31-30.29a18.24 18.24 0 01-3.33-21.35 20.76 20.76 0 013.5-4.62l15.68-15.29a18.66 18.66 0 015.63-3.87 18.11 18.11 0 0120 3.62c5.45 5.29 15.43 15 33.41 32.52M317.07 291.3c40.95 38.1 90.62 83.27 110 99.41a13.46 13.46 0 01.94 19.92L394.63 444a14 14 0 01-20.29-.76c-16.53-19.18-61.09-67.11-99.27-107",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32}),l.createElement("path",{d:"M17.34 193.5l29.41-28.74a4.71 4.71 0 013.41-1.35 4.85 4.85 0 013.41 1.35h0a9.86 9.86 0 008.19 2.77c3.83-.42 7.92-1.6 10.57-4.12 6-5.8-.94-17.23 4.34-24.54a207 207 0 0119.78-22.6c6-5.88 29.84-28.32 69.9-44.45A107.31 107.31 0 01206.67 64c22.59 0 40 10 46.26 15.67a89.54 89.54 0 0110.28 11.64 78.92 78.92 0 00-9.21-2.77 68.82 68.82 0 00-20-1.26c-13.33 1.09-29.41 7.26-38 14-13.9 11-19.87 25.72-20.81 44.71-.68 14.12 2.72 22.1 36.1 55.49a6.6 6.6 0 01-.34 9.16l-18.22 18a6.88 6.88 0 01-9.54.09c-21.94-21.94-36.65-33.09-45-38.16s-15.07-6.5-18.3-6.85a30.85 30.85 0 00-18.27 3.87 11.39 11.39 0 00-2.64 2 14.14 14.14 0 00.42 20.08l1.71 1.6a4.63 4.63 0 010 6.64L71.73 246.6a4.71 4.71 0 01-3.41 1.4 4.86 4.86 0 01-3.41-1.35l-47.57-46.43a4.88 4.88 0 010-6.72z",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32})),Qo=20,lo="text-(--text-color-primary)",ku=()=>{const e=Tn("Home");return s.jsxs("div",{className:Q.homeActionButton,onClick:e,children:[s.jsx(tn,{width:Qo,height:Qo,className:lo}),s.jsx("h2",{className:Q.actionTitle,children:"Start new query"})]})},Eu=()=>s.jsxs("div",{className:Q.homeActionButton,onClick:()=>In({show:!0}),children:[s.jsx(ra,{width:20,height:20,className:lo}),s.jsx("h2",{className:Q.actionTitle,children:"Saved queries"})]}),Ru={mysql:"MySQL",postgres:"PostgreSQL"},Ko=({dbType:e})=>{const[t,n]=l.useState(void 0),o=An(he.EDITOR),a=r=>{o?n(r):ke.error("You don't have permission to connect new data sources in this team")};return s.jsxs("div",{children:[t&&s.jsx(uu,{show:!0,dbType:t,onClose:()=>n(void 0)}),s.jsxs("div",{className:Q.homeActionButton,onClick:()=>a(e),children:[s.jsx(He,{size:24,type:e}),s.jsx("p",{className:Q.actionTitle,children:Ru[e]})]})]})},Lu=()=>s.jsxs("div",{className:Q.homeGrayCard,children:[s.jsx("h2",{className:Q.homeCardTitle,children:"Connect new data source"}),s.jsxs("div",{className:Q.homeCardGridContent,children:[s.jsx(Ko,{dbType:"mysql"}),s.jsx(Ko,{dbType:"postgres"})]})]}),Tu=()=>{const e=J(),{data:t}=bs(),n=Tn("Home"),o=()=>{t&&t.length>0?e(D.workbenchTab.build({id:t[0].id})):n()};return s.jsxs("div",{className:Q.homeActionButton,onClick:o,children:[s.jsx(aa,{width:20,height:20,className:lo}),s.jsx("h2",{className:Q.actionTitle,children:"Workbench"})]})},Au=()=>{const{data:e}=ve(),{data:t}=ao({teamId:e?.teamId});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(n=>s.jsxs("div",{className:Q.dataSourceEntry,onClick:()=>Nn(n.id),tabIndex:0,children:[!n.allowInsert&&s.jsx(Su,{"data-tooltip-id":"default","data-tooltip-content":"This datasource is read-only",width:18,height:18,className:"absolute top-2 right-2"}),s.jsx(He,{size:32,type:n.dbType}),s.jsxs("div",{className:"overflow-hidden",children:[s.jsx("p",{className:"text-(--text-color-primary) font-semibold truncate",children:n.name}),s.jsxs("p",{className:"text-sm text-(--text-color-secondary) truncate",children:[n.dbUrl,":",n.dbPort]})]})]},n.id))})]})},Wt=24,ia=()=>s.jsxs("div",{className:Q.usefulLinks,children:[s.jsxs("a",{href:"https://dataramen.xyz/",target:"_blank",children:[s.jsx(_u,{width:Wt,height:Wt}),s.jsx("span",{children:"Docs"})]}),s.jsxs("a",{href:"https://github.com/OleksandrDemian/dataramen",target:"_blank",children:[s.jsx(ju,{width:Wt,height:Wt}),s.jsx("span",{children:"GitHub"})]}),s.jsxs("a",{href:"https://www.npmjs.com/package/@dataramen/cli",target:"_blank",children:[s.jsx(Nu,{width:Wt,height:Wt}),s.jsx("span",{children:"NPM"})]})]}),Iu=()=>{const{data:e}=ve(),{data:t,isLoading:n}=uc(e?.teamId),o=J();if(n||!t?.length)return null;const a=r=>{o(D.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(He,{size:20,type:r.dataSourceType}),s.jsx("span",{className:"text-sm text-(--text-color-secondary) truncate",children:r.dataSourceName})]})]},r.id))]})},Pu=()=>{const{data:e}=ve(),{data:t}=ao({teamId:e?.teamId}),n=!!t&&t.length>0,o=!!e;return s.jsx("div",{className:"page-container h-screen max-h-screen overflow-y-auto no-scrollbar",children:s.jsxs("div",{className:"page-content",children:[s.jsxs("div",{className:"py-10 text-center w-full sticky top-0 z-0",children:[s.jsx("h1",{className:"comfortaa text-3xl font-semibold text-(--text-color-primary) mb-4",children:"DataRamen"}),s.jsx(ia,{})]}),s.jsxs("div",{className:"flex flex-col gap-8 mt-8 bg-(--bg) z-1",children:[o&&!n&&s.jsx(me,{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(ku,{}),o&&s.jsx(Tu,{}),s.jsx(Eu,{})]})]}),o&&s.jsx(Au,{}),s.jsx(Lu,{}),s.jsx(Iu,{})]})]})})},[Mu,co]=ye(void 0),Ou=()=>co(void 0);function wt(e,t){if(e==null)return"";switch(t){case"json":case"jsonb":return JSON.stringify(e,null,2)}if(e===0||e===!1)return e.toString();switch(typeof e){case"string":return e;case"number":case"boolean":return e.toString();default:return JSON.stringify(e)}}const ts=e=>e.distinct?[e.fn,"DISTINCT",e.value].join(" "):[e.fn,e.value].join(" "),st=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},Du="_container_1qo35_2",$u="_header_1qo35_2",Fu="_fields-container_1qo35_2",Bu="_field-label_1qo35_2",qu="_actions_1qo35_2",xn={container:Du,header:$u,fieldsContainer:Fu,fieldLabel:Bu,actions:qu},Wu=(e,t,n)=>be({queryKey:["entity",e,t,n],queryFn:async()=>{const{data:o}=await $.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}),Uu=()=>ee({mutationFn:async e=>{const{data:t}=await $.post(`/runner/${e.datasourceId}/update`,e);return t.data}}),Hu=()=>ee({mutationFn:async e=>{const{data:t}=await $.post(`/runner/${e.datasourceId}/insert`,e);return t.data}}),uo=e=>l.useMemo(()=>{if(e)return e instanceof ii?e.response?.data.error?e.response.data.error:e.response?.data?.message?e.response.data.message:e.message:e instanceof Error?e.message:"Undefined error"},[e]),ho=()=>{const{pathname:e}=fe();return l.useMemo(()=>Kt({path:D.workbenchTab.path,end:!1},e)?.params.id,[e])},la=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{d:"M248 64C146.39 64 64 146.39 64 248s82.39 184 184 184 184-82.39 184-184S349.61 64 248 64z",fill:"none",stroke:"currentColor",strokeMiterlimit:10,strokeWidth:32}),l.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32,d:"M220 220h32v116"}),l.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeMiterlimit:10,strokeWidth:32,d:"M208 340h88"}),l.createElement("path",{d:"M248 130a26 26 0 1026 26 26 26 0 00-26-26z",fill:"currentColor"})),zu="_container_1ecqh_2",Vu={container:zu},Pn=({containerClassName:e,className:t,...n})=>s.jsxs("label",{className:I(Vu.container,e),children:[s.jsx(tn,{width:16,height:16}),s.jsx("input",{className:I("flex-1 outline-none",t),...n})]}),Qu=({data:e})=>{const[t,{change:n,touched:o}]=kn({}),a=ho(),{mutateAsync:r,error:i}=Hu(),c=uo(i),{data:u}=xs(e.dataSourceId),[h,m]=l.useState(""),d=l.useMemo(()=>u?.find(b=>b.tableName===e.table),[u,e.table]),x=l.useMemo(()=>{if(!d)return[];if(!h)return d.columns.map(g=>({...g,label:st(g.name)}));const b=h.toLowerCase();return d.columns.filter(g=>g.name.toLowerCase().includes(b)).map(g=>({...g,label:st(g.name)}))},[h,d]),p=()=>{const b={};for(const g of o)b[g]=t[g];r({datasourceId:e.dataSourceId,table:e.table,values:b}).then(()=>{Ou(),a&&ta(a)})};return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:xn.header,children:[s.jsxs("p",{className:"text-lg font-semibold",children:["Insert new record in ",s.jsx("span",{className:"underline",children:e.table})]}),c&&s.jsx(me,{variant:"danger",children:s.jsx("p",{children:c})}),s.jsx(Pn,{containerClassName:"mt-2",className:"text-sm",value:h,onChange:b=>m(b.target.value),placeholder:"Filter columns",autoFocus:!0})]}),s.jsx("div",{className:xn.container,children:s.jsx("div",{className:xn.fieldsContainer,children:x.map(b=>s.jsxs("label",{className:xn.fieldLabel,children:[s.jsxs("div",{className:"flex justify-between mb-0.5",children:[s.jsxs("p",{children:[b.isPrimary?"🔐":"🏷️"," ",b.label]}),s.jsxs("p",{className:"text-blue-800 text-sm",children:["[",b.name,": ",b.type,"]"]})]}),s.jsx("input",{className:"input w-full",value:wt(t[b.name]),onChange:n(b.name)})]},b.name))})}),s.jsxs("div",{className:xn.actions,children:[s.jsx("span",{"data-tooltip-id":"default","data-tooltip-content":"Tip: use = to write raw SQL. Ex: =NULL or =NOW()",children:s.jsx(la,{className:"text-(--text-color-secondary)",width:22,height:22})}),s.jsx("span",{className:"flex-1"}),s.jsx("button",{disabled:!o.length,className:"button primary",onClick:p,children:"Run insert"})]})]})},Ku=()=>{const e=Mu(),[t,n]=l.useState(void 0);l.useEffect(()=>{e&&n(e)},[e]);const o=()=>co(void 0);return s.jsxs(we,{isVisible:e!=null,onClose:o,onClosed:()=>n(void 0),noPadding:!0,children:[s.jsx(lt,{onClick:o}),t&&s.jsx(Qu,{data:t})]})},[Gu,Mn]=ye(void 0),Yu=()=>Mn(void 0),Ju="_container_cv445_2",Xu="_header_cv445_2",Zu="_fields-container_cv445_2",ed="_field-label_cv445_2",td="_actions_cv445_2",gn={container:Ju,header:Xu,fieldsContainer:Zu,fieldLabel:ed,actions:td},Je=()=>Date.now().toString(36)+Math.random().toString(36).substring(2),ca=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{d:"M384 224v184a40 40 0 01-40 40H104a40 40 0 01-40-40V168a40 40 0 0140-40h167.48M336 64h112v112M224 288L440 72",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32})),nd=e=>{if(e==null)return"<NULL>";if(e==="")return"<EMPTY STRING>"},sd=({data:e})=>{const[t,{change:n,set:o,reset:a,touched:r}]=kn({}),i=ho(),c=J(),[u,h]=l.useState(""),{data:m,isLoading:d}=Wu(e.dataSourceId,e.tableName,e.entityId),{mutateAsync:x,error:p}=Uu(),{mutateAsync:b}=Et(),g=uo(p),v=An(he.EDITOR),{data:y}=xs(e.dataSourceId),{data:f}=ps(e.dataSourceId),w=l.useMemo(()=>y?.find(j=>j.tableName===e.tableName),[e.tableName,y]),C=l.useMemo(()=>{if(!w)return[];if(!u)return w.columns.map(k=>({...k,label:st(k.name)}));const j=u.toLowerCase();return w.columns.filter(k=>k.name.toLowerCase().includes(j)).map(k=>({...k,label:st(k.name)}))},[u,w]),_=l.useMemo(()=>{const j={};if(!m?.entity)return j;for(let k=0;k<m.columns.length;k++)j[m.columns[k]?.column]=nd(m.entity[k]);return j},[m]);l.useEffect(()=>{const j=m?.entity;if(a(),j&&m?.columns)for(let k=0;k<m.columns.length;k++){const X=m.columns[k];o(X.column,wt(j[k]))}},[m,o,a]);const A=()=>{const j={};for(const k of r)j[k]=t[k];x({datasourceId:e.dataSourceId,table:e.tableName,filters:e.entityId.map(k=>({id:Je(),value:""+k[1],column:k[0],isEnabled:!0})),values:j}).then(()=>{Yu(),i&&ta(i)})},S=()=>{b({name:e.tableName,opts:Nt({dataSourceId:e.dataSourceId,table:e.tableName,filters:e.entityId.map(([j,k])=>({value:`${k}`,column:`${e.tableName}.${j}`,id:Je(),isEnabled:!0}))})}).then(({id:j})=>{c(D.workbenchTab.build({id:j})),Mn(void 0)})},P=!f?.allowUpdate||!v;return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:gn.header,children:[s.jsxs("p",{className:"text-lg font-semibold",children:[P?"View":"Edit"," row in ",s.jsx("span",{className:"underline",children:e?.tableName})]}),g&&s.jsx(me,{variant:"danger",children:s.jsx("p",{children:g})}),s.jsx(Pn,{containerClassName:"mt-2",className:"text-sm",value:u,onChange:j=>h(j.target.value),placeholder:"Filter columns",autoFocus:!0})]}),s.jsx("div",{className:gn.container,children:s.jsx("div",{className:gn.fieldsContainer,children:C.map(j=>s.jsxs("label",{className:gn.fieldLabel,children:[s.jsxs("div",{className:"flex justify-between mb-0.5",children:[s.jsxs("p",{children:[j.isPrimary?"🔐":"🏷️"," ",j.label]}),s.jsxs("p",{className:"text-blue-800 text-sm",children:["[",j.name,": ",j.type,"]"]})]}),s.jsx("input",{disabled:j.isPrimary||d||P,className:"input w-full secondary",value:wt(t[j.name]),onChange:n(j.name),placeholder:_[j.name]})]},j.name))})}),s.jsxs("div",{className:gn.actions,children:[!P&&s.jsx("span",{"data-tooltip-id":"default","data-tooltip-content":"Tip: use = to write raw SQL. Ex: =NULL or =NOW()",children:s.jsx(la,{className:"text-(--text-color-secondary)",width:22,height:22})}),s.jsx("span",{className:"flex-1"}),s.jsxs("button",{className:"button tertiary flex gap-2 items-center",onClick:S,children:[s.jsx(ca,{width:16,height:16}),s.jsx("span",{children:"Open in new tab"})]}),!P&&s.jsx("button",{disabled:!r.length,className:"button primary",onClick:A,children:"Update"})]})]})},od=()=>{const e=Gu(),[t,n]=l.useState(void 0);l.useEffect(()=>{e&&n(e)},[e]);const o=()=>Mn(void 0);return s.jsxs(we,{isVisible:e!=null,onClose:o,onClosed:()=>n(void 0),noPadding:!0,children:[s.jsx(lt,{onClick:o}),t&&s.jsx(sd,{data:t})]})},[rd,Is]=ye(void 0),mo=async e=>new Promise(t=>{Is({message:e,onCancel:()=>{t(!1),Is(void 0)},onConfirm:()=>{t(!0),Is(void 0)}})}),ad=({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"})]})]}),id=()=>{const e=rd(),[t,n]=l.useState(void 0);return l.useEffect(()=>{e&&n(e)},[e]),s.jsx(we,{isVisible:!!e,onClose:()=>e?.onCancel(),onClosed:()=>n(void 0),children:t&&s.jsx(ad,{confirm:t})})},[ld,ns]=ye(void 0),On=async(e,t,n)=>new Promise(o=>{ns({message:e,defaultValue:t,alert:n,onCancel:()=>{ns(void 0),o(void 0)},onConfirm:a=>{ns(void 0),o(a)}})}),cd="_root_ng9lp_1",ud={root:cd},dd=({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:ud.root,children:[s.jsx("h2",{className:"text-xl font-semibold",children:e.message}),e.alert&&s.jsx(me,{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"})]})]})},hd=()=>{const e=ld(),[t,n]=l.useState(void 0);return l.useEffect(()=>{e&&n(e)},[e]),s.jsx(we,{isVisible:!!e,onClose:()=>ns(void 0),onClosed:()=>n(void 0),children:t&&s.jsx(dd,{data:t})})},[md,fd]=ye(void 0),ua=e=>{fd(e)},pd="_textarea_1levt_2",xd={textarea:pd},gd=()=>{const e=md(),t=()=>{e&&(navigator.clipboard.writeText(e.toString()),ke.success("Copied!"))},n=()=>ua(void 0);return s.jsxs(we,{isVisible:!!e,onClose:n,backdropClose:!0,children:[s.jsx("textarea",{className:xd.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"})]})]})},bd="_tabs_1pt3i_2",vd="_mobile_1pt3i_2",yd="_tab_1pt3i_2",wd="_active_1pt3i_2",Cd="_close-button_1pt3i_2",bn={tabs:bd,mobile:vd,tab:yd,active:wd,closeButton:Cd},Go=e=>window.matchMedia(e).matches;function da(e,{defaultValue:t=!1,initializeWithValue:n=!0}={}){const[o,a]=l.useState(()=>n?Go(e):t);return l.useLayoutEffect(()=>{const r=window.matchMedia(e);function i(){a(()=>Go(e))}return i(),r.addListener?r.addListener(i):r.addEventListener("change",i),()=>{r.removeListener?r.removeListener(i):r.removeEventListener("change",i)}},[e]),o}const fo={laptop:"(min-width: 1024px)"},ha=()=>window.matchMedia(fo.laptop).matches,jd="_table_8rihn_2",Nd="_row-index-btn_8rihn_2",_d="_semi-transparent_8rihn_2",Sd="_table-loading_8rihn_2",kd="_table-empty_8rihn_2",Ed="_table-row-cells_8rihn_2",Rd="_header-cell_8rihn_2",Ld="_header-actions_8rihn_2",Td="_cell_8rihn_2",Ad="_value_8rihn_2",Id="_table-config_8rihn_2",Pd="_table-action_8rihn_2",Md="_data-source_8rihn_2",Od="_gray_8rihn_2",Dd="_modal_8rihn_2",$d="_selected-size_8rihn_2",Fd="_pagination-indicator_8rihn_2",R={table:jd,rowIndexBtn:Nd,semiTransparent:_d,tableLoading:Sd,tableEmpty:kd,tableRowCells:Ed,headerCell:Rd,headerActions:Ld,cell:Td,value:Ad,tableConfig:Id,tableAction:Pd,dataSource:Md,gray:Od,modal:Dd,selectedSize:$d,paginationIndicator:Fd},Pe=l.createContext({name:"No name",hooks:[],availableJoins:[],allColumns:[],dataSourceId:"",entities:[],getValue:()=>{},getValueByIndex:()=>{},getColumnByIndex:()=>{},getColumnType:()=>{}}),Ce=l.createContext({state:Nt({}),setState:()=>{}}),Xe=l.createContext({}),ma={ON_ANIMATION_END:Symbol("ON_TRANSITION_END")},fa=()=>{const[e,t]=l.useState(),[n,o]=l.useState("hidden");return l.useMemo(()=>{const 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,[ma.ON_ANIMATION_END]:i}},[e,n])},Bd=e=>{if(e!=="ASC")return e==="DESC"?"ASC":"DESC"},qd=()=>{const{state:e,setState:t}=l.useContext(Ce),n=l.useCallback(o=>{t(a=>{const r=a.orderBy[0];if(r&&r.column===o){const i=Bd(r.direction);return i?{...a,orderBy:[{column:o,direction:i}]}:{...a,orderBy:[]}}return{...a,orderBy:[{column:o,direction:"DESC"}]}})},[t]);return{orderBy:e.orderBy,updateOrderBy:n}},Wd="_options-container_iby6o_2",Ud="_filter-input_iby6o_2",Hd="_list_iby6o_2",zd="_empty-text_iby6o_2",Ct={optionsContainer:Wd,filterInput:Ud,list:Hd,emptyText:zd},Vd="_container_1ynhq_2",Qd="_animate-show_1ynhq_2",Kd="_animate-hide_1ynhq_2",Gd="_content_1ynhq_2",Yd="_backdrop_1ynhq_2",pt={container:Vd,animateShow:Qd,animateHide:Kd,content:Gd,backdrop:Yd},pa=({children:e,handler:t})=>{const n=l.useRef(t.close);n.current=t.close;const o=l.useMemo(()=>{if(!t.position)return;const r={};if(typeof window<"u"){const i=t.position.y>window.innerHeight/2,c=t.position.x>window.innerWidth/2;i?r.bottom=window.innerHeight-t.position.y:r.top=t.position.y,ha()?c?r.right=window.innerWidth-t.position.x:r.left=t.position.x:(r.right=36,r.left=36)}return r},[t.position]);if(vs({enabled:!!o,onClose:t.close}),!o)return null;const a=s.jsxs("div",{className:I(pt.container,t.state==="out"&&pt.animateHide,t.state==="in"&&pt.animateShow),onAnimationEnd:t[ma.ON_ANIMATION_END],children:[s.jsx("div",{className:pt.backdrop,onClick:r=>{r.stopPropagation(),r.preventDefault(),t.close()}}),s.jsx("div",{className:I(pt.content,t.state==="out"&&pt.animateHide,t.state==="in"&&pt.animateShow),style:o,children:e})]});return oo.createPortal(a,document.body)},ge=(e,t)=>e!=null&&e>t,Jd=(e,t)=>e!=null&&e<t,Xd="_root_1834n_2",Zd="_content_1834n_2",eh="_table-name_1834n_2",th="_sub_1834n_2",tt={root:Xd,content:Zd,tableName:eh,sub:th},po=({hook:e,onClick:t})=>e.direction==="out"?s.jsx("button",{className:tt.root,onClick:t,children:s.jsxs("div",{className:tt.content,children:[s.jsx("p",{className:tt.tableName,children:e.toTable}),s.jsxs("p",{className:tt.sub,children:[e.toColumn," = ",e.fromTable,".",e.fromColumn]})]})},e.id):s.jsx("button",{className:tt.root,onClick:t,children:s.jsxs("div",{className:tt.content,children:[s.jsx("p",{className:tt.tableName,children:e.fromTable}),s.jsxs("p",{className:tt.sub,children:[e.fromColumn," = ",e.toTable,".",e.toColumn]})]})},e.id);function nh(e,t,n,o){if(e.direction==="out"){const r=o(n,e.fromTable,e.fromColumn);return{name:`${e.toTable} ${e.toColumn} equals ${r}`,opts:Nt({table:e.toTable,dataSourceId:t,filters:[{id:Je(),column:`${e.toTable}.${e.toColumn}`,value:r==null?"IS NULL":`${r}`,isEnabled:!0}]})}}const a=o(n,e.toTable,e.toColumn);return{name:`${e.fromTable} ${e.fromColumn} equals ${a}`,opts:Nt({table:e.fromTable,dataSourceId:t,filters:[{id:Je(),column:`${e.fromTable}.${e.fromColumn}`,value:a==null?"IS NULL":`${a}`,isEnabled:!0}]})}}const xa=({rowIndex:e,colIndex:t,onClose:n,className:o})=>{const[a,r]=l.useState(""),{dataSourceId:i,hooks:c,getColumnByIndex:u,getValue:h}=l.useContext(Pe),m=l.useMemo(()=>{if(t===void 0)return c;const v=u(t);return v?c.filter(y=>y.toColumn===v.column&&y.toTable===v.table):[]},[t,c,u]),d=Et(),x=J(),p=l.useMemo(()=>{const v=a.toLowerCase();return m.filter(y=>y.fromTable.toLowerCase().includes(v))},[a,m]),b=v=>{d.mutateAsync(nh(v,i,e,h)).then(y=>{x(D.workbenchTab.build({id:y.id})),n?.()})},g=ge(p.length,0);return s.jsxs("div",{className:o,children:[s.jsx(Pn,{autoFocus:!0,className:Ct.filterInput,placeholder:"Filter",value:a,onChange:v=>r(v.target.value)}),s.jsxs("div",{className:Ct.list,children:[g&&p.map(v=>s.jsx(po,{hook:v,onClick:()=>b(v)},v.id)),!g&&s.jsx("p",{className:Ct.emptyText,children:"Empty"})]})]})},sh=({handler:e,rowIndex:t,colIndex:n})=>s.jsx(pa,{handler:e,children:s.jsx("div",{className:Ct.optionsContainer,children:s.jsx(xa,{rowIndex:t,colIndex:n,className:"p-2",onClose:()=>{e.close()}})})}),xo=()=>{const{state:e,setState:t}=l.useContext(Ce),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}},oh=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"})),rh=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"})),ah="_container_13obx_2",ih="_animate-show_13obx_2",lh="_animate-hide_13obx_2",ch="_backdrop_13obx_2",uh="_content_13obx_2",xt={container:ah,animateShow:ih,animateHide:lh,backdrop:ch,content:uh},ga=({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,d=!0)=>{d||(m.preventDefault(),m.stopPropagation());const x={},p=m.clientY>window.innerHeight/2,b=m.clientX>window.innerWidth/2;p?x.bottom=window.innerHeight-m.clientY:x.top=m.clientY,ha()?b?x.right=window.innerWidth-m.clientX:x.left=m.clientX:(x.right=36,x.left=36),a(x),i("in")},close:()=>{i("out")}}),[]),vs({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?.())},h=s.jsxs("div",{className:I(xt.container,r==="out"&&xt.animateHide,r==="in"&&xt.animateShow),onAnimationEnd:u,children:[s.jsx("div",{className:xt.backdrop,onClick:()=>i("out")}),s.jsx("div",{ref:c,style:o,className:I(xt.content,r==="out"&&xt.animateHide,r==="in"&&xt.animateShow),children:e})]});return oo.createPortal(h,document.body)};function Ps(e,t,n){const o=e?.rows?.[t]?.[n],a=e?.columns?.[n];return{value:o,column:a}}const dh=({ref:e})=>{const{data:t}=l.useContext(Xe),{getColumnType:n}=l.useContext(Pe),{setState:o}=l.useContext(Ce);return{copyValue:(c,u)=>{const{value:h,column:m}=Ps(t?.result,c,u);if(m){const d=wt(h,n(m.full));navigator.clipboard.writeText(d),ke.success("Copied!"),e.current?.close()}},showValue:(c,u)=>{const{value:h,column:m}=Ps(t?.result,c,u);if(m){const d=wt(h,n(m.full));ua(d),e.current?.close()}},filterValue:(c,u)=>{const{value:h,column:m}=Ps(t?.result,c,u),d=m?.full||"";if(d){let x;if(h==null)x={id:Je(),isEnabled:!0,isAdvanced:!0,column:d,value:"IS NULL"};else{const p=wt(h,n(d));x={id:Je(),isEnabled:!0,column:d,value:p,fn:m?.fn}}o(p=>({...p,filters:[...p.filters,x]})),ke.success(`Added new filter on column ${m?.alias}`),e.current?.close()}}}},ba=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("rect",{x:128,y:128,width:336,height:336,rx:57,ry:57,fill:"none",stroke:"currentColor",strokeLinejoin:"round",strokeWidth:32}),l.createElement("path",{d:"M383.5 128l.5-24a56.16 56.16 0 00-56-56H112a64.19 64.19 0 00-64 64v216a56.16 56.16 0 0056 56h24",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32})),hh=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})),mh="_section-name_15xdx_2",fh="_item_15xdx_2",gt={sectionName:mh,item:fh},yt=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{d:"M414 321.94L274.22 158.82a24 24 0 00-36.44 0L98 321.94c-13.34 15.57-2.28 39.62 18.22 39.62h279.6c20.5 0 31.56-24.05 18.18-39.62z",fill:"currentColor"})),ph=({onClose:e,rowIndex:t,className:n})=>{const[o,a]=l.useState(""),{entities:r,dataSourceId:i,getValue:c}=l.useContext(Pe),u=l.useMemo(()=>{if(!o)return r;const m=o.toLowerCase();return r.filter(d=>d.toTable.toLowerCase().includes(m))},[r,o]),h=m=>{const d=c(t,m.fromTable,m.fromColumn);d?Mn({tableName:m.toTable,dataSourceId:i,entityId:[[m.toColumn,""+d]]}):ke.error(`Cannot open ${m.toTable} record. ${m.fromTable}.${m.fromColumn} is NULL`),e?.()};return s.jsxs("div",{className:n,children:[s.jsx(Pn,{autoFocus:!0,className:Ct.filterInput,placeholder:"Filter",value:o,onChange:m=>a(m.target.value)}),s.jsx("div",{className:Ct.list,children:ge(u.length,0)?u.map(m=>s.jsx(po,{hook:m,onClick:()=>h(m)},m.id)):s.jsx("p",{className:Ct.emptyText,children:"Empty"})})]})},xh=({ref:e,row:t,col:n,onClosed:o})=>{const a=dh({ref:e}),[r,i]=l.useState("cell"),{hooks:c,entities:u}=l.useContext(Pe),h=()=>a.copyValue(t,n),m=()=>a.showValue(t,n),d=()=>a.filterValue(t,n),x=()=>{i("show-record")},p=()=>{o?.(),i("cell")},b=ge(c?.length,0),g=ge(u?.length,0);return s.jsx(ga,{ref:e,onClosed:p,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:h,children:[s.jsx(ba,{width:14,height:14}),"Copy"]}),s.jsxs("button",{className:gt.item,onClick:m,children:[s.jsx(hh,{width:14,height:14}),"View"]}),s.jsxs("button",{className:gt.item,onClick:d,children:[s.jsx(tn,{width:14,height:14}),"Filter"]}),(g||b)&&s.jsx("p",{className:gt.sectionName,children:"Row actions"}),g&&s.jsxs("button",{className:gt.item,onClick:x,children:[s.jsx(yt,{className:"text-(--text-color-tertiary)",width:14,height:14}),"Show record"]}),b&&s.jsxs("button",{className:gt.item,onClick:()=>i("drill"),children:[s.jsx(yt,{className:"text-(--text-color-tertiary) rotate-180",width:14,height:14}),"Drill down"]})]}),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(yt,{className:"text-(--text-color-secondary) rotate-270",width:16,height:16}),"Drill down"]}),s.jsx(xa,{rowIndex:t,onClose:()=>e.current?.close()})]}),r==="show-record"&&s.jsxs(s.Fragment,{children:[s.jsxs("button",{className:"flex gap-1 items-center cursor-pointer px-2 py-1 text-sm rounded-lg bg-gray-50 hover:bg-gray-100 mb-2",onClick:()=>i("cell"),children:[s.jsx(yt,{className:"text-(--text-color-secondary) rotate-270",width:16,height:16}),"Show record"]}),s.jsx(ph,{rowIndex:t,onClose:()=>e.current?.close()})]})]})})},gh={DESC:"",ASC:"rotate-180"},bh=(e,{column:t,value:n,fn:o})=>{const a=e.map(r=>({...r,isEnabled:r.column===t?!1:r.isEnabled}));return a.push({id:Je(),column:t,isEnabled:!0,value:n,fn:o,isAdvanced:!1}),a},vh=()=>{const{data:e}=l.useContext(Xe),{orderBy:t,updateOrderBy:n}=qd(),{setFilters:o,filters:a}=xo(),r=e?.result.columns||[],i=t[0],c=ge(e?.result.tables.length,1),u=(h,m)=>{On("Filter value","").then(d=>{d&&o(bh(a,{column:h,value:d,fn:m}))})};return s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("td",{children:"🥢"}),r.map(h=>s.jsxs("td",{className:R.headerCell,children:[s.jsxs("div",{className:"overflow-hidden",children:[c&&s.jsx("p",{className:"text-xs truncate italic text-(--text-color-primary)",children:h.table||"-"}),s.jsx("p",{className:"text-sm font-semibold truncate text-(--text-color-primary)",children:h.column})]}),s.jsxs("div",{className:R.headerActions,children:[s.jsx("button",{onClick:()=>n(h.alias),children:i?.column===h.alias?s.jsx(oh,{className:gh[i.direction],width:16,height:16}):s.jsx(rh,{width:16,height:16})}),s.jsx("button",{onClick:()=>u(h.full,h.fn),children:s.jsx(tn,{width:16,height:16})})]})]},h.full))]})})};function yh({value:e,actions:t}){if(e==="")return s.jsx("span",{className:"pointer-events-none text-black/30 truncate",children:"<EMPTY STRING>"});if(e==null)return s.jsx("span",{className:"pointer-events-none text-black/30",children:"<NULL>"});const n=wt(e);return t?.hasRecord||t?.hasDrill?s.jsxs("div",{className:"flex gap-1 items-center justify-between pointer-events-none",children:[s.jsx("span",{className:R.value,children:n}),s.jsxs("div",{className:"flex",children:[t.hasRecord&&s.jsx("span",{className:"text-gray-300 hover:text-green-600 hover:bg-gray-100 rounded p-0.5 cursor-pointer pointer-events-auto","data-cell-action":"ref","data-tooltip-id":"default-xs","data-tooltip-content":"Show record",children:s.jsx(yt,{className:"pointer-events-none",width:16,height:16})}),t.hasDrill&&s.jsx("span",{className:"text-gray-300 hover:text-blue-600 hover:bg-gray-100 rounded p-0.5 cursor-pointer pointer-events-auto","data-cell-action":"drill","data-tooltip-id":"default-xs","data-tooltip-content":"Show related rows",children:s.jsx(yt,{className:"pointer-events-none rotate-180",width:16,height:16})})]})]}):s.jsx("span",{className:R.value,children:n})}const wh=l.memo(({row:e,isLastRow:t,index:n,offset:o,colMeta:a})=>s.jsxs("tr",{className:I(R.tableRowCells,t&&"rounded-b-lg"),children:[s.jsx("td",{"data-row":n,children:s.jsxs("button",{"data-cell-action":"drill-all",className:R.rowIndexBtn,children:[s.jsx(yt,{className:"rotate-180 pointer-events-none",width:16,height:16}),s.jsx("span",{children:n+1+o})]})}),e.map((r,i)=>s.jsx("td",{className:R.cell,"data-row":n,"data-col":i,children:s.jsx(yh,{value:r,actions:a.get(i)})},i))]})),Ch=e=>{if(e.tagName==="TD")return e;let t=e.parentElement,n=5;for(;t&&n>=0;){if(t.tagName==="TD")return t;t=t.parentElement,n--}},Yo=e=>{const t=Ch(e);if(!t)return;const n=parseInt(t.dataset.row,10),o=parseInt(t.dataset.col,10);return{row:n,col:Number.isNaN(o)?void 0:o}},jh=()=>{const{data:e,error:t,isLoading:n,isFetching:o}=l.useContext(Xe),{dataSourceId:a,getColumnByIndex:r,getValueByIndex:i}=l.useContext(Pe),{state:{page:c,size:u}}=l.useContext(Ce),h=l.useRef(null),m=uo(t),d=fa(),[x,p]=l.useState(),b=f=>{const w=f.target,C=w.dataset?.cellAction,_=Yo(w);if(C==="ref"&&ge(_?.col,-1)){const A=i(_.row,_.col),S=r(_.col);S&&Mn({tableName:S.ref.table,dataSourceId:a,entityId:[[S.ref.field,A]]})}else(C==="drill"||C==="drill-all")&&(p(_),d.open(f))},g=f=>{const w=Yo(f.target);w&&(p(w),h.current?.open(f),f.preventDefault(),f.stopPropagation())},v=c*u,y=l.useMemo(()=>{const f=new Map;return e&&e.result.columns.forEach((w,C)=>{f.set(C,{hasRecord:!!w.ref,hasDrill:!!w.referencedBy})}),f},[e]);return s.jsxs(s.Fragment,{children:[x&&d.show&&s.jsx(sh,{handler:d,rowIndex:x.row,colIndex:x.col}),s.jsx(xh,{ref:h,col:x?.col,row:x?.row,onClosed:()=>{p(void 0)}}),m&&s.jsx(me,{variant:"danger",children:m}),n&&s.jsx("div",{className:R.tableLoading,children:"Loading data"}),e&&s.jsxs("table",{className:I(R.table,o&&R.semiTransparent),onClick:b,onContextMenu:g,children:[s.jsx(vh,{}),s.jsxs("tbody",{children:[e.result.rows?.length<1&&s.jsx("tr",{className:R.tableEmpty,children:s.jsx("td",{colSpan:e.result.columns.length+1,children:"No data"})}),e.result.rows?.map((f,w)=>s.jsx(wh,{index:w,offset:v,row:f,colMeta:y,isLastRow:w===e.result.rows.length-1},w))]})]})]})},va=()=>{const{state:e,setState:t}=l.useContext(Ce),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}},Nh=()=>ee({mutationFn:async e=>{const{data:t}=await $.post("/saved-queries",e);return t.data},onSuccess:()=>{K.invalidateQueries({queryKey:["queries"]}),Zt()}}),_h=()=>ee({mutationFn:async e=>$.delete("/saved-queries/"+e),onSuccess:()=>{Zt()}}),Sh=()=>ee({mutationFn:async({id:e,payload:t})=>{const{data:n}=await $.patch("/saved-queries/"+e,t);return n.data},onSuccess:()=>{Zt(),ac()}}),[ys,go]=ye({filters:!1,joins:!1,columns:!1,groupBy:!1,aggregate:!1}),Fe=e=>go(t=>({...t,[e]:!0})),ws=e=>go(t=>({...t,[e]:!1})),as=e=>go(t=>({...t,[e]:!t[e]})),Gt=Math.min,jt=Math.max,is=Math.round,Yn=Math.floor,Be=e=>({x:e,y:e}),kh={left:"right",right:"left",bottom:"top",top:"bottom"},Eh={start:"end",end:"start"};function Qs(e,t,n){return jt(e,Gt(t,n))}function Dn(e,t){return typeof e=="function"?e(t):e}function St(e){return e.split("-")[0]}function $n(e){return e.split("-")[1]}function ya(e){return e==="x"?"y":"x"}function bo(e){return e==="y"?"height":"width"}const Rh=new Set(["top","bottom"]);function ot(e){return Rh.has(St(e))?"y":"x"}function vo(e){return ya(ot(e))}function Lh(e,t,n){n===void 0&&(n=!1);const o=$n(e),a=vo(e),r=bo(a);let i=a==="x"?o===(n?"end":"start")?"right":"left":o==="start"?"bottom":"top";return t.reference[r]>t.floating[r]&&(i=ls(i)),[i,ls(i)]}function Th(e){const t=ls(e);return[Ks(e),t,Ks(t)]}function Ks(e){return e.replace(/start|end/g,t=>Eh[t])}const Jo=["left","right"],Xo=["right","left"],Ah=["top","bottom"],Ih=["bottom","top"];function Ph(e,t,n){switch(e){case"top":case"bottom":return n?t?Xo:Jo:t?Jo:Xo;case"left":case"right":return t?Ah:Ih;default:return[]}}function Mh(e,t,n,o){const a=$n(e);let r=Ph(St(e),n==="start",o);return a&&(r=r.map(i=>i+"-"+a),t&&(r=r.concat(r.map(Ks)))),r}function ls(e){return e.replace(/left|right|bottom|top/g,t=>kh[t])}function Oh(e){return{top:0,right:0,bottom:0,left:0,...e}}function wa(e){return typeof e!="number"?Oh(e):{top:e,right:e,bottom:e,left:e}}function cs(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 Zo(e,t,n){let{reference:o,floating:a}=e;const r=ot(t),i=vo(t),c=bo(i),u=St(t),h=r==="y",m=o.x+o.width/2-a.width/2,d=o.y+o.height/2-a.height/2,x=o[c]/2-a[c]/2;let p;switch(u){case"top":p={x:m,y:o.y-a.height};break;case"bottom":p={x:m,y:o.y+o.height};break;case"right":p={x:o.x+o.width,y:d};break;case"left":p={x:o.x-a.width,y:d};break;default:p={x:o.x,y:o.y}}switch($n(t)){case"start":p[i]-=x*(n&&h?-1:1);break;case"end":p[i]+=x*(n&&h?-1:1);break}return p}const Dh=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 h=await i.getElementRects({reference:e,floating:t,strategy:a}),{x:m,y:d}=Zo(h,o,u),x=o,p={},b=0;for(let g=0;g<c.length;g++){const{name:v,fn:y}=c[g],{x:f,y:w,data:C,reset:_}=await y({x:m,y:d,initialPlacement:o,placement:x,strategy:a,middlewareData:p,rects:h,platform:i,elements:{reference:e,floating:t}});m=f??m,d=w??d,p={...p,[v]:{...p[v],...C}},_&&b<=50&&(b++,typeof _=="object"&&(_.placement&&(x=_.placement),_.rects&&(h=_.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:a}):_.rects),{x:m,y:d}=Zo(h,x,u)),g=-1)}return{x:m,y:d,placement:x,strategy:a,middlewareData:p}};async function Ca(e,t){var n;t===void 0&&(t={});const{x:o,y:a,platform:r,rects:i,elements:c,strategy:u}=e,{boundary:h="clippingAncestors",rootBoundary:m="viewport",elementContext:d="floating",altBoundary:x=!1,padding:p=0}=Dn(t,e),b=wa(p),v=c[x?d==="floating"?"reference":"floating":d],y=cs(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:h,rootBoundary:m,strategy:u})),f=d==="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},_=cs(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 $h=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:h,padding:m=0}=Dn(e,t)||{};if(h==null)return{};const d=wa(m),x={x:n,y:o},p=vo(a),b=bo(p),g=await i.getDimensions(h),v=p==="y",y=v?"top":"left",f=v?"bottom":"right",w=v?"clientHeight":"clientWidth",C=r.reference[b]+r.reference[p]-x[p]-r.floating[b],_=x[p]-r.reference[p],A=await(i.getOffsetParent==null?void 0:i.getOffsetParent(h));let S=A?A[w]:0;(!S||!await(i.isElement==null?void 0:i.isElement(A)))&&(S=c.floating[w]||r.floating[b]);const P=C/2-_/2,j=S/2-g[b]/2-1,k=Gt(d[y],j),X=Gt(d[f],j),je=k,Me=S-g[b]-X,q=S/2-g[b]/2+P,le=Qs(je,q,Me),oe=!u.arrow&&$n(a)!=null&&q!==le&&r.reference[b]/2-(q<je?k:X)-g[b]/2<0,Z=oe?q<je?q-je:q-Me:0;return{[p]:x[p]+Z,data:{[p]:le,centerOffset:q-le-Z,...oe&&{alignmentOffset:Z}},reset:oe}}}),Fh=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:h}=t,{mainAxis:m=!0,crossAxis:d=!0,fallbackPlacements:x,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:b="none",flipAlignment:g=!0,...v}=Dn(e,t);if((n=r.arrow)!=null&&n.alignmentOffset)return{};const y=St(a),f=ot(c),w=St(c)===c,C=await(u.isRTL==null?void 0:u.isRTL(h.floating)),_=x||(w||!g?[ls(c)]:Th(c)),A=b!=="none";!x&&A&&_.push(...Mh(c,g,b,C));const S=[c,..._],P=await Ca(t,v),j=[];let k=((o=r.flip)==null?void 0:o.overflows)||[];if(m&&j.push(P[y]),d){const q=Lh(a,i,C);j.push(P[q[0]],P[q[1]])}if(k=[...k,{placement:a,overflows:j}],!j.every(q=>q<=0)){var X,je;const q=(((X=r.flip)==null?void 0:X.index)||0)+1,le=S[q];if(le&&(!(d==="alignment"?f!==ot(le):!1)||k.every(H=>ot(H.placement)===f?H.overflows[0]>0:!0)))return{data:{index:q,overflows:k},reset:{placement:le}};let oe=(je=k.filter(Z=>Z.overflows[0]<=0).sort((Z,H)=>Z.overflows[1]-H.overflows[1])[0])==null?void 0:je.placement;if(!oe)switch(p){case"bestFit":{var Me;const Z=(Me=k.filter(H=>{if(A){const re=ot(H.placement);return re===f||re==="y"}return!0}).map(H=>[H.placement,H.overflows.filter(re=>re>0).reduce((re,Ve)=>re+Ve,0)]).sort((H,re)=>H[1]-re[1])[0])==null?void 0:Me[0];Z&&(oe=Z);break}case"initialPlacement":oe=c;break}if(a!==oe)return{reset:{placement:oe}}}return{}}}},Bh=new Set(["left","top"]);async function qh(e,t){const{placement:n,platform:o,elements:a}=e,r=await(o.isRTL==null?void 0:o.isRTL(a.floating)),i=St(n),c=$n(n),u=ot(n)==="y",h=Bh.has(i)?-1:1,m=r&&u?-1:1,d=Dn(t,e);let{mainAxis:x,crossAxis:p,alignmentAxis:b}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return c&&typeof b=="number"&&(p=c==="end"?b*-1:b),u?{x:p*m,y:x*h}:{x:x*h,y:p*m}}const Wh=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 qh(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}}}}},Uh=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}=Dn(e,t),h={x:n,y:o},m=await Ca(t,u),d=ot(St(a)),x=ya(d);let p=h[x],b=h[d];if(r){const v=x==="y"?"top":"left",y=x==="y"?"bottom":"right",f=p+m[v],w=p-m[y];p=Qs(f,p,w)}if(i){const v=d==="y"?"top":"left",y=d==="y"?"bottom":"right",f=b+m[v],w=b-m[y];b=Qs(f,b,w)}const g=c.fn({...t,[x]:p,[d]:b});return{...g,data:{x:g.x-n,y:g.y-o,enabled:{[x]:r,[d]:i}}}}}};function Cs(){return typeof window<"u"}function nn(e){return ja(e)?(e.nodeName||"").toLowerCase():"#document"}function xe(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function ze(e){var t;return(t=(ja(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function ja(e){return Cs()?e instanceof Node||e instanceof xe(e).Node:!1}function Ae(e){return Cs()?e instanceof Element||e instanceof xe(e).Element:!1}function We(e){return Cs()?e instanceof HTMLElement||e instanceof xe(e).HTMLElement:!1}function er(e){return!Cs()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof xe(e).ShadowRoot}const Hh=new Set(["inline","contents"]);function Fn(e){const{overflow:t,overflowX:n,overflowY:o,display:a}=Ie(e);return/auto|scroll|overlay|hidden|clip/.test(t+o+n)&&!Hh.has(a)}const zh=new Set(["table","td","th"]);function Vh(e){return zh.has(nn(e))}const Qh=[":popover-open",":modal"];function js(e){return Qh.some(t=>{try{return e.matches(t)}catch{return!1}})}const Kh=["transform","translate","scale","rotate","perspective"],Gh=["transform","translate","scale","rotate","perspective","filter"],Yh=["paint","layout","strict","content"];function yo(e){const t=wo(),n=Ae(e)?Ie(e):e;return Kh.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)||Gh.some(o=>(n.willChange||"").includes(o))||Yh.some(o=>(n.contain||"").includes(o))}function Jh(e){let t=at(e);for(;We(t)&&!Yt(t);){if(yo(t))return t;if(js(t))return null;t=at(t)}return null}function wo(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Xh=new Set(["html","body","#document"]);function Yt(e){return Xh.has(nn(e))}function Ie(e){return xe(e).getComputedStyle(e)}function Ns(e){return Ae(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function at(e){if(nn(e)==="html")return e;const t=e.assignedSlot||e.parentNode||er(e)&&e.host||ze(e);return er(t)?t.host:t}function Na(e){const t=at(e);return Yt(t)?e.ownerDocument?e.ownerDocument.body:e.body:We(t)&&Fn(t)?t:Na(t)}function _n(e,t,n){var o;t===void 0&&(t=[]),n===void 0&&(n=!0);const a=Na(e),r=a===((o=e.ownerDocument)==null?void 0:o.body),i=xe(a);if(r){const c=Gs(i);return t.concat(i,i.visualViewport||[],Fn(a)?a:[],c&&n?_n(c):[])}return t.concat(a,_n(a,[],n))}function Gs(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function _a(e){const t=Ie(e);let n=parseFloat(t.width)||0,o=parseFloat(t.height)||0;const a=We(e),r=a?e.offsetWidth:n,i=a?e.offsetHeight:o,c=is(n)!==r||is(o)!==i;return c&&(n=r,o=i),{width:n,height:o,$:c}}function Co(e){return Ae(e)?e:e.contextElement}function Vt(e){const t=Co(e);if(!We(t))return Be(1);const n=t.getBoundingClientRect(),{width:o,height:a,$:r}=_a(t);let i=(r?is(n.width):n.width)/o,c=(r?is(n.height):n.height)/a;return(!i||!Number.isFinite(i))&&(i=1),(!c||!Number.isFinite(c))&&(c=1),{x:i,y:c}}const Zh=Be(0);function Sa(e){const t=xe(e);return!wo()||!t.visualViewport?Zh:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function em(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==xe(e)?!1:t}function kt(e,t,n,o){t===void 0&&(t=!1),n===void 0&&(n=!1);const a=e.getBoundingClientRect(),r=Co(e);let i=Be(1);t&&(o?Ae(o)&&(i=Vt(o)):i=Vt(e));const c=em(r,n,o)?Sa(r):Be(0);let u=(a.left+c.x)/i.x,h=(a.top+c.y)/i.y,m=a.width/i.x,d=a.height/i.y;if(r){const x=xe(r),p=o&&Ae(o)?xe(o):o;let b=x,g=Gs(b);for(;g&&o&&p!==b;){const v=Vt(g),y=g.getBoundingClientRect(),f=Ie(g),w=y.left+(g.clientLeft+parseFloat(f.paddingLeft))*v.x,C=y.top+(g.clientTop+parseFloat(f.paddingTop))*v.y;u*=v.x,h*=v.y,m*=v.x,d*=v.y,u+=w,h+=C,b=xe(g),g=Gs(b)}}return cs({width:m,height:d,x:u,y:h})}function _s(e,t){const n=Ns(e).scrollLeft;return t?t.left+n:kt(ze(e)).left+n}function ka(e,t){const n=e.getBoundingClientRect(),o=n.left+t.scrollLeft-_s(e,n),a=n.top+t.scrollTop;return{x:o,y:a}}function tm(e){let{elements:t,rect:n,offsetParent:o,strategy:a}=e;const r=a==="fixed",i=ze(o),c=t?js(t.floating):!1;if(o===i||c&&r)return n;let u={scrollLeft:0,scrollTop:0},h=Be(1);const m=Be(0),d=We(o);if((d||!d&&!r)&&((nn(o)!=="body"||Fn(i))&&(u=Ns(o)),We(o))){const p=kt(o);h=Vt(o),m.x=p.x+o.clientLeft,m.y=p.y+o.clientTop}const x=i&&!d&&!r?ka(i,u):Be(0);return{width:n.width*h.x,height:n.height*h.y,x:n.x*h.x-u.scrollLeft*h.x+m.x+x.x,y:n.y*h.y-u.scrollTop*h.y+m.y+x.y}}function nm(e){return Array.from(e.getClientRects())}function sm(e){const t=ze(e),n=Ns(e),o=e.ownerDocument.body,a=jt(t.scrollWidth,t.clientWidth,o.scrollWidth,o.clientWidth),r=jt(t.scrollHeight,t.clientHeight,o.scrollHeight,o.clientHeight);let i=-n.scrollLeft+_s(e);const c=-n.scrollTop;return Ie(o).direction==="rtl"&&(i+=jt(t.clientWidth,o.clientWidth)-a),{width:a,height:r,x:i,y:c}}const tr=25;function om(e,t){const n=xe(e),o=ze(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=wo();(!m||m&&t==="fixed")&&(c=a.offsetLeft,u=a.offsetTop)}const h=_s(o);if(h<=0){const m=o.ownerDocument,d=m.body,x=getComputedStyle(d),p=m.compatMode==="CSS1Compat"&&parseFloat(x.marginLeft)+parseFloat(x.marginRight)||0,b=Math.abs(o.clientWidth-d.clientWidth-p);b<=tr&&(r-=b)}else h<=tr&&(r+=h);return{width:r,height:i,x:c,y:u}}const rm=new Set(["absolute","fixed"]);function am(e,t){const n=kt(e,!0,t==="fixed"),o=n.top+e.clientTop,a=n.left+e.clientLeft,r=We(e)?Vt(e):Be(1),i=e.clientWidth*r.x,c=e.clientHeight*r.y,u=a*r.x,h=o*r.y;return{width:i,height:c,x:u,y:h}}function nr(e,t,n){let o;if(t==="viewport")o=om(e,n);else if(t==="document")o=sm(ze(e));else if(Ae(t))o=am(t,n);else{const a=Sa(e);o={x:t.x-a.x,y:t.y-a.y,width:t.width,height:t.height}}return cs(o)}function Ea(e,t){const n=at(e);return n===t||!Ae(n)||Yt(n)?!1:Ie(n).position==="fixed"||Ea(n,t)}function im(e,t){const n=t.get(e);if(n)return n;let o=_n(e,[],!1).filter(c=>Ae(c)&&nn(c)!=="body"),a=null;const r=Ie(e).position==="fixed";let i=r?at(e):e;for(;Ae(i)&&!Yt(i);){const c=Ie(i),u=yo(i);!u&&c.position==="fixed"&&(a=null),(r?!u&&!a:!u&&c.position==="static"&&!!a&&rm.has(a.position)||Fn(i)&&!u&&Ea(e,i))?o=o.filter(m=>m!==i):a=c,i=at(i)}return t.set(e,o),o}function lm(e){let{element:t,boundary:n,rootBoundary:o,strategy:a}=e;const i=[...n==="clippingAncestors"?js(t)?[]:im(t,this._c):[].concat(n),o],c=i[0],u=i.reduce((h,m)=>{const d=nr(t,m,a);return h.top=jt(d.top,h.top),h.right=Gt(d.right,h.right),h.bottom=Gt(d.bottom,h.bottom),h.left=jt(d.left,h.left),h},nr(t,c,a));return{width:u.right-u.left,height:u.bottom-u.top,x:u.left,y:u.top}}function cm(e){const{width:t,height:n}=_a(e);return{width:t,height:n}}function um(e,t,n){const o=We(t),a=ze(t),r=n==="fixed",i=kt(e,!0,r,t);let c={scrollLeft:0,scrollTop:0};const u=Be(0);function h(){u.x=_s(a)}if(o||!o&&!r)if((nn(t)!=="body"||Fn(a))&&(c=Ns(t)),o){const p=kt(t,!0,r,t);u.x=p.x+t.clientLeft,u.y=p.y+t.clientTop}else a&&h();r&&!o&&a&&h();const m=a&&!o&&!r?ka(a,c):Be(0),d=i.left+c.scrollLeft-u.x-m.x,x=i.top+c.scrollTop-u.y-m.y;return{x:d,y:x,width:i.width,height:i.height}}function Ms(e){return Ie(e).position==="static"}function sr(e,t){if(!We(e)||Ie(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return ze(e)===n&&(n=n.ownerDocument.body),n}function Ra(e,t){const n=xe(e);if(js(e))return n;if(!We(e)){let a=at(e);for(;a&&!Yt(a);){if(Ae(a)&&!Ms(a))return a;a=at(a)}return n}let o=sr(e,t);for(;o&&Vh(o)&&Ms(o);)o=sr(o,t);return o&&Yt(o)&&Ms(o)&&!yo(o)?n:o||Jh(e)||n}const dm=async function(e){const t=this.getOffsetParent||Ra,n=this.getDimensions,o=await n(e.floating);return{reference:um(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}};function hm(e){return Ie(e).direction==="rtl"}const mm={convertOffsetParentRelativeRectToViewportRelativeRect:tm,getDocumentElement:ze,getClippingRect:lm,getOffsetParent:Ra,getElementRects:dm,getClientRects:nm,getDimensions:cm,getScale:Vt,isElement:Ae,isRTL:hm};function La(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function fm(e,t){let n=null,o;const a=ze(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 h=e.getBoundingClientRect(),{left:m,top:d,width:x,height:p}=h;if(c||t(),!x||!p)return;const b=Yn(d),g=Yn(a.clientWidth-(m+x)),v=Yn(a.clientHeight-(d+p)),y=Yn(m),w={rootMargin:-b+"px "+-g+"px "+-v+"px "+-y+"px",threshold:jt(0,Gt(1,u))||1};let C=!0;function _(A){const S=A[0].intersectionRatio;if(S!==u){if(!C)return i();S?i(!1,S):o=setTimeout(()=>{i(!1,1e-7)},1e3)}S===1&&!La(h,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 pm(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,h=Co(e),m=a||r?[...h?_n(h):[],..._n(t)]:[];m.forEach(y=>{a&&y.addEventListener("scroll",n,{passive:!0}),r&&y.addEventListener("resize",n)});const d=h&&c?fm(h,n):null;let x=-1,p=null;i&&(p=new ResizeObserver(y=>{let[f]=y;f&&f.target===h&&p&&(p.unobserve(t),cancelAnimationFrame(x),x=requestAnimationFrame(()=>{var w;(w=p)==null||w.observe(t)})),n()}),h&&!u&&p.observe(h),p.observe(t));let b,g=u?kt(e):null;u&&v();function v(){const y=kt(e);g&&!La(g,y)&&n(),g=y,b=requestAnimationFrame(v)}return n(),()=>{var y;m.forEach(f=>{a&&f.removeEventListener("scroll",n),r&&f.removeEventListener("resize",n)}),d?.(),(y=p)==null||y.disconnect(),p=null,u&&cancelAnimationFrame(b)}}const xm=Wh,gm=Uh,bm=Fh,vm=$h,or=(e,t,n)=>{const o=new Map,a={platform:mm,...n},r={...a.platform,_c:o};return Dh(e,t,{...a,platform:r})};var Os={exports:{}};var rr;function ym(){return rr||(rr=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})()})(Os)),Os.exports}var wm=ym();const Ys=li(wm);var ar={};const Cm="react-tooltip-core-styles",jm="react-tooltip-base-styles",ir={core:!1,base:!1};function lr({css:e,id:t=jm,type:n="base",ref:o}){var a,r;if(!e||typeof document>"u"||ir[n]||n==="core"&&typeof process<"u"&&(!((a=process==null?void 0:ar)===null||a===void 0)&&a.REACT_TOOLTIP_DISABLE_CORE_STYLES)||n!=="base"&&typeof process<"u"&&(!((r=process==null?void 0:ar)===null||r===void 0)&&r.REACT_TOOLTIP_DISABLE_BASE_STYLES))return;n==="core"&&(t=Cm),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)),ir[n]=!0}const cr=async({elementReference:e=null,tooltipReference:t=null,tooltipArrowReference:n=null,place:o="top",offset:a=10,strategy:r="absolute",middlewares:i=[xm(Number(a)),bm({fallbackAxisSideDirection:"start"}),gm({padding:5})],border:c,arrowSize:u=8})=>{if(!e)return{tooltipStyles:{},tooltipArrowStyles:{},place:o};if(t===null)return{tooltipStyles:{},tooltipArrowStyles:{},place:o};const h=i;return n?(h.push(vm({element:n,padding:5})),or(e,t,{placement:o,strategy:r,middleware:h}).then((({x:m,y:d,placement:x,middlewareData:p})=>{var b,g;const v={left:`${m}px`,top:`${d}px`,border:c},{x:y,y:f}=(b=p.arrow)!==null&&b!==void 0?b:{x:0,y:0},w=(g={top:"bottom",right:"left",bottom:"top",left:"right"}[x.split("-")[0]])!==null&&g!==void 0?g:"bottom",C=c&&{borderBottom:c,borderRight:c};let _=0;if(c){const A=`${c}`.match(/(\d+)px/);_=A?.[1]?Number(A[1]):1}return{tooltipStyles:v,tooltipArrowStyles:{left:y!=null?`${y}px`:"",top:f!=null?`${f}px`:"",right:"",bottom:"",...C,[w]:`-${u/2+_}px`},place:x}}))):or(e,t,{placement:"bottom",strategy:r,middleware:h}).then((({x:m,y:d,placement:x})=>({tooltipStyles:{left:`${m}px`,top:`${d}px`},tooltipArrowStyles:{},place:x})))},ur=(e,t)=>!("CSS"in window&&"supports"in window.CSS)||window.CSS.supports(e,t),dr=(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},hr=e=>e!==null&&!Array.isArray(e)&&typeof e=="object",Js=(e,t)=>{if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every(((a,r)=>Js(a,t[r])));if(Array.isArray(e)!==Array.isArray(t))return!1;if(!hr(e)||!hr(t))return e===t;const n=Object.keys(e),o=Object.keys(t);return n.length===o.length&&n.every((a=>Js(e[a],t[a])))},Nm=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"}))},mr=e=>{if(!e)return null;let t=e.parentElement;for(;t;){if(Nm(t))return t;t=t.parentElement}return document.scrollingElement||document.documentElement},_m=typeof window<"u"?l.useLayoutEffect:l.useEffect,_e=e=>{e.current&&(clearTimeout(e.current),e.current=null)},Sm="DEFAULT_TOOLTIP_ID",km={anchorRefs:new Set,activeAnchor:{current:null},attach:()=>{},detach:()=>{},setActiveAnchor:()=>{}},Em=l.createContext({getTooltipData:()=>km});function Ta(e=Sm){return l.useContext(Em).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"},Ds={tooltip:"styles-module_tooltip__mnnfp",arrow:"styles-module_arrow__K0L3T",dark:"styles-module_dark__xNqje",light:"styles-module_light__Z6W-X",success:"styles-module_success__A2AKt",warning:"styles-module_warning__SCK0X",error:"styles-module_error__JvumD",info:"styles-module_info__BWdHW"};const Rm=({forwardRef:e,id:t,className:n,classNameArrow:o,variant:a="dark",anchorId:r,anchorSelect:i,place:c="top",offset:u=10,events:h=["hover"],openOnClick:m=!1,positionStrategy:d="absolute",middlewares:x,wrapper:p,delayShow:b=0,delayHide:g=0,float:v=!1,hidden:y=!1,noArrow:f=!1,clickable:w=!1,closeOnEsc:C=!1,closeOnScroll:_=!1,closeOnResize:A=!1,openEvents:S,closeEvents:P,globalCloseEvents:j,imperativeModeOnly:k,style:X,position:je,afterShow:Me,afterHide:q,disableTooltip:le,content:oe,contentWrapperRef:Z,isOpen:H,defaultIsOpen:re=!1,setIsOpen:Ve,previousActiveAnchor:sn,activeAnchor:W,setActiveAnchor:Rt,border:Bn,opacity:qn,arrowColor:Wn,arrowSize:Lt=8,role:Ss="tooltip"})=>{var ct;const ce=l.useRef(null),Tt=l.useRef(null),Le=l.useRef(null),ut=l.useRef(null),At=l.useRef(null),[dt,Un]=l.useState({tooltipStyles:{},tooltipArrowStyles:{},place:c}),[ue,on]=l.useState(!1),[It,Ze]=l.useState(!1),[V,Pt]=l.useState(null),Hn=l.useRef(!1),Mt=l.useRef(null),{anchorRefs:zn,setActiveAnchor:rn}=Ta(t),an=l.useRef(!1),[et,ln]=l.useState([]),ht=l.useRef(!1),Ot=m||h.includes("click"),Vn=Ot||S?.click||S?.dblclick||S?.mousedown,cn=S?{...S}:{mouseover:!0,focus:!0,mouseenter:!1,click:!1,dblclick:!1,mousedown:!1};!S&&Ot&&Object.assign(cn,{mouseenter:!1,focus:!1,mouseover:!1,click:!0});const mt=P?{...P}:{mouseout:!0,blur:!0,mouseleave:!1,click:!1,dblclick:!1,mouseup:!1};!P&&Ot&&Object.assign(mt,{mouseleave:!1,blur:!1,mouseout:!1});const ne=j?{...j}:{escape:C||!1,scroll:_||!1,resize:A||!1,clickOutsideAnchor:Vn||!1};k&&(Object.assign(cn,{mouseover:!1,focus:!1,mouseenter:!1,click:!1,dblclick:!1,mousedown:!1}),Object.assign(mt,{mouseout:!1,blur:!1,mouseleave:!1,click:!1,dblclick:!1,mouseup:!1}),Object.assign(ne,{escape:!1,scroll:!1,resize:!1,clickOutsideAnchor:!1})),_m((()=>(ht.current=!0,()=>{ht.current=!1})),[]);const de=N=>{ht.current&&(N&&Ze(!0),setTimeout((()=>{ht.current&&(Ve?.(N),H===void 0&&on(N))}),10))};l.useEffect((()=>{if(t){if(ue){L(sn);const E=N(W),B=[...new Set([...E,t])].filter(Boolean).join(" ");W?.setAttribute("aria-describedby",B)}else L(W);return()=>{L(W),L(sn)}}function N(E){var B;return((B=E?.getAttribute("aria-describedby"))===null||B===void 0?void 0:B.split(" "))||[]}function L(E){const B=N(E).filter((te=>te!==t));B.length?E?.setAttribute("aria-describedby",B.join(" ")):E?.removeAttribute("aria-describedby")}}),[W,ue,t,sn]),l.useEffect((()=>{if(H===void 0)return()=>null;H&&Ze(!0);const N=setTimeout((()=>{on(H)}),10);return()=>{clearTimeout(N)}}),[H]),l.useEffect((()=>{if(ue!==Hn.current)if(_e(At),Hn.current=ue,ue)Me?.();else{const N=(L=>{const E=L.match(/^([\d.]+)(ms|s)$/);if(!E)return 0;const[,B,te]=E;return Number(B)*(te==="ms"?1:1e3)})(getComputedStyle(document.body).getPropertyValue("--rt-transition-show-delay"));At.current=setTimeout((()=>{Ze(!1),Pt(null),q?.()}),N+25)}}),[ue]);const un=N=>{Un((L=>Js(L,N)?L:N))},dn=(N=b)=>{_e(Le),It?de(!0):Le.current=setTimeout((()=>{de(!0)}),N)},Dt=(N=g)=>{_e(ut),ut.current=setTimeout((()=>{an.current||de(!1)}),N)},hn=N=>{var L;if(!N)return;const E=(L=N.currentTarget)!==null&&L!==void 0?L:N.target;if(!E?.isConnected)return Rt(null),void rn({current:null});b?dn():de(!0),Rt(E),rn({current:E}),_e(ut)},$t=()=>{w?Dt(g||100):g?Dt():de(!1),_e(Le)},Ft=({x:N,y:L})=>{var E;const B={getBoundingClientRect:()=>({x:N,y:L,width:0,height:0,top:L,left:N,right:N,bottom:L})};cr({place:(E=V?.place)!==null&&E!==void 0?E:c,offset:u,elementReference:B,tooltipReference:ce.current,tooltipArrowReference:Tt.current,strategy:d,middlewares:x,border:Bn,arrowSize:Lt}).then((te=>{un(te)}))},Bt=N=>{if(!N)return;const L=N,E={x:L.clientX,y:L.clientY};Ft(E),Mt.current=E},mn=N=>{var L;if(!ue)return;const E=N.target;E.isConnected&&(!((L=ce.current)===null||L===void 0)&&L.contains(E)||[document.querySelector(`[id='${r}']`),...et].some((B=>B?.contains(E)))||(de(!1),_e(Le)))},Qn=dr(hn,50),G=dr($t,50),ae=N=>{G.cancel(),Qn(N)},T=()=>{Qn.cancel(),G()},M=l.useCallback((()=>{var N,L;const E=(N=V?.position)!==null&&N!==void 0?N:je;E?Ft(E):v?Mt.current&&Ft(Mt.current):W?.isConnected&&cr({place:(L=V?.place)!==null&&L!==void 0?L:c,offset:u,elementReference:W,tooltipReference:ce.current,tooltipArrowReference:Tt.current,strategy:d,middlewares:x,border:Bn,arrowSize:Lt}).then((B=>{ht.current&&un(B)}))}),[ue,W,oe,X,c,V?.place,u,d,je,V?.position,v,Lt]);l.useEffect((()=>{var N,L;const E=new Set(zn);et.forEach((F=>{le?.(F)||E.add({current:F})}));const B=document.querySelector(`[id='${r}']`);B&&!le?.(B)&&E.add({current:B});const te=()=>{de(!1)},Oe=mr(W),De=mr(ce.current);ne.scroll&&(window.addEventListener("scroll",te),Oe?.addEventListener("scroll",te),De?.addEventListener("scroll",te));let ie=null;ne.resize?window.addEventListener("resize",te):W&&ce.current&&(ie=pm(W,ce.current,M,{ancestorResize:!0,elementResize:!0,layoutShift:!0}));const Ne=F=>{F.key==="Escape"&&de(!1)};ne.escape&&window.addEventListener("keydown",Ne),ne.clickOutsideAnchor&&window.addEventListener("click",mn);const U=[],qt=F=>!!(F?.target&&W?.contains(F.target)),Ga=F=>{ue&&qt(F)||hn(F)},Ya=F=>{ue&&qt(F)&&$t()},ko=["mouseover","mouseout","mouseenter","mouseleave","focus","blur"],Eo=["click","dblclick","mousedown","mouseup"];Object.entries(cn).forEach((([F,Qe])=>{Qe&&(ko.includes(F)?U.push({event:F,listener:ae}):Eo.includes(F)&&U.push({event:F,listener:Ga}))})),Object.entries(mt).forEach((([F,Qe])=>{Qe&&(ko.includes(F)?U.push({event:F,listener:T}):Eo.includes(F)&&U.push({event:F,listener:Ya}))})),v&&U.push({event:"pointermove",listener:Bt});const Ro=()=>{an.current=!0},Lo=()=>{an.current=!1,$t()},To=w&&(mt.mouseout||mt.mouseleave);return To&&((N=ce.current)===null||N===void 0||N.addEventListener("mouseover",Ro),(L=ce.current)===null||L===void 0||L.addEventListener("mouseout",Lo)),U.forEach((({event:F,listener:Qe})=>{E.forEach((ks=>{var fn;(fn=ks.current)===null||fn===void 0||fn.addEventListener(F,Qe)}))})),()=>{var F,Qe;ne.scroll&&(window.removeEventListener("scroll",te),Oe?.removeEventListener("scroll",te),De?.removeEventListener("scroll",te)),ne.resize?window.removeEventListener("resize",te):ie?.(),ne.clickOutsideAnchor&&window.removeEventListener("click",mn),ne.escape&&window.removeEventListener("keydown",Ne),To&&((F=ce.current)===null||F===void 0||F.removeEventListener("mouseover",Ro),(Qe=ce.current)===null||Qe===void 0||Qe.removeEventListener("mouseout",Lo)),U.forEach((({event:ks,listener:fn})=>{E.forEach((Ja=>{var Es;(Es=Ja.current)===null||Es===void 0||Es.removeEventListener(ks,fn)}))}))}}),[W,M,It,zn,et,S,P,j,Ot,b,g]),l.useEffect((()=>{var N,L;let E=(L=(N=V?.anchorSelect)!==null&&N!==void 0?N:i)!==null&&L!==void 0?L:"";!E&&t&&(E=`[data-tooltip-id='${t.replace(/'/g,"\\'")}']`);const B=new MutationObserver((te=>{const Oe=[],De=[];te.forEach((ie=>{if(ie.type==="attributes"&&ie.attributeName==="data-tooltip-id"&&(ie.target.getAttribute("data-tooltip-id")===t?Oe.push(ie.target):ie.oldValue===t&&De.push(ie.target)),ie.type==="childList"){if(W){const Ne=[...ie.removedNodes].filter((U=>U.nodeType===1));if(E)try{De.push(...Ne.filter((U=>U.matches(E)))),De.push(...Ne.flatMap((U=>[...U.querySelectorAll(E)])))}catch{}Ne.some((U=>{var qt;return!!(!((qt=U?.contains)===null||qt===void 0)&&qt.call(U,W))&&(Ze(!1),de(!1),Rt(null),_e(Le),_e(ut),!0)}))}if(E)try{const Ne=[...ie.addedNodes].filter((U=>U.nodeType===1));Oe.push(...Ne.filter((U=>U.matches(E)))),Oe.push(...Ne.flatMap((U=>[...U.querySelectorAll(E)])))}catch{}}})),(Oe.length||De.length)&&ln((ie=>[...ie.filter((Ne=>!De.includes(Ne))),...Oe]))}));return B.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-tooltip-id"],attributeOldValue:!0}),()=>{B.disconnect()}}),[t,i,V?.anchorSelect,W]),l.useEffect((()=>{M()}),[M]),l.useEffect((()=>{if(!Z?.current)return()=>null;const N=new ResizeObserver((()=>{setTimeout((()=>M()))}));return N.observe(Z.current),()=>{N.disconnect()}}),[oe,Z?.current]),l.useEffect((()=>{var N;const L=document.querySelector(`[id='${r}']`),E=[...et,L];W&&E.includes(W)||Rt((N=et[0])!==null&&N!==void 0?N:L)}),[r,et,W]),l.useEffect((()=>(re&&de(!0),()=>{_e(Le),_e(ut)})),[]),l.useEffect((()=>{var N;let L=(N=V?.anchorSelect)!==null&&N!==void 0?N:i;if(!L&&t&&(L=`[data-tooltip-id='${t.replace(/'/g,"\\'")}']`),L)try{const E=Array.from(document.querySelectorAll(L));ln(E)}catch{ln([])}}),[t,i,V?.anchorSelect]),l.useEffect((()=>{Le.current&&(_e(Le),dn(b))}),[b]);const pe=(ct=V?.content)!==null&&ct!==void 0?ct:oe,ft=ue&&Object.keys(dt.tooltipStyles).length>0;return l.useImperativeHandle(e,(()=>({open:N=>{if(N?.anchorSelect)try{document.querySelector(N.anchorSelect)}catch{return void console.warn(`[react-tooltip] "${N.anchorSelect}" is not a valid CSS selector`)}Pt(N??null),N?.delay?dn(N.delay):de(!0)},close:N=>{N?.delay?Dt(N.delay):de(!1)},activeAnchor:W,place:dt.place,isOpen:!!(It&&!y&&pe&&ft)}))),It&&!y&&pe?nt.createElement(p,{id:t,role:Ss,className:Ys("react-tooltip",Ut.tooltip,Ds.tooltip,Ds[a],n,`react-tooltip__place-${dt.place}`,Ut[ft?"show":"closing"],ft?"react-tooltip__show":"react-tooltip__closing",d==="fixed"&&Ut.fixed,w&&Ut.clickable),onTransitionEnd:N=>{_e(At),ue||N.propertyName!=="opacity"||(Ze(!1),Pt(null),q?.())},style:{...X,...dt.tooltipStyles,opacity:qn!==void 0&&ft?qn:void 0},ref:ce},pe,nt.createElement(p,{className:Ys("react-tooltip-arrow",Ut.arrow,Ds.arrow,o,f&&Ut.noArrow),style:{...dt.tooltipArrowStyles,background:Wn?`linear-gradient(to right bottom, transparent 50%, ${Wn} 50%)`:void 0,"--rt-arrow-size":`${Lt}px`},ref:Tt})):null},Lm=({content:e})=>nt.createElement("span",{dangerouslySetInnerHTML:{__html:e}}),us=nt.forwardRef((({id:e,anchorId:t,anchorSelect:n,content:o,html:a,render:r,className:i,classNameArrow:c,variant:u="dark",place:h="top",offset:m=10,wrapper:d="div",children:x=null,events:p=["hover"],openOnClick:b=!1,positionStrategy:g="absolute",middlewares:v,delayShow:y=0,delayHide:f=0,float:w=!1,hidden:C=!1,noArrow:_=!1,clickable:A=!1,closeOnEsc:S=!1,closeOnScroll:P=!1,closeOnResize:j=!1,openEvents:k,closeEvents:X,globalCloseEvents:je,imperativeModeOnly:Me=!1,style:q,position:le,isOpen:oe,defaultIsOpen:Z=!1,disableStyleInjection:H=!1,border:re,opacity:Ve,arrowColor:sn,arrowSize:W,setIsOpen:Rt,afterShow:Bn,afterHide:qn,disableTooltip:Wn,role:Lt="tooltip"},Ss)=>{const[ct,ce]=l.useState(o),[Tt,Le]=l.useState(a),[ut,At]=l.useState(h),[dt,Un]=l.useState(u),[ue,on]=l.useState(m),[It,Ze]=l.useState(y),[V,Pt]=l.useState(f),[Hn,Mt]=l.useState(w),[zn,rn]=l.useState(C),[an,et]=l.useState(d),[ln,ht]=l.useState(p),[Ot,Vn]=l.useState(g),[cn,mt]=l.useState(null),[ne,de]=l.useState(null),un=l.useRef(null),dn=l.useRef(H),{anchorRefs:Dt,activeAnchor:hn}=Ta(e),$t=G=>G?.getAttributeNames().reduce(((ae,T)=>{var M;return T.startsWith("data-tooltip-")&&(ae[T.replace(/^data-tooltip-/,"")]=(M=G?.getAttribute(T))!==null&&M!==void 0?M:null),ae}),{}),Ft=G=>{const ae={place:T=>{var M;At((M=T)!==null&&M!==void 0?M:h)},content:T=>{ce(T??o)},html:T=>{Le(T??a)},variant:T=>{var M;Un((M=T)!==null&&M!==void 0?M:u)},offset:T=>{on(T===null?m:Number(T))},wrapper:T=>{var M;et((M=T)!==null&&M!==void 0?M:d)},events:T=>{const M=T?.split(" ");ht(M??p)},"position-strategy":T=>{var M;Vn((M=T)!==null&&M!==void 0?M:g)},"delay-show":T=>{Ze(T===null?y:Number(T))},"delay-hide":T=>{Pt(T===null?f:Number(T))},float:T=>{Mt(T===null?w:T==="true")},hidden:T=>{rn(T===null?C:T==="true")},"class-name":T=>{mt(T)}};Object.values(ae).forEach((T=>T(null))),Object.entries(G).forEach((([T,M])=>{var pe;(pe=ae[T])===null||pe===void 0||pe.call(ae,M)}))};l.useEffect((()=>{ce(o)}),[o]),l.useEffect((()=>{Le(a)}),[a]),l.useEffect((()=>{At(h)}),[h]),l.useEffect((()=>{Un(u)}),[u]),l.useEffect((()=>{on(m)}),[m]),l.useEffect((()=>{Ze(y)}),[y]),l.useEffect((()=>{Pt(f)}),[f]),l.useEffect((()=>{Mt(w)}),[w]),l.useEffect((()=>{rn(C)}),[C]),l.useEffect((()=>{Vn(g)}),[g]),l.useEffect((()=>{dn.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 ae=new Set(Dt);let T=n;if(!T&&e&&(T=`[data-tooltip-id='${e.replace(/'/g,"\\'")}']`),T)try{document.querySelectorAll(T).forEach((L=>{ae.add({current:L})}))}catch{console.warn(`[react-tooltip] "${T}" is not a valid CSS selector`)}const M=document.querySelector(`[id='${t}']`);if(M&&ae.add({current:M}),!ae.size)return()=>null;const pe=(G=ne??M)!==null&&G!==void 0?G:hn.current,ft=new MutationObserver((L=>{L.forEach((E=>{var B;if(!pe||E.type!=="attributes"||!(!((B=E.attributeName)===null||B===void 0)&&B.startsWith("data-tooltip-")))return;const te=$t(pe);Ft(te)}))})),N={attributes:!0,childList:!1,subtree:!1};if(pe){const L=$t(pe);Ft(L),ft.observe(pe,N)}return()=>{ft.disconnect()}}),[Dt,hn,ne,t,n]),l.useEffect((()=>{q?.border&&console.warn("[react-tooltip] Do not set `style.border`. Use `border` prop instead."),re&&!ur("border",`${re}`)&&console.warn(`[react-tooltip] "${re}" is not a valid \`border\`.`),q?.opacity&&console.warn("[react-tooltip] Do not set `style.opacity`. Use `opacity` prop instead."),Ve&&!ur("opacity",`${Ve}`)&&console.warn(`[react-tooltip] "${Ve}" is not a valid \`opacity\`.`)}),[]);let Bt=x;const mn=l.useRef(null);if(r){const G=r({content:ne?.getAttribute("data-tooltip-content")||ct||null,activeAnchor:ne});Bt=G?nt.createElement("div",{ref:mn,className:"react-tooltip-content-wrapper"},G):null}else ct&&(Bt=ct);Tt&&(Bt=nt.createElement(Lm,{content:Tt}));const Qn={forwardRef:Ss,id:e,anchorId:t,anchorSelect:n,className:Ys(i,cn),classNameArrow:c,content:Bt,contentWrapperRef:mn,place:ut,variant:dt,offset:ue,wrapper:an,events:ln,openOnClick:b,positionStrategy:Ot,middlewares:v,delayShow:It,delayHide:V,float:Hn,hidden:zn,noArrow:_,clickable:A,closeOnEsc:S,closeOnScroll:P,closeOnResize:j,openEvents:k,closeEvents:X,globalCloseEvents:je,imperativeModeOnly:Me,style:q,position:le,isOpen:oe,defaultIsOpen:Z,border:re,opacity:Ve,arrowColor:sn,arrowSize:W,setIsOpen:Rt,afterShow:Bn,afterHide:qn,disableTooltip:Wn,activeAnchor:ne,previousActiveAnchor:un.current,setActiveAnchor:G=>{de((ae=>(G?.isSameNode(ae)||(un.current=ae),G)))},role:Lt};return nt.createElement(Rm,{...Qn})}));typeof window<"u"&&window.addEventListener("react-tooltip-inject-styles",(e=>{e.detail.disableCore||lr({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||lr({css:`
4
+ .styles-module_tooltip__mnnfp{padding:8px 16px;border-radius:3px;font-size:90%;width:max-content}.styles-module_arrow__K0L3T{width:var(--rt-arrow-size);height:var(--rt-arrow-size)}[class*='react-tooltip__place-top']>.styles-module_arrow__K0L3T{transform:rotate(45deg)}[class*='react-tooltip__place-right']>.styles-module_arrow__K0L3T{transform:rotate(135deg)}[class*='react-tooltip__place-bottom']>.styles-module_arrow__K0L3T{transform:rotate(225deg)}[class*='react-tooltip__place-left']>.styles-module_arrow__K0L3T{transform:rotate(315deg)}.styles-module_dark__xNqje{background:var(--rt-color-dark);color:var(--rt-color-white)}.styles-module_light__Z6W-X{background-color:var(--rt-color-white);color:var(--rt-color-dark)}.styles-module_success__A2AKt{background-color:var(--rt-color-success);color:var(--rt-color-white)}.styles-module_warning__SCK0X{background-color:var(--rt-color-warning);color:var(--rt-color-white)}.styles-module_error__JvumD{background-color:var(--rt-color-error);color:var(--rt-color-white)}.styles-module_info__BWdHW{background-color:var(--rt-color-info);color:var(--rt-color-white)}`,type:"base"})}));const Sn=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"})),Tm=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})),Aa=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"})),Am=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})),Im=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"})),Pm=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"})),Ia=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"})),Mm=()=>{const e=ho(),t=Tc();return{rename:async o=>{if(e){const a=await On("New tab name",o);a&&await t.mutateAsync({id:e,payload:{name:a}})}return Promise.resolve()}}},Pa=["shift","alt","meta","mod","ctrl","control"],Om={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 rt(e){return(Om[e.trim()]||e.trim()).toLowerCase().replace(/key|digit|numpad/,"")}function Ma(e){return Pa.includes(e)}function $s(e,t=","){return e.toLowerCase().split(t)}function Fs(e,t="+",n=">",o=!1,a){let r=[],i=!1;e=e.trim(),e.includes(n)?(i=!0,r=e.toLocaleLowerCase().split(n).map(h=>rt(h))):r=e.toLocaleLowerCase().split(t).map(h=>rt(h));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(h=>!Pa.includes(h));return{...c,keys:u,description:a,isSequence:i,hotkey:e}}typeof document<"u"&&(document.addEventListener("keydown",e=>{e.code!==void 0&&Oa([rt(e.code)])}),document.addEventListener("keyup",e=>{e.code!==void 0&&Da([rt(e.code)])})),typeof window<"u"&&(window.addEventListener("blur",()=>{Ke.clear()}),window.addEventListener("contextmenu",()=>{setTimeout(()=>{Ke.clear()},0)}));const Ke=new Set;function jo(e){return Array.isArray(e)}function Dm(e,t=","){return(jo(e)?e:e.split(t)).every(n=>Ke.has(n.trim().toLowerCase()))}function Oa(e){const t=Array.isArray(e)?e:[e];Ke.has("meta")&&Ke.forEach(n=>!Ma(n)&&Ke.delete(n.toLowerCase())),t.forEach(n=>Ke.add(n.toLowerCase()))}function Da(e){const t=Array.isArray(e)?e:[e];e==="meta"?Ke.clear():t.forEach(n=>Ke.delete(n.toLowerCase()))}function $m(e,t,n){(typeof n=="function"&&n(e,t)||n===!0)&&e.preventDefault()}function Fm(e,t,n){return typeof n=="function"?n(e,t):n===!0||n===void 0}const Bm=["input","textarea","select","searchbox","slider","spinbutton","menuitem","menuitemcheckbox","menuitemradio","option","radio","textbox"];function qm(e){return $a(e,Bm)}function $a(e,t=!1){const{target:n,composed:o}=e;let a,r;return Wm(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),jo(t)?!!(a&&t&&t.some(i=>i.toLowerCase()===a.toLowerCase()||i===r)):!!(a&&t&&t)}function Wm(e){return!!e.tagName&&!e.tagName.startsWith("-")&&e.tagName.includes("-")}function Um(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 Hm=(e,t,n=!1)=>{const{alt:o,meta:a,mod:r,shift:i,ctrl:c,keys:u,useKey:h}=t,{code:m,key:d,ctrlKey:x,metaKey:p,shiftKey:b,altKey:g}=e,v=rt(m);if(h&&u?.length===1&&u.includes(d))return!0;if(!u?.includes(v)&&!["ctrl","control","unknown","meta","alt","shift","os"].includes(v))return!1;if(!n){if(o!==g&&v!=="alt"||i!==b&&v!=="shift")return!1;if(r){if(!p&&!x)return!1}else if(a!==p&&v!=="meta"&&v!=="os"||c!==x&&v!=="ctrl"&&v!=="control")return!1}return u&&u.length===1&&u.includes(v)?!0:u?Dm(u):!u},zm=l.createContext(void 0),Vm=()=>l.useContext(zm);function Fa(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&&Fa(e[o],t[o]),!0):e===t}const Qm=l.createContext({hotkeys:[],activeScopes:[],toggleScope:()=>{},enableScope:()=>{},disableScope:()=>{}}),Km=()=>l.useContext(Qm);function Gm(e){const t=l.useRef(void 0);return Fa(t.current,e)||(t.current=e),t.current}const fr=e=>{e.stopPropagation(),e.preventDefault(),e.stopImmediatePropagation()},Ym=typeof window<"u"?l.useLayoutEffect:l.useEffect;function qe(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=jo(e)?e.join(i?.delimiter):e,u=Array.isArray(n)?n:Array.isArray(o)?o:void 0,h=l.useCallback(t,u??[]),m=l.useRef(h);u?m.current=h:m.current=t;const d=Gm(i),{activeScopes:x}=Km(),p=Vm();return Ym(()=>{if(d?.enabled===!1||!Um(x,d?.scopes))return;let b=[],g;const v=(C,_=!1)=>{if(!(qm(C)&&!$a(C,d?.enableOnFormTags))){if(a.current!==null){const A=a.current.getRootNode();if((A instanceof Document||A instanceof ShadowRoot)&&A.activeElement!==a.current&&!a.current.contains(A.activeElement)){fr(C);return}}C.target?.isContentEditable&&!d?.enableOnContentEditable||$s(c,d?.delimiter).forEach(A=>{if(A.includes(d?.splitKey??"+")&&A.includes(d?.sequenceSplitKey??">")){console.warn(`Hotkey ${A} contains both ${d?.splitKey??"+"} and ${d?.sequenceSplitKey??">"} which is not supported.`);return}const S=Fs(A,d?.splitKey,d?.sequenceSplitKey,d?.useKey,d?.description);if(S.isSequence){g=setTimeout(()=>{b=[]},d?.sequenceTimeoutMs??1e3);const P=S.useKey?C.key:rt(C.code);if(Ma(P.toLowerCase()))return;b.push(P);const j=S.keys?.[b.length-1];if(P!==j){b=[],g&&clearTimeout(g);return}b.length===S.keys?.length&&(m.current(C,S),g&&clearTimeout(g),b=[])}else if(Hm(C,S,d?.ignoreModifiers)||S.keys?.includes("*")){if(d?.ignoreEventWhen?.(C)||_&&r.current)return;if($m(C,S,d?.preventDefault),!Fm(C,S,d?.enabled)){fr(C);return}m.current(C,S),_||(r.current=!0)}})}},y=C=>{C.code!==void 0&&(Oa(rt(C.code)),(d?.keydown===void 0&&d?.keyup!==!0||d?.keydown)&&v(C))},f=C=>{C.code!==void 0&&(Da(rt(C.code)),r.current=!1,d?.keyup&&v(C,!0))},w=a.current||i?.document||document;return w.addEventListener("keyup",f,i?.eventListenerOptions),w.addEventListener("keydown",y,i?.eventListenerOptions),p&&$s(c,d?.delimiter).forEach(C=>p.addHotkey(Fs(C,d?.splitKey,d?.sequenceSplitKey,d?.useKey,d?.description))),()=>{w.removeEventListener("keyup",f,i?.eventListenerOptions),w.removeEventListener("keydown",y,i?.eventListenerOptions),p&&$s(c,d?.delimiter).forEach(C=>p.removeHotkey(Fs(C,d?.splitKey,d?.sequenceSplitKey,d?.useKey,d?.description))),b=[],g&&clearTimeout(g)}},[c,d,x]),a}function Jm(){return s.jsxs("div",{className:"flex md:grid md:grid-cols-3 items-center bg-white overflow-auto no-scrollbar",children:[s.jsx(Xm,{}),s.jsx(Zm,{}),s.jsx(nf,{})]})}function Xm(){const{dataSourceId:e}=l.useContext(Pe),{data:t}=ps(e),{state:{table:n}}=l.useContext(Ce);return s.jsx("div",{className:R.tableConfig,children:t&&s.jsxs("div",{className:I(R.tableAction,R.dataSource),"data-tooltip-id":"default","data-tooltip-content":n,children:[s.jsx(He,{size:18,type:t.dbType}),s.jsx("p",{className:"text-sm",children:t.name}),s.jsx(Sn,{width:12,height:12}),s.jsx("p",{className:"text-sm",children:n})]})})}function Zm(){const{page:e,size:t,setPage:n}=va(),{data:o,isFetching:a}=l.useContext(Xe),r=e*t,i=!a&&!!o?.result.hasMore,c=o?.result.rows.length||0,u=()=>{e>0&&n(e-1)},h=()=>{i&&n(e+1)};return s.jsxs("div",{className:I(R.tableConfig,"justify-self-center"),children:[s.jsx("span",{"data-tooltip-content":"Previous page","data-tooltip-id":"default",className:I(R.tableAction,R.gray,e<1&&"opacity-30"),onClick:u,role:"button",children:s.jsx(Sn,{width:16,height:16,className:"rotate-180"})}),s.jsxs("span",{"data-tooltip-id":"rows-num",className:R.paginationIndicator,children:[r+1," - ",r+c,i&&"+"]}),s.jsx("span",{"data-tooltip-content":"Next page","data-tooltip-id":"default",className:I(R.tableAction,i?R.gray:"opacity-30"),onClick:h,role:"button",children:s.jsx(Sn,{width:16,height:16})})]})}const ef=[5,10,20,50,100,200],tf=!__CLIENT_CONFIG__.skipAuth;function nf(){const{dataSourceId:e,name:t}=l.useContext(Pe),{data:n}=ps(e),{data:o,refetch:a}=l.useContext(Xe),r=An(he.EDITOR),i=Nh(),{rename:c}=Mm(),{size:u,setSize:h}=va(),{state:m}=l.useContext(Ce),d=Et(),x=J(),p=()=>{d.mutateAsync({name:t,opts:m}).then(f=>{x(D.workbenchTab.build({id:f.id}))})},b=()=>{if(o?.result.queryHistoryId){const f=new URL(window.location.href);f.pathname=D.share.build(),f.searchParams.set("shareId",o.result.queryHistoryId),navigator.clipboard.writeText(f.toString()),ke.success("Share link copied to clipboard")}},g=()=>{o?.result.columns?.[0].table&&co({table:o?.result.columns?.[0].table,dataSourceId:e})},v=async()=>{const f=await On("Query name",t);!f||!o?.result.queryHistoryId||i.mutate({name:f,queryId:o.result.queryHistoryId})},y=()=>c(t);return qe("s",v),qe("r",y),qe("d",p),s.jsxs("div",{className:"flex justify-self-end",children:[s.jsx("span",{"data-tooltip-content":"Show filters","data-tooltip-id":"default",className:I(R.tableAction,R.gray),onClick:()=>Fe("filters"),role:"button",children:s.jsx(Pm,{width:16,height:16})}),s.jsx("span",{"data-tooltip-content":"Join table","data-tooltip-id":"default",className:I(R.tableAction,R.gray),onClick:()=>Fe("joins"),role:"button",children:s.jsx(Ia,{width:16,height:16})}),s.jsx("span",{"data-tooltip-content":"Refresh data","data-tooltip-id":"default",className:I(R.tableAction,R.gray),onClick:()=>a(),role:"button",children:s.jsx(Aa,{width:16,height:16})}),tf&&s.jsx("span",{"data-tooltip-content":"Share query","data-tooltip-id":"default",className:I(R.tableAction,R.gray),onClick:b,role:"button",children:s.jsx(Im,{width:16,height:16})}),s.jsx("span",{"data-tooltip-content":"Duplicate tab","data-tooltip-id":"default",className:I(R.tableAction,R.gray),onClick:p,role:"button",children:s.jsx(Am,{width:16,height:16})}),s.jsx(us,{id:"rows-num",className:"z-10 shadow-md flex gap-1",clickable:!0,variant:"light",opacity:1,children:ef.map(f=>s.jsx("button",{onClick:()=>h(f,!0),className:I(R.tableAction,R.gray,f===u&&R.selectedSize),children:s.jsx("span",{children:f})},f))}),s.jsx("button",{"data-tooltip-id":"explorer-more-actions",className:I(R.tableAction,R.gray),children:s.jsx(Tm,{width:16,height:16})}),s.jsxs(us,{id:"explorer-more-actions",className:"z-10 shadow-md flex flex-col",clickable:!0,variant:"light",opacity:1,children:[s.jsxs("button",{onClick:()=>Fe("columns"),className:I(R.tableAction,R.modal,R.gray,"justify-between"),children:[s.jsx("span",{children:"Columns"}),s.jsx("span",{className:"hotkey",children:"C"})]}),s.jsxs("button",{onClick:()=>Fe("groupBy"),className:I(R.tableAction,R.modal,R.gray,"justify-between"),children:[s.jsx("span",{children:"Group by"}),s.jsx("span",{className:"hotkey",children:"G"})]}),s.jsxs("button",{onClick:()=>Fe("aggregate"),className:I(R.tableAction,R.modal,R.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:I(R.tableAction,R.modal,R.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:I(R.tableAction,R.modal,R.gray),children:[s.jsx("span",{children:"Save query"}),s.jsx("span",{className:"hotkey",children:"S"})]}),n?.allowInsert===!0&&s.jsx("button",{onClick:g,className:I(R.tableAction,R.modal,R.gray),children:"Insert new row"})]})]})]})}const sf="_drop-container_1ehie_2",of="_item_1ehie_2",pr={dropContainer:sf,item:of},Ba=({dataSourceId:e,inputClassName:t,focusId:n,placeholder:o="Column",onChange:a,value:r,autoFocus:i,allowTables:c})=>{const{data:u}=xs(e),h=l.useRef(null),m=l.useMemo(()=>{if(!u)return[];let f=u;return c&&(f=u.filter(w=>c.includes(w.tableName))),f.flatMap(w=>w.columns.map(C=>({value:w.tableName+"."+C.name,label:C.name,table:w.tableName,searchValue:C.name.toLowerCase()})))},[u,c]),d=l.useMemo(()=>{const f=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]),[x,p]=l.useState(!1),[b,g]=l.useState(0),v=f=>{if(f.key==="ArrowDown")f.preventDefault(),g(w=>(w+1)%d.length);else if(f.key==="ArrowUp")f.preventDefault(),g(w=>(w-1+d.length)%d.length);else if(f.key==="Enter"&&b>=0&&b<d.length){f.preventDefault();const w=d[b].value;p(!1);const C=m.findIndex(_=>_.value===w)>-1;a(d[b]?.value||w,C,!0)}};l.useEffect(()=>{const f=h.current?.querySelector('[data-is-active="true"]');f&&f.scrollIntoView({behavior:"smooth",block:"nearest"})},[b]);const y=f=>{const w=f.currentTarget.value,C=m.findIndex(_=>_.value===w)>-1;a(w,C,!1)};return s.jsxs("div",{className:"relative",onFocus:()=>p(!0),onBlur:()=>p(!1),children:[s.jsx("input",{autoFocus:i,onKeyDown:v,value:r,onChange:y,className:t,placeholder:o,"data-focus":n}),x&&d.length>0&&s.jsx("div",{className:pr.dropContainer,ref:h,tabIndex:-1,children:d.map((f,w)=>s.jsxs("div",{className:pr.item,"data-is-active":b===w,onMouseDownCapture:C=>{C.preventDefault(),p(!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))})]})},rf="_actions_gz5uj_2",af="_filter-actions_gz5uj_2",lf="_filter-badge_gz5uj_2",cf="_filters-container_gz5uj_2",uf="_filter-container_gz5uj_2",df="_filter-value_gz5uj_2",Qt={actions:rf,filterActions:af,filterBadge:lf,filtersContainer:cf,filterContainer:uf,filterValue:df},hf=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{d:"M315.27 33L96 304h128l-31.51 173.23a2.36 2.36 0 002.33 2.77h0a2.36 2.36 0 001.89-.95L416 208H288l31.66-173.25a2.45 2.45 0 00-2.44-2.75h0a2.42 2.42 0 00-1.95 1z",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32})),mf=({isAdvanced:e})=>e?s.jsx("span",{"data-tooltip-id":"default","data-tooltip-content":"Advanced mode: parameters and operator will be extracted from the input",className:Qt.filterBadge,children:s.jsx(hf,{width:20,height:20})}):null,ff=({filter:e,dataSourceId:t,allowedTables:n,autoFocus:o,onChangeColumn:a,onChangeValue:r,onRemoveFilter:i,onChangeAdvancedFilter:c,triggerIsEnabled:u,onSubmit:h})=>{const m=x=>{const p=x.target.value;p.charAt(0)===":"?c(e.id,!0):(!e.isAdvanced&&["=","<",">"].includes(p.charAt(0))&&c(e.id,!0),r(e.id,x.currentTarget.value))},d=x=>{x.key==="Backspace"?(e.value.length===0||x.currentTarget.selectionEnd===0)&&c(e.id,!1):x.key==="Enter"&&h()};return s.jsxs("div",{className:Qt.filterContainer,children:[s.jsx("input",{className:"mr-1",type:"checkbox",checked:e.isEnabled!==!1,onClick:()=>u(e.id)}),s.jsx(Ba,{dataSourceId:t,onChange:x=>a(e.id,x),value:e.column,allowTables:n,focusId:"column",inputClassName:"input w-full rounded-r-none!",autoFocus:o}),s.jsxs("div",{className:Qt.filterValue,children:[s.jsx(mf,{isAdvanced:e.isAdvanced}),s.jsx("input",{placeholder:"Filter value",value:e.value,onChange:m,onKeyDown:d,"data-focus":"value",className:"flex-1 outline-none"},e.id)]}),s.jsx("div",{className:Qt.filterActions,children:s.jsx("button",{tabIndex:-1,"data-tooltip-id":"default","data-tooltip-content":"Remove filter",className:"p-0.5 text-sm cursor-pointer rounded-md ml-1",onClick:()=>i(e.id),children:s.jsx(_t,{width:20,height:20,className:"text-red-600"})})})]})},pf=()=>{const{state:e}=l.useContext(Ce),{refetch:t}=l.useContext(Xe),{setFilters:n}=xo(),o=ys(g=>g.filters),a=l.useMemo(()=>[e.table,...e.joins.map(g=>g.table)],[e.table,e.joins]),[r,i]=l.useState([]),c=(g,v)=>{i(y=>[...y.map(f=>f.id===g?{...f,column:v}:f)])},u=(g,v)=>{i(y=>[...y.map(f=>f.id===g?{...f,value:v}:f)])},h=()=>{i(g=>[...g,{id:Je(),value:"",column:"",isEnabled:!0}])},m=g=>{i(v=>v.filter(y=>y.id!==g))},d=(g,v)=>{i(y=>y.map(f=>f.id===g?{...f,isAdvanced:v}:f))},x=()=>ws("filters"),p=()=>{try{n(r.filter(g=>g.value.length>0&&g.column.length>0)),setTimeout(t,1),x()}catch(g){g instanceof Error?ke.error(g.message):ke.error("Error during parsing, check you filters")}},b=g=>{i(v=>v.map(y=>y.id===g?{...y,isEnabled:!y.isEnabled}:y))};return l.useEffect(()=>{o&&i(()=>[...e.filters,{id:Je(),value:"",column:"",isEnabled:!0}])},[o]),qe("f",()=>{as("filters")}),s.jsxs(we,{isVisible:o,onClose:x,portal:!0,onClosed:()=>i([]),noPadding:!0,backdropClose:!0,children:[s.jsx(lt,{onClick:x}),s.jsx("h2",{className:"text-lg font-semibold m-2",children:"Filters"}),s.jsxs("div",{className:Qt.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((g,v)=>s.jsx(ff,{filter:g,dataSourceId:e.dataSourceId,allowedTables:a,onChangeColumn:c,onChangeValue:u,onRemoveFilter:m,onChangeAdvancedFilter:d,triggerIsEnabled:b,onSubmit:p,autoFocus:v===r.length-1},g.id))]}),s.jsxs("div",{className:Qt.actions,children:[s.jsxs("button",{className:"button tertiary flex items-center gap-1 text-sm",onClick:h,children:[s.jsx(Ia,{width:20,height:20}),s.jsx("span",{children:"Add filter"})]}),s.jsx("button",{className:"button primary text-sm",onClick:p,children:"Apply filters"})]})]})},xf="_join-modal_cy2cj_2",gf={joinModal:xf},bf=(e,t)=>e.type!==t.type||e.on!==t.on||e.table!==t.table,vf=(e,t)=>e.type===t.type&&e.on===t.on&&e.table===t.table,qa=()=>{const{state:e,setState:t}=l.useContext(Ce),n=l.useCallback(o=>{t(a=>{const r=a.joins;if(r.some(c=>vf(c,o))){const c=o.table+".";return{...a,joins:r.filter(u=>bf(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}},yf=()=>{const{isFetching:e}=l.useContext(Xe),t=ys(u=>u.joins),{toggle:n}=qa(),{availableJoins:o}=l.useContext(Pe),[a,r]=l.useState(""),i=l.useMemo(()=>{const u=a.toLowerCase();return o.filter(h=>h.fromTable.toLowerCase().includes(u))},[o,a]),c=()=>ws("joins");return qe("j",()=>{o.length>0?Fe("joins"):ke.error("No available tables to join")}),s.jsxs(we,{isVisible:t,onClose:c,portal:!0,backdropClose:!0,children:[s.jsx(lt,{onClick:c}),s.jsxs("div",{className:gf.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(me,{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(po,{hook:u,onClick:()=>{e||(n({table:u.direction==="in"?u.fromTable:u.toTable,type:"LEFT",on:Wc(u)}),r(""),c())}},u.id))})]})]})};function wf(e){return e.reduce((t,n)=>(t[n]=!0,t),{})}function xr(e){return e.reduce((t,n)=>(t[n]=!0,t),{})}const Cf="_container_u6ubk_2",jf="_column-label_u6ubk_2",Nf="_not-active_u6ubk_2",ss={container:Cf,columnLabel:jf,notActive:Nf};function _f(e){if(!e)return[];const t={};return e.forEach(n=>{t[n.table]?t[n.table].push({value:n.full,ogColumn:n.column,label:st(n.column),type:n.type}):t[n.table]=[{value:n.full,ogColumn:n.column,label:st(n.column),type:n.type}],Bc[n.type]&&["YEAR","MONTH","DAY"].forEach(o=>{t[n.table].push({value:o+" "+n.full,ogColumn:n.column,label:o+" "+st(n.column),type:"number",nested:!0})})}),Object.entries(t).reduce((n,[o,a])=>(n.push({name:st(o),columns:a}),n),[])}function Sf(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 kf=({column:e,selected:t,onCheck:n})=>s.jsxs("label",{className:I(ss.columnLabel,t?ss.active:ss.notActive,e.nested&&"pl-5!"),children:[s.jsx("input",{type:"checkbox",checked:t[e.value],name:e.value,onChange:n}),s.jsxs("p",{className:"flex justify-between w-full",children:[s.jsx("span",{"data-tooltip-content":e.value,"data-tooltip-id":"default",children:e.label}),s.jsx("span",{className:"text-blue-600",children:e.type})]})]},e.value),Ef={columns:"c",groupBy:"g"},gr=({mode:e})=>{const t=ys(f=>f[e]),{allColumns:n}=l.useContext(Pe),{state:o,setState:a}=l.useContext(Ce),[r,i]=l.useState({}),[c,u]=l.useState(""),h=l.useMemo(()=>_f(n),[n]),m=o.aggregations.length>0||o.groupBy.length>0,d=l.useMemo(()=>c?Sf(h,c):h,[c,h]),x=f=>{i(w=>({...w,[f.target.name]:f.target.checked}))},p=f=>{const w=f.target.checked;i(C=>{for(const _ of n)C[_.full]=w;return{...C}})},b=()=>{ws(e)},g=()=>{const f=[];for(const[w,C]of Object.entries(r))if(C){const[_,A]=w.split(" ");f.push({value:A||_,fn:A?_: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]);qe(Ef[e],()=>{e==="columns"?m?ke.error("Columns are ignored when there is at least one aggregation or group by"):as("columns"):as("groupBy")}),l.useEffect(()=>{t&&i(()=>wf(o[e].map(f=>f.fn?f.fn+" "+f.value:f.value)))},[t,i]);const y=()=>{u(""),i({})};return s.jsxs(we,{isVisible:t,onClose:b,portal:!0,onClosed:y,backdropClose:!0,children:[s.jsx(lt,{onClick:b}),s.jsxs("div",{className:ss.container,children:[s.jsx("h2",{className:"text-lg font-semibold",children:e==="groupBy"?"Group by":"Show columns"}),s.jsx("input",{autoFocus:!0,className:"input my-2",placeholder:"Filter",value:c,onChange:f=>u(f.target.value)}),s.jsx("div",{className:"overflow-y-auto",children:d.map(f=>s.jsxs("div",{className:"my-2",children:[s.jsxs("p",{className:"font-semibold sticky top-0 bg-white p-1 z-1",children:["📄 ",f.name]}),f.columns.map(w=>s.jsx(kf,{column:w,selected:r,onCheck:x},w.value))]},f.name))}),s.jsxs("div",{className:"flex justify-end gap-2 mt-2",children:[s.jsxs("label",{className:"button tertiary flex gap-2 items-center",children:[s.jsx("input",{type:"checkbox",checked:v,onChange:p}),s.jsx("span",{children:"Select all"})]}),s.jsx("span",{className:"flex-1"}),s.jsx("button",{className:"button tertiary",onClick:b,children:"Cancel"}),s.jsx("button",{className:"button primary",onClick:g,children:"Apply"})]})]})]})},Rf="_options-container_4iru2_2",Lf={optionsContainer:Rf},Bs="COUNT all",Tf=()=>{const e=ys(b=>b.aggregate),{dataSourceId:t}=l.useContext(Pe),{setState:n,state:o}=l.useContext(Ce),{data:a}=l.useContext(Xe),[r,i]=l.useState({fn:"",col:""}),c=b=>i({...r,fn:b.currentTarget.value}),u=b=>i({...r,col:b}),h=()=>ws("aggregate"),m=()=>{const b=r.fn===Bs?{value:"*",fn:"COUNT"}:{fn:r.fn,value:r.col,distinct:r.fn==="COUNT"};n(g=>({...g,aggregations:[...g.aggregations,b]}))},d=r.fn===Bs,x=d?!1:!r.col||!r.fn,p=b=>{const g=qc(b);n(v=>({...v,aggregations:v.aggregations.filter(y=>y.fn!==b.fn||y.value!==b.value),orderBy:v.orderBy.filter(y=>y.column!==g)}))};return qe("a",()=>{as("aggregate")}),s.jsxs(we,{isVisible:e,onClose:h,backdropClose:!0,portal:!0,children:[s.jsx(lt,{onClick:h}),s.jsxs("div",{children:[s.jsx("h2",{className:"text-lg font-semibold",children:"Aggregate"}),ge(o.aggregations.length,0)&&s.jsx("div",{className:"flex flex-col gap-1 mt-4",children:o.aggregations.map((b,g)=>s.jsxs("p",{className:"p-2 rounded-md bg-gray-50 flex items-center justify-between",children:[s.jsx("span",{children:ts(b)}),s.jsx("button",{tabIndex:-1,"data-tooltip-id":"default","data-tooltip-content":"Remove aggregation",className:"p-0.5 text-sm cursor-pointer",onClick:()=>p(b),children:s.jsx(_t,{width:20,height:20,className:"text-red-600"})})]},g))}),s.jsxs("div",{className:Lf.optionsContainer,children:[s.jsxs("label",{className:I(d&&"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:Bs,children:"Count all rows"}),s.jsx("option",{value:"COUNT",children:"Count"}),s.jsx("option",{value:"SUM",children:"Sum"}),s.jsx("option",{value:"MAX",children:"Max"}),s.jsx("option",{value:"MIN",children:"Min"}),s.jsx("option",{value:"AVG",children:"Avg"})]})]}),!d&&s.jsxs("label",{children:[s.jsx("p",{className:"font-semibold text-xs",children:"Column"}),s.jsx(Ba,{inputClassName:"input w-full",dataSourceId:t,allowTables:a?.result.tables||[],onChange:u,value:r.col})]}),s.jsx("button",{className:"button primary",disabled:x,onClick:m,children:"Add"})]})]})]})},Af="_container_1tsit_2",If="_yellow-pill_1tsit_2 _pill_1tsit_2",Pf="_blue-pill_1tsit_2 _pill_1tsit_2",Mf="_purple-pill_1tsit_2 _pill_1tsit_2",Of="_red-pill_1tsit_2 _pill_1tsit_2",Df="_black-pill_1tsit_2 _pill_1tsit_2",$f="_disabled-pill_1tsit_2",bt={container:Af,yellowPill:If,bluePill:Pf,purplePill:Mf,redPill:Of,blackPill:Df,disabledPill:$f};function No(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 Ff(e){return!(e===!0||e===void 0)}const Bf=()=>{const{state:{aggregations:e,columns:t,groupBy:n}}=l.useContext(Ce),{toggle:o,joins:a}=qa(),{filters:r,setFilters:i,removeFilter:c}=xo(),u=()=>Fe("joins"),h=()=>Fe("aggregate"),m=()=>Fe("columns"),d=()=>Fe("groupBy"),x=g=>{g.preventDefault(),g.stopPropagation(),o(a[a.length-1])},p=g=>{i(r.map(v=>({...v,isEnabled:g===v.id?Ff(v.isEnabled):v.isEnabled})),!0)},b=g=>v=>{v.preventDefault(),v.stopPropagation(),c(g)};return r.length>0||a.length>0||n.length>0||t.length>0||e.length>0?s.jsxs("div",{className:bt.container,children:[a.map((g,v)=>s.jsxs("button",{onClick:u,className:bt.yellowPill,"data-tooltip-id":"default","data-tooltip-content":`Joins ${g.table} on ${g.on}`,children:[s.jsx("p",{className:"text-sm",children:g.table}),v===a.length-1&&s.jsx(_t,{onClick:x,width:18,height:18})]},g.table)),r.map(g=>s.jsxs("button",{onClick:()=>p(g.id),onAuxClick:()=>c(g.id),className:I(bt.bluePill,g.isEnabled===!1&&bt.disabledPill),"data-tooltip-id":"default","data-tooltip-content":`${g.column} ${g.value}`,children:[s.jsx("p",{className:"text-sm",children:g.column}),s.jsx("p",{className:"text-sm",children:g.value}),s.jsx(_t,{onClick:b(g.id),width:18,height:18})]},g.id)),e.map(g=>s.jsx("button",{onClick:h,className:I(bt.purplePill),"data-tooltip-id":"default","data-tooltip-content":ts(g),children:s.jsx("p",{className:"text-sm",children:ts(g)})},ts(g))),t.length>0&&s.jsx("button",{onClick:m,className:I(bt.redPill),"data-tooltip-id":"default","data-tooltip-content":"Has hidden columns",children:s.jsx("p",{className:"text-sm",children:"Hidden columns"})}),n.length>0&&s.jsx("button",{onClick:d,className:I(bt.blackPill),"data-tooltip-id":"default","data-tooltip-content":"Has GROUP BY",children:s.jsx("p",{className:"text-sm",children:"Grouped columns"})}),!1]}):null},qf=({options:e,updater:t,name:n,tabId:o})=>{const a=wc(e,t),r=Ac(o,a.state),i=yc(r.data,a.state.dataSourceId,n,o);return s.jsx(Pe,{value:i,children:s.jsx(Ce,{value:a,children:s.jsxs(Xe,{value:r,children:[s.jsx(Jm,{}),s.jsx(Bf,{}),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(jh,{})}),s.jsx(pf,{}),s.jsx(yf,{}),s.jsx(gr,{mode:"columns"}),s.jsx(gr,{mode:"groupBy"}),s.jsx(Tf,{})]})]})})})},_o=({size:e=32})=>s.jsxs("div",{role:"status",children:[s.jsxs("svg",{"aria-hidden":"true",width:e,height:e,className:"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..."})]}),Wf=({id:e})=>{const{data:t}=Rc(e),n=l.useCallback(o=>{if(!t)return;const a=o(Nt(t.opts));K.setQueryData(["workbench-tabs",t.id],{...t,opts:{...t.opts,...a}})},[t]);return t?s.jsx(qf,{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(_o,{})})},Uf=e=>{setTimeout(t=>{const n=document.querySelector(`[data-tab-id="${t}"]`);n&&n.scrollIntoView({behavior:"smooth"})},50,e)},Hf=()=>{const{id:e}=Qi(),t=J(),{data:n}=bs(),o=Lc(),a=da(fo.laptop),r=u=>{if(u===e&&n){if(n.length===1)return t(D.home.build());if(n.length>1){const h=n.find(m=>m.id!==u);if(h)return t(`/workbench/tab/${h.id}`)}}},i=u=>{u.stopPropagation(),u.preventDefault();const h=u.currentTarget.getAttribute("data-tab-id");h&&(o.mutate(h),r(h))},c=u=>{o.mutate(u),r(u)};return l.useEffect(()=>{e&&Uf(e)},[e,n]),s.jsxs("div",{className:"h-screen max-h-screen bg-(--bg) flex flex-col",children:[e?s.jsx(Wf,{id:e}):s.jsx("div",{className:"flex-1"}),s.jsx("div",{className:I(bn.tabs,"no-scrollbar",!a&&bn.mobile),children:n?.map(u=>s.jsxs("div",{onClick:()=>t(D.workbenchTab.build({id:u.id})),className:I(bn.tab,u.id===e&&bn.active),"data-tooltip-id":"default","data-tab-id":u.id,"data-tooltip-content":u.name,onAuxClick:()=>c(u.id),children:[s.jsxs("span",{className:"truncate w-full",children:["🛠️ ",u.name]}),s.jsx("button",{"data-tab-id":u.id,className:bn.closeButton,onClick:i,children:s.jsx(_t,{width:20,height:20})})]},u.id))})]})},zf="_root_11wd1_2",Vf="_up_11wd1_2",Qf="_down_11wd1_2",Kf="_chevron_11wd1_2",Gf="_table-name-container_11wd1_2",Yf="_link_11wd1_2",Jf="_table-name_11wd1_2",Xf="_ul_11wd1_2",Zf="_column-type_11wd1_2",e0="_action-blue_11wd1_2 _action_11wd1_2",t0="_action-red_11wd1_2 _action_11wd1_2",n0="_db-header-container_11wd1_2",s0="_db-header_11wd1_2",o0="_db-subheader_11wd1_2 _db-header_11wd1_2",se={root:zf,up:Vf,down:Qf,chevron:Kf,tableNameContainer:Gf,link:Yf,tableName:Jf,ul:Xf,columnType:Zf,actionBlue:e0,actionRed:t0,dbHeaderContainer:n0,dbHeader:s0,dbSubheader:o0},r0="_sidebar_afm4l_2",a0="_sidebar-visible_afm4l_2",i0="_sidebar-container_afm4l_2",l0="_sidebar-invisible_afm4l_2",c0="_backdrop_afm4l_2",vn={sidebar:r0,sidebarVisible:a0,sidebarContainer:i0,sidebarInvisible:l0,backdrop:c0},So=({children:e,backdropClose:t,isVisible:n,onClose:o,onClosed:a,contentClassName:r})=>{const[i,c]=l.useState(!1),u=()=>{t&&o()},h=m=>{n||getComputedStyle(m.currentTarget).opacity==="0"&&(c(!1),a&&a())};return l.useEffect(()=>{n&&c(!0)},[n]),vs({onClose:u,enabled:n&&t===!0}),s.jsxs("div",{onTransitionEnd:h,className:I(vn.sidebar,n?vn.sidebarVisible:vn.sidebarInvisible),children:[s.jsx("div",{onClick:u,className:vn.backdrop}),s.jsx("div",{className:I(vn.sidebarContainer,r),children:i&&e})]})},u0=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"})),d0=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{d:"M432 144l-28.67 275.74A32 32 0 01371.55 448H140.46a32 32 0 01-31.78-28.26L80 144",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32}),l.createElement("rect",{x:32,y:64,width:448,height:80,rx:16,ry:16,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32}),l.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32,d:"M312 240L200 352M312 352L200 240"})),Wa=(e,t=!0)=>{const n=navigator.clipboard.writeText(e);t&&n.then(()=>{ke.success(`Copied "${e}"`)})},h0=e=>{const t=l.useRef(!1);l.useEffect(()=>{e&&(e.status==="INSPECTING"?t.current=!0:e.status==="READY"&&t.current&&(fc(e.id),t.current=!1))},[e])},m0=new Intl.DateTimeFormat("en",{dateStyle:"full",timeStyle:"long"}),Jn=18;function f0(e,t){return t&&e.toLowerCase().includes(t)?"bg-yellow-200 cursor-pointer":"cursor-pointer"}const p0=({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:se.ul,children:o.map(a=>s.jsx(s.Fragment,{children:s.jsxs("li",{children:[a.isPrimary?"🔐":"🏷️"," ",s.jsx("span",{onClick:()=>Wa(a.name),className:f0(a.name,t),children:a.name})," ",s.jsxs("span",{className:se.columnType,children:["[",a.type,"]"]}),a.ref&&s.jsxs("span",{children:[" ➡️ ",s.jsx("span",{className:se.columnType,children:a.ref.table}),".",a.ref.field]})]},a.name+a.type)}))},e.id)};function x0({id:e}){const{data:t}=ps(e),{data:n}=xs(e),o=J(),a=xc(),r=Xr(),i=gc(),c=Et(),u=l.useMemo(()=>t?.lastInspected?m0.format(new Date(t.lastInspected)):"--",[t]),[h,m]=l.useState({}),[d,x]=l.useState(""),[p,b]=l.useState("table"),g=An(he.EDITOR),v=d.toLowerCase(),y=l.useMemo(()=>{if(!v||!n)return n||[];const j=[];for(const k of n){if(k.tableName.toLowerCase().includes(v)){j.push(k);continue}p!=="table"&&k.columns.findIndex(X=>X.name.toLowerCase().includes(v))>=0&&j.push(k)}return j},[v,n,p]),f=j=>{m(k=>({...k,[j]:!k[j]}))},w=j=>{c.mutateAsync({name:j,opts:Nt({table:j,dataSourceId:e})}).then(k=>{Nn(void 0),o(D.workbenchTab.build({id:k.id}))})},C=()=>{r.mutate(e)},_=async()=>{const j=await On("Enter name",t?.name);j&&a.mutate({id:e,dataSource:{name:j}})},A=async()=>{await mo("Are you sure you want to delete this data source?")&&(i.mutate(e),Nn(void 0))};h0(t);const S=p==="column",P=t?.status==="INSPECTING";return s.jsxs("div",{className:se.root,children:[s.jsxs("div",{className:"sticky top-0 bg-white border-b border-gray-200 px-4 py-2 z-1",children:[s.jsxs("div",{className:se.dbHeaderContainer,children:[s.jsxs("div",{className:se.dbHeader,children:[t&&s.jsx(He,{size:24,type:t.dbType}),s.jsx("p",{className:"truncate text-(--text-color-primary) text-lg",children:t?.name})]}),s.jsxs("div",{className:se.dbSubheader,children:[s.jsx("p",{className:"text-xs text-(--text-color-secondary) truncate",children:u}),g&&s.jsxs("div",{className:"flex justify-end",children:[s.jsx("button",{disabled:r.isPending||P,onClick:C,className:se.actionBlue,"data-tooltip-id":"default-xs","data-tooltip-content":"Refresh schema",children:s.jsx(Aa,{width:16,height:16})}),s.jsx("button",{disabled:r.isPending,onClick:_,className:se.actionBlue,"data-tooltip-id":"default-xs","data-tooltip-content":"Update name",children:s.jsx(u0,{width:16,height:16})}),s.jsx("button",{disabled:r.isPending,onClick:A,className:se.actionRed,"data-tooltip-id":"default-xs","data-tooltip-content":"Delete data source",children:s.jsx(d0,{width:16,height:16})})]})]})]}),s.jsxs("div",{className:"flex gap-2 items-center mt-2",children:[s.jsxs("select",{className:"input text-sm",value:p,onChange:j=>b(j.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 text-sm",placeholder:S?"Search column":"Search table",value:d,onChange:j=>x(j.target.value),autoFocus:!0})]})]}),P&&s.jsxs("div",{className:"flex justify-center gap-2 items-center bg-blue-50 p-4 rounded",children:[s.jsx(_o,{size:16}),s.jsx("p",{className:"text-xs text-blue-800",children:"Inspecting schema"})]}),t?.status==="FAILED"&&s.jsx("div",{className:"flex justify-center gap-2 items-center bg-red-50 p-4 rounded",children:s.jsx("p",{className:"text-xs text-red-800",children:"Latest inspection failed"})}),s.jsx("div",{className:I("overflow-y-auto p-4",P&&"opacity-30"),children:y?.map(j=>s.jsxs("div",{children:[s.jsxs("div",{className:se.tableNameContainer,children:[s.jsx("button",{className:I(se.chevron,h[j.id]?se.down:se.up),onClick:()=>f(j.id),children:s.jsx(Sn,{width:16,height:16})}),s.jsx("button",{className:I(se.tableName,"flex-1"),onClick:()=>f(j.id),children:j.tableName}),s.jsx("button",{className:se.link,onClick:()=>w(j.tableName),"data-tooltip-id":"default-xs","data-tooltip-content":"Explore table data",children:s.jsx(ca,{width:Jn,height:Jn})}),s.jsx("button",{className:se.link,onClick:()=>Wa(j.tableName),"data-tooltip-id":"default-xs","data-tooltip-content":"Copy table name",children:s.jsx(ba,{width:Jn,height:Jn})})]}),(h[j.id]||d.length>0)&&s.jsx(p0,{insp:j,filter:S?v:"",expanded:h[j.id]})]},j.id))})]})}const g0=()=>{const e=Cu(),[t,n]=l.useState(void 0);l.useEffect(()=>{e&&n(e)},[e]);const o=()=>Nn(void 0);return s.jsx(So,{isVisible:e!=null,onClose:o,onClosed:()=>n(void 0),backdropClose:!0,children:t&&s.jsx(x0,{id:t})})},b0="_search-container_zlpq0_2",v0="_search_zlpq0_2",y0="_entry_zlpq0_2",w0="_ds_zlpq0_2",C0="_ds-container_zlpq0_2",j0="_ds-entry_zlpq0_2",N0="_enabled_zlpq0_2",vt={searchContainer:b0,search:v0,entry:y0,ds:w0,dsContainer:C0,dsEntry:j0,enabled:N0};function _0(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 S0=({storage:e=localStorage,localStorageKey:t,initialData:n})=>{const o=ye(_0(t,n,e));return o[2].subscribe(a=>{e.setItem(t,JSON.stringify(a))}),o},[k0,E0]=S0({initialData:[],localStorageKey:"selected-data-sources-v1"}),R0=e=>E0(t=>{const n=t.indexOf(e);return n>-1?(t.splice(n,1),[...t]):[...t,e]}),L0={table:"📄",query:"📖",tab:"🛠️"},T0=({onTable:e,onQuery:t,onWorkbenchTab:n,autoFocus:o})=>{const[a,r]=l.useState(""),[i,c]=l.useState(-1),u=No(a,200),h=k0(),{data:m}=ve(),{data:d}=ao({teamId:m?.teamId}),x=l.useMemo(()=>{const f=[],w=xr(h);if(!d||d.length===0)return[];for(const C of d)w[C.id]&&f.push(C.id);return f},[h,d]),{data:p}=ic(u,{teamId:m?.teamId,selectedDataSources:x}),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)},g=f=>{p&&(f.key==="ArrowDown"?(f.preventDefault(),c(w=>(w+1)%p.length)):f.key==="ArrowUp"?(f.preventDefault(),c(w=>(w-1+p.length)%p.length)):f.key==="Enter"&&i>=0&&p[i]?.name&&(f.preventDefault(),b(p[i])))},v=f=>{const w=f.currentTarget.dataset.tableId,C=p?.find(_=>_.id===w);C&&b(C)},y=l.useMemo(()=>xr(h),[h]);return s.jsxs("div",{className:"overflow-hidden flex flex-col w-full lg:w-lg",children:[ge(d?.length,0)?s.jsx("div",{className:vt.dsContainer+" no-scrollbar",children:d.map(f=>s.jsxs("button",{className:I(vt.dsEntry,y[f.id]&&vt.enabled),onClick:()=>R0(f.id),"data-tooltip-id":"default","data-tooltip-content":f.name,children:[s.jsx(He,{size:18,type:f.dbType}),s.jsx("span",{children:f.name})]},f.id))}):s.jsx(me,{variant:"warning",className:"mb-4",children:"Connect at least one data source to start using DataRamen"}),s.jsxs("div",{className:vt.searchContainer,children:[s.jsx(tn,{className:"text-(--text-color-secondary)",width:18,height:18}),s.jsx("input",{className:vt.search,placeholder:"Search table or saved query to start from",value:a,onChange:f=>r(f.target.value),onKeyDown:g,autoFocus:o})]}),ge(p?.length,0)&&s.jsx("div",{className:"overflow-y-auto max-h-full mt-2",children:p.map((f,w)=>s.jsxs("button",{className:vt.entry,"data-is-active":i===w,"data-table-id":f.id,onClick:v,children:[s.jsxs("p",{className:"truncate",children:[L0[f.type]," ",f.name]}),s.jsxs("p",{className:vt.ds,children:["📦 ",f.dataSourceName]})]},f.id))})]})},A0=()=>{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(we,{isVisible:!!e,onClose:a,backdropClose:!0,children:s.jsx(T0,{autoFocus:!0,onTable:t,onQuery:n,onWorkbenchTab:o})})},I0=()=>{const e=Tn("Hotkey"),t=J(),{pathname:n}=fe(),{data:o}=ve(),{data:a}=bs(),r=D.home.check(n);qe("n",()=>{o&&e()}),qe("w",()=>{o&&(a&&a.length>0?t(D.workbenchTab.build({id:a[0].id})):e())},{enabled:r}),qe("h",()=>{jn({show:!0})})},[P0,Ua]=ye(!1),qs=()=>Ua(!1),Ha=()=>Ua(!0),M0=({repeatPassword:e,password:t})=>t.length<1?null:t.length<8?s.jsx(me,{variant:"warning",children:"New password should be at least 8 characters long"}):t!==e?s.jsx(me,{variant:"warning",children:"Repeat password should match new password"}):null,O0=()=>{const e=P0(),{data:t}=ve(),{mutateAsync:n,isPending:o}=bc(),a=J(),[{password:r,repeatPassword:i},{change:c,touched:u,reset:h}]=kn({password:"",repeatPassword:""}),m=()=>{a("/"),hs.logout().then(()=>{qs()})},d=()=>{n({password:r}).then(()=>{h(),ke.success("Password successfully updated!")})},x=r.length<8||r!==i||o,p=u.includes("password");return s.jsxs(we,{isVisible:e,onClose:qs,children:[s.jsx(lt,{onClick:qs}),s.jsxs("div",{className:"w-full lg:w-lg flex flex-col gap-2",children:[s.jsx(oa,{children:"Account settings"}),s.jsxs("label",{children:[s.jsx("p",{className:"text-xs font-semibold mb-1",children:"Username"}),s.jsx("input",{className:"input w-full",readOnly:!0,disabled:!0,value:t?.username})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsxs("label",{children:[s.jsx("p",{className:"text-xs font-semibold mb-1",children:"Change password"}),s.jsx("input",{className:"input w-full",type:"password",name:"newPassword",autoComplete:"new-password",value: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")})]})]}),p&&s.jsx(M0,{password:r,repeatPassword:i}),s.jsxs("div",{className:"flex justify-end gap-2 mt-2",children:[s.jsx("button",{className:"button tertiary",disabled:x,onClick:d,children:"Update password"}),s.jsx("button",{className:"button danger",onClick:m,children:"Log out"})]})]})]})},[D0,za]=ye(!1),Va=()=>za(!0),br=()=>za(!1),$0=e=>be({queryKey:["team-users"],queryFn:async()=>{const{data:t}=await $.get("/teams/"+e+"/users");return t.data},enabled:!!e}),F0=()=>ee({mutationFn:async({role:e,teamId:t,userId:n})=>(await $.patch("/teams/"+t+"/user-role",{role:e,userId:n}),!0),onSuccess:()=>{K.invalidateQueries({queryKey:["team-users"]})}}),B0=()=>ee({mutationFn:async({teamId:e,userId:t})=>(await $.delete("/teams/"+e,{params:{userId:t}}),!0),onSuccess:()=>{K.invalidateQueries({queryKey:["team-users"]})}}),q0="_user-entry_1eum1_2",W0="_select-container_1eum1_2",vr={userEntry:q0,selectContainer:W0},U0=()=>{const e=D0(),{data:t}=ve(),{data:n}=$0(t?.teamId),{mutate:o,isPending:a}=vc(),{mutate:r,isPending:i}=F0(),{mutate:c,isPending:u}=B0(),[h,{change:m,reset:d}]=kn({password:"",username:""}),x=()=>{o({username:h.username,password:h.password,teamId:t?.teamId||""}),d()},p=(y,f)=>{r({teamId:t.teamId,role:f,userId:y})},b=y=>{mo("Are you sure you want to remove this user?").then(f=>{f&&c({userId:y,teamId:t.teamId})})},g=An(he.ADMIN),v=a||i||u;return s.jsxs(we,{isVisible:e,onClose:br,backdropClose:!0,children:[s.jsx(lt,{onClick:br}),s.jsxs("div",{className:"w-full lg:w-lg flex flex-col overflow-hidden",children:[s.jsx(oa,{children:"Manage users"}),ge(n?.length,0)&&s.jsx("div",{className:"mt-4 overflow-y-auto flex-1",children:n.map(y=>s.jsxs("div",{className:vr.userEntry,children:[s.jsx("div",{className:vr.selectContainer,children:s.jsxs("select",{value:y.role,disabled:!g||v,onChange:f=>p(y.id,f.currentTarget.value),children:[s.jsx("option",{value:he.OWNER,children:"Owner"}),s.jsx("option",{value:he.ADMIN,children:"Admin"}),s.jsx("option",{value:he.EDITOR,children:"Editor"}),s.jsx("option",{value:he.READ_ONLY,children:"Reader"})]})}),s.jsx("p",{className:"flex-1 mx-2",children:y.name}),g&&s.jsx("button",{className:"p-1 cursor-pointer text-red-500 text-sm",onClick:()=>b(y.id),children:"❌"})]},y.id))}),g&&s.jsxs("div",{className:"mt-4",children:[s.jsx("p",{className:"font-semibold",children:"Create new user"}),s.jsxs("div",{className:"flex flex-col lg:flex-row gap-2 lg:items-center mt-2",children:[s.jsx("input",{className:"input flex-1",onChange:m("username"),value:h.username,placeholder:"Username",disabled:v}),s.jsx("input",{className:"input",onChange:m("password"),value:h.password,type:"password",name:"newPassword",autoComplete:"new-password",placeholder:"Password",disabled:v}),s.jsx("button",{className:"button primary",onClick:x,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."})]})]})]})},H0="_gray-card_1k4mb_2",z0="_login-label_1k4mb_2",yr={grayCard:H0,loginLabel:z0},V0=()=>{const[e,t]=l.useState(""),[n,o]=l.useState(""),[a,r]=l.useState(),i=J(),c=u=>{u.preventDefault(),r(void 0),hs.login({password:n,username:e}).then(()=>{i("/",{replace:!0})}).catch(r)};return s.jsx("div",{className:"page-container bg-(--bg) h-screen",children:s.jsxs("div",{className:"page-content items-center",children:[s.jsxs("div",{className:"py-10 text-center w-full sticky top-0 z-0",children:[s.jsx("h1",{className:"comfortaa text-3xl font-semibold text-(--text-color-primary) mb-4",children:"Welcome to DataRamen!"}),s.jsx(ia,{})]}),s.jsxs("form",{className:yr.grayCard,onSubmit:c,children:[s.jsx("h2",{className:yr.loginLabel,children:"Login"}),a&&s.jsx(me,{className:"border border-red-600",variant:"danger",children:"Failed to login. Please verify your credentials"}),s.jsx("input",{value:e,onChange:u=>t(u.currentTarget.value),className:"input secondary",placeholder:"User name"}),s.jsx("input",{value:n,onChange:u=>o(u.currentTarget.value),className:"input secondary",type:"password",placeholder:"Password"}),s.jsx("div",{className:"flex justify-end",children:s.jsx("button",{type:"submit",className:"button primary",children:"Login"})})]})]})})},Q0=()=>{const e=J(),{pathname:t}=fe(),{data:n,isLoading:o}=Zr();l.useEffect(()=>{!n&&!o&&!D.login.check(t)&&e(D.login.build())},[n,o,e,t])},K0=()=>{},G0=__CLIENT_CONFIG__.skipAuth?K0:Q0,Y0=()=>{const[e]=$l(),t=J(),n=Et(),o=e.get("shareId");return l.useEffect(()=>{o&&n.mutateAsync({queryId:o}).then(a=>{t(D.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(_o,{}),s.jsx("p",{children:"Fetching query information"})]}),n.isError&&s.jsx(me,{variant:"danger",children:"Failed to load query information"})]})},J0="_tab-container_b2cer_2",X0="_tab-name_b2cer_2",Z0="_archived-badge_b2cer_2 _badge_b2cer_2",ep="_active-badge_b2cer_2 _badge_b2cer_2",tp="_delete-action_b2cer_2",yn={tabContainer:J0,tabName:X0,archivedBadge:Z0,activeBadge:ep,deleteAction:tp},Qa=({onLoadMore:e,children:t,onClose:n,hasMore:o,onSearchValue:a,searchValue:r})=>s.jsxs("aside",{className:"w-full lg:w-md no-scrollbar",children:[s.jsxs("div",{className:"sticky top-0 px-4 py-2 border-b border-gray-200 bg-white",children:[s.jsxs("h3",{className:"text-lg flex justify-between items-center",children:["Recent tabs",n&&s.jsx("button",{className:"cursor-pointer hover:bg-(--bg-ter) rounded-full p-1",onClick:n,children:s.jsx(_t,{width:24,height:24})})]}),s.jsx(Pn,{containerClassName:"mt-2",className:"text-sm",placeholder:"Filter",value:r,autoFocus:!0,onChange:i=>a(i.target.value)})]}),t,o&&s.jsx("div",{className:"flex justify-center my-2",children:s.jsx("button",{className:"text-blue-800 text-sm p-2 cursor-pointer",onClick:e,children:"Load more"})})]}),np=new Intl.DateTimeFormat,sp=()=>{const[e,t]=l.useState(""),n=No(e),{data:o}=ve(),{data:a,fetchNextPage:r,hasNextPage:i}=lc(o?.teamId,n,25),c=J(),u=ea(),h=Ic(),m=l.useRef(null),d=l.useRef(null),x=b=>{u.mutate(b),jn({show:!1}),c(D.workbenchTab.build({id:b}))},p=()=>{m.current?.close(),h.mutate(d.current)};return s.jsxs(Qa,{hasMore:i,onLoadMore:r,onClose:()=>jn({show:!1}),searchValue:e,onSearchValue:t,children:[a?.map(b=>s.jsxs("div",{className:yn.tabContainer,onClick:()=>x(b.id),onContextMenu:g=>{d.current=b.id,m.current?.open(g,!1)},children:[s.jsxs("div",{className:"flex gap-2 items-center",children:[s.jsx("p",{className:yn.tabName,children:b.name}),b.dataSourceType&&s.jsx(He,{size:16,type:b.dataSourceType}),s.jsx("p",{className:"text-xs text-(--text-color-secondary)",children:b.dataSourceName})]}),s.jsxs("div",{className:"flex gap-2 items-center mt-1",children:[s.jsx("p",{className:"text-xs text-(--text-color-secondary) italic",children:np.format(new Date(b.updatedAt))}),b.archived?s.jsx("span",{className:yn.archivedBadge,children:"Archived"}):s.jsx("span",{className:yn.activeBadge,children:"Active"})]})]},b.id)),s.jsx(ga,{ref:m,children:s.jsx("button",{onClick:p,className:yn.deleteAction,children:"🗑 Delete"})})]})},op=()=>{const e=wu(t=>t.show);return s.jsx(So,{isVisible:e,onClose:()=>jn({show:!1}),backdropClose:!0,children:s.jsx(sp,{})})},rp=()=>{const{data:e}=ve(),t=dc(e?.teamId),n=J();return l.useEffect(()=>{t.mutateAsync().then(o=>{o?n(D.workbenchTab.build({id:o.id}),{replace:!0}):n(D.home.build(),{replace:!0})})},[]),null},ap="_query-entry_1fuln_2",ip={queryEntry:ap},lp=new Intl.DateTimeFormat,cp=({projectQueries:e,isLoading:t})=>{const n=l.useRef(void 0),o=J(),a=Sh(),r=Et(),i=_h(),c=fa(),u=d=>{r.mutateAsync({queryId:d}).then(x=>{In({show:!1}),o(D.workbenchTab.build({id:x.id}))})},h=async d=>{const x=e?.find(b=>b.id===d);if(!x)return;const p=await On("New name?",x?.name);p&&a.mutate({id:x.savedQueryId,payload:{name:p}})},m=d=>{const x=e?.find(p=>p.id===d)?.savedQueryId;x&&i.mutate(x)};return s.jsxs("div",{className:"flex flex-col px-2",children:[ge(e?.length,0)&&e.map(d=>s.jsxs("button",{className:ip.queryEntry,onClick:()=>u(d.id),onContextMenu:x=>{n.current=d.id,c.open(x)},children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-left text-sm font-semibold text-(--text-color-primary)",children:d.name}),s.jsx("p",{className:"text-left text-xs text-(--text-color-secondary) italic",children:lp.format(new Date(d.updatedAt))})]}),s.jsxs("p",{className:"flex gap-2 items-center",children:[s.jsx(He,{size:16,type:d.datasourceType}),s.jsx("span",{className:"truncate text-xs text-(--text-color-secondary)",children:d.datasourceName})]})]},d.savedQueryId)),!t&&Jd(e?.length,1)&&s.jsx("p",{className:"text-center text-sm text-(--text-color-secondary) mt-2",children:"Empty"}),s.jsx(pa,{handler:c,children:s.jsxs("div",{className:"context-menu-container",children:[s.jsx("button",{onClick:d=>{d.preventDefault(),d.stopPropagation(),c.close(),h(n.current)},className:"context-menu-item",children:"✏️ Rename"}),s.jsx("button",{onClick:d=>{d.preventDefault(),d.stopPropagation(),c.close(),m(n.current)},className:"context-menu-item",children:"🗑️ Delete"})]})})]})},up=()=>{const{data:e}=ve(),[t,n]=l.useState(""),o=No(t),{data:a,isLoading:r,fetchNextPage:i,hasNextPage:c}=cc(e?.teamId,o);return s.jsx(Qa,{hasMore:c,onClose:()=>In({show:!1}),onLoadMore:i,searchValue:t,onSearchValue:n,children:s.jsx(cp,{isLoading:r,projectQueries:a||[]})})},dp=()=>{const e=yu(t=>t.show);return s.jsx(So,{isVisible:e,onClose:()=>In({show:!1}),backdropClose:!0,children:s.jsx(up,{})})};function hp(){return I0(),G0(),s.jsxs(s.Fragment,{children:[s.jsxs(ll,{children:[s.jsx(Ht,{path:D.home.path,element:s.jsx(Pu,{})}),s.jsx(Ht,{path:D.workbench.path,element:s.jsx(rp,{})}),s.jsx(Ht,{path:D.workbenchTab.path,element:s.jsx(Hf,{})}),s.jsx(Ht,{path:D.login.path,element:s.jsx(V0,{})}),s.jsx(Ht,{path:D.share.path,element:s.jsx(Y0,{})})]}),s.jsx(Ku,{}),s.jsx(od,{}),s.jsx(gd,{}),s.jsx(g0,{}),s.jsx(A0,{}),s.jsx(O0,{}),s.jsx(U0,{}),s.jsx(op,{}),s.jsx(dp,{}),s.jsx(hd,{}),s.jsx(id,{})]})}const mp="_hidden_134hh_2",fp="_desktop-layout_134hh_2",pp="_mobile-layout_134hh_2",xp="_nav_134hh_2",gp="_shown_134hh_2",bp="_main_134hh_2",vp="_header_134hh_2",yp="_expand_134hh_2",wp="_show_134hh_2",Cp="_hide_134hh_2",jp="_icon_134hh_2",Np="_nav-item_134hh_2",_p="_project-wrapper_134hh_2",O={hidden:mp,desktopLayout:fp,mobileLayout:pp,nav:xp,shown:gp,main:bp,header:vp,expand:yp,show:wp,hide:Cp,icon:jp,navItem:Np,projectWrapper:_p},Sp=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{fill:"currentColor",d:"M507 211.16c-1.42-1.19-14.25-10.94-41.79-10.94a132.55 132.55 0 00-21.61 1.9c-5.22-36.4-35.38-54-36.57-55l-7.36-4.28-4.75 6.9a101.65 101.65 0 00-13.06 30.45c-5 20.7-1.9 40.2 8.55 56.85-12.59 7.14-33 8.8-37.28 9H15.94A15.93 15.93 0 000 262.07a241.25 241.25 0 0014.75 86.83C26.39 379.35 43.72 402 66 415.74 91.22 431.2 132.3 440 178.6 440a344.23 344.23 0 0062.45-5.71 257.44 257.44 0 0081.69-29.73 223.55 223.55 0 0055.57-45.67c26.83-30.21 42.74-64 54.38-94h4.75c29.21 0 47.26-11.66 57.23-21.65a63.31 63.31 0 0015.2-22.36l2.14-6.18z"}),l.createElement("path",{fill:"currentColor",d:"M47.29 236.37H92.4a4 4 0 004-4v-40.48a4 4 0 00-4-4H47.29a4 4 0 00-4 4v40.44a4.16 4.16 0 004 4M109.5 236.37h45.12a4 4 0 004-4v-40.48a4 4 0 00-4-4H109.5a4 4 0 00-4 4v40.44a4.16 4.16 0 004 4M172.9 236.37H218a4 4 0 004-4v-40.48a4 4 0 00-4-4h-45.1a4 4 0 00-4 4v40.44a3.87 3.87 0 004 4M235.36 236.37h45.12a4 4 0 004-4v-40.48a4 4 0 00-4-4h-45.12a4 4 0 00-4 4v40.44a4 4 0 004 4M109.5 178.57h45.12a4.16 4.16 0 004-4v-40.48a4 4 0 00-4-4H109.5a4 4 0 00-4 4v40.44a4.34 4.34 0 004 4M172.9 178.57H218a4.16 4.16 0 004-4v-40.48a4 4 0 00-4-4h-45.1a4 4 0 00-4 4v40.44a4 4 0 004 4M235.36 178.57h45.12a4.16 4.16 0 004-4v-40.48a4.16 4.16 0 00-4-4h-45.12a4 4 0 00-4 4v40.44a4.16 4.16 0 004 4M235.36 120.53h45.12a4 4 0 004-4V76a4.16 4.16 0 00-4-4h-45.12a4 4 0 00-4 4v40.44a4.17 4.17 0 004 4M298.28 236.37h45.12a4 4 0 004-4v-40.48a4 4 0 00-4-4h-45.12a4 4 0 00-4 4v40.44a4.16 4.16 0 004 4"})),kp=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"})),Ep=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"})),Rp=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{d:"M304 336v40a40 40 0 01-40 40H104a40 40 0 01-40-40V136a40 40 0 0140-40h152c22.09 0 48 17.91 48 40v40M368 336l80-80-80-80M176 256h256",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32})),Lp=e=>l.createElement("svg",{className:"ionicon",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg",...e},l.createElement("path",{d:"m 266.89,52 c -5,-5.28 -16.69,-5.34 -21.78,0 L 80,212 v 236 c 0,8.83656 7.163444,16 16,16 h 96 V 328 c 0,-13.25483 10.74517,-24 24,-24 h 80 c 13.25483,0 24,10.74517 24,24 v 136 h 96 c 8.83656,0 16,-7.16344 16,-16 l -0.16428,-236.06357 z",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32})),Tp=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{d:"M344 144c-3.92 52.87-44 96-88 96s-84.15-43.12-88-96c-4-55 35-96 88-96s92 42 88 96z",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32}),l.createElement("path",{d:"M256 304c-87 0-175.3 48-191.64 138.6C62.39 453.52 68.57 464 80 464h352c11.44 0 17.62-10.48 15.65-21.4C431.3 352 343 304 256 304z",fill:"none",stroke:"currentColor",strokeMiterlimit:10,strokeWidth:32})),Ap=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{d:"M402 168c-2.93 40.67-33.1 72-66 72s-63.12-31.32-66-72c-3-42.31 26.37-72 66-72s69 30.46 66 72z",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32}),l.createElement("path",{d:"M336 304c-65.17 0-127.84 32.37-143.54 95.41-2.08 8.34 3.15 16.59 11.72 16.59h263.65c8.57 0 13.77-8.25 11.72-16.59C463.85 335.36 401.18 304 336 304z",fill:"none",stroke:"currentColor",strokeMiterlimit:10,strokeWidth:32}),l.createElement("path",{d:"M200 185.94c-2.34 32.48-26.72 58.06-53 58.06s-50.7-25.57-53-58.06C91.61 152.15 115.34 128 147 128s55.39 24.77 53 57.94z",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32}),l.createElement("path",{d:"M206 306c-18.05-8.27-37.93-11.45-59-11.45-52 0-102.1 25.85-114.65 76.2-1.65 6.66 2.53 13.25 9.37 13.25H154",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeMiterlimit:10,strokeWidth:32})),Ip=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{d:"M380.93 57.37A32 32 0 00358.3 48H94.22A46.21 46.21 0 0048 94.22v323.56A46.21 46.21 0 0094.22 464h323.56A46.36 46.36 0 00464 417.78V153.7a32 32 0 00-9.37-22.63zM256 416a64 64 0 1164-64 63.92 63.92 0 01-64 64zm48-224H112a16 16 0 01-16-16v-64a16 16 0 0116-16h192a16 16 0 0116 16v64a16 16 0 01-16 16z",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32})),wr=!__CLIENT_CONFIG__.skipAuth,Cr=(()=>{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`}})(),Y=20,Se="text-(--text-color-primary)";function Pp(){switch(__CLIENT_CONFIG__.modeName){case"docker":return s.jsx(Sp,{className:Se,width:Y,height:Y});case"cli":return s.jsx(kp,{className:Se,width:Y,height:Y});default:return s.jsx(Ep,{className:Se,width:Y,height:Y})}}const Mp=({dataSource:e})=>s.jsxs("button",{className:O.navItem,onClick:()=>Nn(e.id),"data-tooltip-id":"default","data-tooltip-content":e.name,"data-tooltip-place":"right",children:[s.jsx("span",{className:O.icon,children:s.jsx(He,{size:20,type:e.dbType})}),s.jsx("span",{className:"truncate",children:e.name})]}),Op=()=>{const e=J(),{pathname:t}=fe(),{data:n}=ve(),o=Tn("Desktop nav"),[a,r]=l.useState(!1),{data:i}=bs(),{data:c}=rc(n?.teamId),u=()=>{D.home.check(t)||e(D.home.build())},h=b=>{D.workbenchTab.check(t)||e(D.workbenchTab.build({id:b}))},m=()=>{In({show:!0})},d=()=>{mo("Are you sure you want to logout?").then(b=>{b&&(e("/"),hs.logout())})},x=()=>jn({show:!0}),p=a?void 0:"default";return s.jsxs("nav",{className:I(O.nav,a?O.shown:O.hidden),children:[n&&s.jsxs("div",{className:O.header,children:[s.jsxs("button",{onClick:u,className:O.navItem,"data-tooltip-id":p,"data-tooltip-content":"Home",children:[s.jsx("span",{className:O.icon,children:s.jsx(Lp,{className:Se,width:Y,height:Y})}),s.jsx("span",{className:"truncate",children:"Home"})]}),s.jsxs("button",{onClick:o,className:O.navItem,"data-tooltip-id":p,"data-tooltip-content":"New query",children:[s.jsx("span",{className:O.icon,children:s.jsx(tn,{className:Se,width:Y,height:Y})}),s.jsx("span",{className:"truncate",children:"New query"}),s.jsx("span",{className:"hotkey secondary",children:"N"})]}),s.jsxs("button",{onClick:x,className:O.navItem,"data-tooltip-id":p,"data-tooltip-content":"Recent tabs",children:[s.jsx("span",{className:O.icon,children:s.jsx(ra,{className:Se,width:Y,height:Y})}),s.jsx("span",{className:"truncate",children:"Recent tabs"}),s.jsx("span",{className:"hotkey secondary",children:"H"})]}),s.jsxs("button",{onClick:m,className:O.navItem,"data-tooltip-id":p,"data-tooltip-content":"Saved queries",children:[s.jsx("span",{className:O.icon,children:s.jsx(Ip,{className:Se,width:Y,height:Y})}),s.jsx("span",{className:"truncate",children:"Saved queries"})]}),ge(i?.length,0)&&s.jsxs("button",{onClick:()=>h(i[0].id),className:O.navItem,"data-tooltip-id":p,"data-tooltip-content":"Workbench",children:[s.jsx("span",{className:O.icon,children:s.jsx(aa,{className:Se,width:Y,height:Y})}),s.jsx("span",{className:"truncate",children:"Workbench"}),s.jsx("span",{className:"hotkey secondary",children:"W"})]}),wr&&s.jsxs(s.Fragment,{children:[s.jsxs("button",{onClick:Ha,className:O.navItem,"data-tooltip-id":p,"data-tooltip-content":"User settings",children:[s.jsx("span",{className:O.icon,children:s.jsx(Tp,{className:Se,width:Y,height:Y})}),s.jsx("span",{className:"truncate",children:n.username})]}),s.jsxs("button",{onClick:Va,className:O.navItem,"data-tooltip-id":p,"data-tooltip-content":"Manage users",children:[s.jsx("span",{className:O.icon,children:s.jsx(Ap,{className:Se,width:Y,height:Y})}),s.jsx("span",{className:"truncate",children:"Manage users"})]})]})]}),s.jsx("div",{className:I(O.projectWrapper),children:ge(c?.length,0)&&s.jsx("div",{className:"mt-4 flex flex-col",children:c.map(b=>s.jsx(Mp,{dataSource:b},b.id))})}),wr&&s.jsxs("button",{onClick:d,"data-tooltip-id":p,"data-tooltip-content":"Logout",className:`${O.navItem} mx-1`,children:[s.jsx("span",{className:O.icon,children:s.jsx(Rp,{className:Se,width:20,height:20})}),s.jsx("span",{className:"truncate text-sm text-(--text-color-primary)",children:"Logout"})]}),s.jsxs("div",{className:`${O.navItem} mx-1 cursor-auto!`,"data-tooltip-id":p,"data-tooltip-content":Cr,children:[s.jsx("span",{className:O.icon,children:s.jsx(Pp,{})}),s.jsx("span",{className:"truncate text-sm text-(--text-color-primary)",children:Cr})]}),s.jsxs("button",{onClick:()=>r(!a),"data-tooltip-id":"default","data-tooltip-content":"Expand sidebar","data-tooltip-hidden":a,"data-tooltip-place":"right",className:`${O.navItem} mx-1`,children:[s.jsx("span",{className:I(O.icon,O.expand,a?O.show:O.hide),children:s.jsx(Sn,{className:Se,width:20,height:20})}),s.jsx("span",{className:"truncate text-sm text-(--text-color-primary)",children:"Collapse menu"})]})]})},Dp="_root_uwb3a_2",$p={root:Dp},Ka=!__CLIENT_CONFIG__.skipAuth,Fp=`${$p.root} ${Ka?"grid-cols-4":"grid-cols-2"}`,Bp=()=>{const{pathname:e}=fe(),t=J(),n=Tn("Mobile nav"),o=()=>{D.home.check(e)||t(D.home.build())};return s.jsxs("div",{className:Fp,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"})]}),Ka&&s.jsxs(s.Fragment,{children:[s.jsxs("button",{onClick:Ha,children:[s.jsx("p",{children:"🪪"}),s.jsx("p",{className:"text-xs font-semibold text-gray-600",children:"Account"})]}),s.jsxs("button",{onClick:Va,children:[s.jsx("p",{children:"👥"}),s.jsx("p",{className:"text-xs font-semibold text-gray-600",children:"Users"})]})]})]})},qp=({children:e,isLogin:t})=>s.jsxs("div",{className:O.desktopLayout,children:[s.jsx(us,{id:"default",className:"z-100"}),s.jsx(us,{id:"default-xs",className:"z-100 text-xs!"}),!t&&s.jsx(Op,{}),s.jsx("main",{className:O.main,children:e})]}),Wp=({children:e,isLogin:t})=>s.jsxs("div",{className:O.mobileLayout,children:[s.jsx("main",{className:O.main,children:e}),!t&&s.jsx(Bp,{})]}),Up=({children:e})=>{const t=da(fo.laptop),{pathname:n}=fe(),o=D.login.check(n);return t?s.jsx(qp,{isLogin:o,children:e}):s.jsx(Wp,{isLogin:o,children:e})};ci.createRoot(document.getElementById("root")).render(s.jsxs(nt.StrictMode,{children:[s.jsx(ui,{}),s.jsx(Kl,{client:K,children:s.jsx(Il,{children:s.jsx(Up,{children:s.jsx(hp,{})})})})]}));