@harperfast/harper-pro 5.0.11 → 5.0.13

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.
Files changed (29) hide show
  1. package/core/config/configUtils.js +8 -2
  2. package/core/package-lock.json +2 -2
  3. package/dist/cloneNode/cloneNode.js +38 -20
  4. package/dist/cloneNode/cloneNode.js.map +1 -1
  5. package/dist/core/config/configUtils.js +8 -2
  6. package/dist/core/config/configUtils.js.map +1 -1
  7. package/npm-shrinkwrap.json +2 -2
  8. package/package.json +1 -1
  9. package/studio/web/assets/index-CUg8eaR8.css +1 -0
  10. package/studio/web/assets/index-DlmBuk_k.js +74 -0
  11. package/studio/web/assets/index-DlmBuk_k.js.map +1 -0
  12. package/studio/web/assets/{index.lazy-DRQKYKT0.js → index.lazy-K9dEIsCc.js} +4 -4
  13. package/studio/web/assets/{index.lazy-DRQKYKT0.js.map → index.lazy-K9dEIsCc.js.map} +1 -1
  14. package/studio/web/assets/{profile-wyN1K1z0.js → profile-F3bEc3dt.js} +2 -2
  15. package/studio/web/assets/{profile-wyN1K1z0.js.map → profile-F3bEc3dt.js.map} +1 -1
  16. package/studio/web/assets/status-CnVRDPsO.js +2 -0
  17. package/studio/web/assets/{status-ChrCqVc7.js.map → status-CnVRDPsO.js.map} +1 -1
  18. package/studio/web/assets/{vendor-react-D6IIT0sT.js → vendor-react-DyY32duL.js} +52 -52
  19. package/studio/web/assets/vendor-react-DyY32duL.js.map +1 -0
  20. package/studio/web/assets/{vendor-tanstack-zom2m6Nj.js → vendor-tanstack-D0jMvSWD.js} +2 -2
  21. package/studio/web/assets/{vendor-tanstack-zom2m6Nj.js.map → vendor-tanstack-D0jMvSWD.js.map} +1 -1
  22. package/studio/web/assets/{vendor-viz-BdK5B9uw.js → vendor-viz-Cs-GQIim.js} +2 -2
  23. package/studio/web/assets/{vendor-viz-BdK5B9uw.js.map → vendor-viz-Cs-GQIim.js.map} +1 -1
  24. package/studio/web/index.html +4 -4
  25. package/studio/web/assets/index-C_a0cXHU.css +0 -1
  26. package/studio/web/assets/index-Dk_TRrUg.js +0 -74
  27. package/studio/web/assets/index-Dk_TRrUg.js.map +0 -1
  28. package/studio/web/assets/status-ChrCqVc7.js +0 -2
  29. package/studio/web/assets/vendor-react-D6IIT0sT.js.map +0 -1
@@ -1,74 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index.lazy-DRQKYKT0.js","assets/rolldown-runtime-BTPm5ob3.js","assets/vendor-datadog--sQMslQh.js","assets/vendor-react-D6IIT0sT.js","assets/vendor-core-DlDjzdYO.js","assets/vendor-misc-DiaKLG2J.js","assets/vendor-markdown-DmpzS029.js","assets/vendor-html-BX0IEUi6.js","assets/vendor-monaco-BM3cl_a8.js","assets/vendor-charts-CbDcQ117.js","assets/vendor-react-CrIa5r46.css","assets/index-DZem5S77.css","assets/vendor-viz-BdK5B9uw.js","assets/status-ChrCqVc7.js","assets/profile-wyN1K1z0.js"])))=>i.map(i=>d[i]);
2
- import{o as e}from"./rolldown-runtime-BTPm5ob3.js";import{Cn as t,Dn as n,En as r,Tn as i,_n as a,an as o,dn as s,fn as c,gn as l,hn as u,in as d,ln as f,mn as p,on as m,pn as h,sn as g,un as _,vn as v,wn as y,yn as b}from"./vendor-core-DlDjzdYO.js";import{$i as x,$n as ee,$r as te,$t as ne,Ai as re,An as ie,Ar as S,At as ae,Bi as oe,Bn as se,Br as ce,Bt as le,Ci as ue,Cn as de,Cr as fe,Di as pe,Dn as me,Dr as he,Dt as ge,Ei as _e,En as ve,Er as C,Et as ye,Fi as be,Fn as xe,Fr as Se,Ft as Ce,Gi as we,Gn as Te,Gr as Ee,Gt as De,Hi as Oe,Hn as ke,Hr as Ae,Ht as je,In as Me,It as Ne,Ji as Pe,Jn as Fe,Jt as Ie,Ki as Le,Kn as Re,Kr as ze,Kt as Be,Ln as Ve,Lr as He,Lt as Ue,Mn as We,Mr as Ge,Mt as Ke,Ni as qe,Nn as Je,Nt as Ye,Oi as Xe,On as Ze,Or as Qe,Ot as $e,Pi as et,Pn as w,Pr as tt,Pt as nt,Qi as rt,Qn as it,Qr as at,Qt as ot,Ri as st,Rn as ct,Rr as lt,Rt as ut,Si as dt,Sn as ft,Sr as pt,St as mt,Ti as ht,Tn as gt,Tr as _t,Ui as vt,Un as yt,Ur as bt,Ut as xt,Vi as St,Vn as Ct,Vr as wt,Vt as Tt,Wi as Et,Wn as Dt,Wt as Ot,Xi as kt,Xn as At,Xr as jt,Xt as Mt,Yi as Nt,Yn as Pt,Yr as Ft,Yt as It,Zi as Lt,Zn as Rt,Zr as zt,Zt as Bt,_a as Vt,_i as Ht,_n as Ut,aa as T,ai as Wt,an as Gt,bi as Kt,bn as qt,br as Jt,bt as Yt,ca as Xt,ci as Zt,cn as Qt,cr as $t,da as en,di as tn,dn as nn,dr as rn,ei as an,en as on,er as sn,fa as E,fi as cn,fn as ln,fr as un,ga as dn,gi as fn,gn as pn,gr as mn,ha as D,hi as hn,hn as gn,hr as _n,ia as vn,ii as yn,in as bn,ir as xn,jn as Sn,jr as Cn,jt as wn,ki as Tn,kn as En,kr as Dn,kt as On,la as kn,li as An,ln as jn,lr as Mn,ma as Nn,mi as Pn,mn as Fn,mr as In,na as O,ni as Ln,nn as Rn,nr as k,oa as zn,on as Bn,or as Vn,pa as A,pi as Hn,pn as Un,pr as Wn,qi as Gn,qn as Kn,qr as qn,qt as Jn,ra as j,ri as Yn,rn as Xn,rr as Zn,sa as M,si as Qn,sn as $n,sr as er,ta as tr,ti as nr,tn as rr,tr as ir,ua as ar,ui as or,un as sr,ur as cr,va as lr,vi as ur,vn as dr,wn as fr,wr as pr,xi as mr,xn as hr,xr as gr,xt as _r,ya as vr,yi as yr,yn as br,yr as xr,yt as Sr,zn as N,zr as Cr,zt as wr}from"./vendor-react-D6IIT0sT.js";import{a as Tr,i as Er,r as Dr}from"./vendor-tanstack-zom2m6Nj.js";import{Ar as Or,Br as kr,Dr as Ar,Er as jr,Fr as Mr,Hr as Nr,Ir as Pr,Lr as Fr,Nr as Ir,Or as Lr,Pr as Rr,Rr as zr,Ur as Br,Vr,jr as Hr,kr as Ur,zr as Wr}from"./vendor-misc-DiaKLG2J.js";import{i as Gr,r as Kr}from"./vendor-datadog--sQMslQh.js";import"./vendor-stripe-TdDVajXP.js";import{t as qr}from"./vendor-markdown-DmpzS029.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var Jr=9925,Yr=`HDB_ADMIN`,Xr=1024*1024*1024,Zr=100*1024*1024,P=n.create({withCredentials:!0,baseURL:`/`,timeout:15e3,headers:{"Content-Type":`application/json`}});function Qr(e,t,n){return e===1||e===`1`?`${e} ${t}`:`${e} ${n}`}function $r(e){return e.replicated?.some(e=>ti(e))??!1}function ei(e){return e.status!==`failed`}function ti(e){return e.status===`failed`}function ni(e){if($r(e.data)){let t=e.data.replicated.filter(ei),n=e.data.replicated.filter(ti),r=t.length?`The operation partially succeeded, but ${Qr(n.length,`node`,`nodes`)} failed:`:n.length===1?`The operation failed on the single node:`:`The operation failed on all ${n.length} nodes:`,i=n.map(e=>`${e.node}: ${e.reason}`).join(`
3
- `);return Promise.reject(r+`
4
- `+i)}return e}function ri(e=1e3){return new Promise(t=>{setTimeout(()=>{t(!0)},e)})}function ii(e){return async t=>{let n=t?.response?.status,r=t?.config;return!r||!(n===502||n===503||n===504)?Promise.reject(t):(r.__retryCount=r.__retryCount||0,r.__retryCount>=3?Promise.reject(t):(r.__retryCount+=1,await ri(5e3*2**(r.__retryCount-1)),e.request(r)))}}function ai({id:e=F,operationsUrl:t,port:r,secure:i,forceFabricConnect:a,disableFabricConnect:o}={}){let s=t||I.getOperationsUrl(e);if(s&&(r||i!==void 0)){let e=new URL(s);r&&(e.port=String(r)),i!==void 0&&(e.protocol=i?`https:`:`http:`),s=e.toString()}let c=!o&&(a||I.checkForFabricConnect(e));c&&(e.startsWith(`clu-`)?s=P.defaults.baseURL+`/Cluster/${e}/operation`:e.startsWith(`ins-`)&&(s=P.defaults.baseURL+`/HDBInstance/${e}/operation`));let l=I.checkForBasicAuth(e),u=n.create({auth:c?void 0:l,withCredentials:c||!l,timeout:15e3,headers:{"Content-Type":`application/json`},baseURL:s});return u.interceptors.response.use(ni,ii(u)),u}async function oi(){let{data:e}=await P.get(`/User/current`);return e}var si=[`current-user`];function ci(){return A({queryKey:si,queryFn:oi,retry:!1})}async function li({instanceClient:e,entityId:t}){let{data:n}=await e.post(`/`,{operation:`logout`});if(I.flagForBasicAuth(t,null),n)return n;throw Error(`Something went wrong`)}async function ui({instanceClient:e,...t}){let{data:n}=await e.post(`/`,{operation:`user_info`},t);return n}function di(e){let t=e?.fqdn;if(!t)return null;t.match(/^https?:\/\//i)||(t=`https://${t}`);let n=new URL(t);return t.match(/:\d+/)||(n.port=String(Jr)),t.includes(`://`)||(n.protocol=`https:`),n.toString()}function fi(e){let t=e.instanceFqdn;t.match(/^https?:\/\//i)||(t=`https://${t}`);let n=new URL(t);return e.operationsApiPort&&(n.port=String(e.operationsApiPort)),e.operationsApiSecure!==void 0&&(n.protocol=e.operationsApiSecure?`https:`:`http:`),n.toString()}var F=`OverallAppSignIn`,I=new class{broadListeners=[];specificListeners={};potentiallyAuthenticatedKey=`Studio:PotentiallyAuthenticated`;basicAuthKeyPrefix=`Studio:BasicAuth:`;fabricConnectKeyPrefix=`Studio:FabricConnect:`;potentiallyAuthenticated;checkedAuthentication={};allConnections={};constructor(){this.potentiallyAuthenticated=JSON.parse(localStorage.getItem(this.potentiallyAuthenticatedKey)||`{}`)}getAllConnections(){return this.potentiallyAuthenticated.OverallAppSignIn||(this.allConnections[F]={user:null,isLoading:!1}),this.allConnections}getConnectionById(e){return this.allConnections[e]||(this.allConnections[e]={user:null,isLoading:!!this.potentiallyAuthenticated[e]}),this.allConnections[e]}listenToAllEntities(e){this.broadListeners.includes(e)||this.broadListeners.push(e);for(let e in this.potentiallyAuthenticated)this.ensureUserIsLoaded(e);return()=>{let t=this.broadListeners.indexOf(e);t>=0&&this.broadListeners.splice(t,1)}}listenToEntity(e,t){if(e)return this.specificListeners[e]||(this.specificListeners[e]=[]),this.specificListeners[e].includes(t)||this.specificListeners[e].push(t),this.ensureUserIsLoaded(e),()=>{let n=this.specificListeners[e].indexOf(t);n>=0&&this.specificListeners[e].splice(n,1)}}setUserForEntity(e,t){let n=this.calculateIdFromEntity(e),r=this.calculateKeyFromEntity(e);if(!(!n||!r))return this.setUserForIdAndKey(n,r,t)}setUserForIdAndKey(e,t,n){n?this.flagKeyAsSignedIn(e,t):this.flagKeyAsSignedOut(e),this.updateConnectionIfChanged(e,!1,n)}updateUserForEntity(e,t){let n=this.calculateIdFromEntity(e);if(!n)return;let r=this.getConnectionById(n);r.user&&this.updateConnectionIfChanged(n,!1,{...r.user,...t})}calculateIdFromEntity(e){return F}flagForBasicAuth(e,t){t===null?localStorage.removeItem(this.basicAuthKeyPrefix+e):localStorage.setItem(this.basicAuthKeyPrefix+e,btoa(JSON.stringify(t)))}flagForFabricConnect(e,t){t?localStorage.setItem(this.fabricConnectKeyPrefix+e,`true`):localStorage.removeItem(this.fabricConnectKeyPrefix+e)}checkForBasicAuth(e){let t=localStorage.getItem(this.basicAuthKeyPrefix+e);return t?JSON.parse(atob(t)):void 0}checkForFabricConnect(e){return localStorage.getItem(this.fabricConnectKeyPrefix+e)===`true`}async signOutFromPotentiallyAuthenticatedInstances(){for(let e in this.potentiallyAuthenticated)if(this.allConnections[e].user=null,this.allConnections[e].isLoading=!1,this.flagKeyAsSignedOut(e),e!==`OverallAppSignIn`)try{await li({entityId:e,instanceClient:ai({id:e})})}catch(t){console.error(`Failed to log out from ${e}, carrying on`,t)}}calculateKeyFromEntity(e){return F}updateConnectionIfChanged(e,t,n){this.checkedAuthentication[e]=!0;let r=this.getConnectionById(e),i=!1;r.isLoading!==t&&(r.isLoading=t,i=!0),r.user!==n&&(r.user=n,i=!0),i&&this.updateListeners(e)}flagKeyAsSignedIn(e,t){this.potentiallyAuthenticated[e]!==t&&(this.potentiallyAuthenticated[e]=t,localStorage.setItem(this.potentiallyAuthenticatedKey,JSON.stringify(this.potentiallyAuthenticated)))}flagKeyAsSignedOut(e){this.potentiallyAuthenticated[e]&&(delete this.potentiallyAuthenticated[e],localStorage.setItem(this.potentiallyAuthenticatedKey,JSON.stringify(this.potentiallyAuthenticated)))}async updateListeners(e){if(await ri(1),this.broadListeners)for(let t of this.broadListeners)this.updateListener(e,t);if(this.specificListeners[e])for(let t of this.specificListeners[e])this.updateListener(e,t)}updateListener(e,t){t(this.getConnectionById(e),e)}async ensureUserIsLoaded(e){this.checkedAuthentication[e]||await this.reloadUser(e)}getOperationsUrl(e){return`/`}async reloadUser(e){return this.potentiallyAuthenticated[e]?this.loadUser(e):(this.updateConnectionIfChanged(e,!1,null),null)}async loadUser(e){let t=this.potentiallyAuthenticated[e];this.updateConnectionIfChanged(e,!0,null);let n=null;try{e===`OverallAppSignIn`?n=await ui({instanceClient:ai()}):e&&(n=await ui({instanceClient:ai({id:e})}))}catch(e){console.error(e),n=null}return n?this.flagKeyAsSignedIn(e,t):this.flagKeyAsSignedOut(e),this.updateConnectionIfChanged(e,!1,n),n}},L=e(vr(),1);function pi(){let[e,t]=(0,L.useState)(I.getAllConnections());return(0,L.useEffect)(()=>I.listenToAllEntities((n,r)=>{t({...e,[r]:n})}),[e]),e}function mi(){let e=I.calculateIdFromEntity(F),[t,n]=(0,L.useState)(I.getConnectionById(F));return(0,L.useEffect)(()=>I.listenToEntity(e,n),[e]),t}function hi(){return mi()}function gi(){let{user:e}=hi();return e?.fabricRole===`fabric_admin`||e?.fabricRole===`super_user`}function _i(e){let t=F,{clusterId:n,instanceId:r}=M({strict:!1}),[i,a]=(0,L.useState)(I.getConnectionById(t??r??n));return(0,L.useEffect)(()=>I.listenToEntity(t,a),[t]),i}var vi=`hover:-translate-y-1 transition duration-200`,yi=`border bg-transparent border-2 text-white shadow-xs hover:bg-grey-700/40`,bi=y(`inline-flex
5
- items-center
6
- justify-center
7
- gap-2
8
- whitespace-nowrap
9
- rounded-lg
10
- text-sm
11
- transition-[color,box-shadow]
12
- disabled:pointer-events-none
13
- disabled:opacity-50
14
- [&_svg]:pointer-events-none
15
- [&_svg:not([class*='size-'])]:size-4
16
- [&_svg]:shrink-0
17
- ring-ring/10
18
- dark:ring-ring/20
19
- dark:outline-ring/40
20
- outline-ring/50
21
- focus-visible:ring-1
22
- focus-visible:outline-1
23
- focus-visible:ring-purple-200
24
- aria-invalid:focus-visible:ring-0`,{variants:{variant:{default:`bg-primary text-primary-foreground shadow-sm hover:bg-primary/90`,submit:`bg-gradient-to-r from-blue-100 from-0% to-blue to-100% hover:bg-gradient-to-r hover:from-blue text-primary-foreground shadow-sm`,destructive:`bg-destructive shadow-xs hover:bg-destructive/90`,secondary:`bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80`,ghost:`hover:bg-accent hover:text-muted-foreground`,destructiveGhost:`hover:bg-accent hover:text-red`,link:`text-primary underline-offset-4 hover:underline`,positive:`bg-green text-white shadow-xs hover:bg-green/90`,warning:`bg-yellow text-white shadow-xs hover:bg-yellow/90`,outline:`${yi} ${vi}`,ghostOutline:`${yi} ${vi} border-none`,positiveOutline:`${yi} ${vi} border-green`,destructiveOutline:`${yi} ${vi} border-destructive`,defaultOutline:`${yi} ${vi} border-primary`},size:{default:`h-9 px-4 py-2 has-[>svg]:px-3`,sm:`h-8 rounded-md px-3 has-[>svg]:px-2.5`,lg:`h-10 rounded-md px-6 has-[>svg]:px-4 text-md`,icon:`size-9`}},defaultVariants:{variant:`default`,size:`default`}});function R(...e){return t(r(e))}var z=lr();function B({className:e,variant:t,size:n,asChild:r=!1,...i}){return(0,z.jsx)(r?Gn:`button`,{"data-slot":`button`,className:R(bi({variant:t,size:n,className:e})),...i})}function xi({className:e,...t}){return(0,z.jsx)(`div`,{"data-slot":`card`,className:R(`bg-card text-card-foreground flex flex-col gap-6 rounded-xl py-4 shadow-deep`,e),...t})}function Si({className:e,...t}){return(0,z.jsx)(`div`,{"data-slot":`card-header`,className:R(`flex flex-col gap-1.5 px-6`,e),...t})}function Ci({className:e,...t}){return(0,z.jsx)(`div`,{"data-slot":`card-title`,className:R(`leading-none text-lg`,e),...t})}function wi({className:e,...t}){return(0,z.jsx)(`div`,{"data-slot":`card-description`,className:R(`text-muted-foreground text-xs`,e),...t})}function Ti({className:e,...t}){return(0,z.jsx)(`div`,{"data-slot":`card-content`,className:R(`px-6`,e),...t})}function Ei(e){return e!==null&&!!e.username}function Di(e){if(e&&!Ei(e)){let t=Object.keys(e.roles);if(t.length===1)return`/${t[0]}`}return`/`}function Oi({className:e,error:t,title:n,showReturnToHome:r,children:i}){let{user:a,isLoading:o}=mi();return Di(a),(0,z.jsxs)(xi,{className:R(`text-red p-5 border border-red rounded-md m-12 mt-36`,e),children:[(0,z.jsxs)(Si,{children:[(0,z.jsx)(Ci,{className:`text-2xl`,children:(0,z.jsx)(`h2`,{children:n??`Component Error`})}),(0,z.jsx)(wi,{children:t.message})]}),(0,z.jsxs)(Ti,{children:[i,r!==!1&&(a&&!o?(0,z.jsx)(j,{to:`/`,children:(0,z.jsxs)(B,{children:[` `,(0,z.jsx)(Et,{}),` Return to Home`]})}):(0,z.jsx)(j,{to:`/sign-in`,children:(0,z.jsxs)(B,{children:[` `,(0,z.jsx)(Et,{}),` Go to Sign In Page`]})}))]})]})}function ki(){let{user:e,isLoading:t}=mi();return Di(e),(0,z.jsx)(`div`,{className:`flex items-center justify-center h-screen px-3`,children:(0,z.jsxs)(xi,{className:`text-red p-5 border border-red rounded-md w-full max-w-md`,children:[(0,z.jsx)(Si,{children:(0,z.jsx)(Ci,{className:`text-2xl`,children:(0,z.jsx)(`h2`,{children:`Sorry, Page Not Found`})})}),(0,z.jsx)(Ti,{children:e&&!t?(0,z.jsx)(j,{to:`/`,children:(0,z.jsxs)(B,{children:[` `,(0,z.jsx)(Et,{}),` Return to Home`]})}):(0,z.jsx)(j,{to:`/sign-in`,children:(0,z.jsxs)(B,{children:[` `,(0,z.jsx)(Et,{}),` Go Sign In Page`]})})})]})})}function Ai(){return`ontouchstart`in window||navigator.maxTouchPoints>0}function ji(e){let t=`Error`,n=`We had some trouble!`;console.error(e);let r=e,i=e;if(typeof e==`string`?n=e:r?.response?.data?typeof r.response.data==`string`?n=r.response.data:r.response.data.error?n=r.response.data.error:r.response.data.message&&(n=r.response.data.message):i?.message&&(n=i.message),n.includes(`:`)){let e=n.split(`:`);t=e.shift(),n=e.join(`:`)}k.error(t,{description:n,action:{label:`Dismiss`,onClick:()=>k.dismiss()}})}var Mi=new Dr({queryCache:new Er({onError:ji}),mutationCache:new Tr({onError:ji})});function Ni(e){return!!e}var Pi=!1,Fi=!1;function Ii(){(0,L.useEffect)(()=>{Pi||(Pi=!0,Fi&&(Kr.init({applicationId:`f590deee-4bac-49b4-a202-3b6963d9721d`,clientToken:`pub27aa29cea521492f4fef73032f86a023`,site:`datadoghq.com`,service:`studio`,env:void 0,version:`v5.0.11`,trackViewsManually:!0,trackUserInteractions:!0,sessionSampleRate:100,sessionReplaySampleRate:0,defaultPrivacyLevel:`mask`,plugins:[sn()]}),Kr.onReady(()=>{Kr.startView({service:`studio`,version:`v5.0.11`,name:window.location.pathname||`initial`})})))},[])}function Li(e){if(!Fi)return;Kr.setUser({id:e.id,email:e.email,name:[e.firstname,e.lastname].filter(Boolean).join(` `)||void 0});let t=`hasLoggedInBefore:${e.id}`;localStorage.getItem(t)?Kr.addAction(`return_login`):(Kr.addAction(`first_time_login`),localStorage.setItem(t,`true`));let n=`lastLoginTimestamp:${e.id}`,r=localStorage.getItem(n),i=Date.now();if(r){let e=Math.floor((i-Number(r))/1e3);!Number.isNaN(e)&&e>=0&&Kr.addAction(`login_time_gap`,{value:e})}localStorage.setItem(n,String(i)),Kr.addAction(`login_success`,{userId:e.id})}function Ri(){return(0,z.jsx)(z.Fragment,{children:(0,z.jsx)(rt,{})})}var zi=tr()({component:Ri});function Bi(){return(0,z.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 126.644 96`,width:24,height:24,children:(0,z.jsx)(`path`,{fill:`currentColor`,d:`M81.15,0c-1.2376,2.1973-2.3489,4.4704-3.3591,6.794-9.5975-1.4396-19.3718-1.4396-28.9945,0-.985-2.3236-2.1216-4.5967-3.3591-6.794-9.0166,1.5407-17.8059,4.2431-26.1405,8.0568C2.779,32.5304-1.6914,56.3725.5312,79.8863c9.6732,7.1476,20.5083,12.603,32.0505,16.0884,2.6014-3.4854,4.8998-7.1981,6.8698-11.0623-3.738-1.3891-7.3497-3.1318-10.8098-5.1523.9092-.6567,1.7932-1.3386,2.6519-1.9953,20.281,9.547,43.7696,9.547,64.0758,0,.8587.7072,1.7427,1.3891,2.6519,1.9953-3.4601,2.0457-7.0718,3.7632-10.835,5.1776,1.97,3.8642,4.2683,7.5769,6.8698,11.0623,11.5419-3.4854,22.3769-8.9156,32.0509-16.0631,2.626-27.2771-4.496-50.9172-18.817-71.8548C98.9811,4.2684,90.1918,1.5659,81.1752.0505l-.0252-.0505ZM42.2802,65.4144c-6.2383,0-11.4159-5.6575-11.4159-12.6535s4.9755-12.6788,11.3907-12.6788,11.5169,5.708,11.4159,12.6788c-.101,6.9708-5.026,12.6535-11.3907,12.6535ZM84.3576,65.4144c-6.2637,0-11.3907-5.6575-11.3907-12.6535s4.9755-12.6788,11.3907-12.6788,11.4917,5.708,11.3906,12.6788c-.101,6.9708-5.026,12.6535-11.3906,12.6535Z`})})}function Vi(){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`img`,{src:`/harper-studio_white.png`,alt:`Harper Studio`,className:`w-64 hidden md:inline-block`}),(0,z.jsx)(`img`,{src:`/HDBDogOnly.svg`,width:`50px`,height:`44px`,alt:`Harper`,className:`inline-block md:hidden`})]})}function Hi({className:e,...t}){return(0,z.jsx)(`div`,{className:R(`absolute top-full left-0 isolate z-50 flex justify-center`),children:(0,z.jsx)(it,{"data-slot":`navigation-menu-viewport`,className:R(`origin-top-center bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-90 relative mt-1.5 h-[var(--radix-navigation-menu-viewport-height)] w-full overflow-hidden rounded-md border shadow md:w-[var(--radix-navigation-menu-viewport-width)]`,e),...t})})}function Ui({className:e,children:t,viewport:n=!0,...r}){return(0,z.jsxs)(Rt,{"data-slot":`navigation-menu`,"data-viewport":n,className:R(`group/navigation-menu relative flex max-w-max flex-1 items-center justify-center`,e),...r,children:[t,n&&(0,z.jsx)(Hi,{})]})}function Wi({className:e,...t}){return(0,z.jsx)(Fe,{"data-slot":`navigation-menu-item`,className:R(`relative`,e),...t})}function Gi({className:e,...t}){return(0,z.jsx)(Pt,{"data-slot":`navigation-menu-link`,className:R(`hover:text-white ring-ring/10 dark:ring-ring/20 dark:outline-ring/40 outline-ring/50 flex flex-col gap-1 rounded-sm p-2 text-sm transition-[color,box-shadow] focus-visible:ring-4 focus-visible:outline-1 [&_svg:not([class*='size-'])]:size-4`,e),...t})}function Ki({className:e,...t}){return(0,z.jsx)(At,{"data-slot":`navigation-menu-list`,className:R(`group flex flex-1 list-none items-center justify-center gap-1`,e),...t})}var qi=y(`inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-auto`,{variants:{variant:{default:`border-primary bg-primary/40 text-primary-foreground [a&]:hover:bg-primary/90`,secondary:`border-secondary bg-secondary/40 text-secondary-foreground [a&]:hover:bg-secondary/90`,warning:`border-yellow bg-yellow/40 text-white [a&]:hover:bg-yellow/90`,success:`border-green bg-green/40 text-white [a&]:hover:bg-green/90`,destructive:`border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40`,outline:`text-white [a&]:hover:bg-accent [a&]:hover:text-accent-foreground`}},defaultVariants:{variant:`default`}});function Ji(){let e=`v5.0.11`;return(0,z.jsx)(`a`,{href:e?.startsWith(`v`)?`https://github.com/HarperFast/studio/releases/tag/${e}`:`https://github.com/HarperFast/studio/releases`,target:`_blank`,rel:`noopener noreferrer`,children:(0,z.jsxs)(`span`,{className:R(qi({variant:`default`}),`text-xs inline-block ml-2 align-text-top`),children:[e,` BETA`]})})}function Yi(e={}){let{instanceId:t,clusterId:n}=M({strict:!1});return ai({id:F,...e})}function Xi(e={}){let{instanceId:t,clusterId:n}=M({strict:!1});return{instanceClient:ai({id:F,...e}),entityType:`instance`}}function V(e={}){let{instanceId:t,clusterId:n}=M({strict:!1});return(0,L.useMemo)(()=>Zi({instanceId:t,clusterId:n,...e}),[e.instanceId??t,e.clusterId??n,e.operationsUrl,e.port,e.secure,e.disableFabricConnect,e.forceFabricConnect])}function Zi({instanceId:e,clusterId:t,...n}){let r=F;if(!r)throw Error(`id could not be automatically calculated in useInstanceClientIdParams`);return{instanceClient:ai({id:r,...n}),entityId:r,entityType:`instance`}}function Qi(){localStorage.clear()}function $i(){sessionStorage.clear()}async function ea(){I.setUserForEntity(F,null),Mi.getQueryCache().clear(),Qi(),$i(),await Mi.invalidateQueries({refetchType:`none`})}async function ta(e){await I.signOutFromPotentiallyAuthenticatedInstances(),await li({...e,entityId:F})}function na(){let e=Yi();return E({mutationFn:()=>ta({instanceClient:e}),onSuccess:ea})}function ra(e){let{user:t}=hi(),{organizationId:n}=M({strict:!1}),r=t?.roles?.[e??n];return!r?.permission&&!r?.organization?{update:!1,remove:!1}:r.permission?.super_user?{update:!0,remove:!0}:{update:r.organization.update,remove:r.organization.delete}}function ia(e){let{user:t}=hi(),{organizationId:n}=M({strict:!1}),r=t?.roles?.[e??n];if(!r?.permission&&!r?.organization?.roles)return{create:!1,remove:!1,update:!1,view:!1};if(r.permission?.super_user)return{create:!0,remove:!0,update:!0,view:!0};let i=r.organization.roles;return{create:i.create,remove:i.delete,update:i.update,view:i.view}}function aa(e,t){let{user:n}=hi(),{organizationId:r,clusterId:i}=M({strict:!1});return oa(n,e??r,t??i)}function oa(e,t,n){let r=e?.roles?.[t];if(!r?.permission&&!r?.organization?.clusters)return{create:!1,remove:!1,update:!1,view:!1};if(r.permission?.super_user)return{create:!0,remove:!0,update:!0,view:!0};let i=r.organization.clusters.resources?.find(e=>e.id===n),a=r.organization.clusters;return{create:a.create,remove:i?i.delete:a.delete,update:i?i.update:a.update,view:i?i.view:a.view}}function sa(e,t){let{user:n}=hi(),{organizationId:r,clusterId:i}=M({strict:!1});return ca(n,e??r,t??i)}function ca(e,t,n){let r=e?.roles?.[t];if(!r?.permission&&!r?.organization?.clusters)return{create:!1,remove:!1,update:!1,view:!1};if(r.permission?.super_user)return{create:!0,remove:!0,update:!0,view:!0};let i=r.organization.clusters.resources?.find(e=>e.id===n)?.instances,a=r.organization.clusters;return{create:i?i.create:a.create,remove:i?i.delete:a.delete,update:i?i.update:a.update,view:i?i.view:a.view}}function la(e){let{clusterId:t,instanceId:n}=M({strict:!1}),{user:r}=_i(e??n??t),i=r?.role?.permission;return i?i.super_user===!0:!1}function ua(e){let{clusterId:t,instanceId:n}=M({strict:!1}),{user:r}=_i(e??n??t),i=r?.role?.permission;return i?i.super_user===!0||i.structure_user===!0:!1}function da(e,t,n,r){let{clusterId:i,instanceId:a}=M({strict:!1}),{user:o}=_i(e??a??i),s=o?.role?.permission;return s?s.super_user===!0||s.structure_user===!0?!0:s[t]?.tables?.[n][r]===!0:!1}var fa={className:`text-white`};function pa(){let{mutate:e}=na(),t=T(),{user:n}=mi(),r=kn(),{organizationId:i}=M({strict:!1}),{update:a}=ra(i),{view:o}=ia(i),s=a,c=(0,L.useCallback)(()=>{e(void 0,{onSuccess:async()=>{k.success(`Success`,{description:`You have been signed out successfully.`,action:{label:`Dismiss`,onClick:()=>k.dismiss()}}),t({to:`/sign-in`}),r.invalidate()}})},[e,r,t]),l=(0,L.useMemo)(()=>[!1,!1,!1,{to:`https://docs.harperdb.io/docs`,target:`_blank`,icon:(0,z.jsx)(st,{}),text:`Docs`,textBreakpoint:`md`},{to:`https://github.com/HarperFast/studio/issues`,target:`_blank`,icon:(0,z.jsx)(qe,{}),text:`Report an Issue`,textBreakpoint:`lg`},{to:`https://discord.gg/VzZuaw3Xay`,target:`_blank`,icon:(0,z.jsx)(Bi,{}),text:`Discord`,textBreakpoint:`lg`},{onClick:c,icon:(0,z.jsx)(He,{}),text:`Sign Out`,textBreakpoint:`md`}].filter(Ni),[i,s,o,c]);return n?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(va,{menuItems:l}),(0,z.jsx)(ga,{menuItems:l})]}):(0,z.jsx)(ha,{})}function ma(e){return e.items!==void 0}function ha(){return(0,z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,z.jsxs)(`div`,{className:`inline-block`,children:[(0,z.jsx)(j,{to:`/sign-in`,children:(0,z.jsx)(Vi,{})}),(0,z.jsx)(Ji,{})]}),(0,z.jsx)(Ui,{children:(0,z.jsxs)(Ki,{className:`text-grey-400`,children:[(0,z.jsx)(Wi,{children:(0,z.jsx)(Gi,{asChild:!0,children:(0,z.jsxs)(j,{to:`https://docs.harperdb.io/docs`,target:`_blank`,rel:`noreferrer noopener`,className:`flex-row items-center`,children:[(0,z.jsx)(st,{}),` `,(0,z.jsx)(`span`,{className:`hidden md:inline-block`,children:`Docs`})]})})}),(0,z.jsx)(Wi,{children:(0,z.jsx)(Gi,{asChild:!0,children:(0,z.jsxs)(j,{to:`/sign-in`,className:`flex-row items-center`,activeProps:fa,children:[(0,z.jsx)(lt,{}),` Sign In`]})})})]})})]})}function ga({menuItems:e}){let{user:t}=mi();return Di(t),(0,z.jsx)(`div`,{className:`hidden md:block`,children:(0,z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,z.jsxs)(`div`,{className:`inline-block`,children:[(0,z.jsx)(j,{to:`/`,children:(0,z.jsx)(Vi,{})}),(0,z.jsx)(Ji,{})]}),(0,z.jsx)(Ui,{children:(0,z.jsx)(Ki,{className:`text-grey-400`,children:e.map(e=>ma(e)?!!e.items.length&&(0,z.jsx)(`div`,{className:`bg-black rounded-2xl flex`,children:e.items.map(e=>(0,z.jsx)(_a,{menuItem:e},e.text))},e.text):(0,z.jsx)(_a,{menuItem:e},e.text))})})]})})}function _a({menuItem:e}){return(0,z.jsx)(Wi,{className:`text-gray-400 hover:text-white`,children:(0,z.jsx)(Gi,{asChild:!0,children:(0,z.jsxs)(j,{to:e.to,onClick:e.onClick,className:`flex-row items-center`,target:e.target,activeProps:e.to?fa:void 0,children:[e.icon,(0,z.jsx)(`span`,{className:`hidden ${e.textBreakpoint}:inline-block`,children:e.text}),(0,z.jsx)(`span`,{className:`${e.textBreakpoint}:hidden`,children:`\xA0`})]})})})}function va({menuItems:e}){let{user:t}=mi();Di(t);let[n,r]=(0,L.useState)(!1),i=(0,L.useCallback)(()=>r(e=>!e),[]),a=(0,L.useCallback)(()=>r(!1),[]);return(0,z.jsxs)(`div`,{className:`md:hidden`,id:`mobile-menu`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,z.jsx)(j,{to:`/`,children:(0,z.jsx)(Vi,{})}),(0,z.jsx)(Ji,{}),(0,z.jsxs)(`button`,{type:`button`,className:`shadow-xs text-grey-400 hover:text-white hover:bg-black-dark`,onClick:i,children:[(0,z.jsx)(`span`,{className:`sr-only`,children:n?`Close menu`:`Open menu`}),n?(0,z.jsx)(Zn,{}):(0,z.jsx)(tt,{})]})]}),(0,z.jsx)(`div`,{className:`${n?`fixed`:`hidden`} top-40 bottom-0 left-0 right-0 bg-black-dark opacity-70`,onClick:a}),(0,z.jsx)(`div`,{className:`${n?`block`:`hidden`} md:hidden z-50 space-y-1 pb-3 bg-black-dark absolute left-0 top-full w-full rounded-b-md`,children:e.map(e=>ma(e)?!!e.items.length&&(0,z.jsx)(`div`,{className:`bg-black pl-10 pr-2 py-2`,children:e.items.map(e=>(0,z.jsx)(ya,{menuItem:e,onClick:a},e.text))},e.text):(0,z.jsx)(ya,{menuItem:e,onClick:a},e.text))})]})}function ya({menuItem:e,onClick:t}){let n=(0,L.useCallback)(()=>{e.onClick?.(),t()},[e,t]);return(0,z.jsxs)(j,{to:e.to,onClick:n,target:e.target,className:`flex flex-row px-3 py-2 text-base font-medium rounded-md text-gray-400 hover:text-white`,activeProps:e.to?fa:void 0,children:[e.icon,(0,z.jsx)(`span`,{className:`ml-4`,children:e.text})]})}function ba(){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`header`,{className:`fixed top-0 z-40 w-full h-20 p-4 bg-black-dark dark:bg-black-dark dark:border-b dark:border-black md:px-12`,children:(0,z.jsx)(pa,{})}),(0,z.jsxs)(`div`,{className:`pt-20 grid h-screen grid-cols-1 md:grid-cols-2`,children:[(0,z.jsx)(`section`,{className:`items-center justify-center hidden text-white md:flex px-6 fabricSignupTextContainer`,children:(0,z.jsx)(`img`,{className:`object-scale-down max-h-[calc(100vh-80px-40px)] min-h-115`,src:`/fabric-signup-text.png`,alt:`One Runtime: App, database, Cache and Messaging. Distributed by design, free to deploy, and live in minutes. Deploy!`})}),(0,z.jsx)(`section`,{className:`flex items-center justify-center px-6 bg-linear-(--purple-gradient) dark:bg-linear-(--black-dark-gradient)`,children:(0,z.jsx)(rt,{})})]})]})}var xa;function Sa(){(0,L.useEffect)(()=>{},[])}var Ca=[`gmail.com`,`yahoo.com`,`hotmail.com`,`outlook.com`,`icloud.com`,`aol.com`,`protonmail.com`,`mail.com`,`zoho.com`,`yandex.com`,`gmx.com`,`live.com`,`msn.com`,`me.com`,`inbox.com`];function wa(e){if(!e||!e.includes(`@`))return null;let t=e.split(`@`).pop()||``;if(!t)return null;for(let e of Ca)if(t===e||t.endsWith(`.`+e))return null;return t}var Ta=null;function Ea(){let e=T(),t=kn(),n=Vt(),{redirect:r}=zn({strict:!1});return(0,L.useEffect)(()=>{Ta||=(async function(){let i=await oi().catch(()=>null);if(!i)k.error(`We were not able to verify your sign-in. Please try signing in again.`,{duration:1e4}),await e({to:`/sign-in`});else{I.setUserForEntity(F,i);let a=Di(i);Li(i);let o=wa(i.email);xa?.identify?.({username:i.email,type:`email`,...o?{company:o}:{}}),await n.invalidateQueries({queryKey:si,refetchType:`none`}),await t.invalidate(),await e({to:r?.startsWith(`/`)?r:a})}Ta=null})()},[]),(0,z.jsxs)(`div`,{className:`text-white w-lg flex flex-col gap-4`,children:[(0,z.jsxs)(`h1`,{className:`text-3xl font-light`,children:[(0,z.jsx)(`span`,{"aria-hidden":`true`,className:`text-2xl animate-flower-dance mr-4`,title:`Loading`,children:`🌼`}),`Checking...`]}),(0,z.jsx)(`div`,{className:`underline flex gap-4`,children:(0,z.jsx)(j,{className:`text-sm opacity-50 hover:text-blue-300`,to:`/sign-in`,children:`Try signing in again`})})]})}function Da({delayDuration:e=0,...t}){return(0,z.jsx)(Te,{"data-slot":`tooltip-provider`,delayDuration:e,...t})}function Oa({...e}){return(0,z.jsx)(Da,{children:(0,z.jsx)(Re,{"data-slot":`tooltip`,...e})})}function ka({...e}){return(0,z.jsx)(Kn,{"data-slot":`tooltip-trigger`,...e})}function Aa({className:e,sideOffset:t=0,arrowClassName:n,children:r,...i}){return(0,z.jsx)(Dt,{children:(0,z.jsxs)(yt,{"data-slot":`tooltip-content`,sideOffset:t,className:R(`bg-primary text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance`,e),...i,children:[r,(0,z.jsx)(ke,{className:R(`bg-primary fill-primary z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]`,n)})]})})}var ja=new Map;function Ma(e){if(!e)return``;if(ja.has(e))return ja.get(e);let t=e.replace(/[-_]+/g,` `).replace(/\s+/g,` `).trim();if(!t)return ja.set(e,``),``;let n=t.match(/([A-Z]+(?=[A-Z][a-z])|[A-Z]?[a-z]+|[A-Z]+|[0-9]+)/g);if(!n)return ja.set(e,``),``;let r=[];for(let e=0;e<n.length;e++){let t=n[e],i=e+1<n.length?n[e+1]:void 0;/^[A-Z]{2,}$/.test(t)&&i&&/[A-Z]*s$/.test(i)||/^[A-Z]$/.test(t)&&i!==void 0&&/^[A-Z]s$/.test(i)?(r.push(t+i),e++):r.push(t)}let i=r.map(Na).join(` `);return ja.set(e,i),i}function Na(e){return/^[A-Z]{2,3}s?$/.test(e)||/^[0-9]+$/.test(e)?e:e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}function Pa({restartRequired:e}){let t=Pe(),{organization:n,instance:r,cluster:i}=Nt({strict:!1});return(0,z.jsxs)(`div`,{role:`list`,className:`flex items-center space-x-2 xl:space-x-4 sm:max-w-9/10 max-w-[calc(100%-56px)]`,children:[...(0,L.useMemo)(()=>{let e=t.pathname.split(`/`).filter(e=>e&&e.length>0),a=[(0,z.jsxs)(j,{to:`/`,children:[(0,z.jsx)(Ee,{"aria-hidden":`true`,className:`size-5 shrink-0`}),(0,z.jsx)(`span`,{className:`sr-only`,children:`Home`})]},`home`)];for(let t=0;t<e.length;t++){let o=e[t];if(o===`instance`)continue;let s=`/${e.slice(0,t+1).join(`/`)}`,c=Ma(o);o===`databases`&&e.length===t+3?(c=e[t+2],t+=2):c.startsWith(`Org `)?c=n?.name||`Org`:c.startsWith(`Clu `)?(c=i?.name||`Cluster`,e[t+1]===`instance`&&(s+=`/instances`)):c.startsWith(`Ins `)?c=r?.name?.split(`.`)?.shift()||`Instance`:c===`Apis`&&(c=`APIs`),a.push((0,z.jsx)(`svg`,{fill:`currentColor`,viewBox:`0 0 20 20`,"aria-hidden":`true`,className:`size-5 shrink-0 text-grey`,children:(0,z.jsx)(`path`,{d:`M5.555 17.776l8-16 .894.448-8 16-.894-.448z`})},a.length+`-dash`),(0,z.jsx)(j,{to:s,className:`text-xs md:text-sm font-medium hover:text-grey truncate max-w-48`,children:c},s))}return a},[t.pathname,i?.name,r?.name,n?.name]),e&&(0,z.jsxs)(Oa,{children:[(0,z.jsx)(ka,{asChild:!0,children:(0,z.jsxs)(`div`,{className:`text-xs italic text-muted-foreground`,children:[`* Restart `,(0,z.jsx)(`span`,{className:`hidden lg:inline-block`,children:`Requested`})]})}),(0,z.jsxs)(Aa,{side:`bottom`,children:[`This `,`Instance`,` is requesting a restart, when convenient, to apply your latest changes.`,(0,z.jsx)(`br`,{}),`You can do this from the Apps or Config pages.`]})]})]})}var H=Ve,Fa=(0,L.createContext)({}),Ia=(0,L.createContext)({});function La(){let e=(0,L.useContext)(Fa),t=(0,L.useContext)(Ia),{getFieldState:n}=se(),r=Ct({name:e.name}),i=n(e.name,r);if(!e)throw Error(`useFormField should be used within <FormField>`);let{id:a}=t;return{id:a,name:e.name,formItemId:`${a}-form-item`,formDescriptionId:`${a}-form-item-description`,formMessageId:`${a}-form-item-message`,...i}}function U({...e}){let{error:t,formItemId:n,formDescriptionId:r,formMessageId:i}=La();return(0,z.jsx)(Gn,{"data-slot":`form-control`,id:n,"aria-describedby":t?`${r} ${i}`:`${r}`,"aria-invalid":!!t,...e})}function W({...e}){return(0,z.jsx)(Fa,{value:{name:e.name},children:(0,z.jsx)(Me,{...e})})}function G({className:e,...t}){return(0,z.jsx)(Ia,{value:{id:(0,L.useId)()},children:(0,z.jsx)(`div`,{"data-slot":`form-item`,className:R(`grid gap-2`,e),...t})})}function Ra({className:e,...t}){return(0,z.jsx)(xe,{"data-slot":`label`,className:R(`text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50`,e),...t})}function K({className:e,...t}){let{error:n,formItemId:r}=La();return(0,z.jsx)(Ra,{"data-slot":`form-label`,"data-error":!!n,className:R(`data-[error=true]:text-destructive`,e),htmlFor:r,...t})}function q({className:e,...t}){let{error:n,formMessageId:r}=La(),i=n?String(n?.message):t.children;return i?(0,z.jsx)(`p`,{"data-slot":`form-message`,id:r,className:R(`text-destructive text-sm`,e),...t,children:i}):null}function J({className:e,type:t,...n}){return(0,z.jsx)(`input`,{type:t,"data-slot":`input`,className:R(`border-input file:text-foreground placeholder:text-muted-foreground selection:bg-purple
25
- selection:text-primary-foreground
26
- dark:aria-invalid:outline-destructive dark:aria-invalid:ring-destructive/50 ring-ring/10
27
- dark:ring-ring/20 dark:outline-ring/40 outline-ring/50 aria-invalid:outline-destructive/60
28
- aria-invalid:ring-destructive/20 aria-invalid:border-destructive/60 dark:aria-invalid:border-destructive
29
- flex h-9 w-full min-w-0 rounded-md border bg-grey-700 px-3 py-1 text-base text-white
30
- file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium
31
- focus-visible:ring-1 focus-visible:outline-none focus-visible:ring-purple disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50
32
- aria-invalid:focus-visible:ring-[1px] aria-invalid:focus-visible:outline-none md:text-sm dark:aria-invalid:focus-visible:ring-1`,e),...n})}var za=[`RUNNING`],Ba=[`TERMINATING`,`TERMINATED`,`REMOVED`];function Va(){return`https://fabric.harper.fast/#/?createCluster=`+encodeURIComponent(JSON.stringify({deploymentDescription:`Self-Hosted`,performanceDescription:`Self Supported and Managed`,instances:[{secure:String(location.protocol===`https:`),fqdn:location.hostname,port:parseInt(location.port,10)}]}))}async function Ha({username:e,password:t,instanceClient:n,entityId:r}){let i={username:e,password:t};I.checkForBasicAuth(r)&&(n.defaults.auth=i,n.defaults.withCredentials=!1);let{data:{message:a}}=await n.post(`/`,{operation:`login`,username:e,password:t});if(!I.checkForBasicAuth(r))try{return{message:a,user:await ui({instanceClient:n})}}catch(e){console.error(`Failed to get user after login, trying basic auth`,e)}try{n.defaults.auth=i,n.defaults.withCredentials=!1;let e=await ui({instanceClient:n,auth:i});return I.flagForBasicAuth(r,i),{message:a,user:e}}catch(e){throw n.defaults.auth=void 0,n.defaults.withCredentials=!0,e}let o=ai({id:r,forceFabricConnect:!0}),s=await ui({instanceClient:o});return I.flagForFabricConnect(r,!0),{message:a,user:s,instanceClient:o}}function Ua(){return E({mutationFn:Ha})}function Wa({cluster:e,instance:t,instanceParams:n}){let r=T(),i=kn(),{redirect:a}=zn({strict:!1}),{mutate:o,isPending:s}=Ua();return{isPending:s,submitForm:(0,L.useCallback)(async s=>{o({...s,...n},{onSuccess:async({message:n,user:o})=>{if(k.success(n),e?.instances?.length&&!t)for(let t of e.instances)I.setUserForEntity(t,o);let s=F;if(!s)throw Error(`Sign in failed due to missing cluster or instance.`);I.setUserForEntity(s,o),i.invalidate(),await r({to:a?.startsWith(`/`)?a:`/`})}})},[e,t,n,r,a,i,o])}}async function Ga(e){let{data:t}=await P.get(`/Cluster/${e}`);return t}function Ka(e,t){return A({queryKey:[e],queryFn:()=>Ga(e),retry:!1,staleTime:1900,enabled:!!e,refetchInterval:t?t===!0?1e4:t:void 0})}var qa=c({error:`Please enter a valid email address.`}).toLowerCase().trim(),Ja=v().nonempty({error:`Please enter your password.`}),Ya=v().nonempty({error:`Please enter a username.`}),Xa=l({username:Ya,password:Ja}),Za=l({email:qa,password:Ja});function Qa({entityId:e,instanceClient:t}){return A({queryKey:[e,`health`],queryFn:async()=>{try{return await t.get(`/health`),!0}catch{return!1}},retry:2,refetchInterval:5e3})}var $a=[`localhost`,`127.0.0.1`],eo=function(e){return e.MixedLoopback=`MixedLoopback`,e.InsecureCookieOutsideChromeAndFirefox=`InsecureCookieOutsideChromeAndFirefox`,e}({});function to(e,t,n){if(!n||!t||!e)return null;let r=new URL(n).hostname,i=$a.includes(t),a=$a.includes(r);if(i&&a&&r!==t)return eo.MixedLoopback;if(!i&&a){let t=e.indexOf(`Chrome`)>=0,n=e.indexOf(`Firefox`)>=0;if(!t&&!n)return eo.InsecureCookieOutsideChromeAndFirefox}return null}function no(){let{clusterId:e,instanceId:t}=M({strict:!1}),{data:n}=D(Ka(e,!0)),r=(0,L.useMemo)(()=>t&&n&&n?.instances?.find(e=>e.id===t)||void 0,[n,t]),i=(0,L.useMemo)(()=>n?.status&&za.includes(n.status),[n?.status]),a=`instance`,o=(0,L.useMemo)(()=>n?r?(I.flagForFabricConnect(r.id,!1),fi(r)):(I.flagForFabricConnect(n.id,!1),di(n)):null,[n,r]),s=V({operationsUrl:o}),c=(0,L.useMemo)(()=>o?.includes(`localhost`)||o?.includes(`127.0.0.1`),[o]),l=(0,L.useMemo)(()=>to(navigator.userAgent,location.hostname,o),[o]),{data:u}=D(Qa(s)),d=N({resolver:w(Xa),defaultValues:{username:``,password:``}}),{control:f,handleSubmit:p}=d,{submitForm:m,isPending:h}=Wa({cluster:n,instance:r,instanceParams:s});return!t&&n&&!n?.fqdn?(0,z.jsx)(vn,{to:`../instances`,replace:!0}):i&&n?.resetPassword?(0,z.jsx)(vn,{to:`/${n.organizationId}/${n.id}/finish-setup`,replace:!0}):!i&&n?.resetPassword?(0,z.jsx)(vn,{to:`/${n.organizationId}/${n.id}/starting-up`,replace:!0}):(0,z.jsxs)(z.Fragment,{children:[!1,(0,z.jsx)(`div`,{className:`h-screen items-center justify-center flex`,children:(0,z.jsxs)(`div`,{className:`text-white w-xs`,children:[(0,z.jsxs)(`h2`,{className:`text-2xl font-light`,children:[`Sign in to Harper `,`Local`]}),(0,z.jsx)(H,{...d,children:(0,z.jsxs)(`form`,{id:`auth-${a}-signin-form`,name:`auth-${a}-signin-form`,onSubmit:p(m),className:`my-4`,children:[(0,z.jsx)(W,{control:f,name:`username`,render:({field:e})=>(0,z.jsxs)(G,{className:`my-4`,children:[(0,z.jsx)(K,{children:`Username`}),(0,z.jsx)(U,{children:(0,z.jsx)(J,{autoComplete:`username`,autoFocus:!0,type:`text`,...e})}),(0,z.jsx)(q,{})]})}),(0,z.jsx)(W,{control:f,name:`password`,render:({field:e})=>(0,z.jsxs)(G,{className:`my-4`,children:[(0,z.jsx)(K,{children:`Password`}),(0,z.jsx)(U,{children:(0,z.jsx)(J,{type:`password`,...e})}),(0,z.jsx)(q,{})]})}),(0,z.jsx)(B,{disabled:h,type:`submit`,variant:`submit`,className:`w-full my-2 rounded-full`,children:`Sign In`}),u===!1&&(0,z.jsxs)(`div`,{className:`p-4 mt-4 text-sm text-yellow-800 rounded-lg bg-yellow-50 dark:bg-gray-800 dark:text-yellow-300`,role:`alert`,children:[(0,z.jsx)(`span`,{className:`font-medium`,children:`Warning!`}),` This `,a,` is not responding to GET`,` `,(0,z.jsxs)(`a`,{href:`${o}health`,className:`underline`,target:`_blank`,children:[o,`health`]}),` `,`checks.`,(0,z.jsxs)(`ol`,{className:`list-decimal ml-8 mt-2`,children:[(0,z.jsx)(`li`,{children:`Is the server running?`}),(0,z.jsxs)(`li`,{children:[`Have you`,` `,(0,z.jsx)(`a`,{href:`https://docs.harperdb.io/docs/developers/security/configuration#cors`,target:`_blank`,rel:`noreferrer`,className:`underline`,children:`enabled CORS`}),` `,`for the operations API?`]}),c&&(0,z.jsxs)(`li`,{children:[`Have you allowed`,` `,(0,z.jsx)(`a`,{href:`https://www.google.com/search?q=How+do+I+enable+local+network+access+in+my+browser%3F`,className:`underline`,target:`_blank`,rel:`noreferrer`,children:`local network access`}),` `,`in your browser?`]})]})]}),l===eo.MixedLoopback&&(0,z.jsxs)(`div`,{className:`p-4 mt-4 text-sm text-yellow-800 rounded-lg bg-yellow-50 dark:bg-gray-800 dark:text-yellow-300`,role:`alert`,children:[(0,z.jsx)(`span`,{className:`font-medium`,children:`Warning!`}),` `,`Your login might not work because you're mixing 127.0.0.1 and localhost. Pick one or the other.`]}),l===eo.InsecureCookieOutsideChromeAndFirefox&&(0,z.jsxs)(`div`,{className:`p-4 mt-4 text-sm text-yellow-800 rounded-lg bg-yellow-50 dark:bg-gray-800 dark:text-yellow-300`,role:`alert`,children:[(0,z.jsx)(`span`,{className:`font-medium`,children:`Warning!`}),` `,`Your login might not work because your browser doesn't consider localhost to be secure, so it doesn't pass the cookies along. Firefox or Chromium based browsers should pass the cookies properly.`]}),(0,z.jsxs)(`div`,{className:`p-4 mt-4 text-sm rounded-lg bg-purple-950`,role:`alert`,children:[(0,z.jsx)(`span`,{className:`font-medium`,children:`Did you know?`}),` `,`You can add this instance to your Harper account to manage it remotely.`,(0,z.jsx)(`div`,{className:`text-center pt-2`,children:(0,z.jsx)(j,{to:Va(),target:`_blank`,children:(0,z.jsx)(B,{type:`button`,variant:`positive`,children:`Connect to Harper Fabric`})})})]})]})})]})})]})}async function ro({email:e}){let{data:t}=await P.post(`/ForgotPassword/`,{email:e});if(t)return t;throw Error(`Something went wrong`)}function io(){return E({mutationFn:e=>ro(e)})}var ao=l({email:qa});function oo(){let e=T(),{me:t}=zn({strict:!1}),n=N({resolver:w(ao),defaultValues:{email:t||``}}),r=n.watch(`email`),{setFocus:i,control:a,handleSubmit:o}=n;(0,L.useEffect)(()=>{i(`email`)},[i]);let{mutate:s,isPending:c}=io(),l=async t=>{s(t,{onSuccess:t=>{k.success(`Success`,{description:`${t}`,action:{label:`Dismiss`,onClick:()=>k.dismiss()}}),e({to:`/sign-in`,search:{me:r}})}})};return(0,z.jsxs)(`div`,{className:`text-white w-xs`,children:[(0,z.jsx)(`h2`,{className:`text-2xl font-light`,children:`Enter your account email`}),(0,z.jsx)(`p`,{className:`text-sm pt-1`,children:`If a matching account exists, we'll send you a password reset link.`}),(0,z.jsx)(H,{...n,children:(0,z.jsxs)(`form`,{id:`auth-forgot-password-form`,name:`auth-forgot-password-form`,onSubmit:o(l),className:`my-4`,children:[(0,z.jsx)(W,{control:a,name:`email`,render:({field:e})=>(0,z.jsxs)(G,{className:`my-2`,children:[(0,z.jsx)(K,{children:`Email`}),(0,z.jsx)(U,{children:(0,z.jsx)(J,{disabled:c,type:`email`,className:`bg-purple-400 border-purple-400 dark:bg-black dark:border-black`,...e})}),(0,z.jsx)(q,{})]})}),(0,z.jsx)(B,{type:`submit`,variant:`submit`,disabled:c,className:`w-full my-2 rounded-full`,children:`Send Password Reset Email`})]})}),(0,z.jsxs)(`div`,{className:`flex px-4 mt-4 underline place-content-between`,children:[(0,z.jsx)(j,{className:`text-sm hover:text-blue-300`,to:`/sign-in`,search:{me:r},children:`Sign in to your account`}),(0,z.jsx)(j,{className:`text-sm hover:text-blue-300`,to:`/sign-up`,search:{me:r},children:`Sign up for free`})]})]})}var so=async({token:e,password:t})=>{let{data:n}=await P.put(`/ResetPassword/`,{token:e,newPassword:t});return n};function co(){return E({mutationFn:e=>so(e)})}var lo=l({password:Ja.min(8,{error:`Password must be at least 8 characters long.`}).max(50,{error:`Password cannot be longer than 50 characters.`}),confirmPassword:v()}).refine(e=>e.password===e.confirmPassword,{error:`Passwords do not match.`,path:[`confirmPassword`]});function uo(){let{token:e}=zn({strict:!1}),t=T();(0,L.useEffect)(()=>{e||t({to:`/sign-in`})},[e,t]);let n=N({resolver:w(lo),defaultValues:{password:``,confirmPassword:``}}),{setFocus:r,control:i,handleSubmit:a}=n;(0,L.useEffect)(()=>{r(`password`)},[r]);let{mutate:o,isPending:s}=co(),c=(0,L.useCallback)(async n=>{o({token:e,password:n.password},{onSuccess:()=>{k.success(`Success`,{description:`Your password has been reset successfully.`,action:{label:`Dismiss`,onClick:()=>k.dismiss()}}),t({to:`/sign-in`})}})},[t,o,e]);return(0,z.jsxs)(`div`,{className:`text-white w-xs`,children:[(0,z.jsx)(`h2`,{className:`text-2xl font-light`,children:`Reset Password`}),(0,z.jsx)(H,{...n,children:(0,z.jsxs)(`form`,{id:`auth-reset-password-form`,name:`auth-reset-password-form`,className:`my-4`,onSubmit:a(c),children:[(0,z.jsx)(W,{control:i,name:`password`,render:({field:e})=>(0,z.jsxs)(G,{className:`my-2`,children:[(0,z.jsx)(K,{children:`New Password`}),(0,z.jsx)(U,{children:(0,z.jsx)(J,{disabled:s,type:`password`,className:`bg-purple-400 border-purple-400 dark:bg-black dark:border-black`,...e})}),(0,z.jsx)(q,{})]})}),(0,z.jsx)(W,{control:i,name:`confirmPassword`,render:({field:e})=>(0,z.jsxs)(G,{className:`my-2`,children:[(0,z.jsx)(K,{children:`Confirm Password`}),(0,z.jsx)(U,{children:(0,z.jsx)(J,{disabled:s,type:`password`,className:`bg-purple-400 border-purple-400 dark:bg-black dark:border-black`,...e})}),(0,z.jsx)(q,{})]})}),(0,z.jsx)(B,{variant:`submit`,type:`submit`,disabled:s,className:`w-full my-2 rounded-full`,children:`Submit New Password`})]})})]})}function fo({text:e,disabled:t,onClick:n}){return(0,z.jsx)(`a`,{href:`/oauth/github/login?redirect=%2F%23%2Fcheck-oauth`,onClick:n,children:(0,z.jsxs)(`button`,{className:i(`github-signin-btn`,t&&`opacity-50`),type:`button`,children:[(0,z.jsx)(`img`,{src:`/github/GitHub_Invertocat_White.svg`,alt:`GitHub Logo`,className:`github-icon`}),e]})})}function po({text:e,disabled:t,onClick:n}){return(0,z.jsx)(`a`,{href:`/oauth/google/login?redirect=%2F%23%2Fcheck-oauth`,onClick:n,children:(0,z.jsxs)(`button`,{className:i(`gsi-material-button`,t&&`opacity-50`),type:`button`,children:[(0,z.jsx)(`div`,{className:`gsi-material-button-state`}),(0,z.jsxs)(`div`,{className:`gsi-material-button-content-wrapper`,children:[(0,z.jsx)(`div`,{className:`gsi-material-button-icon`,children:(0,z.jsxs)(`svg`,{version:`1.1`,xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 48 48`,xmlnsXlink:`http://www.w3.org/1999/xlink`,className:`block`,children:[(0,z.jsx)(`path`,{fill:`#EA4335`,d:`M24 9.5c3.54 0 6.71 1.22 9.21 3.6l6.85-6.85C35.9 2.38 30.47 0 24 0 14.62 0 6.51 5.38 2.56 13.22l7.98 6.19C12.43 13.72 17.74 9.5 24 9.5z`}),(0,z.jsx)(`path`,{fill:`#4285F4`,d:`M46.98 24.55c0-1.57-.15-3.09-.38-4.55H24v9.02h12.94c-.58 2.96-2.26 5.48-4.78 7.18l7.73 6c4.51-4.18 7.09-10.36 7.09-17.65z`}),(0,z.jsx)(`path`,{fill:`#FBBC05`,d:`M10.53 28.59c-.48-1.45-.76-2.99-.76-4.59s.27-3.14.76-4.59l-7.98-6.19C.92 16.46 0 20.12 0 24c0 3.88.92 7.54 2.56 10.78l7.97-6.19z`}),(0,z.jsx)(`path`,{fill:`#34A853`,d:`M24 48c6.48 0 11.93-2.13 15.89-5.81l-7.73-6c-2.15 1.45-4.92 2.3-8.16 2.3-6.26 0-11.57-4.22-13.47-9.91l-7.98 6.19C6.51 42.62 14.62 48 24 48z`}),(0,z.jsx)(`path`,{fill:`none`,d:`M0 0h48v48H0z`})]})}),(0,z.jsx)(`span`,{className:`gsi-material-button-contents`,children:e}),(0,z.jsx)(`span`,{className:`hidden`,children:e})]})]})})}function mo(){let e=T(),t=Vt(),n=kn(),{redirect:r}=zn({strict:!1}),{mutate:i,isPending:a}=ho();return{isPending:a,submitForm:(0,L.useCallback)(a=>{i(a,{onSuccess:async i=>{I.setUserForEntity(F,i);let a=Di(i);Li(i);let o=wa(i.email);xa?.identify?.({username:i.email,type:`email`,...o?{company:o}:{}}),await t.invalidateQueries({queryKey:si,refetchType:`none`}),n.invalidate(),await e({to:r?.startsWith(`/`)?r:a})}})},[e,t,r,n,i])}}function ho(){return E({mutationFn:e=>go(e)})}async function go({email:e,password:t}){let{data:n}=await P.post(`/Login/`,{email:e,password:t});if(n)return n;throw Error(`Something went wrong`)}function _o(){let{me:e}=zn({strict:!1}),t=N({resolver:w(Za),defaultValues:{email:e||``,password:``}}),{handleSubmit:n,control:r}=t,i=t.watch(`email`),{submitForm:a,isPending:o}=mo();return(0,z.jsxs)(`div`,{className:`text-white w-xs`,children:[(0,z.jsx)(`h2`,{className:`text-2xl font-light`,children:`Sign in to Harper Fabric`}),(0,z.jsx)(H,{...t,children:(0,z.jsxs)(`form`,{id:`auth-signin-form`,name:`auth-signin-form`,onSubmit:n(a),className:`my-4`,children:[(0,z.jsx)(W,{control:r,name:`email`,render:({field:e})=>(0,z.jsxs)(G,{className:`my-4`,children:[(0,z.jsx)(K,{children:`Email`}),(0,z.jsx)(U,{children:(0,z.jsx)(J,{type:`email`,autoFocus:!0,autoComplete:`email`,className:`bg-purple-400 border-purple-400 dark:bg-black dark:border-black`,...e})}),(0,z.jsx)(q,{})]})}),(0,z.jsx)(W,{control:r,name:`password`,render:({field:e})=>(0,z.jsxs)(G,{className:`my-4`,children:[(0,z.jsx)(K,{children:`Password`}),(0,z.jsx)(U,{children:(0,z.jsx)(J,{type:`password`,autoComplete:`current-password`,className:`bg-purple-400 border-purple-400 dark:bg-black dark:border-black`,...e})}),(0,z.jsx)(q,{})]})}),(0,z.jsx)(B,{type:`submit`,variant:`submit`,className:`w-full my-2 rounded-full`,disabled:o,children:`Sign In`}),(0,z.jsxs)(`div`,{className:`flex px-4 mt-4 underline place-content-between`,children:[(0,z.jsx)(j,{className:`text-sm hover:text-blue-300`,to:`/sign-up`,search:{me:i},children:`Sign up for free`}),(0,z.jsx)(j,{className:`text-sm hover:text-blue-300`,to:`/forgot-password`,search:{me:i},children:`Forgot password?`})]})]})}),(0,z.jsx)(`hr`,{className:`border-gray-600 my-6`}),(0,z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,z.jsx)(po,{text:`Sign in with Google`}),(0,z.jsx)(fo,{text:`Sign in with GitHub`})]})]})}var vo=/^[a-zA-ZàáâäãåąčćęèéêëėįìíîïłńòóôöõøùúûüųūÿýżźñçčšžæÀÁÂÄÃÅĄĆČĖĘÈÉÊËÌÍÎÏĮŁŃÒÓÔÖÕØÙÚÛÜŲŪŸÝŻŹÑßÇŒÆČŠŽ∂ð ,'-]+$/u;async function yo(e){let{data:t}=await P.post(`/User/`,e);if(t)return t;throw Error(`Something went wrong`)}function bo(){return E({mutationFn:e=>yo(e)})}var xo=l({email:qa.max(80,{error:`Email cannot be longer than 80 characters.`}),firstname:v().trim().min(2,{error:`Please enter your first name.`}).regex(vo,{error:`First name can only contain letters, spaces, and hyphens.`}).max(40,{error:`First name cannot be longer than 40 characters.`}),lastname:v().trim().min(2,{error:`Please enter your last name.`}).regex(vo,{error:`Last name can only contain letters, spaces, and hyphens.`}).max(80,{error:`Last name cannot be longer than 80 characters.`}),password:Ja.min(8,{error:`Password must be at least 8 characters long.`}),confirmPassword:v(),acceptTerms:_().refine(e=>e===!0,{message:`You must accept the Privacy Policy and Terms of Service.`})}).refine(e=>e.password===e.confirmPassword,{error:`Passwords do not match.`,path:[`confirmPassword`]});function So(){let e=T(),{email:t,me:n}=zn({strict:!1}),[r,i]=(0,L.useState)(!1),a=N({resolver:w(xo),defaultValues:{firstname:``,lastname:``,email:n||t||``,password:``,confirmPassword:``,acceptTerms:!1}}),o=a.watch(`email`),s=a.watch(`acceptTerms`),{setFocus:c,control:l,handleSubmit:u}=a;(0,L.useEffect)(()=>{c(`firstname`)},[c]);let{mutate:d}=bo(),f=(0,L.useCallback)(async t=>{let{confirmPassword:n,acceptTerms:r,...i}=t;d(i,{onSuccess:()=>{let t=wa(i.email);xa?.identify?.({username:i.email,type:`email`,firstname:i.firstname,lastname:i.lastname,...t?{company:t}:{}}),e({to:`/verifying?email=`+encodeURIComponent(i.email)})}})},[e,d]),p=(0,L.useCallback)(e=>{if(!s)return i(!0),setTimeout(()=>i(!1),1e3),e.preventDefault(),!1},[s]),m=(0,z.jsx)(W,{control:l,name:`acceptTerms`,render:({field:e})=>(0,z.jsxs)(G,{className:`flex flex-row items-start space-x-3 space-y-0 p-1 transition-colors duration-300 ${r?`bg-red-500/20 animate-pulse rounded`:``}`,children:[(0,z.jsx)(U,{children:(0,z.jsx)(J,{type:`checkbox`,className:`size-4 rounded border-gray-300 bg-white text-purple-600 focus:ring-purple-500`,checked:e.value,onChange:e.onChange})}),(0,z.jsxs)(`div`,{className:`space-y-1 leading-none`,children:[(0,z.jsxs)(K,{className:`text-xs font-normal`,children:[`I accept the`,` `,(0,z.jsx)(`a`,{href:`https://www.harper.fast/resources/privacy-policy`,target:`_blank`,rel:`noreferrer`,className:`underline hover:text-blue-300`,children:`Privacy Policy`}),` `,`and`,` `,(0,z.jsx)(`a`,{href:`https://www.harper.fast/resources/paas-terms-of-service`,target:`_blank`,rel:`noreferrer`,className:`underline hover:text-blue-300`,children:`Terms of Service`})]}),(0,z.jsx)(q,{})]})]})});return(0,z.jsxs)(`div`,{className:`text-white w-xs`,children:[(0,z.jsx)(`h2`,{className:`text-2xl font-light`,children:`Sign up for Harper Fabric`}),(0,z.jsxs)(H,{...a,children:[(0,z.jsxs)(`div`,{className:`flex flex-col gap-2 my-6`,children:[m,(0,z.jsx)(po,{text:`Sign up with Google`,disabled:!s,onClick:p}),(0,z.jsx)(fo,{text:`Sign up with GitHub`,disabled:!s,onClick:p})]}),(0,z.jsx)(`hr`,{className:`border-gray-600`}),(0,z.jsxs)(`form`,{id:`auth-signup-form`,name:`auth-signup-form`,onSubmit:u(f),className:`grid gap-4 my-4`,children:[(0,z.jsx)(W,{control:l,name:`firstname`,render:({field:e})=>(0,z.jsxs)(G,{children:[(0,z.jsx)(K,{className:`pb-1`,children:`First Name`}),(0,z.jsx)(U,{children:(0,z.jsx)(J,{type:`text`,className:`bg-purple-400 border-purple-400 dark:bg-black dark:border-black`,autoCapitalize:`words`,...e})}),(0,z.jsx)(q,{})]})}),(0,z.jsx)(W,{control:l,name:`lastname`,render:({field:e})=>(0,z.jsxs)(G,{children:[(0,z.jsx)(K,{className:`pb-1`,children:`Last Name`}),(0,z.jsx)(U,{children:(0,z.jsx)(J,{type:`text`,className:`bg-purple-400 border-purple-400 dark:bg-black dark:border-black`,autoCapitalize:`words`,...e})}),(0,z.jsx)(q,{})]})}),(0,z.jsx)(W,{control:l,name:`email`,render:({field:e})=>(0,z.jsxs)(G,{children:[(0,z.jsx)(K,{className:`pb-1`,children:`Email`}),(0,z.jsx)(U,{children:(0,z.jsx)(J,{type:`email`,readOnly:!!t,disabled:!!t,className:`bg-purple-400 border-purple-400 dark:bg-black dark:border-black`,autoComplete:`email`,autoCapitalize:`none`,...e})}),(0,z.jsx)(q,{})]})}),(0,z.jsx)(W,{control:l,name:`password`,render:({field:e})=>(0,z.jsxs)(G,{children:[(0,z.jsx)(K,{className:`pb-1`,children:`Password`}),(0,z.jsx)(U,{children:(0,z.jsx)(J,{type:`password`,autoComplete:`new-password`,className:`bg-purple-400 border-purple-400 dark:bg-black dark:border-black`,...e})}),(0,z.jsx)(q,{})]})}),(0,z.jsx)(W,{control:l,name:`confirmPassword`,render:({field:e})=>(0,z.jsxs)(G,{children:[(0,z.jsx)(K,{className:`pb-1`,children:`Confirm Password`}),(0,z.jsx)(U,{children:(0,z.jsx)(J,{type:`password`,autoComplete:`new-password`,className:`bg-purple-400 border-purple-400 dark:bg-black dark:border-black`,...e})}),(0,z.jsx)(q,{})]})}),m,(0,z.jsx)(B,{type:`submit`,variant:`submit`,className:`w-full rounded-full my-4`,children:`Sign Up For Free`})]})]}),(0,z.jsx)(`div`,{className:`flex px-4 mt-4 underline place-content-between`,children:(0,z.jsx)(j,{className:`m-auto text-sm hover:text-blue-300`,to:`/sign-in`,search:{me:o},children:`Already have an account? Sign in instead.`})})]})}var Co=async({email:e})=>{let{data:t}=await P.post(`/ResendVerificationEmail/`,{email:e});return t};function wo(){return E({mutationFn:e=>Co(e)})}var To=async e=>{let{data:t}=await P.put(`/VerifyEmail/`,{token:e.toString()});return t};function Eo(){return E({mutationFn:e=>To(e)})}var Do=l({email:qa});function Oo(){let e=T(),{mutate:t,isPending:n}=wo(),r=N({resolver:w(Do),defaultValues:{email:``}}),i=r.watch(`email`),{setFocus:a,control:o,handleSubmit:s}=r;(0,L.useEffect)(()=>{a(`email`)},[a]);let c=(0,L.useCallback)(async n=>{t(n,{onSuccess:t=>{k.success(`Success`,{description:`${t}`,action:{label:`Dismiss`,onClick:()=>k.dismiss()}}),e({to:`/sign-in`,search:{me:i}})}})},[i,e,t]);return(0,z.jsxs)(H,{...r,children:[(0,z.jsx)(`p`,{className:`text-sm py-2`,children:`Please Enter an Email`}),(0,z.jsxs)(`form`,{id:`auth-verify-email-form`,name:`auth-verify-email-form`,onSubmit:s(c),className:`my-4`,children:[(0,z.jsx)(W,{control:o,name:`email`,render:({field:e})=>(0,z.jsxs)(G,{className:`my-2`,children:[(0,z.jsx)(K,{children:`Email`}),(0,z.jsx)(U,{children:(0,z.jsx)(J,{disabled:n,type:`email`,className:`bg-purple-400 border-purple-400 dark:bg-black dark:border-black`,...e})}),(0,z.jsx)(q,{})]})}),(0,z.jsx)(B,{type:`submit`,variant:`submit`,disabled:n,className:`w-full my-2 rounded-full`,children:`Send Verification Email`})]})]})}function ko(){let{token:e}=zn({strict:!1}),t=T(),{mutate:n,isPending:r}=Eo(),i=(0,L.useCallback)(e=>{n(e,{onSuccess:()=>{k.success(`Success`,{description:`Email verified successfully`,action:{label:`Dismiss`,onClick:()=>k.dismiss()}}),t({to:`/sign-in`})}})},[n,t]);return(0,L.useEffect)(()=>{e&&i(e)},[i,e]),(0,z.jsxs)(`div`,{className:`text-white w-xs`,children:[(0,z.jsx)(`h1`,{className:`text-3xl font-light`,children:`Verify Email`}),r?(0,z.jsx)(`p`,{className:`text-sm pt-1`,children:`Verifying email...`}):(0,z.jsx)(Oo,{})]})}function Ao(){let{email:e}=zn({strict:!1}),{mutate:t,isPending:n}=wo(),r=(0,L.useCallback)(n=>(n.preventDefault(),e&&t({email:e},{onSuccess:e=>{k.success(`Code Sent`,{description:`${e}`,action:{label:`Dismiss`,onClick:()=>k.dismiss()}})}}),!1),[e,t]);return(0,z.jsxs)(`div`,{className:`text-white w-lg flex flex-col gap-4`,children:[(0,z.jsxs)(`h1`,{className:`text-3xl font-light`,children:[(0,z.jsx)(`span`,{"aria-hidden":`true`,className:`text-2xl animate-flower-dance mr-4`,title:`Loading`,children:`🌼`}),`Check your email!`]}),(0,z.jsxs)(`p`,{children:[`Your account has been created! You should receive an email with a link to `,(0,z.jsx)(`strong`,{children:`[Verify My Email]`}),`!`]}),(0,z.jsxs)(`p`,{children:[`From: `,(0,z.jsx)(`strong`,{children:`harper@notifications.harperfabric.com`})]}),(0,z.jsxs)(`p`,{children:[`To: `,(0,z.jsx)(`strong`,{children:e||`your email`})]}),(0,z.jsx)(`p`,{children:`Can you click it? Then we can carry on to more fun things!`}),(0,z.jsxs)(`div`,{className:`underline flex gap-4`,children:[(0,z.jsx)(j,{className:`text-sm hover:text-blue-300`,to:`/sign-in`,search:{me:e},children:`I did it, let me sign in!`}),(0,z.jsx)(j,{className:`text-sm opacity-50 hover:text-blue-300`,to:void 0,onClick:r,disabled:n,children:`Send me another code, please.`})]})]})}var jo=O({getParentRoute:()=>zi,id:`_authLayout`,component:ba}),Mo=O({getParentRoute:()=>jo,path:`sign-in`,component:_o,beforeLoad:({context:e,location:t})=>{let n=e.authentication[F]?.user;if(n){let e=t?.search,r=Di(n);throw ar({to:e?.redirect?.startsWith(`/`)?e.redirect:r})}}}),No=O({getParentRoute:()=>zi,path:`sign-in`,component:no,beforeLoad:({context:e,location:t})=>{if(e.authentication.OverallAppSignIn?.user){let e=t?.search;throw ar({to:e?.redirect?.startsWith(`/`)?e.redirect:`/`})}}}),Po=O({getParentRoute:()=>jo,path:`sign-up`,component:So}),Fo=O({getParentRoute:()=>jo,path:`forgot-password`,component:oo}),Io=O({getParentRoute:()=>jo,path:`verify-email`,component:ko}),Lo=O({getParentRoute:()=>jo,path:`verifying`,component:Ao}),Ro=O({getParentRoute:()=>jo,path:`check-oauth`,component:Ea}),zo=O({getParentRoute:()=>jo,path:`reset-password`,component:uo});jo.addChildren([Mo,Po,Ro,Fo,Io,Lo,zo]);var Bo=[No];function Vo({children:e}){return(0,z.jsx)(`nav`,{className:`fixed top-20 w-full h-12 z-39 py-2 px-4 md:px-12 bg-grey-700`,children:(0,z.jsxs)(`div`,{className:`flex items-center h-full space-x-2`,children:[(0,z.jsx)(Pa,{}),e]})})}function Ho(e){if(Ko(e)||qo(e))return`warning`;if(Uo(e))return`success`;switch(e){case`STOPPED`:return`secondary`;case`TERMINATING`:case`TERMINATED`:case`FAILED`:case`REMOVED`:case`ERROR`:return`destructive`;default:return`default`}}function Uo(e){switch(e){case`RUNNING`:case`UPDATED`:return!0;default:return!1}}function Wo(e){switch(e){case`FAILED`:return!0;default:return!1}}function Go(e){switch(e){case`TERMINATED`:return!0;default:return!1}}function Ko(e){switch(e){case`CLONE_PENDING`:return!0;default:return!1}}function qo(e){switch(e){case`PROVISIONING`:case`CLONING`:case`CLONE_READY`:case`UPDATING_HDB_NODES`:case`UPDATING`:return!0;default:return!1}}function Y({...e}){return(0,z.jsx)(Sn,{"data-slot":`dialog`,...e})}function Jo({...e}){return(0,z.jsx)(Je,{"data-slot":`dialog-trigger`,...e})}function Yo({...e}){return(0,z.jsx)(ie,{"data-slot":`dialog-portal`,...e})}function Xo({className:e,...t}){return(0,z.jsx)(En,{"data-slot":`dialog-overlay`,className:R(`data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black-dark/90`,e),...t})}function X({className:e,children:t,...n}){return(0,z.jsxs)(Yo,{"data-slot":`dialog-portal`,children:[(0,z.jsx)(Xo,{}),(0,z.jsxs)(me,{"data-slot":`dialog-content`,className:R(`bg-black data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] lg:max-w-2xl max-h-screen overflow-y-auto translate-x-[-50%] translate-y-[-50%] gap-4 rounded-md p-6 shadow-lg duration-200`,e),...n,children:[t,(0,z.jsxs)(ve,{className:`ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,children:[(0,z.jsx)(Zn,{className:`text-white`}),(0,z.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})}function Zo({className:e,...t}){return(0,z.jsx)(`div`,{"data-slot":`dialog-header`,className:R(`flex flex-col gap-2 text-center sm:text-left`,e),...t})}function Z({className:e,...t}){return(0,z.jsx)(`div`,{"data-slot":`dialog-footer`,className:R(`flex flex-col-reverse gap-2 sm:flex-row sm:justify-end`,e),...t})}function Q({className:e,...t}){return(0,z.jsx)(We,{"data-slot":`dialog-title`,className:R(`text-lg leading-none text-white font-semibold`,e),...t})}function Qo({className:e,...t}){return(0,z.jsx)(Ze,{"data-slot":`dialog-description`,className:R(`text-muted-foreground text-sm`,e),...t})}function $o({typeOfThingBeingDeleted:e,nameOfThingBeingDeleted:t,isModalOpen:n,hideDataLossWarning:r,setIsModalOpen:i,deletionConfirmed:a,deletionPending:o,trigger:s,presentParticiple:c=`Deleting`,transitiveVerb:l=`Delete`}){return(0,z.jsxs)(Y,{open:n,onOpenChange:i,children:[s&&(0,z.jsx)(Jo,{asChild:!0,children:s}),(0,z.jsxs)(X,{className:`sm:max-w-[750px]`,children:[(0,z.jsxs)(Zo,{children:[(0,z.jsxs)(Q,{children:[`Are you sure you want to `,l.toLowerCase(),` this `,e,`?`]}),(0,z.jsx)(Qo,{children:`This action cannot be undone.`})]}),!r&&(0,z.jsxs)(`div`,{className:`p-3 my-5 text-white rounded-md bg-amber-600`,children:[(0,z.jsxs)(`p`,{className:`flex space-x-1 font-semibold align-baseline`,children:[(0,z.jsx)(er,{className:`inline-block size-5`}),` `,(0,z.jsx)(`span`,{children:`Warning`})]}),(0,z.jsxs)(`p`,{className:`pt-2 text-base`,children:[`By `,c.toLowerCase(),` `,e,` `,(0,z.jsx)(`span`,{className:`font-semibold`,children:t}),` `,`you will lose the data stored in it permanently.`]})]}),(0,z.jsx)(Z,{children:(0,z.jsxs)(`div`,{className:`flex justify-center space-x-5`,children:[(0,z.jsxs)(B,{type:`button`,className:`rounded-full`,onClick:()=>i(!1),children:[(0,z.jsx)(Et,{}),` Cancel`]}),(0,z.jsxs)(B,{variant:`destructive`,className:`rounded-full`,onClick:a,disabled:o,children:[(0,z.jsx)($t,{}),` `,l]})]})})]})]})}function es({className:e,variant:t,asChild:n=!1,...r}){return(0,z.jsx)(n?Gn:`span`,{"data-slot":`badge`,className:R(qi({variant:t}),e),...r})}function ts({...e}){return(0,z.jsx)(de,{"data-slot":`dropdown-menu`,...e})}function ns({...e}){return(0,z.jsx)(gt,{"data-slot":`dropdown-menu-trigger`,...e})}function rs({className:e,sideOffset:t=4,...n}){return(0,z.jsx)(ft,{children:(0,z.jsx)(dr,{"data-slot":`dropdown-menu-content`,sideOffset:t,className:R(`bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border border-grey-700 p-1 shadow-md`,e),...n})})}function is({className:e,inset:t,variant:n=`default`,...r}){return(0,z.jsx)(br,{"data-slot":`dropdown-menu-item`,"data-inset":t,"data-variant":n,className:R(`focus:bg-accent focus:text-grey data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...r})}function as({className:e,children:t,checked:n,...r}){return(0,z.jsxs)(Ut,{"data-slot":`dropdown-menu-checkbox-item`,className:R(`focus:bg-primary relative flex cursor-pointer items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),checked:n,...r,children:[(0,z.jsx)(`span`,{className:`pointer-events-none absolute left-2 flex size-3.5 items-center justify-center`,children:(0,z.jsx)(qt,{children:(0,z.jsx)(Tn,{className:`size-4`})})}),t]})}function os({className:e,inset:t,...n}){return(0,z.jsx)(hr,{"data-slot":`dropdown-menu-label`,"data-inset":t,className:R(`px-2 py-1.5 text-sm font-medium data-[inset]:pl-8`,e),...n})}function ss({className:e,...t}){return(0,z.jsx)(fr,{"data-slot":`dropdown-menu-separator`,className:R(`bg-grey-700 -mx-1 my-1 h-px`,e),...t})}function cs(e){return!!e?.plans?.[0]?.planId?.startsWith(`self-hosted`)}function ls({cluster:e}){let t=_i(e.id),{view:n,update:r}=aa(e.organizationId,e.id),i=!I.checkForFabricConnect(e.id)&&!!t.user;if(n){if(!e.fqdn)return(0,z.jsx)(j,{to:`/${e.organizationId}/${e.id}/instances`,className:`text-sm text-nowrap`,"aria-label":`View ${e.name}`,title:`View ${e.name}`,children:(0,z.jsxs)(`span`,{className:`py-2 hover:border-b-2`,children:[`Instances `,(0,z.jsx)(vt,{className:`inline-block`})]})});if(e.resetPassword)return r?(0,z.jsx)(j,{to:`/${e.organizationId}/${e.id}/finish-setup`,className:`text-sm text-nowrap`,"aria-label":`Set Password on ${e.name}`,title:`Set Password on ${e.name}`,children:(0,z.jsxs)(B,{variant:`positive`,className:`py-2 hover:border-b-2 animate-glow-pulse`,children:[`Finish Setup `,(0,z.jsx)(vt,{className:`inline-block`})]})}):(0,z.jsx)(`span`,{className:`py-2 text-nowrap`,children:`Pending Owner Setup`});if(!t.isLoading)return i?(0,z.jsx)(j,{to:`/${e.organizationId}/${e.id}/`,className:`text-sm text-nowrap`,"aria-label":`View ${e.name}`,title:`View ${e.name}`,children:(0,z.jsxs)(`span`,{className:`py-2 hover:border-b-2`,children:[`Direct Connect `,(0,z.jsx)(vt,{className:`inline-block`})]})}):r&&!cs(e)?(0,z.jsx)(j,{to:`/${e.organizationId}/${e.id}/`,className:`text-sm text-nowrap`,"aria-label":`Connect to ${e.name}`,title:`Connect to ${e.name}`,children:(0,z.jsxs)(`span`,{className:`py-2 hover:border-b-2`,children:[`Fabric Connect `,(0,z.jsx)(vt,{className:`inline-block`})]})}):(0,z.jsx)(j,{to:`/${e.organizationId}/${e.id}/sign-in`,className:`text-sm text-nowrap`,"aria-label":`Sign In to ${e.name}`,title:`Sign In to ${e.name}`,children:(0,z.jsxs)(`span`,{className:`py-2 hover:border-b-2`,children:[`Direct Sign In `,(0,z.jsx)(vt,{className:`inline-block`})]})})}}function us(e,t){let n=[];if(e)for(let r of e)n.push(r[t]);return n}function ds({cluster:e,forceProgressBarVisible:t}){let[n,r]=(0,L.useState)(t||!1),{data:i}=D(Ka(n&&e.id,2e3));(0,L.useEffect)(function(){(Ko(e.status)||qo(e.status))&&r(!0)},[n,e.status,i?.instances]);let a=(0,L.useMemo)(()=>{let e=us(i?.plans??[],`planId`),t=i?.instances??[],n=0,r={},a=0,o={},s=0,c={},l=0,u={};for(let i of t){let t=i.status;!t||Go(t)||(Ko(t)?(n+=1,r[t]=`${n} ${Ma(t)}`):qo(t)?(a+=1,o[t]=`${a} ${Ma(t)}`):Wo(t)?(l+=1,u[t]=`${l} ${Ma(t)}`):!i.planId||!e.includes(i.planId)?(a+=1,o.DRAINING_TRAFFIC=`${a} ${Ma(`Draining Traffic`)}`):Uo(t)&&(s+=1,c[t]=`${s} ${Ma(t)}`))}let d=n+a+s;return{pendingWidth:`${d===0?100:n===0?0:n/d*100}%`,updatingWidth:`${a===0?0:a/d*100}%`,failedWidth:`${l===0?0:l/d*100}%`,runningWidth:`${s===0?0:s/d*100}%`,text:[...Object.values(c).sort(),...Object.values(u).sort(),...Object.values(o).sort(),...Object.values(r).sort()].join(` · `)}},[i]);return n?(0,z.jsxs)(`div`,{className:`w-full text-center`,children:[(0,z.jsxs)(`div`,{className:`w-full h-2.5 rounded-full overflow-clip flex shadow`,children:[(0,z.jsx)(`div`,{style:{width:a.runningWidth},className:`grow bg-green/80 transition-[width] duration-1000 ease-in-out motion-reduce:transition-none`}),(0,z.jsx)(`div`,{style:{width:a.failedWidth},className:`grow bg-red/80 transition-[width] duration-1000 ease-in-out motion-reduce:transition-none`}),(0,z.jsx)(`div`,{style:{width:a.updatingWidth},className:`grow animate-pulse bg-yellow/80 transition-[width] duration-1000 ease-in-out motion-reduce:transition-none`}),(0,z.jsx)(`div`,{style:{width:a.pendingWidth},className:`grow bg-gray-600 transition-[width] duration-1000 ease-in-out motion-reduce:transition-none`})]}),a.text&&(0,z.jsx)(`div`,{className:`text-xs text-muted-foreground font-light mt-2`,children:a.text})]}):null}async function fs(e){let{data:t}=await P.delete(`/Cluster/${e}`,{timeout:0});return t}function ps(){return E({mutationFn:e=>fs(e)})}function ms(...e){return(0,L.useMemo)(()=>e.map(e=>(()=>{navigator.clipboard.writeText(e),k.info(`Copied to clipboard!`,{icon:(0,z.jsx)(dt,{}),duration:1e3})})),e)}function hs(e){try{return e===`null`||e===`undefined`||e==null?null:JSON.parse(e)}catch(e){return console.error(`safeParse failed to parse value, returning null instead`,e),null}}function gs(e,t){return hs(localStorage.getItem(e))??t}function _s(e,t){t==null?localStorage.removeItem(e):localStorage.setItem(e,JSON.stringify(t))}function vs(e,t){let n=(0,L.useState)(gs(e,t)),[r]=n;return(0,L.useEffect)(()=>_s(e,r),[e,r]),n}var ys=function(e){return e.ApplicationChatPosition=`ApplicationChatPosition`,e.ApplicationChatWidth=`ApplicationChatWidth`,e.ChatAlwaysApprovedTools=`ChatAlwaysApprovedTools`,e.SavedClusterState=`SavedClusterState`,e}({});function bs({cluster:e}){let t=kn(),n=Vt(),r=(0,L.useMemo)(()=>di(e),[e]),i=Yi({operationsUrl:r}),a=_i(e.id),[,o]=vs(ys.SavedClusterState,null),{view:s,update:c,remove:l,create:u}=aa(e.organizationId,e.id),{mutate:d,isPending:f}=ps(),[p,m]=(0,L.useState)(!1),[h,g]=(0,L.useState)(!1),_=(0,L.useMemo)(()=>e.status&&za.includes(e.status),[e.status]),v=cs(e),y=I.checkForFabricConnect(e.id),b=!y&&!!a.user,x=(0,L.useMemo)(()=>e.status&&Ba.includes(e.status),[e.status]),ee=(0,L.useMemo)(()=>e.status&&Wo(e.status),[e.status]),te=(0,L.useCallback)(async()=>{m(!0);let t=await Ga(e.id).catch(e=>(console.error(`Failed to lookup cluster details, proceeding without checking instances.`,e),null));if(await li({entityId:e.id,instanceClient:i}),t?.instances?.length)for(let e of t.instances)I.setUserForEntity(e,null);I.setUserForEntity(e,null)},[e,i]),ne=(0,L.useCallback)(()=>{o(e),t.navigate({to:`/${e.organizationId}/new-cluster`})},[e,t,o]),re=(0,L.useCallback)(()=>g(!0),[]),ie=(0,L.useCallback)(()=>{let r=e.organizationId;d(e.id,{onSuccess:async()=>{await n.invalidateQueries({queryKey:[r],refetchType:`active`}),await t.invalidate(),k.success(`Success`,{description:v?`Cluster successfully removed.`:`Cluster successfully terminated.`,duration:5e3,action:{label:`Dismiss`,onClick:()=>k.dismiss()}}),g(!1)},onError:()=>{k.error(`Error`,{description:v?`Failed to remove cluster: ${e.name}`:`Failed to terminate cluster: ${e.name}.`,duration:5e3,action:{label:`Dismiss`,onClick:()=>k.dismiss()}}),g(!1)}})},[t,e.organizationId,e.id,e.name,d,v,n]),S=e.domains?.[0]?.domain||e.fqdn,[ae,oe]=ms(`${S}`,`https://${S}`),se=[_&&c&&!a.isLoading&&(!b||y)&&(0,z.jsx)(j,{to:`${e.id}/sign-in`,disabled:p,children:(0,z.jsxs)(is,{children:[(0,z.jsx)(bt,{className:`text-green`}),` Direct Sign In`]})},`sign-in`),_&&c&&(0,z.jsx)(j,{to:`${e.id}/edit`,disabled:p,children:(0,z.jsxs)(is,{children:[(0,z.jsx)(xr,{className:`text-purple-600`}),` `,v?`Edit`:`Edit Scaling`]})},`edit`),_&&c&&!v&&(0,z.jsx)(j,{to:`${e.id}/edit/version`,disabled:p,children:(0,z.jsxs)(is,{children:[(0,z.jsx)(jt,{className:`text-fuchsia-300`}),` Edit Version`]})},`edit-version`),_&&c&&!1,_&&s&&(0,z.jsx)(j,{to:`${e.id}/instances`,disabled:p,children:(0,z.jsxs)(is,{children:[(0,z.jsx)(mn,{className:`text-orange-300`}),` Instances`]})},`instances`),_&&s&&e.fqdn&&(0,z.jsx)(ss,{},`copy-separator`),_&&s&&e.fqdn&&(0,z.jsxs)(is,{onClick:ae,disabled:p,children:[(0,z.jsx)(mr,{}),` Copy Host Name`]},`copy-host-name`),_&&s&&e.fqdn&&(0,z.jsxs)(is,{onClick:oe,disabled:p,children:[(0,z.jsx)(mr,{}),` Copy API URL`]},`copy-api-url`),_&&s&&!!r&&!a.isLoading&&b&&(0,z.jsx)(is,{onClick:te,disabled:p,children:`Direct Sign Out`},`direct-sign-out`),ee&&u&&(0,z.jsx)(is,{className:`focus:bg-green/70 focus:text-white`,onClick:ne,children:`Try Again`},`try-again`),!x&&l&&_&&(0,z.jsx)(ss,{},`remove-separator`),!x&&l&&(0,z.jsxs)(is,{className:`focus:bg-red/70 focus:text-white`,onClick:re,children:[(0,z.jsx)($t,{className:`text-red-300`}),` `,v?`Remove`:`Terminate`]},`remove`)].filter(Ni);return(0,z.jsxs)(xi,{className:`relative h-full justify-between`,children:[(0,z.jsxs)(Si,{children:[(0,z.jsxs)(wi,{className:`flex items-center justify-between`,children:[S?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`truncate max-w-48`,children:S}),(0,z.jsx)(hn,{onClick:ae,size:16,className:`cursor-pointer`}),(0,z.jsx)(`span`,{className:`grow`})]}):(0,z.jsx)(`span`,{children:`Self-Hosted`}),!x&&(0,z.jsxs)(ts,{children:[(0,z.jsx)(ns,{children:(0,z.jsx)(tn,{"aria-label":`Cluster options`})}),(0,z.jsx)(rs,{children:[...se]})]})]}),(0,z.jsx)(Ci,{children:(0,z.jsx)(`h2`,{children:e.name})})]}),(0,z.jsxs)(Ti,{className:`flex items-center justify-between gap-2`,children:[(0,z.jsx)(ds,{cluster:e}),_&&s&&(0,z.jsx)(ls,{cluster:e}),ee&&e.status&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(es,{variant:Ho(e.status),children:Ma(e.status)}),(0,z.jsx)(`span`,{className:`text-xs`,children:`Click "..." to choose how to proceed.`})]})]}),(0,z.jsx)($o,{typeOfThingBeingDeleted:`cluster`,transitiveVerb:v?`Remove`:`Terminate`,presentParticiple:v?`Removing`:`Terminating`,nameOfThingBeingDeleted:e.name,isModalOpen:h,hideDataLossWarning:v,setIsModalOpen:e=>g(e),deletionConfirmed:ie,deletionPending:f})]})}function xs({overEmail:e}){return(0,z.jsx)(`a`,{href:e?`mailto:support@harperdb.io`:`https://discord.com/channels/1415002037439041710/1415002038286286994`,target:`_blank`,rel:`noreferrer`,className:`underline`,children:`Contact us`})}function Ss({className:e,text:t,centered:n,...r}){return(0,z.jsxs)(`div`,{className:`text-white h-full w-full ${e||``} ${n?`flex flex-col items-center justify-center`:``}`,...r,children:[(0,z.jsx)(`img`,{src:`/HDBDogOnly.svg`,width:`100px`,height:`100px`,alt:`HDB Dog Logo Loading`,className:`inline-block`}),(0,z.jsx)(`p`,{className:`pt-4`,children:t||`Loading...`})]})}function Cs({children:e,className:t}){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(Vo,{}),(0,z.jsx)(`div`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-(--spacing(32)))] relative ${t??``}`,children:e})]})}async function ws(e){let{data:t}=await P.get(`/Plan/`,{params:{organizationId:e}});return t}function Ts(e){return A({queryKey:[e,`instancePlan`],queryFn:()=>ws(e),retry:!1})}async function Es(){let{data:e}=await P.get(`/HarperVersions/`);return e}function Ds(){return A({queryKey:[`HarperVersions`],queryFn:Es,staleTime:6e4,retry:!1})}async function Os({organizationId:e,availableHosts:t}={}){let{data:n}=await P.get(`/Region/`,{params:{availableHosts:t,organizationId:e}});return n}function ks({organizationId:e,availableHosts:t}={}){return A({queryKey:[e,`regionLocations`,t],queryFn:()=>Os({organizationId:e,availableHosts:t}),retry:!1})}function As(e){return(t,n)=>t[e]===n[e]?0:t[e]>n[e]?1:-1}function js(e){let t=e.split(`.`).map(Number);return(t[0]<<24|t[1]<<16|t[2]<<8|t[3])>>>0}function Ms(e){return typeof e==`string`?/^(?:25[0-5]|2[0-4]\d|1?\d?\d)(?:\.(?:25[0-5]|2[0-4]\d|1?\d?\d)){3}$/.test(e):!1}function Ns(e,t){return e.instanceFqdn===t.instanceFqdn?e.operationsApiPort-t.operationsApiPort:Ms(e.instanceFqdn)&&Ms(t.instanceFqdn)?js(e.instanceFqdn)-js(t.instanceFqdn):e.instanceFqdn>t.instanceFqdn?1:-1}function Ps(e,t){let n={};for(let r of e){let e=r[t];if(e!==void 0)if(Array.isArray(e))for(let t of e)n[t]||(n[t]=[]),n[t].push(r);else n[e]||(n[e]=[]),n[e].push(r)}return n}function Fs(e,t){let n={};for(let r of e){let e=r[t];if(e!==void 0)if(Array.isArray(e))for(let t of e)n[t]=r;else n[e]=r}return n}function Is(e,t,n){let r=Ps(e,t),i={};for(let e in r)i[e]=Fs(r[e],n);return i}function Ls(e,t){let n=zs(e),r=zs(t);return!n||!r?!1:Hs(r,n)>=0}function Rs(e,t){let n=zs(e),r=zs(t);return!n&&!r?0:n?r?Hs(n,r):1:-1}function zs(e){if(typeof e!=`string`)return null;let[t]=e.split(`+`,1).concat(``),n=t.indexOf(`-`),r=n===-1?t:t.slice(0,n),i=n===-1?``:t.slice(n+1),a=r.split(`.`);if(a.length===0)return null;let o=Bs(a[0]),s=Bs(a[1]??`0`),c=Bs(a[2]??`0`);return o==null||s==null||c==null?null:{major:o,minor:s,patch:c,pre:i?i.split(`.`).map(e=>Vs(e)?Number(e):e):[]}}function Bs(e){return e==null||e===``||!/^\d+$/.test(e)?null:Number(e)}function Vs(e){return/^\d+$/.test(e)}function Hs(e,t){if(e.major!==t.major)return e.major<t.major?-1:1;if(e.minor!==t.minor)return e.minor<t.minor?-1:1;if(e.patch!==t.patch)return e.patch<t.patch?-1:1;let n=e.pre.length>0,r=t.pre.length>0;if(!n&&!r)return 0;if(!n&&r)return 1;if(n&&!r)return-1;let i=Math.min(e.pre.length,t.pre.length);for(let n=0;n<i;n++){let r=e.pre[n],i=t.pre[n],a=typeof r==`number`,o=typeof i==`number`;if(a&&o){if(r!==i)return r<i?-1:1;continue}if(a&&!o)return-1;if(!a&&o)return 1;if(r!==i)return String(r)<String(i)?-1:1}return e.pre.length===t.pre.length?0:e.pre.length<t.pre.length?-1:1}function Us({width:e,className:t,animated:n,placeholder:r}){return(0,z.jsxs)(`div`,{className:i(`w-full bg-gray-200 rounded-full relative`,r?`h-6`:`h-2.5`),children:[r&&(0,z.jsx)(`div`,{className:`absolute top-0 h-full w-full font-bold text-xs flex flex-col items-center justify-center text-black/60 text-shadow-2xs`,children:r}),(0,z.jsx)(`div`,{className:i(`rounded-full`,r?`h-6`:`h-2.5`,!t?.includes(`bg-`)&&`bg-purple/40`,n&&`transition-[width] duration-1000 ease-in-out motion-reduce:transition-none`,t),style:{width:e}})]})}function Ws({duration:e,message:t,lateMessage:n}){let r=(0,L.useRef)(0),i=(0,L.useRef)(0),[a,o]=(0,L.useState)(!1),[s,c]=(0,L.useState)(`5%`),l=(0,L.useCallback)(function t(n){i.current||=n;let a=n-i.current,s=Math.min(a/e,1);c(Math.max(5,s*100)+`%`),s<1?r.current=requestAnimationFrame(t):o(!0)},[e]);return(0,L.useEffect)(()=>(r.current=requestAnimationFrame(l),()=>cancelAnimationFrame(r.current)),[l]),(0,z.jsxs)(z.Fragment,{children:[a?n:t,(0,z.jsx)(Us,{width:s,animated:!1})]})}async function Gs(e){let{data:t}=await P.post(`/Cluster/`,e,{timeout:0});return t}function Ks(){return E({mutationFn:e=>Gs(e)})}async function qs(e){let{id:t,...n}=e,{data:r}=await P.put(`/Cluster/${t}`,n,{timeout:0});return r}function Js(){return E({mutationFn:e=>qs(e)})}async function Ys(e){let{data:t}=await P.get(`/Organization/${e}`);return t}function Xs(e){return A({queryKey:[e],queryFn:()=>Ys(e),retry:!1,refetchInterval:1e4})}var Zs=`ENTERPRISE`;function Qs(e,t){if(t<=0)return``;if(e.length<=t)return e;let n=e.split(`-`);if(n.length===1)return n[0].slice(0,t);let r=[n[0],...n.slice(1).map(e=>e.charAt(0))],i=r.join(`-`);if(i.length<=t)return i;let a=r.slice(1).join(``).length,o=r.length-1,s=t-a-o;if(s>0)return r[0]=r[0].slice(0,s),r.join(`-`);{let e=[],i=0;t>0&&(e.push(n[0].charAt(0)),i=1);for(let n=1;n<r.length&&i+2<=t;n++)e.push(r[n]),i+=2;return e.join(`-`)}}function $s(e,t,n=`-`){let r=t.split(n)[0];return e.findIndex(e=>e.startsWith(r))!==-1}function ec(e){return e.replace(/[^a-zA-Z0-9]/g,`-`).replace(/([a-z])([A-Z])/g,`$1-$2`).toLowerCase().replace(/-+/g,`-`).replace(/^-+|-+$/g,``)}async function tc(e){await P.put(`/Payment/`,e)}function nc(){return E({mutationFn:e=>tc(e)})}function rc(e){let{mutate:t}=nc();return(0,L.useCallback)((n,r)=>{t({paymentMethodId:typeof n==`string`?n:n.id,organizationId:e},{onSuccess:()=>{k.success(`Success! Your payment method has been saved.`),r(!0)},onError:()=>{k.error(`Failed to process payment method details. Please try another payment method.`),r(!1)}})},[t,e])}var ic=(0,L.createContext)(null);function ac(){return(0,L.useContext)(ic)}function oc({hasExistingBilling:e,onPaymentAdded:t,onSaveStateForBillingRedirect:n}){let{organizationId:r}=M({strict:!1}),i=pn(),a=ac(),o=gn(),[s,c]=(0,L.useState)(!1),l=rc(r),u=(0,L.useCallback)(()=>{t(!1)},[t]);return(0,z.jsxs)(`form`,{id:`billing-add-payment-method-form`,name:`billing-add-payment-method-form`,onSubmit:(0,L.useCallback)(async e=>{if(e.preventDefault(),!i||!o)return;c(!0),await o.submit(),n?.(!0);let s=await i.confirmSetup({clientSecret:a.clientSecret,elements:o,redirect:`if_required`,confirmParams:{return_url:`${window.location.origin}/#/${r}/billing/confirm`}});s.error?(console.error(s.error.message),k.error(s.error.message),c(!1),n?.(!1)):s.setupIntent.payment_method&&(l(s.setupIntent.payment_method,t),n?.(!1))},[o,t,n,r,l,i,a.clientSecret]),className:`max-w-xl`,children:[(0,z.jsx)(Fn,{}),(0,z.jsx)(Un,{options:{mode:`billing`}}),(0,z.jsxs)(`div`,{className:`mt-4 flex gap-8 items-center`,children:[(0,z.jsxs)(B,{disabled:!i||!o||s,variant:`submit`,className:`rounded-full`,children:[(0,z.jsx)(Jt,{}),` Add Payment Method`]}),e&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{className:`text-xs text-gray-600`,children:`Your existing payment method will be overwritten.`}),(0,z.jsx)(B,{variant:`defaultOutline`,type:`button`,onClick:u,children:`Cancel`})]})]})]})}async function sc(e){let{data:t}=await P.post(`/StripeAccount/`,e);return t}function cc(){return E({mutationFn:e=>sc(e)})}async function lc(e){let{data:t}=await P.post(`/Payment/`,{organizationId:e.organizationId});return t}function uc(){return E({mutationFn:e=>lc(e)})}function dc(e){let{enabled:t,existingStripeId:n,organizationId:r}=e,{mutate:i}=cc(),{mutate:a}=uc(),[o,s]=(0,L.useState)(void 0);return(0,L.useEffect)(()=>{},[i,t,n,a,(0,L.useCallback)(e=>{s(e.clientSecret)},[]),r]),o}function fc({children:e}){let{organizationId:t}=M({strict:!1}),{data:n}=D(Xs(t)),r=dc({organizationId:t,enabled:!!n,existingStripeId:n?.stripeId});return(0,L.useMemo)(()=>({clientSecret:r||``,appearance:{theme:`night`}}),[r]),console.error(`No VITE_PUBLIC_STRIPE_KEY is configured for this environment.`),(0,z.jsx)(`div`,{className:`mt-20 px-4 pt-4 md:px-12 min-h-[calc(100vh-theme(spacing.32))]`,children:`Setting up your billing is currently disabled. Please check back again later.`})}function pc({onPaymentAdded:e,onSaveStateForBillingRedirect:t}){let{organizationId:n}=M({strict:!1}),{data:r}=D(Xs(n)),i=r?.billing,a=i?.paymentMethod;return(0,z.jsxs)(fc,{children:[(0,z.jsx)(`div`,{className:`mt-2 mb-6`,children:!a&&`You currently have no payment method on file. Please fill out the secure form below.`}),(0,z.jsx)(oc,{hasExistingBilling:!!i,onSaveStateForBillingRedirect:t,onPaymentAdded:e})]})}var mc=function(e){return e.PASS=`pass`,e.FAIL=`fail`,e.PENDING=`pending`,e.ERROR=`error`,e}({});function hc(e){switch(e){case mc.PASS:return`success`;case mc.FAIL:case mc.ERROR:return`destructive`;case mc.PENDING:default:return`default`}}function gc(e){switch(e){case mc.PASS:return`READY`;case mc.FAIL:case mc.ERROR:case mc.PENDING:default:return e.toUpperCase()}}function _c(e,t){return`${String(e).padStart(2,`0`)}/${String(t%100).padStart(2,`0`)}`}function vc(e){let{onSaveStateForBillingRedirect:t,onReplacingPaymentMethod:n}=e??{},{organizationId:r}=M({strict:!1}),{update:i}=ra(r),{data:a,refetch:o}=D(Xs(r)),s=a?.billing?.paymentMethod,[c,l]=(0,L.useState)(!1),u=(0,L.useCallback)(()=>{l(!c),n?.(!c)},[n,c]),d=(0,L.useCallback)(e=>{l(!1),n?.(!1),e&&o()},[n,o]);return a?.type===`ENTERPRISE`?(0,z.jsxs)(`span`,{children:[`You are part of an enterprise organization! We don’t currently show your payment methods on this page. Want to explore your solution with Harper more? `,(0,z.jsx)(xs,{}),`, we would love to talk!`]}):s&&!c?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`mt-2`,children:[s.brand?.toUpperCase()??`Card`,` ending in `,s.last4??`••••`,s.expMonth&&s.expYear?(0,z.jsxs)(z.Fragment,{children:[`(exp `,_c(s.expMonth,s.expYear),`)`]}):null,s.status?(0,z.jsxs)(z.Fragment,{children:[`—`,` `,(0,z.jsx)(es,{variant:hc(s.status),children:gc(s.status)})]}):null]}),i&&(0,z.jsx)(`div`,{className:`mt-2 mb-6`,children:(0,z.jsx)(B,{variant:`defaultOutline`,type:`button`,onClick:u,children:`Replace Payment Method`})})]}):i?(0,z.jsx)(pc,{onSaveStateForBillingRedirect:t,onPaymentAdded:d}):(0,z.jsx)(`div`,{children:`This org doesn't have a payment method, and you don't have access to add one. Please contact your administrator.`})}function yc(e){return e!==void 0&&e>0}function bc({clusterId:e,isPending:t,onGoBackToDetails:n,onSaveStateForBillingRedirect:r,onSubmit:i,organizationId:a,selectedPlan:o}){let{data:s}=D(Xs(a)),c=s?.billing,l=s?.type===Zs,u=l||c?.paymentMethod?.status===mc.PASS,[d,f]=(0,L.useState)(!1),p=yc(o?.planLimits?.expirationMonths)&&o.planLimits.expirationMonths<1e3&&o.planLimits.expirationMonths,m=(0,z.jsx)(z.Fragment,{children:(0,z.jsxs)(`div`,{className:`flex flex-col-reverse gap-2 sm:flex-row sm:justify-end mt-3 max-w-xl`,children:[(0,z.jsxs)(B,{type:`button`,variant:`defaultOutline`,className:`rounded-full`,disabled:t,onClick:n,children:[(0,z.jsx)(Et,{}),` Back to Details`]}),(0,z.jsxs)(B,{disabled:t||!u||d,type:`submit`,variant:`submit`,className:`rounded-full`,onClick:i,children:[e?`Edit Cluster`:`Create New Cluster`,` `,(0,z.jsx)(vt,{})]})]})});if(l)return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`ul`,{className:`list-disc ml-6 max-w-lg`,children:[(0,z.jsx)(`li`,{children:`Reminder: you will be billed at your contracted rate for any additional infrastructure.`}),(0,z.jsxs)(`li`,{children:[`Your account representative can work with you to sort out more precise details, and to help accomplish your objectives with this cluster. `,(0,z.jsx)(xs,{overEmail:!0}),`, we are here to help.`]})]}),m]});let h=p&&`, or ${Qr(p,`month`,`months`)} elapse`;return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`ul`,{className:`list-disc ml-6 mb-6`,children:[(0,z.jsx)(`li`,{children:`You will be billed for this cluster today, and will receive a license for the block of usage you've requested.`}),e&&(0,z.jsx)(`li`,{children:`If you scale up, you'll be charged for the additional blocks you've purchased now, and your next auto renewal will be for all purchased blocks.`}),e&&(0,z.jsx)(`li`,{children:`If you remove a region, that region's usage block will not be used anymore (because it is specific to that region).`}),(0,z.jsxs)(`li`,{children:[`When that block is used up`,h,`, you will be automatically renewed.`]}),(0,z.jsx)(`li`,{children:`While refunds are not available, we’d be happy to assist you with troubleshooting.`}),(0,z.jsxs)(`li`,{children:[`We would love to work with you to sort out more precise details, and to help accomplish your objectives with this cluster. `,(0,z.jsx)(xs,{overEmail:!0}),`, we are here to help.`]})]}),(0,z.jsx)(`p`,{className:`text-muted-foreground text-sm mb-6`,children:`Payment method:`}),(0,z.jsx)(vc,{onSaveStateForBillingRedirect:r,onReplacingPaymentMethod:f}),m]})}var xc=/(^$|^(?:localhost|(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}|(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z]{2,})$)/i,Sc=65535,Cc=v().max(20,`Must be at most 20 characters long.`).regex(/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/,`Can only contain lowercase letters, numbers and dashes. Must not start or end with a dash.`),wc=l({clusterName:v().nonempty(`Please enter a cluster name.`).max(255,`Cluster name cannot be longer than 255 characters long.`),abbreviatedName:b([p(``),g(),Cc]),fqdn:v().regex(xc,`Please enter a valid host name without the port or any path.`).optional(),version:v().optional(),deploymentDescription:v().nonempty(`Please select a deployment tier.`),performanceDescription:v().nonempty(`Please select a performance tier.`),regionPlans:f(l({regionName:v().nonempty(`Please select a region.`),latencyDescription:v().nonempty(`Please select a latency tier.`)})).max(50,{error:`A maximum of 50 regions can be selected for each cluster. `}),instances:f(l({secure:o([`true`,`false`]),fqdn:v().nonempty(`Please enter the host name of your instance.`).regex(xc,`Please enter a valid host name without the port or any path.`),port:u().min(0,`Positive thinking only, please.`).max(Sc,`That port number is too high.`).optional()})).max(100,{error:`A maximum of 100 instances can be added to each cluster.`}),skipToBilling:_().optional(),skipGtmWait:_().optional(),sourceClusterId:v().optional()});function Tc({calculatedNames:e,disabled:t,form:n}){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(W,{control:n.control,name:`abbreviatedName`,render:({field:n})=>(0,z.jsxs)(G,{className:`col-span-3`,children:[(0,z.jsx)(K,{className:`pb-1`,children:`Host Name`}),(0,z.jsx)(U,{children:(0,z.jsx)(J,{...n,type:`text`,maxLength:Cc.maxLength,autoCapitalize:`none`,autoComplete:`off`,autoCorrect:`off`,placeholder:e.suggestedAbbreviatedName,disabled:t})}),(0,z.jsx)(q,{})]})}),(0,z.jsxs)(G,{className:`col-span-3 `,children:[(0,z.jsx)(K,{className:`pb-1`,children:`Full Host Name`}),(0,z.jsx)(U,{children:(0,z.jsx)(`span`,{children:e.fullHostName})}),(0,z.jsx)(q,{})]})]})}function Ec({className:e}={}){return(0,z.jsx)(`div`,{className:(0,L.useMemo)(()=>i(`animate-pulse h-2.5 bg-gray-200 rounded-full dark:bg-gray-700`,!e?.includes(`mb-`)&&`mb-4 `,!e?.includes(`w-`)&&`w-48 `,e),[e])})}function Dc({...e}){return(0,z.jsx)($n,{"data-slot":`select`,...e})}function Oc({...e}){return(0,z.jsx)(on,{"data-slot":`select-group`,...e})}function kc({...e}){return(0,z.jsx)(nn,{"data-slot":`select-value`,...e})}function Ac({className:e,children:t,...n}){return(0,z.jsxs)(sr,{"data-slot":`select-trigger`,className:R(`border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive flex h-9 w-fit items-center justify-between gap-2 rounded-md border bg-grey-700 px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 *:data-[slot=select-value]:truncate *:data-[slot=select-value]:block *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...n,children:[t,(0,z.jsx)(rr,{asChild:!0,children:(0,z.jsx)(Xe,{className:`opacity-50 size-4`})})]})}function jc({className:e,children:t,position:n=`popper`,...r}){return(0,z.jsx)(Bn,{children:(0,z.jsxs)(ne,{"data-slot":`select-content`,className:R(`bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border shadow-md`,n===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),position:n,...r,children:[(0,z.jsx)(Nc,{}),(0,z.jsx)(ln,{className:R(`p-1`,n===`popper`&&`h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1`),children:t}),(0,z.jsx)(Pc,{})]})})}function Mc({className:e,...t}){return(0,z.jsx)(Gt,{"data-slot":`select-label`,className:R(`px-2 py-1.5 text-sm font-medium`,e),...t})}function $({className:e,children:t,...n}){return(0,z.jsxs)(Rn,{"data-slot":`select-item`,className:R(`focus:bg-grey-200 focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2`,e),...n,children:[(0,z.jsx)(bn,{children:t}),(0,z.jsx)(`span`,{className:`absolute right-2 flex size-3.5 items-center justify-center`,children:(0,z.jsx)(Xn,{children:(0,z.jsx)(Tn,{className:`size-4`})})})]})}function Nc({className:e,...t}){return(0,z.jsx)(jn,{"data-slot":`select-scroll-up-button`,className:R(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,z.jsx)(pe,{className:`size-4`})})}function Pc({className:e,...t}){return(0,z.jsx)(Qt,{"data-slot":`select-scroll-down-button`,className:R(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,z.jsx)(Xe,{className:`size-4`})})}var Fc={Colocated:`Shared infrastructure for optimized value`,Dedicated:`Dedicated infrastructure for consistent performance`,"Self-Hosted":`Your own infrastructure`};function Ic({availableDeploymentTypes:e,disabled:t,form:n}){return(0,z.jsx)(W,{control:n.control,name:`deploymentDescription`,render:({field:r})=>(0,z.jsxs)(G,{className:`col-span-3`,children:[(0,z.jsx)(K,{className:`pb-1`,children:`Harper Deployment`}),(0,z.jsx)(L.Suspense,{fallback:(0,z.jsx)(Ec,{}),children:(0,z.jsx)(U,{children:(0,z.jsxs)(Dc,{...r,disabled:t,onValueChange:e=>{r.onChange(e),n.trigger()},children:[(0,z.jsx)(Ac,{className:`w-full h-auto`,children:(0,z.jsx)(kc,{placeholder:`Choose Tier`})}),(0,z.jsx)(jc,{children:(0,z.jsx)(Oc,{children:e.map(e=>(0,z.jsxs)($,{value:e,children:[(0,z.jsx)(`dt`,{className:`text-left font-bold text-sm/6`,children:e}),Fc[e]&&(0,z.jsx)(`dd`,{className:`font-light`,children:Fc[e]})]},e))})})]})})}),(0,z.jsx)(q,{})]})})}function Lc({disabled:e,form:t}){return(0,z.jsx)(W,{control:t.control,name:`fqdn`,render:({field:t})=>(0,z.jsxs)(G,{className:`md:col-span-6 col-span-3`,children:[(0,z.jsx)(K,{className:`pb-1`,children:`Optional Cluster Load Balancer Host Name`}),(0,z.jsx)(U,{children:(0,z.jsx)(J,{...t,type:`text`,autoCapitalize:`none`,autoComplete:`off`,autoCorrect:`off`,placeholder:`example.your-company.com`,disabled:e})}),(0,z.jsx)(q,{})]})})}function Rc({className:e,disabled:t,form:n}){return(0,z.jsx)(W,{control:n.control,name:`clusterName`,render:({field:n})=>(0,z.jsxs)(G,{className:e,children:[(0,z.jsx)(K,{className:`pb-1`,children:`Cluster Name`}),(0,z.jsx)(U,{children:(0,z.jsx)(J,{autoFocus:!0,type:`text`,maxLength:wc.shape.clusterName.maxLength,autoCapitalize:`words`,disabled:t,...n})}),(0,z.jsx)(q,{})]})})}function zc({availablePerformanceDescriptions:e,form:t,selectedDeployment:n}){return(0,z.jsx)(W,{control:t.control,name:`performanceDescription`,render:({field:r})=>(0,z.jsxs)(G,{className:`col-span-3`,children:[(0,z.jsxs)(K,{className:`pb-1`,children:[n.startsWith(`Self`)?`Support`:`Performance`,` & Usage`]}),(0,z.jsx)(L.Suspense,{fallback:(0,z.jsx)(Ec,{}),children:(0,z.jsx)(U,{children:(0,z.jsxs)(Dc,{...r,onValueChange:e=>{r.onChange(e),t.trigger()},disabled:!e?.length,children:[(0,z.jsx)(Ac,{className:`w-full h-auto`,children:(0,z.jsx)(kc,{placeholder:`Choose Tier`})}),(0,z.jsx)(jc,{children:(0,z.jsx)(Oc,{children:e.map(e=>(0,z.jsxs)($,{value:e.performanceTier,children:[(0,z.jsx)(`dt`,{className:`text-left font-bold text-sm/6`,children:e.name}),e.description&&(0,z.jsx)(`dd`,{className:`font-light`,children:e.description})]},e.name))})})]})})}),(0,z.jsx)(q,{})]})})}function Bc({className:e,...t}){let{formDescriptionId:n}=La();return(0,z.jsx)(`p`,{"data-slot":`form-description`,id:n,className:R(`text-muted-foreground text-sm`,e),...t})}function Vc({className:e,form:t}){return(0,z.jsx)(W,{control:t.control,name:`skipGtmWait`,render:({field:t})=>(0,z.jsxs)(G,{className:e,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(U,{children:(0,z.jsx)(J,{type:`checkbox`,className:`w-4 h-4 cursor-pointer`,checked:t.value||!1,onChange:t.onChange,onBlur:t.onBlur,name:t.name,ref:t.ref})}),(0,z.jsx)(K,{className:`cursor-pointer`,children:`Immediate upgrade and restart`})]}),(0,z.jsx)(Bc,{children:`Apply changes immediately without waiting for each instance to be taken out of the load balancer (faster, but potentially less safe).`})]})})}function Hc({className:e,disabled:t,form:n,harperVersions:r}){return r?.value?.length?(0,z.jsx)(W,{control:n.control,name:`version`,render:({field:i})=>(0,z.jsxs)(G,{className:e,children:[(0,z.jsx)(K,{className:`pb-1`,children:`Harper Version`}),(0,z.jsx)(L.Suspense,{fallback:(0,z.jsx)(Ec,{}),children:(0,z.jsx)(U,{children:(0,z.jsxs)(Dc,{...i,disabled:t,onValueChange:e=>{i.onChange(e),n.trigger()},children:[(0,z.jsx)(Ac,{className:`w-full h-auto`,children:(0,z.jsx)(kc,{placeholder:`Choose Version`})}),(0,z.jsx)(jc,{children:(0,z.jsx)(Oc,{children:r?.value.map(e=>(0,z.jsxs)($,{value:e.version,children:[e.version,` `,(0,z.jsx)(`span`,{className:`font-light opacity-50`,children:e.name})]},e.version))})})]})})}),(0,z.jsx)(q,{})]})}):null}var Uc=new RegExp(/^\d+/);function Wc(e,t){let n=parseInt(e.match(Uc)?.[0]||`0`,10),r=parseInt(t.match(Uc)?.[0]||`0`,10);return n===r?0:n>r?1:-1}var Gc=[`B`,`KB`,`MB`,`GB`,`TB`,`PB`,`EB`,`ZB`,`YB`],Kc=[`secs`,`mins`,`hrs`],qc={bytes:1e3,secs:60};function Jc(e,t,n){let r,i;switch(t){case`bytes`:r=Gc,i=qc.bytes;break;case`secs`:r=Kc,i=qc.secs;break;default:return e}let a=r.indexOf(n);return a===-1?e:e/i**a}function Yc(e,t){let n,r;switch(e){case`bytes`:n=Gc,r=qc.bytes;break;case`secs`:n=Kc,r=qc.secs;break;default:return e}let i=0;for(;t>=r&&i<n.length-1;)t/=r,i++;return n[i]}function Xc(e,t=1){let n=e*t,r=Yc(`bytes`,n),i=Jc(n,`bytes`,r);return`${new Intl.NumberFormat().format(Math.round(i))} ${r}`}function Zc(e){return new Intl.NumberFormat().format(e)}var Qc=[`K`,`M`,`B`,`T`,`Qa`,`Qi`,`Sx`,`Sp`,`Oc`,`No`,`Dc`];function $c(e){let t=1e3,n=e;if(Math.abs(n)<t)return String(Math.round(n));let r=-1;do n/=t,++r;while(Math.round(Math.abs(n)*10)/10>=t&&r<Qc.length-1);return`${Zc(Math.round(n))} ${Qc[r]}`}function el({selectedPlan:e,selectedRegion:t,isEnterprise:n}){let[r,i]=(0,L.useState)(!1),a=(0,L.useCallback)(()=>{i(!r)},[r,i]),o=e?.planLimits,s=e?.resourcesPerInstance,c=yc(o?.expirationMonths)&&o.expirationMonths<1e3&&o.expirationMonths,l=t?.purchasedBlockMultiplier??1,u=(0,L.useMemo)(()=>o?[yc(o.totalReadCount)&&{label:`Total Reads`,value:`${$c(o.totalReadCount*l)} reads`},yc(o.totalReadsBytes)&&{label:`Total Read Transfer`,value:`${Xc(o.totalReadsBytes*l)}`},yc(o.readsPerMinuteCount)&&{label:`Read Rate`,value:`${$c(o.readsPerMinuteCount*60*l)}/min`},yc(o.readsPerMinuteBytes)&&{label:`Read Bandwidth`,value:`${Xc(o.readsPerMinuteBytes*60*l)}/min`},yc(o.totalWriteCount)&&{label:`Total Writes`,value:`${$c(o.totalWriteCount)} reads`},yc(o.totalWritesBytes)&&{label:`Total Write Transfer`,value:`${Xc(o.totalWritesBytes)}`},yc(o.writesPerMinuteCount)&&{label:`Write Rate`,value:`${$c(o.writesPerMinuteCount*60)}/min`},yc(o.writesPerMinuteBytes)&&{label:`Write Bandwidth`,value:`${Xc(o.writesPerMinuteBytes*60)}/min`},yc(o.totalRealTimeMessageDeliveries)&&{label:`Total Real-Time Messages`,value:`${$c(o.totalRealTimeMessageDeliveries*l)} messages`},yc(o.totalRealTimeMessageDeliveryBytes)&&{label:`Total Real-Time Message Transfer`,value:`${Xc(o.totalRealTimeMessageDeliveryBytes*l)}`},yc(o.realTimeMessageDeliveriesPerMinute)&&{label:`Real-Time Message Rate`,value:`${$c(o.realTimeMessageDeliveriesPerMinute*60*l)}/min`},yc(o.realTimeMessageDeliveryBytesPerMinute)&&{label:`Real-Time Message Bandwidth`,value:`${Xc(o.realTimeMessageDeliveryBytesPerMinute*60*l)}/min`},yc(o.tlsHandshakes)&&{label:`TLS Handshakes`,value:`${$c(o.tlsHandshakes*60*l)}`},yc(o.applicationComputeHours)&&{label:`Application Compute Hours`,value:`${$c(o.applicationComputeHours*l)}`},!!s&&yc(s.storageGb)&&{label:`Storage`,value:`${Xc(s.storageGb*1e9)}`},!!c&&{label:`Expiration`,value:Qr(c,`month`,`months`)},!!t?.id&&{label:`Region ID`,value:t.id},!!e?.id&&{label:`Plan ID`,value:e.id}].filter(Ni):[],[c,t,e,l]);if(!o)return``;if(!yc(o.totalReadCount))return`This plan has no usage limits.`;let d=n?` Pricing subject to contracted rate.`:` Beta pricing subject to change.`,f=yc(o.readsPerMinuteCount)?`${$c(o.readsPerMinuteCount*l)} reads/min & `:``,p=yc(o.writesPerMinuteCount)?` ${$c(o.writesPerMinuteCount)} writes/min & `:` `,m=yc(o.readsPerMinuteCount)?`in ${t?.region??``} region${t?` (${t?.id})`:``}`:`per server`,h=c?`, for ${Qr(c,`month`,`months`)}`:``,g=n?`for the contracted rate`:`for the price listed above`,_=c?` in ${Qr(c,`month`,`months`)} or`:``;return(0,z.jsxs)(G,{className:`basis-full`,children:[(0,z.jsxs)(K,{onClick:a,children:[(0,z.jsx)(`em`,{className:`text-muted-foreground`,children:e?.id}),` Purchasing usage block for `,f,$c(o.totalReadCount*l),` total reads `,m,`,`,(0,z.jsx)(`br`,{className:`hidden sm:block`}),p,` `,$c(o.totalWriteCount),` total writes`,h,`.`,d,(0,z.jsx)(`br`,{className:`block sm:hidden`}),(0,z.jsxs)(B,{type:`button`,variant:`link`,className:`text-white`,children:[`Learn More `,r?(0,z.jsx)(we,{}):(0,z.jsx)(vt,{})]})]}),(0,z.jsx)(U,{children:(0,z.jsxs)(`dl`,{className:R(`divide-y divide-black overflow-hidden transition-[max-height] duration-200 ease-in`,r?`max-h-fit`:`max-h-0`),children:[(0,z.jsxs)(`div`,{className:`text-sm mb-3 max-w-lg`,children:[`This plan licenses Harper for the usage limits below, `,g,`. The usage license expires`,_,` `,`when any usage limit is reached. New usage blocks are automatically purchased/billed as blocks are consumed.`]}),u.map((e,t)=>(0,z.jsxs)(`div`,{className:R(`px-4 py-1 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-3`,t%2==0&&`bg-gray-700`),children:[(0,z.jsx)(`dt`,{className:`text-sm/6 font-medium text-gray-300`,children:e.label}),(0,z.jsx)(`dd`,{className:`mt-1 text-sm/6 sm:col-span-2 sm:mt-0`,children:e.value})]},e.label))]})}),(0,z.jsx)(q,{})]})}function tl({control:e,fieldArray:t,form:n,index:r,regionNameToLatencyToRegion:i,selectedPlan:a,isEnterprise:o}){let s=(0,L.useMemo)(()=>Object.keys(i).sort(),[i]),c=n.watch(`deploymentDescription`)?.startsWith(`Dedicated`),l=n.watch(`regionPlans.${r}.regionName`),u=n.watch(`regionPlans.${r}.latencyDescription`),d=(0,L.useMemo)(()=>Object.keys(i[l]||{}).sort(Wc).reverse(),[i,l]);(0,L.useEffect)(function(){if(l&&d?.length&&!d?.includes(u)){let e=u?.split(` `)[0].toLowerCase(),t=d.find(t=>e?t.split(` `)[0].toLowerCase()===e:!0)||d[0];n.setValue(`regionPlans.${r}.latencyDescription`,t),n.trigger()}},[d,n,r,u,l]);let f=(0,L.useCallback)(()=>{t?.remove(r),n.trigger()},[t,n,r]);return(0,z.jsxs)(`div`,{className:`md:col-span-6 col-span-3 p-4 rounded-md bg-accent gap-6 flex flex-wrap items-start`,children:[(0,z.jsx)(W,{control:e,name:`regionPlans.${r}.regionName`,render:({field:e})=>(0,z.jsxs)(G,{className:`flex-1`,children:[(0,z.jsxs)(K,{children:[`Region `,t.fields.length>1?r+1:``]}),(0,z.jsx)(U,{children:(0,z.jsxs)(Dc,{onValueChange:t=>{e.onChange(t),n.trigger()},...e,children:[(0,z.jsx)(Ac,{className:`w-full`,children:(0,z.jsx)(kc,{placeholder:`Choose Region`})}),(0,z.jsx)(jc,{children:(0,z.jsx)(Oc,{children:s.map(e=>(0,z.jsx)($,{value:e,children:e},e))})})]})}),(0,z.jsx)(q,{})]})}),(0,z.jsx)(W,{control:e,name:`regionPlans.${r}.latencyDescription`,render:({field:e})=>(0,z.jsxs)(G,{className:`flex-1`,children:[(0,z.jsxs)(K,{children:[`Estimated `,c?`P95`:`P90`,` Latency, Distribution`]}),(0,z.jsx)(U,{children:(0,z.jsxs)(Dc,{onValueChange:t=>{e.onChange(t),n.trigger()},...e,disabled:!d?.length,children:[(0,z.jsx)(Ac,{className:`w-full`,children:(0,z.jsx)(kc,{placeholder:`Choose Latency Tier`})}),(0,z.jsx)(jc,{children:(0,z.jsx)(Oc,{children:d.map(e=>(0,z.jsx)($,{value:e,children:e},e))})})]})}),(0,z.jsx)(q,{})]})}),t?.fields?.length&&t?.fields?.length>1&&(0,z.jsx)(`div`,{className:`flex-none mt-6`,children:(0,z.jsxs)(B,{type:`button`,variant:`destructiveOutline`,size:`sm`,onClick:f,children:[(0,z.jsx)($t,{}),` `,(0,z.jsx)(`span`,{className:`sr-only`,children:`Remove`})]})}),(0,z.jsx)(el,{selectedPlan:a,selectedRegion:i[l]?.[u],isEnterprise:o})]})}function nl({form:e,regionLocations:t,regionNameToLatencyToRegion:n,selectedPlan:r,totalPrice:i,isEnterprise:a}){let o=e.watch(`regionPlans`),s=ct({control:e.control,name:`regionPlans`}),c=(0,L.useMemo)(()=>{let e=o.map(e=>n?.[e.regionName]?.[e.latencyDescription]?.region);return i?t?.find(t=>!e.includes(t.region)):null},[t,n,o,i]),l=(0,L.useCallback)(()=>{c&&(s.append({regionName:c.region,latencyDescription:c.latencyDescription}),e.trigger())},[e,c,s]);return t?.length?(0,z.jsxs)(z.Fragment,{children:[s.fields.map((t,i)=>(0,z.jsx)(tl,{control:e.control,fieldArray:s,form:e,index:i,regionNameToLatencyToRegion:n,selectedPlan:r,isEnterprise:a},t.id)),c&&(0,z.jsx)(`div`,{className:`md:col-span-6 col-span-3`,children:(0,z.jsxs)(B,{type:`button`,variant:`positiveOutline`,className:`rounded-full`,onClick:l,children:[(0,z.jsx)(C,{}),`Add Additional Region Usage`]})})]}):(0,z.jsx)(`div`,{className:`md:col-span-6 col-span-3`,children:(0,z.jsx)(Oi,{className:`mt-0 m-0`,title:`No Regions Available`,showReturnToHome:!1,error:{message:(0,z.jsxs)(z.Fragment,{children:[`The deployment type you selected currently has no available regions. Please try a different deployment type, try again later, or `,(0,z.jsx)(xs,{}),`.`]})}})})}function rl({control:e,fieldArray:t,form:n,index:r}){let i=(0,L.useCallback)(()=>{t?.remove(r)},[t,r]);return(0,z.jsxs)(`div`,{className:`md:col-span-6 col-span-3 p-4 rounded-md bg-accent gap-6 flex flex-wrap items-start`,children:[(0,z.jsx)(W,{control:e,name:`instances.${r}.secure`,render:({field:e})=>(0,z.jsxs)(G,{children:[(0,z.jsxs)(K,{children:[`Instance `,t.fields.length>1?r+1:``]}),(0,z.jsx)(U,{children:(0,z.jsxs)(Dc,{...e,onValueChange:t=>{e.onChange(t),n.trigger()},children:[(0,z.jsx)(Ac,{className:`w-full`,children:(0,z.jsx)(kc,{placeholder:`https://`})}),(0,z.jsx)(jc,{children:(0,z.jsxs)(Oc,{children:[(0,z.jsx)($,{value:`true`,children:`https://`}),(0,z.jsx)($,{value:`false`,children:`http://`})]})})]})}),(0,z.jsx)(q,{})]})}),(0,z.jsx)(W,{control:e,name:`instances.${r}.fqdn`,render:({field:e})=>(0,z.jsxs)(G,{className:`flex-3`,children:[(0,z.jsx)(K,{children:`Host Name`}),(0,z.jsx)(U,{children:(0,z.jsx)(J,{...e,type:`text`,autoCapitalize:`none`,autoComplete:`off`,autoCorrect:`off`})}),(0,z.jsx)(q,{})]})}),(0,z.jsx)(W,{control:e,name:`instances.${r}.port`,render:({field:e})=>(0,z.jsxs)(G,{children:[(0,z.jsx)(K,{children:`Operations API Port`}),(0,z.jsx)(U,{children:(0,z.jsx)(J,{...e,type:`number`,min:0,max:Sc,autoCapitalize:`none`,autoComplete:`off`,autoCorrect:`off`,placeholder:String(Jr),onChange:t=>{e.onChange(t.target.value?parseInt(t.target.value,10):void 0),n.trigger()}})}),(0,z.jsx)(q,{})]})}),t?.fields?.length&&t?.fields?.length>1&&(0,z.jsx)(`div`,{className:`flex-none mt-6`,children:(0,z.jsxs)(B,{type:`button`,variant:`destructiveOutline`,size:`sm`,onClick:i,children:[(0,z.jsx)($t,{}),` `,(0,z.jsx)(`span`,{className:`sr-only`,children:`Remove`})]})})]})}function il({form:e}){let t=ct({control:e.control,name:`instances`}),n=(0,L.useCallback)(()=>{t.append({secure:`true`,fqdn:``,port:Jr})},[t]);return(0,z.jsxs)(z.Fragment,{children:[t.fields.map((n,r)=>(0,z.jsx)(rl,{control:e.control,fieldArray:t,form:e,index:r},n.id)),(0,z.jsx)(`div`,{className:`md:col-span-6 col-span-3`,children:(0,z.jsxs)(B,{type:`button`,variant:`positiveOutline`,className:`rounded-full`,onClick:n,children:[(0,z.jsx)(C,{}),`Add Instance`]})})]})}function al({calculatedNames:e,clusterId:t,deploymentToPerformanceToPlan:n,form:r,harperVersions:i,isEnterprise:a,isPending:o,mode:s,regionLocations:c,regionNameToLatencyToRegion:l,selectedDeployment:u,selectedPerformance:d,selectedPlan:f,totalPrice:p}){let{isDirty:m,isValid:h}=Ct(),g=(0,L.useMemo)(()=>Object.keys(n[u]||{}).map(e=>{let t=e.slice(0,-1).split(`(`);if(t.length>1)return{performanceTier:e,name:t[0],description:t[1]};let n=e.split(` for `);return n.length>1?{performanceTier:e,name:n[0],description:`For `+n[1]}:{performanceTier:e,name:e,description:``}}),[n,u]),_=(0,L.useMemo)(()=>Object.keys(n).sort(),[n]);(0,L.useEffect)(function(){g?.length&&!g.find(e=>e.performanceTier===d)&&(r.setValue(`performanceDescription`,g[0].performanceTier),r.trigger())},[u,d,g,r]);let v=u===`Self-Hosted`,y=(0,z.jsx)(Z,{className:`mt-3 mb-12`,children:(0,z.jsxs)(B,{type:`submit`,variant:`submit`,className:`rounded-full`,disabled:o||t&&!m||!h,children:[s!==`version`&&p>0?`Confirm Payment Details`:t?`Edit Cluster`:`Create New Cluster`,(0,z.jsx)(vt,{})]})});return s===`version`?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`grid grid-cols-3 gap-6 text-white md:grid-cols-6`,children:[(0,z.jsx)(Rc,{className:i?.value?.length?`col-span-3`:`md:col-span-6 col-span-3`,disabled:!0,form:r}),(0,z.jsx)(Hc,{className:`col-span-3`,form:r,harperVersions:i}),(0,z.jsx)(Vc,{className:`col-span-3 md:col-span-6`,form:r})]}),y]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`grid grid-cols-3 gap-6 text-white md:grid-cols-6`,children:[(0,z.jsx)(Rc,{className:i?.value?.length?`col-span-3`:`md:col-span-6 col-span-3`,disabled:!!t,form:r}),(0,z.jsx)(Hc,{className:`col-span-3`,disabled:!!t,form:r,harperVersions:i}),v?(0,z.jsx)(Lc,{form:r,disabled:!!t}):(0,z.jsx)(Tc,{form:r,calculatedNames:e,disabled:!!t}),(0,z.jsx)(Ic,{form:r,availableDeploymentTypes:_}),(0,z.jsx)(zc,{availablePerformanceDescriptions:g,form:r,selectedDeployment:u}),v?(0,z.jsx)(il,{form:r}):(0,z.jsx)(nl,{form:r,regionLocations:c,regionNameToLatencyToRegion:l,selectedPlan:f,totalPrice:p,isEnterprise:a}),t&&!v&&(0,z.jsx)(Vc,{className:`col-span-3 md:col-span-6`,form:r})]}),y]})}function ol(e){let{fqdn:t}=e,{secure:n,port:r}=e;return r||=Jr,r===443&&n===`false`&&(n=`true`),r===80&&n===`true`&&(n=`false`),`${n===`true`?`https`:`http`}://${t}${r===443||r===80?``:`:`+r}`.toLowerCase()}function sl(e,t,n){let r=e.find(e=>(n?!!e.priceUsd:!e.priceUsd)&&e.deploymentType===`colocated`)||e.find(e=>e.deploymentType===`colocated`)||e[0],i=r?.allowedRegionIds;if(r){let e=i?t.filter(e=>i.includes(e.id)):t,n=e.find(e=>e.region===`US`)||e[0];if(n)return{deploymentDescription:r.deploymentDescription,performanceDescription:r.performanceDescription,regionPlans:[{regionName:n.region,latencyDescription:n.latencyDescription}]}}return null}function cl(e,t,n){if(t&&n){let r=e.getValues();if(!r.deploymentDescription||!r.performanceDescription||!r.regionPlans.length){let i=sl(t,n);i&&(!r.deploymentDescription&&!r.performanceDescription&&(e.setValue(`deploymentDescription`,i.deploymentDescription),e.setValue(`performanceDescription`,i.performanceDescription)),r.regionPlans.length||e.setValue(`regionPlans`,i.regionPlans))}}}function ll({price:e}){return(0,z.jsx)(`span`,{className:`text-4xl`,children:new Intl.NumberFormat(`en-US`,{style:`currency`,currency:`USD`}).formatToParts(e||0).map((e,t)=>(0,z.jsx)(ul,{type:e.type,value:e.value},t))})}function ul({type:e,value:t}){switch(e){case`currency`:case`decimal`:case`fraction`:return(0,z.jsx)(`sup`,{className:`font-light text-xl`,children:t});default:return t}}function dl({alreadyUsingFree:e,clusterId:t,defaultValues:n,deploymentToPerformanceToPlan:r,harperVersions:a,mode:o,organization:s,organizationId:c,planTypes:l,regionLocationsColocated:u,regionLocationsDedicated:d,setSavedClusterState:f,startOffOnBilling:p}){let m=T(),h=kn(),g=s?.type===Zs,_=Vt(),{mutate:v,isPending:y}=Ks(),{mutate:b,isPending:x}=Js(),[ee,te]=(0,L.useState)(p),ne=(0,L.useMemo)(()=>Is(u?.sort(As(`latencyDescription`))||[],`region`,`latencyDescription`),[u]),re=(0,L.useMemo)(()=>Is(d?.sort(As(`latencyDescription`))||[],`region`,`latencyDescription`),[d]),ie=(0,L.useCallback)((t,n)=>{let i=new Set,a=r?.[t.deploymentDescription]?.[t.performanceDescription];if(t.deploymentDescription===`Self-Hosted`)for(let e=0;e<t.instances.length;e++){let r=ol(t.instances[e]);i.has(r)?n.addIssue({code:`custom`,path:[`instances.${e}.fqdn`],message:`Every instance url must be unique!`}):i.add(r)}else{a?.priceUsd===0&&e&&n.addIssue({code:`custom`,path:[`performanceDescription`],message:`Only one free cluster is allowed per organization.`});let r=a?.deploymentDescription===`Dedicated`?re:ne;for(let e=0;e<t.regionPlans.length;e++){let o=t.regionPlans[e],s=r[o.regionName]?.[o.latencyDescription];i.has(o.regionName)?n.addIssue({code:`custom`,path:[`regionPlans.${e}.regionName`],message:`You can only select a region once!`}):i.add(o.regionName),a?.allowedRegionIds?.length&&s?.id&&(a.allowedRegionIds.includes(s.id)?e>=1&&n.addIssue({code:`custom`,path:[`regionPlans.${e}.regionName`],message:`You can only select one region with this performance tier!`}):$s(a.allowedRegionIds,s.id)?n.addIssue({code:`custom`,path:[`regionPlans.${e}.latencyDescription`],message:`This latency is not available with the selected performance tier!`}):n.addIssue({code:`custom`,path:[`regionPlans.${e}.regionName`],message:`This region is not available with the selected performance tier!`}))}}},[e,ne,re,r]),S=N({mode:`onChange`,resolver:w(wc.superRefine(ie)),defaultValues:n}),[ae,oe]=(0,L.useState)(!0);(0,L.useEffect)(()=>{ae&&n&&(f(null),oe(!1))},[n,ae,f]);let se=S.watch(`clusterName`),ce=S.watch(`abbreviatedName`),le=S.watch(`deploymentDescription`),ue=S.watch(`performanceDescription`),de=S.watch(`regionPlans`),fe=S.watch(`instances`),pe=le===`Dedicated`?re:ne,me=le===`Dedicated`?d:u;(0,L.useEffect)(function(){let e=S.getValues();le&&(le===`Self-Hosted`?(e.abbreviatedName&&S.setValue(`abbreviatedName`,``),e.regionPlans.length&&S.setValue(`regionPlans`,[]),e.instances.length||S.setValue(`instances`,[{secure:`true`,fqdn:``,port:Jr}])):(e.fqdn&&S.setValue(`fqdn`,``),e.instances.length&&S.setValue(`instances`,[]),e.regionPlans.length||cl(S,l,me)))},[S,l,me,le]);let he=(0,L.useMemo)(()=>{let e=Qs(ec(se),Cc.maxLength);return{suggestedAbbreviatedName:e,fullHostName:`${ce||e}.${s.subdomain||`your-org`}.harperfabric.com`}},[se,ce,s]),ge=(0,L.useMemo)(()=>r?.[le]?.[ue],[r,le,ue]);(0,L.useEffect)(function(){let e=ge?.allowedRegionIds;if(e?.length&&de?.length===1){let t=de[0],n=pe?.[t.regionName]?.[t.latencyDescription];if(!e.includes(n?.id)){let t=me?.filter(t=>e.includes(t.id)),n=t?.find(e=>e.region===`US`)||t?.[0];n&&(S.setValue(`regionPlans.0.regionName`,n.region),S.setValue(`regionPlans.0.latencyDescription`,n.latencyDescription),S.trigger())}}},[ge,de,S,pe,me]),(0,L.useEffect)(function(){if(le!==`Self-Hosted`&&Object.keys(pe).length&&de.length)for(let e=0;e<de.length;e++)pe[de[e].regionName]||S.setValue(`regionPlans.${e}.regionName`,``)},[S,pe,le,de]);let _e=ge?.priceUsd?le===`Self-Hosted`?fe.length*ge.priceUsd:de.reduce((e,t)=>{let n=pe?.[t.regionName]?.[t.latencyDescription];return e+(n?ge.priceUsd*n.instanceCount/2:0)},0):0,ve=(0,L.useCallback)(({creating:e,deploymentDescription:t})=>k.message(e?`Creating Cluster`:`Updating Cluster`,{description:(0,z.jsx)(Ws,{message:`This may take a little bit, hold tight!`,lateMessage:`Still working on it... why don't you grab a coffee, and I'll let you know when it's done?`,duration:t===`Dedicated`?6e4:5e3}),duration:12e4}),[]),C=(0,L.useCallback)(async({clusterId:e,sourceClusterId:t,creating:n,toastId:r,isSelfManaged:i})=>{if(t){let e=(await Ys(c)).clusters?.find(e=>e.id===t);Wo(e?.status)&&await fs(t)}_.invalidateQueries({queryKey:[c],refetchType:`active`}),n||_.invalidateQueries({queryKey:[e],refetchType:`active`}),h.invalidate(),m(i?{to:`/${c}/${e}/instances`}:n?{to:`/${c}/${e}/starting-up`}:{to:`/${c}/${e}/scaling`}),S.reset(),k.success(n?`Cluster Created`:`Cluster Updated`,{id:r,description:i?void 0:n?`It is being provisioned now.`:`The updates are being provisioned now.`,duration:5e3})},[_,h,m,c,S]),ye=(0,L.useCallback)(async()=>{let e=S.getValues(),n=[],i=r[e.deploymentDescription][e.performanceDescription],a=e.deploymentDescription===`Self-Hosted`;if(a)for(let t of e.instances)n.push({autoRenew:!0,instanceFqdn:t.fqdn,operationsApiPort:t.port||9925,operationsApiSecure:t.secure===`true`,planId:i.id});else for(let t of e.regionPlans){let e=pe[t.regionName][t.latencyDescription];n.push({autoRenew:!0,planId:i.id,regionId:e.id})}f(null);let s=ve({creating:!t,deploymentDescription:e.deploymentDescription}),l=()=>k.dismiss(s);t?b(o===`version`?{id:t,version:e.version,skipGtmWait:e.skipGtmWait}:{id:t,regionPlans:n,skipGtmWait:e.skipGtmWait},{onSuccess:t=>C({clusterId:t.id,sourceClusterId:e.sourceClusterId,isSelfManaged:a,creating:!1,toastId:s}),onError:l}):v({abbreviatedName:a?void 0:e.abbreviatedName||he.suggestedAbbreviatedName,autoRenew:!0,fqdn:a&&e.fqdn||void 0,name:e.clusterName,version:e.version,organizationId:c,regionPlans:n},{onSuccess:t=>C({clusterId:t.id,sourceClusterId:e.sourceClusterId,isSelfManaged:a,creating:!0,toastId:s}),onError:l})},[he.suggestedAbbreviatedName,t,r,S,C,ve,c,pe,f,b,v]),be=(0,L.useCallback)(()=>{if(o!==`version`&&_e>0){te(!0);return}return ye()},[o,ye,_e]),xe=(0,L.useCallback)(e=>{f(e?{clusterId:t,...S.getValues(),skipToBilling:!0}:null)},[t,S,f]),Se=(0,L.useCallback)(()=>{te(!1)},[]),Ce=!g&&`mr-37.5`;return(0,z.jsxs)(z.Fragment,{children:[!g&&o!==`version`&&(0,z.jsxs)(`div`,{className:`absolute top-3 right-4 md:right-12 text-right`,children:[(0,z.jsx)(`dt`,{className:`font-light`,children:`Total Price`}),(0,z.jsx)(`dd`,{className:`font-bold`,children:(0,z.jsx)(ll,{price:_e})})]}),(0,z.jsx)(H,{...S,children:ee?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`h1`,{className:i(`text-lg leading-none text-white font-semibold mb-4`,Ce),children:`Cluster Billing`}),(0,z.jsx)(`p`,{className:i(`text-muted-foreground text-sm mb-2`,Ce),children:`Please confirm the following billing details:`}),(0,z.jsx)(bc,{clusterId:t,isPending:y||x,onGoBackToDetails:Se,onSaveStateForBillingRedirect:xe,onSubmit:ye,organizationId:c,selectedPlan:ge})]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`h1`,{className:i(`text-lg leading-none text-white font-semibold mb-4`,Ce),children:`Cluster Configuration`}),(0,z.jsx)(`p`,{className:i(`text-muted-foreground text-sm mb-6`,Ce),children:`Configure your Harper cluster and define deployment plans.`}),(0,z.jsx)(`form`,{id:`cluster-upsert-form`,name:`cluster-upsert-form`,onSubmit:S.handleSubmit(be),children:(0,z.jsx)(al,{calculatedNames:he,clusterId:t,deploymentToPerformanceToPlan:r,form:S,isPending:y||x,harperVersions:a,mode:o,regionLocations:me,regionNameToLatencyToRegion:pe,selectedDeployment:le,selectedPerformance:ue,selectedPlan:ge,totalPrice:_e,isEnterprise:g})})]})})]})}function fl(e){return e?.clusterName!==void 0}function pl(){let{organizationId:e,clusterId:t,mode:n}=M({strict:!1}),{create:r,update:i}=aa(e),{organization:a,cluster:o}=Nt({strict:!1}),[s,c]=vs(ys.SavedClusterState,null),{data:l}=D(Ts(e)),{data:u}=D(ks({availableHosts:!0,organizationId:e})),{data:d}=D(ks({organizationId:e})),{data:f}=D(Ds()),p=(0,L.useMemo)(()=>{if(o){let e=o.instances?.map(e=>e.version).filter(Ni);if(f&&e){let t=e.sort(Rs).pop();return{...f,value:[!!t&&{name:`current`,version:t},...(f?.value||[]).filter(e=>t!==e.version&&(!t||Ls(t,e.version)))].filter(Ni)}}}return f},[f,o]),m=(0,L.useMemo)(()=>{for(let e of a?.clusters??[])if(e.id!==o?.id&&l&&!Go(e.status)&&!Wo(e.status)&&e.plans)for(let t of e.plans){let e=l.find(e=>e.id===t.planId);if(e?.priceUsd===0&&!e.id.startsWith(`self-hosted`))return!0}return!1},[o?.id,a?.clusters,l]),h=(0,L.useMemo)(()=>Is(l?.sort(As(`priceUsd`))||[],`deploymentDescription`,`performanceDescription`),[l]),g=(0,L.useMemo)(()=>{if(!l||!p||!u||!d||t&&!o)return null;let e=o;if(s){if(fl(s))return{...s,clusterName:s.clusterName||``,abbreviatedName:s.abbreviatedName||``,version:s.version,deploymentDescription:s.deploymentDescription||``,performanceDescription:s.performanceDescription||``,fqdn:s.fqdn||``,regionPlans:s.regionPlans||[],instances:s.instances||[]};e=s}let n=l?.find(e=>e.id===o?.plans?.[0].planId),r=[],i=[],a=n?.deploymentDescription===`Dedicated`?d:u,c=sl(l,a,m),f=!1;if(e){if(e.plans){for(let t of e.plans)if(t.regionId){let e=a.find(e=>e.id===t.regionId);e&&r.push({regionName:e.region,latencyDescription:e.latencyDescription})}}if(!r.length&&e.instances){let t=e.instances.filter(e=>e.status&&!Ba.includes(e.status)).sort(Ns);for(let e of t)f=!0,i.push({fqdn:e.instanceFqdn,port:e.operationsApiPort,secure:e.operationsApiSecure?`true`:`false`})}}else c&&r.push(...c.regionPlans);!f&&!r.length&&r.push({regionName:``,latencyDescription:``});let h=p.value?.find(e=>e.name===`current`)?.version??p.value?.find(e=>e.name===`stable`)?.version;return{sourceClusterId:e?.id,autoRenew:e?.plans?.[0]?.autoRenew??!0,clusterName:e?.name??``,abbreviatedName:e?.abbreviatedName??``,version:h,deploymentDescription:n?.deploymentDescription??c?.deploymentDescription??``,performanceDescription:n?.performanceDescription??c?.performanceDescription??``,fqdn:f?e?.fqdn??``:``,instances:i,regionPlans:r}},[m,o,t,l,p,u,d,s]);return!g||!a||!l||!u||!d?(0,z.jsx)(Cs,{children:(0,z.jsx)(Ss,{centered:!0,text:`Loading...`})}):(o?.id?!i:!r)?(0,z.jsx)(Cs,{children:(0,z.jsx)(Oi,{title:`Not Allowed`,error:{message:(0,z.jsxs)(z.Fragment,{children:[`You do not have permission to `,o?.id?`update`:`create`,` clusters in this org.`]})}})}):l.length===0?(0,z.jsx)(Cs,{children:(0,z.jsx)(Oi,{title:`Cluster ${t?`Modification`:`Creation`} Not Currently Allowed`,error:{message:(0,z.jsxs)(z.Fragment,{children:[`There are no available deployment types right now! Please try again later, or `,(0,z.jsx)(xs,{}),`.`]})}})}):(0,z.jsx)(Cs,{className:`max-w-4xl mx-auto`,children:(0,z.jsx)(dl,{alreadyUsingFree:m,clusterId:t,defaultValues:g,deploymentToPerformanceToPlan:h,harperVersions:p,mode:n,organization:a,organizationId:e,planTypes:l,regionLocationsColocated:u,regionLocationsDedicated:d,setSavedClusterState:c,startOffOnBilling:fl(s)&&s.skipToBilling===!0})})}var ml={FAILED:0,UPDATING:1,PROVISIONING:2,RUNNING:3,TERMINATED:4},hl=ml.RUNNING;function gl(e,t){return e.status===t.status?e.name.localeCompare(t.name):(e.status?ml[e.status]??hl:hl)-(t.status?ml[t.status]??hl:hl)}function _l(e,t){let n=t.toLowerCase();return t=>{for(let r of e){let e=t[r];if(e!=null)if(typeof e==`string`){if(e.toLowerCase().includes(n))return!0}else if(typeof e==`boolean`){if(e&&(n===`yes`||n===`true`||n===`1`)||!e&&(n===`no`||n===`false`||n===`0`))return!0}else throw Error(`curryFilterByFuzzySearch has not implemented support for `+typeof e+` fields yet!`)}return!1}}function vl(){let{organizationId:e}=M({strict:!1}),{create:t}=aa(e),{data:n,isSuccess:r}=Nn(Xs(e)),[i]=vs(ys.SavedClusterState,null),[a,o]=(0,L.useState)(``),s=(0,L.useCallback)(()=>o(``),[]),c=(0,L.useCallback)(e=>{o(e.currentTarget.value?.toLowerCase()||``)},[]),l=(0,L.useMemo)(()=>n?.clusters?.slice().filter(e=>!Go(e.status)).sort(gl)||[],[n?.clusters]),u=(0,L.useMemo)(()=>l.filter(_l([`id`,`name`],a))||[],[a,l]);return n&&l.length===0&&t?(0,z.jsx)(pl,{}):i?(0,z.jsx)(vn,{to:`/${e}/new-cluster`}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(Vo,{children:r?(0,z.jsxs)(`div`,{className:`flex w-full justify-end gap-2`,children:[(0,z.jsx)(J,{placeholder:`Filter by name`,className:`inline-block w-full text-xs`,value:a,onChange:c}),t&&(0,z.jsx)(j,{to:`new-cluster`,children:(0,z.jsxs)(B,{variant:`positive`,accessKey:`n`,children:[(0,z.jsx)(C,{}),` `,(0,z.jsxs)(`span`,{className:`hidden sm:inline-block`,children:[(0,z.jsx)(`u`,{children:`N`}),`ew `,(0,z.jsx)(`span`,{className:`hidden md:inline-block`,children:`Cluster`})]})]})})]}):null}),(0,z.jsx)(`section`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-(--spacing(32)))]`,children:(0,z.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-12 mb-4`,children:[u.map(e=>(0,z.jsx)(`div`,{className:`col-span-1 md:col-span-4 lg:col-span-3 2xl:col-span-2`,children:(0,z.jsx)(bs,{cluster:e})},e.id)),!u.length&&(0,z.jsxs)(`div`,{className:`col-span-1 md:col-span-12 text-center`,children:[(0,z.jsx)(`h2`,{className:`my-4 text-xl`,children:`No matches found.`}),(0,z.jsx)(B,{type:`button`,variant:`outline`,onClick:s,children:`Clear Filters`})]})]})})]})}function yl(){let e=URL.parse(location.href);return e?.hash?e.hash.startsWith(`#/`)?e.hash.slice(1):e.hash:`/`}function bl(){return`/#`+yl()}function xl(){let{organizationId:e}=M({strict:!1}),t=T(),n=new URLSearchParams(window.location.search).get(`setup_intent_client_secret`),{setup_intent_client_secret:r}=zn({strict:!1}),[i]=vs(ys.SavedClusterState,null),a=n||r,o=pn(),s=rc(e),c=(0,L.useCallback)(()=>{let e=i?i.clusterId?`../../${i.clusterId}/edit`:`../../new-cluster`:`../`;window.history.replaceState(null,``,bl()),t({search:void 0,to:e})},[t,i]);return(0,L.useEffect)(()=>{!o||!a||!s||!e||!c||(async function(){try{let{setupIntent:e}=await o.retrieveSetupIntent(a);switch(e?.status){case`succeeded`:e.payment_method===null?(k.error(`Failed to process payment method details. Please try another payment method.`),c()):s(e.payment_method,c);break;case`processing`:k.warning(`Processing payment method. Please check back later.`),c();break;case`requires_payment_method`:k.error(`Failed to process payment method details. Please try another payment method.`),c();break;default:k.error(`Failed to process payment method details. Please try another payment method.`),c();break}}catch(e){console.error(e),k.error(`Failed to process payment method details. Please try another payment method.`),c()}})()},[a,c,e,s,o]),(0,z.jsx)(Ss,{centered:!0})}function Sl(){return(0,z.jsx)(fc,{children:(0,z.jsx)(xl,{})})}function Cl({clusterId:e,instanceId:t,organizationId:n},r){return`/`+[n,e,t&&`instance`,t,r].filter(Ni).join(`/`)}var wl=`flex items-center p-2 rounded-lg group`,Tl={className:`text-white hover:bg-gray-700`},El={className:`text-black bg-white pointer-events-none cursor-default`};function Dl(){let{organizationId:e}=M({strict:!1}),{update:t}=ra(e);return t?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(Vo,{}),(0,z.jsx)(`div`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-theme(spacing.32))]`,children:(0,z.jsxs)(`div`,{className:`md:grid gap-4 md:grid-cols-12 min-h-[calc(100vh-theme(spacing.36))] mb-12`,children:[(0,z.jsxs)(`section`,{className:`col-span-1 text-white md:col-span-4 lg:col-span-3 md:border-r-1 border-b md:border-b-0 md:pr-4 border-gray-700`,children:[(0,z.jsx)(Ol,{}),(0,z.jsx)(kl,{})]}),(0,z.jsx)(`section`,{className:`col-span-1 text-white md:col-span-8 lg:col-span-9`,children:(0,z.jsx)(rt,{})})]})})]}):(0,z.jsx)(`div`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-theme(spacing.32))]`,children:`You don't have access to manage payments for this organization. Please contact your administrator.`})}function Ol(){let e=M({strict:!1});return(0,z.jsxs)(`div`,{className:`hidden md:block`,children:[(0,z.jsxs)(`span`,{className:wl,children:[(0,z.jsx)(pr,{className:`inline-block`}),(0,z.jsx)(`h3`,{className:`ms-3 text-2xl font-extrabold dark:text-white`,children:`Billing`})]}),(0,z.jsxs)(`ul`,{className:`border-t border-gray-700 pt-4 mt-4 space-y-2`,children:[(0,z.jsx)(`li`,{children:(0,z.jsxs)(j,{to:Cl(e,`billing`),className:wl,activeOptions:{exact:!0},inactiveProps:Tl,activeProps:El,children:[(0,z.jsx)(Pn,{className:`inline-block`}),` `,(0,z.jsx)(`span`,{className:`ms-3`,children:`Payment Method`})]})}),(0,z.jsx)(`li`,{children:(0,z.jsxs)(j,{to:Cl(e,`billing/invoices`),className:wl,inactiveProps:Tl,activeProps:El,children:[(0,z.jsx)(_t,{className:`inline-block`}),(0,z.jsx)(`span`,{className:`ms-3`,children:`Invoices & Payments`})]})})]})]})}function kl(){let e=M({strict:!1});return(0,z.jsxs)(`ul`,{className:`flex space-x-4 md:hidden py-2`,children:[(0,z.jsx)(`li`,{children:(0,z.jsxs)(j,{to:Cl(e,`billing`),className:wl,activeOptions:{exact:!0},inactiveProps:Tl,activeProps:El,children:[(0,z.jsx)(Pn,{className:`inline-block`}),` `,(0,z.jsx)(`span`,{className:`ms-3`,children:`Payment Method`})]})}),(0,z.jsx)(`li`,{children:(0,z.jsxs)(j,{to:Cl(e,`billing/invoices`),className:wl,inactiveProps:Tl,activeProps:El,children:[(0,z.jsx)(_t,{className:`inline-block`}),` `,(0,z.jsx)(`span`,{className:`ms-3`,children:`Invoices & Payments`})]})})]})}function Al({className:e,containerClassName:t,...n}){return(0,z.jsx)(`div`,{"data-slot":`table-container`,className:R(`relative w-full overflow-x-auto`,t),children:(0,z.jsx)(`table`,{"data-slot":`table`,className:R(`w-full caption-bottom text-sm`,e),...n})})}function jl({className:e,...t}){return(0,z.jsx)(`thead`,{"data-slot":`table-header`,className:R(`[&_tr]:border-b`,e),...t})}function Ml({className:e,...t}){return(0,z.jsx)(`tbody`,{"data-slot":`table-body`,className:R(`[&_tr:last-child]:border-0`,e),...t})}function Nl({className:e,...t}){return(0,z.jsx)(`tr`,{"data-slot":`table-row`,className:R(`border-b border-grey-700 transition-colors`,e),...t})}function Pl({className:e,...t}){return(0,z.jsx)(`th`,{"data-slot":`table-head`,className:R(`h-10 text-left align-middle font-medium whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]`,e),...t})}function Fl({header:e,onColumnClick:t,...n}){let r=(0,L.useCallback)(()=>{e.column.toggleSorting(e.column.getIsSorted()===`asc`);let n=e.column.getIsSorted()===!1||e.column.getIsSorted()!==`asc`;t?.(e.column.columnDef.accessorKey,n)},[e,t]),i=e.column.columnDef.enableSorting,a=e.column.columnDef.enableResizing,o=e.isPlaceholder?null:Jn(e.column.columnDef.header,e.getContext()),s=(0,L.useCallback)(()=>{e.column.resetSize()},[e]);return(0,z.jsx)(Pl,{...n,style:{width:`${e.getSize()}px`},className:i?`px-0`:`px-2`,children:(0,z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[i?(0,z.jsxs)(B,{type:`button`,variant:`ghost`,className:R(`rounded-none`,!e.column.getIsSorted()||e.column.getIsSorted()===`asc`?`cursor-n-resize`:`cursor-s-resize`),onClick:r,children:[o,e.column.getIsSorted()===`asc`?(0,z.jsx)(St,{}):e.column.getIsSorted()===`desc`?(0,z.jsx)(we,{}):(0,z.jsx)(Oe,{className:`text-gray-600`})]}):o,a&&(0,z.jsx)(B,{type:`button`,variant:`ghost`,className:`cursor-col-resize`,onMouseDown:e.getResizeHandler(),onTouchStart:e.getResizeHandler(),onDoubleClick:s,style:{transform:e.column.getIsResizing()?`translateX(${e.getContext().table.getState().columnSizingInfo.deltaOffset}px)`:``},children:(0,z.jsx)(qn,{})})]})})}function Il({className:e,...t}){return(0,z.jsx)(`td`,{"data-slot":`table-cell`,className:R(`align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]`,e),...t})}function Ll({columns:e,data:t,isFetching:n,onRowClick:r,onColumnClick:i,sortingState:a,children:o}){let s=Ie({data:t,columns:e,getCoreRowModel:Mt(),getSortedRowModel:ot(),initialState:{sorting:a}});return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-end space-x-2 pb-4`,children:[(0,z.jsx)(`div`,{className:`grow lg:hidden`}),o,(0,z.jsx)(`div`,{className:`grow hidden lg:visible`})]}),(0,z.jsxs)(Al,{containerClassName:`rounded-md bg-black-dark`,children:[(0,z.jsx)(jl,{children:s.getHeaderGroups().map(e=>(0,z.jsx)(Nl,{className:`border-none`,children:e.headers.map(e=>(0,z.jsx)(Fl,{header:e,onColumnClick:i},e.id))},e.id))}),(0,z.jsx)(Ml,{className:`bg-black border border-grey-700`,children:s.getRowModel().rows?.length?s.getRowModel().rows.map(e=>(0,z.jsx)(Nl,{"data-state":e.getIsSelected()&&`selected`,onClick:()=>r?.(e),className:R(`hover:bg-muted/10 data-[state=selected]:bg-muted`,r&&`cursor-pointer`),children:e.getVisibleCells().map(e=>(0,z.jsx)(Il,{className:`py-2 px-2 overflow-x-hidden max-w-32 text-ellipsis whitespace-nowrap`,style:{width:`${e.column.getSize()}px`},children:Jn(e.column.columnDef.cell,e.getContext())},e.id))},e.id)):(0,z.jsx)(Nl,{children:(0,z.jsx)(Il,{colSpan:e.length,className:`h-24 text-center`,children:n?(0,z.jsx)(`div`,{children:(0,z.jsx)(Ss,{className:`p-12`})}):(0,z.jsx)(`span`,{children:`No results.`})})})})]})]})}function Rl(e){switch(e){case`paid`:return`success`;case`void`:case`uncollectible`:return`destructive`;default:return`default`}}function zl(e){return new Intl.NumberFormat(`en-US`,{style:`currency`,currency:`USD`}).format(e)}function Bl(e,t){if(e<45)return`a few seconds ago`;if(e<120)return`a minute ago`;let n=Math.floor(e/60);if(n<60)return`${n} minutes ago`;if(n<120)return`an hour ago`;let r=Math.floor(e/3600);return r>48?new Date(t).toLocaleString():`${r} hours ago`}var Vl=[{header:`Invoice Id`,accessorKey:`id`,enableSorting:!1},{header:`Status`,accessorKey:`status`,enableSorting:!1,cell:({cell:e})=>(0,z.jsx)(es,{variant:Rl(e.getValue()),children:e.getValue()})},{header:`Date`,accessorKey:`periodStart`,enableSorting:!1,cell:({cell:e})=>{let t=e.row.original.periodStart*1e3,n=e.row.original.periodEnd*1e3,r=(Date.now()-t)/1e3,i=(Date.now()-n)/1e3;return Math.abs(r-i)<1e3?Bl(r,t):[t?Bl(r,t):`-`,n?Bl(i,n):`-`].join(` to `)}},{header:`Amount Due`,accessorKey:`amountDue`,enableSorting:!1,cell:({cell:e})=>zl(e.getValue()?e.getValue()/100:0)},{header:`Amount Paid`,accessorKey:`amountPaid`,enableSorting:!1,cell:({cell:e})=>zl(e.getValue()?e.getValue()/100:0)},{header:`Lines`,accessorKey:`lines`,enableSorting:!1,cell:({cell:e})=>{let t=e.getValue(),n=[];for(let e of t)n.push(`${e.quantity}x ${e.description} @ ${zl(e.amount/100)}`);return n.join(`
33
- `)}}];function Hl(e){return(0,L.useCallback)(async()=>{k.loading(`Refreshing...`,{id:`refreshing`});let t=Date.now();await e(),Date.now()-t<500&&await ri(500),k.success(`Refreshed!`,{id:`refreshing`})},[e])}async function Ul(e){let{data:t}=await P.get(`/Invoice/${e}`);return t}function Wl(e,t){return A({queryKey:[e,`invoices`],queryFn:()=>Ul(e),retry:!1,enabled:!!e,refetchInterval:t?1e4:void 0})}function Gl(){let{organizationId:e}=M({strict:!1}),{data:t}=D(Xs(e)),{data:n,refetch:r,isLoading:i,isFetching:a,isRefetching:o}=D(Wl(t?.type!==`ENTERPRISE`&&t?.id,!1)),s=Hl(r);return t?.type===`ENTERPRISE`?(0,z.jsxs)(`span`,{children:[`You are part of an enterprise organization! We don’t currently show your invoices on this page. Want to explore your solution with Harper more? `,(0,z.jsx)(xs,{}),`, we would love to talk!`]}):i?(0,z.jsx)(Ss,{centered:!0}):!n||!n.length?(0,z.jsxs)(`span`,{children:[`Your invoices will be shown here once one is available! Want to explore your solution with Harper more?`,` `,(0,z.jsx)(xs,{overEmail:!0}),`, we would love to talk!`]}):(0,z.jsx)(Ll,{data:n,columns:Vl,children:(0,z.jsxs)(B,{variant:`defaultOutline`,onClick:s,accessKey:`r`,disabled:a||o,children:[(0,z.jsx)(fe,{}),(0,z.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,z.jsx)(`u`,{children:`R`}),`efresh`]})]})})}function Kl(e){let t=O({getParentRoute:()=>e,path:`billing`,component:Dl}),n=O({getParentRoute:()=>t,path:`/`,component:vc}),r=O({getParentRoute:()=>t,path:`invoices`,component:Gl}),i=O({getParentRoute:()=>t,path:`confirm`,component:Sl});return t.addChildren([n,r,i])}async function ql(e){let{data:t}=await P.get(`/OrganizationRole/${e}`);return t}function Jl(e){return A({queryKey:[e,`roles`],queryFn:()=>ql(e),retry:!1,refetchInterval:10*1e3})}var Yl=[{header:`Role Name`,accessorKey:`roleName`,enableSorting:!1},It().display({header:`Users Assigned`,enableSorting:!1,id:`userIds`,cell:e=>!e.row.original.userIds||e.row.original.userIds.length===0?`No users assigned`:e.row.original.userIds.length})];async function Xl(e){let{data:t}=await P.post(`/Role/`,e);return t}function Zl(){return E({mutationFn:Xl})}var Ql=l({name:v().nonempty({error:`Please enter a role name.`}).regex(/^[a-zA-Z_]*$/,{error:`Role must contain only letters and underscores.`}).max(30,{error:`Role name cannot be longer than 30 characters.`}),update:_(),delete:_()});l({roles:l({create:_(),delete:_(),update:_(),view:_()}),clusters:l({create:_(),delete:_(),update:_(),view:_(),resources:f(l({id:v(),delete:_(),update:_(),view:_(),instances:l({create:_(),delete:_(),update:_(),view:_()})}))})});var $l={roles:{create:!0,view:!0,update:!0,delete:!0},clusters:{create:!0,view:!0,update:!0,delete:!0,resources:[]}};function eu({isModalOpen:e,setIsModalOpen:t}){let n=Vt(),{organizationId:r}=M({strict:!1}),[i,a]=(0,L.useState)(!0),[o,s]=(0,L.useState)(JSON.stringify($l,null,2)),{mutate:c,isPending:l}=Zl(),u=N({resolver:w(Ql),defaultValues:{name:``,update:!1,delete:!1}}),d=(0,L.useCallback)(e=>{a(e.length===0)},[a]),f=(0,L.useCallback)(async e=>{let a=hs(o);if(!a)return;let s={...e,...a,organizationId:r};e&&i&&c(s,{onSuccess:()=>{k.success(`Organization role added successfully!`),t(!1),n.invalidateQueries({queryKey:[r,`roles`],refetchType:`active`}),u.reset()},onError:e=>{k.error(`Failed to add organization role: ${e.message}`)}})},[i,o,c,u,n,t,r]);return(0,z.jsx)(Y,{onOpenChange:t,open:e,children:(0,z.jsxs)(X,{children:[(0,z.jsx)(Q,{children:`Add New Organization Role`}),(0,z.jsx)(Qo,{children:`Set the new organization role permissions.`}),(0,z.jsx)(H,{...u,children:(0,z.jsxs)(`form`,{id:`org-add-role-form`,name:`org-add-role-form`,className:`grid grid-cols-2 gap-4 my-4`,onSubmit:u.handleSubmit(f),children:[(0,z.jsx)(W,{control:u.control,name:`name`,render:({field:e})=>(0,z.jsxs)(G,{className:`col-span-2`,children:[(0,z.jsx)(K,{className:`pb-1`,children:`Role Name`}),(0,z.jsx)(U,{children:(0,z.jsx)(J,{type:`text`,className:``,...e})}),(0,z.jsx)(q,{})]})}),(0,z.jsx)(W,{control:u.control,name:`update`,render:({field:e})=>(0,z.jsxs)(G,{children:[(0,z.jsx)(K,{className:`pb-1`,children:`Can Update Organization`}),(0,z.jsx)(U,{children:(0,z.jsx)(J,{type:`checkbox`,className:`w-6 ml-2`,checked:e.value,onChange:t=>e.onChange(t.target.checked)})}),(0,z.jsx)(q,{})]})}),(0,z.jsx)(W,{control:u.control,name:`delete`,render:({field:e})=>(0,z.jsxs)(G,{children:[(0,z.jsx)(K,{className:`pb-1`,children:`Can Delete Organization`}),(0,z.jsx)(U,{children:(0,z.jsx)(J,{type:`checkbox`,className:`w-6 ml-2`,checked:e.value,onChange:t=>e.onChange(t.target.checked)})}),(0,z.jsx)(q,{})]})}),(0,z.jsx)(`div`,{className:`col-span-2`,children:(0,z.jsx)(Be,{theme:`vs-dark`,height:`300px`,defaultLanguage:`json`,onValidate:d,onChange:e=>{e&&s(e)},defaultValue:JSON.stringify($l,null,2)})}),(0,z.jsx)(Z,{className:`col-span-2`,children:(0,z.jsxs)(`div`,{className:`flex justify-between w-full`,children:[(0,z.jsx)(B,{variant:`destructiveOutline`,className:`rounded-full`,type:`button`,onClick:()=>t(!1),disabled:l,children:`Cancel`}),(0,z.jsx)(B,{variant:`submit`,className:`rounded-full`,disabled:l||!i||!u.formState.isValid,children:`Save Changes`})]})})]})})]})})}async function tu({roleId:e}){let{data:t}=await P.delete(`/Role/${e}`,{id:e,deleted:!0});return t}function nu(){return E({mutationFn:({roleId:e})=>tu({roleId:e})})}async function ru({roleId:e,updatedRoleInfo:t}){let{data:n}=await P.put(`/Role/${e}`,t);return n}function iu(){return E({mutationFn:({roleId:e,updatedRoleInfo:t})=>ru({roleId:e,updatedRoleInfo:t})})}function au({organizationId:e,roleId:t}){return A({queryKey:[e,`roles`,t],queryFn:()=>ou(t),refetchInterval:10*1e3})}async function ou(e){let{data:t}=await P.get(`/Role/${e}`);return t}function su({onRoleDeleteClick:e,setIsConfirmingRoleDeletion:t,isRoleDeletionPending:n}){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(Q,{children:`Confirm Role Deletion`}),(0,z.jsx)(Qo,{children:`Are you sure you want to delete this role? This action cannot be undone.`}),(0,z.jsxs)(Z,{children:[(0,z.jsx)(B,{type:`button`,variant:`defaultOutline`,className:`rounded-full`,onClick:()=>t(!1),children:`Cancel`}),(0,z.jsx)(B,{variant:`destructiveOutline`,className:`rounded-full`,onClick:e,disabled:n,children:n?`Deleting...`:`Delete Role`})]})]})}function cu({data:e,isModalOpen:t,closeModal:n}){let r=Vt(),{data:i}=Nn(au({roleId:e.id,organizationId:e.organizationId})),a=hi(),o=a.user&&a.user?.roles?.[e.organizationId]?.role===e.roleName,{update:s,remove:c}=ia(e.organizationId),{mutate:l,isPending:u}=iu(),{mutate:d,isPending:f}=nu(),[p,m]=(0,L.useState)(!1),h=N({resolver:w(Ql),defaultValues:{name:e.roleName,update:i.organization.update||!1,delete:i.organization.delete||!1}}),g=(0,L.useCallback)(()=>{d({roleId:e.id},{onSuccess:()=>{k.success(`Role deleted successfully!`),n(!0),h.reset()},onError:e=>{k.error(`Error`,{description:`Failed to delete role: ${e instanceof Error?e.message:String(e)}.`,action:{label:`Dismiss`,onClick:()=>k.dismiss()}})}})},[e.id,d,h,n]),[_,v]=(0,L.useState)(!0),[y,b]=(0,L.useState)(JSON.stringify({roles:{...i.organization.roles},clusters:{...i.organization.clusters}},null,2)),x=(0,L.useCallback)(e=>{v(e.length===0)},[v]),ee=(0,L.useCallback)(async t=>{if(!s)return;let i=hs(y);if(!i)return;let a={...t,...i,organizationId:e.organizationId};y&&_&&l({roleId:e.id,updatedRoleInfo:a},{onSuccess:async()=>{k.success(`Role updated successfully!`),await r.invalidateQueries({queryKey:[e.organizationId,`roles`,e.id]}),n(!1),h.reset()},onError:e=>{k.error(`Error`,{description:`Failed to update role: ${e instanceof Error?e.message:String(e)}.`,action:{label:`Dismiss`,onClick:()=>k.dismiss()}})}})},[n,e.id,e.organizationId,h,_,r,i,s,y,l]);return(0,z.jsx)(Y,{onOpenChange:(0,L.useCallback)(()=>n(!1),[n]),open:t,children:(0,z.jsx)(X,{children:p?(0,z.jsx)(su,{onRoleDeleteClick:g,setIsConfirmingRoleDeletion:m,isRoleDeletionPending:f}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(Q,{children:[o||!s?`View`:`Edit`,` Organization Role "`,e.roleName,`"`]}),(0,z.jsx)(H,{...h,children:(0,z.jsxs)(`form`,{id:`org-edit-role-form`,name:`org-edit-role-form`,className:`grid grid-cols-2 gap-4 my-4`,onSubmit:h.handleSubmit(ee),children:[(0,z.jsx)(W,{control:h.control,name:`name`,render:({field:e})=>(0,z.jsxs)(G,{className:`col-span-2`,children:[(0,z.jsx)(K,{className:`pb-1`,children:`Role Name`}),(0,z.jsx)(U,{children:(0,z.jsx)(J,{type:`text`,className:``,...e,disabled:!0,readOnly:!0})}),(0,z.jsx)(q,{})]})}),(0,z.jsx)(W,{control:h.control,name:`update`,render:({field:e})=>(0,z.jsxs)(G,{children:[(0,z.jsx)(K,{className:`pb-1`,children:`Can Update Organization`}),(0,z.jsx)(U,{children:(0,z.jsx)(J,{type:`checkbox`,className:`w-6 ml-2`,disabled:o||!s,readOnly:o||!s,checked:e.value,onChange:t=>e.onChange(t.target.checked)})}),(0,z.jsx)(q,{})]})}),(0,z.jsx)(W,{control:h.control,name:`delete`,render:({field:e})=>(0,z.jsxs)(G,{children:[(0,z.jsx)(K,{className:`pb-1`,children:`Can Delete Organization`}),(0,z.jsx)(U,{children:(0,z.jsx)(J,{type:`checkbox`,className:`w-6 ml-2`,disabled:o||!s,readOnly:o||!s,checked:e.value,onChange:t=>e.onChange(t.target.checked)})}),(0,z.jsx)(q,{})]})}),(0,z.jsx)(`div`,{className:`col-span-2`,children:(0,z.jsx)(Be,{theme:`vs-dark`,height:`300px`,defaultLanguage:`json`,onValidate:x,onChange:e=>{e&&b(e)},options:o||!s?{readOnly:!0}:void 0,defaultValue:y})}),!o&&(c||s)&&(0,z.jsx)(Z,{className:`col-span-2`,children:(0,z.jsxs)(`div`,{className:`flex justify-between w-full`,children:[c&&(0,z.jsx)(B,{type:`button`,variant:`destructiveOutline`,className:`rounded-full`,onClick:()=>m(!0),disabled:u,children:`Delete Role`}),s&&(0,z.jsx)(B,{variant:`submit`,className:`rounded-full`,disabled:!_||u||!h.formState.isValid||!h.formState.isDirty,children:`Save Changes`})]})})]})})]})})})}function lu(){let e=T(),t=Vt(),{organizationId:n,orgRoleId:r}=M({strict:!1}),{create:i}=ia(n),{data:a,refetch:o,isFetching:s,isRefetching:c}=Nn(Jl(n)),l=(0,L.useMemo)(()=>a&&a?.find(e=>e.id===r),[a,r]),u=!!r&&!!l,[d,f]=(0,L.useState)(!1),p=(0,L.useCallback)(async(i,a)=>{await e({to:[r?`..`:``,i].filter(Boolean).join(`/`)}),a&&await t.invalidateQueries({queryKey:[n,`roles`],refetchType:`active`})},[r,e,t]),m=(0,L.useCallback)(()=>{f(!0)},[f]),h=(0,L.useCallback)(e=>p(e.original.id,!1),[p]),g=(0,L.useCallback)(e=>p(void 0,e),[p]),_=Hl(o);return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(Vo,{}),(0,z.jsx)(`div`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-(--spacing(32)))]`,children:(0,z.jsxs)(L.Suspense,{fallback:(0,z.jsx)(Ss,{className:`flex flex-col items-center justify-center h-full`,text:`Loading...`}),children:[(0,z.jsxs)(Ll,{data:a,columns:Yl,onRowClick:h,children:[(0,z.jsxs)(B,{variant:`defaultOutline`,onClick:_,accessKey:`r`,disabled:s||c,children:[(0,z.jsx)(fe,{}),(0,z.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,z.jsx)(`u`,{children:`R`}),`efresh`]})]}),i&&(0,z.jsxs)(B,{variant:`positiveOutline`,onClick:m,accessKey:`a`,disabled:d,children:[(0,z.jsx)(C,{}),(0,z.jsxs)(`span`,{children:[(0,z.jsx)(`u`,{children:`A`}),`dd`]})]})]}),i&&(0,z.jsx)(eu,{isModalOpen:d,setIsModalOpen:f}),u&&(0,z.jsx)(cu,{data:l,isModalOpen:u,closeModal:g})]})})]})}var uu=[{header:`User Id`,accessorKey:`id`,enableSorting:!1},{header:`Email`,accessorKey:`email`,enableSorting:!1},{header:`First Name`,accessorKey:`firstname`,enableSorting:!1},{header:`Last Name`,accessorKey:`lastname`,enableSorting:!1},It().display({header:`Roles`,enableSorting:!1,id:`roles`,cell:e=>e.row.original.roles?.map(e=>e.roleName)?.sort()?.join(`, `)}),{header:`Status`,accessorKey:`status`,enableSorting:!1},{header:`Verified`,accessorKey:`isVerified`,enableSorting:!1}],du=d.object({email:qa.max(80,{error:`Email cannot be longer than 80 characters.`}),roleId:d.string().nonempty({error:`Please select a role.`})});async function fu(e){let{data:t}=await P.post(`/OrganizationRole/`,e);return t}function pu(){return E({mutationFn:e=>fu(e)})}d.object({email:qa.max(80,{error:`Email cannot be longer than 80 characters.`}),roleId:d.string().nonempty({error:`Please select a role.`})});async function mu(e){let{data:t}=await P.post(`/UserInvite/`,e);return t}function hu(){return E({mutationFn:e=>mu(e)})}function gu({isModalOpen:e,onChangesSaved:t,setIsModalOpen:n}){let{organizationId:r}=M({strict:!1}),{data:i}=Nn(Jl(r)),[a,o]=(0,L.useState)(!1),s=N({resolver:w(du),defaultValues:{email:``,roleId:``}}),{mutate:c,isPending:l}=pu(),{mutate:u,isPending:d}=hu(),f=(0,L.useCallback)(async e=>{e&&(a?u:c)(e,{onSuccess:()=>{let r=e.roleId;s.reset(),s.setValue(`roleId`,r),t(),k.success(`User invited successfully!`),n(!1),o(!1)},onError:e=>{e?.status===404&&o(!0)}})},[c,s,u,t,n,a]);return(0,z.jsx)(Y,{onOpenChange:()=>{n(!1),o(!1),s.reset()},open:e,children:(0,z.jsx)(X,{"aria-describedby":void 0,children:(0,z.jsx)(H,{...s,children:(0,z.jsxs)(`form`,{id:`org-add-user-form`,name:`org-add-user-form`,onSubmit:s.handleSubmit(f),className:`grid gap-4 my-4`,children:[(0,z.jsx)(Zo,{children:(0,z.jsx)(Q,{children:a?`Invite User`:`Add User`})}),(0,z.jsx)(W,{control:s.control,name:`email`,render:({field:e})=>(0,z.jsxs)(G,{children:[(0,z.jsx)(K,{className:`pb-1`,children:`Email`}),(0,z.jsx)(U,{children:(0,z.jsx)(J,{type:`email`,enterKeyHint:`next`,autoComplete:`email`,...e})}),(0,z.jsx)(q,{})]})}),(0,z.jsx)(W,{control:s.control,name:`roleId`,render:({field:e})=>(0,z.jsxs)(G,{children:[(0,z.jsx)(K,{className:`pb-1`,children:`Roles`}),(0,z.jsx)(L.Suspense,{fallback:(0,z.jsx)(Ec,{}),children:(0,z.jsx)(U,{children:(0,z.jsxs)(Dc,{...e,onValueChange:t=>e.onChange(t),children:[(0,z.jsx)(Ac,{className:`w-full`,children:(0,z.jsx)(kc,{placeholder:`Choose Role`})}),(0,z.jsx)(jc,{children:(0,z.jsxs)(Oc,{children:[(0,z.jsx)(Mc,{children:`Role`}),i?.map(e=>(0,z.jsx)($,{value:e.id,children:e.roleName},e.id))]})})]})})}),(0,z.jsx)(q,{})]})}),a&&(0,z.jsxs)(Qo,{className:`p-3 my-5 text-white rounded-md bg-amber-600 flex`,children:[(0,z.jsx)(Se,{className:`inline-block size-12 pr-2`}),(0,z.jsx)(`span`,{children:`This person doesn’t have a Fabric account. Do you want to invite them?`})]}),(0,z.jsx)(Z,{children:(0,z.jsx)(`div`,{className:`flex justify-between w-full`,children:(0,z.jsxs)(B,{type:`submit`,variant:`submit`,className:`rounded-full`,disabled:l||d,children:[(0,z.jsx)(Jt,{}),` `,a?`Invite User`:`Add User`]})})})]})})})})}async function _u({roleId:e,userId:t}){let{data:n}=await P.delete(`/OrganizationRole/role/${e}/user/${t}`);return n}function vu(){return E({mutationFn:({roleId:e,userId:t})=>_u({roleId:e,userId:t})})}function yu(e){let[t,n]=(0,L.useState)(e||!1);return[t,(0,L.useCallback)(e=>{n(typeof e==`boolean`?e:e.target.checked)},[])]}function bu({data:e,readOnly:t,canRemove:n,orgRole:r,selectedRoles:i,setChangesMade:a}){let{mutate:o,isPending:s}=pu(),{mutate:c,isPending:l}=vu(),u=!!i[r.roleName],[d,f]=(0,L.useState)(u),[p,m]=yu(u);return(0,L.useEffect)(()=>{p!==d&&(p?o({email:e.email,roleId:r.id},{onSuccess:()=>{f(p),a(!0),k.success(`Role added successfully`)}}):c({userId:e.id,roleId:r.id},{onSuccess:()=>{f(p),a(!0),k.success(`Role removed successfully`)}}))},[o,e.email,e.id,p,r.id,c,a,d]),(0,z.jsxs)(Ra,{className:`flex`,children:[(0,z.jsx)(J,{type:`checkbox`,className:`w-6`,disabled:t||s||l||!n&&p,checked:p,onChange:m}),(0,z.jsx)(`span`,{className:`pl-4 pr-8 flex-1 py-2.5`,children:r.roleName})]},r.id)}function xu({closeModal:e,data:t,isModalOpen:n,onUserUpdated:r}){let{organizationId:i}=M({strict:!1}),a=hi(),{update:o,remove:s}=ia(i),c=a.user?.email===t.email,{data:l}=Nn(Jl(i)),u=(0,L.useMemo)(()=>t.roles?Fs(t.roles,`roleName`):{},[t]),[d,f]=(0,L.useState)(!1);return(0,z.jsx)(Y,{onOpenChange:d?r:e,open:n,children:(0,z.jsxs)(X,{className:`sm:max-w-[750px]`,children:[(0,z.jsx)(Zo,{children:(0,z.jsxs)(Q,{children:[o?`Edit `:`View `,` `,t.email,` `,c?`(yourself)`:``]})}),o&&(0,z.jsxs)(Qo,{children:[`To remove `,c?`your self`:`this user`,` from the organization, uncheck all of the boxes below.`]}),l.map(e=>(0,z.jsx)(bu,{readOnly:!o,canRemove:s,data:t,orgRole:e,selectedRoles:u,setChangesMade:f},e.id))]})})}function Su(e,t){return e.email>t.email?1:-1}function Cu(){let e=T(),{organizationId:t,orgUserId:n}=M({strict:!1}),{update:r}=ia(t),{data:i,refetch:a,isFetching:o,isRefetching:s}=Nn(Jl(t)),c=(0,L.useMemo)(()=>{let e={};for(let t of i)if(t.users)for(let n of t.users)e[n.id]||(e[n.id]={...n,roles:[]}),e[n.id].roles.push(t);return Object.values(e).sort(Su)},[i]),l=(0,L.useMemo)(()=>c?.find(e=>e.id===n),[c,n]),u=(0,L.useCallback)(t=>{e({to:[n?`..`:``,t].filter(Boolean).join(`/`)})},[n,e]),d=!!n&&!!l,[f,p]=(0,L.useState)(!1),[m]=(0,L.useState)({attribute:`email`,descending:!1}),h=(0,L.useMemo)(()=>[{desc:m.descending,id:m.attribute}],[m]),g=(0,L.useCallback)(()=>{p(!0)},[p]),_=(0,L.useCallback)(()=>{a(),p(!1)},[a,p]),v=(0,L.useCallback)(e=>{u(e.original.id)},[u]),y=(0,L.useCallback)(()=>{u(void 0)},[u]),b=(0,L.useCallback)(()=>{a(),u(void 0)},[u,a]),x=Hl(a);return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(Vo,{}),(0,z.jsx)(`div`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-theme(spacing.32))]`,children:(0,z.jsxs)(L.Suspense,{fallback:(0,z.jsx)(Ss,{className:`flex flex-col items-center justify-center h-full`,text:`Loading...`}),children:[(0,z.jsxs)(Ll,{data:c,isFetching:o||s,columns:uu,onRowClick:v,sortingState:h,children:[(0,z.jsxs)(B,{variant:`defaultOutline`,onClick:x,accessKey:`r`,disabled:o||s,children:[(0,z.jsx)(fe,{}),` `,(0,z.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,z.jsx)(`u`,{children:`R`}),`efresh`]})]}),r&&(0,z.jsxs)(B,{variant:`positiveOutline`,onClick:g,accessKey:`a`,disabled:f,children:[(0,z.jsx)(C,{}),` `,(0,z.jsxs)(`span`,{children:[(0,z.jsx)(`u`,{children:`A`}),`dd`]})]})]}),r&&(0,z.jsx)(gu,{isModalOpen:f,onChangesSaved:_,setIsModalOpen:p}),d&&(0,z.jsx)(xu,{closeModal:y,data:l,isModalOpen:d,onUserUpdated:b})]})})]})}function wu({organizationRole:e,onDeleteOrgModal:t}){let{organizationId:n,organizationName:r,roleName:i}=e,{remove:a,update:o}=ra(n),s=o,{view:c}=ia(n),l=(0,L.useCallback)(()=>{t(e)},[t,e]);return(0,z.jsxs)(xi,{className:`relative h-full justify-between`,children:[(0,z.jsxs)(Si,{children:[(0,z.jsxs)(wi,{className:`flex items-center justify-between`,children:[(0,z.jsx)(`span`,{className:`truncate`,children:n}),a&&(0,z.jsxs)(ts,{children:[(0,z.jsx)(ns,{className:`p-4 -m-4 -mr-6 hover:text-white`,children:(0,z.jsx)(tn,{"aria-label":`Options`})}),(0,z.jsxs)(rs,{children:[(0,z.jsx)(os,{className:`text-gray-600 text-xs`,children:`Options`}),(0,z.jsx)(ss,{}),(0,z.jsx)(j,{to:`${n}`,children:(0,z.jsx)(is,{children:`Clusters`})}),c&&(0,z.jsx)(j,{to:`${n}/roles`,children:(0,z.jsx)(is,{children:`Roles`})}),c&&(0,z.jsx)(j,{to:`${n}/users`,children:(0,z.jsx)(is,{children:`Users`})}),s&&(0,z.jsx)(j,{to:`${n}/billing`,children:(0,z.jsx)(is,{children:`Billing`})}),(0,z.jsx)(ss,{}),a&&(0,z.jsx)(is,{className:`focus:bg-red/70 focus:text-white`,onClick:l,children:`Delete`})]})]})]}),(0,z.jsx)(Ci,{children:(0,z.jsx)(`h2`,{children:r})})]}),(0,z.jsxs)(Ti,{className:`flex justify-between`,children:[(0,z.jsx)(es,{children:Ma(i)}),(0,z.jsx)(j,{to:n,className:`text-sm`,"aria-label":`View ${r}`,title:`View ${r}`,children:(0,z.jsxs)(`span`,{className:`py-2 transition-all duration-100 ease-in-out border-0 hover:border-b-2`,children:[`View `,(0,z.jsx)(vt,{className:`inline-block`})]})})]})]})}async function Tu(e){let{data:t}=await P.delete(`/Organization/${e}`);return t}function Eu(){return E({mutationFn:e=>Tu(e)})}async function Du(e){let{data:t}=await P.post(`/Organization/`,{...e});return t}function Ou(){return E({mutationFn:e=>Du(e)})}var ku=v().max(62,{error:`Must be at most 62 characters long.`}).regex(/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/,{error:`Please only use lowercase letters, digits and dashes (-) in the subdomain. Must not start or end with a dash.`}),Au=l({name:v().max(255,{error:`Name cannot be longer than 255 characters.`}),subdomain:b([p(``),g(),ku])});function ju(){let{user:e}=hi(),t=T(),n=N({resolver:w(Au),defaultValues:{name:``,subdomain:``}}),{setFocus:r,watch:i}=n;(0,L.useEffect)(()=>{r(`name`)},[r]);let a=`${e?.firstname} ${e?.lastname} Org`,o=i(`name`)||a,s=i(`subdomain`),c=(0,L.useMemo)(()=>{let e=Qs(ec(o),ku.maxLength);return{suggestedSubdomain:e,fullHostName:`future-cluster-names.${s||e}.harperfabric.com`}},[o,s]),{mutate:l,isPending:u}=Ou(),d=Vt(),f=(0,L.useCallback)(async e=>{l({name:e.name||a,subdomain:e.subdomain||c.suggestedSubdomain},{onSuccess:e=>{d.invalidateQueries({queryKey:si,refetchType:`active`}),I.reloadUser(F),t({to:`/${e.id}`})}})},[c.suggestedSubdomain,d,l,a,t]);return(0,z.jsx)(z.Fragment,{children:(0,z.jsx)(H,{...n,children:(0,z.jsxs)(`form`,{id:`org-add-form`,name:`org-add-form`,onSubmit:n.handleSubmit(f),className:`grid gap-6 text-white max-w-xl`,children:[(0,z.jsx)(W,{control:n.control,name:`name`,render:({field:e})=>(0,z.jsxs)(G,{children:[(0,z.jsx)(K,{className:`pb-1`,children:`Name`}),(0,z.jsx)(U,{children:(0,z.jsx)(J,{type:`text`,maxLength:Au.shape.name.maxLength,autoCapitalize:`words`,placeholder:a,...e})}),(0,z.jsx)(q,{})]})}),(0,z.jsx)(W,{control:n.control,name:`subdomain`,render:({field:e})=>(0,z.jsxs)(G,{children:[(0,z.jsx)(K,{className:`pb-1`,children:`Subdomain`}),(0,z.jsx)(U,{children:(0,z.jsx)(J,{type:`text`,maxLength:ku.maxLength,autoCapitalize:`none`,placeholder:c.suggestedSubdomain,...e})}),(0,z.jsx)(q,{})]})}),(0,z.jsxs)(G,{children:[(0,z.jsx)(K,{className:`pb-1`,children:`Full Host Name`}),(0,z.jsx)(U,{children:(0,z.jsx)(`span`,{children:c.fullHostName})}),(0,z.jsx)(q,{})]}),(0,z.jsx)(Z,{children:(0,z.jsxs)(B,{type:`submit`,variant:`submit`,className:`rounded-full`,disabled:u,children:[`Create New Organization `,(0,z.jsx)(vt,{})]})})]})})})}function Mu(){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(Vo,{}),(0,z.jsx)(`section`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-theme(spacing.32))]`,children:(0,z.jsx)(ju,{})})]})}function Nu(){let e=Vt(),{data:t}=Nn(ci()),{mutate:n,isPending:r}=Eu(),[i,a]=(0,L.useState)(!1),[o,s]=(0,L.useState)(null),[c,l]=(0,L.useState)(``),u=(0,L.useCallback)(()=>l(``),[]),d=(0,L.useMemo)(()=>{let e=t?.roles||{},n=Object.values(e);return Object.keys(e).map((e,t)=>({organizationId:e,organizationName:n[t].organizationName,roleName:n[t].role})).filter(_l([`organizationId`,`organizationName`],c)).sort((e,t)=>(e.organizationName||``)>(t.organizationName||``)?1:-1)||[]},[c,t?.roles]),f=(0,L.useCallback)(e=>{l(e.currentTarget.value?.toLowerCase()||``)},[]),p=(0,L.useCallback)(t=>{t?.organizationId&&n(t.organizationId,{onSuccess:()=>{k.success(`Success`,{description:`Organization successfully deleted.`,duration:5e3,action:{label:`Dismiss`,onClick:()=>k.dismiss()}}),e.invalidateQueries({queryKey:[]}),a(!1)},onError:()=>a(!1)})},[n,e,a]),m=(0,L.useCallback)(e=>{s(e),a(!0)},[]),{createCluster:h}=zn({strict:!1});return d.length===1&&!c.length&&h?(0,z.jsx)(vn,{to:`/${d[0].organizationId}/new-cluster`,replace:!0}):!d.length&&!c.length?(0,z.jsx)(Mu,{}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(Vo,{children:(0,z.jsxs)(`div`,{className:`flex w-full justify-end gap-2`,children:[(0,z.jsx)(J,{placeholder:`Filter by name`,className:`inline-block w-full text-xs`,value:c,onChange:f}),(0,z.jsx)(j,{to:`/new-org`,children:(0,z.jsxs)(B,{variant:`positive`,accessKey:`n`,children:[(0,z.jsx)(C,{}),(0,z.jsxs)(`span`,{className:`hidden sm:inline-block`,children:[(0,z.jsx)(`u`,{children:`N`}),`ew `,(0,z.jsx)(`span`,{className:`hidden md:inline-block`,children:`Organization`})]})]})})]})}),(0,z.jsx)(`section`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-theme(spacing.32))]`,children:(0,z.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-12`,children:[d.map(e=>(0,z.jsx)(`div`,{className:`col-span-1 md:col-span-4 lg:col-span-3 2xl:col-span-2`,children:(0,z.jsx)(wu,{organizationRole:e,onDeleteOrgModal:m})},e.organizationId)),!d.length&&(0,z.jsxs)(`div`,{className:`col-span-1 md:col-span-12 text-center`,children:[(0,z.jsx)(`h2`,{className:`my-4 text-xl`,children:`No matches found.`}),(0,z.jsx)(B,{variant:`outline`,onClick:u,children:`Clear Filters`})]})]})}),o&&(0,z.jsx)($o,{typeOfThingBeingDeleted:`organization`,nameOfThingBeingDeleted:o.organizationName,isModalOpen:i,setIsModalOpen:()=>a(!1),deletionConfirmed:()=>p(o),deletionPending:r})]})}function Pu(){let{isLoading:e}=mi(),{createCluster:t}=zn({strict:!1}),[,n]=vs(ys.SavedClusterState,null);return(0,L.useEffect)(()=>{t&&n(t)},[t,n]),e?(0,z.jsx)(Ss,{className:`fixed z-50 translate-1/2`}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`header`,{className:`fixed top-0 z-40 w-full h-20 p-4 bg-black-dark dark:bg-black-dark dark:border-b dark:border-black md:px-12`,children:(0,z.jsx)(pa,{})}),(0,z.jsx)(`main`,{children:(0,z.jsx)(rt,{})})]})}var Fu=[`/`,`/forgot-password`,`/reset-password`,`/sign-in`,`/sign-up`,`/verify-email`];function Iu(){let e=yl();return!Fu.includes(e)&&{redirect:e}}var Lu=O({getParentRoute:()=>zi,id:`_dashboardLayout`,component:Pu,beforeLoad:({context:e})=>{let t=e.authentication[F];if(t&&!t.isLoading&&!t.user)throw ar({to:`/sign-in`,search:Iu()})}}),Ru=O({getParentRoute:()=>Lu,id:`_orgsLayout`});O({getParentRoute:()=>Ru,path:`/`,component:Nu}),O({getParentRoute:()=>Ru,path:`/new-org`,component:Mu});var zu=O({getParentRoute:()=>Ru,path:`$organizationId`,beforeLoad:async e=>({organization:await e.context.queryClient.ensureQueryData(Xs(e.params.organizationId))})});O({getParentRoute:()=>zu,path:`/roles`,component:lu}),O({getParentRoute:()=>zu,path:`/roles/$orgRoleId`,component:lu}),O({getParentRoute:()=>zu,path:`/users`,component:Cu}),O({getParentRoute:()=>zu,path:`/users/$orgUserId`,component:Cu}),Kl(zu);var Bu=O({getParentRoute:()=>zu,id:`_clusterLayout`});O({getParentRoute:()=>Bu,path:`/`,component:vl}),O({getParentRoute:()=>zu,path:`/new-cluster`,component:pl}),O({getParentRoute:()=>Hu,path:`/edit`,component:pl}),O({getParentRoute:()=>Hu,path:`/edit/$mode`,component:pl});function Vu(){return(0,z.jsx)(rt,{})}var Hu=O({getParentRoute:()=>Bu,path:`$clusterId`,component:Vu,beforeLoad:async({context:e,params:t})=>({cluster:await e.queryClient.ensureQueryData(Ka(t.clusterId))})});function Uu({children:e,className:t}){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(Vo,{}),(0,z.jsx)(`div`,{className:i(`mt-32 px-4 py-4 md:px-12 min-h-[calc(100vh-(--spacing(32)))] flex justify-center`,t),children:e})]})}var Wu=new Set([`com`,`co`,`org`,`net`,`edu`,`gov`,`mil`,`me`,`biz`,`info`,`ac`,`or`,`ne`,`go`,`lg`,`asn`,`id`,`nom`,`sch`,`ltd`,`plc`]);function Gu(e){let t=e.split(`.`);if(t.length<=2)return`@`;let n=t[t.length-1],r=t[t.length-2],i=n.length===2&&Wu.has(r)?3:2;return t.length<=i?`@`:t.slice(0,-i).join(`.`)}function Ku({cluster:{fqdn:e},domain:{domain:t,id:n}}){let r=Gu(t),[i,a,o]=ms(r,e||``,n);return(0,z.jsxs)(`div`,{className:`grid gap-4 grid-cols-1 md:grid-cols-[80px_1fr] pb-6`,children:[(0,z.jsx)(`div`,{className:`text-muted-foreground md:col-span-2 text-wrap`,children:`This domain has been verified! Now to associate it with this cluster, add the following to your DNS registrar:`}),(0,z.jsx)(`div`,{className:`col-span-1`,children:`Type:`}),(0,z.jsx)(`div`,{className:`col-span-1`,children:`CNAME`}),(0,z.jsx)(`div`,{className:`col-span-1`,children:`Name:`}),(0,z.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,z.jsxs)(`div`,{className:`flex items-center gap-1 bg-gray-700 rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,z.jsx)(`input`,{className:`bg-transparent border-none outline-none w-full cursor-text truncate`,type:`text`,readOnly:!0,name:`recordName`,value:r,onClick:i}),(0,z.jsx)(B,{type:`button`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:i,children:(0,z.jsx)(hn,{className:`w-3.5 h-3.5`})})]})}),(0,z.jsx)(`div`,{className:`col-span-1`,children:`TTL:`}),(0,z.jsx)(`div`,{className:`col-span-1`,children:`Auto`}),(0,z.jsx)(`div`,{className:`col-span-1`,children:`Target:`}),(0,z.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,z.jsxs)(`div`,{className:`flex items-center gap-1 bg-gray-700 rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,z.jsx)(`input`,{className:`bg-transparent border-none outline-none w-full cursor-text truncate`,type:`text`,readOnly:!0,name:`recordTarget`,value:e,onClick:a}),(0,z.jsx)(B,{type:`button`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:a,children:(0,z.jsx)(hn,{className:`w-3.5 h-3.5`})})]})}),(0,z.jsx)(`div`,{className:`col-span-1 text-xs`,children:`Domain ID:`}),(0,z.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,z.jsxs)(`div`,{className:`flex items-center gap-1 bg-gray-800 rounded-md px-3 py-0.5 text-xs text-muted-foreground italic flex-1 overflow-hidden`,children:[(0,z.jsx)(`input`,{className:`bg-transparent border-none outline-none w-full cursor-text truncate`,type:`text`,readOnly:!0,name:`domainId`,value:n,onClick:o}),(0,z.jsx)(B,{type:`button`,variant:`ghost`,className:`h-5 w-5 p-0 shrink-0`,onClick:o,children:(0,z.jsx)(hn,{className:`w-3 h-3`})})]})}),(0,z.jsx)(`div`,{className:`text-muted-foreground md:col-span-2 text-wrap italic text-sm`,children:`Select this domain using the checkbox to the left, then click "Bind" in the top right to finish associating it with this cluster.`})]})}function qu({certificate:e,domain:t,cluster:n}){let r=Gu(t.domain),[i,a,o]=ms(r,n.fqdn||``,t.id),s=(0,L.useMemo)(()=>e.issueDate&&!e.inProgress?{width:`100%`,color:`bg-green/80`,pulse:!1,text:`Certificate Issued`}:e.inProgress?{width:`100%`,color:`bg-yellow/80`,pulse:!0,text:`Generating Certificate...`}:{width:`100%`,color:`bg-gray-600`,pulse:!1,text:`Pending Certificate Generation...`},[e]);return(0,z.jsxs)(`div`,{className:`w-full max-w-2xl border border-border/50 rounded-md p-4 bg-gray-900/20`,children:[(0,z.jsxs)(`div`,{className:`mb-4`,children:[(0,z.jsx)(`div`,{className:`w-full h-1.5 rounded-full overflow-clip flex shadow-sm bg-gray-800`,children:(0,z.jsx)(`div`,{style:{width:s.width},className:`grow transition-[width] duration-1000 ease-in-out motion-reduce:transition-none ${s.color} ${s.pulse?`animate-pulse`:``}`})}),(0,z.jsx)(`div`,{className:`text-[10px] text-muted-foreground font-light mt-1 italic`,children:s.text})]}),(0,z.jsxs)(`div`,{className:`grid gap-2 grid-cols-1 md:grid-cols-[80px_1fr] text-sm`,children:[(0,z.jsx)(`div`,{className:`col-span-1 text-xs text-muted-foreground`,children:`CNAME:`}),(0,z.jsxs)(`div`,{className:`col-span-1 flex gap-2 items-center flex-wrap`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-1 bg-gray-800 px-2 py-0.5 rounded text-xs`,children:[(0,z.jsx)(`span`,{className:`truncate max-w-[150px]`,title:r,children:r}),(0,z.jsx)(B,{type:`button`,variant:`ghost`,size:`sm`,className:`h-4 w-4 p-0`,onClick:i,title:`Copy Name`,children:(0,z.jsx)(hn,{className:`w-3 h-3`})})]}),(0,z.jsx)(Ju,{}),(0,z.jsxs)(`div`,{className:`flex items-center gap-1 bg-gray-800 px-2 py-0.5 rounded text-xs`,children:[(0,z.jsx)(`span`,{className:`truncate max-w-[200px]`,title:n.fqdn||``,children:n.fqdn}),(0,z.jsx)(B,{type:`button`,variant:`ghost`,size:`sm`,className:`h-4 w-4 p-0`,onClick:a,title:`Copy Target`,children:(0,z.jsx)(hn,{className:`w-3 h-3`})})]})]}),(0,z.jsx)(`div`,{className:`col-span-1 text-[10px] text-muted-foreground`,children:`Domain ID:`}),(0,z.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,z.jsxs)(`div`,{className:`flex items-center gap-1 bg-gray-800/50 px-2 py-0.5 rounded text-[10px] text-muted-foreground italic`,children:[(0,z.jsx)(`span`,{className:`truncate max-w-[200px]`,children:t.id}),(0,z.jsx)(B,{type:`button`,variant:`ghost`,size:`sm`,className:`h-3 w-3 p-0`,onClick:o,title:`Copy ID`,children:(0,z.jsx)(hn,{className:`w-2.5 h-2.5`})})]})})]})]})}function Ju(){return(0,z.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,className:`w-3 h-3 text-muted-foreground`,children:[(0,z.jsx)(`path`,{d:`M5 12h14`}),(0,z.jsx)(`path`,{d:`m12 5 7 7-7 7`})]})}function Yu(e){let{enabled:t,entityId:n,databaseName:r,tableName:i,searchAttribute:a,sort:o,pageIndex:s,pageSize:c,onlyIfCached:l}=e;return A({enabled:t,queryKey:[n,r,i,`search_by_value`,a,o.attribute||`default`,o.descending||!1,s||0,c||0,l],retry:!1,staleTime:6e4,gcTime:5e3,queryFn:()=>Xu(e)})}async function Xu({instanceClient:e,databaseName:t,tableName:n,searchAttribute:r,sort:i,pageIndex:a,pageSize:o,onlyIfCached:s,headers:c}){let l=i.attribute.length&&!(i.attribute===r&&!i.descending),u=await e.post(`/`,{operation:`search_by_value`,get_attributes:[`*`],database:t,table:n,search_attribute:r,search_value:`*`,sort:l?i:void 0,offset:a*o,limit:o,onlyIfCached:s,noCacheStore:s},{timeout:0,headers:c,validateStatus:e=>e>=200&&e<400||e===404});return u.status===404?{data:[]}:u}function Zu(e){return A({queryKey:[e,`ChallengeCertificate`],queryFn:async()=>{if(!e)return[];let{data:t}=await Xu({searchAttribute:`domain`,entityId:e,databaseName:`data`,tableName:`ChallengeCertificate`,sort:{attribute:`domain`,descending:!0},instanceClient:ai({id:e,forceFabricConnect:!0}),onlyIfCached:!1,pageIndex:0,pageSize:100});return t},enabled:!!e,refetchInterval:5e3})}function Qu(e){return D(Zu(e))}function $u({domain:{challengeToken:e,challengeTxtRecord:t,domain:n,id:r},cluster:{fqdn:i}}){let a=Gu(n),[o,s,c,l,u]=ms(t,e,a,i||``,r);return(0,z.jsxs)(`div`,{className:`grid gap-2 grid-cols-1 md:grid-cols-[80px_1fr] pb-6`,children:[(0,z.jsx)(`div`,{className:`text-muted-foreground md:col-span-2 text-wrap`,children:`Prove that you own this domain by adding the following to your DNS registrar:`}),(0,z.jsx)(`div`,{className:`col-span-1`,children:`Type:`}),(0,z.jsx)(`div`,{className:`col-span-1`,children:`TXT`}),(0,z.jsx)(`div`,{className:`col-span-1`,children:`Name:`}),(0,z.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,z.jsxs)(`div`,{className:`flex items-center gap-1 bg-gray-700 rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,z.jsx)(`input`,{className:`bg-transparent border-none outline-none w-full cursor-text truncate`,type:`text`,readOnly:!0,name:`challengeName`,value:t,onClick:o}),(0,z.jsx)(B,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:o,children:(0,z.jsx)(hn,{className:`w-3.5 h-3.5`})})]})}),(0,z.jsx)(`div`,{className:`col-span-1`,children:`TTL:`}),(0,z.jsx)(`div`,{className:`col-span-1`,children:`Auto`}),(0,z.jsx)(`div`,{className:`col-span-1`,children:`Content:`}),(0,z.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,z.jsxs)(`div`,{className:`flex items-center gap-1 bg-gray-700 rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,z.jsx)(`input`,{className:`bg-transparent border-none outline-none w-full cursor-text truncate`,type:`text`,readOnly:!0,name:`challengeToken`,value:e,onClick:s}),(0,z.jsx)(B,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:s,children:(0,z.jsx)(hn,{className:`w-3.5 h-3.5`})})]})}),(0,z.jsx)(`div`,{className:`text-muted-foreground md:col-span-2 text-wrap mt-4`,children:`While you're at it, you should also add the CNAME record to point to this cluster:`}),(0,z.jsx)(`div`,{className:`col-span-1`,children:`Type:`}),(0,z.jsx)(`div`,{className:`col-span-1`,children:`CNAME`}),(0,z.jsx)(`div`,{className:`col-span-1`,children:`Name:`}),(0,z.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,z.jsxs)(`div`,{className:`flex items-center gap-1 bg-gray-700 rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,z.jsx)(`input`,{className:`bg-transparent border-none outline-none w-full cursor-text truncate`,type:`text`,readOnly:!0,name:`recordName`,value:a,onClick:c}),(0,z.jsx)(B,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:c,children:(0,z.jsx)(hn,{className:`w-3.5 h-3.5`})})]})}),(0,z.jsx)(`div`,{className:`col-span-1`,children:`TTL:`}),(0,z.jsx)(`div`,{className:`col-span-1`,children:`Auto`}),(0,z.jsx)(`div`,{className:`col-span-1`,children:`Target:`}),(0,z.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,z.jsxs)(`div`,{className:`flex items-center gap-1 bg-gray-700 rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,z.jsx)(`input`,{className:`bg-transparent border-none outline-none w-full cursor-text truncate`,type:`text`,readOnly:!0,name:`recordTarget`,value:i,onClick:l}),(0,z.jsx)(B,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:l,children:(0,z.jsx)(hn,{className:`w-3.5 h-3.5`})})]})}),(0,z.jsx)(`div`,{className:`col-span-1 text-xs`,children:`Domain ID:`}),(0,z.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,z.jsxs)(`div`,{className:`flex items-center gap-1 bg-gray-800 rounded-md px-3 py-0.5 text-xs text-muted-foreground italic flex-1 overflow-hidden`,children:[(0,z.jsx)(`input`,{className:`bg-transparent border-none outline-none w-full cursor-text truncate`,type:`text`,readOnly:!0,name:`domainId`,value:r,onClick:u}),(0,z.jsx)(B,{type:`button`,size:`sm`,variant:`ghost`,className:`h-5 w-5 p-0 shrink-0`,onClick:u,children:(0,z.jsx)(hn,{className:`w-3 h-3`})})]})}),(0,z.jsx)(`div`,{className:`text-muted-foreground md:col-span-2 text-wrap mt-2`,children:`Then after your DNS TTL elapses, click the "Validate" button above.`})]})}async function ed({clusterId:e,domainIds:t,generateDomainCerts:n}){let{data:r}=await P.put(`/Cluster/${e}`,{domainIds:t,generateDomainCerts:n},{timeout:0});return r}function td(){return E({mutationFn:e=>ed(e)})}d.object({domainId:d.string()});async function nd(e){let{data:t}=await P.delete(`/Domain/${e.domainId}`);return t}function rd(){return E({mutationFn:e=>nd(e)})}function id(e){return[...new Set(e)]}var ad=It();function od(e,t,n){let{data:r}=Qu(e.id),i=(0,L.useMemo)(()=>!!r?.some(e=>!e.issueDate||e.inProgress),[r]),{mutate:a,isPending:o}=td(),{mutate:s,isPending:c}=rd(),l=o||c,u=(0,L.useCallback)((t,n)=>{if(!Uo(e.status)){k.error(`Cluster is currently `+e.status,{description:`To bind a domain, it must be running.`});return}a({clusterId:e.id,domainIds:id((e.domainIds?.slice()||[]).concat([t])),generateDomainCerts:n},{onSuccess:()=>{Mi.invalidateQueries({queryKey:[e.organizationId],refetchType:`active`}),k.success(`Domain bound!`+(n?` Certificates are being generated in the background now.`:``))}})},[a,e]),d=(0,L.useCallback)(t=>{s({domainId:t},{onSuccess:()=>{Mi.invalidateQueries({queryKey:[e.organizationId,`domains`],refetchType:`active`}),k.success(`Domain removed!`)}})},[s]),f=(0,L.useCallback)(t=>{a({clusterId:e.id,domainIds:(e.domainIds?.slice()||[]).filter(e=>e!==t),generateDomainCerts:!1},{onSuccess:()=>{Mi.invalidateQueries({queryKey:[e.organizationId],refetchType:`active`}),k.success(`Domain unbound!`)}})},[s]);return(0,L.useMemo)(()=>[ad.display({id:`select`,header:`Bind`,size:50,cell:r=>{let a=r.row.original;return a.status===`ACTIVE`&&!a.clusterId&&!cs(e)?(0,z.jsx)(`label`,{className:`p-10 -m-10`,children:(0,z.jsx)(`input`,{type:`checkbox`,checked:t.includes(a.id),onChange:()=>n(a.id),disabled:l||i})}):null}}),ad.display({header:`Domains`,id:`domain`,enableSorting:!1,size:150,cell:e=>{let t=e.row.original;return(0,z.jsxs)(Oa,{children:[(0,z.jsx)(ka,{asChild:!0,children:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{children:t.domain}),(0,z.jsx)(B,{type:`button`,variant:`destructiveGhost`,className:`text-muted-foreground text-xs`,disabled:l||!!t.clusterId,onClick:()=>d(t.id),children:`Remove Domain`})]})}),(0,z.jsx)(Aa,{side:`bottom`,align:`center`,children:t.clusterId?`To delete this domain, please unbind it from all clusters first.`:`Remember to clean up your DNS records!`})]})}}),ad.display({header:`Next Steps`,enableSorting:!1,size:500,id:`nextSteps`,cell:t=>{let n=t.row.original,i=r?.find(e=>e.domain===n.domain);return n.status===`ACTIVE`&&n.clusterId?e.id===n.clusterId?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{children:`Bound to this cluster`}),i&&(!i.issueDate||i.inProgress)&&(0,z.jsx)(`div`,{className:`py-2`,children:(0,z.jsx)(qu,{certificate:i,domain:n,cluster:e})}),(0,z.jsx)(B,{type:`button`,variant:`destructiveGhost`,className:`text-muted-foreground text-xs`,disabled:l,onClick:()=>f(n.id),children:`Unbind Domain`})]}):`Bound to cluster ${n.clusterId}`:n.status===`PENDING_VALIDATION`?(0,z.jsx)($u,{domain:n,cluster:e}):cs(e)?`Cannot be associated with this self-managed cluster.`:n.status===`ACTIVE`&&!n.clusterId?(0,z.jsx)(Ku,{cluster:e,domain:n}):n.status}})],[e,u,l,r,i,t,n])}var sd=d.object({domain:d.string(),organizationId:d.string()});async function cd(e){let{data:t}=await P.post(`/Domain/`,e);return t}function ld(){return E({mutationFn:e=>cd(e)})}async function ud(e){let{data:t}=await P.post(`/Domain/${e}/validate`);return t}async function dd(e){let{data:t}=await P.get(`/Domain/?organizationId=${e}`);return t}function fd(e){return A({queryKey:[e,`domains`],queryFn:()=>dd(e)})}function pd(){let{organizationId:e,clusterId:t}=M({strict:!1}),{data:n}=Nn(Ka(t,!0)),{update:r}=ia(e),{data:i,refetch:a,isFetching:o,isRefetching:s}=D(fd(e)),c=(0,L.useMemo)(()=>i?.filter(e=>e.status===`PENDING_VALIDATION`)||[],[i]),[l]=(0,L.useState)({attribute:`domain`,descending:!1}),u=(0,L.useMemo)(()=>[{desc:l.descending,id:l.attribute}],[l]),d=Hl(a),[f,p]=(0,L.useState)([]),m=(0,L.useCallback)(e=>{p(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[]),{mutate:h,isPending:g}=td(),_=(0,L.useCallback)(()=>{if(!Uo(n.status)){k.error(`Cluster is currently `+n.status,{description:`To bind a domain, it must be running.`});return}h({clusterId:n.id,domainIds:id((n.domainIds?.slice()||[]).concat(f)),generateDomainCerts:!0},{onSuccess:()=>{Mi.invalidateQueries({queryKey:[n.organizationId],refetchType:`active`}),k.success(`Domain(s) bound! Certificates are being generated in the background now.`),p([])}})},[n,f,h]),{mutateAsync:v,isPending:y}=ld(),b=N({resolver:w(sd),defaultValues:{domain:``,organizationId:e}}),x=(0,L.useCallback)(async e=>{if(e){let t=e.domain.split(/[,\s]+/).map(e=>e.trim()).filter(Boolean);for(let n of t)await v({...e,domain:n});b.reset(),await a(),k.success(`${Qr(t.length,`Domain`,`Domains`)} added! Please add the txt record above to your domain registrar.`)}},[v,b,a]),ee=(0,L.useCallback)(async()=>{let e=`Validating ${Qr(c.length,`domain`,`domains`)}...`,t=`validatingDomains`,n=0,r=0;for(let i of c)try{k.loading(e,{description:`${n++} of ${c.length} checked`,id:t}),await ud(i.id)}catch{r+=1}r>0?k.error(`Validation failed!`,{description:`Please make sure the TXT record has been put in place. You may need to wait a bit for the DNS change to propagate.`,id:t}):(await a(),k.success(`Validation succeeded!`,{description:`Please take a look at the next steps for newly verified domains.`,id:t}))},[c]),te=od(n,f,m),ne=b.watch(`domain`),re=(0,L.useMemo)(()=>typeof ne==`string`?ne.trim().split(`.`).length===2:!1,[ne]),ie=(0,L.useCallback)(()=>{typeof ne==`string`&&b.setValue(`domain`,`${ne.trim()}, www.${ne.trim()}`)},[ne,b]);return(0,z.jsx)(Ll,{data:i||[],isFetching:o||s,columns:te,sortingState:u,children:(0,z.jsxs)(`div`,{className:`w-full flex flex-col md:flex-row items-center md:justify-between md:space-x-2 space-y-2 md:space-y-0`,children:[r&&(0,z.jsx)(H,{...b,children:(0,z.jsxs)(`form`,{id:`cluster-add-domain-form`,name:`cluster-add-domain-form`,onSubmit:b.handleSubmit(x),className:`flex gap-1 flex-col md:flex-row`,children:[(0,z.jsx)(W,{control:b.control,name:`domain`,render:({field:e})=>(0,z.jsxs)(G,{className:`flex-1`,children:[(0,z.jsx)(K,{className:`pb-1`,children:`New Domain Name`}),(0,z.jsx)(U,{children:(0,z.jsx)(J,{type:`text`,enterKeyHint:`done`,autoComplete:`off`,...e})}),re&&(0,z.jsxs)(`div`,{className:`mt-1 flex gap-4`,children:[`Adding an apex domain?`,(0,z.jsx)(B,{variant:`positiveOutline`,type:`button`,onClick:ie,children:`Add www as well`})]}),(0,z.jsx)(q,{children:(0,z.jsx)(`span`,{className:`text-muted-foreground italic`,children:`Type in a domain like example.com or your.example.com, and you'll be guided through validating and binding your cluster to it.`})})]})}),(0,z.jsxs)(`div`,{className:`flex-0 self-start flex gap-1 md:pt-6.5`,children:[(0,z.jsxs)(B,{type:`submit`,variant:`submit`,disabled:y,children:[(0,z.jsx)(C,{}),` Add`]}),c.length>0&&(0,z.jsxs)(B,{variant:`positiveOutline`,onClick:ee,accessKey:`r`,type:`button`,disabled:o||s,children:[(0,z.jsx)(wt,{}),` `,(0,z.jsxs)(`span`,{children:[(0,z.jsx)(`u`,{children:`V`}),`alidate`]})]}),(0,z.jsxs)(B,{variant:`defaultOutline`,onClick:d,accessKey:`r`,type:`button`,disabled:o||s,children:[(0,z.jsx)(fe,{}),` `,(0,z.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,z.jsx)(`u`,{children:`R`}),`efresh`]})]})]})]})}),f.length>0&&(0,z.jsx)(`div`,{className:`flex-0 self-start md:pt-6.5`,children:(0,z.jsxs)(B,{variant:`submit`,onClick:_,disabled:g,children:[(0,z.jsx)(Jt,{}),` Bind `,Qr(f.length,`Domain`,`Domains`)]})})]})})}function md(){return(0,z.jsx)(Uu,{className:`flex flex-col justify-start max-w-4xl`,children:(0,z.jsx)(pd,{})})}var hd=l({username:Ya,role:v().nonempty({error:`Please select a role.`}),password:Ja.min(8,{error:`Password must be at least 8 characters long.`}),confirmPassword:v()}).refine(e=>e.password===e.confirmPassword,{error:`Passwords do not match.`,path:[`confirmPassword`]});async function gd(e){await P.patch(`/ResetPasswordUpdater/${e}`)}async function _d(e){let{instanceClient:t,...n}=e,{data:r}=await t.post(`/`,{operation:`add_user`,...n});return r}function vd(){return E({mutationFn:_d})}async function yd({username:e,password:t,role:n,active:r,instanceClient:i}){let{data:a}=await i.post(`/`,{operation:`alter_user`,username:e,password:t,role:n,active:r});return a}function bd(){return E({mutationFn:yd})}async function xd({username:e,instanceClient:t}){let{data:n}=await t.post(`/`,{operation:`drop_user`,username:e});return n}function Sd(){return E({mutationFn:xd})}async function Cd({clusterId:e,initialUsername:t,desiredUsername:n,newPassword:r,tempPassword:i,instanceClient:a}){if(!i)throw Error(`You may not have permission to set the password on this cluster.`);let o=a;try{let a=await Ha({username:t,password:i,instanceClient:o,entityId:e});return a.instanceClient&&(o=a.instanceClient),n===`HDB_ADMIN`?await yd({username:n,password:r,instanceClient:o}):(await _d({username:n,password:r,role:`super_user`,active:!0,instanceClient:o}),await Ha({username:n,password:r,instanceClient:o,entityId:e}),await xd({username:Yr,instanceClient:o})),await gd(e),a}catch(t){throw await li({entityId:e,instanceClient:o}),t}}function wd(){return E({mutationFn:Cd})}function Td(){let{user:e}=hi(),{clusterId:t}=M({strict:!1}),{data:n}=D(Ka(t,!0)),r=T(),i=(0,L.useMemo)(()=>di(n),[n]),a=Yi({operationsUrl:i}),{redirect:o}=zn({strict:!1}),s=kn(),c=N({resolver:w(hd),defaultValues:{confirmPassword:``,password:``,role:`super_user`,username:e?.email??``}}),{setFocus:l,control:u,handleSubmit:d}=c;(0,L.useEffect)(()=>{l(`password`)},[l]);let f=n?.instances?.find(e=>e.tempPassword)?.tempPassword,{mutate:p,isPending:m}=wd(),h=(0,L.useCallback)(async e=>{if(!i){k.error(`Cluster is not yet fully loaded, please wait a moment before trying to sign in.`);return}p({instanceClient:a,clusterId:t,newPassword:e.password,tempPassword:f,initialUsername:Yr,desiredUsername:e.username},{onSuccess:async({message:e,user:t})=>{k.success(e),I.setUserForEntity(n,t),s.invalidate(),await r({to:o?.startsWith(`/`)?o:`../`})}})},[n,t,a,r,i,o,s,p,f]);return n&&!n.resetPassword?(0,z.jsx)(vn,{to:`../sign-in`,replace:!0}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`nav`,{className:`fixed top-20 w-full h-12 z-39 px-4 md:px-12 bg-grey-700 flex items-center`,children:(0,z.jsx)(Pa,{})}),(0,z.jsx)(`div`,{className:`items-center justify-center flex mt-32 py-4 min-h-[calc(100vh-(--spacing(32)))]`,children:(0,z.jsxs)(`div`,{className:`text-white w-xs`,children:[(0,z.jsx)(`h2`,{className:`text-2xl font-light`,children:`Create Admin User`}),(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:`You are ready to create your first user in your new cluster. These credentials belong to you alone, and you can create more users and roles once you create this first one.`}),(0,z.jsx)(H,{...c,children:(0,z.jsxs)(`form`,{id:`cluster-create-admin-form`,name:`cluster-create-admin-form`,onSubmit:d(h),className:`my-4`,children:[(0,z.jsx)(W,{control:u,name:`username`,render:({field:e})=>(0,z.jsxs)(G,{className:`my-4`,children:[(0,z.jsx)(K,{children:`Username`}),(0,z.jsx)(U,{children:(0,z.jsx)(J,{autoComplete:`username`,type:`text`,...e})}),(0,z.jsx)(q,{})]})}),(0,z.jsx)(W,{control:u,name:`password`,render:({field:e})=>(0,z.jsxs)(G,{className:`my-4`,children:[(0,z.jsx)(K,{children:`Password`}),(0,z.jsx)(U,{children:(0,z.jsx)(J,{type:`password`,...e})}),(0,z.jsx)(q,{})]})}),(0,z.jsx)(W,{control:u,name:`confirmPassword`,render:({field:e})=>(0,z.jsxs)(G,{className:`my-4`,children:[(0,z.jsx)(K,{children:`Confirm Password`}),(0,z.jsx)(U,{children:(0,z.jsx)(J,{type:`password`,...e})}),(0,z.jsx)(q,{})]})}),(0,z.jsx)(B,{disabled:m,type:`submit`,variant:`submit`,className:`w-full my-2 rounded-full`,children:`Create Admin User`})]})}),(0,z.jsxs)(`p`,{className:`text-muted-foreground flex gap-2 align-middle`,children:[(0,z.jsx)(Le,{size:36,className:`flex-none`}),(0,z.jsx)(`span`,{children:`These credentials will be used to sign into your cluster directly, providing you a secure connection from your browser to your cluster.`})]})]})})]})}function Ed({columns:e,data:t}){let n=Ie({data:t,columns:e,getCoreRowModel:Mt()});return(0,z.jsx)(`div`,{className:`bg-black-dark rounded-md`,children:(0,z.jsxs)(Al,{children:[(0,z.jsx)(jl,{children:n.getHeaderGroups().map(e=>(0,z.jsx)(Nl,{className:`border-none`,children:e.headers.map(e=>(0,z.jsx)(Pl,{className:`p-4`,style:{width:`${e.getSize()}%`},children:e.isPlaceholder?null:Jn(e.column.columnDef.header,e.getContext())},e.id))},e.id))}),(0,z.jsx)(Ml,{className:`bg-black`,children:n.getRowModel().rows?.length?n.getRowModel().rows.map(e=>(0,z.jsx)(Nl,{"data-state":e.getIsSelected()&&`selected`,className:`hover:bg-muted/10 data-[state=selected]:bg-muted`,children:e.getVisibleCells().map(e=>(0,z.jsx)(Il,{className:`p-4`,style:{width:`${e.column.getSize()}%`},children:Jn(e.column.columnDef.cell,e.getContext())},e.id))},e.id)):(0,z.jsx)(Nl,{children:(0,z.jsx)(Il,{colSpan:e.length,className:`h-24 text-center`,children:`No results.`})})})]})})}function Dd(){return(0,z.jsx)(`div`,{className:`flex-col items-center justify-center px-16 space-y-3 text-center pt-30`,children:(0,z.jsx)(`p`,{children:`No instances found.`})})}function Od({isSelfManaged:e,instance:t}){let{user:n,isLoading:r}=_i(t.id),i=Yi({operationsUrl:(0,L.useMemo)(()=>fi(t),[t])}),{update:a}=sa(),o=I.checkForFabricConnect(t.id),s=(0,L.useCallback)(async()=>{await li({instanceClient:i,entityId:t.id}),I.setUserForEntity(t,null)},[t,i]);return r||![`CLONE_READY`,`RUNNING`,`UPDATED`].includes(t.status)?(0,z.jsx)(ce,{className:`animate-spin`,color:`gray`}):!n||o?(0,z.jsxs)(`span`,{className:`flex gap-4`,children:[a&&!e&&(0,z.jsx)(j,{to:`../instance/${t.id}/`,className:`text-sm`,"aria-label":`Connect to ${t.name} instance`,title:`Connect to ${t.name} instance`,children:(0,z.jsx)(B,{variant:`positiveOutline`,children:`Fabric Connect`})}),(0,z.jsx)(j,{to:`../instance/${t.id}/sign-in`,className:`text-sm`,"aria-label":`Sign in to ${t.name} instance`,title:`Sign in to ${t.name} instance`,children:(0,z.jsx)(B,{variant:a?`defaultOutline`:`positiveOutline`,children:`Direct Sign In`})})]}):(0,z.jsxs)(`span`,{className:`flex gap-4`,children:[(0,z.jsx)(j,{to:`../instance/${t.id}/`,className:`text-sm`,"aria-label":`Go to ${t.name} instance`,title:`Go to ${t.name} instance`,children:(0,z.jsx)(B,{variant:`positiveOutline`,children:`Direct Connect`})}),(0,z.jsx)(B,{variant:`destructiveOutline`,className:`text-sm`,"aria-label":`Sign out from ${t.name} instance`,title:`Sign out from ${t.name} instance`,onClick:s,children:`Direct Sign Out`})]})}function kd({entityId:e,instanceClient:t},n){return A({queryKey:[e,`get_status`],staleTime:9e3,refetchInterval:1e4,retryDelay:1e4,throwOnError:!1,enabled:n,queryFn:async()=>{let{data:e}=await t.post(`/`,{operation:`get_status`});return e}})}function Ad(e,t){return e?.systemStatus?.find(e=>e.id===t)?.status}async function jd({instanceClient:e,id:t,status:n}){let{data:r}=await e.post(`/`,{operation:`set_status`,id:t,status:n});return r}function Md(){return E({mutationFn:jd,onSuccess:(e,t)=>Mi.invalidateQueries({queryKey:[t.entityId,`get_status`]})})}function Nd({instance:e,index:t}){let{update:n}=sa(),r=V({operationsUrl:(0,L.useMemo)(()=>fi(e),[e]),instanceId:e.id,forceFabricConnect:!0}),{mutate:i,isPending:a}=Md(),[o,s]=(0,L.useState)(!1);(0,L.useEffect)(()=>{let e=setTimeout(()=>s(!0),t*500);return()=>clearTimeout(e)},[t]);let{data:c,isLoading:l,isFetching:u}=D(kd(r,o&&n)),d=Ad(c,`availability`)||`Unknown`,f=d===`Available`,p=d===`Unavailable`;return n?(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsxs)(Oa,{children:[(0,z.jsx)(ka,{asChild:!0,children:(0,z.jsx)(`div`,{className:`flex items-center`,children:l||!o||u&&!c?(0,z.jsx)(ce,{className:`animate-spin size-5 text-muted-foreground`}):(0,z.jsx)(es,{variant:f?`success`:p?`destructive`:`default`,className:`size-4 rounded-full p-0`,children:(0,z.jsx)(`span`,{className:`sr-only`,children:f?`Online`:`Offline`})})})}),(0,z.jsxs)(Aa,{children:[u&&c?`Refreshing... `:``,d]})]}),n&&(0,z.jsxs)(`div`,{className:`flex gap-1`,children:[f&&(0,z.jsxs)(Oa,{children:[(0,z.jsx)(ka,{asChild:!0,children:(0,z.jsx)(B,{type:`button`,variant:`destructiveGhost`,size:`icon`,onClick:()=>i({...r,id:`availability`,status:`Unavailable`}),disabled:a,children:a?(0,z.jsx)(ce,{className:`animate-spin size-4`}):(0,z.jsx)(Wn,{className:`size-4`})})}),(0,z.jsx)(Aa,{children:`Bring out of rotation`})]}),p&&(0,z.jsxs)(Oa,{children:[(0,z.jsx)(ka,{asChild:!0,children:(0,z.jsx)(B,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>i({...r,id:`availability`,status:`Available`}),disabled:a,children:a?(0,z.jsx)(ce,{className:`animate-spin size-4`}):(0,z.jsx)(In,{className:`size-4`})})}),(0,z.jsx)(Aa,{children:`Bring back into rotation`})]})]})]}):null}function Pd(){let{clusterId:e}=M({strict:!1}),{data:t,isLoading:n}=D(Ka(e,!0)),r=cs(t),i=(0,L.useMemo)(()=>[{id:`instanceActions`,size:1,minSize:1,cell:e=>(0,z.jsx)(`div`,{className:`flex justify-end gap-2 items-center`,children:(0,z.jsx)(Od,{isSelfManaged:r,instance:e.row.original})})},r&&{accessorKey:`instanceFqdn`,size:90,header:`URL`,cell:e=>ol({secure:e.row.original.operationsApiSecure?`true`:`false`,port:e.row.original.operationsApiPort,fqdn:e.row.original.instanceFqdn})},!r&&{accessorKey:`name`,size:90,header:`Name`},{accessorKey:`status`,header:`Status`,size:1,minSize:1,cell:e=>{let t=e.getValue();return(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(Nd,{instance:e.row.original,index:e.row.index}),t?(0,z.jsx)(es,{variant:Ho(t),children:Ma(t)}):null]})}},!r&&{accessorKey:`version`,size:1,minSize:1,header:`Version`},!r&&{accessorKey:`storageGb`,size:1,minSize:1,header:`Storage`,cell:e=>`${e.getValue()} GB`},!r&&{accessorKey:`usedStorageGb`,size:1,minSize:1,header:`Used Storage`,cell:e=>{let t=e.getValue();return t===void 0?`-`:`${t} GB`}},!r&&{accessorKey:`cpuCores`,size:1,minSize:1,header:`Cores/Threads`,cell:e=>(0,z.jsxs)(z.Fragment,{children:[e.row.original.cpuCores,` / `,e.row.original.threads]})},!r&&{accessorKey:`memoryMb`,size:1,minSize:1,header:`Memory`,cell:e=>`${e.getValue()/1024} GB`}].filter(Ni),[r]),a=(0,L.useMemo)(()=>t?.instances?t.instances.filter(e=>e.status&&!Ba.includes(e.status)).sort(Ns):[],[t]);return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(Vo,{}),(0,z.jsx)(`div`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-(--spacing(32)))]`,children:(0,z.jsx)(xi,{className:`p-0 mt-4 min-h-96`,children:(0,z.jsx)(Ti,{className:`p-0 min-h-96`,children:n?(0,z.jsx)(Ec,{}):a.length?(0,z.jsx)(Ed,{data:a,columns:i}):(0,z.jsx)(Dd,{})})})})]})}function Fd(){let{clusterId:e}=M({strict:!1}),{data:t,isLoading:n}=D(Ka(e,2e3)),r=t?.status,i=(0,L.useMemo)(()=>r&&za.includes(r),[r]);return n||!t?(0,z.jsx)(Uu,{className:`flex justify-center`,children:(0,z.jsx)(Ec,{})}):i?(0,z.jsx)(Uu,{className:`flex justify-center`,children:(0,z.jsxs)(`div`,{className:`center w-2xl flex flex-col gap-4`,children:[(0,z.jsx)(`h1`,{className:`text-xl text-center`,children:`All done!`}),(0,z.jsx)(ds,{cluster:t,forceProgressBarVisible:!0}),(0,z.jsx)(`p`,{children:`Your cluster finished updating, and is ready for interaction.`}),(0,z.jsx)(`div`,{className:`text-center`,children:(0,z.jsx)(ls,{cluster:t})})]})}):(0,z.jsx)(Uu,{className:`flex justify-center`,children:(0,z.jsxs)(`div`,{className:`center w-2xl flex flex-col gap-4`,children:[(0,z.jsx)(`h1`,{className:`text-xl text-center`,children:`Here we go!`}),(0,z.jsx)(ds,{cluster:t,forceProgressBarVisible:!0}),(0,z.jsxs)(`p`,{children:[`Your cluster is updating with the latest changes. This includes waiting several minutes to let traffic drain safely.`,` `,(0,z.jsxs)(`span`,{className:`text-muted-foreground`,children:[`We will let you know when we are ready for you to connect! In the meantime, join us on`,` `,(0,z.jsx)(`a`,{href:`https://discord.gg/VzZuaw3Xay`,target:`_blank`,rel:`noreferrer`,className:`underline hover:text-blue-300`,children:`Discord`}),`! Get real-time help from our engineers, see feature drops early, and connect with others building on Fabric.`]})]})]})})}function Id(){let e=kn(),{clusterId:t}=M({strict:!1}),{data:n,isLoading:r}=D(Ka(t,2e3)),i=n?.status,a=(0,L.useMemo)(()=>i&&za.includes(i),[i]),o=Wo(i),[,s]=vs(ys.SavedClusterState,null),c=(0,L.useCallback)(()=>{s(n),e.navigate({to:`/${n.organizationId}/new-cluster`})},[n,e,s]);return r||!n?(0,z.jsx)(Uu,{className:`flex justify-center`,children:(0,z.jsx)(Ec,{})}):o?(0,z.jsx)(Uu,{className:`flex justify-center`,children:(0,z.jsxs)(`div`,{className:`center max-w-2xl flex flex-col gap-4 items-center`,children:[(0,z.jsx)(Kt,{className:`w-24 h-24`}),(0,z.jsxs)(`span`,{children:[`Your cluster failed to successfully start. This is usually caused by temporary communication problems. Would you like to try again? We also get notified about these failures. `,(0,z.jsx)(xs,{}),` if you want more help.`]}),(0,z.jsx)(B,{type:`button`,variant:`positiveOutline`,onClick:c,children:`Try Again`})]})}):a?(0,z.jsx)(Uu,{className:`flex justify-center`,children:(0,z.jsxs)(`div`,{className:`center max-w-2xl flex flex-col gap-4`,children:[(0,z.jsx)(`h1`,{className:`text-xl text-center`,children:`It's ready!`}),(0,z.jsx)(ds,{cluster:n,forceProgressBarVisible:!0}),(0,z.jsxs)(`p`,{children:[`Let's set up your secure, browser-to-cluster connection now.`,` `,(0,z.jsxs)(`span`,{className:`text-muted-foreground`,children:[`Did you know during this step, you connect straight to your cluster, providing a private secure connection? That's `,(0,z.jsx)(`em`,{children:`Direct Connect`}),`! Once you create your user, you will have the option to`,` `,(0,z.jsx)(`em`,{children:`Fabric Connect`}),` from your Fabric account without having to sign in again.`]})]}),(0,z.jsx)(`div`,{className:`text-center`,children:(0,z.jsx)(ls,{cluster:n})})]})}):(0,z.jsx)(Uu,{className:`flex justify-center`,children:(0,z.jsxs)(`div`,{className:`center max-w-2xl flex flex-col gap-4`,children:[(0,z.jsx)(`h1`,{className:`text-xl text-center`,children:`Here we go!`}),(0,z.jsx)(ds,{cluster:n,forceProgressBarVisible:!0}),(0,z.jsxs)(`p`,{children:[`Your cluster is spinning up with the latest changes, including your own DNS records and private connections. Please wait while we get everything going.`,` `,(0,z.jsxs)(`span`,{className:`text-muted-foreground`,children:[`We will let you know when we are ready for you to connect! In the meantime, join us on`,` `,(0,z.jsx)(`a`,{href:`https://discord.gg/VzZuaw3Xay`,target:`_blank`,rel:`noreferrer`,className:`underline hover:text-blue-300`,children:`Discord`}),`! Get real-time help from our engineers, see feature drops early, and connect with others building on Fabric.`]})]})]})})}O({getParentRoute:()=>Hu,path:`instances`,component:Pd}),O({getParentRoute:()=>Hu,path:`starting-up`,component:Id}),O({getParentRoute:()=>Hu,path:`scaling`,component:Fd}),O({getParentRoute:()=>Hu,path:`domains`,component:md}),O({getParentRoute:()=>Hu,path:`sign-in`,component:no,beforeLoad:({context:e,location:t,params:n})=>{let r=I.checkForFabricConnect(n.clusterId);if(e.authentication[n.clusterId]?.user&&!r){let e=t?.search;throw ar({to:e?.redirect?.startsWith(`/`)?e.redirect:`../`})}}}),O({getParentRoute:()=>Hu,path:`instance/$instanceId/sign-in`,component:no,beforeLoad:({context:e,location:t,params:n})=>{if(!(I.checkForFabricConnect(n.clusterId)||I.checkForFabricConnect(n.instanceId))&&e.authentication[n.instanceId]?.user){let e=t?.search;throw ar({to:e?.redirect?.startsWith(`/`)?e.redirect:`../`})}}}),O({getParentRoute:()=>Hu,path:`finish-setup`,component:Td});function Ld(e){return O({getParentRoute:()=>e,path:`apis`}).lazy(()=>Gr(()=>import(`./index.lazy-DRQKYKT0.js`).then(e=>e.route),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11])))}function Rd(e,t){if(e===t)return!0;if(!e||!t)return!1;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let i of n)if(!r.includes(i)||e[i]!==t[i])return!1;return!0}function zd(e,t){let[n,r]=(0,L.useState)(t),[i,a]=(0,L.useState)(e);return(0,L.useEffect)(()=>{Rd(n,t)||(r(t),a(e))},[n,t,e]),Rd(n,t)?[i,a]:[e,a]}var Bd={};function Vd(e,t,n){let r=(0,L.useCallback)((e,n)=>t(e,n),[n]);(0,L.useEffect)(()=>(Bd[e]||(Bd[e]=[]),Bd[e].push(r),function(){let t=Bd[e].indexOf(r);t>=0&&Bd[e].splice(t,1)}),[e,t,r])}function Hd(e,t,n){let r=Bd[e];if(r)for(let e of r)e(t,n)}function Ud(e,t,n){return r=>Hd(e,t,n??r)}function Wd(e,t,n){return(0,L.useCallback)(r=>Hd(e,t,n??r),[e,t,n])}function Gd(e,t){return hs(sessionStorage.getItem(String(e)))??t}function Kd(e,t){t==null?sessionStorage.removeItem(String(e)):sessionStorage.setItem(String(e),JSON.stringify(t))}function qd(e,t){let n=zd(Gd(e,t),[e]),[r,i]=n;return(0,L.useEffect)(()=>{Kd(e,r),Hd(`Session:${e}`,r)},[e,r]),Vd(`Session:${e}`,function(e){r!==e&&i(e)},[r,e,t]),(0,L.useEffect)(function(){let n=n=>{n.key===e&&i(Gd(e,t))};return window.addEventListener(`storage`,n),()=>{window.removeEventListener(`storage`,n)}},[e,i,t]),n}function Jd(e,t=!1){let[n,r]=qd(e,t),i=(0,L.useCallback)(e=>{e?.preventDefault?.(),r(e=>!e)},[r]),a=(0,L.useCallback)(e=>{e?.preventDefault?.(),r(!0)},[r]),o=(0,L.useCallback)(e=>{e?.preventDefault?.(),r(!1)},[r]);return(0,L.useMemo)(()=>({toggled:n,setToggled:r,toggle:i,toggleOn:a,toggleOff:o}),[i,r,o,a,n])}var Yd=(0,L.createContext)(null);function Xd(){return(0,L.useContext)(Yd)}async function Zd({file:e,project:t,entityType:n,instanceClient:r}){let{data:i}=await r.post(`/`,{operation:`drop_component`,file:e||void 0,project:t,replicated:n===`cluster`});return i}function Qd(e){let t=(e||``)?.split(`.`);return t.length>1?t.slice(-1)[0]:``}function $d(e){switch(Qd(e).toLowerCase()){case`jpg`:case`jpeg`:case`gif`:case`png`:case`pneg`:case`webp`:return!0;default:return!1}}async function ef({instanceClient:e,file:t,project:n,encoding:r}){let{data:i}=await e.post(`/`,{operation:`get_component_file`,project:n,file:t,encoding:r??($d(t)?`base64`:`utf8`)});return{project:n,file:t,...i}}function tf(e){return A({queryKey:nf(e),queryFn:()=>ef(e),enabled:!!e.file&&!!e.project,retry:!1})}function nf(e){return[e.entityId,`get_component_file`,e.project,e.file,e.encoding]}async function rf({file:e,payload:t,project:n,entityType:r,instanceClient:i,encoding:a}){let{data:o}=await i.post(`/`,{operation:`set_component_file`,file:e,payload:t,project:n,encoding:a,replicated:r===`cluster`},{timeout:3e5});return o}function af(){return E({mutationFn:rf})}function of(){let{reloadRootEntries:e,setFocusedItem:t,setSelectedItems:n}=Xd(),r=V();return(0,L.useCallback)(async i=>{let a=!1,o=i.filter(e=>e.from!==e.to);if(o.length===0)return;let s=`Renaming ${Qr(o.length,`File`,`Files`)}`,c={duration:6e4,action:{label:`Cancel`,onClick:()=>{a=!0}}};c.id=k.loading(s,{...c,description:(0,z.jsx)(Us,{animated:!0,width:`0%`})});let l=o.length*3,u=0;function d(){u+=1,k.loading(s,{...c,description:(0,z.jsx)(Us,{animated:!0,width:(u===0?0:u/l*100)+`%`})})}for(let e of o){let t=e.from.split(`/`),n=t.shift(),i=t.join(`/`),o=e.to.split(`/`),s=o.shift(),c=o.join(`/`),l=await ef({...r,file:i,project:n,encoding:`base64`});if(a||(d(),await rf({...r,file:c,project:s,encoding:`base64`,payload:l.message}),a)||(d(),await Zd({...r,file:i,project:n}),a))break;d()}u>=l?k.success(`Renamed ${Qr(o.length,`File`,`Files`)}`,{id:c.id,description:`All done!`,duration:3e3,action:{label:`OK`,onClick:()=>{}}}):k.warning(`Rename Cancelled`,{id:c.id,description:`${u} of ${l} steps completed.`,duration:1e4,action:{label:`OK`,onClick:()=>{}}}),e(),n(e=>{let t=e.slice();for(let e of o){let n=t.indexOf(e.from);n>=0?t.splice(n,1,e.to):t.push(e.to)}return t}),t(e=>{for(let t of o)if(e===t.from)return t.to;return e})},[r,e,t,n])}function sf(e,t){return e[t]!==void 0}function cf(e){return t=>sf(t,e)}function lf(e,t){let[n,r]=(0,L.useState)({value:t});return Vd(e,(e,t)=>r({value:e,trigger:t}),[r]),n}function uf(e,t,n){Hd(e,t,n)}function df(e,t,n){return r=>uf(e,t,n??r)}function ff(e,t,n){return(0,L.useCallback)(r=>{uf(e,t,n??r)},[e,t,n])}var pf=[{handleGlobal(e,t){if((t.cmd||t.ctrl)&&e===`Delete`)return uf(`ShowDeleteDirectoryOrFileModal`,!0),!0},addEditorAction(e){return{id:`delete-file`,label:`Delete File`,keybindings:[e.KeyMod.CtrlCmd|e.KeyCode.Delete],run:df(`ShowDeleteDirectoryOrFileModal`,!0)}}},{handleGlobal(e,t){if(t.ctrl&&t.alt&&t.shift&&e===`˜`)return uf(`ShowAddDirectoryOrFileModalType`,`directory`),!0},addEditorAction(e){return{id:`new-directory`,label:`New Directory`,keybindings:[e.KeyMod.WinCtrl|e.KeyMod.Alt|e.KeyMod.Shift|e.KeyCode.KeyN],run:df(`ShowAddDirectoryOrFileModalType`,`directory`)}}},{handleGlobal(e,t){if(t.ctrl&&e===`n`)return uf(`ShowAddDirectoryOrFileModalType`,`file`),!0},addEditorAction(e){return{id:`new-file`,label:`New File`,keybindings:[e.KeyMod.WinCtrl|e.KeyCode.KeyN],run:df(`ShowAddDirectoryOrFileModalType`,`file`)}}},{handleGlobal(e){if(e===`F2`)return uf(`ShowRenameFileModal`,`file`),!0},addEditorAction(e){return{id:`rename-file`,label:`Rename File`,keybindings:[e.KeyMod.WinCtrl|e.KeyMod.Alt|e.KeyCode.KeyR,e.KeyCode.F2],run:df(`ShowRenameFileModal`,!0)}}},{addEditorAction(){return{id:`revert-file`,label:`Revert File`,run:Ud(`RevertChanges`,!0)}}},{handleGlobal(e,t){if(t.cmd&&e===`s`)return Hd(`SaveFile`,!0),!0},addEditorAction(e){return{id:`save-file`,label:`Save Changes`,keybindings:[e.KeyMod.CtrlCmd|e.KeyCode.KeyS],run:Ud(`SaveFile`,!0)}}}],mf=pf.filter(cf(`addEditorAction`)),hf=pf.filter(cf(`handleGlobal`));function gf(e){let[t,n]=e,r=mf.map(e=>t.addAction(e.addEditorAction(n)));return()=>{for(let e of r)e?.dispose()}}function _f(){(0,L.useEffect)(()=>(document.addEventListener(`keydown`,vf),()=>{document.removeEventListener(`keydown`,vf)}),[])}function vf(e){let t={cmd:e.getModifierState(`Meta`),alt:e.getModifierState(`Alt`),shift:e.getModifierState(`Shift`),ctrl:e.getModifierState(`Control`)};for(let n of hf)if(n.handleGlobal(e.key,t)){e.preventDefault();return}}function yf(e){return e.split(`/`).pop()}function bf(...e){let t=e.flat(1);return t.map((e,n)=>typeof e==`string`?xf(e,n!==0,n!==t.length-1):e).join(`/`)}function xf(e,t=!0,n=!0){let r=t&&e[0]===`/`,i=n&&e[e.length-1]===`/`;return r&&i?e.slice(1,-1):r?e.slice(1):i?e.slice(0,-1):e}function Sf(e){return!!e?.entries}var Cf=`__root__`,wf=`importedApplications`,Tf=`newApplication`;function Ef(e){let t={},n=[],r=[],i=[];for(let a of e)Sf(a)?a.package?r.push(a.path):n.push(a.path):i.push(a.path),Df(t,a);return t[Cf]={index:Cf,isFolder:!0,children:[Tf,wf,...n,...i].filter(Ni),data:void 0,canMove:!1,canRename:!1},t[wf]={index:wf,isFolder:!0,children:r,data:{name:`Imported Applications`,path:wf,package:wf,project:``,entries:[]},canMove:!1,canRename:!1},t[Tf]={index:Tf,isFolder:!1,data:{name:`New Application`,path:Tf,project:``},canMove:!1,canRename:!1},{items:t,rootId:Cf}}function Df(e,t){let n=t.path;if(Sf(t)){let r=t,i=[],a=[];for(let e of r.entries)Sf(e)?i.push(e.path):a.push(e.path);e[n]={index:n,isFolder:!0,children:[...i,...a],data:t,canMove:!1,canRename:!1};for(let t of r.entries)Df(e,t)}else e[n]={index:n,isFolder:!1,data:t,canMove:!t.package,canRename:!t.package}}function Of(){let[e,t]=(0,L.useState)(!1),[n,r]=(0,L.useState)(void 0),i=(0,L.useCallback)(e=>{if(!e.dataTransfer?.types?.includes(`Files`))return;let n=e.target;if(n instanceof Element&&n.classList.contains(`rct-tree-item-button-isFolder`)){let e=n.getAttribute(`data-rct-item-id`);!n.querySelector(`.packageIsLocked`)&&e&&e!==`importedApplications`&&e!==`newApplication`&&r(e=>e===n?e:(e?.classList?.remove?.(`rct-tree-item-title-container-dragging-over`),n.classList.add(`rct-tree-item-title-container-dragging-over`),n))}t(!0)},[]),a=(0,L.useCallback)(()=>{t(!1),r(e=>{e&&e.classList.remove(`rct-tree-item-title-container-dragging-over`)})},[]),o=(0,L.useCallback)(e=>{if(!e.dataTransfer?.types?.includes(`Files`)||e.detail===1337)return;t(!1),n&&(n.classList.remove(`rct-tree-item-title-container-dragging-over`),r(void 0));let i=document.getElementById(`dropTarget`);return i?i.dispatchEvent(new DragEvent(`drop`,{bubbles:!0,detail:1337,cancelable:!0,dataTransfer:e.dataTransfer})):!1},[n]);return(0,L.useEffect)(()=>(document.addEventListener(`dragenter`,i),document.addEventListener(`dragover`,i),document.addEventListener(`dragleave`,a),document.addEventListener(`drop`,o),()=>{document.removeEventListener(`dragenter`,i),document.removeEventListener(`dragover`,i),document.removeEventListener(`dragleave`,a),document.removeEventListener(`drop`,o)}),[i,o,a]),(0,L.useMemo)(()=>({dragging:e,dragTarget:n}),[e,n])}function kf(e){return new Promise((t,n)=>{let r=new FileReader;r.onabort=n,r.onerror=n,r.onload=t,r.readAsDataURL(e)})}function Af(){let[e,t]=(0,L.useState)(``),{clusterId:n}=M({strict:!1}),{openedEntry:r,restrictPackageModification:a,reloadRootEntries:o,entryExists:s}=Xd(),c=!!r&&!r.package&&!a,l=V(),{dragging:u,dragTarget:d}=Of(),f=(d?.getAttribute?.(`data-rct-item-id`))?.split?.(`/`)?.pop?.(),p=r?.project,m=!1,h;if(r?.path){let e=r.path.split(`/`),t=Sf(r);m=c&&(t?e.slice(1):e.slice(1,-1)).join(`/`),h=e[e.length-(t?1:2)]}let g=(0,L.useCallback)(async(e,n)=>{let r=d?.getAttribute?.(`data-rct-item-id`)?.split?.(`/`),i=r?.length?r[0]:c?p:!1,a=r?.length?r.slice(1).join(`/`):c?m:!1;if(i===!1||i===void 0||a===!1||a===void 0)return;let u=[],f=n.slice();for(let t of e){let e=jf(a,t);t.name.startsWith(`.`)||t.relativePath?.includes(`/.`)?f.push({file:t,errors:[{message:`Sensitive files and folders starting with . are skipped.`,code:`dot-ignored`}]}):s(`${i}/${e}`)?f.push({file:t,errors:[{message:`${e} already exists`,code:`duplicate`}]}):u.push(t)}let h=!1,g=`uploading-files`,_={label:`Cancel`,onClick:()=>{h=!0}},v={label:`OK`,onClick:()=>void 0};t(`Uploading ${Qr(u.length,`file`,`files`)}...`);let y=u.reduce((e,t)=>e+t.size,0),b=0,x=0;for(let e of u){x+=1,k.loading(`Upload in progress...`,{id:g,descriptionClassName:`whitespace-pre`,description:`${x} of ${Qr(u.length,`file`,`files`)}
34
- ${e.name}
35
- ${Xc(b)} of ${Xc(y)}`,action:_});let t=jf(a,e),n=(await kf(e)).target.result,r=n.indexOf(`base64,`);h?f.push({file:e,errors:[{message:`${t} cancelled`,code:`cancelled`}]}):(await rf({...l,file:t,project:i,encoding:`base64`,payload:n.slice(r+7)}),b+=e.size)}k.loading(`Reloading sidebar...`,{id:h?void 0:g,action:v,description:``}),await o(),f.length===0?e.length>0&&k.success(`Uploaded ${Qr(u.length,`file`,`files`)}!`,{id:g,action:v,description:``}):(console.log(f),k.error(h?`Cancelled uploads`:`Rejected uploads`,{id:h?void 0:g,action:v,descriptionClassName:`whitespace-pre overflow-y-auto`,description:f.slice(0,5).map(e=>e.errors.map(e=>e.message).join(`
36
- `)).join(`
37
- `)+(f?.length>5?`
38
- Check the console for the full list.`:``)})),t(``)},[d,c,p,m,s,l,o]),{getRootProps:_,getInputProps:v}=je({multiple:!0,maxSize:n&&I.checkForFabricConnect(n)?Zr:Xr,onDrop:g});return!c&&!d?u?(0,z.jsxs)(`div`,{className:i(`border-3 border-dashed`,`pointer-events-auto`,`cursor-copy text-sm text-center`,`p-2 w-full fixed bottom-0 h-16`,`flex flex-col items-center justify-center`,`bg-red-950 border-red-600`),children:[`You cannot upload into`,(0,z.jsx)(`br`,{}),(0,z.jsx)(`strong`,{children:h})]}):null:(0,z.jsxs)(`div`,{..._(),className:u?`fixed top-0 bottom-0 w-full pointer-events-none`:``,children:[(0,z.jsx)(`input`,{id:`dropTarget`,...v()}),(0,z.jsx)(`div`,{className:i(`border-3 border-dashed`,`pointer-events-auto`,`cursor-copy text-sm text-center`,`p-2 w-full fixed bottom-0 h-16`,`flex flex-col items-center justify-center`,u?`animate-glow-pulse bg-green-950 border-green-600`:`bg-purple-950 border-purple-600`),children:e||(d?(0,z.jsxs)(z.Fragment,{children:[`Drop to upload into`,(0,z.jsx)(`br`,{}),(0,z.jsx)(`strong`,{children:f})]}):u?(0,z.jsxs)(z.Fragment,{children:[`Drop to upload into`,(0,z.jsx)(`br`,{}),(0,z.jsx)(`strong`,{children:h})]}):(0,z.jsxs)(z.Fragment,{children:[`Drag and drop to upload`,(0,z.jsx)(`br`,{}),`or click to select files.`]}))})]})}function jf(e,t){let n=t.relativePath??t.name,r=n.indexOf(`/`),i=r===0||r===1?n.slice(r+1):n;return e?`${e}/${i}`:i}function Mf(e){let t=e.data;return t&&`name`in t?t.name:`root`}function Nf(e){let{instanceId:t,clusterId:n}=M({strict:!1}),[r,i]=qd(`EditorFileContent/${F}}/${e}`,void 0);return(0,L.useMemo)(()=>({content:e?r:void 0,setContent:i}),[e,r,i])}var Pf=`w-6 pointer-events-none `;function Ff({opened:e,pkg:t}){let n=Pf+`w-4 h-4 shrink-0`;return t?e?(0,z.jsx)(Cn,{className:`${n} text-orange-600`}):(0,z.jsx)(S,{className:`${n} text-orange-600`}):e?(0,z.jsx)(Yn,{className:`${n} text-orange-400`}):(0,z.jsx)(Ln,{className:`${n} text-orange-400`})}function If({extension:e}){let t=`w-4 h-4 mr-2 shrink-0`;switch(e){case`js`:case`jsx`:case`cjs`:return(0,z.jsx)(Zt,{className:`${t} text-yellow-500`});case`ts`:case`tsx`:return(0,z.jsx)(Zt,{className:`${t} text-blue-500`});case`yaml`:case`yml`:return(0,z.jsx)(yn,{className:t});case`css`:return(0,z.jsx)(yn,{className:`${t} text-blue-500`});case`html`:return(0,z.jsx)(Ht,{className:t});case`json`:return(0,z.jsx)(An,{className:t});case`png`:case`jpg`:case`jpeg`:case`gif`:return(0,z.jsx)(Qn,{className:t});case`svg`:return(0,z.jsx)(Wt,{className:t});case`vue`:return(0,z.jsx)(Zt,{className:`${t} text-green-500`});default:return(0,z.jsx)(yn,{className:t})}}function Lf(){return(0,z.jsx)(Cr,{className:Pf+`w-4 h-4 shrink-0 text-gray-400 ml-2 packageIsLocked`})}function Rf(){return(0,z.jsx)(C,{className:Pf+`w-4 h-4 shrink-0 text-green-500`})}function zf({title:e,item:t,context:n}){let{content:r}=Nf(t.data?.path);return(0,z.jsxs)(z.Fragment,{children:[t.data?.path===`newApplication`?(0,z.jsx)(Rf,{}):Sf(t.data)?(0,z.jsx)(Ff,{opened:n.isExpanded,pkg:!!t.data?.package||t.data.path===`importedApplications`}):(0,z.jsx)(If,{extension:Qd(e)}),(0,z.jsxs)(`span`,{className:`text-nowrap pointer-events-none`,children:[e,r?`*`:``]}),t.data?.package&&(0,z.jsx)(Lf,{})]})}function Bf(){let{rootEntries:e,openedEntry:t,setOpenedEntry:n,focusedItem:r,setFocusedItem:i,expandedItems:a,setExpandedItems:o,selectedItems:s,setSelectedItems:c}=Xd(),{items:l,rootId:u}=(0,L.useMemo)(()=>Ef(e),[e]);_f(),(0,L.useEffect)(function(){if(t?.path!==r&&r){let e=l[r]?.data;e&&n(e)}},[r,l,t?.path,n]);let d=of();return(0,z.jsxs)(`div`,{className:`h-full overflow-auto pr-1.5 pb-18`,children:[(0,z.jsx)(Ot,{canDragAndDrop:!0,canDropOnFolder:!0,canDropOnNonFolder:!1,canReorderItems:!1,canSearch:!0,canRename:!1,getItemTitle:Mf,items:l,onDrop:(0,L.useCallback)((e,t)=>{switch(t.targetType){case`item`:if(l[t.targetItem]?.data?.package)k.error(`Read-Only Imported Application`,{description:`To make changes to an application, please click the "Redeploy" button and update the reference.`});else return d(e.map(e=>({from:e.index,to:bf(t.targetItem,yf(e.index))})));break;default:k.error(`${t.targetType} drop not yet supported`);break}},[l,d]),renderItemTitle:zf,viewState:{applicationsTree:{focusedItem:r,expandedItems:a,selectedItems:s}},onFocusItem:e=>i(e.index),onExpandItem:e=>o([...a,e.index]),onCollapseItem:e=>o(a.filter(t=>t!==e.index)),onSelectItems:e=>c(e),children:(0,z.jsx)(xt,{treeId:`applicationsTree`,rootItem:u,treeLabel:`Applications file tree`})}),(0,z.jsx)(Af,{})]})}async function Vf(e,t=3,n=1e3){let r=0;if(t<=0)throw Error(`retries must be greater than 0`);let i;for(;r<t;)try{return await e()}catch(e){if(r++,i=e,r===t)break;await ri(n)}throw i}async function Hf({operation:e,replicated:t,instanceClient:n}){let{data:r}=await n.post(`/`,{operation:e,service:e===`restart_service`?`http`:void 0,replicated:t});return await ri(1e4),await Vf(()=>ui({instanceClient:n,timeout:3e3}),12,15e3),r}function Uf(){return E({mutationFn:Hf})}function Wf({onRestartedSuccessfully:e}={}){let{clusterId:t}=M({strict:!1}),n=Vt(),[r,i]=(0,L.useState)(!1);return{onRestartClick:(0,L.useCallback)(async()=>{if(!t)throw Error(`clusterId must be set in the route to invoke useRestartClusterClick`);i(!0);let r=!1,a={duration:6e4,action:{label:`Cancel`,onClick:()=>{r=!0}}},o=k.loading(`Restarting`,{...a,description:(0,z.jsx)(Us,{animated:!0,width:`0%`})}),s=await Ga(t),c=I.checkForFabricConnect(s.id),l=s?.instances??[],u=l.filter(e=>e.status===`RUNNING`).map(e=>ai({id:e.id,forceFabricConnect:c,operationsUrl:fi(e)})).reverse(),d=0;if(u.length)for(let e=0;e<u.length;e++){let t=u[e];if(!r){k.loading(`Restarting Instance ${e+1} of ${u.length}`,{...a,id:o,description:(0,z.jsx)(Us,{animated:!0,width:(e===0?0:e/u.length*100)+`%`})});try{await ui({instanceClient:t}),await Hf({operation:`restart`,replicated:!1,instanceClient:t}),d+=1}catch{e+1!==u.length&&(k.loading(`Failed Restarting Instance ${e+1} of ${u.length}`,{...a,id:o,description:`We will carry on momentarily.`}),await ri(3e3))}}}if(i(!1),n.invalidateQueries({queryKey:[t]}),r)k.error(`Cancelled`,{id:o,description:`The restart was partially cancelled.`,duration:1e4,action:{label:`Dismiss`,onClick:()=>k.dismiss()}});else if(l.length===d)e?.(),k.success(`Success`,{id:o,description:`Cluster fully restarted!`,duration:1e4,action:{label:`Dismiss`,onClick:()=>k.dismiss()}});else{let e=Qr(l.length,`instance`,`instances`),t=Qr(d,`"RUNNING" instance was`,`"RUNNING" instances were`);k.error(`Error`,{id:o,description:`Failed to fully restart cluster.
39
- `+([l.length===0&&`No instances were found within the cluster to restart.`,d===0&&`No instances were in a "RUNNING" state of ${e}.`,l.length!==d&&`Only ${t} restarted of ${e}.`].filter(Ni).shift()||``),duration:1e4,action:{label:`Dismiss`,onClick:()=>k.dismiss()}})}},[t,e,n]),isRestartPending:r}}function Gf({operation:e,instanceClient:t,onRestartedSuccessfully:n}){let{clusterId:r,instanceId:i}=M({strict:!1}),a=`Instance`,{mutate:o,isPending:s}=Uf(),c=Vt();return{onRestartClick:(0,L.useCallback)(()=>{let s=k.loading(`Restarting`,{description:`Restarting instance. This may take up to 60 seconds.`,duration:18e4,action:{label:`Dismiss`,onClick:()=>k.dismiss()}});o({operation:e,replicated:e===`restart_service`&&a===`Cluster`,instanceClient:t},{onSuccess:()=>{c.invalidateQueries({queryKey:[r]}),c.invalidateQueries({queryKey:[i]}),k.dismiss(s),k.success(`Success`,{description:`${a} restarted!`,action:{label:`Dismiss`,onClick:()=>k.dismiss()}}),n?.()},onError:()=>{k.dismiss(s),k.error(`Error`,{description:`Failed to restart instance.`,action:{label:`Dismiss`,onClick:()=>k.dismiss()}})}})},[r,t,i,n,e,c,o,a]),isRestartPending:s}}function Kf({className:e,disabled:t,hideText:n,instanceClient:r,operation:a,targetNoun:o,tooltip:s,variant:c}){let{onRestartClick:l,isRestartPending:u}=Wf(),{onRestartClick:d,isRestartPending:f}=Gf({operation:a,instanceClient:r});return(0,z.jsxs)(Oa,{children:[(0,z.jsx)(ka,{asChild:!0,children:(0,z.jsxs)(B,{type:`button`,variant:c||`positiveOutline`,className:i(`mx-0 md:mx-4 rounded-full`,e),onClick:o===`Cluster`&&a===`restart`?l:d,disabled:t||f||u,title:`Restart ${o}`,children:[(0,z.jsx)(gr,{className:`pointer-events-none`}),n!==!0&&(0,z.jsxs)(`span`,{className:`hidden md:inline-block pointer-events-none`,children:[`Restart `,(0,z.jsx)(`span`,{className:`hidden 2xl:inline-block`,children:o})]})]})}),(0,z.jsx)(Aa,{side:`bottom`,children:s||(a===`restart_service`?`Restarts all service threads to apply changes. No downtime expected. Performance may be briefly slower during restart.`:`This fully restarts the Harper service and causes downtime.`)})]})}function qf({toggledSidebar:e,toggleSidebar:t}){let n=V(),{openedEntryContents:r,openedEntry:i,isSavingFile:a,restrictPackageModification:o}=Xd(),{content:s}=Nf(i?.path),c=ua(),l=n.entityType===`instance`?`Instance`:`Cluster`,u=ff(`ShowAddDirectoryOrFileModalType`,`file`),d=ff(`ShowAddDirectoryOrFileModalType`,`directory`),f=ff(`ShowDownloadApplicationModal`,!0),p=ff(`ShowRenameFileModal`,!0),m=ff(`ShowDeleteDirectoryOrFileModal`,!0),h=ff(`ShowRedeployApplicationModal`,!0),g=Wd(`SaveFile`,!0),_=Wd(`RevertChanges`,!0),v=Wd(`ShowNewTableModal`,!0),y=s===void 0||s===r;return(0,z.jsxs)(`div`,{className:`absolute top-0 right-0 left-0 backdrop-blur-sm bg-black-10 shadow-xl flex pr-4 md:pr-12`,children:[(0,z.jsxs)(B,{type:`button`,variant:`ghost`,className:(e?`toggled-sidebar-toggler`:`hidden-sidebar-toggler`)+` inline-flex text-sm md:hidden focus:outline-none focus:ring-2 text-white hover:text-grey focus:ring-gray-600 rounded-none`,onClick:t,children:[(0,z.jsxs)(`span`,{className:`sr-only`,children:[e?`Close`:`Open`,` sidebar`]}),e?(0,z.jsx)(Qe,{}):(0,z.jsx)(Dn,{})]}),i&&i?.path!==`newApplication`&&(0,z.jsxs)(z.Fragment,{children:[i.package&&(0,z.jsxs)(Oa,{children:[(0,z.jsx)(ka,{asChild:!0,children:(0,z.jsxs)(B,{variant:`ghost`,type:`button`,className:`cursor-help`,children:[(0,z.jsx)(Cr,{width:16,height:16}),(0,z.jsx)(`span`,{className:`hidden md:inline-block`,children:`Imported applications are read-only`})]})}),(0,z.jsx)(Aa,{children:o?(0,z.jsxs)(z.Fragment,{children:[`This application is read-only, and cannot be modified.`,(0,z.jsx)(`br`,{}),`It helps govern clustering amongst your instances.`]}):(0,z.jsx)(z.Fragment,{children:`This application is read-only, and cannot be directly modified. But you can re-deploy or remove it.`})})]}),!Sf(i)&&!i.package&&c&&(0,z.jsxs)(B,{variant:`default`,className:`rounded-none`,onClick:g,disabled:y||a,title:`Save`,children:[(0,z.jsx)(Jt,{className:`pointer-events-none`}),(0,z.jsxs)(`span`,{className:`hidden lg:inline-block pointer-events-none`,children:[(0,z.jsx)(`u`,{children:`S`}),`ave`]})]}),!Sf(i)&&!i.package&&c&&(0,z.jsxs)(B,{variant:`ghost`,className:`rounded-none`,onClick:p,disabled:!y||a,title:`Rename`,children:[(0,z.jsx)(he,{className:`pointer-events-none`}),(0,z.jsxs)(`span`,{className:`hidden lg:inline-block pointer-events-none`,children:[(0,z.jsx)(`u`,{children:`R`}),`ename`]})]}),!i.package&&c&&(0,z.jsxs)(B,{variant:`ghost`,className:`rounded-none`,onClick:u,title:`New File`,children:[(0,z.jsx)(yn,{className:`pointer-events-none`}),(0,z.jsxs)(`span`,{className:`pointer-events-none hidden lg:inline-block`,children:[(0,z.jsx)(`u`,{children:`N`}),`ew`,(0,z.jsx)(`span`,{className:`hidden lg:inline-block`,children:`\xA0File`})]})]}),!i.package&&c&&(0,z.jsxs)(B,{variant:`ghost`,className:`rounded-none`,onClick:d,title:`Add Directory`,children:[(0,z.jsx)(Ln,{className:`pointer-events-none`}),(0,z.jsxs)(`span`,{className:`pointer-events-none hidden lg:inline-block`,children:[(0,z.jsx)(`u`,{children:`A`}),`dd`,(0,z.jsx)(`span`,{className:`hidden xl:inline-block`,children:`\xA0Directory`})]})]}),i.path.endsWith(`.graphql`)&&c&&(0,z.jsxs)(B,{variant:`ghost`,className:`rounded-none`,onClick:v,title:`New Table`,children:[(0,z.jsx)(C,{className:`pointer-events-none`}),(0,z.jsxs)(`span`,{className:`hidden lg:inline-block pointer-events-none`,children:[(0,z.jsx)(`span`,{className:`hidden xl:inline-block`,children:`New`}),` Table`]})]}),i.project&&(0,z.jsxs)(B,{variant:`ghost`,className:`rounded-none`,onClick:f,title:`Download Application`,children:[(0,z.jsx)(cn,{className:`pointer-events-none`}),(0,z.jsxs)(`span`,{className:`hidden lg:inline-block pointer-events-none`,children:[`Download`,(0,z.jsx)(`span`,{className:`hidden 2xl:inline-block`,children:`\xA0Application`})]})]}),!!i.package&&c&&!o&&(0,z.jsxs)(B,{variant:`ghost`,className:`rounded-none`,onClick:h,title:`Redeploy Package`,children:[(0,z.jsx)(S,{className:`pointer-events-none`}),(0,z.jsxs)(`span`,{className:`pointer-events-none`,children:[`Redeploy `,(0,z.jsx)(`u`,{children:`P`}),`ackage`]})]}),(0,z.jsx)(`div`,{className:`grow`}),c&&(0,z.jsx)(Kf,{targetNoun:l,instanceClient:n.instanceClient,operation:`restart_service`,variant:`ghost`,className:`rounded-none mx-0 md:mx-0`,disabled:!y||a}),!Sf(i)&&!i.package&&c&&(0,z.jsxs)(B,{type:`button`,variant:`ghost`,className:`rounded-none`,onClick:_,disabled:y||a,title:`Revert Changes`,children:[(0,z.jsx)(Vn,{className:`pointer-events-none`}),(0,z.jsxs)(`span`,{className:`hidden xl:inline-block pointer-events-none`,children:[`Revert `,(0,z.jsx)(`span`,{className:`hidden 2xl:inline-block`,children:`Changes`})]})]}),!o&&c&&(0,z.jsxs)(B,{type:`button`,variant:`destructiveGhost`,className:`rounded-none`,onClick:m,title:`Delete`,children:[(0,z.jsx)($t,{className:`pointer-events-none`}),(0,z.jsxs)(`span`,{className:`hidden xl:inline-block pointer-events-none`,children:[(0,z.jsx)(`u`,{children:`D`}),`elete`]})]})]})]})}function Jf(e){return(0,L.useCallback)((t,n,r)=>{if(n!==`href`)return t;if(t.startsWith(`http`))return r.properties.target=`_blank`,t;{let n=bl().split(`?`)[0];switch(t){case`./apis`:case`./config`:case`./config/roles`:case`./config/users`:case`./databases`:case`./logs`:case`./status`:return`${n}/${t.slice(2)}`}return`${n}?open=${e}/${t.slice(t.startsWith(`../`)?3:2)}`}},[e])}function Yf({className:e,orientation:t=`horizontal`,decorative:n=!0,...r}){return(0,z.jsx)(le,{"data-slot":`separator-root`,decorative:n,orientation:t,className:R(`bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px`,e),...r})}function Xf({className:e,...t}){return(0,z.jsx)(ut,{"data-slot":`tabs`,className:R(`flex flex-col gap-2`,e),...t})}function Zf({className:e,...t}){return(0,z.jsx)(Ue,{"data-slot":`tabs-list`,className:R(`text-muted-foreground inline-flex w-fit items-center justify-center rounded-full bg-gray-950 p-1`,e),...t})}function Qf({className:e,...t}){return(0,z.jsx)(wr,{"data-slot":`tabs-trigger`,className:R(`data-[state=active]:text-white data-[state=active]:bg-gray-600 dark:data-[state=active]:text-foreground focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring focus-visible:ring-[3px] focus-visible:outline-1 text-muted-foreground inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 border rounded-full border-transparent px-2 py-1 font-medium whitespace-nowrap transition-[color,box-shadow] disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...t})}function $f({className:e,...t}){return(0,z.jsx)(Ne,{"data-slot":`tabs-content`,className:R(`flex-1 outline-none`,e),...t})}function ep(e,t,n){for(let r of e)if(r[t]===n)return r}function tp(e){let{user:t}=_i(),n=Xi(),{instance:r,cluster:i}=Nt({strict:!1}),a=n.instanceClient.defaults.baseURL;return(0,L.useMemo)(()=>{let n=ec(e),r=[t?.username&&` --deploymentUsername="${t?.username}"`,a&&` --deploymentURL="${a}"`].filter(Ni).join(``);return[{title:`Install or update the Harper CLI`,code:`npm install -g harper`},{title:`Create your awesome app`,code:`npm create harper ${n}${r.length?` --`:``}${r}`,note:`You will be asked some easy questions to get you started. To make deployments easy, enter your password for this cluster. It will get saved into your local .env file.`},{title:`Start local Harper instance`,code:`npm run dev`,note:`You will be prompted to configure Harper.`},{title:`Learn, make changes, grow!`,code:`cat AGENTS.md`},{title:`Deploy!`,code:`npm run deploy`,note:`Remember that .env file? It makes this deployment easy!`}]},[e,a,t?.username])}function np({defaultApplicationName:e,formState:t,watch:n}){let r=n(`applicationName`)||e,i=tp(r),a=ms(...i.map(e=>e.code));return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(Si,{children:[(0,z.jsx)(Ci,{children:`Deploy with Harper CLI`}),(0,z.jsx)(wi,{children:`Follow these steps to deploy your application using the Harper CLI`})]}),(0,z.jsxs)(Ti,{className:`space-y-6`,children:[i.map((e,t)=>(0,z.jsxs)(`div`,{className:`space-y-3`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(`div`,{className:`w-6 h-6 rounded-full bg-primary text-primary-foreground flex items-center justify-center shrink-0`,children:t+1}),(0,z.jsx)(`h3`,{children:e.title})]}),(0,z.jsxs)(`div`,{className:`ml-8`,children:[(0,z.jsxs)(`div`,{className:`bg-black rounded-lg p-4 flex items-center justify-between group`,children:[(0,z.jsx)(`code`,{className:`text-sm overflow-auto pl-8 -indent-8 wrap-anywhere`,children:e.code}),(0,z.jsx)(B,{type:`button`,variant:`default`,size:`sm`,onClick:a[t],children:(0,z.jsx)(hn,{className:`w-4 h-4`})})]}),e.note&&(0,z.jsx)(`p`,{className:`text-muted-foreground text-sm mt-2`,children:e.note})]}),(0,z.jsx)(Yf,{className:`bg-black`})]},e.title)),r&&(0,z.jsxs)(`div`,{className:`bg-accent rounded-lg p-4`,children:[(0,z.jsxs)(`p`,{className:`text-sm`,children:[(0,z.jsx)(`strong`,{children:`Application Name:`}),` `,r]}),(0,z.jsx)(`p`,{className:`text-muted-foreground text-sm mt-2`,children:`Your application will be deployed with this name`})]}),(0,z.jsxs)(B,{className:`w-full`,variant:`secondary`,disabled:!t.isValid,children:[(0,z.jsx)(Tn,{className:`w-4 h-4 mr-2`}),`I Have Completed These Steps`]})]})]})}function rp({control:e,defaultApplicationName:t}){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(Si,{children:[(0,z.jsx)(Ci,{children:`Application Name`}),(0,z.jsx)(wi,{children:`Choose a name for your new API application`})]}),(0,z.jsx)(Ti,{children:(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsx)(W,{control:e,name:`applicationName`,render:({field:e})=>(0,z.jsxs)(G,{children:[(0,z.jsx)(K,{className:`pb-1`,children:`Name`}),(0,z.jsx)(U,{children:(0,z.jsx)(J,{type:`text`,autoCapitalize:`words`,autoComplete:`off`,autoFocus:!0,placeholder:t,...e})}),(0,z.jsx)(q,{})]})}),(0,z.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`Use lowercase letters, numbers, underscores, and hyphens`})]})})]})}var ip=y(`relative w-full rounded-lg border px-4 py-3 text-sm grid has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] grid-cols-[0_1fr] has-[>svg]:gap-x-3 gap-y-0.5 items-start [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current`,{variants:{variant:{default:`bg-card text-card-foreground`,destructive:`text-destructive bg-card [&>svg]:text-current *:data-[slot=alert-description]:text-destructive/90`,warning:`border-amber-500/50 text-amber-600 dark:text-amber-400 bg-amber-50/50 dark:bg-amber-950/20 [&>svg]:text-amber-600 dark:[&>svg]:text-amber-400`}},defaultVariants:{variant:`default`}});function ap({className:e,variant:t,...n}){return(0,z.jsx)(`div`,{"data-slot":`alert`,role:`alert`,className:R(ip({variant:t}),e),...n})}function op({className:e,...t}){return(0,z.jsx)(`div`,{"data-slot":`alert-title`,className:R(`col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight`,e),...t})}function sp({className:e,...t}){return(0,z.jsx)(`div`,{"data-slot":`alert-description`,className:R(`text-muted-foreground col-start-2 grid justify-items-start gap-1 text-sm [&_p]:leading-relaxed`,e),...t})}function cp({control:e,formState:t,isImportingApplication:n,setValue:r,watch:i}){let a=i(`contents.source`),o=(0,L.useCallback)(e=>{r(`contents.source`,e)},[r]);return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(Si,{children:[(0,z.jsx)(Ci,{children:`Import Existing Application`}),(0,z.jsx)(wi,{children:`Import from Git, NPM, or a tarball URL`})]}),(0,z.jsxs)(Ti,{className:`space-y-6`,children:[(0,z.jsxs)(Xf,{value:a,onValueChange:o,children:[(0,z.jsxs)(Zf,{className:`grid w-full grid-cols-3`,children:[(0,z.jsxs)(Qf,{value:`git`,children:[(0,z.jsx)(Ft,{className:`w-4 h-4 mr-2`}),`Git`]}),(0,z.jsxs)(Qf,{value:`npm`,children:[(0,z.jsx)(S,{className:`w-4 h-4 mr-2`}),`NPM`]}),(0,z.jsxs)(Qf,{value:`tarball`,children:[(0,z.jsx)(Ae,{className:`w-4 h-4 mr-2`}),`Tarball`]})]}),(0,z.jsx)($f,{value:`git`,className:`space-y-4 mt-4`,children:(0,z.jsx)(`div`,{className:`space-y-2`,children:(0,z.jsx)(W,{control:e,name:`contents.ref`,render:({field:e})=>(0,z.jsxs)(G,{children:[(0,z.jsx)(K,{className:`pb-1`,children:`Git Repository URL`}),(0,z.jsx)(U,{children:(0,z.jsx)(J,{type:`text`,autoCapitalize:`none`,autoComplete:`off`,autoFocus:!0,...e})}),(0,z.jsx)(q,{})]})})})}),(0,z.jsx)($f,{value:`npm`,className:`space-y-4 mt-4`,children:(0,z.jsx)(`div`,{className:`space-y-2`,children:(0,z.jsx)(W,{control:e,name:`contents.ref`,render:({field:e})=>(0,z.jsxs)(G,{children:[(0,z.jsx)(K,{className:`pb-1`,children:`NPM Package Reference`}),(0,z.jsx)(U,{children:(0,z.jsx)(J,{type:`text`,autoCapitalize:`none`,autoComplete:`off`,autoFocus:!0,...e})}),(0,z.jsx)(q,{})]})})})}),(0,z.jsx)($f,{value:`tarball`,className:`space-y-4 mt-4`,children:(0,z.jsx)(`div`,{className:`space-y-2`,children:(0,z.jsx)(W,{control:e,name:`contents.ref`,render:({field:e})=>(0,z.jsxs)(G,{children:[(0,z.jsx)(K,{className:`pb-1`,children:`Tarball URL`}),(0,z.jsx)(U,{children:(0,z.jsx)(J,{type:`url`,autoCapitalize:`none`,autoComplete:`off`,autoFocus:!0,...e})}),(0,z.jsx)(q,{})]})})})})]}),(0,z.jsx)(W,{control:e,name:`contents.installCommand`,render:({field:e})=>(0,z.jsxs)(G,{children:[(0,z.jsx)(K,{className:`pb-1`,children:`Install Command`}),(0,z.jsx)(U,{children:(0,z.jsx)(J,{type:`text`,autoCapitalize:`none`,autoComplete:`off`,placeholder:`npm install`,...e})}),(0,z.jsx)(q,{})]})}),(0,z.jsx)(K,{children:`Authorization`}),(0,z.jsx)(W,{control:e,name:`contents.requiresAuth`,render:({field:e})=>(0,z.jsxs)(Xf,{className:`w-full pt-2 pb-0 mb-0`,value:String(e.value),onValueChange:t=>e.onChange(t===`true`),children:[(0,z.jsxs)(Zf,{className:`grid w-full grid-cols-2`,children:[(0,z.jsx)(Qf,{value:`false`,children:`Public Access`}),(0,z.jsx)(Qf,{value:`true`,children:`Requires Auth`})]}),(0,z.jsx)($f,{value:`false`,className:`space-y-4 mt-4`}),(0,z.jsx)($f,{value:`true`,className:`space-y-4 mt-4`,children:(0,z.jsx)(ap,{children:(0,z.jsx)(sp,{children:(0,z.jsxs)(`span`,{children:[`You can manage your certificates over in`,` `,(0,z.jsx)(j,{to:`config`,className:`underline`,children:`Config`}),` `,`>`,` `,(0,z.jsx)(j,{to:`config/ssh-keys`,className:`underline`,children:`SSH Keys`}),`. This enables SSH based auth for private repos, i.e. following the pattern of`,` `,(0,z.jsx)(`a`,{href:`https://github.com/HarperFast/Studio`,target:`_blank`,rel:`noreferrer`,className:`underline`,children:`git@github.com:HarperFast/studio.git`}),`. If you have more than one key, make sure to utilize unique hostnames!`]})})})})]})}),(0,z.jsx)(Yf,{className:`bg-black`}),(0,z.jsxs)(B,{className:`w-full`,disabled:!t.isValid||n,children:[(0,z.jsx)(pt,{className:`w-4 h-4 mr-2`}),`Import Application`]})]})]})}var lp=[{id:`vanilla-js`,name:`Web + REST ORM`,description:`Define your entities in schema.graphql, add your HTML/CSS/JS in web, and you're cooking!`,tags:[`Harper`,`ORM`,`REST`,`GraphQL`],npm:`@harperfast/template-vanilla-studio`,githubUrl:`https://github.com/HarperFast/create-harper/tree/main/template-vanilla`},{id:`vanilla-ts`,name:`TypeScript`,description:`The same Web + REST ORM from the first template, but with TypeScript sprinkled in.`,tags:[`Harper`,`TypeScript`,`GraphQL`],npm:`@harperfast/template-vanilla-ts-studio`,githubUrl:`https://github.com/HarperFast/create-harper/tree/main/template-vanilla-ts`}],up=l({type:p(`template`),id:v(`Please select a template.`)}),dp={type:`template`,id:lp[0].id},fp=l({type:p(`import`),source:o([`git`,`npm`,`tarball`]),ref:v().nonempty(`Please enter a URL or package reference.`),installCommand:v(),requiresAuth:_()}),pp={type:`import`,source:`git`,ref:``,requiresAuth:!1,installCommand:``},mp=l({type:p(`cli`)}),hp={type:`cli`},gp=l({applicationName:v().trim().max(75,{error:`Application name cannot be longer than 75 characters.`}).regex(/^[a-zA-Z0-9-_]*$/,{error:`Can only contain letters, numbers, dashes and underscores.`}),contents:s(`type`,[up,fp,mp])});function _p({className:e,...t}){return(0,z.jsx)(Ce,{"data-slot":`radio-group`,className:R(`grid gap-3`,e),...t})}function vp({className:e,...t}){return(0,z.jsx)(nt,{"data-slot":`radio-group-item`,className:R(`border-input text-primary focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 aspect-square size-4 shrink-0 rounded-full border shadow-xs transition-[color,box-shadow] outline-none disabled:cursor-not-allowed disabled:opacity-50`,e),...t,children:(0,z.jsx)(Ye,{"data-slot":`radio-group-indicator`,className:`relative flex items-center justify-center`,children:(0,z.jsx)(ue,{className:`fill-primary absolute top-1/2 left-1/2 size-2 -translate-x-1/2 -translate-y-1/2`})})})}function yp(e){e.stopPropagation()}function bp({control:e,formState:t,isCreatingFromTemplate:n}){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(Si,{children:[(0,z.jsx)(Ci,{children:`Choose a Template`}),(0,z.jsx)(wi,{children:`Start with a pre-configured template for common use cases`})]}),(0,z.jsxs)(Ti,{children:[(0,z.jsx)(W,{control:e,name:`contents.id`,render:({field:e})=>(0,z.jsx)(_p,{value:e.value,onValueChange:e.onChange,children:(0,z.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:lp.map(e=>(0,z.jsxs)(`div`,{className:`relative`,children:[(0,z.jsx)(vp,{value:e.id,id:e.id,className:`peer sr-only`}),(0,z.jsxs)(Ra,{htmlFor:e.id,className:`flex flex-col gap-3 p-4 border-2 rounded-lg cursor-pointer hover:bg-accent peer-data-[state=checked]:border-green peer-data-[state=checked]:bg-primary/5`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsxs)(`div`,{className:`mb-1 flex items-center gap-2 justify-between`,children:[(0,z.jsx)(`div`,{children:e.name}),(0,z.jsx)(`a`,{href:e.githubUrl,target:`_blank`,rel:`noopener noreferrer`,onClick:yp,className:`opacity-70 hover:opacity-100 transition-colors -m-4 p-4`,children:(0,z.jsx)(`img`,{src:`/github/GitHub_Lockup_White.svg`,alt:`GitHub`,className:`h-4`})})]}),(0,z.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:e.description})]}),(0,z.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:e.tags.map(e=>(0,z.jsx)(es,{variant:`outline`,children:e},e))})]})]},e.id))})})}),(0,z.jsx)(Yf,{className:`my-6 bg-black`}),(0,z.jsxs)(B,{className:`w-full`,disabled:!t.isValid||n,children:[(0,z.jsx)(pt,{className:`w-4 h-4 mr-2`}),`Create from Template`]})]})]})}function xp(e){let t=Xi(),{reloadRootEntries:n,setFocusedItem:r,setExpandedItems:i,setSelectedItems:a}=Xd(),o=(0,L.useCallback)(({project:o})=>{let s=k.loading(`Looking for application...`,{description:`This may take a bit.`,duration:3e5});e(!0),n().then(n=>{let c=n?.entries||[];for(let n of c)if(n.name.toLowerCase()===o.toLowerCase()){r(n.name),a([n.name]),i([n.name]),e(!1),k.success(`Imported successfully`,{description:`${o} is now available in your ${t.entityType}!`,id:s,duration:5e3});return}k.warning(`Deployment Not Detected`,{description:`I searched for ${o} but did not find it in the ${t.entityType} yet. Do you see it on the left? Did you use a different name, perhaps?`,id:s,duration:1e4}),e(!1)})},[t,e,n,r,i,a]);return(0,L.useMemo)(()=>({checkCLI:o}),[o])}async function Sp({instanceClient:e,project:t,template:n,entityType:r}){let{data:i}=await e.post(`/`,{operation:`add_component`,project:t,template:n,replicated:r===`cluster`},{timeout:3e5});return i}function Cp(){return E({mutationFn:Sp})}function wp(e){let{mutate:t,isPending:n}=Cp(),r=Xi(),{reloadRootEntries:i,setFocusedItem:a,setExpandedItems:o,setSelectedItems:s}=Xd(),c=(0,L.useCallback)(({contents:n,project:c})=>{let l=k.loading(`Creating from template...`,{description:`This may take a bit.`,duration:3e5}),u=ep(lp,`id`,n.id);if(!u)return k.error(`Template Not Found`,{description:`Please select a template`,duration:1e4,id:l});t({project:c,template:u.npm||u.githubUrl,...r},{onSuccess:()=>{k.success(`Created successfully!`,{description:`${c} will be available once you restart your ${r.entityType}!`,id:l,duration:5e3}),e(!0),i(),a(c),s([c]),o([c])}})},[t,r,e,i,a,o,s]);return(0,L.useMemo)(()=>({isCreatingFromTemplate:n,createFromTemplate:c}),[n,c])}async function Tp({applicationName:e,applicationUrl:t,installCommand:n,entityType:r,instanceClient:i}){let{data:a}=await i.post(`/`,{operation:`deploy_component`,package:t,project:e,replicated:r===`cluster`,install_command:n||void 0,restart:`rolling`},{timeout:3e5});return a}function Ep(){return E({mutationFn:Tp})}function Dp(e){let{mutate:t,isPending:n}=Ep(),r=Vt(),i=V(),{reloadRootEntries:a,setFocusedItem:o,setExpandedItems:s,setSelectedItems:c}=Xd(),l=(0,L.useCallback)(({contents:n,project:l})=>{let u=k.loading(`Importing application...`,{description:`This may take a bit.`,duration:3e5});t({applicationName:l,applicationUrl:n.ref,installCommand:n.installCommand,...i},{onSuccess:()=>{k.success(`Imported successfully`,{description:`${l} will be available once you restart your ${i.entityType}!`,id:u,duration:5e3}),e(!0),r.invalidateQueries({queryKey:[i.entityId]}),a(),o(l),c([l]),s([l])},onError:()=>{k.dismiss(u)}})},[t,r,i,e,a,o,s,c]);return(0,L.useMemo)(()=>({isImportingApplication:n,importApplication:l}),[n,l])}function Op(){let{rootEntries:e}=Xd(),{organization:t,instance:n,cluster:r}=Nt({strict:!1}),i=(0,L.useMemo)(()=>{let i=ec(r?.name||n?.name||t?.name||``);if(i===``)return i;let a=i,o=1;for(;ep(e,`name`,a);)o+=1,a=`${i}-${o}`;return a},[e,r,n,t]),a=(0,L.useCallback)((t,n)=>{!t.applicationName&&!i?n.addIssue({code:`custom`,path:[`applicationName`],message:`Please name your application!`}):e.find(e=>e.name===t.applicationName)&&n.addIssue({code:`custom`,path:[`applicationName`],message:`That application name is already in use!`})},[i,e]),o=N({resolver:w(gp.superRefine(a)),defaultValues:{applicationName:``,contents:{...pp,...hp,...dp}}}),{watch:s,handleSubmit:c,control:l,setValue:u,formState:d,trigger:f}=o,[p,m]=(0,L.useState)(!1),{isCreatingFromTemplate:h,createFromTemplate:g}=wp(m),{isImportingApplication:_,importApplication:v}=Dp(m),{checkCLI:y}=xp(m),b=(0,L.useCallback)(e=>{let t=e.applicationName||i;switch(e.contents.type){case`template`:g({contents:e.contents,project:t});break;case`import`:v({contents:e.contents,project:t});break;case`cli`:y({contents:e.contents,project:t});break}},[y,g,i,v]),x=s(`contents.type`),ee=(0,L.useCallback)(e=>{let t=d.isValid;u(`contents.type`,e),t||f()},[u,d,f]);return(0,z.jsxs)(`div`,{className:`mx-auto max-w-4xl mt-6`,children:[(0,z.jsxs)(`div`,{className:`text-center`,children:[(0,z.jsx)(`h1`,{className:`text-4xl pt-4 pb-2`,children:`Bootstrap New API Application`}),(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:`Create a new application from templates, import existing code, or deploy with Harper CLI`})]}),(0,z.jsx)(H,{...o,children:(0,z.jsx)(`form`,{id:`instance-add-application-form`,name:`instance-add-application-form`,onSubmit:c(b),className:`flex flex-col gap-4 p-4`,children:(0,z.jsxs)(`fieldset`,{disabled:_||h||p,children:[(0,z.jsx)(xi,{className:`bg-black-dark`,children:(0,z.jsx)(rp,{control:l,defaultApplicationName:i})}),(0,z.jsx)(xi,{className:`bg-black-dark mt-4 pt-0`,children:(0,z.jsxs)(Xf,{defaultValue:x,onValueChange:ee,children:[(0,z.jsxs)(Zf,{className:`w-full grid grid-cols-3 mt-0`,children:[(0,z.jsxs)(Qf,{value:`template`,children:[(0,z.jsx)(be,{}),(0,z.jsx)(`span`,{className:`hidden sm:inline-block`,children:`Templates`})]}),(0,z.jsxs)(Qf,{value:`import`,children:[(0,z.jsx)(zt,{}),`Import`]}),(0,z.jsxs)(Qf,{value:`cli`,children:[(0,z.jsx)(cr,{}),(0,z.jsx)(`span`,{className:`hidden md:inline-block`,children:`Harper`}),` CLI`]})]}),(0,z.jsx)(`div`,{className:`mx-6 mt-1`,children:(0,z.jsx)(Yf,{className:`bg-black`})}),(0,z.jsx)($f,{value:`template`,className:`space-y-4`,children:(0,z.jsx)(bp,{control:l,formState:d,isCreatingFromTemplate:h})}),(0,z.jsx)($f,{value:`import`,className:`space-y-4`,children:(0,z.jsx)(cp,{control:l,formState:d,isImportingApplication:_,setValue:u,watch:s})}),(0,z.jsx)($f,{value:`cli`,className:`space-y-4`,children:(0,z.jsx)(np,{defaultApplicationName:i,formState:d,watch:s})})]})})]})})})]})}var kp={js:`javascript`,cjs:`javascript`,jsx:`javascript`,yaml:`yaml`,ts:`typescript`,tsx:`typescript`,json:`json`,md:`markdown`,html:`html`,css:`css`,graphql:`graphql`,mjs:`javascript`};function Ap(){let e=V(),{openedEntryContents:t,openedEntry:n,restrictPackageModification:r,isSavingFile:i,saveFile:a}=Xd(),{content:o,setContent:s}=Nf(!!n&&!n.package&&n.path),c=(0,L.useCallback)(e=>{s(e===t?void 0:e)},[t,s]),l=ua(),[u,d]=(0,L.useState)(null),f=kp[Qd(n?.path)]||`plaintext`,p=(0,L.useCallback)((e,t)=>{d([e,t])},[]);if((0,L.useEffect)(()=>{if(u&&l&&!n?.package&&!r)return gf(u)},[u,l,n,r]),Vd(`SaveFile`,()=>{n&&!i&&o!==void 0&&a({...e,file:n.path.split(`/`).slice(1).join(`/`),payload:o,project:n.project},n.path)},[n,e,o]),Vd(`RevertChanges`,()=>{if(t!==void 0&&u){let[e]=u;c(void 0),e.setValue(t)}},[t,u]),!n)return null;let m=i||!!n.package||!l;return(0,z.jsx)(Be,{className:`w-full min-h-full h-80`,language:f,theme:`vs-dark`,value:o??t,onMount:p,onChange:m?void 0:c,options:{automaticLayout:!0,minimap:{enabled:!1},readOnly:m,padding:{top:48}}})}function jp(){let{openedEntry:e,openedEntryContents:t}=Xd(),n=Jf(e?.project);return e?.path===`newApplication`?(0,z.jsx)(Op,{}):Sf(e)?(0,z.jsx)(`div`,{className:`directoryReadMe max-w-3xl`,children:(0,z.jsx)(Tt,{urlTransform:n,remarkPlugins:[qr],components:{code:Np},children:t})}):$d(e?.name)?(0,z.jsx)(`div`,{className:`mt-9 absolute top-0 right-0 bottom-0 left-0`,children:(0,z.jsx)(`img`,{className:`w-full h-full object-contain p-20`,alt:e?.name,src:`data:image/${Qd(e?.name)};base64,${t}`})}):(0,z.jsx)(Ap,{})}function Mp({chart:e}){let t=(0,L.useRef)(null),[n,r]=(0,L.useState)(``),[i,a]=(0,L.useState)(null);return(0,L.useEffect)(()=>{let t=`mermaid-${Math.random().toString(36).slice(2,9)}`,n=!1;return Gr(async()=>{let{default:e}=await import(`./vendor-viz-BdK5B9uw.js`).then(e=>e.t);return{default:e}},__vite__mapDeps([12,1,2,4,3,5,6,7,8,9,10])).then(({default:i})=>{n||(i.initialize({startOnLoad:!1,theme:`default`}),i.render(t,e).then(({svg:e})=>{n||(r(e),a(null))}).catch(e=>{n||(console.error(`Mermaid render error:`,e),a(String(e)))}))}),()=>{n=!0}},[e]),i?(0,z.jsx)(`pre`,{className:`text-red-500 bg-red-50 p-3 rounded text-sm overflow-auto`,children:(0,z.jsx)(`code`,{children:e})}):(0,z.jsx)(`div`,{ref:t,className:`my-4 flex justify-center overflow-auto`,dangerouslySetInnerHTML:{__html:n}})}function Np({inline:e,className:t,children:n}){let r=String(n??``).replace(/\n$/,``),[i]=ms(r),a=t?.replace(`language-`,``);return e||!r.includes(`
40
- `)?(0,z.jsx)(`code`,{className:t,children:n}):a===`mermaid`?(0,z.jsx)(Mp,{chart:r}):(0,z.jsxs)(`code`,{className:`relative`,children:[(0,z.jsx)(B,{className:`absolute top-2 right-2`,type:`button`,variant:`default`,size:`sm`,onClick:i,children:(0,z.jsx)(hn,{className:`w-4 h-4`})}),r]})}function Pp(e){return new URL(e.match(/^https?:\/\//i)?e:`https://${e}`).toString()}function Fp(e){if(e?.domains){for(let t of e.domains)if(t.domain)return Pp(t.domain)}return e?.fqdn?Pp(e.fqdn):null}function Ip(){let{clusterId:e,instanceId:t}=M({strict:!1}),n=Yi(),{data:r}=D(Ka(e));return e&&I.checkForFabricConnect(e)||t&&I.checkForFabricConnect(t)||r&&!t?Fp(r):n.defaults.baseURL?n.defaults.baseURL.replace(/:9925\/?/,``):null}function Lp(e,t,n,r=[]){let i=[];for(let a of e){let e=n(a,r);i.push(e);let o=a,s=o[t];s&&(e[t]=Lp(s,t,n,[...r,o]))}return i}function Rp(e){let t=new Set;return{rootEntries:Lp(e||[],`entries`,(e,n)=>{let r=Sf(e)&&e.entries.find(e=>e.name.toLowerCase()===`readme.md`),i=[...n.map(e=>e.name),e.name].join(`/`);return t.add(i),{name:e.name,path:i,project:(n[0]||e)?.name,package:(n[0]||e)?.package,overviewEntry:r&&!Sf(r)&&{name:r.name,path:[...n.map(e=>e.name),e.name,r.name].join(`/`),project:(n[0]||e)?.name,package:(n[0]||e)?.package}||void 0}}),pathsRegistry:t}}function zp(e,t,n){let r=t,i=t.replace(/:9925/,``).replace(/\/?$/,``);return r&&(e=e.replaceAll(/https?:\/\/localhost:9926/g,i)),n.project&&(e=e.replaceAll(`Your New Harper Fabric App`,n.project).replaceAll(`your-project-name-here`,n.project)),e}async function Bp({instanceClient:e}){let{data:t}=await e.post(`/`,{operation:`get_components`});return t}function Vp(e){return A({queryKey:[e.entityId,`get_components`],queryFn:()=>Bp(e),retry:!1})}function Hp({children:e}){let t=T(),[n,r]=(0,L.useState)(void 0),[i,a]=(0,L.useState)(void 0),{setContent:o}=Nf(n?.path),s=V(),c=Ip(),l=Vt(),{open:u}=zn({strict:!1}),{data:d}=Nn(Vp(s)),f=(0,L.useMemo)(()=>Rp(d.entries),[d]),p=(0,L.useCallback)(async()=>l.fetchQuery({queryKey:[s.entityId,`get_components`],networkMode:`online`}),[l,s]);Vd(`ReloadApplicationRootEntries`,p,[p]);let m=(0,L.useCallback)(e=>f.pathsRegistry.has(e),[f.pathsRegistry]),h=f.rootEntries.filter(e=>!e.package&&e.path!==`newApplication`).map(e=>e.name),g=h[0],_=h.slice(0,1);g||(g=Tf,_=[Tf]);let[v,y]=qd(`FileFocused/${s.entityId}`,g),[b,x]=qd(`FolderOpened/${s.entityId}`,h),[ee,te]=qd(`FileSelected/${s.entityId}`,_);(0,L.useEffect)(()=>{if(u?.length){let e=u.split(`?`),n=e[0],r=e[1],i=n.split(`/`);if(r){let e=r.split(`=`);uf(e[0],e[1]===`true`?!0:e[1]===`false`?!1:e[1])}x(e=>{let t=new Set(e);for(let e=1;e<i.length;e++)t.add(i.slice(0,e).join(`/`));return[...t]}),te([n]),y(n),t({search:void 0})}},[t,u,x,y,te]);let ne=n&&(Sf(n)?n.overviewEntry?.path:n.path)||``,re=n&&(Sf(n)?n.overviewEntry?.project:n.project)||``,ie=n&&(Sf(n)?!!n.overviewEntry?.path:!1)||!1,S=nf({file:ne?.split(`/`).slice(1).join(`/`),project:re,...s}),{data:ae}=D(tf({file:ne?.split(`/`).slice(1).join(`/`),project:re,...s}));(0,L.useEffect)(function(){let e=ae?.project+`/`+ae?.file,t=ae?.message;e===ne&&t!==void 0?(ie&&c&&ae&&(t=zp(t,c,ae)),a(t)):a(void 0)},[ae,ne,ie,s]);let{mutate:oe,isPending:se}=af(),ce=(0,L.useCallback)((e,t)=>{oe(e,{onSuccess:()=>{n?.path===t&&e.payload!==void 0&&(o(void 0),a(e.payload||void 0),l.setQueryData(S,{...ae,message:e.payload}))},onError:e=>{console.error(`Error saving file:`,e)}})},[S,ae,n?.path,l,oe,o]),le=(0,L.useMemo)(()=>n?n.package?.includes(`github.com/HarperDB/status-check-fabric`)||n.package?.includes(`github.com/HarperFast/status-check-fabric`)||n.path===`importedApplications`||n.path===`newApplication`:!1,[n]),ue=(0,L.useMemo)(()=>({rootEntries:f.rootEntries,reloadRootEntries:p,entryExists:m,focusedItem:v,setFocusedItem:y,expandedItems:b,setExpandedItems:x,selectedItems:ee,setSelectedItems:te,restrictPackageModification:le,openedEntry:n,setOpenedEntry:r,openedEntryContents:i,setOpenedEntryContents:a,saveFile:ce,isSavingFile:se}),[f.rootEntries,p,m,v,y,b,x,ee,te,le,n,r,i,a,ce,se]);return(0,z.jsx)(Yd.Provider,{value:ue,children:e})}function Up(e){let t=e;if(t?.focus)Wp(t);else{let t=e;t?.target?.focus&&Wp(t.target)}}function Wp(e){ri(1).then(()=>{e.focus?.()})}function Gp(){let{value:e,trigger:t}=lf(`ShowAddDirectoryOrFileModalType`,!1),n=(0,L.useCallback)(()=>{uf(`ShowAddDirectoryOrFileModalType`,!1),Up(t)},[t]),{openedEntry:r,entryExists:i,reloadRootEntries:a,setFocusedItem:o,setSelectedItems:s,setExpandedItems:c}=Xd(),l=V(),{mutate:u,isPending:f}=af(),p=N({resolver:w(d.object({name:d.string().nonempty({error:`Please enter a valid name.`}).regex(/^[a-zA-Z0-9_\- .]*$/,{error:`Names can only contain letters, numbers, underscores, hyphens, periods, and spaces.`}).max(50,{error:`Names cannot be longer than 50 characters.`}).trim()})),defaultValues:{name:``}}),m=(0,L.useCallback)(t=>{if(!r||!e)return;let d=r.path.split(`/`),f=(Sf(r)?d.slice(1):d.slice(1,-1)).join(`/`),m=f?`${f}/${t.name}`:t.name;if(i(r.project+`/`+m)){k.error(`${Ma(e)} already exists!`,{description:m});return}u({file:m,project:r.project,payload:e===`directory`?void 0:``,...l},{onSuccess:()=>{a(),n(),p.reset();let i=[r.project,f,t.name].filter(Ni).join(`/`);o(i),s([i]),e===`directory`&&c(e=>[...e,i])}})},[u,p,n,l,r,i,a,c,o,s,e]),h=(0,L.useCallback)(()=>{n(),p.reset()},[n,p]);return(0,z.jsx)(Y,{onOpenChange:n,open:!!e,children:(0,z.jsx)(X,{"aria-describedby":void 0,className:`text-white`,children:(0,z.jsx)(H,{...p,children:(0,z.jsxs)(`form`,{id:`instance-add-app-${e}-form`,name:`instance-add-app-${e}-form`,onSubmit:p.handleSubmit(m),children:[(0,z.jsxs)(Zo,{children:[(0,z.jsxs)(Q,{children:[`Add `,e]}),(0,z.jsxs)(Qo,{children:[`Enter the name of the `,e,` you want to add`,e===`file`?`, don't forget the extension`:``,`!`]})]}),(0,z.jsx)(W,{control:p.control,name:`name`,render:({field:e})=>(0,z.jsxs)(G,{className:`my-2`,children:[(0,z.jsx)(K,{children:`Name`}),(0,z.jsx)(U,{children:(0,z.jsx)(J,{disabled:f,type:`text`,autoComplete:`off`,autoCapitalize:`off`,...e})}),(0,z.jsx)(q,{})]})}),(0,z.jsx)(Z,{children:(0,z.jsxs)(`div`,{className:`flex justify-between w-full`,children:[(0,z.jsx)(B,{type:`button`,variant:`ghostOutline`,className:`rounded-full`,onClick:h,children:`Cancel`}),(0,z.jsxs)(B,{variant:`positiveOutline`,type:`submit`,className:`rounded-full`,disabled:f,children:[(0,z.jsx)(C,{}),` Add `,e]})]})})]})})})})}function Kp(){let{value:e,trigger:t}=lf(`ShowDeleteDirectoryOrFileModal`,!1),n=V(),{openedEntry:r,reloadRootEntries:i,setFocusedItem:a,setSelectedItems:o,selectedItems:s}=Xd(),c=s.length>1,l=Sf(r),u=l&&r.path===r.project,d=!!r?.package,f=d?`Remove`:`Delete`,p=d?`Imported Application`:u?`Application`:l?`Directory`:`File`,m=(0,L.useCallback)(()=>{uf(`ShowDeleteDirectoryOrFileModal`,!1),Up(t)},[t]),h=(0,L.useCallback)(async()=>{m();let e=[],t=0,r=!1,c={label:`Cancel`,onClick:()=>{r=!0}},l={label:`OK`,onClick:()=>void 0},u=`deleting-files`;for(let i of s.reverse()){e=i.split(`/`);let a=e[0],o=e.length>1?e.slice(1).join(`/`):void 0;if(k.loading(`${f} in progress...`,{id:u,description:`${t} of ${Qr(s.length,`item`,`items`)}`,action:c}),await Zd({file:o,project:a,...n}),r)break;t+=1}if(r?k.warning(`${f} canceled!`,{id:u,description:``,action:l}):k.success(`${f} completed!`,{id:u,description:``,action:l}),e.length){let t=e.slice(0,-1).join(`/`);a(t||void 0),o(t?[t]:[]),i()}},[f,m,n,i,s,a,o]),g=(0,L.useCallback)(e=>{e.preventDefault(),h()},[h]);return(0,z.jsx)(Y,{onOpenChange:m,open:e,children:(0,z.jsxs)(X,{"aria-describedby":void 0,className:`text-white`,children:[(0,z.jsxs)(Zo,{children:[(0,z.jsxs)(Q,{children:[f,` `,p]}),(0,z.jsxs)(Qo,{children:[`Are you sure you want to `,f.toLowerCase(),` `,c?`these ${s.length} items`:`this ${p.toLowerCase()}`,`?`]}),!d&&(0,z.jsx)(Qo,{className:`whitespace-pre`,children:c?s.join(`
41
- `):r?.path})]}),(0,z.jsxs)(`div`,{className:`flex w-full gap-4`,children:[(0,z.jsx)(B,{type:`button`,variant:`ghostOutline`,className:`w-full rounded-full`,onClick:m,children:`Cancel`}),(0,z.jsxs)(B,{variant:`destructiveOutline`,type:`button`,className:`w-full rounded-full`,autoFocus:!0,onClick:g,children:[(0,z.jsx)($t,{}),` `,f,` `,c?`items`:p]})]})]})})}async function qp({packageName:e,project:t,skipNodeModules:n,skipSymlinks:r,instanceClient:i}){let{data:a}=await i.post(`/`,{operation:`package_component`,package:e,project:t,skip_node_modules:n,skip_symlinks:r},{timeout:3e5});return a}function Jp(){return E({mutationFn:qp})}function Yp(){let{value:e,trigger:t}=lf(`ShowDownloadApplicationModal`,!1),n=V(),{openedEntry:r}=Xd(),{mutate:i,isPending:a,isSuccess:o}=Jp(),s=o?`Downloaded`:a?`Downloading`:`Download`,[c,l]=(0,L.useState)(!1),u=(0,L.useCallback)(e=>{l(e.target.checked)},[]),d=(0,L.useCallback)(()=>{uf(`ShowDownloadApplicationModal`,!1),Up(t)},[t]),f=(0,L.useCallback)(e=>{if(e.preventDefault(),!r)return;d();let t=k.loading(`Packaging...`);i({packageName:r.package,project:r.project,skipNodeModules:!c,...n},{onSuccess:e=>{k.success(`Download ready!`,{id:t});let n=document.createElement(`a`);n.setAttribute(`class`,`invisible absolute top-0`);let i=Uint8Array.from(atob(e.payload),e=>e.charCodeAt(0)),a=new Blob([i],{type:`application/gzip`});n.href=URL.createObjectURL(a),n.download=`${r.project}.gz`,document.body.appendChild(n),n.click(),document.body.removeChild(n)}})},[r,i,c,n,d]);return(0,z.jsx)(Y,{onOpenChange:d,open:e,children:(0,z.jsxs)(X,{"aria-describedby":void 0,className:`text-white`,children:[(0,z.jsxs)(Zo,{children:[(0,z.jsx)(Q,{children:`Download Application`}),(0,z.jsxs)(Qo,{children:[`This will package up the contents of `,(0,z.jsx)(`strong`,{children:r?.project}),` into a gzipped file.`]})]}),(0,z.jsxs)(Ra,{className:`flex`,children:[(0,z.jsx)(J,{type:`checkbox`,className:`w-6`,disabled:a,checked:c,onChange:u}),(0,z.jsx)(`span`,{className:`pl-4 pr-8 flex-1 py-2.5`,children:`Include Node Modules`})]}),(0,z.jsxs)(`div`,{className:`flex w-full gap-4`,children:[(0,z.jsx)(B,{type:`button`,variant:`ghostOutline`,className:`w-full rounded-full`,onClick:d,children:`Cancel`}),(0,z.jsxs)(B,{variant:`positive`,type:`button`,className:`w-full rounded-full`,disabled:a,autoFocus:!0,onClick:f,children:[(0,z.jsx)(cn,{}),` `,s,a?`...`:``]})]})]})})}function Xp(e=!1){let[t,n]=(0,L.useState)(e),r=(0,L.useCallback)(e=>{e?.preventDefault?.(),n(e=>!e)},[]),i=(0,L.useCallback)(e=>{e?.preventDefault?.(),n(!0)},[]),a=(0,L.useCallback)(e=>{e?.preventDefault?.(),n(!1)},[]);return(0,L.useMemo)(()=>({toggled:t,setToggled:n,toggle:r,toggleOn:i,toggleOff:a}),[r,n,a,i,t])}function Zp({field:e}){let{toggled:t,toggle:n}=Xp(!1);return(0,z.jsxs)(G,{className:`my-4`,children:[(0,z.jsxs)(K,{onClick:n,className:i(`flex items-center gap-2`,t?``:`text-muted-foreground italic`),children:[t?(0,z.jsx)(we,{}):(0,z.jsx)(vt,{}),` Optional Database Name`]}),(0,z.jsx)(Bc,{className:t?``:`hidden`,children:`"data" is the default recommended name`}),(0,z.jsx)(U,{className:t?``:`hidden`,children:(0,z.jsx)(J,{type:`text`,className:`my-1`,...e})}),(0,z.jsx)(q,{})]})}var Qp=function(e){return e.Any=`Any`,e.BigInt=`BigInt`,e.Blob=`Blob`,e.Boolean=`Boolean`,e.Bytes=`Bytes`,e.Date=`Date`,e.Float=`Float`,e.ID=`ID`,e.Int=`Int`,e.Long=`Long`,e.String=`String`,e}({}),$p=/^[\x20-\x2E|\x30-\x5F|\x61-\x7E]*$/,em=v().regex($p,{error:`Database name cannot include backticks or forward slashes.`}).max(75,{error:`Database name cannot be longer than 75 characters.`}),tm=v().nonempty({error:`Field name is required.`}).regex($p,{error:`Field name cannot include backticks or forward slashes.`}).max(250,{error:`Field name cannot be longer than 250 characters.`}),nm=v().nonempty({error:`Table name is required.`}).regex($p,{error:`Table name cannot include backticks or forward slashes.`}).max(250,{error:`Table name cannot be longer than 250 characters.`}),rm=l({tableName:nm,databaseName:em,expiration:h().or(p(``)),enableRest:_(),sealed:_(),tableFields:f(l({fieldName:tm,fieldType:o(Qp),primaryKey:_(),nullable:_(),indexed:_(),array:_()})).min(1,{error:`Please add at least one field.`})});function im({field:e}){let{toggled:t,toggle:n}=Xp(!1),r=(0,L.useCallback)(t=>e.onChange(t.target.value?parseInt(t.target.value,10):t.target.value),[]);return(0,z.jsxs)(G,{className:`my-4`,children:[(0,z.jsxs)(K,{onClick:n,className:i(`flex items-center gap-2`,t?``:`text-muted-foreground italic`),children:[t?(0,z.jsx)(we,{}):(0,z.jsx)(vt,{}),` Optional Expiration`]}),(0,z.jsx)(Bc,{className:t?``:`hidden`,children:`After how many seconds should records be automatically evicted? Leave blank or set to 0 to skip this feature. (It can be useful for cache records.)`}),(0,z.jsx)(U,{className:t?``:`hidden`,children:(0,z.jsx)(J,{...e,type:`number`,min:0,step:1,className:`my-1`,onChange:r})}),(0,z.jsx)(q,{})]})}function am(){let e=ff(`ShowNewTableModal`,!1),{openedEntry:t,openedEntryContents:n}=Xd(),{setContent:r}=Nf(!!t&&!t.package&&t.path),i=N({resolver:w(rm),defaultValues:{tableName:``,databaseName:`data`,expiration:``,enableRest:!0,sealed:!0,tableFields:[{fieldName:`id`,fieldType:Qp.ID,primaryKey:!0,nullable:!0,indexed:!1,array:!1}]}}),{control:a,handleSubmit:o,formState:s}=i,{fields:c,append:l,remove:u}=ct({name:`tableFields`,control:a}),d=(0,L.useCallback)(()=>{l({fieldName:``,fieldType:Qp.String,primaryKey:!1,nullable:!1,indexed:!1,array:!1})},[l]),f=(0,L.useCallback)(async t=>{r(e=>{let r=e||n||``,i=[!!t.databaseName&&t.databaseName!==`data`&&`database: "${t.databaseName}"`,!!t.expiration&&t.expiration>0&&`expiration: ${t.expiration}`].filter(Ni),a=i.length?`(${i.join(`, `)})`:``,o=t.enableRest?` @export`:``,s=t.sealed?` @sealed`:``,c=t.tableFields.map(e=>{let t=e.array?`[${e.fieldType}]`:e.fieldType,n=e.nullable?``:`!`,r=e.primaryKey?` @primaryKey`:``,i=e.indexed?` @indexed`:``;return`\n\t${e.fieldName}: ${t}${n}${r}${i}`}).join(``);return`${r}\ntype ${t.tableName} @table${a}${o}${s} {${c}\n}\n`}),e()},[r,e,n]);return(0,z.jsx)(H,{...i,children:(0,z.jsxs)(`form`,{id:`instance-new-app-table-form`,name:`instance-new-app-table-form`,onSubmit:o(f),children:[(0,z.jsx)(W,{control:a,name:`tableName`,render:({field:e})=>(0,z.jsxs)(G,{className:`my-4`,children:[(0,z.jsx)(K,{children:`Table Name`}),(0,z.jsx)(U,{children:(0,z.jsx)(J,{type:`text`,className:`my-1`,...e})}),(0,z.jsx)(q,{})]})}),(0,z.jsx)(`h3`,{className:`text-lg`,children:`Table Fields`}),c.map((e,t)=>(0,z.jsxs)(`div`,{className:`p-4 my-2 border rounded-lg`,children:[(0,z.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,z.jsx)(W,{control:a,name:`tableFields.${t}.fieldName`,render:({field:e})=>(0,z.jsxs)(G,{children:[(0,z.jsx)(K,{children:`Field Name`}),(0,z.jsx)(U,{children:(0,z.jsx)(J,{type:`text`,...e})}),(0,z.jsx)(q,{})]})}),(0,z.jsx)(W,{control:a,name:`tableFields.${t}.fieldType`,render:({field:e})=>(0,z.jsxs)(G,{children:[(0,z.jsx)(K,{children:`Type`}),(0,z.jsx)(U,{children:(0,z.jsxs)(Dc,{...e,onValueChange:e.onChange,defaultValue:e.value,children:[(0,z.jsx)(Ac,{className:`w-full`,children:(0,z.jsx)(kc,{})}),(0,z.jsxs)(jc,{children:[(0,z.jsx)($,{value:`Any`,children:`Any`}),(0,z.jsx)($,{value:`BigInt`,children:`BigInt`}),(0,z.jsx)($,{value:`Blob`,children:`Blob`}),(0,z.jsx)($,{value:`Boolean`,children:`Boolean`}),(0,z.jsx)($,{value:`Bytes`,children:`Bytes`}),(0,z.jsx)($,{value:`Date`,children:`Date`}),(0,z.jsx)($,{value:`Float`,children:`Float`}),(0,z.jsx)($,{value:`ID`,children:`ID`}),(0,z.jsx)($,{value:`Int`,children:`Int`}),(0,z.jsx)($,{value:`Long`,children:`Long`}),(0,z.jsx)($,{value:`String`,children:`String`})]})]})}),(0,z.jsx)(q,{})]})})]}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center mt-2 gap-x-2 md:gap-x-4`,children:[(0,z.jsx)(W,{control:a,name:`tableFields.${t}.indexed`,render:({field:e})=>(0,z.jsxs)(G,{className:`inline-flex`,children:[(0,z.jsx)(U,{children:(0,z.jsx)(J,{type:`checkbox`,className:`w-5`,checked:e.value,onChange:t=>e.onChange(t.target.checked)})}),(0,z.jsx)(K,{className:`flex-1 py-2.5`,children:`Indexed`}),(0,z.jsx)(q,{})]})}),(0,z.jsx)(W,{control:a,name:`tableFields.${t}.primaryKey`,render:({field:e})=>(0,z.jsxs)(G,{className:`inline-flex`,children:[(0,z.jsx)(U,{children:(0,z.jsx)(J,{type:`checkbox`,className:`w-5`,checked:e.value,onChange:t=>e.onChange(t.target.checked)})}),(0,z.jsx)(K,{className:`flex-1 py-2.5`,children:`Primary Key`}),(0,z.jsx)(q,{})]})}),(0,z.jsx)(W,{control:a,name:`tableFields.${t}.nullable`,render:({field:e})=>(0,z.jsxs)(G,{className:`inline-flex`,children:[(0,z.jsx)(U,{children:(0,z.jsx)(J,{type:`checkbox`,className:`w-5`,checked:e.value,onChange:t=>e.onChange(t.target.checked)})}),(0,z.jsx)(K,{className:`flex-1 py-2.5`,children:`Nullable`}),(0,z.jsx)(q,{})]})}),(0,z.jsx)(W,{control:a,name:`tableFields.${t}.array`,render:({field:e})=>(0,z.jsxs)(G,{className:`inline-flex`,children:[(0,z.jsx)(U,{children:(0,z.jsx)(J,{type:`checkbox`,className:`w-5`,checked:e.value,onChange:t=>e.onChange(t.target.checked)})}),(0,z.jsx)(K,{className:`flex-1 py-2.5`,children:`Array`}),(0,z.jsx)(q,{})]})}),(0,z.jsx)(`div`,{className:`grow`}),(0,z.jsxs)(B,{type:`button`,variant:`destructiveGhost`,className:`rounded-full`,onClick:()=>u(t),children:[(0,z.jsx)($t,{}),` Remove Field`]})]})]},e.id)),(0,z.jsxs)(B,{variant:`ghost`,type:`button`,className:`w-full`,onClick:d,children:[(0,z.jsx)(C,{}),` Add Another Field`]}),(0,z.jsx)(`hr`,{className:`my-6 border-gray-600`}),(0,z.jsx)(W,{control:a,name:`databaseName`,render:({field:e})=>(0,z.jsx)(Zp,{field:e})}),(0,z.jsx)(W,{control:a,name:`expiration`,render:({field:e})=>(0,z.jsx)(im,{field:e})}),(0,z.jsx)(W,{control:a,name:`enableRest`,render:({field:e})=>(0,z.jsxs)(G,{className:`flex`,children:[(0,z.jsx)(U,{children:(0,z.jsx)(J,{type:`checkbox`,className:`w-5`,checked:e.value,onChange:t=>e.onChange(t.target.checked)})}),(0,z.jsxs)(K,{className:`flex-1 py-2.5`,children:[`Make available as a REST endpoint (add`,` `,(0,z.jsx)(`code`,{className:`text-muted-foreground italic ml-1`,children:`@export`}),`)`]}),(0,z.jsx)(q,{})]})}),(0,z.jsx)(W,{control:a,name:`sealed`,render:({field:e})=>(0,z.jsxs)(G,{className:`flex`,children:[(0,z.jsx)(U,{children:(0,z.jsx)(J,{type:`checkbox`,className:`w-5`,checked:e.value,onChange:t=>e.onChange(t.target.checked)})}),(0,z.jsxs)(K,{className:`flex-1 py-2.5`,children:[`Sealed (add`,(0,z.jsx)(`code`,{className:`text-muted-foreground italic ml-1`,children:`@sealed`}),` to ignore unspecified properties)`]}),(0,z.jsx)(q,{})]})}),(0,z.jsxs)(`div`,{className:`text-muted-foreground italic text-sm pb-2`,children:[`There are even more directives available to you when editing your schema.graphql by hand! You can read more about them`,` `,(0,z.jsx)(`a`,{className:`underline`,target:`_blank`,rel:`noreferrer`,href:`https://docs.harperdb.io/docs/developers/applications/defining-schemas`,children:`in our documentation`}),`.`]}),(0,z.jsxs)(`div`,{className:`flex w-full gap-4 sticky -bottom-6 pb-6 pt-4 bg-black`,children:[(0,z.jsxs)(B,{type:`button`,variant:`ghost`,className:`w-full rounded-full`,onClick:e,children:[(0,z.jsx)(oe,{}),` Cancel`]}),(0,z.jsxs)(B,{variant:`positive`,type:`submit`,className:`w-full rounded-full`,disabled:!s.isValid,children:[(0,z.jsx)(C,{}),` New Table`]})]})]})})}function om(){let{value:e,trigger:t}=lf(`ShowNewTableModal`,!1);return(0,z.jsx)(Y,{onOpenChange:(0,L.useCallback)(()=>{uf(`ShowNewTableModal`,!1),Up(t)},[t]),open:e,children:(0,z.jsxs)(X,{"aria-describedby":void 0,className:`text-white`,children:[(0,z.jsxs)(Zo,{children:[(0,z.jsx)(Q,{children:`New Table`}),(0,z.jsx)(Qo,{children:`Creating a table is the basis of a data-driven application and can immediately be used as RESTful endpoints. This can also be configured as a caching table and extended and customized for specific endpoint behavior.`})]}),(0,z.jsx)(am,{})]})})}function sm(){let{value:e,trigger:t}=lf(`ShowRedeployApplicationModal`,!1),n=Vt(),r=V(),{openedEntry:i}=Xd(),a=i?.package,{mutate:o,isPending:s}=Ep(),c=N({defaultValues:{applicationUrl:a,installCommand:``}}),{control:l,handleSubmit:u,reset:d}=c;(0,L.useEffect)(()=>{d({applicationUrl:a})},[d,a]);let f=(0,L.useCallback)(()=>{uf(`ShowRedeployApplicationModal`,!1),Up(t),d({applicationUrl:a})},[d,a,t]),p=(0,L.useCallback)((e,t)=>{if(!i)return;f();let a=k.loading(`Redeploying...`);o({applicationName:i.project,applicationUrl:e,installCommand:t,...r},{onSuccess:()=>{k.success(`Application ${i.project} redeployed successfully`,{id:a}),n.invalidateQueries({queryKey:[r.entityId,`get_components`],refetchType:`active`})},onError:()=>{k.dismiss(a)}})},[o,i,r,n,f]),m=({applicationUrl:e,installCommand:t})=>{e&&p(e,t)};return(0,z.jsx)(Y,{onOpenChange:f,open:e,children:(0,z.jsxs)(X,{"aria-describedby":void 0,className:`text-white`,children:[(0,z.jsxs)(Zo,{children:[(0,z.jsx)(Q,{children:`Redeploy Package`}),(0,z.jsx)(Qo,{children:`Redeploy this package?`})]}),(0,z.jsx)(`div`,{children:(0,z.jsx)(H,{...c,children:(0,z.jsxs)(`form`,{id:`instance-redeploy-app-form`,name:`instance-redeploy-app-form`,className:`flex flex-col w-full gap-4`,onSubmit:u(m),children:[(0,z.jsx)(W,{control:l,name:`applicationUrl`,render:({field:e})=>(0,z.jsxs)(G,{children:[(0,z.jsx)(K,{className:`pb-1`,children:`Package Reference`}),(0,z.jsx)(U,{children:(0,z.jsx)(J,{type:`text`,autoFocus:!0,...e})}),(0,z.jsx)(q,{})]})}),(0,z.jsx)(W,{control:l,name:`installCommand`,render:({field:e})=>(0,z.jsxs)(G,{children:[(0,z.jsx)(K,{className:`pb-1`,children:`Install Command`}),(0,z.jsx)(U,{children:(0,z.jsx)(J,{type:`text`,placeholder:`npm install`,...e})}),(0,z.jsx)(q,{})]})}),(0,z.jsxs)(B,{variant:`positiveOutline`,type:`submit`,className:`w-full rounded-full`,disabled:s,children:[(0,z.jsx)(fe,{}),` Redeploy Application`]}),(0,z.jsx)(B,{type:`button`,variant:`ghostOutline`,className:`w-full rounded-full`,onClick:f,disabled:s,children:`Cancel`})]})})})]})})}function cm(e){return bf(e.split(`/`).slice(0,-1))}function lm(e,t){return bf(cm(e),t)}function um(){let{value:e,trigger:t}=lf(`ShowRenameFileModal`,!1),n=(0,L.useCallback)(()=>{uf(`ShowRenameFileModal`,!1),Up(t)},[t]),{openedEntry:r,entryExists:i}=Xd(),a=d.object({name:d.string().nonempty({error:`Please enter a valid name.`}).regex(/^[a-zA-Z0-9_\- .]*$/,{error:`Names can only contain letters, numbers, underscores, hyphens, periods, and spaces.`}).max(50,{error:`Names cannot be longer than 50 characters.`}).trim().refine(e=>e!==r?.name,{error:`Please enter a new name.`})}),[o,s]=(0,L.useState)(!1),c=of(),l=N({resolver:w(a)});(0,L.useEffect)(()=>{r?.name&&l.reset({name:r?.name})},[l,r?.name]);let u=(0,L.useCallback)(async e=>{if(!r)return;let t=lm(r.path,e.name);if(i(t)){k.error(`${Sf(r)?`Directory`:`File`} already exists!`,{description:t});return}s(!0),await c([{from:r.path,to:t}]),n(),l.reset(),s(!1)},[n,i,l,r,c,s]),f=(0,L.useCallback)(()=>{n(),l.reset()},[n,l]);return(0,z.jsx)(Y,{onOpenChange:n,open:e,children:(0,z.jsx)(X,{"aria-describedby":void 0,className:`text-white`,children:(0,z.jsx)(H,{...l,children:(0,z.jsxs)(`form`,{id:`instance-rename-app-file-form`,name:`instance-rename-app-file-form`,onSubmit:l.handleSubmit(u),children:[(0,z.jsxs)(Zo,{children:[(0,z.jsx)(Q,{children:`Rename File`}),(0,z.jsx)(Qo,{children:r?.path})]}),(0,z.jsx)(W,{control:l.control,name:`name`,render:({field:e})=>(0,z.jsxs)(G,{className:`my-2`,children:[(0,z.jsx)(K,{children:`Name`}),(0,z.jsx)(U,{children:(0,z.jsx)(J,{disabled:o,type:`text`,autoComplete:`off`,autoCapitalize:`off`,...e})}),(0,z.jsx)(q,{})]})}),(0,z.jsx)(Z,{children:(0,z.jsxs)(`div`,{className:`flex justify-between w-full`,children:[(0,z.jsx)(B,{type:`button`,variant:`ghostOutline`,className:`rounded-full`,onClick:f,children:`Cancel`}),(0,z.jsxs)(B,{variant:`positiveOutline`,type:`submit`,className:`rounded-full`,disabled:o||!l.formState.isDirty||!l.formState.isValid,children:[(0,z.jsx)(he,{}),` Rename`]})]})})]})})})})}function dm(){let{toggle:e,toggled:t}=Jd(`ApplicationsSidebarOpened`,!0);return(0,z.jsxs)(Hp,{children:[(0,z.jsx)(`aside`,{id:`file-explorer-sidebar`,className:i(`pt-[calc(--spacing(32))] w-56 fixed top-0 left-0 bottom-0 z-30`,`bg-black-dark shadow shadow-black`,`transition-transform -translate-x-full`,t?`translate-x-0`:`md:translate-x-0`),"aria-label":`Sidebar`,children:(0,z.jsx)(Bf,{})}),(0,z.jsxs)(`div`,{className:i(`applications-content`,`overflow-y-auto overflow-x-hidden`,`fixed top-32 right-0 bottom-0 left-0`,`transition-[left]`,`md:left-56`,t&&`sm:left-56`),children:[(0,z.jsx)(jp,{}),(0,z.jsx)(qf,{toggledSidebar:t,toggleSidebar:e})]}),(0,z.jsx)(Gp,{}),(0,z.jsx)(om,{}),(0,z.jsx)(Kp,{}),(0,z.jsx)(Yp,{}),(0,z.jsx)(sm,{}),(0,z.jsx)(um,{})]})}function fm(e){return[O({getParentRoute:()=>e,path:`/`,component:dm})]}async function pm({instanceClient:e}){let{data:t}=await e.post(`/`,{operation:`list_certificates`});return t}function mm(e){return A({queryKey:[e.entityId,`list_certificates`],queryFn:()=>pm(e)})}var hm=[{header:`Certificate Name`,accessorKey:`name`,enableSorting:!0},{header:`Issuer`,accessorKey:`details.issuer`,enableSorting:!0},It().display({header:`Expires At`,enableSorting:!1,id:`details.valid_to`,cell:e=>e.row.original.details.valid_to?new Date(e.row.original.details.valid_to).toLocaleString():`N/A`})];function gm({className:e,...t}){return(0,z.jsx)(wn,{"data-slot":`switch`,className:R(`peer data-[state=checked]:bg-green data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50`,e),...t,children:(0,z.jsx)(Ke,{"data-slot":`switch-thumb`,className:R(`bg-white dark:data-[state=unchecked]:bg-white dark:data-[state=checked]:bg-white pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0`)})})}function _m({className:e,...t}){return(0,z.jsx)(`textarea`,{"data-slot":`input`,className:R(`border-input file:text-foreground placeholder:text-muted-foreground selection:bg-purple
42
- selection:text-primary-foreground
43
- dark:aria-invalid:outline-destructive dark:aria-invalid:ring-destructive/50 ring-ring/10
44
- dark:ring-ring/20 dark:outline-ring/40 outline-ring/50 aria-invalid:outline-destructive/60
45
- aria-invalid:ring-destructive/20 aria-invalid:border-destructive/60 dark:aria-invalid:border-destructive
46
- flex w-full min-w-0 rounded-md border bg-grey-700 px-3 py-1 text-base text-white
47
- file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium
48
- focus-visible:ring-1 focus-visible:outline-none focus-visible:ring-purple disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50
49
- aria-invalid:focus-visible:ring-[1px] aria-invalid:focus-visible:outline-none md:text-sm dark:aria-invalid:focus-visible:ring-1`,e),...t})}async function vm({instanceClient:e},t){let{data:n}=await e.post(`/`,{operation:`add_certificate`,...t});return n}var ym=l({name:v().min(1,`Name is required`),certificate:v().min(1,`Certificate is required`),private_key:v().optional(),is_authority:_().default(!1),hosts:v().optional(),uses:v().optional()});function bm(){return E({mutationFn:({instanceParams:e,certificateParams:t})=>vm(e,t)})}function xm({isModalOpen:e,onChangesSaved:t,setIsModalOpen:n}){let r=N({resolver:w(ym),defaultValues:{name:``,certificate:``,private_key:``,is_authority:!1,hosts:``,uses:``}}),i=V(),{mutate:a,isPending:o}=bm(),s=(0,L.useCallback)(async e=>{let{hosts:o,uses:s,private_key:c,...l}=e,u=o?o.split(`,`).map(e=>e.trim()).filter(Boolean):void 0,d=s?s.split(`,`).map(e=>e.trim()).filter(Boolean):void 0;a({instanceParams:i,certificateParams:{...l,private_key:c||void 0,hosts:u&&u.length>0?u:void 0,uses:d&&d.length>0?d:void 0}},{onSuccess:()=>{r.reset(),t(),k.success(`Certificate added successfully!`),n(!1)}})},[a,r,i,t,n]),c=(0,L.useCallback)(()=>{r.reset(),n(!1)},[r,n]);return(0,z.jsx)(Y,{onOpenChange:n,open:e,children:(0,z.jsx)(X,{"aria-describedby":void 0,children:(0,z.jsx)(H,{...r,children:(0,z.jsxs)(`form`,{id:`instance-add-certificate-form`,name:`instance-add-certificate-form`,onSubmit:r.handleSubmit(s),className:`grid gap-4 my-4`,children:[(0,z.jsxs)(Zo,{children:[(0,z.jsx)(Q,{children:`Add New Certificate`}),(0,z.jsx)(Qo,{children:`Enter the details of your Certificate below.`})]}),(0,z.jsx)(W,{control:r.control,name:`name`,render:({field:e})=>(0,z.jsxs)(G,{children:[(0,z.jsx)(K,{className:`pb-1`,children:`Name`}),(0,z.jsx)(U,{children:(0,z.jsx)(J,{type:`text`,autoComplete:`off`,autoCapitalize:`off`,autoFocus:!0,...e})}),(0,z.jsx)(q,{})]})}),(0,z.jsx)(W,{control:r.control,name:`is_authority`,render:({field:e})=>(0,z.jsxs)(G,{className:`flex flex-row items-center justify-between rounded-lg border border-gray-800 p-3 shadow-sm`,children:[(0,z.jsx)(`div`,{className:`space-y-0.5`,children:(0,z.jsx)(K,{children:`Is Authority`})}),(0,z.jsx)(U,{children:(0,z.jsx)(gm,{checked:e.value,onCheckedChange:e.onChange})})]})}),(0,z.jsx)(W,{control:r.control,name:`certificate`,render:({field:e})=>(0,z.jsxs)(G,{children:[(0,z.jsx)(K,{className:`pb-1`,children:`Certificate`}),(0,z.jsx)(U,{children:(0,z.jsx)(_m,{autoComplete:`off`,autoCapitalize:`off`,rows:5,...e})}),(0,z.jsx)(q,{})]})}),(0,z.jsx)(W,{control:r.control,name:`hosts`,render:({field:e})=>(0,z.jsxs)(G,{children:[(0,z.jsx)(K,{className:`pb-1`,children:`Hosts (optional)`}),(0,z.jsx)(Bc,{children:`Comma-separated list of hostnames this certificate is valid for.`}),(0,z.jsx)(U,{children:(0,z.jsx)(J,{type:`text`,autoComplete:`off`,autoCapitalize:`off`,placeholder:`e.g. example.com, *.example.com`,...e})}),(0,z.jsx)(q,{})]})}),(0,z.jsx)(W,{control:r.control,name:`uses`,render:({field:e})=>(0,z.jsxs)(G,{children:[(0,z.jsx)(K,{className:`pb-1`,children:`Uses (optional)`}),(0,z.jsx)(Bc,{children:`Comma-separated list of intended uses, e.g. "https, operations, wss".`}),(0,z.jsx)(U,{children:(0,z.jsx)(J,{type:`text`,autoComplete:`off`,autoCapitalize:`off`,placeholder:`e.g. https, operations, wss`,...e})}),(0,z.jsx)(q,{})]})}),(0,z.jsx)(W,{control:r.control,name:`private_key`,render:({field:e})=>(0,z.jsxs)(G,{children:[(0,z.jsx)(K,{className:`pb-1`,children:`Private Key (optional)`}),(0,z.jsx)(Bc,{children:`PEM formatted private key string.`}),(0,z.jsx)(U,{children:(0,z.jsx)(_m,{autoComplete:`off`,autoCapitalize:`off`,rows:5,...e})}),(0,z.jsx)(q,{})]})}),(0,z.jsx)(Z,{children:(0,z.jsxs)(`div`,{className:`flex justify-between w-full`,children:[(0,z.jsx)(B,{variant:`destructiveOutline`,type:`button`,className:`rounded-full`,onClick:c,disabled:o,children:`Cancel`}),(0,z.jsxs)(B,{type:`submit`,variant:`submit`,className:`rounded-full`,disabled:o||!r.formState.isDirty||!r.formState.isValid,children:[(0,z.jsx)(Jt,{}),` Add Certificate`]})]})})]})})})})}async function Sm({instanceClient:e},t){let{data:n}=await e.post(`/`,{operation:`remove_certificate`,name:t});return n}function Cm(){return E({mutationFn:({instanceParams:e,name:t})=>Sm(e,t)})}function wm({data:e,isModalOpen:t,closeModal:n,onSelectCertificate:r,onChangesSaved:i}){let{name:a}=e,o=V(),{mutate:s,isPending:c}=Cm(),[l,u]=(0,L.useState)(!1),d=(0,L.useCallback)(()=>{u(!0)},[]),f=(0,L.useCallback)(()=>{s({instanceParams:o,name:a},{onSuccess:()=>{k.success(`Certificate removed successfully!`),r(void 0),i()}})},[a,s,o,i,r]);return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(Y,{onOpenChange:n,open:t,children:(0,z.jsx)(X,{className:`sm:max-w-[800px] max-h-[90vh] overflow-y-auto`,"aria-describedby":void 0,children:(0,z.jsxs)(`div`,{className:`grid gap-4 my-4`,children:[(0,z.jsxs)(Zo,{children:[(0,z.jsxs)(Q,{children:[`View Certificate: `,a]}),(0,z.jsx)(Qo,{children:`Details of the selected certificate.`})]}),(0,z.jsxs)(`div`,{className:`space-y-4`,children:[(0,z.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 text-sm bg-gray-900/50 p-4 rounded-lg border border-gray-800`,children:[(0,z.jsxs)(`div`,{className:`col-span-2`,children:[(0,z.jsx)(`p`,{className:`font-semibold`,children:`Issuer`}),(0,z.jsx)(`p`,{className:`text-gray-400 break-all`,children:e.details.issuer||`N/A`})]}),(0,z.jsxs)(`div`,{className:`col-span-2`,children:[(0,z.jsx)(`p`,{className:`font-semibold`,children:`Subject`}),(0,z.jsx)(`p`,{className:`text-gray-400 break-all`,children:e.details.subject||`N/A`})]}),e.details.subject_alt_name&&(0,z.jsxs)(`div`,{className:`col-span-2`,children:[(0,z.jsx)(`p`,{className:`font-semibold`,children:`Subject Alternative Name`}),(0,z.jsx)(`p`,{className:`text-gray-400 break-all`,children:e.details.subject_alt_name})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`p`,{className:`font-semibold`,children:`Valid From`}),(0,z.jsx)(`p`,{className:`text-gray-400`,children:e.details.valid_from?new Date(e.details.valid_from).toLocaleString():`N/A`})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`p`,{className:`font-semibold`,children:`Valid To (Expires At)`}),(0,z.jsx)(`p`,{className:`text-gray-400`,children:e.details.valid_to?new Date(e.details.valid_to).toLocaleString():`N/A`})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`p`,{className:`font-semibold`,children:`Serial Number`}),(0,z.jsx)(`p`,{className:`text-gray-400 font-mono text-xs break-all`,children:e.details.serial_number||`N/A`})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`p`,{className:`font-semibold`,children:`Private Key Name`}),(0,z.jsx)(`p`,{className:`text-gray-400`,children:e.private_key_name||`N/A`})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`p`,{className:`font-semibold`,children:`Is Authority`}),(0,z.jsx)(`p`,{className:`text-gray-400`,children:e.is_authority?`Yes`:`No`})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`p`,{className:`font-semibold`,children:`Is Self-Signed`}),(0,z.jsx)(`p`,{className:`text-gray-400`,children:e.is_self_signed?`Yes`:`No`})]}),e.hosts&&e.hosts.length>0&&(0,z.jsxs)(`div`,{className:`col-span-2`,children:[(0,z.jsx)(`p`,{className:`font-semibold`,children:`Hosts`}),(0,z.jsx)(`p`,{className:`text-gray-400`,children:e.hosts.join(`, `)})]}),(0,z.jsxs)(`div`,{className:`col-span-2`,children:[(0,z.jsx)(`p`,{className:`font-semibold`,children:`Uses`}),(0,z.jsx)(`p`,{className:`text-gray-400`,children:e.uses?.join(`, `)||`N/A`})]})]}),(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsx)(Ra,{children:`Certificate Content`}),(0,z.jsx)(_m,{autoComplete:`off`,autoCapitalize:`off`,rows:8,readOnly:!0,className:`font-mono text-xs`,value:e.certificate})]})]}),(0,z.jsx)(Z,{children:(0,z.jsxs)(`div`,{className:`flex justify-between w-full`,children:[(0,z.jsx)(B,{type:`button`,variant:`destructiveOutline`,className:`rounded-full`,onClick:d,disabled:c,children:`Remove Certificate`}),(0,z.jsx)(B,{type:`button`,variant:`defaultOutline`,className:`rounded-full`,onClick:()=>n(),children:`Close`})]})})]})})}),(0,z.jsx)($o,{isModalOpen:l,setIsModalOpen:u,deletionConfirmed:f,deletionPending:c,typeOfThingBeingDeleted:`certificate`,presentParticiple:`Removing`,transitiveVerb:`Remove`,nameOfThingBeingDeleted:a,hideDataLossWarning:!0})]})}function Tm(){let e=T(),{certName:t}=M({strict:!1}),{data:n,refetch:r,isFetching:i,isRefetching:a}=D(mm(V())),o=(0,L.useMemo)(()=>n?.find(e=>e.name===t),[n,t]),s=(0,L.useCallback)(n=>{let r=n?.original?.name;e({to:[t?`..`:``,r].filter(Boolean).join(`/`)})},[t,e]),c=!!t&&!!o,[l,u]=(0,L.useState)(!1),d=(0,L.useCallback)(()=>{u(!0)},[u]),f=Hl(r);return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(Ll,{columns:hm,data:n||[],isFetching:i,onRowClick:s,children:[(0,z.jsx)(j,{className:`inline-block underline text-sm text-gray-400 hover:text-white`,to:`https://docs.harperdb.io/docs/developers/operations-api/certificate-management`,target:`_blank`,children:`Certificate Management Docs`}),(0,z.jsxs)(B,{variant:`defaultOutline`,onClick:f,accessKey:`r`,disabled:i||a,children:[(0,z.jsx)(fe,{}),(0,z.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,z.jsx)(`u`,{children:`R`}),`efresh`]})]}),(0,z.jsxs)(B,{variant:`positiveOutline`,onClick:d,accessKey:`a`,disabled:l,children:[(0,z.jsx)(C,{}),(0,z.jsxs)(`span`,{children:[(0,z.jsx)(`u`,{children:`A`}),`dd`]})]})]}),l&&(0,z.jsx)(xm,{isModalOpen:l,onChangesSaved:r,setIsModalOpen:u}),c&&(0,z.jsx)(wm,{isModalOpen:c,closeModal:s,data:o,onSelectCertificate:s,onChangesSaved:r})]})}function Em(){return(0,z.jsx)(pd,{})}var Dm=`flex items-center p-2 rounded-lg group`,Om={className:`text-white hover:bg-gray-700`},km={className:`text-black bg-white pointer-events-none cursor-default`};function Am(){let e=M({strict:!1}),{version:t}=Xt({strict:!1}),n=Ls(`4.6.0`,t),{clusterId:r}=e,i=la(),{data:a}=D(Ka(r,!1));a===void 0||cs(a);let o=i&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`li`,{children:(0,z.jsxs)(j,{to:Cl(e,`config/users`),className:Dm,inactiveProps:Om,activeProps:km,children:[(0,z.jsx)(xn,{className:`hidden md:inline-block`}),` `,(0,z.jsx)(`span`,{className:`ms-3`,children:`Users`})]})}),(0,z.jsx)(`li`,{children:(0,z.jsxs)(j,{to:Cl(e,`config/roles`),className:Dm,inactiveProps:Om,activeProps:km,children:[(0,z.jsx)(ze,{className:`hidden md:inline-block`}),` `,(0,z.jsx)(`span`,{className:`ms-3`,children:`Roles`})]})}),n&&(0,z.jsx)(`li`,{children:(0,z.jsxs)(j,{to:Cl(e,`config/certificates`),className:Dm,inactiveProps:Om,activeProps:km,children:[(0,z.jsx)(In,{className:`hidden md:inline-block`}),` `,(0,z.jsx)(`span`,{className:`ms-3`,children:`Certificates`})]})}),!1,n&&(0,z.jsx)(`li`,{children:(0,z.jsxs)(j,{to:Cl(e,`config/ssh-keys`),className:Dm,inactiveProps:Om,activeProps:km,children:[(0,z.jsx)(bt,{className:`hidden md:inline-block`}),` `,(0,z.jsx)(`span`,{className:`ms-3`,children:`SSH Keys`})]})})]});return(0,z.jsxs)(`div`,{className:`md:grid gap-4 md:grid-cols-12 min-h-[calc(100vh-(--spacing(36)))]`,children:[(0,z.jsxs)(`section`,{className:`col-span-1 text-white md:col-span-4 lg:col-span-3 md:border-r border-b md:border-b-0 md:pr-4 border-gray-700`,children:[(0,z.jsx)(jm,{params:e,children:o}),(0,z.jsx)(Mm,{params:e,children:o})]}),(0,z.jsx)(`section`,{className:`col-span-1 text-white md:col-span-8 lg:col-span-9 md:pt-4`,children:(0,z.jsx)(L.Suspense,{fallback:(0,z.jsx)(Ss,{className:`flex flex-col items-center justify-center h-full`,text:`Loading...`}),children:(0,z.jsx)(rt,{})})})]})}function jm({params:e,children:t}){return(0,z.jsxs)(`div`,{className:`hidden md:block pl-4 pt-4`,children:[(0,z.jsxs)(j,{to:Cl(e,`config`),className:Dm,activeOptions:{exact:!0},inactiveProps:Om,activeProps:km,children:[(0,z.jsx)(re,{className:`hidden md:inline-block`}),` `,(0,z.jsx)(`span`,{className:`ms-3`,children:`Overview`})]}),t&&(0,z.jsx)(`ul`,{className:`border-t border-gray-700 pt-4 mt-4 space-y-2`,children:t})]})}function Mm({params:e,children:t}){return(0,z.jsxs)(`ul`,{className:`flex space-x-2 md:hidden py-2 px-4`,children:[(0,z.jsx)(`li`,{children:(0,z.jsxs)(j,{to:Cl(e,`config`),className:Dm,activeOptions:{exact:!0},inactiveProps:Om,activeProps:km,children:[(0,z.jsx)(re,{className:`hidden md:inline-block`}),` `,(0,z.jsx)(`span`,{className:`ms-3`,children:`Overview`})]})}),t]})}async function Nm({clusterId:e,instanceId:t}){return null}function Pm(e){return A({queryKey:[e.clusterId,e.instanceId],queryFn:()=>Nm(e),retry:!1})}var Fm=({loadingRegistration:e,registrationInfo:t})=>{let n=!!t?.version&&parseInt(t.version[0],10)>=5&&`https://github.com/HarperFast/harper/releases/tag/v${t.version}`;return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`dt`,{className:`font-bold text-sm/6`,children:`Harper Version`}),(0,z.jsx)(`dd`,{className:`text-sm/6 sm:mt-2`,children:e?(0,z.jsx)(Ec,{className:`w-10`}):n?(0,z.jsx)(`a`,{href:n,target:`_blank`,className:`underline hover:text-blue-300`,rel:`noopener noreferrer`,children:t.version}):t?.version||`Unknown`})]})};async function Im({instanceClient:e,...t}){let{data:n}=await e.post(`/`,{operation:`set_configuration`,...t});return n}function Lm({onRestartedSuccessfully:e}={}){let t=V(),n=Vt(),[r,i]=(0,L.useState)(!1);return{onConfigUpdate:(0,L.useCallback)(async r=>{i(!0);let a=!1,o={duration:6e4,action:{label:`Cancel`,onClick:()=>{a=!0}}},s=k.loading(`Restarting`,{...o,description:(0,z.jsx)(Us,{animated:!0,width:`0%`})}),c=t.entityType===`cluster`?await Ga(t.entityId):null,l=t.entityType===`cluster`?c?.instances||[]:[{id:t.entityId,status:`RUNNING`}],u=!!c&&I.checkForFabricConnect(c.id),d=t.entityType===`cluster`?l.filter(e=>e.status===`RUNNING`).map(e=>ai({id:e.id,forceFabricConnect:u,operationsUrl:fi(e)})).reverse():[t.instanceClient],f=0;if(d.length)for(let e=0;e<d.length;e++){let t=d[e];if(!a){k.loading(`Updating Instance ${e+1} of ${d.length}`,{...o,id:s,description:(0,z.jsx)(Us,{animated:!0,width:(e===0?0:e/d.length*100)+`%`})});try{await ui({instanceClient:t}),await Im({...r,instanceClient:t}),await Hf({operation:`restart_service`,replicated:!1,instanceClient:t}),f+=1}catch{e+1!==d.length&&(k.loading(`Failed Restarting Instance ${e+1} of ${d.length}`,{...o,id:s,description:`We will carry on momentarily.`}),await ri(3e3))}}}if(i(!1),n.invalidateQueries({queryKey:[t.entityId,`get_configuration`]}),a)k.error(`Cancelled`,{id:s,description:`The config update was partially cancelled.`,duration:1e4,action:{label:`Dismiss`,onClick:()=>k.dismiss()}});else if(l.length===f)e?.(),k.success(`Success`,{id:s,description:`Your configuration has been updated successfully!`,duration:1e4,action:{label:`Dismiss`,onClick:()=>k.dismiss()}});else{let e=Qr(l.length,`instance`,`instances`),t=Qr(f,`"RUNNING" instance was`,`"RUNNING" instances were`);k.error(`Error`,{id:s,description:`Failed to fully update cluster.
50
- `+([l.length===0&&`No instances were found within the cluster to restart.`,f===0&&`No instances were in a "RUNNING" state of ${e}.`,l.length!==f&&`Only ${t} restarted of ${e}.`].filter(Ni).shift()||``),duration:1e4,action:{label:`Dismiss`,onClick:()=>k.dismiss()}})}},[t,e,n]),isPending:r}}function Rm({entityId:e,instanceClient:t}){return A({queryKey:[e,`get_configuration`],queryFn:async()=>{let{data:e}=await t.post(`/`,{operation:`get_configuration`});return e}})}function zm({entityId:e,instanceClient:t}){return A({queryKey:[e,`registration_info`],staleTime:6e4,gcTime:5e3,queryFn:async()=>{let{data:e}=await t.post(`/`,{operation:`registration_info`});return e}})}function Bm({entityId:e,instanceClient:t},n){return A({queryKey:[e,`get_usage_licenses`],enabled:n,queryFn:async()=>{try{let{data:e}=await t.post(`/`,{operation:`get_usage_licenses`});return e}catch(e){return console.error(e),null}}})}var Vm={http:{port:`blocked`,securePort:`blocked`},threads:`blocked`,authentication:{enableSessions:`blocked`},logging:{auditLog:`blocked`,root:`blocked`,rotation:{path:`blocked`}},mqtt:{network:{port:`blocked`,securePort:`blocked`}},operationsApi:{network:{domainSocket:`blocked`,port:`blocked`,securePort:`blocked`}},rootPath:`blocked`,replication:`blocked_except_databases`,storage:`blocked`,tls:`blocked`,node:`blocked`,license:`blocked`,componentsRoot:`blocked`,analytics:`allowed`,applications:`allowed`,localStudio:`allowed`};function Hm(e,t,n){if(JSON.stringify(t)===JSON.stringify(n))return!1;let r=e.split(`.`),i=Vm;for(let e=0;e<r.length;e++){let t=r[e];if(i===`blocked`)return!0;if(i===`blocked_except_databases`)return t!==`databases`;if(typeof i==`object`&&i&&t in i)i=i[t];else return!1}return i===`blocked`}function Um(e,t=Vm){if(typeof e!=`object`||!e)return e;let n=Array.isArray(e)?[]:{};for(let r in e){let i=e[r],a=t?.[r];if(a!==`blocked`)if(a===`blocked_except_databases`){i&&typeof i==`object`&&`databases`in i&&(n.replication={databases:i.databases});continue}else if(typeof a==`object`&&a){let e=Um(i,a);e!==void 0&&(typeof e!=`object`||Object.keys(e).length>0)&&(n[r]=e)}else n[r]=i}return n}function Wm(e,t){if(typeof e!=`object`||!e||typeof t!=`object`||!t)return JSON.stringify(e)===JSON.stringify(t)?void 0:t;let n={},r=new Set([...Object.keys(e),...Object.keys(t)]);for(let i of r){let r=e[i],a=t[i];if(typeof r==`object`&&r&&typeof a==`object`&&a&&!Array.isArray(r)&&!Array.isArray(a)){let e=Wm(r,a);Object.keys(e).length>0&&(n[i]=e)}else JSON.stringify(r)!==JSON.stringify(a)&&(n[i]=a)}return n}function Gm(e,t=``){let n={};for(let r in e){let i=e[r],a=t?`${t}_${r}`:r;typeof i==`object`&&i&&!Array.isArray(i)?Object.assign(n,Gm(i,a)):n[a]=i}return n}var Km=({children:e})=>(0,z.jsx)(z.Fragment,{children:e});function qm(){let{clusterId:e,instanceId:t}=M({strict:!1}),{data:n,isLoading:r}=D(Pm({clusterId:e,instanceId:t})),i=V(),{version:a}=Xt({strict:!1}),{data:o}=D(Bm(i,!1));n?.cluster;let s=n?.instance,{data:c,isLoading:l}=D(zm(i)),{data:u,isLoading:d}=D(Rm(i)),f=(0,L.useMemo)(()=>u?Um(u):null,[u]),[p,m]=(0,L.useState)(!1),[h,g]=(0,L.useState)(``),[_,v]=(0,L.useState)(null),[y,b]=(0,L.useState)([]),{onConfigUpdate:x,isPending:ee}=Lm();(0,L.useEffect)(()=>{f&&!p&&(g(JSON.stringify(f,null,4)),v(null),b([]))},[f,p]);let te=(0,L.useCallback)(e=>{if(g(e||``),e)try{let t=JSON.parse(e);v(null);let n=[],r=(e,t,i=``)=>{for(let a in e){let o=i?`${i}.${a}`:a,s=e[a],c=t?.[a];Hm(o,s,c)?n.push(o):typeof s==`object`&&s&&!Array.isArray(s)&&r(s,c,o)}for(let r in t){let a=i?`${i}.${r}`:r;r in e||Hm(a,void 0,t[r])&&n.push(a)}};f&&r(t,f),b(n)}catch(e){v(e.message),b([])}},[u]),ne=(0,L.useCallback)(()=>{if(!(_||y.length>0))try{x(Gm(Wm(f,JSON.parse(h)))),m(!1)}catch(e){v(e.message)}},[h,_,x,f,y.length]);return(0,L.useMemo)(()=>[],[o,s]),(0,z.jsxs)(`div`,{className:`h-full flex flex-col`,children:[(0,z.jsx)(Km,{children:(0,z.jsxs)(`dl`,{className:`grid grid-cols-1 sm:grid-cols-3`,children:[(0,z.jsx)(`div`,{className:`px-4 pb-4 sm:col-span-2 sm:px-0`,children:(0,z.jsx)(Fm,{loadingRegistration:l,registrationInfo:c})}),(0,z.jsx)(`div`,{className:`px-4 pb-4 text-right sm:col-span-1 sm:px-0`,children:(0,z.jsx)(Kf,{targetNoun:`Instance`,instanceClient:i.instanceClient,operation:`restart`})})]})}),(0,z.jsxs)(`div`,{className:`flex-none flex items-center justify-between mb-2`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsxs)(`h3`,{className:`font-bold text-sm/6`,children:[`Instance Config `,p?`(editing)`:`(read only)`]}),!t&&!1]}),(0,z.jsx)(`div`,{className:`flex items-center gap-2 pr-4`,children:p?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(B,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>m(!1),children:[(0,z.jsx)(Zn,{className:`w-4 h-4 mr-1`}),` Cancel`]}),(0,z.jsxs)(B,{size:`sm`,disabled:!!_||y.length>0||ee,onClick:ne,children:[(0,z.jsx)(Jt,{className:`w-4 h-4 mr-1`}),` `,ee?`Saving...`:`Save & Restart`]})]}):(0,z.jsxs)(B,{size:`sm`,onClick:()=>m(!0),children:[(0,z.jsx)(un,{className:`w-4 h-4 mr-1`}),` Edit`]})})]}),_&&(0,z.jsxs)(ap,{variant:`destructive`,className:`mb-4`,children:[(0,z.jsx)(_e,{className:`h-4 w-4`}),(0,z.jsx)(op,{children:`Invalid JSON`}),(0,z.jsx)(sp,{children:_})]}),y.length>0&&(0,z.jsxs)(ap,{variant:`destructive`,className:`mb-4`,children:[(0,z.jsx)(_e,{className:`h-4 w-4`}),(0,z.jsx)(op,{children:`Restricted Configuration`}),(0,z.jsxs)(sp,{children:[`The following fields cannot be modified via Studio:`,(0,z.jsx)(`ul`,{className:`list-disc ml-4 mt-2`,children:y.map(e=>(0,z.jsx)(`li`,{children:(0,z.jsx)(`code`,{children:e})},e))})]})]}),(0,z.jsx)(`div`,{className:`grow`,children:d?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(Ec,{className:`w-full`}),(0,z.jsx)(Ec,{className:`w-full`}),(0,z.jsx)(Ec,{className:`w-1/2`})]}):(0,z.jsx)(De,{className:`w-full min-h-full h-96`,language:`json`,theme:`vs-dark`,options:{readOnly:!p,scrollBeyondLastLine:!1},value:p?h:JSON.stringify(f,null,4),onChange:te})})]})}var Jm=It(),Ym=[{header:`Role`,accessorKey:`role`,enableSorting:!1},Jm.display({header:`Created`,enableSorting:!1,id:`__createdtime__`,cell:e=>Bl((Date.now()-e.row.original.__createdtime__)/1e3,e.row.original.__createdtime__)}),Jm.display({header:`Updated`,id:`__updatedtime__`,enableSorting:!1,cell:e=>Bl((Date.now()-e.row.original.__updatedtime__)/1e3,e.row.original.__updatedtime__)}),Jm.display({header:`Super User`,id:`super_user`,enableSorting:!1,cell:e=>e.row.original.permission.super_user?`Yes`:`No`}),Jm.display({header:`Structure User`,id:`structure_user`,enableSorting:!1,cell:e=>e.row.original.permission.structure_user?`Yes`:`No`})];async function Xm(e){let{role:t,super_user:n,structure_user:r,instanceClient:i}=e,{data:a}=await i.post(`/`,{operation:`add_role`,role:t,permission:{super_user:n,structure_user:r}});return a}function Zm(){return E({mutationFn:Xm})}var Qm=l({role:v().nonempty({error:`Please enter a role.`}).regex(/^[a-zA-Z_]*$/,{error:`Role must contain only letters and underscores.`}).max(30,{error:`Role cannot be longer than 30 characters.`}),super_user:_(),structure_user:_()});function $m({isModalOpen:e,onChangesSaved:t,setIsModalOpen:n}){let r=N({resolver:w(Qm),defaultValues:{role:``,super_user:!1,structure_user:!1}}),i=V(),{mutate:a,isPending:o}=Zm(),s=(0,L.useCallback)(async e=>{e&&a({role:e.role,super_user:e.super_user,structure_user:e.structure_user,...i},{onSuccess:()=>{r.reset(),t(e.role),k.success(`Role added successfully!`),n(!1)}})},[a,r,i,t,n]),c=(0,L.useCallback)(()=>{r.reset(),n(!1)},[r,n]);return(0,z.jsx)(Y,{onOpenChange:n,open:e,children:(0,z.jsx)(X,{"aria-describedby":void 0,children:(0,z.jsx)(H,{...r,children:(0,z.jsxs)(`form`,{id:`instance-add-role-form`,name:`instance-add-role-form`,onSubmit:r.handleSubmit(s),className:`grid gap-4 my-4 md:grid-cols-2`,children:[(0,z.jsxs)(Zo,{className:`md:col-span-2`,children:[(0,z.jsx)(Q,{children:`Add New Role`}),(0,z.jsx)(Qo,{children:`After adding the role, you will be able to edit the per-table permissions.`})]}),(0,z.jsx)(W,{control:r.control,name:`role`,render:({field:e})=>(0,z.jsxs)(G,{className:`md:col-span-2`,children:[(0,z.jsx)(K,{className:`pb-1`,children:`Name`}),(0,z.jsx)(U,{children:(0,z.jsx)(J,{type:`text`,...e})}),(0,z.jsx)(q,{})]})}),(0,z.jsx)(W,{control:r.control,name:`super_user`,render:({field:e})=>(0,z.jsxs)(G,{className:`flex`,children:[(0,z.jsx)(U,{children:(0,z.jsx)(J,{type:`checkbox`,className:`w-6`,checked:e.value,onChange:t=>e.onChange(t.target.checked)})}),(0,z.jsx)(K,{className:`pl-4 pr-8 flex-1 py-2.5`,children:`Super User`}),(0,z.jsx)(q,{})]})}),(0,z.jsx)(W,{control:r.control,name:`structure_user`,render:({field:e})=>(0,z.jsxs)(G,{className:`flex`,children:[(0,z.jsx)(U,{children:(0,z.jsx)(J,{type:`checkbox`,className:`w-6`,checked:e.value,onChange:t=>e.onChange(t.target.checked)})}),(0,z.jsx)(K,{className:`pl-4 pr-8 flex-1 py-2.5`,children:`Structure User`}),(0,z.jsx)(q,{})]})}),(0,z.jsx)(Z,{className:`md:col-span-2`,children:(0,z.jsxs)(`div`,{className:`flex justify-between w-full`,children:[(0,z.jsx)(B,{variant:`destructiveOutline`,type:`button`,className:`rounded-full`,onClick:c,disabled:o,children:`Cancel`}),(0,z.jsxs)(B,{type:`submit`,variant:`submit`,className:`rounded-full`,disabled:o,children:[(0,z.jsx)(Jt,{}),` Add Role`]})]})})]})})})})}function eh({entityId:e,instanceClient:t}){return A({queryKey:[e,`list_roles`],queryFn:()=>th({instanceClient:t}),refetchInterval:1e4})}async function th({instanceClient:e}){let{data:t}=await e.post(`/`,{operation:`list_roles`});return t}function nh({instanceDatabaseMap:e,currentRolePermissions:t,version:n,showAttributes:r}){let i={...t};if(t.super_user||t.structure_user||t.cluster_user)return t;let[a,o,s]=n.split(`.`).map(e=>parseInt(e,10)),c=n!==`2.0.000`&&a<=2&&o<=1&&s<=2;for(let n in e){i[n]={tables:{}};for(let a in e[n]){let o=e[n][a].attributes.map(e=>e.attribute).sort();if(c){let e=t&&t[n]&&t[n].tables[a];i[n].tables[a]=rh(e,o,r)}else{let e=t&&t[n]&&t[n].tables[a];i[n].tables[a]=ih(e,o,r)}}}return i}function rh(e,t,n){let r=e&&Fs(e.attribute_restrictions,`attribute_name`);return{read:e?e.read:!0,insert:e?e.insert:!0,update:e?e.update:!0,delete:e?e.delete:!0,attribute_restrictions:t.filter(()=>n).map(t=>{let n=r?.[t];return{attribute_name:t,read:n?n.read:e?e.read:!0,insert:n?n.insert:e?e.insert:!0,update:n?n.update:e?e.update:!0,delete:n?n.delete:e?e.delete:!0}})}}function ih(e,t,n){let r=e&&Fs(e.attribute_permissions||[],`attribute_name`);return{read:e?e.read:!1,insert:e?e.insert:!1,update:e?e.update:!1,delete:e?e.delete:!1,attribute_permissions:n?t.map(t=>{let n=r?.[t];return{attribute_name:t,read:n?n.read:e?.attribute_permissions?.length?!1:e?.read||!1,insert:n?n.insert:e?.attribute_permissions?.length?!1:e?.insert||!1,update:n?n.update:e?.attribute_permissions?.length?!1:e?.update||!1}}):null}}async function ah({id:e,permission:t,instanceClient:n}){let{data:r}=await n.post(`/`,{operation:`alter_role`,id:e,permission:t});return r}function oh(){return E({mutationFn:ah})}async function sh({id:e,instanceClient:t}){let{data:n}=await t.post(`/`,{operation:`drop_role`,id:e});return n}function ch(){return E({mutationFn:sh})}async function lh({instanceClient:e}){let{data:t}=await e.post(`/`,{operation:`describe_all`});return t}function uh(e){return A({queryKey:[e.entityId,`describe_all`],queryFn:()=>lh(e),staleTime:6e4,gcTime:5e3,retry:!1})}function dh({data:e,instanceId:t,clusterId:n,isModalOpen:r,closeModal:i,onSelectRole:a,onChangesSaved:o}){let{role:s,permission:c}=e,[l,u]=(0,L.useState)(JSON.stringify(c,null,2)),d=V(),[f,p]=(0,L.useState)(!0),{data:m}=D(uh(d)),{data:h}=D(zm(d)),g=_i(t??n).user?.role?.role===e.role,[_,v]=yu(l?.includes(`attribute_name`)),{mutate:y,isPending:b}=oh(),{mutate:x}=ch(),ee=(0,L.useCallback)(e=>{p(e.length===0)},[p]),te=(0,L.useMemo)(()=>JSON.stringify(m&&h&&nh({instanceDatabaseMap:m,currentRolePermissions:l&&hs(l)||c,version:h.version,showAttributes:_}),null,2),[c,m,h,_,l]);(0,L.useEffect)(()=>{u(te)},[te]);let ne=(0,L.useCallback)(t=>{if(t){let n=JSON.parse(t);if(n.super_user||n.structure_user||n.cluster_user)for(let e in n)(e!==`super_user`&&e!==`structure_user`&&e!==`cluster_user`||n[e]===!1)&&delete n[e];y({id:e.id,permission:n,...d},{onSuccess:()=>{k.success(`Role updated successfully!`),a(void 0),o()}})}},[y,e.id,d,o,a]),re=(0,L.useCallback)(()=>{x({id:e.id,...d},{onSuccess:()=>{k.success(`Role deleted successfully!`),a(void 0),o()}})},[e.id,x,d,o,a]),ie=(0,L.useCallback)(()=>{l&&f&&ne(l)},[l,ne,f]),S=(0,L.useCallback)(()=>{re()},[re]);return(0,z.jsx)(Y,{onOpenChange:i,open:r,children:(0,z.jsxs)(X,{className:`sm:max-w-[750px]`,children:[(0,z.jsxs)(Q,{children:[g?`View`:`Edit`,` Role "`,s,`"`]}),(0,z.jsx)(Qo,{children:g?`You can view your own role, but you cannot edit it. Please assign yourself a different role to edit this role.`:`Edit the role's permissions in JSON format or remove the role entirely.`}),te?(0,z.jsx)(Be,{theme:`vs-dark`,height:`400px`,defaultLanguage:`json`,value:l,options:g?{readOnly:!0}:void 0,onValidate:ee,onChange:u,defaultValue:te}):(0,z.jsx)(Ec,{}),(0,z.jsx)(Z,{children:!g&&(0,z.jsxs)(`div`,{className:`flex justify-between w-full`,children:[(0,z.jsx)(B,{type:`button`,variant:`destructiveOutline`,className:`rounded-full`,onClick:S,disabled:b,children:`Delete Role`}),(0,z.jsx)(`div`,{className:`grow`}),(0,z.jsxs)(Ra,{className:`flex`,children:[(0,z.jsx)(J,{type:`checkbox`,className:`w-6`,checked:_,onChange:v}),(0,z.jsx)(`span`,{className:`pl-4 pr-8 flex-1 py-2.5`,children:`Pick Attributes`})]}),(0,z.jsx)(B,{variant:`submit`,className:`rounded-full`,onClick:ie,disabled:b||!f,children:`Save Changes`})]})})]})})}function fh(){let e=T(),{clusterId:t,instanceId:n,roleId:r}=M({strict:!1}),{data:i,refetch:a,isFetching:o,isRefetching:s}=Nn(eh(V())),c=(0,L.useMemo)(()=>i?.find(e=>e.id===r),[i,r]),l=(0,L.useCallback)(t=>{e({to:[r?`..`:``,t].filter(Boolean).join(`/`)})},[r,e]),u=!!r&&!!c,[d,f]=(0,L.useState)(!1),p=(0,L.useCallback)(()=>{f(!0)},[f]),m=(0,L.useCallback)(e=>{a(),f(!1),l(e)},[l,a]),h=(0,L.useCallback)(e=>{l(e.original.role)},[l]),g=(0,L.useCallback)(()=>{l(void 0)},[l]),_=Hl(a);return(0,z.jsxs)(L.Suspense,{fallback:(0,z.jsx)(Ss,{className:`flex flex-col items-center justify-center h-full`,text:`Loading...`}),children:[(0,z.jsxs)(Ll,{columns:Ym,data:i,isFetching:o,onRowClick:h,children:[(0,z.jsxs)(B,{variant:`defaultOutline`,onClick:_,accessKey:`r`,disabled:o||s,children:[(0,z.jsx)(fe,{}),(0,z.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,z.jsx)(`u`,{children:`R`}),`efresh`]})]}),(0,z.jsxs)(B,{variant:`positiveOutline`,onClick:p,accessKey:`a`,disabled:d,children:[(0,z.jsx)(C,{}),(0,z.jsxs)(`span`,{children:[(0,z.jsx)(`u`,{children:`A`}),`dd`]})]})]}),(0,z.jsx)($m,{isModalOpen:d,onChangesSaved:m,setIsModalOpen:f}),u&&(0,z.jsx)(dh,{instanceId:n,clusterId:t,isModalOpen:u,closeModal:g,data:c,onSelectRole:l,onChangesSaved:()=>a()})]})}async function ph({instanceClient:e}){let{data:t}=await e.post(`/`,{operation:`list_ssh_keys`});return t}function mh(e){return A({queryKey:[e.entityId,`list_ssh_keys`],queryFn:()=>ph(e)})}var hh=[{header:`SSH Key Name`,accessorKey:`name`,enableSorting:!1}];async function gh({instanceClient:e}){let{data:t}=await e.post(`/`,{operation:`get_ssh_known_hosts`});return t}function _h(e){return A({queryKey:[e.entityId,`get_ssh_known_hosts`],queryFn:()=>gh(e)})}var vh=l({known_hosts:v().trim()});async function yh(e){let{instanceClient:t,entityType:n,...r}=e,{data:i}=await t.post(`/`,{operation:`set_ssh_known_hosts`,replicated:n===`cluster`,...r});return i}function bh(){return E({mutationFn:yh})}function xh(){let e=V(),{data:t}=Nn(_h(e)),n=N({resolver:w(vh),defaultValues:{known_hosts:t?.known_hosts||``}}),{mutate:r,isPending:i}=bh(),a=(0,L.useCallback)(async t=>{let{known_hosts:i}=t;i&&r({known_hosts:i.trim()+`
51
- `,...e},{onSuccess:()=>{n.reset(t),k.success(`Known hosts saved!`)}})},[r,n,e]);return(0,z.jsx)(H,{...n,children:(0,z.jsx)(`form`,{id:`instance-edit-known-hosts-form`,name:`instance-edit-known-hosts-form`,onSubmit:n.handleSubmit(a),className:`grid my-4 md:grid-cols-2 overflow-x-auto rounded-md`,children:(0,z.jsx)(W,{control:n.control,name:`known_hosts`,render:({field:e})=>(0,z.jsxs)(G,{className:`md:col-span-2 gap-0`,children:[(0,z.jsx)(K,{className:`bg-black-dark py-3 px-2 m-0 text-left font-medium whitespace-nowrap`,children:`Known Hosts`}),(0,z.jsxs)(`div`,{className:`border border-grey-700 p-2 pb-3`,children:[(0,z.jsx)(Bc,{className:`pb-2`,children:`Manage your known hosts here. When you add a SSH Key with a hostname of "github.com", we'll automatically attempt to resolve GitHub's known hosts for you.`}),(0,z.jsx)(U,{children:(0,z.jsx)(_m,{autoComplete:`off`,autoCapitalize:`off`,className:`whitespace-nowrap`,rows:10,...e})}),(0,z.jsx)(q,{}),(0,z.jsxs)(B,{type:`submit`,variant:`submit`,className:`rounded-full mt-2`,disabled:i||!n.formState.isDirty||!n.formState.isValid,children:[(0,z.jsx)(Jt,{}),` `,i?`Saving`:`Save`,` Known Hosts`,i?`...`:``]})]})]})})})})}var Sh=l({name:v().trim().min(1).regex(/^[a-zA-Z0-9-_]*$/,{error:`Can only contain letters, numbers, dashes and underscores.`}),key:v().min(1).trim(),host:v().min(1).trim(),hostname:v().min(1).trim(),known_hosts:v().trim().optional()});async function Ch(e){let{instanceClient:t,entityType:n,entityId:r,...i}=e,{data:a}=await t.post(`/`,{operation:`add_ssh_key`,replicated:n===`cluster`,...i});return a}function wh(){return E({mutationFn:Ch})}function Th({isModalOpen:e,onChangesSaved:t,setIsModalOpen:n}){let r=N({resolver:w(Sh),defaultValues:{name:``,key:``,host:``,hostname:``,known_hosts:``}}),i=V(),{mutate:a,isPending:o}=wh(),s=(0,L.useCallback)(async e=>{if(e){let{name:o,key:s,host:c,hostname:l,known_hosts:u}=e;a({name:o,key:s.trim()+`
52
- `,host:c,hostname:l,known_hosts:u||void 0,...i},{onSuccess:()=>{r.reset(),t(),k.success(`SSH Key added successfully!`),n(!1)}})}},[a,r,i,t,n]),c=(0,L.useCallback)(()=>{r.reset(),n(!1)},[r,n]);return(0,z.jsx)(Y,{onOpenChange:n,open:e,children:(0,z.jsx)(X,{"aria-describedby":void 0,children:(0,z.jsx)(H,{...r,children:(0,z.jsxs)(`form`,{id:`instance-add-ssh-key-form`,name:`instance-add-ssh-key-form`,onSubmit:r.handleSubmit(s),className:`grid gap-4 my-4 md:grid-cols-2`,children:[(0,z.jsxs)(Zo,{className:`md:col-span-2`,children:[(0,z.jsx)(Q,{children:`Add New SSH Key`}),(0,z.jsx)(Qo,{children:`Enter the details of your SSH Key below.`})]}),(0,z.jsx)(W,{control:r.control,name:`name`,render:({field:e})=>(0,z.jsxs)(G,{className:`md:col-span-2`,children:[(0,z.jsx)(K,{className:`pb-1`,children:`Name`}),(0,z.jsx)(U,{children:(0,z.jsx)(J,{type:`text`,autoComplete:`off`,autoCapitalize:`off`,autoFocus:!0,...e})}),(0,z.jsx)(q,{})]})}),(0,z.jsx)(W,{control:r.control,name:`key`,render:({field:e})=>(0,z.jsxs)(G,{className:`md:col-span-2`,children:[(0,z.jsx)(K,{className:`pb-1`,children:`Key`}),(0,z.jsx)(Bc,{children:`Your private key. Don't have one? Try out "ssh-keygen"! You'll want to add your public key to your registry, i.e. GitHub.`}),(0,z.jsx)(U,{children:(0,z.jsx)(_m,{autoComplete:`off`,autoCapitalize:`off`,rows:3,...e})}),(0,z.jsx)(q,{})]})}),(0,z.jsx)(W,{control:r.control,name:`host`,render:({field:e})=>(0,z.jsxs)(G,{className:`md:col-span-2`,children:[(0,z.jsx)(K,{className:`pb-1`,children:`Host`}),(0,z.jsx)(Bc,{children:`A unique identifying name for the combination of this key and your hostname, i.e. "your-repo.github.com". You will use this instead of the direct hostname to pick your key when importing applications.`}),(0,z.jsx)(U,{children:(0,z.jsx)(J,{type:`text`,autoComplete:`off`,autoCapitalize:`off`,...e})}),(0,z.jsx)(q,{})]})}),(0,z.jsx)(W,{control:r.control,name:`hostname`,render:({field:e})=>(0,z.jsxs)(G,{className:`md:col-span-2`,children:[(0,z.jsx)(K,{className:`pb-1`,children:`Hostname`}),(0,z.jsx)(Bc,{children:`When making the request, the actual hostname to use, i.e. "github.com".`}),(0,z.jsx)(U,{children:(0,z.jsx)(J,{type:`text`,autoComplete:`off`,autoCapitalize:`off`,...e})}),(0,z.jsx)(q,{})]})}),(0,z.jsx)(W,{control:r.control,name:`known_hosts`,render:({field:e})=>(0,z.jsxs)(G,{className:`md:col-span-2`,children:[(0,z.jsx)(K,{className:`pb-1`,children:`Known Hosts`}),(0,z.jsx)(Bc,{children:`Optionally, append known hosts, one per line. GitHub known hosts should resolve automatically.`}),(0,z.jsx)(U,{children:(0,z.jsx)(_m,{autoComplete:`off`,autoCapitalize:`off`,className:`whitespace-nowrap`,rows:3,...e})}),(0,z.jsx)(q,{})]})}),(0,z.jsx)(Z,{className:`md:col-span-2`,children:(0,z.jsxs)(`div`,{className:`flex justify-between w-full`,children:[(0,z.jsx)(B,{variant:`destructiveOutline`,type:`button`,className:`rounded-full`,onClick:c,disabled:o,children:`Cancel`}),(0,z.jsxs)(B,{type:`submit`,variant:`submit`,className:`rounded-full`,disabled:o||!r.formState.isDirty||!r.formState.isValid,children:[(0,z.jsx)(Jt,{}),` Add SSH Key`]})]})})]})})})})}async function Eh(e){let{instanceClient:t,entityType:n,name:r}=e,{data:i}=await t.post(`/`,{operation:`delete_ssh_key`,replicated:n===`cluster`,name:r});return i}function Dh(){return E({mutationFn:Eh})}async function Oh({name:e,instanceClient:t}){let{data:n}=await t.post(`/`,{operation:`get_ssh_key`,name:e});return n}function kh(e){return A({queryKey:[e.entityId,`get_ssh_key`],queryFn:()=>Oh(e),refetchInterval:1e4})}var Ah=l({name:v().trim(),key:v().min(1).trim()});async function jh(e){let{instanceClient:t,entityType:n,name:r,key:i}=e,{data:a}=await t.post(`/`,{operation:`update_ssh_key`,replicated:n===`cluster`,name:r,key:i});return a}function Mh(){return E({mutationFn:jh})}function Nh({data:e,isModalOpen:t,closeModal:n,onSelectSSHKey:r,onChangesSaved:i}){let{name:a}=e,o=N({resolver:w(Ah),defaultValues:{name:a,key:``}}),s=V(),{data:c}=D(kh({...s,name:a})),{mutate:l,isPending:u}=Mh(),{mutate:d}=Dh(),f=(0,L.useCallback)(async({key:e})=>{e&&l({name:a,key:e.trim()+`
53
- `,...s},{onSuccess:()=>{k.success(`SSH Key updated successfully!`),r(void 0),i()}})},[l,a,s,r,i]),p=(0,L.useCallback)(()=>{d({name:a,...s},{onSuccess:()=>{k.success(`SSH Key deleted successfully!`),r(void 0),i()}})},[a,d,s,i,r]);return(0,z.jsx)(Y,{onOpenChange:n,open:t,children:(0,z.jsx)(X,{className:`sm:max-w-[750px]`,"aria-describedby":void 0,children:(0,z.jsx)(H,{...o,children:(0,z.jsxs)(`form`,{id:`instance-edit-ssh-key-form`,name:`instance-edit-ssh-key-form`,onSubmit:o.handleSubmit(f),className:`grid gap-4 my-4 md:grid-cols-2`,children:[(0,z.jsx)(Q,{children:`Edit SSH Key`}),(0,z.jsx)(W,{control:o.control,name:`name`,render:({field:e})=>(0,z.jsxs)(G,{className:`md:col-span-2`,children:[(0,z.jsx)(K,{className:`pb-1`,children:`Name`}),(0,z.jsx)(U,{children:(0,z.jsx)(J,{type:`text`,autoComplete:`off`,autoCapitalize:`off`,readOnly:!0,disabled:!0,...e})}),(0,z.jsx)(q,{})]})}),(0,z.jsx)(W,{control:o.control,name:`key`,render:({field:e})=>(0,z.jsxs)(G,{className:`md:col-span-2`,children:[(0,z.jsx)(K,{className:`pb-1`,children:`Key`}),(0,z.jsx)(Bc,{children:`Replace your existing private key. Lost it? Try out "ssh-keygen"! You'll want to add your public key to your registry, i.e. GitHub.`}),(0,z.jsx)(U,{children:(0,z.jsx)(_m,{autoComplete:`off`,autoCapitalize:`off`,autoFocus:!0,rows:3,...e})}),(0,z.jsx)(q,{})]})}),(0,z.jsxs)(G,{className:`md:col-span-2`,children:[(0,z.jsx)(K,{className:`pb-1`,children:`Host`}),(0,z.jsx)(Bc,{children:`A unique identifying name for the combination of this key and your hostname, i.e. "your-repo.github.com". You will use this instead of the direct hostname to pick your key when importing applications.`}),(0,z.jsx)(U,{children:(0,z.jsx)(J,{type:`text`,autoComplete:`off`,autoCapitalize:`off`,value:c?.host||``,disabled:!0,readOnly:!0})}),(0,z.jsx)(q,{})]}),(0,z.jsxs)(G,{className:`md:col-span-2`,children:[(0,z.jsx)(K,{className:`pb-1`,children:`Hostname`}),(0,z.jsx)(Bc,{children:`When making the request, the actual hostname to use, i.e. "github.com".`}),(0,z.jsx)(U,{children:(0,z.jsx)(J,{type:`text`,autoComplete:`off`,autoCapitalize:`off`,value:c?.hostname||``,disabled:!0,readOnly:!0})}),(0,z.jsx)(q,{})]}),(0,z.jsxs)(Z,{children:[(0,z.jsx)(B,{type:`button`,variant:`destructiveOutline`,className:`rounded-full`,onClick:p,disabled:u,children:`Delete SSH Key`}),(0,z.jsx)(`div`,{className:`grow`}),(0,z.jsx)(B,{type:`submit`,variant:`submit`,className:`rounded-full`,disabled:u||!o.formState.isValid,children:`Update SSH Key`})]})]})})})})}function Ph(){let e=T(),{keyName:t}=M({strict:!1}),{data:n,refetch:r,isFetching:i,isRefetching:a}=D(mh(V())),o=(0,L.useMemo)(()=>n?.find(e=>e.name===t),[n,t]),s=(0,L.useCallback)(n=>{let r=n?.original?.name;e({to:[t?`..`:``,r].filter(Boolean).join(`/`)})},[t,e]),c=!!t&&!!o,[l,u]=(0,L.useState)(!1),d=(0,L.useCallback)(()=>{u(!0)},[u]),f=Hl(r);return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(Ll,{columns:hh,data:n||[],isFetching:i,onRowClick:s,children:[(0,z.jsx)(j,{className:`inline-block underline text-sm text-gray-400 hover:text-white`,to:`https://docs.harperdb.io/docs/developers/security/certificate-management`,target:`_blank`,children:`Certificate Management Docs`}),(0,z.jsxs)(B,{variant:`defaultOutline`,onClick:f,accessKey:`r`,disabled:i||a,children:[(0,z.jsx)(fe,{}),(0,z.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,z.jsx)(`u`,{children:`R`}),`efresh`]})]}),(0,z.jsxs)(B,{variant:`positiveOutline`,onClick:d,accessKey:`a`,disabled:l,children:[(0,z.jsx)(C,{}),(0,z.jsxs)(`span`,{children:[(0,z.jsx)(`u`,{children:`A`}),`dd`]})]})]}),l&&(0,z.jsx)(Th,{isModalOpen:l,onChangesSaved:r,setIsModalOpen:u}),c&&(0,z.jsx)(Nh,{isModalOpen:c,closeModal:s,data:o,onSelectSSHKey:s,onChangesSaved:r}),(0,z.jsx)(L.Suspense,{fallback:(0,z.jsx)(Ss,{text:`Loading...`}),children:(0,z.jsx)(xh,{})})]})}var Fh=It(),Ih=[{header:`Username`,accessorKey:`username`,enableSorting:!1},Fh.display({header:`Role`,enableSorting:!1,id:`role`,cell:e=>e.row.original.role.role}),{header:`Active`,accessorKey:`active`,enableSorting:!1},Fh.display({header:`Created`,enableSorting:!1,id:`__createdtime__`,cell:e=>Bl((Date.now()-e.row.original.__createdtime__)/1e3,e.row.original.__createdtime__)}),{header:`Updated`,accessorKey:`__updatedtime__`,enableSorting:!1,cell:e=>Bl((Date.now()-e.row.original.__updatedtime__)/1e3,e.row.original.__updatedtime__)}];function Lh({isModalOpen:e,onChangesSaved:t,setIsModalOpen:n}){let r=V(),{data:i}=Nn(eh(r)),a=N({resolver:w(hd),defaultValues:{username:``,role:``,password:``,confirmPassword:``}}),{mutate:o,isPending:s}=vd(),c=(0,L.useCallback)(async e=>{e&&o({active:!0,password:e.password,role:e.role,username:e.username,...r},{onSuccess:()=>{let r=e.role;a.reset(),a.setValue(`role`,r),t(),k.success(`User added successfully!`),n(!1)}})},[o,a,r,t,n]);return(0,z.jsx)(Y,{onOpenChange:n,open:e,children:(0,z.jsx)(X,{"aria-describedby":void 0,children:(0,z.jsx)(H,{...a,children:(0,z.jsxs)(`form`,{id:`instance-add-user-form`,name:`instance-add-user-form`,onSubmit:a.handleSubmit(c),className:`grid gap-4 my-4`,children:[(0,z.jsx)(Zo,{children:(0,z.jsx)(Q,{children:`Add New User`})}),(0,z.jsx)(W,{control:a.control,name:`username`,render:({field:e})=>(0,z.jsxs)(G,{children:[(0,z.jsx)(K,{className:`pb-1`,children:`Username`}),(0,z.jsx)(U,{children:(0,z.jsx)(J,{type:`text`,enterKeyHint:`next`,autoComplete:`username`,...e})}),(0,z.jsx)(q,{})]})}),(0,z.jsx)(W,{control:a.control,name:`password`,render:({field:e})=>(0,z.jsxs)(G,{children:[(0,z.jsx)(K,{className:`pb-1`,children:`Password`}),(0,z.jsx)(U,{children:(0,z.jsx)(J,{type:`password`,enterKeyHint:`next`,autoComplete:`new-password`,...e})}),(0,z.jsx)(q,{})]})}),(0,z.jsx)(W,{control:a.control,name:`confirmPassword`,render:({field:e})=>(0,z.jsxs)(G,{children:[(0,z.jsx)(K,{className:`pb-1`,children:`Confirm Password`}),(0,z.jsx)(U,{children:(0,z.jsx)(J,{type:`password`,enterKeyHint:`next`,autoComplete:`new-password`,...e})}),(0,z.jsx)(q,{})]})}),(0,z.jsx)(W,{control:a.control,name:`role`,render:({field:e})=>(0,z.jsxs)(G,{children:[(0,z.jsx)(K,{className:`pb-1`,children:`Role`}),(0,z.jsx)(L.Suspense,{fallback:(0,z.jsx)(Ec,{}),children:(0,z.jsx)(U,{children:(0,z.jsxs)(Dc,{...e,onValueChange:t=>e.onChange(t),children:[(0,z.jsx)(Ac,{className:`w-full`,children:(0,z.jsx)(kc,{placeholder:`Choose Role`})}),(0,z.jsx)(jc,{children:(0,z.jsxs)(Oc,{children:[(0,z.jsx)(Mc,{children:`Role`}),i?.map(e=>(0,z.jsx)($,{value:e.id,children:e.role},e.id))]})})]})})}),(0,z.jsx)(q,{})]})}),(0,z.jsx)(Z,{children:(0,z.jsx)(`div`,{className:`flex justify-between w-full`,children:(0,z.jsxs)(B,{type:`submit`,variant:`submit`,className:`rounded-full`,disabled:s,children:[(0,z.jsx)(Jt,{}),` Add User`]})})})]})})})})}var Rh=l({username:hd.shape.username,role:hd.shape.role,newPassword:hd.shape.password.or(p(``)).optional(),confirmPassword:hd.shape.confirmPassword}).refine(e=>!e.newPassword||e.newPassword.length>=8,{error:`Password must be at least 8 characters long.`,path:[`password`]}).refine(e=>!e.newPassword||e.newPassword===e.confirmPassword,{error:`Passwords do not match.`,path:[`confirmPassword`]});function zh({data:e,onUserUpdated:t}){let n=V(),{data:r}=Nn(eh(n)),{mutate:i,isPending:a}=bd(),o=N({resolver:w(Rh),defaultValues:{username:e.username,role:e.role.role,newPassword:``,confirmPassword:``}}),s=(0,L.useCallback)(r=>{let a={username:e.username,role:r.role,...n};r.newPassword&&(a.password=r.newPassword),i(a,{onSuccess:()=>{o.reset(),k.success(`User edited successfully!`),t()}})},[o,i,e.username,n,t]);return(0,z.jsx)(H,{...o,children:(0,z.jsxs)(`form`,{id:`instance-edit-user-form`,name:`instance-edit-user-form`,onSubmit:o.handleSubmit(s),className:`grid gap-4 my-4`,children:[(0,z.jsx)(Zo,{children:(0,z.jsx)(Q,{children:`Edit User`})}),(0,z.jsx)(W,{control:o.control,name:`username`,render:({field:e})=>(0,z.jsxs)(G,{children:[(0,z.jsx)(K,{className:`pb-1`,children:`Username`}),(0,z.jsx)(U,{children:(0,z.jsx)(J,{type:`text`,enterKeyHint:`next`,autoComplete:`username`,disabled:!0,readOnly:!0,...e})}),(0,z.jsx)(q,{})]})}),(0,z.jsx)(W,{control:o.control,name:`newPassword`,render:({field:e})=>(0,z.jsxs)(G,{children:[(0,z.jsx)(K,{className:`pb-1`,children:`Change Password`}),(0,z.jsx)(U,{children:(0,z.jsx)(J,{type:`password`,enterKeyHint:`next`,autoComplete:`new-password`,...e})}),(0,z.jsx)(q,{})]})}),(0,z.jsx)(W,{control:o.control,name:`confirmPassword`,render:({field:e})=>(0,z.jsxs)(G,{children:[(0,z.jsx)(K,{className:`pb-1`,children:`Confirm Password`}),(0,z.jsx)(U,{children:(0,z.jsx)(J,{type:`password`,enterKeyHint:`next`,autoComplete:`new-password`,...e})}),(0,z.jsx)(q,{})]})}),(0,z.jsx)(W,{control:o.control,name:`role`,render:({field:e})=>(0,z.jsxs)(G,{children:[(0,z.jsx)(K,{className:`pb-1`,children:`Role`}),(0,z.jsx)(L.Suspense,{fallback:(0,z.jsx)(Ec,{}),children:(0,z.jsx)(U,{children:(0,z.jsxs)(Dc,{...e,onValueChange:t=>e.onChange(t),children:[(0,z.jsx)(Ac,{className:`w-full`,children:(0,z.jsx)(kc,{placeholder:`Choose Role`})}),(0,z.jsx)(jc,{children:(0,z.jsxs)(Oc,{children:[(0,z.jsx)(Mc,{children:`Role`}),r?.map(e=>(0,z.jsx)($,{value:e.id,children:e.role},e.id))]})})]})})}),(0,z.jsx)(q,{})]})}),(0,z.jsx)(Z,{children:(0,z.jsx)(`div`,{className:`flex justify-between w-full`,children:(0,z.jsxs)(B,{variant:`submit`,className:`rounded-full`,disabled:a,children:[(0,z.jsx)(Jt,{}),` Save Changes`]})})})]})})}var Bh=l({username:Ya,confirmUsernameForDeletion:v().nonempty({error:`Please type the username again to confirm deletion.`}).toLowerCase()}).refine(e=>e.username===e.confirmUsernameForDeletion,{error:`Username does not match.`,path:[`confirmUsernameForDeletion`]});function Vh({data:e,onUserDeleted:t}){let{mutate:n,isPending:r}=Sd(),i=N({resolver:w(Bh),defaultValues:{username:e.username,confirmUsernameForDeletion:``}}),a=Xi(),o=(0,L.useCallback)(()=>{n({username:e.username,...a},{onSuccess:()=>{i.reset(),k.success(`User deleted successfully!`),t()}})},[e.username,i,n,a,t]);return(0,z.jsx)(H,{...i,children:(0,z.jsxs)(`form`,{id:`instance-delete-user-form`,name:`instance-delete-user-form`,onSubmit:i.handleSubmit(o),className:`grid gap-4 my-4`,children:[(0,z.jsx)(W,{control:i.control,name:`confirmUsernameForDeletion`,render:({field:e})=>(0,z.jsxs)(G,{children:[(0,z.jsx)(K,{className:`pb-1`,children:`Confirm Username`}),(0,z.jsx)(U,{children:(0,z.jsx)(J,{type:`text`,enterKeyHint:`next`,autoComplete:`username`,...e})}),(0,z.jsx)(q,{})]})}),(0,z.jsx)(Z,{children:(0,z.jsx)(`div`,{className:`flex justify-between w-full`,children:(0,z.jsxs)(B,{variant:`destructive`,className:`rounded-full`,disabled:r||!i.formState.isValid,children:[(0,z.jsx)($t,{}),` Delete User`]})})})]})})}function Hh({closeModal:e,clusterId:t,instanceId:n,data:r,isModalOpen:i,onUserDeleted:a,onUserUpdated:o}){let s=_i(n??t).user?.username!==r.username;return(0,z.jsx)(Y,{onOpenChange:e,open:i,children:(0,z.jsxs)(X,{className:`sm:max-w-[750px]`,children:[(0,z.jsx)(zh,{data:r,onUserUpdated:o}),s&&(0,z.jsx)(Vh,{data:r,onUserDeleted:a})]})})}function Uh({entityId:e,instanceClient:t}){return A({queryKey:[e,`list_users`],queryFn:()=>Wh({instanceClient:t}),refetchInterval:1e4})}async function Wh({instanceClient:e}){let{data:t}=await e.post(`/`,{operation:`list_users`});return t}function Gh(){let e=T(),{instanceId:t,clusterId:n,username:r}=M({strict:!1}),{data:i,refetch:a,isFetching:o,isRefetching:s}=Nn(Uh(V())),c=(0,L.useMemo)(()=>i?.find(e=>e.username===r),[i,r]),l=(0,L.useCallback)(t=>{e({to:[r?`..`:``,t].filter(Boolean).join(`/`)})},[r,e]),u=!!r&&!!c,[d,f]=(0,L.useState)(!1),[p]=(0,L.useState)({attribute:`username`,descending:!1}),m=(0,L.useMemo)(()=>[{desc:p.descending,id:p.attribute}],[p]),h=(0,L.useCallback)(()=>{f(!0)},[f]),g=(0,L.useCallback)(()=>{a(),f(!1)},[a,f]),_=(0,L.useCallback)(e=>{l(e.original.username)},[l]),v=(0,L.useCallback)(()=>{l(void 0)},[l]),y=(0,L.useCallback)(()=>{a(),l(void 0)},[l,a]),b=(0,L.useCallback)(()=>{a(),l(void 0)},[l,a]),x=Hl(a);return(0,z.jsxs)(L.Suspense,{fallback:(0,z.jsx)(Ss,{className:`flex flex-col items-center justify-center h-full`,text:`Loading...`}),children:[(0,z.jsxs)(Ll,{data:i,isFetching:o||s,columns:Ih,onRowClick:_,sortingState:m,children:[(0,z.jsxs)(B,{variant:`defaultOutline`,onClick:x,accessKey:`r`,disabled:o||s,children:[(0,z.jsx)(fe,{}),` `,(0,z.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,z.jsx)(`u`,{children:`R`}),`efresh`]})]}),(0,z.jsxs)(B,{variant:`positiveOutline`,onClick:h,accessKey:`a`,disabled:d,children:[(0,z.jsx)(C,{}),` `,(0,z.jsxs)(`span`,{children:[(0,z.jsx)(`u`,{children:`A`}),`dd`]})]})]}),(0,z.jsx)(Lh,{isModalOpen:d,onChangesSaved:g,setIsModalOpen:f}),u&&(0,z.jsx)(Hh,{instanceId:t,clusterId:n,closeModal:v,data:c,isModalOpen:u,onUserDeleted:b,onUserUpdated:y})]})}function Kh({context:e,params:t}){let n=Zi(t);return e.queryClient.ensureQueryData(zm(n))}function qh(e){let t=O({getParentRoute:()=>e,path:`config`,component:Am,loader:Kh}),n=O({getParentRoute:()=>t,path:`/`,component:qm,loader:Kh}),r=O({getParentRoute:()=>t,path:`roles`,component:fh}),i=O({getParentRoute:()=>t,path:`roles/$roleId`,component:fh}),a=O({getParentRoute:()=>t,path:`users`,component:Gh}),o=O({getParentRoute:()=>t,path:`users/$username`,component:Gh}),s=O({getParentRoute:()=>t,path:`domains`,component:Em}),c=O({getParentRoute:()=>t,path:`ssh-keys`,component:Ph}),l=O({getParentRoute:()=>t,path:`ssh-keys/$keyName`,component:Ph}),u=O({getParentRoute:()=>t,path:`certificates`,component:Tm}),d=O({getParentRoute:()=>t,path:`certificates/$certName`,component:Tm});return t.addChildren([n,r,i,a,o,s,c,l,u,d])}function Jh({clusterId:e,databaseName:t,instanceId:n,organizationId:r,tableName:i}){let a=[`databases`,t,i].filter(Ni).join(`/`);return Cl({organizationId:r,instanceId:n,clusterId:e},a)}function Yh({className:e,children:t,...n}){return(0,z.jsxs)(ge,{"data-slot":`scroll-area`,className:R(`relative`,e),...n,children:[(0,z.jsx)(ae,{"data-slot":`scroll-area-viewport`,className:`focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1`,children:t}),(0,z.jsx)(Xh,{}),(0,z.jsx)(ye,{})]})}function Xh({className:e,orientation:t=`vertical`,...n}){return(0,z.jsx)($e,{"data-slot":`scroll-area-scrollbar`,orientation:t,className:R(`flex touch-none p-px transition-colors select-none`,t===`vertical`&&`h-full w-2.5 border-l border-l-transparent`,t===`horizontal`&&`h-2.5 flex-col border-t border-t-transparent`,e),...n,children:(0,z.jsx)(On,{"data-slot":`scroll-area-thumb`,className:`bg-border relative flex-1 rounded-full`})})}async function Zh({databaseName:e,tableName:t,primaryKey:n,replicated:r,instanceClient:i}){let{data:a}=await i.post(`/`,{operation:`create_table`,database:e,table:t,primary_key:n,replicated:r});return a}function Qh(){return E({mutationFn:Zh})}var $h=l({databaseName:em,tableName:nm,primaryKey:v().regex($p,{error:`Primary key cannot include backticks or forward slashes.`}).max(250,{error:`Primary key cannot be longer than 250 characters.`})});function eg({databaseName:e,onSelectTable:t}){let n=Vt(),r=V(),i=kn(),[a,o]=(0,L.useState)(!1),s=N({resolver:w($h),defaultValues:{databaseName:e||``,tableName:``,primaryKey:``}}),{mutate:c}=Qh(),l=async e=>{let a=e.databaseName||`data`,l=e.tableName;c({databaseName:a,tableName:l,primaryKey:e.primaryKey||`id`,...r,replicated:r.entityType===`cluster`},{onSuccess:async()=>{await n.invalidateQueries({queryKey:[r.entityId,`describe_all`],refetchType:`all`}),k.success(`Table ${l} created successfully`),o(!1),s.reset(),t(a,l),await i.invalidate()}})};return(0,z.jsxs)(Y,{open:a,onOpenChange:o,children:[(0,z.jsx)(Jo,{asChild:!0,children:(0,z.jsx)(`div`,{className:`sticky bottom-0 py-4 bg-black/70 backdrop-blur-xs`,children:(0,z.jsxs)(B,{variant:`positiveOutline`,className:`w-full rounded-full`,size:`lg`,accessKey:`t`,children:[(0,z.jsx)(C,{}),(0,z.jsxs)(`span`,{children:[`Create a `,(0,z.jsx)(`u`,{children:`T`}),`able`]})]})})}),(0,z.jsxs)(X,{className:`sm:max-w-[425px]`,children:[(0,z.jsxs)(Zo,{children:[(0,z.jsx)(Q,{children:`Create a New Table`}),(0,z.jsx)(Qo,{children:`What would you like to create?`})]}),(0,z.jsx)(H,{...s,children:(0,z.jsxs)(`form`,{id:`instance-new-table-form`,name:`instance-new-table-form`,onSubmit:s.handleSubmit(l),className:`grid gap-6 text-white`,children:[(0,z.jsx)(W,{control:s.control,name:`tableName`,render:({field:e})=>(0,z.jsxs)(G,{className:``,children:[(0,z.jsx)(K,{className:`pb-1`,children:`Table Name`}),(0,z.jsx)(U,{children:(0,z.jsx)(J,{...e,type:`text`,maxLength:$h.shape.tableName.maxLength,autoFocus:!0,autoCapitalize:`off`,autoComplete:`off`,autoCorrect:`off`})}),(0,z.jsx)(q,{})]})}),(0,z.jsx)(W,{control:s.control,name:`primaryKey`,render:({field:e})=>(0,z.jsxs)(G,{className:``,children:[(0,z.jsx)(K,{className:`pb-1`,children:`Primary Key`}),(0,z.jsx)(U,{children:(0,z.jsx)(J,{...e,placeholder:`id`,type:`text`,maxLength:$h.shape.primaryKey.maxLength,autoCapitalize:`off`,autoComplete:`off`,autoCorrect:`off`})}),(0,z.jsx)(q,{})]})}),(0,z.jsx)(W,{control:s.control,name:`databaseName`,render:({field:e})=>(0,z.jsxs)(G,{className:``,children:[(0,z.jsx)(K,{className:`pb-1`,children:`Database Name`}),(0,z.jsx)(U,{children:(0,z.jsx)(J,{...e,type:`text`,placeholder:`data`,maxLength:$h.shape.databaseName.maxLength,autoCapitalize:`off`,autoComplete:`off`,autoCorrect:`off`})}),(0,z.jsx)(q,{})]})}),(0,z.jsx)(Z,{children:(0,z.jsxs)(B,{type:`submit`,variant:`submit`,className:`rounded-full`,children:[(0,z.jsx)(rn,{}),`Create New Table`]})})]})})]})]})}function tg({instanceDatabaseMap:e}){let t=kn(),n=!e,r=M({strict:!1}),i=T(),a=ua(),{databaseNames:o,tableNames:s}=(0,L.useMemo)(()=>({databaseNames:Object.keys(e||{}).sort(),tableNames:r.databaseName?Object.keys(e?.[r.databaseName]||[]).sort():[]}),[e,r.databaseName]),c=(0,L.useCallback)(n=>{let a=n?Object.keys(e?.[n]||[]).sort():[];r.databaseName?i({to:Jh({...r,databaseName:n,tableName:a[0]})}):t.invalidate()},[e,r,t,i]),l=(0,L.useCallback)((e,t)=>{i({to:Jh({...r,databaseName:e,tableName:t})})},[i,r]);return(0,z.jsxs)(`div`,{className:`pl-3`,children:[(0,z.jsx)(`h1`,{className:`pt-3 pb-3 text-3xl`,children:`Databases`}),n?(0,z.jsx)(Ec,{className:`w-full h-9 m-0 rounded-md bg-gray-700`}):(0,z.jsx)(`div`,{className:`flex space-x-2`,children:(0,z.jsxs)(Dc,{name:`databaseSelect`,value:r.databaseName||``,disabled:o.length===0,onValueChange:c,children:[(0,z.jsx)(Ac,{className:`w-full`,children:(0,z.jsx)(kc,{placeholder:`Select a Database`})}),(0,z.jsx)(jc,{children:(0,z.jsx)(Oc,{children:o.map(e=>(0,z.jsx)($,{value:e,children:e},e))})})]})}),n?(0,z.jsx)(Ec,{className:`w-full min-h-80 rounded-md bg-gray-700 mb-0`}):(0,z.jsxs)(Yh,{className:`border rounded-md min-h-80 border-grey-700 mt-4`,children:[s.length===0&&r.databaseName?.length?(0,z.jsxs)(`div`,{className:`w-full h-full text-center`,children:[(0,z.jsx)(`p`,{className:`py-6`,children:`No tables found in this database.`}),a&&(0,z.jsx)(`p`,{children:`Tap "Create a Table" below!`})]}):s.length===0&&!r.databaseName?.length?(0,z.jsxs)(`p`,{className:`pt-2 text-sm text-center`,children:[`Please `,o.length===0?`create`:`select`,` a table.`]}):``,(0,z.jsx)(`ul`,{children:s.map(e=>(0,z.jsx)(`li`,{className:`flex items-center p-2 border-b hover:bg-grey-700/80 border-grey-700`,children:(0,z.jsxs)(B,{onClick:()=>l(r.databaseName,e),size:`lg`,className:`items-center justify-between w-full bg-transparent border-none shadow-none hover:bg-transparent`,children:[e,(0,z.jsx)(`span`,{children:r.tableName===e&&(0,z.jsx)(vt,{})})]})},e))})]}),a&&(0,z.jsx)(eg,{databaseName:r.databaseName,onSelectTable:l})]})}function ng(e){if(!e)return{dataTableColumns:[],primaryKey:``};let t=e.primary_key??e.hash_attribute??``,{attributes:n}=e,r=[],i=[],a=[],o=[];for(let e=n.length-1;e>=0;e--){let{attribute:t,type:s,is_primary_key:c,indexed:l}=n[e],u={header:t,accessorKey:t,enableSorting:!!(c||l),enableColumnFilter:!!(c||l),size:rg(s)};c?r.push(u):t===`__createdtime__`||t===`__updatedtime__`?o.push(u):u.enableSorting?i.push(u):a.push(u)}return{dataTableColumns:[...r,...i,...a,...o],primaryKey:t}}function rg(e){switch(e){case`Id`:case`ID`:return 1;case`Boolean`:return 1;case`Int`:case`Long`:case`Float`:case`BigInt`:return 1;default:return Math.round(window.innerWidth*.1)}}async function ig({databaseName:e,tableName:t,records:n,instanceClient:r}){let{data:i}=await r.post(`/`,{operation:`insert`,database:e,table:t,records:n});return i}function ag(){return E({mutationFn:ig})}function og({isModalOpen:e,instanceTable:t,setIsModalOpen:n,refreshTable:r}){let{mutate:i,isPending:a}=ag(),o=V(),[s,c]=(0,L.useState)(!0),[l,u]=(0,L.useState)(),[d,f]=(0,L.useState)(!1),[p,m]=(0,L.useState)([]),h=(0,L.useMemo)(()=>{let e={};for(let n of t.attributes)n.is_primary_key||n.attribute===`__createdtime__`||n.attribute===`__updatedtime__`||(e[n.attribute]=sg(n.type));return JSON.stringify(e,null,4)},[t]),g=(0,L.useCallback)(e=>{f(!0),c(e.length===0)},[c]),_=(0,L.useCallback)(()=>{if(l&&s){let e=JSON.parse(l),a=Array.isArray(e)?e:[e],s=k.loading(`Adding ${a.length} records...`);i({...o,databaseName:t.schema,tableName:t.name,records:a},{onSuccess:e=>{r(),e.skipped_hashes?.length||n(!1),m(e.skipped_hashes),(e.skipped_hashes?.length>0?k.warning:k.success)(e.skipped_hashes?.length>0?`Warning!`:`Success!`,{id:s,description:(0,z.jsxs)(z.Fragment,{children:[e.inserted_hashes.length>0&&(0,z.jsxs)(`p`,{children:[`Added `,Qr(e.inserted_hashes.length,`record`,`records`)]}),e.skipped_hashes.length>0&&(0,z.jsxs)(`p`,{children:[`Skipped `,Qr(e.skipped_hashes.length,`record`,`records`)]})]})})}})}},[l,i,o,t.name,t.schema,s,r,n]),v=(0,L.useCallback)(e=>{e?.focus()},[]);return(0,z.jsx)(Y,{onOpenChange:n,open:e,children:(0,z.jsxs)(X,{"aria-describedby":void 0,onEscapeKeyDown:e=>{d&&e.preventDefault()},children:[(0,z.jsx)(Zo,{children:(0,z.jsxs)(Q,{children:[`Add New `,t.name]})}),(t?.primary_key??t?.hash_attribute)&&(0,z.jsxs)(`div`,{className:`text-sm text-gray-500`,children:[`The primary key for this table is`,` `,(0,z.jsxs)(`strong`,{children:[`“`,t.primary_key??t.hash_attribute,`”`]}),`, and will auto-generate. You may manually add it if you want to specify its value.`]}),(0,z.jsx)(De,{className:`w-full h-96`,language:`json`,theme:`vs-dark`,value:h,onValidate:g,onChange:u,options:{minimap:{enabled:!1}},onMount:v}),(0,z.jsxs)(`div`,{className:`text-sm text-gray-500`,children:[(0,z.jsx)(`strong`,{children:`Provide an [array]`}),` if you want to add more than one record at a time.`]}),p.length>0&&(0,z.jsxs)(ap,{className:`mt-2`,children:[(0,z.jsx)(cr,{className:`w-4 h-4`}),(0,z.jsxs)(op,{children:[`Skipped `,p.length===1?`Hash`:`Hashes`,` Detected`]}),(0,z.jsx)(sp,{className:`max-h-36 overflow-auto`,children:(0,z.jsx)(`ol`,{children:p.map(e=>(0,z.jsx)(`li`,{children:e},e))})})]}),(0,z.jsx)(Z,{children:(0,z.jsx)(`div`,{className:`flex justify-between w-full`,children:(0,z.jsxs)(B,{variant:`submit`,className:`rounded-full`,onClick:_,accessKey:`s`,disabled:!l||!s||a,children:[(0,z.jsx)(Jt,{}),` `,(0,z.jsxs)(`span`,{children:[(0,z.jsx)(`u`,{children:`S`}),`ave Changes`]})]})})})]})})}function sg(e){switch(e){case`Date`:return new Date().toISOString();case`Id`:case`ID`:case`String`:return``;case`Boolean`:return!1;case`Int`:case`Long`:case`Float`:case`BigInt`:return 0;default:return null}}async function cg({databaseName:e,replicated:t,instanceClient:n}){let{data:r}=await n.post(`/`,{operation:`drop_database`,database:e,replicated:t});return r}function lg(){return E({mutationFn:cg})}function ug({databaseName:e,onDeleted:t}){let{value:n,trigger:r}=lf(`ShowDeleteDatabase`,!1),i=(0,L.useCallback)(()=>{uf(`ShowDeleteDatabase`,!1),Up(r)},[r]),a=ua(),o=Vt(),s=V(),c=kn(),{mutate:l,isPending:u}=lg(),d=(0,L.useCallback)(()=>{l({databaseName:e,...s,replicated:s.entityType===`cluster`},{onSuccess:async()=>{i(),await o.invalidateQueries({queryKey:[s.entityId,`describe_all`],refetchType:`all`}),await c.invalidate(),k.success(`Database ${e} dropped successfully`),t(`database`)}})},[i,e,l,s,t,o,c]);return!a||!e?(0,z.jsx)(z.Fragment,{}):(0,z.jsx)($o,{typeOfThingBeingDeleted:`database`,nameOfThingBeingDeleted:e,transitiveVerb:`Drop`,presentParticiple:`Dropping`,isModalOpen:n,setIsModalOpen:i,deletionConfirmed:d,deletionPending:u})}async function dg({databaseName:e,tableName:t,replicated:n,instanceClient:r}){let{data:i}=await r.post(`/`,{operation:`drop_table`,database:e,table:t,replicated:n});return i}function fg(){return E({mutationFn:dg})}function pg({databaseName:e,tableName:t,onDeleted:n}){let{value:r,trigger:i}=lf(`ShowDeleteTable`,!1),a=(0,L.useCallback)(()=>{uf(`ShowDeleteTable`,!1),Up(i)},[i]),o=ua(),s=Vt(),c=V(),l=kn(),{mutate:u,isPending:d}=fg(),f=(0,L.useCallback)(()=>{u({databaseName:e,tableName:t,...c,replicated:c.entityType===`cluster`},{onSuccess:async()=>{a(),await s.invalidateQueries({queryKey:[c.entityId,`describe_all`],refetchType:`all`}),await l.invalidate(),k.success(`Table ${t} dropped successfully`),n(`table`)}})},[a,e,u,c,n,s,l,t]);return!o||!e?(0,z.jsx)(z.Fragment,{}):(0,z.jsx)($o,{typeOfThingBeingDeleted:`table`,nameOfThingBeingDeleted:`${e} > ${t}`,transitiveVerb:`Drop`,presentParticiple:`Dropping`,isModalOpen:r,setIsModalOpen:a,deletionConfirmed:f,deletionPending:d})}function mg({canEditRecords:e,canDeleteRecords:t,setIsModalOpen:n,isModalOpen:r,primaryKey:i,data:a,onSaveChanges:o,onDeleteRecord:s,isUpdateTableRecordsPending:c,isDeleteTableRecordsPending:l}){let[u,d]=(0,L.useState)(!0),[f,p]=(0,L.useState)(!1),[m,h]=(0,L.useState)(),g=(0,L.useMemo)(()=>{let e=a?.map(({__createdtime__:e,__updatedtime__:t,...n})=>n);return JSON.stringify(e,null,4)},[a]),_=(0,L.useCallback)(e=>{p(!0),d(e.length===0)},[d]);return(0,z.jsx)(Y,{onOpenChange:n,open:r,children:(0,z.jsxs)(X,{"aria-describedby":void 0,autoFocus:e,onEscapeKeyDown:e?e=>{f&&e.preventDefault()}:void 0,children:[(0,z.jsx)(Zo,{children:(0,z.jsxs)(Q,{children:[e?`Edit`:`View`,` Row`]})}),a?(0,z.jsx)(De,{className:`w-full h-96`,language:`json`,theme:`vs-dark`,options:e?void 0:{readOnly:!0},value:g,onValidate:_,onChange:e=>{h(e)}}):(0,z.jsx)(Ss,{}),(0,z.jsx)(Z,{children:(0,z.jsxs)(`div`,{className:`flex justify-between w-full`,children:[t&&(0,z.jsxs)(B,{variant:`destructive`,className:`rounded-full`,type:`button`,autoFocus:!1,onClick:()=>{let e=a[0]?.[i];e&&s([e])},disabled:l,children:[(0,z.jsx)($t,{}),` Delete Row`]}),e&&(0,z.jsxs)(B,{variant:`submit`,className:`rounded-full`,autoFocus:!0,accessKey:`s`,onClick:()=>{m&&u?o(JSON.parse(m)):n(!1)},disabled:!u||c,children:[(0,z.jsx)(Jt,{}),` `,(0,z.jsxs)(`span`,{children:[(0,z.jsx)(`u`,{children:`S`}),`ave Changes`]})]})]})})]})})}async function hg(e){let{database:t,table:n,fileData:r,instanceClient:i}=e,{data:a}=await i.post(`/`,{operation:`csv_data_load`,database:t,action:`insert`,table:n,data:r});return a}function gg(){return E({mutationFn:hg})}var _g=l({fileData:v(),database:v(),table:v()});function vg({setIsModalOpen:e,isModalOpen:t,onSaveChanges:n,database:r,table:i}){let[a,o]=(0,L.useState)(null),s=V(),{mutate:c,isPending:l}=gg(),u=e=>{if(!e.target.files)return;let t=e.target.files[0];if(t){let e=new FileReader;e.onload=e=>{let n=e.target?.result;typeof n==`string`&&(o(t),d.setValue(`fileData`,n))},e.readAsText(t)}},d=N({resolver:w(_g),defaultValues:{database:r,table:i,fileData:``}}),f=e=>{c({fileData:e.fileData,database:r,table:i,...s},{onSuccess:({message:e})=>{d.reset(),o(null),n(e)}})};return(0,z.jsx)(Y,{onOpenChange:()=>{e(!1),d.reset()},open:t,children:(0,z.jsxs)(X,{children:[(0,z.jsxs)(Zo,{children:[(0,z.jsx)(Q,{children:`Import CSV`}),(0,z.jsx)(Qo,{children:`Upload a CSV file to import data into the table.`})]}),(0,z.jsx)(H,{...d,children:(0,z.jsxs)(`form`,{id:`instance-import-csv-form`,name:`instance-import-csv-form`,onSubmit:d.handleSubmit(f),children:[(0,z.jsx)(`div`,{className:`w-full`,children:(0,z.jsx)(W,{control:d.control,name:`fileData`,render:({field:e})=>(0,z.jsxs)(G,{className:`relative`,children:[(0,z.jsx)(K,{htmlFor:`dropzone-file`,className:`flex flex-col items-center justify-center w-full h-64 border-2 border-grey border-dashed rounded-lg cursor-pointer bg-grey-700 hover:bg-grey-700/80`,children:(0,z.jsx)(U,{children:(0,z.jsxs)(`div`,{children:[(0,z.jsxs)(`div`,{className:`flex flex-col items-center justify-center pt-5 pb-6`,children:[(0,z.jsx)(ur,{className:`text-white`,size:48}),(0,z.jsx)(`p`,{className:`mb-2 text-sm text-white`,children:a?a.name:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`font-semibold`,children:`Click to upload`}),` or drag and drop a CSV File`]})})]}),(0,z.jsx)(J,{id:`dropzone-file`,type:`file`,className:`opacity-0 w-full h-full absolute left-0 top-0 cursor-pointer`,accept:`.csv`,name:e.name,ref:e.ref,onBlur:e.onBlur,disabled:e.disabled,onChange:u})]})})}),(0,z.jsx)(q,{})]})})}),(0,z.jsx)(Z,{className:`mt-4`,children:(0,z.jsxs)(B,{variant:`submit`,className:`rounded-full`,accessKey:`u`,disabled:!a||l,children:[(0,z.jsx)(Jt,{}),(0,z.jsxs)(`span`,{children:[(0,z.jsx)(`u`,{children:`U`}),`pload CSV`]})]})})]})})]})})}async function yg({databaseName:e,instanceClient:t}){let{data:n}=await t.post(`/`,{operation:`cleanup_orphan_blobs`,database:e});return n}function bg(){return E({mutationFn:yg})}async function xg({databaseName:e,tableName:t,hashValues:n,instanceClient:r}){let{data:i}=await r.post(`/`,{operation:`delete`,database:e,table:t,hash_values:n});return i}function Sg(){return E({mutationFn:xg})}async function Cg({databaseName:e,tableName:t,instanceClient:n}){let{data:r}=await n.post(`/`,{operation:`describe_table`,database:e,table:t});return r}function wg(e){return A({queryKey:[e.entityId,e.databaseName,e.tableName,`describe_table`],queryFn:()=>Cg(e),staleTime:6e4,gcTime:5e3,enabled:!!e.databaseName&&!!e.tableName,retry:!1})}var Tg=[`1`,`bet`,`k`,`ok`,`si`,`tru`,`true`,`yes`,`yup`];function Eg(e){let t=e.toLowerCase().trim();return Tg.includes(t)}function Dg(e){return!isNaN(e)&&!isNaN(parseFloat(e))}function Og(e){if(e.startsWith(`0.`)&&Dg(e))return!0;let t=e.toUpperCase().includes(`E`);return!(e!==`0`&&e.startsWith(`0`))&&!t&&Dg(e)}var kg={true:!0,TRUE:!0,false:!1,FALSE:!1,undefined:null,null:null,NULL:null,NaN:NaN},Ag=/^((\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z)))$/;function jg(e){return e==null||e===``||typeof e!=`string`?e:kg[e]===void 0?Og(e)?Number(e):Ag.test(e)?new Date(e):e:kg[e]}function Mg(e){let{enabled:t,entityId:n,databaseName:r,tableName:i,conditions:a,sort:o,pageIndex:s,pageSize:c,onlyIfCached:l}=e;return A({enabled:t&&!!a,queryKey:[n,r,i,`search_by_conditions`,a,o.attribute||`default`,o.descending||!1,s||0,c||0,l],staleTime:6e4,gcTime:5e3,retry:!1,queryFn:()=>Ng(e)})}function Ng({instanceClient:e,databaseName:t,tableName:n,conditions:r,sort:i,pageIndex:a,pageSize:o,onlyIfCached:s,headers:c}){return e.post(`/`,{operation:`search_by_conditions`,get_attributes:[`*`],database:t,table:n,conditions:r,sort:i.attribute.length?i:void 0,offset:a*o,limit:o,onlyIfCached:s,noCacheStore:s},{timeout:0,headers:c})}function Pg(e,t,n){return t.split(/ & /).map(t=>Fg(e,t,n))}function Fg(e,t,n){t.startsWith(e)&&(t=t.substring(e.length));let{comparator:r,value:i}=Rg(t);switch(n?.type){case`ID`:case`String`:return{search_attribute:e,search_type:r,search_value:i};case`Int`:case`BigInt`:case`Long`:case`Float`:{let t=n.type.includes(`Int`)?parseInt(i,10):parseFloat(i);if(isNaN(t))throw Error(`${i} does not appear to be a valid number.`);return{search_attribute:e,search_type:r,search_value:t}}case`Date`:return{search_attribute:e,search_type:r,search_value:new Date(i).toISOString()};case`Boolean`:return{search_attribute:e,search_type:r,search_value:Eg(i)};case`Blob`:case`Bytes`:return{search_attribute:e,search_type:r,search_value:i};default:return{search_attribute:e,search_type:r,search_value:jg(i)}}}var Ig={"=== ":`equals`,"== ":`eq`,"equals ":`equals`,"equal ":`equals`,"eq ":`eq`,"!== ":`not_equal`,"!= ":`ne`,"notequals ":`not_equal`,"notequal ":`not_equal`,"ne ":`ne`},Lg={">":`greater_than`,g:`greater_than`,gt:`greater_than`,"=gt":`greater_than`,greater:`greater_than`,greaterthan:`greater_than`,">=":`greater_than_equal`,ge:`greater_than_equal`,"=ge":`greater_than_equal`,gte:`greater_than_equal`,greaterorequal:`greater_than_equal`,greaterthanequal:`greater_than_equal`,greaterthanorequal:`greater_than_equal`,"<":`less_than`,l:`less_than`,lt:`less_than`,"=lt":`less_than`,less:`less_than`,lessthan:`less_than`,"<=":`less_than_equal`,lte:`less_than_equal`,le:`less_than_equal`,"=le":`less_than_equal`,lessorequal:`less_than_equal`,lessthanequal:`less_than_equal`,lessthanorequal:`less_than_equal`};function Rg(e){let t=e.toLowerCase(),n=t.match(/^([>=<a-z_ ]+)([\d._TZ-]+)$/);if(n){let e=n[1].replace(/[_ ]+/g,``).replace(/^([a-z]+)=$/g,`$1`),t=n[2],r=Lg[e];if(r)return{comparator:r,value:t}}for(let n in Ig)if(t.startsWith(n))return{comparator:Ig[n],value:e.slice(n.length)};return t.endsWith(`*`)?{comparator:`starts_with`,value:e.slice(0,-1)}:{comparator:`equals`,value:e}}function zg({enabled:e,entityId:t,instanceClient:n,databaseName:r,tableName:i,ids:a}){return A({queryKey:[t,`search_by_id`,r,i,a],queryFn:()=>n.post(`/`,{get_attributes:[`*`],ids:a,noCacheStore:!0,onlyIfCached:!0,operation:`search_by_id`,database:r,table:i}),enabled:e&&!!a?.length,retry:!1})}async function Bg(e){let{databaseName:t,tableName:n,records:r,instanceClient:i}=e,{data:a}=await i.post(`/`,{operation:`update`,database:t,table:n,records:r});return a}function Vg(){return E({mutationFn:Bg})}var Hg=a(v(),v());function Ug({applyFilters:e,columnFiltersForm:t,headerGroups:n}){let r=(0,L.useCallback)(t=>{if(t.key===`Enter`)return t.preventDefault(),e(),!1},[e]);return(0,z.jsx)(jl,{children:(0,z.jsx)(H,{...t,children:n.map(e=>(0,z.jsx)(Nl,{className:`border-none`,children:e.headers.map(e=>(0,z.jsx)(Il,{style:{width:`${e.column.getSize()}px`},children:e.column.columnDef.enableColumnFilter&&(0,z.jsx)(W,{control:t.control,name:e.id,render:({field:e})=>(0,z.jsxs)(G,{className:`border-r-1 border-r-black`,children:[(0,z.jsx)(U,{children:(0,z.jsx)(J,{...e,type:`text`,autoCapitalize:`none`,autoComplete:`off`,className:`rounded-none`,onKeyDown:r,value:e.value??``})}),(0,z.jsx)(q,{})]})})},e.id))},e.id))})})}function Wg({columns:e,columnVisibility:t,setColumnVisibility:n}){let r=(0,L.useMemo)(()=>e.map(e=>e.header).filter(Ni),[e]);return(0,z.jsxs)(ts,{children:[(0,z.jsx)(ns,{asChild:!0,children:(0,z.jsxs)(B,{variant:`ghost`,children:[(0,z.jsx)(fn,{className:`inline-block `}),`Columns`]})}),(0,z.jsx)(rs,{children:r.map(e=>(0,z.jsx)(Gg,{columnHeader:e,columnVisibility:t,setColumnVisibility:n},e))})]})}function Gg({columnHeader:e,columnVisibility:t,setColumnVisibility:n}){let{toggled:r,toggle:i}=Xp(t[e]??!0);return(0,L.useEffect)(()=>{t[e]!==r&&n({...t,[e]:r})},[e,t,r,n]),(0,z.jsx)(as,{checked:r,onClick:i,children:e},e)}function Kg({className:e}){return(0,z.jsx)(ce,{className:i(`animate-spin`,e)})}function qg({applyFilters:e,columnFiltersForm:t,columns:n,columnVisibility:r,data:i,isFetching:a,onColumnClick:o,onRowClick:s,pageIndex:c,pageSize:l,primaryKey:u,setPageIndex:d,setPageSize:f,filtersToggled:p,totalPages:m,totalRecords:h}){let g=Ie({data:i||[],columns:n,manualPagination:!0,enableColumnResizing:!0,columnResizeMode:`onEnd`,pageCount:m,defaultColumn:{minSize:1},state:{columnVisibility:r},rowCount:h,getCoreRowModel:Mt(),getPaginationRowModel:Bt()}),_=(0,L.useCallback)(()=>{d(c-1)},[c,d]),v=(0,L.useCallback)(()=>{d(c+1)},[c,d]);return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(Al,{containerClassName:`rounded-md bg-black-dark grow max-h-[calc(100vh-128px-16px-112px-80px)]`,children:[(0,z.jsx)(jl,{children:g.getHeaderGroups().map(e=>(0,z.jsx)(Nl,{className:`border-none`,children:e.headers.map(e=>(0,z.jsx)(Fl,{header:e,onColumnClick:o},e.id))},e.id))}),p&&(0,z.jsx)(Ug,{applyFilters:e,columnFiltersForm:t,headerGroups:g.getHeaderGroups()}),(0,z.jsx)(Ml,{className:`bg-black border border-grey-700`,children:g.getRowModel().rows?.length?g.getRowModel().rows.map(e=>(0,z.jsx)(Jg,{row:e,onRowClick:s,primaryKey:u},e.id)):(0,z.jsx)(Nl,{children:(0,z.jsx)(Il,{colSpan:n.length,className:`h-24 text-center`,children:a||i===void 0?(0,z.jsx)(Kg,{className:`opacity-50 inline-block`}):(0,z.jsx)(`span`,{children:`No results.`})})})})]}),(0,z.jsxs)(`div`,{className:`flex items-center justify-end py-4 space-x-2 pr-4`,children:[(0,z.jsxs)(B,{variant:`defaultOutline`,size:`sm`,onClick:_,className:`select-none`,disabled:c===0,children:[(0,z.jsx)(Et,{}),`Previous`]}),(0,z.jsx)(`div`,{className:`grow`}),(0,z.jsxs)(`div`,{className:`text-center`,children:[(0,z.jsx)(`dt`,{className:`font-medium text-gray-500 text-sm/6 dark:text-gray-400`,children:`Records`}),(0,z.jsx)(`dd`,{className:`font-semibold tracking-tight`,children:h===void 0?(0,z.jsx)(Ec,{}):Zc(h)})]}),h!==void 0&&h>0&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{children:(0,z.jsxs)(Dc,{defaultValue:l.toString(),onValueChange:e=>{f(Number(e))},children:[(0,z.jsx)(Ac,{className:`h-10 w-20`,children:(0,z.jsx)(kc,{})}),(0,z.jsx)(jc,{side:`top`,children:[20,50,100,250].map(e=>(0,z.jsx)($,{value:`${e}`,children:e},e))})]})}),m!==void 0&&m>1&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`text-center`,children:[(0,z.jsx)(`dt`,{className:`font-medium text-gray-500 text-sm/6 dark:text-gray-400`,children:`Pages`}),(0,z.jsx)(`dd`,{className:`font-semibold tracking-tight`,children:Zc(m)})]}),(0,z.jsxs)(`div`,{className:`text-center`,children:[(0,z.jsx)(`dt`,{className:`font-medium text-gray-500 text-sm/6 dark:text-gray-400`,children:`Page`}),(0,z.jsx)(`dd`,{className:`font-semibold tracking-tight`,children:Zc(c+1)})]})]})]}),(0,z.jsx)(`div`,{className:`grow`}),(0,z.jsxs)(B,{variant:`defaultOutline`,size:`sm`,onClick:v,className:`select-none`,disabled:m===void 0||c===m-1,children:[`Next`,(0,z.jsx)(vt,{})]})]})]})}function Jg({row:e,primaryKey:t,onRowClick:n}){let r=(0,L.useMemo)(()=>{let n=e.original,r=n&&n.message===`This entry has expired`,i=e.getVisibleCells();return console.log(`primaryKey, visibleCells`,t,i),r?i[0]?.column?.id===t?[(0,z.jsx)(Yg,{cell:i[0]},i[0].id),(0,z.jsx)(Xg,{colSpan:i.length-1},`expired`)]:[(0,z.jsx)(Xg,{colSpan:i.length},`expired`)]:i.map(e=>(0,z.jsx)(Yg,{cell:e},e.id))},[e,t]);return(0,z.jsx)(Nl,{"data-state":e.getIsSelected()&&`selected`,onClick:()=>n?.(e),className:R(`hover:bg-muted/10 data-[state=selected]:bg-muted`,n&&`cursor-pointer`),children:r})}function Yg({cell:e}){return(0,z.jsx)(Il,{style:{width:`${e.column.getSize()}px`},className:`px-2 py-2 overflow-x-hidden max-w-32 text-ellipsis whitespace-nowrap`,children:e.getValue()==`[object Object]`?JSON.stringify(e.getValue()):Jn(e.column.columnDef.cell,e.getContext())})}function Xg({colSpan:e}){return(0,z.jsx)(Il,{colSpan:e,className:`px-2 py-2 overflow-x-hidden max-w-32 text-ellipsis whitespace-nowrap`,children:(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:`This entry has expired`})})}function Zg({instanceDatabaseMap:e,databaseName:t,tableName:n}){let r=M({strict:!1}),i=T(),a=V(),{clusterId:o,instanceId:s}=r,{toggled:c,toggle:l}=Xp(!0),u=gi(),d=da(s??o,t,n,`insert`),f=da(s??o,t,n,`update`),p=da(s??o,t,n,`delete`),m=ua(),{data:h}=D(wg({...a,databaseName:t,tableName:n})),g=(0,L.useMemo)(()=>Fs(h?.attributes??[],`attribute`),[h]),[_,v]=zd(null,r),[y,b]=(0,L.useState)(!1),x=(0,L.useMemo)(()=>(t?Object.keys(e?.[t]||[]).sort():[]).length===1,[e,t]),{toggled:ee,toggleOn:ne,toggleOff:re}=Xp(!1),ie=N({resolver:w(Hg)}),{reset:S}=ie,ae=ie.watch(),[oe,se]=zd(null,[r.clusterId,r.instanceId,t,n]),ce=(0,L.useCallback)(()=>{let e=[];for(let t in ae)if(ae[t]?.length)try{e.push(...Pg(t,ae[t],g[t]))}catch(e){k.error(String(e))}se(e.length?e:null),S({...ae})},[g,S,ae]),le=(0,L.useCallback)(()=>{S({},{keepValues:!1,keepDirtyValues:!1,keepDefaultValues:!1}),S(),se(null),re()},[re,S]);(0,L.useEffect)(function(){return le()},[r,le]);let{dataTableColumns:de,primaryKey:pe}=ng(h),[me,he]=(0,L.useState)(!1),[ge,_e]=(0,L.useState)(!1),[ve,ye]=zd({attribute:pe,descending:!1},r),[be,xe]=zd(0,[t,n]),[Se,Ce]=(0,L.useState)(20),we=h?.record_count,Te=h?.record_count?Math.ceil(h.record_count/Se):0,Ee=ee&&!!oe,De={...a,enabled:!Ee&&!!pe,databaseName:t,tableName:n,searchAttribute:pe,sort:ve,pageSize:Se,pageIndex:be,onlyIfCached:c},Oe=Yu(De),{data:ke,isFetching:Ae}=D(Oe),je={...a,enabled:Ee&&!!pe,databaseName:t,tableName:n,conditions:oe,sort:ve,pageSize:Se,pageIndex:be,onlyIfCached:c},Me=Mg(je),{data:Ne,isFetching:Pe}=D(Me),Fe=Ee?Ne:ke,Ie=Ae||Pe,{data:Le}=D(zg({...a,enabled:y,databaseName:t,tableName:n,ids:_})),{mutate:Re,isPending:ze}=Vg(),{mutate:Be,isPending:Ve}=Sg(),{mutate:He,isPending:Ue}=bg(),We=Vt(),Ge=(0,L.useCallback)(()=>We.invalidateQueries({queryKey:[a.entityId,t,n]}),[We,a.entityId,t,n]),Ke=(0,L.useCallback)(async()=>{confirm(`Are you sure you want to cleanup orphan blobs for database "${t}"?`)&&He({...a,databaseName:t},{onSuccess:e=>{k.success(e.message||`Orphan blobs cleanup started successfully`),Ge()},onError:e=>{k.error(e instanceof Error?e.message:`Failed to cleanup orphan blobs`)}})},[He,t,a,Ge]),[qe,Je]=(0,L.useState)(!1),Ye=(0,L.useCallback)(async()=>{if(!pe)return;let e=k.loading(`Loading CSV...`);Je(!0);let r={pageIndex:0,pageSize:1e6,headers:{Accept:`text/csv`}},i=await(Ee?Ng({...je,...r}):Xu({...De,...r}));k.loading(`Preparing CSV...`,{id:e});let a=i.data,o=new Blob([a],{type:`text/csv`}),s=URL.createObjectURL(o),c=document.createElement(`a`);c.href=s,c.setAttribute(`download`,`${t}.${n}.${new Date().toISOString()}.csv`),c.click(),k.success(`CSV Exported!`,{id:e}),Je(!1)},[t,n,Oe,Me]),Xe=(0,L.useCallback)(e=>{Re({...a,databaseName:t,tableName:n,records:e},{onSuccess:()=>{Ge(),b(!1),k.success(`Record updated successfully`)}})},[Re,a,t,n,Ge]),Ze=(0,L.useCallback)(e=>{Be({...a,databaseName:t,tableName:n,hashValues:e},{onSuccess:()=>{Ge(),b(!1),k.success(`Record deleted successfully`)}})},[Be,a,t,n,Ge]),Qe=(0,L.useCallback)(e=>{Ge(),_e(!1),k.success(`${e}. Please wait a few moments then refresh the table.`)},[Ge]),$e=e=>{v([e.original[pe]]),b(!y)},tt=(e,t)=>{ye({attribute:e,descending:!t})},nt=Hl(Ge),rt=(0,L.useCallback)(()=>{he(!0)},[he]),it=(0,L.useCallback)(()=>{_e(!0)},[_e]),at=(0,L.useCallback)(e=>void i({to:e===`table`?`../`:`../../`}),[i]),[ot,st]=qd(`ColumnDisplayed/${t}}/${n}`,{}),ct=ff(`ShowDeleteTable`,!0),lt=ff(`ShowDeleteDatabase`,!0);return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`flex flex-col md:flex-row items-center justify-between space-y-3 md:space-y-0 md:space-x-3 pt-15 pb-4 pr-4`,children:[(0,z.jsxs)(`div`,{className:`flex space-x-2`,children:[d&&(0,z.jsxs)(B,{variant:`positiveOutline`,onClick:rt,disabled:me,accessKey:`n`,children:[(0,z.jsx)(C,{}),(0,z.jsxs)(`span`,{children:[`Add `,(0,z.jsx)(`u`,{children:`N`}),`ew Record(s)`]})]}),d&&(0,z.jsxs)(B,{variant:`positiveOutline`,onClick:it,disabled:ge,accessKey:`c`,children:[(0,z.jsx)(ur,{}),(0,z.jsxs)(`span`,{children:[`Import `,(0,z.jsx)(`u`,{children:`C`}),`SV`]})]}),(0,z.jsxs)(B,{variant:`positiveOutline`,onClick:Ye,disabled:qe,accessKey:`e`,children:[(0,z.jsx)(yr,{}),(0,z.jsxs)(`span`,{children:[(0,z.jsx)(`u`,{children:`E`}),`xport CSV`]})]})]}),(0,z.jsxs)(`div`,{className:`flex space-x-2`,children:[ee&&oe&&(0,z.jsxs)(B,{type:`button`,variant:`ghost`,onClick:le,accessKey:`f`,children:[(0,z.jsx)(an,{className:`inline-block `}),(0,z.jsxs)(`span`,{children:[`Clear `,(0,z.jsx)(`u`,{children:`F`}),`ilters`]})]}),ee&&ie.formState.isDirty&&(0,z.jsxs)(B,{variant:`default`,onClick:ce,children:[(0,z.jsx)(nr,{className:`inline-block `}),`Apply Filters`]}),ee&&!oe&&(0,z.jsxs)(B,{variant:`ghost`,onClick:re,accessKey:`f`,children:[(0,z.jsx)(an,{className:`inline-block `}),(0,z.jsxs)(`span`,{children:[`Hide `,(0,z.jsx)(`u`,{children:`F`}),`ilters`]})]}),!ee&&(0,z.jsxs)(B,{variant:`ghost`,onClick:ne,accessKey:`f`,children:[(0,z.jsx)(te,{className:`inline-block `}),(0,z.jsxs)(`span`,{children:[`Show `,(0,z.jsx)(`u`,{children:`F`}),`ilters`]})]}),(0,z.jsx)(B,{variant:`defaultOutline`,onClick:nt,disabled:Ie,children:(0,z.jsx)(fe,{})}),(0,z.jsx)(Wg,{columns:de,columnVisibility:ot,setColumnVisibility:st}),(0,z.jsxs)(ts,{children:[(0,z.jsx)(ns,{disabled:!e,children:(0,z.jsx)(tn,{"aria-label":`Table options`,color:e?`white`:`gray`})}),(0,z.jsxs)(rs,{side:`bottom`,align:`end`,children:[(0,z.jsxs)(is,{className:`focus:bg-primary/70 focus:text-white`,onClick:l,children:[c?(0,z.jsx)(ht,{className:`text-green`}):(0,z.jsx)(ue,{}),`Only If Cached`,(0,z.jsx)(j,{to:`https://docs.harperdb.io/docs/developers/applications/caching#cache-control-header`,target:`_blank`,rel:`noopener noreferrer`,onClick:yp,children:(0,z.jsx)(or,{})})]}),m&&u&&!!s&&(0,z.jsxs)(is,{className:`focus:bg-yellow/70 focus:text-white`,onClick:Ke,disabled:Ue,children:[(0,z.jsx)(et,{className:`text-yellow `}),`Cleanup Orphan Blobs`]}),m&&!x&&(0,z.jsxs)(is,{className:`focus:bg-red/70 focus:text-white`,onClick:ct,children:[(0,z.jsx)($t,{className:`inline-block `}),`Drop Table`]}),m&&(0,z.jsxs)(is,{className:`focus:bg-red/70 focus:text-white`,onClick:lt,children:[(0,z.jsx)(Mn,{}),`Drop Database`]})]})]})]})]}),(0,z.jsx)(qg,{primaryKey:pe,data:Fe?.data,isFetching:Ie,filtersToggled:ee,columns:de,columnVisibility:ot,onRowClick:$e,onColumnClick:tt,totalPages:Te,totalRecords:we,pageIndex:be,pageSize:Se,columnFiltersForm:ie,applyFilters:ce,setPageIndex:xe,setPageSize:Ce}),d&&h&&me&&(0,z.jsx)(og,{instanceTable:h,isModalOpen:me,refreshTable:Ge,setIsModalOpen:he}),(0,z.jsx)(mg,{canEditRecords:f,canDeleteRecords:p,setIsModalOpen:b,isModalOpen:y,primaryKey:pe,data:Le?.data,onSaveChanges:Xe,onDeleteRecord:Ze,isUpdateTableRecordsPending:ze,isDeleteTableRecordsPending:Ve}),(0,z.jsx)(ug,{databaseName:t,onDeleted:at}),(0,z.jsx)(pg,{databaseName:t,tableName:n,onDeleted:at}),(0,z.jsx)(vg,{isModalOpen:ge,setIsModalOpen:_e,onSaveChanges:Qe,database:t,table:n})]})}function Qg(){let e=M({strict:!1}),{data:t}=D(uh(V())),n,r;if(t){e.databaseName||(n=Object.keys(t).sort()[0]);let i=e.databaseName??n;!e.tableName&&i&&t[i]&&(r=Object.keys(t[i]).sort()[0])}return n||r?(0,z.jsx)(vn,{to:Jh({...e,databaseName:n??e.databaseName,tableName:r}),replace:!0}):(0,z.jsxs)(`main`,{className:`grid grid-cols-1 gap-4 md:grid-cols-12 min-h-[calc(100vh-(--spacing(36)))]`,children:[(0,z.jsx)(`section`,{className:`col-span-1 text-white md:col-span-4 lg:col-span-3`,children:(0,z.jsx)(tg,{instanceDatabaseMap:t})}),(0,z.jsx)(`section`,{className:`col-span-1 text-white md:col-span-8 lg:col-span-9 flex flex-col`,children:e.databaseName&&e.tableName&&(0,z.jsx)(Zg,{instanceDatabaseMap:t,databaseName:e.databaseName,tableName:e.tableName})})]})}function $g(e){return O({getParentRoute:()=>e,path:`/databases/{-$databaseName}/{-$tableName}`,component:Qg})}var e_={className:`text-white`};function t_(){let e=la(),t=M({strict:!1}),{version:n}=Xt({strict:!1}),r=Ls(`4.6.0`,n),i=Ls(`4.7.0-beta.7`,n),{data:a}=D(kd(V(),r)),o=a?.restartRequired??!1,s=(0,L.useMemo)(()=>[{to:Cl(t),activeOptions:{exact:!0},name:`Applications`,shortName:`Apps`,icon:(0,z.jsx)(S,{className:`inline-block`})},{to:Cl(t,`databases`),icon:(0,z.jsx)(Hn,{className:`inline-block`}),name:`Databases`},e&&i&&{to:Cl(t,`apis`),name:`APIs`,icon:(0,z.jsx)(mn,{className:`inline-block`})},e&&r&&{to:Cl(t,`status`),icon:(0,z.jsx)(at,{className:`inline-block`}),name:`Status`},e&&{to:Cl(t,`logs`),icon:(0,z.jsx)(Ge,{className:`inline-block`}),name:`Logs`},e&&{to:Cl(t,`config`),icon:(0,z.jsx)(_n,{className:`inline-block`}),name:`Config`}].filter(Ni),[e,t,i,r]);return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(n_,{links:s,restartRequired:o}),(0,z.jsx)(r_,{links:s,restartRequired:o})]})}function n_({links:e,restartRequired:t}){return(0,z.jsxs)(`div`,{className:`hidden md:flex items-center justify-between h-full text-sm text-white`,children:[(0,z.jsx)(Pa,{restartRequired:t}),(0,z.jsx)(`div`,{className:`flex space-x-2`,children:e.map(({shortName:e,...t})=>(0,z.jsxs)(j,{className:`p-2 text-center text-gray-400 hover:text-white`,activeProps:e_,...t,children:[t.icon,(0,z.jsx)(`span`,{className:`hidden xl:inline-block ml-1`,children:t.name}),e&&(0,z.jsx)(`span`,{className:`visible xl:hidden ml-1`,children:e})]},t.to))})]})}function r_({links:e,restartRequired:t}){return(0,z.jsx)(z.Fragment,{children:(0,z.jsxs)(`div`,{className:`flex md:hidden items-center justify-between h-full px-2 text-white`,children:[(0,z.jsx)(Pa,{restartRequired:t}),(0,z.jsxs)(ts,{children:[(0,z.jsx)(ns,{asChild:!0,children:(0,z.jsx)(B,{variant:`ghost`,className:`p-0`,children:(0,z.jsx)(tt,{className:`h-8 w-8`})})}),(0,z.jsxs)(rs,{children:[(0,z.jsx)(os,{children:`Instance Menu`}),(0,z.jsx)(ss,{}),e.map(e=>(0,z.jsx)(is,{asChild:!0,children:(0,z.jsx)(j,{to:e.to,activeProps:e_,children:e.name})},e.to))]})]})]})})}({...Br}),{...Nr},{...Vr},{...kr};function i_(e){let{metricConfig:t,startTime:n,endTime:r}=e;return A({queryKey:[`get_analytics`,t.name,t.path,n,r],queryFn:()=>a_(e)})}async function a_({metricConfig:e,startTime:t,endTime:n,instanceParams:r}){let i={operation:`get_analytics`,metric:e.name,start_time:t,end_time:n};e.path&&(i.conditions=[{attribute:`path`,value:e.path}]);let{data:a}=await r.instanceClient.post(`/`,i);return a}({...Wr}),{...zr},{...Fr},{...Pr},{...Mr},{...Rr},{...Ir},{...Hr};async function o_({instanceClient:e,logFilters:t,replicated:n}){let{data:r}=await e.post(`/`,{operation:`read_log`,start:0,replicated:n,limit:t.limit?parseInt(t.limit,10):void 0,level:t.level===`undefined`?void 0:t.level,from:t.from?new Date(t.from).toISOString():void 0,until:t.until?new Date(t.until).toISOString():void 0,order:`desc`});return r}function s_(e){let t=e.logFilters;return A({queryKey:[e.entityId,`read_log`,t.limit,t.level,t.from,t.until,e.replicated],queryFn:()=>o_(e),retry:!1,refetchInterval:e.isAutoRefreshEnabled?5e3:!1})}({...Or}),{...Ur},{...Lr},{...Ar},{...jr};function c_(){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`nav`,{className:`fixed top-20 w-full z-39 h-12 md:px-12 bg-grey-700`,children:(0,z.jsx)(t_,{})}),(0,z.jsx)(`div`,{className:`mt-32 min-h-[calc(100vh-(--spacing(32)))]`,children:(0,z.jsx)(rt,{})}),!1]})}function l_(e){switch(e){case`local`:return O({getParentRoute:()=>Lu,id:`_instanceLayout`,component:c_,loader:Kh});case`cluster`:return O({getParentRoute:()=>Hu,id:`_instanceLayout`,component:c_,beforeLoad:u_,loader:Kh});case`instance`:return O({getParentRoute:()=>Hu,path:`instance/$instanceId`,component:c_,beforeLoad:u_,loader:Kh})}}async function u_({context:e,params:t}){let n=e.authentication[t.instanceId||t.clusterId];if(n?.isLoading||n?.user)return;let r=e.authentication[F];if(r?.isLoading)return;let{update:i}=t.instanceId?ca(r.user,t.organizationId,t.clusterId):oa(r.user,t.organizationId,t.clusterId);if(i){let e=t.instanceId||t.clusterId,n=ai({id:e,forceFabricConnect:!0});try{let t=await ui({instanceClient:n});I.setUserForIdAndKey(e,n.defaults.baseURL,t),I.flagForFabricConnect(e,!0);return}catch(e){console.error(`Fabric Connect not established`,e)}}throw ar({to:`/${t.organizationId}/${t.clusterId}/`+(t.instanceId?`instance/${t.instanceId}`:``)+`/sign-in`,search:Iu()})}var d_=y(`inline-flex
54
- items-center
55
- justify-center
56
- gap-2
57
- whitespace-nowrap
58
- rounded-lg
59
- text-sm
60
- transition-[color,box-shadow]
61
- disabled:pointer-events-none
62
- disabled:opacity-50
63
- [&_svg]:pointer-events-none
64
- [&_svg:not([class*='size-'])]:size-4
65
- [&_svg]:shrink-0
66
- ring-ring/10
67
- dark:ring-ring/20
68
- dark:outline-ring/40
69
- outline-ring/50
70
- focus-visible:ring-1
71
- focus-visible:outline-1
72
- focus-visible:ring-purple-200
73
- aria-invalid:focus-visible:ring-0`,{variants:{variant:{default:`bg-primary text-primary-foreground shadow-sm hover:bg-primary/90`,outline:`border bg-default border-primary border-2 text-white shadow-xs hover:-translate-y-1 transition duration-200 hover:bg-grey-700/40`},size:{default:`h-9 px-4 py-2 has-[>svg]:px-3`,sm:`h-8 px-1.5 min-w-8`,lg:`h-10 px-2.5 min-w-10`}},defaultVariants:{variant:`default`,size:`default`}});function f_({className:e,variant:t,size:n,...r}){return(0,z.jsx)(mt,{"data-slot":`toggle`,className:R(d_({variant:t,size:n,className:e})),...r})}function p_(e){switch(e){case`warn`:return`warning`;case`notify`:return`success`;case`info`:case`debug`:case`trace`:case void 0:case`stdout`:return`secondary`;case`stderr`:case`error`:return`destructive`;default:return e}}var m_=[`secondary`,`default`,`warning`,`outline`,`success`,`destructive`],h_=0,g_=new Map,__=e=>{if(g_.has(e))return g_.get(e);h_++;let t=m_[h_%m_.length];return g_.set(e,t),t};function v_({columns:e,data:t,onRowClick:n}){let r=Ie({data:t,columns:e,getCoreRowModel:Mt()});return(0,z.jsx)(`div`,{className:`rounded-md bg-black-dark logsTable`,children:(0,z.jsxs)(Al,{className:`text-xs`,children:[(0,z.jsx)(jl,{children:r.getHeaderGroups().map(e=>(0,z.jsx)(Nl,{className:`border-none`,children:e.headers.map(e=>(0,z.jsx)(Pl,{className:`p-4 max-w-96`,children:e.isPlaceholder?null:Jn(e.column.columnDef.header,e.getContext())},e.id))},e.id))}),(0,z.jsx)(Ml,{className:`bg-black`,children:r.getRowModel().rows?.length?r.getRowModel().rows.map(e=>(0,z.jsx)(Nl,{"data-state":e.getIsSelected()&&`selected`,className:R(`hover:bg-muted/10 data-[state=selected]:bg-muted max-w-full`,n&&`cursor-pointer`),onClick:()=>n?.(e),children:e.getVisibleCells().map(e=>(0,z.jsx)(Il,{className:`p-1`,children:Jn(e.column.columnDef.cell,e.getContext())},e.id))},e.id)):(0,z.jsx)(Nl,{children:(0,z.jsx)(Il,{colSpan:e.length,className:`h-24 text-center`,children:`No results.`})})})]})})}function y_(e){try{JSON.parse(e)}catch{return!1}return!0}function b_({setIsModalOpen:e,isModalOpen:t,data:n}){let r=n?__(n.node):`default`;return(0,z.jsx)(Y,{onOpenChange:e,open:t,children:(0,z.jsxs)(X,{"aria-describedby":void 0,children:[(0,z.jsx)(Zo,{children:(0,z.jsx)(Q,{children:`Edit Row`})}),n?(0,z.jsxs)(`div`,{className:`flex flex-col gap-3 text-white`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h3`,{className:`inline-block pr-2`,children:`Level:`}),(0,z.jsx)(es,{variant:p_(n.level),children:Ma(n.level)})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h3`,{children:`Timestamp:`}),(0,z.jsx)(`p`,{className:`text-sm`,children:n.timestamp})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h3`,{children:`Thread:`}),(0,z.jsx)(`p`,{className:`text-sm`,children:n.thread})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h3`,{children:`Node:`}),(0,z.jsx)(es,{variant:r,children:n.node})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h3`,{children:`Tags:`}),(0,z.jsx)(`p`,{className:`text-sm`,children:n.tags&&n.tags.length>0?(0,z.jsx)(`span`,{children:n.tags}):`N/A`})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h3`,{className:`text-lg font-bold`,children:`Message`}),(0,z.jsx)(De,{className:`w-full h-72`,language:y_(n.message)?`json`:`text`,theme:`vs-dark`,value:n.message,options:{readOnly:!0,minimap:{enabled:!1},scrollBeyondLastLine:!1}})]})]}):(0,z.jsx)(Ss,{}),(0,z.jsx)(Z,{children:(0,z.jsxs)(`div`,{className:`flex justify-between w-full`,children:[(0,z.jsxs)(B,{type:`button`,variant:`destructive`,className:`rounded-full`,children:[(0,z.jsx)($t,{}),` Delete Row`]}),(0,z.jsxs)(B,{variant:`submit`,className:`rounded-full`,children:[(0,z.jsx)(Jt,{}),` Save Changes`]})]})})]})})}var x_=l({limit:v().or(g()).or(m()),level:o([`notify`,`error`,`warn`,`info`,`debug`,`trace`,`undefined`]).or(g()).or(m()),from:v().or(g()).or(m()).optional(),until:v().or(g()).or(m()).optional()});function S_({form:e,resetFilters:t,submitFilters:n}){return(0,z.jsx)(`div`,{children:(0,z.jsx)(H,{...e,children:(0,z.jsxs)(`form`,{id:`instance-edit-log-filters-form`,name:`instance-edit-log-filters-form`,onSubmit:e.handleSubmit(n),className:`flex-col space-y-5`,children:[(0,z.jsx)(W,{control:e.control,name:`limit`,render:({field:e})=>(0,z.jsxs)(G,{children:[(0,z.jsx)(K,{children:`Log Limit:`}),(0,z.jsxs)(Dc,{onValueChange:e.onChange,value:e.value??void 0,children:[(0,z.jsx)(Ac,{className:`w-full`,children:(0,z.jsx)(kc,{placeholder:`Select log limit`})}),(0,z.jsx)(jc,{children:(0,z.jsxs)(Oc,{children:[(0,z.jsx)($,{value:`1000`,children:`1000`}),(0,z.jsx)($,{value:`500`,children:`500`}),(0,z.jsx)($,{value:`250`,children:`250`}),(0,z.jsx)($,{value:`100`,children:`100`}),(0,z.jsx)($,{value:`10`,children:`10`})]})})]}),(0,z.jsx)(q,{})]})}),(0,z.jsx)(W,{control:e.control,name:`level`,render:({field:e})=>(0,z.jsxs)(G,{children:[(0,z.jsx)(K,{children:`Log Level:`}),(0,z.jsxs)(Dc,{onValueChange:e.onChange,value:e.value??void 0,children:[(0,z.jsx)(Ac,{className:`w-full`,children:(0,z.jsx)(kc,{placeholder:`Select log level`})}),(0,z.jsx)(jc,{children:(0,z.jsxs)(Oc,{children:[(0,z.jsx)($,{value:`undefined`,children:`All`}),(0,z.jsx)($,{value:`notify`,children:`Notify`}),(0,z.jsx)($,{value:`error`,children:`Error`}),(0,z.jsx)($,{value:`warn`,children:`Warn`}),(0,z.jsx)($,{value:`info`,children:`Info`}),(0,z.jsx)($,{value:`debug`,children:`Debug`}),(0,z.jsx)($,{value:`trace`,children:`Trace`})]})})]}),(0,z.jsx)(q,{})]})}),(0,z.jsx)(W,{control:e.control,name:`from`,render:({field:e})=>(0,z.jsxs)(G,{children:[(0,z.jsx)(K,{children:`Start Date:`}),(0,z.jsx)(U,{children:(0,z.jsx)(J,{type:`datetime-local`,value:e.value??void 0,onChange:e.onChange})}),(0,z.jsx)(q,{})]})}),(0,z.jsx)(W,{control:e.control,name:`until`,render:({field:e})=>(0,z.jsxs)(G,{children:[(0,z.jsx)(K,{children:`End Date:`}),(0,z.jsx)(U,{children:(0,z.jsx)(J,{type:`datetime-local`,value:e.value??void 0,onChange:e.onChange})}),(0,z.jsx)(q,{})]})}),(0,z.jsxs)(`div`,{className:`flex items-center justify-between space-x-2 mt-2`,children:[(0,z.jsx)(B,{type:`submit`,variant:`positiveOutline`,className:`grow`,children:`Apply Filters`}),(0,z.jsx)(B,{type:`reset`,variant:`destructiveOutline`,onClick:t,children:`Clear Filters`})]})]})})})}var C_={limit:`100`,level:`undefined`,from:``,until:``},w_=[{accessorKey:`level`,header:`Status`,cell:({row:e})=>{let{level:t}=e.original;return(0,z.jsx)(es,{variant:p_(t),children:Ma(t)})}},{accessorKey:`timestamp`,header:`Date`,cell:({row:e})=>{let{timestamp:t}=e.original;return(0,z.jsx)(`span`,{children:new Date(t).toLocaleDateString()})}},{accessorKey:`time`,header:`Time`,cell:({row:e})=>{let{timestamp:t}=e.original;return(0,z.jsx)(`span`,{children:new Date(t).toLocaleTimeString()})}},{accessorKey:`thread`,header:`Thread`},{accessorKey:`node`,header:`Node`,cell:({row:e})=>{let{node:t}=e.original,n=__(t);return(0,z.jsx)(z.Fragment,{children:t?(0,z.jsxs)(Oa,{children:[(0,z.jsx)(ka,{asChild:!0,children:(0,z.jsxs)(es,{variant:n,children:[t.split(`.`)[0],`...`]})}),(0,z.jsx)(Aa,{className:`bg-grey-700`,arrowClassName:`bg-grey-700 fill-grey-700`,children:t})]}):null})}},{accessorKey:`tags`,header:`Tags`},{accessorKey:`message`,header:`Message`,cell:({row:e})=>{let{message:t}=e.original;return e.getIsSelected(),(0,z.jsx)(`pre`,{children:(0,z.jsx)(`code`,{children:t})})}}],T_=(e,t)=>!e&&!t||!e||!t?!0:new Date(e)<=new Date(t);function E_(){let[e,t]=(0,L.useState)(C_),[n,r]=(0,L.useState)(!1),[i,a]=(0,L.useState)(),[o,s]=(0,L.useState)(!1),c=V(),{data:l,isLoading:u,refetch:d,isFetching:f}=D(s_({logFilters:e,...c,replicated:c.entityType===`cluster`,isAutoRefreshEnabled:o})),p=N({resolver:w(x_),defaultValues:C_,mode:`onChange`}),m=e=>{a(e.original),r(!0)},h=async e=>{if(!T_(e.from,e.until)){p.setError(`from`,{type:`onChange`,message:`Start date must be before end date`}),p.setError(`until`,{type:`onChange`,message:`End date must be after start date`});return}t(e)},g=async()=>{p.reset(),t(C_)},_=Hl(d);return(0,z.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 text-white md:grid-cols-12`,children:[(0,z.jsxs)(`section`,{className:`col-span-1 md:col-span-4 lg:col-span-3 px-2 pt-4 md:pt-12`,children:[(0,z.jsx)(S_,{form:p,resetFilters:g,submitFilters:h}),(0,z.jsxs)(`div`,{className:`flex items-center justify-between space-x-2 mt-2`,children:[(0,z.jsxs)(B,{variant:`defaultOutline`,onClick:_,disabled:f||u||o,className:`grow`,children:[(0,z.jsx)(fe,{}),`Refresh`]}),(0,z.jsxs)(f_,{variant:`outline`,"aria-label":`Toggle Auto Refresh`,onPressedChange:s,children:[(0,z.jsx)(fe,{}),`Auto Refresh `,o?`On`:`Off`]})]})]}),(0,z.jsx)(`section`,{className:`col-span-1 md:col-span-8 lg:col-span-9`,children:u?(0,z.jsx)(`div`,{children:`Loading...`}):(0,z.jsx)(`div`,{children:(0,z.jsx)(v_,{columns:w_,data:l||[],onRowClick:m})})}),(0,z.jsx)(b_,{isModalOpen:n,setIsModalOpen:r,data:i})]})}function D_(e){return O({getParentRoute:()=>e,path:`logs`,component:E_})}function O_(e){return O({getParentRoute:()=>e,path:`status`,component:x(async()=>Gr(()=>import(`./status-ChrCqVc7.js`),__vite__mapDeps([13,1,3,2,4,5,6,7,8,9,10])),`StatusIndex`)})}function k_(e){let t=l_(e),n=[D_(t),...fm(t),Ld(t),O_(t),qh(t),$g(t)];return t.addChildren(n)}O({getParentRoute:()=>Lu,path:`profile`,component:x(async()=>Gr(()=>import(`./profile-wyN1K1z0.js`),__vite__mapDeps([14,1,4,3,2,5,6,7,8,9,10])),`ProfileIndex`)});var A_=zi.addChildren([...Bo,Lu.addChildren([k_(`local`)])]);function j_({routeTree:e=A_,authentication:t}){return Lt({routeTree:e,history:en(),defaultNotFoundComponent:ki,defaultErrorComponent:Oi,defaultPreload:Ai()?!1:`intent`,trailingSlash:`never`,defaultPreloadStaleTime:0,scrollRestoration:!0,context:{queryClient:Mi,authentication:t||{}}})}function M_(){let e=pi(),t=j_({authentication:e});return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(kt,{router:t,context:{authentication:e}}),(0,z.jsx)(_r,{router:t,position:`bottom-right`})]})}var N_=({...e})=>(0,z.jsx)(ir,{className:`toaster group`,toastOptions:{classNames:{toast:`group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg`,description:`group-[.toast]:text-muted-foreground`,actionButton:`group-[.toast]:bg-primary group-[.toast]:text-primary-foreground font-medium`,cancelButton:`group-[.toast]:bg-muted group-[.toast]:text-muted-foreground font-medium`}},...e}),P_=!1,F_=!1;function I_(){(0,L.useEffect)(()=>{P_||(P_=!0,F_&&(function(e,t,n,r,i){e[r]=e[r]||[],e[r].push({"gtm.start":new Date().getTime(),event:`gtm.js`});let a=t.getElementsByTagName(n)[0],o=t.createElement(n),s=r===`dataLayer`?``:`&l=${r}`;o.async=!0,o.src=`https://www.googletagmanager.com/gtm.js?id=`+i+s,a.parentNode.insertBefore(o,a)})(window,document,`script`,`dataLayer`,`GTM-5QQX432`))},[])}function L_(){return Sa(),Ii(),I_(),(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(dn,{client:Mi,children:[(0,z.jsx)(M_,{}),(0,z.jsx)(Yt,{buttonPosition:`bottom-right`})]}),(0,z.jsx)(N_,{richColors:!0})]})}(0,Sr().createRoot)(document.getElementById(`root`),{onUncaughtError:(e,t)=>{ee(e,t),console.error(`Uncaught error:`,e,t)},onCaughtError:(e,t)=>{ee(e,t),console.error(`Caught error:`,e,t)},onRecoverableError:(e,t)=>{ee(e,t),console.warn(`Recoverable error:`,e,t)}}).render((0,z.jsx)(L.StrictMode,{children:(0,z.jsx)(L_,{})}));export{Ni as A,Ra as C,H as D,U as E,F,I,P as L,B as M,R as N,ea as O,hi as P,K as S,W as T,Ec as _,Ip as a,J as b,Xc as c,Dc as d,jc as f,kc as g,Ac as h,Lm as i,Oi as j,V as k,Yc as l,$ as m,zm as n,kd as o,Oc as p,Rm as r,Bl as s,i_ as t,Jc as u,Ls as v,G as w,q as x,Ss as y};
74
- //# sourceMappingURL=index-Dk_TRrUg.js.map