@dataramen/cli 0.0.79 → 0.0.80

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.
@@ -0,0 +1,4 @@
1
+ import{r as l,a as hi,S as Ir,p as Fo,b as Te,s as ss,c as yn,n as os,i as Vs,d as Bo,t as mi,e as Kn,f as fi,g as pi,h as qo,j as ds,k as Wo,l as xi,m as gi,o as Uo,q as bi,u as s,v as so,w as J,x as B,y as Mr,A as hs,z as vi,B as A,C as kn,D as ge,E as fe,F as yi,G as wi,R as at,H as Ci,I as ji}from"./index-BH-53aoF.js";var zo="popstate";function Ni(e={}){function t(o,r){let{pathname:a,search:i,hash:c}=o.location;return Ks("",{pathname:a,search:i,hash:c},r.state&&r.state.usr||null,r.state&&r.state.key||"default")}function n(o,r){return typeof r=="string"?r:wn(r)}return Si(t,n,null,e)}function Q(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 _i(){return Math.random().toString(36).substring(2,10)}function Ho(e,t){return{usr:e.state,key:e.key,idx:t}}function Ks(e,t,n=null,o){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?Xt(t):t,state:n,key:t&&t.key||o||_i()}}function wn({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 Xt(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 Si(e,t,n,o={}){let{window:r=document.defaultView,v5Compat:a=!1}=o,i=r.history,c="POP",u=null,h=m();h==null&&(h=0,i.replaceState({...i.state,idx:h},""));function m(){return(i.state||{idx:null}).idx}function d(){c="POP";let v=m(),w=v==null?null:v-h;h=v,u&&u({action:c,location:b.location,delta:w})}function g(v,w){c="PUSH";let p=Ks(b.location,v,w);h=m()+1;let y=Ho(p,h),C=b.createHref(p);try{i.pushState(y,"",C)}catch(N){if(N instanceof DOMException&&N.name==="DataCloneError")throw N;r.location.assign(C)}a&&u&&u({action:c,location:b.location,delta:1})}function f(v,w){c="REPLACE";let p=Ks(b.location,v,w);h=m();let y=Ho(p,h),C=b.createHref(p);i.replaceState(y,"",C),a&&u&&u({action:c,location:b.location,delta:0})}function x(v){return ki(v)}let b={get action(){return c},get location(){return e(r,i)},listen(v){if(u)throw new Error("A history only accepts one active listener");return r.addEventListener(zo,d),u=v,()=>{r.removeEventListener(zo,d),u=null}},createHref(v){return t(r,v)},createURL:x,encodeLocation(v){let w=x(v);return{pathname:w.pathname,search:w.search,hash:w.hash}},push:g,replace:f,go(v){return i.go(v)}};return b}function ki(e,t=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),Q(n,"No window.location.(origin|href) available to create URL");let o=typeof e=="string"?e:wn(e);return o=o.replace(/ $/,"%20"),!t&&o.startsWith("//")&&(o=n+o),new URL(o,n)}function Pr(e,t,n="/"){return Ei(e,t,n,!1)}function Ei(e,t,n,o){let r=typeof t=="string"?Xt(t):t,a=Xe(r.pathname||"/",n);if(a==null)return null;let i=Or(e);Ri(i);let c=null;for(let u=0;c==null&&u<i.length;++u){let h=Bi(a);c=$i(i[u],h,o)}return c}function Or(e,t=[],n=[],o="",r=!1){let a=(i,c,u=r,h)=>{let m={relativePath:h===void 0?i.path||"":h,caseSensitive:i.caseSensitive===!0,childrenIndex:c,route:i};if(m.relativePath.startsWith("/")){if(!m.relativePath.startsWith(o)&&u)return;Q(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=Je([o,m.relativePath]),g=n.concat(m);i.children&&i.children.length>0&&(Q(i.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${d}".`),Or(i.children,t,g,d,u)),!(i.path==null&&!i.index)&&t.push({path:d,score:Oi(d,i.index),routesMeta:g})};return e.forEach((i,c)=>{if(i.path===""||!i.path?.includes("?"))a(i,c);else for(let u of Dr(i.path))a(i,c,!0,u)}),t}function Dr(e){let t=e.split("/");if(t.length===0)return[];let[n,...o]=t,r=n.endsWith("?"),a=n.replace(/\?$/,"");if(o.length===0)return r?[a,""]:[a];let i=Dr(o.join("/")),c=[];return c.push(...i.map(u=>u===""?a:[a,u].join("/"))),r&&c.push(...i),c.map(u=>e.startsWith("/")&&u===""?"/":u)}function Ri(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:Di(t.routesMeta.map(o=>o.childrenIndex),n.routesMeta.map(o=>o.childrenIndex)))}var Li=/^:[\w-]+$/,Ti=3,Ai=2,Ii=1,Mi=10,Pi=-2,Vo=e=>e==="*";function Oi(e,t){let n=e.split("/"),o=n.length;return n.some(Vo)&&(o+=Pi),t&&(o+=Ai),n.filter(r=>!Vo(r)).reduce((r,a)=>r+(Li.test(a)?Ti:a===""?Ii:Mi),o)}function Di(e,t){return e.length===t.length&&e.slice(0,-1).every((o,r)=>o===t[r])?e[e.length-1]-t[t.length-1]:0}function $i(e,t,n=!1){let{routesMeta:o}=e,r={},a="/",i=[];for(let c=0;c<o.length;++c){let u=o[c],h=c===o.length-1,m=a==="/"?t:t.slice(a.length)||"/",d=Gt({path:u.relativePath,caseSensitive:u.caseSensitive,end:h},m),g=u.route;if(!d&&h&&n&&!o[o.length-1].route.index&&(d=Gt({path:u.relativePath,caseSensitive:u.caseSensitive,end:!1},m)),!d)return null;Object.assign(r,d.params),i.push({params:r,pathname:Je([a,d.pathname]),pathnameBase:zi(Je([a,d.pathnameBase])),route:g}),d.pathnameBase!=="/"&&(a=Je([a,d.pathnameBase]))}return i}function Gt(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[n,o]=Fi(e.path,e.caseSensitive,e.end),r=t.match(n);if(!r)return null;let a=r[0],i=a.replace(/(.)\/+$/,"$1"),c=r.slice(1);return{params:o.reduce((h,{paramName:m,isOptional:d},g)=>{if(m==="*"){let x=c[g]||"";i=a.slice(0,a.length-x.length).replace(/(.)\/+$/,"$1")}const f=c[g];return d&&!f?h[m]=void 0:h[m]=(f||"").replace(/%2F/g,"/"),h},{}),pathname:a,pathnameBase:i,pattern:e}}function Fi(e,t=!1,n=!0){Ee(e==="*"||!e.endsWith("*")||e.endsWith("/*"),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,"/*")}".`);let o=[],r="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(i,c,u)=>(o.push({paramName:c,isOptional:u!=null}),u?"/?([^\\/]+)?":"/([^\\/]+)")).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(o.push({paramName:"*"}),r+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?r+="\\/*$":e!==""&&e!=="/"&&(r+="(?:(?=\\/|$))"),[new RegExp(r,t?void 0:"i"),o]}function Bi(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 Xe(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 $r=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,qi=e=>$r.test(e);function Wi(e,t="/"){let{pathname:n,search:o="",hash:r=""}=typeof e=="string"?Xt(e):e,a;if(n)if(qi(n))a=n;else{if(n.includes("//")){let i=n;n=n.replace(/\/\/+/g,"/"),Ee(!1,`Pathnames cannot have embedded double slashes - normalizing ${i} -> ${n}`)}n.startsWith("/")?a=Ko(n.substring(1),"/"):a=Ko(n,t)}else a=t;return{pathname:a,search:Hi(o),hash:Vi(r)}}function Ko(e,t){let n=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(r=>{r===".."?n.length>1&&n.pop():r!=="."&&n.push(r)}),n.length>1?n.join("/"):"/"}function Is(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 Ui(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function Fr(e){let t=Ui(e);return t.map((n,o)=>o===t.length-1?n.pathname:n.pathnameBase)}function Br(e,t,n,o=!1){let r;typeof e=="string"?r=Xt(e):(r={...e},Q(!r.pathname||!r.pathname.includes("?"),Is("?","pathname","search",r)),Q(!r.pathname||!r.pathname.includes("#"),Is("#","pathname","hash",r)),Q(!r.search||!r.search.includes("#"),Is("#","search","hash",r)));let a=e===""||r.pathname==="",i=a?"/":r.pathname,c;if(i==null)c=n;else{let d=t.length-1;if(!o&&i.startsWith("..")){let g=i.split("/");for(;g[0]==="..";)g.shift(),d-=1;r.pathname=g.join("/")}c=d>=0?t[d]:"/"}let u=Wi(r,c),h=i&&i!=="/"&&i.endsWith("/"),m=(a||i===".")&&n.endsWith("/");return!u.pathname.endsWith("/")&&(h||m)&&(u.pathname+="/"),u}var Je=e=>e.join("/").replace(/\/\/+/g,"/"),zi=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),Hi=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,Vi=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,Ki=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 Qi(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function Gi(e){return e.map(t=>t.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var qr=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Wr(e,t){let n=e;if(typeof n!="string"||!$r.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let o=n,r=!1;if(qr)try{let a=new URL(window.location.href),i=n.startsWith("//")?new URL(a.protocol+n):new URL(n),c=Xe(i.pathname,t);i.origin===a.origin&&c!=null?n=c+i.search+i.hash:r=!0}catch{Ee(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:o,isExternal:r,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var Ur=["POST","PUT","PATCH","DELETE"];new Set(Ur);var Yi=["GET",...Ur];new Set(Yi);var Zt=l.createContext(null);Zt.displayName="DataRouter";var ms=l.createContext(null);ms.displayName="DataRouterState";var Ji=l.createContext(!1),zr=l.createContext({isTransitioning:!1});zr.displayName="ViewTransition";var Xi=l.createContext(new Map);Xi.displayName="Fetchers";var Zi=l.createContext(null);Zi.displayName="Await";var Re=l.createContext(null);Re.displayName="Navigation";var En=l.createContext(null);En.displayName="Location";var ze=l.createContext({outlet:null,matches:[],isDataRoute:!1});ze.displayName="Route";var oo=l.createContext(null);oo.displayName="RouteError";var Hr="REACT_ROUTER_ERROR",el="REDIRECT",tl="ROUTE_ERROR_RESPONSE";function nl(e){if(e.startsWith(`${Hr}:${el}:{`))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 sl(e){if(e.startsWith(`${Hr}:${tl}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string")return new Ki(t.status,t.statusText,t.data)}catch{}}function ol(e,{relative:t}={}){Q(Rn(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:o}=l.useContext(Re),{hash:r,pathname:a,search:i}=Ln(e,{relative:t}),c=a;return n!=="/"&&(c=a==="/"?n:Je([n,a])),o.createHref({pathname:c,search:i,hash:r})}function Rn(){return l.useContext(En)!=null}function pe(){return Q(Rn(),"useLocation() may be used only in the context of a <Router> component."),l.useContext(En).location}var Vr="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Kr(e){l.useContext(Re).static||l.useLayoutEffect(e)}function ee(){let{isDataRoute:e}=l.useContext(ze);return e?bl():rl()}function rl(){Q(Rn(),"useNavigate() may be used only in the context of a <Router> component.");let e=l.useContext(Zt),{basename:t,navigator:n}=l.useContext(Re),{matches:o}=l.useContext(ze),{pathname:r}=pe(),a=JSON.stringify(Fr(o)),i=l.useRef(!1);return Kr(()=>{i.current=!0}),l.useCallback((u,h={})=>{if(Ee(i.current,Vr),!i.current)return;if(typeof u=="number"){n.go(u);return}let m=Br(u,JSON.parse(a),r,h.relative==="path");e==null&&t!=="/"&&(m.pathname=m.pathname==="/"?t:Je([t,m.pathname])),(h.replace?n.replace:n.push)(m,h.state,h)},[t,n,a,r,e])}l.createContext(null);function al(){let{matches:e}=l.useContext(ze),t=e[e.length-1];return t?t.params:{}}function Ln(e,{relative:t}={}){let{matches:n}=l.useContext(ze),{pathname:o}=pe(),r=JSON.stringify(Fr(n));return l.useMemo(()=>Br(e,JSON.parse(r),o,t==="path"),[e,r,o,t])}function il(e,t){return Qr(e,t)}function Qr(e,t,n,o,r){Q(Rn(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:a}=l.useContext(Re),{matches:i}=l.useContext(ze),c=i[i.length-1],u=c?c.params:{},h=c?c.pathname:"/",m=c?c.pathnameBase:"/",d=c&&c.route;{let p=d&&d.path||"";Yr(h,!d||p.endsWith("*")||p.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${h}" (under <Route path="${p}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
2
+
3
+ Please change the parent <Route path="${p}"> to <Route path="${p==="/"?"*":`${p}/*`}">.`)}let g=pe(),f;if(t){let p=typeof t=="string"?Xt(t):t;Q(m==="/"||p.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 "${p.pathname}" was given in the \`location\` prop.`),f=p}else f=g;let x=f.pathname||"/",b=x;if(m!=="/"){let p=m.replace(/^\//,"").split("/");b="/"+x.replace(/^\//,"").split("/").slice(p.length).join("/")}let v=Pr(e,{pathname:b});Ee(d||v!=null,`No routes matched location "${f.pathname}${f.search}${f.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 "${f.pathname}${f.search}${f.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 w=hl(v&&v.map(p=>Object.assign({},p,{params:Object.assign({},u,p.params),pathname:Je([m,a.encodeLocation?a.encodeLocation(p.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:p.pathname]),pathnameBase:p.pathnameBase==="/"?m:Je([m,a.encodeLocation?a.encodeLocation(p.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:p.pathnameBase])})),i,n,o,r);return t&&w?l.createElement(En.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...f},navigationType:"POP"}},w):w}function ll(){let e=gl(),t=Qi(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,o="rgba(200,200,200, 0.5)",r={padding:"0.5rem",backgroundColor:o},a={padding:"2px 4px",backgroundColor:o},i=null;return console.error("Error handled by React Router default ErrorBoundary:",e),i=l.createElement(l.Fragment,null,l.createElement("p",null,"💿 Hey developer 👋"),l.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",l.createElement("code",{style:a},"ErrorBoundary")," or"," ",l.createElement("code",{style:a},"errorElement")," prop on your route.")),l.createElement(l.Fragment,null,l.createElement("h2",null,"Unexpected Application Error!"),l.createElement("h3",{style:{fontStyle:"italic"}},t),n?l.createElement("pre",{style:r},n):null,i)}var cl=l.createElement(ll,null),Gr=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=sl(e.digest);n&&(e=n)}let t=e!==void 0?l.createElement(ze.Provider,{value:this.props.routeContext},l.createElement(oo.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?l.createElement(ul,{error:e},t):t}};Gr.contextType=Ji;var Ms=new WeakMap;function ul({children:e,error:t}){let{basename:n}=l.useContext(Re);if(typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){let o=nl(t.digest);if(o){let r=Ms.get(t);if(r)throw r;let a=Wr(o.location,n);if(qr&&!Ms.get(t))if(a.isExternal||o.reloadDocument)window.location.href=a.absoluteURL||a.to;else{const i=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(a.to,{replace:o.replace}));throw Ms.set(t,i),i}return l.createElement("meta",{httpEquiv:"refresh",content:`0;url=${a.absoluteURL||a.to}`})}}return e}function dl({routeContext:e,match:t,children:n}){let o=l.useContext(Zt);return o&&o.static&&o.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(o.staticContext._deepestRenderedBoundaryId=t.route.id),l.createElement(ze.Provider,{value:e},n)}function hl(e,t=[],n=null,o=null,r=null){if(e==null){if(!n)return null;if(n.errors)e=n.matches;else if(t.length===0&&!n.initialized&&n.matches.length>0)e=n.matches;else return null}let a=e,i=n?.errors;if(i!=null){let m=a.findIndex(d=>d.route.id&&i?.[d.route.id]!==void 0);Q(m>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(i).join(",")}`),a=a.slice(0,Math.min(a.length,m+1))}let c=!1,u=-1;if(n)for(let m=0;m<a.length;m++){let d=a[m];if((d.route.HydrateFallback||d.route.hydrateFallbackElement)&&(u=m),d.route.id){let{loaderData:g,errors:f}=n,x=d.route.loader&&!g.hasOwnProperty(d.route.id)&&(!f||f[d.route.id]===void 0);if(d.route.lazy||x){c=!0,u>=0?a=a.slice(0,u+1):a=[a[0]];break}}}let h=n&&o?(m,d)=>{o(m,{location:n.location,params:n.matches?.[0]?.params??{},unstable_pattern:Gi(n.matches),errorInfo:d})}:void 0;return a.reduceRight((m,d,g)=>{let f,x=!1,b=null,v=null;n&&(f=i&&d.route.id?i[d.route.id]:void 0,b=d.route.errorElement||cl,c&&(u<0&&g===0?(Yr("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),x=!0,v=null):u===g&&(x=!0,v=d.route.hydrateFallbackElement||null)));let w=t.concat(a.slice(0,g+1)),p=()=>{let y;return f?y=b:x?y=v:d.route.Component?y=l.createElement(d.route.Component,null):d.route.element?y=d.route.element:y=m,l.createElement(dl,{match:d,routeContext:{outlet:m,matches:w,isDataRoute:n!=null},children:y})};return n&&(d.route.ErrorBoundary||d.route.errorElement||g===0)?l.createElement(Gr,{location:n.location,revalidation:n.revalidation,component:b,error:f,children:p(),routeContext:{outlet:null,matches:w,isDataRoute:!0},onError:h}):p()},null)}function ro(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function ml(e){let t=l.useContext(Zt);return Q(t,ro(e)),t}function fl(e){let t=l.useContext(ms);return Q(t,ro(e)),t}function pl(e){let t=l.useContext(ze);return Q(t,ro(e)),t}function ao(e){let t=pl(e),n=t.matches[t.matches.length-1];return Q(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function xl(){return ao("useRouteId")}function gl(){let e=l.useContext(oo),t=fl("useRouteError"),n=ao("useRouteError");return e!==void 0?e:t.errors?.[n]}function bl(){let{router:e}=ml("useNavigate"),t=ao("useNavigate"),n=l.useRef(!1);return Kr(()=>{n.current=!0}),l.useCallback(async(r,a={})=>{Ee(n.current,Vr),n.current&&(typeof r=="number"?await e.navigate(r):await e.navigate(r,{fromRouteId:t,...a}))},[e,t])}var Qo={};function Yr(e,t,n){!t&&!Qo[e]&&(Qo[e]=!0,Ee(!1,n))}l.memo(vl);function vl({routes:e,future:t,state:n,onError:o}){return Qr(e,void 0,n,o,t)}function Vt(e){Q(!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 yl({basename:e="/",children:t=null,location:n,navigationType:o="POP",navigator:r,static:a=!1,unstable_useTransitions:i}){Q(!Rn(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let c=e.replace(/^\/*/,"/"),u=l.useMemo(()=>({basename:c,navigator:r,static:a,unstable_useTransitions:i,future:{}}),[c,r,a,i]);typeof n=="string"&&(n=Xt(n));let{pathname:h="/",search:m="",hash:d="",state:g=null,key:f="default"}=n,x=l.useMemo(()=>{let b=Xe(h,c);return b==null?null:{location:{pathname:b,search:m,hash:d,state:g,key:f},navigationType:o}},[c,h,m,d,g,f,o]);return Ee(x!=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.`),x==null?null:l.createElement(Re.Provider,{value:u},l.createElement(En.Provider,{children:t,value:x}))}function wl({children:e,location:t}){return il(Qs(e),t)}function Qs(e,t=[]){let n=[];return l.Children.forEach(e,(o,r)=>{if(!l.isValidElement(o))return;let a=[...t,r];if(o.type===l.Fragment){n.push.apply(n,Qs(o.props.children,a));return}Q(o.type===Vt,`[${typeof o.type=="string"?o.type:o.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),Q(!o.props.index||!o.props.children,"An index route cannot have child routes.");let i={id:o.props.id||a.join("-"),caseSensitive:o.props.caseSensitive,element:o.props.element,Component:o.props.Component,index:o.props.index,path:o.props.path,middleware:o.props.middleware,loader:o.props.loader,action:o.props.action,hydrateFallbackElement:o.props.hydrateFallbackElement,HydrateFallback:o.props.HydrateFallback,errorElement:o.props.errorElement,ErrorBoundary:o.props.ErrorBoundary,hasErrorBoundary:o.props.hasErrorBoundary===!0||o.props.ErrorBoundary!=null||o.props.errorElement!=null,shouldRevalidate:o.props.shouldRevalidate,handle:o.props.handle,lazy:o.props.lazy};o.props.children&&(i.children=Qs(o.props.children,a)),n.push(i)}),n}var Xn="get",Zn="application/x-www-form-urlencoded";function fs(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function Cl(e){return fs(e)&&e.tagName.toLowerCase()==="button"}function jl(e){return fs(e)&&e.tagName.toLowerCase()==="form"}function Nl(e){return fs(e)&&e.tagName.toLowerCase()==="input"}function _l(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function Sl(e,t){return e.button===0&&(!t||t==="_self")&&!_l(e)}function Gs(e=""){return new URLSearchParams(typeof e=="string"||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,n)=>{let o=e[n];return t.concat(Array.isArray(o)?o.map(r=>[n,r]):[[n,o]])},[]))}function kl(e,t){let n=Gs(e);return t&&t.forEach((o,r)=>{n.has(r)||t.getAll(r).forEach(a=>{n.append(r,a)})}),n}var Qn=null;function El(){if(Qn===null)try{new FormData(document.createElement("form"),0),Qn=!1}catch{Qn=!0}return Qn}var Rl=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Ps(e){return e!=null&&!Rl.has(e)?(Ee(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Zn}"`),null):e}function Ll(e,t){let n,o,r,a,i;if(jl(e)){let c=e.getAttribute("action");o=c?Xe(c,t):null,n=e.getAttribute("method")||Xn,r=Ps(e.getAttribute("enctype"))||Zn,a=new FormData(e)}else if(Cl(e)||Nl(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?Xe(u,t):null,n=e.getAttribute("formmethod")||c.getAttribute("method")||Xn,r=Ps(e.getAttribute("formenctype"))||Ps(c.getAttribute("enctype"))||Zn,a=new FormData(c,e),!El()){let{name:h,type:m,value:d}=e;if(m==="image"){let g=h?`${h}.`:"";a.append(`${g}x`,"0"),a.append(`${g}y`,"0")}else h&&a.append(h,d)}}else{if(fs(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=Xn,o=null,r=Zn,i=e}return a&&r==="text/plain"&&(i=a,a=void 0),{action:o,method:n.toLowerCase(),encType:r,formData:a,body:i}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function io(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function Tl(e,t,n,o){let r=typeof e=="string"?new URL(e,typeof window>"u"?"server://singlefetch/":window.location.origin):e;return n?r.pathname.endsWith("/")?r.pathname=`${r.pathname}_.${o}`:r.pathname=`${r.pathname}.${o}`:r.pathname==="/"?r.pathname=`_root.${o}`:t&&Xe(r.pathname,t)==="/"?r.pathname=`${t.replace(/\/$/,"")}/_root.${o}`:r.pathname=`${r.pathname.replace(/\/$/,"")}.${o}`,r}async function Al(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 Il(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 Ml(e,t,n){let o=await Promise.all(e.map(async r=>{let a=t.routes[r.route.id];if(a){let i=await Al(a,n);return i.links?i.links():[]}return[]}));return $l(o.flat(1).filter(Il).filter(r=>r.rel==="stylesheet"||r.rel==="preload").map(r=>r.rel==="stylesheet"?{...r,rel:"prefetch",as:"style"}:{...r,rel:"prefetch"}))}function Go(e,t,n,o,r,a){let i=(u,h)=>n[h]?u.route.id!==n[h].route.id:!0,c=(u,h)=>n[h].pathname!==u.pathname||n[h].route.path?.endsWith("*")&&n[h].params["*"]!==u.params["*"];return a==="assets"?t.filter((u,h)=>i(u,h)||c(u,h)):a==="data"?t.filter((u,h)=>{let m=o.routes[u.route.id];if(!m||!m.hasLoader)return!1;if(i(u,h)||c(u,h))return!0;if(u.route.shouldRevalidate){let d=u.route.shouldRevalidate({currentUrl:new URL(r.pathname+r.search+r.hash,window.origin),currentParams:n[0]?.params||{},nextUrl:new URL(e,window.origin),nextParams:u.params,defaultShouldRevalidate:!0});if(typeof d=="boolean")return d}return!0}):[]}function Pl(e,t,{includeHydrateFallback:n}={}){return Ol(e.map(o=>{let r=t.routes[o.route.id];if(!r)return[];let a=[r.module];return r.clientActionModule&&(a=a.concat(r.clientActionModule)),r.clientLoaderModule&&(a=a.concat(r.clientLoaderModule)),n&&r.hydrateFallbackModule&&(a=a.concat(r.hydrateFallbackModule)),r.imports&&(a=a.concat(r.imports)),a}).flat(1))}function Ol(e){return[...new Set(e)]}function Dl(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,r)=>{let a=JSON.stringify(Dl(r));return n.has(a)||(n.add(a),o.push({key:a,link:r})),o},[])}function Jr(){let e=l.useContext(Zt);return io(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function Fl(){let e=l.useContext(ms);return io(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var lo=l.createContext(void 0);lo.displayName="FrameworkContext";function Xr(){let e=l.useContext(lo);return io(e,"You must render this element inside a <HydratedRouter> element"),e}function Bl(e,t){let n=l.useContext(lo),[o,r]=l.useState(!1),[a,i]=l.useState(!1),{onFocus:c,onBlur:u,onMouseEnter:h,onMouseLeave:m,onTouchStart:d}=t,g=l.useRef(null);l.useEffect(()=>{if(e==="render"&&i(!0),e==="viewport"){let b=w=>{w.forEach(p=>{i(p.isIntersecting)})},v=new IntersectionObserver(b,{threshold:.5});return g.current&&v.observe(g.current),()=>{v.disconnect()}}},[e]),l.useEffect(()=>{if(o){let b=setTimeout(()=>{i(!0)},100);return()=>{clearTimeout(b)}}},[o]);let f=()=>{r(!0)},x=()=>{r(!1),i(!1)};return n?e!=="intent"?[a,g,{}]:[a,g,{onFocus:gn(c,f),onBlur:gn(u,x),onMouseEnter:gn(h,f),onMouseLeave:gn(m,x),onTouchStart:gn(d,f)}]:[!1,g,{}]}function gn(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function ql({page:e,...t}){let{router:n}=Jr(),o=l.useMemo(()=>Pr(n.routes,e,n.basename),[n.routes,e,n.basename]);return o?l.createElement(Ul,{page:e,matches:o,...t}):null}function Wl(e){let{manifest:t,routeModules:n}=Xr(),[o,r]=l.useState([]);return l.useEffect(()=>{let a=!1;return Ml(e,t,n).then(i=>{a||r(i)}),()=>{a=!0}},[e,t,n]),o}function Ul({page:e,matches:t,...n}){let o=pe(),{future:r,manifest:a,routeModules:i}=Xr(),{basename:c}=Jr(),{loaderData:u,matches:h}=Fl(),m=l.useMemo(()=>Go(e,t,h,a,o,"data"),[e,t,h,a,o]),d=l.useMemo(()=>Go(e,t,h,a,o,"assets"),[e,t,h,a,o]),g=l.useMemo(()=>{if(e===o.pathname+o.search+o.hash)return[];let b=new Set,v=!1;if(t.forEach(p=>{let y=a.routes[p.route.id];!y||!y.hasLoader||(!m.some(C=>C.route.id===p.route.id)&&p.route.id in u&&i[p.route.id]?.shouldRevalidate||y.hasClientLoader?v=!0:b.add(p.route.id))}),b.size===0)return[];let w=Tl(e,c,r.unstable_trailingSlashAwareDataRequests,"data");return v&&b.size>0&&w.searchParams.set("_routes",t.filter(p=>b.has(p.route.id)).map(p=>p.route.id).join(",")),[w.pathname+w.search]},[c,r.unstable_trailingSlashAwareDataRequests,u,o,a,m,t,e,i]),f=l.useMemo(()=>Pl(d,a),[d,a]),x=Wl(d);return l.createElement(l.Fragment,null,g.map(b=>l.createElement("link",{key:b,rel:"prefetch",as:"fetch",href:b,...n})),f.map(b=>l.createElement("link",{key:b,rel:"modulepreload",href:b,...n})),x.map(({key:b,link:v})=>l.createElement("link",{key:b,nonce:n.nonce,...v})))}function zl(...e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}var Hl=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{Hl&&(window.__reactRouterVersion="7.12.0")}catch{}function Vl({basename:e,children:t,unstable_useTransitions:n,window:o}){let r=l.useRef();r.current==null&&(r.current=Ni({window:o,v5Compat:!0}));let a=r.current,[i,c]=l.useState({action:a.action,location:a.location}),u=l.useCallback(h=>{n===!1?c(h):l.startTransition(()=>c(h))},[n]);return l.useLayoutEffect(()=>a.listen(u),[a,u]),l.createElement(yl,{basename:e,children:t,location:i.location,navigationType:i.action,navigator:a,unstable_useTransitions:n})}var Zr=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,ea=l.forwardRef(function({onClick:t,discover:n="render",prefetch:o="none",relative:r,reloadDocument:a,replace:i,state:c,target:u,to:h,preventScrollReset:m,viewTransition:d,unstable_defaultShouldRevalidate:g,...f},x){let{basename:b,unstable_useTransitions:v}=l.useContext(Re),w=typeof h=="string"&&Zr.test(h),p=Wr(h,b);h=p.to;let y=ol(h,{relative:r}),[C,N,I]=Bl(o,f),_=Yl(h,{replace:i,state:c,target:u,preventScrollReset:m,relative:r,viewTransition:d,unstable_defaultShouldRevalidate:g,unstable_useTransitions:v});function M(O){t&&t(O),O.defaultPrevented||_(O)}let k=l.createElement("a",{...f,...I,href:p.absoluteURL||y,onClick:p.isExternal||a?t:M,ref:zl(x,N),target:u,"data-discover":!w&&n==="render"?"true":void 0});return C&&!w?l.createElement(l.Fragment,null,k,l.createElement(ql,{page:y})):k});ea.displayName="Link";var Kl=l.forwardRef(function({"aria-current":t="page",caseSensitive:n=!1,className:o="",end:r=!1,style:a,to:i,viewTransition:c,children:u,...h},m){let d=Ln(i,{relative:h.relative}),g=pe(),f=l.useContext(ms),{navigator:x,basename:b}=l.useContext(Re),v=f!=null&&nc(d)&&c===!0,w=x.encodeLocation?x.encodeLocation(d).pathname:d.pathname,p=g.pathname,y=f&&f.navigation&&f.navigation.location?f.navigation.location.pathname:null;n||(p=p.toLowerCase(),y=y?y.toLowerCase():null,w=w.toLowerCase()),y&&b&&(y=Xe(y,b)||y);const C=w!=="/"&&w.endsWith("/")?w.length-1:w.length;let N=p===w||!r&&p.startsWith(w)&&p.charAt(C)==="/",I=y!=null&&(y===w||!r&&y.startsWith(w)&&y.charAt(w.length)==="/"),_={isActive:N,isPending:I,isTransitioning:v},M=N?t:void 0,k;typeof o=="function"?k=o(_):k=[o,N?"active":null,I?"pending":null,v?"transitioning":null].filter(Boolean).join(" ");let O=typeof a=="function"?a(_):a;return l.createElement(ea,{...h,"aria-current":M,className:k,ref:m,style:O,to:i,viewTransition:c},typeof u=="function"?u(_):u)});Kl.displayName="NavLink";var Ql=l.forwardRef(({discover:e="render",fetcherKey:t,navigate:n,reloadDocument:o,replace:r,state:a,method:i=Xn,action:c,onSubmit:u,relative:h,preventScrollReset:m,viewTransition:d,unstable_defaultShouldRevalidate:g,...f},x)=>{let{unstable_useTransitions:b}=l.useContext(Re),v=ec(),w=tc(c,{relative:h}),p=i.toLowerCase()==="get"?"get":"post",y=typeof c=="string"&&Zr.test(c),C=N=>{if(u&&u(N),N.defaultPrevented)return;N.preventDefault();let I=N.nativeEvent.submitter,_=I?.getAttribute("formmethod")||i,M=()=>v(I||N.currentTarget,{fetcherKey:t,method:_,navigate:n,replace:r,state:a,relative:h,preventScrollReset:m,viewTransition:d,unstable_defaultShouldRevalidate:g});b&&n!==!1?l.startTransition(()=>M()):M()};return l.createElement("form",{ref:x,method:p,action:w,onSubmit:o?u:C,...f,"data-discover":!y&&e==="render"?"true":void 0})});Ql.displayName="Form";function Gl(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function ta(e){let t=l.useContext(Zt);return Q(t,Gl(e)),t}function Yl(e,{target:t,replace:n,state:o,preventScrollReset:r,relative:a,viewTransition:i,unstable_defaultShouldRevalidate:c,unstable_useTransitions:u}={}){let h=ee(),m=pe(),d=Ln(e,{relative:a});return l.useCallback(g=>{if(Sl(g,t)){g.preventDefault();let f=n!==void 0?n:wn(m)===wn(d),x=()=>h(e,{replace:f,state:o,preventScrollReset:r,relative:a,viewTransition:i,unstable_defaultShouldRevalidate:c});u?l.startTransition(()=>x()):x()}},[m,h,d,n,o,t,e,r,a,i,c,u])}function Jl(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(Gs(e)),n=l.useRef(!1),o=pe(),r=l.useMemo(()=>kl(o.search,n.current?null:t.current),[o.search]),a=ee(),i=l.useCallback((c,u)=>{const h=Gs(typeof c=="function"?c(new URLSearchParams(r)):c);n.current=!0,a("?"+h,u)},[a,r]);return[r,i]}var Xl=0,Zl=()=>`__${String(++Xl)}__`;function ec(){let{router:e}=ta("useSubmit"),{basename:t}=l.useContext(Re),n=xl(),o=e.fetch,r=e.navigate;return l.useCallback(async(a,i={})=>{let{action:c,method:u,encType:h,formData:m,body:d}=Ll(a,t);if(i.navigate===!1){let g=i.fetcherKey||Zl();await o(g,n,i.action||c,{unstable_defaultShouldRevalidate:i.unstable_defaultShouldRevalidate,preventScrollReset:i.preventScrollReset,formData:m,body:d,formMethod:i.method||u,formEncType:i.encType||h,flushSync:i.flushSync})}else await r(i.action||c,{unstable_defaultShouldRevalidate:i.unstable_defaultShouldRevalidate,preventScrollReset:i.preventScrollReset,formData:m,body:d,formMethod:i.method||u,formEncType:i.encType||h,replace:i.replace,state:i.state,fromRouteId:n,flushSync:i.flushSync,viewTransition:i.viewTransition})},[o,r,t,n])}function tc(e,{relative:t}={}){let{basename:n}=l.useContext(Re),o=l.useContext(ze);Q(o,"useFormAction must be used inside a RouteContext");let[r]=o.matches.slice(-1),a={...Ln(e||".",{relative:t})},i=pe();if(e==null){a.search=i.search;let c=new URLSearchParams(a.search),u=c.getAll("index");if(u.some(m=>m==="")){c.delete("index"),u.filter(d=>d).forEach(d=>c.append("index",d));let m=c.toString();a.search=m?`?${m}`:""}}return(!e||e===".")&&r.route.index&&(a.search=a.search?a.search.replace(/^\?/,"?index&"):"?index"),n!=="/"&&(a.pathname=a.pathname==="/"?n:Je([n,a.pathname])),wn(a)}function nc(e,{relative:t}={}){let n=l.useContext(zr);Q(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:o}=ta("useViewTransitionState"),r=Ln(e,{relative:t});if(!n.isTransitioning)return!1;let a=Xe(n.currentLocation.pathname,o)||n.currentLocation.pathname,i=Xe(n.nextLocation.pathname,o)||n.nextLocation.pathname;return Gt(r.pathname,i)!=null||Gt(r.pathname,a)!=null}var co=hi(),na=class extends Ir{constructor(e,t){super(),this.options=t,this.#n=e,this.#i=null,this.#a=Fo(),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),Yo(this.#e,this.options)?this.#d():this.updateResult(),this.#v())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Ys(this.#e,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Ys(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&&!ss(this.options,t)&&this.#n.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#e,observer:this});const o=this.hasListeners();o&&Jo(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)||yn(this.options.staleTime,this.#e)!==yn(t.staleTime,this.#e))&&this.#x();const r=this.#g();o&&(this.#e!==n||Te(this.options.enabled,this.#e)!==Te(t.enabled,this.#e)||r!==this.#l)&&this.#b(r)}getOptimisticResult(e){const t=this.#n.getQueryCache().build(this.#n,e),n=this.createResult(t,e);return oc(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(os)),t}#x(){this.#y();const e=yn(this.options.staleTime,this.#e);if(Vs||this.#t.isStale||!Bo(e))return;const n=mi(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,!(Vs||Te(this.options.enabled,this.#e)===!1||!Bo(this.#l)||this.#l===0)&&(this.#u=Kn.setInterval(()=>{(this.options.refetchIntervalInBackground||fi.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,r=this.#t,a=this.#o,i=this.#r,u=e!==n?e.state:this.#s,{state:h}=e;let m={...h},d=!1,g;if(t._optimisticResults){const M=this.hasListeners(),k=!M&&Yo(e,t),O=M&&Jo(e,n,t,o);(k||O)&&(m={...m,...pi(h.data,e.options)}),t._optimisticResults==="isRestoring"&&(m.fetchStatus="idle")}let{error:f,errorUpdatedAt:x,status:b}=m;g=m.data;let v=!1;if(t.placeholderData!==void 0&&g===void 0&&b==="pending"){let M;r?.isPlaceholderData&&t.placeholderData===i?.placeholderData?(M=r.data,v=!0):M=typeof t.placeholderData=="function"?t.placeholderData(this.#m?.state.data,this.#m):t.placeholderData,M!==void 0&&(b="success",g=qo(r?.data,M,t),d=!0)}if(t.select&&g!==void 0&&!v)if(r&&g===a?.data&&t.select===this.#p)g=this.#h;else try{this.#p=t.select,g=t.select(g),g=qo(r?.data,g,t),this.#h=g,this.#i=null}catch(M){this.#i=M}this.#i&&(f=this.#i,g=this.#h,x=Date.now(),b="error");const w=m.fetchStatus==="fetching",p=b==="pending",y=b==="error",C=p&&w,N=g!==void 0,_={status:b,fetchStatus:m.fetchStatus,isPending:p,isSuccess:b==="success",isError:y,isInitialLoading:C,isLoading:C,data:g,dataUpdatedAt:m.dataUpdatedAt,error:f,errorUpdatedAt:x,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:w,isRefetching:w&&!p,isLoadingError:y&&!N,isPaused:m.fetchStatus==="paused",isPlaceholderData:d,isRefetchError:y&&N,isStale:uo(e,t),refetch:this.refetch,promise:this.#a,isEnabled:Te(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){const M=te=>{_.status==="error"?te.reject(_.error):_.data!==void 0&&te.resolve(_.data)},k=()=>{const te=this.#a=_.promise=Fo();M(te)},O=this.#a;switch(O.status){case"pending":e.queryHash===n.queryHash&&M(O);break;case"fulfilled":(_.status==="error"||_.data!==O.value)&&k();break;case"rejected":(_.status!=="error"||_.error!==O.reason)&&k();break}}return _}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),ss(t,e))return;this.#t=t;const n=()=>{if(!e)return!0;const{notifyOnChangeProps:o}=this.options,r=typeof o=="function"?o():o;if(r==="all"||!r&&!this.#f.size)return!0;const a=new Set(r??this.#f);return this.options.throwOnError&&a.add("error"),Object.keys(this.#t).some(i=>{const c=i;return this.#t[c]!==e[c]&&a.has(c)})};this.#j({listeners:n()})}#C(){const e=this.#n.getQueryCache().build(this.#n,this.options);if(e===this.#e)return;const t=this.#e;this.#e=e,this.#s=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#v()}#j(e){ds.batch(()=>{e.listeners&&this.listeners.forEach(t=>{t(this.#t)}),this.#n.getQueryCache().notify({query:this.#e,type:"observerResultsUpdated"})})}};function sc(e,t){return Te(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function Yo(e,t){return sc(e,t)||e.state.data!==void 0&&Ys(e,t,t.refetchOnMount)}function Ys(e,t,n){if(Te(t.enabled,e)!==!1&&yn(t.staleTime,e)!=="static"){const o=typeof n=="function"?n(e):n;return o==="always"||o!==!1&&uo(e,t)}return!1}function Jo(e,t,n,o){return(e!==t||Te(o.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&uo(e,n)}function uo(e,t){return Te(t.enabled,e)!==!1&&e.isStaleByTime(yn(t.staleTime,e))}function oc(e,t){return!ss(e.getCurrentResult(),t)}var rc=class extends na{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){super.setOptions({...e,behavior:Wo()})}getOptimisticResult(e){return e.behavior=Wo(),super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"backward"}}})}createResult(e,t){const{state:n}=e,o=super.createResult(e,t),{isFetching:r,isRefetching:a,isError:i,isRefetchError:c}=o,u=n.fetchMeta?.fetchMore?.direction,h=i&&u==="forward",m=r&&u==="forward",d=i&&u==="backward",g=r&&u==="backward";return{...o,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:gi(t,n.data),hasPreviousPage:xi(t,n.data),isFetchNextPageError:h,isFetchingNextPage:m,isFetchPreviousPageError:d,isFetchingPreviousPage:g,isRefetchError:c&&!h&&!d,isRefetching:a&&!m&&!g}}},ac=class extends Ir{#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),ss(this.options,n)||this.#n.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#s,observer:this}),n?.mutationKey&&this.options.mutationKey&&Uo(n.mutationKey)!==Uo(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??bi();this.#e={...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset}}#r(t){ds.batch(()=>{if(this.#t&&this.hasListeners()){const n=this.#e.variables,o=this.#e.context,r={client:this.#n,meta:this.options.meta,mutationKey:this.options.mutationKey};if(t?.type==="success"){try{this.#t.onSuccess?.(t.data,n,o,r)}catch(a){Promise.reject(a)}try{this.#t.onSettled?.(t.data,null,n,o,r)}catch(a){Promise.reject(a)}}else if(t?.type==="error"){try{this.#t.onError?.(t.error,n,o,r)}catch(a){Promise.reject(a)}try{this.#t.onSettled?.(void 0,t.error,n,o,r)}catch(a){Promise.reject(a)}}}this.listeners.forEach(n=>{n(this.#e)})})}},sa=l.createContext(void 0),oa=e=>{const t=l.useContext(sa);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},ic=({client:e,children:t})=>(l.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),s.jsx(sa.Provider,{value:e,children:t})),ra=l.createContext(!1),lc=()=>l.useContext(ra);ra.Provider;function cc(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var uc=l.createContext(cc()),dc=()=>l.useContext(uc),hc=(e,t,n)=>{const o=n?.state.error&&typeof e.throwOnError=="function"?so(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||o)&&(t.isReset()||(e.retryOnMount=!1))},mc=e=>{l.useEffect(()=>{e.clearReset()},[e])},fc=({result:e,errorResetBoundary:t,throwOnError:n,query:o,suspense:r})=>e.isError&&!t.isReset()&&!e.isFetching&&o&&(r&&e.data===void 0||so(n,[e.error,o])),pc=e=>{if(e.suspense){const n=r=>r==="static"?r:Math.max(r??1e3,1e3),o=e.staleTime;e.staleTime=typeof o=="function"?(...r)=>n(o(...r)):n(o),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},xc=(e,t)=>e.isLoading&&e.isFetching&&!t,gc=(e,t)=>e?.suspense&&t.isPending,Xo=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function aa(e,t,n){const o=lc(),r=dc(),a=oa(),i=a.defaultQueryOptions(e);a.getDefaultOptions().queries?._experimental_beforeQuery?.(i);const c=a.getQueryCache().get(i.queryHash);i._optimisticResults=o?"isRestoring":"optimistic",pc(i),hc(i,r,c),mc(r);const u=!a.getQueryCache().get(i.queryHash),[h]=l.useState(()=>new t(a,i)),m=h.getOptimisticResult(i),d=!o&&e.subscribed!==!1;if(l.useSyncExternalStore(l.useCallback(g=>{const f=d?h.subscribe(ds.batchCalls(g)):os;return h.updateResult(),f},[h,d]),()=>h.getCurrentResult(),()=>h.getCurrentResult()),l.useEffect(()=>{h.setOptions(i)},[i,h]),gc(i,m))throw Xo(i,h,r);if(fc({result:m,errorResetBoundary:r,throwOnError:i.throwOnError,query:c,suspense:i.suspense}))throw m.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(i,m),i.experimental_prefetchInRender&&!Vs&&xc(m,o)&&(u?Xo(i,h,r):c?.promise)?.catch(os).finally(()=>{h.updateResult()}),i.notifyOnChangeProps?m:h.trackResult(m)}function ye(e,t){return aa(e,na)}function ne(e,t){const n=oa(),[o]=l.useState(()=>new ac(n,e));l.useEffect(()=>{o.setOptions(e)},[o,e]);const r=l.useSyncExternalStore(l.useCallback(i=>o.subscribe(ds.batchCalls(i)),[o]),()=>o.getCurrentResult(),()=>o.getCurrentResult()),a=l.useCallback((i,c)=>{o.mutate(i,c).catch(os)},[o]);if(r.error&&so(o.options.throwOnError,[r.error]))throw r.error;return{...r,mutate:a,mutateAsync:r.mutate}}function ia(e,t){return aa(e,rc)}const ut="data-sources",la="auth-user",bc=e=>ye({queryKey:["project","datasources",e],queryFn:async()=>{const{data:t}=await B.get(`/project/team/${e}/datasources`);return t.data},enabled:!!e}),en=e=>{const t=["project","datasources"],n=["project","saved-queries"];return Promise.all([J.invalidateQueries({queryKey:t}),J.invalidateQueries({queryKey:n})])},vc=e=>{const t=["trash","team"];return J.invalidateQueries({queryKey:t})},yc=(e,t)=>ye({queryKey:["project","tables",t.teamId,e,t.selectedDataSources],queryFn:async()=>{const{data:n}=await B.get(`/project/team/${t.teamId}/query`,{params:{size:30,search:e,selectedDataSources:t.selectedDataSources}});return n.data},enabled:!!t.teamId,placeholderData:Mr}),ps=()=>J.invalidateQueries({queryKey:["project","tables"]}),wc=(e,t="",n=30,o)=>ia({queryKey:["project","tabs-history",e,n,o,t],queryFn:async({pageParam:r})=>{const a=new URLSearchParams;a.set("nameFilter",t),a.set("size",n.toString()),a.set("page",r.toString());const{data:i}=await B.get(`/project/team/${e}/tabs-history?${a.toString()}`);return i},select:({pages:r})=>r.flatMap(a=>a.data),enabled:!!e,initialPageParam:0,getNextPageParam:(r,a)=>{if(r.hasMore)return a.length},staleTime:0}),Cc=(e,t="",n=20)=>ia({queryKey:["project","saved-queries",e,t,n],queryFn:async({pageParam:o})=>{const r=new URLSearchParams;r.set("nameFilter",t),r.set("size",n.toString()),r.set("page",o.toString());const{data:a}=await B.get(`/project/team/${e}/queries?${r.toString()}`);return a},enabled:!!e,initialPageParam:0,select:({pages:o})=>o.flatMap(r=>r.data),getNextPageParam:(o,r)=>{if(o.hasMore)return r.length}}),jc=(e,t=10,n=!1)=>ye({queryKey:["project","recent-tabs",e,t,n],queryFn:async()=>{const{data:o}=await B.get(`/project/team/${e}/tabs-history?page=0&size=${t}&archived=${n}`);return o.data},enabled:!!e,staleTime:0}),Nc=e=>ne({mutationFn:async()=>{const{data:t}=await B.get(`/project/team/${e}/tabs-history?page=0&size=1&archived=false`);return t.data?.length?t.data[0]:void 0}}),_c=()=>Promise.all([J.invalidateQueries({queryKey:["project","tabs-history"]}),J.invalidateQueries({queryKey:["project","recent-tabs"]})]),Sc=4e3,xs=e=>ye({queryKey:[ut,e],queryFn:async()=>{const{data:t}=await B.get("/data-sources/"+e);return t.data},enabled:!!e,refetchInterval:t=>t.state?.data?.status==="INSPECTING"?Sc:!1}),ho=e=>ye({queryKey:[ut,e.teamId],queryFn:async()=>{const{data:t}=await B.get("/data-sources",{params:e});return t.data},enabled:e.teamId!==void 0}),gs=e=>ye({queryKey:[ut,e,"inspections"],queryFn:async()=>{const{data:t}=await B.get(`/data-sources/${e}/inspections`);return t.data},enabled:!!e}),kc=e=>J.invalidateQueries({queryKey:[ut,e,"inspections"]}),Ec=()=>ne({mutationFn:async e=>{const{data:t}=await B.post("/data-sources",e);return t.data},onSuccess:()=>{J.invalidateQueries({queryKey:[ut]}),en(),ps()}}),Rc=()=>ne({mutationFn:async({dataSource:e,id:t})=>{const{data:n}=await B.put(`/data-sources/${t}`,e);return n.data},onSuccess:()=>{J.invalidateQueries({queryKey:[ut]}),en(),ps()}}),ca=()=>ne({mutationFn:async e=>{await B.post(`/data-sources/${e}/inspect`)},onSuccess:(e,t)=>{J.invalidateQueries({queryKey:[ut,t]}),ps()}}),Lc=()=>ne({mutationFn:async e=>{await B.delete(`/data-sources/${e}`)},onSuccess:()=>{J.invalidateQueries({queryKey:[ut]}),en(),ps()}}),ua=()=>ye({queryKey:["accessToken"],queryFn:hs.get}),we=()=>{const{data:e}=ua();return ye({queryKey:[la],queryFn:async()=>{const{data:t}=await B.get("/users");return t.data},enabled:!!e,retry:(t,n)=>vi(n)&&n.code==="ERR_NETWORK"?!1:t<3})},Tc=()=>ne({mutationFn:async e=>{const{data:t}=await B.patch("/users",e);return t.data},onSuccess:async e=>{J.setQueryData([la],e)}}),Ac=()=>ne({mutationFn:async e=>(await B.post("/users",e),!0),onSuccess:()=>{J.invalidateQueries({queryKey:["team-users"]})}}),Ce=e=>{const t=new Set;let n=e;const o=c=>(t.add(c),()=>t.delete(c)),r=c=>(t.forEach(u=>u(c)),!0),a=c=>{n=typeof c=="function"?c(n):c,r(n)},i=c=>()=>c?c(n):n;return[c=>l.useSyncExternalStore(o,i(c),i(c)),a,{get:()=>n,subscribe:c=>(c(n),o(c))}]};function Ic(e,t,n,o){return l.useMemo(()=>({name:n,tabId:o,hooks:e?.result.availableHooks||[],availableJoins:e?.result?.availableJoins||[],allColumns:e?.result.allColumns||[],dataSourceId:t,entities:e?.result.availableEntities||[],getValue:(r,a,i)=>{const c=e?.result.columns?.findIndex(u=>u.table===a&&u.column===i);if(c!=null&&c>-1)return e?.result?.rows[r][c]},getColumnByIndex:r=>e?.result?.columns?.[r],getValueByIndex:(r,a)=>e?.result?.rows[r]?.[a],getColumnType:r=>{const a=e?.result.allColumns.find(i=>i.full===r);if(a)return a.type}}),[e,t,n,o])}function Mc(e,t){return l.useMemo(()=>({state:e,setState:t}),[e,t])}function kt(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 Pc(e,t){return{name:e,path:t,build:r=>{if(typeof r=="object"){let a=t;for(const[i,c]of Object.entries(r))a=a.replace(":"+i,c);return a}return t},check:r=>!!Gt({path:t,end:!0},r)}}function bs(e,t){return{name:e,path:t,build:()=>t,check:n=>n===t}}const Oc=bs("Home","/"),Dc=bs("Workbench","/workbench"),$c=bs("Share query","/share"),Fc=bs("Login","/login"),Bc=Pc("Workbench tab","/workbench/tab/:id"),D={home:Oc,workbench:Dc,share:$c,login:Fc,workbenchTab:Bc},vs=e=>{J.setQueryData(["workbench-tabs"],t=>e(t||[]))},qc=(e,t)=>{J.setQueryData(["workbench-tabs",e],n=>n&&t(n))},ys=()=>ye({queryKey:["workbench-tabs"],queryFn:async()=>{const{data:e}=await B.get("/workbench-tabs");return e.data}}),Wc=e=>ye({queryKey:["workbench-tabs",e],queryFn:async()=>{const{data:t}=await B.get(`/workbench-tabs/${e}`);return t.data}}),Lt=()=>ne({mutationFn:async e=>{const{data:t}=await B.post("/workbench-tabs",e);return t.data},onSuccess:async e=>{vs(t=>[...t,{id:e.id,name:e.name,orderIndex:e.orderIndex}])}}),Uc=()=>ne({mutationFn:async({tabId:e,...t})=>(await B.patch(`/workbench-tabs/${e}/archive`,t)).data.data,onSuccess:async e=>{vs(()=>e)}}),da=()=>ne({mutationFn:async e=>(await B.patch(`/workbench-tabs/${e}/restore`),e),onSuccess:()=>fa()}),ha=()=>ne({mutationFn:async({id:e,payload:t})=>(await B.patch(`/workbench-tabs/${e}`,t),!0),onMutate:({id:e,payload:t})=>{qc(e,n=>({...n,...t})),vs(n=>n.map(o=>o.id!==e?o:{...o,name:t.name||o.name}))}}),zc=(e,t)=>{const{dataSourceId:n,searchAll:o,table:r,filters:a,joins:i,orderBy:c,groupBy:u,columns:h,aggregations:m,page:d=0,size:g=20}=t;return ye({queryKey:["workbench-tab-runner",e,n,r,d,g,a,m,i,c,u,h,o],queryFn:async()=>{const{data:f}=await B.post(`/workbench-tabs/${e}/run`,t);return f.data},retry:1,enabled:!!r&&!!n,placeholderData:Mr})},Hc=()=>ne({mutationFn:async e=>{await B.delete(`/workbench-tabs/${e}`)},onSuccess:()=>{fa(),_c()}}),ma=e=>J.invalidateQueries({queryKey:["workbench-tab-runner",e]}),fa=()=>J.invalidateQueries({queryKey:["workbench-tabs"]}),[Vc,Os,Kc]=Ce(void 0),Qc=async()=>new Promise(e=>{Os({onCancel:()=>{Os(void 0),e(void 0)},onConfirm:(t,n,o)=>{Os(void 0),e({dsId:o,id:n,type:t})}})}),Tn=()=>{const e=ee(),t=Lt(),n=da();return l.useCallback(()=>{Kc.get()||Qc().then(r=>{r?.type==="table"?t.mutateAsync({name:r.id,opts:kt({table:r.id,dataSourceId:r.dsId})}).then(a=>{e(D.workbenchTab.build({id:a.id}))}):r?.type==="query"?t.mutateAsync({queryId:r.id}).then(a=>{e(D.workbenchTab.build({id:a.id}))}):r?.type==="tab"&&(n.mutate(r.id),e(D.workbenchTab.build({id:r.id})))})},[])},pa=[{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"}],Gc=pa.reduce((e,t)=>(e[t.value]=t.label,e),{});pa.reduce((e,t)=>(e[t.label]=t.value,e),{});const tn=e=>e.map(t=>({label:Gc[t],value:t}));tn(["=","<>",">",">=","<","<=","IN","NOT IN","IS NULL","IS NOT NULL"]);tn(["=","<>","LIKE","NOT LIKE","IN","NOT IN","IS NULL","IS NOT NULL","CONTAINS","NOT CONTAINS"]);tn(["=","<>","IS NULL","IS NOT NULL"]);tn(["=","<>",">",">=","<","<=","IS NULL","IS NOT NULL"]);tn(["IS NULL","IS NOT NULL"]);tn(["IN","NOT IN"]);const Yc=["char","varchar","binary","varbinary","blob","text","enum","set","character","character varying","text","citext","uuid","xml","json","jsonb"];new Set(Yc);const Jc=["integer","smallint","decimal","numeric","float","real","double precision","int","smallint","integer","bigint","decimal","numeric","real","double precision","serial","bigserial","money"];new Set(Jc);const Xc=["date","datetime","timestamp","timestamptz"].reduce((e,t)=>(e[t]=!0,e),{}),Zc=e=>e.fn?e.distinct===!0?`${e.fn} distinct ${e.value}`:`${e.fn} ${e.value}`:e.value;var me=(e=>(e.OWNER="owner",e.ADMIN="admin",e.EDITOR="editor",e.READ_ONLY="read_only",e))(me||{});const Zo={[me.READ_ONLY]:10,[me.EDITOR]:20,[me.ADMIN]:30,[me.OWNER]:40},eu=e=>`${e.fromTable}.${e.fromColumn} = ${e.toTable}.${e.toColumn}`,An=e=>{const{data:t}=we();return l.useMemo(()=>t?Zo[t.teamRole]>=Zo[e]:!1,[t,e])},tu="_input_n98qv_2",nu="_label_n98qv_2",su="_content_n98qv_2",ou="_form_n98qv_2",ru="_header_n98qv_2",au="_mode-select_n98qv_2",iu="_selected_n98qv_2",lu="_mode-container_n98qv_2",Fe={input:tu,label:nu,content:su,form:ou,header:ru,modeSelect:au,selected:iu,modeContainer:lu},cu="_modal_112c0_2",uu="_modal-visible_112c0_2",du="_modal-invisible_112c0_2",hu="_backdrop_112c0_2",mu="_modal-container_112c0_2",fu="_close-button_112c0_2",Kt={modal:cu,modalVisible:uu,modalInvisible:du,backdrop:hu,modalContainer:mu,closeButton:fu},Ze=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 pu=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 ws=e=>{const t=l.useRef(e.onClose);t.current=e.onClose,l.useEffect(()=>{if(e.enabled)return pu(()=>{t.current()})},[e.enabled])},Me=({children:e,backdropClose:t,isVisible:n,onClose:o,onClosed:r,noPadding:a=!1,portal:i=!1})=>{const[c,u]=l.useState(!1),h=()=>{t&&o()},m=g=>{n||getComputedStyle(g.currentTarget).opacity==="0"&&(u(!1),r&&r())};l.useEffect(()=>{n&&u(!0)},[n]),ws({onClose:h,enabled:n&&t===!0});const d=s.jsxs("div",{onTransitionEnd:m,className:A(Kt.modal,n?Kt.modalVisible:Kt.modalInvisible),children:[s.jsx("div",{onClick:h,className:Kt.backdrop}),s.jsx("div",{className:A(Kt.modalContainer,a!==!0&&"p-4"),children:c&&e})]});return i?co.createPortal(d,document.body):d},nn=({onClick:e})=>{const t=l.useRef(e);return t.current=e,s.jsx("button",{className:Kt.closeButton,onClick:e,children:s.jsx(Ze,{width:20,height:20})})},xa=({children:e})=>s.jsx("h2",{className:"text-xl font-semibold",children:e}),xu=({form:e,change:t,shape:n})=>s.jsx("div",{className:Fe.form,children:n.fields.map(o=>s.jsxs("label",{className:Fe.input,children:[s.jsx("p",{className:Fe.label,children:o.label}),s.jsx("input",{value:e[o.name],onChange:t(o.name),type:o.type})]},o.name))}),gu=e=>l.createElement("svg",{fill:"#000000",width:"800px",height:"800px",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",...e},l.createElement("path",{d:"m24.129 23.412-.508-.484c-.251-.331-.518-.624-.809-.891l-.005-.004q-.448-.407-.931-.774-.387-.266-1.064-.641c-.371-.167-.661-.46-.818-.824l-.004-.01-.048-.024c.212-.021.406-.06.592-.115l-.023.006.57-.157c.236-.074.509-.122.792-.133h.006c.298-.012.579-.06.847-.139l-.025.006q.194-.048.399-.109t.351-.109v-.169q-.145-.217-.351-.496c-.131-.178-.278-.333-.443-.468l-.005-.004q-.629-.556-1.303-1.076c-.396-.309-.845-.624-1.311-.916l-.068-.04c-.246-.162-.528-.312-.825-.435l-.034-.012q-.448-.182-.883-.399c-.097-.048-.21-.09-.327-.119l-.011-.002c-.117-.024-.217-.084-.29-.169l-.001-.001c-.138-.182-.259-.389-.355-.609l-.008-.02q-.145-.339-.314-.651-.363-.702-.702-1.427t-.651-1.452q-.217-.484-.399-.967c-.134-.354-.285-.657-.461-.942l.013.023c-.432-.736-.863-1.364-1.331-1.961l.028.038c-.463-.584-.943-1.106-1.459-1.59l-.008-.007c-.509-.478-1.057-.934-1.632-1.356l-.049-.035q-.896-.651-1.96-1.282c-.285-.168-.616-.305-.965-.393l-.026-.006-1.113-.278-.629-.048q-.314-.024-.629-.024c-.148-.078-.275-.171-.387-.279-.11-.105-.229-.204-.353-.295l-.01-.007c-.605-.353-1.308-.676-2.043-.93l-.085-.026c-.193-.113-.425-.179-.672-.179-.176 0-.345.034-.499.095l.009-.003c-.38.151-.67.458-.795.84l-.003.01c-.073.172-.115.371-.115.581 0 .368.13.705.347.968l-.002-.003q.544.725.834 1.14.217.291.448.605c.141.188.266.403.367.63l.008.021c.056.119.105.261.141.407l.003.016q.048.206.121.448.217.556.411 1.14c.141.425.297.785.478 1.128l-.019-.04q.145.266.291.52t.314.496c.065.098.147.179.241.242l.003.002c.099.072.164.185.169.313v.001c-.114.168-.191.369-.217.586l-.001.006c-.035.253-.085.478-.153.695l.008-.03c-.223.666-.351 1.434-.351 2.231 0 .258.013.512.04.763l-.003-.031c.06.958.349 1.838.812 2.6l-.014-.025c.197.295.408.552.641.787.168.188.412.306.684.306.152 0 .296-.037.422-.103l-.005.002c.35-.126.599-.446.617-.827v-.002c.048-.474.12-.898.219-1.312l-.013.067c.024-.063.038-.135.038-.211 0-.015-.001-.03-.002-.045v.002q-.012-.109.133-.206v.048q.145.339.302.677t.326.677c.295.449.608.841.952 1.202l-.003-.003c.345.372.721.706 1.127 1.001l.022.015c.212.162.398.337.566.528l.004.004c.158.186.347.339.56.454l.01.005v-.024h.048c-.039-.087-.102-.157-.18-.205l-.002-.001c-.079-.044-.147-.088-.211-.136l.005.003q-.217-.217-.448-.484t-.423-.508q-.508-.702-.969-1.467t-.871-1.555q-.194-.387-.375-.798t-.351-.798c-.049-.099-.083-.213-.096-.334v-.005c-.006-.115-.072-.214-.168-.265l-.002-.001c-.121.206-.255.384-.408.545l.001-.001c-.159.167-.289.364-.382.58l-.005.013c-.141.342-.244.739-.289 1.154l-.002.019q-.072.641-.145 1.318l-.048.024-.024.024c-.26-.053-.474-.219-.59-.443l-.002-.005q-.182-.351-.326-.69c-.248-.637-.402-1.374-.423-2.144v-.009c-.009-.122-.013-.265-.013-.408 0-.666.105-1.308.299-1.91l-.012.044q.072-.266.314-.896t.097-.871c-.05-.165-.143-.304-.265-.41l-.001-.001c-.122-.106-.233-.217-.335-.335l-.003-.004q-.169-.244-.326-.52t-.278-.544c-.165-.382-.334-.861-.474-1.353l-.022-.089c-.159-.565-.336-1.043-.546-1.503l.026.064c-.111-.252-.24-.47-.39-.669l.006.008q-.244-.326-.436-.617-.244-.314-.484-.605c-.163-.197-.308-.419-.426-.657l-.009-.02c-.048-.097-.09-.21-.119-.327l-.002-.011c-.011-.035-.017-.076-.017-.117 0-.082.024-.159.066-.223l-.001.002c.011-.056.037-.105.073-.145.039-.035.089-.061.143-.072h.002c.085-.055.188-.088.3-.088.084 0 .165.019.236.053l-.003-.001c.219.062.396.124.569.195l-.036-.013q.459.194.847.375c.298.142.552.292.792.459l-.018-.012q.194.121.387.266t.411.291h.339q.387 0 .822.037c.293.023.564.078.822.164l-.024-.007c.481.143.894.312 1.286.515l-.041-.019q.593.302 1.125.641c.589.367 1.098.743 1.577 1.154l-.017-.014c.5.428.954.867 1.38 1.331l.01.012c.416.454.813.947 1.176 1.464l.031.047c.334.472.671 1.018.974 1.584l.042.085c.081.154.163.343.234.536l.011.033q.097.278.217.57.266.605.57 1.221t.57 1.198l.532 1.161c.187.406.396.756.639 1.079l-.011-.015c.203.217.474.369.778.422l.008.001c.368.092.678.196.978.319l-.047-.017c.143.065.327.134.516.195l.04.011c.212.065.396.151.565.259l-.009-.005c.327.183.604.363.868.559l-.021-.015q.411.302.822.57.194.145.651.423t.484.52c-.114-.004-.249-.007-.384-.007-.492 0-.976.032-1.45.094l.056-.006c-.536.072-1.022.203-1.479.39l.04-.014c-.113.049-.248.094-.388.129l-.019.004c-.142.021-.252.135-.266.277v.001c.061.076.11.164.143.26l.002.006c.034.102.075.19.125.272l-.003-.006c.119.211.247.393.391.561l-.004-.005c.141.174.3.325.476.454l.007.005q.244.194.508.399c.161.126.343.25.532.362l.024.013c.284.174.614.34.958.479l.046.016c.374.15.695.324.993.531l-.016-.011q.291.169.58.375t.556.399c.073.072.137.152.191.239l.003.005c.091.104.217.175.36.193h.003v-.048c-.088-.067-.153-.16-.184-.267l-.001-.004c-.025-.102-.062-.191-.112-.273l.002.004zm-18.576-19.205q-.194 0-.363.012c-.115.008-.222.029-.323.063l.009-.003v.024h.048q.097.145.244.326t.266.351l.387.798.048-.024c.113-.082.2-.192.252-.321l.002-.005c.052-.139.082-.301.082-.469 0-.018 0-.036-.001-.054v.003c-.045-.044-.082-.096-.108-.154l-.001-.003-.081-.182c-.053-.084-.127-.15-.214-.192l-.003-.001c-.094-.045-.174-.102-.244-.169z"})),bu=e=>l.createElement("svg",{width:"800px",height:"800px",viewBox:"0 0 32 32",xmlns:"http://www.w3.org/2000/svg",...e},l.createElement("title",null,"file_type_pgsql"),l.createElement("path",{d:"M29.507,18.773a1.378,1.378,0,0,0-1.144-.921,2.619,2.619,0,0,0-.913.051,8.2,8.2,0,0,1-1.406.185,27.125,27.125,0,0,0,2.872-6.83c.953-3.689.444-5.369-.151-6.13A8.239,8.239,0,0,0,22.121,2a11.773,11.773,0,0,0-3.453.484A12.858,12.858,0,0,0,16.648,2.3a6.565,6.565,0,0,0-3.518.867,16.039,16.039,0,0,0-2.484-.624,7.694,7.694,0,0,0-5.819.924C3.093,4.691,2.289,6.819,2.438,9.792A36.351,36.351,0,0,0,3.844,16.33a22.579,22.579,0,0,0,1.514,3.863A4.786,4.786,0,0,0,7.8,22.742a2.4,2.4,0,0,0,2.379-.516,2.08,2.08,0,0,0,.5.43,3.328,3.328,0,0,0,.944.4,5.069,5.069,0,0,0,3.3-.2c.006.171.011.335.014.477.006.229.013.454.021.665a11.641,11.641,0,0,0,.441,3.3c.016.043.037.107.059.176a3.975,3.975,0,0,0,.991,1.745,2.955,2.955,0,0,0,2.09.777,4.7,4.7,0,0,0,.977-.109A4.592,4.592,0,0,0,22.607,28.1c.811-1.155,1.206-2.894,1.277-5.635.009-.078.018-.152.026-.222l.017-.145.191.017.049,0a7.562,7.562,0,0,0,3.163-.548c.631-.293,2.654-1.361,2.177-2.8"}),l.createElement("path",{d:"M27.689,19.053c-3.163.652-3.38-.418-3.38-.418C27.648,13.68,29.044,7.39,27.839,5.851c-3.286-4.2-8.975-2.213-9.07-2.162l-.031.006a11.28,11.28,0,0,0-2.11-.22,5.212,5.212,0,0,0-3.34,1S3.14.294,3.612,9.733c.1,2.008,2.878,15.194,6.191,11.211,1.211-1.456,2.381-2.688,2.381-2.688a3.071,3.071,0,0,0,2.006.512l.057-.048a2.21,2.21,0,0,0,.023.567c-.854.954-.6,1.121-2.309,1.472-1.726.356-.712.989-.05,1.155a3.508,3.508,0,0,0,3.915-1.272l-.05.2c.334.268.569,1.742.53,3.079a8.481,8.481,0,0,0,.2,2.971c.264.717.526,2.329,2.769,1.849a3.307,3.307,0,0,0,2.98-3.179c.1-1.234.313-1.052.326-2.155l.174-.522c.2-1.673.032-2.213,1.186-1.962l.281.025a6.4,6.4,0,0,0,2.615-.44c1.406-.652,2.239-1.742.853-1.455h0",style:{fill:"#336791"}}),l.createElement("path",{d:"M13.882,10.631a.981.981,0,0,0-.674.1.247.247,0,0,0-.1.164.48.48,0,0,0,.117.314.881.881,0,0,0,.559.349.637.637,0,0,0,.09.006.725.725,0,0,0,.687-.467c.035-.248-.326-.414-.676-.463m9.442.008c-.027-.195-.374-.25-.7-.2s-.647.194-.62.389a.667.667,0,0,0,.62.411.592.592,0,0,0,.083-.006.8.8,0,0,0,.451-.247.5.5,0,0,0,.169-.343",style:{fill:"#fff"}}),l.createElement("path",{d:"M28.741,18.979c-.121-.365-.509-.482-1.154-.349-1.915.4-2.6.121-2.826-.044a26.327,26.327,0,0,0,3.373-7.565,14.374,14.374,0,0,0,.5-3.253,3.513,3.513,0,0,0-.509-2.2,7.482,7.482,0,0,0-6.049-2.825,10.363,10.363,0,0,0-3.5.551,8.717,8.717,0,0,0-1.968-.253,5.684,5.684,0,0,0-3.372.929,15.051,15.051,0,0,0-2.74-.718,6.978,6.978,0,0,0-5.242.805c-1.5,1.064-2.2,2.966-2.061,5.653a35.489,35.489,0,0,0,1.373,6.348c1.07,3.505,2.233,5.49,3.457,5.9a1.548,1.548,0,0,0,.491.081,2.049,2.049,0,0,0,1.563-.886q1.042-1.25,2.155-2.438a3.472,3.472,0,0,0,1.55.417l0,.042q-.14.166-.273.338c-.375.475-.452.574-1.658.823-.343.071-1.254.259-1.267.9-.014.7,1.077.991,1.2,1.022a5.144,5.144,0,0,0,1.249.162,3.634,3.634,0,0,0,2.5-.934,23.674,23.674,0,0,0,.381,5.684,2.854,2.854,0,0,0,2.729,2.1,4.378,4.378,0,0,0,.917-.1,3.462,3.462,0,0,0,3.156-3.212c.177-1.026.481-3.475.624-4.789a3.859,3.859,0,0,0,1.11.137,6.6,6.6,0,0,0,2.519-.48c.712-.331,2-1.141,1.763-1.846ZM24.051,10.1a7.968,7.968,0,0,1-.116,1.107,10.229,10.229,0,0,0-.14,1.3,9.859,9.859,0,0,0,.1,1.47,5.236,5.236,0,0,1-.229,2.986,3.882,3.882,0,0,1-.207-.426c-.058-.141-.185-.368-.359-.681-.68-1.22-2.274-4.078-1.458-5.244.243-.347.86-.7,2.408-.512ZM22.174,3.531a6.617,6.617,0,0,1,5.334,2.522c.975,1.245-.1,6.912-3.205,11.8l-.094-.119-.039-.049a5.524,5.524,0,0,0,.506-3.8,9.114,9.114,0,0,1-.1-1.352,9.572,9.572,0,0,1,.131-1.206,7.614,7.614,0,0,0,.123-1.493.619.619,0,0,0,.013-.21,8.381,8.381,0,0,0-1.912-3.6,8.61,8.61,0,0,0-3.039-2.284,10.246,10.246,0,0,1,2.28-.214ZM9.479,20.654c-.627.754-1.061.61-1.2.562-.928-.31-2.006-2.272-2.955-5.384a35.167,35.167,0,0,1-1.34-6.159c-.12-2.4.462-4.074,1.73-4.974,2.063-1.463,5.456-.587,6.819-.143-.02.019-.04.037-.059.057-2.237,2.259-2.184,6.119-2.178,6.355,0,.091.007.22.018.4a15.969,15.969,0,0,1-.081,3.226A4.08,4.08,0,0,0,11.3,18.007q.133.138.278.262c-.383.41-1.216,1.318-2.1,2.385Zm2.39-3.19a3.3,3.3,0,0,1-.865-2.764,16.7,16.7,0,0,0,.087-3.381c-.006-.095-.011-.178-.014-.243A4.3,4.3,0,0,1,14,10.223a1.188,1.188,0,0,1,.918,1.026c.646,2.989.085,4.234-.365,5.235-.093.206-.181.4-.255.6l-.058.156a10.218,10.218,0,0,0-.368,1.109,2.788,2.788,0,0,1-2-.887Zm.113,4.03a1.733,1.733,0,0,1-.523-.225,2.553,2.553,0,0,1,.557-.166c1.418-.292,1.637-.5,2.116-1.105.11-.139.234-.3.406-.489h0c.256-.287.374-.238.586-.15a.829.829,0,0,1,.408.525.585.585,0,0,1-.05.491A3.1,3.1,0,0,1,11.983,21.495ZM19.406,28.4a2.113,2.113,0,0,1-2.754-1.526,31.129,31.129,0,0,1-.3-6.853.392.392,0,0,0-.017-.124,1.643,1.643,0,0,0-.048-.23,1.589,1.589,0,0,0-.862-1.034,1.216,1.216,0,0,0-.793-.1,9.586,9.586,0,0,1,.342-1.022l.058-.157c.066-.177.148-.36.235-.554.471-1.047,1.117-2.482.416-5.722a2.044,2.044,0,0,0-2.468-1.669A5.694,5.694,0,0,0,11.328,10c-.078.04-.15.078-.216.115A8.244,8.244,0,0,1,13.03,5.163,4.711,4.711,0,0,1,16.6,3.827,7.567,7.567,0,0,1,22.381,6.59,8.774,8.774,0,0,1,23.963,9.3c-1.463-.149-2.458.14-2.962.861-1.1,1.568.6,4.612,1.416,6.075.15.268.279.5.319.6a5.432,5.432,0,0,0,.861,1.387c.077.1.152.189.208.271-.443.128-1.239.423-1.166,1.9-.058.74-.474,4.205-.686,5.43-.279,1.617-.874,2.22-2.548,2.579Zm7.242-8.288a5.714,5.714,0,0,1-1.931.4,2.422,2.422,0,0,1-1.3-.167c-.045-.919.3-1.015.66-1.117.057-.016.112-.032.166-.05a1.353,1.353,0,0,0,.11.08c.639.422,1.78.467,3.39.135l.018,0a4.334,4.334,0,0,1-1.116.72Z",style:{fill:"#fff"}})),He=({size:e,type:t})=>t==="mysql"?s.jsx(gu,{width:e,height:e}):s.jsx(bu,{width:e,height:e}),vu={mysql:"MySQL",postgres:"PostgreSQL"},yu={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"}]},wu={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"}]},Cu=({show:e,onClose:t,dbType:n="postgres"})=>{const o=Ec(),r=ca(),{data:a}=we(),[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 f=await o.mutateAsync({...i,dbPort:Number(i.dbPort),teamId:a.teamId,ownerId:a.id});await r.mutateAsync(f.id),t()},m=f=>{u("allowInsert",!f),u("allowUpdate",!f)},d=o.isPending||r.isPending,g=!i.allowInsert&&!i.allowUpdate;return s.jsxs(Me,{isVisible:e,onClose:t,portal:!0,children:[s.jsxs("div",{className:"max-w-xl mx-auto overflow-y-auto",children:[s.jsxs("div",{className:Fe.header,children:[s.jsx(He,{size:24,type:n}),s.jsx("p",{className:"text-(--text-color-primary) font-semibold",children:vu[n]})]}),o.isError&&s.jsx(ge,{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(ge,{className:"mb-2",variant:"info",children:"Creating connection"}),r.isPending&&s.jsx(ge,{className:"mb-2",variant:"info",children:"Inspecting connection"}),s.jsxs("div",{className:"mt-2",children:[s.jsxs("div",{className:Fe.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(xu,{form:i,change:c,shape:i.dbType==="mysql"?yu:wu})]}),s.jsx("p",{className:"text-sm font-semibold mt-4",children:"Connection mode"}),s.jsxs("div",{className:Fe.modeContainer,children:[s.jsxs("label",{onClick:()=>m(!0),className:A(Fe.modeSelect,g&&Fe.selected),children:[s.jsxs("span",{className:"text-sm font-semibold text-(--text-color-primary)",children:[s.jsx("input",{type:"radio",disabled:d,checked:g,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:A(Fe.modeSelect,!g&&Fe.selected),children:[s.jsxs("span",{className:"text-sm font-semibold text-(--text-color-primary)",children:[s.jsx("input",{type:"radio",disabled:d,checked:!g,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"})]})]})},ju="_data-source-entry_vcqrj_2",Nu="_action-title_vcqrj_2",_u="_recent-tabs-container_vcqrj_2",Su="_recent-tabs-entry_vcqrj_2",ku="_home-action-button_vcqrj_2",Eu="_home-gray-card_vcqrj_2",Ru="_home-card-title_vcqrj_2",Lu="_home-card-grid-content_vcqrj_2",Tu="_useful-links_vcqrj_2",Y={dataSourceEntry:ju,actionTitle:Nu,recentTabsContainer:_u,recentTabsEntry:Su,homeActionButton:ku,homeGrayCard:Eu,homeCardTitle:Ru,homeCardGridContent:Lu,usefulLinks:Tu},[Au,In]=Ce({show:!1}),[Iu,Cn]=Ce({show:!1}),[Mu,jn]=Ce(void 0),Pu=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"})),Ou=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"})),Du=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{d:"M416 221.25V416a48 48 0 01-48 48H144a48 48 0 01-48-48V96a48 48 0 0148-48h98.75a32 32 0 0122.62 9.37l141.26 141.26a32 32 0 019.37 22.62z",fill:"none",stroke:"currentColor",strokeLinejoin:"round",strokeWidth:32}),l.createElement("path",{d:"M256 56v120a32 32 0 0032 32h120M176 288h160M176 368h160",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32})),$u=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{d:"M336 208v-95a80 80 0 00-160 0v95",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32}),l.createElement("rect",{x:96,y:208,width:320,height:272,rx:48,ry:48,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32})),Mn=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"})),ga=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"})),ba=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})),er=20,mo="text-(--text-color-primary)",Fu=()=>{const e=Tn();return s.jsxs("div",{className:Y.homeActionButton,onClick:e,children:[s.jsx(Mn,{width:er,height:er,className:mo}),s.jsx("h2",{className:Y.actionTitle,children:"Start new query"})]})},Bu=()=>s.jsxs("div",{className:Y.homeActionButton,onClick:()=>In({show:!0}),children:[s.jsx(ga,{width:20,height:20,className:mo}),s.jsx("h2",{className:Y.actionTitle,children:"Saved queries"})]}),qu={mysql:"MySQL",postgres:"PostgreSQL"},tr=({dbType:e})=>{const[t,n]=l.useState(void 0),o=An(me.EDITOR),r=a=>{o?n(a):fe.error("You don't have permission to connect new data sources in this team")};return s.jsxs("div",{children:[t&&s.jsx(Cu,{show:!0,dbType:t,onClose:()=>n(void 0)}),s.jsxs("div",{className:Y.homeActionButton,onClick:()=>r(e),children:[s.jsx(He,{size:24,type:e}),s.jsx("p",{className:Y.actionTitle,children:qu[e]})]})]})},Wu=()=>s.jsxs("div",{className:Y.homeGrayCard,children:[s.jsx("h2",{className:Y.homeCardTitle,children:"Connect new data source"}),s.jsxs("div",{className:Y.homeCardGridContent,children:[s.jsx(tr,{dbType:"mysql"}),s.jsx(tr,{dbType:"postgres"})]})]}),Uu=()=>{const e=ee(),{data:t}=ys(),n=Tn(),o=()=>{t&&t.length>0?e(D.workbenchTab.build({id:t[0].id})):n()};return s.jsxs("div",{className:Y.homeActionButton,onClick:o,children:[s.jsx(ba,{width:20,height:20,className:mo}),s.jsx("h2",{className:Y.actionTitle,children:"Workbench"})]})},zu=()=>{const{data:e}=we(),{data:t}=ho({teamId:e?.teamId});return!t||t.length===0?null:s.jsxs("div",{className:Y.homeGrayCard,children:[s.jsx("h2",{className:Y.homeCardTitle,children:"Data sources"}),s.jsx("div",{className:Y.homeCardGridContent,children:t?.map(n=>s.jsxs("div",{className:Y.dataSourceEntry,onClick:()=>jn(n.id),tabIndex:0,children:[!n.allowInsert&&s.jsx($u,{"data-tooltip-id":"default","data-tooltip-content":"This datasource is read-only",width:18,height:18,className:"absolute top-2 right-2"}),s.jsx(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))})]})},zt=24,va=()=>s.jsxs("div",{className:Y.usefulLinks,children:[s.jsxs("a",{href:"https://dataramen.xyz/",target:"_blank",children:[s.jsx(Du,{width:zt,height:zt}),s.jsx("span",{children:"Docs"})]}),s.jsxs("a",{href:"https://github.com/OleksandrDemian/dataramen",target:"_blank",children:[s.jsx(Pu,{width:zt,height:zt}),s.jsx("span",{children:"GitHub"})]}),s.jsxs("a",{href:"https://www.npmjs.com/package/@dataramen/cli",target:"_blank",children:[s.jsx(Ou,{width:zt,height:zt}),s.jsx("span",{children:"NPM"})]})]}),Hu=()=>{const{data:e}=we(),{data:t,isLoading:n}=jc(e?.teamId),o=ee();if(n||!t?.length)return null;const r=a=>{o(D.workbenchTab.build({id:a}))};return s.jsxs("div",{className:Y.recentTabsContainer,children:[s.jsx("h2",{className:Y.homeCardTitle+" px-4 mb-4",children:"Recent tabs"}),t.map(a=>s.jsxs("div",{className:Y.recentTabsEntry,onClick:()=>r(a.id),children:[s.jsx("p",{className:"text-(--text-color-primary) truncate",children:a.name}),s.jsxs("p",{className:"flex items-center gap-2",children:[s.jsx(He,{size:20,type:a.dataSourceType}),s.jsx("span",{className:"text-sm text-(--text-color-secondary) truncate",children:a.dataSourceName})]})]},a.id))]})},Vu=()=>{const{data:e}=we(),{data:t}=ho({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(va,{})]}),s.jsxs("div",{className:"flex flex-col gap-8 mt-8 bg-(--bg) z-1",children:[o&&!n&&s.jsx(ge,{variant:"warning",className:"font-semibold",children:"Connect at least one data source to start using DataRamen"}),s.jsxs("div",{className:Y.homeGrayCard,children:[s.jsx("h2",{className:Y.homeCardTitle,children:"Quick actions"}),s.jsxs("div",{className:Y.homeCardGridContent,children:[s.jsx(Fu,{}),o&&s.jsx(Uu,{}),s.jsx(Bu,{})]})]}),o&&s.jsx(zu,{}),s.jsx(Wu,{}),s.jsx(Hu,{})]})]})})},[Ku,Ds]=Ce(void 0),fo=async e=>new Promise(t=>{Ds({message:e,onCancel:()=>{t(!1),Ds(void 0)},onConfirm:()=>{t(!0),Ds(void 0)}})}),Qu=({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"})]})]}),Gu=()=>{const e=Ku(),[t,n]=l.useState(void 0);return l.useEffect(()=>{e&&n(e)},[e]),s.jsx(Me,{isVisible:!!e,onClose:()=>e?.onCancel(),onClosed:()=>n(void 0),children:t&&s.jsx(Qu,{confirm:t})})},[Yu,jt]=Ce(void 0),Pn=async(e,t)=>new Promise(n=>{jt({message:e,defaultValue:t,onCancel:()=>{jt(void 0),n(void 0)},onConfirm:o=>{jt(void 0),n(o)},type:"string"})}),Ju=async(e,t)=>new Promise(n=>{jt({message:e,defaultValue:t,onCancel:()=>{jt(void 0),n(void 0)},onConfirm:o=>{jt(void 0),n(o)},type:"query-expression"})}),Xu="_root_ng9lp_1",ya={root:Xu},Zu="_root_u7zys_2",ed="_input_u7zys_2",nr={root:Zu,input:ed},td=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})),nd=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:26,fill:"currentColor"}),l.createElement("circle",{cx:346,cy:256,r:26,fill:"currentColor"}),l.createElement("circle",{cx:166,cy:256,r:26,fill:"currentColor"}),l.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32,d:"M160 368L32 256l128-112M352 368l128-112-128-112"})),wa=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"})),sr=(e,t)=>{const n=t.indexOf(e);return n>=t.length?t[0]:t[n+1]},sd=(e,t)=>{const n=t.indexOf(e);return n<=0?t[t.length-1]:t[n-1]},od=({mode:e,onNextMode:t})=>s.jsxs("span",{tabIndex:-1,className:"pr-2 cursor-pointer text-(--text-color-primary)",onClick:t,"data-mode":e,"data-tooltip-id":"default","data-tooltip-content":`Current mode: ${e}. Use up/down arrows to change input mode.`,children:[e==="advanced"&&s.jsx(td,{className:"pointer-events-none",width:20,height:20}),e==="raw"&&s.jsx(nd,{className:"pointer-events-none",width:20,height:20}),e==="default"&&s.jsx(wa,{className:"pointer-events-none",width:20,height:20})]}),Cs=({prefix:e,mode:t="default",allowedModes:n,className:o,inputClass:r,onExpressionChange:a,...i})=>{const c=h=>{a({mode:t,value:h.currentTarget.value})},u=h=>{h.key==="ArrowDown"||h.key==="ArrowUp"?(h.preventDefault(),h.stopPropagation(),a({mode:h.key==="ArrowUp"?sr(t,n):sd(t,n),value:i.value})):i.onKeyDown?.(h)};return s.jsxs("label",{className:A(nr.root,o),"data-input-mode":t,children:[t==="raw"&&!!e&&s.jsx("span",{className:"inline-block pl-1",children:e}),s.jsx("input",{...i,onKeyDown:u,onChange:c,className:A(nr.input,r)}),s.jsx(od,{mode:t,onNextMode:()=>a({mode:sr(t,n),value:i.value})})]})},js=["default","raw"],rd=({data:e})=>{const[t,n]=l.useState("");l.useEffect(()=>{e.defaultValue&&n(e.defaultValue)},[e]);const o=a=>{n(a.target.value)},r=a=>{a.key==="Enter"&&(a.preventDefault(),e.onConfirm(t)),a.key==="Escape"&&(a.preventDefault(),e.onCancel())};return s.jsxs("div",{className:ya.root,children:[s.jsx("h2",{className:"text-xl font-semibold",children:e.message}),s.jsx("input",{autoFocus:!0,className:"w-full input my-2",value:t,onChange:o,onKeyDown:r}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx("button",{className:"button tertiary",onClick:e.onCancel,children:"Cancel"}),s.jsx("button",{className:"button primary",onClick:()=>e.onConfirm(t),children:"Confirm"})]})]})},ad=({data:e})=>{const[t,n]=l.useState({mode:"default",value:e.defaultValue||""}),o=r=>{r.key==="Enter"&&(r.preventDefault(),e.onConfirm(t)),r.key==="Escape"&&(r.preventDefault(),e.onCancel())};return s.jsxs("div",{className:ya.root,children:[s.jsx("h2",{className:"text-xl font-semibold",children:e.message}),s.jsx(Cs,{prefix:"_",autoFocus:!0,className:"w-full my-2 h-8",value:t.value,mode:t.mode,onExpressionChange:n,allowedModes:js,onKeyDown:o,placeholder:"Filter value"}),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"})]})]})},id=()=>{const e=Yu(),[t,n]=l.useState(void 0);return l.useEffect(()=>{e&&n(e)},[e]),s.jsxs(Me,{isVisible:!!e,onClose:()=>jt(void 0),onClosed:()=>n(void 0),children:[t?.type==="string"&&s.jsx(rd,{data:t}),t?.type==="query-expression"&&s.jsx(ad,{data:t})]})},[ld,cd]=Ce(void 0),Ca=e=>{cd(e)},ud="_textarea_1q672_2",dd={textarea:ud},hd=()=>{const e=ld(),t=()=>{e&&(navigator.clipboard.writeText(e.toString()),fe.success("Copied!"))},n=()=>Ca(void 0);return s.jsxs(Me,{isVisible:!!e,onClose:n,backdropClose:!0,children:[s.jsx("textarea",{className:dd.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"})]})]})},md="_tabs_k8xhz_2",fd="_mobile_k8xhz_2",pd="_menu_k8xhz_2",xd="_item_k8xhz_2",gd="_tab_k8xhz_2",bd="_active_k8xhz_2",vd="_close-button_k8xhz_2",$e={tabs:md,mobile:fd,menu:pd,item:xd,tab:gd,active:bd,closeButton:vd},or=e=>window.matchMedia(e).matches;function ja(e,{defaultValue:t=!1,initializeWithValue:n=!0}={}){const[o,r]=l.useState(()=>n?or(e):t);return l.useLayoutEffect(()=>{const a=window.matchMedia(e);function i(){r(()=>or(e))}return i(),a.addListener?a.addListener(i):a.addEventListener("change",i),()=>{a.removeListener?a.removeListener(i):a.removeEventListener("change",i)}},[e]),o}const po={laptop:"(min-width: 1024px)"},Na=()=>window.matchMedia(po.laptop).matches,xo=e=>l.useMemo(()=>{if(e)return e instanceof yi?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]);function Nt(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(" "),Gn=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},yd="_table_al97d_2",wd="_row-index-btn_al97d_2",Cd="_semi-transparent_al97d_2",jd="_table-loading_al97d_2",Nd="_table-empty_al97d_2",_d="_table-row-cells_al97d_2",Sd="_header-cell_al97d_2",kd="_header-actions_al97d_2",Ed="_cell_al97d_2",Rd="_value_al97d_2",Ld="_table-config_al97d_2",Td="_table-action_al97d_2",Ad="_data-source_al97d_2",Id="_gray_al97d_2",Md="_modal_al97d_2",Pd="_selected-size_al97d_2",Od="_pagination-indicator_al97d_2",L={table:yd,rowIndexBtn:wd,semiTransparent:Cd,tableLoading:jd,tableEmpty:Nd,tableRowCells:_d,headerCell:Sd,headerActions:kd,cell:Ed,value:Rd,tableConfig:Ld,tableAction:Td,dataSource:Ad,gray:Id,modal:Md,selectedSize:Pd,paginationIndicator:Od},Pe=l.createContext({name:"No name",hooks:[],availableJoins:[],allColumns:[],dataSourceId:"",entities:[],getValue:()=>{},getValueByIndex:()=>{},getColumnByIndex:()=>{},getColumnType:()=>{}}),je=l.createContext({state:kt({}),setState:()=>{}}),tt=l.createContext({}),_a={ON_ANIMATION_END:Symbol("ON_TRANSITION_END")},Sa=()=>{const[e,t]=l.useState(),[n,o]=l.useState("hidden");return l.useMemo(()=>{const r=c=>{c.preventDefault(),o("in"),t({x:c.clientX-1,y:c.clientY-1})},a=()=>{o("out")},i=()=>{n==="in"?o("visible"):n==="out"&&(t(void 0),o("hidden"))};return{show:!!e,position:e,state:n,open:r,close:a,[_a.ON_ANIMATION_END]:i}},[e,n])},Dd=e=>{if(e!=="ASC")return e==="DESC"?"ASC":"DESC"},$d=()=>{const{state:e,setState:t}=l.useContext(je),n=l.useCallback(o=>{t(r=>{const a=r.orderBy[0];if(a&&a.column===o){const i=Dd(a.direction);return i?{...r,orderBy:[{column:o,direction:i}]}:{...r,orderBy:[]}}return{...r,orderBy:[{column:o,direction:"DESC"}]}})},[t]);return{orderBy:e.orderBy,updateOrderBy:n}},Fd="_options-container_pmdxk_2",Bd="_filter-input_pmdxk_2",qd="_list_pmdxk_2",Wd="_empty-text_pmdxk_2",_t={optionsContainer:Fd,filterInput:Bd,list:qd,emptyText:Wd},Ud="_container_zy41j_2",zd="_animate-show_zy41j_2",Hd="_animate-hide_zy41j_2",Vd="_content_zy41j_2",Kd="_backdrop_zy41j_2",gt={container:Ud,animateShow:zd,animateHide:Hd,content:Vd,backdrop:Kd},ka=({children:e,handler:t})=>{const n=l.useRef(t.close);n.current=t.close;const o=l.useMemo(()=>{if(!t.position)return;const a={};if(typeof window<"u"){const i=t.position.y>window.innerHeight/2,c=t.position.x>window.innerWidth/2;i?a.bottom=window.innerHeight-t.position.y:a.top=t.position.y,Na()?c?a.right=window.innerWidth-t.position.x:a.left=t.position.x:(a.right=36,a.left=36)}return a},[t.position]);if(ws({enabled:!!o,onClose:t.close}),!o)return null;const r=s.jsxs("div",{className:A(gt.container,t.state==="out"&&gt.animateHide,t.state==="in"&&gt.animateShow),onAnimationEnd:t[_a.ON_ANIMATION_END],children:[s.jsx("div",{className:gt.backdrop,onClick:a=>{a.stopPropagation(),a.preventDefault(),t.close()}}),s.jsx("div",{className:A(gt.content,t.state==="out"&&gt.animateHide,t.state==="in"&&gt.animateShow),style:o,children:e})]});return co.createPortal(r,document.body)},et=()=>Date.now().toString(36)+Math.random().toString(36).substring(2),ve=(e,t)=>e!=null&&e>t,Ea=(e,t)=>e!=null&&e<t,Qd="_container_2r6fb_2",Gd={container:Qd},sn=({containerClassName:e,className:t,...n})=>s.jsxs("label",{className:A(Gd.container,e),children:[s.jsx(Mn,{width:16,height:16}),s.jsx("input",{className:A("flex-1 outline-none",t),...n})]}),Yd="_root_10642_2",Jd="_content_10642_2",Xd="_table-name_10642_2",Zd="_sub_10642_2",ot={root:Yd,content:Jd,tableName:Xd,sub:Zd},go=({hook:e,onClick:t})=>e.direction==="out"?s.jsx("button",{className:ot.root,onClick:t,children:s.jsxs("div",{className:ot.content,children:[s.jsx("p",{className:ot.tableName,children:e.toTable}),s.jsxs("p",{className:ot.sub,children:[e.toColumn," = ",e.fromTable,".",e.fromColumn]})]})},e.id):s.jsx("button",{className:ot.root,onClick:t,children:s.jsxs("div",{className:ot.content,children:[s.jsx("p",{className:ot.tableName,children:e.fromTable}),s.jsxs("p",{className:ot.sub,children:[e.fromColumn," = ",e.toTable,".",e.toColumn]})]})},e.id);function eh(e,t,n,o){if(e.direction==="out"){const a=o(n,e.fromTable,e.fromColumn);return{name:`${e.toTable} ${e.toColumn} equals ${a}`,opts:kt({table:e.toTable,dataSourceId:t,filters:[{id:et(),column:`${e.toTable}.${e.toColumn}`,value:a==null?"IS NULL":`${a}`,isEnabled:!0}]})}}const r=o(n,e.toTable,e.toColumn);return{name:`${e.fromTable} ${e.fromColumn} equals ${r}`,opts:kt({table:e.fromTable,dataSourceId:t,filters:[{id:et(),column:`${e.fromTable}.${e.fromColumn}`,value:r==null?"IS NULL":`${r}`,isEnabled:!0}]})}}const Ra=({rowIndex:e,colIndex:t,onClose:n,className:o})=>{const[r,a]=l.useState(""),{dataSourceId:i,hooks:c,getColumnByIndex:u,getValue:h}=l.useContext(Pe),m=l.useMemo(()=>{if(t===void 0)return c;const v=u(t);return v?c.filter(w=>w.toColumn===v.column&&w.toTable===v.table):[]},[t,c,u]),d=Lt(),g=ee(),f=l.useMemo(()=>{const v=r.toLowerCase();return m.filter(w=>w.fromTable.toLowerCase().includes(v))},[r,m]),x=v=>{d.mutateAsync(eh(v,i,e,h)).then(w=>{g(D.workbenchTab.build({id:w.id})),n?.()})},b=ve(f.length,0);return s.jsxs("div",{className:o,children:[s.jsx(sn,{autoFocus:!0,className:_t.filterInput,placeholder:"Filter",value:r,onChange:v=>a(v.target.value)}),s.jsxs("div",{className:_t.list,children:[b&&f.map(v=>s.jsx(go,{hook:v,onClick:()=>x(v)},v.id)),!b&&s.jsx("p",{className:_t.emptyText,children:"Empty"})]})]})},th=({handler:e,rowIndex:t,colIndex:n})=>s.jsx(ka,{handler:e,children:s.jsx("div",{className:_t.optionsContainer,children:s.jsx(Ra,{rowIndex:t,colIndex:n,className:"p-2",onClose:()=>{e.close()}})})}),bo=()=>{const{state:e,setState:t}=l.useContext(je),n=l.useCallback((r,a=!1)=>{t(i=>({...i,page:a?0:i.page,filters:r}))},[t]),o=l.useCallback(r=>{t(a=>({...a,filters:a.filters.filter(i=>i.id!==r)}))},[t]);return{filters:e.filters,removeFilter:o,setFilters:n}},nh=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:48,d:"M112 244l144-144 144 144M256 120v292"})),sh=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32,d:"M464 208L352 96 240 208M352 113.13V416M48 304l112 112 112-112M160 398V96"})),oh="_container_ioqub_2",rh="_animate-show_ioqub_2",ah="_animate-hide_ioqub_2",ih="_backdrop_ioqub_2",lh="_content_ioqub_2",bt={container:oh,animateShow:rh,animateHide:ah,backdrop:ih,content:lh},vo=({children:e,ref:t,onClosed:n})=>{const[o,r]=l.useState(void 0),[a,i]=l.useState("hidden"),c=l.useRef(null);if(l.useImperativeHandle(t,()=>({open:(m,d=!0)=>{d||(m.preventDefault(),m.stopPropagation());const g={},f=m.clientY>window.innerHeight/2,x=m.clientX>window.innerWidth/2;f?g.bottom=window.innerHeight-m.clientY:g.top=m.clientY,Na()?x?g.right=window.innerWidth-m.clientX:g.left=m.clientX:(g.right=36,g.left=36),r(g),i("in")},close:()=>{i("out")}}),[]),ws({enabled:a==="in"||a==="visible",onClose:()=>{i("out")}}),!o)return null;const u=()=>{a==="in"?i("visible"):a==="out"&&(r(void 0),i("hidden"),n?.())},h=s.jsxs("div",{className:A(bt.container,a==="out"&&bt.animateHide,a==="in"&&bt.animateShow),onAnimationEnd:u,children:[s.jsx("div",{className:bt.backdrop,onClick:()=>i("out")}),s.jsx("div",{ref:c,style:o,className:A(bt.content,a==="out"&&bt.animateHide,a==="in"&&bt.animateShow),children:e})]});return co.createPortal(h,document.body)};function $s(e,t,n){const o=e?.rows?.[t]?.[n],r=e?.columns?.[n];return{value:o,column:r}}const ch=({ref:e})=>{const{data:t}=l.useContext(tt),{getColumnType:n}=l.useContext(Pe),{setState:o}=l.useContext(je);return{copyValue:(c,u)=>{const{value:h,column:m}=$s(t?.result,c,u);if(m){const d=Nt(h,n(m.full));navigator.clipboard.writeText(d),fe.success("Copied!"),e.current?.close()}},showValue:(c,u)=>{const{value:h,column:m}=$s(t?.result,c,u);if(m){const d=Nt(h,n(m.full));Ca(d),e.current?.close()}},filterValue:(c,u)=>{const{value:h,column:m}=$s(t?.result,c,u),d=m?.full||"";if(d){let g;if(h==null)g={id:et(),isEnabled:!0,mode:"raw",column:d,value:"IS NULL"};else{const f=Nt(h,n(d));g={id:et(),isEnabled:!0,column:d,value:f,fn:m?.fn,mode:"default"}}o(f=>({...f,filters:[...f.filters,g]})),fe.success(`Added new filter on column ${m?.alias}`),e.current?.close()}}}},La=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("rect",{x:128,y:128,width:336,height:336,rx:57,ry:57,fill:"none",stroke:"currentColor",strokeLinejoin:"round",strokeWidth:32}),l.createElement("path",{d:"M383.5 128l.5-24a56.16 56.16 0 00-56-56H112a64.19 64.19 0 00-64 64v216a56.16 56.16 0 0056 56h24",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32})),uh=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{d:"M255.66 112c-77.94 0-157.89 45.11-220.83 135.33a16 16 0 00-.27 17.77C82.92 340.8 161.8 400 255.66 400c92.84 0 173.34-59.38 221.79-135.25a16.14 16.14 0 000-17.47C428.89 172.28 347.8 112 255.66 112z",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32}),l.createElement("circle",{cx:256,cy:256,r:80,fill:"none",stroke:"currentColor",strokeMiterlimit:10,strokeWidth:32})),dh="_section-name_189yd_2",hh="_item_189yd_2",vt={sectionName:dh,item:hh},Ct=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"})),[mh,yo]=Ce(void 0),fh=e=>{wo(void 0),yo(e)},ph=()=>yo(void 0);function xh(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 Ta=({storage:e=localStorage,localStorageKey:t,initialData:n})=>{const o=Ce(xh(t,n,e));return o[2].subscribe(r=>{e.setItem(t,JSON.stringify(r))}),o},[gh,wo]=Ce(void 0),[bh,vh]=Ta({initialData:{history:[]},localStorageKey:"useEntityEditorHistory_v1"}),Co=(e,t=!0)=>{const n={...e,key:`${e.dataSourceId}-${e.tableName}-${e.entityId.map(o=>o[0]+o[1]).join("")}`};yo(void 0),t&&vh(o=>o.history.some(r=>r.key===n.key)?o:o.history.length<20?{history:[...o.history,n]}:{history:[...o.history.slice(1),n]}),wo(n)},yh=()=>wo(void 0),wh=({onClose:e,rowIndex:t,className:n})=>{const[o,r]=l.useState(""),{entities:a,dataSourceId:i,getValue:c}=l.useContext(Pe),u=l.useMemo(()=>{if(!o)return a;const m=o.toLowerCase();return a.filter(d=>d.toTable.toLowerCase().includes(m))},[a,o]),h=m=>{const d=c(t,m.fromTable,m.fromColumn);d?Co({tableName:m.toTable,dataSourceId:i,entityId:[[m.toColumn,""+d]]}):fe.error(`Cannot open ${m.toTable} record. ${m.fromTable}.${m.fromColumn} is NULL`),e?.()};return s.jsxs("div",{className:n,children:[s.jsx(sn,{autoFocus:!0,className:_t.filterInput,placeholder:"Filter",value:o,onChange:m=>r(m.target.value)}),s.jsx("div",{className:_t.list,children:ve(u.length,0)?u.map(m=>s.jsx(go,{hook:m,onClick:()=>h(m)},m.id)):s.jsx("p",{className:_t.emptyText,children:"Empty"})})]})},Ch=({ref:e,row:t,col:n,onClosed:o})=>{const r=ch({ref:e}),[a,i]=l.useState("cell"),{hooks:c,entities:u}=l.useContext(Pe),h=()=>r.copyValue(t,n),m=()=>r.showValue(t,n),d=()=>r.filterValue(t,n),g=()=>{i("show-record")},f=()=>{o?.(),i("cell")},x=ve(c?.length,0),b=ve(u?.length,0);return s.jsx(vo,{ref:e,onClosed:f,children:s.jsxs("div",{className:"w-full lg:w-sm",children:[a==="cell"&&s.jsxs(s.Fragment,{children:[s.jsx("p",{className:vt.sectionName,children:"Cell actions"}),s.jsxs("button",{className:vt.item,onClick:h,children:[s.jsx(La,{width:14,height:14}),"Copy"]}),s.jsxs("button",{className:vt.item,onClick:m,children:[s.jsx(uh,{width:14,height:14}),"View"]}),s.jsxs("button",{className:vt.item,onClick:d,children:[s.jsx(Mn,{width:14,height:14}),"Filter"]}),(b||x)&&s.jsx("p",{className:vt.sectionName,children:"Row actions"}),b&&s.jsxs("button",{className:vt.item,onClick:g,children:[s.jsx(Ct,{className:"text-(--text-color-tertiary)",width:14,height:14}),"Show record"]}),x&&s.jsxs("button",{className:vt.item,onClick:()=>i("drill"),children:[s.jsx(Ct,{className:"text-(--text-color-tertiary) rotate-180",width:14,height:14}),"Drill down"]})]}),a==="drill"&&s.jsxs(s.Fragment,{children:[s.jsxs("button",{className:"flex gap-1 items-center cursor-pointer px-2 py-1 text-sm rounded-lg bg-gray-50 hover:bg-gray-100 mb-2",onClick:()=>i("cell"),children:[s.jsx(Ct,{className:"text-(--text-color-secondary) rotate-270",width:16,height:16}),"Drill down"]}),s.jsx(Ra,{rowIndex:t,onClose:()=>e.current?.close()})]}),a==="show-record"&&s.jsxs(s.Fragment,{children:[s.jsxs("button",{className:"flex gap-1 items-center cursor-pointer px-2 py-1 text-sm rounded-lg bg-gray-50 hover:bg-gray-100 mb-2",onClick:()=>i("cell"),children:[s.jsx(Ct,{className:"text-(--text-color-secondary) rotate-270",width:16,height:16}),"Show record"]}),s.jsx(wh,{rowIndex:t,onClose:()=>e.current?.close()})]})]})})},jh={DESC:"",ASC:"rotate-180"},Nh=(e,{column:t,value:n,fn:o,mode:r})=>{const a=e.map(i=>({...i,isEnabled:i.column===t?!1:i.isEnabled}));return a.push({id:et(),column:t,isEnabled:!0,value:n,fn:o,mode:r}),a},_h=()=>{const{data:e}=l.useContext(tt),{orderBy:t,updateOrderBy:n}=$d(),{setFilters:o,filters:r}=bo(),a=e?.result.columns||[],i=t[0],c=ve(e?.result.tables.length,1),u=(h,m)=>{Ju("Filter value","").then(d=>{d&&o(Nh(r,{column:h,value:d.value,fn:m,mode:d.mode}))})};return s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("td",{children:"🥢"}),a.map(h=>s.jsxs("td",{className:L.headerCell,children:[s.jsxs("div",{className:"overflow-hidden",children:[c&&s.jsx("p",{className:"text-xs truncate italic text-(--text-color-primary)",children:h.table||"-"}),s.jsx("p",{className:"text-sm font-semibold truncate text-(--text-color-primary)",children:h.column})]}),s.jsxs("div",{className:L.headerActions,children:[s.jsx("button",{onClick:()=>n(h.alias),children:i?.column===h.alias?s.jsx(nh,{className:jh[i.direction],width:16,height:16}):s.jsx(sh,{width:16,height:16})}),s.jsx("button",{onClick:()=>u(h.full,h.fn),children:s.jsx(Mn,{width:16,height:16})})]})]},h.full))]})})};function Sh({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=Nt(e);return t?.hasRecord||t?.hasDrill?s.jsxs("div",{className:"flex gap-1 items-center justify-between pointer-events-none",children:[s.jsx("span",{className:L.value,children:n}),s.jsxs("div",{className:"flex",children:[t.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(Ct,{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(Ct,{className:"pointer-events-none rotate-180",width:16,height:16})})]})]}):s.jsx("span",{className:L.value,children:n})}const kh=l.memo(({row:e,isLastRow:t,index:n,offset:o,colMeta:r})=>s.jsxs("tr",{className:A(L.tableRowCells,t&&"rounded-b-lg"),children:[s.jsx("td",{"data-row":n,children:s.jsxs("button",{"data-cell-action":"drill-all",className:L.rowIndexBtn,children:[s.jsx(Ct,{className:"rotate-180 pointer-events-none",width:16,height:16}),s.jsx("span",{children:n+1+o})]})}),e.map((a,i)=>s.jsx("td",{className:L.cell,"data-row":n,"data-col":i,children:s.jsx(Sh,{value:a,actions:r.get(i)})},i))]})),Eh=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--}},rr=e=>{const t=Eh(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}},Rh=()=>{const{data:e,error:t,isLoading:n,isFetching:o}=l.useContext(tt),{dataSourceId:r,getColumnByIndex:a,getValueByIndex:i}=l.useContext(Pe),{state:{page:c,size:u}}=l.useContext(je),h=l.useRef(null),m=xo(t),d=Sa(),[g,f]=l.useState(),x=p=>{const y=p.target,C=y.dataset?.cellAction,N=rr(y);if(C==="ref"&&ve(N?.col,-1)){const I=i(N.row,N.col),_=a(N.col);_&&Co({tableName:_.ref.table,dataSourceId:r,entityId:[[_.ref.field,I]]})}else(C==="drill"||C==="drill-all")&&(f(N),d.open(p))},b=p=>{const y=rr(p.target);y&&(f(y),h.current?.open(p),p.preventDefault(),p.stopPropagation())},v=c*u,w=l.useMemo(()=>{const p=new Map;return e&&e.result.columns.forEach((y,C)=>{p.set(C,{hasRecord:!!y.ref,hasDrill:!!y.referencedBy})}),p},[e]);return s.jsxs(s.Fragment,{children:[g&&d.show&&s.jsx(th,{handler:d,rowIndex:g.row,colIndex:g.col}),s.jsx(Ch,{ref:h,col:g?.col,row:g?.row,onClosed:()=>{f(void 0)}}),m&&s.jsx(ge,{variant:"danger",children:m}),n&&s.jsx("div",{className:L.tableLoading,children:"Loading data"}),e&&s.jsxs("table",{className:A(L.table,o&&L.semiTransparent),onClick:x,onContextMenu:b,children:[s.jsx(_h,{}),s.jsxs("tbody",{children:[e.result.rows?.length<1&&s.jsx("tr",{className:L.tableEmpty,children:s.jsx("td",{colSpan:e.result.columns.length+1,children:"No data"})}),e.result.rows?.map((p,y)=>s.jsx(kh,{index:y,offset:v,row:p,colMeta:w,isLastRow:y===e.result.rows.length-1},y))]})]})]})},Aa=()=>{const{state:e,setState:t}=l.useContext(je),n=l.useCallback(r=>{t(a=>({...a,page:r}))},[t]),o=l.useCallback((r,a=!1)=>{t(i=>({...i,size:r,page:a?0:i.page}))},[t]);return{page:e.page,size:e.size,setSize:o,setPage:n}},Lh=()=>ne({mutationFn:async e=>{const{data:t}=await B.post("/saved-queries",e);return t.data},onSuccess:()=>{J.invalidateQueries({queryKey:["queries"]}),en()}}),Th=()=>ne({mutationFn:async e=>B.delete("/saved-queries/"+e),onSuccess:()=>{en()}}),Ah=()=>ne({mutationFn:async({id:e,payload:t})=>{const{data:n}=await B.patch("/saved-queries/"+e,t);return n.data},onSuccess:()=>{en(),vc()}}),[Ns,jo]=Ce({filters:!1,joins:!1,columns:!1,groupBy:!1,aggregate:!1}),Be=e=>jo(t=>({...t,[e]:!0})),_s=e=>jo(t=>({...t,[e]:!1})),rs=e=>jo(t=>({...t,[e]:!t[e]})),Yt=Math.min,St=Math.max,as=Math.round,Yn=Math.floor,qe=e=>({x:e,y:e}),Ih={left:"right",right:"left",bottom:"top",top:"bottom"},Mh={start:"end",end:"start"};function Js(e,t,n){return St(e,Yt(t,n))}function On(e,t){return typeof e=="function"?e(t):e}function Et(e){return e.split("-")[0]}function Dn(e){return e.split("-")[1]}function Ia(e){return e==="x"?"y":"x"}function No(e){return e==="y"?"height":"width"}const Ph=new Set(["top","bottom"]);function it(e){return Ph.has(Et(e))?"y":"x"}function _o(e){return Ia(it(e))}function Oh(e,t,n){n===void 0&&(n=!1);const o=Dn(e),r=_o(e),a=No(r);let i=r==="x"?o===(n?"end":"start")?"right":"left":o==="start"?"bottom":"top";return t.reference[a]>t.floating[a]&&(i=is(i)),[i,is(i)]}function Dh(e){const t=is(e);return[Xs(e),t,Xs(t)]}function Xs(e){return e.replace(/start|end/g,t=>Mh[t])}const ar=["left","right"],ir=["right","left"],$h=["top","bottom"],Fh=["bottom","top"];function Bh(e,t,n){switch(e){case"top":case"bottom":return n?t?ir:ar:t?ar:ir;case"left":case"right":return t?$h:Fh;default:return[]}}function qh(e,t,n,o){const r=Dn(e);let a=Bh(Et(e),n==="start",o);return r&&(a=a.map(i=>i+"-"+r),t&&(a=a.concat(a.map(Xs)))),a}function is(e){return e.replace(/left|right|bottom|top/g,t=>Ih[t])}function Wh(e){return{top:0,right:0,bottom:0,left:0,...e}}function Ma(e){return typeof e!="number"?Wh(e):{top:e,right:e,bottom:e,left:e}}function ls(e){const{x:t,y:n,width:o,height:r}=e;return{width:o,height:r,top:n,left:t,right:t+o,bottom:n+r,x:t,y:n}}function lr(e,t,n){let{reference:o,floating:r}=e;const a=it(t),i=_o(t),c=No(i),u=Et(t),h=a==="y",m=o.x+o.width/2-r.width/2,d=o.y+o.height/2-r.height/2,g=o[c]/2-r[c]/2;let f;switch(u){case"top":f={x:m,y:o.y-r.height};break;case"bottom":f={x:m,y:o.y+o.height};break;case"right":f={x:o.x+o.width,y:d};break;case"left":f={x:o.x-r.width,y:d};break;default:f={x:o.x,y:o.y}}switch(Dn(t)){case"start":f[i]-=g*(n&&h?-1:1);break;case"end":f[i]+=g*(n&&h?-1:1);break}return f}const Uh=async(e,t,n)=>{const{placement:o="bottom",strategy:r="absolute",middleware:a=[],platform:i}=n,c=a.filter(Boolean),u=await(i.isRTL==null?void 0:i.isRTL(t));let h=await i.getElementRects({reference:e,floating:t,strategy:r}),{x:m,y:d}=lr(h,o,u),g=o,f={},x=0;for(let b=0;b<c.length;b++){const{name:v,fn:w}=c[b],{x:p,y,data:C,reset:N}=await w({x:m,y:d,initialPlacement:o,placement:g,strategy:r,middlewareData:f,rects:h,platform:i,elements:{reference:e,floating:t}});m=p??m,d=y??d,f={...f,[v]:{...f[v],...C}},N&&x<=50&&(x++,typeof N=="object"&&(N.placement&&(g=N.placement),N.rects&&(h=N.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:r}):N.rects),{x:m,y:d}=lr(h,g,u)),b=-1)}return{x:m,y:d,placement:g,strategy:r,middlewareData:f}};async function Pa(e,t){var n;t===void 0&&(t={});const{x:o,y:r,platform:a,rects:i,elements:c,strategy:u}=e,{boundary:h="clippingAncestors",rootBoundary:m="viewport",elementContext:d="floating",altBoundary:g=!1,padding:f=0}=On(t,e),x=Ma(f),v=c[g?d==="floating"?"reference":"floating":d],w=ls(await a.getClippingRect({element:(n=await(a.isElement==null?void 0:a.isElement(v)))==null||n?v:v.contextElement||await(a.getDocumentElement==null?void 0:a.getDocumentElement(c.floating)),boundary:h,rootBoundary:m,strategy:u})),p=d==="floating"?{x:o,y:r,width:i.floating.width,height:i.floating.height}:i.reference,y=await(a.getOffsetParent==null?void 0:a.getOffsetParent(c.floating)),C=await(a.isElement==null?void 0:a.isElement(y))?await(a.getScale==null?void 0:a.getScale(y))||{x:1,y:1}:{x:1,y:1},N=ls(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:p,offsetParent:y,strategy:u}):p);return{top:(w.top-N.top+x.top)/C.y,bottom:(N.bottom-w.bottom+x.bottom)/C.y,left:(w.left-N.left+x.left)/C.x,right:(N.right-w.right+x.right)/C.x}}const zh=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:o,placement:r,rects:a,platform:i,elements:c,middlewareData:u}=t,{element:h,padding:m=0}=On(e,t)||{};if(h==null)return{};const d=Ma(m),g={x:n,y:o},f=_o(r),x=No(f),b=await i.getDimensions(h),v=f==="y",w=v?"top":"left",p=v?"bottom":"right",y=v?"clientHeight":"clientWidth",C=a.reference[x]+a.reference[f]-g[f]-a.floating[x],N=g[f]-a.reference[f],I=await(i.getOffsetParent==null?void 0:i.getOffsetParent(h));let _=I?I[y]:0;(!_||!await(i.isElement==null?void 0:i.isElement(I)))&&(_=c.floating[y]||a.floating[x]);const M=C/2-N/2,k=_/2-b[x]/2-1,O=Yt(d[w],k),te=Yt(d[p],k),ae=O,Ne=_-b[x]-te,q=_/2-b[x]/2+M,S=Js(ae,q,Ne),P=!u.arrow&&Dn(r)!=null&&q!==S&&a.reference[x]/2-(q<ae?O:te)-b[x]/2<0,z=P?q<ae?q-ae:q-Ne:0;return{[f]:g[f]+z,data:{[f]:S,centerOffset:q-S-z,...P&&{alignmentOffset:z}},reset:P}}}),Hh=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,o;const{placement:r,middlewareData:a,rects:i,initialPlacement:c,platform:u,elements:h}=t,{mainAxis:m=!0,crossAxis:d=!0,fallbackPlacements:g,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:x="none",flipAlignment:b=!0,...v}=On(e,t);if((n=a.arrow)!=null&&n.alignmentOffset)return{};const w=Et(r),p=it(c),y=Et(c)===c,C=await(u.isRTL==null?void 0:u.isRTL(h.floating)),N=g||(y||!b?[is(c)]:Dh(c)),I=x!=="none";!g&&I&&N.push(...qh(c,b,x,C));const _=[c,...N],M=await Pa(t,v),k=[];let O=((o=a.flip)==null?void 0:o.overflows)||[];if(m&&k.push(M[w]),d){const q=Oh(r,i,C);k.push(M[q[0]],M[q[1]])}if(O=[...O,{placement:r,overflows:k}],!k.every(q=>q<=0)){var te,ae;const q=(((te=a.flip)==null?void 0:te.index)||0)+1,S=_[q];if(S&&(!(d==="alignment"?p!==it(S):!1)||O.every(H=>it(H.placement)===p?H.overflows[0]>0:!0)))return{data:{index:q,overflows:O},reset:{placement:S}};let P=(ae=O.filter(z=>z.overflows[0]<=0).sort((z,H)=>z.overflows[1]-H.overflows[1])[0])==null?void 0:ae.placement;if(!P)switch(f){case"bestFit":{var Ne;const z=(Ne=O.filter(H=>{if(I){const ie=it(H.placement);return ie===p||ie==="y"}return!0}).map(H=>[H.placement,H.overflows.filter(ie=>ie>0).reduce((ie,Ke)=>ie+Ke,0)]).sort((H,ie)=>H[1]-ie[1])[0])==null?void 0:Ne[0];z&&(P=z);break}case"initialPlacement":P=c;break}if(r!==P)return{reset:{placement:P}}}return{}}}},Vh=new Set(["left","top"]);async function Kh(e,t){const{placement:n,platform:o,elements:r}=e,a=await(o.isRTL==null?void 0:o.isRTL(r.floating)),i=Et(n),c=Dn(n),u=it(n)==="y",h=Vh.has(i)?-1:1,m=a&&u?-1:1,d=On(t,e);let{mainAxis:g,crossAxis:f,alignmentAxis:x}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return c&&typeof x=="number"&&(f=c==="end"?x*-1:x),u?{x:f*m,y:g*h}:{x:g*h,y:f*m}}const Qh=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,o;const{x:r,y:a,placement:i,middlewareData:c}=t,u=await Kh(t,e);return i===((n=c.offset)==null?void 0:n.placement)&&(o=c.arrow)!=null&&o.alignmentOffset?{}:{x:r+u.x,y:a+u.y,data:{...u,placement:i}}}}},Gh=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:o,placement:r}=t,{mainAxis:a=!0,crossAxis:i=!1,limiter:c={fn:v=>{let{x:w,y:p}=v;return{x:w,y:p}}},...u}=On(e,t),h={x:n,y:o},m=await Pa(t,u),d=it(Et(r)),g=Ia(d);let f=h[g],x=h[d];if(a){const v=g==="y"?"top":"left",w=g==="y"?"bottom":"right",p=f+m[v],y=f-m[w];f=Js(p,f,y)}if(i){const v=d==="y"?"top":"left",w=d==="y"?"bottom":"right",p=x+m[v],y=x-m[w];x=Js(p,x,y)}const b=c.fn({...t,[g]:f,[d]:x});return{...b,data:{x:b.x-n,y:b.y-o,enabled:{[g]:a,[d]:i}}}}}};function Ss(){return typeof window<"u"}function on(e){return Oa(e)?(e.nodeName||"").toLowerCase():"#document"}function be(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Ve(e){var t;return(t=(Oa(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Oa(e){return Ss()?e instanceof Node||e instanceof be(e).Node:!1}function Ae(e){return Ss()?e instanceof Element||e instanceof be(e).Element:!1}function Ue(e){return Ss()?e instanceof HTMLElement||e instanceof be(e).HTMLElement:!1}function cr(e){return!Ss()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof be(e).ShadowRoot}const Yh=new Set(["inline","contents"]);function $n(e){const{overflow:t,overflowX:n,overflowY:o,display:r}=Ie(e);return/auto|scroll|overlay|hidden|clip/.test(t+o+n)&&!Yh.has(r)}const Jh=new Set(["table","td","th"]);function Xh(e){return Jh.has(on(e))}const Zh=[":popover-open",":modal"];function ks(e){return Zh.some(t=>{try{return e.matches(t)}catch{return!1}})}const em=["transform","translate","scale","rotate","perspective"],tm=["transform","translate","scale","rotate","perspective","filter"],nm=["paint","layout","strict","content"];function So(e){const t=ko(),n=Ae(e)?Ie(e):e;return em.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)||tm.some(o=>(n.willChange||"").includes(o))||nm.some(o=>(n.contain||"").includes(o))}function sm(e){let t=ct(e);for(;Ue(t)&&!Jt(t);){if(So(t))return t;if(ks(t))return null;t=ct(t)}return null}function ko(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const om=new Set(["html","body","#document"]);function Jt(e){return om.has(on(e))}function Ie(e){return be(e).getComputedStyle(e)}function Es(e){return Ae(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function ct(e){if(on(e)==="html")return e;const t=e.assignedSlot||e.parentNode||cr(e)&&e.host||Ve(e);return cr(t)?t.host:t}function Da(e){const t=ct(e);return Jt(t)?e.ownerDocument?e.ownerDocument.body:e.body:Ue(t)&&$n(t)?t:Da(t)}function Nn(e,t,n){var o;t===void 0&&(t=[]),n===void 0&&(n=!0);const r=Da(e),a=r===((o=e.ownerDocument)==null?void 0:o.body),i=be(r);if(a){const c=Zs(i);return t.concat(i,i.visualViewport||[],$n(r)?r:[],c&&n?Nn(c):[])}return t.concat(r,Nn(r,[],n))}function Zs(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 r=Ue(e),a=r?e.offsetWidth:n,i=r?e.offsetHeight:o,c=as(n)!==a||as(o)!==i;return c&&(n=a,o=i),{width:n,height:o,$:c}}function Eo(e){return Ae(e)?e:e.contextElement}function Qt(e){const t=Eo(e);if(!Ue(t))return qe(1);const n=t.getBoundingClientRect(),{width:o,height:r,$:a}=$a(t);let i=(a?as(n.width):n.width)/o,c=(a?as(n.height):n.height)/r;return(!i||!Number.isFinite(i))&&(i=1),(!c||!Number.isFinite(c))&&(c=1),{x:i,y:c}}const rm=qe(0);function Fa(e){const t=be(e);return!ko()||!t.visualViewport?rm:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function am(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==be(e)?!1:t}function Rt(e,t,n,o){t===void 0&&(t=!1),n===void 0&&(n=!1);const r=e.getBoundingClientRect(),a=Eo(e);let i=qe(1);t&&(o?Ae(o)&&(i=Qt(o)):i=Qt(e));const c=am(a,n,o)?Fa(a):qe(0);let u=(r.left+c.x)/i.x,h=(r.top+c.y)/i.y,m=r.width/i.x,d=r.height/i.y;if(a){const g=be(a),f=o&&Ae(o)?be(o):o;let x=g,b=Zs(x);for(;b&&o&&f!==x;){const v=Qt(b),w=b.getBoundingClientRect(),p=Ie(b),y=w.left+(b.clientLeft+parseFloat(p.paddingLeft))*v.x,C=w.top+(b.clientTop+parseFloat(p.paddingTop))*v.y;u*=v.x,h*=v.y,m*=v.x,d*=v.y,u+=y,h+=C,x=be(b),b=Zs(x)}}return ls({width:m,height:d,x:u,y:h})}function Rs(e,t){const n=Es(e).scrollLeft;return t?t.left+n:Rt(Ve(e)).left+n}function Ba(e,t){const n=e.getBoundingClientRect(),o=n.left+t.scrollLeft-Rs(e,n),r=n.top+t.scrollTop;return{x:o,y:r}}function im(e){let{elements:t,rect:n,offsetParent:o,strategy:r}=e;const a=r==="fixed",i=Ve(o),c=t?ks(t.floating):!1;if(o===i||c&&a)return n;let u={scrollLeft:0,scrollTop:0},h=qe(1);const m=qe(0),d=Ue(o);if((d||!d&&!a)&&((on(o)!=="body"||$n(i))&&(u=Es(o)),Ue(o))){const f=Rt(o);h=Qt(o),m.x=f.x+o.clientLeft,m.y=f.y+o.clientTop}const g=i&&!d&&!a?Ba(i,u):qe(0);return{width:n.width*h.x,height:n.height*h.y,x:n.x*h.x-u.scrollLeft*h.x+m.x+g.x,y:n.y*h.y-u.scrollTop*h.y+m.y+g.y}}function lm(e){return Array.from(e.getClientRects())}function cm(e){const t=Ve(e),n=Es(e),o=e.ownerDocument.body,r=St(t.scrollWidth,t.clientWidth,o.scrollWidth,o.clientWidth),a=St(t.scrollHeight,t.clientHeight,o.scrollHeight,o.clientHeight);let i=-n.scrollLeft+Rs(e);const c=-n.scrollTop;return Ie(o).direction==="rtl"&&(i+=St(t.clientWidth,o.clientWidth)-r),{width:r,height:a,x:i,y:c}}const ur=25;function um(e,t){const n=be(e),o=Ve(e),r=n.visualViewport;let a=o.clientWidth,i=o.clientHeight,c=0,u=0;if(r){a=r.width,i=r.height;const m=ko();(!m||m&&t==="fixed")&&(c=r.offsetLeft,u=r.offsetTop)}const h=Rs(o);if(h<=0){const m=o.ownerDocument,d=m.body,g=getComputedStyle(d),f=m.compatMode==="CSS1Compat"&&parseFloat(g.marginLeft)+parseFloat(g.marginRight)||0,x=Math.abs(o.clientWidth-d.clientWidth-f);x<=ur&&(a-=x)}else h<=ur&&(a+=h);return{width:a,height:i,x:c,y:u}}const dm=new Set(["absolute","fixed"]);function hm(e,t){const n=Rt(e,!0,t==="fixed"),o=n.top+e.clientTop,r=n.left+e.clientLeft,a=Ue(e)?Qt(e):qe(1),i=e.clientWidth*a.x,c=e.clientHeight*a.y,u=r*a.x,h=o*a.y;return{width:i,height:c,x:u,y:h}}function dr(e,t,n){let o;if(t==="viewport")o=um(e,n);else if(t==="document")o=cm(Ve(e));else if(Ae(t))o=hm(t,n);else{const r=Fa(e);o={x:t.x-r.x,y:t.y-r.y,width:t.width,height:t.height}}return ls(o)}function qa(e,t){const n=ct(e);return n===t||!Ae(n)||Jt(n)?!1:Ie(n).position==="fixed"||qa(n,t)}function mm(e,t){const n=t.get(e);if(n)return n;let o=Nn(e,[],!1).filter(c=>Ae(c)&&on(c)!=="body"),r=null;const a=Ie(e).position==="fixed";let i=a?ct(e):e;for(;Ae(i)&&!Jt(i);){const c=Ie(i),u=So(i);!u&&c.position==="fixed"&&(r=null),(a?!u&&!r:!u&&c.position==="static"&&!!r&&dm.has(r.position)||$n(i)&&!u&&qa(e,i))?o=o.filter(m=>m!==i):r=c,i=ct(i)}return t.set(e,o),o}function fm(e){let{element:t,boundary:n,rootBoundary:o,strategy:r}=e;const i=[...n==="clippingAncestors"?ks(t)?[]:mm(t,this._c):[].concat(n),o],c=i[0],u=i.reduce((h,m)=>{const d=dr(t,m,r);return h.top=St(d.top,h.top),h.right=Yt(d.right,h.right),h.bottom=Yt(d.bottom,h.bottom),h.left=St(d.left,h.left),h},dr(t,c,r));return{width:u.right-u.left,height:u.bottom-u.top,x:u.left,y:u.top}}function pm(e){const{width:t,height:n}=$a(e);return{width:t,height:n}}function xm(e,t,n){const o=Ue(t),r=Ve(t),a=n==="fixed",i=Rt(e,!0,a,t);let c={scrollLeft:0,scrollTop:0};const u=qe(0);function h(){u.x=Rs(r)}if(o||!o&&!a)if((on(t)!=="body"||$n(r))&&(c=Es(t)),o){const f=Rt(t,!0,a,t);u.x=f.x+t.clientLeft,u.y=f.y+t.clientTop}else r&&h();a&&!o&&r&&h();const m=r&&!o&&!a?Ba(r,c):qe(0),d=i.left+c.scrollLeft-u.x-m.x,g=i.top+c.scrollTop-u.y-m.y;return{x:d,y:g,width:i.width,height:i.height}}function Fs(e){return Ie(e).position==="static"}function hr(e,t){if(!Ue(e)||Ie(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Ve(e)===n&&(n=n.ownerDocument.body),n}function Wa(e,t){const n=be(e);if(ks(e))return n;if(!Ue(e)){let r=ct(e);for(;r&&!Jt(r);){if(Ae(r)&&!Fs(r))return r;r=ct(r)}return n}let o=hr(e,t);for(;o&&Xh(o)&&Fs(o);)o=hr(o,t);return o&&Jt(o)&&Fs(o)&&!So(o)?n:o||sm(e)||n}const gm=async function(e){const t=this.getOffsetParent||Wa,n=this.getDimensions,o=await n(e.floating);return{reference:xm(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}};function bm(e){return Ie(e).direction==="rtl"}const vm={convertOffsetParentRelativeRectToViewportRelativeRect:im,getDocumentElement:Ve,getClippingRect:fm,getOffsetParent:Wa,getElementRects:gm,getClientRects:lm,getDimensions:pm,getScale:Qt,isElement:Ae,isRTL:bm};function Ua(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function ym(e,t){let n=null,o;const r=Ve(e);function a(){var c;clearTimeout(o),(c=n)==null||c.disconnect(),n=null}function i(c,u){c===void 0&&(c=!1),u===void 0&&(u=1),a();const h=e.getBoundingClientRect(),{left:m,top:d,width:g,height:f}=h;if(c||t(),!g||!f)return;const x=Yn(d),b=Yn(r.clientWidth-(m+g)),v=Yn(r.clientHeight-(d+f)),w=Yn(m),y={rootMargin:-x+"px "+-b+"px "+-v+"px "+-w+"px",threshold:St(0,Yt(1,u))||1};let C=!0;function N(I){const _=I[0].intersectionRatio;if(_!==u){if(!C)return i();_?i(!1,_):o=setTimeout(()=>{i(!1,1e-7)},1e3)}_===1&&!Ua(h,e.getBoundingClientRect())&&i(),C=!1}try{n=new IntersectionObserver(N,{...y,root:r.ownerDocument})}catch{n=new IntersectionObserver(N,y)}n.observe(e)}return i(!0),a}function wm(e,t,n,o){o===void 0&&(o={});const{ancestorScroll:r=!0,ancestorResize:a=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:c=typeof IntersectionObserver=="function",animationFrame:u=!1}=o,h=Eo(e),m=r||a?[...h?Nn(h):[],...Nn(t)]:[];m.forEach(w=>{r&&w.addEventListener("scroll",n,{passive:!0}),a&&w.addEventListener("resize",n)});const d=h&&c?ym(h,n):null;let g=-1,f=null;i&&(f=new ResizeObserver(w=>{let[p]=w;p&&p.target===h&&f&&(f.unobserve(t),cancelAnimationFrame(g),g=requestAnimationFrame(()=>{var y;(y=f)==null||y.observe(t)})),n()}),h&&!u&&f.observe(h),f.observe(t));let x,b=u?Rt(e):null;u&&v();function v(){const w=Rt(e);b&&!Ua(b,w)&&n(),b=w,x=requestAnimationFrame(v)}return n(),()=>{var w;m.forEach(p=>{r&&p.removeEventListener("scroll",n),a&&p.removeEventListener("resize",n)}),d?.(),(w=f)==null||w.disconnect(),f=null,u&&cancelAnimationFrame(x)}}const Cm=Qh,jm=Gh,Nm=Hh,_m=zh,mr=(e,t,n)=>{const o=new Map,r={platform:vm,...n},a={...r.platform,_c:o};return Uh(e,t,{...r,platform:a})};var Bs={exports:{}};var fr;function Sm(){return fr||(fr=1,(function(e){(function(){var t={}.hasOwnProperty;function n(){for(var a="",i=0;i<arguments.length;i++){var c=arguments[i];c&&(a=r(a,o(c)))}return a}function o(a){if(typeof a=="string"||typeof a=="number")return a;if(typeof a!="object")return"";if(Array.isArray(a))return n.apply(null,a);if(a.toString!==Object.prototype.toString&&!a.toString.toString().includes("[native code]"))return a.toString();var i="";for(var c in a)t.call(a,c)&&a[c]&&(i=r(i,c));return i}function r(a,i){return i?a?a+" "+i:a+i:a}e.exports?(n.default=n,e.exports=n):window.classNames=n})()})(Bs)),Bs.exports}var km=Sm();const eo=wi(km);var pr={};const Em="react-tooltip-core-styles",Rm="react-tooltip-base-styles",xr={core:!1,base:!1};function gr({css:e,id:t=Rm,type:n="base",ref:o}){var r,a;if(!e||typeof document>"u"||xr[n]||n==="core"&&typeof process<"u"&&(!((r=process==null?void 0:pr)===null||r===void 0)&&r.REACT_TOOLTIP_DISABLE_CORE_STYLES)||n!=="base"&&typeof process<"u"&&(!((a=process==null?void 0:pr)===null||a===void 0)&&a.REACT_TOOLTIP_DISABLE_BASE_STYLES))return;n==="core"&&(t=Em),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)),xr[n]=!0}const br=async({elementReference:e=null,tooltipReference:t=null,tooltipArrowReference:n=null,place:o="top",offset:r=10,strategy:a="absolute",middlewares:i=[Cm(Number(r)),Nm({fallbackAxisSideDirection:"start"}),jm({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(_m({element:n,padding:5})),mr(e,t,{placement:o,strategy:a,middleware:h}).then((({x:m,y:d,placement:g,middlewareData:f})=>{var x,b;const v={left:`${m}px`,top:`${d}px`,border:c},{x:w,y:p}=(x=f.arrow)!==null&&x!==void 0?x:{x:0,y:0},y=(b={top:"bottom",right:"left",bottom:"top",left:"right"}[g.split("-")[0]])!==null&&b!==void 0?b:"bottom",C=c&&{borderBottom:c,borderRight:c};let N=0;if(c){const I=`${c}`.match(/(\d+)px/);N=I?.[1]?Number(I[1]):1}return{tooltipStyles:v,tooltipArrowStyles:{left:w!=null?`${w}px`:"",top:p!=null?`${p}px`:"",right:"",bottom:"",...C,[y]:`-${u/2+N}px`},place:g}}))):mr(e,t,{placement:"bottom",strategy:a,middleware:h}).then((({x:m,y:d,placement:g})=>({tooltipStyles:{left:`${m}px`,top:`${d}px`},tooltipArrowStyles:{},place:g})))},vr=(e,t)=>!("CSS"in window&&"supports"in window.CSS)||window.CSS.supports(e,t),yr=(e,t,n)=>{let o=null;const r=function(...a){const i=()=>{o=null};!o&&(e.apply(this,a),o=setTimeout(i,t))};return r.cancel=()=>{o&&(clearTimeout(o),o=null)},r},wr=e=>e!==null&&!Array.isArray(e)&&typeof e=="object",to=(e,t)=>{if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every(((r,a)=>to(r,t[a])));if(Array.isArray(e)!==Array.isArray(t))return!1;if(!wr(e)||!wr(t))return e===t;const n=Object.keys(e),o=Object.keys(t);return n.length===o.length&&n.every((r=>to(e[r],t[r])))},Lm=e=>{if(!(e instanceof HTMLElement||e instanceof SVGElement))return!1;const t=getComputedStyle(e);return["overflow","overflow-x","overflow-y"].some((n=>{const o=t.getPropertyValue(n);return o==="auto"||o==="scroll"}))},Cr=e=>{if(!e)return null;let t=e.parentElement;for(;t;){if(Lm(t))return t;t=t.parentElement}return document.scrollingElement||document.documentElement},Tm=typeof window<"u"?l.useLayoutEffect:l.useEffect,Se=e=>{e.current&&(clearTimeout(e.current),e.current=null)},Am="DEFAULT_TOOLTIP_ID",Im={anchorRefs:new Set,activeAnchor:{current:null},attach:()=>{},detach:()=>{},setActiveAnchor:()=>{}},Mm=l.createContext({getTooltipData:()=>Im});function za(e=Am){return l.useContext(Mm).getTooltipData(e)}var Ht={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"},qs={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 Pm=({forwardRef:e,id:t,className:n,classNameArrow:o,variant:r="dark",anchorId:a,anchorSelect:i,place:c="top",offset:u=10,events:h=["hover"],openOnClick:m=!1,positionStrategy:d="absolute",middlewares:g,wrapper:f,delayShow:x=0,delayHide:b=0,float:v=!1,hidden:w=!1,noArrow:p=!1,clickable:y=!1,closeOnEsc:C=!1,closeOnScroll:N=!1,closeOnResize:I=!1,openEvents:_,closeEvents:M,globalCloseEvents:k,imperativeModeOnly:O,style:te,position:ae,afterShow:Ne,afterHide:q,disableTooltip:S,content:P,contentWrapperRef:z,isOpen:H,defaultIsOpen:ie=!1,setIsOpen:Ke,previousActiveAnchor:rn,activeAnchor:V,setActiveAnchor:Tt,border:Fn,opacity:Bn,arrowColor:qn,arrowSize:At=8,role:Ls="tooltip"})=>{var dt;const ue=l.useRef(null),It=l.useRef(null),Le=l.useRef(null),ht=l.useRef(null),Mt=l.useRef(null),[mt,Wn]=l.useState({tooltipStyles:{},tooltipArrowStyles:{},place:c}),[de,an]=l.useState(!1),[Pt,nt]=l.useState(!1),[G,Ot]=l.useState(null),Un=l.useRef(!1),Dt=l.useRef(null),{anchorRefs:zn,setActiveAnchor:ln}=za(t),cn=l.useRef(!1),[st,un]=l.useState([]),ft=l.useRef(!1),$t=m||h.includes("click"),Hn=$t||_?.click||_?.dblclick||_?.mousedown,dn=_?{..._}:{mouseover:!0,focus:!0,mouseenter:!1,click:!1,dblclick:!1,mousedown:!1};!_&&$t&&Object.assign(dn,{mouseenter:!1,focus:!1,mouseover:!1,click:!0});const pt=M?{...M}:{mouseout:!0,blur:!0,mouseleave:!1,click:!1,dblclick:!1,mouseup:!1};!M&&$t&&Object.assign(pt,{mouseleave:!1,blur:!1,mouseout:!1});const oe=k?{...k}:{escape:C||!1,scroll:N||!1,resize:I||!1,clickOutsideAnchor:Hn||!1};O&&(Object.assign(dn,{mouseover:!1,focus:!1,mouseenter:!1,click:!1,dblclick:!1,mousedown:!1}),Object.assign(pt,{mouseout:!1,blur:!1,mouseleave:!1,click:!1,dblclick:!1,mouseup:!1}),Object.assign(oe,{escape:!1,scroll:!1,resize:!1,clickOutsideAnchor:!1})),Tm((()=>(ft.current=!0,()=>{ft.current=!1})),[]);const he=j=>{ft.current&&(j&&nt(!0),setTimeout((()=>{ft.current&&(Ke?.(j),H===void 0&&an(j))}),10))};l.useEffect((()=>{if(t){if(de){R(rn);const E=j(V),U=[...new Set([...E,t])].filter(Boolean).join(" ");V?.setAttribute("aria-describedby",U)}else R(V);return()=>{R(V),R(rn)}}function j(E){var U;return((U=E?.getAttribute("aria-describedby"))===null||U===void 0?void 0:U.split(" "))||[]}function R(E){const U=j(E).filter((se=>se!==t));U.length?E?.setAttribute("aria-describedby",U.join(" ")):E?.removeAttribute("aria-describedby")}}),[V,de,t,rn]),l.useEffect((()=>{if(H===void 0)return()=>null;H&&nt(!0);const j=setTimeout((()=>{an(H)}),10);return()=>{clearTimeout(j)}}),[H]),l.useEffect((()=>{if(de!==Un.current)if(Se(Mt),Un.current=de,de)Ne?.();else{const j=(R=>{const E=R.match(/^([\d.]+)(ms|s)$/);if(!E)return 0;const[,U,se]=E;return Number(U)*(se==="ms"?1:1e3)})(getComputedStyle(document.body).getPropertyValue("--rt-transition-show-delay"));Mt.current=setTimeout((()=>{nt(!1),Ot(null),q?.()}),j+25)}}),[de]);const hn=j=>{Wn((R=>to(R,j)?R:j))},mn=(j=x)=>{Se(Le),Pt?he(!0):Le.current=setTimeout((()=>{he(!0)}),j)},Ft=(j=b)=>{Se(ht),ht.current=setTimeout((()=>{cn.current||he(!1)}),j)},fn=j=>{var R;if(!j)return;const E=(R=j.currentTarget)!==null&&R!==void 0?R:j.target;if(!E?.isConnected)return Tt(null),void ln({current:null});x?mn():he(!0),Tt(E),ln({current:E}),Se(ht)},Bt=()=>{y?Ft(b||100):b?Ft():he(!1),Se(Le)},qt=({x:j,y:R})=>{var E;const U={getBoundingClientRect:()=>({x:j,y:R,width:0,height:0,top:R,left:j,right:j,bottom:R})};br({place:(E=G?.place)!==null&&E!==void 0?E:c,offset:u,elementReference:U,tooltipReference:ue.current,tooltipArrowReference:It.current,strategy:d,middlewares:g,border:Fn,arrowSize:At}).then((se=>{hn(se)}))},Wt=j=>{if(!j)return;const R=j,E={x:R.clientX,y:R.clientY};qt(E),Dt.current=E},pn=j=>{var R;if(!de)return;const E=j.target;E.isConnected&&(!((R=ue.current)===null||R===void 0)&&R.contains(E)||[document.querySelector(`[id='${a}']`),...st].some((U=>U?.contains(E)))||(he(!1),Se(Le)))},Vn=yr(fn,50),X=yr(Bt,50),le=j=>{X.cancel(),Vn(j)},T=()=>{Vn.cancel(),X()},$=l.useCallback((()=>{var j,R;const E=(j=G?.position)!==null&&j!==void 0?j:ae;E?qt(E):v?Dt.current&&qt(Dt.current):V?.isConnected&&br({place:(R=G?.place)!==null&&R!==void 0?R:c,offset:u,elementReference:V,tooltipReference:ue.current,tooltipArrowReference:It.current,strategy:d,middlewares:g,border:Fn,arrowSize:At}).then((U=>{ft.current&&hn(U)}))}),[de,V,P,te,c,G?.place,u,d,ae,G?.position,v,At]);l.useEffect((()=>{var j,R;const E=new Set(zn);st.forEach((W=>{S?.(W)||E.add({current:W})}));const U=document.querySelector(`[id='${a}']`);U&&!S?.(U)&&E.add({current:U});const se=()=>{he(!1)},Oe=Cr(V),De=Cr(ue.current);oe.scroll&&(window.addEventListener("scroll",se),Oe?.addEventListener("scroll",se),De?.addEventListener("scroll",se));let ce=null;oe.resize?window.addEventListener("resize",se):V&&ue.current&&(ce=wm(V,ue.current,$,{ancestorResize:!0,elementResize:!0,layoutShift:!0}));const _e=W=>{W.key==="Escape"&&he(!1)};oe.escape&&window.addEventListener("keydown",_e),oe.clickOutsideAnchor&&window.addEventListener("click",pn);const K=[],Ut=W=>!!(W?.target&&V?.contains(W.target)),ci=W=>{de&&Ut(W)||fn(W)},ui=W=>{de&&Ut(W)&&Bt()},Mo=["mouseover","mouseout","mouseenter","mouseleave","focus","blur"],Po=["click","dblclick","mousedown","mouseup"];Object.entries(dn).forEach((([W,Qe])=>{Qe&&(Mo.includes(W)?K.push({event:W,listener:le}):Po.includes(W)&&K.push({event:W,listener:ci}))})),Object.entries(pt).forEach((([W,Qe])=>{Qe&&(Mo.includes(W)?K.push({event:W,listener:T}):Po.includes(W)&&K.push({event:W,listener:ui}))})),v&&K.push({event:"pointermove",listener:Wt});const Oo=()=>{cn.current=!0},Do=()=>{cn.current=!1,Bt()},$o=y&&(pt.mouseout||pt.mouseleave);return $o&&((j=ue.current)===null||j===void 0||j.addEventListener("mouseover",Oo),(R=ue.current)===null||R===void 0||R.addEventListener("mouseout",Do)),K.forEach((({event:W,listener:Qe})=>{E.forEach((Ts=>{var xn;(xn=Ts.current)===null||xn===void 0||xn.addEventListener(W,Qe)}))})),()=>{var W,Qe;oe.scroll&&(window.removeEventListener("scroll",se),Oe?.removeEventListener("scroll",se),De?.removeEventListener("scroll",se)),oe.resize?window.removeEventListener("resize",se):ce?.(),oe.clickOutsideAnchor&&window.removeEventListener("click",pn),oe.escape&&window.removeEventListener("keydown",_e),$o&&((W=ue.current)===null||W===void 0||W.removeEventListener("mouseover",Oo),(Qe=ue.current)===null||Qe===void 0||Qe.removeEventListener("mouseout",Do)),K.forEach((({event:Ts,listener:xn})=>{E.forEach((di=>{var As;(As=di.current)===null||As===void 0||As.removeEventListener(Ts,xn)}))}))}}),[V,$,Pt,zn,st,_,M,k,$t,x,b]),l.useEffect((()=>{var j,R;let E=(R=(j=G?.anchorSelect)!==null&&j!==void 0?j:i)!==null&&R!==void 0?R:"";!E&&t&&(E=`[data-tooltip-id='${t.replace(/'/g,"\\'")}']`);const U=new MutationObserver((se=>{const Oe=[],De=[];se.forEach((ce=>{if(ce.type==="attributes"&&ce.attributeName==="data-tooltip-id"&&(ce.target.getAttribute("data-tooltip-id")===t?Oe.push(ce.target):ce.oldValue===t&&De.push(ce.target)),ce.type==="childList"){if(V){const _e=[...ce.removedNodes].filter((K=>K.nodeType===1));if(E)try{De.push(..._e.filter((K=>K.matches(E)))),De.push(..._e.flatMap((K=>[...K.querySelectorAll(E)])))}catch{}_e.some((K=>{var Ut;return!!(!((Ut=K?.contains)===null||Ut===void 0)&&Ut.call(K,V))&&(nt(!1),he(!1),Tt(null),Se(Le),Se(ht),!0)}))}if(E)try{const _e=[...ce.addedNodes].filter((K=>K.nodeType===1));Oe.push(..._e.filter((K=>K.matches(E)))),Oe.push(..._e.flatMap((K=>[...K.querySelectorAll(E)])))}catch{}}})),(Oe.length||De.length)&&un((ce=>[...ce.filter((_e=>!De.includes(_e))),...Oe]))}));return U.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-tooltip-id"],attributeOldValue:!0}),()=>{U.disconnect()}}),[t,i,G?.anchorSelect,V]),l.useEffect((()=>{$()}),[$]),l.useEffect((()=>{if(!z?.current)return()=>null;const j=new ResizeObserver((()=>{setTimeout((()=>$()))}));return j.observe(z.current),()=>{j.disconnect()}}),[P,z?.current]),l.useEffect((()=>{var j;const R=document.querySelector(`[id='${a}']`),E=[...st,R];V&&E.includes(V)||Tt((j=st[0])!==null&&j!==void 0?j:R)}),[a,st,V]),l.useEffect((()=>(ie&&he(!0),()=>{Se(Le),Se(ht)})),[]),l.useEffect((()=>{var j;let R=(j=G?.anchorSelect)!==null&&j!==void 0?j:i;if(!R&&t&&(R=`[data-tooltip-id='${t.replace(/'/g,"\\'")}']`),R)try{const E=Array.from(document.querySelectorAll(R));un(E)}catch{un([])}}),[t,i,G?.anchorSelect]),l.useEffect((()=>{Le.current&&(Se(Le),mn(x))}),[x]);const xe=(dt=G?.content)!==null&&dt!==void 0?dt:P,xt=de&&Object.keys(mt.tooltipStyles).length>0;return l.useImperativeHandle(e,(()=>({open:j=>{if(j?.anchorSelect)try{document.querySelector(j.anchorSelect)}catch{return void console.warn(`[react-tooltip] "${j.anchorSelect}" is not a valid CSS selector`)}Ot(j??null),j?.delay?mn(j.delay):he(!0)},close:j=>{j?.delay?Ft(j.delay):he(!1)},activeAnchor:V,place:mt.place,isOpen:!!(Pt&&!w&&xe&&xt)}))),Pt&&!w&&xe?at.createElement(f,{id:t,role:Ls,className:eo("react-tooltip",Ht.tooltip,qs.tooltip,qs[r],n,`react-tooltip__place-${mt.place}`,Ht[xt?"show":"closing"],xt?"react-tooltip__show":"react-tooltip__closing",d==="fixed"&&Ht.fixed,y&&Ht.clickable),onTransitionEnd:j=>{Se(Mt),de||j.propertyName!=="opacity"||(nt(!1),Ot(null),q?.())},style:{...te,...mt.tooltipStyles,opacity:Bn!==void 0&&xt?Bn:void 0},ref:ue},xe,at.createElement(f,{className:eo("react-tooltip-arrow",Ht.arrow,qs.arrow,o,p&&Ht.noArrow),style:{...mt.tooltipArrowStyles,background:qn?`linear-gradient(to right bottom, transparent 50%, ${qn} 50%)`:void 0,"--rt-arrow-size":`${At}px`},ref:It})):null},Om=({content:e})=>at.createElement("span",{dangerouslySetInnerHTML:{__html:e}}),_n=at.forwardRef((({id:e,anchorId:t,anchorSelect:n,content:o,html:r,render:a,className:i,classNameArrow:c,variant:u="dark",place:h="top",offset:m=10,wrapper:d="div",children:g=null,events:f=["hover"],openOnClick:x=!1,positionStrategy:b="absolute",middlewares:v,delayShow:w=0,delayHide:p=0,float:y=!1,hidden:C=!1,noArrow:N=!1,clickable:I=!1,closeOnEsc:_=!1,closeOnScroll:M=!1,closeOnResize:k=!1,openEvents:O,closeEvents:te,globalCloseEvents:ae,imperativeModeOnly:Ne=!1,style:q,position:S,isOpen:P,defaultIsOpen:z=!1,disableStyleInjection:H=!1,border:ie,opacity:Ke,arrowColor:rn,arrowSize:V,setIsOpen:Tt,afterShow:Fn,afterHide:Bn,disableTooltip:qn,role:At="tooltip"},Ls)=>{const[dt,ue]=l.useState(o),[It,Le]=l.useState(r),[ht,Mt]=l.useState(h),[mt,Wn]=l.useState(u),[de,an]=l.useState(m),[Pt,nt]=l.useState(w),[G,Ot]=l.useState(p),[Un,Dt]=l.useState(y),[zn,ln]=l.useState(C),[cn,st]=l.useState(d),[un,ft]=l.useState(f),[$t,Hn]=l.useState(b),[dn,pt]=l.useState(null),[oe,he]=l.useState(null),hn=l.useRef(null),mn=l.useRef(H),{anchorRefs:Ft,activeAnchor:fn}=za(e),Bt=X=>X?.getAttributeNames().reduce(((le,T)=>{var $;return T.startsWith("data-tooltip-")&&(le[T.replace(/^data-tooltip-/,"")]=($=X?.getAttribute(T))!==null&&$!==void 0?$:null),le}),{}),qt=X=>{const le={place:T=>{var $;Mt(($=T)!==null&&$!==void 0?$:h)},content:T=>{ue(T??o)},html:T=>{Le(T??r)},variant:T=>{var $;Wn(($=T)!==null&&$!==void 0?$:u)},offset:T=>{an(T===null?m:Number(T))},wrapper:T=>{var $;st(($=T)!==null&&$!==void 0?$:d)},events:T=>{const $=T?.split(" ");ft($??f)},"position-strategy":T=>{var $;Hn(($=T)!==null&&$!==void 0?$:b)},"delay-show":T=>{nt(T===null?w:Number(T))},"delay-hide":T=>{Ot(T===null?p:Number(T))},float:T=>{Dt(T===null?y:T==="true")},hidden:T=>{ln(T===null?C:T==="true")},"class-name":T=>{pt(T)}};Object.values(le).forEach((T=>T(null))),Object.entries(X).forEach((([T,$])=>{var xe;(xe=le[T])===null||xe===void 0||xe.call(le,$)}))};l.useEffect((()=>{ue(o)}),[o]),l.useEffect((()=>{Le(r)}),[r]),l.useEffect((()=>{Mt(h)}),[h]),l.useEffect((()=>{Wn(u)}),[u]),l.useEffect((()=>{an(m)}),[m]),l.useEffect((()=>{nt(w)}),[w]),l.useEffect((()=>{Ot(p)}),[p]),l.useEffect((()=>{Dt(y)}),[y]),l.useEffect((()=>{ln(C)}),[C]),l.useEffect((()=>{Hn(b)}),[b]),l.useEffect((()=>{mn.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 X;const le=new Set(Ft);let T=n;if(!T&&e&&(T=`[data-tooltip-id='${e.replace(/'/g,"\\'")}']`),T)try{document.querySelectorAll(T).forEach((R=>{le.add({current:R})}))}catch{console.warn(`[react-tooltip] "${T}" is not a valid CSS selector`)}const $=document.querySelector(`[id='${t}']`);if($&&le.add({current:$}),!le.size)return()=>null;const xe=(X=oe??$)!==null&&X!==void 0?X:fn.current,xt=new MutationObserver((R=>{R.forEach((E=>{var U;if(!xe||E.type!=="attributes"||!(!((U=E.attributeName)===null||U===void 0)&&U.startsWith("data-tooltip-")))return;const se=Bt(xe);qt(se)}))})),j={attributes:!0,childList:!1,subtree:!1};if(xe){const R=Bt(xe);qt(R),xt.observe(xe,j)}return()=>{xt.disconnect()}}),[Ft,fn,oe,t,n]),l.useEffect((()=>{q?.border&&console.warn("[react-tooltip] Do not set `style.border`. Use `border` prop instead."),ie&&!vr("border",`${ie}`)&&console.warn(`[react-tooltip] "${ie}" is not a valid \`border\`.`),q?.opacity&&console.warn("[react-tooltip] Do not set `style.opacity`. Use `opacity` prop instead."),Ke&&!vr("opacity",`${Ke}`)&&console.warn(`[react-tooltip] "${Ke}" is not a valid \`opacity\`.`)}),[]);let Wt=g;const pn=l.useRef(null);if(a){const X=a({content:oe?.getAttribute("data-tooltip-content")||dt||null,activeAnchor:oe});Wt=X?at.createElement("div",{ref:pn,className:"react-tooltip-content-wrapper"},X):null}else dt&&(Wt=dt);It&&(Wt=at.createElement(Om,{content:It}));const Vn={forwardRef:Ls,id:e,anchorId:t,anchorSelect:n,className:eo(i,dn),classNameArrow:c,content:Wt,contentWrapperRef:pn,place:ht,variant:mt,offset:de,wrapper:cn,events:un,openOnClick:x,positionStrategy:$t,middlewares:v,delayShow:Pt,delayHide:G,float:Un,hidden:zn,noArrow:N,clickable:I,closeOnEsc:_,closeOnScroll:M,closeOnResize:k,openEvents:O,closeEvents:te,globalCloseEvents:ae,imperativeModeOnly:Ne,style:q,position:S,isOpen:P,defaultIsOpen:z,border:ie,opacity:Ke,arrowColor:rn,arrowSize:V,setIsOpen:Tt,afterShow:Fn,afterHide:Bn,disableTooltip:qn,activeAnchor:oe,previousActiveAnchor:hn.current,setActiveAnchor:X=>{he((le=>(X?.isSameNode(le)||(hn.current=le),X)))},role:At};return at.createElement(Pm,{...Vn})}));typeof window<"u"&&window.addEventListener("react-tooltip-inject-styles",(e=>{e.detail.disableCore||gr({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||gr({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"})),Ha=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})),Va=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"})),Dm=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})),$m=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"})),Fm=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"})),Ka=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"})),Bm=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{d:"M208 352h-64a96 96 0 010-192h64M304 160h64a96 96 0 010 192h-64M163.29 256h187.42",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:36})),Ro=()=>{const{pathname:e}=pe();return l.useMemo(()=>Gt({path:D.workbenchTab.path,end:!1},e)?.params.id,[e])},qm=()=>{const e=Ro(),t=ha();return{rename:async o=>{if(e){const r=await Pn("New tab name",o);r&&await t.mutateAsync({id:e,payload:{name:r}})}return Promise.resolve()}}},Qa=["shift","alt","meta","mod","ctrl","control"],Wm={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 lt(e){return(Wm[e.trim()]||e.trim()).toLowerCase().replace(/key|digit|numpad/,"")}function Ga(e){return Qa.includes(e)}function Ws(e,t=","){return e.toLowerCase().split(t)}function Us(e,t="+",n=">",o=!1,r){let a=[],i=!1;e=e.trim(),e.includes(n)?(i=!0,a=e.toLocaleLowerCase().split(n).map(h=>lt(h))):a=e.toLocaleLowerCase().split(t).map(h=>lt(h));const c={alt:a.includes("alt"),ctrl:a.includes("ctrl")||a.includes("control"),shift:a.includes("shift"),meta:a.includes("meta"),mod:a.includes("mod"),useKey:o},u=a.filter(h=>!Qa.includes(h));return{...c,keys:u,description:r,isSequence:i,hotkey:e}}typeof document<"u"&&(document.addEventListener("keydown",e=>{e.code!==void 0&&Ya([lt(e.code)])}),document.addEventListener("keyup",e=>{e.code!==void 0&&Ja([lt(e.code)])})),typeof window<"u"&&(window.addEventListener("blur",()=>{Ye.clear()}),window.addEventListener("contextmenu",()=>{setTimeout(()=>{Ye.clear()},0)}));const Ye=new Set;function Lo(e){return Array.isArray(e)}function Um(e,t=","){return(Lo(e)?e:e.split(t)).every(n=>Ye.has(n.trim().toLowerCase()))}function Ya(e){const t=Array.isArray(e)?e:[e];Ye.has("meta")&&Ye.forEach(n=>!Ga(n)&&Ye.delete(n.toLowerCase())),t.forEach(n=>Ye.add(n.toLowerCase()))}function Ja(e){const t=Array.isArray(e)?e:[e];e==="meta"?Ye.clear():t.forEach(n=>Ye.delete(n.toLowerCase()))}function zm(e,t,n){(typeof n=="function"&&n(e,t)||n===!0)&&e.preventDefault()}function Hm(e,t,n){return typeof n=="function"?n(e,t):n===!0||n===void 0}const Vm=["input","textarea","select","searchbox","slider","spinbutton","menuitem","menuitemcheckbox","menuitemradio","option","radio","textbox"];function Km(e){return Xa(e,Vm)}function Xa(e,t=!1){const{target:n,composed:o}=e;let r,a;return Qm(n)&&o?(r=e.composedPath()[0]&&e.composedPath()[0].tagName,a=e.composedPath()[0]&&e.composedPath()[0].role):(r=n&&n.tagName,a=n&&n.role),Lo(t)?!!(r&&t&&t.some(i=>i.toLowerCase()===r.toLowerCase()||i===a)):!!(r&&t&&t)}function Qm(e){return!!e.tagName&&!e.tagName.startsWith("-")&&e.tagName.includes("-")}function Gm(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 Ym=(e,t,n=!1)=>{const{alt:o,meta:r,mod:a,shift:i,ctrl:c,keys:u,useKey:h}=t,{code:m,key:d,ctrlKey:g,metaKey:f,shiftKey:x,altKey:b}=e,v=lt(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!==b&&v!=="alt"||i!==x&&v!=="shift")return!1;if(a){if(!f&&!g)return!1}else if(r!==f&&v!=="meta"&&v!=="os"||c!==g&&v!=="ctrl"&&v!=="control")return!1}return u&&u.length===1&&u.includes(v)?!0:u?Um(u):!u},Jm=l.createContext(void 0),Xm=()=>l.useContext(Jm);function Za(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&&Za(e[o],t[o]),!0):e===t}const Zm=l.createContext({hotkeys:[],activeScopes:[],toggleScope:()=>{},enableScope:()=>{},disableScope:()=>{}}),ef=()=>l.useContext(Zm);function tf(e){const t=l.useRef(void 0);return Za(t.current,e)||(t.current=e),t.current}const jr=e=>{e.stopPropagation(),e.preventDefault(),e.stopImmediatePropagation()},nf=typeof window<"u"?l.useLayoutEffect:l.useEffect;function We(e,t,n,o){const r=l.useRef(null),a=l.useRef(!1),i=Array.isArray(n)?Array.isArray(o)?void 0:o:n,c=Lo(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=tf(i),{activeScopes:g}=ef(),f=Xm();return nf(()=>{if(d?.enabled===!1||!Gm(g,d?.scopes))return;let x=[],b;const v=(C,N=!1)=>{if(!(Km(C)&&!Xa(C,d?.enableOnFormTags))){if(r.current!==null){const I=r.current.getRootNode();if((I instanceof Document||I instanceof ShadowRoot)&&I.activeElement!==r.current&&!r.current.contains(I.activeElement)){jr(C);return}}C.target?.isContentEditable&&!d?.enableOnContentEditable||Ws(c,d?.delimiter).forEach(I=>{if(I.includes(d?.splitKey??"+")&&I.includes(d?.sequenceSplitKey??">")){console.warn(`Hotkey ${I} contains both ${d?.splitKey??"+"} and ${d?.sequenceSplitKey??">"} which is not supported.`);return}const _=Us(I,d?.splitKey,d?.sequenceSplitKey,d?.useKey,d?.description);if(_.isSequence){b=setTimeout(()=>{x=[]},d?.sequenceTimeoutMs??1e3);const M=_.useKey?C.key:lt(C.code);if(Ga(M.toLowerCase()))return;x.push(M);const k=_.keys?.[x.length-1];if(M!==k){x=[],b&&clearTimeout(b);return}x.length===_.keys?.length&&(m.current(C,_),b&&clearTimeout(b),x=[])}else if(Ym(C,_,d?.ignoreModifiers)||_.keys?.includes("*")){if(d?.ignoreEventWhen?.(C)||N&&a.current)return;if(zm(C,_,d?.preventDefault),!Hm(C,_,d?.enabled)){jr(C);return}m.current(C,_),N||(a.current=!0)}})}},w=C=>{C.code!==void 0&&(Ya(lt(C.code)),(d?.keydown===void 0&&d?.keyup!==!0||d?.keydown)&&v(C))},p=C=>{C.code!==void 0&&(Ja(lt(C.code)),a.current=!1,d?.keyup&&v(C,!0))},y=r.current||i?.document||document;return y.addEventListener("keyup",p,i?.eventListenerOptions),y.addEventListener("keydown",w,i?.eventListenerOptions),f&&Ws(c,d?.delimiter).forEach(C=>f.addHotkey(Us(C,d?.splitKey,d?.sequenceSplitKey,d?.useKey,d?.description))),()=>{y.removeEventListener("keyup",p,i?.eventListenerOptions),y.removeEventListener("keydown",w,i?.eventListenerOptions),f&&Ws(c,d?.delimiter).forEach(C=>f.removeHotkey(Us(C,d?.splitKey,d?.sequenceSplitKey,d?.useKey,d?.description))),x=[],b&&clearTimeout(b)}},[c,d,g]),r}function sf(){return s.jsxs("div",{className:"flex md:grid md:grid-cols-3 items-center bg-white overflow-auto no-scrollbar",children:[s.jsx(of,{}),s.jsx(rf,{}),s.jsx(cf,{})]})}function of(){const{dataSourceId:e}=l.useContext(Pe),{data:t}=xs(e),{state:{table:n}}=l.useContext(je);return s.jsx("div",{className:L.tableConfig,children:t&&s.jsxs("div",{className:A(L.tableAction,L.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 rf(){const{page:e,size:t,setPage:n}=Aa(),{data:o,isFetching:r}=l.useContext(tt),a=e*t,i=!r&&!!o?.result.hasMore,c=o?.result.rows.length||0,u=()=>{e>0&&n(e-1)},h=()=>{i&&n(e+1)};return s.jsxs("div",{className:A(L.tableConfig,"justify-self-center"),children:[s.jsx("span",{"data-tooltip-content":"Previous page","data-tooltip-id":"default",className:A(L.tableAction,L.gray,e<1&&"opacity-30"),onClick:u,role:"button",children:s.jsx(Sn,{width:16,height:16,className:"rotate-180"})}),s.jsxs("span",{"data-tooltip-id":"rows-num",className:L.paginationIndicator,children:[a+1," - ",a+c,i&&"+"]}),s.jsx("span",{"data-tooltip-content":"Next page","data-tooltip-id":"default",className:A(L.tableAction,i?L.gray:"opacity-30"),onClick:h,role:"button",children:s.jsx(Sn,{width:16,height:16})})]})}const af=[5,10,20,50,100,200],lf=!__CLIENT_CONFIG__.skipAuth;function cf(){const{dataSourceId:e,name:t}=l.useContext(Pe),{data:n}=xs(e),{data:o,refetch:r}=l.useContext(tt),a=An(me.EDITOR),i=Lh(),{rename:c}=qm(),{size:u,setSize:h}=Aa(),{state:m}=l.useContext(je),d=Lt(),g=ee(),f=()=>{d.mutateAsync({name:t,opts:m}).then(p=>{g(D.workbenchTab.build({id:p.id}))})},x=()=>{if(o?.result.queryHistoryId){const p=new URL(window.location.href);p.pathname=D.share.build(),p.searchParams.set("shareId",o.result.queryHistoryId),navigator.clipboard.writeText(p.toString()),fe.success("Share link copied to clipboard")}},b=()=>{m.table&&fh({table:m.table,dataSourceId:e})},v=async()=>{const p=await Pn("Query name",t);!p||!o?.result.queryHistoryId||i.mutate({name:p,queryId:o.result.queryHistoryId})},w=()=>c(t);return We("s",v),We("r",w),We("d",f),s.jsxs("div",{className:"flex justify-self-end",children:[s.jsx("span",{"data-tooltip-content":"Show filters","data-tooltip-id":"default",className:A(L.tableAction,L.gray),onClick:()=>Be("filters"),role:"button",children:s.jsx(Fm,{width:16,height:16})}),s.jsx("span",{"data-tooltip-content":"Join table","data-tooltip-id":"default",className:A(L.tableAction,L.gray),onClick:()=>Be("joins"),role:"button",children:s.jsx(Bm,{width:16,height:16})}),s.jsx("span",{"data-tooltip-content":"Refresh data","data-tooltip-id":"default",className:A(L.tableAction,L.gray),onClick:()=>r(),role:"button",children:s.jsx(Va,{width:16,height:16})}),lf&&s.jsx("span",{"data-tooltip-content":"Share query","data-tooltip-id":"default",className:A(L.tableAction,L.gray),onClick:x,role:"button",children:s.jsx($m,{width:16,height:16})}),s.jsx("span",{"data-tooltip-content":"Duplicate tab","data-tooltip-id":"default",className:A(L.tableAction,L.gray),onClick:f,role:"button",children:s.jsx(Dm,{width:16,height:16})}),n?.allowInsert===!0&&s.jsx("span",{"data-tooltip-content":"Insert new record","data-tooltip-id":"default",className:A(L.tableAction,L.gray),onClick:b,role:"button",children:s.jsx(Ka,{width:16,height:16})}),s.jsx(_n,{id:"rows-num",className:"z-10 shadow-md flex gap-1",clickable:!0,variant:"light",opacity:1,children:af.map(p=>s.jsx("button",{onClick:()=>h(p,!0),className:A(L.tableAction,L.gray,p===u&&L.selectedSize),children:s.jsx("span",{children:p})},p))}),s.jsx("button",{"data-tooltip-id":"explorer-more-actions",className:A(L.tableAction,L.gray),children:s.jsx(Ha,{width:16,height:16})}),s.jsxs(_n,{id:"explorer-more-actions",className:"z-10 shadow-md flex flex-col",clickable:!0,variant:"light",opacity:1,children:[s.jsxs("button",{onClick:()=>Be("columns"),className:A(L.tableAction,L.modal,L.gray,"justify-between"),children:[s.jsx("span",{children:"Columns"}),s.jsx("span",{className:"hotkey",children:"C"})]}),s.jsxs("button",{onClick:()=>Be("groupBy"),className:A(L.tableAction,L.modal,L.gray,"justify-between"),children:[s.jsx("span",{children:"Group by"}),s.jsx("span",{className:"hotkey",children:"G"})]}),s.jsxs("button",{onClick:()=>Be("aggregate"),className:A(L.tableAction,L.modal,L.gray,"justify-between"),children:[s.jsx("span",{children:"Aggregate"}),s.jsx("span",{className:"hotkey",children:"A"})]}),s.jsx("div",{className:"h-0.5 my-2 bg-gray-100"}),s.jsxs("button",{onClick:w,className:A(L.tableAction,L.modal,L.gray,"justify-between"),children:[s.jsx("span",{children:"Rename tab"}),s.jsx("span",{className:"hotkey",children:"R"})]}),a&&s.jsx(s.Fragment,{children:s.jsxs("button",{onClick:v,className:A(L.tableAction,L.modal,L.gray),children:[s.jsx("span",{children:"Save query"}),s.jsx("span",{className:"hotkey",children:"S"})]})})]})]})}const uf="_drop-container_enkea_2",df="_item_enkea_2",Nr={dropContainer:uf,item:df},ei=({dataSourceId:e,inputClassName:t,focusId:n,placeholder:o="Column",onChange:r,value:a,autoFocus:i,allowTables:c})=>{const{data:u}=gs(e),h=l.useRef(null),m=l.useMemo(()=>{if(!u)return[];let p=u;return c&&(p=u.filter(y=>c.includes(y.tableName))),p.flatMap(y=>y.columns.map(C=>({value:y.tableName+"."+C.name,label:C.name,table:y.tableName,searchValue:C.name.toLowerCase()})))},[u,c]),d=l.useMemo(()=>{const p=a.toLowerCase()||"",y=[];for(let C=0;C<m.length&&y.length<10;C++)m[C].searchValue.includes(p)&&y.push(m[C]);return y},[m,a]),[g,f]=l.useState(!1),[x,b]=l.useState(0),v=p=>{if(p.key==="ArrowDown")p.preventDefault(),b(y=>(y+1)%d.length);else if(p.key==="ArrowUp")p.preventDefault(),b(y=>(y-1+d.length)%d.length);else if(p.key==="Enter"&&x>=0&&x<d.length){p.preventDefault();const y=d[x].value;f(!1);const C=m.findIndex(N=>N.value===y)>-1;r(d[x]?.value||y,C,!0)}};l.useEffect(()=>{const p=h.current?.querySelector('[data-is-active="true"]');p&&p.scrollIntoView({behavior:"smooth",block:"nearest"})},[x]);const w=p=>{const y=p.currentTarget.value,C=m.findIndex(N=>N.value===y)>-1;r(y,C,!1)};return s.jsxs("div",{className:"relative",onFocus:()=>f(!0),onBlur:()=>f(!1),children:[s.jsx("input",{autoFocus:i,onKeyDown:v,value:a,onChange:w,className:t,placeholder:o,"data-focus":n}),g&&d.length>0&&s.jsx("div",{className:Nr.dropContainer,ref:h,tabIndex:-1,children:d.map((p,y)=>s.jsxs("div",{className:Nr.item,"data-is-active":x===y,onMouseDownCapture:C=>{C.preventDefault(),f(!1),r(p.value,!0,!0)},children:[s.jsx("span",{className:"text-xs font-semibold truncate",children:p.table}),s.jsx("p",{className:"truncate text-sm",children:p.label})]},y))})]})},hf="_actions_152yu_2",mf="_filter-actions_152yu_2",ff="_filters-container_152yu_2",pf="_filter-container_152yu_2",cs={actions:hf,filterActions:mf,filtersContainer:ff,filterContainer:pf},xf=({filter:e,dataSourceId:t,allowedTables:n,autoFocus:o,onChangeColumn:r,onChangeValue:a,onRemoveFilter:i,triggerIsEnabled:c,onSubmit:u})=>{const h=m=>{m.key==="Enter"&&u()};return s.jsxs("div",{className:cs.filterContainer,children:[s.jsx("input",{className:"mr-1",type:"checkbox",checked:e.isEnabled!==!1,onClick:()=>c(e.id)}),s.jsx(ei,{dataSourceId:t,onChange:m=>r(e.id,m),value:e.column,allowTables:n,focusId:"column",inputClassName:"input w-full",autoFocus:o}),s.jsx(Cs,{prefix:"_",allowedModes:js,onExpressionChange:m=>a(e.id,m),onKeyDown:h,placeholder:"Filter value",value:e.value,mode:e.mode,className:"h-8"}),s.jsx("div",{className:cs.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(Ze,{width:20,height:20,className:"text-red-600"})})})]})},gf=()=>{const{state:e}=l.useContext(je),{refetch:t}=l.useContext(tt),{setFilters:n}=bo(),o=Ns(x=>x.filters),r=l.useMemo(()=>[e.table,...e.joins.map(x=>x.table)],[e.table,e.joins]),[a,i]=l.useState([]),c=(x,b)=>{i(v=>[...v.map(w=>w.id===x?{...w,column:b}:w)])},u=(x,b)=>{i(v=>[...v.map(w=>w.id===x?{...w,value:b.value,mode:b.mode}:w)])},h=()=>{i(x=>[...x,{id:et(),value:"",column:"",isEnabled:!0,mode:"default"}])},m=x=>{i(b=>b.filter(v=>v.id!==x))},d=()=>_s("filters"),g=()=>{try{n(a.filter(x=>x.value.length>0&&x.column.length>0)),setTimeout(t,1),d()}catch(x){x instanceof Error?fe.error(x.message):fe.error("Error during parsing, check you filters")}},f=x=>{i(b=>b.map(v=>v.id===x?{...v,isEnabled:!v.isEnabled}:v))};return l.useEffect(()=>{o&&i(()=>[...e.filters,{id:et(),value:"",column:"",isEnabled:!0,mode:"default"}])},[o]),We("f",()=>{rs("filters")}),s.jsxs(Me,{isVisible:o,onClose:d,portal:!0,onClosed:()=>i([]),noPadding:!0,backdropClose:!0,children:[s.jsx(nn,{onClick:d}),s.jsx("h2",{className:"text-lg font-semibold m-2",children:"Filters"}),s.jsxs("div",{className:cs.filtersContainer,children:[a.length<1&&s.jsx("p",{className:"p-1 text-center rounded-lg bg-gray-50 border border-gray-200",children:"No filters"}),a.map((x,b)=>s.jsx(xf,{filter:x,dataSourceId:e.dataSourceId,allowedTables:r,onChangeColumn:c,onChangeValue:u,onRemoveFilter:m,triggerIsEnabled:f,onSubmit:g,autoFocus:b===a.length-1},x.id))]}),s.jsxs("div",{className:cs.actions,children:[s.jsxs("button",{className:"button tertiary flex items-center gap-1 text-sm",onClick:h,children:[s.jsx(Ka,{width:20,height:20}),s.jsx("span",{children:"Add filter"})]}),s.jsx("button",{className:"button primary text-sm",onClick:g,children:"Apply filters"})]})]})},bf="_join-modal_ux7d0_2",vf={joinModal:bf},yf=(e,t)=>e.type!==t.type||e.on!==t.on||e.table!==t.table,wf=(e,t)=>e.type===t.type&&e.on===t.on&&e.table===t.table,ti=()=>{const{state:e,setState:t}=l.useContext(je),n=l.useCallback(o=>{t(r=>{const a=r.joins;if(a.some(c=>wf(c,o))){const c=o.table+".";return{...r,joins:a.filter(u=>yf(u,o)),columns:r.columns.filter(u=>!u.value.startsWith(c)),groupBy:r.groupBy.filter(u=>!u.value.startsWith(c)),orderBy:r.orderBy.filter(u=>!u.column.startsWith(c)),aggregations:r.aggregations.filter(u=>!u.value.startsWith(c)),filters:r.filters.filter(u=>!u.column.startsWith(c))}}return{...r,joins:[...a,o]}})},[t]);return{joins:e.joins,toggle:n}},Cf=()=>{const{isFetching:e}=l.useContext(tt),t=Ns(u=>u.joins),{toggle:n}=ti(),{availableJoins:o}=l.useContext(Pe),[r,a]=l.useState(""),i=l.useMemo(()=>{const u=r.toLowerCase();return o.filter(h=>h.fromTable.toLowerCase().includes(u))},[o,r]),c=()=>_s("joins");return We("j",()=>{o.length>0?Be("joins"):fe.error("No available tables to join")}),s.jsxs(Me,{isVisible:t,onClose:c,portal:!0,backdropClose:!0,children:[s.jsx(nn,{onClick:c}),s.jsxs("div",{className:vf.joinModal,children:[s.jsx("h2",{className:"text-lg font-semibold mb-4",children:"Join table"}),o.length>0?s.jsx("input",{className:"input w-full",placeholder:"Filter",autoFocus:!0,onChange:u=>a(u.target.value),value:r,disabled:e}):s.jsx(ge,{variant:"warning",children:s.jsx("p",{className:"text-sm truncate",children:"There is nothing else to join"})}),s.jsx("div",{className:`flex flex-col mt-2 overflow-y-auto ${e?"opacity-40":""}`,children:i.map(u=>s.jsx(go,{hook:u,onClick:()=>{e||(n({table:u.direction==="in"?u.fromTable:u.toTable,type:"LEFT",on:eu(u)}),a(""),c())}},u.id))})]})]})};function jf(e){return e.reduce((t,n)=>(t[n]=!0,t),{})}function _r(e){return e.reduce((t,n)=>(t[n]=!0,t),{})}const Nf="_container_sluxh_2",_f="_column-label_sluxh_2",Sf="_not-active_sluxh_2",ns={container:Nf,columnLabel:_f,notActive:Sf};function kf(e){if(!e)return[];const t={};return e.forEach(n=>{t[n.table]?t[n.table].push({value:n.full,ogColumn:n.column,label:Gn(n.column),type:n.type}):t[n.table]=[{value:n.full,ogColumn:n.column,label:Gn(n.column),type:n.type}],Xc[n.type]&&["YEAR","MONTH","DAY"].forEach(o=>{t[n.table].push({value:o+" "+n.full,ogColumn:n.column,label:o+" "+Gn(n.column),type:"number",nested:!0})})}),Object.entries(t).reduce((n,[o,r])=>(n.push({name:Gn(o),columns:r}),n),[])}function Ef(e,t){const n=t.toLowerCase();return e.map(o=>{const r=o.columns.filter(a=>a.label.toLowerCase().includes(n)||a.ogColumn.toLowerCase().includes(n));return{...o,columns:r}}).filter(o=>o.columns.length>0)}const Rf=({column:e,selected:t,onCheck:n})=>s.jsxs("label",{className:A(ns.columnLabel,t?ns.active:ns.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),Lf={columns:"c",groupBy:"g"},Sr=({mode:e})=>{const t=Ns(p=>p[e]),{allColumns:n}=l.useContext(Pe),{state:o,setState:r}=l.useContext(je),[a,i]=l.useState({}),[c,u]=l.useState(""),h=l.useMemo(()=>kf(n),[n]),m=o.aggregations.length>0||o.groupBy.length>0,d=l.useMemo(()=>c?Ef(h,c):h,[c,h]),g=p=>{i(y=>({...y,[p.target.name]:p.target.checked}))},f=p=>{const y=p.target.checked;i(C=>{for(const N of n)C[N.full]=y;return{...C}})},x=()=>{_s(e)},b=()=>{const p=[];for(const[y,C]of Object.entries(a))if(C){const[N,I]=y.split(" ");p.push({value:I||N,fn:I?N:void 0})}r(y=>({...y,[e]:p})),x()},v=l.useMemo(()=>{for(const p of n)if(!a[p.full])return!1;return!0},[a,n]);We(Lf[e],()=>{e==="columns"?m?fe.error("Columns are ignored when there is at least one aggregation or group by"):rs("columns"):rs("groupBy")}),l.useEffect(()=>{t&&i(()=>jf(o[e].map(p=>p.fn?p.fn+" "+p.value:p.value)))},[t,i]);const w=()=>{u(""),i({})};return s.jsxs(Me,{isVisible:t,onClose:x,portal:!0,onClosed:w,backdropClose:!0,children:[s.jsx(nn,{onClick:x}),s.jsxs("div",{className:ns.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:p=>u(p.target.value)}),s.jsx("div",{className:"overflow-y-auto",children:d.map(p=>s.jsxs("div",{className:"my-2",children:[s.jsxs("p",{className:"font-semibold sticky top-0 bg-white p-1 z-1",children:["📄 ",p.name]}),p.columns.map(y=>s.jsx(Rf,{column:y,selected:a,onCheck:g},y.value))]},p.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:f}),s.jsx("span",{children:"Select all"})]}),s.jsx("span",{className:"flex-1"}),s.jsx("button",{className:"button tertiary",onClick:x,children:"Cancel"}),s.jsx("button",{className:"button primary",onClick:b,children:"Apply"})]})]})]})},Tf="_options-container_vmmph_2",Af={optionsContainer:Tf},zs="COUNT all",If=()=>{const e=Ns(x=>x.aggregate),{dataSourceId:t}=l.useContext(Pe),{setState:n,state:o}=l.useContext(je),{data:r}=l.useContext(tt),[a,i]=l.useState({fn:"",col:""}),c=x=>i({...a,fn:x.currentTarget.value}),u=x=>i({...a,col:x}),h=()=>_s("aggregate"),m=()=>{const x=a.fn===zs?{value:"*",fn:"COUNT"}:{fn:a.fn,value:a.col,distinct:a.fn==="COUNT"};n(b=>({...b,aggregations:[...b.aggregations,x]}))},d=a.fn===zs,g=d?!1:!a.col||!a.fn,f=x=>{const b=Zc(x);n(v=>({...v,aggregations:v.aggregations.filter(w=>w.fn!==x.fn||w.value!==x.value),orderBy:v.orderBy.filter(w=>w.column!==b)}))};return We("a",()=>{rs("aggregate")}),s.jsxs(Me,{isVisible:e,onClose:h,backdropClose:!0,portal:!0,children:[s.jsx(nn,{onClick:h}),s.jsxs("div",{children:[s.jsx("h2",{className:"text-lg font-semibold",children:"Aggregate"}),ve(o.aggregations.length,0)&&s.jsx("div",{className:"flex flex-col gap-1 mt-4",children:o.aggregations.map((x,b)=>s.jsxs("p",{className:"p-2 rounded-md bg-gray-50 flex items-center justify-between",children:[s.jsx("span",{children:ts(x)}),s.jsx("button",{tabIndex:-1,"data-tooltip-id":"default","data-tooltip-content":"Remove aggregation",className:"p-0.5 text-sm cursor-pointer",onClick:()=>f(x),children:s.jsx(Ze,{width:20,height:20,className:"text-red-600"})})]},b))}),s.jsxs("div",{className:Af.optionsContainer,children:[s.jsxs("label",{className:A(d&&"col-span-2"),children:[s.jsx("p",{className:"font-semibold text-xs",children:"Function"}),s.jsxs("select",{className:"input w-full",value:a.fn,onChange:c,autoFocus:!0,children:[s.jsx("option",{value:"",disabled:!0,children:"Select function"}),s.jsx("option",{value:zs,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(ei,{inputClassName:"input w-full",dataSourceId:t,allowTables:r?.result.tables||[],onChange:u,value:a.col})]}),s.jsx("button",{className:"button primary",disabled:g,onClick:m,children:"Add"})]})]})]})},Mf="_container_hjlb6_2",Pf="_yellow-pill_hjlb6_2 _pill_hjlb6_2",Of="_blue-pill_hjlb6_2 _pill_hjlb6_2",Df="_purple-pill_hjlb6_2 _pill_hjlb6_2",$f="_red-pill_hjlb6_2 _pill_hjlb6_2",Ff="_black-pill_hjlb6_2 _pill_hjlb6_2",Bf="_disabled-pill_hjlb6_2",yt={container:Mf,yellowPill:Pf,bluePill:Of,purplePill:Df,redPill:$f,blackPill:Ff,disabledPill:Bf};function qf(e){return!(e===!0||e===void 0)}const Wf=()=>{const{state:{aggregations:e,columns:t,groupBy:n}}=l.useContext(je),{toggle:o,joins:r}=ti(),{filters:a,setFilters:i,removeFilter:c}=bo(),u=()=>Be("joins"),h=()=>Be("aggregate"),m=()=>Be("columns"),d=()=>Be("groupBy"),g=b=>{b.preventDefault(),b.stopPropagation(),o(r[r.length-1])},f=b=>{i(a.map(v=>({...v,isEnabled:b===v.id?qf(v.isEnabled):v.isEnabled})),!0)},x=b=>v=>{v.preventDefault(),v.stopPropagation(),c(b)};return a.length>0||r.length>0||n.length>0||t.length>0||e.length>0?s.jsxs("div",{className:yt.container,children:[r.map((b,v)=>s.jsxs("button",{onClick:u,className:yt.yellowPill,"data-tooltip-id":"default","data-tooltip-content":`Joins ${b.table} on ${b.on}`,children:[s.jsx("p",{className:"text-sm",children:b.table}),v===r.length-1&&s.jsx(Ze,{onClick:g,width:18,height:18})]},b.table)),a.map(b=>s.jsxs("button",{onClick:()=>f(b.id),onAuxClick:()=>c(b.id),className:A(yt.bluePill,b.isEnabled===!1&&yt.disabledPill),"data-tooltip-id":"default","data-tooltip-content":`${b.column} ${b.value}`,children:[s.jsx("p",{className:"text-sm",children:b.column}),s.jsx("p",{className:"text-sm",children:b.value}),s.jsx(Ze,{onClick:x(b.id),width:18,height:18})]},b.id)),e.map(b=>s.jsx("button",{onClick:h,className:A(yt.purplePill),"data-tooltip-id":"default","data-tooltip-content":ts(b),children:s.jsx("p",{className:"text-sm",children:ts(b)})},ts(b))),t.length>0&&s.jsx("button",{onClick:m,className:A(yt.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:A(yt.blackPill),"data-tooltip-id":"default","data-tooltip-content":"Has GROUP BY",children:s.jsx("p",{className:"text-sm",children:"Grouped columns"})})]}):null},Uf=({options:e,updater:t,name:n,tabId:o})=>{const r=Mc(e,t),a=zc(o,r.state),i=Ic(a.data,r.state.dataSourceId,n,o);return s.jsx(Pe,{value:i,children:s.jsx(je,{value:r,children:s.jsxs(tt,{value:a,children:[s.jsx(sf,{}),s.jsx(Wf,{}),s.jsxs("div",{className:"flex-1 flex overflow-hidden border-t border-t-gray-200",children:[s.jsx("div",{className:"flex-1 overflow-auto pb-24 lg:pb-12 no-scrollbar",children:s.jsx(Rh,{})}),s.jsx(gf,{}),s.jsx(Cf,{}),s.jsx(Sr,{mode:"columns"}),s.jsx(Sr,{mode:"groupBy"}),s.jsx(If,{})]})]})})})},To=({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..."})]}),zf=({id:e})=>{const{data:t}=Wc(e),n=l.useCallback(o=>{if(!t)return;const r=o(kt(t.opts));J.setQueryData(["workbench-tabs",t.id],{...t,opts:{...t.opts,...r}})},[t]);return t?s.jsx(Uf,{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(To,{})})},kr=e=>{setTimeout(t=>{const n=document.querySelector(`[data-tab-id="${t}"]`);n&&n.scrollIntoView({behavior:"smooth"})},50,e)},Hf=()=>{const{data:e}=ys(),t=Uc();return{workbenchTabs:e,archive:(o,r,a={})=>{t.mutate({tabId:o,...a});const i=e?.find(h=>h.id===r),c=e?.find(h=>h.id===o);let u;if(e&&i&&c){let h;if(a.all)h=[];else if(a.others)h=e.filter(m=>m.id===o),r!==o&&(u=o);else{const m=e.findIndex(d=>d.id===r);h=e.filter(d=>d.id!==o),h.length>m?u=h[m]?.id:h.length>0&&(u=h[h.length-1].id)}vs(()=>h),h.length===0&&(u="home")}return u}}},Vf=()=>{const e=ha();return{rename:async(n,o)=>{if(o){const r=await Pn("New tab name",n);r&&await e.mutateAsync({id:o,payload:{name:r}})}return Promise.resolve()}}},Kf=()=>{const{id:e}=al(),t=ee(),{workbenchTabs:n,archive:o}=Hf(),{rename:r}=Vf(),[a,i]=l.useState(void 0),c=l.useRef(null),u=ja(po.laptop),h=(f,x={})=>{c.current?.close();const b=o(f,e||"",x);b&&(b==="home"?t(D.home.build(),{replace:!0}):(kr(b),t(D.workbenchTab.build({id:b}),{replace:!0})))},m=f=>{f.stopPropagation(),f.preventDefault();const x=f.currentTarget.getAttribute("data-tab-id");x&&h(x)},d=f=>{const x=f.currentTarget.getAttribute("data-tab-id");x&&c.current&&(f.preventDefault(),f.stopPropagation(),i(x),c.current.open(f))},g=f=>{const x=n?.find(b=>b.id===f);x&&(c.current?.close(),r(x.name,f))};return l.useEffect(()=>{e&&kr(e)},[e,n]),s.jsxs("div",{className:"h-screen max-h-screen bg-(--bg) flex flex-col",children:[e?s.jsx(zf,{id:e}):s.jsx("div",{className:"flex-1"}),ve(n?.length,0)&&s.jsxs("div",{className:A($e.tabs,"no-scrollbar",!u&&$e.mobile),children:[s.jsx(vo,{ref:c,onClosed:()=>i(void 0),children:a&&s.jsxs("div",{className:$e.menu,children:[s.jsx("button",{className:$e.item,onClick:()=>g(a),children:"Rename"}),s.jsx("button",{className:$e.item,onClick:()=>h(a),children:"Close"}),s.jsx("div",{className:"border-t border-gray-200 my-1"}),s.jsx("button",{className:$e.item,onClick:()=>h(a,{others:!0}),children:"Close other tabs"}),s.jsx("button",{className:$e.item,onClick:()=>h(a,{all:!0}),children:"Close all tabs"})]})}),n?.map(f=>s.jsxs("div",{onClick:()=>t(D.workbenchTab.build({id:f.id})),className:A($e.tab,f.id===e&&$e.active),"data-tooltip-id":"default","data-tab-id":f.id,"data-tooltip-content":f.name,onAuxClick:()=>h(f.id),onContextMenu:d,children:[s.jsx("span",{className:"truncate w-full",children:f.name}),s.jsx("button",{"data-tab-id":f.id,className:$e.closeButton,onClick:m,children:s.jsx(Ze,{width:20,height:20})})]},f.id))]})]})},Qf="_root_1bsgo_2",Gf="_up_1bsgo_2",Yf="_down_1bsgo_2",Jf="_chevron_1bsgo_2",Xf="_table-name-container_1bsgo_2",Zf="_link_1bsgo_2",e0="_table-name_1bsgo_2",t0="_ul_1bsgo_2",n0="_column-type_1bsgo_2",s0="_action-blue_1bsgo_2 _action_1bsgo_2",o0="_action-red_1bsgo_2 _action_1bsgo_2",r0="_db-header-container_1bsgo_2",a0="_db-header_1bsgo_2",i0="_db-subheader_1bsgo_2 _db-header_1bsgo_2",re={root:Qf,up:Gf,down:Yf,chevron:Jf,tableNameContainer:Xf,link:Zf,tableName:e0,ul:t0,columnType:n0,actionBlue:s0,actionRed:o0,dbHeaderContainer:r0,dbHeader:a0,dbSubheader:i0},l0="_sidebar_1yd55_2",c0="_sidebar-visible_1yd55_2",u0="_sidebar-container_1yd55_2",d0="_sidebar-invisible_1yd55_2",h0="_backdrop_1yd55_2",bn={sidebar:l0,sidebarVisible:c0,sidebarContainer:u0,sidebarInvisible:d0,backdrop:h0},Ao=({children:e,backdropClose:t,isVisible:n,onClose:o,onClosed:r,contentClassName:a})=>{const[i,c]=l.useState(!1),u=()=>{t&&o()},h=m=>{n||getComputedStyle(m.currentTarget).opacity==="0"&&(c(!1),r&&r())};return l.useEffect(()=>{n&&c(!0)},[n]),ws({onClose:u,enabled:n&&t===!0}),s.jsxs("div",{onTransitionEnd:h,className:A(bn.sidebar,n?bn.sidebarVisible:bn.sidebarInvisible),children:[s.jsx("div",{onClick:u,className:bn.backdrop}),s.jsx("div",{className:A(bn.sidebarContainer,a),children:i&&e})]})},no=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})),m0=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"})),f0=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"})),ni=(e,t=!0)=>{const n=navigator.clipboard.writeText(e);t&&n.then(()=>{fe.success(`Copied "${e}"`)})},p0=e=>{const t=l.useRef(!1);l.useEffect(()=>{e&&(e.status==="INSPECTING"?t.current=!0:e.status==="READY"&&t.current&&(kc(e.id),t.current=!1))},[e])},x0=new Intl.DateTimeFormat("en",{dateStyle:"full",timeStyle:"long"}),Jn=18;function g0(e,t){return t&&e.toLowerCase().includes(t)?"bg-yellow-200 cursor-pointer":"cursor-pointer"}const b0=({insp:e,filter:t,expanded:n})=>{const o=l.useMemo(()=>n?e.columns:t.length<1?[]:e.columns.filter(r=>r.name.toLowerCase().includes(t)),[e,t,n]);return s.jsx("ul",{className:re.ul,children:o.map(r=>s.jsx(s.Fragment,{children:s.jsxs("li",{children:[r.isPrimary?"🔐":"🏷️"," ",s.jsx("span",{onClick:()=>ni(r.name),className:g0(r.name,t),children:r.name})," ",s.jsxs("span",{className:re.columnType,children:["[",r.type,"]"]}),r.ref&&s.jsxs("span",{children:[" ➡️ ",s.jsx("span",{className:re.columnType,children:r.ref.table}),".",r.ref.field]})]},r.name+r.type)}))},e.id)};function v0({id:e}){const{data:t}=xs(e),{data:n}=gs(e),o=ee(),r=Rc(),a=ca(),i=Lc(),c=Lt(),u=l.useMemo(()=>t?.lastInspected?x0.format(new Date(t.lastInspected)):"--",[t]),[h,m]=l.useState({}),[d,g]=l.useState(""),[f,x]=l.useState("table"),b=An(me.EDITOR),v=d.toLowerCase(),w=l.useMemo(()=>{if(!v||!n)return n||[];const k=[];for(const O of n){if(O.tableName.toLowerCase().includes(v)){k.push(O);continue}f!=="table"&&O.columns.findIndex(te=>te.name.toLowerCase().includes(v))>=0&&k.push(O)}return k},[v,n,f]),p=k=>{m(O=>({...O,[k]:!O[k]}))},y=k=>{c.mutateAsync({name:k,opts:kt({table:k,dataSourceId:e})}).then(O=>{jn(void 0),o(D.workbenchTab.build({id:O.id}))})},C=()=>{a.mutate(e)},N=async()=>{const k=await Pn("Enter name",t?.name);k&&r.mutate({id:e,dataSource:{name:k}})},I=async()=>{await fo("Are you sure you want to delete this data source?")&&(i.mutate(e),jn(void 0))};p0(t);const _=f==="column",M=t?.status==="INSPECTING";return s.jsxs("div",{className:re.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:re.dbHeaderContainer,children:[s.jsxs("div",{className:re.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:re.dbSubheader,children:[s.jsx("p",{className:"text-xs text-(--text-color-secondary) truncate",children:u}),b&&s.jsxs("div",{className:"flex justify-end",children:[s.jsx("button",{disabled:a.isPending||M,onClick:C,className:re.actionBlue,"data-tooltip-id":"default-xs","data-tooltip-content":"Refresh schema",children:s.jsx(Va,{width:16,height:16})}),s.jsx("button",{disabled:a.isPending,onClick:N,className:re.actionBlue,"data-tooltip-id":"default-xs","data-tooltip-content":"Update name",children:s.jsx(m0,{width:16,height:16})}),s.jsx("button",{disabled:a.isPending,onClick:I,className:re.actionRed,"data-tooltip-id":"default-xs","data-tooltip-content":"Delete data source",children:s.jsx(f0,{width:16,height:16})})]})]})]}),s.jsxs("div",{className:"flex gap-2 items-center mt-2",children:[s.jsxs("select",{className:"input text-sm",value:f,onChange:k=>x(k.currentTarget.value),children:[s.jsx("option",{value:"table",children:"Table"}),s.jsx("option",{value:"column",children:"Column"})]}),s.jsx("input",{className:"input flex-1 bg-gray-50 text-sm",placeholder:_?"Search column":"Search table",value:d,onChange:k=>g(k.target.value),autoFocus:!0})]})]}),M&&s.jsxs("div",{className:"flex justify-center gap-2 items-center bg-blue-50 p-4 rounded",children:[s.jsx(To,{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:A("overflow-y-auto p-4",M&&"opacity-30"),children:w?.map(k=>s.jsxs("div",{children:[s.jsxs("div",{className:re.tableNameContainer,children:[s.jsx("button",{className:A(re.chevron,h[k.id]?re.down:re.up),onClick:()=>p(k.id),children:s.jsx(Sn,{width:16,height:16})}),s.jsx("button",{className:A(re.tableName,"flex-1"),onClick:()=>p(k.id),children:k.tableName}),s.jsx("button",{className:re.link,onClick:()=>y(k.tableName),"data-tooltip-id":"default-xs","data-tooltip-content":"Explore table data",children:s.jsx(no,{width:Jn,height:Jn})}),s.jsx("button",{className:re.link,onClick:()=>ni(k.tableName),"data-tooltip-id":"default-xs","data-tooltip-content":"Copy table name",children:s.jsx(La,{width:Jn,height:Jn})})]}),(h[k.id]||d.length>0)&&s.jsx(b0,{insp:k,filter:_?v:"",expanded:h[k.id]})]},k.id))})]})}const y0=()=>{const e=Mu(),[t,n]=l.useState(void 0);l.useEffect(()=>{e&&n(e)},[e]);const o=()=>jn(void 0);return s.jsx(Ao,{isVisible:e!=null,onClose:o,onClosed:()=>n(void 0),backdropClose:!0,children:t&&s.jsx(v0,{id:t})})};function Io(e,t=500,n){const[o,r]=l.useState(e),a=l.useRef(n);return a.current=n,l.useEffect(()=>{const i=setTimeout(()=>{r(e),a.current&&a.current(e)},t);return()=>clearTimeout(i)},[e,t]),o}const w0="_search-container_1izag_2",C0="_search_1izag_2",j0="_entry_1izag_2",N0="_ds_1izag_2",_0="_ds-tooltip_1izag_2",S0="_ds-entry_1izag_2",k0="_ds-name_1izag_2",rt={searchContainer:w0,search:C0,entry:j0,ds:N0,dsTooltip:_0,dsEntry:S0,dsName:k0},[E0,R0]=Ta({initialData:[],localStorageKey:"selected-data-sources-v1"}),L0=e=>R0(t=>{const n=t.indexOf(e);return n>-1?(t.splice(n,1),[...t]):[...t,e]}),T0={table:"📄",query:"📖",tab:"🛠️"},A0=({onTable:e,onQuery:t,onWorkbenchTab:n,autoFocus:o})=>{const[r,a]=l.useState(""),[i,c]=l.useState(-1),u=Io(r,200),h=E0(),{data:m}=we(),{data:d}=ho({teamId:m?.teamId}),g=l.useMemo(()=>{const p=[],y=_r(h);if(!d||d.length===0)return[];for(const C of d)y[C.id]&&p.push(C.id);return p},[h,d]),{data:f}=yc(u,{teamId:m?.teamId,selectedDataSources:g}),x=p=>{p.type==="table"?e(p.name,p.dataSourceId):p.type==="query"?t(p.id,p.dataSourceId):p.type==="tab"&&n(p.id,p.dataSourceId)},b=p=>{f&&(p.key==="ArrowDown"?(p.preventDefault(),c(y=>(y+1)%f.length)):p.key==="ArrowUp"?(p.preventDefault(),c(y=>(y-1+f.length)%f.length)):p.key==="Enter"&&i>=0&&f[i]?.name&&(p.preventDefault(),x(f[i])))},v=p=>{const y=p.currentTarget.dataset.tableId,C=f?.find(N=>N.id===y);C&&x(C)},w=l.useMemo(()=>_r(h),[h]);return s.jsxs("div",{className:"overflow-hidden flex flex-col w-full lg:w-lg",children:[s.jsx(_n,{id:"datasources",clickable:!0,className:rt.dsTooltip,variant:"light",place:"left-start",positionStrategy:"fixed",noArrow:!0,opacity:1,children:d?.map(p=>s.jsxs("button",{className:A(rt.dsEntry,w[p.id]&&rt.enabled),onClick:()=>L0(p.id),children:[s.jsx("input",{type:"checkbox",checked:!!w[p.id],readOnly:!0}),s.jsx("p",{className:rt.dsName,children:p.name}),s.jsx("div",{children:s.jsx(He,{size:16,type:p.dbType})})]},p.id))}),Ea(d?.length,1)&&s.jsx(ge,{variant:"warning",className:"mb-4",children:"Connect at least one data source to start using DataRamen"}),s.jsxs("div",{className:rt.searchContainer,children:[s.jsx(sn,{containerClassName:rt.search,placeholder:"Search table or saved query to start from",value:r,onChange:p=>a(p.target.value),onKeyDown:b,autoFocus:o}),ve(d?.length,0)&&s.jsx("span",{"data-tooltip-id":"datasources",children:s.jsx(Ha,{width:16,height:16})})]}),s.jsx("div",{className:"overflow-y-auto max-h-full mt-2",children:f?.map((p,y)=>s.jsxs("button",{className:rt.entry,"data-is-active":i===y,"data-table-id":p.id,onClick:v,children:[s.jsxs("p",{className:"truncate",children:[T0[p.type]," ",p.name]}),s.jsxs("p",{className:rt.ds,children:["📦 ",p.dataSourceName]})]},p.id))})]})},I0=()=>{const e=Vc(),t=(a,i)=>{e?.onConfirm("table",a,i)},n=(a,i)=>{e?.onConfirm("query",a,i)},o=(a,i)=>{e?.onConfirm("tab",a,i)},r=()=>{e?.onCancel()};return s.jsx(Me,{isVisible:!!e,onClose:r,backdropClose:!0,children:s.jsx(A0,{autoFocus:!0,onTable:t,onQuery:n,onWorkbenchTab:o})})},M0=()=>{const e=Tn(),t=ee(),{pathname:n}=pe(),{data:o}=we(),{data:r}=ys(),a=D.home.check(n);We("n",()=>{o&&e()}),We("w",()=>{o&&(r&&r.length>0?t(D.workbenchTab.build({id:r[0].id})):e())},{enabled:a}),We("h",()=>{Cn({show:!0})})},[P0,si]=Ce(!1),Hs=()=>si(!1),oi=()=>si(!0),O0=({repeatPassword:e,password:t})=>t.length<1?null:t.length<8?s.jsx(ge,{variant:"warning",children:"New password should be at least 8 characters long"}):t!==e?s.jsx(ge,{variant:"warning",children:"Repeat password should match new password"}):null,D0=()=>{const e=P0(),{data:t}=we(),{mutateAsync:n,isPending:o}=Tc(),r=ee(),[{password:a,repeatPassword:i},{change:c,touched:u,reset:h}]=kn({password:"",repeatPassword:""}),m=()=>{r("/"),hs.logout().then(()=>{Hs()})},d=()=>{n({password:a}).then(()=>{h(),fe.success("Password successfully updated!")})},g=a.length<8||a!==i||o,f=u.includes("password");return s.jsxs(Me,{isVisible:e,onClose:Hs,children:[s.jsx(nn,{onClick:Hs}),s.jsxs("div",{className:"w-full lg:w-lg flex flex-col gap-2",children:[s.jsx(xa,{children:"Account settings"}),s.jsxs("label",{children:[s.jsx("p",{className:"text-xs font-semibold mb-1",children:"Username"}),s.jsx("input",{className:"input w-full",readOnly:!0,disabled:!0,value:t?.username})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsxs("label",{children:[s.jsx("p",{className:"text-xs font-semibold mb-1",children:"Change password"}),s.jsx("input",{className:"input w-full",type:"password",name:"newPassword",autoComplete:"new-password",value:a,onChange:c("password")})]}),s.jsxs("label",{children:[s.jsx("p",{className:"text-xs font-semibold mb-1",children:"Repeat password"}),s.jsx("input",{className:"input w-full",type:"password",value:i,onChange:c("repeatPassword")})]})]}),f&&s.jsx(O0,{password:a,repeatPassword:i}),s.jsxs("div",{className:"flex justify-end gap-2 mt-2",children:[s.jsx("button",{className:"button tertiary",disabled:g,onClick:d,children:"Update password"}),s.jsx("button",{className:"button danger",onClick:m,children:"Log out"})]})]})]})},[$0,ri]=Ce(!1),ai=()=>ri(!0),Er=()=>ri(!1),F0=e=>ye({queryKey:["team-users"],queryFn:async()=>{const{data:t}=await B.get("/teams/"+e+"/users");return t.data},enabled:!!e}),B0=()=>ne({mutationFn:async({role:e,teamId:t,userId:n})=>(await B.patch("/teams/"+t+"/user-role",{role:e,userId:n}),!0),onSuccess:()=>{J.invalidateQueries({queryKey:["team-users"]})}}),q0=()=>ne({mutationFn:async({teamId:e,userId:t})=>(await B.delete("/teams/"+e,{params:{userId:t}}),!0),onSuccess:()=>{J.invalidateQueries({queryKey:["team-users"]})}}),W0="_user-entry_1e8p7_2",U0="_select-container_1e8p7_2",Rr={userEntry:W0,selectContainer:U0},z0=()=>{const e=$0(),{data:t}=we(),{data:n}=F0(t?.teamId),{mutate:o,isPending:r}=Ac(),{mutate:a,isPending:i}=B0(),{mutate:c,isPending:u}=q0(),[h,{change:m,reset:d}]=kn({password:"",username:""}),g=()=>{o({username:h.username,password:h.password,teamId:t?.teamId||""}),d()},f=(w,p)=>{a({teamId:t.teamId,role:p,userId:w})},x=w=>{fo("Are you sure you want to remove this user?").then(p=>{p&&c({userId:w,teamId:t.teamId})})},b=An(me.ADMIN),v=r||i||u;return s.jsxs(Me,{isVisible:e,onClose:Er,backdropClose:!0,children:[s.jsx(nn,{onClick:Er}),s.jsxs("div",{className:"w-full lg:w-lg flex flex-col overflow-hidden",children:[s.jsx(xa,{children:"Manage users"}),ve(n?.length,0)&&s.jsx("div",{className:"mt-4 overflow-y-auto flex-1",children:n.map(w=>s.jsxs("div",{className:Rr.userEntry,children:[s.jsx("div",{className:Rr.selectContainer,children:s.jsxs("select",{value:w.role,disabled:!b||v,onChange:p=>f(w.id,p.currentTarget.value),children:[s.jsx("option",{value:me.OWNER,children:"Owner"}),s.jsx("option",{value:me.ADMIN,children:"Admin"}),s.jsx("option",{value:me.EDITOR,children:"Editor"}),s.jsx("option",{value:me.READ_ONLY,children:"Reader"})]})}),s.jsx("p",{className:"flex-1 mx-2",children:w.name}),b&&s.jsx("button",{className:"p-1 cursor-pointer text-red-500 text-sm",onClick:()=>x(w.id),children:"❌"})]},w.id))}),b&&s.jsxs("div",{className:"mt-4",children:[s.jsx("p",{className:"font-semibold",children:"Create new user"}),s.jsxs("div",{className:"flex flex-col lg:flex-row gap-2 lg:items-center mt-2",children:[s.jsx("input",{className:"input flex-1",onChange:m("username"),value:h.username,placeholder:"Username",disabled:v}),s.jsx("input",{className:"input",onChange:m("password"),value:h.password,type:"password",name:"newPassword",autoComplete:"new-password",placeholder:"Password",disabled:v}),s.jsx("button",{className:"button primary",onClick:g,disabled:v,children:"Create user"})]}),s.jsx("p",{className:"text-xs mt-1 text-gray-600",children:"You should create default password for the new account. The user should change it after the first login."})]})]})]})},H0="_gray-card_1rp1c_2",V0="_login-label_1rp1c_2",Lr={grayCard:H0,loginLabel:V0},K0=()=>{const[e,t]=l.useState(""),[n,o]=l.useState(""),[r,a]=l.useState(),i=ee(),c=u=>{u.preventDefault(),a(void 0),hs.login({password:n,username:e}).then(()=>{i("/",{replace:!0})}).catch(a)};return s.jsx("div",{className:"page-container bg-(--bg) h-screen",children:s.jsxs("div",{className:"page-content items-center",children:[s.jsxs("div",{className:"py-10 text-center w-full sticky top-0 z-0",children:[s.jsx("h1",{className:"comfortaa text-3xl font-semibold text-(--text-color-primary) mb-4",children:"Welcome to DataRamen!"}),s.jsx(va,{})]}),s.jsxs("form",{className:Lr.grayCard,onSubmit:c,children:[s.jsx("h2",{className:Lr.loginLabel,children:"Login"}),r&&s.jsx(ge,{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=ee(),{pathname:t}=pe(),{data:n,isLoading:o}=ua();l.useEffect(()=>{!n&&!o&&!D.login.check(t)&&e(D.login.build())},[n,o,e,t])},G0=()=>{},Y0=__CLIENT_CONFIG__.skipAuth?G0:Q0,J0=()=>{const[e]=Jl(),t=ee(),n=Lt(),o=e.get("shareId");return l.useEffect(()=>{o&&n.mutateAsync({queryId:o}).then(r=>{t(D.workbenchTab.build({id:r.id}),{replace:!0})})},[o]),s.jsxs("div",{className:"page-container flex items-center justify-center h-screen",children:[n.isPending&&s.jsxs("div",{className:"flex items-center flex-col gap-2",children:[s.jsx(To,{}),s.jsx("p",{children:"Fetching query information"})]}),n.isError&&s.jsx(ge,{variant:"danger",children:"Failed to load query information"})]})},X0="_tab-container_skud1_2",Z0="_tab-name_skud1_2",ep="_archived-badge_skud1_2 _badge_skud1_2",tp="_active-badge_skud1_2 _badge_skud1_2",np="_delete-action_skud1_2",vn={tabContainer:X0,tabName:Z0,archivedBadge:ep,activeBadge:tp,deleteAction:np},ii=({onLoadMore:e,children:t,onClose:n,hasMore:o,onSearchValue:r,searchValue:a})=>s.jsxs("aside",{className:"w-full lg:w-md no-scrollbar",children:[s.jsxs("div",{className:"sticky top-0 px-4 py-2 border-b border-gray-200 bg-white",children:[s.jsxs("h3",{className:"text-lg flex justify-between items-center",children:["Recent tabs",n&&s.jsx("button",{className:"cursor-pointer hover:bg-(--bg-ter) rounded-full p-1",onClick:n,children:s.jsx(Ze,{width:24,height:24})})]}),s.jsx(sn,{containerClassName:"mt-2",className:"text-sm",placeholder:"Filter",value:a,autoFocus:!0,onChange:i=>r(i.target.value)})]}),t,o&&s.jsx("div",{className:"flex justify-center my-2",children:s.jsx("button",{className:"text-blue-800 text-sm p-2 cursor-pointer",onClick:e,children:"Load more"})})]}),sp=new Intl.DateTimeFormat,op=()=>{const[e,t]=l.useState(""),n=Io(e),{data:o}=we(),{data:r,fetchNextPage:a,hasNextPage:i}=wc(o?.teamId,n,25),c=ee(),u=da(),h=Hc(),m=l.useRef(null),d=l.useRef(null),g=x=>{r?.find(v=>v.id===x)?.archived&&u.mutate(x),Cn({show:!1}),c(D.workbenchTab.build({id:x}))},f=()=>{m.current?.close(),h.mutate(d.current)};return s.jsxs(ii,{hasMore:i,onLoadMore:a,onClose:()=>Cn({show:!1}),searchValue:e,onSearchValue:t,children:[r?.map(x=>s.jsxs("div",{className:vn.tabContainer,onClick:()=>g(x.id),onContextMenu:b=>{d.current=x.id,m.current?.open(b,!1)},children:[s.jsxs("div",{className:"flex gap-2 items-center",children:[s.jsx("p",{className:vn.tabName,children:x.name}),x.dataSourceType&&s.jsx(He,{size:16,type:x.dataSourceType}),s.jsx("p",{className:"text-xs text-(--text-color-secondary)",children:x.dataSourceName})]}),s.jsxs("div",{className:"flex gap-2 items-center mt-1",children:[s.jsx("p",{className:"text-xs text-(--text-color-secondary) italic",children:sp.format(new Date(x.updatedAt))}),x.archived?s.jsx("span",{className:vn.archivedBadge,children:"Archived"}):s.jsx("span",{className:vn.activeBadge,children:"Active"})]})]},x.id)),s.jsx(vo,{ref:m,children:s.jsx("button",{onClick:f,className:vn.deleteAction,children:"🗑 Delete"})})]})},rp=()=>{const e=Iu(t=>t.show);return s.jsx(Ao,{isVisible:e,onClose:()=>Cn({show:!1}),backdropClose:!0,children:s.jsx(op,{})})},ap=()=>{const{data:e}=we(),t=Nc(e?.teamId),n=ee();return l.useEffect(()=>{t.mutateAsync().then(o=>{o?n(D.workbenchTab.build({id:o.id}),{replace:!0}):n(D.home.build(),{replace:!0})})},[]),null},ip="_query-entry_166yi_2",lp={queryEntry:ip},cp=new Intl.DateTimeFormat,up=({projectQueries:e,isLoading:t})=>{const n=l.useRef(void 0),o=ee(),r=Ah(),a=Lt(),i=Th(),c=Sa(),u=d=>{a.isPending||a.mutateAsync({queryId:d}).then(g=>{In({show:!1}),o(D.workbenchTab.build({id:g.id}))})},h=async d=>{const g=e?.find(x=>x.id===d);if(!g)return;const f=await Pn("New name?",g?.name);f&&r.mutate({id:g.savedQueryId,payload:{name:f}})},m=d=>{const g=e?.find(f=>f.id===d)?.savedQueryId;g&&i.mutate(g)};return s.jsxs("div",{className:"flex flex-col px-2",children:[ve(e?.length,0)&&e.map(d=>s.jsxs("button",{className:lp.queryEntry,onClick:()=>u(d.id),onContextMenu:g=>{n.current=d.id,c.open(g)},children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-left text-sm font-semibold text-(--text-color-primary)",children:d.name}),s.jsx("p",{className:"text-left text-xs text-(--text-color-secondary) italic",children:cp.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&&Ea(e?.length,1)&&s.jsx("p",{className:"text-center text-sm text-(--text-color-secondary) mt-2",children:"Empty"}),s.jsx(ka,{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"})]})})]})},dp=()=>{const{data:e}=we(),[t,n]=l.useState(""),o=Io(t),{data:r,isLoading:a,fetchNextPage:i,hasNextPage:c}=Cc(e?.teamId,o);return s.jsx(ii,{hasMore:c,onClose:()=>In({show:!1}),onLoadMore:i,searchValue:t,onSearchValue:n,children:s.jsx(up,{isLoading:a,projectQueries:r||[]})})},hp=()=>{const e=Au(t=>t.show);return s.jsx(Ao,{isVisible:e,onClose:()=>In({show:!1}),backdropClose:!0,children:s.jsx(dp,{})})};function mp(){return M0(),Y0(),s.jsxs(s.Fragment,{children:[s.jsxs(wl,{children:[s.jsx(Vt,{path:D.home.path,element:s.jsx(Vu,{})}),s.jsx(Vt,{path:D.workbench.path,element:s.jsx(ap,{})}),s.jsx(Vt,{path:D.workbenchTab.path,element:s.jsx(Kf,{})}),s.jsx(Vt,{path:D.login.path,element:s.jsx(K0,{})}),s.jsx(Vt,{path:D.share.path,element:s.jsx(J0,{})})]}),s.jsx(hd,{}),s.jsx(y0,{}),s.jsx(I0,{}),s.jsx(D0,{}),s.jsx(z0,{}),s.jsx(rp,{}),s.jsx(hp,{}),s.jsx(id,{}),s.jsx(Gu,{})]})}const fp="_hidden_11443_2",pp="_desktop-layout_11443_2",xp="_mobile-layout_11443_2",gp="_nav_11443_2",bp="_shown_11443_2",vp="_main_11443_2",yp="_header_11443_2",wp="_expand_11443_2",Cp="_show_11443_2",jp="_hide_11443_2",Np="_icon_11443_2",_p="_nav-item_11443_2",Sp="_project-wrapper_11443_2",F={hidden:fp,desktopLayout:pp,mobileLayout:xp,nav:gp,shown:bp,main:vp,header:yp,expand:wp,show:Cp,hide:jp,icon:Np,navItem:_p,projectWrapper:Sp},kp=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"})),Ep=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"})),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})),us=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})),Tr=!__CLIENT_CONFIG__.skipAuth,Ar=(()=>{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`}})(),Z=20,ke="text-(--text-color-primary)";function Ip(){switch(__CLIENT_CONFIG__.modeName){case"docker":return s.jsx(kp,{className:ke,width:Z,height:Z});case"cli":return s.jsx(Ep,{className:ke,width:Z,height:Z});default:return s.jsx(wa,{className:ke,width:Z,height:Z})}}const Mp=({dataSource:e})=>s.jsxs("button",{className:F.navItem,onClick:()=>jn(e.id),"data-tooltip-id":"default","data-tooltip-content":e.name,"data-tooltip-place":"right",children:[s.jsx("span",{className:F.icon,children:s.jsx(He,{size:20,type:e.dbType})}),s.jsx("span",{className:"truncate",children:e.name})]}),Pp=()=>{const e=ee(),{pathname:t}=pe(),{data:n}=we(),o=Tn(),[r,a]=l.useState(!1),{data:i}=ys(),{data:c}=bc(n?.teamId),u=()=>{D.home.check(t)||e(D.home.build())},h=x=>{D.workbenchTab.check(t)||e(D.workbenchTab.build({id:x}))},m=()=>{In({show:!0})},d=()=>{fo("Are you sure you want to logout?").then(x=>{x&&(e("/"),hs.logout())})},g=()=>Cn({show:!0}),f=r?void 0:"default";return s.jsxs("nav",{className:A(F.nav,r?F.shown:F.hidden),children:[n&&s.jsxs("div",{className:F.header,children:[s.jsxs("button",{onClick:u,className:F.navItem,"data-tooltip-id":f,"data-tooltip-content":"Home",children:[s.jsx("span",{className:F.icon,children:s.jsx(Lp,{className:ke,width:Z,height:Z})}),s.jsx("span",{className:"truncate",children:"Home"})]}),s.jsxs("button",{onClick:o,className:F.navItem,"data-tooltip-id":f,"data-tooltip-content":"New query",children:[s.jsx("span",{className:F.icon,children:s.jsx(Mn,{className:ke,width:Z,height:Z})}),s.jsx("span",{className:"truncate",children:"New query"}),s.jsx("span",{className:"hotkey secondary",children:"N"})]}),s.jsxs("button",{onClick:g,className:F.navItem,"data-tooltip-id":f,"data-tooltip-content":"Recent tabs",children:[s.jsx("span",{className:F.icon,children:s.jsx(ga,{className:ke,width:Z,height:Z})}),s.jsx("span",{className:"truncate",children:"Recent tabs"}),s.jsx("span",{className:"hotkey secondary",children:"H"})]}),s.jsxs("button",{onClick:m,className:F.navItem,"data-tooltip-id":f,"data-tooltip-content":"Saved queries",children:[s.jsx("span",{className:F.icon,children:s.jsx(us,{className:ke,width:Z,height:Z})}),s.jsx("span",{className:"truncate",children:"Saved queries"})]}),ve(i?.length,0)&&s.jsxs("button",{onClick:()=>h(i[0].id),className:F.navItem,"data-tooltip-id":f,"data-tooltip-content":"Workbench",children:[s.jsx("span",{className:F.icon,children:s.jsx(ba,{className:ke,width:Z,height:Z})}),s.jsx("span",{className:"truncate",children:"Workbench"}),s.jsx("span",{className:"hotkey secondary",children:"W"})]}),Tr&&s.jsxs(s.Fragment,{children:[s.jsxs("button",{onClick:oi,className:F.navItem,"data-tooltip-id":f,"data-tooltip-content":"User settings",children:[s.jsx("span",{className:F.icon,children:s.jsx(Tp,{className:ke,width:Z,height:Z})}),s.jsx("span",{className:"truncate",children:n.username})]}),s.jsxs("button",{onClick:ai,className:F.navItem,"data-tooltip-id":f,"data-tooltip-content":"Manage users",children:[s.jsx("span",{className:F.icon,children:s.jsx(Ap,{className:ke,width:Z,height:Z})}),s.jsx("span",{className:"truncate",children:"Manage users"})]})]})]}),s.jsx("div",{className:A(F.projectWrapper),children:ve(c?.length,0)&&s.jsx("div",{className:"mt-4 flex flex-col",children:c.map(x=>s.jsx(Mp,{dataSource:x},x.id))})}),Tr&&s.jsxs("button",{onClick:d,"data-tooltip-id":f,"data-tooltip-content":"Logout",className:`${F.navItem} mx-1`,children:[s.jsx("span",{className:F.icon,children:s.jsx(Rp,{className:ke,width:20,height:20})}),s.jsx("span",{className:"truncate text-sm text-(--text-color-primary)",children:"Logout"})]}),s.jsxs("div",{className:`${F.navItem} mx-1 cursor-auto!`,"data-tooltip-id":f,"data-tooltip-content":Ar,children:[s.jsx("span",{className:F.icon,children:s.jsx(Ip,{})}),s.jsx("span",{className:"truncate text-sm text-(--text-color-primary)",children:Ar})]}),s.jsxs("button",{onClick:()=>a(!r),"data-tooltip-id":"default","data-tooltip-content":"Expand sidebar","data-tooltip-hidden":r,"data-tooltip-place":"right",className:`${F.navItem} mx-1`,children:[s.jsx("span",{className:A(F.icon,F.expand,r?F.show:F.hide),children:s.jsx(Sn,{className:ke,width:20,height:20})}),s.jsx("span",{className:"truncate text-sm text-(--text-color-primary)",children:"Collapse menu"})]})]})},Op="_root_15fjr_2",Dp={root:Op},li=!__CLIENT_CONFIG__.skipAuth,$p=`${Dp.root} ${li?"grid-cols-4":"grid-cols-2"}`,Fp=()=>{const{pathname:e}=pe(),t=ee(),n=Tn(),o=()=>{D.home.check(e)||t(D.home.build())};return s.jsxs("div",{className:$p,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"})]}),li&&s.jsxs(s.Fragment,{children:[s.jsxs("button",{onClick:oi,children:[s.jsx("p",{children:"🪪"}),s.jsx("p",{className:"text-xs font-semibold text-gray-600",children:"Account"})]}),s.jsxs("button",{onClick:ai,children:[s.jsx("p",{children:"👥"}),s.jsx("p",{className:"text-xs font-semibold text-gray-600",children:"Users"})]})]})]})},Bp=(e,t,n)=>ye({queryKey:["entity",e,t,n],queryFn:async()=>{const{data:o}=await B.get(`/runner/${e}/entity/${t}`,{params:n?.reduce((r,a)=>(r[a[0]]=a[1],r),{})});return o.data},retry:1,enabled:!!t&&!!e&&!!n,staleTime:0}),qp=()=>ne({mutationFn:async e=>{const{data:t}=await B.post(`/runner/${e.datasourceId}/update`,e);return t.data}}),Wp=()=>ne({mutationFn:async e=>{const{data:t}=await B.post(`/runner/${e.datasourceId}/insert`,e);return t.data}}),Up="_root_1b7um_2",zp="_container_1b7um_2",Hp="_header_1b7um_2",Vp="_fields-container_1b7um_2",Kp="_field-label_1b7um_2",Qp="_changed-marker_1b7um_2",Gp="_action-icon_1b7um_2",Ge={root:Up,container:zp,header:Hp,fieldsContainer:Vp,fieldLabel:Kp,changedMarker:Qp,actionIcon:Gp},Yp=e=>{if(e==null)return"<NULL>";if(e==="")return"<EMPTY STRING>"},Jp=e=>e.isPrimary?"🔐 "+e.name:e.ref?"🔑 "+e.name:e.name,Xp=({data:e})=>{const t=bh(S=>S.history),[n,{set:o,reset:r,touched:a,untouch:i}]=kn({}),c=Ro(),u=ee(),[h,m]=l.useState(0),[d,g]=l.useState(""),{data:f,isLoading:x,refetch:b}=Bp(e.dataSourceId,e.tableName,e.entityId),{mutateAsync:v,error:w,isPending:p}=qp(),{mutateAsync:y}=Lt(),C=xo(w),N=An(me.EDITOR),{data:I}=gs(e.dataSourceId),{data:_}=xs(e.dataSourceId),M=l.useMemo(()=>I?.find(S=>S.tableName===e.tableName),[e.tableName,I]),k=l.useMemo(()=>{if(!M)return[];if(!d)return M.columns;const S=d.toLowerCase();return M.columns.filter(P=>P.name.toLowerCase().includes(S))},[d,M]),O=l.useMemo(()=>{const S={};if(!f?.entity)return S;for(let P=0;P<f.columns.length;P++)S[f.columns[P]?.column]=Yp(f.entity[P]);return S},[f]);l.useEffect(()=>{const S=f?.entity;if(r(),S&&f?.columns)for(let P=0;P<f.columns.length;P++){const z=f.columns[P];o(z.column,{value:Nt(S[P]),mode:"default"})}},[f,o,r,h]);const te=()=>{const S={};for(const P of a)S[P]=n[P];v({datasourceId:e.dataSourceId,table:e.tableName,filters:e.entityId.map(P=>({id:et(),value:""+P[1],column:P[0],isEnabled:!0})),values:S}).then(()=>{i(),fe.success("Record successfully updated."),b(),c&&ma(c)})},ae=(S,P,z)=>{y({name:`${S} ${P} = ${z}`,opts:kt({dataSourceId:e.dataSourceId,table:S,filters:[{value:`${z}`,column:`${S}.${P}`,id:et(),isEnabled:!0}]})}).then(({id:H})=>{u(D.workbenchTab.build({id:H}))})},Ne=S=>{const P=t.find(z=>z.key===S);P&&Co(P,!1)},q=!_?.allowUpdate||!N||p;return s.jsxs("div",{className:Ge.root,children:[s.jsxs("div",{className:Ge.header,children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("select",{className:"input rounded-md! w-full",value:e?.key,onChange:S=>Ne(S.currentTarget.value),children:t.map(S=>s.jsxs("option",{value:S.key,children:[S.tableName," - ",S.entityId.map(P=>`${P[0]} = ${P[1]}`)]},S.key))}),!q&&a.length>0&&s.jsx("button",{className:Ge.actionIcon,onClick:()=>m(S=>++S),children:s.jsx(us,{width:20,height:20})}),!q&&s.jsx("button",{disabled:!a.length,onClick:te,className:Ge.actionIcon,children:s.jsx(us,{width:20,height:20})}),s.jsx("button",{className:Ge.actionIcon,onClick:yh,children:s.jsx(Ze,{width:20,height:20})})]}),C&&s.jsx(ge,{variant:"danger",children:s.jsx("p",{children:C})}),s.jsx(sn,{containerClassName:"mt-2",className:"text-sm",value:d,onChange:S=>g(S.target.value),placeholder:"Filter columns"})]}),s.jsx("div",{className:Ge.container,children:s.jsx("div",{className:Ge.fieldsContainer,children:k.map(S=>s.jsxs("label",{className:Ge.fieldLabel,children:[s.jsxs("div",{className:"flex justify-between mb-0.5",children:[s.jsxs("p",{children:[a.includes(S.name)&&s.jsx("span",{className:Ge.changedMarker}),Jp(S)]}),s.jsx("p",{className:"text-blue-800 text-xs",children:S.type})]}),s.jsxs("div",{className:"flex items-center",children:[s.jsx(Cs,{prefix:"=",allowedModes:js,disabled:S.isPrimary||x||q,value:Nt(n[S.name]?.value),mode:n[S.name]?.mode,onExpressionChange:P=>o(S.name,P,!0),placeholder:O[S.name]}),S.ref&&s.jsx("button",{className:"cursor-pointer pl-2",onClick:()=>ae(S.ref.table,S.ref.field,n[S.name]?.value),children:s.jsx(no,{width:16,height:16})}),S.isPrimary&&s.jsx("button",{className:"cursor-pointer pl-2",onClick:()=>ae(e.tableName,S.name,n[S.name]?.value),children:s.jsx(no,{width:16,height:16})})]})]},S.name))})})]})},Zp=()=>{const e=gh();return e?s.jsx(Xp,{data:e}):null},e1="_root_1llrc_2",t1="_container_1llrc_2",n1="_header_1llrc_2",s1="_fields-container_1llrc_2",o1="_field-label_1llrc_2",r1="_icon-action_1llrc_2",wt={root:e1,container:t1,header:n1,fieldsContainer:s1,fieldLabel:o1,iconAction:r1},a1=e=>e.isPrimary?"🔐 "+e.name:e.ref?"🔑 "+e.name:e.name,i1=({data:e})=>{const[t,{set:n,touched:o}]=kn({}),r=Ro(),{mutateAsync:a,error:i,isPending:c}=Wp(),u=xo(i),{data:h}=gs(e.dataSourceId),[m,d]=l.useState(""),g=l.useMemo(()=>h?.find(b=>b.tableName===e.table),[h,e.table]),f=l.useMemo(()=>{if(!g)return[];if(!m)return g.columns;const b=m.toLowerCase();return g.columns.filter(v=>v.name.toLowerCase().includes(b))},[m,g]),x=()=>{const b={};for(const v of o)b[v]=t[v];a({datasourceId:e.dataSourceId,table:e.table,values:b}).then(()=>{fe.success("Record successfully created."),r&&ma(r)})};return s.jsxs("div",{className:wt.root,children:[s.jsxs("div",{className:wt.header,children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsxs("p",{className:"text-lg flex-1 font-semibold underline",children:["New ",e.table]}),s.jsx("button",{disabled:!o.length||c,className:wt.iconAction,onClick:x,children:s.jsx(us,{width:20,height:20})}),s.jsx("button",{className:wt.iconAction,onClick:ph,children:s.jsx(Ze,{width:20,height:20})})]}),u&&s.jsx(ge,{variant:"danger",children:s.jsx("p",{children:u})}),s.jsx(sn,{containerClassName:"mt-2",className:"text-sm",value:m,onChange:b=>d(b.target.value),placeholder:"Filter columns"})]}),s.jsx("div",{className:wt.container,children:s.jsx("div",{className:wt.fieldsContainer,children:f.map(b=>s.jsxs("label",{className:wt.fieldLabel,children:[s.jsxs("div",{className:"flex justify-between mb-0.5",children:[s.jsx("p",{children:a1(b)}),s.jsx("p",{className:"text-blue-800 text-xs",children:b.type})]}),s.jsx(Cs,{disabled:c,prefix:"=",allowedModes:js,mode:t[b.name]?.mode,value:Nt(t[b.name]?.value),onExpressionChange:v=>n(b.name,v,!0)})]},b.name))})})]})},l1=()=>{const e=mh();return e?s.jsx(i1,{data:e}):null},c1=({children:e,isLogin:t})=>s.jsxs("div",{className:F.desktopLayout,children:[s.jsx(_n,{id:"default",className:"z-100"}),s.jsx(_n,{id:"default-xs",className:"z-100 text-xs!"}),!t&&s.jsx(Pp,{}),s.jsx("main",{className:F.main,children:e}),s.jsx(Zp,{}),s.jsx(l1,{})]}),u1=({children:e,isLogin:t})=>s.jsxs("div",{className:F.mobileLayout,children:[s.jsx("main",{className:F.main,children:e}),!t&&s.jsx(Fp,{})]}),d1=({children:e})=>{const t=ja(po.laptop),{pathname:n}=pe(),o=D.login.check(n);return t?s.jsx(c1,{isLogin:o,children:e}):s.jsx(u1,{isLogin:o,children:e})};Ci.createRoot(document.getElementById("root")).render(s.jsxs(at.StrictMode,{children:[s.jsx(ji,{}),s.jsx(ic,{client:J,children:s.jsx(Vl,{children:s.jsx(d1,{children:s.jsx(mp,{})})})})]}));