@dataramen/cli 0.0.58-beta.5 → 0.0.58

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.
@@ -13,7 +13,7 @@ Please change the parent <Route path="${T}"> to <Route path="${T==="/"?"*":`${T}
13
13
  `)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(l){return l instanceof this?l:new this(l)}static concat(l,...i){const r=new this(l);return i.forEach(u=>r.set(u)),r}static accessor(l){const r=(this[vy]=this[vy]={accessors:{}}).accessors,u=this.prototype;function c(d){const m=or(d);r[m]||(Uw(u,d),r[m]=!0)}return B.isArray(l)?l.forEach(c):c(l),this}};Xt.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);B.reduceDescriptors(Xt.prototype,({value:n},l)=>{let i=l[0].toUpperCase()+l.slice(1);return{get:()=>n,set(r){this[i]=r}}});B.freezeMethods(Xt);function Gf(n,l){const i=this||_r,r=l||i,u=Xt.from(r.headers);let c=r.data;return B.forEach(n,function(m){c=m.call(i,c,u.normalize(),l?l.status:void 0)}),u.normalize(),c}function P1(n){return!!(n&&n.__CANCEL__)}function ti(n,l,i){pe.call(this,n??"canceled",pe.ERR_CANCELED,l,i),this.name="CanceledError"}B.inherits(ti,pe,{__CANCEL__:!0});function J1(n,l,i){const r=i.config.validateStatus;!i.status||!r||r(i.status)?n(i):l(new pe("Request failed with status code "+i.status,[pe.ERR_BAD_REQUEST,pe.ERR_BAD_RESPONSE][Math.floor(i.status/100)-4],i.config,i.request,i))}function Lw(n){const l=/^([-+\w]{1,25})(:?\/\/|:)/.exec(n);return l&&l[1]||""}function zw(n,l){n=n||10;const i=new Array(n),r=new Array(n);let u=0,c=0,d;return l=l!==void 0?l:1e3,function(p){const y=Date.now(),g=r[c];d||(d=y),i[u]=p,r[u]=y;let x=c,E=0;for(;x!==u;)E+=i[x++],x=x%n;if(u=(u+1)%n,u===c&&(c=(c+1)%n),y-d<l)return;const C=g&&y-g;return C?Math.round(E*1e3/C):void 0}}function kw(n,l){let i=0,r=1e3/l,u,c;const d=(y,g=Date.now())=>{i=g,u=null,c&&(clearTimeout(c),c=null),n(...y)};return[(...y)=>{const g=Date.now(),x=g-i;x>=r?d(y,g):(u=y,c||(c=setTimeout(()=>{c=null,d(u)},r-x)))},()=>u&&d(u)]}const uu=(n,l,i=3)=>{let r=0;const u=zw(50,250);return kw(c=>{const d=c.loaded,m=c.lengthComputable?c.total:void 0,p=d-r,y=u(p),g=d<=m;r=d;const x={loaded:d,total:m,progress:m?d/m:void 0,bytes:p,rate:y||void 0,estimated:y&&m&&g?(m-d)/y:void 0,event:c,lengthComputable:m!=null,[l?"download":"upload"]:!0};n(x)},i)},gy=(n,l)=>{const i=n!=null;return[r=>l[0]({lengthComputable:i,total:n,loaded:r}),l[1]]},by=n=>(...l)=>B.asap(()=>n(...l)),qw=Ot.hasStandardBrowserEnv?((n,l)=>i=>(i=new URL(i,Ot.origin),n.protocol===i.protocol&&n.host===i.host&&(l||n.port===i.port)))(new URL(Ot.origin),Ot.navigator&&/(msie|trident)/i.test(Ot.navigator.userAgent)):()=>!0,Bw=Ot.hasStandardBrowserEnv?{write(n,l,i,r,u,c,d){if(typeof document>"u")return;const m=[`${n}=${encodeURIComponent(l)}`];B.isNumber(i)&&m.push(`expires=${new Date(i).toUTCString()}`),B.isString(r)&&m.push(`path=${r}`),B.isString(u)&&m.push(`domain=${u}`),c===!0&&m.push("secure"),B.isString(d)&&m.push(`SameSite=${d}`),document.cookie=m.join("; ")},read(n){if(typeof document>"u")return null;const l=document.cookie.match(new RegExp("(?:^|; )"+n+"=([^;]*)"));return l?decodeURIComponent(l[1]):null},remove(n){this.write(n,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function Hw(n){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(n)}function Qw(n,l){return l?n.replace(/\/?\/$/,"")+"/"+l.replace(/^\/+/,""):n}function I1(n,l,i){let r=!Hw(l);return n&&(r||i==!1)?Qw(n,l):l}const xy=n=>n instanceof Xt?{...n}:n;function Zl(n,l){l=l||{};const i={};function r(y,g,x,E){return B.isPlainObject(y)&&B.isPlainObject(g)?B.merge.call({caseless:E},y,g):B.isPlainObject(g)?B.merge({},g):B.isArray(g)?g.slice():g}function u(y,g,x,E){if(B.isUndefined(g)){if(!B.isUndefined(y))return r(void 0,y,x,E)}else return r(y,g,x,E)}function c(y,g){if(!B.isUndefined(g))return r(void 0,g)}function d(y,g){if(B.isUndefined(g)){if(!B.isUndefined(y))return r(void 0,y)}else return r(void 0,g)}function m(y,g,x){if(x in l)return r(y,g);if(x in n)return r(void 0,y)}const p={url:c,method:c,data:c,baseURL:d,transformRequest:d,transformResponse:d,paramsSerializer:d,timeout:d,timeoutMessage:d,withCredentials:d,withXSRFToken:d,adapter:d,responseType:d,xsrfCookieName:d,xsrfHeaderName:d,onUploadProgress:d,onDownloadProgress:d,decompress:d,maxContentLength:d,maxBodyLength:d,beforeRedirect:d,transport:d,httpAgent:d,httpsAgent:d,cancelToken:d,socketPath:d,responseEncoding:d,validateStatus:m,headers:(y,g,x)=>u(xy(y),xy(g),x,!0)};return B.forEach(Object.keys({...n,...l}),function(g){const x=p[g]||u,E=x(n[g],l[g],g);B.isUndefined(E)&&x!==m||(i[g]=E)}),i}const W1=n=>{const l=Zl({},n);let{data:i,withXSRFToken:r,xsrfHeaderName:u,xsrfCookieName:c,headers:d,auth:m}=l;if(l.headers=d=Xt.from(d),l.url=X1(I1(l.baseURL,l.url,l.allowAbsoluteUrls),n.params,n.paramsSerializer),m&&d.set("Authorization","Basic "+btoa((m.username||"")+":"+(m.password?unescape(encodeURIComponent(m.password)):""))),B.isFormData(i)){if(Ot.hasStandardBrowserEnv||Ot.hasStandardBrowserWebWorkerEnv)d.setContentType(void 0);else if(B.isFunction(i.getHeaders)){const p=i.getHeaders(),y=["content-type","content-length"];Object.entries(p).forEach(([g,x])=>{y.includes(g.toLowerCase())&&d.set(g,x)})}}if(Ot.hasStandardBrowserEnv&&(r&&B.isFunction(r)&&(r=r(l)),r||r!==!1&&qw(l.url))){const p=u&&c&&Bw.read(c);p&&d.set(u,p)}return l},Yw=typeof XMLHttpRequest<"u",Vw=Yw&&function(n){return new Promise(function(i,r){const u=W1(n);let c=u.data;const d=Xt.from(u.headers).normalize();let{responseType:m,onUploadProgress:p,onDownloadProgress:y}=u,g,x,E,C,w;function j(){C&&C(),w&&w(),u.cancelToken&&u.cancelToken.unsubscribe(g),u.signal&&u.signal.removeEventListener("abort",g)}let N=new XMLHttpRequest;N.open(u.method.toUpperCase(),u.url,!0),N.timeout=u.timeout;function _(){if(!N)return;const D=Xt.from("getAllResponseHeaders"in N&&N.getAllResponseHeaders()),G={data:!m||m==="text"||m==="json"?N.responseText:N.response,status:N.status,statusText:N.statusText,headers:D,config:n,request:N};J1(function(K){i(K),j()},function(K){r(K),j()},G),N=null}"onloadend"in N?N.onloadend=_:N.onreadystatechange=function(){!N||N.readyState!==4||N.status===0&&!(N.responseURL&&N.responseURL.indexOf("file:")===0)||setTimeout(_)},N.onabort=function(){N&&(r(new pe("Request aborted",pe.ECONNABORTED,n,N)),N=null)},N.onerror=function(H){const G=H&&H.message?H.message:"Network Error",V=new pe(G,pe.ERR_NETWORK,n,N);V.event=H||null,r(V),N=null},N.ontimeout=function(){let H=u.timeout?"timeout of "+u.timeout+"ms exceeded":"timeout exceeded";const G=u.transitional||F1;u.timeoutErrorMessage&&(H=u.timeoutErrorMessage),r(new pe(H,G.clarifyTimeoutError?pe.ETIMEDOUT:pe.ECONNABORTED,n,N)),N=null},c===void 0&&d.setContentType(null),"setRequestHeader"in N&&B.forEach(d.toJSON(),function(H,G){N.setRequestHeader(G,H)}),B.isUndefined(u.withCredentials)||(N.withCredentials=!!u.withCredentials),m&&m!=="json"&&(N.responseType=u.responseType),y&&([E,w]=uu(y,!0),N.addEventListener("progress",E)),p&&N.upload&&([x,C]=uu(p),N.upload.addEventListener("progress",x),N.upload.addEventListener("loadend",C)),(u.cancelToken||u.signal)&&(g=D=>{N&&(r(!D||D.type?new ti(null,n,N):D),N.abort(),N=null)},u.cancelToken&&u.cancelToken.subscribe(g),u.signal&&(u.signal.aborted?g():u.signal.addEventListener("abort",g)));const T=Lw(u.url);if(T&&Ot.protocols.indexOf(T)===-1){r(new pe("Unsupported protocol "+T+":",pe.ERR_BAD_REQUEST,n));return}N.send(c||null)})},Kw=(n,l)=>{const{length:i}=n=n?n.filter(Boolean):[];if(l||i){let r=new AbortController,u;const c=function(y){if(!u){u=!0,m();const g=y instanceof Error?y:this.reason;r.abort(g instanceof pe?g:new ti(g instanceof Error?g.message:g))}};let d=l&&setTimeout(()=>{d=null,c(new pe(`timeout ${l} of ms exceeded`,pe.ETIMEDOUT))},l);const m=()=>{n&&(d&&clearTimeout(d),d=null,n.forEach(y=>{y.unsubscribe?y.unsubscribe(c):y.removeEventListener("abort",c)}),n=null)};n.forEach(y=>y.addEventListener("abort",c));const{signal:p}=r;return p.unsubscribe=()=>B.asap(m),p}},$w=function*(n,l){let i=n.byteLength;if(i<l){yield n;return}let r=0,u;for(;r<i;)u=r+l,yield n.slice(r,u),r=u},Gw=async function*(n,l){for await(const i of Xw(n))yield*$w(i,l)},Xw=async function*(n){if(n[Symbol.asyncIterator]){yield*n;return}const l=n.getReader();try{for(;;){const{done:i,value:r}=await l.read();if(i)break;yield r}}finally{await l.cancel()}},Sy=(n,l,i,r)=>{const u=Gw(n,l);let c=0,d,m=p=>{d||(d=!0,r&&r(p))};return new ReadableStream({async pull(p){try{const{done:y,value:g}=await u.next();if(y){m(),p.close();return}let x=g.byteLength;if(i){let E=c+=x;i(E)}p.enqueue(new Uint8Array(g))}catch(y){throw m(y),y}},cancel(p){return m(p),u.return()}},{highWaterMark:2})},wy=64*1024,{isFunction:Go}=B,Fw=(({Request:n,Response:l})=>({Request:n,Response:l}))(B.global),{ReadableStream:Ey,TextEncoder:Cy}=B.global,_y=(n,...l)=>{try{return!!n(...l)}catch{return!1}},Zw=n=>{n=B.merge.call({skipUndefined:!0},Fw,n);const{fetch:l,Request:i,Response:r}=n,u=l?Go(l):typeof fetch=="function",c=Go(i),d=Go(r);if(!u)return!1;const m=u&&Go(Ey),p=u&&(typeof Cy=="function"?(w=>j=>w.encode(j))(new Cy):async w=>new Uint8Array(await new i(w).arrayBuffer())),y=c&&m&&_y(()=>{let w=!1;const j=new i(Ot.origin,{body:new Ey,method:"POST",get duplex(){return w=!0,"half"}}).headers.has("Content-Type");return w&&!j}),g=d&&m&&_y(()=>B.isReadableStream(new r("").body)),x={stream:g&&(w=>w.body)};u&&["text","arrayBuffer","blob","formData","stream"].forEach(w=>{!x[w]&&(x[w]=(j,N)=>{let _=j&&j[w];if(_)return _.call(j);throw new pe(`Response type '${w}' is not supported`,pe.ERR_NOT_SUPPORT,N)})});const E=async w=>{if(w==null)return 0;if(B.isBlob(w))return w.size;if(B.isSpecCompliantForm(w))return(await new i(Ot.origin,{method:"POST",body:w}).arrayBuffer()).byteLength;if(B.isArrayBufferView(w)||B.isArrayBuffer(w))return w.byteLength;if(B.isURLSearchParams(w)&&(w=w+""),B.isString(w))return(await p(w)).byteLength},C=async(w,j)=>{const N=B.toFiniteNumber(w.getContentLength());return N??E(j)};return async w=>{let{url:j,method:N,data:_,signal:T,cancelToken:D,timeout:H,onDownloadProgress:G,onUploadProgress:V,responseType:K,headers:Z,withCredentials:te="same-origin",fetchOptions:ye}=W1(w),Ae=l||fetch;K=K?(K+"").toLowerCase():"text";let Ce=Kw([T,D&&D.toAbortSignal()],H),$e=null;const me=Ce&&Ce.unsubscribe&&(()=>{Ce.unsubscribe()});let _e;try{if(V&&y&&N!=="get"&&N!=="head"&&(_e=await C(Z,_))!==0){let Q=new i(j,{method:"POST",body:_,duplex:"half"}),I;if(B.isFormData(_)&&(I=Q.headers.get("content-type"))&&Z.setContentType(I),Q.body){const[W,ae]=gy(_e,uu(by(V)));_=Sy(Q.body,wy,W,ae)}}B.isString(te)||(te=te?"include":"omit");const q=c&&"credentials"in i.prototype,F={...ye,signal:Ce,method:N.toUpperCase(),headers:Z.normalize().toJSON(),body:_,duplex:"half",credentials:q?te:void 0};$e=c&&new i(j,F);let J=await(c?Ae($e,ye):Ae(j,F));const he=g&&(K==="stream"||K==="response");if(g&&(G||he&&me)){const Q={};["status","statusText","headers"].forEach(ge=>{Q[ge]=J[ge]});const I=B.toFiniteNumber(J.headers.get("content-length")),[W,ae]=G&&gy(I,uu(by(G),!0))||[];J=new r(Sy(J.body,wy,W,()=>{ae&&ae(),me&&me()}),Q)}K=K||"text";let R=await x[B.findKey(x,K)||"text"](J,w);return!he&&me&&me(),await new Promise((Q,I)=>{J1(Q,I,{data:R,headers:Xt.from(J.headers),status:J.status,statusText:J.statusText,config:w,request:$e})})}catch(q){throw me&&me(),q&&q.name==="TypeError"&&/Load failed|fetch/i.test(q.message)?Object.assign(new pe("Network Error",pe.ERR_NETWORK,w,$e),{cause:q.cause||q}):pe.from(q,q&&q.code,w,$e)}}},Pw=new Map,ev=n=>{let l=n&&n.env||{};const{fetch:i,Request:r,Response:u}=l,c=[r,u,i];let d=c.length,m=d,p,y,g=Pw;for(;m--;)p=c[m],y=g.get(p),y===void 0&&g.set(p,y=m?new Map:Zw(l)),g=y;return y};ev();const Qd={http:hw,xhr:Vw,fetch:{get:ev}};B.forEach(Qd,(n,l)=>{if(n){try{Object.defineProperty(n,"name",{value:l})}catch{}Object.defineProperty(n,"adapterName",{value:l})}});const Ny=n=>`- ${n}`,Jw=n=>B.isFunction(n)||n===null||n===!1;function Iw(n,l){n=B.isArray(n)?n:[n];const{length:i}=n;let r,u;const c={};for(let d=0;d<i;d++){r=n[d];let m;if(u=r,!Jw(r)&&(u=Qd[(m=String(r)).toLowerCase()],u===void 0))throw new pe(`Unknown adapter '${m}'`);if(u&&(B.isFunction(u)||(u=u.get(l))))break;c[m||"#"+d]=u}if(!u){const d=Object.entries(c).map(([p,y])=>`adapter ${p} `+(y===!1?"is not supported by the environment":"is not available in the build"));let m=i?d.length>1?`since :
14
14
  `+d.map(Ny).join(`
15
15
  `):" "+Ny(d[0]):"as no adapter specified";throw new pe("There is no suitable adapter to dispatch the request "+m,"ERR_NOT_SUPPORT")}return u}const tv={getAdapter:Iw,adapters:Qd};function Xf(n){if(n.cancelToken&&n.cancelToken.throwIfRequested(),n.signal&&n.signal.aborted)throw new ti(null,n)}function Ty(n){return Xf(n),n.headers=Xt.from(n.headers),n.data=Gf.call(n,n.transformRequest),["post","put","patch"].indexOf(n.method)!==-1&&n.headers.setContentType("application/x-www-form-urlencoded",!1),tv.getAdapter(n.adapter||_r.adapter,n)(n).then(function(r){return Xf(n),r.data=Gf.call(n,n.transformResponse,r),r.headers=Xt.from(r.headers),r},function(r){return P1(r)||(Xf(n),r&&r.response&&(r.response.data=Gf.call(n,n.transformResponse,r.response),r.response.headers=Xt.from(r.response.headers))),Promise.reject(r)})}const nv="1.13.2",wu={};["object","boolean","number","function","string","symbol"].forEach((n,l)=>{wu[n]=function(r){return typeof r===n||"a"+(l<1?"n ":" ")+n}});const jy={};wu.transitional=function(l,i,r){function u(c,d){return"[Axios v"+nv+"] Transitional option '"+c+"'"+d+(r?". "+r:"")}return(c,d,m)=>{if(l===!1)throw new pe(u(d," has been removed"+(i?" in "+i:"")),pe.ERR_DEPRECATED);return i&&!jy[d]&&(jy[d]=!0,console.warn(u(d," has been deprecated since v"+i+" and will be removed in the near future"))),l?l(c,d,m):!0}};wu.spelling=function(l){return(i,r)=>(console.warn(`${r} is likely a misspelling of ${l}`),!0)};function Ww(n,l,i){if(typeof n!="object")throw new pe("options must be an object",pe.ERR_BAD_OPTION_VALUE);const r=Object.keys(n);let u=r.length;for(;u-- >0;){const c=r[u],d=l[c];if(d){const m=n[c],p=m===void 0||d(m,c,n);if(p!==!0)throw new pe("option "+c+" must be "+p,pe.ERR_BAD_OPTION_VALUE);continue}if(i!==!0)throw new pe("Unknown option "+c,pe.ERR_BAD_OPTION)}}const tu={assertOptions:Ww,validators:wu},Pn=tu.validators;let Kl=class{constructor(l){this.defaults=l||{},this.interceptors={request:new yy,response:new yy}}async request(l,i){try{return await this._request(l,i)}catch(r){if(r instanceof Error){let u={};Error.captureStackTrace?Error.captureStackTrace(u):u=new Error;const c=u.stack?u.stack.replace(/^.+\n/,""):"";try{r.stack?c&&!String(r.stack).endsWith(c.replace(/^.+\n.+\n/,""))&&(r.stack+=`
16
- `+c):r.stack=c}catch{}}throw r}}_request(l,i){typeof l=="string"?(i=i||{},i.url=l):i=l||{},i=Zl(this.defaults,i);const{transitional:r,paramsSerializer:u,headers:c}=i;r!==void 0&&tu.assertOptions(r,{silentJSONParsing:Pn.transitional(Pn.boolean),forcedJSONParsing:Pn.transitional(Pn.boolean),clarifyTimeoutError:Pn.transitional(Pn.boolean)},!1),u!=null&&(B.isFunction(u)?i.paramsSerializer={serialize:u}:tu.assertOptions(u,{encode:Pn.function,serialize:Pn.function},!0)),i.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?i.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:i.allowAbsoluteUrls=!0),tu.assertOptions(i,{baseUrl:Pn.spelling("baseURL"),withXsrfToken:Pn.spelling("withXSRFToken")},!0),i.method=(i.method||this.defaults.method||"get").toLowerCase();let d=c&&B.merge(c.common,c[i.method]);c&&B.forEach(["delete","get","head","post","put","patch","common"],w=>{delete c[w]}),i.headers=Xt.concat(d,c);const m=[];let p=!0;this.interceptors.request.forEach(function(j){typeof j.runWhen=="function"&&j.runWhen(i)===!1||(p=p&&j.synchronous,m.unshift(j.fulfilled,j.rejected))});const y=[];this.interceptors.response.forEach(function(j){y.push(j.fulfilled,j.rejected)});let g,x=0,E;if(!p){const w=[Ty.bind(this),void 0];for(w.unshift(...m),w.push(...y),E=w.length,g=Promise.resolve(i);x<E;)g=g.then(w[x++],w[x++]);return g}E=m.length;let C=i;for(;x<E;){const w=m[x++],j=m[x++];try{C=w(C)}catch(N){j.call(this,N);break}}try{g=Ty.call(this,C)}catch(w){return Promise.reject(w)}for(x=0,E=y.length;x<E;)g=g.then(y[x++],y[x++]);return g}getUri(l){l=Zl(this.defaults,l);const i=I1(l.baseURL,l.url,l.allowAbsoluteUrls);return X1(i,l.params,l.paramsSerializer)}};B.forEach(["delete","get","head","options"],function(l){Kl.prototype[l]=function(i,r){return this.request(Zl(r||{},{method:l,url:i,data:(r||{}).data}))}});B.forEach(["post","put","patch"],function(l){function i(r){return function(c,d,m){return this.request(Zl(m||{},{method:l,headers:r?{"Content-Type":"multipart/form-data"}:{},url:c,data:d}))}}Kl.prototype[l]=i(),Kl.prototype[l+"Form"]=i(!0)});let e3=class av{constructor(l){if(typeof l!="function")throw new TypeError("executor must be a function.");let i;this.promise=new Promise(function(c){i=c});const r=this;this.promise.then(u=>{if(!r._listeners)return;let c=r._listeners.length;for(;c-- >0;)r._listeners[c](u);r._listeners=null}),this.promise.then=u=>{let c;const d=new Promise(m=>{r.subscribe(m),c=m}).then(u);return d.cancel=function(){r.unsubscribe(c)},d},l(function(c,d,m){r.reason||(r.reason=new ti(c,d,m),i(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(l){if(this.reason){l(this.reason);return}this._listeners?this._listeners.push(l):this._listeners=[l]}unsubscribe(l){if(!this._listeners)return;const i=this._listeners.indexOf(l);i!==-1&&this._listeners.splice(i,1)}toAbortSignal(){const l=new AbortController,i=r=>{l.abort(r)};return this.subscribe(i),l.signal.unsubscribe=()=>this.unsubscribe(i),l.signal}static source(){let l;return{token:new av(function(u){l=u}),cancel:l}}};function t3(n){return function(i){return n.apply(null,i)}}function n3(n){return B.isObject(n)&&n.isAxiosError===!0}const vd={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(vd).forEach(([n,l])=>{vd[l]=n});function lv(n){const l=new Kl(n),i=L1(Kl.prototype.request,l);return B.extend(i,Kl.prototype,l,{allOwnKeys:!0}),B.extend(i,l,null,{allOwnKeys:!0}),i.create=function(u){return lv(Zl(n,u))},i}const et=lv(_r);et.Axios=Kl;et.CanceledError=ti;et.CancelToken=e3;et.isCancel=P1;et.VERSION=nv;et.toFormData=Su;et.AxiosError=pe;et.Cancel=et.CanceledError;et.all=function(l){return Promise.all(l)};et.spread=t3;et.isAxiosError=n3;et.mergeConfig=Zl;et.AxiosHeaders=Xt;et.formToJSON=n=>Z1(B.isHTMLForm(n)?new FormData(n):n);et.getAdapter=tv.getAdapter;et.HttpStatusCode=vd;et.default=et;const{Axios:ON,AxiosError:a3,CanceledError:DN,isCancel:MN,CancelToken:UN,VERSION:LN,all:zN,Cancel:kN,isAxiosError:cu,spread:qN,toFormData:BN,AxiosHeaders:HN,HttpStatusCode:QN,formToJSON:YN,getAdapter:VN,mergeConfig:KN}=et,gd="__access_token__",l3=()=>{try{const n=localStorage.getItem(gd);return n||void 0}catch{return}},Xo=n=>{n?localStorage.setItem(gd,n):localStorage.removeItem(gd)};let s3={data:""},i3=n=>typeof window=="object"?((n?n.querySelector("#_goober"):window._goober)||Object.assign((n||document.head).appendChild(document.createElement("style")),{innerHTML:" ",id:"_goober"})).firstChild:n||s3,r3=/(?:([\u0080-\uFFFF\w-%@]+) *:? *([^{;]+?);|([^;}{]*?) *{)|(}\s*)/g,o3=/\/\*[^]*?\*\/| +/g,Ay=/\n+/g,il=(n,l)=>{let i="",r="",u="";for(let c in n){let d=n[c];c[0]=="@"?c[1]=="i"?i=c+" "+d+";":r+=c[1]=="f"?il(d,c):c+"{"+il(d,c[1]=="k"?"":l)+"}":typeof d=="object"?r+=il(d,l?l.replace(/([^,])+/g,m=>c.replace(/([^,]*:\S+\([^)]*\))|([^,])+/g,p=>/&/.test(p)?p.replace(/&/g,m):m?m+" "+p:p)):c):d!=null&&(c=/^--/.test(c)?c:c.replace(/[A-Z]/g,"-$&").toLowerCase(),u+=il.p?il.p(c,d):c+":"+d+";")}return i+(l&&u?l+"{"+u+"}":u)+r},_a={},sv=n=>{if(typeof n=="object"){let l="";for(let i in n)l+=i+sv(n[i]);return l}return n},u3=(n,l,i,r,u)=>{let c=sv(n),d=_a[c]||(_a[c]=(p=>{let y=0,g=11;for(;y<p.length;)g=101*g+p.charCodeAt(y++)>>>0;return"go"+g})(c));if(!_a[d]){let p=c!==n?n:(y=>{let g,x,E=[{}];for(;g=r3.exec(y.replace(o3,""));)g[4]?E.shift():g[3]?(x=g[3].replace(Ay," ").trim(),E.unshift(E[0][x]=E[0][x]||{})):E[0][g[1]]=g[2].replace(Ay," ").trim();return E[0]})(n);_a[d]=il(u?{["@keyframes "+d]:p}:p,i?"":"."+d)}let m=i&&_a.g?_a.g:null;return i&&(_a.g=_a[d]),((p,y,g,x)=>{x?y.data=y.data.replace(x,p):y.data.indexOf(p)===-1&&(y.data=g?p+y.data:y.data+p)})(_a[d],l,r,m),d},c3=(n,l,i)=>n.reduce((r,u,c)=>{let d=l[c];if(d&&d.call){let m=d(i),p=m&&m.props&&m.props.className||/^go/.test(m)&&m;d=p?"."+p:m&&typeof m=="object"?m.props?"":il(m,""):m===!1?"":m}return r+u+(d??"")},"");function Eu(n){let l=this||{},i=n.call?n(l.p):n;return u3(i.unshift?i.raw?c3(i,[].slice.call(arguments,1),l.p):i.reduce((r,u)=>Object.assign(r,u&&u.call?u(l.p):u),{}):i,i3(l.target),l.g,l.o,l.k)}let iv,bd,xd;Eu.bind({g:1});let Aa=Eu.bind({k:1});function f3(n,l,i,r){il.p=l,iv=n,bd=i,xd=r}function pl(n,l){let i=this||{};return function(){let r=arguments;function u(c,d){let m=Object.assign({},c),p=m.className||u.className;i.p=Object.assign({theme:bd&&bd()},m),i.o=/ *go\d+/.test(p),m.className=Eu.apply(i,r)+(p?" "+p:"");let y=n;return n[0]&&(y=m.as||n,delete m.as),xd&&y[0]&&xd(m),iv(y,m)}return u}}var d3=n=>typeof n=="function",fu=(n,l)=>d3(n)?n(l):n,h3=(()=>{let n=0;return()=>(++n).toString()})(),rv=(()=>{let n;return()=>{if(n===void 0&&typeof window<"u"){let l=matchMedia("(prefers-reduced-motion: reduce)");n=!l||l.matches}return n}})(),m3=20,ov=(n,l)=>{switch(l.type){case 0:return{...n,toasts:[l.toast,...n.toasts].slice(0,m3)};case 1:return{...n,toasts:n.toasts.map(c=>c.id===l.toast.id?{...c,...l.toast}:c)};case 2:let{toast:i}=l;return ov(n,{type:n.toasts.find(c=>c.id===i.id)?1:0,toast:i});case 3:let{toastId:r}=l;return{...n,toasts:n.toasts.map(c=>c.id===r||r===void 0?{...c,dismissed:!0,visible:!1}:c)};case 4:return l.toastId===void 0?{...n,toasts:[]}:{...n,toasts:n.toasts.filter(c=>c.id!==l.toastId)};case 5:return{...n,pausedAt:l.time};case 6:let u=l.time-(n.pausedAt||0);return{...n,pausedAt:void 0,toasts:n.toasts.map(c=>({...c,pauseDuration:c.pauseDuration+u}))}}},nu=[],Vl={toasts:[],pausedAt:void 0},Wl=n=>{Vl=ov(Vl,n),nu.forEach(l=>{l(Vl)})},p3={blank:4e3,error:4e3,success:2e3,loading:1/0,custom:4e3},y3=(n={})=>{let[l,i]=b.useState(Vl),r=b.useRef(Vl);b.useEffect(()=>(r.current!==Vl&&i(Vl),nu.push(i),()=>{let c=nu.indexOf(i);c>-1&&nu.splice(c,1)}),[]);let u=l.toasts.map(c=>{var d,m,p;return{...n,...n[c.type],...c,removeDelay:c.removeDelay||((d=n[c.type])==null?void 0:d.removeDelay)||n?.removeDelay,duration:c.duration||((m=n[c.type])==null?void 0:m.duration)||n?.duration||p3[c.type],style:{...n.style,...(p=n[c.type])==null?void 0:p.style,...c.style}}});return{...l,toasts:u}},v3=(n,l="blank",i)=>({createdAt:Date.now(),visible:!0,dismissed:!1,type:l,ariaProps:{role:"status","aria-live":"polite"},message:n,pauseDuration:0,...i,id:i?.id||h3()}),Nr=n=>(l,i)=>{let r=v3(l,n,i);return Wl({type:2,toast:r}),r.id},kt=(n,l)=>Nr("blank")(n,l);kt.error=Nr("error");kt.success=Nr("success");kt.loading=Nr("loading");kt.custom=Nr("custom");kt.dismiss=n=>{Wl({type:3,toastId:n})};kt.remove=n=>Wl({type:4,toastId:n});kt.promise=(n,l,i)=>{let r=kt.loading(l.loading,{...i,...i?.loading});return typeof n=="function"&&(n=n()),n.then(u=>{let c=l.success?fu(l.success,u):void 0;return c?kt.success(c,{id:r,...i,...i?.success}):kt.dismiss(r),u}).catch(u=>{let c=l.error?fu(l.error,u):void 0;c?kt.error(c,{id:r,...i,...i?.error}):kt.dismiss(r)}),n};var g3=(n,l)=>{Wl({type:1,toast:{id:n,height:l}})},b3=()=>{Wl({type:5,time:Date.now()})},hr=new Map,x3=1e3,S3=(n,l=x3)=>{if(hr.has(n))return;let i=setTimeout(()=>{hr.delete(n),Wl({type:4,toastId:n})},l);hr.set(n,i)},w3=n=>{let{toasts:l,pausedAt:i}=y3(n);b.useEffect(()=>{if(i)return;let c=Date.now(),d=l.map(m=>{if(m.duration===1/0)return;let p=(m.duration||0)+m.pauseDuration-(c-m.createdAt);if(p<0){m.visible&&kt.dismiss(m.id);return}return setTimeout(()=>kt.dismiss(m.id),p)});return()=>{d.forEach(m=>m&&clearTimeout(m))}},[l,i]);let r=b.useCallback(()=>{i&&Wl({type:6,time:Date.now()})},[i]),u=b.useCallback((c,d)=>{let{reverseOrder:m=!1,gutter:p=8,defaultPosition:y}=d||{},g=l.filter(C=>(C.position||y)===(c.position||y)&&C.height),x=g.findIndex(C=>C.id===c.id),E=g.filter((C,w)=>w<x&&C.visible).length;return g.filter(C=>C.visible).slice(...m?[E+1]:[0,E]).reduce((C,w)=>C+(w.height||0)+p,0)},[l]);return b.useEffect(()=>{l.forEach(c=>{if(c.dismissed)S3(c.id,c.removeDelay);else{let d=hr.get(c.id);d&&(clearTimeout(d),hr.delete(c.id))}})},[l]),{toasts:l,handlers:{updateHeight:g3,startPause:b3,endPause:r,calculateOffset:u}}},E3=Aa`
16
+ `+c):r.stack=c}catch{}}throw r}}_request(l,i){typeof l=="string"?(i=i||{},i.url=l):i=l||{},i=Zl(this.defaults,i);const{transitional:r,paramsSerializer:u,headers:c}=i;r!==void 0&&tu.assertOptions(r,{silentJSONParsing:Pn.transitional(Pn.boolean),forcedJSONParsing:Pn.transitional(Pn.boolean),clarifyTimeoutError:Pn.transitional(Pn.boolean)},!1),u!=null&&(B.isFunction(u)?i.paramsSerializer={serialize:u}:tu.assertOptions(u,{encode:Pn.function,serialize:Pn.function},!0)),i.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?i.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:i.allowAbsoluteUrls=!0),tu.assertOptions(i,{baseUrl:Pn.spelling("baseURL"),withXsrfToken:Pn.spelling("withXSRFToken")},!0),i.method=(i.method||this.defaults.method||"get").toLowerCase();let d=c&&B.merge(c.common,c[i.method]);c&&B.forEach(["delete","get","head","post","put","patch","common"],w=>{delete c[w]}),i.headers=Xt.concat(d,c);const m=[];let p=!0;this.interceptors.request.forEach(function(j){typeof j.runWhen=="function"&&j.runWhen(i)===!1||(p=p&&j.synchronous,m.unshift(j.fulfilled,j.rejected))});const y=[];this.interceptors.response.forEach(function(j){y.push(j.fulfilled,j.rejected)});let g,x=0,E;if(!p){const w=[Ty.bind(this),void 0];for(w.unshift(...m),w.push(...y),E=w.length,g=Promise.resolve(i);x<E;)g=g.then(w[x++],w[x++]);return g}E=m.length;let C=i;for(;x<E;){const w=m[x++],j=m[x++];try{C=w(C)}catch(N){j.call(this,N);break}}try{g=Ty.call(this,C)}catch(w){return Promise.reject(w)}for(x=0,E=y.length;x<E;)g=g.then(y[x++],y[x++]);return g}getUri(l){l=Zl(this.defaults,l);const i=I1(l.baseURL,l.url,l.allowAbsoluteUrls);return X1(i,l.params,l.paramsSerializer)}};B.forEach(["delete","get","head","options"],function(l){Kl.prototype[l]=function(i,r){return this.request(Zl(r||{},{method:l,url:i,data:(r||{}).data}))}});B.forEach(["post","put","patch"],function(l){function i(r){return function(c,d,m){return this.request(Zl(m||{},{method:l,headers:r?{"Content-Type":"multipart/form-data"}:{},url:c,data:d}))}}Kl.prototype[l]=i(),Kl.prototype[l+"Form"]=i(!0)});let e3=class av{constructor(l){if(typeof l!="function")throw new TypeError("executor must be a function.");let i;this.promise=new Promise(function(c){i=c});const r=this;this.promise.then(u=>{if(!r._listeners)return;let c=r._listeners.length;for(;c-- >0;)r._listeners[c](u);r._listeners=null}),this.promise.then=u=>{let c;const d=new Promise(m=>{r.subscribe(m),c=m}).then(u);return d.cancel=function(){r.unsubscribe(c)},d},l(function(c,d,m){r.reason||(r.reason=new ti(c,d,m),i(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(l){if(this.reason){l(this.reason);return}this._listeners?this._listeners.push(l):this._listeners=[l]}unsubscribe(l){if(!this._listeners)return;const i=this._listeners.indexOf(l);i!==-1&&this._listeners.splice(i,1)}toAbortSignal(){const l=new AbortController,i=r=>{l.abort(r)};return this.subscribe(i),l.signal.unsubscribe=()=>this.unsubscribe(i),l.signal}static source(){let l;return{token:new av(function(u){l=u}),cancel:l}}};function t3(n){return function(i){return n.apply(null,i)}}function n3(n){return B.isObject(n)&&n.isAxiosError===!0}const vd={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(vd).forEach(([n,l])=>{vd[l]=n});function lv(n){const l=new Kl(n),i=L1(Kl.prototype.request,l);return B.extend(i,Kl.prototype,l,{allOwnKeys:!0}),B.extend(i,l,null,{allOwnKeys:!0}),i.create=function(u){return lv(Zl(n,u))},i}const et=lv(_r);et.Axios=Kl;et.CanceledError=ti;et.CancelToken=e3;et.isCancel=P1;et.VERSION=nv;et.toFormData=Su;et.AxiosError=pe;et.Cancel=et.CanceledError;et.all=function(l){return Promise.all(l)};et.spread=t3;et.isAxiosError=n3;et.mergeConfig=Zl;et.AxiosHeaders=Xt;et.formToJSON=n=>Z1(B.isHTMLForm(n)?new FormData(n):n);et.getAdapter=tv.getAdapter;et.HttpStatusCode=vd;et.default=et;const{Axios:DN,AxiosError:a3,CanceledError:MN,isCancel:UN,CancelToken:LN,VERSION:zN,all:kN,Cancel:qN,isAxiosError:cu,spread:BN,toFormData:HN,AxiosHeaders:QN,HttpStatusCode:YN,formToJSON:VN,getAdapter:KN,mergeConfig:$N}=et,gd="__access_token__",l3=()=>{try{const n=localStorage.getItem(gd);return n||void 0}catch{return}},Xo=n=>{n?localStorage.setItem(gd,n):localStorage.removeItem(gd)};let s3={data:""},i3=n=>typeof window=="object"?((n?n.querySelector("#_goober"):window._goober)||Object.assign((n||document.head).appendChild(document.createElement("style")),{innerHTML:" ",id:"_goober"})).firstChild:n||s3,r3=/(?:([\u0080-\uFFFF\w-%@]+) *:? *([^{;]+?);|([^;}{]*?) *{)|(}\s*)/g,o3=/\/\*[^]*?\*\/| +/g,Ay=/\n+/g,il=(n,l)=>{let i="",r="",u="";for(let c in n){let d=n[c];c[0]=="@"?c[1]=="i"?i=c+" "+d+";":r+=c[1]=="f"?il(d,c):c+"{"+il(d,c[1]=="k"?"":l)+"}":typeof d=="object"?r+=il(d,l?l.replace(/([^,])+/g,m=>c.replace(/([^,]*:\S+\([^)]*\))|([^,])+/g,p=>/&/.test(p)?p.replace(/&/g,m):m?m+" "+p:p)):c):d!=null&&(c=/^--/.test(c)?c:c.replace(/[A-Z]/g,"-$&").toLowerCase(),u+=il.p?il.p(c,d):c+":"+d+";")}return i+(l&&u?l+"{"+u+"}":u)+r},_a={},sv=n=>{if(typeof n=="object"){let l="";for(let i in n)l+=i+sv(n[i]);return l}return n},u3=(n,l,i,r,u)=>{let c=sv(n),d=_a[c]||(_a[c]=(p=>{let y=0,g=11;for(;y<p.length;)g=101*g+p.charCodeAt(y++)>>>0;return"go"+g})(c));if(!_a[d]){let p=c!==n?n:(y=>{let g,x,E=[{}];for(;g=r3.exec(y.replace(o3,""));)g[4]?E.shift():g[3]?(x=g[3].replace(Ay," ").trim(),E.unshift(E[0][x]=E[0][x]||{})):E[0][g[1]]=g[2].replace(Ay," ").trim();return E[0]})(n);_a[d]=il(u?{["@keyframes "+d]:p}:p,i?"":"."+d)}let m=i&&_a.g?_a.g:null;return i&&(_a.g=_a[d]),((p,y,g,x)=>{x?y.data=y.data.replace(x,p):y.data.indexOf(p)===-1&&(y.data=g?p+y.data:y.data+p)})(_a[d],l,r,m),d},c3=(n,l,i)=>n.reduce((r,u,c)=>{let d=l[c];if(d&&d.call){let m=d(i),p=m&&m.props&&m.props.className||/^go/.test(m)&&m;d=p?"."+p:m&&typeof m=="object"?m.props?"":il(m,""):m===!1?"":m}return r+u+(d??"")},"");function Eu(n){let l=this||{},i=n.call?n(l.p):n;return u3(i.unshift?i.raw?c3(i,[].slice.call(arguments,1),l.p):i.reduce((r,u)=>Object.assign(r,u&&u.call?u(l.p):u),{}):i,i3(l.target),l.g,l.o,l.k)}let iv,bd,xd;Eu.bind({g:1});let Aa=Eu.bind({k:1});function f3(n,l,i,r){il.p=l,iv=n,bd=i,xd=r}function pl(n,l){let i=this||{};return function(){let r=arguments;function u(c,d){let m=Object.assign({},c),p=m.className||u.className;i.p=Object.assign({theme:bd&&bd()},m),i.o=/ *go\d+/.test(p),m.className=Eu.apply(i,r)+(p?" "+p:"");let y=n;return n[0]&&(y=m.as||n,delete m.as),xd&&y[0]&&xd(m),iv(y,m)}return u}}var d3=n=>typeof n=="function",fu=(n,l)=>d3(n)?n(l):n,h3=(()=>{let n=0;return()=>(++n).toString()})(),rv=(()=>{let n;return()=>{if(n===void 0&&typeof window<"u"){let l=matchMedia("(prefers-reduced-motion: reduce)");n=!l||l.matches}return n}})(),m3=20,ov=(n,l)=>{switch(l.type){case 0:return{...n,toasts:[l.toast,...n.toasts].slice(0,m3)};case 1:return{...n,toasts:n.toasts.map(c=>c.id===l.toast.id?{...c,...l.toast}:c)};case 2:let{toast:i}=l;return ov(n,{type:n.toasts.find(c=>c.id===i.id)?1:0,toast:i});case 3:let{toastId:r}=l;return{...n,toasts:n.toasts.map(c=>c.id===r||r===void 0?{...c,dismissed:!0,visible:!1}:c)};case 4:return l.toastId===void 0?{...n,toasts:[]}:{...n,toasts:n.toasts.filter(c=>c.id!==l.toastId)};case 5:return{...n,pausedAt:l.time};case 6:let u=l.time-(n.pausedAt||0);return{...n,pausedAt:void 0,toasts:n.toasts.map(c=>({...c,pauseDuration:c.pauseDuration+u}))}}},nu=[],Vl={toasts:[],pausedAt:void 0},Wl=n=>{Vl=ov(Vl,n),nu.forEach(l=>{l(Vl)})},p3={blank:4e3,error:4e3,success:2e3,loading:1/0,custom:4e3},y3=(n={})=>{let[l,i]=b.useState(Vl),r=b.useRef(Vl);b.useEffect(()=>(r.current!==Vl&&i(Vl),nu.push(i),()=>{let c=nu.indexOf(i);c>-1&&nu.splice(c,1)}),[]);let u=l.toasts.map(c=>{var d,m,p;return{...n,...n[c.type],...c,removeDelay:c.removeDelay||((d=n[c.type])==null?void 0:d.removeDelay)||n?.removeDelay,duration:c.duration||((m=n[c.type])==null?void 0:m.duration)||n?.duration||p3[c.type],style:{...n.style,...(p=n[c.type])==null?void 0:p.style,...c.style}}});return{...l,toasts:u}},v3=(n,l="blank",i)=>({createdAt:Date.now(),visible:!0,dismissed:!1,type:l,ariaProps:{role:"status","aria-live":"polite"},message:n,pauseDuration:0,...i,id:i?.id||h3()}),Nr=n=>(l,i)=>{let r=v3(l,n,i);return Wl({type:2,toast:r}),r.id},kt=(n,l)=>Nr("blank")(n,l);kt.error=Nr("error");kt.success=Nr("success");kt.loading=Nr("loading");kt.custom=Nr("custom");kt.dismiss=n=>{Wl({type:3,toastId:n})};kt.remove=n=>Wl({type:4,toastId:n});kt.promise=(n,l,i)=>{let r=kt.loading(l.loading,{...i,...i?.loading});return typeof n=="function"&&(n=n()),n.then(u=>{let c=l.success?fu(l.success,u):void 0;return c?kt.success(c,{id:r,...i,...i?.success}):kt.dismiss(r),u}).catch(u=>{let c=l.error?fu(l.error,u):void 0;c?kt.error(c,{id:r,...i,...i?.error}):kt.dismiss(r)}),n};var g3=(n,l)=>{Wl({type:1,toast:{id:n,height:l}})},b3=()=>{Wl({type:5,time:Date.now()})},hr=new Map,x3=1e3,S3=(n,l=x3)=>{if(hr.has(n))return;let i=setTimeout(()=>{hr.delete(n),Wl({type:4,toastId:n})},l);hr.set(n,i)},w3=n=>{let{toasts:l,pausedAt:i}=y3(n);b.useEffect(()=>{if(i)return;let c=Date.now(),d=l.map(m=>{if(m.duration===1/0)return;let p=(m.duration||0)+m.pauseDuration-(c-m.createdAt);if(p<0){m.visible&&kt.dismiss(m.id);return}return setTimeout(()=>kt.dismiss(m.id),p)});return()=>{d.forEach(m=>m&&clearTimeout(m))}},[l,i]);let r=b.useCallback(()=>{i&&Wl({type:6,time:Date.now()})},[i]),u=b.useCallback((c,d)=>{let{reverseOrder:m=!1,gutter:p=8,defaultPosition:y}=d||{},g=l.filter(C=>(C.position||y)===(c.position||y)&&C.height),x=g.findIndex(C=>C.id===c.id),E=g.filter((C,w)=>w<x&&C.visible).length;return g.filter(C=>C.visible).slice(...m?[E+1]:[0,E]).reduce((C,w)=>C+(w.height||0)+p,0)},[l]);return b.useEffect(()=>{l.forEach(c=>{if(c.dismissed)S3(c.id,c.removeDelay);else{let d=hr.get(c.id);d&&(clearTimeout(d),hr.delete(c.id))}})},[l]),{toasts:l,handlers:{updateHeight:g3,startPause:b3,endPause:r,calculateOffset:u}}},E3=Aa`
17
17
  from {
18
18
  transform: scale(0) rotate(45deg);
19
19
  opacity: 0;
@@ -189,5 +189,5 @@ to {
189
189
  > * {
190
190
  pointer-events: auto;
191
191
  }
192
- `,Fo=16,F3=({reverseOrder:n,position:l="top-center",toastOptions:i,gutter:r,children:u,containerStyle:c,containerClassName:d})=>{let{toasts:m,handlers:p}=w3(i);return b.createElement("div",{id:"_rht_toaster",style:{position:"fixed",zIndex:9999,top:Fo,left:Fo,right:Fo,bottom:Fo,pointerEvents:"none",...c},className:d,onMouseEnter:p.startPause,onMouseLeave:p.endPause},m.map(y=>{let g=y.position||l,x=p.calculateOffset(y,{reverseOrder:n,gutter:r,defaultPosition:l}),E=G3(g,x);return b.createElement($3,{id:y.id,key:y.id,onHeightUpdate:p.updateHeight,className:y.visible?X3:"",style:E},y.type==="custom"?fu(y.message,y):u?u(y):b.createElement(K3,{toast:y,position:g}))}))},sn=kt;const rt=new pS({defaultOptions:{queries:{staleTime:1e3*60*5,retry:(n,l)=>cu(l)&&l.response?.status===404?!1:n<3}},mutationCache:new R1({onError:n=>{cu(n)&&n.status&&n.status>=400&&n.status<500&&n.response?.data.error&&sn.error(n.response.data.error)}})}),Z3=async()=>{const{data:n}=await Yd.post("/auth/refresh");return n.data.accessToken},P3=async n=>{const{data:l}=await Yd.post("/auth/login",n);return l.data.accessToken},Ry=()=>{rt.invalidateQueries({queryKey:["accessToken"]})},Tr=(()=>{let n=Promise.resolve(l3()),l=!1;const i=async()=>{await Yd.post("/auth/logout"),Xo(void 0),window.location.reload()};return{get:async()=>n,refresh:()=>(l||(l=!0,n=Z3().then(d=>(Xo(d),d)).catch(()=>{Xo(void 0),i()}).finally(()=>{l=!1,Ry()})),n),login:d=>(l||(l=!0,n=P3(d).then(m=>(Xo(m),m)).finally(()=>{l=!1,Ry()})),n),logout:i}})(),uv=location.hostname.includes("app.dataramen.xyz")?"http://localhost:4466/api":"/api",Te=et.create({baseURL:uv,withCredentials:!0});Te.interceptors.request.use(async n=>{const l=await Tr.get();return l&&(n.headers.Authorization=`Bearer ${l}`),n});Te.interceptors.response.use(n=>n,n=>(cu(n)&&n.status===401&&n?.response?.data.error!=="Missing auth token"&&Tr.refresh(),Promise.reject(n)));const Yd=et.create({baseURL:uv,withCredentials:!0}),yl="data-sources",cv="auth-user",J3=n=>Ft({queryKey:["project","datasources",n],queryFn:async()=>{const{data:l}=await Te.get(`/project/team/${n}/datasources`);return l.data},enabled:!!n}),I3=n=>Ft({queryKey:["project","saved-queries",n],queryFn:async()=>{const{data:l}=await Te.get(`/project/team/${n}/queries`);return l.data},enabled:!!n}),ni=n=>{const l=["project","datasources"],i=["project","saved-queries"];return Promise.all([rt.invalidateQueries({queryKey:l}),rt.invalidateQueries({queryKey:i})])},W3=n=>{const l=["trash","team"];return rt.invalidateQueries({queryKey:l})},e4=(n,l)=>Ft({queryKey:["project",l.teamId,"tables",n,l.selectedDataSources],queryFn:async()=>{const{data:i}=await Te.get(`/project/team/${l.teamId}/query`,{params:{size:30,search:n,selectedDataSources:l.selectedDataSources}});return i.data},enabled:!!l.teamId,staleTime:0}),t4=n=>TS({queryKey:["project","tabs-history",n],queryFn:async({pageParam:l})=>{const{data:i}=await Te.get(`/project/team/${n}/tabs-history?page=${l}&size=30`);return i},select:({pages:l})=>l.flatMap(i=>i.data),enabled:!!n,initialPageParam:0,getNextPageParam:(l,i)=>{if(l.hasMore)return i.length},staleTime:0}),n4=()=>rt.invalidateQueries({queryKey:["project","tabs-history"]}),a4=(n,l)=>{},l4=()=>{},s4={event:a4,pageView:l4},Cu=n=>Ft({queryKey:[yl,n],queryFn:async()=>{const{data:l}=await Te.get("/data-sources/"+n);return l.data},enabled:!!n}),Vd=n=>Ft({queryKey:[yl,n.teamId],queryFn:async()=>{const{data:l}=await Te.get("/data-sources",{params:n});return l.data},enabled:n.teamId!==void 0}),ai=n=>Ft({queryKey:[yl,n,"inspections"],queryFn:async()=>{const{data:l}=await Te.get(`/data-sources/${n}/inspections`);return l.data},enabled:!!n}),i4=()=>vt({mutationFn:async n=>{const{data:l}=await Te.post("/data-sources",n);return l.data},onSuccess:()=>{rt.invalidateQueries({queryKey:[yl]}),ni()},onError:()=>{}}),r4=()=>vt({mutationFn:async({dataSource:n,id:l})=>{const{data:i}=await Te.put(`/data-sources/${l}`,n);return i.data},onSuccess:()=>{rt.invalidateQueries({queryKey:[yl]}),ni()}}),fv=()=>vt({mutationFn:async n=>{await Te.post(`/data-sources/${n}/inspect`)},onSuccess:()=>{rt.invalidateQueries({queryKey:[yl]})}}),o4=()=>vt({mutationFn:async n=>{await Te.delete(`/data-sources/${n}`)},onSuccess:()=>{rt.invalidateQueries({queryKey:[yl]}),ni()}}),dv=()=>Ft({queryKey:["accessToken"],queryFn:Tr.get}),Bn=()=>{const{data:n}=dv();return Ft({queryKey:[cv],queryFn:async()=>{const{data:l}=await Te.get("/users");return l.data},enabled:!!n,retry:(l,i)=>cu(i)&&i.code==="ERR_NETWORK"?!1:l<3})},u4=()=>vt({mutationFn:async n=>{const{data:l}=await Te.patch("/users",n);return l.data},onSuccess:async n=>{rt.setQueryData([cv],n)}}),c4=()=>vt({mutationFn:async n=>(await Te.post("/users",n),!0),onSuccess:()=>{rt.invalidateQueries({queryKey:["team-users"]})}}),f4="_alert_cie9h_2",d4="_info_cie9h_2",h4="_danger_cie9h_2",m4="_success_cie9h_2",p4="_warning_cie9h_2",y4="_dark_cie9h_2",ks={alert:f4,info:d4,danger:h4,success:m4,warning:p4,dark:y4};function hv(n){var l,i,r="";if(typeof n=="string"||typeof n=="number")r+=n;else if(typeof n=="object")if(Array.isArray(n)){var u=n.length;for(l=0;l<u;l++)n[l]&&(i=hv(n[l]))&&(r&&(r+=" "),r+=i)}else for(i in n)n[i]&&(r&&(r+=" "),r+=i);return r}function re(){for(var n,l,i=0,r="",u=arguments.length;i<u;i++)(n=arguments[i])&&(l=hv(n))&&(r&&(r+=" "),r+=l);return r}const wt=({variant:n,noRounded:l,className:i,children:r,...u})=>h.jsx("div",{className:re(ks.alert,!l&&"rounded-lg",(n==="info"||!n)&&ks.info,n==="danger"&&ks.danger,n==="dark"&&ks.dark,n==="warning"&&ks.warning,n==="success"&&ks.success,i),role:"alert",...u,children:r}),un=n=>{const l=new Set;let i=n;const r=m=>(l.add(m),()=>l.delete(m)),u=m=>(l.forEach(p=>p(m)),!0),c=m=>{i=typeof m=="function"?m(i):m,u(i)},d=m=>()=>m?m(i):i;return[m=>b.useSyncExternalStore(r,d(m),d(m)),c,{get:()=>i,subscribe:m=>(m(i),r(m))}]};function v4(n){const l=[];for(const i of n)for(const r of i.columns)r.ref&&(l.push({id:`${i.tableName}->${r.ref.table}.${r.ref.field}`,name:`${i.tableName} in ${r.ref.table}`,where:`${i.tableName}.${r.name} = ${r.ref.table}.${r.ref.field}`,on:{fromTable:r.ref.table,toTable:i.tableName,fromColumn:r.ref.field,toColumn:r.name}}),l.push({id:`${r.ref.table}->${i.tableName}.${r.name}`,name:`${r.ref.table} in ${i.tableName}`,where:`${r.ref.table}.${r.ref.field} = ${i.tableName}.${r.name}`,on:{fromTable:i.tableName,toTable:r.ref.table,fromColumn:r.name,toColumn:r.ref.field}}));return l}const g4=n=>Ft({queryKey:["hooks",n],queryFn:async()=>{const l=await rt.fetchQuery({queryKey:[yl,n,"inspections"],queryFn:async()=>{const{data:i}=await Te.get(`/data-sources/${n}/inspections`);return i.data}});return v4(l)},enabled:!!n}),Kd=[{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:"contains"},{value:"NOT LIKE",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"}],mv=Kd.reduce((n,l)=>(n[l.value]=l.label,n),{}),$d=Kd.reduce((n,l)=>(n[l.label]=l.value,n),{}),li=n=>n.map(l=>({label:mv[l],value:l})),b4=li(["=","<>",">",">=","<","<=","IN","NOT IN","IS NULL","IS NOT NULL"]),x4=li(["=","<>","LIKE","NOT LIKE","IN","NOT IN","IS NULL","IS NOT NULL"]);li(["=","<>","IS NULL","IS NOT NULL"]);const S4=li(["=","<>",">",">=","<","<=","IS NULL","IS NOT NULL"]);li(["IS NULL","IS NOT NULL"]);li(["IN","NOT IN"]);const pv=n=>n!=="IS NULL"&&n!=="IS NOT NULL",w4=(n,l)=>pv(n)?n==="IN"||n==="NOT IN"?l.split(",").map(i=>({value:i.trim(),isColumn:!1})):[{value:l,isColumn:!1}]:[],E4=["char","varchar","binary","varbinary","blob","text","enum","set","character","character varying","text","citext","uuid","xml","json","jsonb"],C4=["integer","smallint","decimal","numeric","float","real","double precision","int","smallint","integer","bigint","decimal","numeric","real","double precision","serial","bigserial","money"],_4=["date","time","datetime","timestamp","year","date","time","time without time zone","time with time zone","timestamp","timestamp without time zone","timestamp with time zone","interval"],N4=["date","datetime","timestamp","timestamptz"].reduce((n,l)=>(n[l]=!0,n),{}),yv=n=>n.fn?n.distinct===!0?`${n.fn} distinct ${n.value}`:`${n.fn} ${n.value}`:n.value;var $t=(n=>(n.OWNER="owner",n.ADMIN="admin",n.EDITOR="editor",n.READ_ONLY="read_only",n))($t||{});const Oy={[$t.READ_ONLY]:10,[$t.EDITOR]:20,[$t.ADMIN]:30,[$t.OWNER]:40};function T4(n,l){if(!n||!l)return{};const i=new Set;for(const u of l)u.table&&i.add(u.table);const r={};for(const u of i){const c=n.find(d=>d.tableName===u);if(c){r[u]=[];const d=c.columns.filter(m=>m.isPrimary);for(const m of d)if(l.find(y=>y.table===u&&y.column===m.name))r[u].push(m.name);else{delete r[u];break}}}return r}function j4(n,l,i,r){const{data:u}=g4(l),{data:c}=ai(l);return b.useMemo(()=>{const d=T4(c,n?.result.columns);return{name:i,tabId:r,hooks:(()=>{const m=[];if(!u||!n||!n.result.columns)return m;for(const p of u)(n.result.tables.includes(p.on.toTable)||n.result.tables.includes(p.on.fromTable))&&m.push(p);return m})(),availableJoins:(()=>{const m=[];if(!u||!n||!n.result.columns)return m;for(const p of u)!n.result.tables.includes(p.on.toTable)&&n.result.tables.includes(p.on.fromTable)&&m.push(p);return m})(),allColumns:n?.result.allColumns||[],dataSourceId:l,entities:Object.keys(d),getValue:(m,p)=>{const y=yv(p),g=n?.result.columns?.findIndex(x=>x.full===y);if(g!=null&&g>-1)return m[g]},getEntityKey:(m,p)=>d[m].reduce((y,g)=>{const x=n?.result.columns?.findIndex(E=>E.column===g&&E.table===m);return x!=null&&x>-1&&y.push([g,p[x]]),y},[]),getColumnType:m=>{const p=n?.result.allColumns.find(y=>y.full===m);if(p)return p.type}}},[n,l,u,c,i])}function A4(n,l){return b.useMemo(()=>({state:n,setState:l}),[n,l])}function $s(n){return{dataSourceId:n.dataSourceId||"",page:n?.page||0,size:n?.size||50,table:n.table||"",filters:n?.filters||[],joins:n?.joins??[],orderBy:n?.orderBy??[],columns:n?.columns??[],groupBy:n?.groupBy??[],aggregations:n?.aggregations??[]}}const Ye={home:{path:"/"},workbench:{path:"/workbench"},share:{path:"/share"},login:{path:"/login"}},Gd=n=>{rt.setQueryData(["workbench-tabs"],l=>n(l||[]))},R4=(n,l)=>{rt.setQueryData(["workbench-tabs",n],i=>i&&l(i))},Xd=()=>Ft({queryKey:["workbench-tabs"],queryFn:async()=>{const{data:n}=await Te.get("/workbench-tabs");return n.data}}),O4=n=>Ft({queryKey:["workbench-tabs",n],queryFn:async()=>{const{data:l}=await Te.get(`/workbench-tabs/${n}`);return l.data}}),si=()=>vt({mutationFn:async n=>{const{data:l}=await Te.post("/workbench-tabs",n);return l.data},onSuccess:async n=>{Gd(l=>[...l,n])}}),D4=()=>vt({mutationFn:async n=>(await Te.patch(`/workbench-tabs/${n}`,{archived:!0}),n),onMutate:n=>{Gd(l=>l.filter(i=>i.id!==n))}}),vv=()=>vt({mutationFn:async n=>(await Te.patch(`/workbench-tabs/${n}`,{archived:!1}),n),onSuccess:()=>bv()}),M4=()=>vt({mutationFn:async({id:n,payload:l})=>(await Te.patch(`/workbench-tabs/${n}`,l),!0),onMutate:({id:n,payload:l})=>{R4(n,i=>({...i,...l})),Gd(i=>i.map(r=>r.id!==n?r:{...r,name:l.name||r.name}))}}),U4=(n,l)=>{const{dataSourceId:i,searchAll:r,table:u,filters:c,joins:d,orderBy:m,groupBy:p,columns:y,aggregations:g,page:x=0,size:E=20}=l;return Ft({queryKey:["workbench-tab-runner",n,i,u,x,E,c,g,d,m,p,y,r],queryFn:async()=>{const{data:C}=await Te.post(`/workbench-tabs/${n}/run`,l);return C.data},retry:1,enabled:!!u&&!!i})},L4=()=>vt({mutationFn:async n=>{await Te.delete(`/workbench-tabs/${n}`)},onSuccess:()=>{bv(),n4()}}),gv=n=>rt.invalidateQueries({queryKey:["workbench-tab-runner",n]}),bv=()=>rt.invalidateQueries({queryKey:["workbench-tabs"]}),[z4,Ff,k4]=un(void 0),q4=async()=>new Promise(n=>{Ff({onCancel:()=>{Ff(void 0),n(void 0)},onConfirm:(l,i,r)=>{Ff(void 0),n({dsId:r,id:i,type:l})}})}),jr=n=>{const l=Et(),i=si(),r=vv();return b.useEffect(()=>{i?.data?.id&&l(`${Ye.workbench.path}/tab/${i.data.id}`),r?.data&&l(`${Ye.workbench.path}/tab/${r?.data}`)},[i.data,r.data]),b.useCallback(()=>{k4.get()||q4().then(c=>{c?.type==="table"?i.mutate({name:c.id,opts:$s({table:c.id,dataSourceId:c.dsId})}):c?.type==="query"?i.mutate({queryId:c.id}):c?.type==="tab"&&r.mutate(c.id)})},[l,n])},Ar=n=>{const{data:l}=Bn();return b.useMemo(()=>l?Oy[l.teamRole]>=Oy[n]:!1,[l,n])},B4="_input_sa5q9_2",H4="_small_sa5q9_2",Q4="_content_sa5q9_2",Y4="_form_sa5q9_2",V4="_mode-select_sa5q9_2",ze={input:B4,small:H4,content:Q4,form:Y4,switch:"_switch_sa5q9_2",modeSelect:V4},K4="_modal_1bv70_2",$4="_modal-visible_1bv70_2",G4="_modal-invisible_1bv70_2",X4="_backdrop_1bv70_2",F4="_modal-container_1bv70_2",Z4="_close-button_1bv70_2",Ys={modal:K4,modalVisible:$4,modalInvisible:G4,backdrop:X4,modalContainer:F4,closeButton:Z4},Pl=n=>b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...n},b.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32,d:"M368 368L144 144M368 144L144 368"})),cn=({children:n,backdropClose:l,isVisible:i,onClose:r,onClosed:u,noPadding:c=!1,portal:d=!1})=>{const[m,p]=b.useState(!1),y=()=>{l&&r()},g=E=>{i||getComputedStyle(E.currentTarget).opacity==="0"&&(p(!1),u&&u())};b.useEffect(()=>{i&&p(!0)},[i]);const x=h.jsxs("div",{onTransitionEnd:g,className:re(Ys.modal,i?Ys.modalVisible:Ys.modalInvisible),children:[h.jsx("div",{onClick:y,className:Ys.backdrop}),h.jsx("div",{className:re(Ys.modalContainer,c!==!0&&"p-4"),children:m&&n})]});return d?Gx.createPortal(x,document.body):x},aa=({onClick:n})=>{const l=b.useRef(n);return l.current=n,b.useEffect(()=>{const i=r=>{r.key==="Escape"&&l.current?.()};return window.addEventListener("keyup",i),()=>{window.removeEventListener("keyup",i)}},[]),h.jsx("button",{className:Ys.closeButton,onClick:n,children:h.jsx(Pl,{width:20,height:20})})},xv=({children:n})=>h.jsx("h2",{className:"text-xl font-semibold",children:n}),Rr=n=>{const[l,i]=b.useState(n),[r,u]=b.useState([]),c=b.useRef(n),d=b.useCallback((y,g)=>{i(x=>({...x,[y]:g}))},[]),m=b.useCallback(y=>g=>{g.target.type==="checkbox"?d(y,g.target.checked):d(y,g.target.value),u(x=>x.includes(y)?x:[...x,y])},[d]),p=b.useCallback(()=>{i(c.current),u([])},[]);return[l,{set:d,change:m,reset:p,touched:r}]},P4=({form:n,change:l})=>h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:re(ze.input,ze.small),children:[h.jsx("label",{children:"Database URL"}),h.jsx("input",{value:n.dbUrl,onChange:l("dbUrl"),className:"input"})]}),h.jsxs("div",{className:re(ze.input,ze.small),children:[h.jsx("label",{children:"Database port"}),h.jsx("input",{value:n.dbPort,onChange:l("dbPort"),type:"number",className:"input"})]}),h.jsxs("div",{className:re(ze.input,ze.small),children:[h.jsx("label",{children:"User"}),h.jsx("input",{value:n.dbUser,onChange:l("dbUser"),className:"input"})]}),h.jsxs("div",{className:re(ze.input,ze.small),children:[h.jsx("label",{children:"Password"}),h.jsx("input",{type:"password",value:n.dbPassword,onChange:l("dbPassword"),className:"input"})]}),h.jsxs("div",{className:re(ze.input,ze.small),children:[h.jsx("label",{children:"Database"}),h.jsx("input",{value:n.dbDatabase,onChange:l("dbDatabase"),className:"input"})]})]}),J4=({form:n,change:l})=>h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:re(ze.input,ze.small),children:[h.jsx("label",{children:"Database URL"}),h.jsx("input",{value:n.dbUrl,onChange:l("dbUrl"),className:"input"})]}),h.jsxs("div",{className:re(ze.input,ze.small),children:[h.jsx("label",{children:"Database port"}),h.jsx("input",{value:n.dbPort,onChange:l("dbPort"),type:"number",className:"input"})]}),h.jsxs("div",{className:re(ze.input,ze.small),children:[h.jsx("label",{children:"User"}),h.jsx("input",{value:n.dbUser,onChange:l("dbUser"),className:"input"})]}),h.jsxs("div",{className:re(ze.input,ze.small),children:[h.jsx("label",{children:"Password"}),h.jsx("input",{type:"password",value:n.dbPassword,onChange:l("dbPassword"),className:"input"})]}),h.jsxs("div",{className:re(ze.input,ze.small),children:[h.jsx("label",{children:"Database"}),h.jsx("input",{value:n.dbDatabase,onChange:l("dbDatabase"),className:"input"})]}),h.jsxs("div",{className:re(ze.input,ze.small),children:[h.jsx("label",{children:"Schema"}),h.jsx("input",{value:n.dbSchema,onChange:l("dbSchema"),className:"input"})]})]}),qs=[{label:"PostgreSQL",tag:"postgres"},{label:"MySQL",tag:"mysql"}],I4=({show:n,onClose:l,dbType:i="postgres"})=>{const r=i4(),u=fv(),{data:c}=Bn(),[d,{change:m,set:p}]=Rr({name:"",dbType:i,dbUrl:"",dbUser:"",dbPassword:"",dbDatabase:"",dbSchema:"",dbPort:5432,teamId:"",ownerId:"",description:"",allowInsert:!1,allowUpdate:!1}),y=async()=>{const w=await r.mutateAsync({...d,dbPort:Number(d.dbPort),teamId:c.teamId,ownerId:c.id});await u.mutateAsync(w.id),l(),s4.event("Create Datasource",{dbType:d.dbType})},g=w=>{p("allowInsert",!w),p("allowUpdate",!w)},x=()=>{l()},E=r.isPending||u.isPending,C=!d.allowInsert&&!d.allowUpdate;return h.jsxs(cn,{isVisible:n,onClose:x,children:[h.jsx(aa,{onClick:x}),h.jsxs(wt,{variant:"warning",className:"text-sm mb-2 max-w-xl",children:["DataRamen is currently under active development. In production-like environments, ",h.jsx("span",{className:"font-semibold underline",children:"it’s recommended to use read-only database credentials"}),"."]}),r.isError&&h.jsx(wt,{variant:"danger",className:"mb-2",children:h.jsx("span",{children:"Failed to connect to the database. Please check if the data are correct and retry."})}),r.isPending&&h.jsx(wt,{className:"mb-2",variant:"info",children:"Creating connection"}),u.isPending&&h.jsx(wt,{className:"mb-2",variant:"info",children:"Inspecting connection"}),h.jsxs("div",{className:ze.switch,children:[h.jsxs("label",{className:"button tertiary",children:[h.jsx("input",{type:"radio",name:"bdType",className:"mr-2",checked:d.dbType===qs[0].tag,onChange:()=>p("dbType",qs[0].tag)}),h.jsx("span",{children:qs[0].label})]}),h.jsxs("label",{className:"button tertiary",children:[h.jsx("input",{type:"radio",name:"bdType",className:"mr-2",checked:d.dbType===qs[1].tag,onChange:()=>p("dbType",qs[1].tag)}),h.jsx("span",{children:qs[1].label})]})]}),h.jsxs("div",{className:"overflow-y-auto mt-2",children:[h.jsx("div",{className:ze.content,children:h.jsxs("div",{className:ze.form,children:[h.jsxs("div",{className:re(ze.input,"col-span-2"),children:[h.jsx("label",{children:"Name"}),h.jsx("input",{value:d.name,onChange:m("name"),className:"input"})]}),h.jsxs("div",{className:re(ze.input,"col-span-2"),children:[h.jsx("label",{children:"Description"}),h.jsx("textarea",{value:d.description,onChange:m("description"),className:"input"})]}),d.dbType==="mysql"&&h.jsx(P4,{form:d,change:m}),d.dbType==="postgres"&&h.jsx(J4,{form:d,change:m})]})}),h.jsxs("div",{className:"mt-4",children:[h.jsxs("label",{className:ze.modeSelect,children:[h.jsxs("div",{children:[h.jsx("input",{type:"radio",name:"production-mode",className:"mr-2",checked:C,onChange:()=>g(!0)}),h.jsx("span",{className:"text-sm font-semibold",children:"Production mode"})]}),h.jsxs("p",{className:"text-xs mt-1 text-gray-600",children:["Mutation operations (such as INSERT or UPDATE) are ",h.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."]})]}),h.jsxs("label",{className:ze.modeSelect,children:[h.jsxs("div",{children:[h.jsx("input",{type:"radio",name:"production-mode",className:"mr-2",checked:!C,onChange:()=>g(!1)}),h.jsx("span",{className:"text-sm font-semibold",children:"Dev mode"})]}),h.jsxs("p",{className:"text-xs mt-1 text-gray-600",children:["Mutation operations (such as INSERT or UPDATE) are ",h.jsx("strong",{children:"allowed"}),". You will be able to insert new rows and edit existing data."]})]})]})]}),h.jsxs("div",{className:"flex justify-end gap-1 mt-2",children:[h.jsx("button",{onClick:x,className:"button tertiary",disabled:E,children:"Cancel"}),h.jsx("button",{onClick:y,className:"button primary",disabled:E,children:"Create"})]})]})},W4="_data-source-entry_1ktzz_2",eE="_action-title_1ktzz_2",tE="_action-subtext_1ktzz_2",nE="_dev-tag_1ktzz_2",aE="_prod-tag_1ktzz_2",Kt={dataSourceEntry:W4,actionTitle:eE,actionSubtext:tE,devTag:nE,prodTag:aE},lE=n=>b.createElement("svg",{fill:"#000000",width:"800px",height:"800px",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",...n},b.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"})),sE=n=>b.createElement("svg",{width:"800px",height:"800px",viewBox:"0 0 32 32",xmlns:"http://www.w3.org/2000/svg",...n},b.createElement("title",null,"file_type_pgsql"),b.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"}),b.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"}}),b.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"}}),b.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"}})),ii=({size:n,type:l})=>l==="mysql"?h.jsx(lE,{width:n,height:n}):h.jsx(sE,{width:n,height:n}),[iE,Gs]=un(void 0),[rE,Xs]=un({show:!1}),oE=()=>{const n=jr("Home");return h.jsxs("div",{className:"card-white lg:col-span-2",onClick:n,children:[h.jsxs("h2",{className:Kt.actionTitle,children:[h.jsx("span",{children:"🔎 Start new query"}),h.jsx("span",{className:"hotkey",children:"N"})]}),h.jsx("input",{className:"input mt-3 w-full",placeholder:"Search table or query to start"})]})},uE=()=>{const[n,l]=b.useState(void 0),i=Ar($t.EDITOR),r=u=>{i?l(u):sn.error("You don't have permission to connect new data sources in this team")};return h.jsxs("div",{children:[n&&h.jsx(I4,{show:!0,dbType:n,onClose:()=>l(void 0)}),h.jsxs("div",{className:"card-white hover:bg-gray-50! cursor-pointer",onClick:()=>r("postgres"),children:[h.jsx("p",{className:Kt.actionTitle,children:"🧙‍♂️ Connection wizard"}),h.jsx("p",{className:Kt.actionSubtext,children:"Configure new database connection."})]})]})},cE=()=>{const n=Et(),{data:l}=Xd(),i=jr("Home"),r=()=>{l&&l.length>0?n(`${Ye.workbench.path}/tab/${l[0].id}`):i()};return h.jsxs("div",{className:"card-white hover:bg-gray-50! cursor-pointer",onClick:r,children:[h.jsxs("h2",{className:Kt.actionTitle,children:[h.jsx("span",{children:"🛠️ Workbench"}),h.jsx("span",{className:"hotkey",children:"W"})]}),h.jsx("p",{className:Kt.actionSubtext,children:"Continue your work from where you left."})]})},fE=()=>{const{data:n}=Bn(),{data:l}=Vd({teamId:n?.teamId}),i=r=>{Gs(r)};return!l||l.length===0?null:h.jsxs("div",{className:"mt-8",children:[h.jsx("h2",{className:"font-semibold text-gray-700",children:"Data sources"}),h.jsx("div",{className:"grid lg:grid-cols-3 gap-2 mt-4",children:l?.map(r=>h.jsxs("div",{className:Kt.dataSourceEntry,onClick:()=>i(r.id),tabIndex:0,children:[h.jsx(ii,{size:32,type:r.dbType}),h.jsxs("div",{className:"overflow-hidden",children:[h.jsx("p",{className:"font-semibold truncate text-gray-800 flex-1",children:r.name}),r.allowInsert?h.jsx("span",{className:Kt.devTag,children:"dev"}):h.jsx("span",{className:Kt.prodTag,children:"prod"})]})]},r.id))})]})},dE=()=>h.jsxs("div",{className:"mt-8",children:[h.jsx("h2",{className:"font-semibold text-gray-700",children:"Useful links"}),h.jsxs("div",{className:"grid lg:grid-cols-3 gap-2 mt-4",children:[h.jsxs("a",{className:"card-white hover:bg-gray-50!",href:"https://dataramen.xyz/",children:[h.jsx("h2",{className:Kt.actionTitle,children:"↗️ Documentation"}),h.jsx("p",{className:Kt.actionSubtext,children:"Learn how to use DataRamen"})]}),h.jsxs("a",{className:"card-white hover:bg-gray-50!",href:"https://github.com/OleksandrDemian/dataramen",children:[h.jsx("h2",{className:Kt.actionTitle,children:"↗️ Github"}),h.jsx("p",{className:Kt.actionSubtext,children:"Codebase is open source"})]}),h.jsxs("a",{className:"card-white hover:bg-gray-50!",href:"#",onClick:()=>Xs({show:!0}),children:[h.jsxs("h2",{className:Kt.actionTitle,children:[h.jsx("span",{children:"⌛ Recent tabs"}),h.jsx("span",{className:"hotkey",children:"H"})]}),h.jsx("p",{className:Kt.actionSubtext,children:"Manage recent tabs"})]})]})]}),hE=()=>{const{data:n}=Bn(),{data:l}=Vd({teamId:n?.teamId}),i=!!l&&l.length>0,r=!!n;return h.jsx("div",{className:"page-container h-screen max-h-screen bg-(--bg)",children:h.jsxs("div",{className:"page-content h-full pb-12 overflow-y-auto",children:[h.jsx("h2",{className:"font-semibold text-gray-700 mt-4 hidden lg:block",children:"Quick actions"}),r&&!i&&h.jsx(wt,{variant:"warning",className:"font-semibold mt-4",children:"Connect at least one datasource to start using DataRamen"}),h.jsxs("div",{className:"grid lg:grid-cols-2 gap-2 mt-4",children:[h.jsx(oE,{}),h.jsx(uE,{}),r&&h.jsx(cE,{})]}),r&&h.jsx(fE,{}),h.jsx(dE,{})]})})},[mE,Fd]=un(void 0),pE=()=>Fd(void 0);function $l(n,l){if(n==null)return"";switch(l){case"json":case"jsonb":return JSON.stringify(n,null,2)}if(n===0||n===!1)return n.toString();switch(typeof n){case"string":return n;case"number":case"boolean":return n.toString();default:return JSON.stringify(n)}}const yE=n=>{const l=n.value?.map(i=>i.value).join(", ")||"";return`${n.column} ${n.operator} ${l}`},vE=n=>n.value?.map(l=>l.value).join(", ")||"",au=n=>n.distinct?[n.fn,"DISTINCT",n.value].join(" "):[n.fn,n.value].join(" "),ol=n=>{let l=n.replace(/[_-]+/g," ");return l=l.replace(/([a-z0-9])([A-Z])/g,"$1 $2"),l=l.toLowerCase().replace(/\b\w/g,i=>i.toUpperCase()),l},gE="_container_13dmo_2",bE="_header_13dmo_2",xE="_fields-container_13dmo_2",SE="_field-label_13dmo_2",wE="_actions_13dmo_2",ur={container:gE,header:bE,fieldsContainer:xE,fieldLabel:SE,actions:wE},dl=()=>Date.now().toString(36)+Math.random().toString(36).substring(2),EE=(n,l,i)=>Ft({queryKey:["entity",n,l,i],queryFn:async()=>{const r=i?i.map(([c,d])=>({id:dl(),column:c,operator:"=",value:[{value:d}],connector:"AND"})):[],{data:u}=await Te.post("/runner/select",{datasourceId:n,opts:{table:l,filters:r,joins:[],columns:[],orderBy:[],groupBy:[],aggregations:[]},size:1,page:0,name:`Select ${l}: [${i?.join()}]`});return u.data},retry:1,enabled:!!l&&!!n&&!!i,staleTime:0}),CE=()=>vt({mutationFn:async n=>{const{data:l}=await Te.post("/runner/update",n);return l.data}}),_E=()=>vt({mutationFn:async n=>{const{data:l}=await Te.post("/runner/insert",n);return l.data}}),Zd=n=>b.useMemo(()=>{if(n)return n instanceof a3?n.response?.data.error?n.response.data.error:n.response?.data?.message?n.response.data.message:n.message:n instanceof Error?n.message:"Undefined error"},[n]),Pd=()=>{const{pathname:n}=qt();return b.useMemo(()=>pr({path:`${Ye.workbench.path}/tab/:id`,end:!1},n)?.params.id,[n])},NE=({data:n})=>{const[l,{change:i,touched:r}]=Rr({}),u=Pd(),{mutateAsync:c,error:d}=_E(),m=Zd(d),{data:p}=ai(n.dataSourceId),[y,g]=b.useState(""),x=b.useMemo(()=>p?.find(w=>w.tableName===n.table),[p,n.table]),E=b.useMemo(()=>{if(!x)return[];if(!y)return x.columns.map(j=>({...j,label:ol(j.name)}));const w=y.toLowerCase();return x.columns.filter(j=>j.name.toLowerCase().includes(w)).map(j=>({...j,label:ol(j.name)}))},[y,x]),C=()=>{const w=[];for(const j of r)w.push({value:l[j],column:j});c({datasourceId:n.dataSourceId,table:n.table,values:w}).then(()=>{pE(),u&&gv(u)})};return h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:ur.header,children:[h.jsxs("p",{className:"text-lg font-semibold",children:["Insert new row in ",h.jsx("span",{className:"underline",children:n.table})]}),m&&h.jsx(wt,{variant:"danger",children:h.jsx("p",{children:m})})]}),h.jsx("div",{className:"bg-gray-50 py-1 px-4 border-y border-gray-200",children:h.jsx("p",{className:"text-xs text-gray-800",children:"Tip: use = to write raw SQL. Ex: =NULL or =NOW()"})}),h.jsx("div",{className:ur.container,children:h.jsx("div",{className:ur.fieldsContainer,children:E.map(w=>h.jsxs("label",{className:ur.fieldLabel,children:[h.jsxs("div",{className:"flex justify-between",children:[h.jsxs("p",{children:[w.isPrimary?"🔐":"🏷️"," ",w.label]}),h.jsxs("p",{className:"text-blue-800 text-sm",children:["[",w.name,": ",w.type,"]"]})]}),h.jsx("input",{className:"input w-full",value:$l(l[w.name]),onChange:i(w.name),placeholder:w.name})]},w.name))})}),h.jsxs("div",{className:ur.actions,children:[h.jsxs("label",{children:[h.jsx("span",{className:"mr-2",children:"🔎"}),h.jsx("input",{className:"input bg-white!",value:y,onChange:w=>g(w.target.value),placeholder:"Filter columns"})]}),h.jsx("span",{className:"flex-1"}),h.jsx("button",{disabled:!r.length,className:"button primary",onClick:C,children:"Run insert"})]})]})},TE=()=>{const n=mE(),[l,i]=b.useState(void 0);b.useEffect(()=>{n&&i(n)},[n]);const r=()=>Fd(void 0);return h.jsxs(cn,{isVisible:n!=null,onClose:r,onClosed:()=>i(void 0),noPadding:!0,children:[h.jsx(aa,{onClick:r}),l&&h.jsx(NE,{data:l})]})},[jE,Jd]=un(void 0),AE=()=>Jd(void 0),RE="_container_1w6r3_2",OE="_header_1w6r3_2",DE="_key_1w6r3_2",ME="_fields-container_1w6r3_2",UE="_field-label_1w6r3_2",LE="_actions_1w6r3_2",Bs={container:RE,header:OE,key:DE,fieldsContainer:ME,fieldLabel:UE,actions:LE},zE=({data:n})=>{const[l,{change:i,set:r,reset:u,touched:c}]=Rr({}),d=Pd(),[m,p]=b.useState(""),{data:y,isLoading:g}=EE(n.dataSourceId,n.tableName,n.entityId),{mutateAsync:x,error:E}=CE(),C=Zd(E),w=Ar($t.EDITOR),{data:j}=ai(n.dataSourceId),{data:N}=Cu(n.dataSourceId),_=b.useMemo(()=>j?.find(V=>V.tableName===n.tableName),[n.tableName,j]),T=b.useMemo(()=>{if(!_)return[];if(!m)return _.columns.map(K=>({...K,label:ol(K.name)}));const V=m.toLowerCase();return _.columns.filter(K=>K.name.toLowerCase().includes(V)).map(K=>({...K,label:ol(K.name)}))},[m,_]);b.useEffect(()=>{const V=y?.rows[0];if(u(),V&&y?.columns)for(let K=0;K<y.columns.length;K++){const Z=y.columns[K];r(Z.column,$l(V[K]))}},[y,r,u]);const D=()=>{const V=[];for(const K of c)V.push({value:l[K],column:K});x({datasourceId:n.dataSourceId,table:n.tableName,filters:n.entityId.map(K=>({id:dl(),value:[{value:K[1]}],column:K[0],connector:"AND",operator:"="})),values:V}).then(()=>{AE(),d&&gv(d)})},H=n.entityId.map(([V,K])=>`${V} = ${K}`).join(", ")||"",G=!N?.allowUpdate||!w;return h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:Bs.header,children:[h.jsxs("p",{className:"text-lg font-semibold",children:[G?"View":"Edit"," row in ",h.jsx("span",{className:"underline",children:n?.tableName})]}),h.jsx("span",{className:Bs.key,children:H}),C&&h.jsx(wt,{variant:"danger",children:h.jsx("p",{children:C})})]}),!G&&h.jsx("div",{className:"bg-gray-50 py-1 px-4 border-y border-gray-200",children:h.jsx("p",{className:"text-xs text-gray-800",children:"Tip: use = to write raw SQL. Ex: =NULL or =NOW()"})}),h.jsx("div",{className:Bs.container,children:h.jsx("div",{className:Bs.fieldsContainer,children:T.map(V=>h.jsxs("label",{className:Bs.fieldLabel,children:[h.jsxs("div",{className:"flex justify-between",children:[h.jsxs("p",{children:[V.isPrimary?"🔐":"🏷️"," ",V.label]}),h.jsxs("p",{className:"text-blue-800 text-sm",children:["[",V.name,": ",V.type,"]"]})]}),h.jsx("input",{disabled:V.isPrimary||g||G,className:"input w-full",value:$l(l[V.name]),onChange:i(V.name),placeholder:V.name})]},V.name))})}),h.jsxs("div",{className:Bs.actions,children:[h.jsxs("label",{children:[h.jsx("span",{className:"mr-2",children:"🔎"}),h.jsx("input",{className:"input bg-white!",value:m,onChange:V=>p(V.target.value),placeholder:"Filter columns"})]}),h.jsx("span",{className:"flex-1"}),!G&&h.jsx("button",{disabled:!c.length,className:"button primary",onClick:D,children:"Run update"})]})]})},kE=()=>{const n=jE(),[l,i]=b.useState(void 0);b.useEffect(()=>{n&&i(n)},[n]);const r=()=>Jd(void 0);return h.jsxs(cn,{isVisible:n!=null,onClose:r,onClosed:()=>i(void 0),noPadding:!0,children:[h.jsx(aa,{onClick:r}),l&&h.jsx(zE,{data:l})]})},[qE,Zf]=un(void 0),Sv=async n=>new Promise(l=>{Zf({message:n,onCancel:()=>{l(!1),Zf(void 0)},onConfirm:()=>{l(!0),Zf(void 0)}})}),BE=({confirm:n})=>h.jsxs("div",{children:[h.jsx("p",{children:n.message}),h.jsxs("div",{className:"flex gap-2 justify-end mt-4",children:[h.jsx("button",{className:"button tertiary",onClick:n.onCancel,children:"Cancel"}),h.jsx("button",{className:"button primary",onClick:n.onConfirm,children:"Confirm"})]})]}),HE=()=>{const n=qE(),[l,i]=b.useState(void 0);return b.useEffect(()=>{n&&i(n)},[n]),h.jsx(cn,{isVisible:!!n,onClose:()=>n?.onCancel(),onClosed:()=>i(void 0),children:l&&h.jsx(BE,{confirm:l})})},[QE,lu]=un(void 0),Or=async(n,l,i)=>new Promise(r=>{lu({message:n,defaultValue:l,alert:i,onCancel:()=>{lu(void 0),r(void 0)},onConfirm:u=>{lu(void 0),r(u)}})}),YE="_root_12mtw_1",VE={root:YE},KE=({data:n})=>{const[l,i]=b.useState("");b.useEffect(()=>{n.defaultValue&&i(n.defaultValue)},[n]);const r=c=>{i(c.target.value)},u=c=>{c.key==="Enter"&&(c.preventDefault(),n.onConfirm(l)),c.key==="Escape"&&(c.preventDefault(),n.onCancel())};return h.jsxs("div",{className:VE.root,children:[h.jsx("h2",{className:"text-xl font-semibold",children:n.message}),n.alert&&h.jsx(wt,{variant:n.alert.type,className:"mt-2",children:n.alert.message}),h.jsx("input",{autoFocus:!0,className:"w-full input my-2",value:l,onChange:r,onKeyDown:u}),h.jsxs("div",{className:"flex justify-end gap-2",children:[h.jsx("button",{className:"button tertiary",onClick:n.onCancel,children:"Cancel"}),h.jsx("button",{className:"button primary",onClick:()=>n.onConfirm(l),children:"Confirm"})]})]})},$E=()=>{const n=QE(),[l,i]=b.useState(void 0);return b.useEffect(()=>{n&&i(n)},[n]),h.jsx(cn,{isVisible:!!n,onClose:()=>lu(void 0),onClosed:()=>i(void 0),children:l&&h.jsx(KE,{data:l})})},[GE,XE]=un(void 0),wv=n=>{XE(n)},FE="_textarea_30cyl_2",ZE={textarea:FE},PE=()=>{const n=GE(),l=()=>{n&&(navigator.clipboard.writeText(n.toString()),sn.success("Copied!"))},i=()=>wv(void 0);return h.jsxs(cn,{isVisible:!!n,onClose:i,backdropClose:!0,children:[h.jsx("textarea",{className:ZE.textarea,readOnly:!0,defaultValue:n?.toString()}),h.jsxs("div",{className:"mt-2 flex gap-1 justify-end",children:[h.jsx("button",{className:"button primary",onClick:l,children:"Copy"}),h.jsx("button",{className:"button tertiary",onClick:i,children:"Close"})]})]})},JE="_tabs_1jhm8_2",IE="_mobile_1jhm8_2",WE="_tab_1jhm8_2",eC="_active_1jhm8_2",tC="_close-button_1jhm8_2",cr={tabs:JE,mobile:IE,tab:WE,active:eC,closeButton:tC},Dy=n=>window.matchMedia(n).matches;function Ev(n,{defaultValue:l=!1,initializeWithValue:i=!0}={}){const[r,u]=b.useState(()=>i?Dy(n):l);return b.useLayoutEffect(()=>{const c=window.matchMedia(n);function d(){u(()=>Dy(n))}return d(),c.addListener?c.addListener(d):c.addEventListener("change",d),()=>{c.removeListener?c.removeListener(d):c.removeEventListener("change",d)}},[n]),r}const Id={laptop:"(min-width: 1024px)"},nC=()=>window.matchMedia(Id.laptop).matches,aC="_table_y5s2h_2",lC="_semi-transparent_y5s2h_2",sC="_table-loading_y5s2h_2",iC="_table-empty_y5s2h_2",rC="_table-row-cells_y5s2h_2",oC="_header-cell_y5s2h_2",uC="_header-actions_y5s2h_2",cC="_cell_y5s2h_2",fC="_cell-actions_y5s2h_2",dC="_value_y5s2h_2",hC="_table-config_y5s2h_2",mC="_tab-name_y5s2h_2",pC="_table-action_y5s2h_2",yC="_blue_y5s2h_2",vC="_modal_y5s2h_2",gC="_selected-size_y5s2h_2",bC="_options-container_y5s2h_2",xC="_row-options-entries-list_y5s2h_2",SC="_underlying-rows-btn_y5s2h_2",wC="_option-item_y5s2h_2",EC="_pagination-indicator_y5s2h_2",se={table:aC,semiTransparent:lC,tableLoading:sC,tableEmpty:iC,tableRowCells:rC,headerCell:oC,headerActions:uC,cell:cC,cellActions:fC,value:dC,tableConfig:hC,tabName:mC,tableAction:pC,blue:yC,modal:vC,selectedSize:gC,optionsContainer:bC,rowOptionsEntriesList:xC,underlyingRowsBtn:SC,optionItem:wC,paginationIndicator:EC},vl=b.createContext({name:"No name",hooks:[],availableJoins:[],allColumns:[],dataSourceId:"",entities:[],getValue:()=>{},getColumnType:()=>{},getEntityKey:()=>[]}),Zt=b.createContext({state:$s({}),setState:()=>{}}),Ra=b.createContext({}),Cv={ON_ANIMATION_END:Symbol("ON_TRANSITION_END")},_v=()=>{const[n,l]=b.useState(),[i,r]=b.useState("hidden");return b.useMemo(()=>{const u=m=>{m.preventDefault(),r("in"),l({x:m.clientX-1,y:m.clientY-1})},c=()=>{r("out")},d=m=>{console.log("onAnimationEnd",m),i==="in"?r("visible"):i==="out"&&(l(void 0),r("hidden"))};return{show:!!n,position:n,state:i,open:u,close:c,[Cv.ON_ANIMATION_END]:d}},[n,i])},CC=n=>{if(n==="ASC")return"DESC";if(n!=="DESC")return"ASC"},_C=()=>{const{state:n,setState:l}=b.useContext(Zt),i=b.useCallback(r=>{l(u=>{const c=u.orderBy[0];if(c&&c.column===r){const d=CC(c.direction);return d?{...u,orderBy:[{column:r,direction:d}]}:{...u,orderBy:[]}}return{...u,orderBy:[{column:r,direction:"ASC"}]}})},[l]);return{orderBy:n.orderBy,updateOrderBy:i}};function NC(n){const l=n.target?.dataset;if(l){if(l.copyCol&&l.copyRow)return{col:parseInt(l.copyCol),row:parseInt(l.copyRow),action:"copy"};if(l.showCol&&l.showRow)return{col:parseInt(l.showCol),row:parseInt(l.showRow),action:"show"};if(l.filterCol&&l.filterRow)return{col:parseInt(l.filterCol),row:parseInt(l.filterRow),action:"filter"}}}function Pf(n,l,i){const r=n?.rows?.[l]?.[i],u=n?.columns?.[i];return{value:r,column:u}}const TC=()=>{const{data:n}=b.useContext(Ra),{getColumnType:l}=b.useContext(vl),{setState:i}=b.useContext(Zt),r=m=>{const{value:p,column:y}=Pf(n?.result,m.row,m.col);if(y){const g=$l(p,l(y.full));navigator.clipboard.writeText(g),sn.success("Copied!")}},u=m=>{const{value:p,column:y}=Pf(n?.result,m.row,m.col);if(y){const g=$l(p,l(y.full));wv(g)}},c=m=>{const{value:p,column:y}=Pf(n?.result,m.row,m.col);let g=y?.full||"",x;if(y?.table===""){sn.error("Filtering on aggregated column is not supported yet");return}if(g){let E;if(p==null)E={id:dl(),isEnabled:!0,column:g,connector:"AND",operator:"IS NULL"};else{const C=$l(p,l(g));E={id:dl(),isEnabled:!0,column:g,connector:"AND",operator:"=",fn:x,value:[{value:C}]}}i(C=>({...C,filters:[...C.filters,E]})),sn.success(`Added new filter on column ${y?.alias}`)}};return m=>{const p=NC(m);p&&(p.action==="copy"?r(p):p.action==="show"?u(p):p.action==="filter"&&c(p))}},jC="_container_1kx3r_2",AC="_animate-show_1kx3r_2",RC="_animate-hide_1kx3r_2",OC="_content_1kx3r_2",DC="_backdrop_1kx3r_2",Hl={container:jC,animateShow:AC,animateHide:RC,content:OC,backdrop:DC},Nv=({children:n,handler:l})=>{const i=b.useRef(l.close);i.current=l.close;const r=b.useMemo(()=>{if(!l.position)return;const u={};if(typeof window<"u"){const c=l.position.y>window.innerHeight/2,d=l.position.x>window.innerWidth/2;c?u.bottom=window.innerHeight-l.position.y:u.top=l.position.y,nC()?d?u.right=window.innerWidth-l.position.x:u.left=l.position.x:(u.right=36,u.left=36)}return u},[l.position]);return b.useEffect(()=>{const u=c=>{c.code==="Escape"&&i.current()};return window.addEventListener("keyup",u),()=>{window.removeEventListener("keyup",u)}},[]),r?h.jsxs("div",{className:re(Hl.container,l.state==="out"&&Hl.animateHide,l.state==="in"&&Hl.animateShow),onAnimationEnd:l[Cv.ON_ANIMATION_END],children:[h.jsx("div",{className:Hl.backdrop,onClick:u=>{u.stopPropagation(),u.preventDefault(),l.close()}}),h.jsx("div",{className:re(Hl.content,l.state==="out"&&Hl.animateHide,l.state==="in"&&Hl.animateShow),style:r,children:n})]}):null},MC="_table_pc08i_2",UC="_root_pc08i_2",LC="_content_pc08i_2",zC="_sub_pc08i_2",Zo={table:MC,root:UC,content:LC,sub:zC},Tv=({hook:n,onClick:l})=>h.jsxs("button",{className:Zo.root,onClick:l,children:[h.jsx("span",{children:"📄"}),h.jsxs("div",{className:Zo.content,children:[h.jsxs("p",{className:Zo.table,children:[" ",n.on.toTable]}),h.jsxs("span",{className:Zo.sub,children:[n.on.toColumn," = ",n.on.fromTable,".",n.on.fromColumn]})]})]},n.where),hl=(n,l)=>n!=null&&n>l,kC=({handler:n,rowIndex:l})=>{const{hooks:i,entities:r,dataSourceId:u,getEntityKey:c,getValue:d}=b.useContext(vl),{state:m}=b.useContext(Zt),{data:p}=b.useContext(Ra),[y,g]=b.useState(""),x=b.useMemo(()=>p?.result.rows[l],[p,l]),E=si(),C=Et(),[w,j]=b.useState("hooks"),N=()=>{x&&E.mutateAsync({name:`${m.table} > [${m.joins.map(V=>V.table).join()}]`,opts:$s({joins:m.joins,table:m.table,dataSourceId:m.dataSourceId,filters:[...m.filters,...m.groupBy.map(V=>({id:dl(),connector:"AND",column:V.value,operator:"=",value:[{value:d(x,V)}]}))]})}).then(V=>{C(`${Ye.workbench.path}/tab/${V.id}`),n.close()})},_=V=>{if(!x)return;const K=d(x,{value:`${V.on.fromTable}.${V.on.fromColumn}`});E.mutateAsync({name:`${V.on.toTable} ${V.on.toColumn} equals ${K}`,opts:$s({table:V.on.toTable,dataSourceId:u,filters:[{id:dl(),column:`${V.on.toTable}.${V.on.toColumn}`,operator:K==null?"IS NULL":"=",connector:"AND",value:K!=null?[{value:K,isColumn:!1}]:void 0}]})}).then(Z=>{C(`${Ye.workbench.path}/tab/${Z.id}`),n.close()})},T=V=>{if(!x)return;const K=c(V,x);n.close(),Jd({tableName:V,dataSourceId:u,entityId:K}),n.close()},D=b.useMemo(()=>y?r.filter(V=>V.includes(y)):r,[r,y]),H=b.useMemo(()=>{if(!p)return[];const V=y.toLowerCase();return i.filter(K=>p.result.columns.some(te=>te.column===K.on.fromColumn&&te.table===K.on.fromTable)?K.on.toTable.toLowerCase().includes(V):!1)},[y,i,p]),G=m.groupBy.length>0;return h.jsx(Nv,{handler:n,children:h.jsxs("div",{className:se.optionsContainer,children:[h.jsxs("div",{className:"grid grid-cols-2 mb-2",children:[h.jsx("button",{className:re("p-2 cursor-pointer border-b",w==="hooks"?"border-white":"border-r rounded-br-lg border-gray-200 bg-gray-50 text-gray-400"),onClick:()=>j("hooks"),children:"Drill down"}),h.jsx("button",{className:re("p-2 cursor-pointer border-b",w==="entities"?"border-white":"border-l rounded-bl-lg border-gray-200 bg-gray-50 text-gray-400"),onClick:()=>j("entities"),children:"Entities"})]}),h.jsx("input",{className:"input mx-2",placeholder:"Filter",value:y,onChange:V=>g(V.target.value)}),w==="entities"&&r.length>0&&h.jsx("div",{className:se.rowOptionsEntriesList,children:hl(D.length,0)?D.map(V=>h.jsx("button",{className:re(se.optionItem,"font-semibold"),onClick:()=>T(V),children:h.jsxs("span",{children:["📄 ",V]})},V)):h.jsx("p",{className:"text-center p-2 text-gray-800",children:"Empty"})}),w==="hooks"&&i.length>0&&h.jsx("div",{className:se.rowOptionsEntriesList,children:H.length>0?H.map(V=>h.jsx(Tv,{hook:V,onClick:()=>_(V)},V.where)):h.jsx("p",{className:"text-center p-2 text-gray-800",children:"Empty"})}),G&&h.jsx("button",{onClick:N,className:se.underlyingRowsBtn,children:"🎯 Underlying rows"})]})})},qC={ASC:"⬆️",DESC:"⬇️"},BC=()=>{const{data:n}=b.useContext(Ra),{orderBy:l,updateOrderBy:i}=_C(),r=n?.result.columns||[],u=l[0],c=hl(n?.result.tables.length,1);return h.jsx("thead",{children:h.jsxs("tr",{children:[h.jsx("td",{className:"py-1 px-4 text-center text-sm text-gray-600 border-r",children:"#"}),r.map(d=>h.jsxs("td",{className:se.headerCell,children:[h.jsxs("div",{className:"overflow-hidden",children:[c&&h.jsx("p",{className:"text-xs truncate italic",children:d.table||"-"}),h.jsx("p",{className:"text-sm font-semibold truncate",children:d.column})]}),h.jsx("div",{className:se.headerActions,children:h.jsx("button",{onClick:()=>i(d.full),children:u?.column===d.full?qC[u.direction]:"↕️"})})]},d.full))]})})};function HC({value:n,row:l,col:i}){if(n==="")return h.jsx("span",{className:"pointer-events-none text-black/30 truncate",children:"<EMPTY STRING>"});if(n==null)return h.jsx("span",{className:"pointer-events-none text-black/30",children:"<NULL>"});const r=$l(n);return h.jsxs(h.Fragment,{children:[h.jsx("span",{"data-row":l,className:se.value,children:r}),h.jsxs("div",{className:se.cellActions,children:[h.jsx("button",{"data-copy-col":i,"data-copy-row":l,children:"📋"}),h.jsx("button",{"data-show-col":i,"data-show-row":l,children:"👀"}),h.jsx("button",{"data-filter-col":i,"data-filter-row":l,children:"🔎"})]})]})}const QC=b.memo(({row:n,isLastRow:l,index:i,offset:r})=>h.jsxs("tr",{className:re(se.tableRowCells,l&&"rounded-b-lg"),children:[h.jsx("td",{className:"py-1 px-4 text-center align-middle text-xs w-8 text-blue-500 border-r",children:i+1+r}),n.map((u,c)=>h.jsx("td",{className:se.cell,"data-row":i,children:h.jsx(HC,{value:u,col:c,row:i})},c))]})),YC=()=>{const{data:n,error:l,isLoading:i,isFetching:r}=b.useContext(Ra),{state:{page:u,size:c}}=b.useContext(Zt),d=Zd(l),m=TC(),p=_v(),[y,g]=b.useState(void 0),x=C=>{const j=C.target?.dataset?.row;j!=null&&(g(parseInt(j)),p.open(C))},E=u*c;return h.jsxs(h.Fragment,{children:[y!=null&&p.show&&h.jsx(kC,{handler:p,rowIndex:y}),d&&h.jsx(wt,{className:"my-4",variant:"danger",children:d}),i&&h.jsx("div",{className:se.tableLoading,children:"Loading data"}),n&&h.jsxs("table",{className:re(se.table,r&&se.semiTransparent),onContextMenu:x,onClick:m,children:[h.jsx(BC,{}),h.jsxs("tbody",{children:[n.result.rows?.length<1&&h.jsx("tr",{className:se.tableEmpty,children:h.jsx("td",{colSpan:n.result.columns.length+1,children:"No data"})}),n.result.rows?.map((C,w)=>h.jsx(QC,{index:w,offset:E,row:C,isLastRow:w===n.result.rows.length-1},w))]})]})]})},VC=()=>{const{state:n,setState:l}=b.useContext(Zt),i=b.useCallback(u=>{l(c=>({...c,page:u}))},[l]),r=b.useCallback((u,c=!1)=>{l(d=>({...d,size:u,page:c?0:d.page}))},[l]);return{page:n.page,size:n.size,setSize:r,setPage:i}},KC=()=>vt({mutationFn:async n=>{const{data:l}=await Te.post("/saved-queries",n);return l.data},onSuccess:()=>{rt.invalidateQueries({queryKey:["queries"]}),ni()}}),$C=()=>vt({mutationFn:async n=>Te.delete("/saved-queries/"+n),onSuccess:()=>{ni()}}),GC=()=>vt({mutationFn:async({id:n,payload:l})=>{const{data:i}=await Te.patch("/saved-queries/"+n,l);return i.data},onSuccess:()=>{ni(),W3()}}),[_u,Wd]=un({filters:!1,joins:!1,columns:!1,groupBy:!1,aggregate:!1}),Un=n=>Wd(l=>({...l,[n]:!0})),Nu=n=>Wd(l=>({...l,[n]:!1})),du=n=>Wd(l=>({...l,[n]:!l[n]})),Fs=Math.min,Gl=Math.max,hu=Math.round,Po=Math.floor,Wn=n=>({x:n,y:n}),XC={left:"right",right:"left",bottom:"top",top:"bottom"},FC={start:"end",end:"start"};function Sd(n,l,i){return Gl(n,Fs(l,i))}function Dr(n,l){return typeof n=="function"?n(l):n}function Jl(n){return n.split("-")[0]}function Mr(n){return n.split("-")[1]}function jv(n){return n==="x"?"y":"x"}function eh(n){return n==="y"?"height":"width"}function ul(n){return["top","bottom"].includes(Jl(n))?"y":"x"}function th(n){return jv(ul(n))}function ZC(n,l,i){i===void 0&&(i=!1);const r=Mr(n),u=th(n),c=eh(u);let d=u==="x"?r===(i?"end":"start")?"right":"left":r==="start"?"bottom":"top";return l.reference[c]>l.floating[c]&&(d=mu(d)),[d,mu(d)]}function PC(n){const l=mu(n);return[wd(n),l,wd(l)]}function wd(n){return n.replace(/start|end/g,l=>FC[l])}function JC(n,l,i){const r=["left","right"],u=["right","left"],c=["top","bottom"],d=["bottom","top"];switch(n){case"top":case"bottom":return i?l?u:r:l?r:u;case"left":case"right":return l?c:d;default:return[]}}function IC(n,l,i,r){const u=Mr(n);let c=JC(Jl(n),i==="start",r);return u&&(c=c.map(d=>d+"-"+u),l&&(c=c.concat(c.map(wd)))),c}function mu(n){return n.replace(/left|right|bottom|top/g,l=>XC[l])}function WC(n){return{top:0,right:0,bottom:0,left:0,...n}}function Av(n){return typeof n!="number"?WC(n):{top:n,right:n,bottom:n,left:n}}function pu(n){const{x:l,y:i,width:r,height:u}=n;return{width:r,height:u,top:i,left:l,right:l+r,bottom:i+u,x:l,y:i}}function My(n,l,i){let{reference:r,floating:u}=n;const c=ul(l),d=th(l),m=eh(d),p=Jl(l),y=c==="y",g=r.x+r.width/2-u.width/2,x=r.y+r.height/2-u.height/2,E=r[m]/2-u[m]/2;let C;switch(p){case"top":C={x:g,y:r.y-u.height};break;case"bottom":C={x:g,y:r.y+r.height};break;case"right":C={x:r.x+r.width,y:x};break;case"left":C={x:r.x-u.width,y:x};break;default:C={x:r.x,y:r.y}}switch(Mr(l)){case"start":C[d]-=E*(i&&y?-1:1);break;case"end":C[d]+=E*(i&&y?-1:1);break}return C}const e6=async(n,l,i)=>{const{placement:r="bottom",strategy:u="absolute",middleware:c=[],platform:d}=i,m=c.filter(Boolean),p=await(d.isRTL==null?void 0:d.isRTL(l));let y=await d.getElementRects({reference:n,floating:l,strategy:u}),{x:g,y:x}=My(y,r,p),E=r,C={},w=0;for(let j=0;j<m.length;j++){const{name:N,fn:_}=m[j],{x:T,y:D,data:H,reset:G}=await _({x:g,y:x,initialPlacement:r,placement:E,strategy:u,middlewareData:C,rects:y,platform:d,elements:{reference:n,floating:l}});g=T??g,x=D??x,C={...C,[N]:{...C[N],...H}},G&&w<=50&&(w++,typeof G=="object"&&(G.placement&&(E=G.placement),G.rects&&(y=G.rects===!0?await d.getElementRects({reference:n,floating:l,strategy:u}):G.rects),{x:g,y:x}=My(y,E,p)),j=-1)}return{x:g,y:x,placement:E,strategy:u,middlewareData:C}};async function Rv(n,l){var i;l===void 0&&(l={});const{x:r,y:u,platform:c,rects:d,elements:m,strategy:p}=n,{boundary:y="clippingAncestors",rootBoundary:g="viewport",elementContext:x="floating",altBoundary:E=!1,padding:C=0}=Dr(l,n),w=Av(C),N=m[E?x==="floating"?"reference":"floating":x],_=pu(await c.getClippingRect({element:(i=await(c.isElement==null?void 0:c.isElement(N)))==null||i?N:N.contextElement||await(c.getDocumentElement==null?void 0:c.getDocumentElement(m.floating)),boundary:y,rootBoundary:g,strategy:p})),T=x==="floating"?{x:r,y:u,width:d.floating.width,height:d.floating.height}:d.reference,D=await(c.getOffsetParent==null?void 0:c.getOffsetParent(m.floating)),H=await(c.isElement==null?void 0:c.isElement(D))?await(c.getScale==null?void 0:c.getScale(D))||{x:1,y:1}:{x:1,y:1},G=pu(c.convertOffsetParentRelativeRectToViewportRelativeRect?await c.convertOffsetParentRelativeRectToViewportRelativeRect({elements:m,rect:T,offsetParent:D,strategy:p}):T);return{top:(_.top-G.top+w.top)/H.y,bottom:(G.bottom-_.bottom+w.bottom)/H.y,left:(_.left-G.left+w.left)/H.x,right:(G.right-_.right+w.right)/H.x}}const t6=n=>({name:"arrow",options:n,async fn(l){const{x:i,y:r,placement:u,rects:c,platform:d,elements:m,middlewareData:p}=l,{element:y,padding:g=0}=Dr(n,l)||{};if(y==null)return{};const x=Av(g),E={x:i,y:r},C=th(u),w=eh(C),j=await d.getDimensions(y),N=C==="y",_=N?"top":"left",T=N?"bottom":"right",D=N?"clientHeight":"clientWidth",H=c.reference[w]+c.reference[C]-E[C]-c.floating[w],G=E[C]-c.reference[C],V=await(d.getOffsetParent==null?void 0:d.getOffsetParent(y));let K=V?V[D]:0;(!K||!await(d.isElement==null?void 0:d.isElement(V)))&&(K=m.floating[D]||c.floating[w]);const Z=H/2-G/2,te=K/2-j[w]/2-1,ye=Fs(x[_],te),Ae=Fs(x[T],te),Ce=ye,$e=K-j[w]-Ae,me=K/2-j[w]/2+Z,_e=Sd(Ce,me,$e),q=!p.arrow&&Mr(u)!=null&&me!==_e&&c.reference[w]/2-(me<Ce?ye:Ae)-j[w]/2<0,F=q?me<Ce?me-Ce:me-$e:0;return{[C]:E[C]+F,data:{[C]:_e,centerOffset:me-_e-F,...q&&{alignmentOffset:F}},reset:q}}}),n6=function(n){return n===void 0&&(n={}),{name:"flip",options:n,async fn(l){var i,r;const{placement:u,middlewareData:c,rects:d,initialPlacement:m,platform:p,elements:y}=l,{mainAxis:g=!0,crossAxis:x=!0,fallbackPlacements:E,fallbackStrategy:C="bestFit",fallbackAxisSideDirection:w="none",flipAlignment:j=!0,...N}=Dr(n,l);if((i=c.arrow)!=null&&i.alignmentOffset)return{};const _=Jl(u),T=ul(m),D=Jl(m)===m,H=await(p.isRTL==null?void 0:p.isRTL(y.floating)),G=E||(D||!j?[mu(m)]:PC(m)),V=w!=="none";!E&&V&&G.push(...IC(m,j,w,H));const K=[m,...G],Z=await Rv(l,N),te=[];let ye=((r=c.flip)==null?void 0:r.overflows)||[];if(g&&te.push(Z[_]),x){const me=ZC(u,d,H);te.push(Z[me[0]],Z[me[1]])}if(ye=[...ye,{placement:u,overflows:te}],!te.every(me=>me<=0)){var Ae,Ce;const me=(((Ae=c.flip)==null?void 0:Ae.index)||0)+1,_e=K[me];if(_e&&(!(x==="alignment"?T!==ul(_e):!1)||ye.every(J=>J.overflows[0]>0&&ul(J.placement)===T)))return{data:{index:me,overflows:ye},reset:{placement:_e}};let q=(Ce=ye.filter(F=>F.overflows[0]<=0).sort((F,J)=>F.overflows[1]-J.overflows[1])[0])==null?void 0:Ce.placement;if(!q)switch(C){case"bestFit":{var $e;const F=($e=ye.filter(J=>{if(V){const he=ul(J.placement);return he===T||he==="y"}return!0}).map(J=>[J.placement,J.overflows.filter(he=>he>0).reduce((he,R)=>he+R,0)]).sort((J,he)=>J[1]-he[1])[0])==null?void 0:$e[0];F&&(q=F);break}case"initialPlacement":q=m;break}if(u!==q)return{reset:{placement:q}}}return{}}}};async function a6(n,l){const{placement:i,platform:r,elements:u}=n,c=await(r.isRTL==null?void 0:r.isRTL(u.floating)),d=Jl(i),m=Mr(i),p=ul(i)==="y",y=["left","top"].includes(d)?-1:1,g=c&&p?-1:1,x=Dr(l,n);let{mainAxis:E,crossAxis:C,alignmentAxis:w}=typeof x=="number"?{mainAxis:x,crossAxis:0,alignmentAxis:null}:{mainAxis:x.mainAxis||0,crossAxis:x.crossAxis||0,alignmentAxis:x.alignmentAxis};return m&&typeof w=="number"&&(C=m==="end"?w*-1:w),p?{x:C*g,y:E*y}:{x:E*y,y:C*g}}const l6=function(n){return n===void 0&&(n=0),{name:"offset",options:n,async fn(l){var i,r;const{x:u,y:c,placement:d,middlewareData:m}=l,p=await a6(l,n);return d===((i=m.offset)==null?void 0:i.placement)&&(r=m.arrow)!=null&&r.alignmentOffset?{}:{x:u+p.x,y:c+p.y,data:{...p,placement:d}}}}},s6=function(n){return n===void 0&&(n={}),{name:"shift",options:n,async fn(l){const{x:i,y:r,placement:u}=l,{mainAxis:c=!0,crossAxis:d=!1,limiter:m={fn:N=>{let{x:_,y:T}=N;return{x:_,y:T}}},...p}=Dr(n,l),y={x:i,y:r},g=await Rv(l,p),x=ul(Jl(u)),E=jv(x);let C=y[E],w=y[x];if(c){const N=E==="y"?"top":"left",_=E==="y"?"bottom":"right",T=C+g[N],D=C-g[_];C=Sd(T,C,D)}if(d){const N=x==="y"?"top":"left",_=x==="y"?"bottom":"right",T=w+g[N],D=w-g[_];w=Sd(T,w,D)}const j=m.fn({...l,[E]:C,[x]:w});return{...j,data:{x:j.x-i,y:j.y-r,enabled:{[E]:c,[x]:d}}}}}};function Tu(){return typeof window<"u"}function ri(n){return Ov(n)?(n.nodeName||"").toLowerCase():"#document"}function rn(n){var l;return(n==null||(l=n.ownerDocument)==null?void 0:l.defaultView)||window}function la(n){var l;return(l=(Ov(n)?n.ownerDocument:n.document)||window.document)==null?void 0:l.documentElement}function Ov(n){return Tu()?n instanceof Node||n instanceof rn(n).Node:!1}function zn(n){return Tu()?n instanceof Element||n instanceof rn(n).Element:!1}function ea(n){return Tu()?n instanceof HTMLElement||n instanceof rn(n).HTMLElement:!1}function Uy(n){return!Tu()||typeof ShadowRoot>"u"?!1:n instanceof ShadowRoot||n instanceof rn(n).ShadowRoot}function Ur(n){const{overflow:l,overflowX:i,overflowY:r,display:u}=kn(n);return/auto|scroll|overlay|hidden|clip/.test(l+r+i)&&!["inline","contents"].includes(u)}function i6(n){return["table","td","th"].includes(ri(n))}function ju(n){return[":popover-open",":modal"].some(l=>{try{return n.matches(l)}catch{return!1}})}function nh(n){const l=ah(),i=zn(n)?kn(n):n;return["transform","translate","scale","rotate","perspective"].some(r=>i[r]?i[r]!=="none":!1)||(i.containerType?i.containerType!=="normal":!1)||!l&&(i.backdropFilter?i.backdropFilter!=="none":!1)||!l&&(i.filter?i.filter!=="none":!1)||["transform","translate","scale","rotate","perspective","filter"].some(r=>(i.willChange||"").includes(r))||["paint","layout","strict","content"].some(r=>(i.contain||"").includes(r))}function r6(n){let l=ml(n);for(;ea(l)&&!Zs(l);){if(nh(l))return l;if(ju(l))return null;l=ml(l)}return null}function ah(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function Zs(n){return["html","body","#document"].includes(ri(n))}function kn(n){return rn(n).getComputedStyle(n)}function Au(n){return zn(n)?{scrollLeft:n.scrollLeft,scrollTop:n.scrollTop}:{scrollLeft:n.scrollX,scrollTop:n.scrollY}}function ml(n){if(ri(n)==="html")return n;const l=n.assignedSlot||n.parentNode||Uy(n)&&n.host||la(n);return Uy(l)?l.host:l}function Dv(n){const l=ml(n);return Zs(l)?n.ownerDocument?n.ownerDocument.body:n.body:ea(l)&&Ur(l)?l:Dv(l)}function vr(n,l,i){var r;l===void 0&&(l=[]),i===void 0&&(i=!0);const u=Dv(n),c=u===((r=n.ownerDocument)==null?void 0:r.body),d=rn(u);if(c){const m=Ed(d);return l.concat(d,d.visualViewport||[],Ur(u)?u:[],m&&i?vr(m):[])}return l.concat(u,vr(u,[],i))}function Ed(n){return n.parent&&Object.getPrototypeOf(n.parent)?n.frameElement:null}function Mv(n){const l=kn(n);let i=parseFloat(l.width)||0,r=parseFloat(l.height)||0;const u=ea(n),c=u?n.offsetWidth:i,d=u?n.offsetHeight:r,m=hu(i)!==c||hu(r)!==d;return m&&(i=c,r=d),{width:i,height:r,$:m}}function lh(n){return zn(n)?n:n.contextElement}function Vs(n){const l=lh(n);if(!ea(l))return Wn(1);const i=l.getBoundingClientRect(),{width:r,height:u,$:c}=Mv(l);let d=(c?hu(i.width):i.width)/r,m=(c?hu(i.height):i.height)/u;return(!d||!Number.isFinite(d))&&(d=1),(!m||!Number.isFinite(m))&&(m=1),{x:d,y:m}}const o6=Wn(0);function Uv(n){const l=rn(n);return!ah()||!l.visualViewport?o6:{x:l.visualViewport.offsetLeft,y:l.visualViewport.offsetTop}}function u6(n,l,i){return l===void 0&&(l=!1),!i||l&&i!==rn(n)?!1:l}function Il(n,l,i,r){l===void 0&&(l=!1),i===void 0&&(i=!1);const u=n.getBoundingClientRect(),c=lh(n);let d=Wn(1);l&&(r?zn(r)&&(d=Vs(r)):d=Vs(n));const m=u6(c,i,r)?Uv(c):Wn(0);let p=(u.left+m.x)/d.x,y=(u.top+m.y)/d.y,g=u.width/d.x,x=u.height/d.y;if(c){const E=rn(c),C=r&&zn(r)?rn(r):r;let w=E,j=Ed(w);for(;j&&r&&C!==w;){const N=Vs(j),_=j.getBoundingClientRect(),T=kn(j),D=_.left+(j.clientLeft+parseFloat(T.paddingLeft))*N.x,H=_.top+(j.clientTop+parseFloat(T.paddingTop))*N.y;p*=N.x,y*=N.y,g*=N.x,x*=N.y,p+=D,y+=H,w=rn(j),j=Ed(w)}}return pu({width:g,height:x,x:p,y})}function sh(n,l){const i=Au(n).scrollLeft;return l?l.left+i:Il(la(n)).left+i}function Lv(n,l,i){i===void 0&&(i=!1);const r=n.getBoundingClientRect(),u=r.left+l.scrollLeft-(i?0:sh(n,r)),c=r.top+l.scrollTop;return{x:u,y:c}}function c6(n){let{elements:l,rect:i,offsetParent:r,strategy:u}=n;const c=u==="fixed",d=la(r),m=l?ju(l.floating):!1;if(r===d||m&&c)return i;let p={scrollLeft:0,scrollTop:0},y=Wn(1);const g=Wn(0),x=ea(r);if((x||!x&&!c)&&((ri(r)!=="body"||Ur(d))&&(p=Au(r)),ea(r))){const C=Il(r);y=Vs(r),g.x=C.x+r.clientLeft,g.y=C.y+r.clientTop}const E=d&&!x&&!c?Lv(d,p,!0):Wn(0);return{width:i.width*y.x,height:i.height*y.y,x:i.x*y.x-p.scrollLeft*y.x+g.x+E.x,y:i.y*y.y-p.scrollTop*y.y+g.y+E.y}}function f6(n){return Array.from(n.getClientRects())}function d6(n){const l=la(n),i=Au(n),r=n.ownerDocument.body,u=Gl(l.scrollWidth,l.clientWidth,r.scrollWidth,r.clientWidth),c=Gl(l.scrollHeight,l.clientHeight,r.scrollHeight,r.clientHeight);let d=-i.scrollLeft+sh(n);const m=-i.scrollTop;return kn(r).direction==="rtl"&&(d+=Gl(l.clientWidth,r.clientWidth)-u),{width:u,height:c,x:d,y:m}}function h6(n,l){const i=rn(n),r=la(n),u=i.visualViewport;let c=r.clientWidth,d=r.clientHeight,m=0,p=0;if(u){c=u.width,d=u.height;const y=ah();(!y||y&&l==="fixed")&&(m=u.offsetLeft,p=u.offsetTop)}return{width:c,height:d,x:m,y:p}}function m6(n,l){const i=Il(n,!0,l==="fixed"),r=i.top+n.clientTop,u=i.left+n.clientLeft,c=ea(n)?Vs(n):Wn(1),d=n.clientWidth*c.x,m=n.clientHeight*c.y,p=u*c.x,y=r*c.y;return{width:d,height:m,x:p,y}}function Ly(n,l,i){let r;if(l==="viewport")r=h6(n,i);else if(l==="document")r=d6(la(n));else if(zn(l))r=m6(l,i);else{const u=Uv(n);r={x:l.x-u.x,y:l.y-u.y,width:l.width,height:l.height}}return pu(r)}function zv(n,l){const i=ml(n);return i===l||!zn(i)||Zs(i)?!1:kn(i).position==="fixed"||zv(i,l)}function p6(n,l){const i=l.get(n);if(i)return i;let r=vr(n,[],!1).filter(m=>zn(m)&&ri(m)!=="body"),u=null;const c=kn(n).position==="fixed";let d=c?ml(n):n;for(;zn(d)&&!Zs(d);){const m=kn(d),p=nh(d);!p&&m.position==="fixed"&&(u=null),(c?!p&&!u:!p&&m.position==="static"&&!!u&&["absolute","fixed"].includes(u.position)||Ur(d)&&!p&&zv(n,d))?r=r.filter(g=>g!==d):u=m,d=ml(d)}return l.set(n,r),r}function y6(n){let{element:l,boundary:i,rootBoundary:r,strategy:u}=n;const d=[...i==="clippingAncestors"?ju(l)?[]:p6(l,this._c):[].concat(i),r],m=d[0],p=d.reduce((y,g)=>{const x=Ly(l,g,u);return y.top=Gl(x.top,y.top),y.right=Fs(x.right,y.right),y.bottom=Fs(x.bottom,y.bottom),y.left=Gl(x.left,y.left),y},Ly(l,m,u));return{width:p.right-p.left,height:p.bottom-p.top,x:p.left,y:p.top}}function v6(n){const{width:l,height:i}=Mv(n);return{width:l,height:i}}function g6(n,l,i){const r=ea(l),u=la(l),c=i==="fixed",d=Il(n,!0,c,l);let m={scrollLeft:0,scrollTop:0};const p=Wn(0);function y(){p.x=sh(u)}if(r||!r&&!c)if((ri(l)!=="body"||Ur(u))&&(m=Au(l)),r){const C=Il(l,!0,c,l);p.x=C.x+l.clientLeft,p.y=C.y+l.clientTop}else u&&y();c&&!r&&u&&y();const g=u&&!r&&!c?Lv(u,m):Wn(0),x=d.left+m.scrollLeft-p.x-g.x,E=d.top+m.scrollTop-p.y-g.y;return{x,y:E,width:d.width,height:d.height}}function Jf(n){return kn(n).position==="static"}function zy(n,l){if(!ea(n)||kn(n).position==="fixed")return null;if(l)return l(n);let i=n.offsetParent;return la(n)===i&&(i=i.ownerDocument.body),i}function kv(n,l){const i=rn(n);if(ju(n))return i;if(!ea(n)){let u=ml(n);for(;u&&!Zs(u);){if(zn(u)&&!Jf(u))return u;u=ml(u)}return i}let r=zy(n,l);for(;r&&i6(r)&&Jf(r);)r=zy(r,l);return r&&Zs(r)&&Jf(r)&&!nh(r)?i:r||r6(n)||i}const b6=async function(n){const l=this.getOffsetParent||kv,i=this.getDimensions,r=await i(n.floating);return{reference:g6(n.reference,await l(n.floating),n.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function x6(n){return kn(n).direction==="rtl"}const S6={convertOffsetParentRelativeRectToViewportRelativeRect:c6,getDocumentElement:la,getClippingRect:y6,getOffsetParent:kv,getElementRects:b6,getClientRects:f6,getDimensions:v6,getScale:Vs,isElement:zn,isRTL:x6};function qv(n,l){return n.x===l.x&&n.y===l.y&&n.width===l.width&&n.height===l.height}function w6(n,l){let i=null,r;const u=la(n);function c(){var m;clearTimeout(r),(m=i)==null||m.disconnect(),i=null}function d(m,p){m===void 0&&(m=!1),p===void 0&&(p=1),c();const y=n.getBoundingClientRect(),{left:g,top:x,width:E,height:C}=y;if(m||l(),!E||!C)return;const w=Po(x),j=Po(u.clientWidth-(g+E)),N=Po(u.clientHeight-(x+C)),_=Po(g),D={rootMargin:-w+"px "+-j+"px "+-N+"px "+-_+"px",threshold:Gl(0,Fs(1,p))||1};let H=!0;function G(V){const K=V[0].intersectionRatio;if(K!==p){if(!H)return d();K?d(!1,K):r=setTimeout(()=>{d(!1,1e-7)},1e3)}K===1&&!qv(y,n.getBoundingClientRect())&&d(),H=!1}try{i=new IntersectionObserver(G,{...D,root:u.ownerDocument})}catch{i=new IntersectionObserver(G,D)}i.observe(n)}return d(!0),c}function E6(n,l,i,r){r===void 0&&(r={});const{ancestorScroll:u=!0,ancestorResize:c=!0,elementResize:d=typeof ResizeObserver=="function",layoutShift:m=typeof IntersectionObserver=="function",animationFrame:p=!1}=r,y=lh(n),g=u||c?[...y?vr(y):[],...vr(l)]:[];g.forEach(_=>{u&&_.addEventListener("scroll",i,{passive:!0}),c&&_.addEventListener("resize",i)});const x=y&&m?w6(y,i):null;let E=-1,C=null;d&&(C=new ResizeObserver(_=>{let[T]=_;T&&T.target===y&&C&&(C.unobserve(l),cancelAnimationFrame(E),E=requestAnimationFrame(()=>{var D;(D=C)==null||D.observe(l)})),i()}),y&&!p&&C.observe(y),C.observe(l));let w,j=p?Il(n):null;p&&N();function N(){const _=Il(n);j&&!qv(j,_)&&i(),j=_,w=requestAnimationFrame(N)}return i(),()=>{var _;g.forEach(T=>{u&&T.removeEventListener("scroll",i),c&&T.removeEventListener("resize",i)}),x?.(),(_=C)==null||_.disconnect(),C=null,p&&cancelAnimationFrame(w)}}const C6=l6,_6=s6,N6=n6,T6=t6,ky=(n,l,i)=>{const r=new Map,u={platform:S6,...i},c={...u.platform,_c:r};return e6(n,l,{...u,platform:c})};var If={exports:{}};var qy;function j6(){return qy||(qy=1,function(n){(function(){var l={}.hasOwnProperty;function i(){for(var c="",d=0;d<arguments.length;d++){var m=arguments[d];m&&(c=u(c,r(m)))}return c}function r(c){if(typeof c=="string"||typeof c=="number")return c;if(typeof c!="object")return"";if(Array.isArray(c))return i.apply(null,c);if(c.toString!==Object.prototype.toString&&!c.toString.toString().includes("[native code]"))return c.toString();var d="";for(var m in c)l.call(c,m)&&c[m]&&(d=u(d,m));return d}function u(c,d){return d?c?c+" "+d:c+d:c}n.exports?(i.default=i,n.exports=i):window.classNames=i})()}(If)),If.exports}var A6=j6();const Cd=Td(A6);var By={};const R6="react-tooltip-core-styles",O6="react-tooltip-base-styles",Hy={core:!1,base:!1};function Qy({css:n,id:l=O6,type:i="base",ref:r}){var u,c;if(!n||typeof document>"u"||Hy[i]||i==="core"&&typeof process<"u"&&(!((u=process==null?void 0:By)===null||u===void 0)&&u.REACT_TOOLTIP_DISABLE_CORE_STYLES)||i!=="base"&&typeof process<"u"&&(!((c=process==null?void 0:By)===null||c===void 0)&&c.REACT_TOOLTIP_DISABLE_BASE_STYLES))return;i==="core"&&(l=R6),r||(r={});const{insertAt:d}=r;if(document.getElementById(l))return;const m=document.head||document.getElementsByTagName("head")[0],p=document.createElement("style");p.id=l,p.type="text/css",d==="top"&&m.firstChild?m.insertBefore(p,m.firstChild):m.appendChild(p),p.styleSheet?p.styleSheet.cssText=n:p.appendChild(document.createTextNode(n)),Hy[i]=!0}const Yy=async({elementReference:n=null,tooltipReference:l=null,tooltipArrowReference:i=null,place:r="top",offset:u=10,strategy:c="absolute",middlewares:d=[C6(Number(u)),N6({fallbackAxisSideDirection:"start"}),_6({padding:5})],border:m,arrowSize:p=8})=>{if(!n)return{tooltipStyles:{},tooltipArrowStyles:{},place:r};if(l===null)return{tooltipStyles:{},tooltipArrowStyles:{},place:r};const y=d;return i?(y.push(T6({element:i,padding:5})),ky(n,l,{placement:r,strategy:c,middleware:y}).then(({x:g,y:x,placement:E,middlewareData:C})=>{var w,j;const N={left:`${g}px`,top:`${x}px`,border:m},{x:_,y:T}=(w=C.arrow)!==null&&w!==void 0?w:{x:0,y:0},D=(j={top:"bottom",right:"left",bottom:"top",left:"right"}[E.split("-")[0]])!==null&&j!==void 0?j:"bottom",H=m&&{borderBottom:m,borderRight:m};let G=0;if(m){const V=`${m}`.match(/(\d+)px/);G=V?.[1]?Number(V[1]):1}return{tooltipStyles:N,tooltipArrowStyles:{left:_!=null?`${_}px`:"",top:T!=null?`${T}px`:"",right:"",bottom:"",...H,[D]:`-${p/2+G}px`},place:E}})):ky(n,l,{placement:"bottom",strategy:c,middleware:y}).then(({x:g,y:x,placement:E})=>({tooltipStyles:{left:`${g}px`,top:`${x}px`},tooltipArrowStyles:{},place:E}))},Vy=(n,l)=>!("CSS"in window&&"supports"in window.CSS)||window.CSS.supports(n,l),Ky=(n,l,i)=>{let r=null;const u=function(...c){const d=()=>{r=null};!r&&(n.apply(this,c),r=setTimeout(d,l))};return u.cancel=()=>{r&&(clearTimeout(r),r=null)},u},$y=n=>n!==null&&!Array.isArray(n)&&typeof n=="object",_d=(n,l)=>{if(n===l)return!0;if(Array.isArray(n)&&Array.isArray(l))return n.length===l.length&&n.every((u,c)=>_d(u,l[c]));if(Array.isArray(n)!==Array.isArray(l))return!1;if(!$y(n)||!$y(l))return n===l;const i=Object.keys(n),r=Object.keys(l);return i.length===r.length&&i.every(u=>_d(n[u],l[u]))},D6=n=>{if(!(n instanceof HTMLElement||n instanceof SVGElement))return!1;const l=getComputedStyle(n);return["overflow","overflow-x","overflow-y"].some(i=>{const r=l.getPropertyValue(i);return r==="auto"||r==="scroll"})},Gy=n=>{if(!n)return null;let l=n.parentElement;for(;l;){if(D6(l))return l;l=l.parentElement}return document.scrollingElement||document.documentElement},M6=typeof window<"u"?b.useLayoutEffect:b.useEffect,Tn=n=>{n.current&&(clearTimeout(n.current),n.current=null)},U6="DEFAULT_TOOLTIP_ID",L6={anchorRefs:new Set,activeAnchor:{current:null},attach:()=>{},detach:()=>{},setActiveAnchor:()=>{}},z6=b.createContext({getTooltipData:()=>L6});function Bv(n=U6){return b.useContext(z6).getTooltipData(n)}var Hs={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"},Wf={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 k6=({forwardRef:n,id:l,className:i,classNameArrow:r,variant:u="dark",anchorId:c,anchorSelect:d,place:m="top",offset:p=10,events:y=["hover"],openOnClick:g=!1,positionStrategy:x="absolute",middlewares:E,wrapper:C,delayShow:w=0,delayHide:j=0,float:N=!1,hidden:_=!1,noArrow:T=!1,clickable:D=!1,closeOnEsc:H=!1,closeOnScroll:G=!1,closeOnResize:V=!1,openEvents:K,closeEvents:Z,globalCloseEvents:te,imperativeModeOnly:ye,style:Ae,position:Ce,afterShow:$e,afterHide:me,disableTooltip:_e,content:q,contentWrapperRef:F,isOpen:J,defaultIsOpen:he=!1,setIsOpen:R,activeAnchor:Q,setActiveAnchor:I,border:W,opacity:ae,arrowColor:ge,arrowSize:oe=8,role:gt="tooltip"})=>{var Me;const Ge=b.useRef(null),Hn=b.useRef(null),Ct=b.useRef(null),fn=b.useRef(null),sa=b.useRef(null),[dn,oi]=b.useState({tooltipStyles:{},tooltipArrowStyles:{},place:m}),[Dt,Mt]=b.useState(!1),[ia,Qn]=b.useState(!1),[Ve,Yn]=b.useState(null),gl=b.useRef(!1),Oa=b.useRef(null),{anchorRefs:bl,setActiveAnchor:es}=Bv(l),hn=b.useRef(!1),[Je,Bt]=b.useState([]),tt=b.useRef(!1),Da=g||y.includes("click"),ui=Da||K?.click||K?.dblclick||K?.mousedown,Ma=K?{...K}:{mouseover:!0,focus:!0,mouseenter:!1,click:!1,dblclick:!1,mousedown:!1};!K&&Da&&Object.assign(Ma,{mouseenter:!1,focus:!1,mouseover:!1,click:!0});const mn=Z?{...Z}:{mouseout:!0,blur:!0,mouseleave:!1,click:!1,dblclick:!1,mouseup:!1};!Z&&Da&&Object.assign(mn,{mouseleave:!1,blur:!1,mouseout:!1});const _t=te?{...te}:{escape:H||!1,scroll:G||!1,resize:V||!1,clickOutsideAnchor:ui||!1};ye&&(Object.assign(Ma,{mouseover:!1,focus:!1,mouseenter:!1,click:!1,dblclick:!1,mousedown:!1}),Object.assign(mn,{mouseout:!1,blur:!1,mouseleave:!1,click:!1,dblclick:!1,mouseup:!1}),Object.assign(_t,{escape:!1,scroll:!1,resize:!1,clickOutsideAnchor:!1})),M6(()=>(tt.current=!0,()=>{tt.current=!1}),[]);const ke=P=>{tt.current&&(P&&Qn(!0),setTimeout(()=>{tt.current&&(R?.(P),J===void 0&&Mt(P))},10))};b.useEffect(()=>{if(J===void 0)return()=>null;J&&Qn(!0);const P=setTimeout(()=>{Mt(J)},10);return()=>{clearTimeout(P)}},[J]),b.useEffect(()=>{if(Dt!==gl.current)if(Tn(sa),gl.current=Dt,Dt)$e?.();else{const P=(ne=>{const ce=ne.match(/^([\d.]+)(ms|s)$/);if(!ce)return 0;const[,Fe,ht]=ce;return Number(Fe)*(ht==="ms"?1:1e3)})(getComputedStyle(document.body).getPropertyValue("--rt-transition-show-delay"));sa.current=setTimeout(()=>{Qn(!1),Yn(null),me?.()},P+25)}},[Dt]);const ra=P=>{oi(ne=>_d(ne,P)?ne:P)},Rn=(P=w)=>{Tn(Ct),ia?ke(!0):Ct.current=setTimeout(()=>{ke(!0)},P)},Ua=(P=j)=>{Tn(fn),fn.current=setTimeout(()=>{hn.current||ke(!1)},P)},La=P=>{var ne;if(!P)return;const ce=(ne=P.currentTarget)!==null&&ne!==void 0?ne:P.target;if(!ce?.isConnected)return I(null),void es({current:null});w?Rn():ke(!0),I(ce),es({current:ce}),Tn(fn)},oa=()=>{D?Ua(j||100):j?Ua():ke(!1),Tn(Ct)},Vn=({x:P,y:ne})=>{var ce;const Fe={getBoundingClientRect:()=>({x:P,y:ne,width:0,height:0,top:ne,left:P,right:P,bottom:ne})};Yy({place:(ce=Ve?.place)!==null&&ce!==void 0?ce:m,offset:p,elementReference:Fe,tooltipReference:Ge.current,tooltipArrowReference:Hn.current,strategy:x,middlewares:E,border:W,arrowSize:oe}).then(ht=>{ra(ht)})},pn=P=>{if(!P)return;const ne=P,ce={x:ne.clientX,y:ne.clientY};Vn(ce),Oa.current=ce},xl=P=>{var ne;if(!Dt)return;const ce=P.target;ce.isConnected&&(!((ne=Ge.current)===null||ne===void 0)&&ne.contains(ce)||[document.querySelector(`[id='${c}']`),...Je].some(Fe=>Fe?.contains(ce))||(ke(!1),Tn(Ct)))},Sl=Ky(La,50),nt=Ky(oa,50),Nt=P=>{nt.cancel(),Sl(P)},ie=()=>{Sl.cancel(),nt()},Se=b.useCallback(()=>{var P,ne;const ce=(P=Ve?.position)!==null&&P!==void 0?P:Ce;ce?Vn(ce):N?Oa.current&&Vn(Oa.current):Q?.isConnected&&Yy({place:(ne=Ve?.place)!==null&&ne!==void 0?ne:m,offset:p,elementReference:Q,tooltipReference:Ge.current,tooltipArrowReference:Hn.current,strategy:x,middlewares:E,border:W,arrowSize:oe}).then(Fe=>{tt.current&&ra(Fe)})},[Dt,Q,q,Ae,m,Ve?.place,p,x,Ce,Ve?.position,N,oe]);b.useEffect(()=>{var P,ne;const ce=new Set(bl);Je.forEach(Oe=>{_e?.(Oe)||ce.add({current:Oe})});const Fe=document.querySelector(`[id='${c}']`);Fe&&!_e?.(Fe)&&ce.add({current:Fe});const ht=()=>{ke(!1)},yn=Gy(Q),Pt=Gy(Ge.current);_t.scroll&&(window.addEventListener("scroll",ht),yn?.addEventListener("scroll",ht),Pt?.addEventListener("scroll",ht));let at=null;_t.resize?window.addEventListener("resize",ht):Q&&Ge.current&&(at=E6(Q,Ge.current,Se,{ancestorResize:!0,elementResize:!0,layoutShift:!0}));const jt=Oe=>{Oe.key==="Escape"&&ke(!1)};_t.escape&&window.addEventListener("keydown",jt),_t.clickOutsideAnchor&&window.addEventListener("click",xl);const Re=[],Jt=Oe=>!!(Oe?.target&&Q?.contains(Oe.target)),wl=Oe=>{Dt&&Jt(Oe)||La(Oe)},za=Oe=>{Dt&&Jt(Oe)&&oa()},lt=["mouseover","mouseout","mouseenter","mouseleave","focus","blur"],ci=["click","dblclick","mousedown","mouseup"];Object.entries(Ma).forEach(([Oe,vn])=>{vn&&(lt.includes(Oe)?Re.push({event:Oe,listener:Nt}):ci.includes(Oe)&&Re.push({event:Oe,listener:wl}))}),Object.entries(mn).forEach(([Oe,vn])=>{vn&&(lt.includes(Oe)?Re.push({event:Oe,listener:ie}):ci.includes(Oe)&&Re.push({event:Oe,listener:za}))}),N&&Re.push({event:"pointermove",listener:pn});const fi=()=>{hn.current=!0},Kn=()=>{hn.current=!1,oa()},ua=D&&(mn.mouseout||mn.mouseleave);return ua&&((P=Ge.current)===null||P===void 0||P.addEventListener("mouseover",fi),(ne=Ge.current)===null||ne===void 0||ne.addEventListener("mouseout",Kn)),Re.forEach(({event:Oe,listener:vn})=>{ce.forEach(ts=>{var El;(El=ts.current)===null||El===void 0||El.addEventListener(Oe,vn)})}),()=>{var Oe,vn;_t.scroll&&(window.removeEventListener("scroll",ht),yn?.removeEventListener("scroll",ht),Pt?.removeEventListener("scroll",ht)),_t.resize?window.removeEventListener("resize",ht):at?.(),_t.clickOutsideAnchor&&window.removeEventListener("click",xl),_t.escape&&window.removeEventListener("keydown",jt),ua&&((Oe=Ge.current)===null||Oe===void 0||Oe.removeEventListener("mouseover",fi),(vn=Ge.current)===null||vn===void 0||vn.removeEventListener("mouseout",Kn)),Re.forEach(({event:ts,listener:El})=>{ce.forEach(ns=>{var ka;(ka=ns.current)===null||ka===void 0||ka.removeEventListener(ts,El)})})}},[Q,Se,ia,bl,Je,K,Z,te,Da,w,j]),b.useEffect(()=>{var P,ne;let ce=(ne=(P=Ve?.anchorSelect)!==null&&P!==void 0?P:d)!==null&&ne!==void 0?ne:"";!ce&&l&&(ce=`[data-tooltip-id='${l.replace(/'/g,"\\'")}']`);const Fe=new MutationObserver(ht=>{const yn=[],Pt=[];ht.forEach(at=>{if(at.type==="attributes"&&at.attributeName==="data-tooltip-id"&&(at.target.getAttribute("data-tooltip-id")===l?yn.push(at.target):at.oldValue===l&&Pt.push(at.target)),at.type==="childList"){if(Q){const jt=[...at.removedNodes].filter(Re=>Re.nodeType===1);if(ce)try{Pt.push(...jt.filter(Re=>Re.matches(ce))),Pt.push(...jt.flatMap(Re=>[...Re.querySelectorAll(ce)]))}catch{}jt.some(Re=>{var Jt;return!!(!((Jt=Re?.contains)===null||Jt===void 0)&&Jt.call(Re,Q))&&(Qn(!1),ke(!1),I(null),Tn(Ct),Tn(fn),!0)})}if(ce)try{const jt=[...at.addedNodes].filter(Re=>Re.nodeType===1);yn.push(...jt.filter(Re=>Re.matches(ce))),yn.push(...jt.flatMap(Re=>[...Re.querySelectorAll(ce)]))}catch{}}}),(yn.length||Pt.length)&&Bt(at=>[...at.filter(jt=>!Pt.includes(jt)),...yn])});return Fe.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-tooltip-id"],attributeOldValue:!0}),()=>{Fe.disconnect()}},[l,d,Ve?.anchorSelect,Q]),b.useEffect(()=>{Se()},[Se]),b.useEffect(()=>{if(!F?.current)return()=>null;const P=new ResizeObserver(()=>{setTimeout(()=>Se())});return P.observe(F.current),()=>{P.disconnect()}},[q,F?.current]),b.useEffect(()=>{var P;const ne=document.querySelector(`[id='${c}']`),ce=[...Je,ne];Q&&ce.includes(Q)||I((P=Je[0])!==null&&P!==void 0?P:ne)},[c,Je,Q]),b.useEffect(()=>(he&&ke(!0),()=>{Tn(Ct),Tn(fn)}),[]),b.useEffect(()=>{var P;let ne=(P=Ve?.anchorSelect)!==null&&P!==void 0?P:d;if(!ne&&l&&(ne=`[data-tooltip-id='${l.replace(/'/g,"\\'")}']`),ne)try{const ce=Array.from(document.querySelectorAll(ne));Bt(ce)}catch{Bt([])}},[l,d,Ve?.anchorSelect]),b.useEffect(()=>{Ct.current&&(Tn(Ct),Rn(w))},[w]);const Ut=(Me=Ve?.content)!==null&&Me!==void 0?Me:q,Tt=Dt&&Object.keys(dn.tooltipStyles).length>0;return b.useImperativeHandle(n,()=>({open:P=>{if(P?.anchorSelect)try{document.querySelector(P.anchorSelect)}catch{return void console.warn(`[react-tooltip] "${P.anchorSelect}" is not a valid CSS selector`)}Yn(P??null),P?.delay?Rn(P.delay):ke(!0)},close:P=>{P?.delay?Ua(P.delay):ke(!1)},activeAnchor:Q,place:dn.place,isOpen:!!(ia&&!_&&Ut&&Tt)})),ia&&!_&&Ut?rl.createElement(C,{id:l,role:gt,className:Cd("react-tooltip",Hs.tooltip,Wf.tooltip,Wf[u],i,`react-tooltip__place-${dn.place}`,Hs[Tt?"show":"closing"],Tt?"react-tooltip__show":"react-tooltip__closing",x==="fixed"&&Hs.fixed,D&&Hs.clickable),onTransitionEnd:P=>{Tn(sa),Dt||P.propertyName!=="opacity"||(Qn(!1),Yn(null),me?.())},style:{...Ae,...dn.tooltipStyles,opacity:ae!==void 0&&Tt?ae:void 0},ref:Ge},Ut,rl.createElement(C,{className:Cd("react-tooltip-arrow",Hs.arrow,Wf.arrow,r,T&&Hs.noArrow),style:{...dn.tooltipArrowStyles,background:ge?`linear-gradient(to right bottom, transparent 50%, ${ge} 50%)`:void 0,"--rt-arrow-size":`${oe}px`},ref:Hn})):null},q6=({content:n})=>rl.createElement("span",{dangerouslySetInnerHTML:{__html:n}}),ih=rl.forwardRef(({id:n,anchorId:l,anchorSelect:i,content:r,html:u,render:c,className:d,classNameArrow:m,variant:p="dark",place:y="top",offset:g=10,wrapper:x="div",children:E=null,events:C=["hover"],openOnClick:w=!1,positionStrategy:j="absolute",middlewares:N,delayShow:_=0,delayHide:T=0,float:D=!1,hidden:H=!1,noArrow:G=!1,clickable:V=!1,closeOnEsc:K=!1,closeOnScroll:Z=!1,closeOnResize:te=!1,openEvents:ye,closeEvents:Ae,globalCloseEvents:Ce,imperativeModeOnly:$e=!1,style:me,position:_e,isOpen:q,defaultIsOpen:F=!1,disableStyleInjection:J=!1,border:he,opacity:R,arrowColor:Q,arrowSize:I,setIsOpen:W,afterShow:ae,afterHide:ge,disableTooltip:oe,role:gt="tooltip"},Me)=>{const[Ge,Hn]=b.useState(r),[Ct,fn]=b.useState(u),[sa,dn]=b.useState(y),[oi,Dt]=b.useState(p),[Mt,ia]=b.useState(g),[Qn,Ve]=b.useState(_),[Yn,gl]=b.useState(T),[Oa,bl]=b.useState(D),[es,hn]=b.useState(H),[Je,Bt]=b.useState(x),[tt,Da]=b.useState(C),[ui,Ma]=b.useState(j),[mn,_t]=b.useState(null),[ke,ra]=b.useState(null),Rn=b.useRef(J),{anchorRefs:Ua,activeAnchor:La}=Bv(n),oa=nt=>nt?.getAttributeNames().reduce((Nt,ie)=>{var Se;return ie.startsWith("data-tooltip-")&&(Nt[ie.replace(/^data-tooltip-/,"")]=(Se=nt?.getAttribute(ie))!==null&&Se!==void 0?Se:null),Nt},{}),Vn=nt=>{const Nt={place:ie=>{var Se;dn((Se=ie)!==null&&Se!==void 0?Se:y)},content:ie=>{Hn(ie??r)},html:ie=>{fn(ie??u)},variant:ie=>{var Se;Dt((Se=ie)!==null&&Se!==void 0?Se:p)},offset:ie=>{ia(ie===null?g:Number(ie))},wrapper:ie=>{var Se;Bt((Se=ie)!==null&&Se!==void 0?Se:x)},events:ie=>{const Se=ie?.split(" ");Da(Se??C)},"position-strategy":ie=>{var Se;Ma((Se=ie)!==null&&Se!==void 0?Se:j)},"delay-show":ie=>{Ve(ie===null?_:Number(ie))},"delay-hide":ie=>{gl(ie===null?T:Number(ie))},float:ie=>{bl(ie===null?D:ie==="true")},hidden:ie=>{hn(ie===null?H:ie==="true")},"class-name":ie=>{_t(ie)}};Object.values(Nt).forEach(ie=>ie(null)),Object.entries(nt).forEach(([ie,Se])=>{var Ut;(Ut=Nt[ie])===null||Ut===void 0||Ut.call(Nt,Se)})};b.useEffect(()=>{Hn(r)},[r]),b.useEffect(()=>{fn(u)},[u]),b.useEffect(()=>{dn(y)},[y]),b.useEffect(()=>{Dt(p)},[p]),b.useEffect(()=>{ia(g)},[g]),b.useEffect(()=>{Ve(_)},[_]),b.useEffect(()=>{gl(T)},[T]),b.useEffect(()=>{bl(D)},[D]),b.useEffect(()=>{hn(H)},[H]),b.useEffect(()=>{Ma(j)},[j]),b.useEffect(()=>{Rn.current!==J&&console.warn("[react-tooltip] Do not change `disableStyleInjection` dynamically.")},[J]),b.useEffect(()=>{typeof window<"u"&&window.dispatchEvent(new CustomEvent("react-tooltip-inject-styles",{detail:{disableCore:J==="core",disableBase:J}}))},[]),b.useEffect(()=>{var nt;const Nt=new Set(Ua);let ie=i;if(!ie&&n&&(ie=`[data-tooltip-id='${n.replace(/'/g,"\\'")}']`),ie)try{document.querySelectorAll(ie).forEach(ne=>{Nt.add({current:ne})})}catch{console.warn(`[react-tooltip] "${ie}" is not a valid CSS selector`)}const Se=document.querySelector(`[id='${l}']`);if(Se&&Nt.add({current:Se}),!Nt.size)return()=>null;const Ut=(nt=ke??Se)!==null&&nt!==void 0?nt:La.current,Tt=new MutationObserver(ne=>{ne.forEach(ce=>{var Fe;if(!Ut||ce.type!=="attributes"||!(!((Fe=ce.attributeName)===null||Fe===void 0)&&Fe.startsWith("data-tooltip-")))return;const ht=oa(Ut);Vn(ht)})}),P={attributes:!0,childList:!1,subtree:!1};if(Ut){const ne=oa(Ut);Vn(ne),Tt.observe(Ut,P)}return()=>{Tt.disconnect()}},[Ua,La,ke,l,i]),b.useEffect(()=>{me?.border&&console.warn("[react-tooltip] Do not set `style.border`. Use `border` prop instead."),he&&!Vy("border",`${he}`)&&console.warn(`[react-tooltip] "${he}" is not a valid \`border\`.`),me?.opacity&&console.warn("[react-tooltip] Do not set `style.opacity`. Use `opacity` prop instead."),R&&!Vy("opacity",`${R}`)&&console.warn(`[react-tooltip] "${R}" is not a valid \`opacity\`.`)},[]);let pn=E;const xl=b.useRef(null);if(c){const nt=c({content:ke?.getAttribute("data-tooltip-content")||Ge||null,activeAnchor:ke});pn=nt?rl.createElement("div",{ref:xl,className:"react-tooltip-content-wrapper"},nt):null}else Ge&&(pn=Ge);Ct&&(pn=rl.createElement(q6,{content:Ct}));const Sl={forwardRef:Me,id:n,anchorId:l,anchorSelect:i,className:Cd(d,mn),classNameArrow:m,content:pn,contentWrapperRef:xl,place:sa,variant:oi,offset:Mt,wrapper:Je,events:tt,openOnClick:w,positionStrategy:ui,middlewares:N,delayShow:Qn,delayHide:Yn,float:Oa,hidden:es,noArrow:G,clickable:V,closeOnEsc:K,closeOnScroll:Z,closeOnResize:te,openEvents:ye,closeEvents:Ae,globalCloseEvents:Ce,imperativeModeOnly:$e,style:me,position:_e,isOpen:q,defaultIsOpen:F,border:he,opacity:R,arrowColor:Q,arrowSize:I,setIsOpen:W,afterShow:ae,afterHide:ge,disableTooltip:oe,activeAnchor:ke,setActiveAnchor:nt=>ra(nt),role:gt};return rl.createElement(k6,{...Sl})});typeof window<"u"&&window.addEventListener("react-tooltip-inject-styles",n=>{n.detail.disableCore||Qy({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"}),n.detail.disableBase||Qy({css:`
193
- .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 gr=n=>b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...n},b.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:48,d:"M184 112l144 144-144 144"})),B6=n=>b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...n},b.createElement("path",{d:"M320 146s24.36-12-64-12a160 160 0 10160 160",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeMiterlimit:10,strokeWidth:32}),b.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32,d:"M256 58l80 80-80 80"})),H6=n=>b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...n},b.createElement("rect",{x:128,y:128,width:336,height:336,rx:57,ry:57,fill:"none",stroke:"currentColor",strokeLinejoin:"round",strokeWidth:32}),b.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})),Q6=n=>b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...n},b.createElement("circle",{cx:128,cy:256,r:48,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32}),b.createElement("circle",{cx:384,cy:112,r:48,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32}),b.createElement("circle",{cx:384,cy:400,r:48,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32}),b.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"})),Y6=()=>{const n=Pd(),l=M4();return{rename:async r=>{if(n){const u=await Or("New tab name",r);u&&await l.mutateAsync({id:n,payload:{name:u}})}return Promise.resolve()}}},Hv=["shift","alt","meta","mod","ctrl","control"],V6={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 fl(n){return(V6[n.trim()]||n.trim()).toLowerCase().replace(/key|digit|numpad/,"")}function Qv(n){return Hv.includes(n)}function ed(n,l=","){return n.toLowerCase().split(l)}function td(n,l="+",i=">",r=!1,u){let c=[],d=!1;n=n.trim(),n.includes(i)?(d=!0,c=n.toLocaleLowerCase().split(i).map(y=>fl(y))):c=n.toLocaleLowerCase().split(l).map(y=>fl(y));const m={alt:c.includes("alt"),ctrl:c.includes("ctrl")||c.includes("control"),shift:c.includes("shift"),meta:c.includes("meta"),mod:c.includes("mod"),useKey:r},p=c.filter(y=>!Hv.includes(y));return{...m,keys:p,description:u,isSequence:d,hotkey:n}}typeof document<"u"&&(document.addEventListener("keydown",n=>{n.code!==void 0&&Yv([fl(n.code)])}),document.addEventListener("keyup",n=>{n.code!==void 0&&Vv([fl(n.code)])})),typeof window<"u"&&(window.addEventListener("blur",()=>{Na.clear()}),window.addEventListener("contextmenu",()=>{setTimeout(()=>{Na.clear()},0)}));const Na=new Set;function rh(n){return Array.isArray(n)}function K6(n,l=","){return(rh(n)?n:n.split(l)).every(i=>Na.has(i.trim().toLowerCase()))}function Yv(n){const l=Array.isArray(n)?n:[n];Na.has("meta")&&Na.forEach(i=>!Qv(i)&&Na.delete(i.toLowerCase())),l.forEach(i=>Na.add(i.toLowerCase()))}function Vv(n){const l=Array.isArray(n)?n:[n];n==="meta"?Na.clear():l.forEach(i=>Na.delete(i.toLowerCase()))}function $6(n,l,i){(typeof i=="function"&&i(n,l)||i===!0)&&n.preventDefault()}function G6(n,l,i){return typeof i=="function"?i(n,l):i===!0||i===void 0}const X6=["input","textarea","select","searchbox","slider","spinbutton","menuitem","menuitemcheckbox","menuitemradio","option","radio","textbox"];function F6(n){return Kv(n,X6)}function Kv(n,l=!1){const{target:i,composed:r}=n;let u,c;return Z6(i)&&r?(u=n.composedPath()[0]&&n.composedPath()[0].tagName,c=n.composedPath()[0]&&n.composedPath()[0].role):(u=i&&i.tagName,c=i&&i.role),rh(l)?!!(u&&l&&l.some(d=>d.toLowerCase()===u.toLowerCase()||d===c)):!!(u&&l&&l)}function Z6(n){return!!n.tagName&&!n.tagName.startsWith("-")&&n.tagName.includes("-")}function P6(n,l){return n.length===0&&l?(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):l?n.some(i=>l.includes(i))||n.includes("*"):!0}const J6=(n,l,i=!1)=>{const{alt:r,meta:u,mod:c,shift:d,ctrl:m,keys:p,useKey:y}=l,{code:g,key:x,ctrlKey:E,metaKey:C,shiftKey:w,altKey:j}=n,N=fl(g);if(y&&p?.length===1&&p.includes(x))return!0;if(!p?.includes(N)&&!["ctrl","control","unknown","meta","alt","shift","os"].includes(N))return!1;if(!i){if(r!==j&&N!=="alt"||d!==w&&N!=="shift")return!1;if(c){if(!C&&!E)return!1}else if(u!==C&&N!=="meta"&&N!=="os"||m!==E&&N!=="ctrl"&&N!=="control")return!1}return p&&p.length===1&&p.includes(N)?!0:p?K6(p):!p},I6=b.createContext(void 0),W6=()=>b.useContext(I6);function $v(n,l){return n&&l&&typeof n=="object"&&typeof l=="object"?Object.keys(n).length===Object.keys(l).length&&Object.keys(n).reduce((i,r)=>i&&$v(n[r],l[r]),!0):n===l}const e_=b.createContext({hotkeys:[],activeScopes:[],toggleScope:()=>{},enableScope:()=>{},disableScope:()=>{}}),t_=()=>b.useContext(e_);function n_(n){const l=b.useRef(void 0);return $v(l.current,n)||(l.current=n),l.current}const Xy=n=>{n.stopPropagation(),n.preventDefault(),n.stopImmediatePropagation()},a_=typeof window<"u"?b.useLayoutEffect:b.useEffect;function on(n,l,i,r){const u=b.useRef(null),c=b.useRef(!1),d=Array.isArray(i)?Array.isArray(r)?void 0:r:i,m=rh(n)?n.join(d?.delimiter):n,p=Array.isArray(i)?i:Array.isArray(r)?r:void 0,y=b.useCallback(l,p??[]),g=b.useRef(y);p?g.current=y:g.current=l;const x=n_(d),{activeScopes:E}=t_(),C=W6();return a_(()=>{if(x?.enabled===!1||!P6(E,x?.scopes))return;let w=[],j;const N=(H,G=!1)=>{if(!(F6(H)&&!Kv(H,x?.enableOnFormTags))){if(u.current!==null){const V=u.current.getRootNode();if((V instanceof Document||V instanceof ShadowRoot)&&V.activeElement!==u.current&&!u.current.contains(V.activeElement)){Xy(H);return}}H.target?.isContentEditable&&!x?.enableOnContentEditable||ed(m,x?.delimiter).forEach(V=>{if(V.includes(x?.splitKey??"+")&&V.includes(x?.sequenceSplitKey??">")){console.warn(`Hotkey ${V} contains both ${x?.splitKey??"+"} and ${x?.sequenceSplitKey??">"} which is not supported.`);return}const K=td(V,x?.splitKey,x?.sequenceSplitKey,x?.useKey,x?.description);if(K.isSequence){j=setTimeout(()=>{w=[]},x?.sequenceTimeoutMs??1e3);const Z=K.useKey?H.key:fl(H.code);if(Qv(Z.toLowerCase()))return;w.push(Z);const te=K.keys?.[w.length-1];if(Z!==te){w=[],j&&clearTimeout(j);return}w.length===K.keys?.length&&(g.current(H,K),j&&clearTimeout(j),w=[])}else if(J6(H,K,x?.ignoreModifiers)||K.keys?.includes("*")){if(x?.ignoreEventWhen?.(H)||G&&c.current)return;if($6(H,K,x?.preventDefault),!G6(H,K,x?.enabled)){Xy(H);return}g.current(H,K),G||(c.current=!0)}})}},_=H=>{H.code!==void 0&&(Yv(fl(H.code)),(x?.keydown===void 0&&x?.keyup!==!0||x?.keydown)&&N(H))},T=H=>{H.code!==void 0&&(Vv(fl(H.code)),c.current=!1,x?.keyup&&N(H,!0))},D=u.current||d?.document||document;return D.addEventListener("keyup",T,d?.eventListenerOptions),D.addEventListener("keydown",_,d?.eventListenerOptions),C&&ed(m,x?.delimiter).forEach(H=>C.addHotkey(td(H,x?.splitKey,x?.sequenceSplitKey,x?.useKey,x?.description))),()=>{D.removeEventListener("keyup",T,d?.eventListenerOptions),D.removeEventListener("keydown",_,d?.eventListenerOptions),C&&ed(m,x?.delimiter).forEach(H=>C.removeHotkey(td(H,x?.splitKey,x?.sequenceSplitKey,x?.useKey,x?.description))),w=[],j&&clearTimeout(j)}},[m,x,E]),u}function l_(){return h.jsxs("div",{className:"flex items-center bg-white border-b border-gray-200 overflow-auto no-scrollbar",children:[h.jsx(s_,{}),h.jsx(r_,{})]})}function s_(){const{dataSourceId:n,name:l}=b.useContext(vl),{data:i}=Cu(n),{data:r}=b.useContext(Ra),u=Ar($t.EDITOR),c=KC(),{rename:d}=Y6(),m=()=>{r?.result.columns?.[0].table&&Fd({table:r?.result.columns?.[0].table,dataSourceId:n})},p=async()=>{const g=await Or("Query name",l);!g||!r?.result.queryHistoryId||c.mutate({name:g,queryId:r.result.queryHistoryId})},y=()=>d(l);return on("s",p),on("r",y),h.jsxs("div",{className:se.tableConfig,children:[h.jsx("button",{"data-tooltip-id":"default","data-tooltip-content":"Rename tab",onClick:y,className:re(se.tableAction,se.blue,"block"),children:h.jsxs("span",{className:se.tabName,children:["🛠️ ",l]})}),h.jsxs("button",{"data-tooltip-id":"explorer-more-actions",className:re(se.tableAction,se.blue),children:[h.jsx("span",{className:"whitespace-nowrap",children:"Options"}),h.jsx(gr,{width:16,height:16,className:"rotate-90"})]}),h.jsxs(ih,{id:"explorer-more-actions",className:"z-10 shadow-md flex flex-col",clickable:!0,variant:"light",opacity:1,children:[h.jsxs("button",{"data-tooltip-id":"default","data-tooltip-content":"Manage filters",onClick:()=>Un("filters"),className:re(se.tableAction,se.modal,se.blue),children:[h.jsx("span",{children:"Filters"}),h.jsx("span",{className:"hotkey",children:"F"})]}),h.jsxs("button",{"data-tooltip-id":"default","data-tooltip-content":"Join tables",onClick:()=>Un("joins"),className:re(se.tableAction,se.modal,se.blue),children:[h.jsx("span",{children:"Joins"}),h.jsx("span",{className:"hotkey",children:"J"})]}),h.jsxs("button",{onClick:()=>Un("columns"),className:re(se.tableAction,se.modal,se.blue,"justify-between"),children:[h.jsx("span",{children:"Columns"}),h.jsx("span",{className:"hotkey",children:"C"})]}),h.jsxs("button",{onClick:()=>Un("groupBy"),className:re(se.tableAction,se.modal,se.blue,"justify-between"),children:[h.jsx("span",{children:"Group by"}),h.jsx("span",{className:"hotkey",children:"G"})]}),h.jsxs("button",{onClick:()=>Un("aggregate"),className:re(se.tableAction,se.modal,se.blue,"justify-between"),children:[h.jsx("span",{children:"Aggregate"}),h.jsx("span",{className:"hotkey",children:"A"})]}),u&&h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"h-0.5 my-2 bg-gray-100"}),h.jsxs("button",{onClick:p,className:re(se.tableAction,se.modal,se.blue),children:[h.jsx("span",{children:"Save query"}),h.jsx("span",{className:"hotkey",children:"S"})]}),i?.allowInsert===!0&&h.jsx("button",{onClick:m,className:re(se.tableAction,se.modal,se.blue),children:"Insert new row"})]})]})]})}const i_=[5,10,20,50,100,200];function r_(){const{page:n,size:l,setPage:i,setSize:r}=VC(),{data:u,refetch:c,isFetching:d}=b.useContext(Ra),{name:m}=b.useContext(vl),{state:p}=b.useContext(Zt),y=si(),g=Et(),x=()=>{y.mutateAsync({name:m,opts:p}).then(T=>{g(`${Ye.workbench.path}/tab/${T.id}`)})},E=()=>{if(u?.result.queryHistoryId){const T=new URL(window.location.href);T.pathname=Ye.share.path,T.searchParams.set("shareId",u.result.queryHistoryId),navigator.clipboard.writeText(T.toString()),sn.success("Share link copied to clipboard")}};on("d",x);const C=n*l,w=!d&&!!u?.result.hasMore,j=u?.result.rows.length||0,N=()=>{n>0&&i(n-1)},_=()=>{w&&i(n+1)};return h.jsxs("div",{className:se.tableConfig,children:[h.jsxs("span",{"data-tooltip-id":"rows-num",className:se.paginationIndicator,children:[C+1," - ",C+j,w&&"+"]}),h.jsx("span",{"data-tooltip-content":"Previous page","data-tooltip-id":"default",className:re(se.tableAction,se.blue,n<1&&"opacity-30"),onClick:N,role:"button",children:h.jsx(gr,{width:16,height:16,className:"rotate-180"})}),h.jsx("span",{"data-tooltip-content":"Next page","data-tooltip-id":"default",className:re(se.tableAction,w?se.blue:"opacity-30"),onClick:_,role:"button",children:h.jsx(gr,{width:16,height:16})}),h.jsx("span",{"data-tooltip-content":"Refresh data","data-tooltip-id":"default",className:re(se.tableAction,se.blue),onClick:()=>c(),role:"button",children:h.jsx(B6,{width:16,height:16})}),h.jsx("span",{"data-tooltip-content":"Share query","data-tooltip-id":"default",className:re(se.tableAction,se.blue),onClick:E,role:"button",children:h.jsx(Q6,{width:16,height:16})}),h.jsx("span",{"data-tooltip-content":"Duplicate tab","data-tooltip-id":"default",className:re(se.tableAction,se.blue),onClick:x,role:"button",children:h.jsx(H6,{width:16,height:16})}),h.jsx(ih,{id:"rows-num",className:"z-10 shadow-md flex gap-1",clickable:!0,variant:"light",opacity:1,children:i_.map(T=>h.jsx("button",{onClick:()=>r(T,!0),className:re(se.tableAction,se.blue,T===l&&se.selectedSize),children:h.jsx("span",{children:T})},T))})]})}const o_="_drop-container_3xdxk_2",u_="_item_3xdxk_2",Fy={dropContainer:o_,item:u_},Nd=({dataSourceId:n,focusId:l,placeholder:i="Column",onChange:r,value:u,autoFocus:c,allowTables:d})=>{const{data:m}=ai(n),p=b.useRef(null),y=b.useMemo(()=>{if(!m)return[];let _=m;return d&&(_=m.filter(T=>d.includes(T.tableName))),_.flatMap(T=>T.columns.map(D=>({value:T.tableName+"."+D.name,label:D.name,table:T.tableName,searchValue:D.name.toLowerCase()})))},[m,d]),g=b.useMemo(()=>{const _=u.toLowerCase()||"",T=[];for(let D=0;D<y.length&&T.length<10;D++)y[D].searchValue.includes(_)&&T.push(y[D]);return T},[y,u]),[x,E]=b.useState(!1),[C,w]=b.useState(0),j=_=>{if(_.key==="ArrowDown")_.preventDefault(),w(T=>(T+1)%g.length);else if(_.key==="ArrowUp")_.preventDefault(),w(T=>(T-1+g.length)%g.length);else if(_.key==="Enter"&&C>=0&&C<g.length){_.preventDefault();const T=g[C].value;E(!1);const D=y.findIndex(H=>H.value===T)>-1;r(g[C]?.value||T,D,!0)}};b.useEffect(()=>{const _=p.current?.querySelector('[data-is-active="true"]');_&&_.scrollIntoView({behavior:"smooth",block:"nearest"})},[C]);const N=_=>{const T=_.currentTarget.value,D=y.findIndex(H=>H.value===T)>-1;r(T,D,!1)};return h.jsxs("div",{className:"relative",onFocus:()=>E(!0),onBlur:()=>E(!1),children:[h.jsx("input",{autoFocus:c,onKeyDown:j,value:u,onChange:N,className:"input w-full",placeholder:i,"data-focus":l}),x&&g.length>0&&h.jsx("div",{className:Fy.dropContainer,ref:p,tabIndex:-1,children:g.map((_,T)=>h.jsxs("div",{className:Fy.item,"data-is-active":C===T,onMouseDownCapture:D=>{D.preventDefault(),E(!1),r(_.value,!0,!0)},children:[h.jsx("span",{className:"text-xs font-semibold truncate",children:_.table}),h.jsx("p",{className:"truncate text-sm",children:_.label})]},T))})]})},c_="_drop-container_149or_2",f_="_item_149or_2",Zy={dropContainer:c_,item:f_};function d_(n){return E4.includes(n)?x4:C4.includes(n)?b4:_4.includes(n)?S4:Kd}const h_=({value:n,onChange:l,autoFocus:i,focusId:r,colType:u})=>{const c=b.useMemo(()=>{const E=n.toLowerCase()||"";return d_(u||"").filter(C=>C.label.includes(E))},[n,u]),d=b.useRef(null),[m,p]=b.useState(!1),[y,g]=b.useState(0),x=E=>{E.key==="ArrowDown"?(E.preventDefault(),g(C=>(C+1)%c.length)):E.key==="ArrowUp"?(E.preventDefault(),g(C=>(C-1+c.length)%c.length)):E.key==="Enter"&&(y>=0&&y<c.length?(E.preventDefault(),p(!1),l(c[y]?.label||"",!0)):l(n,!0))};return b.useEffect(()=>{const E=d.current?.querySelector('[data-is-active="true"]');E&&E.scrollIntoView({behavior:"smooth",block:"nearest"})},[y]),h.jsxs("div",{className:"relative",children:[h.jsx("input",{onKeyDown:x,value:n,onChange:E=>l(E.target.value,!1),className:"input w-full",placeholder:"Operator",autoFocus:i,onFocus:()=>p(!0),onBlur:()=>p(!1),"data-focus":r}),m&&c.length>0&&h.jsx("ul",{className:Zy.dropContainer,ref:d,tabIndex:-1,children:c.map((E,C)=>h.jsx("li",{className:Zy.item,"data-is-active":y===C,onMouseDownCapture:w=>{w.preventDefault(),p(!1),l(E.label,!0)},children:E.label},C))})]})},Gv=()=>{const{state:n,setState:l}=b.useContext(Zt),i=b.useCallback((u,c=!1)=>{l(d=>({...d,page:c?0:d.page,filters:u}))},[l]),r=b.useCallback(u=>{l(c=>({...c,filters:c.filters.filter(d=>d.id!==u)}))},[l]);return{filters:n.filters,removeFilter:r,setFilters:i}},m_="_actions_1r6uv_2",p_="_filter-actions_1r6uv_2",Xv={actions:m_,filterActions:p_},y_=["=","<",">",">=","<>","!=","<="];function v_(n){for(let l=0;l<n.length;l++){const i=n[l];if(!i.operator.length&&!i.value.length&&!i.column.length)continue;if(!i.column.includes("."))return sn.error(`Filter #${l+1} has invalid column value`),!1;const r=$d[i.operator];if(!r)return sn.error(`Filter #${l+1} has invalid operator`),!1;if(i.isColumnRef&&!y_.includes(r))return sn.error(`Filter #${l+1} cannot reference another column because it uses '${i.operator}' operator`),!1}return!0}function g_(n){const l=[];return n.forEach(i=>{if(!i.operator.length||!i.column.length||i.operator!=="is null"&&i.operator!=="is not null"&&!i.value.length)return;const r=$d[i.operator];l.push({id:i.id,value:i.isColumnRef?[{value:i.value,isColumn:!0}]:w4(r,i.value),operator:r,column:i.column,isEnabled:i.isEnabled,connector:"AND"})}),l}function b_(n){let l="";if(n.value)for(let i=0;i<n.value.length;i++)l+=n.value[i].value,i<n.value.length-1&&(l+=", ");return l}const x_=({filter:n,dataSourceId:l,allowedTables:i,inspections:r,autoFocus:u,onChangeColumn:c,onChangeOperator:d,onChangeValue:m,onRemoveFilter:p,triggerIsEnabled:y,onIsColumnChange:g})=>{const x=b.useMemo(()=>{if(!r)return"";let E=null;for(const C of r)for(const w of C.columns)C.tableName+"."+w.name===n.column&&(E=w);return E?.type?E.type:""},[n.column,r]);return h.jsxs("div",{className:"flex gap-2 items-center",children:[h.jsx("label",{children:h.jsx("input",{type:"checkbox",checked:n.isEnabled!==!1,onClick:()=>y(n.id)})}),h.jsx("label",{className:"w-full",children:h.jsx(Nd,{dataSourceId:l,onChange:E=>c(n.id,E),value:n.column,allowTables:i,focusId:"column",autoFocus:u})}),h.jsx("label",{children:h.jsx(h_,{onChange:E=>d(n.id,E),focusId:"operator",colType:x,value:n.operator})}),pv($d[n.operator])&&h.jsx("label",{className:"w-full",children:n.isColumnRef?h.jsx(Nd,{dataSourceId:l,onChange:E=>m(n.id,E),value:n.value,allowTables:i,focusId:"value",placeholder:"Search column"}):h.jsx("input",{className:"input w-full",placeholder:"Filter value",value:n.value,onChange:E=>m(n.id,E.currentTarget.value),"data-focus":"value"})}),h.jsxs("div",{className:Xv.filterActions,children:[h.jsx("button",{tabIndex:-1,"data-tooltip-id":"default","data-tooltip-content":"If enabled, the value will reference another column instead of being raw string",className:re("p-0.5 cursor-pointer rounded-lg border",n.isColumnRef?"bg-blue-50 border-blue-200":"bg-white border-white"),onClick:()=>g(n.id,!n.isColumnRef),children:"🏷️"}),h.jsx("button",{tabIndex:-1,"data-tooltip-id":"default","data-tooltip-content":"Remove filter",className:"p-0.5 text-sm cursor-pointer",onClick:()=>p(n.id),children:h.jsx(Pl,{width:20,height:20,className:"text-red-600"})})]})]})},S_=()=>{const{state:n}=b.useContext(Zt),{setFilters:l}=Gv(),i=_u(N=>N.filters),{data:r}=ai(n.dataSourceId),u=b.useMemo(()=>[n.table,...n.joins.map(N=>N.table)],[n.table,n.joins]),[c,d]=b.useState([]),m=(N,_)=>{d(T=>[...T.map(D=>D.id===N?{...D,column:_}:D)])},p=(N,_)=>{d(T=>[...T.map(D=>D.id===N?{...D,operator:_}:D)])},y=(N,_)=>{d(T=>[...T.map(D=>D.id===N?{...D,value:_}:D)])},g=()=>{d(N=>[...N,{id:dl(),value:"",column:"",operator:"",isColumnRef:!1,isEnabled:!0}])},x=(N,_)=>{d(T=>[...T.map(D=>D.id===N?{...D,isColumnRef:_}:D)])},E=N=>{d(_=>_.filter(T=>T.id!==N))},C=()=>Nu("filters"),w=()=>{v_(c)&&(l(g_(c)),C())},j=N=>{d(_=>_.map(T=>T.id===N?{...T,isEnabled:!T.isEnabled}:T))};return b.useEffect(()=>{i&&d(()=>{const N=n.filters.map(_=>({id:_.id,value:b_(_),column:_.column,operator:mv[_.operator],isColumnRef:!!_.value?.[0]?.isColumn,isEnabled:_.isEnabled}));return N.push({id:dl(),value:"",column:"",operator:"",isColumnRef:!1,isEnabled:!0}),N})},[i]),on("f",()=>{du("filters")}),on("ctrl+f",()=>{alert("Save filters")}),h.jsxs(cn,{isVisible:i,onClose:C,portal:!0,onClosed:()=>d([]),children:[h.jsx(aa,{onClick:C}),h.jsx("h2",{className:"text-lg font-semibold",children:"Filters"}),h.jsxs("div",{className:"flex gap-4 flex-col w-full lg:w-lg my-4",children:[c.length<1&&h.jsx("p",{className:"p-1 text-center rounded-lg bg-gray-50 border border-gray-200",children:"No filters"}),c.map((N,_)=>h.jsx(x_,{filter:N,dataSourceId:n.dataSourceId,allowedTables:u,inspections:r||[],onChangeColumn:m,onChangeOperator:p,onChangeValue:y,onRemoveFilter:E,onIsColumnChange:x,triggerIsEnabled:j,autoFocus:_===c.length-1},N.id))]}),h.jsxs("div",{className:Xv.actions,children:[h.jsx("button",{className:"button tertiary",onClick:g,children:"Add filter"}),h.jsx("button",{className:"button primary",onClick:w,children:"Apply filters"})]})]})},w_="_join-modal_1pmtt_2",E_={joinModal:w_},C_=(n,l)=>n.type!==l.type||n.on!==l.on||n.table!==l.table,__=(n,l)=>n.type===l.type&&n.on===l.on&&n.table===l.table,Fv=()=>{const{state:n,setState:l}=b.useContext(Zt),i=b.useCallback(r=>{l(u=>{const c=u.joins;if(c.some(m=>__(m,r))){const m=r.table+".";return{...u,joins:c.filter(p=>C_(p,r)),columns:u.columns.filter(p=>!p.value.startsWith(m)),groupBy:u.groupBy.filter(p=>!p.value.startsWith(m)),orderBy:u.orderBy.filter(p=>!p.column.startsWith(m)),aggregations:u.aggregations.filter(p=>!p.value.startsWith(m)),filters:u.filters.filter(p=>!p.column.startsWith(m))}}return{...u,joins:[...c,r]}})},[l]);return{joins:n.joins,toggle:i}},N_=()=>{const{isFetching:n}=b.useContext(Ra),l=_u(p=>p.joins),{toggle:i}=Fv(),{availableJoins:r}=b.useContext(vl),[u,c]=b.useState(""),d=b.useMemo(()=>{const p=u.toLowerCase();return r.filter(y=>y.on.toTable.toLowerCase().includes(p))},[r,u]),m=()=>Nu("joins");return on("j",()=>{r.length>0?Un("joins"):sn.error("No available tables to join")}),h.jsxs(cn,{isVisible:l,onClose:m,portal:!0,children:[h.jsx(aa,{onClick:m}),h.jsxs("div",{className:E_.joinModal,children:[h.jsx("h2",{className:"text-lg font-semibold mb-4",children:"Join table"}),r.length>0?h.jsx("input",{className:"input w-full",placeholder:"Filter",autoFocus:!0,onChange:p=>c(p.target.value),value:u,disabled:n}):h.jsx(wt,{variant:"warning",children:h.jsx("p",{className:"text-sm truncate",children:"There is nothing else to join"})}),h.jsx("div",{className:`flex flex-col mt-2 overflow-y-auto ${n?"opacity-40":""}`,children:d.map(p=>h.jsx(Tv,{hook:p,onClick:()=>{n||(i({table:p.on.toTable,type:"LEFT",on:p.where}),c(""),m())}},p.where))})]})]})};function T_(n){return n.reduce((l,i)=>(l[i]=!0,l),{})}function Py(n){return n.reduce((l,i)=>(l[i]=!0,l),{})}const j_="_container_1t5ww_2",A_="_column-label_1t5ww_2",R_="_not-active_1t5ww_2",su={container:j_,columnLabel:A_,notActive:R_};function O_(n){if(!n)return[];const l={};return n.forEach(i=>{l[i.table]?l[i.table].push({value:i.full,ogColumn:i.column,label:ol(i.column),type:i.type}):l[i.table]=[{value:i.full,ogColumn:i.column,label:ol(i.column),type:i.type}],N4[i.type]&&["YEAR","MONTH","DAY"].forEach(r=>{l[i.table].push({value:r+" "+i.full,ogColumn:i.column,label:r+" "+ol(i.column),type:"number",nested:!0})})}),Object.entries(l).reduce((i,[r,u])=>(i.push({name:ol(r),columns:u}),i),[])}function D_(n,l){const i=l.toLowerCase();return n.map(r=>{const u=r.columns.filter(c=>c.label.toLowerCase().includes(i)||c.ogColumn.toLowerCase().includes(i));return{...r,columns:u}}).filter(r=>r.columns.length>0)}const M_=({column:n,selected:l,onCheck:i})=>h.jsxs("label",{className:re(su.columnLabel,l?su.active:su.notActive,n.nested&&"pl-5!"),children:[h.jsx("input",{type:"checkbox",checked:l[n.value],name:n.value,onChange:i}),h.jsxs("p",{className:"flex justify-between w-full",children:[h.jsx("span",{"data-tooltip-content":n.value,"data-tooltip-id":"default",children:n.label}),h.jsx("span",{className:"text-blue-600",children:n.type})]})]},n.value),U_={columns:"c",groupBy:"g"},Jy=({mode:n})=>{const l=_u(_=>_[n]),{allColumns:i}=b.useContext(vl),{state:r,setState:u}=b.useContext(Zt),[c,d]=b.useState({}),[m,p]=b.useState(""),y=b.useMemo(()=>O_(i),[i]),g=r.aggregations.length>0||r.groupBy.length>0,x=b.useMemo(()=>m?D_(y,m):y,[m,y]),E=_=>{d(T=>({...T,[_.target.name]:_.target.checked}))},C=_=>{const T=_.target.checked;d(D=>{for(const H of i)D[H.full]=T;return{...D}})},w=()=>{Nu(n)},j=()=>{const _=[];for(const[T,D]of Object.entries(c))if(D){const[H,G]=T.split(" ");_.push({value:G||H,fn:G?H:void 0})}u(T=>({...T,[n]:_})),w()},N=b.useMemo(()=>{for(const _ of i)if(!c[_.full])return!1;return!0},[c,i]);return on(U_[n],()=>{n==="columns"?g?sn.error("Columns are ignored when there is at least one aggregation or group by"):du("columns"):du("groupBy")}),b.useEffect(()=>{if(!l){d({});return}d(()=>T_(r[n].map(_=>_.fn?_.fn+" "+_.value:_.value)))},[l,d]),h.jsxs(cn,{isVisible:l,onClose:w,portal:!0,children:[h.jsx(aa,{onClick:w}),h.jsxs("div",{className:su.container,children:[h.jsx("h2",{className:"text-lg font-semibold",children:n==="groupBy"?"Group by":"Show columns"}),h.jsx("input",{autoFocus:!0,className:"input my-2",placeholder:"Filter",value:m,onChange:_=>p(_.target.value)}),h.jsx("div",{className:"overflow-y-auto",children:x.map(_=>h.jsxs("div",{className:"my-2",children:[h.jsxs("p",{className:"font-semibold sticky top-0 bg-white p-1 z-1",children:["📄 ",_.name]}),_.columns.map(T=>h.jsx(M_,{column:T,selected:c,onCheck:E},T.value))]},_.name))}),h.jsxs("div",{className:"flex justify-end gap-2 mt-2",children:[h.jsxs("label",{className:"button tertiary flex gap-2 items-center",children:[h.jsx("input",{type:"checkbox",checked:N,onChange:C}),h.jsx("span",{children:"Select all"})]}),h.jsx("span",{className:"flex-1"}),h.jsx("button",{className:"button tertiary",onClick:w,children:"Cancel"}),h.jsx("button",{className:"button primary",onClick:j,children:"Apply"})]})]})]})},L_="_options-container_ss0hd_2",z_={optionsContainer:L_},nd="COUNT all",k_=()=>{const n=_u(w=>w.aggregate),{dataSourceId:l}=b.useContext(vl),{setState:i,state:r}=b.useContext(Zt),{data:u}=b.useContext(Ra),[c,d]=b.useState({fn:"",col:""}),m=w=>d({...c,fn:w.currentTarget.value}),p=w=>d({...c,col:w}),y=()=>Nu("aggregate"),g=()=>{const w=c.fn===nd?{value:"*",fn:"COUNT"}:{fn:c.fn,value:c.col,distinct:c.fn==="COUNT"};i(j=>({...j,aggregations:[...j.aggregations,w]}))},x=c.fn===nd,E=x?!1:!c.col||!c.fn,C=w=>{const j=yv(w);i(N=>({...N,aggregations:N.aggregations.filter(_=>_.fn!==w.fn||_.value!==w.value),orderBy:N.orderBy.filter(_=>_.column!==j)}))};return on("a",()=>{du("aggregate")}),h.jsxs(cn,{isVisible:n,onClose:y,backdropClose:!0,portal:!0,children:[h.jsx(aa,{onClick:y}),h.jsxs("div",{children:[h.jsx("h2",{className:"text-lg font-semibold",children:"Aggregate"}),hl(r.aggregations.length,0)&&h.jsx("div",{className:"flex flex-col gap-1 mt-4",children:r.aggregations.map((w,j)=>h.jsxs("p",{className:"p-2 rounded-md bg-gray-50 flex items-center justify-between",children:[h.jsx("span",{children:au(w)}),h.jsx("button",{tabIndex:-1,"data-tooltip-id":"default","data-tooltip-content":"Remove aggregation",className:"p-0.5 text-sm cursor-pointer",onClick:()=>C(w),children:h.jsx(Pl,{width:20,height:20,className:"text-red-600"})})]},j))}),h.jsxs("div",{className:z_.optionsContainer,children:[h.jsxs("label",{className:re(x&&"col-span-2"),children:[h.jsx("p",{className:"font-semibold text-xs",children:"Function"}),h.jsxs("select",{className:"input w-full",value:c.fn,onChange:m,autoFocus:!0,children:[h.jsx("option",{value:"",disabled:!0,children:"Select function"}),h.jsx("option",{value:nd,children:"Count all rows"}),h.jsx("option",{value:"COUNT",children:"Count"}),h.jsx("option",{value:"SUM",children:"Sum"}),h.jsx("option",{value:"MAX",children:"Max"}),h.jsx("option",{value:"MIN",children:"Min"}),h.jsx("option",{value:"AVG",children:"Avg"})]})]}),!x&&h.jsxs("label",{children:[h.jsx("p",{className:"font-semibold text-xs",children:"Column"}),h.jsx(Nd,{dataSourceId:l,allowTables:u?.result.tables||[],onChange:p,value:c.col})]}),h.jsx("button",{className:"button primary",disabled:E,onClick:g,children:"Add"})]})]})]})},q_="_container_n68f7_2",B_="_yellow-pill_n68f7_2 _pill_n68f7_2",H_="_yellow-outline-pill_n68f7_2 _pill_n68f7_2",Q_="_green-pill_n68f7_2 _pill_n68f7_2",Y_="_blue-pill_n68f7_2 _pill_n68f7_2",V_="_blue-outline-pill_n68f7_2 _pill_n68f7_2",K_="_purple-pill_n68f7_2 _pill_n68f7_2",$_="_red-pill_n68f7_2 _pill_n68f7_2",G_="_black-pill_n68f7_2 _pill_n68f7_2",X_="_disabled-pill_n68f7_2",Jn={container:q_,yellowPill:B_,yellowOutlinePill:H_,greenPill:Q_,bluePill:Y_,blueOutlinePill:V_,purplePill:K_,redPill:$_,blackPill:G_,disabledPill:X_},Iy=n=>b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...n},b.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32,d:"M256 112v288M400 256H112"}));function Zv(n,l=500,i){const[r,u]=b.useState(n),c=b.useRef(i);return c.current=i,b.useEffect(()=>{const d=setTimeout(()=>{u(n),c.current&&c.current(n)},l);return()=>clearTimeout(d)},[n,l]),r}const F_=()=>{const{state:{table:n,dataSourceId:l,aggregations:i,columns:r,groupBy:u}}=b.useContext(Zt),{filters:c,setFilters:d,removeFilter:m}=Gv(),{toggle:p,joins:y}=Fv(),{data:g}=Cu(l),x=()=>Un("joins"),E=()=>Un("filters"),C=()=>Un("aggregate"),w=()=>Un("columns"),j=()=>Un("groupBy"),N=D=>{d(c.map(H=>({...H,isEnabled:D===H.id?!H.isEnabled:H.isEnabled})),!0)},_=D=>{D.preventDefault(),D.stopPropagation(),p(y[y.length-1])},T=D=>H=>{H.preventDefault(),H.stopPropagation(),m(D)};return h.jsxs("div",{className:Jn.container,children:[g&&h.jsxs("button",{onClick:x,className:Jn.greenPill,"data-tooltip-id":"default","data-tooltip-content":n,children:[h.jsx(ii,{size:18,type:g.dbType}),h.jsx("p",{className:"text-sm",children:g.name}),h.jsx(gr,{width:12,height:12}),h.jsx("p",{className:"text-sm",children:n})]}),h.jsxs("button",{onClick:x,className:Jn.yellowOutlinePill,"data-tooltip-id":"default","data-tooltip-content":"Join table, hotkey J",children:[h.jsx(Iy,{width:18,height:18}),h.jsx("p",{className:"text-sm",children:"Table"})]}),y.map((D,H)=>h.jsxs("button",{onClick:x,className:Jn.yellowPill,"data-tooltip-id":"default","data-tooltip-content":`Joins ${D.table} on ${D.on}`,children:[h.jsx("p",{className:"text-sm",children:D.table}),H===y.length-1&&h.jsx(Pl,{onClick:_,width:18,height:18})]},D.table)),h.jsxs("button",{onClick:E,className:Jn.blueOutlinePill,"data-tooltip-id":"default","data-tooltip-content":"Add filters, hotkey F",children:[h.jsx(Iy,{width:18,height:18}),h.jsx("p",{className:"text-sm",children:"Filter"})]}),c.map(D=>h.jsxs("button",{onClick:()=>N(D.id),onAuxClick:()=>m(D.id),className:re(Jn.bluePill,D.isEnabled===!1&&Jn.disabledPill),"data-tooltip-id":"default","data-tooltip-content":yE(D),children:[h.jsx("p",{className:"text-sm",children:D.column}),h.jsx("p",{className:"text-sm",children:D.operator}),h.jsx("p",{className:"text-sm",children:vE(D)}),h.jsx(Pl,{onClick:T(D.id),width:18,height:18})]},D.id)),i.map(D=>h.jsx("button",{onClick:C,className:re(Jn.purplePill),"data-tooltip-id":"default","data-tooltip-content":au(D),children:h.jsx("p",{className:"text-sm",children:au(D)})},au(D))),r.length>0&&h.jsx("button",{onClick:w,className:re(Jn.redPill),"data-tooltip-id":"default","data-tooltip-content":"Has hidden columns",children:h.jsx("p",{className:"text-sm",children:"Hidden columns"})}),u.length>0&&h.jsx("button",{onClick:j,className:re(Jn.blackPill),"data-tooltip-id":"default","data-tooltip-content":"Has GROUP BY",children:h.jsx("p",{className:"text-sm",children:"GROUP BY"})}),h.jsx(Z_,{})]})};function Z_(){const{state:n,setState:l}=b.useContext(Zt),[i,r]=b.useState(()=>n.searchAll);return on("k",()=>{Or("Search all text values for",n.searchAll||"",{type:"info",message:"This will search all text values using LIKE operator (numbers, dates and other non string values are not searched)."}).then(c=>{c!==void 0&&(l(d=>({...d,searchAll:c.length>0?c:void 0})),r(c.length>0?c:void 0))})}),Zv(i,500,c=>{l(d=>({...d,searchAll:c&&c.length>0?c:void 0}))}),h.jsx("input",{className:"input text-sm","data-tooltip-id":"default","data-tooltip-content":"Search text in all columns. Can be slow when using a lot of columns.",placeholder:"Search text in all columns",value:i||"",onChange:c=>r(c.currentTarget.value)})}const P_=({options:n,updater:l,name:i,tabId:r})=>{const u=A4(n,l),c=U4(r,u.state),d=j4(c.data,u.state.dataSourceId,i,r);return c.isError?h.jsx("div",{className:"flex-1",children:h.jsx(wt,{variant:"danger",children:"Failed to load query"})}):h.jsx(vl,{value:d,children:h.jsx(Zt,{value:u,children:h.jsxs(Ra,{value:c,children:[h.jsx(l_,{}),h.jsx(F_,{}),h.jsxs("div",{className:"flex-1 flex overflow-hidden border-t border-gray-200",children:[h.jsx("div",{className:"flex-1 overflow-auto pb-24 lg:pb-12 no-scrollbar",children:h.jsx(YC,{})}),h.jsx(S_,{}),h.jsx(N_,{}),h.jsx(Jy,{mode:"columns"}),h.jsx(Jy,{mode:"groupBy"}),h.jsx(k_,{})]})]})})})},Pv=()=>h.jsxs("div",{role:"status",children:[h.jsxs("svg",{"aria-hidden":"true",className:"w-8 h-8 text-gray-200 animate-spin dark:text-gray-600 fill-blue-600",viewBox:"0 0 100 101",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[h.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"}),h.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"})]}),h.jsx("span",{className:"sr-only",children:"Loading..."})]}),J_=({id:n})=>{const{data:l}=O4(n),i=b.useCallback(r=>{if(!l)return;const u=r($s(l.opts));rt.setQueryData(["workbench-tabs",l.id],{...l,opts:{...l.opts,...u}})},[l]);return l?h.jsx(P_,{updater:i,options:l.opts,name:l.name,tabId:l.id}):h.jsx("div",{className:"flex-1 flex justify-center items-center",children:h.jsx(Pv,{})})},I_=n=>{setTimeout(l=>{const i=document.querySelector(`[data-tab-id="${l}"]`);i&&i.scrollIntoView({behavior:"smooth"})},50,n)},W_=()=>{const{id:n}=Z2(),l=Et(),{data:i}=Xd(),r=D4(),u=Ev(Id.laptop),c=p=>{if(p===n&&i){if(i.length===1)return l(Ye.home.path);if(i.length>1){const y=i.find(g=>g.id!==p);if(y)return l(`/workbench/tab/${y.id}`)}}},d=p=>{p.stopPropagation(),p.preventDefault();const y=p.currentTarget.getAttribute("data-tab-id");y&&(r.mutate(y),c(y))},m=p=>{r.mutate(p),c(p)};return b.useEffect(()=>{n&&I_(n)},[n]),h.jsxs("div",{className:"h-screen max-h-screen bg-(--bg) flex flex-col",children:[n&&h.jsx(J_,{id:n}),h.jsx("div",{className:re(cr.tabs,"no-scrollbar",!u&&cr.mobile),children:i?.map(p=>h.jsxs("div",{onClick:()=>l(`${Ye.workbench.path}/tab/${p.id}`),className:re(cr.tab,p.id===n&&cr.active),"data-tooltip-id":"default","data-tab-id":p.id,"data-tooltip-content":p.name,onAuxClick:()=>m(p.id),children:[h.jsxs("span",{className:"truncate w-full",children:["🛠️ ",p.name]}),h.jsx("button",{"data-tab-id":p.id,className:cr.closeButton,onClick:d,children:h.jsx(Pl,{width:20,height:20})})]},p.id))})]})},e5="_root_1e5nd_2",t5="_down_1e5nd_2",n5="_chevron_1e5nd_2",a5="_table-name-container_1e5nd_2",l5="_link_1e5nd_2",s5="_table-name_1e5nd_2",i5="_ul_1e5nd_2",r5="_column-type_1e5nd_2",o5="_action-blue_1e5nd_2 _action_1e5nd_2",u5="_action-red_1e5nd_2 _action_1e5nd_2",jn={root:e5,down:t5,chevron:n5,tableNameContainer:a5,link:l5,tableName:s5,ul:i5,columnType:r5,actionBlue:o5,actionRed:u5},[$N,c5]=un(!1),Jv=()=>c5(!1),f5="_sidebar_1dc7f_2",d5="_sidebar-visible_1dc7f_2",h5="_sidebar-container_1dc7f_2",m5="_sidebar-invisible_1dc7f_2",p5="_backdrop_1dc7f_2",fr={sidebar:f5,sidebarVisible:d5,sidebarContainer:h5,sidebarInvisible:m5,backdrop:p5},Iv=({children:n,backdropClose:l,isVisible:i,onClose:r,onClosed:u,contentClassName:c})=>{const[d,m]=b.useState(!1),p=b.useRef(r);p.current=r;const y=()=>{l&&r()},g=x=>{i||getComputedStyle(x.currentTarget).opacity==="0"&&(m(!1),u&&u())};return b.useEffect(()=>{i&&m(!0)},[i]),b.useEffect(()=>{const x=E=>{i&&E.key==="Escape"&&p.current()};return window.addEventListener("keydown",x),()=>{window.removeEventListener("keydown",x)}},[i]),h.jsxs("div",{onTransitionEnd:g,className:re(fr.sidebar,i?fr.sidebarVisible:fr.sidebarInvisible),children:[h.jsx("div",{onClick:y,className:fr.backdrop}),h.jsx("div",{className:re(fr.sidebarContainer,c),children:d&&n})]})},y5=new Intl.DateTimeFormat("en",{dateStyle:"full",timeStyle:"long"});function v5(n,l){if(l&&n.toLowerCase().includes(l))return"bg-yellow-200"}const g5=({insp:n,filter:l,expanded:i})=>{const r=b.useMemo(()=>i?n.columns:l.length<1?[]:n.columns.filter(u=>u.name.toLowerCase().includes(l)),[n,l,i]);return h.jsx("ul",{className:jn.ul,children:r.map(u=>h.jsx(h.Fragment,{children:h.jsxs("li",{children:[u.isPrimary?"🔐":"🏷️"," ",h.jsx("span",{className:v5(u.name,l),children:u.name})," ",h.jsxs("span",{className:jn.columnType,children:["[",u.type,"]"]}),u.ref&&h.jsxs("span",{children:[" ➡️ ",h.jsx("span",{className:jn.columnType,children:u.ref.table}),".",u.ref.field]})]},u.name+u.type)}))},n.id)};function b5({id:n}){const{data:l}=Cu(n),{data:i}=ai(n),r=Et(),u=r4(),c=fv(),d=o4(),m=si(),p=b.useMemo(()=>l?.lastInspected?y5.format(new Date(l.lastInspected)):"--",[l]),[y,g]=b.useState({}),[x,E]=b.useState(""),[C,w]=b.useState("table"),j=Ar($t.EDITOR),N=x.toLowerCase(),_=b.useMemo(()=>{if(!N||!i)return i||[];const Z=[];for(const te of i){if(te.tableName.toLowerCase().includes(N)){Z.push(te);continue}C!=="table"&&te.columns.findIndex(ye=>ye.name.toLowerCase().includes(N))>=0&&Z.push(te)}return Z},[N,i,C]),T=Z=>{g(te=>({...te,[Z]:!te[Z]}))},D=Z=>{m.mutateAsync({name:Z,opts:$s({table:Z,dataSourceId:n})}).then(te=>{Gs(void 0),Jv(),r(`${Ye.workbench.path}/tab/${te.id}`)})},H=()=>{c.mutate(n)},G=async()=>{const Z=await Or("Enter name",l?.name);Z&&u.mutate({id:n,dataSource:{name:Z}})},V=async()=>{await Sv("Are you sure you want to delete this data source?")&&(d.mutate(n),Gs(void 0))},K=C==="column";return h.jsxs("div",{className:jn.root,children:[h.jsxs("div",{className:"sticky top-0 bg-white border-b border-gray-200 p-4",children:[h.jsxs("h3",{className:"page-head flex gap-2",children:[l&&h.jsx(ii,{size:32,type:l.dbType}),h.jsx("span",{className:"truncate",children:l?.name})]}),h.jsx("p",{className:"mt-2 text-xs text-gray-800",children:"Last DB inspection"}),h.jsx("p",{className:"text-sm font-semibold",children:p}),j&&h.jsxs("div",{className:"mt-2 flex gap-2",children:[h.jsx("button",{disabled:c.isPending,onClick:H,className:jn.actionBlue,children:"Refresh schema"}),h.jsx("button",{disabled:c.isPending,onClick:G,className:jn.actionBlue,children:"Rename"}),h.jsx("button",{disabled:c.isPending,onClick:V,className:jn.actionRed,children:"Delete"})]}),h.jsxs("div",{className:"flex gap-2 items-center mb-2 mt-4",children:[h.jsxs("select",{className:"input",value:C,onChange:Z=>w(Z.currentTarget.value),children:[h.jsx("option",{value:"table",children:"Table"}),h.jsx("option",{value:"column",children:"Column"})]}),h.jsx("input",{className:"input flex-1 bg-gray-50",placeholder:K?"Search column":"Search table",value:x,onChange:Z=>E(Z.target.value),autoFocus:!0})]})]}),h.jsx("div",{className:"overflow-y-auto p-4",children:_?.map(Z=>h.jsxs("div",{children:[h.jsxs("div",{className:jn.tableNameContainer,children:[h.jsx("button",{className:re(jn.chevron,y[Z.id]&&jn.down),onClick:()=>T(Z.id),children:h.jsx(gr,{width:16,height:16})}),h.jsx("button",{className:re(jn.tableName,"flex-1"),onClick:()=>T(Z.id),children:Z.tableName}),h.jsx("button",{className:jn.link,onClick:()=>D(Z.tableName),children:"↗️"})]}),(y[Z.id]||x.length>0)&&h.jsx(g5,{insp:Z,filter:K?N:"",expanded:y[Z.id]})]},Z.id))})]})}const x5=()=>{const n=iE(),[l,i]=b.useState(void 0);b.useEffect(()=>{n&&i(n)},[n]);const r=()=>Gs(void 0);return h.jsx(Iv,{isVisible:n!=null,onClose:r,onClosed:()=>i(void 0),backdropClose:!0,children:l&&h.jsx(b5,{id:l})})},S5="_search_xcfpz_2",w5="_entry_xcfpz_2",E5="_ds_xcfpz_2",C5="_ds-container_xcfpz_2",_5="_ds-entry_xcfpz_2",N5="_enabled_xcfpz_2",Qs={search:S5,entry:w5,ds:E5,dsContainer:C5,dsEntry:_5,enabled:N5};function T5(n,l,i){try{const r=i.getItem(n);if(r)return JSON.parse(r)}catch(r){console.warn("Failed to restore tabs",r)}return l}const j5=({storage:n=localStorage,localStorageKey:l,initialData:i})=>{const r=un(T5(l,i,n));return r[2].subscribe(u=>{n.setItem(l,JSON.stringify(u))}),r},[A5,R5]=j5({initialData:[],localStorageKey:"selected-data-sources-v1"}),O5=n=>R5(l=>{const i=l.indexOf(n);return i>-1?(l.splice(i,1),[...l]):[...l,n]}),D5={table:"📄",query:"📖",tab:"🛠️"},M5=({onTable:n,onQuery:l,onWorkbenchTab:i,autoFocus:r})=>{const[u,c]=b.useState(""),[d,m]=b.useState(-1),p=Zv(u,200),y=A5(),{data:g}=Bn(),{data:x}=Vd({teamId:g?.teamId}),E=b.useMemo(()=>{const T=[],D=Py(y);if(!x||x.length===0)return[];for(const H of x)D[H.id]&&T.push(H.id);return T},[y,x]),{data:C}=e4(p,{teamId:g?.teamId,selectedDataSources:E}),w=T=>{T.type==="table"?n(T.name,T.dataSourceId):T.type==="query"?l(T.id,T.dataSourceId):T.type==="tab"&&i(T.id,T.dataSourceId)},j=T=>{C&&(T.key==="ArrowDown"?(T.preventDefault(),m(D=>(D+1)%C.length)):T.key==="ArrowUp"?(T.preventDefault(),m(D=>(D-1+C.length)%C.length)):T.key==="Enter"&&d>=0&&C[d]?.name&&(T.preventDefault(),w(C[d])))},N=T=>{const D=T.currentTarget.dataset.tableId,H=C?.find(G=>G.id===D);H&&w(H)},_=b.useMemo(()=>Py(y),[y]);return h.jsxs("div",{className:"overflow-hidden flex flex-col w-full lg:w-lg",children:[hl(x?.length,0)&&h.jsx("div",{className:Qs.dsContainer,children:x.map(T=>h.jsxs("button",{className:re(Qs.dsEntry,_[T.id]&&Qs.enabled),onClick:()=>O5(T.id),children:[h.jsx(ii,{size:24,type:T.dbType}),h.jsx("span",{children:T.name})]},T.id))}),h.jsx("input",{className:Qs.search,placeholder:"Search table or saved query to start from",value:u,onChange:T=>c(T.target.value),onKeyDown:j,autoFocus:r}),hl(C?.length,0)&&h.jsx("div",{className:"overflow-y-auto max-h-full mt-2",children:C.map((T,D)=>h.jsxs("button",{className:Qs.entry,"data-is-active":d===D,"data-table-id":T.id,onClick:N,children:[h.jsxs("p",{className:"font-semibold",children:[D5[T.type]," ",T.name]}),h.jsxs("p",{className:Qs.ds,children:["📦 ",T.dataSourceName]})]},T.id))})]})},U5=()=>{const n=z4(),l=(c,d)=>{n?.onConfirm("table",c,d)},i=(c,d)=>{n?.onConfirm("query",c,d)},r=(c,d)=>{n?.onConfirm("tab",c,d)},u=()=>{n?.onCancel()};return h.jsxs(cn,{isVisible:!!n,onClose:u,children:[h.jsx(aa,{onClick:u}),h.jsx(M5,{autoFocus:!0,onTable:l,onQuery:i,onWorkbenchTab:r})]})},L5=()=>{const n=jr("Hotkey"),l=Et(),{pathname:i}=qt(),{data:r}=Bn(),{data:u}=Xd(),c=i===Ye.home.path;on("n",()=>{r&&n()}),on("w",()=>{r&&(u&&u.length>0?l(`${Ye.workbench.path}/tab/${u[0].id}`):n())},{enabled:c}),on("h",()=>{Xs({show:!0})})},z5=()=>{const n=qt();b.useEffect(()=>{},[n.pathname])},[k5,Wv]=un(!1),ad=()=>Wv(!1),eg=()=>Wv(!0),q5=({repeatPassword:n,password:l})=>l.length<1?null:l.length<8?h.jsx(wt,{variant:"warning",children:"New password should be at least 8 characters long"}):l!==n?h.jsx(wt,{variant:"warning",children:"Repeat password should match new password"}):null,B5=()=>{const n=k5(),{data:l}=Bn(),{mutateAsync:i,isPending:r}=u4(),u=Et(),[{password:c,repeatPassword:d},{change:m,touched:p,reset:y}]=Rr({password:"",repeatPassword:""}),g=()=>{u("/"),Tr.logout().then(()=>{ad()})},x=()=>{i({password:c}).then(()=>{y(),sn.success("Password successfully updated!")})},E=c.length<8||c!==d||r,C=p.includes("password");return h.jsxs(cn,{isVisible:n,onClose:ad,children:[h.jsx(aa,{onClick:ad}),h.jsxs("div",{className:"w-full lg:w-lg flex flex-col gap-2",children:[h.jsx(xv,{children:"Account settings"}),h.jsxs("label",{children:[h.jsx("p",{className:"text-xs font-semibold mb-1",children:"Username"}),h.jsx("input",{className:"input w-full",readOnly:!0,disabled:!0,value:l?.username})]}),h.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[h.jsxs("label",{children:[h.jsx("p",{className:"text-xs font-semibold mb-1",children:"Change password"}),h.jsx("input",{className:"input w-full",type:"password",name:"newPassword",autoComplete:"new-password",value:c,onChange:m("password")})]}),h.jsxs("label",{children:[h.jsx("p",{className:"text-xs font-semibold mb-1",children:"Repeat password"}),h.jsx("input",{className:"input w-full",type:"password",value:d,onChange:m("repeatPassword")})]})]}),C&&h.jsx(q5,{password:c,repeatPassword:d}),h.jsxs("div",{className:"flex justify-end gap-2 mt-2",children:[h.jsx("button",{className:"button tertiary",disabled:E,onClick:x,children:"Update password"}),h.jsx("button",{className:"button danger",onClick:g,children:"Log out"})]})]})]})},[H5,tg]=un(!1),ng=()=>tg(!0),Wy=()=>tg(!1),Q5=n=>Ft({queryKey:["team-users"],queryFn:async()=>{const{data:l}=await Te.get("/teams/"+n+"/users");return l.data},enabled:!!n}),Y5=()=>vt({mutationFn:async({role:n,teamId:l,userId:i})=>(await Te.patch("/teams/"+l+"/user-role",{role:n,userId:i}),!0),onSuccess:()=>{rt.invalidateQueries({queryKey:["team-users"]})}}),V5=()=>vt({mutationFn:async({teamId:n,userId:l})=>(await Te.delete("/teams/"+n,{params:{userId:l}}),!0),onSuccess:()=>{rt.invalidateQueries({queryKey:["team-users"]})}}),K5="_user-entry_1vr21_2",$5="_select-container_1vr21_2",e1={userEntry:K5,selectContainer:$5},G5=()=>{const n=H5(),{data:l}=Bn(),{data:i}=Q5(l?.teamId),{mutate:r,isPending:u}=c4(),{mutate:c,isPending:d}=Y5(),{mutate:m,isPending:p}=V5(),[y,{change:g,reset:x}]=Rr({password:"",username:""}),E=()=>{r({username:y.username,password:y.password,teamId:l?.teamId||""}),x()},C=(_,T)=>{c({teamId:l.teamId,role:T,userId:_})},w=_=>{Sv("Are you sure you want to remove this user?").then(T=>{T&&m({userId:_,teamId:l.teamId})})},j=Ar($t.ADMIN),N=u||d||p;return h.jsxs(cn,{isVisible:n,onClose:Wy,backdropClose:!0,children:[h.jsx(aa,{onClick:Wy}),h.jsxs("div",{className:"w-full lg:w-lg flex flex-col overflow-hidden",children:[h.jsx(xv,{children:"Manage users"}),hl(i?.length,0)&&h.jsx("div",{className:"mt-4 overflow-y-auto flex-1",children:i.map(_=>h.jsxs("div",{className:e1.userEntry,children:[h.jsx("div",{className:e1.selectContainer,children:h.jsxs("select",{value:_.role,disabled:!j||N,onChange:T=>C(_.id,T.currentTarget.value),children:[h.jsx("option",{value:$t.OWNER,children:"Owner"}),h.jsx("option",{value:$t.ADMIN,children:"Admin"}),h.jsx("option",{value:$t.EDITOR,children:"Editor"}),h.jsx("option",{value:$t.READ_ONLY,children:"Reader"})]})}),h.jsx("p",{className:"flex-1 mx-2",children:_.name}),j&&h.jsx("button",{className:"p-1 cursor-pointer text-red-500 text-sm",onClick:()=>w(_.id),children:"❌"})]},_.id))}),j&&h.jsxs("div",{className:"mt-4",children:[h.jsx("p",{className:"font-semibold",children:"Create new user"}),h.jsxs("div",{className:"flex flex-col lg:flex-row gap-2 lg:items-center mt-2",children:[h.jsx("input",{className:"input flex-1",onChange:g("username"),value:y.username,placeholder:"Username",disabled:N}),h.jsx("input",{className:"input",onChange:g("password"),value:y.password,type:"password",name:"newPassword",autoComplete:"new-password",placeholder:"Password",disabled:N}),h.jsx("button",{className:"button primary",onClick:E,disabled:N,children:"Create user"})]}),h.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."})]})]})]})},X5=()=>{const[n,l]=b.useState(""),[i,r]=b.useState(""),[u,c]=b.useState(),[d,m]=b.useState(!1),p=Et(),y=g=>{g.preventDefault(),c(void 0),Tr.login({password:i,username:n}).then(()=>{p("/",{replace:!0})}).catch(c)};return h.jsx("div",{className:"page-container bg-(--bg) h-screen",children:h.jsx("div",{className:"page-content items-center",children:h.jsxs("form",{className:"flex flex-col gap-2 w-full lg:w-lg",onSubmit:y,children:[h.jsx("p",{className:"font-semibold text-xl min-w-md",children:"Login"}),u&&h.jsx(wt,{variant:"danger",children:"Failed to login. Please verify your credentials"}),h.jsx("input",{value:n,onChange:g=>l(g.currentTarget.value),className:"input",placeholder:"User name"}),h.jsx("input",{value:i,onChange:g=>r(g.currentTarget.value),className:"input",type:"password",placeholder:"Password"}),h.jsx("button",{type:"submit",className:"button primary",children:"Login"}),d?h.jsxs(wt,{className:"w-full border border-blue-500",children:[h.jsx("p",{children:"If this is your first login, the default credentials are:"}),h.jsxs("ul",{className:"mt-2",children:[h.jsxs("li",{children:["Username: ",h.jsx("strong",{children:"admin"})]}),h.jsxs("li",{children:["Password: ",h.jsx("strong",{children:"admin"})]})]}),h.jsx("p",{className:"mt-2",children:"Please make sure to change the default password to a secure one."})]}):h.jsx("button",{className:"button tertiary",onClick:()=>m(!0),children:"First login?"})]})})})},F5=()=>{const n=Et(),{pathname:l}=qt(),{data:i,isLoading:r}=dv();b.useEffect(()=>{!i&&!r&&l!==Ye.login.path&&n(Ye.login.path)},[i,r,n,l])},Z5=()=>{const[n]=Hx(),l=Et(),i=si(),r=n.get("shareId");return b.useEffect(()=>{r&&i.mutateAsync({queryId:r}).then(u=>{l(`${Ye.workbench.path}/tab/${u.id}`,{replace:!0})})},[r]),h.jsxs("div",{className:"page-container flex items-center justify-center h-screen",children:[i.isPending&&h.jsxs("div",{className:"flex items-center flex-col gap-2",children:[h.jsx(Pv,{}),h.jsx("p",{children:"Fetching query information"})]}),i.isError&&h.jsx(wt,{variant:"danger",children:"Failed to load query information"})]})},P5="_container_lsf5s_2",J5="_header_lsf5s_2",I5="_close-button_lsf5s_2",W5="_tab-container_lsf5s_2",eN="_tab-name_lsf5s_2",tN="_archived-badge_lsf5s_2 _badge_lsf5s_2",nN="_active-badge_lsf5s_2 _badge_lsf5s_2",aN="_action-blue_lsf5s_2",lN="_action-red_lsf5s_2",sN="_load-more-btn_lsf5s_2",In={container:P5,header:J5,closeButton:I5,tabContainer:W5,tabName:eN,archivedBadge:tN,activeBadge:nN,actionBlue:aN,actionRed:lN,loadMoreBtn:sN},iN=new Intl.DateTimeFormat,rN=()=>{const{data:n}=Bn(),{data:l,fetchNextPage:i,hasNextPage:r,isFetching:u}=t4(n?.teamId),c=Et(),d=vv(),m=L4(),p=x=>{d.mutate(x),Xs({show:!1}),c(`${Ye.workbench.path}/tab/${x}`)},y=x=>{m.mutate(x)},g=l&&l?.length>0;return h.jsxs("div",{className:In.container,children:[h.jsxs("div",{className:In.header,children:[h.jsx("h3",{className:"text-lg",children:"Tabs history"}),h.jsx("button",{className:In.closeButton,onClick:()=>Xs({show:!1}),children:h.jsx(Pl,{width:24,height:24})})]}),!g&&h.jsx(wt,{variant:"warning",children:"History is empty."}),l?.map(x=>h.jsxs("div",{className:In.tabContainer,children:[h.jsxs("div",{className:"flex gap-2 items-center",children:[h.jsx("p",{className:In.tabName,children:x.name}),x.dataSourceType&&h.jsx(ii,{size:16,type:x.dataSourceType}),h.jsx("p",{className:"text-sm",children:x.dataSourceName})]}),h.jsxs("div",{className:"flex gap-2 items-center mt-1",children:[h.jsx("p",{className:"text-sm italic",children:iN.format(new Date(x.updatedAt))}),x.archived?h.jsx("span",{className:In.archivedBadge,children:"Archived"}):h.jsx("span",{className:In.activeBadge,children:"Active"}),h.jsx("span",{className:"flex-1"}),h.jsx("button",{onClick:()=>p(x.id),className:In.actionBlue,children:"Open"}),h.jsx("button",{onClick:()=>y(x.id),className:In.actionRed,children:"Delete"})]})]},x.id)),r&&!u&&h.jsx("div",{className:"flex justify-center mt-4",children:h.jsx("button",{className:In.loadMoreBtn,onClick:()=>i(),children:"Load more"})})]})},oN=()=>{const n=rE(l=>l.show);return h.jsx(Iv,{isVisible:n,onClose:()=>Xs({show:!1}),backdropClose:!0,children:h.jsx(rN,{})})};function uN(){return L5(),z5(),F5(),h.jsxs(h.Fragment,{children:[h.jsxs(cx,{children:[h.jsx(dr,{path:Ye.home.path,element:h.jsx(hE,{})}),h.jsx(dr,{path:`${Ye.workbench.path}/tab/:id`,element:h.jsx(W_,{})}),h.jsx(dr,{path:Ye.login.path,element:h.jsx(X5,{})}),h.jsx(dr,{path:Ye.share.path,element:h.jsx(Z5,{})})]}),h.jsx(TE,{}),h.jsx(kE,{}),h.jsx(PE,{}),h.jsx(x5,{}),h.jsx(U5,{}),h.jsx(B5,{}),h.jsx(G5,{}),h.jsx(oN,{}),h.jsx($E,{}),h.jsx(HE,{})]})}const cN="_desktop-layout_mhqiw_2",fN="_mobile-layout_mhqiw_2",dN="_nav_mhqiw_2",hN="_main_mhqiw_2",mN="_header_mhqiw_2",Ps={desktopLayout:cN,mobileLayout:fN,nav:dN,main:hN,header:mN},pN="_container_qmz1z_2",yN="_menu_qmz1z_2",oh={container:pN,menu:yN},vN=({name:n,id:l,onRename:i,onDelete:r,onOpen:u})=>{const c=_v();return h.jsxs("button",{className:oh.menu,onContextMenu:c.open,onClick:()=>u(l),children:[h.jsx(Nv,{handler:c,children:h.jsxs("div",{className:"context-menu-container",children:[h.jsx("button",{onClick:d=>{d.preventDefault(),d.stopPropagation(),c.close(),i(l)},className:"context-menu-item",children:"✏️ Rename"}),h.jsx("button",{onClick:d=>{d.preventDefault(),d.stopPropagation(),c.close(),r(l)},className:"context-menu-item",children:"🗑️ Delete"})]})}),h.jsxs("span",{children:["📖 ",n]})]})},gN=({dataSource:n,index:l})=>{const i=()=>{Gs(n.id)};return on(l.toString(),()=>{Gs(r=>{if(r!==n.id)return n.id})}),h.jsxs("button",{className:oh.menu,onClick:i,children:[h.jsx(ii,{size:20,type:n.dbType}),h.jsx("p",{className:"truncate flex-1 text-left mx-1.5",children:n.name}),h.jsx("span",{className:"hotkey",children:l})]})},bN=()=>{const n=Et(),{data:l}=Bn(),{data:i}=J3(l?.teamId),{data:r}=I3(l?.teamId),u=si(),c=GC(),d=$C(),m=g=>{u.mutateAsync({queryId:g}).then(x=>{n(`${Ye.workbench.path}/tab/${x.id}`)})},p=async g=>{const x=r?.find(C=>C.id===g);if(!x)return;const E=await Or("New name?",x?.name);E&&c.mutate({id:x.savedQueryId,payload:{name:E}})},y=g=>{const x=r?.find(E=>E.id===g)?.savedQueryId;x&&d.mutate(x)};return h.jsx("div",{className:oh.container,children:h.jsxs("div",{className:"flex-1 overflow-y-auto",children:[hl(i?.length,0)&&h.jsxs("div",{className:"mt-4",children:[h.jsx("p",{className:"font-semibold text-sm text-gray-600 mb-2",children:"DATA SOURCES"}),i.map((g,x)=>h.jsx(gN,{dataSource:g,index:x+1},g.id))]}),hl(r?.length,0)&&h.jsxs("div",{className:"mt-4",children:[h.jsx("p",{className:"font-semibold text-sm text-gray-600 mb-2",children:"SAVED QUERIES"}),r.map(g=>h.jsx(vN,{onDelete:y,onRename:p,onOpen:m,name:g.name,id:g.id},g.savedQueryId))]})]})})},xN=()=>{const n=Et(),{pathname:l}=qt(),{data:i}=Bn(),r=jr("Desktop nav"),u=()=>{Jv(),l!==Ye.home.path&&n(Ye.home.path)},c=()=>Xs({show:!0});return h.jsxs("nav",{className:Ps.nav,children:[i&&h.jsxs("div",{className:Ps.header,children:[h.jsx("button",{onClick:u,className:"flex justify-between items-center",children:h.jsx("span",{children:"🏠 Home"})}),h.jsxs("button",{onClick:r,className:"flex justify-between items-center",children:[h.jsx("span",{children:"🔎 New query"}),h.jsx("span",{className:"hotkey",children:"N"})]}),h.jsxs("button",{onClick:c,className:"flex justify-between items-center",children:[h.jsx("span",{children:"⌛ Recent tabs"}),h.jsx("span",{className:"hotkey",children:"H"})]}),h.jsxs("button",{onClick:eg,children:["🪪 ",i.username]}),h.jsx("button",{onClick:ng,children:"👥 Manage users"})]}),h.jsx(bN,{})]})},SN="_root_akcjn_2",wN={root:SN},EN=()=>{const{pathname:n}=qt(),l=Et(),i=jr("Mobile nav"),r=()=>{n!==Ye.home.path&&l(Ye.home.path)};return h.jsxs("div",{className:wN.root,children:[h.jsxs("button",{onClick:r,children:[h.jsx("p",{children:"🏠"}),h.jsx("p",{className:"text-xs font-semibold text-gray-600",children:"Home"})]}),h.jsxs("button",{onClick:i,children:[h.jsx("p",{children:"🔎"}),h.jsx("p",{className:"text-xs font-semibold text-gray-600",children:"New query"})]}),h.jsxs("button",{onClick:eg,children:[h.jsx("p",{children:"🪪"}),h.jsx("p",{className:"text-xs font-semibold text-gray-600",children:"Account"})]}),h.jsxs("button",{onClick:ng,children:[h.jsx("p",{children:"👥"}),h.jsx("p",{className:"text-xs font-semibold text-gray-600",children:"Users"})]})]})},CN=({children:n,isLogin:l})=>h.jsxs("div",{className:Ps.desktopLayout,children:[h.jsx(ih,{id:"default",className:"z-100"}),!l&&h.jsx(xN,{}),h.jsx("main",{className:Ps.main,children:n})]}),_N=({children:n,isLogin:l})=>h.jsxs("div",{className:Ps.mobileLayout,children:[h.jsx("main",{className:Ps.main,children:n}),!l&&h.jsx(EN,{})]}),NN=({children:n})=>{const l=Ev(Id.laptop),{pathname:i}=qt(),r=i===Ye.login.path;return l?h.jsx(CN,{isLogin:r,children:n}):h.jsx(_N,{isLogin:r,children:n})};g2.createRoot(document.getElementById("root")).render(h.jsxs(rl.StrictMode,{children:[h.jsx(F3,{}),h.jsx(yS,{client:rt,children:h.jsx(Lx,{children:h.jsx(NN,{children:h.jsx(uN,{})})})})]}));
192
+ `,Fo=16,F3=({reverseOrder:n,position:l="top-center",toastOptions:i,gutter:r,children:u,containerStyle:c,containerClassName:d})=>{let{toasts:m,handlers:p}=w3(i);return b.createElement("div",{id:"_rht_toaster",style:{position:"fixed",zIndex:9999,top:Fo,left:Fo,right:Fo,bottom:Fo,pointerEvents:"none",...c},className:d,onMouseEnter:p.startPause,onMouseLeave:p.endPause},m.map(y=>{let g=y.position||l,x=p.calculateOffset(y,{reverseOrder:n,gutter:r,defaultPosition:l}),E=G3(g,x);return b.createElement($3,{id:y.id,key:y.id,onHeightUpdate:p.updateHeight,className:y.visible?X3:"",style:E},y.type==="custom"?fu(y.message,y):u?u(y):b.createElement(K3,{toast:y,position:g}))}))},sn=kt;const rt=new pS({defaultOptions:{queries:{staleTime:1e3*60*5,retry:(n,l)=>cu(l)&&l.response?.status===404?!1:n<3}},mutationCache:new R1({onError:n=>{cu(n)&&n.status&&n.status>=400&&n.status<500&&n.response?.data.error&&sn.error(n.response.data.error)}})}),Z3=async()=>{const{data:n}=await Yd.post("/auth/refresh");return n.data.accessToken},P3=async n=>{const{data:l}=await Yd.post("/auth/login",n);return l.data.accessToken},Ry=()=>{rt.invalidateQueries({queryKey:["accessToken"]})},Tr=(()=>{let n=Promise.resolve(l3()),l=!1;const i=async()=>{await Yd.post("/auth/logout"),Xo(void 0),window.location.reload()};return{get:async()=>n,refresh:()=>(l||(l=!0,n=Z3().then(d=>(Xo(d),d)).catch(()=>{Xo(void 0),i()}).finally(()=>{l=!1,Ry()})),n),login:d=>(l||(l=!0,n=P3(d).then(m=>(Xo(m),m)).finally(()=>{l=!1,Ry()})),n),logout:i}})(),uv=location.hostname.includes("app.dataramen.xyz")?"http://localhost:4466/api":"/api",Te=et.create({baseURL:uv,withCredentials:!0});Te.interceptors.request.use(async n=>{const l=await Tr.get();return l&&(n.headers.Authorization=`Bearer ${l}`),n});Te.interceptors.response.use(n=>n,n=>(cu(n)&&n.status===401&&n?.response?.data.error!=="Missing auth token"&&Tr.refresh(),Promise.reject(n)));const Yd=et.create({baseURL:uv,withCredentials:!0}),yl="data-sources",cv="auth-user",J3=n=>Ft({queryKey:["project","datasources",n],queryFn:async()=>{const{data:l}=await Te.get(`/project/team/${n}/datasources`);return l.data},enabled:!!n}),I3=n=>Ft({queryKey:["project","saved-queries",n],queryFn:async()=>{const{data:l}=await Te.get(`/project/team/${n}/queries`);return l.data},enabled:!!n}),ni=n=>{const l=["project","datasources"],i=["project","saved-queries"];return Promise.all([rt.invalidateQueries({queryKey:l}),rt.invalidateQueries({queryKey:i})])},W3=n=>{const l=["trash","team"];return rt.invalidateQueries({queryKey:l})},e4=(n,l)=>Ft({queryKey:["project",l.teamId,"tables",n,l.selectedDataSources],queryFn:async()=>{const{data:i}=await Te.get(`/project/team/${l.teamId}/query`,{params:{size:30,search:n,selectedDataSources:l.selectedDataSources}});return i.data},enabled:!!l.teamId,staleTime:0}),t4=(n,l=30)=>TS({queryKey:["project","tabs-history",n,l],queryFn:async({pageParam:i})=>{const{data:r}=await Te.get(`/project/team/${n}/tabs-history?page=${i}&size=${l}`);return r},select:({pages:i})=>i.flatMap(r=>r.data),enabled:!!n,initialPageParam:0,getNextPageParam:(i,r)=>{if(i.hasMore)return r.length},staleTime:0}),n4=()=>rt.invalidateQueries({queryKey:["project","tabs-history"]}),a4=(n,l)=>{},l4=()=>{},s4={event:a4,pageView:l4},Cu=n=>Ft({queryKey:[yl,n],queryFn:async()=>{const{data:l}=await Te.get("/data-sources/"+n);return l.data},enabled:!!n}),Vd=n=>Ft({queryKey:[yl,n.teamId],queryFn:async()=>{const{data:l}=await Te.get("/data-sources",{params:n});return l.data},enabled:n.teamId!==void 0}),ai=n=>Ft({queryKey:[yl,n,"inspections"],queryFn:async()=>{const{data:l}=await Te.get(`/data-sources/${n}/inspections`);return l.data},enabled:!!n}),i4=()=>vt({mutationFn:async n=>{const{data:l}=await Te.post("/data-sources",n);return l.data},onSuccess:()=>{rt.invalidateQueries({queryKey:[yl]}),ni()},onError:()=>{}}),r4=()=>vt({mutationFn:async({dataSource:n,id:l})=>{const{data:i}=await Te.put(`/data-sources/${l}`,n);return i.data},onSuccess:()=>{rt.invalidateQueries({queryKey:[yl]}),ni()}}),fv=()=>vt({mutationFn:async n=>{await Te.post(`/data-sources/${n}/inspect`)},onSuccess:()=>{rt.invalidateQueries({queryKey:[yl]})}}),o4=()=>vt({mutationFn:async n=>{await Te.delete(`/data-sources/${n}`)},onSuccess:()=>{rt.invalidateQueries({queryKey:[yl]}),ni()}}),dv=()=>Ft({queryKey:["accessToken"],queryFn:Tr.get}),Bn=()=>{const{data:n}=dv();return Ft({queryKey:[cv],queryFn:async()=>{const{data:l}=await Te.get("/users");return l.data},enabled:!!n,retry:(l,i)=>cu(i)&&i.code==="ERR_NETWORK"?!1:l<3})},u4=()=>vt({mutationFn:async n=>{const{data:l}=await Te.patch("/users",n);return l.data},onSuccess:async n=>{rt.setQueryData([cv],n)}}),c4=()=>vt({mutationFn:async n=>(await Te.post("/users",n),!0),onSuccess:()=>{rt.invalidateQueries({queryKey:["team-users"]})}}),f4="_alert_cie9h_2",d4="_info_cie9h_2",h4="_danger_cie9h_2",m4="_success_cie9h_2",p4="_warning_cie9h_2",y4="_dark_cie9h_2",ks={alert:f4,info:d4,danger:h4,success:m4,warning:p4,dark:y4};function hv(n){var l,i,r="";if(typeof n=="string"||typeof n=="number")r+=n;else if(typeof n=="object")if(Array.isArray(n)){var u=n.length;for(l=0;l<u;l++)n[l]&&(i=hv(n[l]))&&(r&&(r+=" "),r+=i)}else for(i in n)n[i]&&(r&&(r+=" "),r+=i);return r}function re(){for(var n,l,i=0,r="",u=arguments.length;i<u;i++)(n=arguments[i])&&(l=hv(n))&&(r&&(r+=" "),r+=l);return r}const wt=({variant:n,noRounded:l,className:i,children:r,...u})=>h.jsx("div",{className:re(ks.alert,!l&&"rounded-lg",(n==="info"||!n)&&ks.info,n==="danger"&&ks.danger,n==="dark"&&ks.dark,n==="warning"&&ks.warning,n==="success"&&ks.success,i),role:"alert",...u,children:r}),un=n=>{const l=new Set;let i=n;const r=m=>(l.add(m),()=>l.delete(m)),u=m=>(l.forEach(p=>p(m)),!0),c=m=>{i=typeof m=="function"?m(i):m,u(i)},d=m=>()=>m?m(i):i;return[m=>b.useSyncExternalStore(r,d(m),d(m)),c,{get:()=>i,subscribe:m=>(m(i),r(m))}]};function v4(n){const l=[];for(const i of n)for(const r of i.columns)r.ref&&(l.push({id:`${i.tableName}->${r.ref.table}.${r.ref.field}`,name:`${i.tableName} in ${r.ref.table}`,where:`${i.tableName}.${r.name} = ${r.ref.table}.${r.ref.field}`,on:{fromTable:r.ref.table,toTable:i.tableName,fromColumn:r.ref.field,toColumn:r.name}}),l.push({id:`${r.ref.table}->${i.tableName}.${r.name}`,name:`${r.ref.table} in ${i.tableName}`,where:`${r.ref.table}.${r.ref.field} = ${i.tableName}.${r.name}`,on:{fromTable:i.tableName,toTable:r.ref.table,fromColumn:r.name,toColumn:r.ref.field}}));return l}const g4=n=>Ft({queryKey:["hooks",n],queryFn:async()=>{const l=await rt.fetchQuery({queryKey:[yl,n,"inspections"],queryFn:async()=>{const{data:i}=await Te.get(`/data-sources/${n}/inspections`);return i.data}});return v4(l)},enabled:!!n}),Kd=[{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:"contains"},{value:"NOT LIKE",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"}],mv=Kd.reduce((n,l)=>(n[l.value]=l.label,n),{}),$d=Kd.reduce((n,l)=>(n[l.label]=l.value,n),{}),li=n=>n.map(l=>({label:mv[l],value:l})),b4=li(["=","<>",">",">=","<","<=","IN","NOT IN","IS NULL","IS NOT NULL"]),x4=li(["=","<>","LIKE","NOT LIKE","IN","NOT IN","IS NULL","IS NOT NULL"]);li(["=","<>","IS NULL","IS NOT NULL"]);const S4=li(["=","<>",">",">=","<","<=","IS NULL","IS NOT NULL"]);li(["IS NULL","IS NOT NULL"]);li(["IN","NOT IN"]);const pv=n=>n!=="IS NULL"&&n!=="IS NOT NULL",w4=(n,l)=>pv(n)?n==="IN"||n==="NOT IN"?l.split(",").map(i=>({value:i.trim(),isColumn:!1})):[{value:l,isColumn:!1}]:[],E4=["char","varchar","binary","varbinary","blob","text","enum","set","character","character varying","text","citext","uuid","xml","json","jsonb"],C4=["integer","smallint","decimal","numeric","float","real","double precision","int","smallint","integer","bigint","decimal","numeric","real","double precision","serial","bigserial","money"],_4=["date","time","datetime","timestamp","year","date","time","time without time zone","time with time zone","timestamp","timestamp without time zone","timestamp with time zone","interval"],N4=["date","datetime","timestamp","timestamptz"].reduce((n,l)=>(n[l]=!0,n),{}),yv=n=>n.fn?n.distinct===!0?`${n.fn} distinct ${n.value}`:`${n.fn} ${n.value}`:n.value;var $t=(n=>(n.OWNER="owner",n.ADMIN="admin",n.EDITOR="editor",n.READ_ONLY="read_only",n))($t||{});const Oy={[$t.READ_ONLY]:10,[$t.EDITOR]:20,[$t.ADMIN]:30,[$t.OWNER]:40};function T4(n,l){if(!n||!l)return{};const i=new Set;for(const u of l)u.table&&i.add(u.table);const r={};for(const u of i){const c=n.find(d=>d.tableName===u);if(c){r[u]=[];const d=c.columns.filter(m=>m.isPrimary);for(const m of d)if(l.find(y=>y.table===u&&y.column===m.name))r[u].push(m.name);else{delete r[u];break}}}return r}function j4(n,l,i,r){const{data:u}=g4(l),{data:c}=ai(l);return b.useMemo(()=>{const d=T4(c,n?.result.columns);return{name:i,tabId:r,hooks:(()=>{const m=[];if(!u||!n||!n.result.columns)return m;for(const p of u)(n.result.tables.includes(p.on.toTable)||n.result.tables.includes(p.on.fromTable))&&m.push(p);return m})(),availableJoins:(()=>{const m=[];if(!u||!n||!n.result.columns)return m;for(const p of u)!n.result.tables.includes(p.on.toTable)&&n.result.tables.includes(p.on.fromTable)&&m.push(p);return m})(),allColumns:n?.result.allColumns||[],dataSourceId:l,entities:Object.keys(d),getValue:(m,p)=>{const y=yv(p),g=n?.result.columns?.findIndex(x=>x.full===y);if(g!=null&&g>-1)return m[g]},getEntityKey:(m,p)=>d[m].reduce((y,g)=>{const x=n?.result.columns?.findIndex(E=>E.column===g&&E.table===m);return x!=null&&x>-1&&y.push([g,p[x]]),y},[]),getColumnType:m=>{const p=n?.result.allColumns.find(y=>y.full===m);if(p)return p.type}}},[n,l,u,c,i])}function A4(n,l){return b.useMemo(()=>({state:n,setState:l}),[n,l])}function $s(n){return{dataSourceId:n.dataSourceId||"",page:n?.page||0,size:n?.size||50,table:n.table||"",filters:n?.filters||[],joins:n?.joins??[],orderBy:n?.orderBy??[],columns:n?.columns??[],groupBy:n?.groupBy??[],aggregations:n?.aggregations??[]}}const Ye={home:{path:"/"},workbench:{path:"/workbench"},share:{path:"/share"},login:{path:"/login"}},Gd=n=>{rt.setQueryData(["workbench-tabs"],l=>n(l||[]))},R4=(n,l)=>{rt.setQueryData(["workbench-tabs",n],i=>i&&l(i))},Xd=()=>Ft({queryKey:["workbench-tabs"],queryFn:async()=>{const{data:n}=await Te.get("/workbench-tabs");return n.data}}),O4=n=>Ft({queryKey:["workbench-tabs",n],queryFn:async()=>{const{data:l}=await Te.get(`/workbench-tabs/${n}`);return l.data}}),si=()=>vt({mutationFn:async n=>{const{data:l}=await Te.post("/workbench-tabs",n);return l.data},onSuccess:async n=>{Gd(l=>[...l,n])}}),D4=()=>vt({mutationFn:async n=>(await Te.patch(`/workbench-tabs/${n}`,{archived:!0}),n),onMutate:n=>{Gd(l=>l.filter(i=>i.id!==n))}}),vv=()=>vt({mutationFn:async n=>(await Te.patch(`/workbench-tabs/${n}`,{archived:!1}),n),onSuccess:()=>bv()}),M4=()=>vt({mutationFn:async({id:n,payload:l})=>(await Te.patch(`/workbench-tabs/${n}`,l),!0),onMutate:({id:n,payload:l})=>{R4(n,i=>({...i,...l})),Gd(i=>i.map(r=>r.id!==n?r:{...r,name:l.name||r.name}))}}),U4=(n,l)=>{const{dataSourceId:i,searchAll:r,table:u,filters:c,joins:d,orderBy:m,groupBy:p,columns:y,aggregations:g,page:x=0,size:E=20}=l;return Ft({queryKey:["workbench-tab-runner",n,i,u,x,E,c,g,d,m,p,y,r],queryFn:async()=>{const{data:C}=await Te.post(`/workbench-tabs/${n}/run`,l);return C.data},retry:1,enabled:!!u&&!!i})},L4=()=>vt({mutationFn:async n=>{await Te.delete(`/workbench-tabs/${n}`)},onSuccess:()=>{bv(),n4()}}),gv=n=>rt.invalidateQueries({queryKey:["workbench-tab-runner",n]}),bv=()=>rt.invalidateQueries({queryKey:["workbench-tabs"]}),[z4,Ff,k4]=un(void 0),q4=async()=>new Promise(n=>{Ff({onCancel:()=>{Ff(void 0),n(void 0)},onConfirm:(l,i,r)=>{Ff(void 0),n({dsId:r,id:i,type:l})}})}),jr=n=>{const l=Et(),i=si(),r=vv();return b.useEffect(()=>{i?.data?.id&&l(`${Ye.workbench.path}/tab/${i.data.id}`),r?.data&&l(`${Ye.workbench.path}/tab/${r?.data}`)},[i.data,r.data]),b.useCallback(()=>{k4.get()||q4().then(c=>{c?.type==="table"?i.mutate({name:c.id,opts:$s({table:c.id,dataSourceId:c.dsId})}):c?.type==="query"?i.mutate({queryId:c.id}):c?.type==="tab"&&r.mutate(c.id)})},[l,n])},Ar=n=>{const{data:l}=Bn();return b.useMemo(()=>l?Oy[l.teamRole]>=Oy[n]:!1,[l,n])},B4="_input_sa5q9_2",H4="_small_sa5q9_2",Q4="_content_sa5q9_2",Y4="_form_sa5q9_2",V4="_mode-select_sa5q9_2",ze={input:B4,small:H4,content:Q4,form:Y4,switch:"_switch_sa5q9_2",modeSelect:V4},K4="_modal_1bv70_2",$4="_modal-visible_1bv70_2",G4="_modal-invisible_1bv70_2",X4="_backdrop_1bv70_2",F4="_modal-container_1bv70_2",Z4="_close-button_1bv70_2",Ys={modal:K4,modalVisible:$4,modalInvisible:G4,backdrop:X4,modalContainer:F4,closeButton:Z4},Pl=n=>b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...n},b.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32,d:"M368 368L144 144M368 144L144 368"})),cn=({children:n,backdropClose:l,isVisible:i,onClose:r,onClosed:u,noPadding:c=!1,portal:d=!1})=>{const[m,p]=b.useState(!1),y=()=>{l&&r()},g=E=>{i||getComputedStyle(E.currentTarget).opacity==="0"&&(p(!1),u&&u())};b.useEffect(()=>{i&&p(!0)},[i]);const x=h.jsxs("div",{onTransitionEnd:g,className:re(Ys.modal,i?Ys.modalVisible:Ys.modalInvisible),children:[h.jsx("div",{onClick:y,className:Ys.backdrop}),h.jsx("div",{className:re(Ys.modalContainer,c!==!0&&"p-4"),children:m&&n})]});return d?Gx.createPortal(x,document.body):x},aa=({onClick:n})=>{const l=b.useRef(n);return l.current=n,b.useEffect(()=>{const i=r=>{r.key==="Escape"&&l.current?.()};return window.addEventListener("keyup",i),()=>{window.removeEventListener("keyup",i)}},[]),h.jsx("button",{className:Ys.closeButton,onClick:n,children:h.jsx(Pl,{width:20,height:20})})},xv=({children:n})=>h.jsx("h2",{className:"text-xl font-semibold",children:n}),Rr=n=>{const[l,i]=b.useState(n),[r,u]=b.useState([]),c=b.useRef(n),d=b.useCallback((y,g)=>{i(x=>({...x,[y]:g}))},[]),m=b.useCallback(y=>g=>{g.target.type==="checkbox"?d(y,g.target.checked):d(y,g.target.value),u(x=>x.includes(y)?x:[...x,y])},[d]),p=b.useCallback(()=>{i(c.current),u([])},[]);return[l,{set:d,change:m,reset:p,touched:r}]},P4=({form:n,change:l})=>h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:re(ze.input,ze.small),children:[h.jsx("label",{children:"Database URL"}),h.jsx("input",{value:n.dbUrl,onChange:l("dbUrl"),className:"input"})]}),h.jsxs("div",{className:re(ze.input,ze.small),children:[h.jsx("label",{children:"Database port"}),h.jsx("input",{value:n.dbPort,onChange:l("dbPort"),type:"number",className:"input"})]}),h.jsxs("div",{className:re(ze.input,ze.small),children:[h.jsx("label",{children:"User"}),h.jsx("input",{value:n.dbUser,onChange:l("dbUser"),className:"input"})]}),h.jsxs("div",{className:re(ze.input,ze.small),children:[h.jsx("label",{children:"Password"}),h.jsx("input",{type:"password",value:n.dbPassword,onChange:l("dbPassword"),className:"input"})]}),h.jsxs("div",{className:re(ze.input,ze.small),children:[h.jsx("label",{children:"Database"}),h.jsx("input",{value:n.dbDatabase,onChange:l("dbDatabase"),className:"input"})]})]}),J4=({form:n,change:l})=>h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:re(ze.input,ze.small),children:[h.jsx("label",{children:"Database URL"}),h.jsx("input",{value:n.dbUrl,onChange:l("dbUrl"),className:"input"})]}),h.jsxs("div",{className:re(ze.input,ze.small),children:[h.jsx("label",{children:"Database port"}),h.jsx("input",{value:n.dbPort,onChange:l("dbPort"),type:"number",className:"input"})]}),h.jsxs("div",{className:re(ze.input,ze.small),children:[h.jsx("label",{children:"User"}),h.jsx("input",{value:n.dbUser,onChange:l("dbUser"),className:"input"})]}),h.jsxs("div",{className:re(ze.input,ze.small),children:[h.jsx("label",{children:"Password"}),h.jsx("input",{type:"password",value:n.dbPassword,onChange:l("dbPassword"),className:"input"})]}),h.jsxs("div",{className:re(ze.input,ze.small),children:[h.jsx("label",{children:"Database"}),h.jsx("input",{value:n.dbDatabase,onChange:l("dbDatabase"),className:"input"})]}),h.jsxs("div",{className:re(ze.input,ze.small),children:[h.jsx("label",{children:"Schema"}),h.jsx("input",{value:n.dbSchema,onChange:l("dbSchema"),className:"input"})]})]}),qs=[{label:"PostgreSQL",tag:"postgres"},{label:"MySQL",tag:"mysql"}],I4=({show:n,onClose:l,dbType:i="postgres"})=>{const r=i4(),u=fv(),{data:c}=Bn(),[d,{change:m,set:p}]=Rr({name:"",dbType:i,dbUrl:"",dbUser:"",dbPassword:"",dbDatabase:"",dbSchema:"",dbPort:5432,teamId:"",ownerId:"",description:"",allowInsert:!1,allowUpdate:!1}),y=async()=>{const w=await r.mutateAsync({...d,dbPort:Number(d.dbPort),teamId:c.teamId,ownerId:c.id});await u.mutateAsync(w.id),l(),s4.event("Create Datasource",{dbType:d.dbType})},g=w=>{p("allowInsert",!w),p("allowUpdate",!w)},x=()=>{l()},E=r.isPending||u.isPending,C=!d.allowInsert&&!d.allowUpdate;return h.jsxs(cn,{isVisible:n,onClose:x,children:[h.jsx(aa,{onClick:x}),h.jsxs(wt,{variant:"warning",className:"text-sm mb-2 max-w-xl",children:["DataRamen is currently under active development. In production-like environments, ",h.jsx("span",{className:"font-semibold underline",children:"it’s recommended to use read-only database credentials"}),"."]}),r.isError&&h.jsx(wt,{variant:"danger",className:"mb-2",children:h.jsx("span",{children:"Failed to connect to the database. Please check if the data are correct and retry."})}),r.isPending&&h.jsx(wt,{className:"mb-2",variant:"info",children:"Creating connection"}),u.isPending&&h.jsx(wt,{className:"mb-2",variant:"info",children:"Inspecting connection"}),h.jsxs("div",{className:ze.switch,children:[h.jsxs("label",{className:"button tertiary",children:[h.jsx("input",{type:"radio",name:"bdType",className:"mr-2",checked:d.dbType===qs[0].tag,onChange:()=>p("dbType",qs[0].tag)}),h.jsx("span",{children:qs[0].label})]}),h.jsxs("label",{className:"button tertiary",children:[h.jsx("input",{type:"radio",name:"bdType",className:"mr-2",checked:d.dbType===qs[1].tag,onChange:()=>p("dbType",qs[1].tag)}),h.jsx("span",{children:qs[1].label})]})]}),h.jsxs("div",{className:"overflow-y-auto mt-2",children:[h.jsx("div",{className:ze.content,children:h.jsxs("div",{className:ze.form,children:[h.jsxs("div",{className:re(ze.input,"col-span-2"),children:[h.jsx("label",{children:"Name"}),h.jsx("input",{value:d.name,onChange:m("name"),className:"input"})]}),h.jsxs("div",{className:re(ze.input,"col-span-2"),children:[h.jsx("label",{children:"Description"}),h.jsx("textarea",{value:d.description,onChange:m("description"),className:"input"})]}),d.dbType==="mysql"&&h.jsx(P4,{form:d,change:m}),d.dbType==="postgres"&&h.jsx(J4,{form:d,change:m})]})}),h.jsxs("div",{className:"mt-4",children:[h.jsxs("label",{className:ze.modeSelect,children:[h.jsxs("div",{children:[h.jsx("input",{type:"radio",name:"production-mode",className:"mr-2",checked:C,onChange:()=>g(!0)}),h.jsx("span",{className:"text-sm font-semibold",children:"Production mode"})]}),h.jsxs("p",{className:"text-xs mt-1 text-gray-600",children:["Mutation operations (such as INSERT or UPDATE) are ",h.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."]})]}),h.jsxs("label",{className:ze.modeSelect,children:[h.jsxs("div",{children:[h.jsx("input",{type:"radio",name:"production-mode",className:"mr-2",checked:!C,onChange:()=>g(!1)}),h.jsx("span",{className:"text-sm font-semibold",children:"Dev mode"})]}),h.jsxs("p",{className:"text-xs mt-1 text-gray-600",children:["Mutation operations (such as INSERT or UPDATE) are ",h.jsx("strong",{children:"allowed"}),". You will be able to insert new rows and edit existing data."]})]})]})]}),h.jsxs("div",{className:"flex justify-end gap-1 mt-2",children:[h.jsx("button",{onClick:x,className:"button tertiary",disabled:E,children:"Cancel"}),h.jsx("button",{onClick:y,className:"button primary",disabled:E,children:"Create"})]})]})},W4="_data-source-entry_1ktzz_2",eE="_action-title_1ktzz_2",tE="_action-subtext_1ktzz_2",nE="_dev-tag_1ktzz_2",aE="_prod-tag_1ktzz_2",Kt={dataSourceEntry:W4,actionTitle:eE,actionSubtext:tE,devTag:nE,prodTag:aE},lE=n=>b.createElement("svg",{fill:"#000000",width:"800px",height:"800px",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",...n},b.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"})),sE=n=>b.createElement("svg",{width:"800px",height:"800px",viewBox:"0 0 32 32",xmlns:"http://www.w3.org/2000/svg",...n},b.createElement("title",null,"file_type_pgsql"),b.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"}),b.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"}}),b.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"}}),b.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"}})),ii=({size:n,type:l})=>l==="mysql"?h.jsx(lE,{width:n,height:n}):h.jsx(sE,{width:n,height:n}),[iE,Gs]=un(void 0),[rE,Xs]=un({show:!1}),oE=()=>{const n=jr("Home");return h.jsxs("div",{className:"card-white lg:col-span-2",onClick:n,children:[h.jsxs("h2",{className:Kt.actionTitle,children:[h.jsx("span",{children:"🔎 Start new query"}),h.jsx("span",{className:"hotkey",children:"N"})]}),h.jsx("input",{className:"input mt-3 w-full",placeholder:"Search table or query to start"})]})},uE=()=>{const[n,l]=b.useState(void 0),i=Ar($t.EDITOR),r=u=>{i?l(u):sn.error("You don't have permission to connect new data sources in this team")};return h.jsxs("div",{children:[n&&h.jsx(I4,{show:!0,dbType:n,onClose:()=>l(void 0)}),h.jsxs("div",{className:"card-white hover:bg-gray-50! cursor-pointer",onClick:()=>r("postgres"),children:[h.jsx("p",{className:Kt.actionTitle,children:"🧙‍♂️ Connection wizard"}),h.jsx("p",{className:Kt.actionSubtext,children:"Configure new database connection."})]})]})},cE=()=>{const n=Et(),{data:l}=Xd(),i=jr("Home"),r=()=>{l&&l.length>0?n(`${Ye.workbench.path}/tab/${l[0].id}`):i()};return h.jsxs("div",{className:"card-white hover:bg-gray-50! cursor-pointer",onClick:r,children:[h.jsxs("h2",{className:Kt.actionTitle,children:[h.jsx("span",{children:"🛠️ Workbench"}),h.jsx("span",{className:"hotkey",children:"W"})]}),h.jsx("p",{className:Kt.actionSubtext,children:"Continue your work from where you left."})]})},fE=()=>{const{data:n}=Bn(),{data:l}=Vd({teamId:n?.teamId}),i=r=>{Gs(r)};return!l||l.length===0?null:h.jsxs("div",{className:"mt-8",children:[h.jsx("h2",{className:"font-semibold text-gray-700",children:"Data sources"}),h.jsx("div",{className:"grid lg:grid-cols-3 gap-2 mt-4",children:l?.map(r=>h.jsxs("div",{className:Kt.dataSourceEntry,onClick:()=>i(r.id),tabIndex:0,children:[h.jsx(ii,{size:32,type:r.dbType}),h.jsxs("div",{className:"overflow-hidden",children:[h.jsx("p",{className:"font-semibold truncate text-gray-800 flex-1",children:r.name}),r.allowInsert?h.jsx("span",{className:Kt.devTag,children:"dev"}):h.jsx("span",{className:Kt.prodTag,children:"prod"})]})]},r.id))})]})},dE=()=>h.jsxs("div",{className:"mt-8",children:[h.jsx("h2",{className:"font-semibold text-gray-700",children:"Useful links"}),h.jsxs("div",{className:"grid lg:grid-cols-3 gap-2 mt-4",children:[h.jsxs("a",{className:"card-white hover:bg-gray-50!",href:"https://dataramen.xyz/",children:[h.jsx("h2",{className:Kt.actionTitle,children:"↗️ Documentation"}),h.jsx("p",{className:Kt.actionSubtext,children:"Learn how to use DataRamen"})]}),h.jsxs("a",{className:"card-white hover:bg-gray-50!",href:"https://github.com/OleksandrDemian/dataramen",children:[h.jsx("h2",{className:Kt.actionTitle,children:"↗️ Github"}),h.jsx("p",{className:Kt.actionSubtext,children:"Codebase is open source"})]}),h.jsxs("a",{className:"card-white hover:bg-gray-50!",href:"#",onClick:()=>Xs({show:!0}),children:[h.jsxs("h2",{className:Kt.actionTitle,children:[h.jsx("span",{children:"⌛ Recent tabs"}),h.jsx("span",{className:"hotkey",children:"H"})]}),h.jsx("p",{className:Kt.actionSubtext,children:"Manage recent tabs"})]})]})]}),hE=()=>{const{data:n}=Bn(),{data:l}=Vd({teamId:n?.teamId}),i=!!l&&l.length>0,r=!!n;return h.jsx("div",{className:"page-container h-screen max-h-screen bg-(--bg)",children:h.jsxs("div",{className:"page-content h-full pb-12 overflow-y-auto",children:[h.jsx("h2",{className:"font-semibold text-gray-700 mt-4 hidden lg:block",children:"Quick actions"}),r&&!i&&h.jsx(wt,{variant:"warning",className:"font-semibold mt-4",children:"Connect at least one datasource to start using DataRamen"}),h.jsxs("div",{className:"grid lg:grid-cols-2 gap-2 mt-4",children:[h.jsx(oE,{}),h.jsx(uE,{}),r&&h.jsx(cE,{})]}),r&&h.jsx(fE,{}),h.jsx(dE,{})]})})},[mE,Fd]=un(void 0),pE=()=>Fd(void 0);function $l(n,l){if(n==null)return"";switch(l){case"json":case"jsonb":return JSON.stringify(n,null,2)}if(n===0||n===!1)return n.toString();switch(typeof n){case"string":return n;case"number":case"boolean":return n.toString();default:return JSON.stringify(n)}}const yE=n=>{const l=n.value?.map(i=>i.value).join(", ")||"";return`${n.column} ${n.operator} ${l}`},vE=n=>n.value?.map(l=>l.value).join(", ")||"",au=n=>n.distinct?[n.fn,"DISTINCT",n.value].join(" "):[n.fn,n.value].join(" "),ol=n=>{let l=n.replace(/[_-]+/g," ");return l=l.replace(/([a-z0-9])([A-Z])/g,"$1 $2"),l=l.toLowerCase().replace(/\b\w/g,i=>i.toUpperCase()),l},gE="_container_13dmo_2",bE="_header_13dmo_2",xE="_fields-container_13dmo_2",SE="_field-label_13dmo_2",wE="_actions_13dmo_2",ur={container:gE,header:bE,fieldsContainer:xE,fieldLabel:SE,actions:wE},dl=()=>Date.now().toString(36)+Math.random().toString(36).substring(2),EE=(n,l,i)=>Ft({queryKey:["entity",n,l,i],queryFn:async()=>{const r=i?i.map(([c,d])=>({id:dl(),column:c,operator:"=",value:[{value:d}],connector:"AND"})):[],{data:u}=await Te.post("/runner/select",{datasourceId:n,opts:{table:l,filters:r,joins:[],columns:[],orderBy:[],groupBy:[],aggregations:[]},size:1,page:0,name:`Select ${l}: [${i?.join()}]`});return u.data},retry:1,enabled:!!l&&!!n&&!!i,staleTime:0}),CE=()=>vt({mutationFn:async n=>{const{data:l}=await Te.post("/runner/update",n);return l.data}}),_E=()=>vt({mutationFn:async n=>{const{data:l}=await Te.post("/runner/insert",n);return l.data}}),Zd=n=>b.useMemo(()=>{if(n)return n instanceof a3?n.response?.data.error?n.response.data.error:n.response?.data?.message?n.response.data.message:n.message:n instanceof Error?n.message:"Undefined error"},[n]),Pd=()=>{const{pathname:n}=qt();return b.useMemo(()=>pr({path:`${Ye.workbench.path}/tab/:id`,end:!1},n)?.params.id,[n])},NE=({data:n})=>{const[l,{change:i,touched:r}]=Rr({}),u=Pd(),{mutateAsync:c,error:d}=_E(),m=Zd(d),{data:p}=ai(n.dataSourceId),[y,g]=b.useState(""),x=b.useMemo(()=>p?.find(w=>w.tableName===n.table),[p,n.table]),E=b.useMemo(()=>{if(!x)return[];if(!y)return x.columns.map(j=>({...j,label:ol(j.name)}));const w=y.toLowerCase();return x.columns.filter(j=>j.name.toLowerCase().includes(w)).map(j=>({...j,label:ol(j.name)}))},[y,x]),C=()=>{const w=[];for(const j of r)w.push({value:l[j],column:j});c({datasourceId:n.dataSourceId,table:n.table,values:w}).then(()=>{pE(),u&&gv(u)})};return h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:ur.header,children:[h.jsxs("p",{className:"text-lg font-semibold",children:["Insert new row in ",h.jsx("span",{className:"underline",children:n.table})]}),m&&h.jsx(wt,{variant:"danger",children:h.jsx("p",{children:m})})]}),h.jsx("div",{className:"bg-gray-50 py-1 px-4 border-y border-gray-200",children:h.jsx("p",{className:"text-xs text-gray-800",children:"Tip: use = to write raw SQL. Ex: =NULL or =NOW()"})}),h.jsx("div",{className:ur.container,children:h.jsx("div",{className:ur.fieldsContainer,children:E.map(w=>h.jsxs("label",{className:ur.fieldLabel,children:[h.jsxs("div",{className:"flex justify-between",children:[h.jsxs("p",{children:[w.isPrimary?"🔐":"🏷️"," ",w.label]}),h.jsxs("p",{className:"text-blue-800 text-sm",children:["[",w.name,": ",w.type,"]"]})]}),h.jsx("input",{className:"input w-full",value:$l(l[w.name]),onChange:i(w.name),placeholder:w.name})]},w.name))})}),h.jsxs("div",{className:ur.actions,children:[h.jsxs("label",{children:[h.jsx("span",{className:"mr-2",children:"🔎"}),h.jsx("input",{className:"input bg-white!",value:y,onChange:w=>g(w.target.value),placeholder:"Filter columns"})]}),h.jsx("span",{className:"flex-1"}),h.jsx("button",{disabled:!r.length,className:"button primary",onClick:C,children:"Run insert"})]})]})},TE=()=>{const n=mE(),[l,i]=b.useState(void 0);b.useEffect(()=>{n&&i(n)},[n]);const r=()=>Fd(void 0);return h.jsxs(cn,{isVisible:n!=null,onClose:r,onClosed:()=>i(void 0),noPadding:!0,children:[h.jsx(aa,{onClick:r}),l&&h.jsx(NE,{data:l})]})},[jE,Jd]=un(void 0),AE=()=>Jd(void 0),RE="_container_1w6r3_2",OE="_header_1w6r3_2",DE="_key_1w6r3_2",ME="_fields-container_1w6r3_2",UE="_field-label_1w6r3_2",LE="_actions_1w6r3_2",Bs={container:RE,header:OE,key:DE,fieldsContainer:ME,fieldLabel:UE,actions:LE},zE=({data:n})=>{const[l,{change:i,set:r,reset:u,touched:c}]=Rr({}),d=Pd(),[m,p]=b.useState(""),{data:y,isLoading:g}=EE(n.dataSourceId,n.tableName,n.entityId),{mutateAsync:x,error:E}=CE(),C=Zd(E),w=Ar($t.EDITOR),{data:j}=ai(n.dataSourceId),{data:N}=Cu(n.dataSourceId),_=b.useMemo(()=>j?.find(V=>V.tableName===n.tableName),[n.tableName,j]),T=b.useMemo(()=>{if(!_)return[];if(!m)return _.columns.map(K=>({...K,label:ol(K.name)}));const V=m.toLowerCase();return _.columns.filter(K=>K.name.toLowerCase().includes(V)).map(K=>({...K,label:ol(K.name)}))},[m,_]);b.useEffect(()=>{const V=y?.rows[0];if(u(),V&&y?.columns)for(let K=0;K<y.columns.length;K++){const Z=y.columns[K];r(Z.column,$l(V[K]))}},[y,r,u]);const D=()=>{const V=[];for(const K of c)V.push({value:l[K],column:K});x({datasourceId:n.dataSourceId,table:n.tableName,filters:n.entityId.map(K=>({id:dl(),value:[{value:K[1]}],column:K[0],connector:"AND",operator:"="})),values:V}).then(()=>{AE(),d&&gv(d)})},H=n.entityId.map(([V,K])=>`${V} = ${K}`).join(", ")||"",G=!N?.allowUpdate||!w;return h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:Bs.header,children:[h.jsxs("p",{className:"text-lg font-semibold",children:[G?"View":"Edit"," row in ",h.jsx("span",{className:"underline",children:n?.tableName})]}),h.jsx("span",{className:Bs.key,children:H}),C&&h.jsx(wt,{variant:"danger",children:h.jsx("p",{children:C})})]}),!G&&h.jsx("div",{className:"bg-gray-50 py-1 px-4 border-y border-gray-200",children:h.jsx("p",{className:"text-xs text-gray-800",children:"Tip: use = to write raw SQL. Ex: =NULL or =NOW()"})}),h.jsx("div",{className:Bs.container,children:h.jsx("div",{className:Bs.fieldsContainer,children:T.map(V=>h.jsxs("label",{className:Bs.fieldLabel,children:[h.jsxs("div",{className:"flex justify-between",children:[h.jsxs("p",{children:[V.isPrimary?"🔐":"🏷️"," ",V.label]}),h.jsxs("p",{className:"text-blue-800 text-sm",children:["[",V.name,": ",V.type,"]"]})]}),h.jsx("input",{disabled:V.isPrimary||g||G,className:"input w-full",value:$l(l[V.name]),onChange:i(V.name),placeholder:V.name})]},V.name))})}),h.jsxs("div",{className:Bs.actions,children:[h.jsxs("label",{children:[h.jsx("span",{className:"mr-2",children:"🔎"}),h.jsx("input",{className:"input bg-white!",value:m,onChange:V=>p(V.target.value),placeholder:"Filter columns"})]}),h.jsx("span",{className:"flex-1"}),!G&&h.jsx("button",{disabled:!c.length,className:"button primary",onClick:D,children:"Run update"})]})]})},kE=()=>{const n=jE(),[l,i]=b.useState(void 0);b.useEffect(()=>{n&&i(n)},[n]);const r=()=>Jd(void 0);return h.jsxs(cn,{isVisible:n!=null,onClose:r,onClosed:()=>i(void 0),noPadding:!0,children:[h.jsx(aa,{onClick:r}),l&&h.jsx(zE,{data:l})]})},[qE,Zf]=un(void 0),Sv=async n=>new Promise(l=>{Zf({message:n,onCancel:()=>{l(!1),Zf(void 0)},onConfirm:()=>{l(!0),Zf(void 0)}})}),BE=({confirm:n})=>h.jsxs("div",{children:[h.jsx("p",{children:n.message}),h.jsxs("div",{className:"flex gap-2 justify-end mt-4",children:[h.jsx("button",{className:"button tertiary",onClick:n.onCancel,children:"Cancel"}),h.jsx("button",{className:"button primary",onClick:n.onConfirm,children:"Confirm"})]})]}),HE=()=>{const n=qE(),[l,i]=b.useState(void 0);return b.useEffect(()=>{n&&i(n)},[n]),h.jsx(cn,{isVisible:!!n,onClose:()=>n?.onCancel(),onClosed:()=>i(void 0),children:l&&h.jsx(BE,{confirm:l})})},[QE,lu]=un(void 0),Or=async(n,l,i)=>new Promise(r=>{lu({message:n,defaultValue:l,alert:i,onCancel:()=>{lu(void 0),r(void 0)},onConfirm:u=>{lu(void 0),r(u)}})}),YE="_root_12mtw_1",VE={root:YE},KE=({data:n})=>{const[l,i]=b.useState("");b.useEffect(()=>{n.defaultValue&&i(n.defaultValue)},[n]);const r=c=>{i(c.target.value)},u=c=>{c.key==="Enter"&&(c.preventDefault(),n.onConfirm(l)),c.key==="Escape"&&(c.preventDefault(),n.onCancel())};return h.jsxs("div",{className:VE.root,children:[h.jsx("h2",{className:"text-xl font-semibold",children:n.message}),n.alert&&h.jsx(wt,{variant:n.alert.type,className:"mt-2",children:n.alert.message}),h.jsx("input",{autoFocus:!0,className:"w-full input my-2",value:l,onChange:r,onKeyDown:u}),h.jsxs("div",{className:"flex justify-end gap-2",children:[h.jsx("button",{className:"button tertiary",onClick:n.onCancel,children:"Cancel"}),h.jsx("button",{className:"button primary",onClick:()=>n.onConfirm(l),children:"Confirm"})]})]})},$E=()=>{const n=QE(),[l,i]=b.useState(void 0);return b.useEffect(()=>{n&&i(n)},[n]),h.jsx(cn,{isVisible:!!n,onClose:()=>lu(void 0),onClosed:()=>i(void 0),children:l&&h.jsx(KE,{data:l})})},[GE,XE]=un(void 0),wv=n=>{XE(n)},FE="_textarea_30cyl_2",ZE={textarea:FE},PE=()=>{const n=GE(),l=()=>{n&&(navigator.clipboard.writeText(n.toString()),sn.success("Copied!"))},i=()=>wv(void 0);return h.jsxs(cn,{isVisible:!!n,onClose:i,backdropClose:!0,children:[h.jsx("textarea",{className:ZE.textarea,readOnly:!0,defaultValue:n?.toString()}),h.jsxs("div",{className:"mt-2 flex gap-1 justify-end",children:[h.jsx("button",{className:"button primary",onClick:l,children:"Copy"}),h.jsx("button",{className:"button tertiary",onClick:i,children:"Close"})]})]})},JE="_tabs_1jhm8_2",IE="_mobile_1jhm8_2",WE="_tab_1jhm8_2",eC="_active_1jhm8_2",tC="_close-button_1jhm8_2",cr={tabs:JE,mobile:IE,tab:WE,active:eC,closeButton:tC},Dy=n=>window.matchMedia(n).matches;function Ev(n,{defaultValue:l=!1,initializeWithValue:i=!0}={}){const[r,u]=b.useState(()=>i?Dy(n):l);return b.useLayoutEffect(()=>{const c=window.matchMedia(n);function d(){u(()=>Dy(n))}return d(),c.addListener?c.addListener(d):c.addEventListener("change",d),()=>{c.removeListener?c.removeListener(d):c.removeEventListener("change",d)}},[n]),r}const Id={laptop:"(min-width: 1024px)"},nC=()=>window.matchMedia(Id.laptop).matches,aC="_table_y5s2h_2",lC="_semi-transparent_y5s2h_2",sC="_table-loading_y5s2h_2",iC="_table-empty_y5s2h_2",rC="_table-row-cells_y5s2h_2",oC="_header-cell_y5s2h_2",uC="_header-actions_y5s2h_2",cC="_cell_y5s2h_2",fC="_cell-actions_y5s2h_2",dC="_value_y5s2h_2",hC="_table-config_y5s2h_2",mC="_tab-name_y5s2h_2",pC="_table-action_y5s2h_2",yC="_blue_y5s2h_2",vC="_modal_y5s2h_2",gC="_selected-size_y5s2h_2",bC="_options-container_y5s2h_2",xC="_row-options-entries-list_y5s2h_2",SC="_underlying-rows-btn_y5s2h_2",wC="_option-item_y5s2h_2",EC="_pagination-indicator_y5s2h_2",se={table:aC,semiTransparent:lC,tableLoading:sC,tableEmpty:iC,tableRowCells:rC,headerCell:oC,headerActions:uC,cell:cC,cellActions:fC,value:dC,tableConfig:hC,tabName:mC,tableAction:pC,blue:yC,modal:vC,selectedSize:gC,optionsContainer:bC,rowOptionsEntriesList:xC,underlyingRowsBtn:SC,optionItem:wC,paginationIndicator:EC},vl=b.createContext({name:"No name",hooks:[],availableJoins:[],allColumns:[],dataSourceId:"",entities:[],getValue:()=>{},getColumnType:()=>{},getEntityKey:()=>[]}),Zt=b.createContext({state:$s({}),setState:()=>{}}),Ra=b.createContext({}),Cv={ON_ANIMATION_END:Symbol("ON_TRANSITION_END")},_v=()=>{const[n,l]=b.useState(),[i,r]=b.useState("hidden");return b.useMemo(()=>{const u=m=>{m.preventDefault(),r("in"),l({x:m.clientX-1,y:m.clientY-1})},c=()=>{r("out")},d=m=>{console.log("onAnimationEnd",m),i==="in"?r("visible"):i==="out"&&(l(void 0),r("hidden"))};return{show:!!n,position:n,state:i,open:u,close:c,[Cv.ON_ANIMATION_END]:d}},[n,i])},CC=n=>{if(n==="ASC")return"DESC";if(n!=="DESC")return"ASC"},_C=()=>{const{state:n,setState:l}=b.useContext(Zt),i=b.useCallback(r=>{l(u=>{const c=u.orderBy[0];if(c&&c.column===r){const d=CC(c.direction);return d?{...u,orderBy:[{column:r,direction:d}]}:{...u,orderBy:[]}}return{...u,orderBy:[{column:r,direction:"ASC"}]}})},[l]);return{orderBy:n.orderBy,updateOrderBy:i}};function NC(n){const l=n.target?.dataset;if(l){if(l.copyCol&&l.copyRow)return{col:parseInt(l.copyCol),row:parseInt(l.copyRow),action:"copy"};if(l.showCol&&l.showRow)return{col:parseInt(l.showCol),row:parseInt(l.showRow),action:"show"};if(l.filterCol&&l.filterRow)return{col:parseInt(l.filterCol),row:parseInt(l.filterRow),action:"filter"}}}function Pf(n,l,i){const r=n?.rows?.[l]?.[i],u=n?.columns?.[i];return{value:r,column:u}}const TC=()=>{const{data:n}=b.useContext(Ra),{getColumnType:l}=b.useContext(vl),{setState:i}=b.useContext(Zt),r=m=>{const{value:p,column:y}=Pf(n?.result,m.row,m.col);if(y){const g=$l(p,l(y.full));navigator.clipboard.writeText(g),sn.success("Copied!")}},u=m=>{const{value:p,column:y}=Pf(n?.result,m.row,m.col);if(y){const g=$l(p,l(y.full));wv(g)}},c=m=>{const{value:p,column:y}=Pf(n?.result,m.row,m.col);let g=y?.full||"",x;if(y?.table===""){sn.error("Filtering on aggregated column is not supported yet");return}if(g){let E;if(p==null)E={id:dl(),isEnabled:!0,column:g,connector:"AND",operator:"IS NULL"};else{const C=$l(p,l(g));E={id:dl(),isEnabled:!0,column:g,connector:"AND",operator:"=",fn:x,value:[{value:C}]}}i(C=>({...C,filters:[...C.filters,E]})),sn.success(`Added new filter on column ${y?.alias}`)}};return m=>{const p=NC(m);p&&(p.action==="copy"?r(p):p.action==="show"?u(p):p.action==="filter"&&c(p))}},jC="_container_1kx3r_2",AC="_animate-show_1kx3r_2",RC="_animate-hide_1kx3r_2",OC="_content_1kx3r_2",DC="_backdrop_1kx3r_2",Hl={container:jC,animateShow:AC,animateHide:RC,content:OC,backdrop:DC},Nv=({children:n,handler:l})=>{const i=b.useRef(l.close);i.current=l.close;const r=b.useMemo(()=>{if(!l.position)return;const u={};if(typeof window<"u"){const c=l.position.y>window.innerHeight/2,d=l.position.x>window.innerWidth/2;c?u.bottom=window.innerHeight-l.position.y:u.top=l.position.y,nC()?d?u.right=window.innerWidth-l.position.x:u.left=l.position.x:(u.right=36,u.left=36)}return u},[l.position]);return b.useEffect(()=>{const u=c=>{c.code==="Escape"&&i.current()};return window.addEventListener("keyup",u),()=>{window.removeEventListener("keyup",u)}},[]),r?h.jsxs("div",{className:re(Hl.container,l.state==="out"&&Hl.animateHide,l.state==="in"&&Hl.animateShow),onAnimationEnd:l[Cv.ON_ANIMATION_END],children:[h.jsx("div",{className:Hl.backdrop,onClick:u=>{u.stopPropagation(),u.preventDefault(),l.close()}}),h.jsx("div",{className:re(Hl.content,l.state==="out"&&Hl.animateHide,l.state==="in"&&Hl.animateShow),style:r,children:n})]}):null},MC="_table_pc08i_2",UC="_root_pc08i_2",LC="_content_pc08i_2",zC="_sub_pc08i_2",Zo={table:MC,root:UC,content:LC,sub:zC},Tv=({hook:n,onClick:l})=>h.jsxs("button",{className:Zo.root,onClick:l,children:[h.jsx("span",{children:"📄"}),h.jsxs("div",{className:Zo.content,children:[h.jsxs("p",{className:Zo.table,children:[" ",n.on.toTable]}),h.jsxs("span",{className:Zo.sub,children:[n.on.toColumn," = ",n.on.fromTable,".",n.on.fromColumn]})]})]},n.where),hl=(n,l)=>n!=null&&n>l,kC=({handler:n,rowIndex:l})=>{const{hooks:i,entities:r,dataSourceId:u,getEntityKey:c,getValue:d}=b.useContext(vl),{state:m}=b.useContext(Zt),{data:p}=b.useContext(Ra),[y,g]=b.useState(""),x=b.useMemo(()=>p?.result.rows[l],[p,l]),E=si(),C=Et(),[w,j]=b.useState("hooks"),N=()=>{x&&E.mutateAsync({name:`${m.table} > [${m.joins.map(V=>V.table).join()}]`,opts:$s({joins:m.joins,table:m.table,dataSourceId:m.dataSourceId,filters:[...m.filters,...m.groupBy.map(V=>({id:dl(),connector:"AND",column:V.value,operator:"=",value:[{value:d(x,V)}]}))]})}).then(V=>{C(`${Ye.workbench.path}/tab/${V.id}`),n.close()})},_=V=>{if(!x)return;const K=d(x,{value:`${V.on.fromTable}.${V.on.fromColumn}`});E.mutateAsync({name:`${V.on.toTable} ${V.on.toColumn} equals ${K}`,opts:$s({table:V.on.toTable,dataSourceId:u,filters:[{id:dl(),column:`${V.on.toTable}.${V.on.toColumn}`,operator:K==null?"IS NULL":"=",connector:"AND",value:K!=null?[{value:K,isColumn:!1}]:void 0}]})}).then(Z=>{C(`${Ye.workbench.path}/tab/${Z.id}`),n.close()})},T=V=>{if(!x)return;const K=c(V,x);n.close(),Jd({tableName:V,dataSourceId:u,entityId:K}),n.close()},D=b.useMemo(()=>y?r.filter(V=>V.includes(y)):r,[r,y]),H=b.useMemo(()=>{if(!p)return[];const V=y.toLowerCase();return i.filter(K=>p.result.columns.some(te=>te.column===K.on.fromColumn&&te.table===K.on.fromTable)?K.on.toTable.toLowerCase().includes(V):!1)},[y,i,p]),G=m.groupBy.length>0;return h.jsx(Nv,{handler:n,children:h.jsxs("div",{className:se.optionsContainer,children:[h.jsxs("div",{className:"grid grid-cols-2 mb-2",children:[h.jsx("button",{className:re("p-2 cursor-pointer border-b",w==="hooks"?"border-white":"border-r rounded-br-lg border-gray-200 bg-gray-50 text-gray-400"),onClick:()=>j("hooks"),children:"Drill down"}),h.jsx("button",{className:re("p-2 cursor-pointer border-b",w==="entities"?"border-white":"border-l rounded-bl-lg border-gray-200 bg-gray-50 text-gray-400"),onClick:()=>j("entities"),children:"Entities"})]}),h.jsx("input",{className:"input mx-2",placeholder:"Filter",value:y,onChange:V=>g(V.target.value)}),w==="entities"&&r.length>0&&h.jsx("div",{className:se.rowOptionsEntriesList,children:hl(D.length,0)?D.map(V=>h.jsx("button",{className:re(se.optionItem,"font-semibold"),onClick:()=>T(V),children:h.jsxs("span",{children:["📄 ",V]})},V)):h.jsx("p",{className:"text-center p-2 text-gray-800",children:"Empty"})}),w==="hooks"&&i.length>0&&h.jsx("div",{className:se.rowOptionsEntriesList,children:H.length>0?H.map(V=>h.jsx(Tv,{hook:V,onClick:()=>_(V)},V.where)):h.jsx("p",{className:"text-center p-2 text-gray-800",children:"Empty"})}),G&&h.jsx("button",{onClick:N,className:se.underlyingRowsBtn,children:"🎯 Underlying rows"})]})})},qC={ASC:"⬆️",DESC:"⬇️"},BC=()=>{const{data:n}=b.useContext(Ra),{orderBy:l,updateOrderBy:i}=_C(),r=n?.result.columns||[],u=l[0],c=hl(n?.result.tables.length,1);return h.jsx("thead",{children:h.jsxs("tr",{children:[h.jsx("td",{className:"py-1 px-4 text-center text-sm text-gray-600 border-r",children:"#"}),r.map(d=>h.jsxs("td",{className:se.headerCell,children:[h.jsxs("div",{className:"overflow-hidden",children:[c&&h.jsx("p",{className:"text-xs truncate italic",children:d.table||"-"}),h.jsx("p",{className:"text-sm font-semibold truncate",children:d.column})]}),h.jsx("div",{className:se.headerActions,children:h.jsx("button",{onClick:()=>i(d.full),children:u?.column===d.full?qC[u.direction]:"↕️"})})]},d.full))]})})};function HC({value:n,row:l,col:i}){if(n==="")return h.jsx("span",{className:"pointer-events-none text-black/30 truncate",children:"<EMPTY STRING>"});if(n==null)return h.jsx("span",{className:"pointer-events-none text-black/30",children:"<NULL>"});const r=$l(n);return h.jsxs(h.Fragment,{children:[h.jsx("span",{"data-row":l,className:se.value,children:r}),h.jsxs("div",{className:se.cellActions,children:[h.jsx("button",{"data-copy-col":i,"data-copy-row":l,children:"📋"}),h.jsx("button",{"data-show-col":i,"data-show-row":l,children:"👀"}),h.jsx("button",{"data-filter-col":i,"data-filter-row":l,children:"🔎"})]})]})}const QC=b.memo(({row:n,isLastRow:l,index:i,offset:r})=>h.jsxs("tr",{className:re(se.tableRowCells,l&&"rounded-b-lg"),children:[h.jsx("td",{className:"py-1 px-4 text-center align-middle text-xs w-8 text-blue-500 border-r",children:i+1+r}),n.map((u,c)=>h.jsx("td",{className:se.cell,"data-row":i,children:h.jsx(HC,{value:u,col:c,row:i})},c))]})),YC=()=>{const{data:n,error:l,isLoading:i,isFetching:r}=b.useContext(Ra),{state:{page:u,size:c}}=b.useContext(Zt),d=Zd(l),m=TC(),p=_v(),[y,g]=b.useState(void 0),x=C=>{const j=C.target?.dataset?.row;j!=null&&(g(parseInt(j)),p.open(C))},E=u*c;return h.jsxs(h.Fragment,{children:[y!=null&&p.show&&h.jsx(kC,{handler:p,rowIndex:y}),d&&h.jsx(wt,{className:"my-4",variant:"danger",children:d}),i&&h.jsx("div",{className:se.tableLoading,children:"Loading data"}),n&&h.jsxs("table",{className:re(se.table,r&&se.semiTransparent),onContextMenu:x,onClick:m,children:[h.jsx(BC,{}),h.jsxs("tbody",{children:[n.result.rows?.length<1&&h.jsx("tr",{className:se.tableEmpty,children:h.jsx("td",{colSpan:n.result.columns.length+1,children:"No data"})}),n.result.rows?.map((C,w)=>h.jsx(QC,{index:w,offset:E,row:C,isLastRow:w===n.result.rows.length-1},w))]})]})]})},VC=()=>{const{state:n,setState:l}=b.useContext(Zt),i=b.useCallback(u=>{l(c=>({...c,page:u}))},[l]),r=b.useCallback((u,c=!1)=>{l(d=>({...d,size:u,page:c?0:d.page}))},[l]);return{page:n.page,size:n.size,setSize:r,setPage:i}},KC=()=>vt({mutationFn:async n=>{const{data:l}=await Te.post("/saved-queries",n);return l.data},onSuccess:()=>{rt.invalidateQueries({queryKey:["queries"]}),ni()}}),$C=()=>vt({mutationFn:async n=>Te.delete("/saved-queries/"+n),onSuccess:()=>{ni()}}),GC=()=>vt({mutationFn:async({id:n,payload:l})=>{const{data:i}=await Te.patch("/saved-queries/"+n,l);return i.data},onSuccess:()=>{ni(),W3()}}),[_u,Wd]=un({filters:!1,joins:!1,columns:!1,groupBy:!1,aggregate:!1}),Un=n=>Wd(l=>({...l,[n]:!0})),Nu=n=>Wd(l=>({...l,[n]:!1})),du=n=>Wd(l=>({...l,[n]:!l[n]})),Fs=Math.min,Gl=Math.max,hu=Math.round,Po=Math.floor,Wn=n=>({x:n,y:n}),XC={left:"right",right:"left",bottom:"top",top:"bottom"},FC={start:"end",end:"start"};function Sd(n,l,i){return Gl(n,Fs(l,i))}function Dr(n,l){return typeof n=="function"?n(l):n}function Jl(n){return n.split("-")[0]}function Mr(n){return n.split("-")[1]}function jv(n){return n==="x"?"y":"x"}function eh(n){return n==="y"?"height":"width"}function ul(n){return["top","bottom"].includes(Jl(n))?"y":"x"}function th(n){return jv(ul(n))}function ZC(n,l,i){i===void 0&&(i=!1);const r=Mr(n),u=th(n),c=eh(u);let d=u==="x"?r===(i?"end":"start")?"right":"left":r==="start"?"bottom":"top";return l.reference[c]>l.floating[c]&&(d=mu(d)),[d,mu(d)]}function PC(n){const l=mu(n);return[wd(n),l,wd(l)]}function wd(n){return n.replace(/start|end/g,l=>FC[l])}function JC(n,l,i){const r=["left","right"],u=["right","left"],c=["top","bottom"],d=["bottom","top"];switch(n){case"top":case"bottom":return i?l?u:r:l?r:u;case"left":case"right":return l?c:d;default:return[]}}function IC(n,l,i,r){const u=Mr(n);let c=JC(Jl(n),i==="start",r);return u&&(c=c.map(d=>d+"-"+u),l&&(c=c.concat(c.map(wd)))),c}function mu(n){return n.replace(/left|right|bottom|top/g,l=>XC[l])}function WC(n){return{top:0,right:0,bottom:0,left:0,...n}}function Av(n){return typeof n!="number"?WC(n):{top:n,right:n,bottom:n,left:n}}function pu(n){const{x:l,y:i,width:r,height:u}=n;return{width:r,height:u,top:i,left:l,right:l+r,bottom:i+u,x:l,y:i}}function My(n,l,i){let{reference:r,floating:u}=n;const c=ul(l),d=th(l),m=eh(d),p=Jl(l),y=c==="y",g=r.x+r.width/2-u.width/2,x=r.y+r.height/2-u.height/2,E=r[m]/2-u[m]/2;let C;switch(p){case"top":C={x:g,y:r.y-u.height};break;case"bottom":C={x:g,y:r.y+r.height};break;case"right":C={x:r.x+r.width,y:x};break;case"left":C={x:r.x-u.width,y:x};break;default:C={x:r.x,y:r.y}}switch(Mr(l)){case"start":C[d]-=E*(i&&y?-1:1);break;case"end":C[d]+=E*(i&&y?-1:1);break}return C}const e6=async(n,l,i)=>{const{placement:r="bottom",strategy:u="absolute",middleware:c=[],platform:d}=i,m=c.filter(Boolean),p=await(d.isRTL==null?void 0:d.isRTL(l));let y=await d.getElementRects({reference:n,floating:l,strategy:u}),{x:g,y:x}=My(y,r,p),E=r,C={},w=0;for(let j=0;j<m.length;j++){const{name:N,fn:_}=m[j],{x:T,y:D,data:H,reset:G}=await _({x:g,y:x,initialPlacement:r,placement:E,strategy:u,middlewareData:C,rects:y,platform:d,elements:{reference:n,floating:l}});g=T??g,x=D??x,C={...C,[N]:{...C[N],...H}},G&&w<=50&&(w++,typeof G=="object"&&(G.placement&&(E=G.placement),G.rects&&(y=G.rects===!0?await d.getElementRects({reference:n,floating:l,strategy:u}):G.rects),{x:g,y:x}=My(y,E,p)),j=-1)}return{x:g,y:x,placement:E,strategy:u,middlewareData:C}};async function Rv(n,l){var i;l===void 0&&(l={});const{x:r,y:u,platform:c,rects:d,elements:m,strategy:p}=n,{boundary:y="clippingAncestors",rootBoundary:g="viewport",elementContext:x="floating",altBoundary:E=!1,padding:C=0}=Dr(l,n),w=Av(C),N=m[E?x==="floating"?"reference":"floating":x],_=pu(await c.getClippingRect({element:(i=await(c.isElement==null?void 0:c.isElement(N)))==null||i?N:N.contextElement||await(c.getDocumentElement==null?void 0:c.getDocumentElement(m.floating)),boundary:y,rootBoundary:g,strategy:p})),T=x==="floating"?{x:r,y:u,width:d.floating.width,height:d.floating.height}:d.reference,D=await(c.getOffsetParent==null?void 0:c.getOffsetParent(m.floating)),H=await(c.isElement==null?void 0:c.isElement(D))?await(c.getScale==null?void 0:c.getScale(D))||{x:1,y:1}:{x:1,y:1},G=pu(c.convertOffsetParentRelativeRectToViewportRelativeRect?await c.convertOffsetParentRelativeRectToViewportRelativeRect({elements:m,rect:T,offsetParent:D,strategy:p}):T);return{top:(_.top-G.top+w.top)/H.y,bottom:(G.bottom-_.bottom+w.bottom)/H.y,left:(_.left-G.left+w.left)/H.x,right:(G.right-_.right+w.right)/H.x}}const t6=n=>({name:"arrow",options:n,async fn(l){const{x:i,y:r,placement:u,rects:c,platform:d,elements:m,middlewareData:p}=l,{element:y,padding:g=0}=Dr(n,l)||{};if(y==null)return{};const x=Av(g),E={x:i,y:r},C=th(u),w=eh(C),j=await d.getDimensions(y),N=C==="y",_=N?"top":"left",T=N?"bottom":"right",D=N?"clientHeight":"clientWidth",H=c.reference[w]+c.reference[C]-E[C]-c.floating[w],G=E[C]-c.reference[C],V=await(d.getOffsetParent==null?void 0:d.getOffsetParent(y));let K=V?V[D]:0;(!K||!await(d.isElement==null?void 0:d.isElement(V)))&&(K=m.floating[D]||c.floating[w]);const Z=H/2-G/2,te=K/2-j[w]/2-1,ye=Fs(x[_],te),Ae=Fs(x[T],te),Ce=ye,$e=K-j[w]-Ae,me=K/2-j[w]/2+Z,_e=Sd(Ce,me,$e),q=!p.arrow&&Mr(u)!=null&&me!==_e&&c.reference[w]/2-(me<Ce?ye:Ae)-j[w]/2<0,F=q?me<Ce?me-Ce:me-$e:0;return{[C]:E[C]+F,data:{[C]:_e,centerOffset:me-_e-F,...q&&{alignmentOffset:F}},reset:q}}}),n6=function(n){return n===void 0&&(n={}),{name:"flip",options:n,async fn(l){var i,r;const{placement:u,middlewareData:c,rects:d,initialPlacement:m,platform:p,elements:y}=l,{mainAxis:g=!0,crossAxis:x=!0,fallbackPlacements:E,fallbackStrategy:C="bestFit",fallbackAxisSideDirection:w="none",flipAlignment:j=!0,...N}=Dr(n,l);if((i=c.arrow)!=null&&i.alignmentOffset)return{};const _=Jl(u),T=ul(m),D=Jl(m)===m,H=await(p.isRTL==null?void 0:p.isRTL(y.floating)),G=E||(D||!j?[mu(m)]:PC(m)),V=w!=="none";!E&&V&&G.push(...IC(m,j,w,H));const K=[m,...G],Z=await Rv(l,N),te=[];let ye=((r=c.flip)==null?void 0:r.overflows)||[];if(g&&te.push(Z[_]),x){const me=ZC(u,d,H);te.push(Z[me[0]],Z[me[1]])}if(ye=[...ye,{placement:u,overflows:te}],!te.every(me=>me<=0)){var Ae,Ce;const me=(((Ae=c.flip)==null?void 0:Ae.index)||0)+1,_e=K[me];if(_e&&(!(x==="alignment"?T!==ul(_e):!1)||ye.every(J=>J.overflows[0]>0&&ul(J.placement)===T)))return{data:{index:me,overflows:ye},reset:{placement:_e}};let q=(Ce=ye.filter(F=>F.overflows[0]<=0).sort((F,J)=>F.overflows[1]-J.overflows[1])[0])==null?void 0:Ce.placement;if(!q)switch(C){case"bestFit":{var $e;const F=($e=ye.filter(J=>{if(V){const he=ul(J.placement);return he===T||he==="y"}return!0}).map(J=>[J.placement,J.overflows.filter(he=>he>0).reduce((he,R)=>he+R,0)]).sort((J,he)=>J[1]-he[1])[0])==null?void 0:$e[0];F&&(q=F);break}case"initialPlacement":q=m;break}if(u!==q)return{reset:{placement:q}}}return{}}}};async function a6(n,l){const{placement:i,platform:r,elements:u}=n,c=await(r.isRTL==null?void 0:r.isRTL(u.floating)),d=Jl(i),m=Mr(i),p=ul(i)==="y",y=["left","top"].includes(d)?-1:1,g=c&&p?-1:1,x=Dr(l,n);let{mainAxis:E,crossAxis:C,alignmentAxis:w}=typeof x=="number"?{mainAxis:x,crossAxis:0,alignmentAxis:null}:{mainAxis:x.mainAxis||0,crossAxis:x.crossAxis||0,alignmentAxis:x.alignmentAxis};return m&&typeof w=="number"&&(C=m==="end"?w*-1:w),p?{x:C*g,y:E*y}:{x:E*y,y:C*g}}const l6=function(n){return n===void 0&&(n=0),{name:"offset",options:n,async fn(l){var i,r;const{x:u,y:c,placement:d,middlewareData:m}=l,p=await a6(l,n);return d===((i=m.offset)==null?void 0:i.placement)&&(r=m.arrow)!=null&&r.alignmentOffset?{}:{x:u+p.x,y:c+p.y,data:{...p,placement:d}}}}},s6=function(n){return n===void 0&&(n={}),{name:"shift",options:n,async fn(l){const{x:i,y:r,placement:u}=l,{mainAxis:c=!0,crossAxis:d=!1,limiter:m={fn:N=>{let{x:_,y:T}=N;return{x:_,y:T}}},...p}=Dr(n,l),y={x:i,y:r},g=await Rv(l,p),x=ul(Jl(u)),E=jv(x);let C=y[E],w=y[x];if(c){const N=E==="y"?"top":"left",_=E==="y"?"bottom":"right",T=C+g[N],D=C-g[_];C=Sd(T,C,D)}if(d){const N=x==="y"?"top":"left",_=x==="y"?"bottom":"right",T=w+g[N],D=w-g[_];w=Sd(T,w,D)}const j=m.fn({...l,[E]:C,[x]:w});return{...j,data:{x:j.x-i,y:j.y-r,enabled:{[E]:c,[x]:d}}}}}};function Tu(){return typeof window<"u"}function ri(n){return Ov(n)?(n.nodeName||"").toLowerCase():"#document"}function rn(n){var l;return(n==null||(l=n.ownerDocument)==null?void 0:l.defaultView)||window}function la(n){var l;return(l=(Ov(n)?n.ownerDocument:n.document)||window.document)==null?void 0:l.documentElement}function Ov(n){return Tu()?n instanceof Node||n instanceof rn(n).Node:!1}function zn(n){return Tu()?n instanceof Element||n instanceof rn(n).Element:!1}function ea(n){return Tu()?n instanceof HTMLElement||n instanceof rn(n).HTMLElement:!1}function Uy(n){return!Tu()||typeof ShadowRoot>"u"?!1:n instanceof ShadowRoot||n instanceof rn(n).ShadowRoot}function Ur(n){const{overflow:l,overflowX:i,overflowY:r,display:u}=kn(n);return/auto|scroll|overlay|hidden|clip/.test(l+r+i)&&!["inline","contents"].includes(u)}function i6(n){return["table","td","th"].includes(ri(n))}function ju(n){return[":popover-open",":modal"].some(l=>{try{return n.matches(l)}catch{return!1}})}function nh(n){const l=ah(),i=zn(n)?kn(n):n;return["transform","translate","scale","rotate","perspective"].some(r=>i[r]?i[r]!=="none":!1)||(i.containerType?i.containerType!=="normal":!1)||!l&&(i.backdropFilter?i.backdropFilter!=="none":!1)||!l&&(i.filter?i.filter!=="none":!1)||["transform","translate","scale","rotate","perspective","filter"].some(r=>(i.willChange||"").includes(r))||["paint","layout","strict","content"].some(r=>(i.contain||"").includes(r))}function r6(n){let l=ml(n);for(;ea(l)&&!Zs(l);){if(nh(l))return l;if(ju(l))return null;l=ml(l)}return null}function ah(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function Zs(n){return["html","body","#document"].includes(ri(n))}function kn(n){return rn(n).getComputedStyle(n)}function Au(n){return zn(n)?{scrollLeft:n.scrollLeft,scrollTop:n.scrollTop}:{scrollLeft:n.scrollX,scrollTop:n.scrollY}}function ml(n){if(ri(n)==="html")return n;const l=n.assignedSlot||n.parentNode||Uy(n)&&n.host||la(n);return Uy(l)?l.host:l}function Dv(n){const l=ml(n);return Zs(l)?n.ownerDocument?n.ownerDocument.body:n.body:ea(l)&&Ur(l)?l:Dv(l)}function vr(n,l,i){var r;l===void 0&&(l=[]),i===void 0&&(i=!0);const u=Dv(n),c=u===((r=n.ownerDocument)==null?void 0:r.body),d=rn(u);if(c){const m=Ed(d);return l.concat(d,d.visualViewport||[],Ur(u)?u:[],m&&i?vr(m):[])}return l.concat(u,vr(u,[],i))}function Ed(n){return n.parent&&Object.getPrototypeOf(n.parent)?n.frameElement:null}function Mv(n){const l=kn(n);let i=parseFloat(l.width)||0,r=parseFloat(l.height)||0;const u=ea(n),c=u?n.offsetWidth:i,d=u?n.offsetHeight:r,m=hu(i)!==c||hu(r)!==d;return m&&(i=c,r=d),{width:i,height:r,$:m}}function lh(n){return zn(n)?n:n.contextElement}function Vs(n){const l=lh(n);if(!ea(l))return Wn(1);const i=l.getBoundingClientRect(),{width:r,height:u,$:c}=Mv(l);let d=(c?hu(i.width):i.width)/r,m=(c?hu(i.height):i.height)/u;return(!d||!Number.isFinite(d))&&(d=1),(!m||!Number.isFinite(m))&&(m=1),{x:d,y:m}}const o6=Wn(0);function Uv(n){const l=rn(n);return!ah()||!l.visualViewport?o6:{x:l.visualViewport.offsetLeft,y:l.visualViewport.offsetTop}}function u6(n,l,i){return l===void 0&&(l=!1),!i||l&&i!==rn(n)?!1:l}function Il(n,l,i,r){l===void 0&&(l=!1),i===void 0&&(i=!1);const u=n.getBoundingClientRect(),c=lh(n);let d=Wn(1);l&&(r?zn(r)&&(d=Vs(r)):d=Vs(n));const m=u6(c,i,r)?Uv(c):Wn(0);let p=(u.left+m.x)/d.x,y=(u.top+m.y)/d.y,g=u.width/d.x,x=u.height/d.y;if(c){const E=rn(c),C=r&&zn(r)?rn(r):r;let w=E,j=Ed(w);for(;j&&r&&C!==w;){const N=Vs(j),_=j.getBoundingClientRect(),T=kn(j),D=_.left+(j.clientLeft+parseFloat(T.paddingLeft))*N.x,H=_.top+(j.clientTop+parseFloat(T.paddingTop))*N.y;p*=N.x,y*=N.y,g*=N.x,x*=N.y,p+=D,y+=H,w=rn(j),j=Ed(w)}}return pu({width:g,height:x,x:p,y})}function sh(n,l){const i=Au(n).scrollLeft;return l?l.left+i:Il(la(n)).left+i}function Lv(n,l,i){i===void 0&&(i=!1);const r=n.getBoundingClientRect(),u=r.left+l.scrollLeft-(i?0:sh(n,r)),c=r.top+l.scrollTop;return{x:u,y:c}}function c6(n){let{elements:l,rect:i,offsetParent:r,strategy:u}=n;const c=u==="fixed",d=la(r),m=l?ju(l.floating):!1;if(r===d||m&&c)return i;let p={scrollLeft:0,scrollTop:0},y=Wn(1);const g=Wn(0),x=ea(r);if((x||!x&&!c)&&((ri(r)!=="body"||Ur(d))&&(p=Au(r)),ea(r))){const C=Il(r);y=Vs(r),g.x=C.x+r.clientLeft,g.y=C.y+r.clientTop}const E=d&&!x&&!c?Lv(d,p,!0):Wn(0);return{width:i.width*y.x,height:i.height*y.y,x:i.x*y.x-p.scrollLeft*y.x+g.x+E.x,y:i.y*y.y-p.scrollTop*y.y+g.y+E.y}}function f6(n){return Array.from(n.getClientRects())}function d6(n){const l=la(n),i=Au(n),r=n.ownerDocument.body,u=Gl(l.scrollWidth,l.clientWidth,r.scrollWidth,r.clientWidth),c=Gl(l.scrollHeight,l.clientHeight,r.scrollHeight,r.clientHeight);let d=-i.scrollLeft+sh(n);const m=-i.scrollTop;return kn(r).direction==="rtl"&&(d+=Gl(l.clientWidth,r.clientWidth)-u),{width:u,height:c,x:d,y:m}}function h6(n,l){const i=rn(n),r=la(n),u=i.visualViewport;let c=r.clientWidth,d=r.clientHeight,m=0,p=0;if(u){c=u.width,d=u.height;const y=ah();(!y||y&&l==="fixed")&&(m=u.offsetLeft,p=u.offsetTop)}return{width:c,height:d,x:m,y:p}}function m6(n,l){const i=Il(n,!0,l==="fixed"),r=i.top+n.clientTop,u=i.left+n.clientLeft,c=ea(n)?Vs(n):Wn(1),d=n.clientWidth*c.x,m=n.clientHeight*c.y,p=u*c.x,y=r*c.y;return{width:d,height:m,x:p,y}}function Ly(n,l,i){let r;if(l==="viewport")r=h6(n,i);else if(l==="document")r=d6(la(n));else if(zn(l))r=m6(l,i);else{const u=Uv(n);r={x:l.x-u.x,y:l.y-u.y,width:l.width,height:l.height}}return pu(r)}function zv(n,l){const i=ml(n);return i===l||!zn(i)||Zs(i)?!1:kn(i).position==="fixed"||zv(i,l)}function p6(n,l){const i=l.get(n);if(i)return i;let r=vr(n,[],!1).filter(m=>zn(m)&&ri(m)!=="body"),u=null;const c=kn(n).position==="fixed";let d=c?ml(n):n;for(;zn(d)&&!Zs(d);){const m=kn(d),p=nh(d);!p&&m.position==="fixed"&&(u=null),(c?!p&&!u:!p&&m.position==="static"&&!!u&&["absolute","fixed"].includes(u.position)||Ur(d)&&!p&&zv(n,d))?r=r.filter(g=>g!==d):u=m,d=ml(d)}return l.set(n,r),r}function y6(n){let{element:l,boundary:i,rootBoundary:r,strategy:u}=n;const d=[...i==="clippingAncestors"?ju(l)?[]:p6(l,this._c):[].concat(i),r],m=d[0],p=d.reduce((y,g)=>{const x=Ly(l,g,u);return y.top=Gl(x.top,y.top),y.right=Fs(x.right,y.right),y.bottom=Fs(x.bottom,y.bottom),y.left=Gl(x.left,y.left),y},Ly(l,m,u));return{width:p.right-p.left,height:p.bottom-p.top,x:p.left,y:p.top}}function v6(n){const{width:l,height:i}=Mv(n);return{width:l,height:i}}function g6(n,l,i){const r=ea(l),u=la(l),c=i==="fixed",d=Il(n,!0,c,l);let m={scrollLeft:0,scrollTop:0};const p=Wn(0);function y(){p.x=sh(u)}if(r||!r&&!c)if((ri(l)!=="body"||Ur(u))&&(m=Au(l)),r){const C=Il(l,!0,c,l);p.x=C.x+l.clientLeft,p.y=C.y+l.clientTop}else u&&y();c&&!r&&u&&y();const g=u&&!r&&!c?Lv(u,m):Wn(0),x=d.left+m.scrollLeft-p.x-g.x,E=d.top+m.scrollTop-p.y-g.y;return{x,y:E,width:d.width,height:d.height}}function Jf(n){return kn(n).position==="static"}function zy(n,l){if(!ea(n)||kn(n).position==="fixed")return null;if(l)return l(n);let i=n.offsetParent;return la(n)===i&&(i=i.ownerDocument.body),i}function kv(n,l){const i=rn(n);if(ju(n))return i;if(!ea(n)){let u=ml(n);for(;u&&!Zs(u);){if(zn(u)&&!Jf(u))return u;u=ml(u)}return i}let r=zy(n,l);for(;r&&i6(r)&&Jf(r);)r=zy(r,l);return r&&Zs(r)&&Jf(r)&&!nh(r)?i:r||r6(n)||i}const b6=async function(n){const l=this.getOffsetParent||kv,i=this.getDimensions,r=await i(n.floating);return{reference:g6(n.reference,await l(n.floating),n.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function x6(n){return kn(n).direction==="rtl"}const S6={convertOffsetParentRelativeRectToViewportRelativeRect:c6,getDocumentElement:la,getClippingRect:y6,getOffsetParent:kv,getElementRects:b6,getClientRects:f6,getDimensions:v6,getScale:Vs,isElement:zn,isRTL:x6};function qv(n,l){return n.x===l.x&&n.y===l.y&&n.width===l.width&&n.height===l.height}function w6(n,l){let i=null,r;const u=la(n);function c(){var m;clearTimeout(r),(m=i)==null||m.disconnect(),i=null}function d(m,p){m===void 0&&(m=!1),p===void 0&&(p=1),c();const y=n.getBoundingClientRect(),{left:g,top:x,width:E,height:C}=y;if(m||l(),!E||!C)return;const w=Po(x),j=Po(u.clientWidth-(g+E)),N=Po(u.clientHeight-(x+C)),_=Po(g),D={rootMargin:-w+"px "+-j+"px "+-N+"px "+-_+"px",threshold:Gl(0,Fs(1,p))||1};let H=!0;function G(V){const K=V[0].intersectionRatio;if(K!==p){if(!H)return d();K?d(!1,K):r=setTimeout(()=>{d(!1,1e-7)},1e3)}K===1&&!qv(y,n.getBoundingClientRect())&&d(),H=!1}try{i=new IntersectionObserver(G,{...D,root:u.ownerDocument})}catch{i=new IntersectionObserver(G,D)}i.observe(n)}return d(!0),c}function E6(n,l,i,r){r===void 0&&(r={});const{ancestorScroll:u=!0,ancestorResize:c=!0,elementResize:d=typeof ResizeObserver=="function",layoutShift:m=typeof IntersectionObserver=="function",animationFrame:p=!1}=r,y=lh(n),g=u||c?[...y?vr(y):[],...vr(l)]:[];g.forEach(_=>{u&&_.addEventListener("scroll",i,{passive:!0}),c&&_.addEventListener("resize",i)});const x=y&&m?w6(y,i):null;let E=-1,C=null;d&&(C=new ResizeObserver(_=>{let[T]=_;T&&T.target===y&&C&&(C.unobserve(l),cancelAnimationFrame(E),E=requestAnimationFrame(()=>{var D;(D=C)==null||D.observe(l)})),i()}),y&&!p&&C.observe(y),C.observe(l));let w,j=p?Il(n):null;p&&N();function N(){const _=Il(n);j&&!qv(j,_)&&i(),j=_,w=requestAnimationFrame(N)}return i(),()=>{var _;g.forEach(T=>{u&&T.removeEventListener("scroll",i),c&&T.removeEventListener("resize",i)}),x?.(),(_=C)==null||_.disconnect(),C=null,p&&cancelAnimationFrame(w)}}const C6=l6,_6=s6,N6=n6,T6=t6,ky=(n,l,i)=>{const r=new Map,u={platform:S6,...i},c={...u.platform,_c:r};return e6(n,l,{...u,platform:c})};var If={exports:{}};var qy;function j6(){return qy||(qy=1,function(n){(function(){var l={}.hasOwnProperty;function i(){for(var c="",d=0;d<arguments.length;d++){var m=arguments[d];m&&(c=u(c,r(m)))}return c}function r(c){if(typeof c=="string"||typeof c=="number")return c;if(typeof c!="object")return"";if(Array.isArray(c))return i.apply(null,c);if(c.toString!==Object.prototype.toString&&!c.toString.toString().includes("[native code]"))return c.toString();var d="";for(var m in c)l.call(c,m)&&c[m]&&(d=u(d,m));return d}function u(c,d){return d?c?c+" "+d:c+d:c}n.exports?(i.default=i,n.exports=i):window.classNames=i})()}(If)),If.exports}var A6=j6();const Cd=Td(A6);var By={};const R6="react-tooltip-core-styles",O6="react-tooltip-base-styles",Hy={core:!1,base:!1};function Qy({css:n,id:l=O6,type:i="base",ref:r}){var u,c;if(!n||typeof document>"u"||Hy[i]||i==="core"&&typeof process<"u"&&(!((u=process==null?void 0:By)===null||u===void 0)&&u.REACT_TOOLTIP_DISABLE_CORE_STYLES)||i!=="base"&&typeof process<"u"&&(!((c=process==null?void 0:By)===null||c===void 0)&&c.REACT_TOOLTIP_DISABLE_BASE_STYLES))return;i==="core"&&(l=R6),r||(r={});const{insertAt:d}=r;if(document.getElementById(l))return;const m=document.head||document.getElementsByTagName("head")[0],p=document.createElement("style");p.id=l,p.type="text/css",d==="top"&&m.firstChild?m.insertBefore(p,m.firstChild):m.appendChild(p),p.styleSheet?p.styleSheet.cssText=n:p.appendChild(document.createTextNode(n)),Hy[i]=!0}const Yy=async({elementReference:n=null,tooltipReference:l=null,tooltipArrowReference:i=null,place:r="top",offset:u=10,strategy:c="absolute",middlewares:d=[C6(Number(u)),N6({fallbackAxisSideDirection:"start"}),_6({padding:5})],border:m,arrowSize:p=8})=>{if(!n)return{tooltipStyles:{},tooltipArrowStyles:{},place:r};if(l===null)return{tooltipStyles:{},tooltipArrowStyles:{},place:r};const y=d;return i?(y.push(T6({element:i,padding:5})),ky(n,l,{placement:r,strategy:c,middleware:y}).then(({x:g,y:x,placement:E,middlewareData:C})=>{var w,j;const N={left:`${g}px`,top:`${x}px`,border:m},{x:_,y:T}=(w=C.arrow)!==null&&w!==void 0?w:{x:0,y:0},D=(j={top:"bottom",right:"left",bottom:"top",left:"right"}[E.split("-")[0]])!==null&&j!==void 0?j:"bottom",H=m&&{borderBottom:m,borderRight:m};let G=0;if(m){const V=`${m}`.match(/(\d+)px/);G=V?.[1]?Number(V[1]):1}return{tooltipStyles:N,tooltipArrowStyles:{left:_!=null?`${_}px`:"",top:T!=null?`${T}px`:"",right:"",bottom:"",...H,[D]:`-${p/2+G}px`},place:E}})):ky(n,l,{placement:"bottom",strategy:c,middleware:y}).then(({x:g,y:x,placement:E})=>({tooltipStyles:{left:`${g}px`,top:`${x}px`},tooltipArrowStyles:{},place:E}))},Vy=(n,l)=>!("CSS"in window&&"supports"in window.CSS)||window.CSS.supports(n,l),Ky=(n,l,i)=>{let r=null;const u=function(...c){const d=()=>{r=null};!r&&(n.apply(this,c),r=setTimeout(d,l))};return u.cancel=()=>{r&&(clearTimeout(r),r=null)},u},$y=n=>n!==null&&!Array.isArray(n)&&typeof n=="object",_d=(n,l)=>{if(n===l)return!0;if(Array.isArray(n)&&Array.isArray(l))return n.length===l.length&&n.every((u,c)=>_d(u,l[c]));if(Array.isArray(n)!==Array.isArray(l))return!1;if(!$y(n)||!$y(l))return n===l;const i=Object.keys(n),r=Object.keys(l);return i.length===r.length&&i.every(u=>_d(n[u],l[u]))},D6=n=>{if(!(n instanceof HTMLElement||n instanceof SVGElement))return!1;const l=getComputedStyle(n);return["overflow","overflow-x","overflow-y"].some(i=>{const r=l.getPropertyValue(i);return r==="auto"||r==="scroll"})},Gy=n=>{if(!n)return null;let l=n.parentElement;for(;l;){if(D6(l))return l;l=l.parentElement}return document.scrollingElement||document.documentElement},M6=typeof window<"u"?b.useLayoutEffect:b.useEffect,Tn=n=>{n.current&&(clearTimeout(n.current),n.current=null)},U6="DEFAULT_TOOLTIP_ID",L6={anchorRefs:new Set,activeAnchor:{current:null},attach:()=>{},detach:()=>{},setActiveAnchor:()=>{}},z6=b.createContext({getTooltipData:()=>L6});function Bv(n=U6){return b.useContext(z6).getTooltipData(n)}var Hs={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"},Wf={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 k6=({forwardRef:n,id:l,className:i,classNameArrow:r,variant:u="dark",anchorId:c,anchorSelect:d,place:m="top",offset:p=10,events:y=["hover"],openOnClick:g=!1,positionStrategy:x="absolute",middlewares:E,wrapper:C,delayShow:w=0,delayHide:j=0,float:N=!1,hidden:_=!1,noArrow:T=!1,clickable:D=!1,closeOnEsc:H=!1,closeOnScroll:G=!1,closeOnResize:V=!1,openEvents:K,closeEvents:Z,globalCloseEvents:te,imperativeModeOnly:ye,style:Ae,position:Ce,afterShow:$e,afterHide:me,disableTooltip:_e,content:q,contentWrapperRef:F,isOpen:J,defaultIsOpen:he=!1,setIsOpen:R,activeAnchor:Q,setActiveAnchor:I,border:W,opacity:ae,arrowColor:ge,arrowSize:oe=8,role:gt="tooltip"})=>{var Me;const Ge=b.useRef(null),Hn=b.useRef(null),Ct=b.useRef(null),fn=b.useRef(null),sa=b.useRef(null),[dn,oi]=b.useState({tooltipStyles:{},tooltipArrowStyles:{},place:m}),[Dt,Mt]=b.useState(!1),[ia,Qn]=b.useState(!1),[Ve,Yn]=b.useState(null),gl=b.useRef(!1),Oa=b.useRef(null),{anchorRefs:bl,setActiveAnchor:es}=Bv(l),hn=b.useRef(!1),[Je,Bt]=b.useState([]),tt=b.useRef(!1),Da=g||y.includes("click"),ui=Da||K?.click||K?.dblclick||K?.mousedown,Ma=K?{...K}:{mouseover:!0,focus:!0,mouseenter:!1,click:!1,dblclick:!1,mousedown:!1};!K&&Da&&Object.assign(Ma,{mouseenter:!1,focus:!1,mouseover:!1,click:!0});const mn=Z?{...Z}:{mouseout:!0,blur:!0,mouseleave:!1,click:!1,dblclick:!1,mouseup:!1};!Z&&Da&&Object.assign(mn,{mouseleave:!1,blur:!1,mouseout:!1});const _t=te?{...te}:{escape:H||!1,scroll:G||!1,resize:V||!1,clickOutsideAnchor:ui||!1};ye&&(Object.assign(Ma,{mouseover:!1,focus:!1,mouseenter:!1,click:!1,dblclick:!1,mousedown:!1}),Object.assign(mn,{mouseout:!1,blur:!1,mouseleave:!1,click:!1,dblclick:!1,mouseup:!1}),Object.assign(_t,{escape:!1,scroll:!1,resize:!1,clickOutsideAnchor:!1})),M6(()=>(tt.current=!0,()=>{tt.current=!1}),[]);const ke=P=>{tt.current&&(P&&Qn(!0),setTimeout(()=>{tt.current&&(R?.(P),J===void 0&&Mt(P))},10))};b.useEffect(()=>{if(J===void 0)return()=>null;J&&Qn(!0);const P=setTimeout(()=>{Mt(J)},10);return()=>{clearTimeout(P)}},[J]),b.useEffect(()=>{if(Dt!==gl.current)if(Tn(sa),gl.current=Dt,Dt)$e?.();else{const P=(ne=>{const ce=ne.match(/^([\d.]+)(ms|s)$/);if(!ce)return 0;const[,Fe,ht]=ce;return Number(Fe)*(ht==="ms"?1:1e3)})(getComputedStyle(document.body).getPropertyValue("--rt-transition-show-delay"));sa.current=setTimeout(()=>{Qn(!1),Yn(null),me?.()},P+25)}},[Dt]);const ra=P=>{oi(ne=>_d(ne,P)?ne:P)},Rn=(P=w)=>{Tn(Ct),ia?ke(!0):Ct.current=setTimeout(()=>{ke(!0)},P)},Ua=(P=j)=>{Tn(fn),fn.current=setTimeout(()=>{hn.current||ke(!1)},P)},La=P=>{var ne;if(!P)return;const ce=(ne=P.currentTarget)!==null&&ne!==void 0?ne:P.target;if(!ce?.isConnected)return I(null),void es({current:null});w?Rn():ke(!0),I(ce),es({current:ce}),Tn(fn)},oa=()=>{D?Ua(j||100):j?Ua():ke(!1),Tn(Ct)},Vn=({x:P,y:ne})=>{var ce;const Fe={getBoundingClientRect:()=>({x:P,y:ne,width:0,height:0,top:ne,left:P,right:P,bottom:ne})};Yy({place:(ce=Ve?.place)!==null&&ce!==void 0?ce:m,offset:p,elementReference:Fe,tooltipReference:Ge.current,tooltipArrowReference:Hn.current,strategy:x,middlewares:E,border:W,arrowSize:oe}).then(ht=>{ra(ht)})},pn=P=>{if(!P)return;const ne=P,ce={x:ne.clientX,y:ne.clientY};Vn(ce),Oa.current=ce},xl=P=>{var ne;if(!Dt)return;const ce=P.target;ce.isConnected&&(!((ne=Ge.current)===null||ne===void 0)&&ne.contains(ce)||[document.querySelector(`[id='${c}']`),...Je].some(Fe=>Fe?.contains(ce))||(ke(!1),Tn(Ct)))},Sl=Ky(La,50),nt=Ky(oa,50),Nt=P=>{nt.cancel(),Sl(P)},ie=()=>{Sl.cancel(),nt()},Se=b.useCallback(()=>{var P,ne;const ce=(P=Ve?.position)!==null&&P!==void 0?P:Ce;ce?Vn(ce):N?Oa.current&&Vn(Oa.current):Q?.isConnected&&Yy({place:(ne=Ve?.place)!==null&&ne!==void 0?ne:m,offset:p,elementReference:Q,tooltipReference:Ge.current,tooltipArrowReference:Hn.current,strategy:x,middlewares:E,border:W,arrowSize:oe}).then(Fe=>{tt.current&&ra(Fe)})},[Dt,Q,q,Ae,m,Ve?.place,p,x,Ce,Ve?.position,N,oe]);b.useEffect(()=>{var P,ne;const ce=new Set(bl);Je.forEach(Oe=>{_e?.(Oe)||ce.add({current:Oe})});const Fe=document.querySelector(`[id='${c}']`);Fe&&!_e?.(Fe)&&ce.add({current:Fe});const ht=()=>{ke(!1)},yn=Gy(Q),Pt=Gy(Ge.current);_t.scroll&&(window.addEventListener("scroll",ht),yn?.addEventListener("scroll",ht),Pt?.addEventListener("scroll",ht));let at=null;_t.resize?window.addEventListener("resize",ht):Q&&Ge.current&&(at=E6(Q,Ge.current,Se,{ancestorResize:!0,elementResize:!0,layoutShift:!0}));const jt=Oe=>{Oe.key==="Escape"&&ke(!1)};_t.escape&&window.addEventListener("keydown",jt),_t.clickOutsideAnchor&&window.addEventListener("click",xl);const Re=[],Jt=Oe=>!!(Oe?.target&&Q?.contains(Oe.target)),wl=Oe=>{Dt&&Jt(Oe)||La(Oe)},za=Oe=>{Dt&&Jt(Oe)&&oa()},lt=["mouseover","mouseout","mouseenter","mouseleave","focus","blur"],ci=["click","dblclick","mousedown","mouseup"];Object.entries(Ma).forEach(([Oe,vn])=>{vn&&(lt.includes(Oe)?Re.push({event:Oe,listener:Nt}):ci.includes(Oe)&&Re.push({event:Oe,listener:wl}))}),Object.entries(mn).forEach(([Oe,vn])=>{vn&&(lt.includes(Oe)?Re.push({event:Oe,listener:ie}):ci.includes(Oe)&&Re.push({event:Oe,listener:za}))}),N&&Re.push({event:"pointermove",listener:pn});const fi=()=>{hn.current=!0},Kn=()=>{hn.current=!1,oa()},ua=D&&(mn.mouseout||mn.mouseleave);return ua&&((P=Ge.current)===null||P===void 0||P.addEventListener("mouseover",fi),(ne=Ge.current)===null||ne===void 0||ne.addEventListener("mouseout",Kn)),Re.forEach(({event:Oe,listener:vn})=>{ce.forEach(ts=>{var El;(El=ts.current)===null||El===void 0||El.addEventListener(Oe,vn)})}),()=>{var Oe,vn;_t.scroll&&(window.removeEventListener("scroll",ht),yn?.removeEventListener("scroll",ht),Pt?.removeEventListener("scroll",ht)),_t.resize?window.removeEventListener("resize",ht):at?.(),_t.clickOutsideAnchor&&window.removeEventListener("click",xl),_t.escape&&window.removeEventListener("keydown",jt),ua&&((Oe=Ge.current)===null||Oe===void 0||Oe.removeEventListener("mouseover",fi),(vn=Ge.current)===null||vn===void 0||vn.removeEventListener("mouseout",Kn)),Re.forEach(({event:ts,listener:El})=>{ce.forEach(ns=>{var ka;(ka=ns.current)===null||ka===void 0||ka.removeEventListener(ts,El)})})}},[Q,Se,ia,bl,Je,K,Z,te,Da,w,j]),b.useEffect(()=>{var P,ne;let ce=(ne=(P=Ve?.anchorSelect)!==null&&P!==void 0?P:d)!==null&&ne!==void 0?ne:"";!ce&&l&&(ce=`[data-tooltip-id='${l.replace(/'/g,"\\'")}']`);const Fe=new MutationObserver(ht=>{const yn=[],Pt=[];ht.forEach(at=>{if(at.type==="attributes"&&at.attributeName==="data-tooltip-id"&&(at.target.getAttribute("data-tooltip-id")===l?yn.push(at.target):at.oldValue===l&&Pt.push(at.target)),at.type==="childList"){if(Q){const jt=[...at.removedNodes].filter(Re=>Re.nodeType===1);if(ce)try{Pt.push(...jt.filter(Re=>Re.matches(ce))),Pt.push(...jt.flatMap(Re=>[...Re.querySelectorAll(ce)]))}catch{}jt.some(Re=>{var Jt;return!!(!((Jt=Re?.contains)===null||Jt===void 0)&&Jt.call(Re,Q))&&(Qn(!1),ke(!1),I(null),Tn(Ct),Tn(fn),!0)})}if(ce)try{const jt=[...at.addedNodes].filter(Re=>Re.nodeType===1);yn.push(...jt.filter(Re=>Re.matches(ce))),yn.push(...jt.flatMap(Re=>[...Re.querySelectorAll(ce)]))}catch{}}}),(yn.length||Pt.length)&&Bt(at=>[...at.filter(jt=>!Pt.includes(jt)),...yn])});return Fe.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-tooltip-id"],attributeOldValue:!0}),()=>{Fe.disconnect()}},[l,d,Ve?.anchorSelect,Q]),b.useEffect(()=>{Se()},[Se]),b.useEffect(()=>{if(!F?.current)return()=>null;const P=new ResizeObserver(()=>{setTimeout(()=>Se())});return P.observe(F.current),()=>{P.disconnect()}},[q,F?.current]),b.useEffect(()=>{var P;const ne=document.querySelector(`[id='${c}']`),ce=[...Je,ne];Q&&ce.includes(Q)||I((P=Je[0])!==null&&P!==void 0?P:ne)},[c,Je,Q]),b.useEffect(()=>(he&&ke(!0),()=>{Tn(Ct),Tn(fn)}),[]),b.useEffect(()=>{var P;let ne=(P=Ve?.anchorSelect)!==null&&P!==void 0?P:d;if(!ne&&l&&(ne=`[data-tooltip-id='${l.replace(/'/g,"\\'")}']`),ne)try{const ce=Array.from(document.querySelectorAll(ne));Bt(ce)}catch{Bt([])}},[l,d,Ve?.anchorSelect]),b.useEffect(()=>{Ct.current&&(Tn(Ct),Rn(w))},[w]);const Ut=(Me=Ve?.content)!==null&&Me!==void 0?Me:q,Tt=Dt&&Object.keys(dn.tooltipStyles).length>0;return b.useImperativeHandle(n,()=>({open:P=>{if(P?.anchorSelect)try{document.querySelector(P.anchorSelect)}catch{return void console.warn(`[react-tooltip] "${P.anchorSelect}" is not a valid CSS selector`)}Yn(P??null),P?.delay?Rn(P.delay):ke(!0)},close:P=>{P?.delay?Ua(P.delay):ke(!1)},activeAnchor:Q,place:dn.place,isOpen:!!(ia&&!_&&Ut&&Tt)})),ia&&!_&&Ut?rl.createElement(C,{id:l,role:gt,className:Cd("react-tooltip",Hs.tooltip,Wf.tooltip,Wf[u],i,`react-tooltip__place-${dn.place}`,Hs[Tt?"show":"closing"],Tt?"react-tooltip__show":"react-tooltip__closing",x==="fixed"&&Hs.fixed,D&&Hs.clickable),onTransitionEnd:P=>{Tn(sa),Dt||P.propertyName!=="opacity"||(Qn(!1),Yn(null),me?.())},style:{...Ae,...dn.tooltipStyles,opacity:ae!==void 0&&Tt?ae:void 0},ref:Ge},Ut,rl.createElement(C,{className:Cd("react-tooltip-arrow",Hs.arrow,Wf.arrow,r,T&&Hs.noArrow),style:{...dn.tooltipArrowStyles,background:ge?`linear-gradient(to right bottom, transparent 50%, ${ge} 50%)`:void 0,"--rt-arrow-size":`${oe}px`},ref:Hn})):null},q6=({content:n})=>rl.createElement("span",{dangerouslySetInnerHTML:{__html:n}}),ih=rl.forwardRef(({id:n,anchorId:l,anchorSelect:i,content:r,html:u,render:c,className:d,classNameArrow:m,variant:p="dark",place:y="top",offset:g=10,wrapper:x="div",children:E=null,events:C=["hover"],openOnClick:w=!1,positionStrategy:j="absolute",middlewares:N,delayShow:_=0,delayHide:T=0,float:D=!1,hidden:H=!1,noArrow:G=!1,clickable:V=!1,closeOnEsc:K=!1,closeOnScroll:Z=!1,closeOnResize:te=!1,openEvents:ye,closeEvents:Ae,globalCloseEvents:Ce,imperativeModeOnly:$e=!1,style:me,position:_e,isOpen:q,defaultIsOpen:F=!1,disableStyleInjection:J=!1,border:he,opacity:R,arrowColor:Q,arrowSize:I,setIsOpen:W,afterShow:ae,afterHide:ge,disableTooltip:oe,role:gt="tooltip"},Me)=>{const[Ge,Hn]=b.useState(r),[Ct,fn]=b.useState(u),[sa,dn]=b.useState(y),[oi,Dt]=b.useState(p),[Mt,ia]=b.useState(g),[Qn,Ve]=b.useState(_),[Yn,gl]=b.useState(T),[Oa,bl]=b.useState(D),[es,hn]=b.useState(H),[Je,Bt]=b.useState(x),[tt,Da]=b.useState(C),[ui,Ma]=b.useState(j),[mn,_t]=b.useState(null),[ke,ra]=b.useState(null),Rn=b.useRef(J),{anchorRefs:Ua,activeAnchor:La}=Bv(n),oa=nt=>nt?.getAttributeNames().reduce((Nt,ie)=>{var Se;return ie.startsWith("data-tooltip-")&&(Nt[ie.replace(/^data-tooltip-/,"")]=(Se=nt?.getAttribute(ie))!==null&&Se!==void 0?Se:null),Nt},{}),Vn=nt=>{const Nt={place:ie=>{var Se;dn((Se=ie)!==null&&Se!==void 0?Se:y)},content:ie=>{Hn(ie??r)},html:ie=>{fn(ie??u)},variant:ie=>{var Se;Dt((Se=ie)!==null&&Se!==void 0?Se:p)},offset:ie=>{ia(ie===null?g:Number(ie))},wrapper:ie=>{var Se;Bt((Se=ie)!==null&&Se!==void 0?Se:x)},events:ie=>{const Se=ie?.split(" ");Da(Se??C)},"position-strategy":ie=>{var Se;Ma((Se=ie)!==null&&Se!==void 0?Se:j)},"delay-show":ie=>{Ve(ie===null?_:Number(ie))},"delay-hide":ie=>{gl(ie===null?T:Number(ie))},float:ie=>{bl(ie===null?D:ie==="true")},hidden:ie=>{hn(ie===null?H:ie==="true")},"class-name":ie=>{_t(ie)}};Object.values(Nt).forEach(ie=>ie(null)),Object.entries(nt).forEach(([ie,Se])=>{var Ut;(Ut=Nt[ie])===null||Ut===void 0||Ut.call(Nt,Se)})};b.useEffect(()=>{Hn(r)},[r]),b.useEffect(()=>{fn(u)},[u]),b.useEffect(()=>{dn(y)},[y]),b.useEffect(()=>{Dt(p)},[p]),b.useEffect(()=>{ia(g)},[g]),b.useEffect(()=>{Ve(_)},[_]),b.useEffect(()=>{gl(T)},[T]),b.useEffect(()=>{bl(D)},[D]),b.useEffect(()=>{hn(H)},[H]),b.useEffect(()=>{Ma(j)},[j]),b.useEffect(()=>{Rn.current!==J&&console.warn("[react-tooltip] Do not change `disableStyleInjection` dynamically.")},[J]),b.useEffect(()=>{typeof window<"u"&&window.dispatchEvent(new CustomEvent("react-tooltip-inject-styles",{detail:{disableCore:J==="core",disableBase:J}}))},[]),b.useEffect(()=>{var nt;const Nt=new Set(Ua);let ie=i;if(!ie&&n&&(ie=`[data-tooltip-id='${n.replace(/'/g,"\\'")}']`),ie)try{document.querySelectorAll(ie).forEach(ne=>{Nt.add({current:ne})})}catch{console.warn(`[react-tooltip] "${ie}" is not a valid CSS selector`)}const Se=document.querySelector(`[id='${l}']`);if(Se&&Nt.add({current:Se}),!Nt.size)return()=>null;const Ut=(nt=ke??Se)!==null&&nt!==void 0?nt:La.current,Tt=new MutationObserver(ne=>{ne.forEach(ce=>{var Fe;if(!Ut||ce.type!=="attributes"||!(!((Fe=ce.attributeName)===null||Fe===void 0)&&Fe.startsWith("data-tooltip-")))return;const ht=oa(Ut);Vn(ht)})}),P={attributes:!0,childList:!1,subtree:!1};if(Ut){const ne=oa(Ut);Vn(ne),Tt.observe(Ut,P)}return()=>{Tt.disconnect()}},[Ua,La,ke,l,i]),b.useEffect(()=>{me?.border&&console.warn("[react-tooltip] Do not set `style.border`. Use `border` prop instead."),he&&!Vy("border",`${he}`)&&console.warn(`[react-tooltip] "${he}" is not a valid \`border\`.`),me?.opacity&&console.warn("[react-tooltip] Do not set `style.opacity`. Use `opacity` prop instead."),R&&!Vy("opacity",`${R}`)&&console.warn(`[react-tooltip] "${R}" is not a valid \`opacity\`.`)},[]);let pn=E;const xl=b.useRef(null);if(c){const nt=c({content:ke?.getAttribute("data-tooltip-content")||Ge||null,activeAnchor:ke});pn=nt?rl.createElement("div",{ref:xl,className:"react-tooltip-content-wrapper"},nt):null}else Ge&&(pn=Ge);Ct&&(pn=rl.createElement(q6,{content:Ct}));const Sl={forwardRef:Me,id:n,anchorId:l,anchorSelect:i,className:Cd(d,mn),classNameArrow:m,content:pn,contentWrapperRef:xl,place:sa,variant:oi,offset:Mt,wrapper:Je,events:tt,openOnClick:w,positionStrategy:ui,middlewares:N,delayShow:Qn,delayHide:Yn,float:Oa,hidden:es,noArrow:G,clickable:V,closeOnEsc:K,closeOnScroll:Z,closeOnResize:te,openEvents:ye,closeEvents:Ae,globalCloseEvents:Ce,imperativeModeOnly:$e,style:me,position:_e,isOpen:q,defaultIsOpen:F,border:he,opacity:R,arrowColor:Q,arrowSize:I,setIsOpen:W,afterShow:ae,afterHide:ge,disableTooltip:oe,activeAnchor:ke,setActiveAnchor:nt=>ra(nt),role:gt};return rl.createElement(k6,{...Sl})});typeof window<"u"&&window.addEventListener("react-tooltip-inject-styles",n=>{n.detail.disableCore||Qy({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"}),n.detail.disableBase||Qy({css:`
193
+ .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 gr=n=>b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...n},b.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:48,d:"M184 112l144 144-144 144"})),B6=n=>b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...n},b.createElement("path",{d:"M320 146s24.36-12-64-12a160 160 0 10160 160",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeMiterlimit:10,strokeWidth:32}),b.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32,d:"M256 58l80 80-80 80"})),H6=n=>b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...n},b.createElement("rect",{x:128,y:128,width:336,height:336,rx:57,ry:57,fill:"none",stroke:"currentColor",strokeLinejoin:"round",strokeWidth:32}),b.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})),Q6=n=>b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...n},b.createElement("circle",{cx:128,cy:256,r:48,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32}),b.createElement("circle",{cx:384,cy:112,r:48,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32}),b.createElement("circle",{cx:384,cy:400,r:48,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32}),b.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"})),Y6=()=>{const n=Pd(),l=M4();return{rename:async r=>{if(n){const u=await Or("New tab name",r);u&&await l.mutateAsync({id:n,payload:{name:u}})}return Promise.resolve()}}},Hv=["shift","alt","meta","mod","ctrl","control"],V6={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 fl(n){return(V6[n.trim()]||n.trim()).toLowerCase().replace(/key|digit|numpad/,"")}function Qv(n){return Hv.includes(n)}function ed(n,l=","){return n.toLowerCase().split(l)}function td(n,l="+",i=">",r=!1,u){let c=[],d=!1;n=n.trim(),n.includes(i)?(d=!0,c=n.toLocaleLowerCase().split(i).map(y=>fl(y))):c=n.toLocaleLowerCase().split(l).map(y=>fl(y));const m={alt:c.includes("alt"),ctrl:c.includes("ctrl")||c.includes("control"),shift:c.includes("shift"),meta:c.includes("meta"),mod:c.includes("mod"),useKey:r},p=c.filter(y=>!Hv.includes(y));return{...m,keys:p,description:u,isSequence:d,hotkey:n}}typeof document<"u"&&(document.addEventListener("keydown",n=>{n.code!==void 0&&Yv([fl(n.code)])}),document.addEventListener("keyup",n=>{n.code!==void 0&&Vv([fl(n.code)])})),typeof window<"u"&&(window.addEventListener("blur",()=>{Na.clear()}),window.addEventListener("contextmenu",()=>{setTimeout(()=>{Na.clear()},0)}));const Na=new Set;function rh(n){return Array.isArray(n)}function K6(n,l=","){return(rh(n)?n:n.split(l)).every(i=>Na.has(i.trim().toLowerCase()))}function Yv(n){const l=Array.isArray(n)?n:[n];Na.has("meta")&&Na.forEach(i=>!Qv(i)&&Na.delete(i.toLowerCase())),l.forEach(i=>Na.add(i.toLowerCase()))}function Vv(n){const l=Array.isArray(n)?n:[n];n==="meta"?Na.clear():l.forEach(i=>Na.delete(i.toLowerCase()))}function $6(n,l,i){(typeof i=="function"&&i(n,l)||i===!0)&&n.preventDefault()}function G6(n,l,i){return typeof i=="function"?i(n,l):i===!0||i===void 0}const X6=["input","textarea","select","searchbox","slider","spinbutton","menuitem","menuitemcheckbox","menuitemradio","option","radio","textbox"];function F6(n){return Kv(n,X6)}function Kv(n,l=!1){const{target:i,composed:r}=n;let u,c;return Z6(i)&&r?(u=n.composedPath()[0]&&n.composedPath()[0].tagName,c=n.composedPath()[0]&&n.composedPath()[0].role):(u=i&&i.tagName,c=i&&i.role),rh(l)?!!(u&&l&&l.some(d=>d.toLowerCase()===u.toLowerCase()||d===c)):!!(u&&l&&l)}function Z6(n){return!!n.tagName&&!n.tagName.startsWith("-")&&n.tagName.includes("-")}function P6(n,l){return n.length===0&&l?(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):l?n.some(i=>l.includes(i))||n.includes("*"):!0}const J6=(n,l,i=!1)=>{const{alt:r,meta:u,mod:c,shift:d,ctrl:m,keys:p,useKey:y}=l,{code:g,key:x,ctrlKey:E,metaKey:C,shiftKey:w,altKey:j}=n,N=fl(g);if(y&&p?.length===1&&p.includes(x))return!0;if(!p?.includes(N)&&!["ctrl","control","unknown","meta","alt","shift","os"].includes(N))return!1;if(!i){if(r!==j&&N!=="alt"||d!==w&&N!=="shift")return!1;if(c){if(!C&&!E)return!1}else if(u!==C&&N!=="meta"&&N!=="os"||m!==E&&N!=="ctrl"&&N!=="control")return!1}return p&&p.length===1&&p.includes(N)?!0:p?K6(p):!p},I6=b.createContext(void 0),W6=()=>b.useContext(I6);function $v(n,l){return n&&l&&typeof n=="object"&&typeof l=="object"?Object.keys(n).length===Object.keys(l).length&&Object.keys(n).reduce((i,r)=>i&&$v(n[r],l[r]),!0):n===l}const e_=b.createContext({hotkeys:[],activeScopes:[],toggleScope:()=>{},enableScope:()=>{},disableScope:()=>{}}),t_=()=>b.useContext(e_);function n_(n){const l=b.useRef(void 0);return $v(l.current,n)||(l.current=n),l.current}const Xy=n=>{n.stopPropagation(),n.preventDefault(),n.stopImmediatePropagation()},a_=typeof window<"u"?b.useLayoutEffect:b.useEffect;function on(n,l,i,r){const u=b.useRef(null),c=b.useRef(!1),d=Array.isArray(i)?Array.isArray(r)?void 0:r:i,m=rh(n)?n.join(d?.delimiter):n,p=Array.isArray(i)?i:Array.isArray(r)?r:void 0,y=b.useCallback(l,p??[]),g=b.useRef(y);p?g.current=y:g.current=l;const x=n_(d),{activeScopes:E}=t_(),C=W6();return a_(()=>{if(x?.enabled===!1||!P6(E,x?.scopes))return;let w=[],j;const N=(H,G=!1)=>{if(!(F6(H)&&!Kv(H,x?.enableOnFormTags))){if(u.current!==null){const V=u.current.getRootNode();if((V instanceof Document||V instanceof ShadowRoot)&&V.activeElement!==u.current&&!u.current.contains(V.activeElement)){Xy(H);return}}H.target?.isContentEditable&&!x?.enableOnContentEditable||ed(m,x?.delimiter).forEach(V=>{if(V.includes(x?.splitKey??"+")&&V.includes(x?.sequenceSplitKey??">")){console.warn(`Hotkey ${V} contains both ${x?.splitKey??"+"} and ${x?.sequenceSplitKey??">"} which is not supported.`);return}const K=td(V,x?.splitKey,x?.sequenceSplitKey,x?.useKey,x?.description);if(K.isSequence){j=setTimeout(()=>{w=[]},x?.sequenceTimeoutMs??1e3);const Z=K.useKey?H.key:fl(H.code);if(Qv(Z.toLowerCase()))return;w.push(Z);const te=K.keys?.[w.length-1];if(Z!==te){w=[],j&&clearTimeout(j);return}w.length===K.keys?.length&&(g.current(H,K),j&&clearTimeout(j),w=[])}else if(J6(H,K,x?.ignoreModifiers)||K.keys?.includes("*")){if(x?.ignoreEventWhen?.(H)||G&&c.current)return;if($6(H,K,x?.preventDefault),!G6(H,K,x?.enabled)){Xy(H);return}g.current(H,K),G||(c.current=!0)}})}},_=H=>{H.code!==void 0&&(Yv(fl(H.code)),(x?.keydown===void 0&&x?.keyup!==!0||x?.keydown)&&N(H))},T=H=>{H.code!==void 0&&(Vv(fl(H.code)),c.current=!1,x?.keyup&&N(H,!0))},D=u.current||d?.document||document;return D.addEventListener("keyup",T,d?.eventListenerOptions),D.addEventListener("keydown",_,d?.eventListenerOptions),C&&ed(m,x?.delimiter).forEach(H=>C.addHotkey(td(H,x?.splitKey,x?.sequenceSplitKey,x?.useKey,x?.description))),()=>{D.removeEventListener("keyup",T,d?.eventListenerOptions),D.removeEventListener("keydown",_,d?.eventListenerOptions),C&&ed(m,x?.delimiter).forEach(H=>C.removeHotkey(td(H,x?.splitKey,x?.sequenceSplitKey,x?.useKey,x?.description))),w=[],j&&clearTimeout(j)}},[m,x,E]),u}function l_(){return h.jsxs("div",{className:"flex items-center bg-white border-b border-gray-200 overflow-auto no-scrollbar",children:[h.jsx(s_,{}),h.jsx(r_,{})]})}function s_(){const{dataSourceId:n,name:l}=b.useContext(vl),{data:i}=Cu(n),{data:r}=b.useContext(Ra),u=Ar($t.EDITOR),c=KC(),{rename:d}=Y6(),m=()=>{r?.result.columns?.[0].table&&Fd({table:r?.result.columns?.[0].table,dataSourceId:n})},p=async()=>{const g=await Or("Query name",l);!g||!r?.result.queryHistoryId||c.mutate({name:g,queryId:r.result.queryHistoryId})},y=()=>d(l);return on("s",p),on("r",y),h.jsxs("div",{className:se.tableConfig,children:[h.jsx("button",{"data-tooltip-id":"default","data-tooltip-content":"Rename tab",onClick:y,className:re(se.tableAction,se.blue,"block"),children:h.jsxs("span",{className:se.tabName,children:["🛠️ ",l]})}),h.jsxs("button",{"data-tooltip-id":"explorer-more-actions",className:re(se.tableAction,se.blue),children:[h.jsx("span",{className:"whitespace-nowrap",children:"Options"}),h.jsx(gr,{width:16,height:16,className:"rotate-90"})]}),h.jsxs(ih,{id:"explorer-more-actions",className:"z-10 shadow-md flex flex-col",clickable:!0,variant:"light",opacity:1,children:[h.jsxs("button",{"data-tooltip-id":"default","data-tooltip-content":"Manage filters",onClick:()=>Un("filters"),className:re(se.tableAction,se.modal,se.blue),children:[h.jsx("span",{children:"Filters"}),h.jsx("span",{className:"hotkey",children:"F"})]}),h.jsxs("button",{"data-tooltip-id":"default","data-tooltip-content":"Join tables",onClick:()=>Un("joins"),className:re(se.tableAction,se.modal,se.blue),children:[h.jsx("span",{children:"Joins"}),h.jsx("span",{className:"hotkey",children:"J"})]}),h.jsxs("button",{onClick:()=>Un("columns"),className:re(se.tableAction,se.modal,se.blue,"justify-between"),children:[h.jsx("span",{children:"Columns"}),h.jsx("span",{className:"hotkey",children:"C"})]}),h.jsxs("button",{onClick:()=>Un("groupBy"),className:re(se.tableAction,se.modal,se.blue,"justify-between"),children:[h.jsx("span",{children:"Group by"}),h.jsx("span",{className:"hotkey",children:"G"})]}),h.jsxs("button",{onClick:()=>Un("aggregate"),className:re(se.tableAction,se.modal,se.blue,"justify-between"),children:[h.jsx("span",{children:"Aggregate"}),h.jsx("span",{className:"hotkey",children:"A"})]}),u&&h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"h-0.5 my-2 bg-gray-100"}),h.jsxs("button",{onClick:p,className:re(se.tableAction,se.modal,se.blue),children:[h.jsx("span",{children:"Save query"}),h.jsx("span",{className:"hotkey",children:"S"})]}),i?.allowInsert===!0&&h.jsx("button",{onClick:m,className:re(se.tableAction,se.modal,se.blue),children:"Insert new row"})]})]})]})}const i_=[5,10,20,50,100,200];function r_(){const{page:n,size:l,setPage:i,setSize:r}=VC(),{data:u,refetch:c,isFetching:d}=b.useContext(Ra),{name:m}=b.useContext(vl),{state:p}=b.useContext(Zt),y=si(),g=Et(),x=()=>{y.mutateAsync({name:m,opts:p}).then(T=>{g(`${Ye.workbench.path}/tab/${T.id}`)})},E=()=>{if(u?.result.queryHistoryId){const T=new URL(window.location.href);T.pathname=Ye.share.path,T.searchParams.set("shareId",u.result.queryHistoryId),navigator.clipboard.writeText(T.toString()),sn.success("Share link copied to clipboard")}};on("d",x);const C=n*l,w=!d&&!!u?.result.hasMore,j=u?.result.rows.length||0,N=()=>{n>0&&i(n-1)},_=()=>{w&&i(n+1)};return h.jsxs("div",{className:se.tableConfig,children:[h.jsxs("span",{"data-tooltip-id":"rows-num",className:se.paginationIndicator,children:[C+1," - ",C+j,w&&"+"]}),h.jsx("span",{"data-tooltip-content":"Previous page","data-tooltip-id":"default",className:re(se.tableAction,se.blue,n<1&&"opacity-30"),onClick:N,role:"button",children:h.jsx(gr,{width:16,height:16,className:"rotate-180"})}),h.jsx("span",{"data-tooltip-content":"Next page","data-tooltip-id":"default",className:re(se.tableAction,w?se.blue:"opacity-30"),onClick:_,role:"button",children:h.jsx(gr,{width:16,height:16})}),h.jsx("span",{"data-tooltip-content":"Refresh data","data-tooltip-id":"default",className:re(se.tableAction,se.blue),onClick:()=>c(),role:"button",children:h.jsx(B6,{width:16,height:16})}),h.jsx("span",{"data-tooltip-content":"Share query","data-tooltip-id":"default",className:re(se.tableAction,se.blue),onClick:E,role:"button",children:h.jsx(Q6,{width:16,height:16})}),h.jsx("span",{"data-tooltip-content":"Duplicate tab","data-tooltip-id":"default",className:re(se.tableAction,se.blue),onClick:x,role:"button",children:h.jsx(H6,{width:16,height:16})}),h.jsx(ih,{id:"rows-num",className:"z-10 shadow-md flex gap-1",clickable:!0,variant:"light",opacity:1,children:i_.map(T=>h.jsx("button",{onClick:()=>r(T,!0),className:re(se.tableAction,se.blue,T===l&&se.selectedSize),children:h.jsx("span",{children:T})},T))})]})}const o_="_drop-container_3xdxk_2",u_="_item_3xdxk_2",Fy={dropContainer:o_,item:u_},Nd=({dataSourceId:n,focusId:l,placeholder:i="Column",onChange:r,value:u,autoFocus:c,allowTables:d})=>{const{data:m}=ai(n),p=b.useRef(null),y=b.useMemo(()=>{if(!m)return[];let _=m;return d&&(_=m.filter(T=>d.includes(T.tableName))),_.flatMap(T=>T.columns.map(D=>({value:T.tableName+"."+D.name,label:D.name,table:T.tableName,searchValue:D.name.toLowerCase()})))},[m,d]),g=b.useMemo(()=>{const _=u.toLowerCase()||"",T=[];for(let D=0;D<y.length&&T.length<10;D++)y[D].searchValue.includes(_)&&T.push(y[D]);return T},[y,u]),[x,E]=b.useState(!1),[C,w]=b.useState(0),j=_=>{if(_.key==="ArrowDown")_.preventDefault(),w(T=>(T+1)%g.length);else if(_.key==="ArrowUp")_.preventDefault(),w(T=>(T-1+g.length)%g.length);else if(_.key==="Enter"&&C>=0&&C<g.length){_.preventDefault();const T=g[C].value;E(!1);const D=y.findIndex(H=>H.value===T)>-1;r(g[C]?.value||T,D,!0)}};b.useEffect(()=>{const _=p.current?.querySelector('[data-is-active="true"]');_&&_.scrollIntoView({behavior:"smooth",block:"nearest"})},[C]);const N=_=>{const T=_.currentTarget.value,D=y.findIndex(H=>H.value===T)>-1;r(T,D,!1)};return h.jsxs("div",{className:"relative",onFocus:()=>E(!0),onBlur:()=>E(!1),children:[h.jsx("input",{autoFocus:c,onKeyDown:j,value:u,onChange:N,className:"input w-full",placeholder:i,"data-focus":l}),x&&g.length>0&&h.jsx("div",{className:Fy.dropContainer,ref:p,tabIndex:-1,children:g.map((_,T)=>h.jsxs("div",{className:Fy.item,"data-is-active":C===T,onMouseDownCapture:D=>{D.preventDefault(),E(!1),r(_.value,!0,!0)},children:[h.jsx("span",{className:"text-xs font-semibold truncate",children:_.table}),h.jsx("p",{className:"truncate text-sm",children:_.label})]},T))})]})},c_="_drop-container_149or_2",f_="_item_149or_2",Zy={dropContainer:c_,item:f_};function d_(n){return E4.includes(n)?x4:C4.includes(n)?b4:_4.includes(n)?S4:Kd}const h_=({value:n,onChange:l,autoFocus:i,focusId:r,colType:u})=>{const c=b.useMemo(()=>{const E=n.toLowerCase()||"";return d_(u||"").filter(C=>C.label.includes(E))},[n,u]),d=b.useRef(null),[m,p]=b.useState(!1),[y,g]=b.useState(0),x=E=>{E.key==="ArrowDown"?(E.preventDefault(),g(C=>(C+1)%c.length)):E.key==="ArrowUp"?(E.preventDefault(),g(C=>(C-1+c.length)%c.length)):E.key==="Enter"&&(y>=0&&y<c.length?(E.preventDefault(),p(!1),l(c[y]?.label||"",!0)):l(n,!0))};return b.useEffect(()=>{const E=d.current?.querySelector('[data-is-active="true"]');E&&E.scrollIntoView({behavior:"smooth",block:"nearest"})},[y]),h.jsxs("div",{className:"relative",children:[h.jsx("input",{onKeyDown:x,value:n,onChange:E=>l(E.target.value,!1),className:"input w-full",placeholder:"Operator",autoFocus:i,onFocus:()=>p(!0),onBlur:()=>p(!1),"data-focus":r}),m&&c.length>0&&h.jsx("ul",{className:Zy.dropContainer,ref:d,tabIndex:-1,children:c.map((E,C)=>h.jsx("li",{className:Zy.item,"data-is-active":y===C,onMouseDownCapture:w=>{w.preventDefault(),p(!1),l(E.label,!0)},children:E.label},C))})]})},Gv=()=>{const{state:n,setState:l}=b.useContext(Zt),i=b.useCallback((u,c=!1)=>{l(d=>({...d,page:c?0:d.page,filters:u}))},[l]),r=b.useCallback(u=>{l(c=>({...c,filters:c.filters.filter(d=>d.id!==u)}))},[l]);return{filters:n.filters,removeFilter:r,setFilters:i}},m_="_actions_1r6uv_2",p_="_filter-actions_1r6uv_2",Xv={actions:m_,filterActions:p_},y_=["=","<",">",">=","<>","!=","<="];function v_(n){for(let l=0;l<n.length;l++){const i=n[l];if(!i.operator.length&&!i.value.length&&!i.column.length)continue;if(!i.column.includes("."))return sn.error(`Filter #${l+1} has invalid column value`),!1;const r=$d[i.operator];if(!r)return sn.error(`Filter #${l+1} has invalid operator`),!1;if(i.isColumnRef&&!y_.includes(r))return sn.error(`Filter #${l+1} cannot reference another column because it uses '${i.operator}' operator`),!1}return!0}function g_(n){const l=[];return n.forEach(i=>{if(!i.operator.length||!i.column.length||i.operator!=="is null"&&i.operator!=="is not null"&&!i.value.length)return;const r=$d[i.operator];l.push({id:i.id,value:i.isColumnRef?[{value:i.value,isColumn:!0}]:w4(r,i.value),operator:r,column:i.column,isEnabled:i.isEnabled,connector:"AND"})}),l}function b_(n){let l="";if(n.value)for(let i=0;i<n.value.length;i++)l+=n.value[i].value,i<n.value.length-1&&(l+=", ");return l}const x_=({filter:n,dataSourceId:l,allowedTables:i,inspections:r,autoFocus:u,onChangeColumn:c,onChangeOperator:d,onChangeValue:m,onRemoveFilter:p,triggerIsEnabled:y,onIsColumnChange:g})=>{const x=b.useMemo(()=>{if(!r)return"";let E=null;for(const C of r)for(const w of C.columns)C.tableName+"."+w.name===n.column&&(E=w);return E?.type?E.type:""},[n.column,r]);return h.jsxs("div",{className:"flex gap-2 items-center",children:[h.jsx("label",{children:h.jsx("input",{type:"checkbox",checked:n.isEnabled!==!1,onClick:()=>y(n.id)})}),h.jsx("label",{className:"w-full",children:h.jsx(Nd,{dataSourceId:l,onChange:E=>c(n.id,E),value:n.column,allowTables:i,focusId:"column",autoFocus:u})}),h.jsx("label",{children:h.jsx(h_,{onChange:E=>d(n.id,E),focusId:"operator",colType:x,value:n.operator})}),pv($d[n.operator])&&h.jsx("label",{className:"w-full",children:n.isColumnRef?h.jsx(Nd,{dataSourceId:l,onChange:E=>m(n.id,E),value:n.value,allowTables:i,focusId:"value",placeholder:"Search column"}):h.jsx("input",{className:"input w-full",placeholder:"Filter value",value:n.value,onChange:E=>m(n.id,E.currentTarget.value),"data-focus":"value"})}),h.jsxs("div",{className:Xv.filterActions,children:[h.jsx("button",{tabIndex:-1,"data-tooltip-id":"default","data-tooltip-content":"If enabled, the value will reference another column instead of being raw string",className:re("p-0.5 cursor-pointer rounded-lg border",n.isColumnRef?"bg-blue-50 border-blue-200":"bg-white border-white"),onClick:()=>g(n.id,!n.isColumnRef),children:"🏷️"}),h.jsx("button",{tabIndex:-1,"data-tooltip-id":"default","data-tooltip-content":"Remove filter",className:"p-0.5 text-sm cursor-pointer",onClick:()=>p(n.id),children:h.jsx(Pl,{width:20,height:20,className:"text-red-600"})})]})]})},S_=()=>{const{state:n}=b.useContext(Zt),{setFilters:l}=Gv(),i=_u(N=>N.filters),{data:r}=ai(n.dataSourceId),u=b.useMemo(()=>[n.table,...n.joins.map(N=>N.table)],[n.table,n.joins]),[c,d]=b.useState([]),m=(N,_)=>{d(T=>[...T.map(D=>D.id===N?{...D,column:_}:D)])},p=(N,_)=>{d(T=>[...T.map(D=>D.id===N?{...D,operator:_}:D)])},y=(N,_)=>{d(T=>[...T.map(D=>D.id===N?{...D,value:_}:D)])},g=()=>{d(N=>[...N,{id:dl(),value:"",column:"",operator:"",isColumnRef:!1,isEnabled:!0}])},x=(N,_)=>{d(T=>[...T.map(D=>D.id===N?{...D,isColumnRef:_}:D)])},E=N=>{d(_=>_.filter(T=>T.id!==N))},C=()=>Nu("filters"),w=()=>{v_(c)&&(l(g_(c)),C())},j=N=>{d(_=>_.map(T=>T.id===N?{...T,isEnabled:!T.isEnabled}:T))};return b.useEffect(()=>{i&&d(()=>{const N=n.filters.map(_=>({id:_.id,value:b_(_),column:_.column,operator:mv[_.operator],isColumnRef:!!_.value?.[0]?.isColumn,isEnabled:_.isEnabled}));return N.push({id:dl(),value:"",column:"",operator:"",isColumnRef:!1,isEnabled:!0}),N})},[i]),on("f",()=>{du("filters")}),on("ctrl+f",()=>{alert("Save filters")}),h.jsxs(cn,{isVisible:i,onClose:C,portal:!0,onClosed:()=>d([]),children:[h.jsx(aa,{onClick:C}),h.jsx("h2",{className:"text-lg font-semibold",children:"Filters"}),h.jsxs("div",{className:"flex gap-4 flex-col w-full lg:w-lg my-4",children:[c.length<1&&h.jsx("p",{className:"p-1 text-center rounded-lg bg-gray-50 border border-gray-200",children:"No filters"}),c.map((N,_)=>h.jsx(x_,{filter:N,dataSourceId:n.dataSourceId,allowedTables:u,inspections:r||[],onChangeColumn:m,onChangeOperator:p,onChangeValue:y,onRemoveFilter:E,onIsColumnChange:x,triggerIsEnabled:j,autoFocus:_===c.length-1},N.id))]}),h.jsxs("div",{className:Xv.actions,children:[h.jsx("button",{className:"button tertiary",onClick:g,children:"Add filter"}),h.jsx("button",{className:"button primary",onClick:w,children:"Apply filters"})]})]})},w_="_join-modal_1pmtt_2",E_={joinModal:w_},C_=(n,l)=>n.type!==l.type||n.on!==l.on||n.table!==l.table,__=(n,l)=>n.type===l.type&&n.on===l.on&&n.table===l.table,Fv=()=>{const{state:n,setState:l}=b.useContext(Zt),i=b.useCallback(r=>{l(u=>{const c=u.joins;if(c.some(m=>__(m,r))){const m=r.table+".";return{...u,joins:c.filter(p=>C_(p,r)),columns:u.columns.filter(p=>!p.value.startsWith(m)),groupBy:u.groupBy.filter(p=>!p.value.startsWith(m)),orderBy:u.orderBy.filter(p=>!p.column.startsWith(m)),aggregations:u.aggregations.filter(p=>!p.value.startsWith(m)),filters:u.filters.filter(p=>!p.column.startsWith(m))}}return{...u,joins:[...c,r]}})},[l]);return{joins:n.joins,toggle:i}},N_=()=>{const{isFetching:n}=b.useContext(Ra),l=_u(p=>p.joins),{toggle:i}=Fv(),{availableJoins:r}=b.useContext(vl),[u,c]=b.useState(""),d=b.useMemo(()=>{const p=u.toLowerCase();return r.filter(y=>y.on.toTable.toLowerCase().includes(p))},[r,u]),m=()=>Nu("joins");return on("j",()=>{r.length>0?Un("joins"):sn.error("No available tables to join")}),h.jsxs(cn,{isVisible:l,onClose:m,portal:!0,children:[h.jsx(aa,{onClick:m}),h.jsxs("div",{className:E_.joinModal,children:[h.jsx("h2",{className:"text-lg font-semibold mb-4",children:"Join table"}),r.length>0?h.jsx("input",{className:"input w-full",placeholder:"Filter",autoFocus:!0,onChange:p=>c(p.target.value),value:u,disabled:n}):h.jsx(wt,{variant:"warning",children:h.jsx("p",{className:"text-sm truncate",children:"There is nothing else to join"})}),h.jsx("div",{className:`flex flex-col mt-2 overflow-y-auto ${n?"opacity-40":""}`,children:d.map(p=>h.jsx(Tv,{hook:p,onClick:()=>{n||(i({table:p.on.toTable,type:"LEFT",on:p.where}),c(""),m())}},p.where))})]})]})};function T_(n){return n.reduce((l,i)=>(l[i]=!0,l),{})}function Py(n){return n.reduce((l,i)=>(l[i]=!0,l),{})}const j_="_container_1t5ww_2",A_="_column-label_1t5ww_2",R_="_not-active_1t5ww_2",su={container:j_,columnLabel:A_,notActive:R_};function O_(n){if(!n)return[];const l={};return n.forEach(i=>{l[i.table]?l[i.table].push({value:i.full,ogColumn:i.column,label:ol(i.column),type:i.type}):l[i.table]=[{value:i.full,ogColumn:i.column,label:ol(i.column),type:i.type}],N4[i.type]&&["YEAR","MONTH","DAY"].forEach(r=>{l[i.table].push({value:r+" "+i.full,ogColumn:i.column,label:r+" "+ol(i.column),type:"number",nested:!0})})}),Object.entries(l).reduce((i,[r,u])=>(i.push({name:ol(r),columns:u}),i),[])}function D_(n,l){const i=l.toLowerCase();return n.map(r=>{const u=r.columns.filter(c=>c.label.toLowerCase().includes(i)||c.ogColumn.toLowerCase().includes(i));return{...r,columns:u}}).filter(r=>r.columns.length>0)}const M_=({column:n,selected:l,onCheck:i})=>h.jsxs("label",{className:re(su.columnLabel,l?su.active:su.notActive,n.nested&&"pl-5!"),children:[h.jsx("input",{type:"checkbox",checked:l[n.value],name:n.value,onChange:i}),h.jsxs("p",{className:"flex justify-between w-full",children:[h.jsx("span",{"data-tooltip-content":n.value,"data-tooltip-id":"default",children:n.label}),h.jsx("span",{className:"text-blue-600",children:n.type})]})]},n.value),U_={columns:"c",groupBy:"g"},Jy=({mode:n})=>{const l=_u(_=>_[n]),{allColumns:i}=b.useContext(vl),{state:r,setState:u}=b.useContext(Zt),[c,d]=b.useState({}),[m,p]=b.useState(""),y=b.useMemo(()=>O_(i),[i]),g=r.aggregations.length>0||r.groupBy.length>0,x=b.useMemo(()=>m?D_(y,m):y,[m,y]),E=_=>{d(T=>({...T,[_.target.name]:_.target.checked}))},C=_=>{const T=_.target.checked;d(D=>{for(const H of i)D[H.full]=T;return{...D}})},w=()=>{Nu(n)},j=()=>{const _=[];for(const[T,D]of Object.entries(c))if(D){const[H,G]=T.split(" ");_.push({value:G||H,fn:G?H:void 0})}u(T=>({...T,[n]:_})),w()},N=b.useMemo(()=>{for(const _ of i)if(!c[_.full])return!1;return!0},[c,i]);return on(U_[n],()=>{n==="columns"?g?sn.error("Columns are ignored when there is at least one aggregation or group by"):du("columns"):du("groupBy")}),b.useEffect(()=>{if(!l){d({});return}d(()=>T_(r[n].map(_=>_.fn?_.fn+" "+_.value:_.value)))},[l,d]),h.jsxs(cn,{isVisible:l,onClose:w,portal:!0,children:[h.jsx(aa,{onClick:w}),h.jsxs("div",{className:su.container,children:[h.jsx("h2",{className:"text-lg font-semibold",children:n==="groupBy"?"Group by":"Show columns"}),h.jsx("input",{autoFocus:!0,className:"input my-2",placeholder:"Filter",value:m,onChange:_=>p(_.target.value)}),h.jsx("div",{className:"overflow-y-auto",children:x.map(_=>h.jsxs("div",{className:"my-2",children:[h.jsxs("p",{className:"font-semibold sticky top-0 bg-white p-1 z-1",children:["📄 ",_.name]}),_.columns.map(T=>h.jsx(M_,{column:T,selected:c,onCheck:E},T.value))]},_.name))}),h.jsxs("div",{className:"flex justify-end gap-2 mt-2",children:[h.jsxs("label",{className:"button tertiary flex gap-2 items-center",children:[h.jsx("input",{type:"checkbox",checked:N,onChange:C}),h.jsx("span",{children:"Select all"})]}),h.jsx("span",{className:"flex-1"}),h.jsx("button",{className:"button tertiary",onClick:w,children:"Cancel"}),h.jsx("button",{className:"button primary",onClick:j,children:"Apply"})]})]})]})},L_="_options-container_ss0hd_2",z_={optionsContainer:L_},nd="COUNT all",k_=()=>{const n=_u(w=>w.aggregate),{dataSourceId:l}=b.useContext(vl),{setState:i,state:r}=b.useContext(Zt),{data:u}=b.useContext(Ra),[c,d]=b.useState({fn:"",col:""}),m=w=>d({...c,fn:w.currentTarget.value}),p=w=>d({...c,col:w}),y=()=>Nu("aggregate"),g=()=>{const w=c.fn===nd?{value:"*",fn:"COUNT"}:{fn:c.fn,value:c.col,distinct:c.fn==="COUNT"};i(j=>({...j,aggregations:[...j.aggregations,w]}))},x=c.fn===nd,E=x?!1:!c.col||!c.fn,C=w=>{const j=yv(w);i(N=>({...N,aggregations:N.aggregations.filter(_=>_.fn!==w.fn||_.value!==w.value),orderBy:N.orderBy.filter(_=>_.column!==j)}))};return on("a",()=>{du("aggregate")}),h.jsxs(cn,{isVisible:n,onClose:y,backdropClose:!0,portal:!0,children:[h.jsx(aa,{onClick:y}),h.jsxs("div",{children:[h.jsx("h2",{className:"text-lg font-semibold",children:"Aggregate"}),hl(r.aggregations.length,0)&&h.jsx("div",{className:"flex flex-col gap-1 mt-4",children:r.aggregations.map((w,j)=>h.jsxs("p",{className:"p-2 rounded-md bg-gray-50 flex items-center justify-between",children:[h.jsx("span",{children:au(w)}),h.jsx("button",{tabIndex:-1,"data-tooltip-id":"default","data-tooltip-content":"Remove aggregation",className:"p-0.5 text-sm cursor-pointer",onClick:()=>C(w),children:h.jsx(Pl,{width:20,height:20,className:"text-red-600"})})]},j))}),h.jsxs("div",{className:z_.optionsContainer,children:[h.jsxs("label",{className:re(x&&"col-span-2"),children:[h.jsx("p",{className:"font-semibold text-xs",children:"Function"}),h.jsxs("select",{className:"input w-full",value:c.fn,onChange:m,autoFocus:!0,children:[h.jsx("option",{value:"",disabled:!0,children:"Select function"}),h.jsx("option",{value:nd,children:"Count all rows"}),h.jsx("option",{value:"COUNT",children:"Count"}),h.jsx("option",{value:"SUM",children:"Sum"}),h.jsx("option",{value:"MAX",children:"Max"}),h.jsx("option",{value:"MIN",children:"Min"}),h.jsx("option",{value:"AVG",children:"Avg"})]})]}),!x&&h.jsxs("label",{children:[h.jsx("p",{className:"font-semibold text-xs",children:"Column"}),h.jsx(Nd,{dataSourceId:l,allowTables:u?.result.tables||[],onChange:p,value:c.col})]}),h.jsx("button",{className:"button primary",disabled:E,onClick:g,children:"Add"})]})]})]})},q_="_container_n68f7_2",B_="_yellow-pill_n68f7_2 _pill_n68f7_2",H_="_yellow-outline-pill_n68f7_2 _pill_n68f7_2",Q_="_green-pill_n68f7_2 _pill_n68f7_2",Y_="_blue-pill_n68f7_2 _pill_n68f7_2",V_="_blue-outline-pill_n68f7_2 _pill_n68f7_2",K_="_purple-pill_n68f7_2 _pill_n68f7_2",$_="_red-pill_n68f7_2 _pill_n68f7_2",G_="_black-pill_n68f7_2 _pill_n68f7_2",X_="_disabled-pill_n68f7_2",Jn={container:q_,yellowPill:B_,yellowOutlinePill:H_,greenPill:Q_,bluePill:Y_,blueOutlinePill:V_,purplePill:K_,redPill:$_,blackPill:G_,disabledPill:X_},Iy=n=>b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...n},b.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32,d:"M256 112v288M400 256H112"}));function Zv(n,l=500,i){const[r,u]=b.useState(n),c=b.useRef(i);return c.current=i,b.useEffect(()=>{const d=setTimeout(()=>{u(n),c.current&&c.current(n)},l);return()=>clearTimeout(d)},[n,l]),r}function F_(n){return!(n===!0||n===void 0)}const Z_=()=>{const{state:{table:n,dataSourceId:l,aggregations:i,columns:r,groupBy:u}}=b.useContext(Zt),{filters:c,setFilters:d,removeFilter:m}=Gv(),{toggle:p,joins:y}=Fv(),{data:g}=Cu(l),x=()=>Un("joins"),E=()=>Un("filters"),C=()=>Un("aggregate"),w=()=>Un("columns"),j=()=>Un("groupBy"),N=D=>{d(c.map(H=>({...H,isEnabled:D===H.id?F_(H.isEnabled):H.isEnabled})),!0)},_=D=>{D.preventDefault(),D.stopPropagation(),p(y[y.length-1])},T=D=>H=>{H.preventDefault(),H.stopPropagation(),m(D)};return h.jsxs("div",{className:Jn.container,children:[g&&h.jsxs("button",{onClick:x,className:Jn.greenPill,"data-tooltip-id":"default","data-tooltip-content":n,children:[h.jsx(ii,{size:18,type:g.dbType}),h.jsx("p",{className:"text-sm",children:g.name}),h.jsx(gr,{width:12,height:12}),h.jsx("p",{className:"text-sm",children:n})]}),h.jsxs("button",{onClick:x,className:Jn.yellowOutlinePill,"data-tooltip-id":"default","data-tooltip-content":"Join table, hotkey J",children:[h.jsx(Iy,{width:18,height:18}),h.jsx("p",{className:"text-sm",children:"Table"})]}),y.map((D,H)=>h.jsxs("button",{onClick:x,className:Jn.yellowPill,"data-tooltip-id":"default","data-tooltip-content":`Joins ${D.table} on ${D.on}`,children:[h.jsx("p",{className:"text-sm",children:D.table}),H===y.length-1&&h.jsx(Pl,{onClick:_,width:18,height:18})]},D.table)),h.jsxs("button",{onClick:E,className:Jn.blueOutlinePill,"data-tooltip-id":"default","data-tooltip-content":"Add filters, hotkey F",children:[h.jsx(Iy,{width:18,height:18}),h.jsx("p",{className:"text-sm",children:"Filter"})]}),c.map(D=>h.jsxs("button",{onClick:()=>N(D.id),onAuxClick:()=>m(D.id),className:re(Jn.bluePill,D.isEnabled===!1&&Jn.disabledPill),"data-tooltip-id":"default","data-tooltip-content":yE(D),children:[h.jsx("p",{className:"text-sm",children:D.column}),h.jsx("p",{className:"text-sm",children:D.operator}),h.jsx("p",{className:"text-sm",children:vE(D)}),h.jsx(Pl,{onClick:T(D.id),width:18,height:18})]},D.id)),i.map(D=>h.jsx("button",{onClick:C,className:re(Jn.purplePill),"data-tooltip-id":"default","data-tooltip-content":au(D),children:h.jsx("p",{className:"text-sm",children:au(D)})},au(D))),r.length>0&&h.jsx("button",{onClick:w,className:re(Jn.redPill),"data-tooltip-id":"default","data-tooltip-content":"Has hidden columns",children:h.jsx("p",{className:"text-sm",children:"Hidden columns"})}),u.length>0&&h.jsx("button",{onClick:j,className:re(Jn.blackPill),"data-tooltip-id":"default","data-tooltip-content":"Has GROUP BY",children:h.jsx("p",{className:"text-sm",children:"GROUP BY"})}),h.jsx(P_,{})]})};function P_(){const{state:n,setState:l}=b.useContext(Zt),[i,r]=b.useState(()=>n.searchAll);return on("k",()=>{Or("Search all text values for",n.searchAll||"",{type:"info",message:"This will search all text values using LIKE operator (numbers, dates and other non string values are not searched)."}).then(c=>{c!==void 0&&(l(d=>({...d,searchAll:c.length>0?c:void 0})),r(c.length>0?c:void 0))})}),Zv(i,500,c=>{l(d=>({...d,searchAll:c&&c.length>0?c:void 0}))}),h.jsx("input",{className:"input text-sm","data-tooltip-id":"default","data-tooltip-content":"Search text in all columns. Can be slow when using a lot of columns.",placeholder:"Search text in all columns",value:i||"",onChange:c=>r(c.currentTarget.value)})}const J_=({options:n,updater:l,name:i,tabId:r})=>{const u=A4(n,l),c=U4(r,u.state),d=j4(c.data,u.state.dataSourceId,i,r);return c.isError?h.jsx("div",{className:"flex-1",children:h.jsx(wt,{variant:"danger",children:"Failed to load query"})}):h.jsx(vl,{value:d,children:h.jsx(Zt,{value:u,children:h.jsxs(Ra,{value:c,children:[h.jsx(l_,{}),h.jsx(Z_,{}),h.jsxs("div",{className:"flex-1 flex overflow-hidden border-t border-gray-200",children:[h.jsx("div",{className:"flex-1 overflow-auto pb-24 lg:pb-12 no-scrollbar",children:h.jsx(YC,{})}),h.jsx(S_,{}),h.jsx(N_,{}),h.jsx(Jy,{mode:"columns"}),h.jsx(Jy,{mode:"groupBy"}),h.jsx(k_,{})]})]})})})},Pv=()=>h.jsxs("div",{role:"status",children:[h.jsxs("svg",{"aria-hidden":"true",className:"w-8 h-8 text-gray-200 animate-spin dark:text-gray-600 fill-blue-600",viewBox:"0 0 100 101",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[h.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"}),h.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"})]}),h.jsx("span",{className:"sr-only",children:"Loading..."})]}),I_=({id:n})=>{const{data:l}=O4(n),i=b.useCallback(r=>{if(!l)return;const u=r($s(l.opts));rt.setQueryData(["workbench-tabs",l.id],{...l,opts:{...l.opts,...u}})},[l]);return l?h.jsx(J_,{updater:i,options:l.opts,name:l.name,tabId:l.id}):h.jsx("div",{className:"flex-1 flex justify-center items-center",children:h.jsx(Pv,{})})},W_=n=>{setTimeout(l=>{const i=document.querySelector(`[data-tab-id="${l}"]`);i&&i.scrollIntoView({behavior:"smooth"})},50,n)},e5=()=>{const{id:n}=Z2(),l=Et(),{data:i}=Xd(),r=D4(),u=Ev(Id.laptop),c=p=>{if(p===n&&i){if(i.length===1)return l(Ye.home.path);if(i.length>1){const y=i.find(g=>g.id!==p);if(y)return l(`/workbench/tab/${y.id}`)}}},d=p=>{p.stopPropagation(),p.preventDefault();const y=p.currentTarget.getAttribute("data-tab-id");y&&(r.mutate(y),c(y))},m=p=>{r.mutate(p),c(p)};return b.useEffect(()=>{n&&W_(n)},[n]),h.jsxs("div",{className:"h-screen max-h-screen bg-(--bg) flex flex-col",children:[n&&h.jsx(I_,{id:n}),h.jsx("div",{className:re(cr.tabs,"no-scrollbar",!u&&cr.mobile),children:i?.map(p=>h.jsxs("div",{onClick:()=>l(`${Ye.workbench.path}/tab/${p.id}`),className:re(cr.tab,p.id===n&&cr.active),"data-tooltip-id":"default","data-tab-id":p.id,"data-tooltip-content":p.name,onAuxClick:()=>m(p.id),children:[h.jsxs("span",{className:"truncate w-full",children:["🛠️ ",p.name]}),h.jsx("button",{"data-tab-id":p.id,className:cr.closeButton,onClick:d,children:h.jsx(Pl,{width:20,height:20})})]},p.id))})]})},t5="_root_1e5nd_2",n5="_down_1e5nd_2",a5="_chevron_1e5nd_2",l5="_table-name-container_1e5nd_2",s5="_link_1e5nd_2",i5="_table-name_1e5nd_2",r5="_ul_1e5nd_2",o5="_column-type_1e5nd_2",u5="_action-blue_1e5nd_2 _action_1e5nd_2",c5="_action-red_1e5nd_2 _action_1e5nd_2",jn={root:t5,down:n5,chevron:a5,tableNameContainer:l5,link:s5,tableName:i5,ul:r5,columnType:o5,actionBlue:u5,actionRed:c5},[GN,f5]=un(!1),Jv=()=>f5(!1),d5="_sidebar_1dc7f_2",h5="_sidebar-visible_1dc7f_2",m5="_sidebar-container_1dc7f_2",p5="_sidebar-invisible_1dc7f_2",y5="_backdrop_1dc7f_2",fr={sidebar:d5,sidebarVisible:h5,sidebarContainer:m5,sidebarInvisible:p5,backdrop:y5},Iv=({children:n,backdropClose:l,isVisible:i,onClose:r,onClosed:u,contentClassName:c})=>{const[d,m]=b.useState(!1),p=b.useRef(r);p.current=r;const y=()=>{l&&r()},g=x=>{i||getComputedStyle(x.currentTarget).opacity==="0"&&(m(!1),u&&u())};return b.useEffect(()=>{i&&m(!0)},[i]),b.useEffect(()=>{const x=E=>{i&&E.key==="Escape"&&p.current()};return window.addEventListener("keydown",x),()=>{window.removeEventListener("keydown",x)}},[i]),h.jsxs("div",{onTransitionEnd:g,className:re(fr.sidebar,i?fr.sidebarVisible:fr.sidebarInvisible),children:[h.jsx("div",{onClick:y,className:fr.backdrop}),h.jsx("div",{className:re(fr.sidebarContainer,c),children:d&&n})]})},v5=new Intl.DateTimeFormat("en",{dateStyle:"full",timeStyle:"long"});function g5(n,l){if(l&&n.toLowerCase().includes(l))return"bg-yellow-200"}const b5=({insp:n,filter:l,expanded:i})=>{const r=b.useMemo(()=>i?n.columns:l.length<1?[]:n.columns.filter(u=>u.name.toLowerCase().includes(l)),[n,l,i]);return h.jsx("ul",{className:jn.ul,children:r.map(u=>h.jsx(h.Fragment,{children:h.jsxs("li",{children:[u.isPrimary?"🔐":"🏷️"," ",h.jsx("span",{className:g5(u.name,l),children:u.name})," ",h.jsxs("span",{className:jn.columnType,children:["[",u.type,"]"]}),u.ref&&h.jsxs("span",{children:[" ➡️ ",h.jsx("span",{className:jn.columnType,children:u.ref.table}),".",u.ref.field]})]},u.name+u.type)}))},n.id)};function x5({id:n}){const{data:l}=Cu(n),{data:i}=ai(n),r=Et(),u=r4(),c=fv(),d=o4(),m=si(),p=b.useMemo(()=>l?.lastInspected?v5.format(new Date(l.lastInspected)):"--",[l]),[y,g]=b.useState({}),[x,E]=b.useState(""),[C,w]=b.useState("table"),j=Ar($t.EDITOR),N=x.toLowerCase(),_=b.useMemo(()=>{if(!N||!i)return i||[];const Z=[];for(const te of i){if(te.tableName.toLowerCase().includes(N)){Z.push(te);continue}C!=="table"&&te.columns.findIndex(ye=>ye.name.toLowerCase().includes(N))>=0&&Z.push(te)}return Z},[N,i,C]),T=Z=>{g(te=>({...te,[Z]:!te[Z]}))},D=Z=>{m.mutateAsync({name:Z,opts:$s({table:Z,dataSourceId:n})}).then(te=>{Gs(void 0),Jv(),r(`${Ye.workbench.path}/tab/${te.id}`)})},H=()=>{c.mutate(n)},G=async()=>{const Z=await Or("Enter name",l?.name);Z&&u.mutate({id:n,dataSource:{name:Z}})},V=async()=>{await Sv("Are you sure you want to delete this data source?")&&(d.mutate(n),Gs(void 0))},K=C==="column";return h.jsxs("div",{className:jn.root,children:[h.jsxs("div",{className:"sticky top-0 bg-white border-b border-gray-200 p-4",children:[h.jsxs("h3",{className:"page-head flex gap-2",children:[l&&h.jsx(ii,{size:32,type:l.dbType}),h.jsx("span",{className:"truncate",children:l?.name})]}),h.jsx("p",{className:"mt-2 text-xs text-gray-800",children:"Last DB inspection"}),h.jsx("p",{className:"text-sm font-semibold",children:p}),j&&h.jsxs("div",{className:"mt-2 flex gap-2",children:[h.jsx("button",{disabled:c.isPending,onClick:H,className:jn.actionBlue,children:"Refresh schema"}),h.jsx("button",{disabled:c.isPending,onClick:G,className:jn.actionBlue,children:"Rename"}),h.jsx("button",{disabled:c.isPending,onClick:V,className:jn.actionRed,children:"Delete"})]}),h.jsxs("div",{className:"flex gap-2 items-center mb-2 mt-4",children:[h.jsxs("select",{className:"input",value:C,onChange:Z=>w(Z.currentTarget.value),children:[h.jsx("option",{value:"table",children:"Table"}),h.jsx("option",{value:"column",children:"Column"})]}),h.jsx("input",{className:"input flex-1 bg-gray-50",placeholder:K?"Search column":"Search table",value:x,onChange:Z=>E(Z.target.value),autoFocus:!0})]})]}),h.jsx("div",{className:"overflow-y-auto p-4",children:_?.map(Z=>h.jsxs("div",{children:[h.jsxs("div",{className:jn.tableNameContainer,children:[h.jsx("button",{className:re(jn.chevron,y[Z.id]&&jn.down),onClick:()=>T(Z.id),children:h.jsx(gr,{width:16,height:16})}),h.jsx("button",{className:re(jn.tableName,"flex-1"),onClick:()=>T(Z.id),children:Z.tableName}),h.jsx("button",{className:jn.link,onClick:()=>D(Z.tableName),children:"↗️"})]}),(y[Z.id]||x.length>0)&&h.jsx(b5,{insp:Z,filter:K?N:"",expanded:y[Z.id]})]},Z.id))})]})}const S5=()=>{const n=iE(),[l,i]=b.useState(void 0);b.useEffect(()=>{n&&i(n)},[n]);const r=()=>Gs(void 0);return h.jsx(Iv,{isVisible:n!=null,onClose:r,onClosed:()=>i(void 0),backdropClose:!0,children:l&&h.jsx(x5,{id:l})})},w5="_search_14vf7_2",E5="_entry_14vf7_2",C5="_ds_14vf7_2",_5="_ds-container_14vf7_2",N5="_ds-entry_14vf7_2",T5="_enabled_14vf7_2",Qs={search:w5,entry:E5,ds:C5,dsContainer:_5,dsEntry:N5,enabled:T5};function j5(n,l,i){try{const r=i.getItem(n);if(r)return JSON.parse(r)}catch(r){console.warn("Failed to restore tabs",r)}return l}const A5=({storage:n=localStorage,localStorageKey:l,initialData:i})=>{const r=un(j5(l,i,n));return r[2].subscribe(u=>{n.setItem(l,JSON.stringify(u))}),r},[R5,O5]=A5({initialData:[],localStorageKey:"selected-data-sources-v1"}),D5=n=>O5(l=>{const i=l.indexOf(n);return i>-1?(l.splice(i,1),[...l]):[...l,n]}),M5={table:"📄",query:"📖",tab:"🛠️"},U5=({onTable:n,onQuery:l,onWorkbenchTab:i,autoFocus:r})=>{const[u,c]=b.useState(""),[d,m]=b.useState(-1),p=Zv(u,200),y=R5(),{data:g}=Bn(),{data:x}=Vd({teamId:g?.teamId}),E=b.useMemo(()=>{const T=[],D=Py(y);if(!x||x.length===0)return[];for(const H of x)D[H.id]&&T.push(H.id);return T},[y,x]),{data:C}=e4(p,{teamId:g?.teamId,selectedDataSources:E}),w=T=>{T.type==="table"?n(T.name,T.dataSourceId):T.type==="query"?l(T.id,T.dataSourceId):T.type==="tab"&&i(T.id,T.dataSourceId)},j=T=>{C&&(T.key==="ArrowDown"?(T.preventDefault(),m(D=>(D+1)%C.length)):T.key==="ArrowUp"?(T.preventDefault(),m(D=>(D-1+C.length)%C.length)):T.key==="Enter"&&d>=0&&C[d]?.name&&(T.preventDefault(),w(C[d])))},N=T=>{const D=T.currentTarget.dataset.tableId,H=C?.find(G=>G.id===D);H&&w(H)},_=b.useMemo(()=>Py(y),[y]);return h.jsxs("div",{className:"overflow-hidden flex flex-col w-full lg:w-lg",children:[hl(x?.length,0)&&h.jsx("div",{className:Qs.dsContainer,children:x.map(T=>h.jsxs("button",{className:re(Qs.dsEntry,_[T.id]&&Qs.enabled),onClick:()=>D5(T.id),children:[h.jsx(ii,{size:24,type:T.dbType}),h.jsx("span",{children:T.name})]},T.id))}),h.jsx("input",{className:Qs.search,placeholder:"Search table or saved query to start from",value:u,onChange:T=>c(T.target.value),onKeyDown:j,autoFocus:r}),hl(C?.length,0)&&h.jsx("div",{className:"overflow-y-auto max-h-full mt-2",children:C.map((T,D)=>h.jsxs("button",{className:Qs.entry,"data-is-active":d===D,"data-table-id":T.id,onClick:N,children:[h.jsxs("p",{className:"font-semibold truncate",children:[M5[T.type]," ",T.name]}),h.jsxs("p",{className:Qs.ds,children:["📦 ",T.dataSourceName]})]},T.id))})]})},L5=()=>{const n=z4(),l=(c,d)=>{n?.onConfirm("table",c,d)},i=(c,d)=>{n?.onConfirm("query",c,d)},r=(c,d)=>{n?.onConfirm("tab",c,d)},u=()=>{n?.onCancel()};return h.jsxs(cn,{isVisible:!!n,onClose:u,children:[h.jsx(aa,{onClick:u}),h.jsx(U5,{autoFocus:!0,onTable:l,onQuery:i,onWorkbenchTab:r})]})},z5=()=>{const n=jr("Hotkey"),l=Et(),{pathname:i}=qt(),{data:r}=Bn(),{data:u}=Xd(),c=i===Ye.home.path;on("n",()=>{r&&n()}),on("w",()=>{r&&(u&&u.length>0?l(`${Ye.workbench.path}/tab/${u[0].id}`):n())},{enabled:c}),on("h",()=>{Xs({show:!0})})},k5=()=>{const n=qt();b.useEffect(()=>{},[n.pathname])},[q5,Wv]=un(!1),ad=()=>Wv(!1),eg=()=>Wv(!0),B5=({repeatPassword:n,password:l})=>l.length<1?null:l.length<8?h.jsx(wt,{variant:"warning",children:"New password should be at least 8 characters long"}):l!==n?h.jsx(wt,{variant:"warning",children:"Repeat password should match new password"}):null,H5=()=>{const n=q5(),{data:l}=Bn(),{mutateAsync:i,isPending:r}=u4(),u=Et(),[{password:c,repeatPassword:d},{change:m,touched:p,reset:y}]=Rr({password:"",repeatPassword:""}),g=()=>{u("/"),Tr.logout().then(()=>{ad()})},x=()=>{i({password:c}).then(()=>{y(),sn.success("Password successfully updated!")})},E=c.length<8||c!==d||r,C=p.includes("password");return h.jsxs(cn,{isVisible:n,onClose:ad,children:[h.jsx(aa,{onClick:ad}),h.jsxs("div",{className:"w-full lg:w-lg flex flex-col gap-2",children:[h.jsx(xv,{children:"Account settings"}),h.jsxs("label",{children:[h.jsx("p",{className:"text-xs font-semibold mb-1",children:"Username"}),h.jsx("input",{className:"input w-full",readOnly:!0,disabled:!0,value:l?.username})]}),h.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[h.jsxs("label",{children:[h.jsx("p",{className:"text-xs font-semibold mb-1",children:"Change password"}),h.jsx("input",{className:"input w-full",type:"password",name:"newPassword",autoComplete:"new-password",value:c,onChange:m("password")})]}),h.jsxs("label",{children:[h.jsx("p",{className:"text-xs font-semibold mb-1",children:"Repeat password"}),h.jsx("input",{className:"input w-full",type:"password",value:d,onChange:m("repeatPassword")})]})]}),C&&h.jsx(B5,{password:c,repeatPassword:d}),h.jsxs("div",{className:"flex justify-end gap-2 mt-2",children:[h.jsx("button",{className:"button tertiary",disabled:E,onClick:x,children:"Update password"}),h.jsx("button",{className:"button danger",onClick:g,children:"Log out"})]})]})]})},[Q5,tg]=un(!1),ng=()=>tg(!0),Wy=()=>tg(!1),Y5=n=>Ft({queryKey:["team-users"],queryFn:async()=>{const{data:l}=await Te.get("/teams/"+n+"/users");return l.data},enabled:!!n}),V5=()=>vt({mutationFn:async({role:n,teamId:l,userId:i})=>(await Te.patch("/teams/"+l+"/user-role",{role:n,userId:i}),!0),onSuccess:()=>{rt.invalidateQueries({queryKey:["team-users"]})}}),K5=()=>vt({mutationFn:async({teamId:n,userId:l})=>(await Te.delete("/teams/"+n,{params:{userId:l}}),!0),onSuccess:()=>{rt.invalidateQueries({queryKey:["team-users"]})}}),$5="_user-entry_1vr21_2",G5="_select-container_1vr21_2",e1={userEntry:$5,selectContainer:G5},X5=()=>{const n=Q5(),{data:l}=Bn(),{data:i}=Y5(l?.teamId),{mutate:r,isPending:u}=c4(),{mutate:c,isPending:d}=V5(),{mutate:m,isPending:p}=K5(),[y,{change:g,reset:x}]=Rr({password:"",username:""}),E=()=>{r({username:y.username,password:y.password,teamId:l?.teamId||""}),x()},C=(_,T)=>{c({teamId:l.teamId,role:T,userId:_})},w=_=>{Sv("Are you sure you want to remove this user?").then(T=>{T&&m({userId:_,teamId:l.teamId})})},j=Ar($t.ADMIN),N=u||d||p;return h.jsxs(cn,{isVisible:n,onClose:Wy,backdropClose:!0,children:[h.jsx(aa,{onClick:Wy}),h.jsxs("div",{className:"w-full lg:w-lg flex flex-col overflow-hidden",children:[h.jsx(xv,{children:"Manage users"}),hl(i?.length,0)&&h.jsx("div",{className:"mt-4 overflow-y-auto flex-1",children:i.map(_=>h.jsxs("div",{className:e1.userEntry,children:[h.jsx("div",{className:e1.selectContainer,children:h.jsxs("select",{value:_.role,disabled:!j||N,onChange:T=>C(_.id,T.currentTarget.value),children:[h.jsx("option",{value:$t.OWNER,children:"Owner"}),h.jsx("option",{value:$t.ADMIN,children:"Admin"}),h.jsx("option",{value:$t.EDITOR,children:"Editor"}),h.jsx("option",{value:$t.READ_ONLY,children:"Reader"})]})}),h.jsx("p",{className:"flex-1 mx-2",children:_.name}),j&&h.jsx("button",{className:"p-1 cursor-pointer text-red-500 text-sm",onClick:()=>w(_.id),children:"❌"})]},_.id))}),j&&h.jsxs("div",{className:"mt-4",children:[h.jsx("p",{className:"font-semibold",children:"Create new user"}),h.jsxs("div",{className:"flex flex-col lg:flex-row gap-2 lg:items-center mt-2",children:[h.jsx("input",{className:"input flex-1",onChange:g("username"),value:y.username,placeholder:"Username",disabled:N}),h.jsx("input",{className:"input",onChange:g("password"),value:y.password,type:"password",name:"newPassword",autoComplete:"new-password",placeholder:"Password",disabled:N}),h.jsx("button",{className:"button primary",onClick:E,disabled:N,children:"Create user"})]}),h.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."})]})]})]})},F5=()=>{const[n,l]=b.useState(""),[i,r]=b.useState(""),[u,c]=b.useState(),[d,m]=b.useState(!1),p=Et(),y=g=>{g.preventDefault(),c(void 0),Tr.login({password:i,username:n}).then(()=>{p("/",{replace:!0})}).catch(c)};return h.jsx("div",{className:"page-container bg-(--bg) h-screen",children:h.jsx("div",{className:"page-content items-center",children:h.jsxs("form",{className:"flex flex-col gap-2 w-full lg:w-lg",onSubmit:y,children:[h.jsx("p",{className:"font-semibold text-xl min-w-md",children:"Login"}),u&&h.jsx(wt,{variant:"danger",children:"Failed to login. Please verify your credentials"}),h.jsx("input",{value:n,onChange:g=>l(g.currentTarget.value),className:"input",placeholder:"User name"}),h.jsx("input",{value:i,onChange:g=>r(g.currentTarget.value),className:"input",type:"password",placeholder:"Password"}),h.jsx("button",{type:"submit",className:"button primary",children:"Login"}),d?h.jsxs(wt,{className:"w-full border border-blue-500",children:[h.jsx("p",{children:"If this is your first login, the default credentials are:"}),h.jsxs("ul",{className:"mt-2",children:[h.jsxs("li",{children:["Username: ",h.jsx("strong",{children:"admin"})]}),h.jsxs("li",{children:["Password: ",h.jsx("strong",{children:"admin"})]})]}),h.jsx("p",{className:"mt-2",children:"Please make sure to change the default password to a secure one."})]}):h.jsx("button",{className:"button tertiary",onClick:()=>m(!0),children:"First login?"})]})})})},Z5=()=>{const n=Et(),{pathname:l}=qt(),{data:i,isLoading:r}=dv();b.useEffect(()=>{!i&&!r&&l!==Ye.login.path&&n(Ye.login.path)},[i,r,n,l])},P5=()=>{const[n]=Hx(),l=Et(),i=si(),r=n.get("shareId");return b.useEffect(()=>{r&&i.mutateAsync({queryId:r}).then(u=>{l(`${Ye.workbench.path}/tab/${u.id}`,{replace:!0})})},[r]),h.jsxs("div",{className:"page-container flex items-center justify-center h-screen",children:[i.isPending&&h.jsxs("div",{className:"flex items-center flex-col gap-2",children:[h.jsx(Pv,{}),h.jsx("p",{children:"Fetching query information"})]}),i.isError&&h.jsx(wt,{variant:"danger",children:"Failed to load query information"})]})},J5="_container_101ks_2",I5="_header_101ks_2",W5="_close-button_101ks_2",eN="_tab-container_101ks_2",tN="_tab-name_101ks_2",nN="_archived-badge_101ks_2 _badge_101ks_2",aN="_active-badge_101ks_2 _badge_101ks_2",lN="_action-blue_101ks_2 _action_101ks_2",sN="_action-red_101ks_2 _action_101ks_2",iN="_load-more-btn_101ks_2",In={container:J5,header:I5,closeButton:W5,tabContainer:eN,tabName:tN,archivedBadge:nN,activeBadge:aN,actionBlue:lN,actionRed:sN,loadMoreBtn:iN},rN=new Intl.DateTimeFormat,oN=()=>{const{data:n}=Bn(),{data:l,fetchNextPage:i,hasNextPage:r,isFetching:u}=t4(n?.teamId,5),c=Et(),d=vv(),m=L4(),p=x=>{d.mutate(x),Xs({show:!1}),c(`${Ye.workbench.path}/tab/${x}`)},y=x=>{m.mutate(x)},g=l&&l?.length>0;return h.jsxs("div",{className:In.container,children:[h.jsxs("div",{className:In.header,children:[h.jsx("h3",{className:"text-lg",children:"Tabs history"}),h.jsx("button",{className:In.closeButton,onClick:()=>Xs({show:!1}),children:h.jsx(Pl,{width:24,height:24})})]}),!g&&h.jsx(wt,{variant:"warning",children:"History is empty."}),l?.map(x=>h.jsxs("div",{className:In.tabContainer,children:[h.jsxs("div",{className:"flex gap-2 items-center",children:[h.jsx("p",{className:In.tabName,children:x.name}),x.dataSourceType&&h.jsx(ii,{size:16,type:x.dataSourceType}),h.jsx("p",{className:"text-sm",children:x.dataSourceName})]}),h.jsxs("div",{className:"flex gap-2 items-center mt-1",children:[h.jsx("p",{className:"text-sm italic",children:rN.format(new Date(x.updatedAt))}),x.archived?h.jsx("span",{className:In.archivedBadge,children:"Archived"}):h.jsx("span",{className:In.activeBadge,children:"Active"}),h.jsx("span",{className:"flex-1"}),h.jsx("button",{onClick:()=>p(x.id),className:In.actionBlue,children:"Open"}),h.jsx("button",{onClick:()=>y(x.id),className:In.actionRed,children:"Delete"})]})]},x.id)),r&&!u&&h.jsx("div",{className:"flex justify-center my-2",children:h.jsx("button",{className:In.loadMoreBtn,onClick:()=>i(),children:"Load more"})})]})},uN=()=>{const n=rE(l=>l.show);return h.jsx(Iv,{isVisible:n,onClose:()=>Xs({show:!1}),backdropClose:!0,children:h.jsx(oN,{})})};function cN(){return z5(),k5(),Z5(),h.jsxs(h.Fragment,{children:[h.jsxs(cx,{children:[h.jsx(dr,{path:Ye.home.path,element:h.jsx(hE,{})}),h.jsx(dr,{path:`${Ye.workbench.path}/tab/:id`,element:h.jsx(e5,{})}),h.jsx(dr,{path:Ye.login.path,element:h.jsx(F5,{})}),h.jsx(dr,{path:Ye.share.path,element:h.jsx(P5,{})})]}),h.jsx(TE,{}),h.jsx(kE,{}),h.jsx(PE,{}),h.jsx(S5,{}),h.jsx(L5,{}),h.jsx(H5,{}),h.jsx(X5,{}),h.jsx(uN,{}),h.jsx($E,{}),h.jsx(HE,{})]})}const fN="_desktop-layout_mhqiw_2",dN="_mobile-layout_mhqiw_2",hN="_nav_mhqiw_2",mN="_main_mhqiw_2",pN="_header_mhqiw_2",Ps={desktopLayout:fN,mobileLayout:dN,nav:hN,main:mN,header:pN},yN="_container_qmz1z_2",vN="_menu_qmz1z_2",oh={container:yN,menu:vN},gN=({name:n,id:l,onRename:i,onDelete:r,onOpen:u})=>{const c=_v();return h.jsxs("button",{className:oh.menu,onContextMenu:c.open,onClick:()=>u(l),children:[h.jsx(Nv,{handler:c,children:h.jsxs("div",{className:"context-menu-container",children:[h.jsx("button",{onClick:d=>{d.preventDefault(),d.stopPropagation(),c.close(),i(l)},className:"context-menu-item",children:"✏️ Rename"}),h.jsx("button",{onClick:d=>{d.preventDefault(),d.stopPropagation(),c.close(),r(l)},className:"context-menu-item",children:"🗑️ Delete"})]})}),h.jsxs("span",{children:["📖 ",n]})]})},bN=({dataSource:n,index:l})=>{const i=()=>{Gs(n.id)};return on(l.toString(),()=>{Gs(r=>{if(r!==n.id)return n.id})}),h.jsxs("button",{className:oh.menu,onClick:i,children:[h.jsx(ii,{size:20,type:n.dbType}),h.jsx("p",{className:"truncate flex-1 text-left mx-1.5",children:n.name}),h.jsx("span",{className:"hotkey",children:l})]})},xN=()=>{const n=Et(),{data:l}=Bn(),{data:i}=J3(l?.teamId),{data:r}=I3(l?.teamId),u=si(),c=GC(),d=$C(),m=g=>{u.mutateAsync({queryId:g}).then(x=>{n(`${Ye.workbench.path}/tab/${x.id}`)})},p=async g=>{const x=r?.find(C=>C.id===g);if(!x)return;const E=await Or("New name?",x?.name);E&&c.mutate({id:x.savedQueryId,payload:{name:E}})},y=g=>{const x=r?.find(E=>E.id===g)?.savedQueryId;x&&d.mutate(x)};return h.jsx("div",{className:oh.container,children:h.jsxs("div",{className:"flex-1 overflow-y-auto",children:[hl(i?.length,0)&&h.jsxs("div",{className:"mt-4",children:[h.jsx("p",{className:"font-semibold text-sm text-gray-600 mb-2",children:"DATA SOURCES"}),i.map((g,x)=>h.jsx(bN,{dataSource:g,index:x+1},g.id))]}),hl(r?.length,0)&&h.jsxs("div",{className:"mt-4",children:[h.jsx("p",{className:"font-semibold text-sm text-gray-600 mb-2",children:"SAVED QUERIES"}),r.map(g=>h.jsx(gN,{onDelete:y,onRename:p,onOpen:m,name:g.name,id:g.id},g.savedQueryId))]})]})})},SN=()=>{const n=Et(),{pathname:l}=qt(),{data:i}=Bn(),r=jr("Desktop nav"),u=()=>{Jv(),l!==Ye.home.path&&n(Ye.home.path)},c=()=>Xs({show:!0});return h.jsxs("nav",{className:Ps.nav,children:[i&&h.jsxs("div",{className:Ps.header,children:[h.jsx("button",{onClick:u,className:"flex justify-between items-center",children:h.jsx("span",{children:"🏠 Home"})}),h.jsxs("button",{onClick:r,className:"flex justify-between items-center",children:[h.jsx("span",{children:"🔎 New query"}),h.jsx("span",{className:"hotkey",children:"N"})]}),h.jsxs("button",{onClick:c,className:"flex justify-between items-center",children:[h.jsx("span",{children:"⌛ Recent tabs"}),h.jsx("span",{className:"hotkey",children:"H"})]}),h.jsxs("button",{onClick:eg,children:["🪪 ",i.username]}),h.jsx("button",{onClick:ng,children:"👥 Manage users"})]}),h.jsx(xN,{})]})},wN="_root_akcjn_2",EN={root:wN},CN=()=>{const{pathname:n}=qt(),l=Et(),i=jr("Mobile nav"),r=()=>{n!==Ye.home.path&&l(Ye.home.path)};return h.jsxs("div",{className:EN.root,children:[h.jsxs("button",{onClick:r,children:[h.jsx("p",{children:"🏠"}),h.jsx("p",{className:"text-xs font-semibold text-gray-600",children:"Home"})]}),h.jsxs("button",{onClick:i,children:[h.jsx("p",{children:"🔎"}),h.jsx("p",{className:"text-xs font-semibold text-gray-600",children:"New query"})]}),h.jsxs("button",{onClick:eg,children:[h.jsx("p",{children:"🪪"}),h.jsx("p",{className:"text-xs font-semibold text-gray-600",children:"Account"})]}),h.jsxs("button",{onClick:ng,children:[h.jsx("p",{children:"👥"}),h.jsx("p",{className:"text-xs font-semibold text-gray-600",children:"Users"})]})]})},_N=({children:n,isLogin:l})=>h.jsxs("div",{className:Ps.desktopLayout,children:[h.jsx(ih,{id:"default",className:"z-100"}),!l&&h.jsx(SN,{}),h.jsx("main",{className:Ps.main,children:n})]}),NN=({children:n,isLogin:l})=>h.jsxs("div",{className:Ps.mobileLayout,children:[h.jsx("main",{className:Ps.main,children:n}),!l&&h.jsx(CN,{})]}),TN=({children:n})=>{const l=Ev(Id.laptop),{pathname:i}=qt(),r=i===Ye.login.path;return l?h.jsx(_N,{isLogin:r,children:n}):h.jsx(NN,{isLogin:r,children:n})};g2.createRoot(document.getElementById("root")).render(h.jsxs(rl.StrictMode,{children:[h.jsx(F3,{}),h.jsx(yS,{client:rt,children:h.jsx(Lx,{children:h.jsx(TN,{children:h.jsx(cN,{})})})})]}));