@harperfast/harper 5.2.5 → 5.2.6
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.
- package/bin/restart.ts +48 -23
- package/bin/restartExitWatchdog.ts +99 -0
- package/bin/run.ts +16 -10
- package/dist/bin/restart.js +39 -21
- package/dist/bin/restart.js.map +1 -1
- package/dist/bin/restartExitWatchdog.d.ts +5 -0
- package/dist/bin/restartExitWatchdog.js +100 -0
- package/dist/bin/restartExitWatchdog.js.map +1 -0
- package/dist/bin/run.d.ts +2 -0
- package/dist/bin/run.js +17 -10
- package/dist/bin/run.js.map +1 -1
- package/dist/resources/DatabaseTransaction.d.ts +18 -1
- package/dist/resources/DatabaseTransaction.js +63 -1
- package/dist/resources/DatabaseTransaction.js.map +1 -1
- package/dist/resources/LMDBTransaction.d.ts +2 -0
- package/dist/resources/LMDBTransaction.js +7 -1
- package/dist/resources/LMDBTransaction.js.map +1 -1
- package/dist/resources/Resource.js +5 -4
- package/dist/resources/Resource.js.map +1 -1
- package/dist/resources/ResourceInterface.d.ts +5 -0
- package/dist/resources/ResourceInterface.js.map +1 -1
- package/dist/resources/Table.js +53 -9
- package/dist/resources/Table.js.map +1 -1
- package/dist/resources/transaction.js +1 -1
- package/dist/resources/transaction.js.map +1 -1
- package/dist/server/threads/manageThreads.d.ts +1 -0
- package/dist/server/threads/manageThreads.js +20 -3
- package/dist/server/threads/manageThreads.js.map +1 -1
- package/dist/utility/processManagement/processManagement.js +21 -3
- package/dist/utility/processManagement/processManagement.js.map +1 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/resources/DESIGN.md +19 -19
- package/resources/DatabaseTransaction.ts +63 -2
- package/resources/LMDBTransaction.ts +7 -1
- package/resources/Resource.ts +6 -5
- package/resources/ResourceInterface.ts +5 -0
- package/resources/Table.ts +57 -8
- package/resources/transaction.ts +2 -2
- package/server/DESIGN.md +6 -0
- package/server/threads/manageThreads.js +17 -3
- package/studio/web/assets/{Chat-Lgj1d-8d.js → Chat-BNHY84-Z.js} +1 -1
- package/studio/web/assets/{FloatingChat-jLWvR4kI.js → FloatingChat-BbztUci0.js} +3 -3
- package/studio/web/assets/{apiToken-DYI4DqWa.js → apiToken-D0x_S8Wq.js} +1 -1
- package/studio/web/assets/{applications-DCmc9-lk.js → applications-BU83fSEG.js} +1 -1
- package/studio/web/assets/{index-CqbCnqsT.js → index-BQB9R8Ug.js} +4 -4
- package/studio/web/assets/{index.lazy-BNqr3j0f.js → index.lazy-CtErm5q7.js} +3 -3
- package/studio/web/assets/{notifications-Bb2cj14_.js → notifications-B8rDagJM.js} +1 -1
- package/studio/web/assets/{notifications-DVlKonbI.js → notifications-CPwYKDDH.js} +1 -1
- package/studio/web/assets/{profile-BSQWfYfq.js → profile-D0hB1xdm.js} +1 -1
- package/studio/web/assets/{regions-Dk3g8bBF.js → regions-y_jxsBpN.js} +1 -1
- package/studio/web/assets/{setComponentFile-DoITgNLb.js → setComponentFile-DSHbURTI.js} +1 -1
- package/studio/web/assets/{setup-CiEALLa7.js → setup-J5SrM1Kp.js} +1 -1
- package/studio/web/assets/{status-CK9tD-Nd.js → status-IoJkDzlx.js} +1 -1
- package/studio/web/assets/{swagger-ui-react-CxjCDFB-.js → swagger-ui-react-BlgSS25O.js} +1 -1
- package/studio/web/assets/{useEntityRestURL-Cy-0i1UZ.js → useEntityRestURL-qfahJnvr.js} +1 -1
- package/studio/web/index.html +1 -1
- package/utility/processManagement/processManagement.js +19 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/notifications-
|
|
2
|
-
import{a as e,t}from"./rolldown-runtime-B0Z9INg1.js";import{a as n,c as r,d as i,f as a,i as o,l as s,m as c,n as l,o as u,p as d,r as f,s as p,t as m,u as h}from"./authStore-B3IhXrn6.js";import{E as g,O as _,T as v,_ as y,a as b,b as x,c as S,d as C,g as w,i as T,k as E,n as D,p as O,s as k,t as A,v as j,y as M}from"./vendor-core-CddkYGh5.js";import{i as N,n as P,t as F}from"./button-DfBmT4rc.js";import{A as ee,B as te,C as I,D as L,E as ne,F as re,H as ie,I as R,L as z,M as ae,N as oe,O as se,P as ce,R as le,S as ue,T as de,V as fe,_ as pe,b as me,g as he,h as ge,k as B,m as _e,n as ve,q as ye,r as be,t as xe,v as Se,w as V,y as Ce,z as H}from"./vendor-tanstack-FsM5XZNE.js";import{a as we,i as Te,t as Ee}from"./vendor-datadog-XDrpA25D.js";import{r as De,t as Oe}from"./vendor-react-BhazFIp8.js";import{a as ke,i as Ae,n as je,o as Me,r as Ne,t as Pe}from"./useAuth-DiJUZS1C.js";import{$ as Fe,At as Ie,B as Le,C as Re,Ct as ze,Dt as Be,Et as Ve,H as He,Lt as Ue,Mt as We,Nt as Ge,Ot as Ke,Pt as qe,R as Je,Rt as U,S as Ye,St as Xe,Tt as Ze,U as Qe,V as $e,W as et,_t as tt,at as nt,b as rt,bt as it,ct as at,dt as ot,et as st,ft as ct,gt as lt,ht as ut,it as dt,jt as ft,kt as pt,lt as mt,mt as ht,nt as gt,ot as _t,pt as vt,rt as yt,st as bt,tt as xt,ut as St,v as Ct,vt as wt,wt as Tt,x as Et,xt as Dt,y as Ot,yt as kt,z as At,zt as jt}from"./vendor-ui-BLIveqaL.js";import{a as Mt,i as Nt,n as Pt,r as Ft,t as It}from"./card-ByrPS_wa.js";import{t as W}from"./createLucideIcon-BMkDbMrz.js";import{a as Lt,c as Rt,d as zt,f as Bt,g as Vt,i as Ht,l as Ut,m as Wt,n as Gt,o as Kt,p as qt,r as Jt,s as Yt,t as Xt,u as Zt}from"./select-CKgJgpkn.js";import{a as Qt,i as $t,n as en,r as tn,t as nn}from"./getRegistrationInfo--NLLrics.js";import{a as rn,c as an,i as on,l as sn,n as cn,o as ln,r as un,s as dn,t as fn}from"./table-BvFflPWi.js";import{i as pn,r as mn,t as hn}from"./x-D39AGKMb.js";import{t as gn}from"./chevron-right-CY-tr2sG.js";import{t as _n}from"./errorText-NpBmvk9I.js";import{n as vn,r as yn,t as bn}from"./queryClient-BLhQvmWC.js";import{i as xn,n as Sn,r as Cn,t as wn}from"./setLocalStorage-CD_L8p_D.js";import{t as Tn}from"./useLocalStorage-DetQlhBe.js";import{a as En,i as Dn,n as On,o as G,r as kn,s as An,t as jn}from"./pollUnlessForbidden-DIDXGBc5.js";import{n as Mn,r as Nn,t as Pn}from"./textarea-a3RnTY31.js";import{t as Fn}from"./tokenization-CWuvR2gh.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),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();function In(e){return e!==null&&!!e.username}function Ln(e){if(e&&!In(e)){let t=Object.keys(e.roles);if(t.length===1)return`/${t[0]}`}return`/`}var Rn=W(`activity`,[[`path`,{d:`M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2`,key:`169zse`}]]),zn=W(`arrow-down-to-line`,[[`path`,{d:`M12 17V3`,key:`1cwfxf`}],[`path`,{d:`m6 11 6 6 6-6`,key:`12ii2o`}],[`path`,{d:`M19 21H5`,key:`150jfl`}]]),Bn=W(`arrow-right`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),Vn=W(`arrow-up-from-line`,[[`path`,{d:`m18 9-6-6-6 6`,key:`kcunyi`}],[`path`,{d:`M12 3v14`,key:`7cf3v8`}],[`path`,{d:`M5 21h14`,key:`11awu3`}]]),Hn=W(`bell`,[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}]]),Un=W(`book-open-text`,[[`path`,{d:`M12 5v16`,key:`1f6ucr`}],[`path`,{d:`M16 13h2`,key:`weia3s`}],[`path`,{d:`M16 9h2`,key:`1n7gjm`}],[`path`,{d:`M20.001 19A2 2 0 0022 17V5a2 2 0 00-1.999-2L16 3.002A5 5 0 0012 5a5 5 0 00-4-2H4a2 2 0 00-2 2v12a2 2 0 001.999 2H8a5 5 0 014 2 5 5 0 014-2z`,key:`1fyvmf`}],[`path`,{d:`M6 13h2`,key:`1cckiz`}],[`path`,{d:`M6 9h2`,key:`1k7j9f`}]]),Wn=W(`brush-cleaning`,[[`path`,{d:`m16 22-1-4`,key:`1ow2iv`}],[`path`,{d:`M19 14a1 1 0 0 0 1-1v-1a2 2 0 0 0-2-2h-3a1 1 0 0 1-1-1V4a2 2 0 0 0-4 0v5a1 1 0 0 1-1 1H6a2 2 0 0 0-2 2v1a1 1 0 0 0 1 1`,key:`11gii7`}],[`path`,{d:`M19 14H5l-1.973 6.767A1 1 0 0 0 4 22h16a1 1 0 0 0 .973-1.233z`,key:`bju7h4`}],[`path`,{d:`m8 22 1-4`,key:`s3unb`}]]),Gn=W(`bug`,[[`path`,{d:`M12 20v-9`,key:`1qisl0`}],[`path`,{d:`M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z`,key:`uouzyp`}],[`path`,{d:`M14.12 3.88 16 2`,key:`qol33r`}],[`path`,{d:`M21 21a4 4 0 0 0-3.81-4`,key:`1b0z45`}],[`path`,{d:`M21 5a4 4 0 0 1-3.55 3.97`,key:`5cxbf6`}],[`path`,{d:`M22 13h-4`,key:`1jl80f`}],[`path`,{d:`M3 21a4 4 0 0 1 3.81-4`,key:`1fjd4g`}],[`path`,{d:`M3 5a4 4 0 0 0 3.55 3.97`,key:`1d7oge`}],[`path`,{d:`M6 13H2`,key:`82j7cp`}],[`path`,{d:`m8 2 1.88 1.88`,key:`fmnt4t`}],[`path`,{d:`M9 7.13V6a3 3 0 1 1 6 0v1.13`,key:`1vgav8`}]]),Kn=W(`calendar-clock`,[[`path`,{d:`M16 14v2.2l1.6 1`,key:`fo4ql5`}],[`path`,{d:`M16 2v3`,key:`otl347`}],[`path`,{d:`M21 7.338V5a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2h2.338`,key:`7hb8p4`}],[`path`,{d:`M3 9h5.859`,key:`numkqi`}],[`path`,{d:`M8 2v3`,key:`1ioesn`}],[`circle`,{cx:`16`,cy:`16`,r:`6`,key:`qoo3c4`}]]),qn=W(`chart-column-increasing`,[[`path`,{d:`M13 17V9`,key:`1fwyjl`}],[`path`,{d:`M18 17V5`,key:`sfb6ij`}],[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`,key:`c24i48`}],[`path`,{d:`M8 17v-3`,key:`17ska0`}]]),Jn=W(`chart-pie`,[[`path`,{d:`M21 12c.552 0 1.005-.449.95-.998a10 10 0 0 0-8.953-8.951c-.55-.055-.998.398-.998.95v8a1 1 0 0 0 1 1z`,key:`pzmjnu`}],[`path`,{d:`M21.21 15.89A10 10 0 1 1 8 2.83`,key:`k2fpak`}]]),Yn=W(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),Xn=W(`circle-alert`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]]),Zn=W(`circle-check-big`,[[`path`,{d:`M21.801 10A10 10 0 1 1 17 3.335`,key:`yps3ct`}],[`path`,{d:`m9 11 3 3L22 4`,key:`1pflzl`}]]),Qn=W(`circle-check`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),$n=W(`circle-dashed`,[[`path`,{d:`M10.1 2.182a10 10 0 0 1 3.8 0`,key:`5ilxe3`}],[`path`,{d:`M13.9 21.818a10 10 0 0 1-3.8 0`,key:`11zvb9`}],[`path`,{d:`M17.609 3.721a10 10 0 0 1 2.69 2.7`,key:`1iw5b2`}],[`path`,{d:`M2.182 13.9a10 10 0 0 1 0-3.8`,key:`c0bmvh`}],[`path`,{d:`M20.279 17.609a10 10 0 0 1-2.7 2.69`,key:`1ruxm7`}],[`path`,{d:`M21.818 10.1a10 10 0 0 1 0 3.8`,key:`qkgqxc`}],[`path`,{d:`M3.721 6.391a10 10 0 0 1 2.7-2.69`,key:`1mcia2`}],[`path`,{d:`M6.391 20.279a10 10 0 0 1-2.69-2.7`,key:`1fvljs`}]]),er=W(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),tr=W(`clipboard-check`,[[`rect`,{width:`8`,height:`4`,x:`8`,y:`2`,rx:`1`,ry:`1`,key:`tgr4d6`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2`,key:`116196`}],[`path`,{d:`m9 14 2 2 4-4`,key:`df797q`}]]),nr=W(`clipboard`,[[`rect`,{width:`8`,height:`4`,x:`8`,y:`2`,rx:`1`,ry:`1`,key:`tgr4d6`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2`,key:`116196`}]]),rr=W(`cloud-alert`,[[`path`,{d:`M12 12v4`,key:`tww15h`}],[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M8.128 16.949A7 7 0 1 1 15.71 8h1.79a1 1 0 0 1 0 9h-1.642`,key:`1namsd`}]]),ir=W(`cloud-download`,[[`path`,{d:`M12 13v8l-4-4`,key:`1f5nwf`}],[`path`,{d:`m12 21 4-4`,key:`1lfcce`}],[`path`,{d:`M4.393 15.269A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.436 8.284`,key:`ui1hmy`}]]),ar=W(`cloud-upload`,[[`path`,{d:`M12 13v8`,key:`1l5pq0`}],[`path`,{d:`M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242`,key:`1pljnt`}],[`path`,{d:`m8 17 4-4 4 4`,key:`1quai1`}]]),or=W(`columns-3-cog`,[[`path`,{d:`M10.6 21H5a2 2 0 01-2-2V5a2 2 0 012-2h14a2 2 0 012 2v5.6`,key:`19s2bv`}],[`path`,{d:`m14.305 19.53.923-.382`,key:`3m78fa`}],[`path`,{d:`M15 3v7.6`,key:`mv9izd`}],[`path`,{d:`m15.229 16.852-.924-.383`,key:`qpfz85`}],[`path`,{d:`m16.852 15.228-.383-.923`,key:`5xggr7`}],[`path`,{d:`m16.852 20.772-.383.924`,key:`dpfhf9`}],[`path`,{d:`m19.148 15.228.383-.923`,key:`1reyyz`}],[`path`,{d:`m19.53 21.696-.382-.924`,key:`1goivc`}],[`path`,{d:`m20.773 16.852.922-.383`,key:`59dfo2`}],[`path`,{d:`m20.773 19.148.922.383`,key:`1lk755`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}]]),sr=W(`copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),cr=W(`credit-card`,[[`rect`,{width:`20`,height:`14`,x:`2`,y:`5`,rx:`2`,key:`ynyp8z`}],[`line`,{x1:`2`,x2:`22`,y1:`10`,y2:`10`,key:`1b3vmo`}]]),lr=W(`database`,[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 5V19A9 3 0 0 0 21 19V5`,key:`1wlel7`}],[`path`,{d:`M3 12A9 3 0 0 0 21 12`,key:`mv7ke4`}]]),ur=W(`ellipsis`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]]),dr=W(`external-link`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),fr=W(`eye-off`,[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),pr=W(`eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),mr=W(`file-up`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M12 12v6`,key:`3ahymv`}],[`path`,{d:`m15 15-3-3-3 3`,key:`15xj92`}]]),hr=W(`funnel-plus`,[[`path`,{d:`M13.354 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14v6a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341l1.218-1.348`,key:`8mvsmf`}],[`path`,{d:`M16 6h6`,key:`1dogtp`}],[`path`,{d:`M19 3v6`,key:`1ytpjt`}]]),gr=W(`funnel-x`,[[`path`,{d:`M12.531 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14v6a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341l.427-.473`,key:`ol2ft2`}],[`path`,{d:`m16.5 3.5 5 5`,key:`15e6fa`}],[`path`,{d:`m21.5 3.5-5 5`,key:`m0lwru`}]]),_r=W(`funnel`,[[`path`,{d:`M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z`,key:`sc7q7i`}]]),vr=W(`gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]),yr=W(`git-graph`,[[`circle`,{cx:`5`,cy:`6`,r:`3`,key:`1qnov2`}],[`path`,{d:`M5 9v6`,key:`158jrl`}],[`circle`,{cx:`5`,cy:`18`,r:`3`,key:`104gr9`}],[`path`,{d:`M12 3v18`,key:`108xh3`}],[`circle`,{cx:`19`,cy:`6`,r:`3`,key:`108a5v`}],[`path`,{d:`M16 15.7A9 9 0 0 0 19 9`,key:`1e3vqb`}]]),br=W(`globe`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]),xr=W(`handshake`,[[`path`,{d:`m11 17 2 2a1 1 0 1 0 3-3`,key:`efffak`}],[`path`,{d:`m14 14 2.5 2.5a1 1 0 1 0 3-3l-3.88-3.88a3 3 0 0 0-4.24 0l-.88.88a1 1 0 1 1-3-3l2.81-2.81a5.79 5.79 0 0 1 7.06-.87l.47.28a2 2 0 0 0 1.42.25L21 4`,key:`9pr0kb`}],[`path`,{d:`m21 3 1 11h-2`,key:`1tisrp`}],[`path`,{d:`M3 3 2 14l6.5 6.5a1 1 0 1 0 3-3`,key:`1uvwmv`}],[`path`,{d:`M3 4h8`,key:`1ep09j`}]]),Sr=W(`house`,[[`path`,{d:`M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8`,key:`5wwlr5`}],[`path`,{d:`M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z`,key:`r6nss1`}]]),Cr=W(`info`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]),wr=W(`key-round`,[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]),Tr=W(`key`,[[`path`,{d:`m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4`,key:`g0fldk`}],[`path`,{d:`m21 2-9.6 9.6`,key:`1j0ho8`}],[`circle`,{cx:`7.5`,cy:`15.5`,r:`5.5`,key:`yqb3hr`}]]),Er=W(`layout-dashboard`,[[`rect`,{width:`7`,height:`9`,x:`3`,y:`3`,rx:`1`,key:`10lvy0`}],[`rect`,{width:`7`,height:`5`,x:`14`,y:`3`,rx:`1`,key:`16une8`}],[`rect`,{width:`7`,height:`9`,x:`14`,y:`12`,rx:`1`,key:`1hutg5`}],[`rect`,{width:`7`,height:`5`,x:`3`,y:`16`,rx:`1`,key:`ldoo1y`}]]),Dr=W(`life-buoy`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m4.93 4.93 4.24 4.24`,key:`1ymg45`}],[`path`,{d:`m14.83 9.17 4.24-4.24`,key:`1cb5xl`}],[`path`,{d:`m14.83 14.83 4.24 4.24`,key:`q42g0n`}],[`path`,{d:`m9.17 14.83-4.24 4.24`,key:`bqpfvv`}],[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}]]),Or=W(`list-todo`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`rect`,{x:`3`,y:`4`,width:`6`,height:`6`,rx:`1`,key:`cif1o7`}]]),kr=W(`loader-circle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),Ar=W(`lock`,[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`,key:`fwvmzm`}]]),jr=W(`log-out`,[[`path`,{d:`m16 17 5-5-5-5`,key:`1bji2h`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}]]),Mr=W(`log-in`,[[`path`,{d:`m10 17 5-5-5-5`,key:`1bsop3`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4`,key:`u53s6r`}]]),Nr=W(`mail-warning`,[[`path`,{d:`M22 10.5V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h12.5`,key:`e61zoh`}],[`path`,{d:`m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7`,key:`1ocrg3`}],[`path`,{d:`M20 14v4`,key:`1hm744`}],[`path`,{d:`M20 22v.01`,key:`12bgn6`}]]),Pr=W(`mail`,[[`path`,{d:`m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7`,key:`132q7q`}],[`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,key:`izxlao`}]]),Fr=W(`map-pin`,[[`path`,{d:`M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0`,key:`1r0f0z`}],[`circle`,{cx:`12`,cy:`10`,r:`3`,key:`ilqhr7`}]]),Ir=W(`menu`,[[`path`,{d:`M4 5h16`,key:`1tepv9`}],[`path`,{d:`M4 12h16`,key:`1lakjw`}],[`path`,{d:`M4 19h16`,key:`1djgab`}]]),Lr=W(`monitor`,[[`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`,key:`48i651`}],[`line`,{x1:`8`,x2:`16`,y1:`21`,y2:`21`,key:`1svkeh`}],[`line`,{x1:`12`,x2:`12`,y1:`17`,y2:`21`,key:`vw1qmm`}]]),Rr=W(`moon`,[[`path`,{d:`M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401`,key:`kfwtm`}]]),zr=W(`notepad-text`,[[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`path`,{d:`M12 2v4`,key:`3427ic`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`rect`,{width:`16`,height:`18`,x:`4`,y:`4`,rx:`2`,key:`1u9h20`}],[`path`,{d:`M8 10h6`,key:`3oa6kw`}],[`path`,{d:`M8 14h8`,key:`1fgep2`}],[`path`,{d:`M8 18h5`,key:`17enja`}]]),Br=W(`octagon-alert`,[[`path`,{d:`M12 16h.01`,key:`1drbdi`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M15.312 2a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586l-4.688-4.688A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2z`,key:`1fd625`}]]),Vr=W(`package`,[[`path`,{d:`M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z`,key:`1a0edw`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}],[`polyline`,{points:`3.29 7 12 12 20.71 7`,key:`ousv84`}],[`path`,{d:`m7.5 4.27 9 5.15`,key:`1c824w`}]]),Hr=W(`play`,[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]),Ur=W(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),Wr=W(`refresh-cw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),Gr=W(`rocket`,[[`path`,{d:`M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5`,key:`qeys4`}],[`path`,{d:`M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09`,key:`u4xsad`}],[`path`,{d:`M9 12a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.4 22.4 0 0 1-4 2z`,key:`676m9`}],[`path`,{d:`M9 12H4s.55-3.03 2-4c1.62-1.08 5 .05 5 .05`,key:`92ym6u`}]]),Kr=W(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),qr=W(`rotate-cw`,[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]),Jr=W(`save`,[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`,key:`1c8476`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`,key:`1ydtos`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`,key:`t51u73`}]]),Yr=W(`scale`,[[`path`,{d:`M12 3v18`,key:`108xh3`}],[`path`,{d:`m19 8 3 8a5 5 0 0 1-6 0zV7`,key:`zcdpyk`}],[`path`,{d:`M3 7h1a17 17 0 0 0 8-2 17 17 0 0 0 8 2h1`,key:`1yorad`}],[`path`,{d:`m5 8 3 8a5 5 0 0 1-6 0zV7`,key:`eua70x`}],[`path`,{d:`M7 21h10`,key:`1b0cd5`}]]),Xr=W(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),Zr=W(`server`,[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]),Qr=W(`settings`,[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`,key:`1i5ecw`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),$r=W(`shield-check`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),ei=W(`shield-x`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m14.5 9.5-5 5`,key:`17q4r4`}],[`path`,{d:`m9.5 9.5 5 5`,key:`18nt4w`}]]);W(`shield`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}]]);var ti=W(`sliders-horizontal`,[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]),ni=W(`square-pen`,[[`path`,{d:`M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7`,key:`1m0v6g`}],[`path`,{d:`M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z`,key:`ohrbg2`}]]),ri=W(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),ii=W(`sun`,[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`m4.93 4.93 1.41 1.41`,key:`149t6j`}],[`path`,{d:`m17.66 17.66 1.41 1.41`,key:`ptbguv`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`m6.34 17.66-1.41 1.41`,key:`1m8zz5`}],[`path`,{d:`m19.07 4.93-1.41 1.41`,key:`1shlcs`}]]),ai=W(`table-2`,[[`path`,{d:`M9 3H5a2 2 0 0 0-2 2v4m6-6h10a2 2 0 0 1 2 2v4M9 3v18m0 0h10a2 2 0 0 0 2-2V9M9 21H5a2 2 0 0 1-2-2V9m0 0h18`,key:`gugj83`}]]),oi=W(`table`,[[`path`,{d:`M12 3v18`,key:`108xh3`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 9h18`,key:`1pudct`}],[`path`,{d:`M3 15h18`,key:`5xshup`}]]),si=W(`tag`,[[`path`,{d:`M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z`,key:`vktsd0`}],[`circle`,{cx:`7.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`kqv944`}]]),ci=W(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]),li=W(`ticket`,[[`path`,{d:`M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z`,key:`qn84l0`}],[`path`,{d:`M13 5v2`,key:`dyzc3o`}],[`path`,{d:`M13 17v2`,key:`1ont0d`}],[`path`,{d:`M13 11v2`,key:`1wjjxi`}]]),ui=W(`trash-2`,[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]),di=W(`trash`,[[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]),fi=W(`triangle-alert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),pi=W(`user-minus`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}],[`line`,{x1:`22`,x2:`16`,y1:`11`,y2:`11`,key:`1shjgl`}]]),mi=W(`user`,[[`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`,key:`975kel`}],[`circle`,{cx:`12`,cy:`7`,r:`4`,key:`17ys0d`}]]),hi=W(`users`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]),gi=W(`zap`,[[`path`,{d:`M15.914 4a1.5 1.5 0 00-2.474-1.561l-9 9A1.5 1.5 0 005.5 14h4.002a.5.5 0 01.471.666L8.086 20a1.5 1.5 0 002.475 1.56l9-9A1.5 1.5 0 0018.5 10h-3.997a.5.5 0 01-.472-.667z`,key:`1v7up4`}]]),K=De();function _i({className:e,error:t,title:n,showReturnToHome:r,children:i}){let{user:a,isLoading:o}=Ae();return Ln(a),(0,K.jsxs)(It,{className:P(`text-red p-5 border border-red rounded-md m-12 mt-36`,e),children:[(0,K.jsxs)(Nt,{children:[(0,K.jsx)(Mt,{className:`text-2xl`,children:(0,K.jsx)(`h2`,{children:n??`Component Error`})}),(0,K.jsx)(Ft,{children:t.message})]}),(0,K.jsxs)(Pt,{children:[i,r!==!1&&(a&&!o?(0,K.jsx)(V,{to:`/`,children:(0,K.jsxs)(F,{children:[` `,(0,K.jsx)(Qt,{}),` Return to Home`]})}):(0,K.jsx)(V,{to:`/sign-in`,children:(0,K.jsxs)(F,{children:[` `,(0,K.jsx)(Qt,{}),` Go to Sign In Page`]})}))]})]})}function vi(){let{user:e,isLoading:t}=Ae();return Ln(e),(0,K.jsx)(`div`,{className:`flex items-center justify-center h-screen px-3`,children:(0,K.jsxs)(It,{className:`text-red p-5 border border-red rounded-md w-full max-w-md`,children:[(0,K.jsx)(Nt,{children:(0,K.jsx)(Mt,{className:`text-2xl`,children:(0,K.jsx)(`h2`,{children:`Sorry, Page Not Found`})})}),(0,K.jsx)(Pt,{children:e&&!t?(0,K.jsx)(V,{to:`/`,children:(0,K.jsxs)(F,{children:[` `,(0,K.jsx)(Qt,{}),` Return to Home`]})}):(0,K.jsx)(V,{to:`/sign-in`,children:(0,K.jsxs)(F,{children:[` `,(0,K.jsx)(Qt,{}),` Go Sign In Page`]})})})]})})}function yi(){return`ontouchstart`in window||navigator.maxTouchPoints>0}var q=e(we(),1);function bi({...e}){return(0,K.jsx)(pt,{"data-slot":`dropdown-menu`,...e})}function xi({...e}){return(0,K.jsx)(qe,{"data-slot":`dropdown-menu-trigger`,...e})}function Si({className:e,sideOffset:t=4,...n}){return(0,K.jsx)(Ke,{children:(0,K.jsx)(Tt,{"data-slot":`dropdown-menu-content`,sideOffset:t,className:P(`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-border p-1 shadow-md`,e),...n})})}function Ci({className:e,inset:t,variant:n=`default`,...r}){return(0,K.jsx)(Ze,{"data-slot":`dropdown-menu-item`,"data-inset":t,"data-variant":n,className:P(`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 wi({className:e,children:t,checked:n,...r}){return(0,K.jsxs)(ze,{"data-slot":`dropdown-menu-checkbox-item`,className:P(`focus:bg-accent focus:text-accent-foreground 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,K.jsx)(`span`,{className:`pointer-events-none absolute left-2 flex size-3.5 items-center justify-center`,children:(0,K.jsx)(Ve,{children:(0,K.jsx)(pn,{className:`size-4`})})}),t]})}function Ti({className:e,inset:t,...n}){return(0,K.jsx)(Be,{"data-slot":`dropdown-menu-label`,"data-inset":t,className:P(`px-2 py-1.5 text-sm font-medium data-[inset]:pl-8`,e),...n})}function Ei({className:e,...t}){return(0,K.jsx)(Ie,{"data-slot":`dropdown-menu-separator`,className:P(`bg-border -mx-1 my-1 h-px`,e),...t})}function Di({className:e,...t}){return(0,K.jsx)(`span`,{"data-slot":`dropdown-menu-shortcut`,className:P(`text-muted-foreground ml-auto text-xs tracking-widest`,e),...t})}function Oi({...e}){return(0,K.jsx)(ft,{"data-slot":`dropdown-menu-sub`,...e})}function ki({className:e,inset:t,children:n,...r}){return(0,K.jsxs)(Ge,{"data-slot":`dropdown-menu-sub-trigger`,"data-inset":t,className:P(`focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground`,`flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none`,`data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0`,`[&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground`,e),...r,children:[n,(0,K.jsx)(gn,{className:`ml-auto size-4`})]})}function Ai({className:e,...t}){return(0,K.jsx)(We,{"data-slot":`dropdown-menu-sub-content`,className:P(`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 min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-hidden rounded-md border p-1 shadow-lg`,e),...t})}var ji=`flex items-center gap-3 p-2 rounded-lg text-sm transition-colors`,Mi=`block p-2 rounded-lg text-sm transition-colors`,Ni={className:`text-foreground hover:bg-accent dark:text-white dark:hover:bg-grey-700`},Pi={className:`font-medium text-primary bg-primary/10 dark:text-white dark:bg-white/10`};function Fi({items:e,ariaLabel:t}){let{pathname:n}=he(),r=e=>e.exact?n===e.to:n.startsWith(e.to),i=e.find(r)??e[0],a=i.icon;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`nav`,{className:`hidden md:flex flex-col gap-1`,"aria-label":t,children:e.map(e=>{let t=e.icon;return(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(V,{to:e.to,className:ji,activeOptions:{exact:!!e.exact},activeProps:Pi,inactiveProps:Ni,children:[(0,K.jsx)(t,{className:`size-4 shrink-0`}),e.label]}),e.children&&r(e)&&(0,K.jsx)(`div`,{className:`mt-1 ml-4 flex flex-col gap-1 border-l border-border pl-3`,children:e.children.map(e=>(0,K.jsx)(V,{to:e.to,className:Mi,activeOptions:{exact:!!e.exact},activeProps:Pi,inactiveProps:Ni,children:e.label},e.to))})]},e.to)})}),(0,K.jsx)(`div`,{className:`md:hidden`,children:(0,K.jsxs)(bi,{children:[(0,K.jsx)(xi,{asChild:!0,children:(0,K.jsxs)(F,{variant:`outline`,className:`w-full justify-between`,children:[(0,K.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(a,{className:`size-4`}),i.label]}),(0,K.jsx)(mn,{className:`size-4`})]})}),(0,K.jsx)(Si,{align:`start`,className:`w-(--radix-dropdown-menu-trigger-width)`,children:e.map(e=>{let t=e.icon;return[(0,K.jsx)(Ci,{asChild:!0,children:(0,K.jsxs)(V,{to:e.to,className:`flex items-center gap-2`,children:[(0,K.jsx)(t,{className:`size-4`}),e.label]})},e.to),...e.children&&r(e)?e.children.map(e=>(0,K.jsx)(Ci,{asChild:!0,children:(0,K.jsx)(V,{to:e.to,className:`flex items-center gap-2 pl-8`,children:e.label})},e.to)):[]]})})]})})]})}var Ii=[{to:`/admin/notifications`,label:`Notifications`,icon:Hn,permission:`systemStatus:write`},{to:`/admin/regions`,label:`Regions`,icon:br,permission:`region:read`},{to:`/admin/api-token`,label:`API Token`,icon:wr,permission:`apiToken:create`,ssoAccountOnly:!0}];function Li(e){let t=e!==null&&`fabricRole`in e&&e.fabricRole===`super_user`;return Ii.filter(n=>Pe(e,n.permission)&&!(n.ssoAccountOnly&&t))}function Ri(e){return Li(e).length>0}function zi(){let{isLoading:e,user:t}=je(),{pathname:n}=he();if(e)return null;let r=Li(t);if(!r.length)return(0,K.jsx)(ne,{to:`/`,replace:!0});let i=Ii.find(e=>n.startsWith(e.to));return i&&!r.includes(i)?(0,K.jsx)(ne,{to:r[0].to,replace:!0}):(0,K.jsx)(`div`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-(--spacing(32)))]`,children:(0,K.jsxs)(`div`,{className:`md:grid gap-6 md:grid-cols-12`,children:[(0,K.jsx)(`aside`,{className:`md:col-span-3 lg:col-span-2 mb-4 md:mb-0`,children:(0,K.jsx)(Fi,{items:r,ariaLabel:`Admin sections`})}),(0,K.jsx)(`section`,{className:`md:col-span-9 lg:col-span-10 min-w-0`,children:(0,K.jsx)(Ce,{})})]})})}function Bi({className:e,text:t,centered:n,...r}){return(0,K.jsxs)(`div`,{className:`text-foreground h-full w-full ${e||``} ${n?`flex flex-col items-center justify-center`:``}`,...r,children:[(0,K.jsx)(`img`,{src:`/HDBDogOnly.svg`,width:`100px`,height:`100px`,alt:`HDB Dog Logo Loading`,className:`inline-block`}),(0,K.jsx)(`p`,{className:`pt-4`,children:t||`Loading...`})]})}function Vi(){return(0,K.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 126.644 96`,width:24,height:24,children:(0,K.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 Hi(){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`img`,{src:`/harper-studio_white.png`,alt:`Harper Studio`,className:`w-64 hidden md:inline-block`}),(0,K.jsx)(`img`,{src:`/HDBDogOnly.svg`,width:`50px`,height:`44px`,alt:`Harper`,className:`inline-block md:hidden`})]})}var Ui=v(`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-foreground [a&]:hover:bg-yellow/90`,success:`border-green bg-green/40 text-foreground [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-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground`}},defaultVariants:{variant:`default`}});function Wi({className:e,variant:t,asChild:n=!1,...r}){return(0,K.jsx)(n?jt:`span`,{"data-slot":`badge`,className:P(Ui({variant:t}),e),...r})}function Gi({className:e,children:t,...n}){return(0,K.jsxs)(kt,{"data-slot":`scroll-area`,className:P(`relative`,e),...n,children:[(0,K.jsx)(Xe,{"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,K.jsx)(Ki,{}),(0,K.jsx)(wt,{})]})}function Ki({className:e,orientation:t=`vertical`,...n}){return(0,K.jsx)(it,{"data-slot":`scroll-area-scrollbar`,orientation:t,className:P(`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,K.jsx)(Dt,{"data-slot":`scroll-area-thumb`,className:`bg-border relative flex-1 rounded-full`})})}var qi=[`notification-acks`];function Ji(){let e=Cn(Sn.AckedNotificationIds,[]);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function Yi(e){yn.setQueryData(qi,e);try{wn(Sn.AckedNotificationIds,e)}catch(e){console.warn(`[notifications] could not persist acknowledgements`,e)}}function Xi(){return z({queryKey:qi,queryFn:Ji,staleTime:1/0,gcTime:1/0,initialData:Ji})}function Zi(e){Yi(Array.from(new Set([...Ji(),e])))}function Qi(e){Yi(Ji().filter(t=>t!==e))}function $i(){let{data:e}=H(Xi());return(0,q.useMemo)(()=>new Set(e??[]),[e])}var ea={critical:{severity:`critical`,label:`Critical`,Icon:Br,badgeVariant:`destructive`,bannerClass:`bg-destructive/10 border-destructive/40 text-foreground`,iconClass:`text-destructive`},warning:{severity:`warning`,label:`Warning`,Icon:fi,badgeVariant:`warning`,bannerClass:`bg-yellow/10 border-yellow/40 text-foreground`,iconClass:`text-yellow`},info:{severity:`info`,label:`Info`,Icon:Cr,badgeVariant:`secondary`,bannerClass:`bg-secondary/20 border-secondary/50 text-foreground`,iconClass:`text-secondary-foreground`}},ta=new Set([`critical`,`error`,`outage`,`incident`,`down`,`danger`]),na=new Set([`warning`,`warn`,`maintenance`,`degraded`,`notice`]),ra=new Set([`info`,`information`,`informational`,`success`,`ok`]);function ia(e){let t=(e??``).trim().toLowerCase();return na.has(t)?`warning`:ra.has(t)?`info`:(ta.has(t),`critical`)}function aa(e){return ea[ia(e)]}var oa={critical:0,warning:1,info:2};function sa(e){if(e==null)return{kind:`absent`};if(typeof e==`number`)return Number.isFinite(e)?{kind:`valid`,ms:e}:{kind:`invalid`};if(typeof e!=`string`)return{kind:`invalid`};let t=e.trim();if(!t)return{kind:`absent`};if(/^\d+$/.test(t))return{kind:`valid`,ms:Number(t)};let n=Date.parse(t);return Number.isNaN(n)?{kind:`invalid`}:{kind:`valid`,ms:n}}function ca(e){let t=sa(e);return t.kind===`valid`?t.ms:null}function la(e){return new Date(e).toLocaleString()}function ua(e,t){let n=sa(e.startAt),r=sa(e.endAt);return n.kind===`invalid`||r.kind===`invalid`?{state:`expired`,label:`Schedule unavailable`}:n.kind===`valid`&&t<n.ms?{state:`upcoming`,label:`Starts ${la(n.ms)}`}:r.kind===`valid`&&t>r.ms?{state:`expired`,label:`Ended ${la(r.ms)}`}:r.kind===`valid`?{state:`active`,label:`Active until ${la(r.ms)}`}:{state:`active`,label:`Active`}}var da=new Set([`http`,`https`,`mailto`]);function fa(e){if(!e)return null;let t=e.trim();if(!t)return null;if(t.startsWith(`//`))return{kind:`external`,href:t};let n=t.match(/^([a-z][a-z0-9+.-]*):/i)?.[1]?.toLowerCase();return n?da.has(n)?{kind:`external`,href:t}:null:{kind:`internal`,href:t.startsWith(`/`)?t:`/${t}`}}function pa({url:e,className:t,children:n,onNavigate:r}){let i=fa(e);return i?i.kind===`external`?(0,K.jsxs)(`a`,{href:i.href,target:`_blank`,rel:`noreferrer noopener`,className:t,children:[n??`Learn more`,(0,K.jsx)(dr,{className:`inline size-3 ml-1 align-[-1px]`})]}):(0,K.jsx)(V,{to:i.href,className:t,onClick:r,children:n??`View details`}):null}var ma=[`system-status`];async function ha(){let{data:e}=await N.get(`/SystemStatus/`);return Array.isArray(e)?e:[]}function ga(){return z({queryKey:ma,queryFn:ha,refetchInterval:6e4,staleTime:3e4})}var _a=3e4,va=new Set,ya=Date.now(),ba=null;function xa(e){return va.add(e),ba||=(ya=Date.now(),setInterval(()=>{ya=Date.now(),va.forEach(e=>e())},_a)),()=>{va.delete(e),va.size===0&&ba&&(clearInterval(ba),ba=null)}}function Sa(){return(0,q.useSyncExternalStore)(xa,()=>ya,()=>ya)}function Ca(){return H(ga())}function wa(){let[e,t]=(0,q.useState)(()=>window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`);return(0,q.useEffect)(()=>{let e=window.matchMedia(`(prefers-color-scheme: dark)`),n=e=>t(e.matches?`dark`:`light`);return e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e}var Ta=(0,q.createContext)([`system`,()=>{}]);function Ea({children:e}){let[t,n]=Tn(Sn.Theme,`system`),r=wa();return(0,q.useEffect)(()=>{let e=t===`dark`||t===`system`&&r===`dark`;document.documentElement.classList.toggle(`dark`,e)},[t,r]),(0,K.jsx)(Ta.Provider,{value:[t,n],children:e})}function Da(){return(0,q.useContext)(Ta)}var Oa=[{value:`light`,icon:(0,K.jsx)(ii,{className:`size-4`}),label:`Light`},{value:`system`,icon:(0,K.jsx)(Lr,{className:`size-4`}),label:`System`},{value:`dark`,icon:(0,K.jsx)(Rr,{className:`size-4`}),label:`Dark`}];function ka(){let[e,t]=Da();return(0,K.jsx)(`div`,{className:`flex items-center bg-muted dark:bg-black rounded-xl p-0.5 gap-0.5`,children:Oa.map(({value:n,icon:r,label:i})=>(0,K.jsx)(`button`,{type:`button`,title:i,onClick:()=>t(n),className:`p-1.5 rounded-lg transition-colors ${e===n?`bg-background text-foreground shadow-xs`:`text-muted-foreground hover:text-foreground`}`,children:r},n))})}function Aa({className:e,...t}){return(0,K.jsx)(`div`,{className:P(`absolute top-full left-0 isolate z-50 flex justify-center`),children:(0,K.jsx)(tt,{"data-slot":`navigation-menu-viewport`,className:P(`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 ja({className:e,children:t,viewport:n=!0,...r}){return(0,K.jsxs)(lt,{"data-slot":`navigation-menu`,"data-viewport":n,className:P(`group/navigation-menu relative flex max-w-max flex-1 items-center justify-center`,e),...r,children:[t,n&&(0,K.jsx)(Aa,{})]})}function Ma({className:e,...t}){return(0,K.jsx)(vt,{"data-slot":`navigation-menu-item`,className:P(`relative`,e),...t})}function Na({className:e,...t}){return(0,K.jsx)(ht,{"data-slot":`navigation-menu-link`,className:P(`hover:text-foreground dark: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 Pa({className:e,...t}){return(0,K.jsx)(ut,{"data-slot":`navigation-menu-list`,className:P(`group flex flex-1 list-none items-center justify-center gap-1`,e),...t})}function Fa({delayDuration:e=0,...t}){return(0,K.jsx)(St,{"data-slot":`tooltip-provider`,delayDuration:e,...t})}function Ia({...e}){return(0,K.jsx)(Fa,{children:(0,K.jsx)(ot,{"data-slot":`tooltip`,...e})})}function La({...e}){return(0,K.jsx)(ct,{"data-slot":`tooltip-trigger`,...e})}function Ra({className:e,sideOffset:t=0,arrowClassName:n,children:r,...i}){return(0,K.jsx)(mt,{children:(0,K.jsxs)(at,{"data-slot":`tooltip-content`,sideOffset:t,className:P(`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,K.jsx)(bt,{className:P(`bg-primary fill-primary z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]`,n)})]})})}function za(){let e=`v5.2.5`,t=e.startsWith(`v`)?`https://github.com/HarperFast/studio/releases/tag/${e}`:`https://github.com/HarperFast/studio/releases`;return(0,K.jsx)(`a`,{href:t,target:`_blank`,rel:`noopener noreferrer`,children:(0,K.jsxs)(`span`,{className:P(Ui({variant:`default`}),`text-xs inline-block ml-2 align-text-top`),children:[e,` BETA`]})})}function Ba(){localStorage.clear()}function Va(){sessionStorage.clear()}async function Ha(){l.setUserForEntity(m,null),yn.getQueryCache().clear(),Ba(),Va(),await yn.invalidateQueries({refetchType:`none`})}async function Ua(e){await l.signOutFromPotentiallyAuthenticatedInstances(),await u({...e,entityId:m})}function Wa(){let e=En();return R({mutationFn:()=>Ua({instanceClient:e}),onSuccess:Ha})}var Ga={className:`text-foreground dark:text-white font-semibold`};function Ka(){let{mutate:e}=Wa(),t=L(),{user:n}=Ae(),r=Ri(n),i=ae(),a=(0,q.useCallback)(()=>{e(void 0,{onSuccess:async()=>{U.success(`Success`,{description:`You have been signed out successfully.`,action:{label:`Dismiss`,onClick:()=>U.dismiss()}}),t({to:`/sign-in`}),i.invalidate()}})},[e,i,t]),o=(0,q.useMemo)(()=>[!1,!1,{to:`https://docs.harperdb.io/docs`,target:`_blank`,icon:(0,K.jsx)(Un,{}),text:`Docs`,textBreakpoint:`md`},{to:`https://github.com/HarperFast/studio/issues`,target:`_blank`,icon:(0,K.jsx)(Gn,{}),text:`Report an Issue`,textBreakpoint:`lg`},{to:`https://discord.gg/VzZuaw3Xay`,target:`_blank`,icon:(0,K.jsx)(Vi,{}),text:`Discord`,textBreakpoint:`lg`},{onClick:a,icon:(0,K.jsx)(jr,{}),text:`Sign Out`,textBreakpoint:`md`}].filter(kn),[a,r]);return n?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Za,{menuItems:o}),(0,K.jsx)(Ya,{menuItems:o})]}):(0,K.jsx)(Ja,{})}function qa(e){return e.items!==void 0}function Ja(){return(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`inline-block`,children:[(0,K.jsx)(V,{to:`/sign-in`,children:(0,K.jsx)(Hi,{})}),(0,K.jsx)(za,{})]}),(0,K.jsx)(ja,{children:(0,K.jsxs)(Pa,{className:`text-muted-foreground dark:text-grey-400`,children:[(0,K.jsx)(Ma,{children:(0,K.jsx)(Na,{asChild:!0,children:(0,K.jsxs)(V,{to:`https://docs.harperdb.io/docs`,target:`_blank`,rel:`noreferrer noopener`,className:`flex-row items-center`,children:[(0,K.jsx)(Un,{}),` `,(0,K.jsx)(`span`,{className:`hidden md:inline-block`,children:`Docs`})]})})}),(0,K.jsx)(Ma,{children:(0,K.jsx)(ka,{})}),(0,K.jsx)(Ma,{children:(0,K.jsx)(Na,{asChild:!0,children:(0,K.jsxs)(V,{to:`/sign-in`,className:`flex-row items-center`,activeProps:Ga,children:[(0,K.jsx)(Mr,{}),` Sign In`]})})})]})})]})}function Ya({menuItems:e}){let{user:t}=Ae();return Ln(t),(0,K.jsx)(`div`,{className:`hidden md:[@media(hover:hover)]:block xl:block`,children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`inline-block`,children:[(0,K.jsx)(V,{to:`/`,children:(0,K.jsx)(Hi,{})}),(0,K.jsx)(za,{})]}),(0,K.jsx)(ja,{children:(0,K.jsxs)(Pa,{className:`text-muted-foreground dark:text-grey-400`,children:[e.map(e=>qa(e)?!!e.items.length&&(0,K.jsx)(`div`,{className:`bg-muted dark:bg-black rounded-2xl flex`,children:e.items.map(e=>(0,K.jsx)(Xa,{menuItem:e},e.text))},e.text):(0,K.jsx)(Xa,{menuItem:e},e.text)),!1,(0,K.jsx)(Ma,{children:(0,K.jsx)(ka,{})})]})})]})})}function Xa({menuItem:e}){return(0,K.jsx)(Ma,{className:`text-muted-foreground dark:text-gray-400 hover:text-foreground dark:hover:text-white`,children:(0,K.jsxs)(Ia,{children:[(0,K.jsx)(La,{asChild:!0,children:(0,K.jsx)(Na,{asChild:!0,children:(0,K.jsxs)(V,{to:e.to,onClick:e.onClick,"aria-label":e.text,className:`flex-row items-center`,target:e.target,activeProps:e.to?Ga:void 0,children:[e.icon,(0,K.jsx)(`span`,{className:`hidden ${e.textBreakpoint}:inline-block`,children:e.text}),(0,K.jsx)(`span`,{className:`${e.textBreakpoint}:hidden`,children:`\xA0`})]})})}),(0,K.jsx)(Ra,{side:`bottom`,className:`${e.textBreakpoint}:hidden`,children:e.text})]})})}function Za({menuItems:e}){let{user:t}=Ae();Ln(t);let[n,r]=(0,q.useState)(!1),i=(0,q.useCallback)(()=>r(e=>!e),[]),a=(0,q.useCallback)(()=>r(!1),[]);return(0,K.jsxs)(`div`,{className:`md:[@media(hover:hover)]:hidden xl:hidden`,id:`mobile-menu`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(V,{to:`/`,children:(0,K.jsx)(Hi,{})}),(0,K.jsx)(za,{}),(0,K.jsxs)(`div`,{className:`flex items-center`,children:[!1,(0,K.jsxs)(`button`,{type:`button`,className:`shadow-xs text-muted-foreground dark:text-grey-400 hover:text-foreground dark:hover:text-white hover:bg-muted dark:hover:bg-black-dark`,onClick:i,children:[(0,K.jsx)(`span`,{className:`sr-only`,children:n?`Close menu`:`Open menu`}),n?(0,K.jsx)(hn,{}):(0,K.jsx)(Ir,{})]})]})]}),(0,K.jsx)(`div`,{className:`${n?`fixed`:`hidden`} top-40 bottom-0 left-0 right-0 bg-foreground/20 dark:bg-black-dark dark:opacity-70`,onClick:a}),(0,K.jsxs)(`div`,{className:`${n?`block`:`hidden`} md:hidden z-50 space-y-1 pb-3 bg-card border-b border-border dark:bg-black-dark dark:border-none absolute left-0 top-full w-full rounded-b-md`,children:[(0,K.jsx)(`div`,{className:`flex justify-end px-3 pt-2`,children:(0,K.jsx)(ka,{})}),e.map(e=>qa(e)?!!e.items.length&&(0,K.jsx)(`div`,{className:`bg-muted dark:bg-black pl-10 pr-2 py-2`,children:e.items.map(e=>(0,K.jsx)(Qa,{menuItem:e,onClick:a},e.text))},e.text):(0,K.jsx)(Qa,{menuItem:e,onClick:a},e.text))]})]})}function Qa({menuItem:e,onClick:t}){let n=(0,q.useCallback)(()=>{e.onClick?.(),t()},[e,t]);return(0,K.jsxs)(V,{to:e.to,onClick:n,target:e.target,className:`flex flex-row px-3 py-2 text-base font-medium rounded-md text-muted-foreground dark:text-gray-400 hover:text-foreground dark:hover:text-white`,activeProps:e.to?Ga:void 0,children:[e.icon,(0,K.jsx)(`span`,{className:`ml-4`,children:e.text})]})}function $a(){let{isLoading:e}=Ae(),{createCluster:t}=se({strict:!1}),[,n]=Tn(Sn.SavedClusterState,null);return(0,q.useEffect)(()=>{t&&n(t)},[t,n]),e?(0,K.jsx)(Bi,{className:`fixed z-50 translate-1/2`}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`header`,{className:`fixed top-0 z-40 w-full h-20 p-4 bg-gradient-to-r from-violet-100 to-white border-b border-violet-200 dark:from-purple-950 dark:to-zinc-900 dark:border-purple-950 md:px-12`,children:(0,K.jsx)(Ka,{})}),(0,K.jsx)(`main`,{children:(0,K.jsx)(Ce,{})})]})}function eo(){let e=location.hash;return e?e.startsWith(`#/`)?e.slice(1):e:`/`}var to=[`/`,`/forgot-password`,`/reset-password`,`/sign-in`,`/sign-up`,`/verify-email`];function no(){let e=eo();return!to.includes(e)&&{redirect:e}}var ro=`me|email|token|access_token|id_token|refresh_token|code|secret|password|api[-_]?key`,io=String.raw`[^&#\s",<>[\]{}|\\]+`,ao=String.raw`[\w.%+!~*'()-]+(?:@|%40)[\w-]+(?:\.[\w-]+)*\.\w{2,}`;new RegExp(String.raw`([?&](?:${ro})=)${io}`,`gi`),new RegExp(String.raw`([?&](?:${ro})=)${io}|${ao}`,`gi`);var oo=!1;function so(){(0,q.useEffect)(()=>{oo||=!0},[])}function co(){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(ge,{}),(0,K.jsx)(Ce,{})]})}var lo=ue()({component:co}),uo=I({getParentRoute:()=>lo,id:`_dashboardLayout`,component:$a,beforeLoad:({context:e})=>{let t=e.authentication[m];if(t&&!t.isLoading&&!t.user)throw re({to:`/sign-in`,search:no()})}}),fo=I({getParentRoute:()=>uo,path:`admin`,component:zi});I({getParentRoute:()=>fo,path:`/`,beforeLoad:()=>{throw re({to:`/admin/notifications`})}}),I({getParentRoute:()=>fo,path:`notifications`,head:()=>({meta:[{title:`Notifications — Harper Fabric`}]}),component:me(async()=>Te(()=>import(`./notifications-Bb2cj14_.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15])),`NotificationsAdminIndex`)}),I({getParentRoute:()=>fo,path:`regions`,head:()=>({meta:[{title:`Regions — Harper Fabric`}]}),component:me(async()=>Te(()=>import(`./regions-Dk3g8bBF.js`),__vite__mapDeps([16,1,3,2,4,5,6,7,17,18,8,9,10,11,12,13])),`RegionsIndex`)}),I({getParentRoute:()=>fo,path:`api-token`,head:()=>({meta:[{title:`API Token — Harper Fabric`}]}),component:me(async()=>Te(()=>import(`./apiToken-DYI4DqWa.js`),__vite__mapDeps([19,1,2,3,4,5,6,7,20])),`ApiTokenIndex`)});function po(){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`header`,{className:`fixed top-0 z-40 w-full h-20 p-4 bg-gradient-to-r from-violet-100 to-white border-b border-violet-200 dark:from-purple-950 dark:to-zinc-900 dark:border-purple-950 md:px-12`,children:(0,K.jsx)(Ka,{})}),(0,K.jsxs)(`div`,{className:`pt-20 h-screen grid grid-cols-1 md:grid-cols-2`,children:[(0,K.jsx)(`section`,{"aria-label":`Harper Fabric overview`,className:`items-center justify-center hidden text-white md:flex px-6 fabricSignupTextContainer`,children:(0,K.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,K.jsx)(`main`,{className:`overflow-y-auto px-6 bg-white dark:bg-linear-(--black-dark-gradient) border-l border-border dark:border-none`,children:(0,K.jsx)(`div`,{className:`min-h-full flex items-start justify-center py-12`,children:(0,K.jsx)(Ce,{})})})]})]})}var mo;function ho(){(0,q.useEffect)(()=>{},[])}var go=[`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 _o(e){if(!e||!e.includes(`@`))return null;let t=e.split(`@`).pop()||``;if(!t)return null;for(let e of go)if(t===e||t.endsWith(`.`+e))return null;return t}var vo=`utm_`;function yo(e){let t=new URLSearchParams(e),n=Array.from(t.keys()).filter(e=>e.toLowerCase().startsWith(vo));if(n.length===0)return e;for(let e of n)t.delete(e);let r=t.toString();return r?`?${r}`:``}function bo(){if(typeof location>`u`||typeof history>`u`)return;let{search:e,pathname:t,hash:n,origin:r}=location,i=yo(e);i!==e&&history.replaceState(history.state,``,`${r}${t}${i}${n}`)}var xo=null;function So(){let e=L(),t=ae(),n=ie(),{redirect:i}=se({strict:!1});return(0,q.useEffect)(()=>{xo||=(async function(){let a=await r().catch(()=>null);if(!a)U.error(`We were not able to verify your sign-in. Please try signing in again.`,{duration:1e4}),await e({to:`/sign-in`});else{l.setUserForEntity(m,a),bo();let r=Ln(a),o=_o(a.email);mo?.identify?.({username:a.email,type:`email`,...o?{company:o}:{}}),await n.invalidateQueries({queryKey:p,refetchType:`none`}),await t.invalidate(),await e({to:i?.startsWith(`/`)?i:r})}xo=null})()},[]),(0,K.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`text-foreground dark:text-white w-lg flex flex-col gap-4`,children:[(0,K.jsxs)(`h1`,{className:`text-3xl font-light`,children:[(0,K.jsx)(`span`,{"aria-hidden":`true`,className:`text-2xl animate-flower-dance mr-4`,title:`Loading`,children:`🌼`}),`Checking...`]}),(0,K.jsx)(`div`,{className:`underline flex gap-4`,children:(0,K.jsx)(V,{className:`text-sm opacity-50 text-muted-foreground hover:text-foreground dark:text-inherit dark:hover:text-blue-300`,to:`/sign-in`,children:`Try signing in again`})})]})}var Co=new Map;function wo(e){if(!e)return``;if(Co.has(e))return Co.get(e);let t=e.replace(/[-_]+/g,` `).replace(/\s+/g,` `).trim();if(!t)return Co.set(e,``),``;let n=t.match(/([A-Z]+(?=[A-Z][a-z])|[A-Z]?[a-z]+|[A-Z]+|[0-9]+)/g);if(!n)return Co.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(To).join(` `);return Co.set(e,i),i}function To(e){return/^[A-Z]{2,3}s?$/.test(e)||/^[0-9]+$/.test(e)?e:e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}function Eo({restartRequired:e}){let t=he(),{organization:n,instance:r,cluster:i}=de({strict:!1}),a=(0,q.useMemo)(()=>{let e=t.pathname.split(`/`).filter(e=>e&&e.length>0),a=[(0,K.jsxs)(V,{to:`/`,children:[(0,K.jsx)(Sr,{"aria-hidden":`true`,className:`size-5 shrink-0`}),(0,K.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=wo(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,K.jsx)(`svg`,{fill:`currentColor`,viewBox:`0 0 20 20`,"aria-hidden":`true`,className:`size-5 shrink-0 text-grey`,children:(0,K.jsx)(`path`,{d:`M5.555 17.776l8-16 .894.448-8 16-.894-.448z`})},a.length+`-dash`),(0,K.jsx)(V,{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]);return(0,K.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:[...a,e&&(0,K.jsxs)(Ia,{children:[(0,K.jsx)(La,{asChild:!0,children:(0,K.jsxs)(`div`,{className:`text-xs italic text-muted-foreground`,children:[`* Restart `,(0,K.jsx)(`span`,{className:`hidden lg:inline-block`,children:`Requested`})]})}),(0,K.jsxs)(Ra,{side:`bottom`,children:[`This `,`Instance`,` is requesting a restart, when convenient, to apply your latest changes.`,(0,K.jsx)(`br`,{}),`You can do this from the Apps or Config pages.`]})]})]})}var Do=gt,Oo=(0,q.createContext)({}),ko=(0,q.createContext)({});function Ao(){let e=(0,q.useContext)(Oo),t=(0,q.useContext)(ko),{getFieldState:n}=nt(),r=_t({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 J({...e}){let{error:t,formItemId:n,formDescriptionId:r,formMessageId:i}=Ao();return(0,K.jsx)(jt,{"data-slot":`form-control`,id:n,"aria-describedby":t?`${r} ${i}`:`${r}`,"aria-invalid":!!t,...e})}function Y({...e}){return(0,K.jsx)(Oo,{value:{name:e.name},children:(0,K.jsx)(xt,{...e})})}function X({className:e,...t}){let n=(0,q.useId)();return(0,K.jsx)(ko,{value:{id:n},children:(0,K.jsx)(`div`,{"data-slot":`form-item`,className:P(`grid gap-2`,e),...t})})}function jo({className:e,...t}){return(0,K.jsx)(st,{"data-slot":`label`,className:P(`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 Z({className:e,...t}){let{error:n,formItemId:r}=Ao();return(0,K.jsx)(jo,{"data-slot":`form-label`,"data-error":!!n,className:P(`data-[error=true]:text-destructive`,e),htmlFor:r,...t})}function Q({className:e,...t}){let{error:n,formMessageId:r}=Ao(),i=n?String(n?.message):t.children;return i?(0,K.jsx)(`p`,{"data-slot":`form-message`,id:r,className:P(`text-destructive text-sm`,e),...t,children:i}):null}function $({className:e,type:t,...n}){return(0,K.jsx)(`input`,{type:t,"data-slot":`input`,className:P(`border-input file:text-foreground placeholder:text-muted-foreground selection:bg-purple
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/notifications-B8rDagJM.js","assets/rolldown-runtime-B0Z9INg1.js","assets/button-DfBmT4rc.js","assets/vendor-core-CddkYGh5.js","assets/vendor-datadog-XDrpA25D.js","assets/vendor-react-BhazFIp8.js","assets/vendor-ui-BLIveqaL.js","assets/vendor-tanstack-FsM5XZNE.js","assets/select-CKgJgpkn.js","assets/createLucideIcon-BMkDbMrz.js","assets/x-D39AGKMb.js","assets/setLocalStorage-CD_L8p_D.js","assets/useLocalStorage-DetQlhBe.js","assets/table-BvFflPWi.js","assets/textarea-a3RnTY31.js","assets/alertDialog-BaBrZQ4M.js","assets/regions-y_jxsBpN.js","assets/useAuth-DiJUZS1C.js","assets/authStore-B3IhXrn6.js","assets/apiToken-D0x_S8Wq.js","assets/card-ByrPS_wa.js","assets/setup-J5SrM1Kp.js","assets/dist-cY0BPcz0.js","assets/editor.api-eUd8PqEu.js","assets/editor-jjEx9u7D.css","assets/register-3F1Tje_F.js","assets/register-S_PdXsoi.js","assets/editor-BDfNodZS.js","assets/toggleHighContrast-CyNC3SCQ.js","assets/toggleHighContrast--ixms01u.css","assets/index.lazy-CtErm5q7.js","assets/getRegistrationInfo--NLLrics.js","assets/pollUnlessForbidden-DIDXGBc5.js","assets/useEntityRestURL-qfahJnvr.js","assets/index-BnYZFLIB.css","assets/applications-BU83fSEG.js","assets/chevron-right-CY-tr2sG.js","assets/tabs-Dd_ElZ36.js","assets/setComponentFile-DSHbURTI.js","assets/queryClient-BLhQvmWC.js","assets/errorText-NpBmvk9I.js","assets/languageServices-Bl-BvoAb.js","assets/applications-DNZhsH95.css","assets/FloatingChat-BbztUci0.js","assets/react-VeAY02s6.js","assets/status-IoJkDzlx.js","assets/linear-DwB_ruUT.js","assets/string-f6JzSHaO.js","assets/defaultLocale-BFoDCU3G.js","assets/init-ZlXS9mIS.js","assets/ordinal-CPleeUAT.js","assets/time-D55sDum-.js","assets/band-DZ4Jagyz.js","assets/path-fybaL0A-.js","assets/math-Bi_r_ZWc.js","assets/array-BifhSqXX.js","assets/isArrayLikeObject-BHDnhloL.js","assets/line-Bom3IjHi.js","assets/react-redux-Ds7wf7Ax.js","assets/getAnalytics-rTxZLIM5.js","assets/notifications-CPwYKDDH.js","assets/profile-D0hB1xdm.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{a as e,t}from"./rolldown-runtime-B0Z9INg1.js";import{a as n,c as r,d as i,f as a,i as o,l as s,m as c,n as l,o as u,p as d,r as f,s as p,t as m,u as h}from"./authStore-B3IhXrn6.js";import{E as g,O as _,T as v,_ as y,a as b,b as x,c as S,d as C,g as w,i as T,k as E,n as D,p as O,s as k,t as A,v as j,y as M}from"./vendor-core-CddkYGh5.js";import{i as N,n as P,t as F}from"./button-DfBmT4rc.js";import{A as ee,B as te,C as I,D as L,E as ne,F as re,H as ie,I as R,L as z,M as ae,N as oe,O as se,P as ce,R as le,S as ue,T as de,V as fe,_ as pe,b as me,g as he,h as ge,k as B,m as _e,n as ve,q as ye,r as be,t as xe,v as Se,w as V,y as Ce,z as H}from"./vendor-tanstack-FsM5XZNE.js";import{a as we,i as Te,t as Ee}from"./vendor-datadog-XDrpA25D.js";import{r as De,t as Oe}from"./vendor-react-BhazFIp8.js";import{a as ke,i as Ae,n as je,o as Me,r as Ne,t as Pe}from"./useAuth-DiJUZS1C.js";import{$ as Fe,At as Ie,B as Le,C as Re,Ct as ze,Dt as Be,Et as Ve,H as He,Lt as Ue,Mt as We,Nt as Ge,Ot as Ke,Pt as qe,R as Je,Rt as U,S as Ye,St as Xe,Tt as Ze,U as Qe,V as $e,W as et,_t as tt,at as nt,b as rt,bt as it,ct as at,dt as ot,et as st,ft as ct,gt as lt,ht as ut,it as dt,jt as ft,kt as pt,lt as mt,mt as ht,nt as gt,ot as _t,pt as vt,rt as yt,st as bt,tt as xt,ut as St,v as Ct,vt as wt,wt as Tt,x as Et,xt as Dt,y as Ot,yt as kt,z as At,zt as jt}from"./vendor-ui-BLIveqaL.js";import{a as Mt,i as Nt,n as Pt,r as Ft,t as It}from"./card-ByrPS_wa.js";import{t as W}from"./createLucideIcon-BMkDbMrz.js";import{a as Lt,c as Rt,d as zt,f as Bt,g as Vt,i as Ht,l as Ut,m as Wt,n as Gt,o as Kt,p as qt,r as Jt,s as Yt,t as Xt,u as Zt}from"./select-CKgJgpkn.js";import{a as Qt,i as $t,n as en,r as tn,t as nn}from"./getRegistrationInfo--NLLrics.js";import{a as rn,c as an,i as on,l as sn,n as cn,o as ln,r as un,s as dn,t as fn}from"./table-BvFflPWi.js";import{i as pn,r as mn,t as hn}from"./x-D39AGKMb.js";import{t as gn}from"./chevron-right-CY-tr2sG.js";import{t as _n}from"./errorText-NpBmvk9I.js";import{n as vn,r as yn,t as bn}from"./queryClient-BLhQvmWC.js";import{i as xn,n as Sn,r as Cn,t as wn}from"./setLocalStorage-CD_L8p_D.js";import{t as Tn}from"./useLocalStorage-DetQlhBe.js";import{a as En,i as Dn,n as On,o as G,r as kn,s as An,t as jn}from"./pollUnlessForbidden-DIDXGBc5.js";import{n as Mn,r as Nn,t as Pn}from"./textarea-a3RnTY31.js";import{t as Fn}from"./tokenization-CWuvR2gh.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),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();function In(e){return e!==null&&!!e.username}function Ln(e){if(e&&!In(e)){let t=Object.keys(e.roles);if(t.length===1)return`/${t[0]}`}return`/`}var Rn=W(`activity`,[[`path`,{d:`M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2`,key:`169zse`}]]),zn=W(`arrow-down-to-line`,[[`path`,{d:`M12 17V3`,key:`1cwfxf`}],[`path`,{d:`m6 11 6 6 6-6`,key:`12ii2o`}],[`path`,{d:`M19 21H5`,key:`150jfl`}]]),Bn=W(`arrow-right`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),Vn=W(`arrow-up-from-line`,[[`path`,{d:`m18 9-6-6-6 6`,key:`kcunyi`}],[`path`,{d:`M12 3v14`,key:`7cf3v8`}],[`path`,{d:`M5 21h14`,key:`11awu3`}]]),Hn=W(`bell`,[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}]]),Un=W(`book-open-text`,[[`path`,{d:`M12 5v16`,key:`1f6ucr`}],[`path`,{d:`M16 13h2`,key:`weia3s`}],[`path`,{d:`M16 9h2`,key:`1n7gjm`}],[`path`,{d:`M20.001 19A2 2 0 0022 17V5a2 2 0 00-1.999-2L16 3.002A5 5 0 0012 5a5 5 0 00-4-2H4a2 2 0 00-2 2v12a2 2 0 001.999 2H8a5 5 0 014 2 5 5 0 014-2z`,key:`1fyvmf`}],[`path`,{d:`M6 13h2`,key:`1cckiz`}],[`path`,{d:`M6 9h2`,key:`1k7j9f`}]]),Wn=W(`brush-cleaning`,[[`path`,{d:`m16 22-1-4`,key:`1ow2iv`}],[`path`,{d:`M19 14a1 1 0 0 0 1-1v-1a2 2 0 0 0-2-2h-3a1 1 0 0 1-1-1V4a2 2 0 0 0-4 0v5a1 1 0 0 1-1 1H6a2 2 0 0 0-2 2v1a1 1 0 0 0 1 1`,key:`11gii7`}],[`path`,{d:`M19 14H5l-1.973 6.767A1 1 0 0 0 4 22h16a1 1 0 0 0 .973-1.233z`,key:`bju7h4`}],[`path`,{d:`m8 22 1-4`,key:`s3unb`}]]),Gn=W(`bug`,[[`path`,{d:`M12 20v-9`,key:`1qisl0`}],[`path`,{d:`M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z`,key:`uouzyp`}],[`path`,{d:`M14.12 3.88 16 2`,key:`qol33r`}],[`path`,{d:`M21 21a4 4 0 0 0-3.81-4`,key:`1b0z45`}],[`path`,{d:`M21 5a4 4 0 0 1-3.55 3.97`,key:`5cxbf6`}],[`path`,{d:`M22 13h-4`,key:`1jl80f`}],[`path`,{d:`M3 21a4 4 0 0 1 3.81-4`,key:`1fjd4g`}],[`path`,{d:`M3 5a4 4 0 0 0 3.55 3.97`,key:`1d7oge`}],[`path`,{d:`M6 13H2`,key:`82j7cp`}],[`path`,{d:`m8 2 1.88 1.88`,key:`fmnt4t`}],[`path`,{d:`M9 7.13V6a3 3 0 1 1 6 0v1.13`,key:`1vgav8`}]]),Kn=W(`calendar-clock`,[[`path`,{d:`M16 14v2.2l1.6 1`,key:`fo4ql5`}],[`path`,{d:`M16 2v3`,key:`otl347`}],[`path`,{d:`M21 7.338V5a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2h2.338`,key:`7hb8p4`}],[`path`,{d:`M3 9h5.859`,key:`numkqi`}],[`path`,{d:`M8 2v3`,key:`1ioesn`}],[`circle`,{cx:`16`,cy:`16`,r:`6`,key:`qoo3c4`}]]),qn=W(`chart-column-increasing`,[[`path`,{d:`M13 17V9`,key:`1fwyjl`}],[`path`,{d:`M18 17V5`,key:`sfb6ij`}],[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`,key:`c24i48`}],[`path`,{d:`M8 17v-3`,key:`17ska0`}]]),Jn=W(`chart-pie`,[[`path`,{d:`M21 12c.552 0 1.005-.449.95-.998a10 10 0 0 0-8.953-8.951c-.55-.055-.998.398-.998.95v8a1 1 0 0 0 1 1z`,key:`pzmjnu`}],[`path`,{d:`M21.21 15.89A10 10 0 1 1 8 2.83`,key:`k2fpak`}]]),Yn=W(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),Xn=W(`circle-alert`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]]),Zn=W(`circle-check-big`,[[`path`,{d:`M21.801 10A10 10 0 1 1 17 3.335`,key:`yps3ct`}],[`path`,{d:`m9 11 3 3L22 4`,key:`1pflzl`}]]),Qn=W(`circle-check`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),$n=W(`circle-dashed`,[[`path`,{d:`M10.1 2.182a10 10 0 0 1 3.8 0`,key:`5ilxe3`}],[`path`,{d:`M13.9 21.818a10 10 0 0 1-3.8 0`,key:`11zvb9`}],[`path`,{d:`M17.609 3.721a10 10 0 0 1 2.69 2.7`,key:`1iw5b2`}],[`path`,{d:`M2.182 13.9a10 10 0 0 1 0-3.8`,key:`c0bmvh`}],[`path`,{d:`M20.279 17.609a10 10 0 0 1-2.7 2.69`,key:`1ruxm7`}],[`path`,{d:`M21.818 10.1a10 10 0 0 1 0 3.8`,key:`qkgqxc`}],[`path`,{d:`M3.721 6.391a10 10 0 0 1 2.7-2.69`,key:`1mcia2`}],[`path`,{d:`M6.391 20.279a10 10 0 0 1-2.69-2.7`,key:`1fvljs`}]]),er=W(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),tr=W(`clipboard-check`,[[`rect`,{width:`8`,height:`4`,x:`8`,y:`2`,rx:`1`,ry:`1`,key:`tgr4d6`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2`,key:`116196`}],[`path`,{d:`m9 14 2 2 4-4`,key:`df797q`}]]),nr=W(`clipboard`,[[`rect`,{width:`8`,height:`4`,x:`8`,y:`2`,rx:`1`,ry:`1`,key:`tgr4d6`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2`,key:`116196`}]]),rr=W(`cloud-alert`,[[`path`,{d:`M12 12v4`,key:`tww15h`}],[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M8.128 16.949A7 7 0 1 1 15.71 8h1.79a1 1 0 0 1 0 9h-1.642`,key:`1namsd`}]]),ir=W(`cloud-download`,[[`path`,{d:`M12 13v8l-4-4`,key:`1f5nwf`}],[`path`,{d:`m12 21 4-4`,key:`1lfcce`}],[`path`,{d:`M4.393 15.269A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.436 8.284`,key:`ui1hmy`}]]),ar=W(`cloud-upload`,[[`path`,{d:`M12 13v8`,key:`1l5pq0`}],[`path`,{d:`M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242`,key:`1pljnt`}],[`path`,{d:`m8 17 4-4 4 4`,key:`1quai1`}]]),or=W(`columns-3-cog`,[[`path`,{d:`M10.6 21H5a2 2 0 01-2-2V5a2 2 0 012-2h14a2 2 0 012 2v5.6`,key:`19s2bv`}],[`path`,{d:`m14.305 19.53.923-.382`,key:`3m78fa`}],[`path`,{d:`M15 3v7.6`,key:`mv9izd`}],[`path`,{d:`m15.229 16.852-.924-.383`,key:`qpfz85`}],[`path`,{d:`m16.852 15.228-.383-.923`,key:`5xggr7`}],[`path`,{d:`m16.852 20.772-.383.924`,key:`dpfhf9`}],[`path`,{d:`m19.148 15.228.383-.923`,key:`1reyyz`}],[`path`,{d:`m19.53 21.696-.382-.924`,key:`1goivc`}],[`path`,{d:`m20.773 16.852.922-.383`,key:`59dfo2`}],[`path`,{d:`m20.773 19.148.922.383`,key:`1lk755`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}]]),sr=W(`copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),cr=W(`credit-card`,[[`rect`,{width:`20`,height:`14`,x:`2`,y:`5`,rx:`2`,key:`ynyp8z`}],[`line`,{x1:`2`,x2:`22`,y1:`10`,y2:`10`,key:`1b3vmo`}]]),lr=W(`database`,[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 5V19A9 3 0 0 0 21 19V5`,key:`1wlel7`}],[`path`,{d:`M3 12A9 3 0 0 0 21 12`,key:`mv7ke4`}]]),ur=W(`ellipsis`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]]),dr=W(`external-link`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),fr=W(`eye-off`,[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),pr=W(`eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),mr=W(`file-up`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M12 12v6`,key:`3ahymv`}],[`path`,{d:`m15 15-3-3-3 3`,key:`15xj92`}]]),hr=W(`funnel-plus`,[[`path`,{d:`M13.354 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14v6a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341l1.218-1.348`,key:`8mvsmf`}],[`path`,{d:`M16 6h6`,key:`1dogtp`}],[`path`,{d:`M19 3v6`,key:`1ytpjt`}]]),gr=W(`funnel-x`,[[`path`,{d:`M12.531 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14v6a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341l.427-.473`,key:`ol2ft2`}],[`path`,{d:`m16.5 3.5 5 5`,key:`15e6fa`}],[`path`,{d:`m21.5 3.5-5 5`,key:`m0lwru`}]]),_r=W(`funnel`,[[`path`,{d:`M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z`,key:`sc7q7i`}]]),vr=W(`gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]),yr=W(`git-graph`,[[`circle`,{cx:`5`,cy:`6`,r:`3`,key:`1qnov2`}],[`path`,{d:`M5 9v6`,key:`158jrl`}],[`circle`,{cx:`5`,cy:`18`,r:`3`,key:`104gr9`}],[`path`,{d:`M12 3v18`,key:`108xh3`}],[`circle`,{cx:`19`,cy:`6`,r:`3`,key:`108a5v`}],[`path`,{d:`M16 15.7A9 9 0 0 0 19 9`,key:`1e3vqb`}]]),br=W(`globe`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]),xr=W(`handshake`,[[`path`,{d:`m11 17 2 2a1 1 0 1 0 3-3`,key:`efffak`}],[`path`,{d:`m14 14 2.5 2.5a1 1 0 1 0 3-3l-3.88-3.88a3 3 0 0 0-4.24 0l-.88.88a1 1 0 1 1-3-3l2.81-2.81a5.79 5.79 0 0 1 7.06-.87l.47.28a2 2 0 0 0 1.42.25L21 4`,key:`9pr0kb`}],[`path`,{d:`m21 3 1 11h-2`,key:`1tisrp`}],[`path`,{d:`M3 3 2 14l6.5 6.5a1 1 0 1 0 3-3`,key:`1uvwmv`}],[`path`,{d:`M3 4h8`,key:`1ep09j`}]]),Sr=W(`house`,[[`path`,{d:`M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8`,key:`5wwlr5`}],[`path`,{d:`M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z`,key:`r6nss1`}]]),Cr=W(`info`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]),wr=W(`key-round`,[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]),Tr=W(`key`,[[`path`,{d:`m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4`,key:`g0fldk`}],[`path`,{d:`m21 2-9.6 9.6`,key:`1j0ho8`}],[`circle`,{cx:`7.5`,cy:`15.5`,r:`5.5`,key:`yqb3hr`}]]),Er=W(`layout-dashboard`,[[`rect`,{width:`7`,height:`9`,x:`3`,y:`3`,rx:`1`,key:`10lvy0`}],[`rect`,{width:`7`,height:`5`,x:`14`,y:`3`,rx:`1`,key:`16une8`}],[`rect`,{width:`7`,height:`9`,x:`14`,y:`12`,rx:`1`,key:`1hutg5`}],[`rect`,{width:`7`,height:`5`,x:`3`,y:`16`,rx:`1`,key:`ldoo1y`}]]),Dr=W(`life-buoy`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m4.93 4.93 4.24 4.24`,key:`1ymg45`}],[`path`,{d:`m14.83 9.17 4.24-4.24`,key:`1cb5xl`}],[`path`,{d:`m14.83 14.83 4.24 4.24`,key:`q42g0n`}],[`path`,{d:`m9.17 14.83-4.24 4.24`,key:`bqpfvv`}],[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}]]),Or=W(`list-todo`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`rect`,{x:`3`,y:`4`,width:`6`,height:`6`,rx:`1`,key:`cif1o7`}]]),kr=W(`loader-circle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),Ar=W(`lock`,[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`,key:`fwvmzm`}]]),jr=W(`log-out`,[[`path`,{d:`m16 17 5-5-5-5`,key:`1bji2h`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}]]),Mr=W(`log-in`,[[`path`,{d:`m10 17 5-5-5-5`,key:`1bsop3`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4`,key:`u53s6r`}]]),Nr=W(`mail-warning`,[[`path`,{d:`M22 10.5V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h12.5`,key:`e61zoh`}],[`path`,{d:`m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7`,key:`1ocrg3`}],[`path`,{d:`M20 14v4`,key:`1hm744`}],[`path`,{d:`M20 22v.01`,key:`12bgn6`}]]),Pr=W(`mail`,[[`path`,{d:`m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7`,key:`132q7q`}],[`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,key:`izxlao`}]]),Fr=W(`map-pin`,[[`path`,{d:`M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0`,key:`1r0f0z`}],[`circle`,{cx:`12`,cy:`10`,r:`3`,key:`ilqhr7`}]]),Ir=W(`menu`,[[`path`,{d:`M4 5h16`,key:`1tepv9`}],[`path`,{d:`M4 12h16`,key:`1lakjw`}],[`path`,{d:`M4 19h16`,key:`1djgab`}]]),Lr=W(`monitor`,[[`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`,key:`48i651`}],[`line`,{x1:`8`,x2:`16`,y1:`21`,y2:`21`,key:`1svkeh`}],[`line`,{x1:`12`,x2:`12`,y1:`17`,y2:`21`,key:`vw1qmm`}]]),Rr=W(`moon`,[[`path`,{d:`M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401`,key:`kfwtm`}]]),zr=W(`notepad-text`,[[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`path`,{d:`M12 2v4`,key:`3427ic`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`rect`,{width:`16`,height:`18`,x:`4`,y:`4`,rx:`2`,key:`1u9h20`}],[`path`,{d:`M8 10h6`,key:`3oa6kw`}],[`path`,{d:`M8 14h8`,key:`1fgep2`}],[`path`,{d:`M8 18h5`,key:`17enja`}]]),Br=W(`octagon-alert`,[[`path`,{d:`M12 16h.01`,key:`1drbdi`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M15.312 2a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586l-4.688-4.688A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2z`,key:`1fd625`}]]),Vr=W(`package`,[[`path`,{d:`M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z`,key:`1a0edw`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}],[`polyline`,{points:`3.29 7 12 12 20.71 7`,key:`ousv84`}],[`path`,{d:`m7.5 4.27 9 5.15`,key:`1c824w`}]]),Hr=W(`play`,[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]),Ur=W(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),Wr=W(`refresh-cw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),Gr=W(`rocket`,[[`path`,{d:`M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5`,key:`qeys4`}],[`path`,{d:`M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09`,key:`u4xsad`}],[`path`,{d:`M9 12a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.4 22.4 0 0 1-4 2z`,key:`676m9`}],[`path`,{d:`M9 12H4s.55-3.03 2-4c1.62-1.08 5 .05 5 .05`,key:`92ym6u`}]]),Kr=W(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),qr=W(`rotate-cw`,[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]),Jr=W(`save`,[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`,key:`1c8476`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`,key:`1ydtos`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`,key:`t51u73`}]]),Yr=W(`scale`,[[`path`,{d:`M12 3v18`,key:`108xh3`}],[`path`,{d:`m19 8 3 8a5 5 0 0 1-6 0zV7`,key:`zcdpyk`}],[`path`,{d:`M3 7h1a17 17 0 0 0 8-2 17 17 0 0 0 8 2h1`,key:`1yorad`}],[`path`,{d:`m5 8 3 8a5 5 0 0 1-6 0zV7`,key:`eua70x`}],[`path`,{d:`M7 21h10`,key:`1b0cd5`}]]),Xr=W(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),Zr=W(`server`,[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]),Qr=W(`settings`,[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`,key:`1i5ecw`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),$r=W(`shield-check`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),ei=W(`shield-x`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m14.5 9.5-5 5`,key:`17q4r4`}],[`path`,{d:`m9.5 9.5 5 5`,key:`18nt4w`}]]);W(`shield`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}]]);var ti=W(`sliders-horizontal`,[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]),ni=W(`square-pen`,[[`path`,{d:`M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7`,key:`1m0v6g`}],[`path`,{d:`M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z`,key:`ohrbg2`}]]),ri=W(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),ii=W(`sun`,[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`m4.93 4.93 1.41 1.41`,key:`149t6j`}],[`path`,{d:`m17.66 17.66 1.41 1.41`,key:`ptbguv`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`m6.34 17.66-1.41 1.41`,key:`1m8zz5`}],[`path`,{d:`m19.07 4.93-1.41 1.41`,key:`1shlcs`}]]),ai=W(`table-2`,[[`path`,{d:`M9 3H5a2 2 0 0 0-2 2v4m6-6h10a2 2 0 0 1 2 2v4M9 3v18m0 0h10a2 2 0 0 0 2-2V9M9 21H5a2 2 0 0 1-2-2V9m0 0h18`,key:`gugj83`}]]),oi=W(`table`,[[`path`,{d:`M12 3v18`,key:`108xh3`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 9h18`,key:`1pudct`}],[`path`,{d:`M3 15h18`,key:`5xshup`}]]),si=W(`tag`,[[`path`,{d:`M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z`,key:`vktsd0`}],[`circle`,{cx:`7.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`kqv944`}]]),ci=W(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]),li=W(`ticket`,[[`path`,{d:`M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z`,key:`qn84l0`}],[`path`,{d:`M13 5v2`,key:`dyzc3o`}],[`path`,{d:`M13 17v2`,key:`1ont0d`}],[`path`,{d:`M13 11v2`,key:`1wjjxi`}]]),ui=W(`trash-2`,[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]),di=W(`trash`,[[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]),fi=W(`triangle-alert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),pi=W(`user-minus`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}],[`line`,{x1:`22`,x2:`16`,y1:`11`,y2:`11`,key:`1shjgl`}]]),mi=W(`user`,[[`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`,key:`975kel`}],[`circle`,{cx:`12`,cy:`7`,r:`4`,key:`17ys0d`}]]),hi=W(`users`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]),gi=W(`zap`,[[`path`,{d:`M15.914 4a1.5 1.5 0 00-2.474-1.561l-9 9A1.5 1.5 0 005.5 14h4.002a.5.5 0 01.471.666L8.086 20a1.5 1.5 0 002.475 1.56l9-9A1.5 1.5 0 0018.5 10h-3.997a.5.5 0 01-.472-.667z`,key:`1v7up4`}]]),K=De();function _i({className:e,error:t,title:n,showReturnToHome:r,children:i}){let{user:a,isLoading:o}=Ae();return Ln(a),(0,K.jsxs)(It,{className:P(`text-red p-5 border border-red rounded-md m-12 mt-36`,e),children:[(0,K.jsxs)(Nt,{children:[(0,K.jsx)(Mt,{className:`text-2xl`,children:(0,K.jsx)(`h2`,{children:n??`Component Error`})}),(0,K.jsx)(Ft,{children:t.message})]}),(0,K.jsxs)(Pt,{children:[i,r!==!1&&(a&&!o?(0,K.jsx)(V,{to:`/`,children:(0,K.jsxs)(F,{children:[` `,(0,K.jsx)(Qt,{}),` Return to Home`]})}):(0,K.jsx)(V,{to:`/sign-in`,children:(0,K.jsxs)(F,{children:[` `,(0,K.jsx)(Qt,{}),` Go to Sign In Page`]})}))]})]})}function vi(){let{user:e,isLoading:t}=Ae();return Ln(e),(0,K.jsx)(`div`,{className:`flex items-center justify-center h-screen px-3`,children:(0,K.jsxs)(It,{className:`text-red p-5 border border-red rounded-md w-full max-w-md`,children:[(0,K.jsx)(Nt,{children:(0,K.jsx)(Mt,{className:`text-2xl`,children:(0,K.jsx)(`h2`,{children:`Sorry, Page Not Found`})})}),(0,K.jsx)(Pt,{children:e&&!t?(0,K.jsx)(V,{to:`/`,children:(0,K.jsxs)(F,{children:[` `,(0,K.jsx)(Qt,{}),` Return to Home`]})}):(0,K.jsx)(V,{to:`/sign-in`,children:(0,K.jsxs)(F,{children:[` `,(0,K.jsx)(Qt,{}),` Go Sign In Page`]})})})]})})}function yi(){return`ontouchstart`in window||navigator.maxTouchPoints>0}var q=e(we(),1);function bi({...e}){return(0,K.jsx)(pt,{"data-slot":`dropdown-menu`,...e})}function xi({...e}){return(0,K.jsx)(qe,{"data-slot":`dropdown-menu-trigger`,...e})}function Si({className:e,sideOffset:t=4,...n}){return(0,K.jsx)(Ke,{children:(0,K.jsx)(Tt,{"data-slot":`dropdown-menu-content`,sideOffset:t,className:P(`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-border p-1 shadow-md`,e),...n})})}function Ci({className:e,inset:t,variant:n=`default`,...r}){return(0,K.jsx)(Ze,{"data-slot":`dropdown-menu-item`,"data-inset":t,"data-variant":n,className:P(`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 wi({className:e,children:t,checked:n,...r}){return(0,K.jsxs)(ze,{"data-slot":`dropdown-menu-checkbox-item`,className:P(`focus:bg-accent focus:text-accent-foreground 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,K.jsx)(`span`,{className:`pointer-events-none absolute left-2 flex size-3.5 items-center justify-center`,children:(0,K.jsx)(Ve,{children:(0,K.jsx)(pn,{className:`size-4`})})}),t]})}function Ti({className:e,inset:t,...n}){return(0,K.jsx)(Be,{"data-slot":`dropdown-menu-label`,"data-inset":t,className:P(`px-2 py-1.5 text-sm font-medium data-[inset]:pl-8`,e),...n})}function Ei({className:e,...t}){return(0,K.jsx)(Ie,{"data-slot":`dropdown-menu-separator`,className:P(`bg-border -mx-1 my-1 h-px`,e),...t})}function Di({className:e,...t}){return(0,K.jsx)(`span`,{"data-slot":`dropdown-menu-shortcut`,className:P(`text-muted-foreground ml-auto text-xs tracking-widest`,e),...t})}function Oi({...e}){return(0,K.jsx)(ft,{"data-slot":`dropdown-menu-sub`,...e})}function ki({className:e,inset:t,children:n,...r}){return(0,K.jsxs)(Ge,{"data-slot":`dropdown-menu-sub-trigger`,"data-inset":t,className:P(`focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground`,`flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none`,`data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0`,`[&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground`,e),...r,children:[n,(0,K.jsx)(gn,{className:`ml-auto size-4`})]})}function Ai({className:e,...t}){return(0,K.jsx)(We,{"data-slot":`dropdown-menu-sub-content`,className:P(`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 min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-hidden rounded-md border p-1 shadow-lg`,e),...t})}var ji=`flex items-center gap-3 p-2 rounded-lg text-sm transition-colors`,Mi=`block p-2 rounded-lg text-sm transition-colors`,Ni={className:`text-foreground hover:bg-accent dark:text-white dark:hover:bg-grey-700`},Pi={className:`font-medium text-primary bg-primary/10 dark:text-white dark:bg-white/10`};function Fi({items:e,ariaLabel:t}){let{pathname:n}=he(),r=e=>e.exact?n===e.to:n.startsWith(e.to),i=e.find(r)??e[0],a=i.icon;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`nav`,{className:`hidden md:flex flex-col gap-1`,"aria-label":t,children:e.map(e=>{let t=e.icon;return(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(V,{to:e.to,className:ji,activeOptions:{exact:!!e.exact},activeProps:Pi,inactiveProps:Ni,children:[(0,K.jsx)(t,{className:`size-4 shrink-0`}),e.label]}),e.children&&r(e)&&(0,K.jsx)(`div`,{className:`mt-1 ml-4 flex flex-col gap-1 border-l border-border pl-3`,children:e.children.map(e=>(0,K.jsx)(V,{to:e.to,className:Mi,activeOptions:{exact:!!e.exact},activeProps:Pi,inactiveProps:Ni,children:e.label},e.to))})]},e.to)})}),(0,K.jsx)(`div`,{className:`md:hidden`,children:(0,K.jsxs)(bi,{children:[(0,K.jsx)(xi,{asChild:!0,children:(0,K.jsxs)(F,{variant:`outline`,className:`w-full justify-between`,children:[(0,K.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(a,{className:`size-4`}),i.label]}),(0,K.jsx)(mn,{className:`size-4`})]})}),(0,K.jsx)(Si,{align:`start`,className:`w-(--radix-dropdown-menu-trigger-width)`,children:e.map(e=>{let t=e.icon;return[(0,K.jsx)(Ci,{asChild:!0,children:(0,K.jsxs)(V,{to:e.to,className:`flex items-center gap-2`,children:[(0,K.jsx)(t,{className:`size-4`}),e.label]})},e.to),...e.children&&r(e)?e.children.map(e=>(0,K.jsx)(Ci,{asChild:!0,children:(0,K.jsx)(V,{to:e.to,className:`flex items-center gap-2 pl-8`,children:e.label})},e.to)):[]]})})]})})]})}var Ii=[{to:`/admin/notifications`,label:`Notifications`,icon:Hn,permission:`systemStatus:write`},{to:`/admin/regions`,label:`Regions`,icon:br,permission:`region:read`},{to:`/admin/api-token`,label:`API Token`,icon:wr,permission:`apiToken:create`,ssoAccountOnly:!0}];function Li(e){let t=e!==null&&`fabricRole`in e&&e.fabricRole===`super_user`;return Ii.filter(n=>Pe(e,n.permission)&&!(n.ssoAccountOnly&&t))}function Ri(e){return Li(e).length>0}function zi(){let{isLoading:e,user:t}=je(),{pathname:n}=he();if(e)return null;let r=Li(t);if(!r.length)return(0,K.jsx)(ne,{to:`/`,replace:!0});let i=Ii.find(e=>n.startsWith(e.to));return i&&!r.includes(i)?(0,K.jsx)(ne,{to:r[0].to,replace:!0}):(0,K.jsx)(`div`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-(--spacing(32)))]`,children:(0,K.jsxs)(`div`,{className:`md:grid gap-6 md:grid-cols-12`,children:[(0,K.jsx)(`aside`,{className:`md:col-span-3 lg:col-span-2 mb-4 md:mb-0`,children:(0,K.jsx)(Fi,{items:r,ariaLabel:`Admin sections`})}),(0,K.jsx)(`section`,{className:`md:col-span-9 lg:col-span-10 min-w-0`,children:(0,K.jsx)(Ce,{})})]})})}function Bi({className:e,text:t,centered:n,...r}){return(0,K.jsxs)(`div`,{className:`text-foreground h-full w-full ${e||``} ${n?`flex flex-col items-center justify-center`:``}`,...r,children:[(0,K.jsx)(`img`,{src:`/HDBDogOnly.svg`,width:`100px`,height:`100px`,alt:`HDB Dog Logo Loading`,className:`inline-block`}),(0,K.jsx)(`p`,{className:`pt-4`,children:t||`Loading...`})]})}function Vi(){return(0,K.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 126.644 96`,width:24,height:24,children:(0,K.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 Hi(){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`img`,{src:`/harper-studio_white.png`,alt:`Harper Studio`,className:`w-64 hidden md:inline-block`}),(0,K.jsx)(`img`,{src:`/HDBDogOnly.svg`,width:`50px`,height:`44px`,alt:`Harper`,className:`inline-block md:hidden`})]})}var Ui=v(`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-foreground [a&]:hover:bg-yellow/90`,success:`border-green bg-green/40 text-foreground [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-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground`}},defaultVariants:{variant:`default`}});function Wi({className:e,variant:t,asChild:n=!1,...r}){return(0,K.jsx)(n?jt:`span`,{"data-slot":`badge`,className:P(Ui({variant:t}),e),...r})}function Gi({className:e,children:t,...n}){return(0,K.jsxs)(kt,{"data-slot":`scroll-area`,className:P(`relative`,e),...n,children:[(0,K.jsx)(Xe,{"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,K.jsx)(Ki,{}),(0,K.jsx)(wt,{})]})}function Ki({className:e,orientation:t=`vertical`,...n}){return(0,K.jsx)(it,{"data-slot":`scroll-area-scrollbar`,orientation:t,className:P(`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,K.jsx)(Dt,{"data-slot":`scroll-area-thumb`,className:`bg-border relative flex-1 rounded-full`})})}var qi=[`notification-acks`];function Ji(){let e=Cn(Sn.AckedNotificationIds,[]);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function Yi(e){yn.setQueryData(qi,e);try{wn(Sn.AckedNotificationIds,e)}catch(e){console.warn(`[notifications] could not persist acknowledgements`,e)}}function Xi(){return z({queryKey:qi,queryFn:Ji,staleTime:1/0,gcTime:1/0,initialData:Ji})}function Zi(e){Yi(Array.from(new Set([...Ji(),e])))}function Qi(e){Yi(Ji().filter(t=>t!==e))}function $i(){let{data:e}=H(Xi());return(0,q.useMemo)(()=>new Set(e??[]),[e])}var ea={critical:{severity:`critical`,label:`Critical`,Icon:Br,badgeVariant:`destructive`,bannerClass:`bg-destructive/10 border-destructive/40 text-foreground`,iconClass:`text-destructive`},warning:{severity:`warning`,label:`Warning`,Icon:fi,badgeVariant:`warning`,bannerClass:`bg-yellow/10 border-yellow/40 text-foreground`,iconClass:`text-yellow`},info:{severity:`info`,label:`Info`,Icon:Cr,badgeVariant:`secondary`,bannerClass:`bg-secondary/20 border-secondary/50 text-foreground`,iconClass:`text-secondary-foreground`}},ta=new Set([`critical`,`error`,`outage`,`incident`,`down`,`danger`]),na=new Set([`warning`,`warn`,`maintenance`,`degraded`,`notice`]),ra=new Set([`info`,`information`,`informational`,`success`,`ok`]);function ia(e){let t=(e??``).trim().toLowerCase();return na.has(t)?`warning`:ra.has(t)?`info`:(ta.has(t),`critical`)}function aa(e){return ea[ia(e)]}var oa={critical:0,warning:1,info:2};function sa(e){if(e==null)return{kind:`absent`};if(typeof e==`number`)return Number.isFinite(e)?{kind:`valid`,ms:e}:{kind:`invalid`};if(typeof e!=`string`)return{kind:`invalid`};let t=e.trim();if(!t)return{kind:`absent`};if(/^\d+$/.test(t))return{kind:`valid`,ms:Number(t)};let n=Date.parse(t);return Number.isNaN(n)?{kind:`invalid`}:{kind:`valid`,ms:n}}function ca(e){let t=sa(e);return t.kind===`valid`?t.ms:null}function la(e){return new Date(e).toLocaleString()}function ua(e,t){let n=sa(e.startAt),r=sa(e.endAt);return n.kind===`invalid`||r.kind===`invalid`?{state:`expired`,label:`Schedule unavailable`}:n.kind===`valid`&&t<n.ms?{state:`upcoming`,label:`Starts ${la(n.ms)}`}:r.kind===`valid`&&t>r.ms?{state:`expired`,label:`Ended ${la(r.ms)}`}:r.kind===`valid`?{state:`active`,label:`Active until ${la(r.ms)}`}:{state:`active`,label:`Active`}}var da=new Set([`http`,`https`,`mailto`]);function fa(e){if(!e)return null;let t=e.trim();if(!t)return null;if(t.startsWith(`//`))return{kind:`external`,href:t};let n=t.match(/^([a-z][a-z0-9+.-]*):/i)?.[1]?.toLowerCase();return n?da.has(n)?{kind:`external`,href:t}:null:{kind:`internal`,href:t.startsWith(`/`)?t:`/${t}`}}function pa({url:e,className:t,children:n,onNavigate:r}){let i=fa(e);return i?i.kind===`external`?(0,K.jsxs)(`a`,{href:i.href,target:`_blank`,rel:`noreferrer noopener`,className:t,children:[n??`Learn more`,(0,K.jsx)(dr,{className:`inline size-3 ml-1 align-[-1px]`})]}):(0,K.jsx)(V,{to:i.href,className:t,onClick:r,children:n??`View details`}):null}var ma=[`system-status`];async function ha(){let{data:e}=await N.get(`/SystemStatus/`);return Array.isArray(e)?e:[]}function ga(){return z({queryKey:ma,queryFn:ha,refetchInterval:6e4,staleTime:3e4})}var _a=3e4,va=new Set,ya=Date.now(),ba=null;function xa(e){return va.add(e),ba||=(ya=Date.now(),setInterval(()=>{ya=Date.now(),va.forEach(e=>e())},_a)),()=>{va.delete(e),va.size===0&&ba&&(clearInterval(ba),ba=null)}}function Sa(){return(0,q.useSyncExternalStore)(xa,()=>ya,()=>ya)}function Ca(){return H(ga())}function wa(){let[e,t]=(0,q.useState)(()=>window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`);return(0,q.useEffect)(()=>{let e=window.matchMedia(`(prefers-color-scheme: dark)`),n=e=>t(e.matches?`dark`:`light`);return e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e}var Ta=(0,q.createContext)([`system`,()=>{}]);function Ea({children:e}){let[t,n]=Tn(Sn.Theme,`system`),r=wa();return(0,q.useEffect)(()=>{let e=t===`dark`||t===`system`&&r===`dark`;document.documentElement.classList.toggle(`dark`,e)},[t,r]),(0,K.jsx)(Ta.Provider,{value:[t,n],children:e})}function Da(){return(0,q.useContext)(Ta)}var Oa=[{value:`light`,icon:(0,K.jsx)(ii,{className:`size-4`}),label:`Light`},{value:`system`,icon:(0,K.jsx)(Lr,{className:`size-4`}),label:`System`},{value:`dark`,icon:(0,K.jsx)(Rr,{className:`size-4`}),label:`Dark`}];function ka(){let[e,t]=Da();return(0,K.jsx)(`div`,{className:`flex items-center bg-muted dark:bg-black rounded-xl p-0.5 gap-0.5`,children:Oa.map(({value:n,icon:r,label:i})=>(0,K.jsx)(`button`,{type:`button`,title:i,onClick:()=>t(n),className:`p-1.5 rounded-lg transition-colors ${e===n?`bg-background text-foreground shadow-xs`:`text-muted-foreground hover:text-foreground`}`,children:r},n))})}function Aa({className:e,...t}){return(0,K.jsx)(`div`,{className:P(`absolute top-full left-0 isolate z-50 flex justify-center`),children:(0,K.jsx)(tt,{"data-slot":`navigation-menu-viewport`,className:P(`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 ja({className:e,children:t,viewport:n=!0,...r}){return(0,K.jsxs)(lt,{"data-slot":`navigation-menu`,"data-viewport":n,className:P(`group/navigation-menu relative flex max-w-max flex-1 items-center justify-center`,e),...r,children:[t,n&&(0,K.jsx)(Aa,{})]})}function Ma({className:e,...t}){return(0,K.jsx)(vt,{"data-slot":`navigation-menu-item`,className:P(`relative`,e),...t})}function Na({className:e,...t}){return(0,K.jsx)(ht,{"data-slot":`navigation-menu-link`,className:P(`hover:text-foreground dark: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 Pa({className:e,...t}){return(0,K.jsx)(ut,{"data-slot":`navigation-menu-list`,className:P(`group flex flex-1 list-none items-center justify-center gap-1`,e),...t})}function Fa({delayDuration:e=0,...t}){return(0,K.jsx)(St,{"data-slot":`tooltip-provider`,delayDuration:e,...t})}function Ia({...e}){return(0,K.jsx)(Fa,{children:(0,K.jsx)(ot,{"data-slot":`tooltip`,...e})})}function La({...e}){return(0,K.jsx)(ct,{"data-slot":`tooltip-trigger`,...e})}function Ra({className:e,sideOffset:t=0,arrowClassName:n,children:r,...i}){return(0,K.jsx)(mt,{children:(0,K.jsxs)(at,{"data-slot":`tooltip-content`,sideOffset:t,className:P(`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,K.jsx)(bt,{className:P(`bg-primary fill-primary z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]`,n)})]})})}function za(){let e=`v5.2.6`,t=e.startsWith(`v`)?`https://github.com/HarperFast/studio/releases/tag/${e}`:`https://github.com/HarperFast/studio/releases`;return(0,K.jsx)(`a`,{href:t,target:`_blank`,rel:`noopener noreferrer`,children:(0,K.jsxs)(`span`,{className:P(Ui({variant:`default`}),`text-xs inline-block ml-2 align-text-top`),children:[e,` BETA`]})})}function Ba(){localStorage.clear()}function Va(){sessionStorage.clear()}async function Ha(){l.setUserForEntity(m,null),yn.getQueryCache().clear(),Ba(),Va(),await yn.invalidateQueries({refetchType:`none`})}async function Ua(e){await l.signOutFromPotentiallyAuthenticatedInstances(),await u({...e,entityId:m})}function Wa(){let e=En();return R({mutationFn:()=>Ua({instanceClient:e}),onSuccess:Ha})}var Ga={className:`text-foreground dark:text-white font-semibold`};function Ka(){let{mutate:e}=Wa(),t=L(),{user:n}=Ae(),r=Ri(n),i=ae(),a=(0,q.useCallback)(()=>{e(void 0,{onSuccess:async()=>{U.success(`Success`,{description:`You have been signed out successfully.`,action:{label:`Dismiss`,onClick:()=>U.dismiss()}}),t({to:`/sign-in`}),i.invalidate()}})},[e,i,t]),o=(0,q.useMemo)(()=>[!1,!1,{to:`https://docs.harperdb.io/docs`,target:`_blank`,icon:(0,K.jsx)(Un,{}),text:`Docs`,textBreakpoint:`md`},{to:`https://github.com/HarperFast/studio/issues`,target:`_blank`,icon:(0,K.jsx)(Gn,{}),text:`Report an Issue`,textBreakpoint:`lg`},{to:`https://discord.gg/VzZuaw3Xay`,target:`_blank`,icon:(0,K.jsx)(Vi,{}),text:`Discord`,textBreakpoint:`lg`},{onClick:a,icon:(0,K.jsx)(jr,{}),text:`Sign Out`,textBreakpoint:`md`}].filter(kn),[a,r]);return n?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Za,{menuItems:o}),(0,K.jsx)(Ya,{menuItems:o})]}):(0,K.jsx)(Ja,{})}function qa(e){return e.items!==void 0}function Ja(){return(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`inline-block`,children:[(0,K.jsx)(V,{to:`/sign-in`,children:(0,K.jsx)(Hi,{})}),(0,K.jsx)(za,{})]}),(0,K.jsx)(ja,{children:(0,K.jsxs)(Pa,{className:`text-muted-foreground dark:text-grey-400`,children:[(0,K.jsx)(Ma,{children:(0,K.jsx)(Na,{asChild:!0,children:(0,K.jsxs)(V,{to:`https://docs.harperdb.io/docs`,target:`_blank`,rel:`noreferrer noopener`,className:`flex-row items-center`,children:[(0,K.jsx)(Un,{}),` `,(0,K.jsx)(`span`,{className:`hidden md:inline-block`,children:`Docs`})]})})}),(0,K.jsx)(Ma,{children:(0,K.jsx)(ka,{})}),(0,K.jsx)(Ma,{children:(0,K.jsx)(Na,{asChild:!0,children:(0,K.jsxs)(V,{to:`/sign-in`,className:`flex-row items-center`,activeProps:Ga,children:[(0,K.jsx)(Mr,{}),` Sign In`]})})})]})})]})}function Ya({menuItems:e}){let{user:t}=Ae();return Ln(t),(0,K.jsx)(`div`,{className:`hidden md:[@media(hover:hover)]:block xl:block`,children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`inline-block`,children:[(0,K.jsx)(V,{to:`/`,children:(0,K.jsx)(Hi,{})}),(0,K.jsx)(za,{})]}),(0,K.jsx)(ja,{children:(0,K.jsxs)(Pa,{className:`text-muted-foreground dark:text-grey-400`,children:[e.map(e=>qa(e)?!!e.items.length&&(0,K.jsx)(`div`,{className:`bg-muted dark:bg-black rounded-2xl flex`,children:e.items.map(e=>(0,K.jsx)(Xa,{menuItem:e},e.text))},e.text):(0,K.jsx)(Xa,{menuItem:e},e.text)),!1,(0,K.jsx)(Ma,{children:(0,K.jsx)(ka,{})})]})})]})})}function Xa({menuItem:e}){return(0,K.jsx)(Ma,{className:`text-muted-foreground dark:text-gray-400 hover:text-foreground dark:hover:text-white`,children:(0,K.jsxs)(Ia,{children:[(0,K.jsx)(La,{asChild:!0,children:(0,K.jsx)(Na,{asChild:!0,children:(0,K.jsxs)(V,{to:e.to,onClick:e.onClick,"aria-label":e.text,className:`flex-row items-center`,target:e.target,activeProps:e.to?Ga:void 0,children:[e.icon,(0,K.jsx)(`span`,{className:`hidden ${e.textBreakpoint}:inline-block`,children:e.text}),(0,K.jsx)(`span`,{className:`${e.textBreakpoint}:hidden`,children:`\xA0`})]})})}),(0,K.jsx)(Ra,{side:`bottom`,className:`${e.textBreakpoint}:hidden`,children:e.text})]})})}function Za({menuItems:e}){let{user:t}=Ae();Ln(t);let[n,r]=(0,q.useState)(!1),i=(0,q.useCallback)(()=>r(e=>!e),[]),a=(0,q.useCallback)(()=>r(!1),[]);return(0,K.jsxs)(`div`,{className:`md:[@media(hover:hover)]:hidden xl:hidden`,id:`mobile-menu`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(V,{to:`/`,children:(0,K.jsx)(Hi,{})}),(0,K.jsx)(za,{}),(0,K.jsxs)(`div`,{className:`flex items-center`,children:[!1,(0,K.jsxs)(`button`,{type:`button`,className:`shadow-xs text-muted-foreground dark:text-grey-400 hover:text-foreground dark:hover:text-white hover:bg-muted dark:hover:bg-black-dark`,onClick:i,children:[(0,K.jsx)(`span`,{className:`sr-only`,children:n?`Close menu`:`Open menu`}),n?(0,K.jsx)(hn,{}):(0,K.jsx)(Ir,{})]})]})]}),(0,K.jsx)(`div`,{className:`${n?`fixed`:`hidden`} top-40 bottom-0 left-0 right-0 bg-foreground/20 dark:bg-black-dark dark:opacity-70`,onClick:a}),(0,K.jsxs)(`div`,{className:`${n?`block`:`hidden`} md:hidden z-50 space-y-1 pb-3 bg-card border-b border-border dark:bg-black-dark dark:border-none absolute left-0 top-full w-full rounded-b-md`,children:[(0,K.jsx)(`div`,{className:`flex justify-end px-3 pt-2`,children:(0,K.jsx)(ka,{})}),e.map(e=>qa(e)?!!e.items.length&&(0,K.jsx)(`div`,{className:`bg-muted dark:bg-black pl-10 pr-2 py-2`,children:e.items.map(e=>(0,K.jsx)(Qa,{menuItem:e,onClick:a},e.text))},e.text):(0,K.jsx)(Qa,{menuItem:e,onClick:a},e.text))]})]})}function Qa({menuItem:e,onClick:t}){let n=(0,q.useCallback)(()=>{e.onClick?.(),t()},[e,t]);return(0,K.jsxs)(V,{to:e.to,onClick:n,target:e.target,className:`flex flex-row px-3 py-2 text-base font-medium rounded-md text-muted-foreground dark:text-gray-400 hover:text-foreground dark:hover:text-white`,activeProps:e.to?Ga:void 0,children:[e.icon,(0,K.jsx)(`span`,{className:`ml-4`,children:e.text})]})}function $a(){let{isLoading:e}=Ae(),{createCluster:t}=se({strict:!1}),[,n]=Tn(Sn.SavedClusterState,null);return(0,q.useEffect)(()=>{t&&n(t)},[t,n]),e?(0,K.jsx)(Bi,{className:`fixed z-50 translate-1/2`}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`header`,{className:`fixed top-0 z-40 w-full h-20 p-4 bg-gradient-to-r from-violet-100 to-white border-b border-violet-200 dark:from-purple-950 dark:to-zinc-900 dark:border-purple-950 md:px-12`,children:(0,K.jsx)(Ka,{})}),(0,K.jsx)(`main`,{children:(0,K.jsx)(Ce,{})})]})}function eo(){let e=location.hash;return e?e.startsWith(`#/`)?e.slice(1):e:`/`}var to=[`/`,`/forgot-password`,`/reset-password`,`/sign-in`,`/sign-up`,`/verify-email`];function no(){let e=eo();return!to.includes(e)&&{redirect:e}}var ro=`me|email|token|access_token|id_token|refresh_token|code|secret|password|api[-_]?key`,io=String.raw`[^&#\s",<>[\]{}|\\]+`,ao=String.raw`[\w.%+!~*'()-]+(?:@|%40)[\w-]+(?:\.[\w-]+)*\.\w{2,}`;new RegExp(String.raw`([?&](?:${ro})=)${io}`,`gi`),new RegExp(String.raw`([?&](?:${ro})=)${io}|${ao}`,`gi`);var oo=!1;function so(){(0,q.useEffect)(()=>{oo||=!0},[])}function co(){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(ge,{}),(0,K.jsx)(Ce,{})]})}var lo=ue()({component:co}),uo=I({getParentRoute:()=>lo,id:`_dashboardLayout`,component:$a,beforeLoad:({context:e})=>{let t=e.authentication[m];if(t&&!t.isLoading&&!t.user)throw re({to:`/sign-in`,search:no()})}}),fo=I({getParentRoute:()=>uo,path:`admin`,component:zi});I({getParentRoute:()=>fo,path:`/`,beforeLoad:()=>{throw re({to:`/admin/notifications`})}}),I({getParentRoute:()=>fo,path:`notifications`,head:()=>({meta:[{title:`Notifications — Harper Fabric`}]}),component:me(async()=>Te(()=>import(`./notifications-B8rDagJM.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15])),`NotificationsAdminIndex`)}),I({getParentRoute:()=>fo,path:`regions`,head:()=>({meta:[{title:`Regions — Harper Fabric`}]}),component:me(async()=>Te(()=>import(`./regions-y_jxsBpN.js`),__vite__mapDeps([16,1,3,2,4,5,6,7,17,18,8,9,10,11,12,13])),`RegionsIndex`)}),I({getParentRoute:()=>fo,path:`api-token`,head:()=>({meta:[{title:`API Token — Harper Fabric`}]}),component:me(async()=>Te(()=>import(`./apiToken-D0x_S8Wq.js`),__vite__mapDeps([19,1,2,3,4,5,6,7,20])),`ApiTokenIndex`)});function po(){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`header`,{className:`fixed top-0 z-40 w-full h-20 p-4 bg-gradient-to-r from-violet-100 to-white border-b border-violet-200 dark:from-purple-950 dark:to-zinc-900 dark:border-purple-950 md:px-12`,children:(0,K.jsx)(Ka,{})}),(0,K.jsxs)(`div`,{className:`pt-20 h-screen grid grid-cols-1 md:grid-cols-2`,children:[(0,K.jsx)(`section`,{"aria-label":`Harper Fabric overview`,className:`items-center justify-center hidden text-white md:flex px-6 fabricSignupTextContainer`,children:(0,K.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,K.jsx)(`main`,{className:`overflow-y-auto px-6 bg-white dark:bg-linear-(--black-dark-gradient) border-l border-border dark:border-none`,children:(0,K.jsx)(`div`,{className:`min-h-full flex items-start justify-center py-12`,children:(0,K.jsx)(Ce,{})})})]})]})}var mo;function ho(){(0,q.useEffect)(()=>{},[])}var go=[`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 _o(e){if(!e||!e.includes(`@`))return null;let t=e.split(`@`).pop()||``;if(!t)return null;for(let e of go)if(t===e||t.endsWith(`.`+e))return null;return t}var vo=`utm_`;function yo(e){let t=new URLSearchParams(e),n=Array.from(t.keys()).filter(e=>e.toLowerCase().startsWith(vo));if(n.length===0)return e;for(let e of n)t.delete(e);let r=t.toString();return r?`?${r}`:``}function bo(){if(typeof location>`u`||typeof history>`u`)return;let{search:e,pathname:t,hash:n,origin:r}=location,i=yo(e);i!==e&&history.replaceState(history.state,``,`${r}${t}${i}${n}`)}var xo=null;function So(){let e=L(),t=ae(),n=ie(),{redirect:i}=se({strict:!1});return(0,q.useEffect)(()=>{xo||=(async function(){let a=await r().catch(()=>null);if(!a)U.error(`We were not able to verify your sign-in. Please try signing in again.`,{duration:1e4}),await e({to:`/sign-in`});else{l.setUserForEntity(m,a),bo();let r=Ln(a),o=_o(a.email);mo?.identify?.({username:a.email,type:`email`,...o?{company:o}:{}}),await n.invalidateQueries({queryKey:p,refetchType:`none`}),await t.invalidate(),await e({to:i?.startsWith(`/`)?i:r})}xo=null})()},[]),(0,K.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`text-foreground dark:text-white w-lg flex flex-col gap-4`,children:[(0,K.jsxs)(`h1`,{className:`text-3xl font-light`,children:[(0,K.jsx)(`span`,{"aria-hidden":`true`,className:`text-2xl animate-flower-dance mr-4`,title:`Loading`,children:`🌼`}),`Checking...`]}),(0,K.jsx)(`div`,{className:`underline flex gap-4`,children:(0,K.jsx)(V,{className:`text-sm opacity-50 text-muted-foreground hover:text-foreground dark:text-inherit dark:hover:text-blue-300`,to:`/sign-in`,children:`Try signing in again`})})]})}var Co=new Map;function wo(e){if(!e)return``;if(Co.has(e))return Co.get(e);let t=e.replace(/[-_]+/g,` `).replace(/\s+/g,` `).trim();if(!t)return Co.set(e,``),``;let n=t.match(/([A-Z]+(?=[A-Z][a-z])|[A-Z]?[a-z]+|[A-Z]+|[0-9]+)/g);if(!n)return Co.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(To).join(` `);return Co.set(e,i),i}function To(e){return/^[A-Z]{2,3}s?$/.test(e)||/^[0-9]+$/.test(e)?e:e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}function Eo({restartRequired:e}){let t=he(),{organization:n,instance:r,cluster:i}=de({strict:!1}),a=(0,q.useMemo)(()=>{let e=t.pathname.split(`/`).filter(e=>e&&e.length>0),a=[(0,K.jsxs)(V,{to:`/`,children:[(0,K.jsx)(Sr,{"aria-hidden":`true`,className:`size-5 shrink-0`}),(0,K.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=wo(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,K.jsx)(`svg`,{fill:`currentColor`,viewBox:`0 0 20 20`,"aria-hidden":`true`,className:`size-5 shrink-0 text-grey`,children:(0,K.jsx)(`path`,{d:`M5.555 17.776l8-16 .894.448-8 16-.894-.448z`})},a.length+`-dash`),(0,K.jsx)(V,{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]);return(0,K.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:[...a,e&&(0,K.jsxs)(Ia,{children:[(0,K.jsx)(La,{asChild:!0,children:(0,K.jsxs)(`div`,{className:`text-xs italic text-muted-foreground`,children:[`* Restart `,(0,K.jsx)(`span`,{className:`hidden lg:inline-block`,children:`Requested`})]})}),(0,K.jsxs)(Ra,{side:`bottom`,children:[`This `,`Instance`,` is requesting a restart, when convenient, to apply your latest changes.`,(0,K.jsx)(`br`,{}),`You can do this from the Apps or Config pages.`]})]})]})}var Do=gt,Oo=(0,q.createContext)({}),ko=(0,q.createContext)({});function Ao(){let e=(0,q.useContext)(Oo),t=(0,q.useContext)(ko),{getFieldState:n}=nt(),r=_t({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 J({...e}){let{error:t,formItemId:n,formDescriptionId:r,formMessageId:i}=Ao();return(0,K.jsx)(jt,{"data-slot":`form-control`,id:n,"aria-describedby":t?`${r} ${i}`:`${r}`,"aria-invalid":!!t,...e})}function Y({...e}){return(0,K.jsx)(Oo,{value:{name:e.name},children:(0,K.jsx)(xt,{...e})})}function X({className:e,...t}){let n=(0,q.useId)();return(0,K.jsx)(ko,{value:{id:n},children:(0,K.jsx)(`div`,{"data-slot":`form-item`,className:P(`grid gap-2`,e),...t})})}function jo({className:e,...t}){return(0,K.jsx)(st,{"data-slot":`label`,className:P(`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 Z({className:e,...t}){let{error:n,formItemId:r}=Ao();return(0,K.jsx)(jo,{"data-slot":`form-label`,"data-error":!!n,className:P(`data-[error=true]:text-destructive`,e),htmlFor:r,...t})}function Q({className:e,...t}){let{error:n,formMessageId:r}=Ao(),i=n?String(n?.message):t.children;return i?(0,K.jsx)(`p`,{"data-slot":`form-message`,id:r,className:P(`text-destructive text-sm`,e),...t,children:i}):null}function $({className:e,type:t,...n}){return(0,K.jsx)(`input`,{type:t,"data-slot":`input`,className:P(`border-input file:text-foreground placeholder:text-muted-foreground selection:bg-purple
|
|
3
3
|
selection:text-primary-foreground
|
|
4
4
|
dark:aria-invalid:outline-destructive dark:aria-invalid:ring-destructive/50 ring-ring/10
|
|
5
5
|
dark:ring-ring/20 dark:outline-ring/40 outline-ring/50 aria-invalid:outline-destructive/60
|
|
@@ -9,7 +9,7 @@ import{a as e,t}from"./rolldown-runtime-B0Z9INg1.js";import{a as n,c as r,d as i
|
|
|
9
9
|
focus-visible:ring-1 focus-visible:outline-none focus-visible:ring-purple disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50
|
|
10
10
|
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 Mo=[`RUNNING`],No=[`TERMINATING`,`TERMINATED`,`REMOVED`];function Po(){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 Fo({username:e,password:t,instanceClient:r,entityId:i}){let a={username:e,password:t};l.checkForBasicAuth(i)&&(r.defaults.auth=a,r.defaults.withCredentials=!1);let{data:{message:o}}=await r.post(`/`,{operation:`login`,username:e,password:t});if(!l.checkForBasicAuth(i))try{let e=await n({instanceClient:r});return l.setLastConnectMode(i,`direct`),{message:o,user:e}}catch(e){console.error(`Failed to get user after login, trying basic auth`,e)}try{r.defaults.auth=a,r.defaults.withCredentials=!1;let e=await n({instanceClient:r,auth:a});return l.flagForBasicAuth(i,a),l.setLastConnectMode(i,`direct`),{message:o,user:e}}catch(e){throw r.defaults.auth=void 0,r.defaults.withCredentials=!0,e}}function Io(){return R({mutationFn:Fo})}function Lo({cluster:e,instance:t,instanceParams:n}){let r=L(),i=ae(),{redirect:a}=se({strict:!1}),{mutate:o,isPending:s}=Io();return{isPending:s,submitForm:(0,q.useCallback)(async s=>{o({...s,...n},{onSuccess:async({message:n,user:o})=>{if(U.success(n),e?.instances?.length&&!t)for(let t of e.instances)l.setUserForEntity(t,o);let s=m;if(!s)throw Error(`Sign in failed due to missing cluster or instance.`);l.setUserForEntity(s,o),i.invalidate(),await r({to:a?.startsWith(`/`)?a:`/`})}})},[e,t,n,r,a,i,o])}}function Ro(e){if(Uo(e)||Wo(e))return`warning`;if(Bo(e))return`success`;switch(e){case`STOPPED`:return`destructive`;case`TERMINATING`:case`TERMINATED`:case`FAILED`:case`REMOVED`:case`ERROR`:return`destructive`;default:return`default`}}function zo(e){switch(e){case`STOPPED`:case`STOPPING`:case`STARTING`:case`RESTARTING`:return!0;default:return!1}}function Bo(e){switch(e){case`RUNNING`:case`UPDATED`:return!0;default:return!1}}function Vo(e){switch(e){case`FAILED`:return!0;default:return!1}}function Ho(e){switch(e){case`TERMINATED`:return!0;default:return!1}}function Uo(e){switch(e){case`CLONE_PENDING`:case`PENDING_UPGRADE`:return!0;default:return!1}}function Wo(e){switch(e){case`PROVISIONING`:case`CLONING`:case`CLONE_READY`:case`UPDATING_HDB_NODES`:case`DRAINING`:case`UPDATING`:return!0;default:return!1}}function Go(e){let t=(e?.instances??[]).filter(e=>!(e.status&&No.includes(e.status)));return t.length>0&&t.every(e=>Bo(e.status))}async function Ko(e){let{data:t}=await N.get(`/Cluster/${e}`);return t}async function qo(e,t){let{queryKey:n}=Jo(t);await e.cancelQueries({queryKey:n,exact:!0}),e.setQueryData(n,e=>e&&{...e,resetPassword:!1})}function Jo(e,t){return z({queryKey:[e],queryFn:()=>Ko(e),retry:!1,staleTime:1900,enabled:!!e,refetchInterval:jn(t?t===!0?1e4:t:void 0)})}var Yo=C({error:`Please enter a valid email address.`}).toLowerCase().trim(),Xo=M().nonempty({error:`Please enter your password.`}),Zo=M().nonempty({error:`Please enter a username.`}),Qo=y({username:Zo,password:Xo}),$o=y({email:Yo,password:Xo});function es({entityId:e,instanceClient:t}){return z({queryKey:[`health`,e],queryFn:async()=>{try{return await t.get(`/health`),!0}catch{return!1}},retry:2,refetchInterval:5e3})}var ts=[`localhost`,`127.0.0.1`],ns=function(e){return e.MixedLoopback=`MixedLoopback`,e.InsecureCookieOutsideChromeAndFirefox=`InsecureCookieOutsideChromeAndFirefox`,e}({});function rs(e,t,n){if(!n||!t||!e)return null;let r=new URL(n).hostname,i=ts.includes(t),a=ts.includes(r);if(i&&a&&r!==t)return`MixedLoopback`;if(!i&&a){let t=e.indexOf(`Chrome`)>=0,n=e.indexOf(`Firefox`)>=0;if(!t&&!n)return`InsecureCookieOutsideChromeAndFirefox`}return null}function is(){let{clusterId:e,instanceId:t}=B({strict:!1}),{data:n}=H(Jo(e,!0)),r=(0,q.useMemo)(()=>t&&n&&n?.instances?.find(e=>e.id===t)||void 0,[n,t]),i=(0,q.useMemo)(()=>n?.status&&Mo.includes(n.status),[n?.status]),a=`instance`,s=(0,q.useMemo)(()=>n?r?(l.flagForFabricConnect(r.id,!1),f(r)):(l.flagForFabricConnect(n.id,!1),o(n)):null,[n,r]),c=r?.id??n?.id;(0,q.useEffect)(()=>{r?l.setUserForEntity(r,null):n&&l.setUserForEntity(n,null)},[c]);let u=G({operationsUrl:s}),d=(0,q.useMemo)(()=>s?.includes(`localhost`)||s?.includes(`127.0.0.1`),[s]),p=(0,q.useMemo)(()=>rs(navigator.userAgent,location.hostname,s),[s]),{data:m}=H(es(u)),h=dt({resolver:Fe(Qo),defaultValues:{username:``,password:``}}),{control:_,handleSubmit:v}=h,{submitForm:y,isPending:b}=Lo({cluster:n,instance:r,instanceParams:u});if(!t&&n&&!n?.fqdn)return(0,K.jsx)(ne,{to:`../instances`,replace:!0});if(n?.resetPassword){let e=i&&Go(n);return(0,K.jsx)(ne,{to:`/${n.organizationId}/${n.id}/${e?`finish-setup`:`starting-up`}`,replace:!0})}return(0,K.jsxs)(K.Fragment,{children:[!1,(0,K.jsx)(`div`,{className:g(`min-h-screen`,`items-center justify-center flex`),children:(0,K.jsxs)(`div`,{className:`text-foreground w-xs py-8`,children:[(0,K.jsxs)(`h1`,{className:`text-2xl font-light`,children:[`Sign in to Harper `,`Local`]}),(0,K.jsx)(Do,{...h,children:(0,K.jsxs)(`form`,{id:`auth-${a}-signin-form`,name:`auth-${a}-signin-form`,onSubmit:v(y),className:`my-4`,children:[(0,K.jsx)(Y,{control:_,name:`username`,render:({field:e})=>(0,K.jsxs)(X,{className:`my-4`,children:[(0,K.jsx)(Z,{children:`Username`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{autoComplete:`username`,autoFocus:!0,type:`text`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:_,name:`password`,render:({field:e})=>(0,K.jsxs)(X,{className:`my-4`,children:[(0,K.jsx)(Z,{children:`Password`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`password`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(F,{disabled:b,type:`submit`,variant:`submit`,className:`w-full my-2`,children:`Sign In`}),m===!1&&(0,K.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,K.jsx)(`span`,{className:`font-medium`,children:`Warning!`}),` This `,a,` is not responding to GET`,` `,(0,K.jsxs)(`a`,{href:`${s}health`,className:`underline`,target:`_blank`,children:[s,`health`]}),` `,`checks.`,(0,K.jsxs)(`ol`,{className:`list-decimal ml-8 mt-2`,children:[(0,K.jsx)(`li`,{children:`Is the server running?`}),(0,K.jsxs)(`li`,{children:[`Have you`,` `,(0,K.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?`]}),d&&(0,K.jsxs)(`li`,{children:[`Have you allowed`,` `,(0,K.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?`]})]})]}),p===ns.MixedLoopback&&(0,K.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,K.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.`]}),p===ns.InsecureCookieOutsideChromeAndFirefox&&(0,K.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,K.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,K.jsxs)(`div`,{className:`p-4 mt-4 text-sm rounded-lg bg-purple-950`,role:`alert`,children:[(0,K.jsx)(`span`,{className:`font-medium`,children:`Did you know?`}),` `,`You can add this instance to your Harper account to manage it remotely.`,(0,K.jsx)(`div`,{className:`text-center pt-2`,children:(0,K.jsx)(V,{to:Po(),target:`_blank`,children:(0,K.jsx)(F,{type:`button`,variant:`positive`,children:`Connect to Harper Fabric`})})})]})]})})]})})]})}async function as({email:e}){let{data:t}=await N.post(`/ForgotPassword/`,{email:e});if(t)return t;throw Error(`Something went wrong`)}function os(){return R({mutationFn:e=>as(e)})}var ss=y({email:Yo});function cs(){let e=L(),{me:t}=se({strict:!1}),n=dt({resolver:Fe(ss),defaultValues:{email:t||``}}),r=n.watch(`email`),{setFocus:i,control:a,handleSubmit:o}=n;(0,q.useEffect)(()=>{i(`email`)},[i]);let{mutate:s,isPending:c}=os(),l=async t=>{s(t,{onSuccess:t=>{U.success(`Success`,{description:`${t}`,action:{label:`Dismiss`,onClick:()=>U.dismiss()}}),e({to:`/sign-in`,search:{me:r}})}})};return(0,K.jsxs)(`div`,{className:`text-foreground dark:text-white w-xs`,children:[(0,K.jsx)(`h1`,{className:`text-2xl font-light`,children:`Enter your account email`}),(0,K.jsx)(`p`,{className:`text-sm pt-1`,children:`If a matching account exists, we'll send you a password reset link.`}),(0,K.jsx)(Do,{...n,children:(0,K.jsxs)(`form`,{id:`auth-forgot-password-form`,name:`auth-forgot-password-form`,onSubmit:o(l),className:`my-4`,children:[(0,K.jsx)(Y,{control:a,name:`email`,render:({field:e})=>(0,K.jsxs)(X,{className:`my-2`,children:[(0,K.jsx)(Z,{children:`Email`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{disabled:c,type:`email`,className:`dark:bg-black dark:border-black`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(F,{type:`submit`,variant:`submit`,disabled:c,className:`w-full my-2`,children:`Send Password Reset Email`})]})}),(0,K.jsxs)(`div`,{className:`flex px-4 mt-4 underline place-content-between`,children:[(0,K.jsx)(V,{className:`text-sm hover:text-blue-300`,to:`/sign-in`,search:{me:r},children:`Sign in to your account`}),(0,K.jsx)(V,{className:`text-sm hover:text-blue-300`,to:`/sign-up`,search:{me:r},children:`Sign up for free`})]})]})}var ls=async({token:e,password:t})=>{let{data:n}=await N.put(`/ResetPassword/`,{token:e,newPassword:t});return n};function us(){return R({mutationFn:e=>ls(e)})}var ds=y({password:Xo.min(8,{error:`Password must be at least 8 characters long.`}).max(50,{error:`Password cannot be longer than 50 characters.`}),confirmPassword:M()}).refine(e=>e.password===e.confirmPassword,{error:`Passwords do not match.`,path:[`confirmPassword`]});function fs(){let{token:e}=se({strict:!1}),t=L();(0,q.useEffect)(()=>{e||t({to:`/sign-in`})},[e,t]);let n=dt({resolver:Fe(ds),defaultValues:{password:``,confirmPassword:``}}),{setFocus:r,control:i,handleSubmit:a}=n;(0,q.useEffect)(()=>{r(`password`)},[r]);let{mutate:o,isPending:s}=us(),c=(0,q.useCallback)(async n=>{o({token:e,password:n.password},{onSuccess:()=>{U.success(`Success`,{description:`Your password has been reset successfully.`,action:{label:`Dismiss`,onClick:()=>U.dismiss()}}),t({to:`/sign-in`})}})},[t,o,e]);return(0,K.jsxs)(`div`,{className:`text-foreground dark:text-white w-xs`,children:[(0,K.jsx)(`h1`,{className:`text-2xl font-light`,children:`Reset Password`}),(0,K.jsx)(Do,{...n,children:(0,K.jsxs)(`form`,{id:`auth-reset-password-form`,name:`auth-reset-password-form`,className:`my-4`,onSubmit:a(c),children:[(0,K.jsx)(Y,{control:i,name:`password`,render:({field:e})=>(0,K.jsxs)(X,{className:`my-2`,children:[(0,K.jsx)(Z,{children:`New Password`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{disabled:s,type:`password`,autoComplete:`new-password`,className:`dark:bg-black dark:border-black`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:i,name:`confirmPassword`,render:({field:e})=>(0,K.jsxs)(X,{className:`my-2`,children:[(0,K.jsx)(Z,{children:`Confirm Password`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{disabled:s,type:`password`,autoComplete:`new-password`,className:`dark:bg-black dark:border-black`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(F,{variant:`submit`,type:`submit`,disabled:s,className:`w-full my-2`,children:`Submit New Password`})]})})]})}function ps(){return(0,K.jsx)(Wi,{className:`pointer-events-none absolute -top-2 right-3 z-10 rounded-full border-primary bg-primary px-1.5 py-0 text-[10px] font-medium text-white shadow-sm`,children:`Last used`})}function ms({text:e,disabled:t,onClick:n,lastUsed:r=!1}){let i=(0,K.jsxs)(`a`,{href:`/oauth/github/login?redirect=%2F%23%2Fcheck-oauth`,onClick:n,"aria-disabled":t||void 0,className:g(`github-signin-btn`,t&&`opacity-50 cursor-default`),children:[(0,K.jsx)(`img`,{src:`/github/GitHub_Invertocat_White.svg`,alt:``,className:`github-icon`}),e]});return r?(0,K.jsxs)(`div`,{className:`relative flex flex-col`,children:[i,(0,K.jsx)(ps,{})]}):i}function hs({text:e,disabled:t,onClick:n,lastUsed:r=!1}){let i=(0,K.jsxs)(`a`,{href:`/oauth/google/login?redirect=%2F%23%2Fcheck-oauth`,onClick:n,"aria-disabled":t||void 0,className:g(`gsi-material-button`,t&&`opacity-50 cursor-default`),children:[(0,K.jsx)(`div`,{"aria-hidden":`true`,className:`gsi-material-button-state`}),(0,K.jsxs)(`div`,{className:`gsi-material-button-content-wrapper`,children:[(0,K.jsx)(`div`,{"aria-hidden":`true`,className:`gsi-material-button-icon`,children:(0,K.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,K.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,K.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,K.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,K.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,K.jsx)(`path`,{fill:`none`,d:`M0 0h48v48H0z`})]})}),(0,K.jsx)(`span`,{className:`gsi-material-button-contents`,children:e}),(0,K.jsx)(`span`,{className:`hidden`,children:e})]})]});return r?(0,K.jsxs)(`div`,{className:`relative flex flex-col`,children:[i,(0,K.jsx)(ps,{})]}):i}function gs(e){if(!E(e)||e.response?.status!==403)return!1;let t=e.response.data,n=typeof t==`string`?t:_n(t?.error)??_n(t?.message)??_n(t?.title)??``;return/verif/i.test(n)}var _s=async({email:e})=>{let{data:t}=await N.post(`/ResendVerificationEmail/`,{email:e});return t};function vs(){return R({mutationFn:e=>_s(e)})}function ys(){let e=L(),t=ie(),n=ae(),{redirect:r}=se({strict:!1}),{mutate:i,isPending:a}=bs(),{mutate:o}=vs();return{isPending:a,submitForm:(0,q.useCallback)(a=>{i(a,{onSuccess:async i=>{l.setUserForEntity(m,i),bo();let a=Ln(i),o=_o(i.email);mo?.identify?.({username:i.email,type:`email`,...o?{company:o}:{}}),await t.invalidateQueries({queryKey:p,refetchType:`none`}),n.invalidate(),await e({to:r?.startsWith(`/`)?r:a})},onError:t=>{if(gs(t)){o({email:a.email},{onSuccess:()=>U.info(`Verify your email to finish signing in`,{description:`We sent a new verification link to ${a.email}.`})}),e({to:`/verifying?email=`+encodeURIComponent(a.email)});return}vn(t)}})},[e,t,r,o,n,i])}}function bs(){return R({mutationFn:e=>xs(e),meta:{skipGlobalErrorToast:!0}})}async function xs({email:e,password:t}){let{data:n}=await N.post(`/Login/`,{email:e,password:t});if(n)return n;throw Error(`Something went wrong`)}function Ss(){let[e,t]=Tn(Sn.RememberSignInMethod,!0),[n,r]=Tn(Sn.LastUsedSignInMethod,null),i=(0,q.useCallback)(t=>{e&&(wn(Sn.LastUsedSignInMethod,t),r(t))},[e,r]),a=(0,q.useCallback)(()=>{r(null),t(!1)},[r,t]),o=(0,q.useCallback)(()=>{t(!0)},[t]);return{lastUsed:e?n:null,remember:e,recordMethod:i,disable:a,enable:o}}var Cs=`mx-auto mt-3 block text-xs text-muted-foreground underline hover:text-foreground dark:text-inherit dark:hover:text-blue-300`;function ws(){let{me:e}=se({strict:!1}),t=dt({resolver:Fe($o),defaultValues:{email:e||``,password:``}}),{handleSubmit:n,control:r}=t,i=t.watch(`email`),{submitForm:a,isPending:o}=ys(),{lastUsed:s,remember:c,recordMethod:l,disable:u,enable:d}=Ss();return(0,K.jsxs)(`div`,{className:`text-foreground dark:text-white w-xs`,children:[(0,K.jsx)(`h1`,{className:`text-2xl font-light text-center`,children:`Sign in to Harper Fabric`}),(0,K.jsx)(Do,{...t,children:(0,K.jsxs)(`form`,{id:`auth-signin-form`,name:`auth-signin-form`,onSubmit:n(a),className:`my-4`,children:[(0,K.jsx)(Y,{control:r,name:`email`,render:({field:e})=>(0,K.jsxs)(X,{className:`my-4`,children:[(0,K.jsx)(Z,{children:`Email`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`email`,autoFocus:!0,autoComplete:`email`,className:`dark:bg-black dark:border-black`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:r,name:`password`,render:({field:e})=>(0,K.jsxs)(X,{className:`my-4`,children:[(0,K.jsx)(Z,{children:`Password`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`password`,autoComplete:`current-password`,className:`dark:bg-black dark:border-black`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(F,{type:`submit`,variant:`submit`,className:`w-full my-2`,disabled:o,children:`Sign In`}),(0,K.jsxs)(`div`,{className:`flex px-4 mt-4 underline place-content-between`,children:[(0,K.jsx)(V,{className:`text-sm text-muted-foreground hover:text-foreground dark:text-inherit dark:hover:text-blue-300`,to:`/sign-up`,search:{me:i},children:`Sign up for free`}),(0,K.jsx)(V,{className:`text-sm text-muted-foreground hover:text-foreground dark:text-inherit dark:hover:text-blue-300`,to:`/forgot-password`,search:{me:i},children:`Forgot password?`})]})]})}),(0,K.jsx)(`hr`,{"aria-hidden":`true`,className:`border-border dark:border-gray-600 my-6`}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,K.jsx)(hs,{text:`Sign in with Google`,lastUsed:s===`google`,onClick:()=>l(`google`)}),(0,K.jsx)(ms,{text:`Sign in with GitHub`,lastUsed:s===`github`,onClick:()=>l(`github`)})]}),c?s&&(0,K.jsx)(`button`,{type:`button`,onClick:u,className:Cs,children:`On a shared device? Forget my sign-in method.`}):(0,K.jsx)(`button`,{type:`button`,onClick:d,className:Cs,children:`Remember my last sign-in method on this device.`})]})}var Ts=/^[a-zA-ZàáâäãåąčćęèéêëėįìíîïłńòóôöõøùúûüųūÿýżźñçčšžæÀÁÂÄÃÅĄĆČĖĘÈÉÊËÌÍÎÏĮŁŃÒÓÔÖÕØÙÚÛÜŲŪŸÝŻŹÑßÇŒÆČŠŽ∂ð ,'-]+$/u;async function Es(e){let{data:t}=await N.post(`/User/`,e);if(t)return t;throw Error(`Something went wrong`)}function Ds(){return R({mutationFn:e=>Es(e),meta:{skipGlobalErrorToast:!0}})}var Os=y({email:Yo.max(80,{error:`Email cannot be longer than 80 characters.`}),firstname:M().trim().min(2,{error:`Please enter your first name.`}).regex(Ts,{error:`First name can only contain letters, spaces, and hyphens.`}).max(40,{error:`First name cannot be longer than 40 characters.`}),lastname:M().trim().min(2,{error:`Please enter your last name.`}).regex(Ts,{error:`Last name can only contain letters, spaces, and hyphens.`}).max(80,{error:`Last name cannot be longer than 80 characters.`}),password:Xo.min(8,{error:`Password must be at least 8 characters long.`}),confirmPassword:M(),acceptTerms:S().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 ks(){let e=L(),{email:t,me:n}=se({strict:!1}),[r,i]=(0,q.useState)(!1),a=dt({resolver:Fe(Os),defaultValues:{firstname:``,lastname:``,email:n||t||``,password:``,confirmPassword:``,acceptTerms:!1}}),o=a.watch(`email`),s=a.watch(`acceptTerms`),{setFocus:c,setError:l,clearErrors:u,control:d,handleSubmit:f,formState:p}=a,m=p.errors.root?.message;(0,q.useEffect)(()=>{c(`firstname`)},[c]);let{mutate:h,isPending:g}=Ds(),_=(0,q.useCallback)(async t=>{let{confirmPassword:n,acceptTerms:r,...i}=t;u(`root`),h(i,{onSuccess:()=>{let t=_o(i.email);mo?.identify?.({username:i.email,type:`email`,firstname:i.firstname,lastname:i.lastname,...t?{company:t}:{}}),bo(),e({to:`/verifying?email=`+encodeURIComponent(i.email)})},onError:e=>{console.error(e),l(`root`,{type:`server`,message:bn(e).message})}})},[u,e,l,h]),v=(0,q.useCallback)(e=>{if(!s)return i(!0),setTimeout(()=>i(!1),1e3),e.preventDefault(),!1},[s]),y=(0,K.jsx)(Y,{control:d,name:`acceptTerms`,render:({field:e})=>(0,K.jsxs)(X,{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,K.jsx)(J,{children:(0,K.jsx)($,{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,K.jsxs)(`div`,{className:`space-y-1 leading-none`,children:[(0,K.jsxs)(Z,{className:`text-xs font-normal`,children:[`I accept the`,` `,(0,K.jsx)(`a`,{href:`https://www.harper.fast/resources/privacy-policy`,target:`_blank`,rel:`noreferrer`,className:`underline hover:text-blue-300`,"aria-label":`Privacy Policy (opens in new tab)`,children:`Privacy Policy`}),` `,`and`,` `,(0,K.jsx)(`a`,{href:`https://www.harper.fast/resources/paas-terms-of-service`,target:`_blank`,rel:`noreferrer`,className:`underline hover:text-blue-300`,"aria-label":`Terms of Service (opens in new tab)`,children:`Terms of Service`})]}),(0,K.jsx)(Q,{})]})]})});return(0,K.jsxs)(`div`,{className:`text-foreground dark:text-white w-xs`,children:[(0,K.jsx)(`h1`,{className:`text-2xl font-light text-center`,children:`Sign up for Harper Fabric`}),(0,K.jsxs)(Do,{...a,children:[(0,K.jsxs)(`div`,{className:`flex flex-col gap-2 my-6`,children:[y,(0,K.jsx)(hs,{text:`Sign up with Google`,disabled:!s,onClick:v}),(0,K.jsx)(ms,{text:`Sign up with GitHub`,disabled:!s,onClick:v})]}),(0,K.jsx)(`hr`,{className:`border-gray-600`}),(0,K.jsxs)(`form`,{id:`auth-signup-form`,name:`auth-signup-form`,onSubmit:f(_),className:`grid gap-4 my-4`,children:[(0,K.jsx)(Y,{control:d,name:`firstname`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`First Name`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`text`,className:`dark:bg-black dark:border-black`,autoCapitalize:`words`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:d,name:`lastname`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Last Name`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`text`,className:`dark:bg-black dark:border-black`,autoCapitalize:`words`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:d,name:`email`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Email`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`email`,readOnly:!!t,disabled:!!t,className:`dark:bg-black dark:border-black`,autoComplete:`email`,autoCapitalize:`none`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:d,name:`password`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Password`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`password`,autoComplete:`new-password`,className:`dark:bg-black dark:border-black`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:d,name:`confirmPassword`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Confirm Password`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`password`,autoComplete:`new-password`,className:`dark:bg-black dark:border-black`,...e})}),(0,K.jsx)(Q,{})]})}),y,m&&(0,K.jsx)(`p`,{role:`alert`,"data-slot":`form-message`,className:`text-destructive text-sm`,children:m}),(0,K.jsx)(F,{type:`submit`,variant:`submit`,disabled:g,className:`w-full my-4`,children:`Sign Up For Free`})]})]}),(0,K.jsx)(`div`,{className:`flex px-4 mt-4 underline place-content-between`,children:(0,K.jsx)(V,{className:`m-auto text-sm hover:text-blue-300`,to:`/sign-in`,search:{me:o},children:`Already have an account? Sign in instead.`})})]})}var As=async e=>{let{data:t}=await N.put(`/VerifyEmail/`,{token:e.toString()});return t};function js(){return R({mutationFn:e=>As(e)})}var Ms=y({email:Yo});function Ns(){let e=L(),{mutate:t,isPending:n}=vs(),r=dt({resolver:Fe(Ms),defaultValues:{email:``}}),i=r.watch(`email`),{setFocus:a,control:o,handleSubmit:s}=r;(0,q.useEffect)(()=>{a(`email`)},[a]);let c=(0,q.useCallback)(async n=>{t(n,{onSuccess:t=>{U.success(`Success`,{description:`${t}`,action:{label:`Dismiss`,onClick:()=>U.dismiss()}}),e({to:`/sign-in`,search:{me:i}})}})},[i,e,t]);return(0,K.jsxs)(Do,{...r,children:[(0,K.jsx)(`p`,{className:`text-sm py-2`,children:`Please Enter an Email`}),(0,K.jsxs)(`form`,{id:`auth-verify-email-form`,name:`auth-verify-email-form`,onSubmit:s(c),className:`my-4`,children:[(0,K.jsx)(Y,{control:o,name:`email`,render:({field:e})=>(0,K.jsxs)(X,{className:`my-2`,children:[(0,K.jsx)(Z,{children:`Email`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{disabled:n,type:`email`,className:`dark:bg-black dark:border-black`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(F,{type:`submit`,variant:`submit`,disabled:n,className:`w-full my-2`,children:`Send Verification Email`})]})]})}function Ps(){let{token:e}=se({strict:!1}),t=L(),{mutate:n,isPending:r}=js(),i=(0,q.useCallback)(e=>{n(e,{onSuccess:()=>{U.success(`Success`,{description:`Email verified successfully`,action:{label:`Dismiss`,onClick:()=>U.dismiss()}}),t({to:`/sign-in`})}})},[n,t]);return(0,q.useEffect)(()=>{e&&i(e)},[i,e]),(0,K.jsxs)(`div`,{className:`text-foreground dark:text-white w-xs`,children:[(0,K.jsx)(`h1`,{className:`text-3xl font-light`,children:`Verify Email`}),r?(0,K.jsx)(`p`,{className:`text-sm pt-1`,children:`Verifying email...`}):(0,K.jsx)(Ns,{})]})}function Fs(){let{email:e}=se({strict:!1}),{mutate:t,isPending:n}=vs(),r=(0,q.useCallback)(n=>(n.preventDefault(),e&&t({email:e},{onSuccess:e=>{U.success(`Code Sent`,{description:`${e}`,action:{label:`Dismiss`,onClick:()=>U.dismiss()}})}}),!1),[e,t]);return(0,K.jsxs)(`div`,{className:`text-foreground dark:text-white w-lg flex flex-col gap-4`,children:[(0,K.jsxs)(`h1`,{className:`text-3xl font-light`,children:[(0,K.jsx)(`span`,{"aria-hidden":`true`,className:`text-2xl animate-flower-dance mr-4`,title:`Loading`,children:`🌼`}),`Check your email!`]}),(0,K.jsxs)(`p`,{children:[`Your account has been created! You should receive an email with a link to `,(0,K.jsx)(`strong`,{children:`[Verify My Email]`}),`!`]}),(0,K.jsxs)(`p`,{children:[`From: `,(0,K.jsx)(`strong`,{children:`harper@notifications.harperfabric.com`})]}),(0,K.jsxs)(`p`,{children:[`To: `,(0,K.jsx)(`strong`,{children:e||`your email`})]}),(0,K.jsx)(`p`,{children:`Can you click it? Then we can carry on to more fun things!`}),(0,K.jsxs)(`div`,{className:`underline flex gap-4`,children:[(0,K.jsx)(V,{className:`text-sm text-muted-foreground hover:text-foreground dark:text-inherit dark:hover:text-blue-300`,to:`/sign-in`,search:{me:e},children:`I did it, let me sign in!`}),(0,K.jsx)(V,{className:`text-sm opacity-50 text-muted-foreground hover:text-foreground dark:text-inherit dark:hover:text-blue-300`,to:void 0,onClick:r,disabled:n,children:`Send me another code, please.`})]})]})}var Is=I({getParentRoute:()=>lo,id:`_authLayout`,component:po}),Ls=I({getParentRoute:()=>Is,path:`sign-in`,head:()=>({meta:[{title:`Sign In — Harper Fabric`}]}),component:ws,beforeLoad:({context:e,location:t})=>{let n=e.authentication[m]?.user;if(n){let e=t?.search,r=Ln(n);throw re({to:e?.redirect?.startsWith(`/`)?e.redirect:r})}}}),Rs=I({getParentRoute:()=>lo,path:`sign-in`,head:()=>({meta:[{title:`Sign In — Harper Fabric`}]}),component:is,beforeLoad:({context:e,location:t})=>{if(e.authentication.OverallAppSignIn?.user){let e=t?.search;throw re({to:e?.redirect?.startsWith(`/`)?e.redirect:`/`})}}}),zs=I({getParentRoute:()=>Is,path:`sign-up`,head:()=>({meta:[{title:`Sign Up — Harper Fabric`}]}),component:ks}),Bs=I({getParentRoute:()=>Is,path:`forgot-password`,head:()=>({meta:[{title:`Forgot Password — Harper Fabric`}]}),component:cs}),Vs=I({getParentRoute:()=>Is,path:`verify-email`,head:()=>({meta:[{title:`Verify Email — Harper Fabric`}]}),component:Ps}),Hs=I({getParentRoute:()=>Is,path:`verifying`,head:()=>({meta:[{title:`Check Your Email — Harper Fabric`}]}),component:Fs}),Us=I({getParentRoute:()=>Is,path:`check-oauth`,head:()=>({meta:[{title:`Signing In — Harper Fabric`}]}),component:So}),Ws=I({getParentRoute:()=>Is,path:`reset-password`,head:()=>({meta:[{title:`Reset Password — Harper Fabric`}]}),component:fs});Is.addChildren([Ls,zs,Us,Bs,Vs,Hs,Ws]);var Gs=[Rs];function Ks({children:e}){return(0,K.jsx)(`nav`,{className:`fixed top-20 w-full h-12 z-39 py-2 px-4 md:px-12 bg-violet-50 border-b border-violet-100 dark:bg-grey-700 dark:border-none`,children:(0,K.jsxs)(`div`,{className:`flex items-center h-full space-x-2`,children:[(0,K.jsx)(Eo,{}),e]})})}function qs({typeOfThingBeingDeleted:e,nameOfThingBeingDeleted:t,isModalOpen:n,hideDataLossWarning:r,setIsModalOpen:i,deletionConfirmed:a,deletionPending:o,trigger:s,presentParticiple:c=`Deleting`,transitiveVerb:l=`Delete`}){return(0,K.jsxs)(Rt,{open:n,onOpenChange:i,children:[s&&(0,K.jsx)(Wt,{asChild:!0,children:s}),(0,K.jsxs)(Ut,{className:`sm:max-w-[750px]`,children:[(0,K.jsxs)(Bt,{children:[(0,K.jsxs)(qt,{children:[`Are you sure you want to `,l.toLowerCase(),` this `,e,`?`]}),(0,K.jsx)(Zt,{children:`This action cannot be undone.`})]}),!r&&(0,K.jsxs)(`div`,{className:`p-3 my-5 text-white rounded-md bg-amber-600`,children:[(0,K.jsxs)(`p`,{className:`flex space-x-1 font-semibold align-baseline`,children:[(0,K.jsx)(fi,{className:`inline-block size-5`}),` `,(0,K.jsx)(`span`,{children:`Warning`})]}),(0,K.jsxs)(`p`,{className:`pt-2 text-base`,children:[`By `,c.toLowerCase(),` `,e,` `,(0,K.jsx)(`span`,{className:`font-semibold`,children:t}),` `,`you will lose the data stored in it permanently.`]})]}),(0,K.jsx)(zt,{children:(0,K.jsxs)(`div`,{className:`flex justify-center space-x-5`,children:[(0,K.jsxs)(F,{type:`button`,onClick:()=>i(!1),children:[(0,K.jsx)(Qt,{}),` Cancel`]}),(0,K.jsxs)(F,{variant:`destructive`,onClick:a,disabled:o,children:[(0,K.jsx)(di,{}),` `,l]})]})})]})]})}function Js({...e}){return(0,K.jsx)(He,{"data-slot":`context-menu`,...e})}function Ys({...e}){return(0,K.jsx)(et,{"data-slot":`context-menu-trigger`,...e})}function Xs({className:e,...t}){return(0,K.jsx)($e,{children:(0,K.jsx)(Je,{"data-slot":`context-menu-content`,className:P(`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-context-menu-content-available-height) min-w-[8rem] origin-(--radix-context-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border border-border p-1 shadow-md`,e),...t})})}function Zs({className:e,inset:t,variant:n=`default`,...r}){return(0,K.jsx)(At,{"data-slot":`context-menu-item`,"data-inset":t,"data-variant":n,className:P(`focus:bg-accent focus:text-grey dark:focus:bg-white/15 dark:focus:text-white`,`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 Qs({className:e,inset:t,...n}){return(0,K.jsx)(Le,{"data-slot":`context-menu-label`,"data-inset":t,className:P(`px-2 py-1.5 text-sm font-medium data-[inset]:pl-8`,e),...n})}function $s({className:e,...t}){return(0,K.jsx)(Qe,{"data-slot":`context-menu-separator`,className:P(`bg-border -mx-1 my-1 h-px`,e),...t})}function ec({className:e,...t}){return(0,K.jsx)(`span`,{"data-slot":`context-menu-shortcut`,className:P(`text-muted-foreground ml-auto text-xs tracking-widest`,e),...t})}var tc={dropdown:{Item:Ci,Label:Ti,Separator:Ei},context:{Item:Zs,Label:Qs,Separator:$s}};function nc(e,t){let{Item:n,Label:r,Separator:i}=tc[t];return e.map(e=>{if(e.type===`separator`)return(0,K.jsx)(i,{},e.key);if(e.type===`label`)return(0,K.jsx)(r,{className:e.className,children:e.label},e.key);let t=(0,K.jsxs)(n,{className:e.className,onClick:e.onClick,disabled:e.disabled,variant:e.variant,children:[e.icon,e.label]});return e.to?(0,K.jsx)(V,{to:e.to,disabled:e.disabled,children:t},e.key):(0,K.jsx)(q.Fragment,{children:t},e.key)})}function rc({items:e,children:t}){return e.length?(0,K.jsxs)(Js,{children:[(0,K.jsx)(Ys,{asChild:!0,children:t}),(0,K.jsx)(Xs,{children:nc(e,`context`)})]}):(0,K.jsx)(K.Fragment,{children:t})}var ic=new Set([`add_component`,`cleanup_orphan_blobs`,`clear_status`,`delete_audit_logs_before`,`delete_files_before`,`delete_transaction_logs_before`,`deploy_component`,`drop_component`,`drop_custom_function`,`drop_custom_function_project`,`get_backup`,`get_status`,`install_node_modules`,`package_component`,`read_transaction_log`,`restart_service`,`search_jobs_by_start_date`,`set_component_file`,`set_configuration`,`set_custom_function`,`set_status`,`delete_records_before`,`registration_info`]);function ac(e){return ic.has(e)}function oc(e){let t=wc.get(e);return!!t?.aliasOf||!!t?.nonDelegable||!!t?.outOfGate||ac(e)}var sc=`5.1.0-alpha.1`,cc=`5.2.0-alpha.1`,lc=`Data`,uc=`Schema`,dc=`Users & Roles`,fc=`Components & Deployments`,pc=`Clustering & Replication`,mc=`Jobs`,hc=`Logs & Analytics`,gc=`System`,_c=`Managed Backups`,vc=`Secrets & Environment`,yc=`Agent`,bc=[lc,uc,dc,fc,pc,mc,hc,gc,_c,vc,yc],xc=[{name:`search`,su:!1,category:lc},{name:`search_by_conditions`,su:!1,category:lc},{name:`search_by_hash`,su:!1,category:lc},{name:`search_by_id`,su:!1,category:lc,aliasOf:`search_by_hash`},{name:`search_by_value`,su:!1,category:lc},{name:`sql`,su:!1,category:lc,outOfGate:!0,caveat:`SQL is authorized against table permissions, not this list — listing or omitting it does not restrict SQL statements.`},{name:`insert`,su:!1,category:lc},{name:`update`,su:!1,category:lc},{name:`upsert`,su:!1,category:lc},{name:`delete`,su:!1,category:lc},{name:`delete_records_before`,su:!0,category:lc},{name:`csv_data_load`,su:!1,category:lc},{name:`csv_file_load`,su:!1,category:lc},{name:`csv_url_load`,su:!1,category:lc},{name:`import_from_s3`,su:!1,category:lc},{name:`export_local`,su:!0,category:lc},{name:`export_to_s3`,su:!0,category:lc},{name:`describe_all`,su:!1,category:uc},{name:`describe_database`,su:!1,category:uc,aliasOf:`describe_schema`},{name:`describe_schema`,su:!1,category:uc},{name:`describe_table`,su:!1,category:uc},{name:`create_database`,su:!0,category:uc},{name:`create_schema`,su:!0,category:uc,aliasOf:`create_database`},{name:`drop_database`,su:!0,category:uc},{name:`drop_schema`,su:!0,category:uc,aliasOf:`drop_database`},{name:`create_table`,su:!0,category:uc},{name:`drop_table`,su:!0,category:uc},{name:`create_attribute`,su:!1,category:uc},{name:`drop_attribute`,su:!0,category:uc},{name:`cleanup_orphan_blobs`,su:!0,category:uc},{name:`user_info`,su:!1,category:dc},{name:`list_users`,su:!0,category:dc},{name:`add_user`,su:!0,category:dc},{name:`alter_user`,su:!0,category:dc},{name:`drop_user`,su:!0,category:dc},{name:`list_roles`,su:!0,category:dc},{name:`add_role`,su:!0,category:dc},{name:`alter_role`,su:!0,category:dc},{name:`drop_role`,su:!0,category:dc},{name:`refresh_operation_token`,su:!1,category:dc},{name:`get_components`,su:!0,category:fc},{name:`get_component_file`,su:!0,category:fc},{name:`set_component_file`,su:!0,category:fc},{name:`add_component`,su:!0,category:fc},{name:`drop_component`,su:!0,category:fc},{name:`deploy_component`,su:!0,category:fc},{name:`package_component`,su:!0,category:fc},{name:`install_node_modules`,su:!0,category:fc},{name:`audit_node_modules`,su:!0,category:fc},{name:`custom_functions_status`,su:!0,category:fc},{name:`get_custom_functions`,su:!0,category:fc},{name:`get_custom_function`,su:!0,category:fc},{name:`set_custom_function`,su:!0,category:fc},{name:`drop_custom_function`,su:!0,category:fc},{name:`add_custom_function_project`,su:!0,category:fc,aliasOf:`add_component`},{name:`deploy_custom_function_project`,su:!0,category:fc,aliasOf:`deploy_component`},{name:`package_custom_function_project`,su:!0,category:fc,aliasOf:`package_component`},{name:`drop_custom_function_project`,su:!0,category:fc,aliasOf:`drop_component`},{name:`list_deployments`,su:!0,category:fc,addedIn:sc},{name:`get_deployment`,su:!0,category:fc,addedIn:sc},{name:`get_deployment_payload`,su:!0,category:fc,addedIn:sc,nonDelegable:!0},{name:`delete_deployment_payload`,su:!0,category:fc,addedIn:sc},{name:`add_node`,su:!0,category:pc},{name:`update_node`,su:!0,category:pc},{name:`set_node_replication`,su:!0,category:pc},{name:`purge_stream`,su:!0,category:pc},{name:`catchup`,su:!0,category:pc},{name:`get_job`,su:!1,category:mc},{name:`search_jobs_by_start_date`,su:!0,category:mc},{name:`update_job`,su:!0,category:mc},{name:`delete_job`,su:!0,category:mc},{name:`read_log`,su:!0,category:hc},{name:`read_audit_log`,su:!0,category:hc},{name:`read_transaction_log`,su:!0,category:hc},{name:`delete_files_before`,su:!0,category:hc},{name:`delete_audit_logs_before`,su:!0,category:hc},{name:`delete_transaction_logs_before`,su:!0,category:hc},{name:`get_analytics`,su:!1,category:hc},{name:`list_metrics`,su:!1,category:hc},{name:`describe_metric`,su:!1,category:hc},{name:`get_configuration`,su:!0,category:gc},{name:`set_configuration`,su:!0,category:gc},{name:`restart`,su:!0,category:gc},{name:`restart_service`,su:!0,category:gc},{name:`system_information`,su:!0,category:gc},{name:`get_status`,su:!0,category:gc},{name:`set_status`,su:!0,category:gc},{name:`clear_status`,su:!0,category:gc},{name:`registration_info`,su:!1,category:gc},{name:`get_backup`,su:!0,category:gc},{name:`create_backup`,su:!0,category:_c,addedIn:cc,nonDelegable:!0},{name:`verify_backup`,su:!0,category:_c,addedIn:cc,nonDelegable:!0},{name:`restore_backup`,su:!0,category:_c,addedIn:cc,nonDelegable:!0},{name:`list_backups`,su:!0,category:_c,addedIn:cc,nonDelegable:!0},{name:`delete_backup`,su:!0,category:_c,addedIn:cc,nonDelegable:!0},{name:`purge_backups`,su:!0,category:_c,addedIn:cc,nonDelegable:!0},{name:`set_secret`,su:!0,category:vc,addedIn:cc,nonDelegable:!0},{name:`grant_secret`,su:!0,category:vc,addedIn:cc,nonDelegable:!0},{name:`revoke_secret`,su:!0,category:vc,addedIn:cc,nonDelegable:!0},{name:`list_secrets`,su:!0,category:vc,addedIn:cc,nonDelegable:!0},{name:`delete_secret`,su:!0,category:vc,addedIn:cc,nonDelegable:!0},{name:`get_secrets_public_key`,su:!0,category:vc,addedIn:cc,nonDelegable:!0},{name:`set_env_value`,su:!0,category:vc,addedIn:cc},{name:`delete_env_value`,su:!0,category:vc,addedIn:cc},{name:`get_env_keys`,su:!0,category:vc,addedIn:cc},{name:`agent_prompt`,su:!0,category:yc,addedIn:sc},{name:`get_agent_session`,su:!0,category:yc,addedIn:sc},{name:`list_agent_sessions`,su:!0,category:yc,addedIn:sc},{name:`cancel_agent_run`,su:!0,category:yc,addedIn:sc},{name:`approve_agent_action`,su:!0,category:yc,addedIn:sc},{name:`set_agent_config`,su:!0,category:yc,addedIn:sc}],Sc=[`search`,`search_by_conditions`,`search_by_hash`,`search_by_id`,`search_by_value`,`sql`,`describe_all`,`describe_schema`,`describe_database`,`describe_table`,`user_info`,`get_job`,`get_analytics`,`list_metrics`,`describe_metric`],Cc=[{name:`read_only`,description:`Read-only data access: searches, SQL, schema describes, and user/analytics reads.`,members:Sc},{name:`admin_read`,description:`Read-only access to configuration, logs, and component views (normally super_user-only).`,members:[`get_configuration`,`read_log`,`read_audit_log`,`get_custom_functions`,`get_custom_function`,`get_components`,`get_component_file`]},{name:`standard_user`,description:`Everything in read_only plus data writes and bulk loads. No DDL, user management, or admin reads.`,members:[...Sc,`insert`,`update`,`upsert`,`delete`,`csv_data_load`,`csv_file_load`,`csv_url_load`,`import_from_s3`]},{name:`agent`,description:`Drive the built-in agent: prompts, sessions, and run approvals. Excludes agent configuration.`,members:[`agent_prompt`,`get_agent_session`,`list_agent_sessions`,`cancel_agent_run`,`approve_agent_action`],addedIn:cc}],wc=new Map(xc.map(e=>[e.name,e])),Tc=new Map(Cc.map(e=>[e.name,e]));function Ec(e){return wc.get(e)}function Dc(e){return wc.get(e)?.aliasOf??e}function Oc(e){return Tc.has(e)}function kc(e){return!!e&&$t(`5.0.0-alpha.8`,e)}function Ac(e){return xc.filter(t=>!t.nonDelegable&&!t.aliasOf&&(!t.addedIn||$t(t.addedIn,e)))}function jc(e){return Cc.filter(t=>!t.addedIn||$t(t.addedIn,e))}function Mc(e){let t=new Set;for(let n of e){let e=Tc.get(n);if(e){for(let n of e.members){let e=wc.get(n)?.aliasOf??n;oc(e)||t.add(e)}continue}oc(n)||t.add(n)}return[...t].sort()}function Nc(e,t=40){return e.length>t?`${e.slice(0,t).join(`, `)}, +${e.length-t} more`:e.join(`, `)}var Pc=[`super_user`,`structure_user`,`cluster_user`,`operations`],Fc=new Set(Pc);function Ic(e,t,n){if((t===`operations`?n:Fc.has(t))||!Object.hasOwn(e,t))return;let r=e[t];return typeof r==`object`&&r&&!Array.isArray(r)?r:void 0}function Lc(e){return e?.super_user===!0||e?.cluster_user===!0}function Rc(e){let t=e?.structure_user;return t===!0?!0:Array.isArray(t)&&t.length>0?t:!1}var zc=[`create_table`,`create_attribute`,`drop_table`,`drop_attribute`];function Bc(e){let t=e?.operations;return Array.isArray(t)&&t.every(e=>typeof e==`string`)?t:void 0}function Vc(e,t){let n=e?.operations;return e===void 0||n===void 0?`absent`:t?Bc(e)===void 0?n&&typeof n!=`string`&&!Array.isArray(n)?`breaks-auth`:`malformed`:`allowlist`:Ic(e,`operations`,!1)===void 0?`inert`:`database`}function Hc(e){let t=Pc.filter(t=>t in e),n=Object.keys(e).filter(e=>!Fc.has(e));return Object.fromEntries([...t,...n].map(t=>[t,e[t]]))}function Uc(e,t){let n={...e};return t===void 0?delete n.operations:n.operations=t,Hc(n)}var Wc={read:[`search`,`search_by_conditions`,`search_by_hash`,`search_by_value`,`sql`],insert:[`insert`],update:[`update`],delete:[`delete`]},Gc=[`insert`],Kc=[`csv_data_load`,`get_job`],qc=[`csv_url_load`,`get_job`],Jc={"json-records":Gc,"csv-data":Kc,"csv-url":qc},Yc={sample:[Gc,Kc],file:[Gc,Kc],url:[qc]},Xc=Object.keys(Yc),Zc=new WeakMap,Qc=new Map(Cc.map(e=>[e.name,e.members]));function $c(e){let t=new Set;for(let n of e){let e=Qc.get(n);if(e)for(let n of e)t.add(n);else t.add(n)}return t}function el(e,t){let n=Bc(e);if(!n)return!0;let r=Zc.get(n);return r||(r=$c(n),Zc.set(n,r)),t.some(e=>r.has(Dc(e)))}function tl(e,t){return e?.super_user===!0||el(e,t)}function nl(e,t){return tl(e,Wc[t]??[])}function rl(e,t){return t.every(t=>el(e,[t]))}function il(e,t){return e?.super_user===!0||rl(e,Jc[t])}function al(e,t){return e?.super_user===!0||Yc[t].some(t=>rl(e,t))}function ol(e){return Xc.some(t=>al(e,t))}function sl(e,t,n,r){return nl(e,r)&&ll(e,t,n,r)}function cl(e,t,n){return ol(e)&&ll(e,t,n,`insert`)}function ll(e,t,n,r){return e?e.super_user===!0||e.structure_user===!0||Ic(e,t,!1)?.tables?.[n]?.[r]===!0:!1}function ul(e){let{user:t}=je(),{organizationId:n}=B({strict:!1}),r=dl(t,e??n);return{update:Pe(t,`org:update`)||r.update,remove:Pe(t,`org:delete`)||r.remove}}function dl(e,t){let n=e?.roles?.[t];return!n||`oauthProviders`in n||!n.permission&&!n.organization?{update:!1,remove:!1}:n.permission?.super_user?{update:!0,remove:!0}:{update:n.organization.update,remove:n.organization.delete}}function fl(e){let{user:t}=je(),{organizationId:n}=B({strict:!1}),r=pl(t,e??n);return{create:Pe(t,`role:create`)||r.create,remove:Pe(t,`role:delete`)||r.remove,update:Pe(t,`role:update`)||r.update,view:Pe(t,`role:read`)||r.view}}function pl(e,t){let n=e?.roles?.[t];if(!n||`oauthProviders`in n||!n.permission&&!n.organization?.roles)return{create:!1,remove:!1,update:!1,view:!1};if(n.permission?.super_user)return{create:!0,remove:!0,update:!0,view:!0};let r=n.organization.roles;return{create:r.create,remove:r.delete,update:r.update,view:r.view}}function ml(e,t){let{user:n}=je(),{organizationId:r,clusterId:i}=B({strict:!1});return hl(n,e??r,t??i)}function hl(e,t,n){let r=gl(e,t,n);return{create:Pe(e,`cluster:create`)||r.create,remove:Pe(e,`cluster:delete`)||r.remove,update:Pe(e,`cluster:update`)||r.update,view:Pe(e,`cluster:read`)||r.view}}function gl(e,t,n){let r=e?.roles?.[t];if(!r||`oauthProviders`in r||!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 _l(e,t){let{user:n}=je(),{organizationId:r,clusterId:i}=B({strict:!1});return vl(n,e??r,t??i)}function vl(e,t,n){let r=yl(e,t,n);return{create:Pe(e,`cluster:update`)||r.create,remove:Pe(e,`cluster:delete`)||r.remove,update:Pe(e,`instance:update`)||r.update,view:Pe(e,`instance:read`)||r.view}}function yl(e,t,n){let r=e?.roles?.[t];if(!r||`oauthProviders`in r||!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 bl(e){let{clusterId:t,instanceId:n}=B({strict:!1}),{user:r}=Ne(e??n??t),i=r?.role?.permission;return i?i.super_user===!0:!1}function xl(e){let{clusterId:t,instanceId:n}=B({strict:!1}),{user:r}=Ne(e??n??t),i=r?.role?.permission;return i?i.super_user===!0||i.structure_user===!0:!1}function Sl(e,t,n,r){let{clusterId:i,instanceId:a}=B({strict:!1}),{user:o}=Ne(e??a??i);return sl(o?.role?.permission,t,n,r)}function Cl(e,t,n){let{clusterId:r,instanceId:i}=B({strict:!1}),{user:a}=Ne(e??i??r);return cl(a?.role?.permission,t,n)}function wl(e){let{clusterId:t,instanceId:n}=B({strict:!1}),{user:r}=Ne(e??n??t);return ol(r?.role?.permission)}function Tl(e){let{clusterId:t,instanceId:n}=B({strict:!1}),{user:r}=Ne(e??n??t),i=r?.role?.permission;return(0,q.useMemo)(()=>({methods:Object.fromEntries(Xc.map(e=>[e,al(i,e)])),allowsSource:e=>il(i,e),allowsDestination:(e,t)=>cl(i,e,t)}),[i])}function El(e){return!!e?.plans?.[0]?.planId?.startsWith(`self-hosted`)}function Dl({cluster:e,hasCardLink:t=!1}){let{view:n,update:r}=ml(e.organizationId,e.id),i=`/${e.organizationId}/${e.id}`;if(n)return El(e)?(0,K.jsx)(Ol,{cluster:e,hasCardLink:t}):e.fqdn?e.resetPassword?r?(0,K.jsx)(V,{to:`${i}/finish-setup`,className:`text-sm text-nowrap`,"aria-label":`Set Password on ${e.name}`,title:`Set Password on ${e.name}`,children:(0,K.jsxs)(F,{variant:`positive`,className:`py-2 hover:border-b-2 animate-glow-pulse`,children:[`Finish Setup `,(0,K.jsx)(Bn,{className:`inline-block`})]})}):(0,K.jsx)(`span`,{className:`py-2 text-nowrap`,children:`Pending Owner Setup`}):(0,K.jsx)(Ol,{cluster:e,hasCardLink:t}):t?(0,K.jsxs)(`span`,{className:`text-sm text-nowrap py-2 ml-auto`,children:[`Instances `,(0,K.jsx)(Bn,{className:`inline-block`})]}):(0,K.jsx)(V,{to:`${i}/instances`,className:`text-sm text-nowrap`,"aria-label":`View ${e.name}`,title:`View ${e.name}`,children:(0,K.jsxs)(`span`,{className:`py-2 hover:border-b-2`,children:[`Instances `,(0,K.jsx)(Bn,{className:`inline-block`})]})})}function Ol({cluster:e,hasCardLink:t}){return t?(0,K.jsxs)(`span`,{className:`text-sm text-nowrap py-2 ml-auto`,children:[`Open `,(0,K.jsx)(Bn,{className:`inline-block`})]}):(0,K.jsx)(V,{to:`/${e.organizationId}/${e.id}`,className:`text-sm text-nowrap`,"aria-label":`Open ${e.name}`,title:`Open ${e.name}`,children:(0,K.jsxs)(`span`,{className:`py-2 hover:border-b-2`,children:[`Open `,(0,K.jsx)(Bn,{className:`inline-block`})]})})}function kl({clusterName:e,isPending:t,stopOpen:n,setStopOpen:r,onConfirmStop:i,restartOpen:a,setRestartOpen:o,onConfirmRestart:s}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Rt,{open:n,onOpenChange:r,children:(0,K.jsxs)(Ut,{className:`sm:max-w-[560px]`,children:[(0,K.jsxs)(Bt,{children:[(0,K.jsxs)(qt,{children:[`Stop cluster `,e,`?`]}),(0,K.jsx)(Zt,{children:`This stops every instance in the cluster. It will be offline and stop serving traffic until you start it again.`})]}),(0,K.jsx)(zt,{children:(0,K.jsxs)(`div`,{className:`flex justify-end gap-3`,children:[(0,K.jsx)(F,{type:`button`,variant:`defaultOutline`,onClick:()=>r(!1),children:`Cancel`}),(0,K.jsx)(F,{type:`button`,variant:`destructive`,onClick:i,disabled:t,children:`Stop cluster`})]})})]})}),(0,K.jsx)(Rt,{open:a,onOpenChange:o,children:(0,K.jsxs)(Ut,{className:`sm:max-w-[560px]`,children:[(0,K.jsxs)(Bt,{children:[(0,K.jsxs)(qt,{children:[`Restart cluster `,e]}),(0,K.jsx)(Zt,{children:`Choose how to restart the cluster's instances.`})]}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-3 py-2`,children:[(0,K.jsxs)(`button`,{type:`button`,disabled:t,onClick:()=>s(`rolling`),className:`rounded-lg border border-border p-4 text-left transition-colors hover:border-primary hover:bg-accent/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:opacity-60`,children:[(0,K.jsxs)(`div`,{className:`font-medium`,children:[`Rolling `,(0,K.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`(recommended)`})]}),(0,K.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`One instance at a time, waiting for each to rejoin before moving on. No downtime.`})]}),(0,K.jsxs)(`button`,{type:`button`,disabled:t,onClick:()=>s(`parallel`),className:`rounded-lg border border-border p-4 text-left transition-colors hover:border-primary hover:bg-accent/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:opacity-60`,children:[(0,K.jsx)(`div`,{className:`font-medium`,children:`Parallel`}),(0,K.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`All instances at once. Faster, but the whole cluster is briefly offline.`})]})]}),(0,K.jsx)(zt,{children:(0,K.jsx)(F,{type:`button`,variant:`defaultOutline`,onClick:()=>o(!1),children:`Cancel`})})]})})]})}function Al(e,t){let n=[];if(e)for(let r of e)n.push(r[t]);return n}function jl({cluster:e,forceProgressBarVisible:t}){let[n,r]=(0,q.useState)(t||!1),{data:i}=H(Jo(n&&e.id,2e3));(0,q.useEffect)(function(){(Uo(e.status)||Wo(e.status))&&r(!0)},[n,e.status,i?.instances]);let a=(0,q.useMemo)(()=>{let e=Al(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||Ho(t)||(Uo(t)?(n+=1,r[t]=`${n} ${wo(t)}`):Wo(t)?(a+=1,o[t]=`${a} ${wo(t)}`):Vo(t)?(l+=1,u[t]=`${l} ${wo(t)}`):!i.planId||!e.includes(i.planId)?(a+=1,o.DRAINING_TRAFFIC=`${a} ${wo(`Draining Traffic`)}`):Bo(t)&&(s+=1,c[t]=`${s} ${wo(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,K.jsxs)(`div`,{className:`w-full text-center`,children:[(0,K.jsxs)(`div`,{className:`w-full h-2.5 rounded-full overflow-clip flex shadow`,children:[(0,K.jsx)(`div`,{style:{width:a.runningWidth},className:`grow bg-green/80 transition-[width] duration-1000 ease-in-out motion-reduce:transition-none`}),(0,K.jsx)(`div`,{style:{width:a.failedWidth},className:`grow bg-red/80 transition-[width] duration-1000 ease-in-out motion-reduce:transition-none`}),(0,K.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,K.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,K.jsx)(`div`,{className:`text-xs text-muted-foreground font-light mt-2`,children:a.text})]}):null}function Ml({open:e,setOpen:t,action:n,targetName:r,scope:i,isPending:a,onConfirm:o}){let s=n===`start`?`Start`:`Restart`;return(0,K.jsx)(Rt,{open:e,onOpenChange:t,children:(0,K.jsxs)(Ut,{className:`sm:max-w-[560px]`,children:[(0,K.jsxs)(Bt,{children:[(0,K.jsxs)(qt,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Dr,{className:`size-5 text-yellow`}),s,` `,r,` in safe mode?`]}),(0,K.jsxs)(Zt,{children:[`Safe mode boots Harper`,` `,(0,K.jsx)(`strong`,{className:`text-foreground`,children:`without loading your applications or components`}),`. Use it to recover `,i===`cluster`?`a cluster`:`an instance`,` `,`that a bad app, component, or config is keeping from starting. Then fix or remove what's broken and`,` `,n===`start`?`start`:`restart`,` normally to bring everything back.`]})]}),(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:i===`cluster`?`All instances are ${n===`start`?`started`:`restarted`} at once (parallel)${n===`restart`?`, so expect a brief interruption while they come back.`:`.`}`:`The instance ${n===`start`?`starts`:`restarts`} in safe mode${n===`restart`?`, so expect a brief interruption while it comes back.`:`.`}`}),(0,K.jsx)(zt,{children:(0,K.jsxs)(`div`,{className:`flex justify-end gap-3`,children:[(0,K.jsx)(F,{type:`button`,variant:`defaultOutline`,onClick:()=>t(!1),children:`Cancel`}),(0,K.jsxs)(F,{type:`button`,variant:`warning`,onClick:o,disabled:a,children:[(0,K.jsx)(Dr,{}),` `,s,` in safe mode`]})]})})]})})}async function Nl(e){let{data:t}=await N.delete(`/Cluster/${e}`,{timeout:0});return t}function Pl(){return R({mutationFn:e=>Nl(e)})}async function Fl({clusterId:e,action:t,safeMode:n,strategy:r}){let i={};n!==void 0&&(i.safeMode=n),r!==void 0&&(i.strategy=r);let{data:a}=await N.post(`/Cluster/${e}/container/${t}`,i);return a}function Il(){return R({mutationFn:Fl})}var Ll={stop:`Stopping`,start:`Starting`,restart:`Restarting`};function Rl(e){let{mutateAsync:t,isPending:n}=Il(),r=ie();return{run:(0,q.useCallback)(async(n,i)=>{let a=i?.label??Ll[n],o=U.loading(a,{description:`${a} cluster ${e.name}. Status will update automatically.`,duration:3e4,action:{label:`Dismiss`,onClick:()=>U.dismiss()}});try{await t({clusterId:e.id,action:n,safeMode:i?.safeMode,strategy:i?.strategy}),r.invalidateQueries({queryKey:[e.organizationId]}),r.invalidateQueries({queryKey:[e.id]}),U.dismiss(o),U.success(`Request accepted`,{description:`${e.name} is ${a.toLowerCase()}. The status will update automatically.`,action:{label:`Dismiss`,onClick:()=>U.dismiss()}})}catch{U.dismiss(o)}},[e.id,e.name,e.organizationId,t,r]),isPending:n}}async function zl(e){if(!navigator.clipboard)return U.error(`Clipboard access is not available in this environment.`),!1;try{return await navigator.clipboard.writeText(e),!0}catch{return U.error(`Failed to copy to clipboard.`),!1}}function Bl(e){zl(e).then(e=>{e&&U.info(`Copied to clipboard!`,{icon:(0,K.jsx)(tr,{}),duration:1e3})})}function Vl(...e){return(0,q.useMemo)(()=>e.map(e=>()=>Bl(e)),e)}function Hl(){return Bl}function Ul({cluster:e}){let t=ae(),n=ie(),r=(0,q.useMemo)(()=>o(e),[e]),i=En({operationsUrl:r}),a=Ne(e.id),[,s]=Tn(Sn.SavedClusterState,null),{view:c,update:d,remove:f,create:p}=ml(e.organizationId,e.id),{mutate:m,isPending:h}=Pl(),[g,_]=(0,q.useState)(!1),[v,y]=(0,q.useState)(!1),[b,x]=(0,q.useState)(!1),[S,C]=(0,q.useState)(!1),[w,T]=(0,q.useState)(null),{run:E,isPending:D}=Rl(e),O=e.status===`RUNNING`,k=e.status===`STOPPED`,A=e.status===`PARTIAL`,j=e.status===`STOPPING`||e.status===`STARTING`||e.status===`RESTARTING`,M=j||k||A,N=(0,q.useMemo)(()=>!!(e.status&&Mo.includes(e.status)),[e.status]),P=El(e),F=d&&!P,ee=l.checkForFabricConnect(e.id),te=!ee&&!!a.user,I=(0,q.useMemo)(()=>!!(e.status&&No.includes(e.status)),[e.status]),L=(0,q.useMemo)(()=>!!(e.status&&Vo(e.status)),[e.status]),ne=d&&!P&&!I&&!Wo(e.status)&&!Uo(e.status),re=(0,q.useCallback)(async()=>{_(!0);let t=await Ko(e.id).catch(e=>(console.error(`Failed to lookup cluster details, proceeding without checking instances.`,e),null));if(await u({entityId:e.id,instanceClient:i}),t?.instances?.length)for(let e of t.instances)l.setUserForEntity(e,null);l.setUserForEntity(e,null)},[e,i]),R=(0,q.useCallback)(()=>{s(e),t.navigate({to:`/${e.organizationId}/new-cluster`})},[e,t,s]),z=(0,q.useCallback)(()=>y(!0),[]),oe=(0,q.useCallback)(()=>{let r=e.organizationId;m(e.id,{onSuccess:async()=>{await n.invalidateQueries({queryKey:[r],refetchType:`active`}),await t.invalidate(),U.success(`Success`,{description:P?`Cluster successfully removed.`:`Cluster successfully terminated.`,duration:5e3,action:{label:`Dismiss`,onClick:()=>U.dismiss()}}),y(!1)},onError:()=>{U.error(`Error`,{description:P?`Failed to remove cluster: ${e.name}`:`Failed to terminate cluster: ${e.name}.`,duration:5e3,action:{label:`Dismiss`,onClick:()=>U.dismiss()}}),y(!1)}})},[t,e.organizationId,e.id,e.name,m,P,n]),se=!c||I?void 0:e.status===`STOPPED`?`/${e.organizationId}/${e.id}/instances`:e.status===`PARTIAL`?`/${e.organizationId}/${e.id}`:N?P?`/${e.organizationId}/${e.id}`:e.fqdn?e.resetPassword?void 0:`/${e.organizationId}/${e.id}`:`/${e.organizationId}/${e.id}/instances`:void 0,ce=e.domains?.[0]?.domain||e.fqdn,[le,ue]=Vl(`${ce}`,`https://${ce}`),de=[{type:`label`,key:`label`,className:`text-gray-600 text-xs`,label:`Options`},{type:`separator`,key:`label-separator`},N&&d&&!a.isLoading&&(!te||ee)&&{key:`sign-in`,to:`${e.id}/sign-in`,disabled:g,icon:(0,K.jsx)(Tr,{className:`text-green`}),label:`Direct Sign In`},N&&c&&!!r&&!a.isLoading&&te&&{key:`direct-sign-out`,onClick:re,disabled:g,label:`Direct Sign Out`},N&&d&&{key:`edit`,to:`${e.id}/edit`,disabled:g,icon:(0,K.jsx)(Yr,{className:`text-purple-600`}),label:P?`Edit`:`Edit Scaling`},ne&&{key:`edit-version`,to:`${e.id}/edit/version`,disabled:g,icon:(0,K.jsx)(yr,{className:`text-fuchsia-300`}),label:`Edit Version`},N&&d&&!1,N&&c&&{key:`instances`,to:`${e.id}/instances`,disabled:g,icon:(0,K.jsx)(Zr,{className:`text-orange-300`}),label:`Instances`},N&&c&&!!a.user&&{key:`deployments`,to:`${e.id}/config/deployments`,disabled:g,icon:(0,K.jsx)(Gr,{className:`text-sky-400`}),label:`Deployments`},F&&(O||k||A)&&{type:`separator`,key:`container-separator`},F&&(O||k||A)&&{type:`label`,key:`container-label`,className:`text-gray-600 text-xs`,label:`Container`},F&&(k||A)&&{key:`container-start`,disabled:D,onClick:()=>void E(`start`,{safeMode:!1,strategy:`parallel`}),icon:(0,K.jsx)(Hr,{}),label:`Start`},F&&k&&{key:`container-start-safe`,disabled:D,onClick:()=>T(`start`),icon:(0,K.jsx)(Dr,{}),label:`Start in safe mode`},F&&(O||A)&&{key:`container-restart`,disabled:D,onClick:()=>C(!0),icon:(0,K.jsx)(qr,{}),label:`Restart`},F&&O&&{key:`container-restart-safe`,disabled:D,onClick:()=>T(`restart`),icon:(0,K.jsx)(Dr,{}),label:`Restart in safe mode`},F&&(O||A)&&{key:`container-stop`,variant:`destructive`,disabled:D,onClick:()=>x(!0),icon:(0,K.jsx)(ri,{}),label:`Stop`},N&&c&&!!e.fqdn&&{type:`separator`,key:`copy-separator`},N&&c&&!!e.fqdn&&{key:`copy-host-name`,onClick:le,disabled:g,icon:(0,K.jsx)(nr,{}),label:`Copy Host Name`},N&&c&&!!e.fqdn&&{key:`copy-api-url`,onClick:ue,disabled:g,icon:(0,K.jsx)(nr,{}),label:`Copy API URL`},L&&p&&{key:`try-again`,onClick:R,className:`focus:bg-green/70 focus:text-white`,label:`Try Again`},!I&&f&&N&&{type:`separator`,key:`remove-separator`},!I&&f&&{key:`remove`,onClick:z,className:`focus:bg-red/70 focus:text-white`,icon:(0,K.jsx)(di,{className:`text-red-300`}),label:P?`Remove`:`Terminate`}].filter(kn);return(0,K.jsx)(rc,{items:I?[]:de,children:(0,K.jsxs)(It,{className:`relative h-full justify-between transition-[transform,box-shadow] duration-200 ${se?`hover:scale-[1.02] hover:shadow-lg hover:ring-2 hover:ring-primary/60 dark:hover:ring-violet-400/70`:`hover:shadow-lg`}`,children:[se&&(0,K.jsx)(V,{to:se,"aria-label":`${P||e.fqdn?`Open`:`View`} ${e.name}`,className:`absolute inset-0 rounded-[inherit] focus-visible:ring-2 focus-visible:ring-purple-200 focus-visible:outline-none`}),(0,K.jsxs)(Nt,{children:[(0,K.jsxs)(Ft,{className:`flex items-center justify-between`,children:[ce?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`truncate max-w-48`,children:ce}),(0,K.jsx)(`button`,{type:`button`,"aria-label":`Copy host name`,onClick:e=>{e.stopPropagation(),le()},className:`relative z-10 -m-1.5 p-1.5 rounded-md text-muted-foreground cursor-pointer hover:bg-accent/60 hover:text-foreground`,children:(0,K.jsx)(sr,{size:16})}),(0,K.jsx)(`span`,{className:`grow`})]}):(0,K.jsx)(`span`,{children:`Self-Hosted`}),!I&&(0,K.jsxs)(bi,{children:[(0,K.jsx)(xi,{"aria-label":`Cluster options`,onClick:e=>e.stopPropagation(),className:`relative z-10 -m-2 p-2 rounded-md hover:bg-accent/60`,children:(0,K.jsx)(ur,{})}),(0,K.jsx)(Si,{children:nc(de,`dropdown`)})]})]}),(0,K.jsx)(Mt,{children:(0,K.jsx)(`h2`,{children:e.name})})]}),(0,K.jsxs)(Pt,{className:`flex items-center justify-between gap-2`,children:[(0,K.jsx)(jl,{cluster:e}),N&&c&&(0,K.jsx)(Dl,{cluster:e,hasCardLink:!!se}),M&&e.status&&(0,K.jsxs)(Wi,{variant:k?`destructive`:`warning`,children:[j&&(0,K.jsx)(kr,{className:`animate-spin`}),wo(e.status)]}),L&&e.status&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Wi,{variant:Ro(e.status),children:wo(e.status)}),(0,K.jsx)(`span`,{className:`text-xs`,children:`Click "..." to choose how to proceed.`})]})]}),(0,K.jsx)(qs,{typeOfThingBeingDeleted:`cluster`,transitiveVerb:P?`Remove`:`Terminate`,presentParticiple:P?`Removing`:`Terminating`,nameOfThingBeingDeleted:e.name,isModalOpen:v,hideDataLossWarning:P,setIsModalOpen:e=>y(e),deletionConfirmed:oe,deletionPending:h}),(0,K.jsx)(kl,{clusterName:e.name,isPending:D,stopOpen:b,setStopOpen:x,onConfirmStop:()=>{x(!1),E(`stop`,{strategy:`parallel`})},restartOpen:S,setRestartOpen:C,onConfirmRestart:e=>{C(!1),E(`restart`,{safeMode:!1,strategy:e})}}),(0,K.jsx)(Ml,{open:w!==null,setOpen:e=>{e||T(null)},action:w??`restart`,targetName:e.name,scope:`cluster`,isPending:D,onConfirm:()=>{let e=w;T(null),e&&E(e,{safeMode:!0,strategy:`parallel`,label:e===`start`?`Starting in safe mode`:`Restarting in safe mode`})}})]})})}function Wl({overEmail:e}){return(0,K.jsx)(`a`,{href:e?`mailto:support@harperdb.io`:`https://discord.com/channels/1415002037439041710/1415002038286286994`,target:`_blank`,rel:`noreferrer`,className:`underline`,children:`Contact us`})}function Gl({children:e,className:t}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Ks,{}),(0,K.jsx)(`div`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-(--spacing(32)))] relative ${t??``}`,children:e})]})}function Kl({children:e}){let{organizationId:t,clusterId:n}=B({strict:!1}),{view:r,update:i}=ml(t,n),{data:a}=H(Jo(n,!1)),o=a?El(a):!1,s=`/${t}/${n}`,c=[{to:s,label:`Overview`,icon:Er,exact:!0},r&&!o&&{to:`${s}/usage`,label:`Usage`,icon:qn},i&&{to:`${s}/edit`,label:o?`Configuration`:`Scaling`,icon:vr,exact:!0},i&&!o&&{to:`${s}/edit/version`,label:`Version`,icon:si,exact:!0},i&&!o&&{to:`${s}/domains`,label:`Domains`,icon:br},r&&{to:`${s}/instances`,label:`Instances`,icon:Zr}].filter(Boolean);return(0,K.jsx)(`div`,{className:`relative mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-(--spacing(32)))]`,children:(0,K.jsxs)(`div`,{className:`md:grid gap-6 md:grid-cols-12`,children:[(0,K.jsx)(`aside`,{className:`md:col-span-3 lg:col-span-2 mb-4 md:mb-0`,children:(0,K.jsx)(Fi,{items:c,ariaLabel:`Cluster sections`})}),(0,K.jsx)(`section`,{className:`md:col-span-9 lg:col-span-10 min-w-0`,children:e})]})})}async function ql(e){let{data:t}=await N.get(`/Plan/`,{params:{organizationId:e}});return t}function Jl(e){return z({queryKey:[e,`instancePlan`],queryFn:()=>ql(e),retry:!1})}var Yl=[`stable`,`next`,`beta`,`alpha`];function Xl(e){let t=Yl.indexOf(e);return t===-1?Yl.length:t}function Zl(e){let t=new Map;for(let n of e){let e=t.get(n.version);(!e||Xl(n.name)<Xl(e.name))&&t.set(n.version,n)}return[...t.values()]}async function Ql(e){let{data:t}=await N.get(`/HarperVersions/`,{params:{organizationId:e}}),n=t;return{...n,value:Zl(n.value)}}function $l(e){return z({queryKey:[e,`HarperVersions`],queryFn:()=>Ql(e),staleTime:6e4,retry:!1})}async function eu({organizationId:e,availableHosts:t}={}){let{data:n}=await N.get(`/Region/`,{params:{availableHosts:t,organizationId:e}});return n}function tu({organizationId:e,availableHosts:t}={}){return z({queryKey:[e,`regionLocations`,t],queryFn:()=>eu({organizationId:e,availableHosts:t}),retry:!1})}function nu(e){return(t,n)=>t[e]===n[e]?0:t[e]>n[e]?1:-1}function ru(e){let t=e.split(`.`).map(Number);return(t[0]<<24|t[1]<<16|t[2]<<8|t[3])>>>0}function iu(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)}function au(e,t){return e.instanceFqdn===t.instanceFqdn?e.operationsApiPort-t.operationsApiPort:iu(e.instanceFqdn)&&iu(t.instanceFqdn)?ru(e.instanceFqdn)-ru(t.instanceFqdn):e.instanceFqdn>t.instanceFqdn?1:-1}function ou(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 su(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 cu(e,t,n){let r=ou(e,t),i={};for(let e in r)i[e]=su(r[e],n);return i}function lu({duration:e,message:t,lateMessage:n}){let r=(0,q.useRef)(0),i=(0,q.useRef)(0),[a,o]=(0,q.useState)(!1),[s,c]=(0,q.useState)(`5%`),l=(0,q.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,q.useEffect)(()=>(r.current=requestAnimationFrame(l),()=>cancelAnimationFrame(r.current)),[l]),(0,K.jsxs)(K.Fragment,{children:[a?n:t,(0,K.jsx)(en,{width:s,animated:!1})]})}async function uu(e){let{data:t}=await N.post(`/Cluster/`,e,{timeout:0});return t}function du(){return R({mutationFn:e=>uu(e)})}async function fu(e){let{id:t,...n}=e,{data:r}=await N.put(`/Cluster/${t}`,n,{timeout:0});return r}function pu(){return R({mutationFn:e=>fu(e)})}function mu(e){return!!e&&e!==`undefined`&&e!==`null`}async function hu(e){if(!mu(e))throw Error(`getOrganization called without a valid organization id (got: ${e})`);let{data:t}=await N.get(`/Organization/${e}`);return t}function gu(e){return z({queryKey:[e],queryFn:()=>hu(e),retry:!1,enabled:mu(e),refetchInterval:jn(1e4)})}var _u=`ENTERPRISE`;function vu(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 yu(e,t,n=`-`){let r=t.split(n)[0];return e.findIndex(e=>e.startsWith(r))!==-1}function bu(e){return e.replace(/[^a-zA-Z0-9]/g,`-`).replace(/([a-z])([A-Z])/g,`$1-$2`).toLowerCase().replace(/-+/g,`-`).replace(/^-+|-+$/g,``)}function xu(e){return e!==void 0&&e>0}function Su(e,t,n){return t===void 0?Promise.resolve():e.invalidateQueries({predicate:e=>e.queryKey[0]===t||e.queryKey[1]===t,...n})}async function Cu(e){await N.put(`/Payment/`,e)}function wu(){return R({mutationFn:e=>Cu(e)})}function Tu(e){let{mutate:t}=wu();return(0,q.useCallback)((n,r)=>{t({paymentMethodId:typeof n==`string`?n:n.id,organizationId:e},{onSuccess:()=>{U.success(`Success! Your payment method has been saved.`),r(!0)},onError:()=>{U.error(`Failed to process payment method details. Please try another payment method.`),r(!1)}})},[t,e])}var Eu=(0,q.createContext)(null);function Du(){return(0,q.useContext)(Eu)}var Ou=t(((e,t)=>{t.exports=`SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED`})),ku=t(((e,t)=>{var n=Ou();function r(){}function i(){}i.resetWarningCache=r,t.exports=function(){function e(e,t,r,i,a,o){if(o!==n){var s=Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw s.name=`Invariant Violation`,s}}e.isRequired=e;function t(){return e}var a={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:i,resetWarningCache:r};return a.PropTypes=a,a}})),Au=t(((e,t)=>{t.exports=ku()()})),ju=e(Au(),1);function Mu(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Nu(e){if(Array.isArray(e))return e}function Pu(e,t,n){return(t=Uu(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Fu(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t!==0)for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function Iu(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
11
11
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Lu(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Ru(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Lu(Object(n),!0).forEach(function(t){Pu(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Lu(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function zu(e,t){if(e==null)return{};var n,r,i=Bu(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Bu(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function Vu(e,t){return Nu(e)||Fu(e,t)||Gu(e,t)||Iu()}function Hu(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Uu(e){var t=Hu(e,`string`);return typeof t==`symbol`?t:t+``}function Wu(e){"@babel/helpers - typeof";return Wu=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},Wu(e)}function Gu(e,t){if(e){if(typeof e==`string`)return Mu(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Mu(e,t):void 0}}var Ku=function(e,t,n){var r=!!n,i=q.useRef(n);q.useEffect(function(){i.current=n},[n]),q.useEffect(function(){if(!r||!e)return function(){};var n=function(){if(i.current)return i.current.apply(i,arguments)};return e.on(t,n),function(){e.off(t,n)}},[r,t,e,i])},qu=function(e){var t=q.useRef(e);return q.useEffect(function(){t.current=e},[e]),t.current},Ju=function(e){return e!==null&&Wu(e)===`object`},Yu=`[object Object]`,Xu=function e(t,n){if(!Ju(t)||!Ju(n))return t===n;var r=Array.isArray(t);if(r!==Array.isArray(n))return!1;var i=Object.prototype.toString.call(t)===Yu;if(i!==(Object.prototype.toString.call(n)===Yu))return!1;if(!i&&!r)return t===n;var a=Object.keys(t),o=Object.keys(n);if(a.length!==o.length)return!1;for(var s={},c=0;c<a.length;c+=1)s[a[c]]=!0;for(var l=0;l<o.length;l+=1)s[o[l]]=!0;var u=Object.keys(s);if(u.length!==a.length)return!1;var d=t,f=n;return u.every(function(t){return e(d[t],f[t])})},Zu=function(e,t,n){return Ju(e)?Object.keys(e).reduce(function(r,i){var a=!Ju(t)||!Xu(e[i],t[i]);return n.includes(i)?(a&&console.warn(`Unsupported prop change: options.${i} is not a mutable property.`),r):a?Ru(Ru({},r||{}),{},Pu({},i,e[i])):r},null):null},Qu=q.createContext(null);Qu.displayName=`ElementsContext`;var $u=function(e,t){if(!e)throw Error(`Could not find Elements context; You need to wrap the part of your app that ${t} in an <Elements> provider.`);return e};ju.default.any,ju.default.object;var ed=function(e){return $u(q.useContext(Qu),e)},td=function(){return ed(`calls useElements()`).elements};ju.default.func.isRequired;var nd=q.createContext(null);nd.displayName=`CheckoutContext`;var rd=function(e){var t=q.useContext(nd),n=q.useContext(Qu);if(t){if(n)throw Error(`You cannot wrap the part of your app that ${e} in both a checkout provider and <Elements> provider.`);return t}return $u(n,e)},id=[`mode`],ad=function(e){return e.charAt(0).toUpperCase()+e.slice(1)},od=function(e,t,n){var r=`${ad(e)}Element`,i=t?function(e){rd(`mounts <${r}>`);var t=e.id,n=e.className;return q.createElement(`div`,{id:t,className:n})}:function(t){var n=t.id,i=t.className,a=t.options,o=a===void 0?{}:a,s=t.onBlur,c=t.onFocus,l=t.onReady,u=t.onChange,d=t.onEscape,f=t.onClick,p=t.onLoadError,m=t.onLoaderStart,h=t.onNetworksChange,g=t.onConfirm,_=t.onCancel,v=t.onShippingAddressChange,y=t.onShippingRateChange,b=t.onSavedPaymentMethodRemove,x=t.onSavedPaymentMethodUpdate,S=t.onAvailablePaymentMethodsChange,C=rd(`mounts <${r}>`),w=`elements`in C?C.elements:null,T=`checkoutState`in C?C.checkoutState:null,E=T?.type===`success`||T?.type===`loading`?T.sdk:null,D=Vu(q.useState(null),2),O=D[0],k=D[1],A=q.useRef(null),j=q.useRef(null);Ku(O,`blur`,s),Ku(O,`focus`,c),Ku(O,`escape`,d),Ku(O,`click`,f),Ku(O,`loaderror`,p),Ku(O,`loaderstart`,m),Ku(O,`networkschange`,h),Ku(O,`confirm`,g),Ku(O,`cancel`,_),Ku(O,`shippingaddresschange`,v),Ku(O,`shippingratechange`,y),Ku(O,`savedpaymentmethodremove`,b),Ku(O,`savedpaymentmethodupdate`,x),Ku(O,`availablepaymentmethodschange`,S),Ku(O,`change`,u);var M;l&&(M=e===`expressCheckout`?l:function(){l(O)}),Ku(O,`ready`,M),q.useLayoutEffect(function(){if(A.current===null&&j.current!==null&&(w||E)){var t=null;if(E){var n=E,i=E;switch(e){case`paymentForm`:t=i.createForm(o);break;case`payment`:t=n.createPaymentElement(o);break;case`address`:if(`mode`in o){var a=o.mode,s=zu(o,id);if(a===`shipping`)t=n.createShippingAddressElement(s);else if(a===`billing`)t=n.createBillingAddressElement(s);else throw Error(`Invalid options.mode. mode must be 'billing' or 'shipping'.`)}else throw Error(`You must supply options.mode. mode must be 'billing' or 'shipping'.`);break;case`expressCheckout`:t=n.createExpressCheckoutElement(o);break;case`currencySelector`:t=E.createCurrencySelectorElement();break;case`taxId`:t=n.createTaxIdElement(o);break;case`contactDetails`:t=n.createContactDetailsElement();break;case`terms`:t=n.createTermsElement(o);break;default:throw Error(`<${r}> is not supported inside a checkout provider. Use an <Elements> provider instead.`)}}else w&&(t=w.create(e,o));A.current=t,k(t),t&&t.mount(j.current)}},[w,E,o]);var N=qu(o);return q.useEffect(function(){if(A.current){var e=Zu(o,N,[`paymentRequest`]);e&&`update`in A.current&&A.current.update(e)}},[o,N]),q.useLayoutEffect(function(){return function(){if(A.current&&typeof A.current.destroy==`function`)try{A.current.destroy(),A.current=null}catch{}}},[]),q.createElement(`div`,{id:n,className:i,ref:j})};return i.propTypes={id:ju.default.string,className:ju.default.string,onChange:ju.default.func,onBlur:ju.default.func,onFocus:ju.default.func,onReady:ju.default.func,onEscape:ju.default.func,onClick:ju.default.func,onLoadError:ju.default.func,onLoaderStart:ju.default.func,onNetworksChange:ju.default.func,onConfirm:ju.default.func,onCancel:ju.default.func,onShippingAddressChange:ju.default.func,onShippingRateChange:ju.default.func,onSavedPaymentMethodRemove:ju.default.func,onSavedPaymentMethodUpdate:ju.default.func,onAvailablePaymentMethodsChange:ju.default.func,options:ju.default.object},i.displayName=r,i.__elementType=e,i},sd=typeof window>`u`,cd=q.createContext(null);cd.displayName=`EmbeddedCheckoutProviderContext`;var ld=function(){return rd(`calls useStripe()`).stripe};od(`auBankAccount`,sd),od(`card`,sd),od(`cardNumber`,sd),od(`cardExpiry`,sd),od(`cardCvc`,sd),od(`currencySelector`,sd),od(`iban`,sd);var ud=od(`payment`,sd);od(`expressCheckout`,sd),od(`paymentRequestButton`,sd),od(`linkAuthentication`,sd),od(`contactDetails`,sd);var dd=od(`address`,sd);od(`shippingAddress`,sd),od(`paymentMethodMessaging`,sd),od(`taxId`,sd),od(`issuingCardNumberDisplay`,sd),od(`issuingCardCvcDisplay`,sd),od(`issuingCardExpiryDisplay`,sd),od(`issuingCardPinDisplay`,sd),od(`issuingCardCopyButton`,sd),od(`terms`,sd);function fd({hasExistingBilling:e,onPaymentAdded:t,onSaveStateForBillingRedirect:n}){let{organizationId:r}=B({strict:!1}),i=ld(),a=Du(),o=td(),[s,c]=(0,q.useState)(!1),l=Tu(r),u=(0,q.useCallback)(()=>{t(!1)},[t]),d=(0,q.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),U.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]);return(0,K.jsxs)(`form`,{id:`billing-add-payment-method-form`,name:`billing-add-payment-method-form`,onSubmit:d,className:`max-w-xl`,children:[(0,K.jsx)(ud,{}),(0,K.jsx)(dd,{options:{mode:`billing`}}),(0,K.jsxs)(`div`,{className:`mt-4 flex gap-8 items-center`,children:[(0,K.jsxs)(F,{disabled:!i||!o||s,variant:`submit`,children:[(0,K.jsx)(Jr,{}),` Add Payment Method`]}),e&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`text-xs text-gray-600`,children:`Your existing payment method will be overwritten.`}),(0,K.jsx)(F,{variant:`defaultOutline`,type:`button`,onClick:u,children:`Cancel`})]})]})]})}var pd=`dahlia`,md=`https://js.stripe.com`,hd=`${md}/${pd}/stripe.js`,gd=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,_d=/^https:\/\/js\.stripe\.com\/(v3|[a-z]+)\/stripe\.js(\?.*)?$/,vd=`loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used`,yd=function(e){return gd.test(e)||_d.test(e)},bd=function(){for(var e=document.querySelectorAll(`script[src^="${md}"]`),t=0;t<e.length;t++){var n=e[t];if(yd(n.src))return n}return null},xd=function(e){var t=e&&!e.advancedFraudSignals?`?advancedFraudSignals=false`:``,n=document.createElement(`script`);n.src=`${hd}${t}`;var r=document.head||document.body;if(!r)throw Error(`Expected document.body not to be null. Stripe.js requires a <body> element.`);return r.appendChild(n),n},Sd=null,Cd=null,wd=null,Td=function(e){return function(t){e(Error(`Failed to load Stripe.js`,{cause:t}))}},Ed=function(e,t){return function(){window.Stripe?e(window.Stripe):t(Error(`Stripe.js not available`))}},Dd=function(e){return Sd===null?(Sd=new Promise(function(t,n){if(typeof window>`u`||typeof document>`u`){t(null);return}if(window.Stripe&&e&&console.warn(vd),window.Stripe){t(window.Stripe);return}try{var r=bd();if(r&&e)console.warn(vd);else if(!r)r=xd(e);else if(r&&wd!==null&&Cd!==null){var i;r.removeEventListener(`load`,wd),r.removeEventListener(`error`,Cd),(i=r.parentNode)==null||i.removeChild(r),r=xd(e)}wd=Ed(t,n),Cd=Td(n),r.addEventListener(`load`,wd),r.addEventListener(`error`,Cd)}catch(e){n(e);return}}),Sd.catch(function(e){return Sd=null,Promise.reject(e)})):Sd},Od,kd=function(){return Od||(Od=Dd(null).catch(function(e){return Od=null,Promise.reject(e)}),Od)};Promise.resolve().then(function(){return kd()}).catch(function(e){console.warn(e)});async function Ad(e){let{data:t}=await N.post(`/StripeAccount/`,e);return t}function jd(){return R({mutationFn:e=>Ad(e)})}async function Md(e){let{data:t}=await N.post(`/Payment/`,{organizationId:e.organizationId});return t}function Nd(){return R({mutationFn:e=>Md(e)})}function Pd(e){let{enabled:t,existingStripeId:n,organizationId:r}=e,{mutate:i}=jd(),{mutate:a}=Nd(),[o,s]=(0,q.useState)(void 0),c=(0,q.useCallback)(e=>{s(e.clientSecret)},[]);return(0,q.useEffect)(()=>{},[i,t,n,a,c,r]),o}function Fd({children:e}){let{organizationId:t}=B({strict:!1}),{data:n}=H(gu(t)),r=Pd({organizationId:t,enabled:!!n,existingStripeId:n?.stripeId}),i=wa();return(0,q.useMemo)(()=>({clientSecret:r||``,appearance:{theme:i===`dark`?`night`:`stripe`}}),[r,i]),console.error(`No VITE_PUBLIC_STRIPE_KEY is configured for this environment.`),(0,K.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 Id({onPaymentAdded:e,onSaveStateForBillingRedirect:t}){let{organizationId:n}=B({strict:!1}),{data:r}=H(gu(n)),i=r?.billing,a=i?.paymentMethod;return(0,K.jsxs)(Fd,{children:[(0,K.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,K.jsx)(fd,{hasExistingBilling:!!i,onSaveStateForBillingRedirect:t,onPaymentAdded:e})]})}var Ld=function(e){return e.PASS=`pass`,e.FAIL=`fail`,e.PENDING=`pending`,e.ERROR=`error`,e}({});function Rd(e){switch(e){case Ld.PASS:return`success`;case Ld.FAIL:case Ld.ERROR:return`destructive`;case Ld.PENDING:default:return`default`}}function zd(e){switch(e){case Ld.PASS:return`READY`;case Ld.FAIL:case Ld.ERROR:case Ld.PENDING:default:return e.toUpperCase()}}function Bd(e,t){return`${String(e).padStart(2,`0`)}/${String(t%100).padStart(2,`0`)}`}function Vd(e){let{onSaveStateForBillingRedirect:t,onReplacingPaymentMethod:n}=e??{},{organizationId:r}=B({strict:!1}),{update:i}=ul(r),{data:a,refetch:o}=H(gu(r)),s=a?.billing?.paymentMethod,[c,l]=(0,q.useState)(!1),u=(0,q.useCallback)(()=>{l(!c),n?.(!c)},[n,c]),d=(0,q.useCallback)(e=>{l(!1),n?.(!1),e&&o()},[n,o]);return a?.type===`ENTERPRISE`?(0,K.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,K.jsx)(Wl,{}),`, we would love to talk!`]}):s&&!c?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`mt-2`,children:[s.brand?.toUpperCase()??`Card`,` ending in `,s.last4??`••••`,s.expMonth&&s.expYear?(0,K.jsxs)(K.Fragment,{children:[`(exp `,Bd(s.expMonth,s.expYear),`)`]}):null,s.status?(0,K.jsxs)(K.Fragment,{children:[`—`,` `,(0,K.jsx)(Wi,{variant:Rd(s.status),children:zd(s.status)})]}):null]}),i&&(0,K.jsx)(`div`,{className:`mt-2 mb-6`,children:(0,K.jsx)(F,{variant:`defaultOutline`,type:`button`,onClick:u,children:`Replace Payment Method`})})]}):i?(0,K.jsx)(Id,{onSaveStateForBillingRedirect:t,onPaymentAdded:d}):(0,K.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 Hd({clusterId:e,isPending:t,onGoBackToDetails:n,onSaveStateForBillingRedirect:r,onSubmit:i,organizationId:o,selectedPlan:s}){let{data:c}=H(gu(o)),l=c?.billing,u=c?.type===_u,d=u||l?.paymentMethod?.status===Ld.PASS,[f,p]=(0,q.useState)(!1),m=xu(s?.planLimits?.expirationMonths)&&s.planLimits.expirationMonths<1e3&&s.planLimits.expirationMonths,h=(0,K.jsx)(K.Fragment,{children:(0,K.jsxs)(`div`,{className:`flex flex-col-reverse gap-2 sm:flex-row sm:justify-end mt-3 max-w-xl`,children:[(0,K.jsxs)(F,{type:`button`,variant:`defaultOutline`,disabled:t,onClick:n,children:[(0,K.jsx)(Qt,{}),` Back to Details`]}),(0,K.jsxs)(F,{disabled:t||!d||f,type:`submit`,variant:`submit`,onClick:i,children:[e?`Edit Cluster`:`Create New Cluster`,` `,(0,K.jsx)(Bn,{})]})]})});if(u)return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`ul`,{className:`list-disc ml-6 max-w-lg`,children:[(0,K.jsx)(`li`,{children:`Reminder: you will be billed at your contracted rate for any additional infrastructure.`}),(0,K.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,K.jsx)(Wl,{overEmail:!0}),`, we are here to help.`]})]}),h]});let g=m&&`, or ${a(m,`month`,`months`)} elapse`;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`ul`,{className:`list-disc ml-6 mb-6`,children:[(0,K.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,K.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,K.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,K.jsxs)(`li`,{children:[`When that block is used up`,g,`, you will be automatically renewed.`]}),(0,K.jsx)(`li`,{children:`While refunds are not available, we’d be happy to assist you with troubleshooting.`}),(0,K.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,K.jsx)(Wl,{overEmail:!0}),`, we are here to help.`]})]}),(0,K.jsx)(`p`,{className:`text-muted-foreground text-sm mb-6`,children:`Payment method:`}),(0,K.jsx)(Vd,{onSaveStateForBillingRedirect:r,onReplacingPaymentMethod:p}),h]})}var Ud=/(^$|^(?: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,Wd=65535,Gd=M().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.`),Kd=y({clusterName:M().nonempty(`Please enter a cluster name.`).max(255,`Cluster name cannot be longer than 255 characters long.`),abbreviatedName:x([O(``),b(),Gd]).optional(),fqdn:M().regex(Ud,`Please enter a valid host name without the port or any path.`).optional(),version:M().optional(),deploymentDescription:M().nonempty(`Please select a deployment tier.`),performanceDescription:M().nonempty(`Please select a performance tier.`),regionPlans:k(y({regionName:M().nonempty(`Please select a region.`),latencyDescription:M().nonempty(`Please select a latency tier.`)})).max(50,{error:`A maximum of 50 regions can be selected for each cluster. `}),instances:k(y({secure:D([`true`,`false`]),fqdn:M().nonempty(`Please enter the host name of your instance.`).regex(Ud,`Please enter a valid host name without the port or any path.`),port:w().min(0,`Positive thinking only, please.`).max(Wd,`That port number is too high.`).optional()})).max(100,{error:`A maximum of 100 instances can be added to each cluster.`}),skipToBilling:S().optional(),skipGtmWait:S().optional(),sourceClusterId:M().optional()});function qd({calculatedNames:e,disabled:t,form:n}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Y,{control:n.control,name:`abbreviatedName`,render:({field:n})=>(0,K.jsxs)(X,{className:`col-span-3`,children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Host Name`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{...n,type:`text`,maxLength:Gd.maxLength,autoCapitalize:`none`,autoComplete:`off`,autoCorrect:`off`,placeholder:e.suggestedAbbreviatedName,disabled:t})}),(0,K.jsx)(Q,{})]})}),(0,K.jsxs)(X,{className:`col-span-3 `,children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Full Host Name`}),(0,K.jsx)(J,{children:(0,K.jsx)(`span`,{children:e.fullHostName})}),(0,K.jsx)(Q,{})]})]})}function Jd({className:e}={}){let t=(0,q.useMemo)(()=>g(`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]);return(0,K.jsx)(`div`,{className:t})}var Yd={Colocated:`Shared infrastructure for optimized value`,Dedicated:`Dedicated infrastructure for consistent performance`,"Self-Hosted":`Your own infrastructure`};function Xd({availableDeploymentTypes:e,disabled:t,form:n}){return(0,K.jsx)(Y,{control:n.control,name:`deploymentDescription`,render:({field:r})=>(0,K.jsxs)(X,{className:`col-span-3`,children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Harper Deployment`}),(0,K.jsx)(q.Suspense,{fallback:(0,K.jsx)(Jd,{}),children:(0,K.jsx)(J,{children:(0,K.jsxs)(Xt,{...r,disabled:t,onValueChange:e=>{r.onChange(e),n.trigger()},children:[(0,K.jsx)(Kt,{className:`w-full h-auto`,children:(0,K.jsx)(Yt,{placeholder:`Choose Tier`})}),(0,K.jsx)(Gt,{children:(0,K.jsx)(Jt,{children:e.map(e=>(0,K.jsxs)(Ht,{value:e,children:[(0,K.jsx)(`dt`,{className:`text-left font-bold text-sm/6`,children:e}),Yd[e]&&(0,K.jsx)(`dd`,{className:`font-light`,children:Yd[e]})]},e))})})]})})}),(0,K.jsx)(Q,{})]})})}function Zd({disabled:e,form:t}){return(0,K.jsx)(Y,{control:t.control,name:`fqdn`,render:({field:t})=>(0,K.jsxs)(X,{className:`md:col-span-6 col-span-3`,children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Optional Cluster Load Balancer Host Name`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{...t,type:`text`,autoCapitalize:`none`,autoComplete:`off`,autoCorrect:`off`,placeholder:`example.your-company.com`,disabled:e})}),(0,K.jsx)(Q,{})]})})}function Qd({className:e,disabled:t,form:n}){return(0,K.jsx)(Y,{control:n.control,name:`clusterName`,render:({field:n})=>(0,K.jsxs)(X,{className:e,children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Cluster Name`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{autoFocus:!0,type:`text`,maxLength:Kd.shape.clusterName.maxLength,autoCapitalize:`words`,disabled:t,...n})}),(0,K.jsx)(Q,{})]})})}function $d({availablePerformanceDescriptions:e,form:t,selectedDeployment:n}){return(0,K.jsx)(Y,{control:t.control,name:`performanceDescription`,render:({field:r})=>(0,K.jsxs)(X,{className:`col-span-3`,children:[(0,K.jsxs)(Z,{className:`pb-1`,children:[n.startsWith(`Self`)?`Support`:`Performance`,` & Usage`]}),(0,K.jsx)(q.Suspense,{fallback:(0,K.jsx)(Jd,{}),children:(0,K.jsx)(J,{children:(0,K.jsxs)(Xt,{...r,onValueChange:e=>{r.onChange(e),t.trigger()},disabled:!e?.length,children:[(0,K.jsx)(Kt,{className:`w-full h-auto`,children:(0,K.jsx)(Yt,{placeholder:`Choose Tier`})}),(0,K.jsx)(Gt,{children:(0,K.jsx)(Jt,{children:e.map(e=>(0,K.jsxs)(Ht,{value:e.performanceTier,children:[(0,K.jsxs)(`dt`,{className:`text-left font-bold text-sm/6 flex items-center gap-2`,children:[e.name,e.isPremium&&(0,K.jsx)(Wi,{children:`Premium`})]}),e.description&&(0,K.jsx)(`dd`,{className:`text-left font-light`,children:e.description})]},e.name))})})]})})}),(0,K.jsx)(Q,{})]})})}function ef({className:e,...t}){let{formDescriptionId:n}=Ao();return(0,K.jsx)(`p`,{"data-slot":`form-description`,id:n,className:P(`text-muted-foreground text-sm`,e),...t})}function tf({className:e,form:t}){return(0,K.jsx)(Y,{control:t.control,name:`skipGtmWait`,render:({field:t})=>(0,K.jsxs)(X,{className:e,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(J,{children:(0,K.jsx)($,{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,K.jsx)(Z,{className:`cursor-pointer`,children:`Immediate upgrade and restart`})]}),(0,K.jsx)(ef,{children:`Apply changes immediately without waiting for each instance to be taken out of the load balancer (faster, but potentially less safe).`})]})})}function nf({className:e,disabled:t,form:n,harperVersions:r}){return r?.value?.length?(0,K.jsx)(Y,{control:n.control,name:`version`,render:({field:i})=>(0,K.jsxs)(X,{className:e,children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Harper Version`}),(0,K.jsx)(q.Suspense,{fallback:(0,K.jsx)(Jd,{}),children:(0,K.jsx)(J,{children:(0,K.jsxs)(Xt,{...i,disabled:t,onValueChange:e=>{i.onChange(e),n.trigger()},children:[(0,K.jsx)(Kt,{className:`w-full h-auto`,children:(0,K.jsx)(Yt,{placeholder:`Choose Version`})}),(0,K.jsx)(Gt,{children:(0,K.jsx)(Jt,{children:r?.value.map(e=>(0,K.jsxs)(Ht,{value:e.version,children:[e.version,` `,(0,K.jsx)(`span`,{className:`font-light opacity-50`,children:e.name})]},e.version))})})]})})}),(0,K.jsx)(Q,{})]})}):null}var rf=new RegExp(/^\d+/);function af(e,t){let n=parseInt(e.match(rf)?.[0]||`0`,10),r=parseInt(t.match(rf)?.[0]||`0`,10);return n===r?0:n>r?1:-1}var of=[`B`,`KB`,`MB`,`GB`,`TB`,`PB`,`EB`,`ZB`,`YB`],sf=[`secs`,`mins`,`hrs`],cf={bytes:1e3,secs:60};function lf(e,t,n){let r,i;switch(t){case`bytes`:r=of,i=cf.bytes;break;case`secs`:r=sf,i=cf.secs;break;default:return e}let a=r.indexOf(n);return a===-1?e:e/i**a}function uf(e,t){let n,r;switch(e){case`bytes`:n=of,r=cf.bytes;break;case`secs`:n=sf,r=cf.secs;break;default:return e}let i=0;for(;t>=r&&i<n.length-1;)t/=r,i++;return n[i]}function df(e,t=1){let n=e*t,r=uf(`bytes`,n),i=lf(n,`bytes`,r);return`${new Intl.NumberFormat().format(Math.round(i))} ${r}`}function ff(e){return new Intl.NumberFormat().format(e)}var pf=[`K`,`M`,`B`,`T`,`Qa`,`Qi`,`Sx`,`Sp`,`Oc`,`No`,`Dc`];function mf(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<pf.length-1);return`${ff(Math.round(n))} ${pf[r]}`}function hf(e,t){let n=Object.values(t).flatMap(e=>Object.values(e)).map(e=>e.purchasedBlockMultiplier??1),r=Math.max(...n,1),i=Math.min(...n,r),a=t=>{let n=e.map(t).filter(e=>typeof e==`number`&&e>0);return n.length?{min:Math.min(...n),max:Math.max(...n)}:{min:0,max:0}},o=a(e=>e.planLimits?.readsPerMinuteCount),s=a(e=>e.planLimits?.totalReadCount);return{readRate:{min:o.min*i,max:o.max*r},totalReads:{min:s.min*i,max:s.max*r},writeRate:a(e=>e.planLimits?.writesPerMinuteCount),totalWrites:a(e=>e.planLimits?.totalWriteCount)}}function gf(e,{min:t,max:n}){if(e<=0)return 0;let r=Math.max(Math.min(t,e),1),i=Math.max(n,e);if(i<=r)return 1;let a=(Math.log(e)-Math.log(r))/(Math.log(i)-Math.log(r));return Math.min(Math.max(a,0),1)}function _f({selectedPlan:e,selectedRegion:t,usageScale:n,isEnterprise:r,cloudProvider:i}){let[o,s]=(0,q.useState)(!1),c=(0,q.useCallback)(()=>{s(!o)},[o,s]),l=e?.planLimits,u=e?.resourcesPerInstance,d=i&&e?.cloudInstanceTypes?.[i],f=xu(l?.expirationMonths)&&l.expirationMonths<1e3&&l.expirationMonths,p=t?.purchasedBlockMultiplier??1,m=(0,q.useMemo)(()=>l?[xu(l.totalReadCount)&&{label:`Total Reads`,value:mf(l.totalReadCount*p)},xu(l.totalReadsBytes)&&{label:`Total Read Transfer`,value:`${df(l.totalReadsBytes*p)}`},xu(l.readsPerMinuteCount)&&{label:`Read Rate`,value:`${mf(l.readsPerMinuteCount*60*p)}/hr`},xu(l.readsPerMinuteBytes)&&{label:`Read Bandwidth`,value:`${df(l.readsPerMinuteBytes*60*p)}/hr`},xu(l.totalWriteCount)&&{label:`Total Writes`,value:mf(l.totalWriteCount)},xu(l.totalWritesBytes)&&{label:`Total Write Transfer`,value:`${df(l.totalWritesBytes)}`},xu(l.writesPerMinuteCount)&&{label:`Write Rate`,value:`${mf(l.writesPerMinuteCount*60)}/hr`},xu(l.writesPerMinuteBytes)&&{label:`Write Bandwidth`,value:`${df(l.writesPerMinuteBytes*60)}/hr`},xu(l.totalRealTimeMessageDeliveries)&&{label:`Total Real-Time Messages`,value:`${mf(l.totalRealTimeMessageDeliveries*p)} messages`},xu(l.totalRealTimeMessageDeliveryBytes)&&{label:`Total Real-Time Message Transfer`,value:`${df(l.totalRealTimeMessageDeliveryBytes*p)}`},xu(l.realTimeMessageDeliveriesPerMinute)&&{label:`Real-Time Message Rate`,value:`${mf(l.realTimeMessageDeliveriesPerMinute*60*p)}/hr`},xu(l.realTimeMessageDeliveryBytesPerMinute)&&{label:`Real-Time Message Bandwidth`,value:`${df(l.realTimeMessageDeliveryBytesPerMinute*60*p)}/hr`},xu(l.tlsHandshakes)&&{label:`TLS Handshakes`,value:`${mf(l.tlsHandshakes*60*p)}`},xu(l.applicationComputeHours)&&{label:`Application Compute Hours`,value:`${mf(l.applicationComputeHours*p)}`},!!u&&xu(u.storageGb)&&{label:`Storage`,value:`${df(u.storageGb*1e9)}`},!!u&&xu(u.cpuCores)&&{label:`Maximum CPU Cores`,value:`${mf(u.cpuCores)}`},!!u&&xu(u.memoryMb)&&{label:`Memory`,value:`${u.memoryMb/1024} GB`},!!d&&{label:`Cloud Instance Type`,value:d},!!f&&{label:`Expiration`,value:a(f,`month`,`months`)},!!t?.id&&{label:`Region ID`,value:t.id},!!e?.id&&{label:`Plan ID`,value:e.id}].filter(kn):[],[f,t,e,p]);if(!l)return``;if(!xu(l.totalReadCount))return`This plan has no usage limits.`;let h=r?`for the contracted rate`:`for the price listed above`,g=f?` in ${a(f,`month`,`months`)} or`:``,_=xu(l.readsPerMinuteCount)?l.readsPerMinuteCount*p:0,v=xu(l.writesPerMinuteCount)?l.writesPerMinuteCount:0,y=l.totalReadCount*p,b=xu(l.totalWriteCount)?l.totalWriteCount:0,x=[_>0&&{icon:vr,label:`Read Rate`,value:`${mf(_)}/min`,fill:gf(_,n.readRate)},y>0&&{icon:Vn,label:`Total Reads`,value:mf(y),fill:gf(y,n.totalReads)},v>0&&{icon:vr,label:`Write Rate`,value:`${mf(v)}/min`,fill:gf(v,n.writeRate)},b>0&&{icon:zn,label:`Total Writes`,value:mf(b),fill:gf(b,n.totalWrites)},!!f&&{icon:Kn,label:`License Term`,value:a(f,`month`,`months`)}].filter(kn);return(0,K.jsxs)(X,{className:`basis-full`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-2`,children:[(0,K.jsx)(Z,{onClick:c,className:`cursor-pointer`,children:`Usage block included with this plan`}),(0,K.jsxs)(F,{type:`button`,variant:`link`,className:`text-foreground`,onClick:c,children:[`Learn More `,o?(0,K.jsx)(Vt,{}):(0,K.jsx)(Bn,{})]})]}),(0,K.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-3 lg:grid-cols-5`,children:x.map(e=>(0,K.jsx)(vf,{icon:e.icon,label:e.label,value:e.value,fill:e.fill},e.label))}),(0,K.jsx)(J,{children:(0,K.jsxs)(`dl`,{className:P(`divide-y divide-border rounded-md overflow-hidden transition-[max-height] duration-200 ease-in`,o?`max-h-fit border border-border`:`max-h-0`),children:[(0,K.jsxs)(`div`,{className:`text-sm px-4 py-5 leading-relaxed text-muted-foreground`,children:[`This plan licenses Harper for the usage limits below, `,h,`. The usage license expires`,g,` `,`when any usage limit is reached. New usage blocks are automatically purchased/billed as blocks are consumed.`]}),m.map((e,t)=>(0,K.jsxs)(`div`,{className:P(`px-4 py-1 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-3`,t%2==0&&`bg-muted dark:bg-grey-700`),children:[(0,K.jsx)(`dt`,{className:`text-sm/6 font-medium text-foreground`,children:e.label}),(0,K.jsx)(`dd`,{className:`mt-1 text-sm/6 text-muted-foreground sm:col-span-2 sm:mt-0`,children:e.value})]},e.label))]})}),(0,K.jsx)(Q,{})]})}function vf({icon:e,label:t,value:n,fill:r}){return(0,K.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-md border border-border bg-background/50 p-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,K.jsx)(e,{className:`size-4 shrink-0`}),(0,K.jsx)(`span`,{className:`text-xs font-medium`,children:t})]}),(0,K.jsx)(`span`,{className:`text-lg font-bold text-foreground tabular-nums`,children:n}),r!==void 0&&(0,K.jsx)(`div`,{className:`h-1.5 w-full overflow-hidden rounded-full bg-sky-500/15`,children:(0,K.jsx)(`div`,{className:`h-full rounded-full bg-sky-500 transition-[width] duration-300`,style:{width:`${Math.max(Math.min(r,1)*100,4)}%`}})})]})}function yf({control:e,fieldArray:t,form:n,index:r,regionNameToLatencyToRegion:i,premiumOnlyRegions:a,usageScale:o,selectedPlan:s,isEnterprise:c,cloudProvider:l}){let u=(0,q.useMemo)(()=>Object.keys(i).sort(),[i]),d=n.watch(`deploymentDescription`)?.startsWith(`Dedicated`),f=n.watch(`regionPlans.${r}.regionName`),p=n.watch(`regionPlans.${r}.latencyDescription`),m=(0,q.useMemo)(()=>Object.keys(i[f]||{}).sort(af).reverse(),[i,f]),h=s?.allowedRegionIds,g=(0,q.useCallback)(e=>!h?.length||Object.values(i[e]||{}).some(e=>h.includes(e.id)),[h,i]),_=(0,q.useCallback)(e=>{if(!h?.length)return!0;let t=i[f]?.[e]?.id;return!t||h.includes(t)},[h,i,f]);(0,q.useEffect)(function(){if(f&&m?.length&&!m?.includes(p)){let e=p?.split(` `)[0].toLowerCase(),t=m.find(t=>!e||t.split(` `)[0].toLowerCase()===e)||m[0];n.setValue(`regionPlans.${r}.latencyDescription`,t),n.trigger()}},[m,n,r,p,f]);let v=(0,q.useCallback)(()=>{t?.remove(r),n.trigger()},[t,n,r]);return(0,K.jsxs)(`div`,{className:`md:col-span-6 col-span-3 py-2 pl-4 border-l-4 border-border gap-6 flex flex-wrap items-start`,children:[(0,K.jsx)(Y,{control:e,name:`regionPlans.${r}.regionName`,render:({field:e})=>(0,K.jsxs)(X,{className:`flex-1`,children:[(0,K.jsxs)(Z,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(Fr,{className:`size-4 shrink-0`}),`Region `,t.fields.length>1?r+1:``]}),(0,K.jsx)(J,{children:(0,K.jsxs)(Xt,{onValueChange:t=>{e.onChange(t),n.trigger()},...e,children:[(0,K.jsx)(Kt,{className:`w-full`,children:(0,K.jsx)(Yt,{placeholder:`Choose Region`})}),(0,K.jsx)(Gt,{children:(0,K.jsx)(Jt,{children:u.map(e=>(0,K.jsx)(Ht,{value:e,disabled:!g(e),children:(0,K.jsxs)(`span`,{className:`flex items-center gap-2`,children:[e,a.regionNames.has(e)&&(0,K.jsx)(Wi,{children:`Premium`})]})},e))})})]})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:e,name:`regionPlans.${r}.latencyDescription`,render:({field:e})=>(0,K.jsxs)(X,{className:`flex-1`,children:[(0,K.jsxs)(Z,{children:[`Estimated `,d?`P95`:`P90`,` Latency, Distribution`]}),(0,K.jsx)(J,{children:(0,K.jsxs)(Xt,{onValueChange:t=>{e.onChange(t),n.trigger()},...e,disabled:!m?.length,children:[(0,K.jsx)(Kt,{className:`w-full`,children:(0,K.jsx)(Yt,{placeholder:`Choose Latency Tier`})}),(0,K.jsx)(Gt,{children:(0,K.jsx)(Jt,{children:m.map(e=>(0,K.jsx)(Ht,{value:e,disabled:!_(e),children:(0,K.jsxs)(`span`,{className:`flex items-center gap-2`,children:[e,(()=>{let t=i[f]?.[e]?.id;return t&&a.regionIds.has(t)&&(0,K.jsx)(Wi,{children:`Premium`})})()]})},e))})})]})}),(0,K.jsx)(Q,{})]})}),t?.fields?.length&&t?.fields?.length>1&&(0,K.jsx)(`div`,{className:`flex-none mt-6`,children:(0,K.jsxs)(F,{type:`button`,variant:`destructiveOutline`,size:`sm`,onClick:v,children:[(0,K.jsx)(di,{}),` `,(0,K.jsx)(`span`,{className:`sr-only`,children:`Remove`})]})}),(0,K.jsx)(_f,{selectedPlan:s,selectedRegion:i[f]?.[p],usageScale:o,isEnterprise:c,cloudProvider:l})]})}function bf({form:e,regionLocations:t,regionNameToLatencyToRegion:n,premiumOnlyRegions:r,usageScale:i,selectedPlan:a,totalPrice:o,isEnterprise:s,cloudProvider:c}){let l=e.watch(`regionPlans`),u=yt({control:e.control,name:`regionPlans`}),d=(0,q.useMemo)(()=>{let e=l.map(e=>n?.[e.regionName]?.[e.latencyDescription]?.region);return o?t?.find(t=>!e.includes(t.region)):null},[t,n,l,o]),f=(0,q.useCallback)(()=>{d&&(u.append({regionName:d.region,latencyDescription:d.latencyDescription}),e.trigger())},[e,d,u]);return t?.length?(0,K.jsxs)(K.Fragment,{children:[u.fields.map((t,o)=>(0,K.jsx)(yf,{control:e.control,fieldArray:u,form:e,index:o,regionNameToLatencyToRegion:n,premiumOnlyRegions:r,usageScale:i,selectedPlan:a,isEnterprise:s,cloudProvider:c},t.id)),d&&(0,K.jsx)(`div`,{className:`md:col-span-6 col-span-3`,children:(0,K.jsxs)(F,{type:`button`,variant:`positiveOutline`,onClick:f,children:[(0,K.jsx)(Ur,{}),`Add Additional Region Usage`]})})]}):(0,K.jsx)(`div`,{className:`md:col-span-6 col-span-3`,children:(0,K.jsx)(_i,{className:`mt-0 m-0`,title:`No Regions Available`,showReturnToHome:!1,error:{message:(0,K.jsxs)(K.Fragment,{children:[`The deployment type you selected currently has no available regions. Please try a different deployment type, try again later, or `,(0,K.jsx)(Wl,{}),`.`]})}})})}function xf({control:e,fieldArray:t,form:n,index:r}){let i=(0,q.useCallback)(()=>{t?.remove(r)},[t,r]);return(0,K.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,K.jsx)(Y,{control:e,name:`instances.${r}.secure`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsxs)(Z,{children:[`Instance `,t.fields.length>1?r+1:``]}),(0,K.jsx)(J,{children:(0,K.jsxs)(Xt,{...e,onValueChange:t=>{e.onChange(t),n.trigger()},children:[(0,K.jsx)(Kt,{className:`w-full`,children:(0,K.jsx)(Yt,{placeholder:`https://`})}),(0,K.jsx)(Gt,{children:(0,K.jsxs)(Jt,{children:[(0,K.jsx)(Ht,{value:`true`,children:`https://`}),(0,K.jsx)(Ht,{value:`false`,children:`http://`})]})})]})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:e,name:`instances.${r}.fqdn`,render:({field:e})=>(0,K.jsxs)(X,{className:`flex-3`,children:[(0,K.jsx)(Z,{children:`Host Name`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{...e,type:`text`,autoCapitalize:`none`,autoComplete:`off`,autoCorrect:`off`,onChange:t=>{e.onChange(t);let i=t.target.value,a=i===`localhost`||i===`127.0.0.1`,o=n.getFieldState(`instances.${r}.secure`);a&&!o.isDirty&&n.setValue(`instances.${r}.secure`,`false`)}})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:e,name:`instances.${r}.port`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Operations API Port`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{...e,type:`number`,min:0,max:Wd,autoCapitalize:`none`,autoComplete:`off`,autoCorrect:`off`,placeholder:String(c),onChange:t=>{e.onChange(t.target.value?parseInt(t.target.value,10):void 0),n.trigger()}})}),(0,K.jsx)(Q,{})]})}),t?.fields?.length&&t?.fields?.length>1&&(0,K.jsx)(`div`,{className:`flex-none mt-6`,children:(0,K.jsxs)(F,{type:`button`,variant:`destructiveOutline`,size:`sm`,onClick:i,children:[(0,K.jsx)(di,{}),` `,(0,K.jsx)(`span`,{className:`sr-only`,children:`Remove`})]})})]})}function Sf({form:e}){let t=yt({control:e.control,name:`instances`}),n=(0,q.useCallback)(()=>{t.append({secure:`true`,fqdn:``,port:c})},[t]);return(0,K.jsxs)(K.Fragment,{children:[t.fields.map((n,r)=>(0,K.jsx)(xf,{control:e.control,fieldArray:t,form:e,index:r},n.id)),(0,K.jsx)(`div`,{className:`md:col-span-6 col-span-3`,children:(0,K.jsxs)(F,{type:`button`,variant:`positiveOutline`,onClick:n,children:[(0,K.jsx)(Ur,{}),`Add Instance`]})})]})}function Cf(e,t){return!e.allowedRegionIds?.length||e.allowedRegionIds.includes(t)}function wf(e,t){let n=new Set,r=new Set;if(!e.length)return{regionNames:n,regionIds:r};let i=Math.min(...e.map(e=>e.planLevel??0)),a=e.filter(e=>(e.planLevel??0)===i),o=e.filter(e=>(e.planLevel??0)>i);if(!o.length)return{regionNames:n,regionIds:r};for(let[e,i]of Object.entries(t)){let t=!1,s=!0;for(let e of Object.values(i)){let n=a.some(t=>Cf(t,e.id)),i=o.some(t=>Cf(t,e.id));!n&&!i||(t=!0,n?s=!1:r.add(e.id))}t&&s&&n.add(e)}return{regionNames:n,regionIds:r}}function Tf({calculatedNames:e,clusterId:t,deploymentToPerformanceToPlan:n,form:r,harperVersions:i,isEnterprise:a,cloudProvider:o,isPending:s,mode:c,partialUpgrade:l,regionLocations:u,regionNameToLatencyToRegion:d,selectedDeployment:f,selectedPerformance:p,selectedPlan:m,totalPrice:h}){let{isDirty:g,isValid:_}=_t(),v=(0,q.useMemo)(()=>{let e=n[f]||{},t=Object.values(e).map(e=>e.planLevel??0),r=t.length?Math.min(...t):0;return Object.keys(e).map(t=>{let n=(e[t].planLevel??0)>r,i=t.slice(0,-1).split(`(`);if(i.length>1)return{performanceTier:t,name:i[0],description:i[1],isPremium:n};let a=t.split(` for `);return a.length>1?{performanceTier:t,name:a[0],description:`For `+a[1],isPremium:n}:{performanceTier:t,name:t,description:``,isPremium:n}})},[n,f]),y=(0,q.useMemo)(()=>Object.keys(n).sort(),[n]),b=(0,q.useMemo)(()=>wf(Object.values(n[f]||{}),d),[n,d,f]),x=(0,q.useMemo)(()=>hf(Object.values(n).flatMap(e=>Object.values(e)),d),[n,d]);(0,q.useEffect)(function(){v?.length&&!v.find(e=>e.performanceTier===p)&&(r.setValue(`performanceDescription`,v[0].performanceTier),r.trigger())},[f,p,v,r]);let S=f===`Self-Hosted`,C=(0,K.jsx)(zt,{className:`mt-3 mb-12`,children:(0,K.jsxs)(F,{type:`submit`,variant:`submit`,disabled:s||t&&!g&&!(c===`version`&&l)||!_,children:[c!==`version`&&h>0?`Confirm Payment Details`:t?`Edit Cluster`:`Create New Cluster`,(0,K.jsx)(Bn,{})]})});return c===`version`?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-3 items-start gap-6 text-foreground md:grid-cols-6`,children:[(0,K.jsx)(Qd,{className:i?.value?.length?`col-span-3`:`md:col-span-6 col-span-3`,disabled:!0,form:r}),(0,K.jsx)(nf,{className:`col-span-3`,form:r,harperVersions:i}),(0,K.jsx)(tf,{className:`col-span-3 md:col-span-6`,form:r}),l&&(0,K.jsxs)(`p`,{className:`col-span-3 md:col-span-6 max-w-prose text-xs font-light text-amber-600 dark:text-amber-400`,children:[l.behindCount,` of `,l.total,` instances`,` `,l.behindCount===1?`is`:`are`,` still on an older version. Re-run the upgrade to bring`,` `,l.behindCount===1?`it`:`them`,` up to `,l.latest,`.`]})]}),C]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-3 items-start gap-6 text-foreground md:grid-cols-6`,children:[(0,K.jsx)(Qd,{className:i?.value?.length?`col-span-3`:`md:col-span-6 col-span-3`,disabled:!!t,form:r}),(0,K.jsx)(nf,{className:`col-span-3`,disabled:!!t,form:r,harperVersions:i}),S?(0,K.jsx)(Zd,{form:r,disabled:!!t}):(0,K.jsx)(qd,{form:r,calculatedNames:e,disabled:!!t}),(0,K.jsx)(Xd,{form:r,availableDeploymentTypes:y}),(0,K.jsx)($d,{availablePerformanceDescriptions:v,form:r,selectedDeployment:f}),S?(0,K.jsx)(Sf,{form:r}):(0,K.jsx)(bf,{form:r,regionLocations:u,regionNameToLatencyToRegion:d,premiumOnlyRegions:b,usageScale:x,selectedPlan:m,totalPrice:h,isEnterprise:a,cloudProvider:o}),t&&!S&&(0,K.jsx)(tf,{className:`col-span-3 md:col-span-6`,form:r})]}),C]})}function Ef(e){let{fqdn:t}=e,{secure:n,port:r}=e;return r||=c,r===443&&n===`false`&&(n=`true`),r===80&&n===`true`&&(n=`false`),`${n===`true`?`https`:`http`}://${t}${r===443||r===80?``:`:`+r}`.toLowerCase()}function Df(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 Of(e,t,n){if(t&&n){let r=e.getValues();if(!r.deploymentDescription||!r.performanceDescription||!r.regionPlans.length){let i=Df(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 kf({price:e}){let t=new Intl.NumberFormat(`en-US`,{style:`currency`,currency:`USD`}).formatToParts(e||0);return(0,K.jsx)(`span`,{className:`text-4xl`,children:t.map((e,t)=>(0,K.jsx)(Af,{type:e.type,value:e.value},t))})}function Af({type:e,value:t}){switch(e){case`currency`:case`decimal`:case`fraction`:return(0,K.jsx)(`sup`,{className:`font-light text-xl`,children:t});default:return t}}function jf({alreadyUsingFree:e,clusterId:t,defaultValues:n,deploymentToPerformanceToPlan:r,harperVersions:i,mode:o,organization:s,organizationId:l,partialUpgrade:u,planTypes:d,regionLocationsColocated:f,regionLocationsDedicated:p,setSavedClusterState:m,startOffOnBilling:h}){let _=L(),v=ae(),y=s?.type===_u,b=s?.channel===`Akamai`?`linode`:void 0,x=ie(),{mutate:S,isPending:C}=du(),{mutate:w,isPending:T}=pu(),[E,D]=(0,q.useState)(h),O=(0,q.useMemo)(()=>cu(f?.sort(nu(`latencyDescription`))||[],`region`,`latencyDescription`),[f]),k=(0,q.useMemo)(()=>cu(p?.sort(nu(`latencyDescription`))||[],`region`,`latencyDescription`),[p]),A=(0,q.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=Ef(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`?k:O;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!`}):yu(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,O,k,r]),j=dt({mode:`onChange`,resolver:Fe(Kd.superRefine(A)),defaultValues:n}),[M,N]=(0,q.useState)(!0);(0,q.useEffect)(()=>{M&&n&&(m(null),N(!1))},[n,M,m]);let P=j.watch(`clusterName`),F=j.watch(`abbreviatedName`),ee=j.watch(`deploymentDescription`),te=j.watch(`performanceDescription`),I=j.watch(`regionPlans`),ne=j.watch(`instances`),re=ee===`Dedicated`?k:O,R=ee===`Dedicated`?p:f;(0,q.useEffect)(function(){let e=j.getValues();ee&&(ee===`Self-Hosted`?(e.abbreviatedName&&j.setValue(`abbreviatedName`,``),e.regionPlans.length&&j.setValue(`regionPlans`,[]),e.instances.length||j.setValue(`instances`,[{secure:`true`,fqdn:``,port:c}])):(e.fqdn&&j.setValue(`fqdn`,``),e.instances.length&&j.setValue(`instances`,[]),e.regionPlans.length||Of(j,d,R)))},[j,d,R,ee]);let z=(0,q.useMemo)(()=>{let e=vu(bu(P),Gd.maxLength);return{suggestedAbbreviatedName:e,fullHostName:`${F||e}.${s.subdomain||`your-org`}.harperfabric.com`}},[P,F,s]),oe=(0,q.useMemo)(()=>r?.[ee]?.[te],[r,ee,te]);(0,q.useEffect)(function(){let e=oe?.allowedRegionIds;if(e?.length&&I?.length===1){let t=I[0],n=re?.[t.regionName]?.[t.latencyDescription];if(!e.includes(n?.id)){let t=R?.filter(t=>e.includes(t.id)),n=t?.find(e=>e.region===`US`)||t?.[0];n&&(j.setValue(`regionPlans.0.regionName`,n.region),j.setValue(`regionPlans.0.latencyDescription`,n.latencyDescription),j.trigger())}}},[oe,I,j,re,R]),(0,q.useEffect)(function(){if(ee!==`Self-Hosted`&&Object.keys(re).length&&I.length)for(let e=0;e<I.length;e++){let t=I[e];re[t.regionName]||j.setValue(`regionPlans.${e}.regionName`,``)}},[j,re,ee,I]);let se=oe?.priceUsd?ee===`Self-Hosted`?ne.length*oe.priceUsd:I.reduce((e,t)=>{let n=re?.[t.regionName]?.[t.latencyDescription];return e+(n?oe.priceUsd*n.instanceCount/2:0)},0):0,ce=oe?.planLimits?.expirationMonths,le=xu(ce)&&ce<1e3?ce:void 0,ue=le?se/le:se,de=(0,q.useCallback)(({creating:e,deploymentDescription:t})=>U.message(e?`Creating Cluster`:`Updating Cluster`,{description:(0,K.jsx)(lu,{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:0}),[]),fe=(0,q.useCallback)(async({clusterId:e,sourceClusterId:t,creating:n,toastId:r,isSelfManaged:i,skipGtmWait:a})=>{if(t){let e=(await hu(l)).clusters?.find(e=>e.id===t);Vo(e?.status)&&await Nl(t)}x.invalidateQueries({queryKey:[l],refetchType:`active`}),n||Su(x,e,{refetchType:`active`}),v.invalidate(),_(i?{to:`/${l}/${e}/instances`}:n?{to:`/${l}/${e}/starting-up`}:{to:`/${l}/${e}/scaling`,search:a?{immediate:!0}:void 0}),j.reset(),U.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})},[x,v,_,l,j]),pe=(0,q.useCallback)(async()=>{let e=j.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=re[t.regionName][t.latencyDescription];n.push({autoRenew:!0,planId:i.id,regionId:e.id})}m(null);let s=de({creating:!t,deploymentDescription:e.deploymentDescription}),c=()=>U.dismiss(s);t?w(o===`version`?{id:t,version:e.version,skipGtmWait:e.skipGtmWait}:{id:t,regionPlans:n,skipGtmWait:e.skipGtmWait},{onSuccess:t=>fe({clusterId:t.id,sourceClusterId:e.sourceClusterId,isSelfManaged:a,creating:!1,toastId:s,skipGtmWait:e.skipGtmWait}),onError:c}):S({abbreviatedName:a?void 0:e.abbreviatedName||z.suggestedAbbreviatedName,autoRenew:!0,fqdn:a&&e.fqdn||void 0,name:e.clusterName,version:e.version,organizationId:l,regionPlans:n},{onSuccess:t=>fe({clusterId:t.id,sourceClusterId:e.sourceClusterId,isSelfManaged:a,creating:!0,toastId:s}),onError:c})},[z.suggestedAbbreviatedName,t,r,j,fe,de,l,re,m,w,S]),me=(0,q.useCallback)(()=>{if(o!==`version`&&se>0){D(!0);return}return pe()},[o,pe,se]),he=(0,q.useCallback)(e=>{m(e?{clusterId:t,...j.getValues(),skipToBilling:!0}:null)},[t,j,m]),ge=(0,q.useCallback)(()=>{D(!1)},[]),B=!y&&`mr-37.5`;return(0,K.jsxs)(K.Fragment,{children:[!y&&o!==`version`&&(0,K.jsxs)(`div`,{className:`absolute top-3 right-4 md:right-12 flex flex-col items-end text-right`,children:[(0,K.jsx)(`dt`,{className:`font-light`,children:le?`Monthly Price`:`Total Price`}),(0,K.jsx)(`dd`,{className:`font-bold`,children:se>0?(0,K.jsxs)(`span`,{className:`inline-flex items-baseline`,children:[(0,K.jsx)(kf,{price:ue}),!!le&&(0,K.jsxs)(`span`,{className:`font-light text-base text-muted-foreground`,children:[`/mo`,le>1&&(0,K.jsx)(`sup`,{children:`*`})]})]}):(0,K.jsx)(`span`,{className:`text-4xl text-green`,children:`Free`})})]}),(0,K.jsx)(Do,{...j,children:E?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`h1`,{className:g(`text-lg leading-none text-foreground font-semibold mb-4`,B),children:`Cluster Billing`}),(0,K.jsx)(`p`,{className:g(`text-muted-foreground text-sm mb-2`,B),children:`Please confirm the following billing details:`}),(0,K.jsx)(Hd,{clusterId:t,isPending:C||T,onGoBackToDetails:ge,onSaveStateForBillingRedirect:he,onSubmit:pe,organizationId:l,selectedPlan:oe})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`h1`,{className:g(`text-lg leading-none text-foreground font-semibold mb-4`,B),children:`Cluster Configuration`}),(0,K.jsxs)(`div`,{className:g(`mb-6 flex flex-col items-start gap-2`,B),children:[(0,K.jsx)(`p`,{className:`sr-only`,children:`Configure your Harper cluster and define deployment plans.`}),!y&&o!==`version`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Wi,{variant:`warning`,children:`Beta pricing subject to change.`}),!!le&&le>1&&se>0&&(0,K.jsxs)(`p`,{className:`max-w-prose text-xs font-light text-muted-foreground`,children:[`* Billed as`,` `,new Intl.NumberFormat(`en-US`,{style:`currency`,currency:`USD`}).format(se),` `,`every`,` `,a(le,`month`,`months`),`, or sooner if you reach a usage limit — then a new license is issued.`]})]})]}),(0,K.jsx)(`form`,{id:`cluster-upsert-form`,name:`cluster-upsert-form`,onSubmit:j.handleSubmit(me),children:(0,K.jsx)(Tf,{calculatedNames:z,clusterId:t,deploymentToPerformanceToPlan:r,form:j,isPending:C||T,harperVersions:i,mode:o,partialUpgrade:u,regionLocations:R,regionNameToLatencyToRegion:re,selectedDeployment:ee,selectedPerformance:te,selectedPlan:oe,totalPrice:se,isEnterprise:y,cloudProvider:b})})]})})]})}function Mf(e){return e?.clusterName!==void 0}function Nf(e){let t=e.filter(e=>!!e&&!(e.status!=null&&No.includes(e.status))).map(e=>e.version).filter(e=>!!e);if(t.length<2)return null;let n=t.reduce((e,t)=>tn(t,e)>0?t:e),r=t.filter(e=>e!==n).length;return r>0?{latest:n,behindCount:r,total:t.length}:null}function Pf({isEdit:e,className:t,children:n}){return e?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Ks,{}),(0,K.jsx)(Kl,{children:(0,K.jsx)(`div`,{className:t,children:n})})]}):(0,K.jsx)(Gl,{className:t,children:n})}function Ff(){let{organizationId:e,clusterId:t,mode:n}=B({strict:!1}),{create:r,update:i}=ml(e),{organization:a,cluster:o}=de({strict:!1}),[s,c]=Tn(Sn.SavedClusterState,null),{data:l}=H(Jl(e)),{data:u}=H(tu({availableHosts:!0,organizationId:e})),{data:d}=H(tu({organizationId:e})),{data:f}=H($l(e)),p=(0,q.useMemo)(()=>{if(o){let e=o.instances?.map(e=>e.version).filter(kn);if(f&&e){let t=[...e].sort(tn).pop(),n=new Set(e);return{...f,value:[!!t&&{name:`current`,version:t},...(f?.value||[]).filter(e=>!n.has(e.version)&&(!t||$t(t,e.version)))].filter(kn)}}}return f},[f,o]),m=(0,q.useMemo)(()=>Nf(o?.instances??[]),[o]),h=(0,q.useMemo)(()=>{for(let e of a?.clusters??[])if(e.id!==o?.id&&l&&!Ho(e.status)&&!Vo(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]),g=(0,q.useMemo)(()=>cu(l?.sort(nu(`priceUsd`))||[],`deploymentDescription`,`performanceDescription`),[l]),_=(0,q.useMemo)(()=>{if(!l||!p||!u||!d||t&&!o)return null;let e=o;if(s){if(Mf(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=Df(l,a,h),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&&!No.includes(e.status)).sort(au);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 m=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:m,deploymentDescription:n?.deploymentDescription??c?.deploymentDescription??``,performanceDescription:n?.performanceDescription??c?.performanceDescription??``,fqdn:f?e?.fqdn??``:``,instances:i,regionPlans:r}},[h,o,t,l,p,u,d,s]);return!_||!a||!l||!u||!d?(0,K.jsx)(Pf,{isEdit:!!t,children:(0,K.jsx)(Bi,{centered:!0,text:`Loading...`})}):(o?.id?!i:!r)?(0,K.jsx)(Pf,{isEdit:!!t,children:(0,K.jsx)(_i,{title:`Not Allowed`,error:{message:(0,K.jsxs)(K.Fragment,{children:[`You do not have permission to `,o?.id?`update`:`create`,` clusters in this org.`]})}})}):l.length===0?(0,K.jsx)(Pf,{isEdit:!!t,children:(0,K.jsx)(_i,{title:`Cluster ${t?`Modification`:`Creation`} Not Currently Allowed`,error:{message:(0,K.jsxs)(K.Fragment,{children:[`There are no available deployment types right now! Please try again later, or `,(0,K.jsx)(Wl,{}),`.`]})}})}):(0,K.jsx)(Pf,{isEdit:!!t,className:`max-w-4xl mx-auto`,children:(0,K.jsx)(jf,{alreadyUsingFree:h,clusterId:t,defaultValues:_,deploymentToPerformanceToPlan:g,harperVersions:p,mode:n,organization:a,organizationId:e,partialUpgrade:m,planTypes:l,regionLocationsColocated:u,regionLocationsDedicated:d,setSavedClusterState:c,startOffOnBilling:Mf(s)&&s.skipToBilling===!0})})}function If({children:e}){let{organizationId:t}=B({strict:!1}),{view:n}=fl(t),{update:r}=ul(t),i=`/${t}`,a=[{to:i,label:`Clusters`,icon:Zr,exact:!0},n&&{to:`${i}/users`,label:`Users`,icon:hi},n&&{to:`${i}/roles`,label:`Roles`,icon:$r},r&&{to:`${i}/billing`,label:`Billing`,icon:cr,children:[{to:`${i}/billing`,label:`Payment Method`,exact:!0},{to:`${i}/billing/invoices`,label:`Invoices`}]},r&&{to:`${i}/settings`,label:`Settings`,icon:Qr}].filter(Boolean);return(0,K.jsx)(`div`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-(--spacing(32)))]`,children:(0,K.jsxs)(`div`,{className:`md:grid gap-6 md:grid-cols-12`,children:[(0,K.jsx)(`aside`,{className:`md:col-span-3 lg:col-span-2 mb-4 md:mb-0`,children:(0,K.jsx)(Fi,{items:a,ariaLabel:`Organization sections`})}),(0,K.jsx)(`section`,{className:`md:col-span-9 lg:col-span-10 min-w-0`,children:e})]})})}var Lf={FAILED:0,UPDATING:1,PROVISIONING:2,RUNNING:3,TERMINATED:4},Rf=Lf.RUNNING;function zf(e,t){return e.status===t.status?e.name.localeCompare(t.name):(e.status?Lf[e.status]??Rf:Rf)-(t.status?Lf[t.status]??Rf:Rf)}function Bf(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 Vf(){let{organizationId:e}=B({strict:!1}),{create:t}=ml(e),{data:n,isSuccess:r}=le(gu(e)),[i]=Tn(Sn.SavedClusterState,null),[a,o]=(0,q.useState)(``),s=(0,q.useCallback)(()=>o(``),[]),c=(0,q.useCallback)(e=>{o(e.currentTarget.value?.toLowerCase()||``)},[]),l=(0,q.useMemo)(()=>n?.clusters?.slice().filter(e=>!Ho(e.status)).sort(zf)||[],[n?.clusters]),u=(0,q.useMemo)(()=>l.filter(Bf([`id`,`name`],a))||[],[a,l]);return n&&l.length===0&&t?(0,K.jsx)(Ff,{}):i?(0,K.jsx)(ne,{to:`/${e}/new-cluster`}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Ks,{children:r&&t&&(0,K.jsx)(`div`,{className:`flex w-full justify-end`,children:(0,K.jsx)(V,{to:`new-cluster`,children:(0,K.jsxs)(F,{variant:`positive`,accessKey:`n`,children:[(0,K.jsx)(Ur,{}),` `,(0,K.jsxs)(`span`,{className:`hidden sm:inline-block`,children:[(0,K.jsx)(`u`,{children:`N`}),`ew `,(0,K.jsx)(`span`,{className:`hidden md:inline-block`,children:`Cluster`})]})]})})})}),(0,K.jsxs)(If,{children:[(0,K.jsxs)(`div`,{className:`relative mb-6 w-full`,children:[(0,K.jsx)(Xr,{className:`pointer-events-none absolute left-0 top-1/2 size-4 -translate-y-1/2 text-muted-foreground`}),(0,K.jsx)($,{placeholder:`Filter by name`,className:`w-full rounded-none border-0 border-b border-border bg-transparent dark:bg-transparent pl-6 shadow-none focus-visible:border-primary focus-visible:ring-0`,value:a,onChange:c})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-9 mb-4`,children:[u.map(e=>(0,K.jsx)(`div`,{className:`col-span-1 md:col-span-3 xl:col-span-3 2xl:col-span-2`,children:(0,K.jsx)(Ul,{cluster:e})},e.id)),!u.length&&(0,K.jsxs)(`div`,{className:`col-span-1 md:col-span-9 text-center`,children:[(0,K.jsx)(`h2`,{className:`my-4 text-xl`,children:`No matches found.`}),(0,K.jsx)(F,{type:`button`,variant:`outline`,onClick:s,children:`Clear Filters`})]})]})]})]})}function Hf(){return`/#`+eo()}function Uf(){let{organizationId:e}=B({strict:!1}),t=L(),n=new URLSearchParams(window.location.search).get(`setup_intent_client_secret`),{setup_intent_client_secret:r}=se({strict:!1}),[i]=Tn(Sn.SavedClusterState,null),a=n||r,o=ld(),s=Tu(e),c=(0,q.useCallback)(()=>{let e=i?i.clusterId?`../../${i.clusterId}/edit`:`../../new-cluster`:`../`;window.history.replaceState(null,``,Hf()),t({search:void 0,to:e})},[t,i]);return(0,q.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?(U.error(`Failed to process payment method details. Please try another payment method.`),c()):s(e.payment_method,c);break;case`processing`:U.warning(`Processing payment method. Please check back later.`),c();break;case`requires_payment_method`:U.error(`Failed to process payment method details. Please try another payment method.`),c();break;default:U.error(`Failed to process payment method details. Please try another payment method.`),c()}}catch(e){console.error(e),U.error(`Failed to process payment method details. Please try another payment method.`),c()}})()},[a,c,e,s,o]),(0,K.jsx)(Bi,{centered:!0})}function Wf(){return(0,K.jsx)(Fd,{children:(0,K.jsx)(Uf,{})})}function Gf(){let{organizationId:e}=B({strict:!1}),{update:t}=ul(e);return t?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Ks,{}),(0,K.jsx)(If,{children:(0,K.jsx)(Ce,{})})]}):(0,K.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 Kf({columns:e,data:t,isFetching:n,onRowClick:r,onColumnClick:i,sortingState:a,children:o}){let s=be({features:Nn,data:t,columns:e,initialState:{sorting:a??[]}});return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-end space-x-2 pb-4`,children:[(0,K.jsx)(`div`,{className:`grow lg:hidden`}),o,(0,K.jsx)(`div`,{className:`grow hidden lg:visible`})]}),(0,K.jsxs)(fn,{containerClassName:`rounded-md bg-card dark:bg-black-dark`,children:[(0,K.jsx)(ln,{children:s.getHeaderGroups().map(e=>(0,K.jsx)(dn,{className:`border-none`,children:e.headers.map(e=>(0,K.jsx)(rn,{header:e,onColumnClick:i},e.id))},e.id))}),(0,K.jsx)(cn,{className:`bg-background dark:bg-black border border-border dark:border-grey-700`,children:s.getRowModel().rows?.length?s.getRowModel().rows.map(e=>(0,K.jsx)(dn,{"data-state":e.getIsSelected()&&`selected`,onClick:()=>r?.(e),className:P(`hover:bg-muted/10 data-[state=selected]:bg-muted`,r&&`cursor-pointer`),children:e.getVisibleCells().map(e=>(0,K.jsx)(un,{className:`py-2 px-2 overflow-x-hidden max-w-32 text-ellipsis whitespace-nowrap`,style:{width:`${e.column.getSize()}px`},children:_e(e.column.columnDef.cell,e.getContext())},e.id))},e.id)):(0,K.jsx)(dn,{children:(0,K.jsx)(un,{colSpan:e.length,className:`h-24 text-center`,children:n?(0,K.jsx)(`div`,{children:(0,K.jsx)(Bi,{className:`p-12`})}):(0,K.jsx)(`span`,{children:`No results.`})})})})]})]})}function qf(e){switch(e){case`paid`:return`success`;case`void`:case`uncollectible`:return`destructive`;default:return`default`}}function Jf(e){return new Intl.NumberFormat(`en-US`,{style:`currency`,currency:`USD`}).format(e)}function Yf(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 Xf=[{header:`Invoice Id`,accessorKey:`id`,enableSorting:!1},{header:`Status`,accessorKey:`status`,enableSorting:!1,cell:({cell:e})=>(0,K.jsx)(Wi,{variant:qf(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?Yf(r,t):[t?Yf(r,t):`-`,n?Yf(i,n):`-`].join(` to `)}},{header:`Amount Due`,accessorKey:`amountDue`,enableSorting:!1,cell:({cell:e})=>Jf(e.getValue()?e.getValue()/100:0)},{header:`Amount Paid`,accessorKey:`amountPaid`,enableSorting:!1,cell:({cell:e})=>Jf(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} @ ${Jf(e.amount/100)}`);return n.join(`
|
|
12
|
-
`)}}];function Zf(e){return(0,q.useCallback)(async()=>{U.loading(`Refreshing...`,{id:`refreshing`});let t=Date.now();await e(),Date.now()-t<500&&await i(500),U.success(`Refreshed!`,{id:`refreshing`})},[e])}async function Qf(e){let{data:t}=await N.get(`/Invoice/${e}`);return t}function $f(e,t){return z({queryKey:[e,`invoices`],queryFn:()=>Qf(e),retry:!1,enabled:!!e,refetchInterval:t?1e4:void 0})}function ep(){let{organizationId:e}=B({strict:!1}),{data:t}=H(gu(e)),{data:n,refetch:r,isLoading:i,isFetching:a,isRefetching:o}=H($f(t?.type!==`ENTERPRISE`&&t?.id,!1)),s=Zf(r);return t?.type===`ENTERPRISE`?(0,K.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,K.jsx)(Wl,{}),`, we would love to talk!`]}):i?(0,K.jsx)(Bi,{centered:!0}):!n||!n.length?(0,K.jsxs)(`span`,{children:[`Your invoices will be shown here once one is available! Want to explore your solution with Harper more?`,` `,(0,K.jsx)(Wl,{overEmail:!0}),`, we would love to talk!`]}):(0,K.jsx)(Kf,{data:n,columns:Xf,children:(0,K.jsxs)(F,{variant:`defaultOutline`,onClick:s,accessKey:`r`,disabled:a||o,children:[(0,K.jsx)(Wr,{}),(0,K.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,K.jsx)(`u`,{children:`R`}),`efresh`]})]})})}function tp(e){let t=I({getParentRoute:()=>e,path:`billing`,head:()=>({meta:[{title:`Billing — Harper Fabric`}]}),component:Gf}),n=I({getParentRoute:()=>t,path:`/`,head:()=>({meta:[{title:`Payment Methods — Harper Fabric`}]}),component:Vd}),r=I({getParentRoute:()=>t,path:`invoices`,head:()=>({meta:[{title:`Invoices — Harper Fabric`}]}),component:ep}),i=I({getParentRoute:()=>t,path:`confirm`,head:()=>({meta:[{title:`Confirm Payment — Harper Fabric`}]}),component:Wf});return t.addChildren([n,r,i])}async function np(e){let{data:t}=await N.get(`/OrganizationRole/${e}`);return t}function rp(e){return z({queryKey:[e,`roles`],queryFn:()=>np(e),retry:!1,refetchInterval:jn(1e4)})}var ip=Mn(),ap=[{header:`Role Name`,accessorKey:`roleName`,enableSorting:!1},ip.display({header:`ID`,id:`id`,enableSorting:!1,cell:e=>(0,K.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,title:e.row.original.id,children:e.row.original.id})}),ip.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 op(e){let{data:t}=await N.post(`/Role/`,e);return t}function sp(){return R({mutationFn:op})}var cp=y({name:M().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:S(),delete:S()});y({roles:y({create:S(),delete:S(),update:S(),view:S()}),clusters:y({create:S(),delete:S(),update:S(),view:S(),resources:k(y({id:M(),delete:S(),update:S(),view:S(),instances:y({create:S(),delete:S(),update:S(),view:S()})}))})});function lp(){let[e]=Da(),t=wa();return e===`dark`||e===`system`&&t===`dark`?`vs-dark`:`light`}var up=(0,q.lazy)(async()=>(await Te(()=>import(`./setup-CiEALLa7.js`),__vite__mapDeps([21,4,1,22,23,24,25,26,27,28,29])),{default:(await Te(()=>import(`./dist-cY0BPcz0.js`),__vite__mapDeps([22,1,4]))).default}));function dp(e){return(0,K.jsx)(q.Suspense,{fallback:e.loading??null,children:(0,K.jsx)(up,{...e})})}var fp={roles:{create:!0,view:!0,update:!0,delete:!0},clusters:{create:!0,view:!0,update:!0,delete:!0,resources:[]}};function pp({isModalOpen:e,setIsModalOpen:t}){let n=lp(),r=ie(),{organizationId:i}=B({strict:!1}),[a,o]=(0,q.useState)(!0),[s,c]=(0,q.useState)(JSON.stringify(fp,null,2)),{mutate:l,isPending:u}=sp(),d=dt({resolver:Fe(cp),defaultValues:{name:``,update:!1,delete:!1}}),f=(0,q.useCallback)(e=>{o(e.length===0)},[o]),p=(0,q.useCallback)(async e=>{let n=xn(s);if(!n)return;let o={...e,...n,organizationId:i};e&&a&&l(o,{onSuccess:()=>{U.success(`Organization role added successfully!`),t(!1),r.invalidateQueries({queryKey:[i,`roles`],refetchType:`active`}),d.reset()},onError:e=>{U.error(`Failed to add organization role: ${e.message}`)}})},[a,s,l,d,r,t,i]);return(0,K.jsx)(Rt,{onOpenChange:t,open:e,children:(0,K.jsxs)(Ut,{resizable:!0,children:[(0,K.jsx)(qt,{children:`Add New Organization Role`}),(0,K.jsx)(Zt,{children:`Set the new organization role permissions.`}),(0,K.jsx)(Do,{...d,children:(0,K.jsxs)(`form`,{id:`org-add-role-form`,name:`org-add-role-form`,className:`flex flex-1 min-h-0 flex-col gap-4 my-4`,onSubmit:d.handleSubmit(p),children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,K.jsx)(Y,{control:d.control,name:`name`,render:({field:e})=>(0,K.jsxs)(X,{className:`col-span-2`,children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Role Name`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`text`,className:``,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:d.control,name:`update`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Can Update Organization`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`checkbox`,className:`w-6 ml-2`,checked:e.value,onChange:t=>e.onChange(t.target.checked)})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:d.control,name:`delete`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Can Delete Organization`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`checkbox`,className:`w-6 ml-2`,checked:e.value,onChange:t=>e.onChange(t.target.checked)})}),(0,K.jsx)(Q,{})]})})]}),(0,K.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,K.jsx)(dp,{className:`w-full h-full`,theme:n,defaultLanguage:`json`,onValidate:f,onChange:e=>{e&&c(e)},options:{automaticLayout:!0},defaultValue:JSON.stringify(fp,null,2)})}),(0,K.jsx)(zt,{children:(0,K.jsxs)(`div`,{className:`flex justify-between w-full`,children:[(0,K.jsx)(F,{variant:`destructiveOutline`,type:`button`,onClick:()=>t(!1),disabled:u,children:`Cancel`}),(0,K.jsx)(F,{variant:`submit`,disabled:u||!a||!d.formState.isValid,children:`Save Changes`})]})})]})})]})})}async function mp({roleId:e}){let{data:t}=await N.delete(`/Role/${e}`,{id:e,deleted:!0});return t}function hp(){return R({mutationFn:({roleId:e})=>mp({roleId:e})})}async function gp({roleId:e,updatedRoleInfo:t}){let{data:n}=await N.put(`/Role/${e}`,t);return n}function _p(){return R({mutationFn:({roleId:e,updatedRoleInfo:t})=>gp({roleId:e,updatedRoleInfo:t})})}function vp({organizationId:e,roleId:t}){return z({queryKey:[e,`roles`,t],queryFn:()=>yp(t),refetchInterval:jn(1e4),retry:On()})}async function yp(e){let{data:t}=await N.get(`/Role/${e}`);return t}function bp({onRoleDeleteClick:e,setIsConfirmingRoleDeletion:t,isRoleDeletionPending:n}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(qt,{children:`Confirm Role Deletion`}),(0,K.jsx)(Zt,{children:`Are you sure you want to delete this role? This action cannot be undone.`}),(0,K.jsxs)(zt,{children:[(0,K.jsx)(F,{type:`button`,variant:`defaultOutline`,onClick:()=>t(!1),children:`Cancel`}),(0,K.jsx)(F,{variant:`destructiveOutline`,onClick:e,disabled:n,children:n?`Deleting...`:`Delete Role`})]})]})}function xp({data:e,isModalOpen:t,closeModal:n}){let r=(0,q.useCallback)(()=>n(!1),[n]);return(0,K.jsx)(Rt,{onOpenChange:r,open:t,children:(0,K.jsx)(Ut,{resizable:!0,children:(0,K.jsx)(q.Suspense,{fallback:(0,K.jsx)(Sp,{roleName:e.roleName}),children:(0,K.jsx)(Cp,{data:e,closeModal:n})})})})}function Sp({roleName:e}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(qt,{children:[`Organization Role "`,e,`"`]}),(0,K.jsx)(Bi,{centered:!0,text:`Loading role…`,className:`flex-1 min-h-0`})]})}function Cp({data:e,closeModal:t}){let n=ie(),{data:r}=le(vp({roleId:e.id,organizationId:e.organizationId})),i=je().user?.roles?.[e.organizationId]?.id===e.id,{update:a,remove:o}=fl(e.organizationId),{mutate:s,isPending:c}=_p(),{mutate:l,isPending:u}=hp(),d=lp(),[f,p]=(0,q.useState)(!1),m=dt({resolver:Fe(cp),defaultValues:{name:e.roleName,update:r.organization.update||!1,delete:r.organization.delete||!1}}),h=(0,q.useCallback)(()=>{l({roleId:e.id},{onSuccess:()=>{U.success(`Role deleted successfully!`),t(!0),m.reset()},onError:e=>{U.error(`Error`,{description:`Failed to delete role: ${e instanceof Error?e.message:String(e)}.`,action:{label:`Dismiss`,onClick:()=>U.dismiss()}})}})},[e.id,l,m,t]),[g,_]=(0,q.useState)(!0),v=(0,q.useMemo)(()=>JSON.stringify({roles:{...r.organization.roles},clusters:{...r.organization.clusters}},null,2),[r]),[y,b]=(0,q.useState)(v),x=y!==v,S=(0,q.useCallback)(e=>{_(e.length===0)},[_]),C=(0,q.useCallback)(async r=>{if(!a)return;let i=xn(y);if(!i)return;let o={...r,...i,organizationId:e.organizationId};y&&g&&s({roleId:e.id,updatedRoleInfo:o},{onSuccess:async()=>{U.success(`Role updated successfully!`),await n.invalidateQueries({queryKey:[e.organizationId,`roles`,e.id]}),t(!1),m.reset()},onError:e=>{U.error(`Error`,{description:`Failed to update role: ${e instanceof Error?e.message:String(e)}.`,action:{label:`Dismiss`,onClick:()=>U.dismiss()}})}})},[t,e.id,e.organizationId,m,g,n,r,a,y,s]);return f?(0,K.jsx)(bp,{onRoleDeleteClick:h,setIsConfirmingRoleDeletion:p,isRoleDeletionPending:u}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(qt,{children:[i||!a?`View`:`Edit`,` Organization Role "`,e.roleName,`"`]}),(0,K.jsx)(Do,{...m,children:(0,K.jsxs)(`form`,{id:`org-edit-role-form`,name:`org-edit-role-form`,className:`flex flex-1 min-h-0 flex-col gap-4 my-4`,onSubmit:m.handleSubmit(C),children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,K.jsx)(Y,{control:m.control,name:`name`,render:({field:e})=>(0,K.jsxs)(X,{className:`col-span-2`,children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Role Name`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`text`,className:``,...e,disabled:!0,readOnly:!0})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:m.control,name:`update`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Can Update Organization`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`checkbox`,className:`w-6 ml-2`,disabled:i||!a,readOnly:i||!a,checked:e.value,onChange:t=>e.onChange(t.target.checked)})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:m.control,name:`delete`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Can Delete Organization`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`checkbox`,className:`w-6 ml-2`,disabled:i||!a,readOnly:i||!a,checked:e.value,onChange:t=>e.onChange(t.target.checked)})}),(0,K.jsx)(Q,{})]})})]}),(0,K.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,K.jsx)(dp,{className:`w-full h-full`,theme:d,defaultLanguage:`json`,onValidate:S,onChange:e=>{e&&b(e)},options:{readOnly:i||!a,automaticLayout:!0},defaultValue:y})}),!i&&(o||a)&&(0,K.jsx)(zt,{children:(0,K.jsxs)(`div`,{className:`flex justify-between w-full`,children:[o&&(0,K.jsx)(F,{type:`button`,variant:`destructiveOutline`,onClick:()=>p(!0),disabled:c,children:`Delete Role`}),a&&(0,K.jsx)(F,{variant:`submit`,disabled:!g||c||!m.formState.isValid||!m.formState.isDirty&&!x,children:`Save Changes`})]})})]})})]})}function wp(){let e=L(),t=ie(),{organizationId:n,orgRoleId:r}=B({strict:!1}),{create:i}=fl(n),{data:a,refetch:o,isFetching:s,isRefetching:c}=le(rp(n)),l=(0,q.useMemo)(()=>a&&a?.find(e=>e.id===r),[a,r]),u=!!r&&!!l,[d,f]=(0,q.useState)(!1),p=(0,q.useCallback)(async(i,a)=>{let o=[r?`..`:``,i].filter(Boolean);await e({to:o.join(`/`)}),a&&await t.invalidateQueries({queryKey:[n,`roles`],refetchType:`active`})},[r,e,t]),m=(0,q.useCallback)(()=>{f(!0)},[f]),h=(0,q.useCallback)(e=>p(e.original.id,!1),[p]),g=(0,q.useCallback)(e=>p(void 0,e),[p]),_=Zf(o);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Ks,{}),(0,K.jsx)(If,{children:(0,K.jsxs)(q.Suspense,{fallback:(0,K.jsx)(Bi,{className:`flex flex-col items-center justify-center h-full`,text:`Loading...`}),children:[(0,K.jsxs)(Kf,{data:a,columns:ap,onRowClick:h,children:[(0,K.jsxs)(F,{variant:`defaultOutline`,onClick:_,accessKey:`r`,disabled:s||c,children:[(0,K.jsx)(Wr,{}),(0,K.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,K.jsx)(`u`,{children:`R`}),`efresh`]})]}),i&&(0,K.jsxs)(F,{variant:`positiveOutline`,onClick:m,accessKey:`a`,disabled:d,children:[(0,K.jsx)(Ur,{}),(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`u`,{children:`A`}),`dd`]})]})]}),i&&(0,K.jsx)(pp,{isModalOpen:d,setIsModalOpen:f}),u&&(0,K.jsx)(xp,{data:l,isModalOpen:u,closeModal:g},l.id)]})})]})}function Tp({className:e,...t}){return(0,K.jsx)(Ye,{"data-slot":`switch`,className:P(`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-grey-500 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,K.jsx)(Re,{"data-slot":`switch-thumb`,className:P(`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 Ep(e){return`//oauth/${e}/login`}async function Dp(e,t){let{data:n}=await N.patch(`/Organization/${e}/settings/oauth`,t);return n}var Op=y({domain:M().min(1,`Domain is required`),clientId:M().min(1,`Client ID is required`),clientSecret:M().min(1,`Client secret is required`),scope:M().optional()}),kp=y({domain:M().min(1,`Domain is required`),clientId:M().optional(),clientSecret:M().optional(),scope:M().optional()});function Ap(){let{organizationId:e}=B({strict:!1}),{user:t}=je(),{update:n}=ul(e),{data:r}=le(gu(e)),i=ie(),[a,o]=(0,q.useState)(!1),[s,c]=(0,q.useState)(null),l=r.settings?.oauthConfigs??[],{mutate:u,isPending:d}=R({mutationFn:t=>Dp(e,t),onSuccess:()=>void i.invalidateQueries({queryKey:[e]}),onError:()=>U.error(`Failed to update OAuth settings.`)}),f=dt({resolver:Fe(Op),defaultValues:{domain:``,clientId:``,clientSecret:``,scope:`openid email profile`}}),p=e=>{u({provider:`okta`,...e},{onSuccess:()=>{U.success(`OAuth provider added.`),f.reset(),o(!1)}})},m=dt({resolver:Fe(kp)}),h=e=>{c(e.id??null),m.reset({domain:e.domain,clientId:``,clientSecret:``,scope:e.scope??``})},g=(e,t)=>{let n={id:e.id,provider:e.provider,domain:t.domain,scope:t.scope};t.clientId&&(n.clientId=t.clientId),t.clientSecret&&(n.clientSecret=t.clientSecret),u(n,{onSuccess:()=>{U.success(`OAuth provider updated.`),c(null)}})},_=(e,t)=>{u({id:e.id,provider:e.provider,[t]:!e[t]})},v=e=>`//oauth/${e}/callback`,y=async e=>{await zl(e)&&U.success(`Sign-in URL copied.`)},b=async e=>{await zl(e)&&U.success(`Redirect URI copied.`)};return n?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Ks,{}),(0,K.jsx)(If,{children:(0,K.jsxs)(`div`,{className:`max-w-2xl`,children:[(0,K.jsx)(`h2`,{className:`text-2xl text-foreground font-light mb-6`,children:`Authentication`}),(0,K.jsxs)(`section`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,K.jsx)(`h3`,{className:`text-lg text-foreground font-medium`,children:`OAuth Providers`}),!a&&(0,K.jsxs)(F,{variant:`positiveOutline`,size:`sm`,onClick:()=>o(!0),children:[(0,K.jsx)(Ur,{}),`Add Provider`]})]}),l.length===0&&!a&&(0,K.jsx)(`p`,{className:`text-muted-foreground text-sm mb-4`,children:`No OAuth providers configured.`}),l.map(e=>{let n=t?.oauthConfigId===e.id;return s===e.id?(0,K.jsxs)(`div`,{className:`border rounded-lg p-4 mb-3 text-foreground`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,K.jsx)(`h4`,{className:`font-medium`,children:`Edit Provider`}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>c(null),className:`text-muted-foreground hover:text-foreground`,children:(0,K.jsx)(hn,{className:`size-4`})})]}),(0,K.jsx)(Do,{...m,children:(0,K.jsxs)(`form`,{onSubmit:m.handleSubmit(t=>g(e,t)),className:`space-y-4`,children:[(0,K.jsx)(Y,{control:m.control,name:`domain`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Domain`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{placeholder:`company.okta.com`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:m.control,name:`clientId`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Client ID`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{placeholder:`Leave blank to keep existing`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:m.control,name:`clientSecret`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Client Secret`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`password`,placeholder:`Leave blank to keep existing`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:m.control,name:`scope`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Scope`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{placeholder:`openid email profile`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsxs)(`div`,{className:`flex gap-2 pt-2`,children:[(0,K.jsx)(F,{type:`submit`,variant:`positive`,disabled:d,children:d?`Saving...`:`Save`}),(0,K.jsx)(F,{type:`button`,variant:`outline`,onClick:()=>c(null),children:`Cancel`})]})]})})]},e.id):(0,K.jsx)(`div`,{className:`border rounded-lg p-4 mb-3 text-foreground`,children:(0,K.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between sm:gap-4`,children:[(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[(0,K.jsx)(`span`,{className:`font-medium`,children:e.domain}),(0,K.jsx)(`span`,{className:`text-xs text-muted-foreground uppercase bg-muted px-2 py-0.5 rounded`,children:e.provider}),e.enabled===!1&&(0,K.jsx)(`span`,{className:`text-xs text-destructive bg-destructive/10 px-2 py-0.5 rounded`,children:`Disabled`})]}),(0,K.jsxs)(`p`,{className:`text-sm text-muted-foreground mb-2`,children:[`Client ID: `,(0,K.jsx)(`span`,{className:`text-foreground font-mono`,children:`****`})]}),e.id&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`mt-3 rounded-md bg-muted px-3 py-2`,children:[(0,K.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground mb-1`,children:`Okta redirect URI`}),(0,K.jsxs)(`p`,{className:`text-xs text-muted-foreground mb-1.5`,children:[`Add to `,(0,K.jsx)(`span`,{className:`font-medium text-foreground`,children:`Login redirect URIs`}),` `,`in your Okta app settings.`]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-sm text-foreground font-mono truncate`,children:v(e.id)}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>void b(v(e.id)),className:`hover:text-foreground shrink-0 text-muted-foreground`,title:`Copy redirect URI`,children:(0,K.jsx)(sr,{className:`size-3.5`})})]})]}),(0,K.jsxs)(`div`,{className:`mt-2 rounded-md bg-muted px-3 py-2`,children:[(0,K.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground mb-1.5`,children:`User login link`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`a`,{href:Ep(e.id),target:`_blank`,rel:`noreferrer`,className:`text-sm text-foreground truncate hover:underline`,children:Ep(e.id)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0 text-muted-foreground`,children:[(0,K.jsx)(`button`,{type:`button`,onClick:()=>void y(Ep(e.id)),className:`hover:text-foreground`,title:`Copy login link`,children:(0,K.jsx)(sr,{className:`size-3.5`})}),(0,K.jsx)(`a`,{href:Ep(e.id),target:`_blank`,rel:`noreferrer`,className:`hover:text-foreground`,title:`Open login link`,children:(0,K.jsx)(dr,{className:`size-3.5`})})]})]})]})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-3 sm:shrink-0`,children:[(0,K.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-foreground cursor-pointer`,children:[(0,K.jsx)(Tp,{checked:e.enabled!==!1,onCheckedChange:()=>_(e,`enabled`),disabled:d}),`Enabled`]}),(0,K.jsxs)(Ia,{children:[(0,K.jsx)(La,{asChild:!0,children:(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-2 text-sm text-foreground ${n?`cursor-pointer`:`cursor-not-allowed opacity-50`}`,children:[(0,K.jsx)(Tp,{checked:!!e.required,onCheckedChange:()=>_(e,`required`),disabled:d||!n}),`Required`]})}),!n&&(0,K.jsxs)(Ra,{children:[`Sign in via `,e.provider,` first to enable Required`]})]}),(0,K.jsx)(F,{variant:`outline`,size:`sm`,onClick:()=>h(e),disabled:d,children:(0,K.jsx)(an,{className:`size-4`})})]})]})},e.id)}),a&&(0,K.jsxs)(`div`,{className:`border rounded-lg p-4 text-foreground`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,K.jsx)(`h4`,{className:`font-medium`,children:`Add Okta Provider`}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>{o(!1),f.reset()},className:`text-muted-foreground hover:text-foreground`,children:(0,K.jsx)(hn,{className:`size-4`})})]}),(0,K.jsxs)(`p`,{className:`text-xs text-muted-foreground mb-4`,children:[`After saving, copy the `,(0,K.jsx)(`span`,{className:`font-medium text-foreground`,children:`Okta redirect URI`}),` `,`from the provider card and add it to your Okta app's`,` `,(0,K.jsx)(`span`,{className:`font-medium text-foreground`,children:`Login redirect URIs`}),`.`]}),(0,K.jsx)(Do,{...f,children:(0,K.jsxs)(`form`,{onSubmit:f.handleSubmit(p),className:`space-y-4`,children:[(0,K.jsx)(Y,{control:f.control,name:`domain`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Domain`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{placeholder:`company.okta.com`,autoFocus:!0,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:f.control,name:`clientId`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Client ID`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{placeholder:`Okta Client ID`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:f.control,name:`clientSecret`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Client Secret`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`password`,placeholder:`Okta Client Secret`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:f.control,name:`scope`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Scope`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{placeholder:`openid email profile`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsxs)(`div`,{className:`flex gap-2 pt-2`,children:[(0,K.jsx)(F,{type:`submit`,variant:`positive`,disabled:d,children:d?`Adding...`:`Add Provider`}),(0,K.jsx)(F,{type:`button`,variant:`outline`,onClick:()=>{o(!1),f.reset()},children:`Cancel`})]})]})})]})]})]})})]}):(0,K.jsx)(`div`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-theme(spacing.32))] text-foreground`,children:`You don't have permission to manage settings for this organization.`})}A.object({email:Yo.max(80,{error:`Email cannot be longer than 80 characters.`}),roleId:A.string().nonempty({error:`Please select a role.`})});async function jp(e){let{data:t}=await N.post(`/UserInvite/`,e);return t}function Mp(){return R({mutationFn:e=>jp(e)})}function Np({user:e}){let{update:t}=fl(),{mutate:n,isPending:r}=Mp(),i=e.roles?.[0]?.id,a=(0,q.useCallback)(t=>{if(t.stopPropagation(),!e.email||!i){U.error(`Cannot resend invite: this user has no email or role.`);return}n({email:e.email,roleId:i},{onSuccess:()=>U.success(`Invitation resent to ${e.email}.`)})},[n,i,e.email]);return t?(0,K.jsxs)(F,{variant:`ghost`,size:`sm`,className:`h-auto px-2 py-0 align-middle text-sm`,onClick:a,disabled:r||!i,children:[(0,K.jsx)(Pr,{}),` Resend invite`]}):null}var Pp=Mn(),Fp=[{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},Pp.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},Pp.display({header:``,enableSorting:!1,id:`actions`,cell:e=>e.row.original.status===`PENDING`?(0,K.jsx)(Np,{user:e.row.original}):null})];function Ip({name:e,id:t}){return(0,K.jsxs)(`span`,{className:`flex items-baseline gap-2 truncate`,children:[(0,K.jsx)(`span`,{className:`truncate`,children:e}),(0,K.jsx)(`span`,{className:`text-muted-foreground font-mono text-xs`,children:t})]})}var Lp=A.object({email:Yo.max(80,{error:`Email cannot be longer than 80 characters.`}),roleId:A.string().nonempty({error:`Please select a role.`})});async function Rp(e){let{data:t}=await N.post(`/OrganizationRole/`,e);return t}function zp(){return R({mutationFn:e=>Rp(e)})}function Bp({isModalOpen:e,onChangesSaved:t,setIsModalOpen:n}){let{organizationId:r}=B({strict:!1}),{data:i,isLoading:a}=H({...rp(r),throwOnError:!0}),[o,s]=(0,q.useState)(!1),c=dt({resolver:Fe(Lp),defaultValues:{email:``,roleId:``}}),{mutate:l,isPending:u}=zp(),{mutate:d,isPending:f}=Mp(),p=(0,q.useCallback)(async e=>{e&&(o?d:l)(e,{onSuccess:()=>{let r=e.roleId;c.reset(),c.setValue(`roleId`,r),t(),U.success(`User invited successfully!`),n(!1),s(!1)},onError:e=>{e?.status===404&&s(!0)}})},[l,c,d,t,n,o]);return(0,K.jsx)(Rt,{onOpenChange:()=>{n(!1),s(!1),c.reset()},open:e,children:(0,K.jsx)(Ut,{"aria-describedby":void 0,children:(0,K.jsx)(Do,{...c,children:(0,K.jsxs)(`form`,{id:`org-add-user-form`,name:`org-add-user-form`,onSubmit:c.handleSubmit(p),className:`grid gap-4 my-4`,children:[(0,K.jsx)(Bt,{children:(0,K.jsx)(qt,{children:o?`Invite User`:`Add User`})}),(0,K.jsx)(Y,{control:c.control,name:`email`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Email`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`email`,enterKeyHint:`next`,autoComplete:`email`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:c.control,name:`roleId`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Roles`}),a?(0,K.jsx)(Jd,{}):(0,K.jsx)(J,{children:(0,K.jsxs)(Xt,{...e,onValueChange:t=>e.onChange(t),children:[(0,K.jsx)(Kt,{className:`w-full`,children:(0,K.jsx)(Yt,{placeholder:`Choose Role`})}),(0,K.jsx)(Gt,{children:(0,K.jsxs)(Jt,{children:[(0,K.jsx)(Lt,{children:`Role`}),i?.map(e=>(0,K.jsx)(Ht,{value:e.id,children:(0,K.jsx)(Ip,{name:e.roleName,id:e.id})},e.id))]})})]})}),(0,K.jsx)(Q,{})]})}),o&&(0,K.jsxs)(Zt,{className:`p-3 my-5 text-white rounded-md bg-amber-600 flex`,children:[(0,K.jsx)(Nr,{className:`inline-block size-12 pr-2`}),(0,K.jsx)(`span`,{children:`This person doesn’t have a Fabric account. Do you want to invite them?`})]}),(0,K.jsx)(zt,{children:(0,K.jsx)(`div`,{className:`flex justify-between w-full`,children:(0,K.jsxs)(F,{type:`submit`,variant:`submit`,disabled:u||f,children:[(0,K.jsx)(Jr,{}),` `,o?`Invite User`:`Add User`]})})})]})})})})}async function Vp({roleId:e,userId:t}){let{data:n}=await N.delete(`/OrganizationRole/role/${e}/user/${t}`);return n}function Hp(){return R({mutationFn:({roleId:e,userId:t})=>Vp({roleId:e,userId:t})})}function Up(e){let[t,n]=(0,q.useState)(e||!1);return[t,(0,q.useCallback)(e=>{n(typeof e==`boolean`?e:e.target.checked)},[])]}function Wp({data:e,readOnly:t,canRemove:n,orgRole:r,selectedRoles:i,setChangesMade:a}){let{mutate:o,isPending:s}=zp(),{mutate:c,isPending:l}=Hp(),u=!!i[r.id],[d,f]=(0,q.useState)(u),[p,m]=Up(u);return(0,q.useEffect)(()=>{p!==d&&(p?o({email:e.email,roleId:r.id},{onSuccess:()=>{f(p),a(!0),U.success(`Role added successfully`)}}):c({userId:e.id,roleId:r.id},{onSuccess:()=>{f(p),a(!0),U.success(`Role removed successfully`)}}))},[o,e.email,e.id,p,r.id,c,a,d]),(0,K.jsxs)(jo,{className:`flex`,children:[(0,K.jsx)($,{type:`checkbox`,className:`w-6`,disabled:t||s||l||!n&&p,checked:p,onChange:m}),(0,K.jsx)(`span`,{className:`pl-4 pr-8 flex-1 py-2.5`,children:r.roleName})]},r.id)}function Gp({isSelf:e,isPending:t,onConfirm:n}){let[r,i]=(0,q.useState)(!1),a=e?{idle:`Leave organization`,confirm:`Confirm leave`,busy:`Leaving…`,warning:`You’ll lose access to this organization and everything in it. You won’t be able to return unless another member invites you back.`}:{idle:`Remove from organization`,confirm:`Confirm removal`,busy:`Removing…`,warning:`This revokes their access to this organization and everything in it. Their Harper account isn’t deleted, and they can be added back later.`},o=e?jr:pi;return r?(0,K.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,K.jsxs)(`p`,{role:`alert`,className:`flex items-start gap-2 text-sm text-muted-foreground border border-amber-500/50 rounded-md p-3`,children:[(0,K.jsx)(fi,{className:`size-4 text-amber-500 shrink-0 mt-0.5`}),(0,K.jsx)(`span`,{children:a.warning})]}),(0,K.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,K.jsx)(F,{type:`button`,variant:`ghostOutline`,disabled:t,onClick:()=>i(!1),children:`Cancel`}),(0,K.jsxs)(F,{type:`button`,variant:`destructive`,disabled:t,onClick:n,children:[(0,K.jsx)(o,{}),` `,t?a.busy:a.confirm]})]})]}):(0,K.jsx)(`div`,{className:`flex justify-start`,children:(0,K.jsxs)(F,{type:`button`,variant:`destructiveOutline`,disabled:t,onClick:()=>i(!0),children:[(0,K.jsx)(o,{}),` `,a.idle]})})}function Kp(e){return e?.trim().toLowerCase()===`admin`}function qp({canDelete:e,isSelf:t,orgUserCount:n,adminCount:r,isAdmin:i,roleCount:a}){let o=e?t&&n<=1?`sole-member`:t&&i&&r<=1?`last-admin`:null:null,s=e&&o===null;return{canRemoveRoles:s,showRemovalAction:s&&a>0,blockedReason:o}}function Jp({closeModal:e,data:t,isModalOpen:n,onUserUpdated:r,orgUserCount:i,orgAdminCount:a}){let{organizationId:o}=B({strict:!1}),s=je(),{update:c,remove:l}=fl(o),u=s.user?.email===t.email,[d,f]=(0,q.useState)(!1),{canRemoveRoles:p,showRemovalAction:m,blockedReason:h}=qp({canDelete:l,isSelf:u,orgUserCount:i,adminCount:a,isAdmin:(t.roles??[]).some(e=>Kp(e.roleName)),roleCount:t.roles?.length??0}),{mutateAsync:g}=Hp(),[_,v]=(0,q.useState)(!1),y=(0,q.useCallback)(async()=>{let e=t.roles??[];v(!0),(await Promise.allSettled(e.map(e=>g({userId:t.id,roleId:e.id})))).some(e=>e.status===`rejected`&&e.reason?.response?.status!==404)?U.error(u?`Something went wrong leaving the organization. Please try again.`:`Couldn’t remove ${t.email} from the organization. Please try again.`):U.success(u?`You’ve left the organization.`:`${t.email} was removed from the organization.`),v(!1),r()},[t.roles,t.id,t.email,u,g,r]);return(0,K.jsx)(Rt,{onOpenChange:d?r:e,open:n,children:(0,K.jsxs)(Ut,{resizable:!0,children:[(0,K.jsx)(Bt,{children:(0,K.jsxs)(qt,{children:[c?`Edit `:`View `,` `,t.email,` `,u?`(yourself)`:``]})}),c&&(0,K.jsxs)(Zt,{children:[`Use the checkboxes to change which roles `,u?`you have`:`this user has`,`.`,m&&(u?` To leave the organization entirely, use the button below.`:` To remove this user from the organization entirely, use the button below.`)]}),(0,K.jsx)(q.Suspense,{fallback:(0,K.jsx)(Bi,{centered:!0,text:`Loading roles…`,className:`flex-1 min-h-0`}),children:(0,K.jsx)(Yp,{data:t,organizationId:o,update:c,canRemove:p,setChangesMade:f})}),t.status===`PENDING`&&(0,K.jsx)(`div`,{className:`border-t border-border pt-4`,children:(0,K.jsx)(Np,{user:t})}),m&&(0,K.jsx)(`div`,{className:`border-t border-border pt-4`,children:(0,K.jsx)(Gp,{isSelf:u,isPending:_,onConfirm:y})}),h&&(0,K.jsxs)(`p`,{className:`flex items-start gap-2 text-sm text-muted-foreground border border-amber-500/50 rounded-md p-3`,children:[(0,K.jsx)(fi,{className:`size-4 text-amber-500 shrink-0 mt-0.5`}),(0,K.jsx)(`span`,{children:h===`sole-member`?`You’re the only member of this organization, so you can’t remove your roles or leave — it would be left with no one to manage it. If you no longer need this organization, terminate its clusters, then delete the organization from the ⋯ menu on the Organizations page.`:`You’re the only admin of this organization, so you can’t remove your roles or leave — it would be left with no one who can manage its members, roles, or clusters. Give another member the admin role first, then you can step back.`})]})]})})}function Yp({data:e,organizationId:t,update:n,canRemove:r,setChangesMade:i}){let{data:a}=le(rp(t)),o=(0,q.useMemo)(()=>e.roles?su(e.roles,`id`):{},[e]);return(0,K.jsx)(`div`,{className:`flex flex-1 min-h-0 flex-col gap-2 overflow-y-auto`,children:a.map(t=>(0,K.jsx)(Wp,{readOnly:!n,canRemove:r,data:e,orgRole:t,selectedRoles:o,setChangesMade:i},t.id))})}function Xp(e,t){return e.email>t.email?1:-1}function Zp(e){return(e.users??[]).filter(e=>e!=null)}function Qp(e){let t={};for(let n of e)for(let e of Zp(n))t[e.id]||(t[e.id]={...e,roles:[]}),t[e.id].roles.push(n);return Object.values(t).sort(Xp)}function $p(e){let t=new Set;for(let n of e)if(Kp(n.roleName))for(let e of Zp(n))t.add(e.id);return t.size}function em(){let e=L(),{organizationId:t,orgUserId:n}=B({strict:!1}),{update:r}=fl(t),{data:i,refetch:a,isFetching:o,isRefetching:s}=le(rp(t)),c=(0,q.useMemo)(()=>Qp(i),[i]),l=(0,q.useMemo)(()=>$p(i),[i]),u=(0,q.useMemo)(()=>c?.find(e=>e.id===n),[c,n]),d=(0,q.useCallback)(t=>{let r=[n?`..`:``,t].filter(Boolean);e({to:r.join(`/`)})},[n,e]),f=!!n&&!!u,[p,m]=(0,q.useState)(!1),[h]=(0,q.useState)({attribute:`email`,descending:!1}),g=(0,q.useMemo)(()=>[{desc:h.descending,id:h.attribute}],[h]),_=(0,q.useCallback)(()=>{m(!0)},[m]),v=(0,q.useCallback)(()=>{a(),m(!1)},[a,m]),y=(0,q.useCallback)(e=>{d(e.original.id)},[d]),b=(0,q.useCallback)(()=>{d(void 0)},[d]),x=(0,q.useCallback)(()=>{a(),d(void 0)},[d,a]),S=Zf(a);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Ks,{}),(0,K.jsx)(If,{children:(0,K.jsxs)(q.Suspense,{fallback:(0,K.jsx)(Bi,{className:`flex flex-col items-center justify-center h-full`,text:`Loading...`}),children:[(0,K.jsxs)(Kf,{data:c,isFetching:o||s,columns:Fp,onRowClick:y,sortingState:g,children:[(0,K.jsxs)(F,{variant:`defaultOutline`,onClick:S,accessKey:`r`,disabled:o||s,children:[(0,K.jsx)(Wr,{}),` `,(0,K.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,K.jsx)(`u`,{children:`R`}),`efresh`]})]}),r&&(0,K.jsxs)(F,{variant:`positiveOutline`,onClick:_,accessKey:`a`,disabled:p,children:[(0,K.jsx)(Ur,{}),` `,(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`u`,{children:`A`}),`dd`]})]})]}),r&&(0,K.jsx)(Bp,{isModalOpen:p,onChangesSaved:v,setIsModalOpen:m}),f&&(0,K.jsx)(Jp,{closeModal:b,data:u,isModalOpen:f,onUserUpdated:x,orgUserCount:c.length,orgAdminCount:l})]})})]})}function tm({className:e,...t}){return(0,K.jsx)(`div`,{"data-slot":`skeleton`,className:P(`bg-primary/10 animate-pulse rounded-md`,e),...t})}function nm({organizationId:e,organizationName:t,providers:n}){return(0,K.jsxs)(It,{className:`relative h-full justify-between opacity-90`,children:[(0,K.jsxs)(Nt,{children:[(0,K.jsx)(Ft,{className:`truncate`,children:e}),(0,K.jsx)(Mt,{children:(0,K.jsx)(`h2`,{children:t})})]}),(0,K.jsxs)(Pt,{className:`flex flex-col gap-2`,children:[(0,K.jsxs)(`p`,{className:`text-xs text-muted-foreground flex items-center gap-1.5 mb-1`,children:[(0,K.jsx)(wr,{className:`size-3 shrink-0`}),`Sign in with an OAuth provider to access this organization.`]}),n.map(e=>(0,K.jsx)(`a`,{href:Ep(e.oauthConfigId),children:(0,K.jsxs)(F,{variant:`outline`,className:`w-full`,children:[`Sign in with `,e.name]})},e.oauthConfigId))]})]})}var rm=y({couponId:M().nonempty({message:`Please enter a coupon ID.`}).trim()});async function im({organizationId:e,couponId:t}){let{data:n}=await N.post(`/Coupon`,{organizationId:e,couponId:t},{validateStatus:e=>e>=200&&e<400||e===400||e===409});return n}function am(){return R({mutationFn:im})}function om({organizationId:e,organizationName:t,isOpen:n,onClose:r}){let{mutate:i,isPending:a}=am(),o=dt({resolver:Fe(rm),defaultValues:{couponId:``}}),{handleSubmit:s,control:c,reset:l}=o;(0,q.useEffect)(()=>{n&&l({couponId:``})},[n,l]);let u=(0,q.useCallback)(n=>{i({organizationId:e,couponId:n.couponId},{onSuccess:i=>{i?U.error(`Error`,{description:i||`Failed to add coupon.`}):(U.success(`Success`,{description:`Coupon "${n.couponId}" added to ${t||e}.`}),r())}})},[i,e,t,r]);return(0,K.jsx)(Rt,{open:n,onOpenChange:e=>!e&&r(),children:(0,K.jsxs)(Ut,{children:[(0,K.jsxs)(Bt,{children:[(0,K.jsx)(qt,{children:`Add Coupon`}),(0,K.jsxs)(Zt,{children:[`Add a coupon code to`,` `,t||e,`. This coupon will be applied to the next billing cycle.`,(0,K.jsx)(`br`,{}),`Coupons can be created in our`,` `,(0,K.jsx)(`a`,{href:`https://dashboard.stripe.com/`,target:`_blank`,rel:`noreferrer`,className:`text-purple hover:underline`,children:`Stripe Dashboard`}),`.`]})]}),(0,K.jsx)(Do,{...o,children:(0,K.jsxs)(`form`,{onSubmit:s(u),children:[(0,K.jsx)(`div`,{className:`grid gap-4 py-4`,children:(0,K.jsx)(Y,{control:c,name:`couponId`,render:({field:e})=>(0,K.jsxs)(X,{className:`grid items-center gap-4`,children:[(0,K.jsx)(Z,{children:`Coupon ID`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{...e,placeholder:`e.g. 100OFF`,disabled:a})}),(0,K.jsx)(Q,{})]})})}),(0,K.jsxs)(zt,{children:[(0,K.jsx)(F,{type:`button`,variant:`ghost`,onClick:r,disabled:a,children:`Cancel`}),(0,K.jsx)(F,{type:`submit`,disabled:a,children:a?`Adding...`:`Add Coupon`})]})]})})]})})}function sm({organizationRole:e,onDeleteOrgModal:t}){let{organizationId:n,organizationName:r,roleName:i}=e,{remove:a,update:o}=ul(n),s=o,{view:c}=fl(n),l=Me(`billing:write`),[u,d]=(0,q.useState)(!1),f=(0,q.useCallback)(()=>{t(e)},[t,e]),p=[{type:`label`,key:`label`,className:`text-gray-600 text-xs`,label:`Options`},{type:`separator`,key:`sep-top`},{key:`clusters`,to:`${n}`,icon:(0,K.jsx)(Zr,{className:`size-4 mr-2 text-blue-500`}),label:`Clusters`},c&&{key:`roles`,to:`${n}/roles`,icon:(0,K.jsx)($r,{className:`size-4 mr-2 text-purple`}),label:`Roles`},c&&{key:`users`,to:`${n}/users`,icon:(0,K.jsx)(hi,{className:`size-4 mr-2 text-orange-500`}),label:`Users`},s&&{key:`billing`,to:`${n}/billing`,icon:(0,K.jsx)(cr,{className:`size-4 mr-2 text-green-500`}),label:`Billing`},o&&{key:`settings`,to:`${n}/settings`,icon:(0,K.jsx)(wr,{className:`size-4 mr-2 text-yellow-500`}),label:`Settings`},l&&{key:`add-coupon`,onClick:()=>d(!0),icon:(0,K.jsx)(li,{className:`size-4 mr-2 text-pink-500`}),label:`Add Coupon`},a&&{type:`separator`,key:`sep-bottom`},a&&{key:`delete`,onClick:f,className:`focus:bg-red/70 focus:text-white`,icon:(0,K.jsx)(ui,{className:`size-4 mr-2 text-red-500`}),label:`Delete`}].filter(kn),m=a||l;return(0,K.jsx)(rc,{items:m?p:[],children:(0,K.jsxs)(It,{className:`relative h-full justify-between transition-[transform,box-shadow] duration-200 hover:scale-[1.02] hover:shadow-lg hover:ring-2 hover:ring-primary/60 dark:hover:ring-violet-400/70`,children:[(0,K.jsx)(V,{to:n,"aria-label":`View ${r??n}`,className:`absolute inset-0 rounded-[inherit] focus-visible:ring-2 focus-visible:ring-purple-200 focus-visible:outline-none`}),(0,K.jsxs)(Nt,{children:[(0,K.jsxs)(Ft,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`truncate`,children:n}),m&&(0,K.jsxs)(bi,{children:[(0,K.jsx)(xi,{"aria-label":`Options`,onClick:e=>e.stopPropagation(),className:`relative z-10 -m-2 p-2 rounded-md hover:bg-accent/60 hover:text-foreground`,children:(0,K.jsx)(ur,{})}),(0,K.jsx)(Si,{children:nc(p,`dropdown`)})]})]}),(0,K.jsx)(Mt,{children:(0,K.jsx)(`h2`,{children:r})})]}),(0,K.jsxs)(Pt,{className:`flex items-center justify-between gap-2`,children:[(0,K.jsx)(Wi,{className:`min-w-0 shrink`,title:wo(i),children:(0,K.jsx)(`span`,{className:`truncate`,children:wo(i)})}),(0,K.jsxs)(`span`,{className:`text-sm shrink-0 py-2 whitespace-nowrap ml-auto`,children:[`View `,(0,K.jsx)(Bn,{className:`inline-block`})]})]}),(0,K.jsx)(om,{organizationId:n,organizationName:r,isOpen:u,onClose:()=>d(!1)})]})})}async function cm(e){let{data:t}=await N.delete(`/Organization/${e}`);return t}function lm(){return R({mutationFn:e=>cm(e)})}async function um(e){let{data:t}=await N.post(`/Organization/`,{...e});return t}function dm(){return R({mutationFn:e=>um(e)})}var fm=M().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.`}),pm=y({name:M().max(255,{error:`Name cannot be longer than 255 characters.`}),subdomain:x([O(``),b(),fm]).optional()});function mm(){let{user:e}=je(),t=L(),n=dt({resolver:Fe(pm),defaultValues:{name:``,subdomain:``}}),{setFocus:r,watch:i}=n;(0,q.useEffect)(()=>{r(`name`)},[r]);let a=`${e?.firstname} ${e?.lastname} Org`,o=i(`name`)||a,s=i(`subdomain`),c=(0,q.useMemo)(()=>{let e=vu(bu(o),fm.maxLength);return{suggestedSubdomain:e,fullHostName:`future-cluster-names.${s||e}.harperfabric.com`}},[o,s]),{mutate:u,isPending:d}=dm(),f=ie(),h=(0,q.useCallback)(async e=>{u({name:e.name||a,subdomain:e.subdomain||c.suggestedSubdomain},{onSuccess:e=>{f.invalidateQueries({queryKey:p,refetchType:`active`}),l.reloadUser(m),t({to:`/${e.id}`})}})},[c.suggestedSubdomain,f,u,a,t]);return(0,K.jsx)(K.Fragment,{children:(0,K.jsx)(Do,{...n,children:(0,K.jsxs)(`form`,{id:`org-add-form`,name:`org-add-form`,onSubmit:n.handleSubmit(h),className:`grid gap-6 text-foreground max-w-xl`,children:[(0,K.jsx)(Y,{control:n.control,name:`name`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Name`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`text`,maxLength:pm.shape.name.maxLength,autoCapitalize:`words`,placeholder:a,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:n.control,name:`subdomain`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Subdomain`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`text`,maxLength:fm.maxLength,autoCapitalize:`none`,placeholder:c.suggestedSubdomain,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Full Host Name`}),(0,K.jsx)(J,{children:(0,K.jsx)(`span`,{children:c.fullHostName})}),(0,K.jsx)(Q,{})]}),(0,K.jsx)(zt,{children:(0,K.jsxs)(F,{type:`submit`,variant:`submit`,disabled:d,children:[`Create New Organization `,(0,K.jsx)(Bn,{})]})})]})})})}function hm(){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Ks,{}),(0,K.jsx)(`section`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-theme(spacing.32))]`,children:(0,K.jsx)(mm,{})})]})}var gm={org:`organization`,clu:`cluster`,ins:`instance`},_m=/^(org|clu|ins)-[a-z0-9]+$/;function vm(e){if(typeof e!=`string`)return null;let t=e.trim(),n=_m.exec(t);return n?{kind:gm[n[1]],id:t}:null}function ym(e,t){let n=e*12;return`/Admin/Organization/?${[...t?[`name=ct=${encodeURIComponent(t)}`]:[],`status=ne=DELETED`,`sort(name)`,`limit(${n},${n+12+1})`].join(`&`)}`}async function bm(e,t){let{data:n}=await N.get(ym(e,t));return{organizations:n.slice(0,12),hasNextPage:n.length>12}}var xm={organizations:[],hasNextPage:!1};function Sm(e){return e instanceof _&&(e.response?.status===404||e.status===404)}async function Cm(e){try{let{data:t}=await N.get(`/Admin/Organization/${e}`);return t?{organizations:[t],hasNextPage:!1}:xm}catch(e){if(Sm(e))return xm;throw e}}async function wm(e){try{let{data:t}=await N.get(`/Cluster/${e}`),n=t?.organizationId;return n?await Cm(n):xm}catch(e){if(Sm(e))return xm;throw e}}function Tm(e,t){let n=vm(t);return z({queryKey:[`admin-all-organizations`,t,e],queryFn:()=>n?.kind===`organization`?Cm(n.id):n?.kind===`cluster`?wm(n.id):bm(e,t),placeholderData:ye,retry:!1})}function Em(e,t=300,n){let[r,i]=(0,q.useState)(e),a=n?n(e):e;return(0,q.useEffect)(()=>{let n=setTimeout(()=>i(e),t);return()=>clearTimeout(n)},[a,t]),r}function Dm(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 Om(e,t){let[n,r]=(0,q.useState)(t),[i,a]=(0,q.useState)(e);return(0,q.useEffect)(()=>{Dm(n,t)||(r(t),a(e))},[n,t,e]),Dm(n,t)?[i,a]:[e,a]}var km={};function Am(e,t,n){let r=(0,q.useCallback)((e,n)=>t(e,n),[n]);(0,q.useEffect)(()=>(km[e]||(km[e]=[]),km[e].push(r),function(){let t=km[e].indexOf(r);t>=0&&km[e].splice(t,1)}),[e,t,r])}function jm(e,t,n){let r=km[e];if(r)for(let e of r)e(t,n)}function Mm(e,t,n){return r=>jm(e,t,n??r)}function Nm(e,t,n){return(0,q.useCallback)(r=>jm(e,t,n??r),[e,t,n])}function Pm(e,t){return xn(sessionStorage.getItem(String(e)))??t}function Fm(e,t){t==null?sessionStorage.removeItem(String(e)):sessionStorage.setItem(String(e),JSON.stringify(t))}function Im(e,t){let n=Om(Pm(e,t),[e]),[r,i]=n;return(0,q.useEffect)(()=>{Fm(e,r),jm(`Session:${e}`,r)},[e,r]),Am(`Session:${e}`,function(e){r!==e&&i(e)},[r,e,t]),(0,q.useEffect)(function(){let n=n=>{n.key===e&&i(Pm(e,t))};return window.addEventListener(`storage`,n),()=>{window.removeEventListener(`storage`,n)}},[e,i,t]),n}function Lm(){let e=ie(),{data:t}=le(s()),{mutate:n,isPending:r}=lm(),[i,a]=(0,q.useState)(!1),[o,c]=(0,q.useState)(null),[l,u]=(0,q.useState)(``),d=(0,q.useCallback)(()=>u(``),[]),f=Me(`org:read`),[p,m]=Im(`ShowAllOrganizations`,!1),[h,g]=(0,q.useState)(0),_=f&&p,v=(0,q.useCallback)(e=>{m(e),g(0)},[m]),y=Em(l,300),b=(0,q.useMemo)(()=>{if(!f)return null;let e=vm(y);return e?.kind===`organization`||e?.kind===`cluster`?e:null},[f,y]),x=_||!!b,{data:S,isPending:C}=H({...Tm(h,y),enabled:x}),{organizationRoles:w,oauthLockedOrgs:T}=(0,q.useMemo)(()=>{let e=t?.roles||{},n=[],r=[];for(let[t,i]of Object.entries(e))`oauthProviders`in i&&!f?r.push({organizationId:t,organizationName:i.organizationName,providers:i.oauthProviders}):n.push({organizationId:t,organizationName:i.organizationName,roleName:i.role??`fabric staff`});return{organizationRoles:n.filter(Bf([`organizationId`,`organizationName`],l)).sort((e,t)=>(e.organizationName||``)>(t.organizationName||``)?1:-1),oauthLockedOrgs:r}},[l,t?.roles,f]),E=(0,q.useMemo)(()=>{let e=t?.roles||{};return(S?.organizations||[]).map(t=>({organizationId:t.id,organizationName:t.name,roleName:e[t.id]?.role||`fabric staff`}))},[S?.organizations,t?.roles]),D=x?E:w,O=(0,q.useCallback)(e=>{u(e.currentTarget.value||``),g(0)},[]),k=(0,q.useCallback)(t=>{t?.organizationId&&n(t.organizationId,{onSuccess:()=>{U.success(`Success`,{description:`Organization successfully deleted.`,duration:5e3,action:{label:`Dismiss`,onClick:()=>U.dismiss()}}),e.invalidateQueries({queryKey:[]}),a(!1)},onError:()=>a(!1)})},[n,e,a]),A=(0,q.useCallback)(e=>{c(e),a(!0)},[]),{createCluster:j}=se({strict:!1});return!_&&w.length===1&&!l.length&&j?(0,K.jsx)(ne,{to:`/${w[0].organizationId}/new-cluster`,replace:!0}):!_&&!w.length&&!T.length&&!l.length?(0,K.jsx)(hm,{}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Ks,{children:(0,K.jsxs)(`div`,{className:`flex w-full items-center justify-end gap-2`,children:[f&&(0,K.jsxs)(`label`,{className:`flex shrink-0 cursor-pointer items-center gap-2 text-xs`,children:[(0,K.jsx)(Tp,{checked:p,onCheckedChange:v,"aria-label":`Show all organizations`}),(0,K.jsx)(`span`,{className:`hidden sm:inline-block`,children:`All Orgs`})]}),(0,K.jsx)($,{placeholder:`Filter by name`,className:`inline-block w-full text-xs`,value:l,onChange:O}),(0,K.jsx)(V,{to:`/new-org`,children:(0,K.jsxs)(F,{variant:`positive`,accessKey:`n`,children:[(0,K.jsx)(Ur,{}),(0,K.jsxs)(`span`,{className:`hidden sm:inline-block`,children:[(0,K.jsx)(`u`,{children:`N`}),`ew `,(0,K.jsx)(`span`,{className:`hidden md:inline-block`,children:`Organization`})]})]})})]})}),(0,K.jsxs)(`section`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-theme(spacing.32))]`,children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-12`,children:[!x&&T.map(e=>(0,K.jsx)(`div`,{className:`col-span-1 md:col-span-4 lg:col-span-3 2xl:col-span-2`,children:(0,K.jsx)(nm,{organizationId:e.organizationId,organizationName:e.organizationName,providers:e.providers})},e.organizationId)),x&&C?Array.from({length:12},(e,t)=>(0,K.jsx)(tm,{className:`col-span-1 h-40 md:col-span-4 lg:col-span-3 2xl:col-span-2`},t)):D.map(e=>(0,K.jsx)(`div`,{className:`col-span-1 md:col-span-4 lg:col-span-3 2xl:col-span-2`,children:(0,K.jsx)(sm,{organizationRole:e,onDeleteOrgModal:A})},e.organizationId)),!D.length&&!(x&&C)&&(x||!T.length)&&(0,K.jsxs)(`div`,{className:`col-span-1 md:col-span-12 text-center`,children:[(0,K.jsx)(`h2`,{className:`my-4 text-xl`,children:`No matches found.`}),(0,K.jsx)(F,{variant:`outline`,onClick:d,children:`Clear Filters`})]})]}),x&&(h>0||S?.hasNextPage)&&(0,K.jsxs)(`div`,{className:`flex items-center justify-center gap-4 py-6`,children:[(0,K.jsxs)(F,{variant:`defaultOutline`,size:`sm`,className:`select-none`,disabled:h===0,onClick:()=>g(e=>e-1),children:[(0,K.jsx)(Qt,{}),`Previous`]}),(0,K.jsxs)(`span`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:[`Page `,h+1]}),(0,K.jsxs)(F,{variant:`defaultOutline`,size:`sm`,className:`select-none`,disabled:!S?.hasNextPage,onClick:()=>g(e=>e+1),children:[`Next`,(0,K.jsx)(Bn,{})]})]})]}),o&&(0,K.jsx)(qs,{typeOfThingBeingDeleted:`organization`,nameOfThingBeingDeleted:o.organizationName,isModalOpen:i,setIsModalOpen:()=>a(!1),deletionConfirmed:()=>k(o),deletionPending:r})]})}var Rm=I({getParentRoute:()=>uo,id:`_orgsLayout`});I({getParentRoute:()=>Rm,path:`/`,head:()=>({meta:[{title:`Organizations — Harper Fabric`}]}),component:Lm}),I({getParentRoute:()=>Rm,path:`/new-org`,head:()=>({meta:[{title:`New Organization — Harper Fabric`}]}),component:hm});var zm=I({getParentRoute:()=>Rm,path:`$organizationId`,beforeLoad:async e=>{let{organizationId:t}=e.params;if(!mu(t))throw re({to:`/`});return{organization:await e.context.queryClient.ensureQueryData(gu(t))}}});I({getParentRoute:()=>zm,path:`/roles`,head:()=>({meta:[{title:`Organization Roles — Harper Fabric`}]}),component:wp}),I({getParentRoute:()=>zm,path:`/roles/$orgRoleId`,head:()=>({meta:[{title:`Organization Roles — Harper Fabric`}]}),component:wp}),I({getParentRoute:()=>zm,path:`/users`,head:()=>({meta:[{title:`Organization Users — Harper Fabric`}]}),component:em}),I({getParentRoute:()=>zm,path:`/users/$orgUserId`,head:()=>({meta:[{title:`Organization Users — Harper Fabric`}]}),component:em}),I({getParentRoute:()=>zm,path:`/settings`,component:Ap}),tp(zm);var Bm=I({getParentRoute:()=>zm,id:`_clusterLayout`});I({getParentRoute:()=>Bm,path:`/`,head:()=>({meta:[{title:`Clusters — Harper Fabric`}]}),component:Vf}),I({getParentRoute:()=>zm,path:`/new-cluster`,head:()=>({meta:[{title:`New Cluster — Harper Fabric`}]}),component:Ff}),I({getParentRoute:()=>Hm,path:`/edit`,head:()=>({meta:[{title:`Edit Cluster — Harper Fabric`}]}),component:Ff}),I({getParentRoute:()=>Hm,path:`/edit/$mode`,head:()=>({meta:[{title:`Edit Cluster — Harper Fabric`}]}),component:Ff});function Vm(){return(0,K.jsx)(Ce,{})}var Hm=I({getParentRoute:()=>Bm,path:`$clusterId`,component:Vm,beforeLoad:async({context:e,params:t})=>({cluster:await e.queryClient.ensureQueryData(Jo(t.clusterId))})}),Um=e=>new Intl.NumberFormat(void 0,{notation:`compact`,maximumFractionDigits:1}).format(e),Wm=e=>`${new Intl.NumberFormat(void 0,{maximumFractionDigits:1}).format(e)} hr`,Gm=e=>df(e),Km={reads:`Reads`,readBytes:`Read data`,writes:`Writes`,writeBytes:`Write data`,realTimeMessages:`Real-time messages`,realTimeBytes:`Real-time data`,cpuTimeHours:`Compute`,storageBytes:`Storage`},qm={reads:Um,readBytes:Gm,writes:Um,writeBytes:Gm,realTimeMessages:Um,realTimeBytes:Gm,cpuTimeHours:Wm,storageBytes:Gm},Jm=[`reads`,`readBytes`,`writes`,`writeBytes`,`realTimeMessages`,`realTimeBytes`,`cpuTimeHours`,`storageBytes`];function Ym(e,t,n){return{label:n??Km[e],used:t.used,limit:t.limit,unlimited:t.unlimited,limitKnown:t.limitKnown,format:qm[e]}}function Xm({label:e,used:t,limit:n,unlimited:r,limitKnown:i,format:a}){let o=r||n!=null&&n<0,s=i&&!o&&n!=null&&n>0,c=s?Math.min(100,Math.round(t/n*100)):0,l=c>=90;return(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2 text-sm`,children:[(0,K.jsx)(`span`,{className:`text-foreground`,children:e}),(0,K.jsxs)(`span`,{className:`text-muted-foreground tabular-nums`,children:[(0,K.jsx)(`span`,{className:`text-foreground`,children:a(t)}),s?(0,K.jsxs)(K.Fragment,{children:[`/ `,a(n)]}):` used`]})]}),(0,K.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-2`,children:[(0,K.jsx)(`div`,{className:`h-2 flex-1 overflow-hidden rounded-full bg-muted`,children:s?(0,K.jsx)(`div`,{className:`h-full rounded-full ${l?`bg-yellow`:`bg-primary dark:bg-violet-400`}`,style:{width:`${c}%`}}):o?(0,K.jsx)(`div`,{className:`h-full w-full bg-[repeating-linear-gradient(-45deg,transparent,transparent_5px,var(--color-border)_5px,var(--color-border)_9px)] dark:bg-[repeating-linear-gradient(-45deg,transparent,transparent_5px,rgba(255,255,255,0.32)_5px,rgba(255,255,255,0.32)_9px)]`}):null}),(0,K.jsx)(`span`,{className:`w-16 shrink-0 text-right text-xs tabular-nums ${l?`text-yellow`:`text-muted-foreground`}`,children:s?`${c}%`:o?`Unlimited`:`—`})]})]})}function Zm(e){return z({queryKey:[`clusterUsage`,e],queryFn:async()=>{let{data:t}=await N.get(`/Cluster/${e}/usage`);return t},enabled:!!e,staleTime:6e4})}function Qm(e){return H(Zm(e))}function $m(e){let{regions:t}=e,n=t.every(e=>e.planName===t[0]?.planName)?t[0]?.planName:null,r=t.length>1?`next renewal`:`renews`;return[n?`${n} plan`:null,e.renewsAt?`${r} ${eh(e.renewsAt)}`:null].filter(Boolean).join(` · `)}function eh(e){return new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`}).format(new Date(e))}function th({clusterId:e,base:t}){let{data:n}=Qm(e);return!n||n.selfManaged||n.regions.length===0?null:(0,K.jsxs)(`section`,{className:`mt-6 rounded-2xl border border-border bg-card p-5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,K.jsx)(`h2`,{className:`text-sm font-medium text-foreground`,children:`Plan usage`}),(0,K.jsxs)(V,{to:`${t}/usage`,className:`inline-flex items-center gap-1 text-xs text-primary hover:underline dark:text-violet-300`,children:[`View all usage `,(0,K.jsx)(Bn,{className:`size-3`})]})]}),(0,K.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:$m(n)}),(0,K.jsx)(`div`,{className:`mt-4`,children:n.regions.length===1?(0,K.jsx)(nh,{data:n}):(0,K.jsx)(rh,{data:n})})]})}function nh({data:e}){let t=e.regions[0].metrics,n=[Ym(`reads`,t.reads),Ym(`writes`,t.writes),Ym(`storageBytes`,t.storageBytes),Ym(`cpuTimeHours`,t.cpuTimeHours)];return(0,K.jsx)(`div`,{className:`grid grid-cols-1 gap-x-8 gap-y-4 sm:grid-cols-2`,children:n.map(e=>(0,K.jsx)(Xm,{...e},e.label))})}function rh({data:e}){let t=e.mostConstrained;return(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`p`,{className:`mb-1.5 text-xs text-muted-foreground`,children:[`Most constrained of `,e.regions.length,` regions`]}),t?(0,K.jsx)(Xm,{...Ym(t.metric,{used:t.used,limit:t.limit,unlimited:!1,limitKnown:!0},`${t.region??`Region`} · ${Km[t.metric]}`)}):(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No metered limits on the current plan — see the breakdown for details.`})]})}function ih({cluster:e}){let t=ae(),n=ie(),{update:r,remove:i}=ml(e.organizationId,e.id),{run:a,isPending:o}=Rl(e),{mutate:s,isPending:c}=Pl(),[l,u]=(0,q.useState)(!1),[d,f]=(0,q.useState)(!1),[p,m]=(0,q.useState)(!1),[h,g]=(0,q.useState)(null),_=e.status===`RUNNING`,v=e.status===`STOPPED`,y=e.status===`PARTIAL`,b=!r||o,x=(0,q.useCallback)(()=>{s(e.id,{onSuccess:async()=>{await n.invalidateQueries({queryKey:[e.organizationId],refetchType:`active`}),m(!1),U.success(`Success`,{description:`Cluster successfully terminated.`,action:{label:`Dismiss`,onClick:()=>U.dismiss()}}),t.navigate({to:`/${e.organizationId}`})},onError:()=>{m(!1)}})},[e.id,e.organizationId,s,n,t]),S=(0,q.useCallback)(()=>{let e=h;g(null),e&&a(e,{safeMode:!0,strategy:`parallel`,label:e===`start`?`Starting in safe mode`:`Restarting in safe mode`})},[h,a]);return El(e)||!r&&!i?null:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(bi,{children:[(0,K.jsx)(xi,{asChild:!0,children:(0,K.jsxs)(F,{variant:`outline`,size:`sm`,disabled:o,className:`gap-1.5 hover:translate-y-0 data-[state=open]:[&>svg]:rotate-180`,children:[`Cluster actions`,(0,K.jsx)(mn,{className:`size-4 transition-transform`})]})}),(0,K.jsxs)(Si,{align:`end`,className:`w-56`,children:[(0,K.jsx)(Ti,{className:`text-gray-600 text-xs`,children:`Container`}),(0,K.jsxs)(Ci,{disabled:b||!(v||y),onClick:()=>void a(`start`,{safeMode:!1,strategy:`parallel`}),children:[(0,K.jsx)(Hr,{}),` Start`]}),(0,K.jsxs)(Ci,{disabled:b||!v,onClick:()=>g(`start`),children:[(0,K.jsx)(Dr,{}),` Start in safe mode`]}),(0,K.jsxs)(Ci,{disabled:b||!(_||y),onClick:()=>f(!0),children:[(0,K.jsx)(qr,{}),` Restart`]}),(0,K.jsxs)(Ci,{disabled:b||!_,onClick:()=>g(`restart`),children:[(0,K.jsx)(Dr,{}),` Restart in safe mode`]}),(0,K.jsxs)(Ci,{variant:`destructive`,disabled:b||!(_||y),onClick:()=>u(!0),children:[(0,K.jsx)(ri,{}),` Stop`]}),(0,K.jsx)(Ei,{}),(0,K.jsxs)(Ci,{variant:`destructive`,disabled:!i,onClick:()=>m(!0),children:[(0,K.jsx)(di,{}),` Terminate`]})]})]}),(0,K.jsx)(kl,{clusterName:e.name,isPending:o,stopOpen:l,setStopOpen:u,onConfirmStop:()=>{u(!1),a(`stop`,{strategy:`parallel`})},restartOpen:d,setRestartOpen:f,onConfirmRestart:e=>{f(!1),a(`restart`,{safeMode:!1,strategy:e})}}),(0,K.jsx)(Ml,{open:h!==null,setOpen:e=>{e||g(null)},action:h??`restart`,targetName:e.name,scope:`cluster`,isPending:o,onConfirm:S}),(0,K.jsx)(qs,{typeOfThingBeingDeleted:`cluster`,transitiveVerb:`Terminate`,presentParticiple:`Terminating`,nameOfThingBeingDeleted:e.name,isModalOpen:p,setIsModalOpen:m,deletionConfirmed:x,deletionPending:c})]})}function ah(){let{clusterId:e}=B({strict:!1}),t=ae(),n=L(),{data:r}=H(Jo(e,!0)),{user:i,isLoading:a}=Ne(e),{view:s,update:c}=ml(r?.organizationId,r?.id),[d,f]=(0,q.useState)(!1),p=r?.domains?.[0]?.domain||r?.fqdn||``,[m,g]=Vl(p,p?`https://${p}`:``),_=r?`/${r.organizationId}/${r.id}`:``,v=(0,q.useCallback)(async()=>{if(r){f(!0);try{await l.establishFabricConnectAuth({id:r.id,operationsUrl:o(r)}),await t.invalidate()}catch{U.error(`Could not connect to this cluster through Fabric Connect.`)}finally{f(!1)}}},[r,t]),y=(0,q.useCallback)(()=>{r&&(l.setUserForEntity(r,null),l.flagForFabricConnect(r.id,!1)),n({to:`${_}/sign-in`})},[_,r,n]),b=(0,q.useCallback)(async()=>{if(r){try{await u({instanceClient:h({id:r.id}),entityId:r.id})}catch{}l.setUserForEntity(r,null),l.flagForFabricConnect(r.id,!1),l.flagForBasicAuth(r.id,null),await t.invalidate()}},[r,t]);if(!r)return(0,K.jsx)(sh,{children:(0,K.jsx)(ch,{})});if(!s)return(0,K.jsx)(ne,{to:`/${r.organizationId}`,replace:!0});if(El(r))return(0,K.jsx)(oh,{cluster:r});if(!r.fqdn)return(0,K.jsx)(ne,{to:`${_}/instances`,replace:!0});if(r.resetPassword){if(!c)return(0,K.jsx)(sh,{children:(0,K.jsxs)(`div`,{className:`text-center py-12`,children:[(0,K.jsx)(Zr,{className:`size-12 text-muted-foreground mx-auto mb-4`}),(0,K.jsx)(`h1`,{className:`text-xl font-medium mb-2 text-foreground`,children:`Pending Owner Setup`}),(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground max-w-md mx-auto`,children:`This cluster needs an administrator to finish setup before it can be used.`})]})});let e=r.status&&Mo.includes(r.status)&&Go(r);return(0,K.jsx)(ne,{to:`${_}/${e?`finish-setup`:`starting-up`}`,replace:!0})}let x=l.checkForFabricConnect(r.id),S=!!i,C=l.getLastConnectMode(r.id),w=(r.instances??[]).filter(e=>e.status&&!No.includes(e.status)).length,T=r.instances??[],E=!!r.status&&Mo.includes(r.status)&&T.length>0&&T.every(e=>e.safeMode);return(0,K.jsxs)(sh,{children:[(0,K.jsxs)(`div`,{className:`flex items-start gap-4 mb-6`,children:[(0,K.jsx)(`div`,{className:`flex items-center justify-center size-12 rounded-xl bg-violet-50 text-primary dark:bg-grey-700 dark:text-violet-300 shrink-0`,children:(0,K.jsx)(Zr,{className:`size-6`})}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3 flex-wrap`,children:[(0,K.jsx)(`h1`,{className:`text-2xl font-light text-foreground`,children:r.name}),(0,K.jsx)(lh,{status:r.status}),E&&(0,K.jsx)(uh,{})]}),(0,K.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-sm text-muted-foreground`,children:[(0,K.jsxs)(`span`,{children:[w,` `,w===1?`instance`:`instances`]}),(0,K.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,K.jsxs)(`a`,{href:`https://${p}`,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 hover:text-foreground hover:underline`,children:[p,(0,K.jsx)(dr,{className:`size-3`})]}),(0,K.jsxs)(bi,{children:[(0,K.jsx)(xi,{"aria-label":`Copy cluster URLs`,className:`rounded-md p-1 -m-1 hover:bg-accent/60 hover:text-foreground`,children:(0,K.jsx)(sr,{className:`size-3.5`})}),(0,K.jsxs)(Si,{align:`start`,children:[(0,K.jsx)(Ci,{onClick:m,children:`Copy host name`}),(0,K.jsx)(Ci,{onClick:g,children:`Copy API URL`})]})]})]})]}),(0,K.jsx)(ih,{cluster:r})]}),a?(0,K.jsx)(ch,{}):S?(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-4 text-sm`,children:[(0,K.jsx)(Qn,{className:`size-4 text-green shrink-0`}),(0,K.jsx)(`span`,{className:`font-medium text-green`,children:x?`Connected via Fabric Connect`:`Signed in directly`}),(0,K.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`· `,x?`through your Harper account`:`session cookie`]})]}),(0,K.jsxs)(V,{to:`${_}/apps`,className:`group flex items-center gap-4 rounded-2xl border-2 border-primary/30 bg-primary/5 p-6 transition-all hover:border-primary hover:bg-primary/10 dark:border-violet-400/30 dark:bg-violet-400/5 dark:hover:border-violet-400 dark:hover:bg-violet-400/10`,children:[(0,K.jsx)(`div`,{className:`flex size-12 items-center justify-center rounded-xl bg-primary/10 text-primary shrink-0 dark:bg-violet-400/15 dark:text-violet-300`,children:(0,K.jsx)(Gr,{className:`size-6`})}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`div`,{className:`text-lg font-medium text-foreground`,children:`Enter cluster`}),(0,K.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`Open the studio — apps, databases, APIs, logs, and config.`})]}),(0,K.jsx)(Bn,{className:`size-5 text-muted-foreground transition-transform group-hover:translate-x-1`})]}),(0,K.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-4 text-sm`,children:[x&&(0,K.jsx)(`button`,{type:`button`,onClick:y,className:`text-muted-foreground hover:text-foreground transition-colors`,children:`Switch to direct sign-in`}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>void b(),className:`text-muted-foreground hover:text-destructive transition-colors`,children:x?`Disconnect`:`Direct sign out`})]})]}):(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{className:`text-sm font-medium text-foreground mb-3`,children:`Connect to this cluster`}),(0,K.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3.5`,children:[c&&!El(r)&&(0,K.jsx)(dh,{icon:gi,title:`Fabric Connect`,description:`Connect through your Harper account. No cluster credentials needed.`,pill:C===`fabric`?`last`:C?void 0:`recommended`,children:(0,K.jsx)(F,{className:`w-full`,disabled:d,onClick:()=>void v(),children:d?(0,K.jsx)(kr,{className:`animate-spin`}):`Fabric Connect`})}),(0,K.jsx)(dh,{icon:wr,title:`Direct sign-in`,description:`Sign in with this cluster's Harper username and password.`,pill:C===`direct`?`last`:void 0,children:(0,K.jsx)(F,{className:`w-full`,variant:`outline`,onClick:y,children:`Direct sign-in`})})]})]}),(0,K.jsx)(th,{clusterId:r.id,base:_})]})}function oh({cluster:e}){let t=ae(),n=L(),r=`/${e.organizationId}/${e.id}`,i=(0,q.useMemo)(()=>(e.instances??[]).filter(e=>e.status&&!No.includes(e.status)).sort(au),[e.instances]),a=i.at(0),{user:o,isLoading:s}=Ne(a?.id),c=!!a&&!!o,d=(0,q.useCallback)(()=>{a&&n({to:`${r}/instance/${a.id}/sign-in`})},[r,a,n]),p=(0,q.useCallback)(async()=>{if(a){try{await u({instanceClient:h({id:a.id,operationsUrl:f(a)}),entityId:a.id})}catch{}l.setUserForEntity(a,null),l.flagForBasicAuth(a.id,null),await t.invalidate()}},[a,t]);return(0,K.jsxs)(sh,{children:[(0,K.jsxs)(`div`,{className:`flex items-start gap-4 mb-6`,children:[(0,K.jsx)(`div`,{className:`flex items-center justify-center size-12 rounded-xl bg-violet-50 text-primary dark:bg-grey-700 dark:text-violet-300 shrink-0`,children:(0,K.jsx)(Zr,{className:`size-6`})}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3 flex-wrap`,children:[(0,K.jsx)(`h1`,{className:`text-2xl font-light text-foreground`,children:e.name}),(0,K.jsx)(`span`,{className:`inline-flex items-center gap-1.5 text-xs px-2.5 py-0.5 rounded-full text-muted-foreground bg-muted`,children:`Self-Hosted`})]}),(0,K.jsx)(`div`,{className:`mt-1 text-sm text-muted-foreground`,children:(0,K.jsxs)(V,{to:`${r}/instances`,className:`hover:text-foreground hover:underline`,children:[i.length,` `,i.length===1?`instance`:`instances`]})})]})]}),a?s?(0,K.jsx)(ch,{}):c?(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-4 text-sm`,children:[(0,K.jsx)(Qn,{className:`size-4 text-green shrink-0`}),(0,K.jsx)(`span`,{className:`font-medium text-green`,children:`Signed in directly`}),(0,K.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`· `,a.name||a.instanceFqdn]})]}),(0,K.jsxs)(V,{to:`${r}/instance/${a.id}/`,className:`group flex items-center gap-4 rounded-2xl border-2 border-primary/30 bg-primary/5 p-6 transition-all hover:border-primary hover:bg-primary/10 dark:border-violet-400/30 dark:bg-violet-400/5 dark:hover:border-violet-400 dark:hover:bg-violet-400/10`,children:[(0,K.jsx)(`div`,{className:`flex size-12 items-center justify-center rounded-xl bg-primary/10 text-primary shrink-0 dark:bg-violet-400/15 dark:text-violet-300`,children:(0,K.jsx)(Gr,{className:`size-6`})}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`div`,{className:`text-lg font-medium text-foreground`,children:`Enter cluster`}),(0,K.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`Open the studio — apps, databases, APIs, logs, and config.`})]}),(0,K.jsx)(Bn,{className:`size-5 text-muted-foreground transition-transform group-hover:translate-x-1`})]}),(0,K.jsx)(`div`,{className:`mt-4 flex flex-wrap gap-4 text-sm`,children:(0,K.jsx)(`button`,{type:`button`,onClick:()=>void p(),className:`text-muted-foreground hover:text-destructive transition-colors`,children:`Direct sign out`})})]}):(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{className:`text-sm font-medium text-foreground mb-3`,children:`Connect to this cluster`}),(0,K.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3.5`,children:(0,K.jsx)(dh,{icon:wr,title:`Direct sign-in`,description:`Sign in with this instance's Harper username and password.`,children:(0,K.jsx)(F,{className:`w-full`,variant:`outline`,onClick:d,children:`Direct sign-in`})})})]}):(0,K.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`This cluster has no instances yet. Register one from the`,` `,(0,K.jsx)(V,{to:`${r}/instances`,className:`underline hover:text-foreground`,children:`Instances`}),` page.`]})]})}function sh({children:e}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Ks,{}),(0,K.jsx)(Kl,{children:(0,K.jsx)(`div`,{className:`max-w-3xl`,children:e})})]})}function ch(){return(0,K.jsx)(`div`,{className:`flex justify-center py-10 text-muted-foreground`,children:(0,K.jsx)(kr,{className:`size-6 animate-spin`})})}function lh({status:e}){let t=e&&Mo.includes(e)?`text-green bg-green/10`:e===`STOPPED`?`text-destructive bg-destructive/10`:e===`PARTIAL`?`text-yellow bg-yellow/10`:`text-muted-foreground bg-muted`;return(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs px-2.5 py-0.5 rounded-full ${t}`,children:[(0,K.jsx)(`span`,{className:`size-1.5 rounded-full bg-current`}),e?e.charAt(0)+e.slice(1).toLowerCase():`Unknown`]})}function uh(){return(0,K.jsxs)(`span`,{title:`All instances running in safe mode — user apps/components are not loaded`,className:`inline-flex items-center gap-1.5 text-xs px-2.5 py-0.5 rounded-full text-yellow bg-yellow/10`,children:[(0,K.jsx)(Dr,{className:`size-3`}),`Safe mode`]})}function dh({icon:e,title:t,description:n,pill:r,children:i}){return(0,K.jsxs)(`div`,{className:`relative rounded-xl p-4.5 bg-card border ${r===`last`?`border-2 border-green`:r===`recommended`?`border-2 border-primary dark:border-violet-400`:`border-border`}`,children:[r&&(0,K.jsx)(`span`,{className:`absolute -top-2.5 left-4 rounded-full bg-card`,children:(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs px-2.5 py-0.5 rounded-full ${r===`last`?`text-green bg-green/15`:`text-primary bg-violet-50 dark:text-violet-300 dark:bg-grey-700`}`,children:[r===`last`&&(0,K.jsx)(`span`,{className:`size-1.5 rounded-full bg-current`}),r===`last`?`Last used`:`Recommended`]})}),(0,K.jsx)(e,{className:`size-6 text-primary dark:text-violet-300 mb-2`}),(0,K.jsx)(`div`,{className:`text-[15px] font-medium text-foreground mb-1`,children:t}),(0,K.jsx)(`p`,{className:`text-[13px] text-muted-foreground leading-normal mb-4`,children:n}),i]})}function fh({children:e,className:t}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Ks,{}),(0,K.jsx)(Kl,{children:(0,K.jsx)(`div`,{className:t,children:e})})]})}var ph=new Set([`com`,`co`,`org`,`net`,`edu`,`gov`,`mil`,`me`,`biz`,`info`,`ac`,`or`,`ne`,`go`,`lg`,`asn`,`id`,`nom`,`sch`,`ltd`,`plc`]);function mh(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&&ph.has(r)?3:2;return t.length<=i?`@`:t.slice(0,-i).join(`.`)}function hh({cluster:{fqdn:e},domain:{domain:t,id:n}}){let r=mh(t),[i,a,o]=Vl(r,e||``,n);return(0,K.jsxs)(`div`,{className:`grid gap-4 grid-cols-1 md:grid-cols-[80px_1fr] pb-6`,children:[(0,K.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,K.jsx)(`div`,{className:`col-span-1`,children:`Type:`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`CNAME`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Name:`}),(0,K.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,K.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,K.jsx)(F,{type:`button`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:i,children:(0,K.jsx)(sr,{className:`w-3.5 h-3.5`})})]})}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`TTL:`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Auto`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Target:`}),(0,K.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,K.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,K.jsx)(F,{type:`button`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:a,children:(0,K.jsx)(sr,{className:`w-3.5 h-3.5`})})]})}),(0,K.jsx)(`div`,{className:`col-span-1 text-xs`,children:`Domain ID:`}),(0,K.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-0.5 text-xs text-muted-foreground italic flex-1 overflow-hidden`,children:[(0,K.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,K.jsx)(F,{type:`button`,variant:`ghost`,className:`h-5 w-5 p-0 shrink-0`,onClick:o,children:(0,K.jsx)(sr,{className:`w-3 h-3`})})]})}),(0,K.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 gh({certificate:e,domain:t,cluster:n}){let r=mh(t.domain),[i,a,o]=Vl(r,n.fqdn||``,t.id),s=(0,q.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,K.jsxs)(`div`,{className:`w-full max-w-2xl border border-border/50 rounded-md p-4 bg-gray-900/20`,children:[(0,K.jsxs)(`div`,{className:`mb-4`,children:[(0,K.jsx)(`div`,{className:`w-full h-1.5 rounded-full overflow-clip flex shadow-sm bg-gray-800`,children:(0,K.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,K.jsx)(`div`,{className:`text-[10px] text-muted-foreground font-light mt-1 italic`,children:s.text})]}),(0,K.jsxs)(`div`,{className:`grid gap-2 grid-cols-1 md:grid-cols-[80px_1fr] text-sm`,children:[(0,K.jsx)(`div`,{className:`col-span-1 text-xs text-muted-foreground`,children:`CNAME:`}),(0,K.jsxs)(`div`,{className:`col-span-1 flex gap-2 items-center flex-wrap`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted px-2 py-0.5 rounded text-xs`,children:[(0,K.jsx)(`span`,{className:`truncate max-w-[150px]`,title:r,children:r}),(0,K.jsx)(F,{type:`button`,variant:`ghost`,size:`sm`,className:`h-4 w-4 p-0`,onClick:i,title:`Copy Name`,children:(0,K.jsx)(sr,{className:`w-3 h-3`})})]}),(0,K.jsx)(_h,{}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted px-2 py-0.5 rounded text-xs`,children:[(0,K.jsx)(`span`,{className:`truncate max-w-[200px]`,title:n.fqdn||``,children:n.fqdn}),(0,K.jsx)(F,{type:`button`,variant:`ghost`,size:`sm`,className:`h-4 w-4 p-0`,onClick:a,title:`Copy Target`,children:(0,K.jsx)(sr,{className:`w-3 h-3`})})]})]}),(0,K.jsx)(`div`,{className:`col-span-1 text-[10px] text-muted-foreground`,children:`Domain ID:`}),(0,K.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted px-2 py-0.5 rounded text-[10px] text-muted-foreground italic`,children:[(0,K.jsx)(`span`,{className:`truncate max-w-[200px]`,children:t.id}),(0,K.jsx)(F,{type:`button`,variant:`ghost`,size:`sm`,className:`h-3 w-3 p-0`,onClick:o,title:`Copy ID`,children:(0,K.jsx)(sr,{className:`w-2.5 h-2.5`})})]})})]})]})}function _h(){return(0,K.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,K.jsx)(`path`,{d:`M5 12h14`}),(0,K.jsx)(`path`,{d:`m12 5 7 7-7 7`})]})}function vh(e){let{enabled:t,entityId:n,databaseName:r,tableName:i,searchAttribute:a,sort:o,pageIndex:s,pageSize:c,onlyIfCached:l,getAttributes:u}=e;return z({enabled:t,queryKey:[n,r,i,`search_by_value`,a,o.attribute||`default`,o.descending||!1,s||0,c||0,l,u??null],retry:!1,staleTime:6e4,gcTime:5e3,queryFn:()=>yh(e)})}async function yh({instanceClient:e,databaseName:t,tableName:n,searchAttribute:r,sort:i,pageIndex:a,pageSize:o,onlyIfCached:s,getAttributes:c,headers:l}){let u=i.attribute.length&&!(i.attribute===r&&!i.descending),d=await e.post(`/`,{operation:`search_by_value`,get_attributes:c??[`*`],database:t,table:n,search_attribute:r,search_value:`*`,sort:u?i:void 0,offset:a*o,limit:o,onlyIfCached:s,noCacheStore:s},{timeout:0,headers:l,validateStatus:e=>e>=200&&e<400||e===404});return d.status===404?{data:[]}:d}function bh(e){return z({queryKey:[e,`ChallengeCertificate`],queryFn:async()=>{if(!e)return[];let{data:t}=await yh({searchAttribute:`domain`,entityId:e,databaseName:`data`,tableName:`ChallengeCertificate`,sort:{attribute:`domain`,descending:!0},instanceClient:h({id:e,forceFabricConnect:!0}),onlyIfCached:!1,pageIndex:0,pageSize:100});return t},enabled:!!e,refetchInterval:jn(5e3),retry:On()})}function xh(e){return H(bh(e))}function Sh({domain:{challengeToken:e,challengeTxtRecord:t,domain:n,id:r},cluster:{fqdn:i}}){let a=mh(n),[o,s,c,l,u]=Vl(t,e,a,i||``,r);return(0,K.jsxs)(`div`,{className:`grid gap-2 grid-cols-1 md:grid-cols-[80px_1fr] pb-6`,children:[(0,K.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,K.jsx)(`div`,{className:`col-span-1`,children:`Type:`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`TXT`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Name:`}),(0,K.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,K.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,K.jsx)(F,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:o,children:(0,K.jsx)(sr,{className:`w-3.5 h-3.5`})})]})}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`TTL:`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Auto`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Content:`}),(0,K.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,K.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,K.jsx)(F,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:s,children:(0,K.jsx)(sr,{className:`w-3.5 h-3.5`})})]})}),(0,K.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,K.jsx)(`div`,{className:`col-span-1`,children:`Type:`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`CNAME`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Name:`}),(0,K.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,K.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,K.jsx)(F,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:c,children:(0,K.jsx)(sr,{className:`w-3.5 h-3.5`})})]})}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`TTL:`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Auto`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Target:`}),(0,K.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,K.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,K.jsx)(F,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:l,children:(0,K.jsx)(sr,{className:`w-3.5 h-3.5`})})]})}),(0,K.jsx)(`div`,{className:`col-span-1 text-xs`,children:`Domain ID:`}),(0,K.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-0.5 text-xs text-muted-foreground italic flex-1 overflow-hidden`,children:[(0,K.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,K.jsx)(F,{type:`button`,size:`sm`,variant:`ghost`,className:`h-5 w-5 p-0 shrink-0`,onClick:u,children:(0,K.jsx)(sr,{className:`w-3 h-3`})})]})}),(0,K.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 Ch({clusterId:e,domainIds:t,generateDomainCerts:n}){let{data:r}=await N.put(`/Cluster/${e}`,{domainIds:t,generateDomainCerts:n},{timeout:0});return r}function wh(){return R({mutationFn:e=>Ch(e)})}A.object({domainId:A.string()});async function Th(e){let{data:t}=await N.delete(`/Domain/${e.domainId}`);return t}function Eh(){return R({mutationFn:e=>Th(e)})}function Dh(e){return[...new Set(e)]}var Oh=Mn();function kh(e,t,n){let{data:r}=xh(e.id),i=(0,q.useMemo)(()=>!!r?.some(e=>!e.issueDate||e.inProgress),[r]),{mutate:a,isPending:o}=wh(),{mutate:s,isPending:c}=Eh(),l=o||c,u=(0,q.useCallback)((t,n)=>{if(!Bo(e.status)){U.error(`Cluster is currently `+e.status,{description:`To bind a domain, it must be running.`});return}a({clusterId:e.id,domainIds:Dh((e.domainIds?.slice()||[]).concat([t])),generateDomainCerts:n},{onSuccess:()=>{yn.invalidateQueries({queryKey:[e.organizationId],refetchType:`active`}),U.success(`Domain bound!`+(n?` Certificates are being generated in the background now.`:``))}})},[a,e]),d=(0,q.useCallback)(t=>{s({domainId:t},{onSuccess:()=>{yn.invalidateQueries({queryKey:[e.organizationId,`domains`],refetchType:`active`}),U.success(`Domain removed!`)}})},[s]),f=(0,q.useCallback)(t=>{a({clusterId:e.id,domainIds:(e.domainIds?.slice()||[]).filter(e=>e!==t),generateDomainCerts:!1},{onSuccess:()=>{yn.invalidateQueries({queryKey:[e.organizationId],refetchType:`active`}),U.success(`Domain unbound!`)}})},[s]);return(0,q.useMemo)(()=>[Oh.display({id:`select`,header:`Bind`,size:50,cell:r=>{let a=r.row.original;return a.status===`ACTIVE`&&!a.clusterId&&!El(e)?(0,K.jsx)(`label`,{className:`p-10 -m-10`,children:(0,K.jsx)(`input`,{type:`checkbox`,checked:t.includes(a.id),onChange:()=>n(a.id),disabled:l||i})}):null}}),Oh.display({header:`Domains`,id:`domain`,enableSorting:!1,size:150,cell:e=>{let t=e.row.original;return(0,K.jsxs)(Ia,{children:[(0,K.jsx)(La,{asChild:!0,children:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{children:t.domain}),(0,K.jsx)(F,{type:`button`,variant:`destructiveGhost`,className:`text-muted-foreground text-xs`,disabled:l||!!t.clusterId,onClick:()=>d(t.id),children:`Remove Domain`})]})}),(0,K.jsx)(Ra,{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!`})]})}}),Oh.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,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{children:`Bound to this cluster`}),i&&(!i.issueDate||i.inProgress)&&(0,K.jsx)(`div`,{className:`py-2`,children:(0,K.jsx)(gh,{certificate:i,domain:n,cluster:e})}),(0,K.jsx)(F,{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,K.jsx)(Sh,{domain:n,cluster:e}):El(e)?`Cannot be associated with this self-managed cluster.`:n.status===`ACTIVE`&&!n.clusterId?(0,K.jsx)(hh,{cluster:e,domain:n}):n.status}})],[e,u,l,r,i,t,n])}var Ah=A.object({domain:A.string(),organizationId:A.string()});async function jh(e){let{data:t}=await N.post(`/Domain/`,e);return t}function Mh(){return R({mutationFn:e=>jh(e)})}async function Nh(e){let{data:t}=await N.post(`/Domain/${e}/validate`);return t}async function Ph(e){let{data:t}=await N.get(`/Domain/?organizationId=${e}`);return t}function Fh(e){return z({queryKey:[e,`domains`],queryFn:()=>Ph(e)})}function Ih(){let{organizationId:e,clusterId:t}=B({strict:!1}),{data:n}=le(Jo(t,!0)),{update:r}=fl(e),{data:i,refetch:o,isFetching:s,isRefetching:c}=H(Fh(e)),l=(0,q.useMemo)(()=>i?.filter(e=>e.status===`PENDING_VALIDATION`)||[],[i]),[u]=(0,q.useState)({attribute:`domain`,descending:!1}),d=(0,q.useMemo)(()=>[{desc:u.descending,id:u.attribute}],[u]),f=Zf(o),[p,m]=(0,q.useState)([]),h=(0,q.useCallback)(e=>{m(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[]),{mutate:g,isPending:_}=wh(),v=(0,q.useCallback)(()=>{if(!Bo(n.status)){U.error(`Cluster is currently `+n.status,{description:`To bind a domain, it must be running.`});return}g({clusterId:n.id,domainIds:Dh((n.domainIds?.slice()||[]).concat(p)),generateDomainCerts:!0},{onSuccess:()=>{yn.invalidateQueries({queryKey:[n.organizationId],refetchType:`active`}),U.success(`Domain(s) bound! Certificates are being generated in the background now.`),m([])}})},[n,p,g]),{mutateAsync:y,isPending:b}=Mh(),x=dt({resolver:Fe(Ah),defaultValues:{domain:``,organizationId:e}}),S=(0,q.useCallback)(async e=>{if(e){let t=e.domain.split(/[,\s]+/).map(e=>e.trim()).filter(Boolean);for(let n of t)await y({...e,domain:n});x.reset(),await o(),U.success(`${a(t.length,`Domain`,`Domains`)} added! Please add the txt record above to your domain registrar.`)}},[y,x,o]),C=(0,q.useCallback)(async()=>{let e=`Validating ${a(l.length,`domain`,`domains`)}...`,t=`validatingDomains`,n=0,r=0;for(let i of l)try{U.loading(e,{description:`${n++} of ${l.length} checked`,id:t}),await Nh(i.id)}catch{r+=1}r>0?U.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 o(),U.success(`Validation succeeded!`,{description:`Please take a look at the next steps for newly verified domains.`,id:t}))},[l]),w=kh(n,p,h),T=x.watch(`domain`),E=(0,q.useMemo)(()=>typeof T==`string`&&T.trim().split(`.`).length===2,[T]),D=(0,q.useCallback)(()=>{typeof T==`string`&&x.setValue(`domain`,`${T.trim()}, www.${T.trim()}`)},[T,x]);return(0,K.jsx)(Kf,{data:i||[],isFetching:s||c,columns:w,sortingState:d,children:(0,K.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,K.jsx)(Do,{...x,children:(0,K.jsxs)(`form`,{id:`cluster-add-domain-form`,name:`cluster-add-domain-form`,onSubmit:x.handleSubmit(S),className:`flex gap-1 flex-col md:flex-row`,children:[(0,K.jsx)(Y,{control:x.control,name:`domain`,render:({field:e})=>(0,K.jsxs)(X,{className:`flex-1`,children:[(0,K.jsx)(Z,{className:`pb-1`,children:`New Domain Name`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`text`,enterKeyHint:`done`,autoComplete:`off`,...e})}),E&&(0,K.jsxs)(`div`,{className:`mt-1 flex gap-4`,children:[`Adding an apex domain?`,(0,K.jsx)(F,{variant:`positiveOutline`,type:`button`,onClick:D,children:`Add www as well`})]}),(0,K.jsx)(Q,{children:(0,K.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,K.jsxs)(`div`,{className:`flex-0 self-start flex gap-1 md:pt-6.5`,children:[(0,K.jsxs)(F,{type:`submit`,variant:`submit`,disabled:b,children:[(0,K.jsx)(Ur,{}),` Add`]}),l.length>0&&(0,K.jsxs)(F,{variant:`positiveOutline`,onClick:C,accessKey:`r`,type:`button`,disabled:s||c,children:[(0,K.jsx)(Or,{}),` `,(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`u`,{children:`V`}),`alidate`]})]}),(0,K.jsxs)(F,{variant:`defaultOutline`,onClick:f,accessKey:`r`,type:`button`,disabled:s||c,children:[(0,K.jsx)(Wr,{}),` `,(0,K.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,K.jsx)(`u`,{children:`R`}),`efresh`]})]})]})]})}),p.length>0&&(0,K.jsx)(`div`,{className:`flex-0 self-start md:pt-6.5`,children:(0,K.jsxs)(F,{variant:`submit`,onClick:v,disabled:_,children:[(0,K.jsx)(Jr,{}),` Bind `,a(p.length,`Domain`,`Domains`)]})})]})})}function Lh(){return(0,K.jsx)(fh,{className:`flex flex-col justify-start max-w-4xl`,children:(0,K.jsx)(Ih,{})})}var Rh=y({username:Zo,role:M().nonempty({error:`Please select a role.`}),password:Xo.min(8,{error:`Password must be at least 8 characters long.`}),confirmPassword:M()}).refine(e=>e.password===e.confirmPassword,{error:`Passwords do not match.`,path:[`confirmPassword`]});async function zh(e){await N.patch(`/ResetPasswordUpdater/${e}`)}async function Bh(e){let{instanceClient:t,...n}=e,{data:r}=await t.post(`/`,{operation:`add_user`,...n});return r}function Vh(){return R({mutationFn:Bh})}async function Hh({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 Uh(){return R({mutationFn:Hh})}async function Wh({username:e,instanceClient:t}){let{data:n}=await t.post(`/`,{operation:`drop_user`,username:e});return n}function Gh(){return R({mutationFn:Wh})}async function Kh({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 Fo({username:t,password:i,instanceClient:o,entityId:e});return a.instanceClient&&(o=a.instanceClient),n===`HDB_ADMIN`?await Hh({username:n,password:r,instanceClient:o}):(await Bh({username:n,password:r,role:`super_user`,active:!0,instanceClient:o}),await Fo({username:n,password:r,instanceClient:o,entityId:e}),await Wh({username:d,instanceClient:o})),await zh(e),a}catch(t){throw await u({entityId:e,instanceClient:o}),t}}function qh(){return R({mutationFn:Kh})}function Jh(){let{user:e}=je(),{clusterId:t}=B({strict:!1}),{data:n}=H(Jo(t,!0)),r=L(),i=ie(),a=(0,q.useMemo)(()=>o(n),[n]),s=En({operationsUrl:a}),{redirect:c}=se({strict:!1}),u=ae(),f=dt({resolver:Fe(Rh),defaultValues:{confirmPassword:``,password:``,role:`super_user`,username:e?.email??``}}),{setFocus:p,control:m,handleSubmit:h}=f;(0,q.useEffect)(()=>{p(`password`)},[p]);let g=n?.instances?.find(e=>e.tempPassword)?.tempPassword,_=Go(n),{mutate:v,isPending:y}=qh(),b=(0,q.useCallback)(async e=>{if(!a){U.error(`Cluster is not yet fully loaded, please wait a moment before trying to sign in.`);return}if(!_){U.error(`Some instances are still starting up. You can create your admin user once they are all running.`);return}v({instanceClient:s,clusterId:t,newPassword:e.password,tempPassword:g,initialUsername:d,desiredUsername:e.username},{onSuccess:async({message:e,user:a})=>{U.success(e),l.setUserForEntity(n,a),await qo(i,t),u.invalidate(),await r({to:c?.startsWith(`/`)?c:`../`})}})},[n,t,s,_,r,a,i,c,u,v,g]);return n&&!n.resetPassword?(0,K.jsx)(ne,{to:`../sign-in`,replace:!0}):n&&!_?(0,K.jsx)(ne,{to:`../starting-up`,replace:!0}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`nav`,{"aria-label":`Breadcrumb`,className:`fixed top-20 w-full h-12 z-39 px-4 md:px-12 bg-violet-50 border-b border-violet-100 dark:bg-grey-700 dark:border-none flex items-center`,children:(0,K.jsx)(Eo,{})}),(0,K.jsx)(`div`,{className:`items-center justify-center flex mt-32 py-4 min-h-[calc(100vh-(--spacing(32)))]`,children:(0,K.jsxs)(`div`,{className:`text-foreground w-xs`,children:[(0,K.jsx)(`h1`,{className:`text-2xl font-light`,children:`Create Admin User`}),(0,K.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,K.jsx)(Do,{...f,children:(0,K.jsxs)(`form`,{id:`cluster-create-admin-form`,name:`cluster-create-admin-form`,onSubmit:h(b),className:`my-4`,children:[(0,K.jsx)(Y,{control:m,name:`username`,render:({field:e})=>(0,K.jsxs)(X,{className:`my-4`,children:[(0,K.jsx)(Z,{children:`Username`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{autoComplete:`username`,type:`text`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:m,name:`password`,render:({field:e})=>(0,K.jsxs)(X,{className:`my-4`,children:[(0,K.jsx)(Z,{children:`Password`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`password`,autoComplete:`new-password`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:m,name:`confirmPassword`,render:({field:e})=>(0,K.jsxs)(X,{className:`my-4`,children:[(0,K.jsx)(Z,{children:`Confirm Password`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`password`,autoComplete:`new-password`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(F,{disabled:y,type:`submit`,variant:`submit`,className:`w-full my-2`,children:`Create Admin User`})]})}),(0,K.jsxs)(`p`,{className:`text-muted-foreground flex gap-2 align-middle`,children:[(0,K.jsx)(Rn,{size:36,className:`flex-none`}),(0,K.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 Yh({columns:e,data:t,renderRowWrapper:n}){let r=be({features:Nn,data:t,columns:e});return(0,K.jsx)(`div`,{className:`bg-card dark:bg-black-dark rounded-md`,children:(0,K.jsxs)(fn,{children:[(0,K.jsx)(ln,{children:r.getHeaderGroups().map(e=>(0,K.jsx)(dn,{className:`border-none`,children:e.headers.map(e=>(0,K.jsx)(on,{className:`p-4`,style:{width:`${e.getSize()}%`},children:e.isPlaceholder?null:_e(e.column.columnDef.header,e.getContext())},e.id))},e.id))}),(0,K.jsx)(cn,{className:`bg-background dark:bg-black`,children:r.getRowModel().rows?.length?r.getRowModel().rows.map(e=>{let t=(0,K.jsx)(dn,{"data-state":e.getIsSelected()&&`selected`,className:`hover:bg-muted/10 data-[state=selected]:bg-muted`,children:e.getVisibleCells().map(e=>(0,K.jsx)(un,{className:`p-4`,style:{width:`${e.column.getSize()}%`},children:_e(e.column.columnDef.cell,e.getContext())},e.id))});return(0,K.jsx)(q.Fragment,{children:n?n(e.original,t):t},e.id)}):(0,K.jsx)(dn,{children:(0,K.jsx)(un,{colSpan:e.length,className:`h-24 text-center`,children:`No results.`})})})]})})}function Xh(){return(0,K.jsx)(`div`,{className:`flex-col items-center justify-center px-16 space-y-3 text-center pt-30`,children:(0,K.jsx)(`p`,{children:`No instances found.`})})}async function Zh({instance:e,instanceClient:t}){try{await u({instanceClient:t,entityId:e.id})}catch{}l.signOutLocally(e.id),e.clusterId&&l.signOutLocally(e.clusterId)}async function Qh({instanceId:e,action:t,safeMode:n}){let r=n===void 0?{}:{safeMode:n},{data:i}=await N.post(`/HDBInstance/${e}/container/${t}`,r);return i}function $h(){return R({mutationFn:Qh})}var eg={stop:`Stopping`,start:`Starting`,restart:`Restarting`};function tg(e){let{clusterId:t}=B({strict:!1}),{mutateAsync:n,isPending:r}=$h(),i=ie();return{run:(0,q.useCallback)(async(r,a)=>{let o=a?.label??eg[r],s=e.name??e.id,c=U.loading(o,{description:`${o} ${s}. Status will update shortly.`,duration:3e4,action:{label:`Dismiss`,onClick:()=>U.dismiss()}});try{await n({instanceId:e.id,action:r,safeMode:a?.safeMode}),t&&i.invalidateQueries({queryKey:[t]}),i.invalidateQueries({queryKey:[e.id]}),U.dismiss(c),U.success(`Request accepted`,{description:`${s} is ${o.toLowerCase()}. The status will update automatically.`,action:{label:`Dismiss`,onClick:()=>U.dismiss()}})}catch{U.dismiss(c)}},[t,e.id,e.name,n,i]),isPending:r}}function ng({entityId:e,instanceClient:t},n){return z({queryKey:[`get_status`,e],staleTime:9e3,refetchInterval:jn(1e4),retry:On(),retryDelay:1e4,throwOnError:!1,enabled:n,queryFn:async()=>{let{data:e}=await t.post(`/`,{operation:`get_status`});return e}})}function rg(e,t){return e?.systemStatus?.find(e=>e.id===t)?.status}async function ig({instanceClient:e,id:t,status:n}){let{data:r}=await e.post(`/`,{operation:`set_status`,id:t,status:n});return r}function ag(){return R({mutationFn:ig,onSuccess:(e,t)=>yn.invalidateQueries({queryKey:[`get_status`,t.entityId]})})}var og=[`CLONE_READY`,`RUNNING`,`UPDATED`,`PENDING_UPGRADE`];function sg(e,t,n){let{user:r}=Ne(e.id),i=(0,q.useMemo)(()=>f(e),[e]),a=En({operationsUrl:i}),{update:o}=_l(),s=l.checkForFabricConnect(e.id),c=G({operationsUrl:i,instanceId:e.id,forceFabricConnect:!0}),{data:u}=H(ng(c,n&&o&&!zo(e.status))),d=rg(u,`availability`)||`Unknown`,p=d===`Available`,m=d===`Unavailable`,{mutate:h,isPending:g}=ag(),{run:_,isPending:v}=tg(e),[y,b]=(0,q.useState)(null),x=e.instanceFqdn,S=Ef({secure:e.operationsApiSecure?`true`:`false`,port:e.operationsApiPort,fqdn:e.instanceFqdn}),[C,w]=Vl(x??``,S),T=(0,q.useCallback)(async()=>{await Zh({instance:e,instanceClient:a})},[e,a]),E=!!e.status&&og.includes(e.status),D=!!r&&!s,O=E,k=!!x,A=o&&E&&(p||m),j=e.status===`RUNNING`,M=e.status===`STOPPED`,N=o&&!t&&(j||M),P=[O&&D&&{key:`direct-connect`,to:`../instance/${e.id}/`,icon:(0,K.jsx)(Zr,{className:`text-green`}),label:`Direct Connect`},O&&D&&{key:`direct-sign-out`,onClick:T,variant:`destructive`,icon:(0,K.jsx)(jr,{}),label:`Direct Sign Out`},O&&!D&&o&&!t&&{key:`fabric-connect`,to:`../instance/${e.id}/`,icon:(0,K.jsx)(Zr,{className:`text-green`}),label:`Fabric Connect`},O&&!D&&{key:`direct-sign-in`,to:`../instance/${e.id}/sign-in`,icon:(0,K.jsx)(Mr,{}),label:`Direct Sign In`},O&&k&&{type:`separator`,key:`copy-sep`},k&&{key:`copy-fqdn`,onClick:C,icon:(0,K.jsx)(nr,{}),label:`Copy Instance FQDN`},k&&{key:`copy-api`,onClick:w,icon:(0,K.jsx)(nr,{}),label:`Copy API URL`},(O||k)&&A&&{type:`separator`,key:`rotation-sep`},A&&p&&{key:`out-of-rotation`,variant:`destructive`,disabled:g,onClick:()=>h({...c,id:`availability`,status:`Unavailable`}),icon:(0,K.jsx)(ei,{}),label:`Bring out of rotation`},A&&m&&{key:`into-rotation`,disabled:g,onClick:()=>h({...c,id:`availability`,status:`Available`}),icon:(0,K.jsx)($r,{}),label:`Bring back into rotation`},(O||k||A)&&N&&{type:`separator`,key:`container-sep`},N&&{type:`label`,key:`container-label`,className:`text-gray-600 text-xs`,label:`Container`},N&&M&&{key:`container-start`,disabled:v,onClick:()=>void _(`start`,{safeMode:!1}),icon:(0,K.jsx)(Hr,{}),label:`Start`},N&&M&&{key:`container-start-safe`,disabled:v,onClick:()=>b(`start`),icon:(0,K.jsx)(Dr,{}),label:`Start in safe mode`},N&&j&&{key:`container-restart`,disabled:v,onClick:()=>void _(`restart`,{safeMode:!1}),icon:(0,K.jsx)(qr,{}),label:`Restart`},N&&j&&{key:`container-restart-safe`,disabled:v,onClick:()=>b(`restart`),icon:(0,K.jsx)(Dr,{}),label:`Restart in safe mode`},N&&j&&{key:`container-stop`,variant:`destructive`,disabled:v,onClick:()=>void _(`stop`),icon:(0,K.jsx)(ri,{}),label:`Stop`}].filter(kn),F=(0,K.jsx)(Ml,{open:y!==null,setOpen:e=>{e||b(null)},action:y??`restart`,targetName:e.name??e.id,scope:`instance`,isPending:v,onConfirm:()=>{let e=y;b(null),e&&_(e,{safeMode:!0,label:e===`start`?`Starting in safe mode`:`Restarting in safe mode`})}});return P.length?{items:[{type:`label`,key:`label`,className:`text-gray-600 text-xs`,label:`Options`},{type:`separator`,key:`label-sep`},...P],dialog:F}:{items:[],dialog:F}}function cg({instance:e,isSelfManaged:t}){let[n,r]=(0,q.useState)(!1),{items:i,dialog:a}=sg(e,t,n);return i.length?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(bi,{open:n,onOpenChange:r,children:[(0,K.jsx)(xi,{asChild:!0,children:(0,K.jsx)(F,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Instance options`,children:(0,K.jsx)(ur,{})})}),(0,K.jsx)(Si,{align:`end`,className:`min-w-48`,children:nc(i,`dropdown`)})]}),a]}):null}function lg({isSelfManaged:e,instance:t}){let{user:n,isLoading:r}=Ne(t.id),i=(0,q.useMemo)(()=>f(t),[t]),a=En({operationsUrl:i}),{update:o}=_l(),s=l.checkForFabricConnect(t.id),c=(0,q.useCallback)(async()=>{await Zh({instance:t,instanceClient:a})},[t,a]);return zo(t.status)?(0,K.jsx)(`span`,{className:`text-muted-foreground text-sm`,children:`—`}):r||!t.status||![`CLONE_READY`,`RUNNING`,`UPDATED`,`PENDING_UPGRADE`].includes(t.status)?(0,K.jsx)(kr,{className:`animate-spin`,color:`gray`}):!n||s?(0,K.jsxs)(`span`,{className:`flex gap-4`,children:[o&&!e&&(0,K.jsx)(V,{to:`../instance/${t.id}/`,className:`text-sm`,"aria-label":`Connect to ${t.name} instance`,title:`Connect to ${t.name} instance`,children:(0,K.jsx)(F,{variant:`positiveOutline`,children:`Fabric Connect`})}),(0,K.jsx)(V,{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,K.jsx)(F,{variant:o?`defaultOutline`:`positiveOutline`,children:`Direct Sign In`})})]}):(0,K.jsxs)(`span`,{className:`flex gap-4`,children:[(0,K.jsx)(V,{to:`../instance/${t.id}/`,className:`text-sm`,"aria-label":`Go to ${t.name} instance`,title:`Go to ${t.name} instance`,children:(0,K.jsx)(F,{variant:`positiveOutline`,children:`Direct Connect`})}),(0,K.jsx)(F,{variant:`destructiveOutline`,className:`text-sm`,"aria-label":`Sign out from ${t.name} instance`,title:`Sign out from ${t.name} instance`,onClick:c,children:`Direct Sign Out`})]})}function ug({instance:e,isSelfManaged:t,children:n}){let[r,i]=(0,q.useState)(!1),{items:a,dialog:o}=sg(e,t,r);return a.length?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(Js,{onOpenChange:i,children:[(0,K.jsx)(Ys,{asChild:!0,children:n}),(0,K.jsx)(Xs,{className:`min-w-48`,children:nc(a,`context`)})]}),o]}):(0,K.jsx)(K.Fragment,{children:n})}function dg({instance:e,index:t}){let{update:n}=_l(),r=(0,q.useMemo)(()=>f(e),[e]),i=G({operationsUrl:r,instanceId:e.id,forceFabricConnect:!0}),{mutate:a,isPending:o}=ag(),[s,c]=(0,q.useState)(!1);(0,q.useEffect)(()=>{let e=setTimeout(()=>c(!0),t*500);return()=>clearTimeout(e)},[t]);let l=zo(e.status),{data:u,isLoading:d,isFetching:p}=H(ng(i,s&&n&&!l)),m=rg(u,`availability`)||`Unknown`,h=m===`Available`,g=m===`Unavailable`;return n?l?(0,K.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,K.jsxs)(Ia,{children:[(0,K.jsx)(La,{asChild:!0,children:(0,K.jsx)(`span`,{className:`inline-block size-4 rounded-full bg-muted-foreground/40`,"aria-label":`Not running`})}),(0,K.jsx)(Ra,{children:`Not running`})]})}):(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)(Ia,{children:[(0,K.jsx)(La,{asChild:!0,children:(0,K.jsx)(`div`,{className:`flex items-center`,children:d||!s||p&&!u?(0,K.jsx)(kr,{className:`animate-spin size-5 text-muted-foreground`}):(0,K.jsx)(Wi,{variant:h?`success`:g?`destructive`:`default`,className:`size-4 rounded-full p-0`,children:(0,K.jsx)(`span`,{className:`sr-only`,children:h?`Online`:`Offline`})})})}),(0,K.jsxs)(Ra,{children:[p&&u?`Refreshing... `:``,m]})]}),n&&(0,K.jsxs)(`div`,{className:`flex gap-1`,children:[h&&(0,K.jsxs)(Ia,{children:[(0,K.jsx)(La,{asChild:!0,children:(0,K.jsx)(F,{type:`button`,variant:`destructiveGhost`,size:`icon`,onClick:()=>a({...i,id:`availability`,status:`Unavailable`}),disabled:o,children:o?(0,K.jsx)(kr,{className:`animate-spin size-4`}):(0,K.jsx)(ei,{className:`size-4`})})}),(0,K.jsx)(Ra,{children:`Bring out of rotation`})]}),g&&(0,K.jsxs)(Ia,{children:[(0,K.jsx)(La,{asChild:!0,children:(0,K.jsx)(F,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>a({...i,id:`availability`,status:`Available`}),disabled:o,children:o?(0,K.jsx)(kr,{className:`animate-spin size-4`}):(0,K.jsx)($r,{className:`size-4`})})}),(0,K.jsx)(Ra,{children:`Bring back into rotation`})]})]})]}):null}function fg(){let{clusterId:e}=B({strict:!1}),{data:t,isLoading:n}=H(Jo(e,!0)),r=El(t),i=(0,q.useMemo)(()=>[{id:`instanceActions`,size:1,minSize:1,cell:e=>(0,K.jsx)(`div`,{className:`flex justify-end gap-2 items-center`,children:(0,K.jsx)(lg,{isSelfManaged:r,instance:e.row.original})})},r&&{accessorKey:`instanceFqdn`,size:90,header:`URL`,cell:e=>Ef({secure:e.row.original.operationsApiSecure?`true`:`false`,port:e.row.original.operationsApiPort,fqdn:e.row.original.instanceFqdn})},!r&&{accessorKey:`name`,size:90,header:`Name`},!r&&{accessorKey:`status`,header:`Status`,size:1,minSize:1,cell:e=>{let t=e.getValue();return(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(dg,{instance:e.row.original,index:e.row.index}),t?(0,K.jsx)(Wi,{variant:Ro(t),children:wo(t)}):null,e.row.original.safeMode&&!zo(e.row.original.status)?(0,K.jsxs)(Wi,{variant:`warning`,title:`Running in safe mode — user apps/components are not loaded`,children:[(0,K.jsx)(Dr,{}),`Safe mode`]}):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,K.jsxs)(K.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`},{id:`instanceMenu`,size:1,minSize:1,cell:e=>(0,K.jsx)(`div`,{className:`flex justify-end`,children:(0,K.jsx)(cg,{isSelfManaged:r,instance:e.row.original})})}].filter(kn),[r]),a=(0,q.useMemo)(()=>t?.instances?t.instances.filter(e=>e.status&&!No.includes(e.status)).sort(au):[],[t]);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Ks,{}),(0,K.jsx)(Kl,{children:(0,K.jsx)(It,{className:`p-0 min-h-96`,children:(0,K.jsx)(Pt,{className:`p-0 min-h-96`,children:n?(0,K.jsx)(Jd,{}):a.length?(0,K.jsx)(Yh,{data:a,columns:i,renderRowWrapper:(e,t)=>(0,K.jsx)(ug,{instance:e,isSelfManaged:r,children:t})}):(0,K.jsx)(Xh,{})})})})]})}function pg(){let{clusterId:e}=B({strict:!1}),{immediate:t}=se({strict:!1}),n=t===!0||t===`true`,{data:r,isLoading:i}=H(Jo(e,2e3)),a=r?.status,o=(0,q.useMemo)(()=>a&&Mo.includes(a),[a]);return i||!r?(0,K.jsx)(fh,{className:`flex justify-center`,children:(0,K.jsx)(Jd,{})}):o?(0,K.jsx)(fh,{className:`flex justify-center`,children:(0,K.jsxs)(`div`,{className:`center w-2xl flex flex-col gap-4`,children:[(0,K.jsx)(`h1`,{className:`text-xl text-center`,children:`All done!`}),(0,K.jsx)(jl,{cluster:r,forceProgressBarVisible:!0}),(0,K.jsx)(`p`,{children:`Your cluster finished updating, and is ready for interaction.`}),(0,K.jsx)(`div`,{className:`text-center`,children:(0,K.jsx)(Dl,{cluster:r})})]})}):(0,K.jsx)(fh,{className:`flex justify-center`,children:(0,K.jsxs)(`div`,{className:`center w-2xl flex flex-col gap-4`,children:[(0,K.jsx)(`h1`,{className:`text-xl text-center`,children:`Here we go!`}),(0,K.jsx)(jl,{cluster:r,forceProgressBarVisible:!0}),(0,K.jsxs)(`p`,{children:[n?`Your cluster is applying the latest changes immediately, without waiting to take instances out of rotation.`:`Your cluster is updating with the latest changes. This includes waiting several minutes to let traffic drain safely.`,` `,(0,K.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,K.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 mg({children:e,className:t}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Ks,{}),(0,K.jsx)(`div`,{className:g(`mt-32 px-4 py-4 md:px-12 min-h-[calc(100vh-(--spacing(32)))] flex justify-center`,t),children:e})]})}function hg(){let e=ae(),{clusterId:t}=B({strict:!1}),{data:n,isLoading:r}=H(Jo(t,2e3)),i=n?.status,a=(0,q.useMemo)(()=>i&&Mo.includes(i)&&Go(n),[i,n]),o=Vo(i),[,s]=Tn(Sn.SavedClusterState,null),c=(0,q.useCallback)(()=>{s(n),e.navigate({to:`/${n.organizationId}/new-cluster`})},[n,e,s]);return r||!n?(0,K.jsx)(mg,{className:`flex justify-center`,children:(0,K.jsx)(Jd,{})}):o?(0,K.jsx)(mg,{className:`flex justify-center`,children:(0,K.jsxs)(`div`,{className:`center max-w-2xl flex flex-col gap-4 items-center`,children:[(0,K.jsx)(rr,{className:`w-24 h-24`}),(0,K.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,K.jsx)(Wl,{}),` if you want more help.`]}),(0,K.jsx)(F,{type:`button`,variant:`positiveOutline`,onClick:c,children:`Try Again`})]})}):a?(0,K.jsx)(mg,{className:`flex justify-center`,children:(0,K.jsxs)(`div`,{className:`center max-w-2xl flex flex-col gap-4`,children:[(0,K.jsx)(`h1`,{className:`text-xl text-center`,children:`It's ready!`}),(0,K.jsx)(jl,{cluster:n,forceProgressBarVisible:!0}),(0,K.jsxs)(`p`,{children:[`Let's set up your secure, browser-to-cluster connection now.`,` `,(0,K.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,K.jsx)(`em`,{children:`Direct Connect`}),`! Once you create your user, you will have the option to`,` `,(0,K.jsx)(`em`,{children:`Fabric Connect`}),` from your Fabric account without having to sign in again.`]})]}),(0,K.jsx)(`div`,{className:`text-center`,children:(0,K.jsx)(Dl,{cluster:n})})]})}):(0,K.jsx)(mg,{className:`flex justify-center`,children:(0,K.jsxs)(`div`,{className:`center max-w-2xl flex flex-col gap-4`,children:[(0,K.jsx)(`h1`,{className:`text-xl text-center`,children:`Here we go!`}),(0,K.jsx)(jl,{cluster:n,forceProgressBarVisible:!0}),(0,K.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,K.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,K.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 gg(){let{clusterId:e}=B({strict:!1}),{data:t,isLoading:n}=Qm(e);if(n)return(0,K.jsxs)(fh,{className:`max-w-4xl pb-20`,children:[(0,K.jsx)(`h1`,{className:`text-2xl font-light text-foreground`,children:`Usage`}),(0,K.jsx)(`div`,{className:`flex justify-center py-16 text-muted-foreground`,children:(0,K.jsx)(kr,{className:`size-6 animate-spin`})})]});let r=t&&!t.selfManaged?Sg(t.regions):null;return(0,K.jsxs)(fh,{className:`max-w-4xl pb-20`,children:[(0,K.jsx)(`h1`,{className:`text-2xl font-light text-foreground`,children:`Usage`}),t?t.selfManaged?(0,K.jsx)(Tg,{children:`Usage isn't tracked for self-hosted clusters — they run under their own license.`}):t.regions.length===0?(0,K.jsx)(Tg,{children:`No usage has been recorded for the current cycle yet.`}):(0,K.jsxs)(`div`,{className:`mt-5 space-y-3`,children:[t.regions.map(e=>(0,K.jsx)(_g,{region:e,showPlanInfo:r==null},e.region??e.regionIds.join())),r&&(0,K.jsx)(vg,{header:(0,K.jsx)(yg,{title:`Plan limits & resources`}),aside:r.planId??void 0,children:(0,K.jsx)(bg,{rateLimits:r.rateLimits,resourcesPerInstance:r.resourcesPerInstance})})]}):(0,K.jsx)(Eg,{})]})}function _g({region:e,showPlanInfo:t}){let n=Jm.map(t=>Ym(t,e.metrics[t])),r=[e.planName?`${e.planName} plan`:null,e.status===`exhausted`?`consumed — awaiting renewal`:e.status===`lapsed`?`not renewed`:e.expiresAt?`renews ${xg(e.expiresAt)}`:null].filter(Boolean).join(` · `);return(0,K.jsxs)(vg,{defaultOpen:e.status!==`lapsed`,aside:e.regionIds.length>0?e.regionIds.join(`, `):void 0,header:(0,K.jsxs)(yg,{title:e.region??`Region`,meta:r,children:[e.status===`exhausted`&&(0,K.jsx)(`span`,{className:`rounded-full bg-yellow/10 px-2 py-0.5 text-[11px] text-yellow`,children:`Cycle exhausted`}),e.status===`lapsed`&&(0,K.jsx)(`span`,{className:`rounded-full bg-muted px-2 py-0.5 text-[11px] text-muted-foreground`,children:`No active license`})]}),children:[(0,K.jsx)(`div`,{className:`grid grid-cols-1 gap-x-10 gap-y-4 sm:grid-cols-2`,children:n.map(e=>(0,K.jsx)(Xm,{...e},e.label))}),t&&(0,K.jsx)(bg,{rateLimits:e.rateLimits,resourcesPerInstance:e.resourcesPerInstance})]})}function vg({header:e,aside:t,defaultOpen:n=!0,children:r}){let[i,a]=(0,q.useState)(n);return(0,K.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-border`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>a(e=>!e),"aria-expanded":i,className:`flex w-full items-center gap-3 px-4 py-3 text-left transition-colors hover:bg-accent/40`,children:[(0,K.jsx)(gn,{className:`size-4 shrink-0 text-muted-foreground transition-transform ${i?`rotate-90`:``}`}),(0,K.jsx)(`div`,{className:`min-w-0 flex-1`,children:e}),t&&(0,K.jsx)(`span`,{className:`shrink-0 self-start pt-0.5 font-mono text-[11px] text-muted-foreground/70`,children:t})]}),i&&(0,K.jsx)(`div`,{className:`border-t border-border px-4 py-4`,children:r})]})}function yg({title:e,meta:t,children:n}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,K.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:e}),n]}),t&&(0,K.jsx)(`div`,{className:`mt-0.5 text-xs text-muted-foreground`,children:t})]})}function bg({rateLimits:e,resourcesPerInstance:t}){let n=e,r=n?wg([[`Reads / minute`,n.readsPerMinute,ff],[`Read bandwidth / minute`,n.readsPerMinuteBytes,df],[`Writes / minute`,n.writesPerMinute,ff],[`Write bandwidth / minute`,n.writesPerMinuteBytes,df],[`Real-time deliveries / minute`,n.realTimeDeliveriesPerMinute,ff],[`Real-time bandwidth / minute`,n.realTimeDeliveryBytesPerMinute,df],[`TLS handshakes (cycle)`,n.tlsHandshakes,ff]]):[],i=t,a=i?Cg([[`Storage`,i.storageGb,e=>`${ff(e)} GB`],[`Memory`,i.memoryMb,e=>df(e*1e3*1e3)],[`vCPU`,i.cpuCores,e=>`${e} ${e===1?`core`:`cores`}`],[`Threads`,i.threads,e=>String(e)]]):[];return(0,K.jsxs)(K.Fragment,{children:[r.length>0&&(0,K.jsx)(Dg,{title:`Rate limits`,subtitle:`Throughput ceilings — not part of the cycle allotment, and not metered.`,children:(0,K.jsx)(Og,{rows:r})}),a.length>0&&(0,K.jsx)(Dg,{title:`Per-instance resources`,subtitle:`Provisioned capacity on each instance.`,children:(0,K.jsx)(Og,{rows:a})})]})}function xg(e){return new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`}).format(new Date(e))}function Sg(e){if(e.length===0)return null;let t=e[0];if(t.rateLimits==null&&t.resourcesPerInstance==null)return null;let n=e=>JSON.stringify([e.rateLimits,e.resourcesPerInstance]),r=n(t),i=e.every(e=>e.planId===t.planId);return e.every(e=>n(e)===r)?{rateLimits:t.rateLimits,resourcesPerInstance:t.resourcesPerInstance,planId:i?t.planId:null}:null}function Cg(e){return e.filter(e=>typeof e[1]==`number`&&e[1]>0).map(([e,t,n])=>[e,n(t)])}function wg(e){return e.filter(e=>e[1]!=null).map(([e,t,n])=>[e,t.unlimited?`Unlimited`:t.limitKnown&&t.limit!=null?n(t.limit):`—`])}function Tg({children:e}){return(0,K.jsx)(`p`,{className:`mt-3 text-sm text-muted-foreground`,children:e})}function Eg(){return(0,K.jsx)(`div`,{role:`alert`,className:`mt-5 rounded-xl border border-destructive/40 bg-destructive/10 p-4 text-sm text-destructive`,children:`Couldn't load usage data — refresh to try again.`})}function Dg({title:e,subtitle:t,children:n}){return(0,K.jsxs)(`div`,{className:`mt-6 first:mt-0`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium text-foreground`,children:e}),(0,K.jsx)(`p`,{className:`mt-0.5 mb-3 text-xs text-muted-foreground`,children:t}),n]})}function Og({rows:e}){return(0,K.jsx)(`dl`,{className:`grid grid-cols-1 gap-x-10 gap-y-2 sm:grid-cols-2`,children:e.map(([e,t])=>(0,K.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2 border-b border-border/60 py-1.5 text-sm`,children:[(0,K.jsx)(`dt`,{className:`text-muted-foreground`,children:e}),(0,K.jsx)(`dd`,{className:`text-foreground tabular-nums`,children:t})]},e))})}I({getParentRoute:()=>Hm,path:`instances`,head:()=>({meta:[{title:`Instances — Harper Fabric`}]}),component:fg}),I({getParentRoute:()=>Hm,path:`starting-up`,head:()=>({meta:[{title:`Starting Up — Harper Fabric`}]}),component:hg}),I({getParentRoute:()=>Hm,path:`scaling`,head:()=>({meta:[{title:`Scaling — Harper Fabric`}]}),component:pg}),I({getParentRoute:()=>Hm,path:`domains`,head:()=>({meta:[{title:`Domains — Harper Fabric`}]}),component:Lh}),I({getParentRoute:()=>Hm,path:`usage`,head:()=>({meta:[{title:`Usage — Harper Fabric`}]}),component:gg});function kg({location:e,params:t}){let n=l.checkForFabricConnect(t.clusterId);if(l.getConnectionById(t.clusterId).user&&!n){let t=e?.search?.redirect;throw re({to:t?.startsWith(`/`)?t:`../`})}}function Ag({location:e,params:t}){let n=l.checkForFabricConnect(t.instanceId);if(l.getConnectionById(t.instanceId).user&&!n){let t=e?.search?.redirect;throw re({to:t?.startsWith(`/`)?t:`../`})}}I({getParentRoute:()=>Hm,path:`sign-in`,head:()=>({meta:[{title:`Sign In — Harper Fabric`}]}),component:is,beforeLoad:kg}),I({getParentRoute:()=>Hm,path:`instance/$instanceId/sign-in`,head:()=>({meta:[{title:`Sign In — Harper Fabric`}]}),component:is,beforeLoad:Ag}),I({getParentRoute:()=>Hm,path:`finish-setup`,head:()=>({meta:[{title:`Create Admin User — Harper Fabric`}]}),component:Jh}),I({getParentRoute:()=>Hm,path:`/`,head:()=>({meta:[{title:`Cluster — Harper Fabric`}]}),component:ah});function jg(e){return I({getParentRoute:()=>e,path:`apis`,head:()=>({meta:[{title:`APIs — Harper Fabric`}]})}).lazy(()=>Te(()=>import(`./index.lazy-BNqr3j0f.js`).then(e=>e.route),__vite__mapDeps([30,1,2,3,4,5,6,7,31,9,32,18,33,34])))}function Mg(e,t){return[I({getParentRoute:()=>e,path:t===`cluster`?`apps`:`/`,head:()=>({meta:[{title:`Applications — Harper Fabric`}]}),component:me(()=>Te(()=>import(`./applications-DCmc9-lk.js`),__vite__mapDeps([35,1,18,3,2,4,5,6,7,17,20,9,8,10,11,12,31,13,36,37,38,32,39,40,23,24,25,15,33,41,26,27,28,29,42])),`ApplicationsEditor`)})]}async function Ng({instanceClient:e}){let{data:t}=await e.post(`/`,{operation:`list_certificates`});return t}function Pg(e){return z({queryKey:[e.entityId,`list_certificates`],queryFn:()=>Ng(e)})}var Fg=[{header:`Certificate Name`,accessorKey:`name`,enableSorting:!0},{header:`Issuer`,accessorKey:`details.issuer`,enableSorting:!0},Mn().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`})];async function Ig({instanceClient:e},t){let{data:n}=await e.post(`/`,{operation:`add_certificate`,...t});return n}var Lg=y({name:M().min(1,`Name is required`),certificate:M().min(1,`Certificate is required`),private_key:M().optional(),is_authority:S().default(!1),hosts:M().optional(),uses:M().optional()});function Rg(){return R({mutationFn:({instanceParams:e,certificateParams:t})=>Ig(e,t)})}function zg({isModalOpen:e,onChangesSaved:t,setIsModalOpen:n}){let r=dt({resolver:Fe(Lg),defaultValues:{name:``,certificate:``,private_key:``,is_authority:!1,hosts:``,uses:``}}),i=G(),{mutate:a,isPending:o}=Rg(),s=(0,q.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(),U.success(`Certificate added successfully!`),n(!1)}})},[a,r,i,t,n]),c=(0,q.useCallback)(()=>{r.reset(),n(!1)},[r,n]);return(0,K.jsx)(Rt,{onOpenChange:n,open:e,children:(0,K.jsx)(Ut,{"aria-describedby":void 0,children:(0,K.jsx)(Do,{...r,children:(0,K.jsxs)(`form`,{id:`instance-add-certificate-form`,name:`instance-add-certificate-form`,onSubmit:r.handleSubmit(s),className:`grid gap-4 my-4`,children:[(0,K.jsxs)(Bt,{children:[(0,K.jsx)(qt,{children:`Add New Certificate`}),(0,K.jsx)(Zt,{children:`Enter the details of your Certificate below.`})]}),(0,K.jsx)(Y,{control:r.control,name:`name`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Name`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`text`,autoComplete:`off`,autoCapitalize:`off`,autoFocus:!0,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:r.control,name:`is_authority`,render:({field:e})=>(0,K.jsxs)(X,{className:`flex flex-row items-center justify-between rounded-lg border border-gray-800 p-3 shadow-sm`,children:[(0,K.jsx)(`div`,{className:`space-y-0.5`,children:(0,K.jsx)(Z,{children:`Is Authority`})}),(0,K.jsx)(J,{children:(0,K.jsx)(Tp,{checked:e.value,onCheckedChange:e.onChange})})]})}),(0,K.jsx)(Y,{control:r.control,name:`certificate`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Certificate`}),(0,K.jsx)(J,{children:(0,K.jsx)(Pn,{autoComplete:`off`,autoCapitalize:`off`,rows:5,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:r.control,name:`hosts`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Hosts (optional)`}),(0,K.jsx)(ef,{children:`Comma-separated list of hostnames this certificate is valid for.`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`text`,autoComplete:`off`,autoCapitalize:`off`,placeholder:`e.g. example.com, *.example.com`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:r.control,name:`uses`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Uses (optional)`}),(0,K.jsx)(ef,{children:`Comma-separated list of intended uses, e.g. "https, operations, wss".`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`text`,autoComplete:`off`,autoCapitalize:`off`,placeholder:`e.g. https, operations, wss`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:r.control,name:`private_key`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Private Key (optional)`}),(0,K.jsx)(ef,{children:`PEM formatted private key string.`}),(0,K.jsx)(J,{children:(0,K.jsx)(Pn,{autoComplete:`off`,autoCapitalize:`off`,rows:5,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(zt,{children:(0,K.jsxs)(`div`,{className:`flex justify-between w-full`,children:[(0,K.jsx)(F,{variant:`destructiveOutline`,type:`button`,onClick:c,disabled:o,children:`Cancel`}),(0,K.jsxs)(F,{type:`submit`,variant:`submit`,disabled:o||!r.formState.isDirty||!r.formState.isValid,children:[(0,K.jsx)(Jr,{}),` Add Certificate`]})]})})]})})})})}async function Bg({instanceClient:e},t){let{data:n}=await e.post(`/`,{operation:`remove_certificate`,name:t});return n}function Vg(){return R({mutationFn:({instanceParams:e,name:t})=>Bg(e,t)})}function Hg({data:e,isModalOpen:t,closeModal:n,onSelectCertificate:r,onChangesSaved:i}){let{name:a}=e,o=G(),{mutate:s,isPending:c}=Vg(),[l,u]=(0,q.useState)(!1),d=(0,q.useCallback)(()=>{u(!0)},[]),f=(0,q.useCallback)(()=>{s({instanceParams:o,name:a},{onSuccess:()=>{U.success(`Certificate removed successfully!`),r(void 0),i()}})},[a,s,o,i,r]);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Rt,{onOpenChange:n,open:t,children:(0,K.jsx)(Ut,{className:`sm:max-w-[800px] max-h-[90vh] overflow-y-auto`,"aria-describedby":void 0,children:(0,K.jsxs)(`div`,{className:`grid gap-4 my-4`,children:[(0,K.jsxs)(Bt,{children:[(0,K.jsxs)(qt,{children:[`View Certificate: `,a]}),(0,K.jsx)(Zt,{children:`Details of the selected certificate.`})]}),(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 text-sm bg-muted p-4 rounded-lg border border-border`,children:[(0,K.jsxs)(`div`,{className:`col-span-2`,children:[(0,K.jsx)(`p`,{className:`font-semibold`,children:`Issuer`}),(0,K.jsx)(`p`,{className:`text-muted-foreground break-all`,children:e.details.issuer||`N/A`})]}),(0,K.jsxs)(`div`,{className:`col-span-2`,children:[(0,K.jsx)(`p`,{className:`font-semibold`,children:`Subject`}),(0,K.jsx)(`p`,{className:`text-muted-foreground break-all`,children:e.details.subject||`N/A`})]}),e.details.subject_alt_name&&(0,K.jsxs)(`div`,{className:`col-span-2`,children:[(0,K.jsx)(`p`,{className:`font-semibold`,children:`Subject Alternative Name`}),(0,K.jsx)(`p`,{className:`text-muted-foreground break-all`,children:e.details.subject_alt_name})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`font-semibold`,children:`Valid From`}),(0,K.jsx)(`p`,{className:`text-muted-foreground`,children:e.details.valid_from?new Date(e.details.valid_from).toLocaleString():`N/A`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`font-semibold`,children:`Valid To (Expires At)`}),(0,K.jsx)(`p`,{className:`text-muted-foreground`,children:e.details.valid_to?new Date(e.details.valid_to).toLocaleString():`N/A`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`font-semibold`,children:`Serial Number`}),(0,K.jsx)(`p`,{className:`text-muted-foreground font-mono text-xs break-all`,children:e.details.serial_number||`N/A`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`font-semibold`,children:`Private Key Name`}),(0,K.jsx)(`p`,{className:`text-muted-foreground`,children:e.private_key_name||`N/A`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`font-semibold`,children:`Is Authority`}),(0,K.jsx)(`p`,{className:`text-muted-foreground`,children:e.is_authority?`Yes`:`No`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`font-semibold`,children:`Is Self-Signed`}),(0,K.jsx)(`p`,{className:`text-muted-foreground`,children:e.is_self_signed?`Yes`:`No`})]}),e.hosts&&e.hosts.length>0&&(0,K.jsxs)(`div`,{className:`col-span-2`,children:[(0,K.jsx)(`p`,{className:`font-semibold`,children:`Hosts`}),(0,K.jsx)(`p`,{className:`text-muted-foreground`,children:e.hosts.join(`, `)})]}),(0,K.jsxs)(`div`,{className:`col-span-2`,children:[(0,K.jsx)(`p`,{className:`font-semibold`,children:`Uses`}),(0,K.jsx)(`p`,{className:`text-muted-foreground`,children:e.uses?.join(`, `)||`N/A`})]})]}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(jo,{children:`Certificate Content`}),(0,K.jsx)(Pn,{autoComplete:`off`,autoCapitalize:`off`,rows:8,readOnly:!0,className:`font-mono text-xs`,value:e.certificate})]})]}),(0,K.jsx)(zt,{children:(0,K.jsxs)(`div`,{className:`flex justify-between w-full`,children:[(0,K.jsx)(F,{type:`button`,variant:`destructiveOutline`,onClick:d,disabled:c,children:`Remove Certificate`}),(0,K.jsx)(F,{type:`button`,variant:`defaultOutline`,onClick:()=>n(),children:`Close`})]})})]})})}),(0,K.jsx)(qs,{isModalOpen:l,setIsModalOpen:u,deletionConfirmed:f,deletionPending:c,typeOfThingBeingDeleted:`certificate`,presentParticiple:`Removing`,transitiveVerb:`Remove`,nameOfThingBeingDeleted:a,hideDataLossWarning:!0})]})}function Ug(){let e=L(),{certName:t}=B({strict:!1}),n=G(),{data:r,refetch:i,isFetching:a,isRefetching:o}=H(Pg(n)),s=(0,q.useMemo)(()=>r?.find(e=>e.name===t),[r,t]),c=(0,q.useCallback)(n=>{let r=n?.original?.name,i=[t?`..`:``,r].filter(Boolean);e({to:i.join(`/`)})},[t,e]),l=!!t&&!!s,[u,d]=(0,q.useState)(!1),f=(0,q.useCallback)(()=>{d(!0)},[d]),p=Zf(i);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(Kf,{columns:Fg,data:r||[],isFetching:a,onRowClick:c,children:[(0,K.jsx)(V,{className:`inline-block underline text-sm text-muted-foreground hover:text-foreground`,to:`https://docs.harperdb.io/docs/developers/operations-api/certificate-management`,target:`_blank`,children:`Certificate Management Docs`}),(0,K.jsxs)(F,{variant:`defaultOutline`,onClick:p,accessKey:`r`,disabled:a||o,children:[(0,K.jsx)(Wr,{}),(0,K.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,K.jsx)(`u`,{children:`R`}),`efresh`]})]}),(0,K.jsxs)(F,{variant:`positiveOutline`,onClick:f,accessKey:`a`,disabled:u,children:[(0,K.jsx)(Ur,{}),(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`u`,{children:`A`}),`dd`]})]})]}),u&&(0,K.jsx)(zg,{isModalOpen:u,onChangesSaved:i,setIsModalOpen:d}),l&&(0,K.jsx)(Hg,{isModalOpen:l,closeModal:c,data:s,onSelectCertificate:c,onChangesSaved:i})]})}var Wg=new Set([`success`,`failed`,`rolled_back`]);function Gg(e){return!!e&&Wg.has(e)}var Kg=2e3,qg=1e4;async function Jg({instanceClient:e,project:t,status:n,since:r,until:i,limit:a,offset:o}){let{data:s}=await e.post(`/`,{operation:`list_deployments`,project:t,status:n,since:r,until:i,limit:a,offset:o});return s}function Yg(e){let{entityId:t,project:n,status:r,since:i,until:a,limit:o,offset:s,pollWhileOpen:c}=e;return z({queryKey:[t,`list_deployments`,{project:n,status:r,since:i,until:a,limit:o,offset:s}],queryFn:()=>Jg(e),retry:!1,enabled:e.enabled!==!1,refetchInterval:c?e=>(e.state.data?.deployments??[]).some(e=>!Gg(e.status))?Kg:qg:!1})}var Xg={pending:`warning`,extracting:`warning`,installing:`warning`,loading:`warning`,replicating:`warning`,restarting:`warning`,success:`success`,failed:`destructive`,rolled_back:`destructive`},Zg={pending:`Pending`,extracting:`Extracting`,installing:`Installing`,loading:`Loading`,replicating:`Replicating`,restarting:`Restarting`,success:`Success`,failed:`Failed`,rolled_back:`Rolled back`};function Qg({status:e}){return(0,K.jsx)(Wi,{variant:Xg[e]??`secondary`,children:Zg[e]??e})}var $g=Mn();function e_(e){return e?Yf((Date.now()-e)/1e3,e):`—`}var t_=[{header:`Project`,accessorKey:`project`,enableSorting:!1},$g.display({header:`Status`,id:`status`,enableSorting:!1,cell:e=>(0,K.jsx)(Qg,{status:e.row.original.status})}),$g.display({header:`Started`,id:`started_at`,enableSorting:!1,cell:e=>e_(e.row.original.started_at)}),$g.display({header:`Completed`,id:`completed_at`,enableSorting:!1,cell:e=>e_(e.row.original.completed_at)}),{header:`User`,accessorKey:`user`,enableSorting:!1},{header:`Origin`,accessorKey:`origin_node`,enableSorting:!1}];function n_({className:e,orientation:t=`horizontal`,decorative:n=!0,...r}){return(0,K.jsx)(Et,{"data-slot":`separator-root`,decorative:n,orientation:t,className:P(`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})}async function*r_(e,t){let n=e.getReader(),r=new TextDecoder(`utf-8`),i=``,a=!1;try{for(;;){if(t?.aborted)return;let{value:e,done:s}=await n.read();if(s){a=!0;break}i+=r.decode(e,{stream:!0}),yield*o()}if(i+=r.decode(),i.trim()){let e=i_(i);e&&(yield e)}}finally{a||n.cancel().catch(()=>{}),n.releaseLock()}function*o(){for(;;){let e=i.indexOf(`
|
|
12
|
+
`)}}];function Zf(e){return(0,q.useCallback)(async()=>{U.loading(`Refreshing...`,{id:`refreshing`});let t=Date.now();await e(),Date.now()-t<500&&await i(500),U.success(`Refreshed!`,{id:`refreshing`})},[e])}async function Qf(e){let{data:t}=await N.get(`/Invoice/${e}`);return t}function $f(e,t){return z({queryKey:[e,`invoices`],queryFn:()=>Qf(e),retry:!1,enabled:!!e,refetchInterval:t?1e4:void 0})}function ep(){let{organizationId:e}=B({strict:!1}),{data:t}=H(gu(e)),{data:n,refetch:r,isLoading:i,isFetching:a,isRefetching:o}=H($f(t?.type!==`ENTERPRISE`&&t?.id,!1)),s=Zf(r);return t?.type===`ENTERPRISE`?(0,K.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,K.jsx)(Wl,{}),`, we would love to talk!`]}):i?(0,K.jsx)(Bi,{centered:!0}):!n||!n.length?(0,K.jsxs)(`span`,{children:[`Your invoices will be shown here once one is available! Want to explore your solution with Harper more?`,` `,(0,K.jsx)(Wl,{overEmail:!0}),`, we would love to talk!`]}):(0,K.jsx)(Kf,{data:n,columns:Xf,children:(0,K.jsxs)(F,{variant:`defaultOutline`,onClick:s,accessKey:`r`,disabled:a||o,children:[(0,K.jsx)(Wr,{}),(0,K.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,K.jsx)(`u`,{children:`R`}),`efresh`]})]})})}function tp(e){let t=I({getParentRoute:()=>e,path:`billing`,head:()=>({meta:[{title:`Billing — Harper Fabric`}]}),component:Gf}),n=I({getParentRoute:()=>t,path:`/`,head:()=>({meta:[{title:`Payment Methods — Harper Fabric`}]}),component:Vd}),r=I({getParentRoute:()=>t,path:`invoices`,head:()=>({meta:[{title:`Invoices — Harper Fabric`}]}),component:ep}),i=I({getParentRoute:()=>t,path:`confirm`,head:()=>({meta:[{title:`Confirm Payment — Harper Fabric`}]}),component:Wf});return t.addChildren([n,r,i])}async function np(e){let{data:t}=await N.get(`/OrganizationRole/${e}`);return t}function rp(e){return z({queryKey:[e,`roles`],queryFn:()=>np(e),retry:!1,refetchInterval:jn(1e4)})}var ip=Mn(),ap=[{header:`Role Name`,accessorKey:`roleName`,enableSorting:!1},ip.display({header:`ID`,id:`id`,enableSorting:!1,cell:e=>(0,K.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,title:e.row.original.id,children:e.row.original.id})}),ip.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 op(e){let{data:t}=await N.post(`/Role/`,e);return t}function sp(){return R({mutationFn:op})}var cp=y({name:M().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:S(),delete:S()});y({roles:y({create:S(),delete:S(),update:S(),view:S()}),clusters:y({create:S(),delete:S(),update:S(),view:S(),resources:k(y({id:M(),delete:S(),update:S(),view:S(),instances:y({create:S(),delete:S(),update:S(),view:S()})}))})});function lp(){let[e]=Da(),t=wa();return e===`dark`||e===`system`&&t===`dark`?`vs-dark`:`light`}var up=(0,q.lazy)(async()=>(await Te(()=>import(`./setup-J5SrM1Kp.js`),__vite__mapDeps([21,4,1,22,23,24,25,26,27,28,29])),{default:(await Te(()=>import(`./dist-cY0BPcz0.js`),__vite__mapDeps([22,1,4]))).default}));function dp(e){return(0,K.jsx)(q.Suspense,{fallback:e.loading??null,children:(0,K.jsx)(up,{...e})})}var fp={roles:{create:!0,view:!0,update:!0,delete:!0},clusters:{create:!0,view:!0,update:!0,delete:!0,resources:[]}};function pp({isModalOpen:e,setIsModalOpen:t}){let n=lp(),r=ie(),{organizationId:i}=B({strict:!1}),[a,o]=(0,q.useState)(!0),[s,c]=(0,q.useState)(JSON.stringify(fp,null,2)),{mutate:l,isPending:u}=sp(),d=dt({resolver:Fe(cp),defaultValues:{name:``,update:!1,delete:!1}}),f=(0,q.useCallback)(e=>{o(e.length===0)},[o]),p=(0,q.useCallback)(async e=>{let n=xn(s);if(!n)return;let o={...e,...n,organizationId:i};e&&a&&l(o,{onSuccess:()=>{U.success(`Organization role added successfully!`),t(!1),r.invalidateQueries({queryKey:[i,`roles`],refetchType:`active`}),d.reset()},onError:e=>{U.error(`Failed to add organization role: ${e.message}`)}})},[a,s,l,d,r,t,i]);return(0,K.jsx)(Rt,{onOpenChange:t,open:e,children:(0,K.jsxs)(Ut,{resizable:!0,children:[(0,K.jsx)(qt,{children:`Add New Organization Role`}),(0,K.jsx)(Zt,{children:`Set the new organization role permissions.`}),(0,K.jsx)(Do,{...d,children:(0,K.jsxs)(`form`,{id:`org-add-role-form`,name:`org-add-role-form`,className:`flex flex-1 min-h-0 flex-col gap-4 my-4`,onSubmit:d.handleSubmit(p),children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,K.jsx)(Y,{control:d.control,name:`name`,render:({field:e})=>(0,K.jsxs)(X,{className:`col-span-2`,children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Role Name`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`text`,className:``,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:d.control,name:`update`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Can Update Organization`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`checkbox`,className:`w-6 ml-2`,checked:e.value,onChange:t=>e.onChange(t.target.checked)})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:d.control,name:`delete`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Can Delete Organization`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`checkbox`,className:`w-6 ml-2`,checked:e.value,onChange:t=>e.onChange(t.target.checked)})}),(0,K.jsx)(Q,{})]})})]}),(0,K.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,K.jsx)(dp,{className:`w-full h-full`,theme:n,defaultLanguage:`json`,onValidate:f,onChange:e=>{e&&c(e)},options:{automaticLayout:!0},defaultValue:JSON.stringify(fp,null,2)})}),(0,K.jsx)(zt,{children:(0,K.jsxs)(`div`,{className:`flex justify-between w-full`,children:[(0,K.jsx)(F,{variant:`destructiveOutline`,type:`button`,onClick:()=>t(!1),disabled:u,children:`Cancel`}),(0,K.jsx)(F,{variant:`submit`,disabled:u||!a||!d.formState.isValid,children:`Save Changes`})]})})]})})]})})}async function mp({roleId:e}){let{data:t}=await N.delete(`/Role/${e}`,{id:e,deleted:!0});return t}function hp(){return R({mutationFn:({roleId:e})=>mp({roleId:e})})}async function gp({roleId:e,updatedRoleInfo:t}){let{data:n}=await N.put(`/Role/${e}`,t);return n}function _p(){return R({mutationFn:({roleId:e,updatedRoleInfo:t})=>gp({roleId:e,updatedRoleInfo:t})})}function vp({organizationId:e,roleId:t}){return z({queryKey:[e,`roles`,t],queryFn:()=>yp(t),refetchInterval:jn(1e4),retry:On()})}async function yp(e){let{data:t}=await N.get(`/Role/${e}`);return t}function bp({onRoleDeleteClick:e,setIsConfirmingRoleDeletion:t,isRoleDeletionPending:n}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(qt,{children:`Confirm Role Deletion`}),(0,K.jsx)(Zt,{children:`Are you sure you want to delete this role? This action cannot be undone.`}),(0,K.jsxs)(zt,{children:[(0,K.jsx)(F,{type:`button`,variant:`defaultOutline`,onClick:()=>t(!1),children:`Cancel`}),(0,K.jsx)(F,{variant:`destructiveOutline`,onClick:e,disabled:n,children:n?`Deleting...`:`Delete Role`})]})]})}function xp({data:e,isModalOpen:t,closeModal:n}){let r=(0,q.useCallback)(()=>n(!1),[n]);return(0,K.jsx)(Rt,{onOpenChange:r,open:t,children:(0,K.jsx)(Ut,{resizable:!0,children:(0,K.jsx)(q.Suspense,{fallback:(0,K.jsx)(Sp,{roleName:e.roleName}),children:(0,K.jsx)(Cp,{data:e,closeModal:n})})})})}function Sp({roleName:e}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(qt,{children:[`Organization Role "`,e,`"`]}),(0,K.jsx)(Bi,{centered:!0,text:`Loading role…`,className:`flex-1 min-h-0`})]})}function Cp({data:e,closeModal:t}){let n=ie(),{data:r}=le(vp({roleId:e.id,organizationId:e.organizationId})),i=je().user?.roles?.[e.organizationId]?.id===e.id,{update:a,remove:o}=fl(e.organizationId),{mutate:s,isPending:c}=_p(),{mutate:l,isPending:u}=hp(),d=lp(),[f,p]=(0,q.useState)(!1),m=dt({resolver:Fe(cp),defaultValues:{name:e.roleName,update:r.organization.update||!1,delete:r.organization.delete||!1}}),h=(0,q.useCallback)(()=>{l({roleId:e.id},{onSuccess:()=>{U.success(`Role deleted successfully!`),t(!0),m.reset()},onError:e=>{U.error(`Error`,{description:`Failed to delete role: ${e instanceof Error?e.message:String(e)}.`,action:{label:`Dismiss`,onClick:()=>U.dismiss()}})}})},[e.id,l,m,t]),[g,_]=(0,q.useState)(!0),v=(0,q.useMemo)(()=>JSON.stringify({roles:{...r.organization.roles},clusters:{...r.organization.clusters}},null,2),[r]),[y,b]=(0,q.useState)(v),x=y!==v,S=(0,q.useCallback)(e=>{_(e.length===0)},[_]),C=(0,q.useCallback)(async r=>{if(!a)return;let i=xn(y);if(!i)return;let o={...r,...i,organizationId:e.organizationId};y&&g&&s({roleId:e.id,updatedRoleInfo:o},{onSuccess:async()=>{U.success(`Role updated successfully!`),await n.invalidateQueries({queryKey:[e.organizationId,`roles`,e.id]}),t(!1),m.reset()},onError:e=>{U.error(`Error`,{description:`Failed to update role: ${e instanceof Error?e.message:String(e)}.`,action:{label:`Dismiss`,onClick:()=>U.dismiss()}})}})},[t,e.id,e.organizationId,m,g,n,r,a,y,s]);return f?(0,K.jsx)(bp,{onRoleDeleteClick:h,setIsConfirmingRoleDeletion:p,isRoleDeletionPending:u}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(qt,{children:[i||!a?`View`:`Edit`,` Organization Role "`,e.roleName,`"`]}),(0,K.jsx)(Do,{...m,children:(0,K.jsxs)(`form`,{id:`org-edit-role-form`,name:`org-edit-role-form`,className:`flex flex-1 min-h-0 flex-col gap-4 my-4`,onSubmit:m.handleSubmit(C),children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,K.jsx)(Y,{control:m.control,name:`name`,render:({field:e})=>(0,K.jsxs)(X,{className:`col-span-2`,children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Role Name`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`text`,className:``,...e,disabled:!0,readOnly:!0})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:m.control,name:`update`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Can Update Organization`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`checkbox`,className:`w-6 ml-2`,disabled:i||!a,readOnly:i||!a,checked:e.value,onChange:t=>e.onChange(t.target.checked)})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:m.control,name:`delete`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Can Delete Organization`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`checkbox`,className:`w-6 ml-2`,disabled:i||!a,readOnly:i||!a,checked:e.value,onChange:t=>e.onChange(t.target.checked)})}),(0,K.jsx)(Q,{})]})})]}),(0,K.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,K.jsx)(dp,{className:`w-full h-full`,theme:d,defaultLanguage:`json`,onValidate:S,onChange:e=>{e&&b(e)},options:{readOnly:i||!a,automaticLayout:!0},defaultValue:y})}),!i&&(o||a)&&(0,K.jsx)(zt,{children:(0,K.jsxs)(`div`,{className:`flex justify-between w-full`,children:[o&&(0,K.jsx)(F,{type:`button`,variant:`destructiveOutline`,onClick:()=>p(!0),disabled:c,children:`Delete Role`}),a&&(0,K.jsx)(F,{variant:`submit`,disabled:!g||c||!m.formState.isValid||!m.formState.isDirty&&!x,children:`Save Changes`})]})})]})})]})}function wp(){let e=L(),t=ie(),{organizationId:n,orgRoleId:r}=B({strict:!1}),{create:i}=fl(n),{data:a,refetch:o,isFetching:s,isRefetching:c}=le(rp(n)),l=(0,q.useMemo)(()=>a&&a?.find(e=>e.id===r),[a,r]),u=!!r&&!!l,[d,f]=(0,q.useState)(!1),p=(0,q.useCallback)(async(i,a)=>{let o=[r?`..`:``,i].filter(Boolean);await e({to:o.join(`/`)}),a&&await t.invalidateQueries({queryKey:[n,`roles`],refetchType:`active`})},[r,e,t]),m=(0,q.useCallback)(()=>{f(!0)},[f]),h=(0,q.useCallback)(e=>p(e.original.id,!1),[p]),g=(0,q.useCallback)(e=>p(void 0,e),[p]),_=Zf(o);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Ks,{}),(0,K.jsx)(If,{children:(0,K.jsxs)(q.Suspense,{fallback:(0,K.jsx)(Bi,{className:`flex flex-col items-center justify-center h-full`,text:`Loading...`}),children:[(0,K.jsxs)(Kf,{data:a,columns:ap,onRowClick:h,children:[(0,K.jsxs)(F,{variant:`defaultOutline`,onClick:_,accessKey:`r`,disabled:s||c,children:[(0,K.jsx)(Wr,{}),(0,K.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,K.jsx)(`u`,{children:`R`}),`efresh`]})]}),i&&(0,K.jsxs)(F,{variant:`positiveOutline`,onClick:m,accessKey:`a`,disabled:d,children:[(0,K.jsx)(Ur,{}),(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`u`,{children:`A`}),`dd`]})]})]}),i&&(0,K.jsx)(pp,{isModalOpen:d,setIsModalOpen:f}),u&&(0,K.jsx)(xp,{data:l,isModalOpen:u,closeModal:g},l.id)]})})]})}function Tp({className:e,...t}){return(0,K.jsx)(Ye,{"data-slot":`switch`,className:P(`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-grey-500 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,K.jsx)(Re,{"data-slot":`switch-thumb`,className:P(`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 Ep(e){return`//oauth/${e}/login`}async function Dp(e,t){let{data:n}=await N.patch(`/Organization/${e}/settings/oauth`,t);return n}var Op=y({domain:M().min(1,`Domain is required`),clientId:M().min(1,`Client ID is required`),clientSecret:M().min(1,`Client secret is required`),scope:M().optional()}),kp=y({domain:M().min(1,`Domain is required`),clientId:M().optional(),clientSecret:M().optional(),scope:M().optional()});function Ap(){let{organizationId:e}=B({strict:!1}),{user:t}=je(),{update:n}=ul(e),{data:r}=le(gu(e)),i=ie(),[a,o]=(0,q.useState)(!1),[s,c]=(0,q.useState)(null),l=r.settings?.oauthConfigs??[],{mutate:u,isPending:d}=R({mutationFn:t=>Dp(e,t),onSuccess:()=>void i.invalidateQueries({queryKey:[e]}),onError:()=>U.error(`Failed to update OAuth settings.`)}),f=dt({resolver:Fe(Op),defaultValues:{domain:``,clientId:``,clientSecret:``,scope:`openid email profile`}}),p=e=>{u({provider:`okta`,...e},{onSuccess:()=>{U.success(`OAuth provider added.`),f.reset(),o(!1)}})},m=dt({resolver:Fe(kp)}),h=e=>{c(e.id??null),m.reset({domain:e.domain,clientId:``,clientSecret:``,scope:e.scope??``})},g=(e,t)=>{let n={id:e.id,provider:e.provider,domain:t.domain,scope:t.scope};t.clientId&&(n.clientId=t.clientId),t.clientSecret&&(n.clientSecret=t.clientSecret),u(n,{onSuccess:()=>{U.success(`OAuth provider updated.`),c(null)}})},_=(e,t)=>{u({id:e.id,provider:e.provider,[t]:!e[t]})},v=e=>`//oauth/${e}/callback`,y=async e=>{await zl(e)&&U.success(`Sign-in URL copied.`)},b=async e=>{await zl(e)&&U.success(`Redirect URI copied.`)};return n?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Ks,{}),(0,K.jsx)(If,{children:(0,K.jsxs)(`div`,{className:`max-w-2xl`,children:[(0,K.jsx)(`h2`,{className:`text-2xl text-foreground font-light mb-6`,children:`Authentication`}),(0,K.jsxs)(`section`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,K.jsx)(`h3`,{className:`text-lg text-foreground font-medium`,children:`OAuth Providers`}),!a&&(0,K.jsxs)(F,{variant:`positiveOutline`,size:`sm`,onClick:()=>o(!0),children:[(0,K.jsx)(Ur,{}),`Add Provider`]})]}),l.length===0&&!a&&(0,K.jsx)(`p`,{className:`text-muted-foreground text-sm mb-4`,children:`No OAuth providers configured.`}),l.map(e=>{let n=t?.oauthConfigId===e.id;return s===e.id?(0,K.jsxs)(`div`,{className:`border rounded-lg p-4 mb-3 text-foreground`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,K.jsx)(`h4`,{className:`font-medium`,children:`Edit Provider`}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>c(null),className:`text-muted-foreground hover:text-foreground`,children:(0,K.jsx)(hn,{className:`size-4`})})]}),(0,K.jsx)(Do,{...m,children:(0,K.jsxs)(`form`,{onSubmit:m.handleSubmit(t=>g(e,t)),className:`space-y-4`,children:[(0,K.jsx)(Y,{control:m.control,name:`domain`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Domain`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{placeholder:`company.okta.com`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:m.control,name:`clientId`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Client ID`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{placeholder:`Leave blank to keep existing`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:m.control,name:`clientSecret`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Client Secret`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`password`,placeholder:`Leave blank to keep existing`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:m.control,name:`scope`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Scope`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{placeholder:`openid email profile`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsxs)(`div`,{className:`flex gap-2 pt-2`,children:[(0,K.jsx)(F,{type:`submit`,variant:`positive`,disabled:d,children:d?`Saving...`:`Save`}),(0,K.jsx)(F,{type:`button`,variant:`outline`,onClick:()=>c(null),children:`Cancel`})]})]})})]},e.id):(0,K.jsx)(`div`,{className:`border rounded-lg p-4 mb-3 text-foreground`,children:(0,K.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between sm:gap-4`,children:[(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[(0,K.jsx)(`span`,{className:`font-medium`,children:e.domain}),(0,K.jsx)(`span`,{className:`text-xs text-muted-foreground uppercase bg-muted px-2 py-0.5 rounded`,children:e.provider}),e.enabled===!1&&(0,K.jsx)(`span`,{className:`text-xs text-destructive bg-destructive/10 px-2 py-0.5 rounded`,children:`Disabled`})]}),(0,K.jsxs)(`p`,{className:`text-sm text-muted-foreground mb-2`,children:[`Client ID: `,(0,K.jsx)(`span`,{className:`text-foreground font-mono`,children:`****`})]}),e.id&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`mt-3 rounded-md bg-muted px-3 py-2`,children:[(0,K.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground mb-1`,children:`Okta redirect URI`}),(0,K.jsxs)(`p`,{className:`text-xs text-muted-foreground mb-1.5`,children:[`Add to `,(0,K.jsx)(`span`,{className:`font-medium text-foreground`,children:`Login redirect URIs`}),` `,`in your Okta app settings.`]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-sm text-foreground font-mono truncate`,children:v(e.id)}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>void b(v(e.id)),className:`hover:text-foreground shrink-0 text-muted-foreground`,title:`Copy redirect URI`,children:(0,K.jsx)(sr,{className:`size-3.5`})})]})]}),(0,K.jsxs)(`div`,{className:`mt-2 rounded-md bg-muted px-3 py-2`,children:[(0,K.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground mb-1.5`,children:`User login link`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`a`,{href:Ep(e.id),target:`_blank`,rel:`noreferrer`,className:`text-sm text-foreground truncate hover:underline`,children:Ep(e.id)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0 text-muted-foreground`,children:[(0,K.jsx)(`button`,{type:`button`,onClick:()=>void y(Ep(e.id)),className:`hover:text-foreground`,title:`Copy login link`,children:(0,K.jsx)(sr,{className:`size-3.5`})}),(0,K.jsx)(`a`,{href:Ep(e.id),target:`_blank`,rel:`noreferrer`,className:`hover:text-foreground`,title:`Open login link`,children:(0,K.jsx)(dr,{className:`size-3.5`})})]})]})]})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-3 sm:shrink-0`,children:[(0,K.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-foreground cursor-pointer`,children:[(0,K.jsx)(Tp,{checked:e.enabled!==!1,onCheckedChange:()=>_(e,`enabled`),disabled:d}),`Enabled`]}),(0,K.jsxs)(Ia,{children:[(0,K.jsx)(La,{asChild:!0,children:(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-2 text-sm text-foreground ${n?`cursor-pointer`:`cursor-not-allowed opacity-50`}`,children:[(0,K.jsx)(Tp,{checked:!!e.required,onCheckedChange:()=>_(e,`required`),disabled:d||!n}),`Required`]})}),!n&&(0,K.jsxs)(Ra,{children:[`Sign in via `,e.provider,` first to enable Required`]})]}),(0,K.jsx)(F,{variant:`outline`,size:`sm`,onClick:()=>h(e),disabled:d,children:(0,K.jsx)(an,{className:`size-4`})})]})]})},e.id)}),a&&(0,K.jsxs)(`div`,{className:`border rounded-lg p-4 text-foreground`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,K.jsx)(`h4`,{className:`font-medium`,children:`Add Okta Provider`}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>{o(!1),f.reset()},className:`text-muted-foreground hover:text-foreground`,children:(0,K.jsx)(hn,{className:`size-4`})})]}),(0,K.jsxs)(`p`,{className:`text-xs text-muted-foreground mb-4`,children:[`After saving, copy the `,(0,K.jsx)(`span`,{className:`font-medium text-foreground`,children:`Okta redirect URI`}),` `,`from the provider card and add it to your Okta app's`,` `,(0,K.jsx)(`span`,{className:`font-medium text-foreground`,children:`Login redirect URIs`}),`.`]}),(0,K.jsx)(Do,{...f,children:(0,K.jsxs)(`form`,{onSubmit:f.handleSubmit(p),className:`space-y-4`,children:[(0,K.jsx)(Y,{control:f.control,name:`domain`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Domain`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{placeholder:`company.okta.com`,autoFocus:!0,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:f.control,name:`clientId`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Client ID`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{placeholder:`Okta Client ID`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:f.control,name:`clientSecret`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Client Secret`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`password`,placeholder:`Okta Client Secret`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:f.control,name:`scope`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Scope`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{placeholder:`openid email profile`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsxs)(`div`,{className:`flex gap-2 pt-2`,children:[(0,K.jsx)(F,{type:`submit`,variant:`positive`,disabled:d,children:d?`Adding...`:`Add Provider`}),(0,K.jsx)(F,{type:`button`,variant:`outline`,onClick:()=>{o(!1),f.reset()},children:`Cancel`})]})]})})]})]})]})})]}):(0,K.jsx)(`div`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-theme(spacing.32))] text-foreground`,children:`You don't have permission to manage settings for this organization.`})}A.object({email:Yo.max(80,{error:`Email cannot be longer than 80 characters.`}),roleId:A.string().nonempty({error:`Please select a role.`})});async function jp(e){let{data:t}=await N.post(`/UserInvite/`,e);return t}function Mp(){return R({mutationFn:e=>jp(e)})}function Np({user:e}){let{update:t}=fl(),{mutate:n,isPending:r}=Mp(),i=e.roles?.[0]?.id,a=(0,q.useCallback)(t=>{if(t.stopPropagation(),!e.email||!i){U.error(`Cannot resend invite: this user has no email or role.`);return}n({email:e.email,roleId:i},{onSuccess:()=>U.success(`Invitation resent to ${e.email}.`)})},[n,i,e.email]);return t?(0,K.jsxs)(F,{variant:`ghost`,size:`sm`,className:`h-auto px-2 py-0 align-middle text-sm`,onClick:a,disabled:r||!i,children:[(0,K.jsx)(Pr,{}),` Resend invite`]}):null}var Pp=Mn(),Fp=[{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},Pp.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},Pp.display({header:``,enableSorting:!1,id:`actions`,cell:e=>e.row.original.status===`PENDING`?(0,K.jsx)(Np,{user:e.row.original}):null})];function Ip({name:e,id:t}){return(0,K.jsxs)(`span`,{className:`flex items-baseline gap-2 truncate`,children:[(0,K.jsx)(`span`,{className:`truncate`,children:e}),(0,K.jsx)(`span`,{className:`text-muted-foreground font-mono text-xs`,children:t})]})}var Lp=A.object({email:Yo.max(80,{error:`Email cannot be longer than 80 characters.`}),roleId:A.string().nonempty({error:`Please select a role.`})});async function Rp(e){let{data:t}=await N.post(`/OrganizationRole/`,e);return t}function zp(){return R({mutationFn:e=>Rp(e)})}function Bp({isModalOpen:e,onChangesSaved:t,setIsModalOpen:n}){let{organizationId:r}=B({strict:!1}),{data:i,isLoading:a}=H({...rp(r),throwOnError:!0}),[o,s]=(0,q.useState)(!1),c=dt({resolver:Fe(Lp),defaultValues:{email:``,roleId:``}}),{mutate:l,isPending:u}=zp(),{mutate:d,isPending:f}=Mp(),p=(0,q.useCallback)(async e=>{e&&(o?d:l)(e,{onSuccess:()=>{let r=e.roleId;c.reset(),c.setValue(`roleId`,r),t(),U.success(`User invited successfully!`),n(!1),s(!1)},onError:e=>{e?.status===404&&s(!0)}})},[l,c,d,t,n,o]);return(0,K.jsx)(Rt,{onOpenChange:()=>{n(!1),s(!1),c.reset()},open:e,children:(0,K.jsx)(Ut,{"aria-describedby":void 0,children:(0,K.jsx)(Do,{...c,children:(0,K.jsxs)(`form`,{id:`org-add-user-form`,name:`org-add-user-form`,onSubmit:c.handleSubmit(p),className:`grid gap-4 my-4`,children:[(0,K.jsx)(Bt,{children:(0,K.jsx)(qt,{children:o?`Invite User`:`Add User`})}),(0,K.jsx)(Y,{control:c.control,name:`email`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Email`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`email`,enterKeyHint:`next`,autoComplete:`email`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:c.control,name:`roleId`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Roles`}),a?(0,K.jsx)(Jd,{}):(0,K.jsx)(J,{children:(0,K.jsxs)(Xt,{...e,onValueChange:t=>e.onChange(t),children:[(0,K.jsx)(Kt,{className:`w-full`,children:(0,K.jsx)(Yt,{placeholder:`Choose Role`})}),(0,K.jsx)(Gt,{children:(0,K.jsxs)(Jt,{children:[(0,K.jsx)(Lt,{children:`Role`}),i?.map(e=>(0,K.jsx)(Ht,{value:e.id,children:(0,K.jsx)(Ip,{name:e.roleName,id:e.id})},e.id))]})})]})}),(0,K.jsx)(Q,{})]})}),o&&(0,K.jsxs)(Zt,{className:`p-3 my-5 text-white rounded-md bg-amber-600 flex`,children:[(0,K.jsx)(Nr,{className:`inline-block size-12 pr-2`}),(0,K.jsx)(`span`,{children:`This person doesn’t have a Fabric account. Do you want to invite them?`})]}),(0,K.jsx)(zt,{children:(0,K.jsx)(`div`,{className:`flex justify-between w-full`,children:(0,K.jsxs)(F,{type:`submit`,variant:`submit`,disabled:u||f,children:[(0,K.jsx)(Jr,{}),` `,o?`Invite User`:`Add User`]})})})]})})})})}async function Vp({roleId:e,userId:t}){let{data:n}=await N.delete(`/OrganizationRole/role/${e}/user/${t}`);return n}function Hp(){return R({mutationFn:({roleId:e,userId:t})=>Vp({roleId:e,userId:t})})}function Up(e){let[t,n]=(0,q.useState)(e||!1);return[t,(0,q.useCallback)(e=>{n(typeof e==`boolean`?e:e.target.checked)},[])]}function Wp({data:e,readOnly:t,canRemove:n,orgRole:r,selectedRoles:i,setChangesMade:a}){let{mutate:o,isPending:s}=zp(),{mutate:c,isPending:l}=Hp(),u=!!i[r.id],[d,f]=(0,q.useState)(u),[p,m]=Up(u);return(0,q.useEffect)(()=>{p!==d&&(p?o({email:e.email,roleId:r.id},{onSuccess:()=>{f(p),a(!0),U.success(`Role added successfully`)}}):c({userId:e.id,roleId:r.id},{onSuccess:()=>{f(p),a(!0),U.success(`Role removed successfully`)}}))},[o,e.email,e.id,p,r.id,c,a,d]),(0,K.jsxs)(jo,{className:`flex`,children:[(0,K.jsx)($,{type:`checkbox`,className:`w-6`,disabled:t||s||l||!n&&p,checked:p,onChange:m}),(0,K.jsx)(`span`,{className:`pl-4 pr-8 flex-1 py-2.5`,children:r.roleName})]},r.id)}function Gp({isSelf:e,isPending:t,onConfirm:n}){let[r,i]=(0,q.useState)(!1),a=e?{idle:`Leave organization`,confirm:`Confirm leave`,busy:`Leaving…`,warning:`You’ll lose access to this organization and everything in it. You won’t be able to return unless another member invites you back.`}:{idle:`Remove from organization`,confirm:`Confirm removal`,busy:`Removing…`,warning:`This revokes their access to this organization and everything in it. Their Harper account isn’t deleted, and they can be added back later.`},o=e?jr:pi;return r?(0,K.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,K.jsxs)(`p`,{role:`alert`,className:`flex items-start gap-2 text-sm text-muted-foreground border border-amber-500/50 rounded-md p-3`,children:[(0,K.jsx)(fi,{className:`size-4 text-amber-500 shrink-0 mt-0.5`}),(0,K.jsx)(`span`,{children:a.warning})]}),(0,K.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,K.jsx)(F,{type:`button`,variant:`ghostOutline`,disabled:t,onClick:()=>i(!1),children:`Cancel`}),(0,K.jsxs)(F,{type:`button`,variant:`destructive`,disabled:t,onClick:n,children:[(0,K.jsx)(o,{}),` `,t?a.busy:a.confirm]})]})]}):(0,K.jsx)(`div`,{className:`flex justify-start`,children:(0,K.jsxs)(F,{type:`button`,variant:`destructiveOutline`,disabled:t,onClick:()=>i(!0),children:[(0,K.jsx)(o,{}),` `,a.idle]})})}function Kp(e){return e?.trim().toLowerCase()===`admin`}function qp({canDelete:e,isSelf:t,orgUserCount:n,adminCount:r,isAdmin:i,roleCount:a}){let o=e?t&&n<=1?`sole-member`:t&&i&&r<=1?`last-admin`:null:null,s=e&&o===null;return{canRemoveRoles:s,showRemovalAction:s&&a>0,blockedReason:o}}function Jp({closeModal:e,data:t,isModalOpen:n,onUserUpdated:r,orgUserCount:i,orgAdminCount:a}){let{organizationId:o}=B({strict:!1}),s=je(),{update:c,remove:l}=fl(o),u=s.user?.email===t.email,[d,f]=(0,q.useState)(!1),{canRemoveRoles:p,showRemovalAction:m,blockedReason:h}=qp({canDelete:l,isSelf:u,orgUserCount:i,adminCount:a,isAdmin:(t.roles??[]).some(e=>Kp(e.roleName)),roleCount:t.roles?.length??0}),{mutateAsync:g}=Hp(),[_,v]=(0,q.useState)(!1),y=(0,q.useCallback)(async()=>{let e=t.roles??[];v(!0),(await Promise.allSettled(e.map(e=>g({userId:t.id,roleId:e.id})))).some(e=>e.status===`rejected`&&e.reason?.response?.status!==404)?U.error(u?`Something went wrong leaving the organization. Please try again.`:`Couldn’t remove ${t.email} from the organization. Please try again.`):U.success(u?`You’ve left the organization.`:`${t.email} was removed from the organization.`),v(!1),r()},[t.roles,t.id,t.email,u,g,r]);return(0,K.jsx)(Rt,{onOpenChange:d?r:e,open:n,children:(0,K.jsxs)(Ut,{resizable:!0,children:[(0,K.jsx)(Bt,{children:(0,K.jsxs)(qt,{children:[c?`Edit `:`View `,` `,t.email,` `,u?`(yourself)`:``]})}),c&&(0,K.jsxs)(Zt,{children:[`Use the checkboxes to change which roles `,u?`you have`:`this user has`,`.`,m&&(u?` To leave the organization entirely, use the button below.`:` To remove this user from the organization entirely, use the button below.`)]}),(0,K.jsx)(q.Suspense,{fallback:(0,K.jsx)(Bi,{centered:!0,text:`Loading roles…`,className:`flex-1 min-h-0`}),children:(0,K.jsx)(Yp,{data:t,organizationId:o,update:c,canRemove:p,setChangesMade:f})}),t.status===`PENDING`&&(0,K.jsx)(`div`,{className:`border-t border-border pt-4`,children:(0,K.jsx)(Np,{user:t})}),m&&(0,K.jsx)(`div`,{className:`border-t border-border pt-4`,children:(0,K.jsx)(Gp,{isSelf:u,isPending:_,onConfirm:y})}),h&&(0,K.jsxs)(`p`,{className:`flex items-start gap-2 text-sm text-muted-foreground border border-amber-500/50 rounded-md p-3`,children:[(0,K.jsx)(fi,{className:`size-4 text-amber-500 shrink-0 mt-0.5`}),(0,K.jsx)(`span`,{children:h===`sole-member`?`You’re the only member of this organization, so you can’t remove your roles or leave — it would be left with no one to manage it. If you no longer need this organization, terminate its clusters, then delete the organization from the ⋯ menu on the Organizations page.`:`You’re the only admin of this organization, so you can’t remove your roles or leave — it would be left with no one who can manage its members, roles, or clusters. Give another member the admin role first, then you can step back.`})]})]})})}function Yp({data:e,organizationId:t,update:n,canRemove:r,setChangesMade:i}){let{data:a}=le(rp(t)),o=(0,q.useMemo)(()=>e.roles?su(e.roles,`id`):{},[e]);return(0,K.jsx)(`div`,{className:`flex flex-1 min-h-0 flex-col gap-2 overflow-y-auto`,children:a.map(t=>(0,K.jsx)(Wp,{readOnly:!n,canRemove:r,data:e,orgRole:t,selectedRoles:o,setChangesMade:i},t.id))})}function Xp(e,t){return e.email>t.email?1:-1}function Zp(e){return(e.users??[]).filter(e=>e!=null)}function Qp(e){let t={};for(let n of e)for(let e of Zp(n))t[e.id]||(t[e.id]={...e,roles:[]}),t[e.id].roles.push(n);return Object.values(t).sort(Xp)}function $p(e){let t=new Set;for(let n of e)if(Kp(n.roleName))for(let e of Zp(n))t.add(e.id);return t.size}function em(){let e=L(),{organizationId:t,orgUserId:n}=B({strict:!1}),{update:r}=fl(t),{data:i,refetch:a,isFetching:o,isRefetching:s}=le(rp(t)),c=(0,q.useMemo)(()=>Qp(i),[i]),l=(0,q.useMemo)(()=>$p(i),[i]),u=(0,q.useMemo)(()=>c?.find(e=>e.id===n),[c,n]),d=(0,q.useCallback)(t=>{let r=[n?`..`:``,t].filter(Boolean);e({to:r.join(`/`)})},[n,e]),f=!!n&&!!u,[p,m]=(0,q.useState)(!1),[h]=(0,q.useState)({attribute:`email`,descending:!1}),g=(0,q.useMemo)(()=>[{desc:h.descending,id:h.attribute}],[h]),_=(0,q.useCallback)(()=>{m(!0)},[m]),v=(0,q.useCallback)(()=>{a(),m(!1)},[a,m]),y=(0,q.useCallback)(e=>{d(e.original.id)},[d]),b=(0,q.useCallback)(()=>{d(void 0)},[d]),x=(0,q.useCallback)(()=>{a(),d(void 0)},[d,a]),S=Zf(a);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Ks,{}),(0,K.jsx)(If,{children:(0,K.jsxs)(q.Suspense,{fallback:(0,K.jsx)(Bi,{className:`flex flex-col items-center justify-center h-full`,text:`Loading...`}),children:[(0,K.jsxs)(Kf,{data:c,isFetching:o||s,columns:Fp,onRowClick:y,sortingState:g,children:[(0,K.jsxs)(F,{variant:`defaultOutline`,onClick:S,accessKey:`r`,disabled:o||s,children:[(0,K.jsx)(Wr,{}),` `,(0,K.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,K.jsx)(`u`,{children:`R`}),`efresh`]})]}),r&&(0,K.jsxs)(F,{variant:`positiveOutline`,onClick:_,accessKey:`a`,disabled:p,children:[(0,K.jsx)(Ur,{}),` `,(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`u`,{children:`A`}),`dd`]})]})]}),r&&(0,K.jsx)(Bp,{isModalOpen:p,onChangesSaved:v,setIsModalOpen:m}),f&&(0,K.jsx)(Jp,{closeModal:b,data:u,isModalOpen:f,onUserUpdated:x,orgUserCount:c.length,orgAdminCount:l})]})})]})}function tm({className:e,...t}){return(0,K.jsx)(`div`,{"data-slot":`skeleton`,className:P(`bg-primary/10 animate-pulse rounded-md`,e),...t})}function nm({organizationId:e,organizationName:t,providers:n}){return(0,K.jsxs)(It,{className:`relative h-full justify-between opacity-90`,children:[(0,K.jsxs)(Nt,{children:[(0,K.jsx)(Ft,{className:`truncate`,children:e}),(0,K.jsx)(Mt,{children:(0,K.jsx)(`h2`,{children:t})})]}),(0,K.jsxs)(Pt,{className:`flex flex-col gap-2`,children:[(0,K.jsxs)(`p`,{className:`text-xs text-muted-foreground flex items-center gap-1.5 mb-1`,children:[(0,K.jsx)(wr,{className:`size-3 shrink-0`}),`Sign in with an OAuth provider to access this organization.`]}),n.map(e=>(0,K.jsx)(`a`,{href:Ep(e.oauthConfigId),children:(0,K.jsxs)(F,{variant:`outline`,className:`w-full`,children:[`Sign in with `,e.name]})},e.oauthConfigId))]})]})}var rm=y({couponId:M().nonempty({message:`Please enter a coupon ID.`}).trim()});async function im({organizationId:e,couponId:t}){let{data:n}=await N.post(`/Coupon`,{organizationId:e,couponId:t},{validateStatus:e=>e>=200&&e<400||e===400||e===409});return n}function am(){return R({mutationFn:im})}function om({organizationId:e,organizationName:t,isOpen:n,onClose:r}){let{mutate:i,isPending:a}=am(),o=dt({resolver:Fe(rm),defaultValues:{couponId:``}}),{handleSubmit:s,control:c,reset:l}=o;(0,q.useEffect)(()=>{n&&l({couponId:``})},[n,l]);let u=(0,q.useCallback)(n=>{i({organizationId:e,couponId:n.couponId},{onSuccess:i=>{i?U.error(`Error`,{description:i||`Failed to add coupon.`}):(U.success(`Success`,{description:`Coupon "${n.couponId}" added to ${t||e}.`}),r())}})},[i,e,t,r]);return(0,K.jsx)(Rt,{open:n,onOpenChange:e=>!e&&r(),children:(0,K.jsxs)(Ut,{children:[(0,K.jsxs)(Bt,{children:[(0,K.jsx)(qt,{children:`Add Coupon`}),(0,K.jsxs)(Zt,{children:[`Add a coupon code to`,` `,t||e,`. This coupon will be applied to the next billing cycle.`,(0,K.jsx)(`br`,{}),`Coupons can be created in our`,` `,(0,K.jsx)(`a`,{href:`https://dashboard.stripe.com/`,target:`_blank`,rel:`noreferrer`,className:`text-purple hover:underline`,children:`Stripe Dashboard`}),`.`]})]}),(0,K.jsx)(Do,{...o,children:(0,K.jsxs)(`form`,{onSubmit:s(u),children:[(0,K.jsx)(`div`,{className:`grid gap-4 py-4`,children:(0,K.jsx)(Y,{control:c,name:`couponId`,render:({field:e})=>(0,K.jsxs)(X,{className:`grid items-center gap-4`,children:[(0,K.jsx)(Z,{children:`Coupon ID`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{...e,placeholder:`e.g. 100OFF`,disabled:a})}),(0,K.jsx)(Q,{})]})})}),(0,K.jsxs)(zt,{children:[(0,K.jsx)(F,{type:`button`,variant:`ghost`,onClick:r,disabled:a,children:`Cancel`}),(0,K.jsx)(F,{type:`submit`,disabled:a,children:a?`Adding...`:`Add Coupon`})]})]})})]})})}function sm({organizationRole:e,onDeleteOrgModal:t}){let{organizationId:n,organizationName:r,roleName:i}=e,{remove:a,update:o}=ul(n),s=o,{view:c}=fl(n),l=Me(`billing:write`),[u,d]=(0,q.useState)(!1),f=(0,q.useCallback)(()=>{t(e)},[t,e]),p=[{type:`label`,key:`label`,className:`text-gray-600 text-xs`,label:`Options`},{type:`separator`,key:`sep-top`},{key:`clusters`,to:`${n}`,icon:(0,K.jsx)(Zr,{className:`size-4 mr-2 text-blue-500`}),label:`Clusters`},c&&{key:`roles`,to:`${n}/roles`,icon:(0,K.jsx)($r,{className:`size-4 mr-2 text-purple`}),label:`Roles`},c&&{key:`users`,to:`${n}/users`,icon:(0,K.jsx)(hi,{className:`size-4 mr-2 text-orange-500`}),label:`Users`},s&&{key:`billing`,to:`${n}/billing`,icon:(0,K.jsx)(cr,{className:`size-4 mr-2 text-green-500`}),label:`Billing`},o&&{key:`settings`,to:`${n}/settings`,icon:(0,K.jsx)(wr,{className:`size-4 mr-2 text-yellow-500`}),label:`Settings`},l&&{key:`add-coupon`,onClick:()=>d(!0),icon:(0,K.jsx)(li,{className:`size-4 mr-2 text-pink-500`}),label:`Add Coupon`},a&&{type:`separator`,key:`sep-bottom`},a&&{key:`delete`,onClick:f,className:`focus:bg-red/70 focus:text-white`,icon:(0,K.jsx)(ui,{className:`size-4 mr-2 text-red-500`}),label:`Delete`}].filter(kn),m=a||l;return(0,K.jsx)(rc,{items:m?p:[],children:(0,K.jsxs)(It,{className:`relative h-full justify-between transition-[transform,box-shadow] duration-200 hover:scale-[1.02] hover:shadow-lg hover:ring-2 hover:ring-primary/60 dark:hover:ring-violet-400/70`,children:[(0,K.jsx)(V,{to:n,"aria-label":`View ${r??n}`,className:`absolute inset-0 rounded-[inherit] focus-visible:ring-2 focus-visible:ring-purple-200 focus-visible:outline-none`}),(0,K.jsxs)(Nt,{children:[(0,K.jsxs)(Ft,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`truncate`,children:n}),m&&(0,K.jsxs)(bi,{children:[(0,K.jsx)(xi,{"aria-label":`Options`,onClick:e=>e.stopPropagation(),className:`relative z-10 -m-2 p-2 rounded-md hover:bg-accent/60 hover:text-foreground`,children:(0,K.jsx)(ur,{})}),(0,K.jsx)(Si,{children:nc(p,`dropdown`)})]})]}),(0,K.jsx)(Mt,{children:(0,K.jsx)(`h2`,{children:r})})]}),(0,K.jsxs)(Pt,{className:`flex items-center justify-between gap-2`,children:[(0,K.jsx)(Wi,{className:`min-w-0 shrink`,title:wo(i),children:(0,K.jsx)(`span`,{className:`truncate`,children:wo(i)})}),(0,K.jsxs)(`span`,{className:`text-sm shrink-0 py-2 whitespace-nowrap ml-auto`,children:[`View `,(0,K.jsx)(Bn,{className:`inline-block`})]})]}),(0,K.jsx)(om,{organizationId:n,organizationName:r,isOpen:u,onClose:()=>d(!1)})]})})}async function cm(e){let{data:t}=await N.delete(`/Organization/${e}`);return t}function lm(){return R({mutationFn:e=>cm(e)})}async function um(e){let{data:t}=await N.post(`/Organization/`,{...e});return t}function dm(){return R({mutationFn:e=>um(e)})}var fm=M().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.`}),pm=y({name:M().max(255,{error:`Name cannot be longer than 255 characters.`}),subdomain:x([O(``),b(),fm]).optional()});function mm(){let{user:e}=je(),t=L(),n=dt({resolver:Fe(pm),defaultValues:{name:``,subdomain:``}}),{setFocus:r,watch:i}=n;(0,q.useEffect)(()=>{r(`name`)},[r]);let a=`${e?.firstname} ${e?.lastname} Org`,o=i(`name`)||a,s=i(`subdomain`),c=(0,q.useMemo)(()=>{let e=vu(bu(o),fm.maxLength);return{suggestedSubdomain:e,fullHostName:`future-cluster-names.${s||e}.harperfabric.com`}},[o,s]),{mutate:u,isPending:d}=dm(),f=ie(),h=(0,q.useCallback)(async e=>{u({name:e.name||a,subdomain:e.subdomain||c.suggestedSubdomain},{onSuccess:e=>{f.invalidateQueries({queryKey:p,refetchType:`active`}),l.reloadUser(m),t({to:`/${e.id}`})}})},[c.suggestedSubdomain,f,u,a,t]);return(0,K.jsx)(K.Fragment,{children:(0,K.jsx)(Do,{...n,children:(0,K.jsxs)(`form`,{id:`org-add-form`,name:`org-add-form`,onSubmit:n.handleSubmit(h),className:`grid gap-6 text-foreground max-w-xl`,children:[(0,K.jsx)(Y,{control:n.control,name:`name`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Name`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`text`,maxLength:pm.shape.name.maxLength,autoCapitalize:`words`,placeholder:a,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:n.control,name:`subdomain`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Subdomain`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`text`,maxLength:fm.maxLength,autoCapitalize:`none`,placeholder:c.suggestedSubdomain,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Full Host Name`}),(0,K.jsx)(J,{children:(0,K.jsx)(`span`,{children:c.fullHostName})}),(0,K.jsx)(Q,{})]}),(0,K.jsx)(zt,{children:(0,K.jsxs)(F,{type:`submit`,variant:`submit`,disabled:d,children:[`Create New Organization `,(0,K.jsx)(Bn,{})]})})]})})})}function hm(){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Ks,{}),(0,K.jsx)(`section`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-theme(spacing.32))]`,children:(0,K.jsx)(mm,{})})]})}var gm={org:`organization`,clu:`cluster`,ins:`instance`},_m=/^(org|clu|ins)-[a-z0-9]+$/;function vm(e){if(typeof e!=`string`)return null;let t=e.trim(),n=_m.exec(t);return n?{kind:gm[n[1]],id:t}:null}function ym(e,t){let n=e*12;return`/Admin/Organization/?${[...t?[`name=ct=${encodeURIComponent(t)}`]:[],`status=ne=DELETED`,`sort(name)`,`limit(${n},${n+12+1})`].join(`&`)}`}async function bm(e,t){let{data:n}=await N.get(ym(e,t));return{organizations:n.slice(0,12),hasNextPage:n.length>12}}var xm={organizations:[],hasNextPage:!1};function Sm(e){return e instanceof _&&(e.response?.status===404||e.status===404)}async function Cm(e){try{let{data:t}=await N.get(`/Admin/Organization/${e}`);return t?{organizations:[t],hasNextPage:!1}:xm}catch(e){if(Sm(e))return xm;throw e}}async function wm(e){try{let{data:t}=await N.get(`/Cluster/${e}`),n=t?.organizationId;return n?await Cm(n):xm}catch(e){if(Sm(e))return xm;throw e}}function Tm(e,t){let n=vm(t);return z({queryKey:[`admin-all-organizations`,t,e],queryFn:()=>n?.kind===`organization`?Cm(n.id):n?.kind===`cluster`?wm(n.id):bm(e,t),placeholderData:ye,retry:!1})}function Em(e,t=300,n){let[r,i]=(0,q.useState)(e),a=n?n(e):e;return(0,q.useEffect)(()=>{let n=setTimeout(()=>i(e),t);return()=>clearTimeout(n)},[a,t]),r}function Dm(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 Om(e,t){let[n,r]=(0,q.useState)(t),[i,a]=(0,q.useState)(e);return(0,q.useEffect)(()=>{Dm(n,t)||(r(t),a(e))},[n,t,e]),Dm(n,t)?[i,a]:[e,a]}var km={};function Am(e,t,n){let r=(0,q.useCallback)((e,n)=>t(e,n),[n]);(0,q.useEffect)(()=>(km[e]||(km[e]=[]),km[e].push(r),function(){let t=km[e].indexOf(r);t>=0&&km[e].splice(t,1)}),[e,t,r])}function jm(e,t,n){let r=km[e];if(r)for(let e of r)e(t,n)}function Mm(e,t,n){return r=>jm(e,t,n??r)}function Nm(e,t,n){return(0,q.useCallback)(r=>jm(e,t,n??r),[e,t,n])}function Pm(e,t){return xn(sessionStorage.getItem(String(e)))??t}function Fm(e,t){t==null?sessionStorage.removeItem(String(e)):sessionStorage.setItem(String(e),JSON.stringify(t))}function Im(e,t){let n=Om(Pm(e,t),[e]),[r,i]=n;return(0,q.useEffect)(()=>{Fm(e,r),jm(`Session:${e}`,r)},[e,r]),Am(`Session:${e}`,function(e){r!==e&&i(e)},[r,e,t]),(0,q.useEffect)(function(){let n=n=>{n.key===e&&i(Pm(e,t))};return window.addEventListener(`storage`,n),()=>{window.removeEventListener(`storage`,n)}},[e,i,t]),n}function Lm(){let e=ie(),{data:t}=le(s()),{mutate:n,isPending:r}=lm(),[i,a]=(0,q.useState)(!1),[o,c]=(0,q.useState)(null),[l,u]=(0,q.useState)(``),d=(0,q.useCallback)(()=>u(``),[]),f=Me(`org:read`),[p,m]=Im(`ShowAllOrganizations`,!1),[h,g]=(0,q.useState)(0),_=f&&p,v=(0,q.useCallback)(e=>{m(e),g(0)},[m]),y=Em(l,300),b=(0,q.useMemo)(()=>{if(!f)return null;let e=vm(y);return e?.kind===`organization`||e?.kind===`cluster`?e:null},[f,y]),x=_||!!b,{data:S,isPending:C}=H({...Tm(h,y),enabled:x}),{organizationRoles:w,oauthLockedOrgs:T}=(0,q.useMemo)(()=>{let e=t?.roles||{},n=[],r=[];for(let[t,i]of Object.entries(e))`oauthProviders`in i&&!f?r.push({organizationId:t,organizationName:i.organizationName,providers:i.oauthProviders}):n.push({organizationId:t,organizationName:i.organizationName,roleName:i.role??`fabric staff`});return{organizationRoles:n.filter(Bf([`organizationId`,`organizationName`],l)).sort((e,t)=>(e.organizationName||``)>(t.organizationName||``)?1:-1),oauthLockedOrgs:r}},[l,t?.roles,f]),E=(0,q.useMemo)(()=>{let e=t?.roles||{};return(S?.organizations||[]).map(t=>({organizationId:t.id,organizationName:t.name,roleName:e[t.id]?.role||`fabric staff`}))},[S?.organizations,t?.roles]),D=x?E:w,O=(0,q.useCallback)(e=>{u(e.currentTarget.value||``),g(0)},[]),k=(0,q.useCallback)(t=>{t?.organizationId&&n(t.organizationId,{onSuccess:()=>{U.success(`Success`,{description:`Organization successfully deleted.`,duration:5e3,action:{label:`Dismiss`,onClick:()=>U.dismiss()}}),e.invalidateQueries({queryKey:[]}),a(!1)},onError:()=>a(!1)})},[n,e,a]),A=(0,q.useCallback)(e=>{c(e),a(!0)},[]),{createCluster:j}=se({strict:!1});return!_&&w.length===1&&!l.length&&j?(0,K.jsx)(ne,{to:`/${w[0].organizationId}/new-cluster`,replace:!0}):!_&&!w.length&&!T.length&&!l.length?(0,K.jsx)(hm,{}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Ks,{children:(0,K.jsxs)(`div`,{className:`flex w-full items-center justify-end gap-2`,children:[f&&(0,K.jsxs)(`label`,{className:`flex shrink-0 cursor-pointer items-center gap-2 text-xs`,children:[(0,K.jsx)(Tp,{checked:p,onCheckedChange:v,"aria-label":`Show all organizations`}),(0,K.jsx)(`span`,{className:`hidden sm:inline-block`,children:`All Orgs`})]}),(0,K.jsx)($,{placeholder:`Filter by name`,className:`inline-block w-full text-xs`,value:l,onChange:O}),(0,K.jsx)(V,{to:`/new-org`,children:(0,K.jsxs)(F,{variant:`positive`,accessKey:`n`,children:[(0,K.jsx)(Ur,{}),(0,K.jsxs)(`span`,{className:`hidden sm:inline-block`,children:[(0,K.jsx)(`u`,{children:`N`}),`ew `,(0,K.jsx)(`span`,{className:`hidden md:inline-block`,children:`Organization`})]})]})})]})}),(0,K.jsxs)(`section`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-theme(spacing.32))]`,children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-12`,children:[!x&&T.map(e=>(0,K.jsx)(`div`,{className:`col-span-1 md:col-span-4 lg:col-span-3 2xl:col-span-2`,children:(0,K.jsx)(nm,{organizationId:e.organizationId,organizationName:e.organizationName,providers:e.providers})},e.organizationId)),x&&C?Array.from({length:12},(e,t)=>(0,K.jsx)(tm,{className:`col-span-1 h-40 md:col-span-4 lg:col-span-3 2xl:col-span-2`},t)):D.map(e=>(0,K.jsx)(`div`,{className:`col-span-1 md:col-span-4 lg:col-span-3 2xl:col-span-2`,children:(0,K.jsx)(sm,{organizationRole:e,onDeleteOrgModal:A})},e.organizationId)),!D.length&&!(x&&C)&&(x||!T.length)&&(0,K.jsxs)(`div`,{className:`col-span-1 md:col-span-12 text-center`,children:[(0,K.jsx)(`h2`,{className:`my-4 text-xl`,children:`No matches found.`}),(0,K.jsx)(F,{variant:`outline`,onClick:d,children:`Clear Filters`})]})]}),x&&(h>0||S?.hasNextPage)&&(0,K.jsxs)(`div`,{className:`flex items-center justify-center gap-4 py-6`,children:[(0,K.jsxs)(F,{variant:`defaultOutline`,size:`sm`,className:`select-none`,disabled:h===0,onClick:()=>g(e=>e-1),children:[(0,K.jsx)(Qt,{}),`Previous`]}),(0,K.jsxs)(`span`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:[`Page `,h+1]}),(0,K.jsxs)(F,{variant:`defaultOutline`,size:`sm`,className:`select-none`,disabled:!S?.hasNextPage,onClick:()=>g(e=>e+1),children:[`Next`,(0,K.jsx)(Bn,{})]})]})]}),o&&(0,K.jsx)(qs,{typeOfThingBeingDeleted:`organization`,nameOfThingBeingDeleted:o.organizationName,isModalOpen:i,setIsModalOpen:()=>a(!1),deletionConfirmed:()=>k(o),deletionPending:r})]})}var Rm=I({getParentRoute:()=>uo,id:`_orgsLayout`});I({getParentRoute:()=>Rm,path:`/`,head:()=>({meta:[{title:`Organizations — Harper Fabric`}]}),component:Lm}),I({getParentRoute:()=>Rm,path:`/new-org`,head:()=>({meta:[{title:`New Organization — Harper Fabric`}]}),component:hm});var zm=I({getParentRoute:()=>Rm,path:`$organizationId`,beforeLoad:async e=>{let{organizationId:t}=e.params;if(!mu(t))throw re({to:`/`});return{organization:await e.context.queryClient.ensureQueryData(gu(t))}}});I({getParentRoute:()=>zm,path:`/roles`,head:()=>({meta:[{title:`Organization Roles — Harper Fabric`}]}),component:wp}),I({getParentRoute:()=>zm,path:`/roles/$orgRoleId`,head:()=>({meta:[{title:`Organization Roles — Harper Fabric`}]}),component:wp}),I({getParentRoute:()=>zm,path:`/users`,head:()=>({meta:[{title:`Organization Users — Harper Fabric`}]}),component:em}),I({getParentRoute:()=>zm,path:`/users/$orgUserId`,head:()=>({meta:[{title:`Organization Users — Harper Fabric`}]}),component:em}),I({getParentRoute:()=>zm,path:`/settings`,component:Ap}),tp(zm);var Bm=I({getParentRoute:()=>zm,id:`_clusterLayout`});I({getParentRoute:()=>Bm,path:`/`,head:()=>({meta:[{title:`Clusters — Harper Fabric`}]}),component:Vf}),I({getParentRoute:()=>zm,path:`/new-cluster`,head:()=>({meta:[{title:`New Cluster — Harper Fabric`}]}),component:Ff}),I({getParentRoute:()=>Hm,path:`/edit`,head:()=>({meta:[{title:`Edit Cluster — Harper Fabric`}]}),component:Ff}),I({getParentRoute:()=>Hm,path:`/edit/$mode`,head:()=>({meta:[{title:`Edit Cluster — Harper Fabric`}]}),component:Ff});function Vm(){return(0,K.jsx)(Ce,{})}var Hm=I({getParentRoute:()=>Bm,path:`$clusterId`,component:Vm,beforeLoad:async({context:e,params:t})=>({cluster:await e.queryClient.ensureQueryData(Jo(t.clusterId))})}),Um=e=>new Intl.NumberFormat(void 0,{notation:`compact`,maximumFractionDigits:1}).format(e),Wm=e=>`${new Intl.NumberFormat(void 0,{maximumFractionDigits:1}).format(e)} hr`,Gm=e=>df(e),Km={reads:`Reads`,readBytes:`Read data`,writes:`Writes`,writeBytes:`Write data`,realTimeMessages:`Real-time messages`,realTimeBytes:`Real-time data`,cpuTimeHours:`Compute`,storageBytes:`Storage`},qm={reads:Um,readBytes:Gm,writes:Um,writeBytes:Gm,realTimeMessages:Um,realTimeBytes:Gm,cpuTimeHours:Wm,storageBytes:Gm},Jm=[`reads`,`readBytes`,`writes`,`writeBytes`,`realTimeMessages`,`realTimeBytes`,`cpuTimeHours`,`storageBytes`];function Ym(e,t,n){return{label:n??Km[e],used:t.used,limit:t.limit,unlimited:t.unlimited,limitKnown:t.limitKnown,format:qm[e]}}function Xm({label:e,used:t,limit:n,unlimited:r,limitKnown:i,format:a}){let o=r||n!=null&&n<0,s=i&&!o&&n!=null&&n>0,c=s?Math.min(100,Math.round(t/n*100)):0,l=c>=90;return(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2 text-sm`,children:[(0,K.jsx)(`span`,{className:`text-foreground`,children:e}),(0,K.jsxs)(`span`,{className:`text-muted-foreground tabular-nums`,children:[(0,K.jsx)(`span`,{className:`text-foreground`,children:a(t)}),s?(0,K.jsxs)(K.Fragment,{children:[`/ `,a(n)]}):` used`]})]}),(0,K.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-2`,children:[(0,K.jsx)(`div`,{className:`h-2 flex-1 overflow-hidden rounded-full bg-muted`,children:s?(0,K.jsx)(`div`,{className:`h-full rounded-full ${l?`bg-yellow`:`bg-primary dark:bg-violet-400`}`,style:{width:`${c}%`}}):o?(0,K.jsx)(`div`,{className:`h-full w-full bg-[repeating-linear-gradient(-45deg,transparent,transparent_5px,var(--color-border)_5px,var(--color-border)_9px)] dark:bg-[repeating-linear-gradient(-45deg,transparent,transparent_5px,rgba(255,255,255,0.32)_5px,rgba(255,255,255,0.32)_9px)]`}):null}),(0,K.jsx)(`span`,{className:`w-16 shrink-0 text-right text-xs tabular-nums ${l?`text-yellow`:`text-muted-foreground`}`,children:s?`${c}%`:o?`Unlimited`:`—`})]})]})}function Zm(e){return z({queryKey:[`clusterUsage`,e],queryFn:async()=>{let{data:t}=await N.get(`/Cluster/${e}/usage`);return t},enabled:!!e,staleTime:6e4})}function Qm(e){return H(Zm(e))}function $m(e){let{regions:t}=e,n=t.every(e=>e.planName===t[0]?.planName)?t[0]?.planName:null,r=t.length>1?`next renewal`:`renews`;return[n?`${n} plan`:null,e.renewsAt?`${r} ${eh(e.renewsAt)}`:null].filter(Boolean).join(` · `)}function eh(e){return new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`}).format(new Date(e))}function th({clusterId:e,base:t}){let{data:n}=Qm(e);return!n||n.selfManaged||n.regions.length===0?null:(0,K.jsxs)(`section`,{className:`mt-6 rounded-2xl border border-border bg-card p-5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,K.jsx)(`h2`,{className:`text-sm font-medium text-foreground`,children:`Plan usage`}),(0,K.jsxs)(V,{to:`${t}/usage`,className:`inline-flex items-center gap-1 text-xs text-primary hover:underline dark:text-violet-300`,children:[`View all usage `,(0,K.jsx)(Bn,{className:`size-3`})]})]}),(0,K.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:$m(n)}),(0,K.jsx)(`div`,{className:`mt-4`,children:n.regions.length===1?(0,K.jsx)(nh,{data:n}):(0,K.jsx)(rh,{data:n})})]})}function nh({data:e}){let t=e.regions[0].metrics,n=[Ym(`reads`,t.reads),Ym(`writes`,t.writes),Ym(`storageBytes`,t.storageBytes),Ym(`cpuTimeHours`,t.cpuTimeHours)];return(0,K.jsx)(`div`,{className:`grid grid-cols-1 gap-x-8 gap-y-4 sm:grid-cols-2`,children:n.map(e=>(0,K.jsx)(Xm,{...e},e.label))})}function rh({data:e}){let t=e.mostConstrained;return(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`p`,{className:`mb-1.5 text-xs text-muted-foreground`,children:[`Most constrained of `,e.regions.length,` regions`]}),t?(0,K.jsx)(Xm,{...Ym(t.metric,{used:t.used,limit:t.limit,unlimited:!1,limitKnown:!0},`${t.region??`Region`} · ${Km[t.metric]}`)}):(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No metered limits on the current plan — see the breakdown for details.`})]})}function ih({cluster:e}){let t=ae(),n=ie(),{update:r,remove:i}=ml(e.organizationId,e.id),{run:a,isPending:o}=Rl(e),{mutate:s,isPending:c}=Pl(),[l,u]=(0,q.useState)(!1),[d,f]=(0,q.useState)(!1),[p,m]=(0,q.useState)(!1),[h,g]=(0,q.useState)(null),_=e.status===`RUNNING`,v=e.status===`STOPPED`,y=e.status===`PARTIAL`,b=!r||o,x=(0,q.useCallback)(()=>{s(e.id,{onSuccess:async()=>{await n.invalidateQueries({queryKey:[e.organizationId],refetchType:`active`}),m(!1),U.success(`Success`,{description:`Cluster successfully terminated.`,action:{label:`Dismiss`,onClick:()=>U.dismiss()}}),t.navigate({to:`/${e.organizationId}`})},onError:()=>{m(!1)}})},[e.id,e.organizationId,s,n,t]),S=(0,q.useCallback)(()=>{let e=h;g(null),e&&a(e,{safeMode:!0,strategy:`parallel`,label:e===`start`?`Starting in safe mode`:`Restarting in safe mode`})},[h,a]);return El(e)||!r&&!i?null:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(bi,{children:[(0,K.jsx)(xi,{asChild:!0,children:(0,K.jsxs)(F,{variant:`outline`,size:`sm`,disabled:o,className:`gap-1.5 hover:translate-y-0 data-[state=open]:[&>svg]:rotate-180`,children:[`Cluster actions`,(0,K.jsx)(mn,{className:`size-4 transition-transform`})]})}),(0,K.jsxs)(Si,{align:`end`,className:`w-56`,children:[(0,K.jsx)(Ti,{className:`text-gray-600 text-xs`,children:`Container`}),(0,K.jsxs)(Ci,{disabled:b||!(v||y),onClick:()=>void a(`start`,{safeMode:!1,strategy:`parallel`}),children:[(0,K.jsx)(Hr,{}),` Start`]}),(0,K.jsxs)(Ci,{disabled:b||!v,onClick:()=>g(`start`),children:[(0,K.jsx)(Dr,{}),` Start in safe mode`]}),(0,K.jsxs)(Ci,{disabled:b||!(_||y),onClick:()=>f(!0),children:[(0,K.jsx)(qr,{}),` Restart`]}),(0,K.jsxs)(Ci,{disabled:b||!_,onClick:()=>g(`restart`),children:[(0,K.jsx)(Dr,{}),` Restart in safe mode`]}),(0,K.jsxs)(Ci,{variant:`destructive`,disabled:b||!(_||y),onClick:()=>u(!0),children:[(0,K.jsx)(ri,{}),` Stop`]}),(0,K.jsx)(Ei,{}),(0,K.jsxs)(Ci,{variant:`destructive`,disabled:!i,onClick:()=>m(!0),children:[(0,K.jsx)(di,{}),` Terminate`]})]})]}),(0,K.jsx)(kl,{clusterName:e.name,isPending:o,stopOpen:l,setStopOpen:u,onConfirmStop:()=>{u(!1),a(`stop`,{strategy:`parallel`})},restartOpen:d,setRestartOpen:f,onConfirmRestart:e=>{f(!1),a(`restart`,{safeMode:!1,strategy:e})}}),(0,K.jsx)(Ml,{open:h!==null,setOpen:e=>{e||g(null)},action:h??`restart`,targetName:e.name,scope:`cluster`,isPending:o,onConfirm:S}),(0,K.jsx)(qs,{typeOfThingBeingDeleted:`cluster`,transitiveVerb:`Terminate`,presentParticiple:`Terminating`,nameOfThingBeingDeleted:e.name,isModalOpen:p,setIsModalOpen:m,deletionConfirmed:x,deletionPending:c})]})}function ah(){let{clusterId:e}=B({strict:!1}),t=ae(),n=L(),{data:r}=H(Jo(e,!0)),{user:i,isLoading:a}=Ne(e),{view:s,update:c}=ml(r?.organizationId,r?.id),[d,f]=(0,q.useState)(!1),p=r?.domains?.[0]?.domain||r?.fqdn||``,[m,g]=Vl(p,p?`https://${p}`:``),_=r?`/${r.organizationId}/${r.id}`:``,v=(0,q.useCallback)(async()=>{if(r){f(!0);try{await l.establishFabricConnectAuth({id:r.id,operationsUrl:o(r)}),await t.invalidate()}catch{U.error(`Could not connect to this cluster through Fabric Connect.`)}finally{f(!1)}}},[r,t]),y=(0,q.useCallback)(()=>{r&&(l.setUserForEntity(r,null),l.flagForFabricConnect(r.id,!1)),n({to:`${_}/sign-in`})},[_,r,n]),b=(0,q.useCallback)(async()=>{if(r){try{await u({instanceClient:h({id:r.id}),entityId:r.id})}catch{}l.setUserForEntity(r,null),l.flagForFabricConnect(r.id,!1),l.flagForBasicAuth(r.id,null),await t.invalidate()}},[r,t]);if(!r)return(0,K.jsx)(sh,{children:(0,K.jsx)(ch,{})});if(!s)return(0,K.jsx)(ne,{to:`/${r.organizationId}`,replace:!0});if(El(r))return(0,K.jsx)(oh,{cluster:r});if(!r.fqdn)return(0,K.jsx)(ne,{to:`${_}/instances`,replace:!0});if(r.resetPassword){if(!c)return(0,K.jsx)(sh,{children:(0,K.jsxs)(`div`,{className:`text-center py-12`,children:[(0,K.jsx)(Zr,{className:`size-12 text-muted-foreground mx-auto mb-4`}),(0,K.jsx)(`h1`,{className:`text-xl font-medium mb-2 text-foreground`,children:`Pending Owner Setup`}),(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground max-w-md mx-auto`,children:`This cluster needs an administrator to finish setup before it can be used.`})]})});let e=r.status&&Mo.includes(r.status)&&Go(r);return(0,K.jsx)(ne,{to:`${_}/${e?`finish-setup`:`starting-up`}`,replace:!0})}let x=l.checkForFabricConnect(r.id),S=!!i,C=l.getLastConnectMode(r.id),w=(r.instances??[]).filter(e=>e.status&&!No.includes(e.status)).length,T=r.instances??[],E=!!r.status&&Mo.includes(r.status)&&T.length>0&&T.every(e=>e.safeMode);return(0,K.jsxs)(sh,{children:[(0,K.jsxs)(`div`,{className:`flex items-start gap-4 mb-6`,children:[(0,K.jsx)(`div`,{className:`flex items-center justify-center size-12 rounded-xl bg-violet-50 text-primary dark:bg-grey-700 dark:text-violet-300 shrink-0`,children:(0,K.jsx)(Zr,{className:`size-6`})}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3 flex-wrap`,children:[(0,K.jsx)(`h1`,{className:`text-2xl font-light text-foreground`,children:r.name}),(0,K.jsx)(lh,{status:r.status}),E&&(0,K.jsx)(uh,{})]}),(0,K.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-sm text-muted-foreground`,children:[(0,K.jsxs)(`span`,{children:[w,` `,w===1?`instance`:`instances`]}),(0,K.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,K.jsxs)(`a`,{href:`https://${p}`,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 hover:text-foreground hover:underline`,children:[p,(0,K.jsx)(dr,{className:`size-3`})]}),(0,K.jsxs)(bi,{children:[(0,K.jsx)(xi,{"aria-label":`Copy cluster URLs`,className:`rounded-md p-1 -m-1 hover:bg-accent/60 hover:text-foreground`,children:(0,K.jsx)(sr,{className:`size-3.5`})}),(0,K.jsxs)(Si,{align:`start`,children:[(0,K.jsx)(Ci,{onClick:m,children:`Copy host name`}),(0,K.jsx)(Ci,{onClick:g,children:`Copy API URL`})]})]})]})]}),(0,K.jsx)(ih,{cluster:r})]}),a?(0,K.jsx)(ch,{}):S?(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-4 text-sm`,children:[(0,K.jsx)(Qn,{className:`size-4 text-green shrink-0`}),(0,K.jsx)(`span`,{className:`font-medium text-green`,children:x?`Connected via Fabric Connect`:`Signed in directly`}),(0,K.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`· `,x?`through your Harper account`:`session cookie`]})]}),(0,K.jsxs)(V,{to:`${_}/apps`,className:`group flex items-center gap-4 rounded-2xl border-2 border-primary/30 bg-primary/5 p-6 transition-all hover:border-primary hover:bg-primary/10 dark:border-violet-400/30 dark:bg-violet-400/5 dark:hover:border-violet-400 dark:hover:bg-violet-400/10`,children:[(0,K.jsx)(`div`,{className:`flex size-12 items-center justify-center rounded-xl bg-primary/10 text-primary shrink-0 dark:bg-violet-400/15 dark:text-violet-300`,children:(0,K.jsx)(Gr,{className:`size-6`})}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`div`,{className:`text-lg font-medium text-foreground`,children:`Enter cluster`}),(0,K.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`Open the studio — apps, databases, APIs, logs, and config.`})]}),(0,K.jsx)(Bn,{className:`size-5 text-muted-foreground transition-transform group-hover:translate-x-1`})]}),(0,K.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-4 text-sm`,children:[x&&(0,K.jsx)(`button`,{type:`button`,onClick:y,className:`text-muted-foreground hover:text-foreground transition-colors`,children:`Switch to direct sign-in`}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>void b(),className:`text-muted-foreground hover:text-destructive transition-colors`,children:x?`Disconnect`:`Direct sign out`})]})]}):(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{className:`text-sm font-medium text-foreground mb-3`,children:`Connect to this cluster`}),(0,K.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3.5`,children:[c&&!El(r)&&(0,K.jsx)(dh,{icon:gi,title:`Fabric Connect`,description:`Connect through your Harper account. No cluster credentials needed.`,pill:C===`fabric`?`last`:C?void 0:`recommended`,children:(0,K.jsx)(F,{className:`w-full`,disabled:d,onClick:()=>void v(),children:d?(0,K.jsx)(kr,{className:`animate-spin`}):`Fabric Connect`})}),(0,K.jsx)(dh,{icon:wr,title:`Direct sign-in`,description:`Sign in with this cluster's Harper username and password.`,pill:C===`direct`?`last`:void 0,children:(0,K.jsx)(F,{className:`w-full`,variant:`outline`,onClick:y,children:`Direct sign-in`})})]})]}),(0,K.jsx)(th,{clusterId:r.id,base:_})]})}function oh({cluster:e}){let t=ae(),n=L(),r=`/${e.organizationId}/${e.id}`,i=(0,q.useMemo)(()=>(e.instances??[]).filter(e=>e.status&&!No.includes(e.status)).sort(au),[e.instances]),a=i.at(0),{user:o,isLoading:s}=Ne(a?.id),c=!!a&&!!o,d=(0,q.useCallback)(()=>{a&&n({to:`${r}/instance/${a.id}/sign-in`})},[r,a,n]),p=(0,q.useCallback)(async()=>{if(a){try{await u({instanceClient:h({id:a.id,operationsUrl:f(a)}),entityId:a.id})}catch{}l.setUserForEntity(a,null),l.flagForBasicAuth(a.id,null),await t.invalidate()}},[a,t]);return(0,K.jsxs)(sh,{children:[(0,K.jsxs)(`div`,{className:`flex items-start gap-4 mb-6`,children:[(0,K.jsx)(`div`,{className:`flex items-center justify-center size-12 rounded-xl bg-violet-50 text-primary dark:bg-grey-700 dark:text-violet-300 shrink-0`,children:(0,K.jsx)(Zr,{className:`size-6`})}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3 flex-wrap`,children:[(0,K.jsx)(`h1`,{className:`text-2xl font-light text-foreground`,children:e.name}),(0,K.jsx)(`span`,{className:`inline-flex items-center gap-1.5 text-xs px-2.5 py-0.5 rounded-full text-muted-foreground bg-muted`,children:`Self-Hosted`})]}),(0,K.jsx)(`div`,{className:`mt-1 text-sm text-muted-foreground`,children:(0,K.jsxs)(V,{to:`${r}/instances`,className:`hover:text-foreground hover:underline`,children:[i.length,` `,i.length===1?`instance`:`instances`]})})]})]}),a?s?(0,K.jsx)(ch,{}):c?(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-4 text-sm`,children:[(0,K.jsx)(Qn,{className:`size-4 text-green shrink-0`}),(0,K.jsx)(`span`,{className:`font-medium text-green`,children:`Signed in directly`}),(0,K.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`· `,a.name||a.instanceFqdn]})]}),(0,K.jsxs)(V,{to:`${r}/instance/${a.id}/`,className:`group flex items-center gap-4 rounded-2xl border-2 border-primary/30 bg-primary/5 p-6 transition-all hover:border-primary hover:bg-primary/10 dark:border-violet-400/30 dark:bg-violet-400/5 dark:hover:border-violet-400 dark:hover:bg-violet-400/10`,children:[(0,K.jsx)(`div`,{className:`flex size-12 items-center justify-center rounded-xl bg-primary/10 text-primary shrink-0 dark:bg-violet-400/15 dark:text-violet-300`,children:(0,K.jsx)(Gr,{className:`size-6`})}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`div`,{className:`text-lg font-medium text-foreground`,children:`Enter cluster`}),(0,K.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`Open the studio — apps, databases, APIs, logs, and config.`})]}),(0,K.jsx)(Bn,{className:`size-5 text-muted-foreground transition-transform group-hover:translate-x-1`})]}),(0,K.jsx)(`div`,{className:`mt-4 flex flex-wrap gap-4 text-sm`,children:(0,K.jsx)(`button`,{type:`button`,onClick:()=>void p(),className:`text-muted-foreground hover:text-destructive transition-colors`,children:`Direct sign out`})})]}):(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{className:`text-sm font-medium text-foreground mb-3`,children:`Connect to this cluster`}),(0,K.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3.5`,children:(0,K.jsx)(dh,{icon:wr,title:`Direct sign-in`,description:`Sign in with this instance's Harper username and password.`,children:(0,K.jsx)(F,{className:`w-full`,variant:`outline`,onClick:d,children:`Direct sign-in`})})})]}):(0,K.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`This cluster has no instances yet. Register one from the`,` `,(0,K.jsx)(V,{to:`${r}/instances`,className:`underline hover:text-foreground`,children:`Instances`}),` page.`]})]})}function sh({children:e}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Ks,{}),(0,K.jsx)(Kl,{children:(0,K.jsx)(`div`,{className:`max-w-3xl`,children:e})})]})}function ch(){return(0,K.jsx)(`div`,{className:`flex justify-center py-10 text-muted-foreground`,children:(0,K.jsx)(kr,{className:`size-6 animate-spin`})})}function lh({status:e}){let t=e&&Mo.includes(e)?`text-green bg-green/10`:e===`STOPPED`?`text-destructive bg-destructive/10`:e===`PARTIAL`?`text-yellow bg-yellow/10`:`text-muted-foreground bg-muted`;return(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs px-2.5 py-0.5 rounded-full ${t}`,children:[(0,K.jsx)(`span`,{className:`size-1.5 rounded-full bg-current`}),e?e.charAt(0)+e.slice(1).toLowerCase():`Unknown`]})}function uh(){return(0,K.jsxs)(`span`,{title:`All instances running in safe mode — user apps/components are not loaded`,className:`inline-flex items-center gap-1.5 text-xs px-2.5 py-0.5 rounded-full text-yellow bg-yellow/10`,children:[(0,K.jsx)(Dr,{className:`size-3`}),`Safe mode`]})}function dh({icon:e,title:t,description:n,pill:r,children:i}){return(0,K.jsxs)(`div`,{className:`relative rounded-xl p-4.5 bg-card border ${r===`last`?`border-2 border-green`:r===`recommended`?`border-2 border-primary dark:border-violet-400`:`border-border`}`,children:[r&&(0,K.jsx)(`span`,{className:`absolute -top-2.5 left-4 rounded-full bg-card`,children:(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs px-2.5 py-0.5 rounded-full ${r===`last`?`text-green bg-green/15`:`text-primary bg-violet-50 dark:text-violet-300 dark:bg-grey-700`}`,children:[r===`last`&&(0,K.jsx)(`span`,{className:`size-1.5 rounded-full bg-current`}),r===`last`?`Last used`:`Recommended`]})}),(0,K.jsx)(e,{className:`size-6 text-primary dark:text-violet-300 mb-2`}),(0,K.jsx)(`div`,{className:`text-[15px] font-medium text-foreground mb-1`,children:t}),(0,K.jsx)(`p`,{className:`text-[13px] text-muted-foreground leading-normal mb-4`,children:n}),i]})}function fh({children:e,className:t}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Ks,{}),(0,K.jsx)(Kl,{children:(0,K.jsx)(`div`,{className:t,children:e})})]})}var ph=new Set([`com`,`co`,`org`,`net`,`edu`,`gov`,`mil`,`me`,`biz`,`info`,`ac`,`or`,`ne`,`go`,`lg`,`asn`,`id`,`nom`,`sch`,`ltd`,`plc`]);function mh(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&&ph.has(r)?3:2;return t.length<=i?`@`:t.slice(0,-i).join(`.`)}function hh({cluster:{fqdn:e},domain:{domain:t,id:n}}){let r=mh(t),[i,a,o]=Vl(r,e||``,n);return(0,K.jsxs)(`div`,{className:`grid gap-4 grid-cols-1 md:grid-cols-[80px_1fr] pb-6`,children:[(0,K.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,K.jsx)(`div`,{className:`col-span-1`,children:`Type:`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`CNAME`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Name:`}),(0,K.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,K.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,K.jsx)(F,{type:`button`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:i,children:(0,K.jsx)(sr,{className:`w-3.5 h-3.5`})})]})}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`TTL:`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Auto`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Target:`}),(0,K.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,K.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,K.jsx)(F,{type:`button`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:a,children:(0,K.jsx)(sr,{className:`w-3.5 h-3.5`})})]})}),(0,K.jsx)(`div`,{className:`col-span-1 text-xs`,children:`Domain ID:`}),(0,K.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-0.5 text-xs text-muted-foreground italic flex-1 overflow-hidden`,children:[(0,K.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,K.jsx)(F,{type:`button`,variant:`ghost`,className:`h-5 w-5 p-0 shrink-0`,onClick:o,children:(0,K.jsx)(sr,{className:`w-3 h-3`})})]})}),(0,K.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 gh({certificate:e,domain:t,cluster:n}){let r=mh(t.domain),[i,a,o]=Vl(r,n.fqdn||``,t.id),s=(0,q.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,K.jsxs)(`div`,{className:`w-full max-w-2xl border border-border/50 rounded-md p-4 bg-gray-900/20`,children:[(0,K.jsxs)(`div`,{className:`mb-4`,children:[(0,K.jsx)(`div`,{className:`w-full h-1.5 rounded-full overflow-clip flex shadow-sm bg-gray-800`,children:(0,K.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,K.jsx)(`div`,{className:`text-[10px] text-muted-foreground font-light mt-1 italic`,children:s.text})]}),(0,K.jsxs)(`div`,{className:`grid gap-2 grid-cols-1 md:grid-cols-[80px_1fr] text-sm`,children:[(0,K.jsx)(`div`,{className:`col-span-1 text-xs text-muted-foreground`,children:`CNAME:`}),(0,K.jsxs)(`div`,{className:`col-span-1 flex gap-2 items-center flex-wrap`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted px-2 py-0.5 rounded text-xs`,children:[(0,K.jsx)(`span`,{className:`truncate max-w-[150px]`,title:r,children:r}),(0,K.jsx)(F,{type:`button`,variant:`ghost`,size:`sm`,className:`h-4 w-4 p-0`,onClick:i,title:`Copy Name`,children:(0,K.jsx)(sr,{className:`w-3 h-3`})})]}),(0,K.jsx)(_h,{}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted px-2 py-0.5 rounded text-xs`,children:[(0,K.jsx)(`span`,{className:`truncate max-w-[200px]`,title:n.fqdn||``,children:n.fqdn}),(0,K.jsx)(F,{type:`button`,variant:`ghost`,size:`sm`,className:`h-4 w-4 p-0`,onClick:a,title:`Copy Target`,children:(0,K.jsx)(sr,{className:`w-3 h-3`})})]})]}),(0,K.jsx)(`div`,{className:`col-span-1 text-[10px] text-muted-foreground`,children:`Domain ID:`}),(0,K.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted px-2 py-0.5 rounded text-[10px] text-muted-foreground italic`,children:[(0,K.jsx)(`span`,{className:`truncate max-w-[200px]`,children:t.id}),(0,K.jsx)(F,{type:`button`,variant:`ghost`,size:`sm`,className:`h-3 w-3 p-0`,onClick:o,title:`Copy ID`,children:(0,K.jsx)(sr,{className:`w-2.5 h-2.5`})})]})})]})]})}function _h(){return(0,K.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,K.jsx)(`path`,{d:`M5 12h14`}),(0,K.jsx)(`path`,{d:`m12 5 7 7-7 7`})]})}function vh(e){let{enabled:t,entityId:n,databaseName:r,tableName:i,searchAttribute:a,sort:o,pageIndex:s,pageSize:c,onlyIfCached:l,getAttributes:u}=e;return z({enabled:t,queryKey:[n,r,i,`search_by_value`,a,o.attribute||`default`,o.descending||!1,s||0,c||0,l,u??null],retry:!1,staleTime:6e4,gcTime:5e3,queryFn:()=>yh(e)})}async function yh({instanceClient:e,databaseName:t,tableName:n,searchAttribute:r,sort:i,pageIndex:a,pageSize:o,onlyIfCached:s,getAttributes:c,headers:l}){let u=i.attribute.length&&!(i.attribute===r&&!i.descending),d=await e.post(`/`,{operation:`search_by_value`,get_attributes:c??[`*`],database:t,table:n,search_attribute:r,search_value:`*`,sort:u?i:void 0,offset:a*o,limit:o,onlyIfCached:s,noCacheStore:s},{timeout:0,headers:l,validateStatus:e=>e>=200&&e<400||e===404});return d.status===404?{data:[]}:d}function bh(e){return z({queryKey:[e,`ChallengeCertificate`],queryFn:async()=>{if(!e)return[];let{data:t}=await yh({searchAttribute:`domain`,entityId:e,databaseName:`data`,tableName:`ChallengeCertificate`,sort:{attribute:`domain`,descending:!0},instanceClient:h({id:e,forceFabricConnect:!0}),onlyIfCached:!1,pageIndex:0,pageSize:100});return t},enabled:!!e,refetchInterval:jn(5e3),retry:On()})}function xh(e){return H(bh(e))}function Sh({domain:{challengeToken:e,challengeTxtRecord:t,domain:n,id:r},cluster:{fqdn:i}}){let a=mh(n),[o,s,c,l,u]=Vl(t,e,a,i||``,r);return(0,K.jsxs)(`div`,{className:`grid gap-2 grid-cols-1 md:grid-cols-[80px_1fr] pb-6`,children:[(0,K.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,K.jsx)(`div`,{className:`col-span-1`,children:`Type:`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`TXT`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Name:`}),(0,K.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,K.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,K.jsx)(F,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:o,children:(0,K.jsx)(sr,{className:`w-3.5 h-3.5`})})]})}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`TTL:`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Auto`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Content:`}),(0,K.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,K.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,K.jsx)(F,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:s,children:(0,K.jsx)(sr,{className:`w-3.5 h-3.5`})})]})}),(0,K.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,K.jsx)(`div`,{className:`col-span-1`,children:`Type:`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`CNAME`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Name:`}),(0,K.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,K.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,K.jsx)(F,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:c,children:(0,K.jsx)(sr,{className:`w-3.5 h-3.5`})})]})}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`TTL:`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Auto`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Target:`}),(0,K.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,K.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,K.jsx)(F,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:l,children:(0,K.jsx)(sr,{className:`w-3.5 h-3.5`})})]})}),(0,K.jsx)(`div`,{className:`col-span-1 text-xs`,children:`Domain ID:`}),(0,K.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-0.5 text-xs text-muted-foreground italic flex-1 overflow-hidden`,children:[(0,K.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,K.jsx)(F,{type:`button`,size:`sm`,variant:`ghost`,className:`h-5 w-5 p-0 shrink-0`,onClick:u,children:(0,K.jsx)(sr,{className:`w-3 h-3`})})]})}),(0,K.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 Ch({clusterId:e,domainIds:t,generateDomainCerts:n}){let{data:r}=await N.put(`/Cluster/${e}`,{domainIds:t,generateDomainCerts:n},{timeout:0});return r}function wh(){return R({mutationFn:e=>Ch(e)})}A.object({domainId:A.string()});async function Th(e){let{data:t}=await N.delete(`/Domain/${e.domainId}`);return t}function Eh(){return R({mutationFn:e=>Th(e)})}function Dh(e){return[...new Set(e)]}var Oh=Mn();function kh(e,t,n){let{data:r}=xh(e.id),i=(0,q.useMemo)(()=>!!r?.some(e=>!e.issueDate||e.inProgress),[r]),{mutate:a,isPending:o}=wh(),{mutate:s,isPending:c}=Eh(),l=o||c,u=(0,q.useCallback)((t,n)=>{if(!Bo(e.status)){U.error(`Cluster is currently `+e.status,{description:`To bind a domain, it must be running.`});return}a({clusterId:e.id,domainIds:Dh((e.domainIds?.slice()||[]).concat([t])),generateDomainCerts:n},{onSuccess:()=>{yn.invalidateQueries({queryKey:[e.organizationId],refetchType:`active`}),U.success(`Domain bound!`+(n?` Certificates are being generated in the background now.`:``))}})},[a,e]),d=(0,q.useCallback)(t=>{s({domainId:t},{onSuccess:()=>{yn.invalidateQueries({queryKey:[e.organizationId,`domains`],refetchType:`active`}),U.success(`Domain removed!`)}})},[s]),f=(0,q.useCallback)(t=>{a({clusterId:e.id,domainIds:(e.domainIds?.slice()||[]).filter(e=>e!==t),generateDomainCerts:!1},{onSuccess:()=>{yn.invalidateQueries({queryKey:[e.organizationId],refetchType:`active`}),U.success(`Domain unbound!`)}})},[s]);return(0,q.useMemo)(()=>[Oh.display({id:`select`,header:`Bind`,size:50,cell:r=>{let a=r.row.original;return a.status===`ACTIVE`&&!a.clusterId&&!El(e)?(0,K.jsx)(`label`,{className:`p-10 -m-10`,children:(0,K.jsx)(`input`,{type:`checkbox`,checked:t.includes(a.id),onChange:()=>n(a.id),disabled:l||i})}):null}}),Oh.display({header:`Domains`,id:`domain`,enableSorting:!1,size:150,cell:e=>{let t=e.row.original;return(0,K.jsxs)(Ia,{children:[(0,K.jsx)(La,{asChild:!0,children:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{children:t.domain}),(0,K.jsx)(F,{type:`button`,variant:`destructiveGhost`,className:`text-muted-foreground text-xs`,disabled:l||!!t.clusterId,onClick:()=>d(t.id),children:`Remove Domain`})]})}),(0,K.jsx)(Ra,{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!`})]})}}),Oh.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,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{children:`Bound to this cluster`}),i&&(!i.issueDate||i.inProgress)&&(0,K.jsx)(`div`,{className:`py-2`,children:(0,K.jsx)(gh,{certificate:i,domain:n,cluster:e})}),(0,K.jsx)(F,{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,K.jsx)(Sh,{domain:n,cluster:e}):El(e)?`Cannot be associated with this self-managed cluster.`:n.status===`ACTIVE`&&!n.clusterId?(0,K.jsx)(hh,{cluster:e,domain:n}):n.status}})],[e,u,l,r,i,t,n])}var Ah=A.object({domain:A.string(),organizationId:A.string()});async function jh(e){let{data:t}=await N.post(`/Domain/`,e);return t}function Mh(){return R({mutationFn:e=>jh(e)})}async function Nh(e){let{data:t}=await N.post(`/Domain/${e}/validate`);return t}async function Ph(e){let{data:t}=await N.get(`/Domain/?organizationId=${e}`);return t}function Fh(e){return z({queryKey:[e,`domains`],queryFn:()=>Ph(e)})}function Ih(){let{organizationId:e,clusterId:t}=B({strict:!1}),{data:n}=le(Jo(t,!0)),{update:r}=fl(e),{data:i,refetch:o,isFetching:s,isRefetching:c}=H(Fh(e)),l=(0,q.useMemo)(()=>i?.filter(e=>e.status===`PENDING_VALIDATION`)||[],[i]),[u]=(0,q.useState)({attribute:`domain`,descending:!1}),d=(0,q.useMemo)(()=>[{desc:u.descending,id:u.attribute}],[u]),f=Zf(o),[p,m]=(0,q.useState)([]),h=(0,q.useCallback)(e=>{m(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[]),{mutate:g,isPending:_}=wh(),v=(0,q.useCallback)(()=>{if(!Bo(n.status)){U.error(`Cluster is currently `+n.status,{description:`To bind a domain, it must be running.`});return}g({clusterId:n.id,domainIds:Dh((n.domainIds?.slice()||[]).concat(p)),generateDomainCerts:!0},{onSuccess:()=>{yn.invalidateQueries({queryKey:[n.organizationId],refetchType:`active`}),U.success(`Domain(s) bound! Certificates are being generated in the background now.`),m([])}})},[n,p,g]),{mutateAsync:y,isPending:b}=Mh(),x=dt({resolver:Fe(Ah),defaultValues:{domain:``,organizationId:e}}),S=(0,q.useCallback)(async e=>{if(e){let t=e.domain.split(/[,\s]+/).map(e=>e.trim()).filter(Boolean);for(let n of t)await y({...e,domain:n});x.reset(),await o(),U.success(`${a(t.length,`Domain`,`Domains`)} added! Please add the txt record above to your domain registrar.`)}},[y,x,o]),C=(0,q.useCallback)(async()=>{let e=`Validating ${a(l.length,`domain`,`domains`)}...`,t=`validatingDomains`,n=0,r=0;for(let i of l)try{U.loading(e,{description:`${n++} of ${l.length} checked`,id:t}),await Nh(i.id)}catch{r+=1}r>0?U.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 o(),U.success(`Validation succeeded!`,{description:`Please take a look at the next steps for newly verified domains.`,id:t}))},[l]),w=kh(n,p,h),T=x.watch(`domain`),E=(0,q.useMemo)(()=>typeof T==`string`&&T.trim().split(`.`).length===2,[T]),D=(0,q.useCallback)(()=>{typeof T==`string`&&x.setValue(`domain`,`${T.trim()}, www.${T.trim()}`)},[T,x]);return(0,K.jsx)(Kf,{data:i||[],isFetching:s||c,columns:w,sortingState:d,children:(0,K.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,K.jsx)(Do,{...x,children:(0,K.jsxs)(`form`,{id:`cluster-add-domain-form`,name:`cluster-add-domain-form`,onSubmit:x.handleSubmit(S),className:`flex gap-1 flex-col md:flex-row`,children:[(0,K.jsx)(Y,{control:x.control,name:`domain`,render:({field:e})=>(0,K.jsxs)(X,{className:`flex-1`,children:[(0,K.jsx)(Z,{className:`pb-1`,children:`New Domain Name`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`text`,enterKeyHint:`done`,autoComplete:`off`,...e})}),E&&(0,K.jsxs)(`div`,{className:`mt-1 flex gap-4`,children:[`Adding an apex domain?`,(0,K.jsx)(F,{variant:`positiveOutline`,type:`button`,onClick:D,children:`Add www as well`})]}),(0,K.jsx)(Q,{children:(0,K.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,K.jsxs)(`div`,{className:`flex-0 self-start flex gap-1 md:pt-6.5`,children:[(0,K.jsxs)(F,{type:`submit`,variant:`submit`,disabled:b,children:[(0,K.jsx)(Ur,{}),` Add`]}),l.length>0&&(0,K.jsxs)(F,{variant:`positiveOutline`,onClick:C,accessKey:`r`,type:`button`,disabled:s||c,children:[(0,K.jsx)(Or,{}),` `,(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`u`,{children:`V`}),`alidate`]})]}),(0,K.jsxs)(F,{variant:`defaultOutline`,onClick:f,accessKey:`r`,type:`button`,disabled:s||c,children:[(0,K.jsx)(Wr,{}),` `,(0,K.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,K.jsx)(`u`,{children:`R`}),`efresh`]})]})]})]})}),p.length>0&&(0,K.jsx)(`div`,{className:`flex-0 self-start md:pt-6.5`,children:(0,K.jsxs)(F,{variant:`submit`,onClick:v,disabled:_,children:[(0,K.jsx)(Jr,{}),` Bind `,a(p.length,`Domain`,`Domains`)]})})]})})}function Lh(){return(0,K.jsx)(fh,{className:`flex flex-col justify-start max-w-4xl`,children:(0,K.jsx)(Ih,{})})}var Rh=y({username:Zo,role:M().nonempty({error:`Please select a role.`}),password:Xo.min(8,{error:`Password must be at least 8 characters long.`}),confirmPassword:M()}).refine(e=>e.password===e.confirmPassword,{error:`Passwords do not match.`,path:[`confirmPassword`]});async function zh(e){await N.patch(`/ResetPasswordUpdater/${e}`)}async function Bh(e){let{instanceClient:t,...n}=e,{data:r}=await t.post(`/`,{operation:`add_user`,...n});return r}function Vh(){return R({mutationFn:Bh})}async function Hh({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 Uh(){return R({mutationFn:Hh})}async function Wh({username:e,instanceClient:t}){let{data:n}=await t.post(`/`,{operation:`drop_user`,username:e});return n}function Gh(){return R({mutationFn:Wh})}async function Kh({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 Fo({username:t,password:i,instanceClient:o,entityId:e});return a.instanceClient&&(o=a.instanceClient),n===`HDB_ADMIN`?await Hh({username:n,password:r,instanceClient:o}):(await Bh({username:n,password:r,role:`super_user`,active:!0,instanceClient:o}),await Fo({username:n,password:r,instanceClient:o,entityId:e}),await Wh({username:d,instanceClient:o})),await zh(e),a}catch(t){throw await u({entityId:e,instanceClient:o}),t}}function qh(){return R({mutationFn:Kh})}function Jh(){let{user:e}=je(),{clusterId:t}=B({strict:!1}),{data:n}=H(Jo(t,!0)),r=L(),i=ie(),a=(0,q.useMemo)(()=>o(n),[n]),s=En({operationsUrl:a}),{redirect:c}=se({strict:!1}),u=ae(),f=dt({resolver:Fe(Rh),defaultValues:{confirmPassword:``,password:``,role:`super_user`,username:e?.email??``}}),{setFocus:p,control:m,handleSubmit:h}=f;(0,q.useEffect)(()=>{p(`password`)},[p]);let g=n?.instances?.find(e=>e.tempPassword)?.tempPassword,_=Go(n),{mutate:v,isPending:y}=qh(),b=(0,q.useCallback)(async e=>{if(!a){U.error(`Cluster is not yet fully loaded, please wait a moment before trying to sign in.`);return}if(!_){U.error(`Some instances are still starting up. You can create your admin user once they are all running.`);return}v({instanceClient:s,clusterId:t,newPassword:e.password,tempPassword:g,initialUsername:d,desiredUsername:e.username},{onSuccess:async({message:e,user:a})=>{U.success(e),l.setUserForEntity(n,a),await qo(i,t),u.invalidate(),await r({to:c?.startsWith(`/`)?c:`../`})}})},[n,t,s,_,r,a,i,c,u,v,g]);return n&&!n.resetPassword?(0,K.jsx)(ne,{to:`../sign-in`,replace:!0}):n&&!_?(0,K.jsx)(ne,{to:`../starting-up`,replace:!0}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`nav`,{"aria-label":`Breadcrumb`,className:`fixed top-20 w-full h-12 z-39 px-4 md:px-12 bg-violet-50 border-b border-violet-100 dark:bg-grey-700 dark:border-none flex items-center`,children:(0,K.jsx)(Eo,{})}),(0,K.jsx)(`div`,{className:`items-center justify-center flex mt-32 py-4 min-h-[calc(100vh-(--spacing(32)))]`,children:(0,K.jsxs)(`div`,{className:`text-foreground w-xs`,children:[(0,K.jsx)(`h1`,{className:`text-2xl font-light`,children:`Create Admin User`}),(0,K.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,K.jsx)(Do,{...f,children:(0,K.jsxs)(`form`,{id:`cluster-create-admin-form`,name:`cluster-create-admin-form`,onSubmit:h(b),className:`my-4`,children:[(0,K.jsx)(Y,{control:m,name:`username`,render:({field:e})=>(0,K.jsxs)(X,{className:`my-4`,children:[(0,K.jsx)(Z,{children:`Username`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{autoComplete:`username`,type:`text`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:m,name:`password`,render:({field:e})=>(0,K.jsxs)(X,{className:`my-4`,children:[(0,K.jsx)(Z,{children:`Password`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`password`,autoComplete:`new-password`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:m,name:`confirmPassword`,render:({field:e})=>(0,K.jsxs)(X,{className:`my-4`,children:[(0,K.jsx)(Z,{children:`Confirm Password`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`password`,autoComplete:`new-password`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(F,{disabled:y,type:`submit`,variant:`submit`,className:`w-full my-2`,children:`Create Admin User`})]})}),(0,K.jsxs)(`p`,{className:`text-muted-foreground flex gap-2 align-middle`,children:[(0,K.jsx)(Rn,{size:36,className:`flex-none`}),(0,K.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 Yh({columns:e,data:t,renderRowWrapper:n}){let r=be({features:Nn,data:t,columns:e});return(0,K.jsx)(`div`,{className:`bg-card dark:bg-black-dark rounded-md`,children:(0,K.jsxs)(fn,{children:[(0,K.jsx)(ln,{children:r.getHeaderGroups().map(e=>(0,K.jsx)(dn,{className:`border-none`,children:e.headers.map(e=>(0,K.jsx)(on,{className:`p-4`,style:{width:`${e.getSize()}%`},children:e.isPlaceholder?null:_e(e.column.columnDef.header,e.getContext())},e.id))},e.id))}),(0,K.jsx)(cn,{className:`bg-background dark:bg-black`,children:r.getRowModel().rows?.length?r.getRowModel().rows.map(e=>{let t=(0,K.jsx)(dn,{"data-state":e.getIsSelected()&&`selected`,className:`hover:bg-muted/10 data-[state=selected]:bg-muted`,children:e.getVisibleCells().map(e=>(0,K.jsx)(un,{className:`p-4`,style:{width:`${e.column.getSize()}%`},children:_e(e.column.columnDef.cell,e.getContext())},e.id))});return(0,K.jsx)(q.Fragment,{children:n?n(e.original,t):t},e.id)}):(0,K.jsx)(dn,{children:(0,K.jsx)(un,{colSpan:e.length,className:`h-24 text-center`,children:`No results.`})})})]})})}function Xh(){return(0,K.jsx)(`div`,{className:`flex-col items-center justify-center px-16 space-y-3 text-center pt-30`,children:(0,K.jsx)(`p`,{children:`No instances found.`})})}async function Zh({instance:e,instanceClient:t}){try{await u({instanceClient:t,entityId:e.id})}catch{}l.signOutLocally(e.id),e.clusterId&&l.signOutLocally(e.clusterId)}async function Qh({instanceId:e,action:t,safeMode:n}){let r=n===void 0?{}:{safeMode:n},{data:i}=await N.post(`/HDBInstance/${e}/container/${t}`,r);return i}function $h(){return R({mutationFn:Qh})}var eg={stop:`Stopping`,start:`Starting`,restart:`Restarting`};function tg(e){let{clusterId:t}=B({strict:!1}),{mutateAsync:n,isPending:r}=$h(),i=ie();return{run:(0,q.useCallback)(async(r,a)=>{let o=a?.label??eg[r],s=e.name??e.id,c=U.loading(o,{description:`${o} ${s}. Status will update shortly.`,duration:3e4,action:{label:`Dismiss`,onClick:()=>U.dismiss()}});try{await n({instanceId:e.id,action:r,safeMode:a?.safeMode}),t&&i.invalidateQueries({queryKey:[t]}),i.invalidateQueries({queryKey:[e.id]}),U.dismiss(c),U.success(`Request accepted`,{description:`${s} is ${o.toLowerCase()}. The status will update automatically.`,action:{label:`Dismiss`,onClick:()=>U.dismiss()}})}catch{U.dismiss(c)}},[t,e.id,e.name,n,i]),isPending:r}}function ng({entityId:e,instanceClient:t},n){return z({queryKey:[`get_status`,e],staleTime:9e3,refetchInterval:jn(1e4),retry:On(),retryDelay:1e4,throwOnError:!1,enabled:n,queryFn:async()=>{let{data:e}=await t.post(`/`,{operation:`get_status`});return e}})}function rg(e,t){return e?.systemStatus?.find(e=>e.id===t)?.status}async function ig({instanceClient:e,id:t,status:n}){let{data:r}=await e.post(`/`,{operation:`set_status`,id:t,status:n});return r}function ag(){return R({mutationFn:ig,onSuccess:(e,t)=>yn.invalidateQueries({queryKey:[`get_status`,t.entityId]})})}var og=[`CLONE_READY`,`RUNNING`,`UPDATED`,`PENDING_UPGRADE`];function sg(e,t,n){let{user:r}=Ne(e.id),i=(0,q.useMemo)(()=>f(e),[e]),a=En({operationsUrl:i}),{update:o}=_l(),s=l.checkForFabricConnect(e.id),c=G({operationsUrl:i,instanceId:e.id,forceFabricConnect:!0}),{data:u}=H(ng(c,n&&o&&!zo(e.status))),d=rg(u,`availability`)||`Unknown`,p=d===`Available`,m=d===`Unavailable`,{mutate:h,isPending:g}=ag(),{run:_,isPending:v}=tg(e),[y,b]=(0,q.useState)(null),x=e.instanceFqdn,S=Ef({secure:e.operationsApiSecure?`true`:`false`,port:e.operationsApiPort,fqdn:e.instanceFqdn}),[C,w]=Vl(x??``,S),T=(0,q.useCallback)(async()=>{await Zh({instance:e,instanceClient:a})},[e,a]),E=!!e.status&&og.includes(e.status),D=!!r&&!s,O=E,k=!!x,A=o&&E&&(p||m),j=e.status===`RUNNING`,M=e.status===`STOPPED`,N=o&&!t&&(j||M),P=[O&&D&&{key:`direct-connect`,to:`../instance/${e.id}/`,icon:(0,K.jsx)(Zr,{className:`text-green`}),label:`Direct Connect`},O&&D&&{key:`direct-sign-out`,onClick:T,variant:`destructive`,icon:(0,K.jsx)(jr,{}),label:`Direct Sign Out`},O&&!D&&o&&!t&&{key:`fabric-connect`,to:`../instance/${e.id}/`,icon:(0,K.jsx)(Zr,{className:`text-green`}),label:`Fabric Connect`},O&&!D&&{key:`direct-sign-in`,to:`../instance/${e.id}/sign-in`,icon:(0,K.jsx)(Mr,{}),label:`Direct Sign In`},O&&k&&{type:`separator`,key:`copy-sep`},k&&{key:`copy-fqdn`,onClick:C,icon:(0,K.jsx)(nr,{}),label:`Copy Instance FQDN`},k&&{key:`copy-api`,onClick:w,icon:(0,K.jsx)(nr,{}),label:`Copy API URL`},(O||k)&&A&&{type:`separator`,key:`rotation-sep`},A&&p&&{key:`out-of-rotation`,variant:`destructive`,disabled:g,onClick:()=>h({...c,id:`availability`,status:`Unavailable`}),icon:(0,K.jsx)(ei,{}),label:`Bring out of rotation`},A&&m&&{key:`into-rotation`,disabled:g,onClick:()=>h({...c,id:`availability`,status:`Available`}),icon:(0,K.jsx)($r,{}),label:`Bring back into rotation`},(O||k||A)&&N&&{type:`separator`,key:`container-sep`},N&&{type:`label`,key:`container-label`,className:`text-gray-600 text-xs`,label:`Container`},N&&M&&{key:`container-start`,disabled:v,onClick:()=>void _(`start`,{safeMode:!1}),icon:(0,K.jsx)(Hr,{}),label:`Start`},N&&M&&{key:`container-start-safe`,disabled:v,onClick:()=>b(`start`),icon:(0,K.jsx)(Dr,{}),label:`Start in safe mode`},N&&j&&{key:`container-restart`,disabled:v,onClick:()=>void _(`restart`,{safeMode:!1}),icon:(0,K.jsx)(qr,{}),label:`Restart`},N&&j&&{key:`container-restart-safe`,disabled:v,onClick:()=>b(`restart`),icon:(0,K.jsx)(Dr,{}),label:`Restart in safe mode`},N&&j&&{key:`container-stop`,variant:`destructive`,disabled:v,onClick:()=>void _(`stop`),icon:(0,K.jsx)(ri,{}),label:`Stop`}].filter(kn),F=(0,K.jsx)(Ml,{open:y!==null,setOpen:e=>{e||b(null)},action:y??`restart`,targetName:e.name??e.id,scope:`instance`,isPending:v,onConfirm:()=>{let e=y;b(null),e&&_(e,{safeMode:!0,label:e===`start`?`Starting in safe mode`:`Restarting in safe mode`})}});return P.length?{items:[{type:`label`,key:`label`,className:`text-gray-600 text-xs`,label:`Options`},{type:`separator`,key:`label-sep`},...P],dialog:F}:{items:[],dialog:F}}function cg({instance:e,isSelfManaged:t}){let[n,r]=(0,q.useState)(!1),{items:i,dialog:a}=sg(e,t,n);return i.length?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(bi,{open:n,onOpenChange:r,children:[(0,K.jsx)(xi,{asChild:!0,children:(0,K.jsx)(F,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Instance options`,children:(0,K.jsx)(ur,{})})}),(0,K.jsx)(Si,{align:`end`,className:`min-w-48`,children:nc(i,`dropdown`)})]}),a]}):null}function lg({isSelfManaged:e,instance:t}){let{user:n,isLoading:r}=Ne(t.id),i=(0,q.useMemo)(()=>f(t),[t]),a=En({operationsUrl:i}),{update:o}=_l(),s=l.checkForFabricConnect(t.id),c=(0,q.useCallback)(async()=>{await Zh({instance:t,instanceClient:a})},[t,a]);return zo(t.status)?(0,K.jsx)(`span`,{className:`text-muted-foreground text-sm`,children:`—`}):r||!t.status||![`CLONE_READY`,`RUNNING`,`UPDATED`,`PENDING_UPGRADE`].includes(t.status)?(0,K.jsx)(kr,{className:`animate-spin`,color:`gray`}):!n||s?(0,K.jsxs)(`span`,{className:`flex gap-4`,children:[o&&!e&&(0,K.jsx)(V,{to:`../instance/${t.id}/`,className:`text-sm`,"aria-label":`Connect to ${t.name} instance`,title:`Connect to ${t.name} instance`,children:(0,K.jsx)(F,{variant:`positiveOutline`,children:`Fabric Connect`})}),(0,K.jsx)(V,{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,K.jsx)(F,{variant:o?`defaultOutline`:`positiveOutline`,children:`Direct Sign In`})})]}):(0,K.jsxs)(`span`,{className:`flex gap-4`,children:[(0,K.jsx)(V,{to:`../instance/${t.id}/`,className:`text-sm`,"aria-label":`Go to ${t.name} instance`,title:`Go to ${t.name} instance`,children:(0,K.jsx)(F,{variant:`positiveOutline`,children:`Direct Connect`})}),(0,K.jsx)(F,{variant:`destructiveOutline`,className:`text-sm`,"aria-label":`Sign out from ${t.name} instance`,title:`Sign out from ${t.name} instance`,onClick:c,children:`Direct Sign Out`})]})}function ug({instance:e,isSelfManaged:t,children:n}){let[r,i]=(0,q.useState)(!1),{items:a,dialog:o}=sg(e,t,r);return a.length?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(Js,{onOpenChange:i,children:[(0,K.jsx)(Ys,{asChild:!0,children:n}),(0,K.jsx)(Xs,{className:`min-w-48`,children:nc(a,`context`)})]}),o]}):(0,K.jsx)(K.Fragment,{children:n})}function dg({instance:e,index:t}){let{update:n}=_l(),r=(0,q.useMemo)(()=>f(e),[e]),i=G({operationsUrl:r,instanceId:e.id,forceFabricConnect:!0}),{mutate:a,isPending:o}=ag(),[s,c]=(0,q.useState)(!1);(0,q.useEffect)(()=>{let e=setTimeout(()=>c(!0),t*500);return()=>clearTimeout(e)},[t]);let l=zo(e.status),{data:u,isLoading:d,isFetching:p}=H(ng(i,s&&n&&!l)),m=rg(u,`availability`)||`Unknown`,h=m===`Available`,g=m===`Unavailable`;return n?l?(0,K.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,K.jsxs)(Ia,{children:[(0,K.jsx)(La,{asChild:!0,children:(0,K.jsx)(`span`,{className:`inline-block size-4 rounded-full bg-muted-foreground/40`,"aria-label":`Not running`})}),(0,K.jsx)(Ra,{children:`Not running`})]})}):(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)(Ia,{children:[(0,K.jsx)(La,{asChild:!0,children:(0,K.jsx)(`div`,{className:`flex items-center`,children:d||!s||p&&!u?(0,K.jsx)(kr,{className:`animate-spin size-5 text-muted-foreground`}):(0,K.jsx)(Wi,{variant:h?`success`:g?`destructive`:`default`,className:`size-4 rounded-full p-0`,children:(0,K.jsx)(`span`,{className:`sr-only`,children:h?`Online`:`Offline`})})})}),(0,K.jsxs)(Ra,{children:[p&&u?`Refreshing... `:``,m]})]}),n&&(0,K.jsxs)(`div`,{className:`flex gap-1`,children:[h&&(0,K.jsxs)(Ia,{children:[(0,K.jsx)(La,{asChild:!0,children:(0,K.jsx)(F,{type:`button`,variant:`destructiveGhost`,size:`icon`,onClick:()=>a({...i,id:`availability`,status:`Unavailable`}),disabled:o,children:o?(0,K.jsx)(kr,{className:`animate-spin size-4`}):(0,K.jsx)(ei,{className:`size-4`})})}),(0,K.jsx)(Ra,{children:`Bring out of rotation`})]}),g&&(0,K.jsxs)(Ia,{children:[(0,K.jsx)(La,{asChild:!0,children:(0,K.jsx)(F,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>a({...i,id:`availability`,status:`Available`}),disabled:o,children:o?(0,K.jsx)(kr,{className:`animate-spin size-4`}):(0,K.jsx)($r,{className:`size-4`})})}),(0,K.jsx)(Ra,{children:`Bring back into rotation`})]})]})]}):null}function fg(){let{clusterId:e}=B({strict:!1}),{data:t,isLoading:n}=H(Jo(e,!0)),r=El(t),i=(0,q.useMemo)(()=>[{id:`instanceActions`,size:1,minSize:1,cell:e=>(0,K.jsx)(`div`,{className:`flex justify-end gap-2 items-center`,children:(0,K.jsx)(lg,{isSelfManaged:r,instance:e.row.original})})},r&&{accessorKey:`instanceFqdn`,size:90,header:`URL`,cell:e=>Ef({secure:e.row.original.operationsApiSecure?`true`:`false`,port:e.row.original.operationsApiPort,fqdn:e.row.original.instanceFqdn})},!r&&{accessorKey:`name`,size:90,header:`Name`},!r&&{accessorKey:`status`,header:`Status`,size:1,minSize:1,cell:e=>{let t=e.getValue();return(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(dg,{instance:e.row.original,index:e.row.index}),t?(0,K.jsx)(Wi,{variant:Ro(t),children:wo(t)}):null,e.row.original.safeMode&&!zo(e.row.original.status)?(0,K.jsxs)(Wi,{variant:`warning`,title:`Running in safe mode — user apps/components are not loaded`,children:[(0,K.jsx)(Dr,{}),`Safe mode`]}):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,K.jsxs)(K.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`},{id:`instanceMenu`,size:1,minSize:1,cell:e=>(0,K.jsx)(`div`,{className:`flex justify-end`,children:(0,K.jsx)(cg,{isSelfManaged:r,instance:e.row.original})})}].filter(kn),[r]),a=(0,q.useMemo)(()=>t?.instances?t.instances.filter(e=>e.status&&!No.includes(e.status)).sort(au):[],[t]);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Ks,{}),(0,K.jsx)(Kl,{children:(0,K.jsx)(It,{className:`p-0 min-h-96`,children:(0,K.jsx)(Pt,{className:`p-0 min-h-96`,children:n?(0,K.jsx)(Jd,{}):a.length?(0,K.jsx)(Yh,{data:a,columns:i,renderRowWrapper:(e,t)=>(0,K.jsx)(ug,{instance:e,isSelfManaged:r,children:t})}):(0,K.jsx)(Xh,{})})})})]})}function pg(){let{clusterId:e}=B({strict:!1}),{immediate:t}=se({strict:!1}),n=t===!0||t===`true`,{data:r,isLoading:i}=H(Jo(e,2e3)),a=r?.status,o=(0,q.useMemo)(()=>a&&Mo.includes(a),[a]);return i||!r?(0,K.jsx)(fh,{className:`flex justify-center`,children:(0,K.jsx)(Jd,{})}):o?(0,K.jsx)(fh,{className:`flex justify-center`,children:(0,K.jsxs)(`div`,{className:`center w-2xl flex flex-col gap-4`,children:[(0,K.jsx)(`h1`,{className:`text-xl text-center`,children:`All done!`}),(0,K.jsx)(jl,{cluster:r,forceProgressBarVisible:!0}),(0,K.jsx)(`p`,{children:`Your cluster finished updating, and is ready for interaction.`}),(0,K.jsx)(`div`,{className:`text-center`,children:(0,K.jsx)(Dl,{cluster:r})})]})}):(0,K.jsx)(fh,{className:`flex justify-center`,children:(0,K.jsxs)(`div`,{className:`center w-2xl flex flex-col gap-4`,children:[(0,K.jsx)(`h1`,{className:`text-xl text-center`,children:`Here we go!`}),(0,K.jsx)(jl,{cluster:r,forceProgressBarVisible:!0}),(0,K.jsxs)(`p`,{children:[n?`Your cluster is applying the latest changes immediately, without waiting to take instances out of rotation.`:`Your cluster is updating with the latest changes. This includes waiting several minutes to let traffic drain safely.`,` `,(0,K.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,K.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 mg({children:e,className:t}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Ks,{}),(0,K.jsx)(`div`,{className:g(`mt-32 px-4 py-4 md:px-12 min-h-[calc(100vh-(--spacing(32)))] flex justify-center`,t),children:e})]})}function hg(){let e=ae(),{clusterId:t}=B({strict:!1}),{data:n,isLoading:r}=H(Jo(t,2e3)),i=n?.status,a=(0,q.useMemo)(()=>i&&Mo.includes(i)&&Go(n),[i,n]),o=Vo(i),[,s]=Tn(Sn.SavedClusterState,null),c=(0,q.useCallback)(()=>{s(n),e.navigate({to:`/${n.organizationId}/new-cluster`})},[n,e,s]);return r||!n?(0,K.jsx)(mg,{className:`flex justify-center`,children:(0,K.jsx)(Jd,{})}):o?(0,K.jsx)(mg,{className:`flex justify-center`,children:(0,K.jsxs)(`div`,{className:`center max-w-2xl flex flex-col gap-4 items-center`,children:[(0,K.jsx)(rr,{className:`w-24 h-24`}),(0,K.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,K.jsx)(Wl,{}),` if you want more help.`]}),(0,K.jsx)(F,{type:`button`,variant:`positiveOutline`,onClick:c,children:`Try Again`})]})}):a?(0,K.jsx)(mg,{className:`flex justify-center`,children:(0,K.jsxs)(`div`,{className:`center max-w-2xl flex flex-col gap-4`,children:[(0,K.jsx)(`h1`,{className:`text-xl text-center`,children:`It's ready!`}),(0,K.jsx)(jl,{cluster:n,forceProgressBarVisible:!0}),(0,K.jsxs)(`p`,{children:[`Let's set up your secure, browser-to-cluster connection now.`,` `,(0,K.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,K.jsx)(`em`,{children:`Direct Connect`}),`! Once you create your user, you will have the option to`,` `,(0,K.jsx)(`em`,{children:`Fabric Connect`}),` from your Fabric account without having to sign in again.`]})]}),(0,K.jsx)(`div`,{className:`text-center`,children:(0,K.jsx)(Dl,{cluster:n})})]})}):(0,K.jsx)(mg,{className:`flex justify-center`,children:(0,K.jsxs)(`div`,{className:`center max-w-2xl flex flex-col gap-4`,children:[(0,K.jsx)(`h1`,{className:`text-xl text-center`,children:`Here we go!`}),(0,K.jsx)(jl,{cluster:n,forceProgressBarVisible:!0}),(0,K.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,K.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,K.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 gg(){let{clusterId:e}=B({strict:!1}),{data:t,isLoading:n}=Qm(e);if(n)return(0,K.jsxs)(fh,{className:`max-w-4xl pb-20`,children:[(0,K.jsx)(`h1`,{className:`text-2xl font-light text-foreground`,children:`Usage`}),(0,K.jsx)(`div`,{className:`flex justify-center py-16 text-muted-foreground`,children:(0,K.jsx)(kr,{className:`size-6 animate-spin`})})]});let r=t&&!t.selfManaged?Sg(t.regions):null;return(0,K.jsxs)(fh,{className:`max-w-4xl pb-20`,children:[(0,K.jsx)(`h1`,{className:`text-2xl font-light text-foreground`,children:`Usage`}),t?t.selfManaged?(0,K.jsx)(Tg,{children:`Usage isn't tracked for self-hosted clusters — they run under their own license.`}):t.regions.length===0?(0,K.jsx)(Tg,{children:`No usage has been recorded for the current cycle yet.`}):(0,K.jsxs)(`div`,{className:`mt-5 space-y-3`,children:[t.regions.map(e=>(0,K.jsx)(_g,{region:e,showPlanInfo:r==null},e.region??e.regionIds.join())),r&&(0,K.jsx)(vg,{header:(0,K.jsx)(yg,{title:`Plan limits & resources`}),aside:r.planId??void 0,children:(0,K.jsx)(bg,{rateLimits:r.rateLimits,resourcesPerInstance:r.resourcesPerInstance})})]}):(0,K.jsx)(Eg,{})]})}function _g({region:e,showPlanInfo:t}){let n=Jm.map(t=>Ym(t,e.metrics[t])),r=[e.planName?`${e.planName} plan`:null,e.status===`exhausted`?`consumed — awaiting renewal`:e.status===`lapsed`?`not renewed`:e.expiresAt?`renews ${xg(e.expiresAt)}`:null].filter(Boolean).join(` · `);return(0,K.jsxs)(vg,{defaultOpen:e.status!==`lapsed`,aside:e.regionIds.length>0?e.regionIds.join(`, `):void 0,header:(0,K.jsxs)(yg,{title:e.region??`Region`,meta:r,children:[e.status===`exhausted`&&(0,K.jsx)(`span`,{className:`rounded-full bg-yellow/10 px-2 py-0.5 text-[11px] text-yellow`,children:`Cycle exhausted`}),e.status===`lapsed`&&(0,K.jsx)(`span`,{className:`rounded-full bg-muted px-2 py-0.5 text-[11px] text-muted-foreground`,children:`No active license`})]}),children:[(0,K.jsx)(`div`,{className:`grid grid-cols-1 gap-x-10 gap-y-4 sm:grid-cols-2`,children:n.map(e=>(0,K.jsx)(Xm,{...e},e.label))}),t&&(0,K.jsx)(bg,{rateLimits:e.rateLimits,resourcesPerInstance:e.resourcesPerInstance})]})}function vg({header:e,aside:t,defaultOpen:n=!0,children:r}){let[i,a]=(0,q.useState)(n);return(0,K.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-border`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>a(e=>!e),"aria-expanded":i,className:`flex w-full items-center gap-3 px-4 py-3 text-left transition-colors hover:bg-accent/40`,children:[(0,K.jsx)(gn,{className:`size-4 shrink-0 text-muted-foreground transition-transform ${i?`rotate-90`:``}`}),(0,K.jsx)(`div`,{className:`min-w-0 flex-1`,children:e}),t&&(0,K.jsx)(`span`,{className:`shrink-0 self-start pt-0.5 font-mono text-[11px] text-muted-foreground/70`,children:t})]}),i&&(0,K.jsx)(`div`,{className:`border-t border-border px-4 py-4`,children:r})]})}function yg({title:e,meta:t,children:n}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,K.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:e}),n]}),t&&(0,K.jsx)(`div`,{className:`mt-0.5 text-xs text-muted-foreground`,children:t})]})}function bg({rateLimits:e,resourcesPerInstance:t}){let n=e,r=n?wg([[`Reads / minute`,n.readsPerMinute,ff],[`Read bandwidth / minute`,n.readsPerMinuteBytes,df],[`Writes / minute`,n.writesPerMinute,ff],[`Write bandwidth / minute`,n.writesPerMinuteBytes,df],[`Real-time deliveries / minute`,n.realTimeDeliveriesPerMinute,ff],[`Real-time bandwidth / minute`,n.realTimeDeliveryBytesPerMinute,df],[`TLS handshakes (cycle)`,n.tlsHandshakes,ff]]):[],i=t,a=i?Cg([[`Storage`,i.storageGb,e=>`${ff(e)} GB`],[`Memory`,i.memoryMb,e=>df(e*1e3*1e3)],[`vCPU`,i.cpuCores,e=>`${e} ${e===1?`core`:`cores`}`],[`Threads`,i.threads,e=>String(e)]]):[];return(0,K.jsxs)(K.Fragment,{children:[r.length>0&&(0,K.jsx)(Dg,{title:`Rate limits`,subtitle:`Throughput ceilings — not part of the cycle allotment, and not metered.`,children:(0,K.jsx)(Og,{rows:r})}),a.length>0&&(0,K.jsx)(Dg,{title:`Per-instance resources`,subtitle:`Provisioned capacity on each instance.`,children:(0,K.jsx)(Og,{rows:a})})]})}function xg(e){return new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`}).format(new Date(e))}function Sg(e){if(e.length===0)return null;let t=e[0];if(t.rateLimits==null&&t.resourcesPerInstance==null)return null;let n=e=>JSON.stringify([e.rateLimits,e.resourcesPerInstance]),r=n(t),i=e.every(e=>e.planId===t.planId);return e.every(e=>n(e)===r)?{rateLimits:t.rateLimits,resourcesPerInstance:t.resourcesPerInstance,planId:i?t.planId:null}:null}function Cg(e){return e.filter(e=>typeof e[1]==`number`&&e[1]>0).map(([e,t,n])=>[e,n(t)])}function wg(e){return e.filter(e=>e[1]!=null).map(([e,t,n])=>[e,t.unlimited?`Unlimited`:t.limitKnown&&t.limit!=null?n(t.limit):`—`])}function Tg({children:e}){return(0,K.jsx)(`p`,{className:`mt-3 text-sm text-muted-foreground`,children:e})}function Eg(){return(0,K.jsx)(`div`,{role:`alert`,className:`mt-5 rounded-xl border border-destructive/40 bg-destructive/10 p-4 text-sm text-destructive`,children:`Couldn't load usage data — refresh to try again.`})}function Dg({title:e,subtitle:t,children:n}){return(0,K.jsxs)(`div`,{className:`mt-6 first:mt-0`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium text-foreground`,children:e}),(0,K.jsx)(`p`,{className:`mt-0.5 mb-3 text-xs text-muted-foreground`,children:t}),n]})}function Og({rows:e}){return(0,K.jsx)(`dl`,{className:`grid grid-cols-1 gap-x-10 gap-y-2 sm:grid-cols-2`,children:e.map(([e,t])=>(0,K.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2 border-b border-border/60 py-1.5 text-sm`,children:[(0,K.jsx)(`dt`,{className:`text-muted-foreground`,children:e}),(0,K.jsx)(`dd`,{className:`text-foreground tabular-nums`,children:t})]},e))})}I({getParentRoute:()=>Hm,path:`instances`,head:()=>({meta:[{title:`Instances — Harper Fabric`}]}),component:fg}),I({getParentRoute:()=>Hm,path:`starting-up`,head:()=>({meta:[{title:`Starting Up — Harper Fabric`}]}),component:hg}),I({getParentRoute:()=>Hm,path:`scaling`,head:()=>({meta:[{title:`Scaling — Harper Fabric`}]}),component:pg}),I({getParentRoute:()=>Hm,path:`domains`,head:()=>({meta:[{title:`Domains — Harper Fabric`}]}),component:Lh}),I({getParentRoute:()=>Hm,path:`usage`,head:()=>({meta:[{title:`Usage — Harper Fabric`}]}),component:gg});function kg({location:e,params:t}){let n=l.checkForFabricConnect(t.clusterId);if(l.getConnectionById(t.clusterId).user&&!n){let t=e?.search?.redirect;throw re({to:t?.startsWith(`/`)?t:`../`})}}function Ag({location:e,params:t}){let n=l.checkForFabricConnect(t.instanceId);if(l.getConnectionById(t.instanceId).user&&!n){let t=e?.search?.redirect;throw re({to:t?.startsWith(`/`)?t:`../`})}}I({getParentRoute:()=>Hm,path:`sign-in`,head:()=>({meta:[{title:`Sign In — Harper Fabric`}]}),component:is,beforeLoad:kg}),I({getParentRoute:()=>Hm,path:`instance/$instanceId/sign-in`,head:()=>({meta:[{title:`Sign In — Harper Fabric`}]}),component:is,beforeLoad:Ag}),I({getParentRoute:()=>Hm,path:`finish-setup`,head:()=>({meta:[{title:`Create Admin User — Harper Fabric`}]}),component:Jh}),I({getParentRoute:()=>Hm,path:`/`,head:()=>({meta:[{title:`Cluster — Harper Fabric`}]}),component:ah});function jg(e){return I({getParentRoute:()=>e,path:`apis`,head:()=>({meta:[{title:`APIs — Harper Fabric`}]})}).lazy(()=>Te(()=>import(`./index.lazy-CtErm5q7.js`).then(e=>e.route),__vite__mapDeps([30,1,2,3,4,5,6,7,31,9,32,18,33,34])))}function Mg(e,t){return[I({getParentRoute:()=>e,path:t===`cluster`?`apps`:`/`,head:()=>({meta:[{title:`Applications — Harper Fabric`}]}),component:me(()=>Te(()=>import(`./applications-BU83fSEG.js`),__vite__mapDeps([35,1,18,3,2,4,5,6,7,17,20,9,8,10,11,12,31,13,36,37,38,32,39,40,23,24,25,15,33,41,26,27,28,29,42])),`ApplicationsEditor`)})]}async function Ng({instanceClient:e}){let{data:t}=await e.post(`/`,{operation:`list_certificates`});return t}function Pg(e){return z({queryKey:[e.entityId,`list_certificates`],queryFn:()=>Ng(e)})}var Fg=[{header:`Certificate Name`,accessorKey:`name`,enableSorting:!0},{header:`Issuer`,accessorKey:`details.issuer`,enableSorting:!0},Mn().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`})];async function Ig({instanceClient:e},t){let{data:n}=await e.post(`/`,{operation:`add_certificate`,...t});return n}var Lg=y({name:M().min(1,`Name is required`),certificate:M().min(1,`Certificate is required`),private_key:M().optional(),is_authority:S().default(!1),hosts:M().optional(),uses:M().optional()});function Rg(){return R({mutationFn:({instanceParams:e,certificateParams:t})=>Ig(e,t)})}function zg({isModalOpen:e,onChangesSaved:t,setIsModalOpen:n}){let r=dt({resolver:Fe(Lg),defaultValues:{name:``,certificate:``,private_key:``,is_authority:!1,hosts:``,uses:``}}),i=G(),{mutate:a,isPending:o}=Rg(),s=(0,q.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(),U.success(`Certificate added successfully!`),n(!1)}})},[a,r,i,t,n]),c=(0,q.useCallback)(()=>{r.reset(),n(!1)},[r,n]);return(0,K.jsx)(Rt,{onOpenChange:n,open:e,children:(0,K.jsx)(Ut,{"aria-describedby":void 0,children:(0,K.jsx)(Do,{...r,children:(0,K.jsxs)(`form`,{id:`instance-add-certificate-form`,name:`instance-add-certificate-form`,onSubmit:r.handleSubmit(s),className:`grid gap-4 my-4`,children:[(0,K.jsxs)(Bt,{children:[(0,K.jsx)(qt,{children:`Add New Certificate`}),(0,K.jsx)(Zt,{children:`Enter the details of your Certificate below.`})]}),(0,K.jsx)(Y,{control:r.control,name:`name`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Name`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`text`,autoComplete:`off`,autoCapitalize:`off`,autoFocus:!0,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:r.control,name:`is_authority`,render:({field:e})=>(0,K.jsxs)(X,{className:`flex flex-row items-center justify-between rounded-lg border border-gray-800 p-3 shadow-sm`,children:[(0,K.jsx)(`div`,{className:`space-y-0.5`,children:(0,K.jsx)(Z,{children:`Is Authority`})}),(0,K.jsx)(J,{children:(0,K.jsx)(Tp,{checked:e.value,onCheckedChange:e.onChange})})]})}),(0,K.jsx)(Y,{control:r.control,name:`certificate`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Certificate`}),(0,K.jsx)(J,{children:(0,K.jsx)(Pn,{autoComplete:`off`,autoCapitalize:`off`,rows:5,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:r.control,name:`hosts`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Hosts (optional)`}),(0,K.jsx)(ef,{children:`Comma-separated list of hostnames this certificate is valid for.`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`text`,autoComplete:`off`,autoCapitalize:`off`,placeholder:`e.g. example.com, *.example.com`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:r.control,name:`uses`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Uses (optional)`}),(0,K.jsx)(ef,{children:`Comma-separated list of intended uses, e.g. "https, operations, wss".`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`text`,autoComplete:`off`,autoCapitalize:`off`,placeholder:`e.g. https, operations, wss`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:r.control,name:`private_key`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Private Key (optional)`}),(0,K.jsx)(ef,{children:`PEM formatted private key string.`}),(0,K.jsx)(J,{children:(0,K.jsx)(Pn,{autoComplete:`off`,autoCapitalize:`off`,rows:5,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(zt,{children:(0,K.jsxs)(`div`,{className:`flex justify-between w-full`,children:[(0,K.jsx)(F,{variant:`destructiveOutline`,type:`button`,onClick:c,disabled:o,children:`Cancel`}),(0,K.jsxs)(F,{type:`submit`,variant:`submit`,disabled:o||!r.formState.isDirty||!r.formState.isValid,children:[(0,K.jsx)(Jr,{}),` Add Certificate`]})]})})]})})})})}async function Bg({instanceClient:e},t){let{data:n}=await e.post(`/`,{operation:`remove_certificate`,name:t});return n}function Vg(){return R({mutationFn:({instanceParams:e,name:t})=>Bg(e,t)})}function Hg({data:e,isModalOpen:t,closeModal:n,onSelectCertificate:r,onChangesSaved:i}){let{name:a}=e,o=G(),{mutate:s,isPending:c}=Vg(),[l,u]=(0,q.useState)(!1),d=(0,q.useCallback)(()=>{u(!0)},[]),f=(0,q.useCallback)(()=>{s({instanceParams:o,name:a},{onSuccess:()=>{U.success(`Certificate removed successfully!`),r(void 0),i()}})},[a,s,o,i,r]);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Rt,{onOpenChange:n,open:t,children:(0,K.jsx)(Ut,{className:`sm:max-w-[800px] max-h-[90vh] overflow-y-auto`,"aria-describedby":void 0,children:(0,K.jsxs)(`div`,{className:`grid gap-4 my-4`,children:[(0,K.jsxs)(Bt,{children:[(0,K.jsxs)(qt,{children:[`View Certificate: `,a]}),(0,K.jsx)(Zt,{children:`Details of the selected certificate.`})]}),(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 text-sm bg-muted p-4 rounded-lg border border-border`,children:[(0,K.jsxs)(`div`,{className:`col-span-2`,children:[(0,K.jsx)(`p`,{className:`font-semibold`,children:`Issuer`}),(0,K.jsx)(`p`,{className:`text-muted-foreground break-all`,children:e.details.issuer||`N/A`})]}),(0,K.jsxs)(`div`,{className:`col-span-2`,children:[(0,K.jsx)(`p`,{className:`font-semibold`,children:`Subject`}),(0,K.jsx)(`p`,{className:`text-muted-foreground break-all`,children:e.details.subject||`N/A`})]}),e.details.subject_alt_name&&(0,K.jsxs)(`div`,{className:`col-span-2`,children:[(0,K.jsx)(`p`,{className:`font-semibold`,children:`Subject Alternative Name`}),(0,K.jsx)(`p`,{className:`text-muted-foreground break-all`,children:e.details.subject_alt_name})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`font-semibold`,children:`Valid From`}),(0,K.jsx)(`p`,{className:`text-muted-foreground`,children:e.details.valid_from?new Date(e.details.valid_from).toLocaleString():`N/A`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`font-semibold`,children:`Valid To (Expires At)`}),(0,K.jsx)(`p`,{className:`text-muted-foreground`,children:e.details.valid_to?new Date(e.details.valid_to).toLocaleString():`N/A`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`font-semibold`,children:`Serial Number`}),(0,K.jsx)(`p`,{className:`text-muted-foreground font-mono text-xs break-all`,children:e.details.serial_number||`N/A`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`font-semibold`,children:`Private Key Name`}),(0,K.jsx)(`p`,{className:`text-muted-foreground`,children:e.private_key_name||`N/A`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`font-semibold`,children:`Is Authority`}),(0,K.jsx)(`p`,{className:`text-muted-foreground`,children:e.is_authority?`Yes`:`No`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`font-semibold`,children:`Is Self-Signed`}),(0,K.jsx)(`p`,{className:`text-muted-foreground`,children:e.is_self_signed?`Yes`:`No`})]}),e.hosts&&e.hosts.length>0&&(0,K.jsxs)(`div`,{className:`col-span-2`,children:[(0,K.jsx)(`p`,{className:`font-semibold`,children:`Hosts`}),(0,K.jsx)(`p`,{className:`text-muted-foreground`,children:e.hosts.join(`, `)})]}),(0,K.jsxs)(`div`,{className:`col-span-2`,children:[(0,K.jsx)(`p`,{className:`font-semibold`,children:`Uses`}),(0,K.jsx)(`p`,{className:`text-muted-foreground`,children:e.uses?.join(`, `)||`N/A`})]})]}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(jo,{children:`Certificate Content`}),(0,K.jsx)(Pn,{autoComplete:`off`,autoCapitalize:`off`,rows:8,readOnly:!0,className:`font-mono text-xs`,value:e.certificate})]})]}),(0,K.jsx)(zt,{children:(0,K.jsxs)(`div`,{className:`flex justify-between w-full`,children:[(0,K.jsx)(F,{type:`button`,variant:`destructiveOutline`,onClick:d,disabled:c,children:`Remove Certificate`}),(0,K.jsx)(F,{type:`button`,variant:`defaultOutline`,onClick:()=>n(),children:`Close`})]})})]})})}),(0,K.jsx)(qs,{isModalOpen:l,setIsModalOpen:u,deletionConfirmed:f,deletionPending:c,typeOfThingBeingDeleted:`certificate`,presentParticiple:`Removing`,transitiveVerb:`Remove`,nameOfThingBeingDeleted:a,hideDataLossWarning:!0})]})}function Ug(){let e=L(),{certName:t}=B({strict:!1}),n=G(),{data:r,refetch:i,isFetching:a,isRefetching:o}=H(Pg(n)),s=(0,q.useMemo)(()=>r?.find(e=>e.name===t),[r,t]),c=(0,q.useCallback)(n=>{let r=n?.original?.name,i=[t?`..`:``,r].filter(Boolean);e({to:i.join(`/`)})},[t,e]),l=!!t&&!!s,[u,d]=(0,q.useState)(!1),f=(0,q.useCallback)(()=>{d(!0)},[d]),p=Zf(i);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(Kf,{columns:Fg,data:r||[],isFetching:a,onRowClick:c,children:[(0,K.jsx)(V,{className:`inline-block underline text-sm text-muted-foreground hover:text-foreground`,to:`https://docs.harperdb.io/docs/developers/operations-api/certificate-management`,target:`_blank`,children:`Certificate Management Docs`}),(0,K.jsxs)(F,{variant:`defaultOutline`,onClick:p,accessKey:`r`,disabled:a||o,children:[(0,K.jsx)(Wr,{}),(0,K.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,K.jsx)(`u`,{children:`R`}),`efresh`]})]}),(0,K.jsxs)(F,{variant:`positiveOutline`,onClick:f,accessKey:`a`,disabled:u,children:[(0,K.jsx)(Ur,{}),(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`u`,{children:`A`}),`dd`]})]})]}),u&&(0,K.jsx)(zg,{isModalOpen:u,onChangesSaved:i,setIsModalOpen:d}),l&&(0,K.jsx)(Hg,{isModalOpen:l,closeModal:c,data:s,onSelectCertificate:c,onChangesSaved:i})]})}var Wg=new Set([`success`,`failed`,`rolled_back`]);function Gg(e){return!!e&&Wg.has(e)}var Kg=2e3,qg=1e4;async function Jg({instanceClient:e,project:t,status:n,since:r,until:i,limit:a,offset:o}){let{data:s}=await e.post(`/`,{operation:`list_deployments`,project:t,status:n,since:r,until:i,limit:a,offset:o});return s}function Yg(e){let{entityId:t,project:n,status:r,since:i,until:a,limit:o,offset:s,pollWhileOpen:c}=e;return z({queryKey:[t,`list_deployments`,{project:n,status:r,since:i,until:a,limit:o,offset:s}],queryFn:()=>Jg(e),retry:!1,enabled:e.enabled!==!1,refetchInterval:c?e=>(e.state.data?.deployments??[]).some(e=>!Gg(e.status))?Kg:qg:!1})}var Xg={pending:`warning`,extracting:`warning`,installing:`warning`,loading:`warning`,replicating:`warning`,restarting:`warning`,success:`success`,failed:`destructive`,rolled_back:`destructive`},Zg={pending:`Pending`,extracting:`Extracting`,installing:`Installing`,loading:`Loading`,replicating:`Replicating`,restarting:`Restarting`,success:`Success`,failed:`Failed`,rolled_back:`Rolled back`};function Qg({status:e}){return(0,K.jsx)(Wi,{variant:Xg[e]??`secondary`,children:Zg[e]??e})}var $g=Mn();function e_(e){return e?Yf((Date.now()-e)/1e3,e):`—`}var t_=[{header:`Project`,accessorKey:`project`,enableSorting:!1},$g.display({header:`Status`,id:`status`,enableSorting:!1,cell:e=>(0,K.jsx)(Qg,{status:e.row.original.status})}),$g.display({header:`Started`,id:`started_at`,enableSorting:!1,cell:e=>e_(e.row.original.started_at)}),$g.display({header:`Completed`,id:`completed_at`,enableSorting:!1,cell:e=>e_(e.row.original.completed_at)}),{header:`User`,accessorKey:`user`,enableSorting:!1},{header:`Origin`,accessorKey:`origin_node`,enableSorting:!1}];function n_({className:e,orientation:t=`horizontal`,decorative:n=!0,...r}){return(0,K.jsx)(Et,{"data-slot":`separator-root`,decorative:n,orientation:t,className:P(`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})}async function*r_(e,t){let n=e.getReader(),r=new TextDecoder(`utf-8`),i=``,a=!1;try{for(;;){if(t?.aborted)return;let{value:e,done:s}=await n.read();if(s){a=!0;break}i+=r.decode(e,{stream:!0}),yield*o()}if(i+=r.decode(),i.trim()){let e=i_(i);e&&(yield e)}}finally{a||n.cancel().catch(()=>{}),n.releaseLock()}function*o(){for(;;){let e=i.indexOf(`
|
|
13
13
|
|
|
14
14
|
`),t=i.indexOf(`\r
|
|
15
15
|
\r
|
|
@@ -807,4 +807,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
807
807
|
disabled:pointer-events-none disabled:opacity-40
|
|
808
808
|
[&_svg]:size-4 [&_svg]:shrink-0`,e&&`bg-muted font-semibold text-foreground`,t),...n})}function gE({pageCount:e,disabled:t,onGo:n}){let[r,i]=(0,q.useState)(``);return(0,K.jsxs)(`form`,{onSubmit:t=>{t.preventDefault();let a=Number(r);Number.isFinite(a)&&a>=1&&n(Math.min(a,e)),i(``)},className:`hidden items-center gap-2 @min-[840px]:flex`,children:[(0,K.jsx)(`label`,{htmlFor:`pagination-go-to`,className:`text-sm whitespace-nowrap text-muted-foreground`,children:`Go to`}),(0,K.jsx)(`input`,{id:`pagination-go-to`,type:`number`,min:1,max:e,inputMode:`numeric`,placeholder:`Page`,disabled:t,value:r,onChange:e=>i(e.target.value),className:`h-9 w-20 rounded-md border border-input bg-white px-3 text-sm text-foreground
|
|
809
809
|
placeholder:text-muted-foreground focus-visible:ring-1 focus-visible:ring-purple focus-visible:outline-none
|
|
810
|
-
disabled:pointer-events-none disabled:opacity-50 dark:bg-grey-700 dark:text-white`})]})}function _E({pageSize:e,onChange:t}){return(0,K.jsxs)(`div`,{className:`hidden items-center gap-2 @min-[960px]:flex`,children:[(0,K.jsx)(`span`,{className:`text-sm whitespace-nowrap text-muted-foreground`,children:`Rows`}),(0,K.jsxs)(Xt,{value:String(e),onValueChange:e=>t(Number(e)),children:[(0,K.jsx)(Kt,{"aria-label":`Rows per page`,className:`h-9 w-20`,children:(0,K.jsx)(Yt,{})}),(0,K.jsx)(Gt,{side:`top`,children:fE.map(e=>(0,K.jsx)(Ht,{value:String(e),children:ff(e)},e))})]})]})}function vE(e,t,n=1){if(t<=n*2+5)return yE(1,t);let r=Math.max(e-n,1),i=Math.min(e+n,t),a=r>2,o=i<t-1,s=3+2*n;return!a&&o?[...yE(1,s),`ellipsis`,t]:a&&!o?[1,`ellipsis`,...yE(t-s+1,t)]:[1,`ellipsis`,...yE(r,i),`ellipsis`,t]}function yE(e,t){return Array.from({length:t-e+1},(t,n)=>e+n)}function bE({applyFilters:e,columnFiltersForm:t,columns:n,columnVisibility:r,columnSizing:i,setColumnSizing:a,data:o,isFetching:s,onColumnClick:c,onRowClick:l,pageIndex:u,pageSize:d,primaryKey:f,setPageIndex:p,setPageSize:m,filtersToggled:h,totalPages:g,totalRecords:_,isEstimatedCount:v,estimatedRange:y,isExactCountFetching:b,isExactCountError:x,onRequestExactCount:S}){let C=be({features:Nn,data:o||[],columns:n,manualSorting:!0,enableColumnResizing:!0,columnResizeMode:`onEnd`,onColumnSizingChange:a,defaultColumn:{minSize:80},state:{columnVisibility:r,columnSizing:i}}),w=C.state.columnResizing,T=w.isResizingColumn,E=null;if(T){let e=C.options.defaultColumn?.minSize??20,t=C.getColumn(T)?.getSize()??0,n=0;for(let e of C.getVisibleLeafColumns())if(n+=e.getSize(),e.id===T)break;E=n+Math.max(w.deltaOffset??0,e-t)}return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`relative flex flex-col grow`,children:[(0,K.jsxs)(fn,{containerClassName:`rounded-md bg-card dark:bg-black-dark grow overflow-visible`,className:`table-fixed`,children:[(0,K.jsx)(ln,{children:C.getHeaderGroups().map(e=>(0,K.jsxs)(dn,{className:`border-none`,children:[e.headers.map(e=>(0,K.jsx)(rn,{header:e,onColumnClick:c,className:`sticky top-32 z-10 bg-card dark:bg-black-dark border-b border-border`},e.id)),(0,K.jsx)(on,{"aria-hidden":!0,className:`w-full p-0 sticky top-32 z-10 bg-card dark:bg-black-dark border-b border-border`})]},e.id))}),h&&(0,K.jsx)(sE,{applyFilters:e,columnFiltersForm:t,headerGroups:C.getHeaderGroups()}),(0,K.jsx)(cn,{className:`bg-background dark:bg-black border border-border dark:border-grey-700`,children:C.getRowModel().rows?.length?C.getRowModel().rows.map(e=>(0,K.jsx)(xE,{row:e,onRowClick:l,primaryKey:f},e.id)):(0,K.jsx)(dn,{children:(0,K.jsx)(un,{colSpan:n.length+1,className:`h-24 text-center`,children:s||o===void 0?(0,K.jsx)(dE,{className:`opacity-50 inline-block`}):(0,K.jsx)(`span`,{children:`No results.`})})})})]}),E!==null&&(0,K.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute top-0 bottom-0 z-20 w-0.5 bg-primary`,style:{left:`${E}px`}})]}),(0,K.jsx)(pE,{pageIndex:u,pageSize:d,totalPages:g,totalRecords:_,isEstimatedCount:v,estimatedRange:y,isExactCountFetching:b,isExactCountError:x,onRequestExactCount:S,setPageIndex:p,setPageSize:m})]})}function xE({row:e,primaryKey:t,onRowClick:n}){let r=e.getVisibleCells(),i=(0,q.useMemo)(()=>{let n=e.original;return n&&n.message===`This entry has expired`?r[0]?.column?.id===t?[(0,K.jsx)(SE,{cell:r[0]},r[0].id),(0,K.jsx)(CE,{colSpan:r.length-1},`expired`)]:[(0,K.jsx)(CE,{colSpan:r.length},`expired`)]:r.map(e=>(0,K.jsx)(SE,{cell:e},e.id))},[e,t,r]);return(0,K.jsxs)(dn,{"data-state":e.getIsSelected()&&`selected`,onClick:()=>n?.(e),className:P(`hover:bg-muted/10 data-[state=selected]:bg-muted`,n&&`cursor-pointer`),children:[i,(0,K.jsx)(un,{"aria-hidden":!0,className:`p-0`})]})}function SE({cell:e}){let t=e.column.getSize();return(0,K.jsx)(un,{"data-col-id":e.column.id,style:{width:`${t}px`,maxWidth:`${t}px`},className:`px-2 py-2 overflow-hidden text-ellipsis whitespace-nowrap`,children:_e(e.column.columnDef.cell,e.getContext())})}function CE({colSpan:e}){return(0,K.jsx)(un,{colSpan:e,className:`px-2 py-2 overflow-x-hidden max-w-32 text-ellipsis whitespace-nowrap`,children:(0,K.jsx)(`span`,{className:`text-muted-foreground`,children:`This entry has expired`})})}function wE({instanceDatabaseMap:e,databaseName:t,tableName:n}){let r=B({strict:!1}),i=G(),{clusterId:a,instanceId:o}=r,{toggled:s,toggle:c}=XT(!0),l=Me(`instance:update`),u=Sl(o??a,t,n,`insert`),d=Cl(o??a,t,n),f=Sl(o??a,t,n,`update`),p=Sl(o??a,t,n,`delete`),m=xl(),{data:h}=H(zS({...i,databaseName:t,tableName:n})),g=e?.[t],_=g?.[n],v=h??_,y=(0,q.useMemo)(()=>su(v?.attributes??[],`attribute`),[v]),{data:b}=H(KT(i)),x=b?.[t]?.[n],S=(0,q.useMemo)(()=>qb(v,g,x),[v,g,x]),C=(0,q.useMemo)(()=>Qb(v,g),[v,g]),w=(0,q.useMemo)(()=>Yb(v?.attributes,g),[v,g]),[T,E]=Om(null,r),[D,O]=(0,q.useState)(!1),[k,A]=Om(null,r),j=(0,q.useMemo)(()=>(t?Object.keys(e?.[t]||[]).sort():[]).length===1,[e,t]),{toggled:M,toggleOn:N,toggleOff:P}=XT(!1),ee=dt({resolver:Fe(oE)}),{reset:te}=ee,I=ee.watch(),[L,ne]=Om(null,[r.clusterId,r.instanceId,t,n]),re=(0,q.useCallback)(e=>{let t=[];for(let n in e){let r=e[n];if(r?.length)try{t.push(...kS(n,r,y[n],S[n]))}catch(e){U.error(String(e))}}return t},[y,S]),R=(0,q.useCallback)(()=>{let e=re(I);ne(e.length?e:null),te({...I})},[re,te,I]),z=(0,q.useCallback)(()=>{te({},{keepValues:!1,keepDirtyValues:!1,keepDefaultValues:!1}),te(),ne(null),P()},[P,te]);(0,q.useEffect)(function(){return z()},[r,z]);let{filters:ae}=se({strict:!1}),oe=JSON.stringify([t,n,ae??null]),ce=(0,q.useRef)(null);(0,q.useEffect)(function(){if(!v||ce.current===oe)return;let e=ce.current===null;if(ce.current=oe,ae){te({...ae});let e=re(ae);ne(e.length?e:null),N()}else e||z()},[ae,oe,v,te,re,ne,N,z]);let{dataTableColumns:le,primaryKey:ue}=_S(v,S),[de,fe]=Om({attribute:ue,descending:!1},r),[pe,me]=Om(0,[t,n,L]),[he,ge]=(0,q.useState)(20),_e=h?.record_count??_?.record_count,ve=h?.estimated_record_range??_?.estimated_record_range,[ye,be]=Om(!1,[t,n]),{data:xe,isFetching:Se,isError:Ce,refetch:we}=H(rE({...i,enabled:ye,databaseName:t,tableName:n})),Te=(0,q.useCallback)(()=>{ye?we():be(!0)},[ye,we,be]),Ee=xe??_e,De=Ee?Math.ceil(Ee/he):0,Oe=xe===void 0&&ve!==void 0,ke=M&&!!L,Ae=vh({...i,enabled:!ke&&!!ue,databaseName:t,tableName:n,searchAttribute:ue,sort:de,pageSize:he,pageIndex:pe,onlyIfCached:s,getAttributes:C}),{data:je,isFetching:Ne}=H(Ae),Pe=DS({...i,enabled:ke&&!!ue,databaseName:t,tableName:n,conditions:L,sort:de,pageSize:he,pageIndex:pe,onlyIfCached:s,getAttributes:C}),{data:Ie,isFetching:Le}=H(Pe),Re=ke?Ie:je,ze=Ne||Le,{data:Be,isFetching:Ve,isError:He}=H(tE({...i,enabled:D,databaseName:t,tableName:n,ids:T})),Ue=D&&!!k&&(!ue||k[ue]==null),We=Be?.data,Ge=!Ue&&!!T?.length&&!Ve&&(He||Array.isArray(We)&&We.length===0),{mutate:Ke,isPending:qe}=aE(),{mutate:Je,isPending:Ye}=eE(),{mutate:Xe,isPending:Ze}=QT(),Qe=ie(),$e=(0,q.useCallback)(()=>Qe.invalidateQueries({queryKey:[i.entityId,t,n]}),[Qe,i.entityId,t,n]),et=(0,q.useCallback)(async()=>{confirm(`Are you sure you want to cleanup orphan blobs for database "${t}"?`)&&Xe({...i,databaseName:t},{onSuccess:e=>{U.success(e.message||`Orphan blobs cleanup started successfully`),$e()},onError:e=>{U.error(e instanceof Error?e.message:`Failed to cleanup orphan blobs`)}})},[Xe,t,i,$e]),{exportCsv:tt,isExporting:nt}=FS(),rt=(0,q.useCallback)(()=>{tt({databaseName:t,tableName:n,primaryKey:ue,sort:de,conditions:ke?L:null})},[tt,t,n,ue,de,ke,L]),it=(0,q.useCallback)(e=>{Ke({...i,databaseName:t,tableName:n,records:e},{onSuccess:()=>{$e(),O(!1),U.success(`Record updated successfully`)}})},[Ke,i,t,n,$e]),at=(0,q.useCallback)(e=>{Je({...i,databaseName:t,tableName:n,hashValues:e},{onSuccess:()=>{$e(),O(!1),U.success(`Record deleted successfully`)}})},[Je,i,t,n,$e]),ot=e=>{let t=ue?e.original[ue]:void 0;A(e.original),E(t==null?null:[t]),O(!0)},st=(e,t)=>{fe({attribute:e,descending:!t})},ct=Zf($e),lt=(0,q.useCallback)(()=>{jx(`ShowAddTableRecords`,{databaseName:t,tableName:n})},[t,n]),ut=(0,q.useCallback)(()=>{jx(`ShowImportData`,{databaseName:t,tableName:n})},[t,n]),[ft,pt]=Im(`ColumnDisplayed/${t}/${n}`,{}),mt=(0,q.useMemo)(()=>({...Object.fromEntries(Zb(S).map(e=>[e,!1])),...ft}),[S,ft]),[ht,gt]=Im(`ColumnSizing/${t}/${n}`,{});return(0,K.jsxs)(K.Fragment,{children:[(0,K.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,K.jsxs)(`div`,{className:`flex space-x-2`,children:[u&&(0,K.jsxs)(F,{variant:`positiveOutline`,onClick:lt,accessKey:`n`,children:[(0,K.jsx)(Ur,{}),(0,K.jsxs)(`span`,{children:[`Add `,(0,K.jsx)(`u`,{children:`N`}),`ew Record(s)`]})]}),d&&(0,K.jsxs)(F,{variant:`positiveOutline`,onClick:ut,accessKey:`i`,children:[(0,K.jsx)(ar,{}),(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`u`,{children:`I`}),`mport Data`]})]}),(0,K.jsxs)(F,{variant:`positiveOutline`,onClick:rt,disabled:nt,accessKey:`e`,children:[(0,K.jsx)(ir,{}),(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`u`,{children:`E`}),`xport CSV`]})]})]}),(0,K.jsxs)(`div`,{className:`flex space-x-2`,children:[M&&L&&(0,K.jsxs)(F,{type:`button`,variant:`ghost`,onClick:z,accessKey:`f`,children:[(0,K.jsx)(gr,{className:`inline-block `}),(0,K.jsxs)(`span`,{children:[`Clear `,(0,K.jsx)(`u`,{children:`F`}),`ilters`]})]}),M&&ee.formState.isDirty&&(0,K.jsxs)(F,{variant:`default`,onClick:R,children:[(0,K.jsx)(hr,{className:`inline-block `}),`Apply Filters`]}),M&&!L&&(0,K.jsxs)(F,{variant:`ghost`,onClick:P,accessKey:`f`,children:[(0,K.jsx)(gr,{className:`inline-block `}),(0,K.jsxs)(`span`,{children:[`Hide `,(0,K.jsx)(`u`,{children:`F`}),`ilters`]})]}),!M&&(0,K.jsxs)(F,{variant:`ghost`,onClick:N,accessKey:`f`,children:[(0,K.jsx)(_r,{className:`inline-block `}),(0,K.jsxs)(`span`,{children:[`Show `,(0,K.jsx)(`u`,{children:`F`}),`ilters`]})]}),(0,K.jsx)(F,{variant:`defaultOutline`,onClick:ct,disabled:ze,children:(0,K.jsx)(Wr,{})}),(0,K.jsx)(lE,{columns:le,columnVisibility:mt,setColumnVisibility:pt}),(0,K.jsxs)(bi,{children:[(0,K.jsx)(xi,{asChild:!0,disabled:!e,children:(0,K.jsx)(F,{variant:`ghost`,size:`icon`,disabled:!e,children:(0,K.jsx)(ur,{"aria-label":`Table options`})})}),(0,K.jsxs)(Si,{side:`bottom`,align:`end`,children:[(0,K.jsxs)(Ci,{className:`focus:bg-primary/70 focus:text-white`,onClick:c,children:[s?(0,K.jsx)(Zn,{className:`text-green`}):(0,K.jsx)(er,{}),`Only If Cached`,(0,K.jsx)(V,{to:`https://docs.harperdb.io/docs/developers/applications/caching#cache-control-header`,target:`_blank`,rel:`noopener noreferrer`,onClick:fS,children:(0,K.jsx)(dr,{})})]}),m&&l&&!!o&&(0,K.jsxs)(Ci,{className:`focus:bg-yellow/70 focus:text-white`,onClick:et,disabled:Ze,children:[(0,K.jsx)(Wn,{className:`text-yellow `}),`Cleanup Orphan Blobs`]}),m&&!j&&(0,K.jsxs)(Ci,{className:`focus:bg-red/70 focus:text-white`,onClick:()=>jx(`ShowDeleteTable`,{databaseName:t,tableName:n}),children:[(0,K.jsx)(di,{className:`inline-block `}),`Drop Table`]}),m&&(0,K.jsxs)(Ci,{className:`focus:bg-red/70 focus:text-white`,onClick:()=>jx(`ShowDeleteDatabase`,{databaseName:t}),children:[(0,K.jsx)(ui,{}),`Drop Database`]})]})]})]})]}),(0,K.jsx)(bE,{primaryKey:ue,data:Re?.data,isFetching:ze,filtersToggled:M,columns:le,columnVisibility:mt,columnSizing:ht,setColumnSizing:gt,onRowClick:ot,onColumnClick:st,totalPages:De,totalRecords:Ee,isEstimatedCount:Oe,estimatedRange:ve,isExactCountFetching:Se,isExactCountError:Ce,onRequestExactCount:Te,pageIndex:pe,pageSize:he,columnFiltersForm:ee,applyFilters:R,setPageIndex:me,setPageSize:ge}),(0,K.jsx)(YT,{canEditRecords:f,canDeleteRecords:p,setIsModalOpen:O,isModalOpen:D,primaryKey:ue,missingPrimaryKey:Ue,recordUnavailable:Ge,syntheticAttributes:w,data:Ue||Ge?k?[k]:void 0:Be?.data,onSaveChanges:it,onDeleteRecord:at,isUpdateTableRecordsPending:qe,isDeleteTableRecordsPending:Ye})]})}function TE(e,t){if(!e)return null;if(!(t.databaseName&&e[t.databaseName])){let n=Object.keys(e).sort()[0];return n&&n!==t.databaseName?{databaseName:n,tableName:void 0}:null}return t.tableName&&!e[t.databaseName][t.tableName]?{databaseName:t.databaseName,tableName:void 0}:null}var EE=10;function DE(e){return Math.max(200,Math.floor(e/2))}function OE(e,t){return Math.round(Math.min(Math.max(e,200),DE(t)))}function kE(){let[e,t]=Tn(Sn.DatabasesSidebarWidth,320),[n,r]=(0,q.useState)(!1),[i,a]=(0,q.useState)(()=>OE(e,window.innerWidth)),o=(0,q.useRef)(i);o.current=i;let s=(0,q.useRef)(null);(0,q.useEffect)(()=>{n||a(OE(e,window.innerWidth))},[e,n]),(0,q.useEffect)(()=>{let t=()=>{n||a(OE(e,window.innerWidth))};return window.addEventListener(`resize`,t),()=>window.removeEventListener(`resize`,t)},[e,n]);let c=(0,q.useCallback)(e=>{e.preventDefault(),s.current={startX:e.clientX,startWidth:o.current},r(!0)},[]);return(0,q.useEffect)(()=>{if(!n)return;let e=e=>{let t=s.current;t&&a(OE(t.startWidth+(e.clientX-t.startX),window.innerWidth))},i=()=>{r(!1),t(o.current)},c=document.body.style.userSelect;return document.body.style.userSelect=`none`,window.addEventListener(`mousemove`,e),window.addEventListener(`mouseup`,i),()=>{document.body.style.userSelect=c,window.removeEventListener(`mousemove`,e),window.removeEventListener(`mouseup`,i)}},[n,t]),{width:i,isResizing:n,startResizing:c,handleKeyDown:(0,q.useCallback)(e=>{e.key===`ArrowLeft`?(e.preventDefault(),t(e=>OE(e-EE,window.innerWidth))):e.key===`ArrowRight`&&(e.preventDefault(),t(e=>OE(e+EE,window.innerWidth)))},[t])}}function AE(){let e=B({strict:!1}),t=G(),{data:n}=H(Gv({...t,skipRecordCount:!0})),{width:r,isResizing:i,startResizing:a,handleKeyDown:o}=kE(),s={"--db-sidebar-width":`${r}px`},c=TE(n,e);return c?(0,K.jsx)(ne,{to:Vb({...e,...c}),replace:!0}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`main`,{className:`flex flex-col gap-4 md:flex-row md:items-start`,children:[(0,K.jsxs)(`section`,{style:s,className:`relative text-foreground w-full md:w-[var(--db-sidebar-width)] md:shrink-0 md:border-r border-border flex flex-col min-h-0 md:sticky md:top-32 md:h-[calc(100vh-(--spacing(32)))] md:max-h-[calc(100vh-(--spacing(32)))] overflow-y-clip`,children:[(0,K.jsx)(Ww,{instanceDatabaseMap:n}),(0,K.jsx)(`div`,{role:`separator`,tabIndex:0,"aria-orientation":`vertical`,"aria-label":`Resize sidebar`,"aria-valuenow":r,"aria-valuemin":200,"aria-valuemax":DE(window.innerWidth),onMouseDown:a,onKeyDown:o,className:`group hidden md:block absolute top-0 bottom-0 right-0 w-4 translate-x-1/2 z-40 cursor-col-resize outline-none`,children:(0,K.jsx)(`div`,{className:P(`absolute inset-y-0 left-1/2 w-1 -translate-x-1/2 transition-colors`,`group-hover:bg-violet-400/60 dark:group-hover:bg-violet-500/60 group-focus-visible:bg-violet-500/80`,i&&`bg-violet-400/60 dark:bg-violet-500/60`)})})]}),(0,K.jsx)(`section`,{className:`text-foreground w-full md:flex-1 md:min-w-0 flex flex-col min-h-0`,children:e.databaseName&&e.tableName?(0,K.jsx)(wE,{instanceDatabaseMap:n,databaseName:e.databaseName,tableName:e.tableName}):e.databaseName?(0,K.jsx)(WS,{instanceDatabaseMap:n,databaseName:e.databaseName}):null})]}),n&&(0,K.jsx)(dS,{instanceDatabaseMap:n})]})}function jE(e){return I({getParentRoute:()=>e,path:`/databases/{-$databaseName}/{-$tableName}`,head:()=>({meta:[{title:`Databases — Harper Fabric`}]}),component:AE})}var ME={className:`text-primary font-semibold bg-primary/10 rounded-md dark:text-white dark:bg-white/10`};function NE(){let e=bl(),t=B({strict:!1}),{version:n}=ee({strict:!1}),r=$t(`4.6.0`,n)&&e,i=$t(`4.7.0-beta.7`,n),a=G(),{data:o}=H(ng(a,r)),s=o?.restartRequired??!1,c=(0,q.useMemo)(()=>[e&&{to:t.clusterId&&!t.instanceId?m_(t,`apps`):m_(t),activeOptions:{exact:!0},name:`Applications`,shortName:`Apps`,icon:(0,K.jsx)(Vr,{className:`inline-block`})},{to:m_(t,`databases`),icon:(0,K.jsx)(lr,{className:`inline-block`}),name:`Databases`},e&&i&&{to:m_(t,`apis`),name:`APIs`,icon:(0,K.jsx)(Zr,{className:`inline-block`})},e&&r&&{to:m_(t,`status`),icon:(0,K.jsx)(vr,{className:`inline-block`}),name:`Status`},e&&{to:m_(t,`logs`),icon:(0,K.jsx)(zr,{className:`inline-block`}),name:`Logs`},e&&{to:m_(t,`config`),icon:(0,K.jsx)(Qr,{className:`inline-block`}),name:`Config`}].filter(kn),[e,t,i,r]);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(PE,{links:c,restartRequired:s}),(0,K.jsx)(FE,{links:c,restartRequired:s})]})}function PE({links:e,restartRequired:t}){return(0,K.jsxs)(`div`,{className:`hidden md:[@media(hover:hover)]:flex xl:flex items-center justify-between h-full text-sm text-foreground`,children:[(0,K.jsx)(Eo,{restartRequired:t}),(0,K.jsx)(`div`,{className:`flex space-x-2`,children:e.map(({shortName:e,...t})=>{let n=(0,K.jsxs)(V,{"aria-label":t.name,className:`p-2 text-center text-muted-foreground hover:text-foreground`,activeProps:ME,...t,children:[t.icon,(0,K.jsx)(`span`,{className:`hidden xl:inline-block ml-1`,children:t.name}),e&&(0,K.jsx)(`span`,{className:`visible xl:hidden ml-1`,children:e})]},t.to);return e?n:(0,K.jsxs)(Ia,{children:[(0,K.jsx)(La,{asChild:!0,children:n}),(0,K.jsx)(Ra,{side:`bottom`,className:`xl:hidden`,children:t.name})]},t.to)})})]})}function FE({links:e,restartRequired:t}){return(0,K.jsx)(K.Fragment,{children:(0,K.jsxs)(`div`,{className:`flex md:[@media(hover:hover)]:hidden xl:hidden items-center justify-between h-full px-2 text-foreground`,children:[(0,K.jsx)(Eo,{restartRequired:t}),(0,K.jsxs)(bi,{children:[(0,K.jsx)(xi,{asChild:!0,children:(0,K.jsx)(F,{variant:`ghost`,className:`p-0`,children:(0,K.jsx)(Ir,{className:`h-8 w-8`})})}),(0,K.jsxs)(Si,{children:[(0,K.jsx)(Ti,{children:`Instance Menu`}),(0,K.jsx)(Ei,{}),e.map(e=>(0,K.jsx)(Ci,{asChild:!0,children:(0,K.jsxs)(V,{to:e.to,activeProps:ME,className:`flex items-center gap-2`,children:[e.icon,e.name]})},e.to))]})]})]})})}(0,q.lazy)(()=>Te(()=>import(`./FloatingChat-jLWvR4kI.js`).then(e=>({default:e.FloatingChat})),__vite__mapDeps([43,1,4,5,44,9,11,12])));function IE(){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`nav`,{className:`fixed top-20 w-full z-39 h-12 md:px-12 bg-violet-50 border-b border-violet-100 dark:bg-grey-700 dark:border-none`,children:(0,K.jsx)(NE,{})}),(0,K.jsx)(`div`,{className:`mt-32 min-h-[calc(100vh-(--spacing(32)))]`,children:(0,K.jsx)(Ce,{})}),!1]})}function LE(e){switch(e){case`local`:return I({getParentRoute:()=>uo,id:`_instanceLayout`,component:IE,loader:zb});case`cluster`:return I({getParentRoute:()=>Hm,id:`_instanceLayout`,component:IE,beforeLoad:RE,loader:zb});case`instance`:return I({getParentRoute:()=>Hm,path:`instance/$instanceId`,component:IE,beforeLoad:RE,loader:zb})}}async function RE({context:e,params:t}){let n=t.instanceId||t.clusterId,r=!1;if(l.checkForFabricConnect(n)&&!l.hasResolvedFabricConnect(n)&&(r=!0,await zE(n,e.cluster,t.instanceId)))return;let i=l.getConnectionById(n);if(i.isLoading||i.user)return;let a=e.authentication[m];if(!a||a.isLoading)return;let{update:o}=t.instanceId?vl(a.user,t.organizationId,t.clusterId):hl(a.user,t.organizationId,t.clusterId);if(!r&&o&&await zE(n,e.cluster,t.instanceId))return;let s=`/${t.organizationId}/${t.clusterId}/`+(t.instanceId?`instance/${t.instanceId}`:``)+`/sign-in`;throw re({to:s,search:no()})}async function zE(e,t,n){try{return await l.establishFabricConnectAuth({id:e,operationsUrl:BE(t,n)}),!0}catch(e){return console.debug(`Fabric Connect not established`,e),!1}}function BE(e,t){if(t){let n=e?.instances?.find(e=>e.id===t);return n?f(n):void 0}return o(e)??void 0}function VE(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 HE=[`secondary`,`default`,`warning`,`outline`,`success`,`destructive`],UE=0,WE=new Map,GE=e=>{if(WE.has(e))return WE.get(e);UE++;let t=HE[UE%HE.length];return WE.set(e,t),t};function KE(e){switch(e){case`error`:case`stderr`:return`border-l-destructive`;case`warn`:return`border-l-yellow-500`;case`notify`:return`border-l-green-500`;default:return`border-l-transparent`}}function qE({columns:e,data:t,onRowClick:n,containerRef:r}){let i=be({features:Nn,data:t,columns:e});return(0,K.jsxs)(fn,{className:`text-xs`,containerRef:r,containerClassName:`rounded-md bg-card dark:bg-black-dark logsTable max-h-[calc(100vh-(--spacing(48)))] overflow-y-auto md:max-h-[calc(100vh-(--spacing(40)))]`,children:[(0,K.jsx)(ln,{children:i.getHeaderGroups().map(e=>(0,K.jsx)(dn,{className:`border-b border-border`,children:e.headers.map(e=>(0,K.jsx)(on,{className:`p-4 max-w-96 sticky top-0 z-10 border-b border-border bg-card dark:bg-black-dark`,children:e.isPlaceholder?null:_e(e.column.columnDef.header,e.getContext())},e.id))},e.id))}),(0,K.jsx)(cn,{className:`bg-background dark:bg-black`,children:i.getRowModel().rows?.length?i.getRowModel().rows.map(e=>(0,K.jsx)(dn,{"data-state":e.getIsSelected()&&`selected`,className:P(`hover:bg-muted/20 data-[state=selected]:bg-muted max-w-full border-l-2`,KE(e.original.level),n&&`cursor-pointer`),onClick:()=>n?.(e),children:e.getVisibleCells().map(e=>(0,K.jsx)(un,{className:`p-2`,children:_e(e.column.columnDef.cell,e.getContext())},e.id))},e.id)):(0,K.jsx)(dn,{children:(0,K.jsx)(un,{colSpan:e.length,className:`h-24 text-center`,children:`No results.`})})})]})}var JE=524288,YE=class{totalChars=0;spent=!1;get isSpent(){return this.spent}admit(e){return this.spent?{admitted:!1,justExhausted:!1,oversize:!1}:e>524288?{admitted:!1,justExhausted:!1,oversize:!0}:this.totalChars+e>8388608?(this.spent=!0,{admitted:!1,justExhausted:!0,oversize:!1}):(this.totalChars+=e,{admitted:!0,justExhausted:!1,oversize:!1})}};function XE(e){try{JSON.parse(e)}catch{return!1}return!0}function ZE(e){return!e||e.length>524288?`plaintext`:XE(e)?`json`:`plaintext`}function QE({label:e,children:t}){return(0,K.jsxs)(`div`,{className:`flex items-start gap-3 py-1.5 border-b border-border/50 last:border-0`,children:[(0,K.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground w-20 shrink-0 pt-0.5`,children:e}),(0,K.jsx)(`span`,{className:`text-xs`,children:t})]})}function $E({setIsModalOpen:e,isModalOpen:t,data:n}){let r=n?GE(n.node):`default`,i=lp();return(0,K.jsx)(Rt,{onOpenChange:e,open:t,children:(0,K.jsxs)(Ut,{"aria-describedby":void 0,resizable:!0,children:[(0,K.jsx)(Bt,{children:(0,K.jsx)(qt,{children:`Log Entry`})}),n?(0,K.jsxs)(`div`,{className:`flex flex-1 min-h-0 flex-col gap-2 text-popover-foreground`,children:[(0,K.jsxs)(`div`,{className:`rounded-md border border-border/50 bg-muted/20 px-3 py-1`,children:[(0,K.jsx)(QE,{label:`Level`,children:(0,K.jsx)(Wi,{variant:VE(n.level),children:wo(n.level)})}),(0,K.jsx)(QE,{label:`Timestamp`,children:(0,K.jsx)(`span`,{className:`tabular-nums`,children:new Date(n.timestamp).toLocaleString()})}),(0,K.jsx)(QE,{label:`Thread`,children:(0,K.jsx)(`span`,{className:`tabular-nums font-mono`,children:n.thread})}),n.node&&(0,K.jsx)(QE,{label:`Node`,children:(0,K.jsx)(Wi,{variant:r,children:n.node})}),n.tags&&n.tags.length>0&&(0,K.jsx)(QE,{label:`Tags`,children:(0,K.jsx)(`span`,{className:`font-mono`,children:n.tags})})]}),(0,K.jsxs)(`div`,{className:`flex flex-1 min-h-0 flex-col`,children:[(0,K.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground mb-1.5`,children:`Message`}),(0,K.jsx)(`div`,{className:`rounded-md overflow-hidden border border-border/50 flex-1 min-h-0`,children:(0,K.jsx)(dp,{className:`w-full h-full`,language:ZE(n.message),theme:i,value:n.message,options:{readOnly:!0,minimap:{enabled:!1},scrollBeyondLastLine:!1,fontSize:12,padding:{top:12,bottom:12},automaticLayout:!0}})})]})]}):(0,K.jsx)(Bi,{})]})})}var eD=y({limit:M().or(b()).or(T()).optional(),level:D([`notify`,`error`,`warn`,`info`,`debug`,`trace`,`undefined`]).or(b()).or(T()).optional(),from:M().or(b()).or(T()).optional(),until:M().or(b()).or(T()).optional(),log_name:D([`hdb.log`,`system.log`]).or(b()).or(T()).optional(),filter:M().or(b()).or(T()).optional()}),tD=`dark:bg-grey-600 dark:border-grey-500`;function nD({form:e,resetFilters:t,submitFilters:n,showLogName:r,showFilter:i,isOpen:a,onOpenChange:o}){return(0,K.jsxs)(It,{className:P(a?`block`:`hidden`,`mt-3 md:mt-0 md:block`),children:[(0,K.jsx)(Nt,{className:`hidden md:block`,children:(0,K.jsx)(`button`,{type:`button`,onClick:()=>o(!a),"aria-expanded":a,"aria-controls":`logs-filters-content`,className:`flex w-full items-center justify-between md:pointer-events-none`,children:(0,K.jsxs)(Mt,{className:`flex items-center gap-2 text-base`,children:[(0,K.jsx)(ti,{className:`size-4 text-muted-foreground`}),`Filters`]})})}),(0,K.jsx)(Pt,{id:`logs-filters-content`,children:(0,K.jsx)(Do,{...e,children:(0,K.jsxs)(`form`,{id:`instance-edit-log-filters-form`,name:`instance-edit-log-filters-form`,onSubmit:e.handleSubmit(n),className:`flex-col space-y-4`,children:[i&&(0,K.jsx)(Y,{control:e.control,name:`filter`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(J,{children:(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(Xr,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground`}),(0,K.jsx)($,{type:`search`,placeholder:`Search logs…`,className:P(`pl-9`,tD),value:e.value??``,onChange:e.onChange})]})}),(0,K.jsx)(Q,{})]})}),r&&(0,K.jsx)(Y,{control:e.control,name:`log_name`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Log file`}),(0,K.jsxs)(Xt,{onValueChange:e.onChange,value:e.value??void 0,children:[(0,K.jsx)(Kt,{className:P(`w-full bg-white`,tD),children:(0,K.jsx)(Yt,{placeholder:`Select log file`})}),(0,K.jsx)(Gt,{children:(0,K.jsxs)(Jt,{children:[(0,K.jsx)(Ht,{value:`hdb.log`,children:`Application (hdb.log)`}),(0,K.jsx)(Ht,{value:`system.log`,children:`System (system.log)`})]})})]}),(0,K.jsx)(Q,{})]})}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,K.jsx)(Y,{control:e.control,name:`limit`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Limit`}),(0,K.jsxs)(Xt,{onValueChange:e.onChange,value:e.value??void 0,children:[(0,K.jsx)(Kt,{className:P(`w-full bg-white`,tD),children:(0,K.jsx)(Yt,{placeholder:`Limit`})}),(0,K.jsx)(Gt,{children:(0,K.jsxs)(Jt,{children:[(0,K.jsx)(Ht,{value:`1000`,children:`1000`}),(0,K.jsx)(Ht,{value:`500`,children:`500`}),(0,K.jsx)(Ht,{value:`250`,children:`250`}),(0,K.jsx)(Ht,{value:`100`,children:`100`}),(0,K.jsx)(Ht,{value:`10`,children:`10`})]})})]}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:e.control,name:`level`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Level`}),(0,K.jsxs)(Xt,{onValueChange:e.onChange,value:e.value??void 0,children:[(0,K.jsx)(Kt,{className:P(`w-full bg-white`,tD),children:(0,K.jsx)(Yt,{placeholder:`Level`})}),(0,K.jsx)(Gt,{children:(0,K.jsxs)(Jt,{children:[(0,K.jsx)(Ht,{value:`undefined`,children:`All`}),(0,K.jsx)(Ht,{value:`notify`,children:`Notify`}),(0,K.jsx)(Ht,{value:`error`,children:`Error`}),(0,K.jsx)(Ht,{value:`warn`,children:`Warn`}),(0,K.jsx)(Ht,{value:`info`,children:`Info`}),(0,K.jsx)(Ht,{value:`debug`,children:`Debug`}),(0,K.jsx)(Ht,{value:`trace`,children:`Trace`})]})})]}),(0,K.jsx)(Q,{})]})})]}),(0,K.jsx)(Y,{control:e.control,name:`from`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Start date`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`datetime-local`,className:tD,value:e.value??void 0,onChange:e.onChange})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:e.control,name:`until`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`End date`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`datetime-local`,className:tD,value:e.value??void 0,onChange:e.onChange})}),(0,K.jsx)(Q,{})]})}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,K.jsx)(F,{type:`submit`,variant:`positiveOutline`,className:`grow`,children:`Apply Filters`}),(0,K.jsx)(F,{type:`reset`,variant:`destructiveOutline`,onClick:t,children:`Clear`})]})]})})})]})}var rD=1e4;function iD(e){if(!e)return;let t=parseInt(e,10);if(!(!Number.isFinite(t)||t<=0))return Math.min(t,rD)}function aD(e,t){return{operation:`read_log`,start:0,replicated:t,limit:iD(e.limit),level:e.level===`undefined`?void 0:e.level,from:e.from?new Date(e.from).toISOString():void 0,until:e.until?new Date(e.until).toISOString():void 0,log_name:e.log_name??void 0,filter:e.filter?e.filter:void 0,order:`desc`}}async function oD({instanceClient:e,logFilters:t,replicated:n}){let{data:r}=await e.post(`/`,aD(t,n));return r}function sD(e){let t=e.logFilters;return z({queryKey:[`read_log`,e.entityId,t.limit,t.level,t.from,t.until,t.log_name,t.filter,e.replicated],queryFn:()=>oD(e),retry:!1,refetchInterval:e.isAutoRefreshEnabled?5e3:!1})}async function cD({connection:e,logFilters:t,replicated:n,signal:r,onEntry:i}){let{url:a,headers:o,credentials:s}=l_(e),c;try{c=await fetch(a,{method:`POST`,headers:o,credentials:s,body:JSON.stringify(aD(t,n)),signal:r})}catch(e){throw r?.aborted?e:new o_(`Failed to open the read_log SSE stream.`,{cause:e})}let l=c.headers.get(`content-type`)??``;if(!c.ok||!l.includes(`text/event-stream`)||!c.body)throw await c.body?.cancel().catch(()=>{}),new o_(`read_log did not return an event stream (status ${c.status}, content-type "${l}").`);for await(let e of r_(c.body,r)){if(e.event===`error`){let t=a_(e);if(!t||typeof t!=`object`)throw new c_(typeof t==`string`&&t?t:`The log stream failed.`);let n=t;throw new c_(n.message??`The log stream failed.`,{code:n.code})}if(e.event===`done`||e.event===`end`)return;for(let t of lD(a_(e)))i(t)}}function lD(e){return Array.isArray(e)?e.filter(uD):uD(e)?[e]:[]}function uD(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.timestamp==`string`&&(typeof t.level==`string`||typeof t.message==`string`)}function dD(e){return[e.timestamp,e.node??``,e.thread??``,e.level,e.message].join(`|`)}function fD(e,t,n){let r=new Set,i=[];for(let n of[...t,...e]){let e=dD(n);r.has(e)||(r.add(e),i.push(n))}return i.sort((e,t)=>e.timestamp<t.timestamp?1:e.timestamp>t.timestamp?-1:0),n>0&&i.length>n?i.slice(0,n):i}var pD={entries:[],fellBack:!1};function mD(e,t){switch(t.kind){case`reset`:return pD;case`retry`:return e.fellBack?{...e,fellBack:!1}:e;case`append`:{if(t.entries.length===0)return e;let n=e.entries.concat(t.entries);return n.length<=t.cap?{...e,entries:n}:(n.sort((e,t)=>e.timestamp<t.timestamp?1:e.timestamp>t.timestamp?-1:0),{...e,entries:n.slice(0,t.cap)})}case`fellBack`:return{...e,fellBack:!0}}}function hD(){let e=G();return l.isDirectConnection(e.entityId)}var gD=1e3,_D=2e3,vD=250;function yD(e){return iD(e)??gD}function bD(e,t){return JSON.stringify([e.limit,e.level,e.from,e.until,e.log_name,e.filter,t])}function xD({params:e,logFilters:t,replicated:n,live:r}){let i=hD(),[a,o]=(0,q.useReducer)(mD,pD),s=r&&i&&!a.fellBack,c=bD(t,n),l=yD(t.limit),u=Math.max(_D,l),d=H(sD({...e,logFilters:t,replicated:n,isAutoRefreshEnabled:r&&!s}));(0,q.useEffect)(()=>{o({kind:`reset`})},[e.entityId,c]),(0,q.useEffect)(()=>{r&&o({kind:`retry`})},[r]);let f=(0,q.useRef)({logFilters:t,replicated:n});f.current={logFilters:t,replicated:n},(0,q.useEffect)(()=>{if(!s)return;let t=new AbortController,n=[],r=()=>{if(n.length>0&&!t.signal.aborted){let e=n;n=[],o({kind:`append`,entries:e,cap:u})}},i=setInterval(r,vD);return cD({connection:{id:e.entityId},logFilters:f.current.logFilters,replicated:f.current.replicated,signal:t.signal,onEntry:e=>n.push(e)}).catch(()=>{}).finally(()=>{clearInterval(i),!t.signal.aborted&&(r(),o({kind:`fellBack`}))}),()=>{clearInterval(i),t.abort()}},[s,e.entityId,c]);let p=(0,q.useMemo)(()=>{let e=d.data??[];return a.entries.length===0?e:fD(e,a.entries,l)},[d.data,a.entries,l]),m=s?`streaming`:r?`polling`:`idle`;return{logs:p,isLoading:d.isLoading,isFetching:d.isFetching,refetch:()=>d.refetch(),transport:m}}var SD={log_name:`hdb.log`,limit:`100`,level:`undefined`,from:``,until:``,filter:``},CD={error:(0,K.jsx)(Xn,{className:`size-3`}),stderr:(0,K.jsx)(Xn,{className:`size-3`}),warn:(0,K.jsx)(fi,{className:`size-3`}),notify:(0,K.jsx)(Hn,{className:`size-3`}),info:(0,K.jsx)(Cr,{className:`size-3`}),debug:(0,K.jsx)(Gn,{className:`size-3`}),trace:(0,K.jsx)(Rn,{className:`size-3`}),stdout:(0,K.jsx)(ci,{className:`size-3`})},wD=[{accessorKey:`level`,header:`Level`,cell:({row:e})=>{let{level:t}=e.original;return(0,K.jsxs)(Wi,{variant:VE(t),children:[CD[t],wo(t)]})}},{accessorKey:`timestamp`,header:`Timestamp`,cell:({row:e})=>{let{timestamp:t}=e.original,n=new Date(t),r=n.getFullYear()===new Date().getFullYear()?n.toLocaleDateString(void 0,{month:`numeric`,day:`2-digit`}):n.toLocaleDateString();return(0,K.jsxs)(`span`,{className:`tabular-nums whitespace-nowrap text-muted-foreground`,children:[r,` `,n.toLocaleTimeString()]})}},{accessorKey:`message`,header:`Message`,cell:({row:e})=>{let{message:t}=e.original;return(0,K.jsx)(`span`,{className:`block max-w-xl truncate font-mono text-xs`,children:t})}},{accessorKey:`thread`,header:`Thread`,cell:({row:e})=>(0,K.jsx)(`span`,{className:`text-muted-foreground tabular-nums`,children:e.original.thread})},{accessorKey:`node`,header:`Node`,cell:({row:e})=>{let{node:t}=e.original,n=GE(t);return(0,K.jsx)(K.Fragment,{children:t?(0,K.jsxs)(Ia,{children:[(0,K.jsx)(La,{asChild:!0,children:(0,K.jsxs)(Wi,{variant:n,children:[t.split(`.`)[0],`...`]})}),(0,K.jsx)(Ra,{className:`bg-popover text-popover-foreground border border-border`,arrowClassName:`bg-popover fill-popover`,children:t})]}):null})}},{accessorKey:`tags`,header:`Tags`,cell:({row:e})=>{let{tags:t}=e.original;return t&&t.length>0?(0,K.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:t}):null}}],TD=(e,t)=>!e&&!t||!e||!t||new Date(e)<=new Date(t);function ED(){return(0,K.jsxs)(`div`,{className:`rounded-md bg-card dark:bg-black-dark overflow-hidden`,children:[(0,K.jsx)(`div`,{className:`flex gap-4 p-4 border-b border-border`,children:[`w-14`,`w-32`,`w-14`,`w-24`,`w-16`,`flex-1`].map((e,t)=>(0,K.jsx)(tm,{className:`h-4 ${e}`},t))}),Array.from({length:12}).map((e,t)=>(0,K.jsxs)(`div`,{className:`flex gap-4 p-3 border-b border-border/40 border-l-2 border-l-transparent`,children:[(0,K.jsx)(tm,{className:`h-5 w-14`}),(0,K.jsx)(tm,{className:`h-5 w-32`}),(0,K.jsx)(tm,{className:`h-5 w-10`}),(0,K.jsx)(tm,{className:`h-5 w-20`}),(0,K.jsx)(tm,{className:`h-5 w-12`}),(0,K.jsx)(tm,{className:`h-5 flex-1 max-w-xs`})]},t))]})}function DD(){let[e,t]=(0,q.useState)(SD),[n,r]=(0,q.useState)(!1),[i,a]=(0,q.useState)(),[o,s]=(0,q.useState)(!1),[c,l]=Tn(Sn.LogsOrderReversed,!1),[u,d]=(0,q.useState)(!1),f=G(),{data:p}=H(nn(f)),m=p?.version,h=!!m&&$t(`4.7.16`,m),{logs:g,isLoading:_,isFetching:v,refetch:y,transport:b}=xD({params:f,logFilters:e,replicated:f.entityType===`cluster`,live:o}),x=(0,q.useMemo)(()=>c?[...g??[]].reverse():g??[],[g,c]),S=(0,q.useRef)(null);(0,q.useEffect)(()=>{let e=S.current;_||!e||e.scrollTo({top:c?e.scrollHeight:0})},[c,_]),(0,q.useEffect)(()=>{let e=S.current;!o||_||!e||e.scrollTo({top:c?e.scrollHeight:0})},[x,o,c,_]);let C=dt({resolver:Fe(eD),defaultValues:SD,mode:`onChange`}),w=e=>{a(e.original),r(!0)},T=async e=>{if(!TD(e.from,e.until)){C.setError(`from`,{type:`onChange`,message:`Start date must be before end date`}),C.setError(`until`,{type:`onChange`,message:`End date must be after start date`});return}t(e)},E=async()=>{C.reset(),t(SD)},D=Zf(y);return(0,K.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 pt-2 text-foreground md:grid-cols-12 md:gap-4`,children:[(0,K.jsxs)(`section`,{className:`col-span-1 md:col-span-4 lg:col-span-3 px-2 pb-0 md:self-start md:sticky md:top-34 md:max-h-[calc(100vh-(--spacing(34)))] md:overflow-y-auto md:pb-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 md:hidden`,children:[(0,K.jsxs)(F,{variant:`defaultOutline`,onClick:()=>d(e=>!e),"aria-label":`Toggle filters`,"aria-expanded":u,className:`flex-1`,children:[(0,K.jsx)(ti,{}),`Filters`]}),(0,K.jsxs)(F,{variant:`defaultOutline`,onClick:D,disabled:v||_||o,"aria-label":`Refresh logs`,className:`flex-1`,children:[(0,K.jsx)(Wr,{className:v?`animate-spin`:``}),`Refresh`]}),(0,K.jsxs)(F,{variant:c?`default`:`defaultOutline`,onClick:()=>l(e=>!e),"aria-label":`Reverse log order`,"aria-pressed":c,className:`flex-1`,children:[(0,K.jsx)(sn,{}),`Reverse`]})]}),(0,K.jsx)(nD,{form:C,resetFilters:E,submitFilters:T,showLogName:!1,showFilter:h,isOpen:u,onOpenChange:d}),(0,K.jsxs)(`div`,{className:`mt-3 space-y-3 hidden md:block`,children:[(0,K.jsxs)(F,{variant:`defaultOutline`,onClick:D,disabled:v||_||o,className:`w-full`,children:[(0,K.jsx)(Wr,{}),`Refresh`]}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-2.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-foreground`,children:[(0,K.jsx)(Tp,{id:`logs-live-switch`,"aria-label":`Toggle live logs`,checked:o,onCheckedChange:s}),(0,K.jsxs)(`label`,{htmlFor:`logs-live-switch`,className:`flex items-center gap-2 cursor-pointer`,children:[(0,K.jsx)(Wr,{className:`size-4 ${o?`animate-spin [animation-duration:3s]`:``}`}),o?b===`streaming`?`Live (streaming)`:`Live (polling every 5s)`:`Live`]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-foreground`,children:[(0,K.jsx)(Tp,{id:`logs-reverse-order-switch`,"aria-label":`Reverse log order`,checked:c,onCheckedChange:l}),(0,K.jsxs)(`label`,{htmlFor:`logs-reverse-order-switch`,className:`flex items-center gap-2 cursor-pointer`,children:[(0,K.jsx)(sn,{className:`size-4`}),c?`Oldest first`:`Newest first`]})]})]})]})]}),(0,K.jsx)(`section`,{className:`col-span-1 md:col-span-8 lg:col-span-9`,children:_?(0,K.jsx)(ED,{}):(0,K.jsx)(qE,{columns:wD,data:x,onRowClick:w,containerRef:S})}),(0,K.jsx)($E,{isModalOpen:n,setIsModalOpen:r,data:i})]})}function OD(e){return I({getParentRoute:()=>e,path:`logs`,head:()=>({meta:[{title:`Logs — Harper Fabric`}]}),component:DD})}var kD=6e4,AD=60*kD,jD=24*AD,MD=[{id:`1h`,label:`Last 1 hour`,durationMs:AD,bucketMs:1*kD,expandedBucketMs:1*kD},{id:`6h`,label:`Last 6 hours`,durationMs:6*AD,bucketMs:2*kD,expandedBucketMs:1*kD},{id:`24h`,label:`Last 24 hours`,durationMs:jD,bucketMs:10*kD,expandedBucketMs:5*kD},{id:`7d`,label:`Last 7 days`,durationMs:7*jD,bucketMs:AD,expandedBucketMs:15*kD},{id:`30d`,label:`Last 30 days`,durationMs:30*jD,bucketMs:4*AD,expandedBucketMs:AD}];function ND(e){let t=MD.find(t=>t.id===e);if(!t)throw Error(`Unknown preset: ${e}`);return t}function PD(e){let t=(e,t)=>`${e} ${t}${e===1?``:`s`}`;return e>=AD&&e%AD===0?t(e/AD,`hour`):e>=kD&&e%kD===0?t(e/kD,`minute`):e>=1e3&&e%1e3==0?t(e/1e3,`second`):`${e} ms`}function FD(e,t){let n=e=>t?.expanded?e.expandedBucketMs:e.bucketMs,r=n(MD[0]);if(!Number.isFinite(e)||e<=0)return r;for(let t of MD)if(e<=t.durationMs*1.01)return n(t);let i=MD[MD.length-1];return Math.max(r,Math.ceil(e/(i.durationMs/n(i))))}var ID=[{label:`Off`,value:0},{label:`30s`,value:3e4},{label:`60s`,value:6e4},{label:`5m`,value:3e5}],LD=6e4,RD=[`health`,`traffic`,`requests`,`database`,`replication`,`storage`,`overview`],zD={tab:`health`,range:`1h`,refresh:LD};function BD(e){let t=e.refresh===``?NaN:Number(e.refresh);return{tab:RD.find(t=>t===e.tab)??zD.tab,range:MD.find(t=>t.id===e.range)?.id??zD.range,refresh:ID.find(e=>e.value===t)?.value??zD.refresh}}function VD(e){return I({getParentRoute:()=>e,path:`status`,validateSearch:BD,search:{middlewares:[oe(zD)]},head:()=>({meta:[{title:`Status — Harper Fabric`}]}),component:me(async()=>Te(()=>import(`./status-CK9tD-Nd.js`),__vite__mapDeps([45,1,3,2,4,5,6,7,20,9,8,10,11,12,37,40,32,18,46,47,48,49,50,51,52,53,54,55,56,57,58,59])),`StatusIndex`)})}function HD(e){let t=LE(e),n=[OD(t),...Mg(t,e),jg(t),VD(t),Bb(t),jE(t)];return t.addChildren(n)}I({getParentRoute:()=>uo,path:`notifications`,head:()=>({meta:[{title:`Notifications — Harper Fabric`}]}),component:me(async()=>Te(()=>import(`./notifications-DVlKonbI.js`),__vite__mapDeps([60,1,2,3,4,5,6])),`NotificationsCenter`)}),I({getParentRoute:()=>uo,path:`profile`,head:()=>({meta:[{title:`Profile — Harper Fabric`}]}),component:me(async()=>Te(()=>import(`./profile-BSQWfYfq.js`),__vite__mapDeps([61,1,18,3,2,4,5,6,7,17])),`ProfileIndex`)});var UD=lo.addChildren([...Gs,uo.addChildren([HD(`local`)])]);function WD({routeTree:e=UD,authentication:t}){let[n]=(0,q.useState)(()=>Se({routeTree:e,history:ce(),defaultNotFoundComponent:vi,defaultErrorComponent:_i,defaultPreload:!yi()&&`intent`,trailingSlash:`never`,defaultPreloadStaleTime:0,scrollRestoration:!0,context:{queryClient:yn,authentication:t||{}}}));return n}function GD(){let e=ke(),t=WD({authentication:e}),n=(0,q.useRef)(e);return(0,q.useEffect)(()=>{n.current!==e&&(n.current=e,t.invalidate())},[t,e]),(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(pe,{router:t,context:{authentication:e}}),(0,K.jsx)(ve,{router:t,position:`bottom-right`})]})}var KD=({...e})=>(0,K.jsx)(Ue,{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}),qD=!1;function JD(){(0,q.useEffect)(()=>{qD||=!0},[])}function YD(){return ho(),so(),JD(),(0,K.jsxs)(Ea,{children:[(0,K.jsxs)(fe,{client:yn,children:[(0,K.jsx)(GD,{}),(0,K.jsx)(xe,{buttonPosition:`bottom-right`})]}),(0,K.jsx)(KD,{richColors:!0})]})}function XD(){l.signOutAllLocally(),yn.getMutationCache().clear(),yn.getQueryCache().clear(),Ba(),Va()}function ZD(e,t=()=>!1,n=()=>!0){return r=>(r?.response?.status===401&&!t(r.config?.url??``)&&n(r.config)&&e(),Promise.reject(r))}var QD=[`/Login/`,`/ForgotPassword/`,`/ResetPassword/`,`/VerifyEmail/`,`/ResendVerificationEmail/`],$D=`authUserAtSend`;function eO(){let e=l.getConnectionById(m).user;return e&&`id`in e?e.id:null}var tO=!1;function nO(){tO||(tO=!0,N.interceptors.request.use(e=>(e[$D]=eO(),e)),N.interceptors.response.use(e=>e,ZD(XD,e=>QD.some(t=>e.startsWith(t)),e=>e?.[$D]===eO())))}function rO(){if(typeof Node!=`function`||!Node.prototype)return;let e=`__harperTranslationGuarded__`,t=Node.prototype;if(t[e])return;Object.defineProperty(t,e,{value:!0,configurable:!0,writable:!0,enumerable:!1});let n=Node.prototype.removeChild;Node.prototype.removeChild=function(e){return e instanceof Node&&e.parentNode!==this?e:n.call(this,e)};let r=Node.prototype.insertBefore;Node.prototype.insertBefore=function(e,t){return t instanceof Node&&t.parentNode!==this?r.call(this,e,null):r.call(this,e,t)}}var iO=`Studio:StaleDeployReloadedAt`,aO=6e4,oO=`__harperStaleDeployReloadState__`;function sO(){if(!(typeof window>`u`))return window[oO]}function cO(){let e=sO();if(e){try{let e=Number(sessionStorage.getItem(iO)??0);if(Date.now()-e<aO)return;sessionStorage.setItem(iO,String(Date.now()))}catch{return}e.reload()}}function lO(e=()=>window.location.reload()){if(typeof window>`u`)return;let t=window,n=t[oO];if(n){n.reload=e;return}t[oO]={reload:e},window.addEventListener(`vite:preloadError`,()=>cO())}var uO=Oe();rO(),lO(),nO(),(0,uO.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,K.jsx)(q.StrictMode,{children:(0,K.jsx)(YD,{})}));export{zy as $,Wr as $n,$s as $t,pT as A,bi as An,Im as At,BS as B,_i as Bn,Yf as Bt,gT as C,fa as Cn,s_ as Ct,cT as D,$i as Dn,Yh as Dt,uT as E,Qi as En,ng as Et,Qw as F,Di as Fn,Am as Ft,jx as G,ci as Gn,bu as Gt,OS as H,fi as Hn,df as Ht,Ew as I,Oi as In,tm as It,ix as J,$r as Jn,xl as Jt,Nx as K,oi as Kn,Hl as Kt,UC as L,Ai as Ln,Tp as Lt,eT as M,Si as Mn,Mm as Mt,Yw as N,Ci as Nn,jm as Nt,mT as O,Wi as On,Dh as Ot,$w as P,Ei as Pn,Nm as Pt,Zy as Q,Gr as Qn,Zs as Qt,KS as R,ki as Rn,dp as Rt,sT as S,ua as Sn,p_ as St,vT as T,Zi as Tn,n_ as Tt,fS as U,di as Un,Au as Ut,RS as V,mi as Vn,Hf as Vt,Mx as W,ui as Wn,Su as Wt,yb as X,Jr as Xn,Js as Xt,$b as Y,Xr as Yn,bl as Yt,nb as Z,Kr as Zn,Xs as Zt,zT as _,Sa as _n,H_ as _t,PD as a,Z as an,Cr as ar,jy as at,hT as b,oa as bn,v_ as bt,oD as c,Y as cn,Qn as cr,Wv as ct,iE as d,eo as dn,iv as dt,ec as en,Ur as er,By as et,$T as f,Ha as fn,nv as ft,HT as g,Ca as gn,G_ as gt,UT as h,La as hn,Y_ as ht,MD as i,Q as in,wr as ir,Ly as it,fT as j,wi as jn,Pm as jt,lT as k,Bi as kn,yh as kt,YE as l,J as ln,Xn as lr,av as lt,VT as m,Ra as mn,X_ as mt,BD as n,Jo as nn,Ar as nr,ky as nt,ND as o,jo as on,lr as or,Iy as ot,XT as p,Ia as pn,J_ as pt,Ax as q,ai as qn,Vl as qt,ID as r,$ as rn,kr as rr,Ay as rt,FD as s,X as sn,sr,Yv as st,cO as t,Ys as tn,Vr as tr,Ey as tt,JE as u,Do as un,Bn as ur,rv as ut,LT as v,ma as vn,w_ as vt,_T as w,ca as wn,o_ as wt,oT as x,aa as xn,m_ as xt,IT as y,pa as yn,S_ as yt,GS as z,xi as zn,lp as zt};
|
|
810
|
+
disabled:pointer-events-none disabled:opacity-50 dark:bg-grey-700 dark:text-white`})]})}function _E({pageSize:e,onChange:t}){return(0,K.jsxs)(`div`,{className:`hidden items-center gap-2 @min-[960px]:flex`,children:[(0,K.jsx)(`span`,{className:`text-sm whitespace-nowrap text-muted-foreground`,children:`Rows`}),(0,K.jsxs)(Xt,{value:String(e),onValueChange:e=>t(Number(e)),children:[(0,K.jsx)(Kt,{"aria-label":`Rows per page`,className:`h-9 w-20`,children:(0,K.jsx)(Yt,{})}),(0,K.jsx)(Gt,{side:`top`,children:fE.map(e=>(0,K.jsx)(Ht,{value:String(e),children:ff(e)},e))})]})]})}function vE(e,t,n=1){if(t<=n*2+5)return yE(1,t);let r=Math.max(e-n,1),i=Math.min(e+n,t),a=r>2,o=i<t-1,s=3+2*n;return!a&&o?[...yE(1,s),`ellipsis`,t]:a&&!o?[1,`ellipsis`,...yE(t-s+1,t)]:[1,`ellipsis`,...yE(r,i),`ellipsis`,t]}function yE(e,t){return Array.from({length:t-e+1},(t,n)=>e+n)}function bE({applyFilters:e,columnFiltersForm:t,columns:n,columnVisibility:r,columnSizing:i,setColumnSizing:a,data:o,isFetching:s,onColumnClick:c,onRowClick:l,pageIndex:u,pageSize:d,primaryKey:f,setPageIndex:p,setPageSize:m,filtersToggled:h,totalPages:g,totalRecords:_,isEstimatedCount:v,estimatedRange:y,isExactCountFetching:b,isExactCountError:x,onRequestExactCount:S}){let C=be({features:Nn,data:o||[],columns:n,manualSorting:!0,enableColumnResizing:!0,columnResizeMode:`onEnd`,onColumnSizingChange:a,defaultColumn:{minSize:80},state:{columnVisibility:r,columnSizing:i}}),w=C.state.columnResizing,T=w.isResizingColumn,E=null;if(T){let e=C.options.defaultColumn?.minSize??20,t=C.getColumn(T)?.getSize()??0,n=0;for(let e of C.getVisibleLeafColumns())if(n+=e.getSize(),e.id===T)break;E=n+Math.max(w.deltaOffset??0,e-t)}return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`relative flex flex-col grow`,children:[(0,K.jsxs)(fn,{containerClassName:`rounded-md bg-card dark:bg-black-dark grow overflow-visible`,className:`table-fixed`,children:[(0,K.jsx)(ln,{children:C.getHeaderGroups().map(e=>(0,K.jsxs)(dn,{className:`border-none`,children:[e.headers.map(e=>(0,K.jsx)(rn,{header:e,onColumnClick:c,className:`sticky top-32 z-10 bg-card dark:bg-black-dark border-b border-border`},e.id)),(0,K.jsx)(on,{"aria-hidden":!0,className:`w-full p-0 sticky top-32 z-10 bg-card dark:bg-black-dark border-b border-border`})]},e.id))}),h&&(0,K.jsx)(sE,{applyFilters:e,columnFiltersForm:t,headerGroups:C.getHeaderGroups()}),(0,K.jsx)(cn,{className:`bg-background dark:bg-black border border-border dark:border-grey-700`,children:C.getRowModel().rows?.length?C.getRowModel().rows.map(e=>(0,K.jsx)(xE,{row:e,onRowClick:l,primaryKey:f},e.id)):(0,K.jsx)(dn,{children:(0,K.jsx)(un,{colSpan:n.length+1,className:`h-24 text-center`,children:s||o===void 0?(0,K.jsx)(dE,{className:`opacity-50 inline-block`}):(0,K.jsx)(`span`,{children:`No results.`})})})})]}),E!==null&&(0,K.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute top-0 bottom-0 z-20 w-0.5 bg-primary`,style:{left:`${E}px`}})]}),(0,K.jsx)(pE,{pageIndex:u,pageSize:d,totalPages:g,totalRecords:_,isEstimatedCount:v,estimatedRange:y,isExactCountFetching:b,isExactCountError:x,onRequestExactCount:S,setPageIndex:p,setPageSize:m})]})}function xE({row:e,primaryKey:t,onRowClick:n}){let r=e.getVisibleCells(),i=(0,q.useMemo)(()=>{let n=e.original;return n&&n.message===`This entry has expired`?r[0]?.column?.id===t?[(0,K.jsx)(SE,{cell:r[0]},r[0].id),(0,K.jsx)(CE,{colSpan:r.length-1},`expired`)]:[(0,K.jsx)(CE,{colSpan:r.length},`expired`)]:r.map(e=>(0,K.jsx)(SE,{cell:e},e.id))},[e,t,r]);return(0,K.jsxs)(dn,{"data-state":e.getIsSelected()&&`selected`,onClick:()=>n?.(e),className:P(`hover:bg-muted/10 data-[state=selected]:bg-muted`,n&&`cursor-pointer`),children:[i,(0,K.jsx)(un,{"aria-hidden":!0,className:`p-0`})]})}function SE({cell:e}){let t=e.column.getSize();return(0,K.jsx)(un,{"data-col-id":e.column.id,style:{width:`${t}px`,maxWidth:`${t}px`},className:`px-2 py-2 overflow-hidden text-ellipsis whitespace-nowrap`,children:_e(e.column.columnDef.cell,e.getContext())})}function CE({colSpan:e}){return(0,K.jsx)(un,{colSpan:e,className:`px-2 py-2 overflow-x-hidden max-w-32 text-ellipsis whitespace-nowrap`,children:(0,K.jsx)(`span`,{className:`text-muted-foreground`,children:`This entry has expired`})})}function wE({instanceDatabaseMap:e,databaseName:t,tableName:n}){let r=B({strict:!1}),i=G(),{clusterId:a,instanceId:o}=r,{toggled:s,toggle:c}=XT(!0),l=Me(`instance:update`),u=Sl(o??a,t,n,`insert`),d=Cl(o??a,t,n),f=Sl(o??a,t,n,`update`),p=Sl(o??a,t,n,`delete`),m=xl(),{data:h}=H(zS({...i,databaseName:t,tableName:n})),g=e?.[t],_=g?.[n],v=h??_,y=(0,q.useMemo)(()=>su(v?.attributes??[],`attribute`),[v]),{data:b}=H(KT(i)),x=b?.[t]?.[n],S=(0,q.useMemo)(()=>qb(v,g,x),[v,g,x]),C=(0,q.useMemo)(()=>Qb(v,g),[v,g]),w=(0,q.useMemo)(()=>Yb(v?.attributes,g),[v,g]),[T,E]=Om(null,r),[D,O]=(0,q.useState)(!1),[k,A]=Om(null,r),j=(0,q.useMemo)(()=>(t?Object.keys(e?.[t]||[]).sort():[]).length===1,[e,t]),{toggled:M,toggleOn:N,toggleOff:P}=XT(!1),ee=dt({resolver:Fe(oE)}),{reset:te}=ee,I=ee.watch(),[L,ne]=Om(null,[r.clusterId,r.instanceId,t,n]),re=(0,q.useCallback)(e=>{let t=[];for(let n in e){let r=e[n];if(r?.length)try{t.push(...kS(n,r,y[n],S[n]))}catch(e){U.error(String(e))}}return t},[y,S]),R=(0,q.useCallback)(()=>{let e=re(I);ne(e.length?e:null),te({...I})},[re,te,I]),z=(0,q.useCallback)(()=>{te({},{keepValues:!1,keepDirtyValues:!1,keepDefaultValues:!1}),te(),ne(null),P()},[P,te]);(0,q.useEffect)(function(){return z()},[r,z]);let{filters:ae}=se({strict:!1}),oe=JSON.stringify([t,n,ae??null]),ce=(0,q.useRef)(null);(0,q.useEffect)(function(){if(!v||ce.current===oe)return;let e=ce.current===null;if(ce.current=oe,ae){te({...ae});let e=re(ae);ne(e.length?e:null),N()}else e||z()},[ae,oe,v,te,re,ne,N,z]);let{dataTableColumns:le,primaryKey:ue}=_S(v,S),[de,fe]=Om({attribute:ue,descending:!1},r),[pe,me]=Om(0,[t,n,L]),[he,ge]=(0,q.useState)(20),_e=h?.record_count??_?.record_count,ve=h?.estimated_record_range??_?.estimated_record_range,[ye,be]=Om(!1,[t,n]),{data:xe,isFetching:Se,isError:Ce,refetch:we}=H(rE({...i,enabled:ye,databaseName:t,tableName:n})),Te=(0,q.useCallback)(()=>{ye?we():be(!0)},[ye,we,be]),Ee=xe??_e,De=Ee?Math.ceil(Ee/he):0,Oe=xe===void 0&&ve!==void 0,ke=M&&!!L,Ae=vh({...i,enabled:!ke&&!!ue,databaseName:t,tableName:n,searchAttribute:ue,sort:de,pageSize:he,pageIndex:pe,onlyIfCached:s,getAttributes:C}),{data:je,isFetching:Ne}=H(Ae),Pe=DS({...i,enabled:ke&&!!ue,databaseName:t,tableName:n,conditions:L,sort:de,pageSize:he,pageIndex:pe,onlyIfCached:s,getAttributes:C}),{data:Ie,isFetching:Le}=H(Pe),Re=ke?Ie:je,ze=Ne||Le,{data:Be,isFetching:Ve,isError:He}=H(tE({...i,enabled:D,databaseName:t,tableName:n,ids:T})),Ue=D&&!!k&&(!ue||k[ue]==null),We=Be?.data,Ge=!Ue&&!!T?.length&&!Ve&&(He||Array.isArray(We)&&We.length===0),{mutate:Ke,isPending:qe}=aE(),{mutate:Je,isPending:Ye}=eE(),{mutate:Xe,isPending:Ze}=QT(),Qe=ie(),$e=(0,q.useCallback)(()=>Qe.invalidateQueries({queryKey:[i.entityId,t,n]}),[Qe,i.entityId,t,n]),et=(0,q.useCallback)(async()=>{confirm(`Are you sure you want to cleanup orphan blobs for database "${t}"?`)&&Xe({...i,databaseName:t},{onSuccess:e=>{U.success(e.message||`Orphan blobs cleanup started successfully`),$e()},onError:e=>{U.error(e instanceof Error?e.message:`Failed to cleanup orphan blobs`)}})},[Xe,t,i,$e]),{exportCsv:tt,isExporting:nt}=FS(),rt=(0,q.useCallback)(()=>{tt({databaseName:t,tableName:n,primaryKey:ue,sort:de,conditions:ke?L:null})},[tt,t,n,ue,de,ke,L]),it=(0,q.useCallback)(e=>{Ke({...i,databaseName:t,tableName:n,records:e},{onSuccess:()=>{$e(),O(!1),U.success(`Record updated successfully`)}})},[Ke,i,t,n,$e]),at=(0,q.useCallback)(e=>{Je({...i,databaseName:t,tableName:n,hashValues:e},{onSuccess:()=>{$e(),O(!1),U.success(`Record deleted successfully`)}})},[Je,i,t,n,$e]),ot=e=>{let t=ue?e.original[ue]:void 0;A(e.original),E(t==null?null:[t]),O(!0)},st=(e,t)=>{fe({attribute:e,descending:!t})},ct=Zf($e),lt=(0,q.useCallback)(()=>{jx(`ShowAddTableRecords`,{databaseName:t,tableName:n})},[t,n]),ut=(0,q.useCallback)(()=>{jx(`ShowImportData`,{databaseName:t,tableName:n})},[t,n]),[ft,pt]=Im(`ColumnDisplayed/${t}/${n}`,{}),mt=(0,q.useMemo)(()=>({...Object.fromEntries(Zb(S).map(e=>[e,!1])),...ft}),[S,ft]),[ht,gt]=Im(`ColumnSizing/${t}/${n}`,{});return(0,K.jsxs)(K.Fragment,{children:[(0,K.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,K.jsxs)(`div`,{className:`flex space-x-2`,children:[u&&(0,K.jsxs)(F,{variant:`positiveOutline`,onClick:lt,accessKey:`n`,children:[(0,K.jsx)(Ur,{}),(0,K.jsxs)(`span`,{children:[`Add `,(0,K.jsx)(`u`,{children:`N`}),`ew Record(s)`]})]}),d&&(0,K.jsxs)(F,{variant:`positiveOutline`,onClick:ut,accessKey:`i`,children:[(0,K.jsx)(ar,{}),(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`u`,{children:`I`}),`mport Data`]})]}),(0,K.jsxs)(F,{variant:`positiveOutline`,onClick:rt,disabled:nt,accessKey:`e`,children:[(0,K.jsx)(ir,{}),(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`u`,{children:`E`}),`xport CSV`]})]})]}),(0,K.jsxs)(`div`,{className:`flex space-x-2`,children:[M&&L&&(0,K.jsxs)(F,{type:`button`,variant:`ghost`,onClick:z,accessKey:`f`,children:[(0,K.jsx)(gr,{className:`inline-block `}),(0,K.jsxs)(`span`,{children:[`Clear `,(0,K.jsx)(`u`,{children:`F`}),`ilters`]})]}),M&&ee.formState.isDirty&&(0,K.jsxs)(F,{variant:`default`,onClick:R,children:[(0,K.jsx)(hr,{className:`inline-block `}),`Apply Filters`]}),M&&!L&&(0,K.jsxs)(F,{variant:`ghost`,onClick:P,accessKey:`f`,children:[(0,K.jsx)(gr,{className:`inline-block `}),(0,K.jsxs)(`span`,{children:[`Hide `,(0,K.jsx)(`u`,{children:`F`}),`ilters`]})]}),!M&&(0,K.jsxs)(F,{variant:`ghost`,onClick:N,accessKey:`f`,children:[(0,K.jsx)(_r,{className:`inline-block `}),(0,K.jsxs)(`span`,{children:[`Show `,(0,K.jsx)(`u`,{children:`F`}),`ilters`]})]}),(0,K.jsx)(F,{variant:`defaultOutline`,onClick:ct,disabled:ze,children:(0,K.jsx)(Wr,{})}),(0,K.jsx)(lE,{columns:le,columnVisibility:mt,setColumnVisibility:pt}),(0,K.jsxs)(bi,{children:[(0,K.jsx)(xi,{asChild:!0,disabled:!e,children:(0,K.jsx)(F,{variant:`ghost`,size:`icon`,disabled:!e,children:(0,K.jsx)(ur,{"aria-label":`Table options`})})}),(0,K.jsxs)(Si,{side:`bottom`,align:`end`,children:[(0,K.jsxs)(Ci,{className:`focus:bg-primary/70 focus:text-white`,onClick:c,children:[s?(0,K.jsx)(Zn,{className:`text-green`}):(0,K.jsx)(er,{}),`Only If Cached`,(0,K.jsx)(V,{to:`https://docs.harperdb.io/docs/developers/applications/caching#cache-control-header`,target:`_blank`,rel:`noopener noreferrer`,onClick:fS,children:(0,K.jsx)(dr,{})})]}),m&&l&&!!o&&(0,K.jsxs)(Ci,{className:`focus:bg-yellow/70 focus:text-white`,onClick:et,disabled:Ze,children:[(0,K.jsx)(Wn,{className:`text-yellow `}),`Cleanup Orphan Blobs`]}),m&&!j&&(0,K.jsxs)(Ci,{className:`focus:bg-red/70 focus:text-white`,onClick:()=>jx(`ShowDeleteTable`,{databaseName:t,tableName:n}),children:[(0,K.jsx)(di,{className:`inline-block `}),`Drop Table`]}),m&&(0,K.jsxs)(Ci,{className:`focus:bg-red/70 focus:text-white`,onClick:()=>jx(`ShowDeleteDatabase`,{databaseName:t}),children:[(0,K.jsx)(ui,{}),`Drop Database`]})]})]})]})]}),(0,K.jsx)(bE,{primaryKey:ue,data:Re?.data,isFetching:ze,filtersToggled:M,columns:le,columnVisibility:mt,columnSizing:ht,setColumnSizing:gt,onRowClick:ot,onColumnClick:st,totalPages:De,totalRecords:Ee,isEstimatedCount:Oe,estimatedRange:ve,isExactCountFetching:Se,isExactCountError:Ce,onRequestExactCount:Te,pageIndex:pe,pageSize:he,columnFiltersForm:ee,applyFilters:R,setPageIndex:me,setPageSize:ge}),(0,K.jsx)(YT,{canEditRecords:f,canDeleteRecords:p,setIsModalOpen:O,isModalOpen:D,primaryKey:ue,missingPrimaryKey:Ue,recordUnavailable:Ge,syntheticAttributes:w,data:Ue||Ge?k?[k]:void 0:Be?.data,onSaveChanges:it,onDeleteRecord:at,isUpdateTableRecordsPending:qe,isDeleteTableRecordsPending:Ye})]})}function TE(e,t){if(!e)return null;if(!(t.databaseName&&e[t.databaseName])){let n=Object.keys(e).sort()[0];return n&&n!==t.databaseName?{databaseName:n,tableName:void 0}:null}return t.tableName&&!e[t.databaseName][t.tableName]?{databaseName:t.databaseName,tableName:void 0}:null}var EE=10;function DE(e){return Math.max(200,Math.floor(e/2))}function OE(e,t){return Math.round(Math.min(Math.max(e,200),DE(t)))}function kE(){let[e,t]=Tn(Sn.DatabasesSidebarWidth,320),[n,r]=(0,q.useState)(!1),[i,a]=(0,q.useState)(()=>OE(e,window.innerWidth)),o=(0,q.useRef)(i);o.current=i;let s=(0,q.useRef)(null);(0,q.useEffect)(()=>{n||a(OE(e,window.innerWidth))},[e,n]),(0,q.useEffect)(()=>{let t=()=>{n||a(OE(e,window.innerWidth))};return window.addEventListener(`resize`,t),()=>window.removeEventListener(`resize`,t)},[e,n]);let c=(0,q.useCallback)(e=>{e.preventDefault(),s.current={startX:e.clientX,startWidth:o.current},r(!0)},[]);return(0,q.useEffect)(()=>{if(!n)return;let e=e=>{let t=s.current;t&&a(OE(t.startWidth+(e.clientX-t.startX),window.innerWidth))},i=()=>{r(!1),t(o.current)},c=document.body.style.userSelect;return document.body.style.userSelect=`none`,window.addEventListener(`mousemove`,e),window.addEventListener(`mouseup`,i),()=>{document.body.style.userSelect=c,window.removeEventListener(`mousemove`,e),window.removeEventListener(`mouseup`,i)}},[n,t]),{width:i,isResizing:n,startResizing:c,handleKeyDown:(0,q.useCallback)(e=>{e.key===`ArrowLeft`?(e.preventDefault(),t(e=>OE(e-EE,window.innerWidth))):e.key===`ArrowRight`&&(e.preventDefault(),t(e=>OE(e+EE,window.innerWidth)))},[t])}}function AE(){let e=B({strict:!1}),t=G(),{data:n}=H(Gv({...t,skipRecordCount:!0})),{width:r,isResizing:i,startResizing:a,handleKeyDown:o}=kE(),s={"--db-sidebar-width":`${r}px`},c=TE(n,e);return c?(0,K.jsx)(ne,{to:Vb({...e,...c}),replace:!0}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`main`,{className:`flex flex-col gap-4 md:flex-row md:items-start`,children:[(0,K.jsxs)(`section`,{style:s,className:`relative text-foreground w-full md:w-[var(--db-sidebar-width)] md:shrink-0 md:border-r border-border flex flex-col min-h-0 md:sticky md:top-32 md:h-[calc(100vh-(--spacing(32)))] md:max-h-[calc(100vh-(--spacing(32)))] overflow-y-clip`,children:[(0,K.jsx)(Ww,{instanceDatabaseMap:n}),(0,K.jsx)(`div`,{role:`separator`,tabIndex:0,"aria-orientation":`vertical`,"aria-label":`Resize sidebar`,"aria-valuenow":r,"aria-valuemin":200,"aria-valuemax":DE(window.innerWidth),onMouseDown:a,onKeyDown:o,className:`group hidden md:block absolute top-0 bottom-0 right-0 w-4 translate-x-1/2 z-40 cursor-col-resize outline-none`,children:(0,K.jsx)(`div`,{className:P(`absolute inset-y-0 left-1/2 w-1 -translate-x-1/2 transition-colors`,`group-hover:bg-violet-400/60 dark:group-hover:bg-violet-500/60 group-focus-visible:bg-violet-500/80`,i&&`bg-violet-400/60 dark:bg-violet-500/60`)})})]}),(0,K.jsx)(`section`,{className:`text-foreground w-full md:flex-1 md:min-w-0 flex flex-col min-h-0`,children:e.databaseName&&e.tableName?(0,K.jsx)(wE,{instanceDatabaseMap:n,databaseName:e.databaseName,tableName:e.tableName}):e.databaseName?(0,K.jsx)(WS,{instanceDatabaseMap:n,databaseName:e.databaseName}):null})]}),n&&(0,K.jsx)(dS,{instanceDatabaseMap:n})]})}function jE(e){return I({getParentRoute:()=>e,path:`/databases/{-$databaseName}/{-$tableName}`,head:()=>({meta:[{title:`Databases — Harper Fabric`}]}),component:AE})}var ME={className:`text-primary font-semibold bg-primary/10 rounded-md dark:text-white dark:bg-white/10`};function NE(){let e=bl(),t=B({strict:!1}),{version:n}=ee({strict:!1}),r=$t(`4.6.0`,n)&&e,i=$t(`4.7.0-beta.7`,n),a=G(),{data:o}=H(ng(a,r)),s=o?.restartRequired??!1,c=(0,q.useMemo)(()=>[e&&{to:t.clusterId&&!t.instanceId?m_(t,`apps`):m_(t),activeOptions:{exact:!0},name:`Applications`,shortName:`Apps`,icon:(0,K.jsx)(Vr,{className:`inline-block`})},{to:m_(t,`databases`),icon:(0,K.jsx)(lr,{className:`inline-block`}),name:`Databases`},e&&i&&{to:m_(t,`apis`),name:`APIs`,icon:(0,K.jsx)(Zr,{className:`inline-block`})},e&&r&&{to:m_(t,`status`),icon:(0,K.jsx)(vr,{className:`inline-block`}),name:`Status`},e&&{to:m_(t,`logs`),icon:(0,K.jsx)(zr,{className:`inline-block`}),name:`Logs`},e&&{to:m_(t,`config`),icon:(0,K.jsx)(Qr,{className:`inline-block`}),name:`Config`}].filter(kn),[e,t,i,r]);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(PE,{links:c,restartRequired:s}),(0,K.jsx)(FE,{links:c,restartRequired:s})]})}function PE({links:e,restartRequired:t}){return(0,K.jsxs)(`div`,{className:`hidden md:[@media(hover:hover)]:flex xl:flex items-center justify-between h-full text-sm text-foreground`,children:[(0,K.jsx)(Eo,{restartRequired:t}),(0,K.jsx)(`div`,{className:`flex space-x-2`,children:e.map(({shortName:e,...t})=>{let n=(0,K.jsxs)(V,{"aria-label":t.name,className:`p-2 text-center text-muted-foreground hover:text-foreground`,activeProps:ME,...t,children:[t.icon,(0,K.jsx)(`span`,{className:`hidden xl:inline-block ml-1`,children:t.name}),e&&(0,K.jsx)(`span`,{className:`visible xl:hidden ml-1`,children:e})]},t.to);return e?n:(0,K.jsxs)(Ia,{children:[(0,K.jsx)(La,{asChild:!0,children:n}),(0,K.jsx)(Ra,{side:`bottom`,className:`xl:hidden`,children:t.name})]},t.to)})})]})}function FE({links:e,restartRequired:t}){return(0,K.jsx)(K.Fragment,{children:(0,K.jsxs)(`div`,{className:`flex md:[@media(hover:hover)]:hidden xl:hidden items-center justify-between h-full px-2 text-foreground`,children:[(0,K.jsx)(Eo,{restartRequired:t}),(0,K.jsxs)(bi,{children:[(0,K.jsx)(xi,{asChild:!0,children:(0,K.jsx)(F,{variant:`ghost`,className:`p-0`,children:(0,K.jsx)(Ir,{className:`h-8 w-8`})})}),(0,K.jsxs)(Si,{children:[(0,K.jsx)(Ti,{children:`Instance Menu`}),(0,K.jsx)(Ei,{}),e.map(e=>(0,K.jsx)(Ci,{asChild:!0,children:(0,K.jsxs)(V,{to:e.to,activeProps:ME,className:`flex items-center gap-2`,children:[e.icon,e.name]})},e.to))]})]})]})})}(0,q.lazy)(()=>Te(()=>import(`./FloatingChat-BbztUci0.js`).then(e=>({default:e.FloatingChat})),__vite__mapDeps([43,1,4,5,44,9,11,12])));function IE(){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`nav`,{className:`fixed top-20 w-full z-39 h-12 md:px-12 bg-violet-50 border-b border-violet-100 dark:bg-grey-700 dark:border-none`,children:(0,K.jsx)(NE,{})}),(0,K.jsx)(`div`,{className:`mt-32 min-h-[calc(100vh-(--spacing(32)))]`,children:(0,K.jsx)(Ce,{})}),!1]})}function LE(e){switch(e){case`local`:return I({getParentRoute:()=>uo,id:`_instanceLayout`,component:IE,loader:zb});case`cluster`:return I({getParentRoute:()=>Hm,id:`_instanceLayout`,component:IE,beforeLoad:RE,loader:zb});case`instance`:return I({getParentRoute:()=>Hm,path:`instance/$instanceId`,component:IE,beforeLoad:RE,loader:zb})}}async function RE({context:e,params:t}){let n=t.instanceId||t.clusterId,r=!1;if(l.checkForFabricConnect(n)&&!l.hasResolvedFabricConnect(n)&&(r=!0,await zE(n,e.cluster,t.instanceId)))return;let i=l.getConnectionById(n);if(i.isLoading||i.user)return;let a=e.authentication[m];if(!a||a.isLoading)return;let{update:o}=t.instanceId?vl(a.user,t.organizationId,t.clusterId):hl(a.user,t.organizationId,t.clusterId);if(!r&&o&&await zE(n,e.cluster,t.instanceId))return;let s=`/${t.organizationId}/${t.clusterId}/`+(t.instanceId?`instance/${t.instanceId}`:``)+`/sign-in`;throw re({to:s,search:no()})}async function zE(e,t,n){try{return await l.establishFabricConnectAuth({id:e,operationsUrl:BE(t,n)}),!0}catch(e){return console.debug(`Fabric Connect not established`,e),!1}}function BE(e,t){if(t){let n=e?.instances?.find(e=>e.id===t);return n?f(n):void 0}return o(e)??void 0}function VE(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 HE=[`secondary`,`default`,`warning`,`outline`,`success`,`destructive`],UE=0,WE=new Map,GE=e=>{if(WE.has(e))return WE.get(e);UE++;let t=HE[UE%HE.length];return WE.set(e,t),t};function KE(e){switch(e){case`error`:case`stderr`:return`border-l-destructive`;case`warn`:return`border-l-yellow-500`;case`notify`:return`border-l-green-500`;default:return`border-l-transparent`}}function qE({columns:e,data:t,onRowClick:n,containerRef:r}){let i=be({features:Nn,data:t,columns:e});return(0,K.jsxs)(fn,{className:`text-xs`,containerRef:r,containerClassName:`rounded-md bg-card dark:bg-black-dark logsTable max-h-[calc(100vh-(--spacing(48)))] overflow-y-auto md:max-h-[calc(100vh-(--spacing(40)))]`,children:[(0,K.jsx)(ln,{children:i.getHeaderGroups().map(e=>(0,K.jsx)(dn,{className:`border-b border-border`,children:e.headers.map(e=>(0,K.jsx)(on,{className:`p-4 max-w-96 sticky top-0 z-10 border-b border-border bg-card dark:bg-black-dark`,children:e.isPlaceholder?null:_e(e.column.columnDef.header,e.getContext())},e.id))},e.id))}),(0,K.jsx)(cn,{className:`bg-background dark:bg-black`,children:i.getRowModel().rows?.length?i.getRowModel().rows.map(e=>(0,K.jsx)(dn,{"data-state":e.getIsSelected()&&`selected`,className:P(`hover:bg-muted/20 data-[state=selected]:bg-muted max-w-full border-l-2`,KE(e.original.level),n&&`cursor-pointer`),onClick:()=>n?.(e),children:e.getVisibleCells().map(e=>(0,K.jsx)(un,{className:`p-2`,children:_e(e.column.columnDef.cell,e.getContext())},e.id))},e.id)):(0,K.jsx)(dn,{children:(0,K.jsx)(un,{colSpan:e.length,className:`h-24 text-center`,children:`No results.`})})})]})}var JE=524288,YE=class{totalChars=0;spent=!1;get isSpent(){return this.spent}admit(e){return this.spent?{admitted:!1,justExhausted:!1,oversize:!1}:e>524288?{admitted:!1,justExhausted:!1,oversize:!0}:this.totalChars+e>8388608?(this.spent=!0,{admitted:!1,justExhausted:!0,oversize:!1}):(this.totalChars+=e,{admitted:!0,justExhausted:!1,oversize:!1})}};function XE(e){try{JSON.parse(e)}catch{return!1}return!0}function ZE(e){return!e||e.length>524288?`plaintext`:XE(e)?`json`:`plaintext`}function QE({label:e,children:t}){return(0,K.jsxs)(`div`,{className:`flex items-start gap-3 py-1.5 border-b border-border/50 last:border-0`,children:[(0,K.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground w-20 shrink-0 pt-0.5`,children:e}),(0,K.jsx)(`span`,{className:`text-xs`,children:t})]})}function $E({setIsModalOpen:e,isModalOpen:t,data:n}){let r=n?GE(n.node):`default`,i=lp();return(0,K.jsx)(Rt,{onOpenChange:e,open:t,children:(0,K.jsxs)(Ut,{"aria-describedby":void 0,resizable:!0,children:[(0,K.jsx)(Bt,{children:(0,K.jsx)(qt,{children:`Log Entry`})}),n?(0,K.jsxs)(`div`,{className:`flex flex-1 min-h-0 flex-col gap-2 text-popover-foreground`,children:[(0,K.jsxs)(`div`,{className:`rounded-md border border-border/50 bg-muted/20 px-3 py-1`,children:[(0,K.jsx)(QE,{label:`Level`,children:(0,K.jsx)(Wi,{variant:VE(n.level),children:wo(n.level)})}),(0,K.jsx)(QE,{label:`Timestamp`,children:(0,K.jsx)(`span`,{className:`tabular-nums`,children:new Date(n.timestamp).toLocaleString()})}),(0,K.jsx)(QE,{label:`Thread`,children:(0,K.jsx)(`span`,{className:`tabular-nums font-mono`,children:n.thread})}),n.node&&(0,K.jsx)(QE,{label:`Node`,children:(0,K.jsx)(Wi,{variant:r,children:n.node})}),n.tags&&n.tags.length>0&&(0,K.jsx)(QE,{label:`Tags`,children:(0,K.jsx)(`span`,{className:`font-mono`,children:n.tags})})]}),(0,K.jsxs)(`div`,{className:`flex flex-1 min-h-0 flex-col`,children:[(0,K.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground mb-1.5`,children:`Message`}),(0,K.jsx)(`div`,{className:`rounded-md overflow-hidden border border-border/50 flex-1 min-h-0`,children:(0,K.jsx)(dp,{className:`w-full h-full`,language:ZE(n.message),theme:i,value:n.message,options:{readOnly:!0,minimap:{enabled:!1},scrollBeyondLastLine:!1,fontSize:12,padding:{top:12,bottom:12},automaticLayout:!0}})})]})]}):(0,K.jsx)(Bi,{})]})})}var eD=y({limit:M().or(b()).or(T()).optional(),level:D([`notify`,`error`,`warn`,`info`,`debug`,`trace`,`undefined`]).or(b()).or(T()).optional(),from:M().or(b()).or(T()).optional(),until:M().or(b()).or(T()).optional(),log_name:D([`hdb.log`,`system.log`]).or(b()).or(T()).optional(),filter:M().or(b()).or(T()).optional()}),tD=`dark:bg-grey-600 dark:border-grey-500`;function nD({form:e,resetFilters:t,submitFilters:n,showLogName:r,showFilter:i,isOpen:a,onOpenChange:o}){return(0,K.jsxs)(It,{className:P(a?`block`:`hidden`,`mt-3 md:mt-0 md:block`),children:[(0,K.jsx)(Nt,{className:`hidden md:block`,children:(0,K.jsx)(`button`,{type:`button`,onClick:()=>o(!a),"aria-expanded":a,"aria-controls":`logs-filters-content`,className:`flex w-full items-center justify-between md:pointer-events-none`,children:(0,K.jsxs)(Mt,{className:`flex items-center gap-2 text-base`,children:[(0,K.jsx)(ti,{className:`size-4 text-muted-foreground`}),`Filters`]})})}),(0,K.jsx)(Pt,{id:`logs-filters-content`,children:(0,K.jsx)(Do,{...e,children:(0,K.jsxs)(`form`,{id:`instance-edit-log-filters-form`,name:`instance-edit-log-filters-form`,onSubmit:e.handleSubmit(n),className:`flex-col space-y-4`,children:[i&&(0,K.jsx)(Y,{control:e.control,name:`filter`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(J,{children:(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(Xr,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground`}),(0,K.jsx)($,{type:`search`,placeholder:`Search logs…`,className:P(`pl-9`,tD),value:e.value??``,onChange:e.onChange})]})}),(0,K.jsx)(Q,{})]})}),r&&(0,K.jsx)(Y,{control:e.control,name:`log_name`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Log file`}),(0,K.jsxs)(Xt,{onValueChange:e.onChange,value:e.value??void 0,children:[(0,K.jsx)(Kt,{className:P(`w-full bg-white`,tD),children:(0,K.jsx)(Yt,{placeholder:`Select log file`})}),(0,K.jsx)(Gt,{children:(0,K.jsxs)(Jt,{children:[(0,K.jsx)(Ht,{value:`hdb.log`,children:`Application (hdb.log)`}),(0,K.jsx)(Ht,{value:`system.log`,children:`System (system.log)`})]})})]}),(0,K.jsx)(Q,{})]})}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,K.jsx)(Y,{control:e.control,name:`limit`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Limit`}),(0,K.jsxs)(Xt,{onValueChange:e.onChange,value:e.value??void 0,children:[(0,K.jsx)(Kt,{className:P(`w-full bg-white`,tD),children:(0,K.jsx)(Yt,{placeholder:`Limit`})}),(0,K.jsx)(Gt,{children:(0,K.jsxs)(Jt,{children:[(0,K.jsx)(Ht,{value:`1000`,children:`1000`}),(0,K.jsx)(Ht,{value:`500`,children:`500`}),(0,K.jsx)(Ht,{value:`250`,children:`250`}),(0,K.jsx)(Ht,{value:`100`,children:`100`}),(0,K.jsx)(Ht,{value:`10`,children:`10`})]})})]}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:e.control,name:`level`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Level`}),(0,K.jsxs)(Xt,{onValueChange:e.onChange,value:e.value??void 0,children:[(0,K.jsx)(Kt,{className:P(`w-full bg-white`,tD),children:(0,K.jsx)(Yt,{placeholder:`Level`})}),(0,K.jsx)(Gt,{children:(0,K.jsxs)(Jt,{children:[(0,K.jsx)(Ht,{value:`undefined`,children:`All`}),(0,K.jsx)(Ht,{value:`notify`,children:`Notify`}),(0,K.jsx)(Ht,{value:`error`,children:`Error`}),(0,K.jsx)(Ht,{value:`warn`,children:`Warn`}),(0,K.jsx)(Ht,{value:`info`,children:`Info`}),(0,K.jsx)(Ht,{value:`debug`,children:`Debug`}),(0,K.jsx)(Ht,{value:`trace`,children:`Trace`})]})})]}),(0,K.jsx)(Q,{})]})})]}),(0,K.jsx)(Y,{control:e.control,name:`from`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Start date`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`datetime-local`,className:tD,value:e.value??void 0,onChange:e.onChange})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:e.control,name:`until`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`End date`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`datetime-local`,className:tD,value:e.value??void 0,onChange:e.onChange})}),(0,K.jsx)(Q,{})]})}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,K.jsx)(F,{type:`submit`,variant:`positiveOutline`,className:`grow`,children:`Apply Filters`}),(0,K.jsx)(F,{type:`reset`,variant:`destructiveOutline`,onClick:t,children:`Clear`})]})]})})})]})}var rD=1e4;function iD(e){if(!e)return;let t=parseInt(e,10);if(!(!Number.isFinite(t)||t<=0))return Math.min(t,rD)}function aD(e,t){return{operation:`read_log`,start:0,replicated:t,limit:iD(e.limit),level:e.level===`undefined`?void 0:e.level,from:e.from?new Date(e.from).toISOString():void 0,until:e.until?new Date(e.until).toISOString():void 0,log_name:e.log_name??void 0,filter:e.filter?e.filter:void 0,order:`desc`}}async function oD({instanceClient:e,logFilters:t,replicated:n}){let{data:r}=await e.post(`/`,aD(t,n));return r}function sD(e){let t=e.logFilters;return z({queryKey:[`read_log`,e.entityId,t.limit,t.level,t.from,t.until,t.log_name,t.filter,e.replicated],queryFn:()=>oD(e),retry:!1,refetchInterval:e.isAutoRefreshEnabled?5e3:!1})}async function cD({connection:e,logFilters:t,replicated:n,signal:r,onEntry:i}){let{url:a,headers:o,credentials:s}=l_(e),c;try{c=await fetch(a,{method:`POST`,headers:o,credentials:s,body:JSON.stringify(aD(t,n)),signal:r})}catch(e){throw r?.aborted?e:new o_(`Failed to open the read_log SSE stream.`,{cause:e})}let l=c.headers.get(`content-type`)??``;if(!c.ok||!l.includes(`text/event-stream`)||!c.body)throw await c.body?.cancel().catch(()=>{}),new o_(`read_log did not return an event stream (status ${c.status}, content-type "${l}").`);for await(let e of r_(c.body,r)){if(e.event===`error`){let t=a_(e);if(!t||typeof t!=`object`)throw new c_(typeof t==`string`&&t?t:`The log stream failed.`);let n=t;throw new c_(n.message??`The log stream failed.`,{code:n.code})}if(e.event===`done`||e.event===`end`)return;for(let t of lD(a_(e)))i(t)}}function lD(e){return Array.isArray(e)?e.filter(uD):uD(e)?[e]:[]}function uD(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.timestamp==`string`&&(typeof t.level==`string`||typeof t.message==`string`)}function dD(e){return[e.timestamp,e.node??``,e.thread??``,e.level,e.message].join(`|`)}function fD(e,t,n){let r=new Set,i=[];for(let n of[...t,...e]){let e=dD(n);r.has(e)||(r.add(e),i.push(n))}return i.sort((e,t)=>e.timestamp<t.timestamp?1:e.timestamp>t.timestamp?-1:0),n>0&&i.length>n?i.slice(0,n):i}var pD={entries:[],fellBack:!1};function mD(e,t){switch(t.kind){case`reset`:return pD;case`retry`:return e.fellBack?{...e,fellBack:!1}:e;case`append`:{if(t.entries.length===0)return e;let n=e.entries.concat(t.entries);return n.length<=t.cap?{...e,entries:n}:(n.sort((e,t)=>e.timestamp<t.timestamp?1:e.timestamp>t.timestamp?-1:0),{...e,entries:n.slice(0,t.cap)})}case`fellBack`:return{...e,fellBack:!0}}}function hD(){let e=G();return l.isDirectConnection(e.entityId)}var gD=1e3,_D=2e3,vD=250;function yD(e){return iD(e)??gD}function bD(e,t){return JSON.stringify([e.limit,e.level,e.from,e.until,e.log_name,e.filter,t])}function xD({params:e,logFilters:t,replicated:n,live:r}){let i=hD(),[a,o]=(0,q.useReducer)(mD,pD),s=r&&i&&!a.fellBack,c=bD(t,n),l=yD(t.limit),u=Math.max(_D,l),d=H(sD({...e,logFilters:t,replicated:n,isAutoRefreshEnabled:r&&!s}));(0,q.useEffect)(()=>{o({kind:`reset`})},[e.entityId,c]),(0,q.useEffect)(()=>{r&&o({kind:`retry`})},[r]);let f=(0,q.useRef)({logFilters:t,replicated:n});f.current={logFilters:t,replicated:n},(0,q.useEffect)(()=>{if(!s)return;let t=new AbortController,n=[],r=()=>{if(n.length>0&&!t.signal.aborted){let e=n;n=[],o({kind:`append`,entries:e,cap:u})}},i=setInterval(r,vD);return cD({connection:{id:e.entityId},logFilters:f.current.logFilters,replicated:f.current.replicated,signal:t.signal,onEntry:e=>n.push(e)}).catch(()=>{}).finally(()=>{clearInterval(i),!t.signal.aborted&&(r(),o({kind:`fellBack`}))}),()=>{clearInterval(i),t.abort()}},[s,e.entityId,c]);let p=(0,q.useMemo)(()=>{let e=d.data??[];return a.entries.length===0?e:fD(e,a.entries,l)},[d.data,a.entries,l]),m=s?`streaming`:r?`polling`:`idle`;return{logs:p,isLoading:d.isLoading,isFetching:d.isFetching,refetch:()=>d.refetch(),transport:m}}var SD={log_name:`hdb.log`,limit:`100`,level:`undefined`,from:``,until:``,filter:``},CD={error:(0,K.jsx)(Xn,{className:`size-3`}),stderr:(0,K.jsx)(Xn,{className:`size-3`}),warn:(0,K.jsx)(fi,{className:`size-3`}),notify:(0,K.jsx)(Hn,{className:`size-3`}),info:(0,K.jsx)(Cr,{className:`size-3`}),debug:(0,K.jsx)(Gn,{className:`size-3`}),trace:(0,K.jsx)(Rn,{className:`size-3`}),stdout:(0,K.jsx)(ci,{className:`size-3`})},wD=[{accessorKey:`level`,header:`Level`,cell:({row:e})=>{let{level:t}=e.original;return(0,K.jsxs)(Wi,{variant:VE(t),children:[CD[t],wo(t)]})}},{accessorKey:`timestamp`,header:`Timestamp`,cell:({row:e})=>{let{timestamp:t}=e.original,n=new Date(t),r=n.getFullYear()===new Date().getFullYear()?n.toLocaleDateString(void 0,{month:`numeric`,day:`2-digit`}):n.toLocaleDateString();return(0,K.jsxs)(`span`,{className:`tabular-nums whitespace-nowrap text-muted-foreground`,children:[r,` `,n.toLocaleTimeString()]})}},{accessorKey:`message`,header:`Message`,cell:({row:e})=>{let{message:t}=e.original;return(0,K.jsx)(`span`,{className:`block max-w-xl truncate font-mono text-xs`,children:t})}},{accessorKey:`thread`,header:`Thread`,cell:({row:e})=>(0,K.jsx)(`span`,{className:`text-muted-foreground tabular-nums`,children:e.original.thread})},{accessorKey:`node`,header:`Node`,cell:({row:e})=>{let{node:t}=e.original,n=GE(t);return(0,K.jsx)(K.Fragment,{children:t?(0,K.jsxs)(Ia,{children:[(0,K.jsx)(La,{asChild:!0,children:(0,K.jsxs)(Wi,{variant:n,children:[t.split(`.`)[0],`...`]})}),(0,K.jsx)(Ra,{className:`bg-popover text-popover-foreground border border-border`,arrowClassName:`bg-popover fill-popover`,children:t})]}):null})}},{accessorKey:`tags`,header:`Tags`,cell:({row:e})=>{let{tags:t}=e.original;return t&&t.length>0?(0,K.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:t}):null}}],TD=(e,t)=>!e&&!t||!e||!t||new Date(e)<=new Date(t);function ED(){return(0,K.jsxs)(`div`,{className:`rounded-md bg-card dark:bg-black-dark overflow-hidden`,children:[(0,K.jsx)(`div`,{className:`flex gap-4 p-4 border-b border-border`,children:[`w-14`,`w-32`,`w-14`,`w-24`,`w-16`,`flex-1`].map((e,t)=>(0,K.jsx)(tm,{className:`h-4 ${e}`},t))}),Array.from({length:12}).map((e,t)=>(0,K.jsxs)(`div`,{className:`flex gap-4 p-3 border-b border-border/40 border-l-2 border-l-transparent`,children:[(0,K.jsx)(tm,{className:`h-5 w-14`}),(0,K.jsx)(tm,{className:`h-5 w-32`}),(0,K.jsx)(tm,{className:`h-5 w-10`}),(0,K.jsx)(tm,{className:`h-5 w-20`}),(0,K.jsx)(tm,{className:`h-5 w-12`}),(0,K.jsx)(tm,{className:`h-5 flex-1 max-w-xs`})]},t))]})}function DD(){let[e,t]=(0,q.useState)(SD),[n,r]=(0,q.useState)(!1),[i,a]=(0,q.useState)(),[o,s]=(0,q.useState)(!1),[c,l]=Tn(Sn.LogsOrderReversed,!1),[u,d]=(0,q.useState)(!1),f=G(),{data:p}=H(nn(f)),m=p?.version,h=!!m&&$t(`4.7.16`,m),{logs:g,isLoading:_,isFetching:v,refetch:y,transport:b}=xD({params:f,logFilters:e,replicated:f.entityType===`cluster`,live:o}),x=(0,q.useMemo)(()=>c?[...g??[]].reverse():g??[],[g,c]),S=(0,q.useRef)(null);(0,q.useEffect)(()=>{let e=S.current;_||!e||e.scrollTo({top:c?e.scrollHeight:0})},[c,_]),(0,q.useEffect)(()=>{let e=S.current;!o||_||!e||e.scrollTo({top:c?e.scrollHeight:0})},[x,o,c,_]);let C=dt({resolver:Fe(eD),defaultValues:SD,mode:`onChange`}),w=e=>{a(e.original),r(!0)},T=async e=>{if(!TD(e.from,e.until)){C.setError(`from`,{type:`onChange`,message:`Start date must be before end date`}),C.setError(`until`,{type:`onChange`,message:`End date must be after start date`});return}t(e)},E=async()=>{C.reset(),t(SD)},D=Zf(y);return(0,K.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 pt-2 text-foreground md:grid-cols-12 md:gap-4`,children:[(0,K.jsxs)(`section`,{className:`col-span-1 md:col-span-4 lg:col-span-3 px-2 pb-0 md:self-start md:sticky md:top-34 md:max-h-[calc(100vh-(--spacing(34)))] md:overflow-y-auto md:pb-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 md:hidden`,children:[(0,K.jsxs)(F,{variant:`defaultOutline`,onClick:()=>d(e=>!e),"aria-label":`Toggle filters`,"aria-expanded":u,className:`flex-1`,children:[(0,K.jsx)(ti,{}),`Filters`]}),(0,K.jsxs)(F,{variant:`defaultOutline`,onClick:D,disabled:v||_||o,"aria-label":`Refresh logs`,className:`flex-1`,children:[(0,K.jsx)(Wr,{className:v?`animate-spin`:``}),`Refresh`]}),(0,K.jsxs)(F,{variant:c?`default`:`defaultOutline`,onClick:()=>l(e=>!e),"aria-label":`Reverse log order`,"aria-pressed":c,className:`flex-1`,children:[(0,K.jsx)(sn,{}),`Reverse`]})]}),(0,K.jsx)(nD,{form:C,resetFilters:E,submitFilters:T,showLogName:!1,showFilter:h,isOpen:u,onOpenChange:d}),(0,K.jsxs)(`div`,{className:`mt-3 space-y-3 hidden md:block`,children:[(0,K.jsxs)(F,{variant:`defaultOutline`,onClick:D,disabled:v||_||o,className:`w-full`,children:[(0,K.jsx)(Wr,{}),`Refresh`]}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-2.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-foreground`,children:[(0,K.jsx)(Tp,{id:`logs-live-switch`,"aria-label":`Toggle live logs`,checked:o,onCheckedChange:s}),(0,K.jsxs)(`label`,{htmlFor:`logs-live-switch`,className:`flex items-center gap-2 cursor-pointer`,children:[(0,K.jsx)(Wr,{className:`size-4 ${o?`animate-spin [animation-duration:3s]`:``}`}),o?b===`streaming`?`Live (streaming)`:`Live (polling every 5s)`:`Live`]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-foreground`,children:[(0,K.jsx)(Tp,{id:`logs-reverse-order-switch`,"aria-label":`Reverse log order`,checked:c,onCheckedChange:l}),(0,K.jsxs)(`label`,{htmlFor:`logs-reverse-order-switch`,className:`flex items-center gap-2 cursor-pointer`,children:[(0,K.jsx)(sn,{className:`size-4`}),c?`Oldest first`:`Newest first`]})]})]})]})]}),(0,K.jsx)(`section`,{className:`col-span-1 md:col-span-8 lg:col-span-9`,children:_?(0,K.jsx)(ED,{}):(0,K.jsx)(qE,{columns:wD,data:x,onRowClick:w,containerRef:S})}),(0,K.jsx)($E,{isModalOpen:n,setIsModalOpen:r,data:i})]})}function OD(e){return I({getParentRoute:()=>e,path:`logs`,head:()=>({meta:[{title:`Logs — Harper Fabric`}]}),component:DD})}var kD=6e4,AD=60*kD,jD=24*AD,MD=[{id:`1h`,label:`Last 1 hour`,durationMs:AD,bucketMs:1*kD,expandedBucketMs:1*kD},{id:`6h`,label:`Last 6 hours`,durationMs:6*AD,bucketMs:2*kD,expandedBucketMs:1*kD},{id:`24h`,label:`Last 24 hours`,durationMs:jD,bucketMs:10*kD,expandedBucketMs:5*kD},{id:`7d`,label:`Last 7 days`,durationMs:7*jD,bucketMs:AD,expandedBucketMs:15*kD},{id:`30d`,label:`Last 30 days`,durationMs:30*jD,bucketMs:4*AD,expandedBucketMs:AD}];function ND(e){let t=MD.find(t=>t.id===e);if(!t)throw Error(`Unknown preset: ${e}`);return t}function PD(e){let t=(e,t)=>`${e} ${t}${e===1?``:`s`}`;return e>=AD&&e%AD===0?t(e/AD,`hour`):e>=kD&&e%kD===0?t(e/kD,`minute`):e>=1e3&&e%1e3==0?t(e/1e3,`second`):`${e} ms`}function FD(e,t){let n=e=>t?.expanded?e.expandedBucketMs:e.bucketMs,r=n(MD[0]);if(!Number.isFinite(e)||e<=0)return r;for(let t of MD)if(e<=t.durationMs*1.01)return n(t);let i=MD[MD.length-1];return Math.max(r,Math.ceil(e/(i.durationMs/n(i))))}var ID=[{label:`Off`,value:0},{label:`30s`,value:3e4},{label:`60s`,value:6e4},{label:`5m`,value:3e5}],LD=6e4,RD=[`health`,`traffic`,`requests`,`database`,`replication`,`storage`,`overview`],zD={tab:`health`,range:`1h`,refresh:LD};function BD(e){let t=e.refresh===``?NaN:Number(e.refresh);return{tab:RD.find(t=>t===e.tab)??zD.tab,range:MD.find(t=>t.id===e.range)?.id??zD.range,refresh:ID.find(e=>e.value===t)?.value??zD.refresh}}function VD(e){return I({getParentRoute:()=>e,path:`status`,validateSearch:BD,search:{middlewares:[oe(zD)]},head:()=>({meta:[{title:`Status — Harper Fabric`}]}),component:me(async()=>Te(()=>import(`./status-IoJkDzlx.js`),__vite__mapDeps([45,1,3,2,4,5,6,7,20,9,8,10,11,12,37,40,32,18,46,47,48,49,50,51,52,53,54,55,56,57,58,59])),`StatusIndex`)})}function HD(e){let t=LE(e),n=[OD(t),...Mg(t,e),jg(t),VD(t),Bb(t),jE(t)];return t.addChildren(n)}I({getParentRoute:()=>uo,path:`notifications`,head:()=>({meta:[{title:`Notifications — Harper Fabric`}]}),component:me(async()=>Te(()=>import(`./notifications-CPwYKDDH.js`),__vite__mapDeps([60,1,2,3,4,5,6])),`NotificationsCenter`)}),I({getParentRoute:()=>uo,path:`profile`,head:()=>({meta:[{title:`Profile — Harper Fabric`}]}),component:me(async()=>Te(()=>import(`./profile-D0hB1xdm.js`),__vite__mapDeps([61,1,18,3,2,4,5,6,7,17])),`ProfileIndex`)});var UD=lo.addChildren([...Gs,uo.addChildren([HD(`local`)])]);function WD({routeTree:e=UD,authentication:t}){let[n]=(0,q.useState)(()=>Se({routeTree:e,history:ce(),defaultNotFoundComponent:vi,defaultErrorComponent:_i,defaultPreload:!yi()&&`intent`,trailingSlash:`never`,defaultPreloadStaleTime:0,scrollRestoration:!0,context:{queryClient:yn,authentication:t||{}}}));return n}function GD(){let e=ke(),t=WD({authentication:e}),n=(0,q.useRef)(e);return(0,q.useEffect)(()=>{n.current!==e&&(n.current=e,t.invalidate())},[t,e]),(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(pe,{router:t,context:{authentication:e}}),(0,K.jsx)(ve,{router:t,position:`bottom-right`})]})}var KD=({...e})=>(0,K.jsx)(Ue,{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}),qD=!1;function JD(){(0,q.useEffect)(()=>{qD||=!0},[])}function YD(){return ho(),so(),JD(),(0,K.jsxs)(Ea,{children:[(0,K.jsxs)(fe,{client:yn,children:[(0,K.jsx)(GD,{}),(0,K.jsx)(xe,{buttonPosition:`bottom-right`})]}),(0,K.jsx)(KD,{richColors:!0})]})}function XD(){l.signOutAllLocally(),yn.getMutationCache().clear(),yn.getQueryCache().clear(),Ba(),Va()}function ZD(e,t=()=>!1,n=()=>!0){return r=>(r?.response?.status===401&&!t(r.config?.url??``)&&n(r.config)&&e(),Promise.reject(r))}var QD=[`/Login/`,`/ForgotPassword/`,`/ResetPassword/`,`/VerifyEmail/`,`/ResendVerificationEmail/`],$D=`authUserAtSend`;function eO(){let e=l.getConnectionById(m).user;return e&&`id`in e?e.id:null}var tO=!1;function nO(){tO||(tO=!0,N.interceptors.request.use(e=>(e[$D]=eO(),e)),N.interceptors.response.use(e=>e,ZD(XD,e=>QD.some(t=>e.startsWith(t)),e=>e?.[$D]===eO())))}function rO(){if(typeof Node!=`function`||!Node.prototype)return;let e=`__harperTranslationGuarded__`,t=Node.prototype;if(t[e])return;Object.defineProperty(t,e,{value:!0,configurable:!0,writable:!0,enumerable:!1});let n=Node.prototype.removeChild;Node.prototype.removeChild=function(e){return e instanceof Node&&e.parentNode!==this?e:n.call(this,e)};let r=Node.prototype.insertBefore;Node.prototype.insertBefore=function(e,t){return t instanceof Node&&t.parentNode!==this?r.call(this,e,null):r.call(this,e,t)}}var iO=`Studio:StaleDeployReloadedAt`,aO=6e4,oO=`__harperStaleDeployReloadState__`;function sO(){if(!(typeof window>`u`))return window[oO]}function cO(){let e=sO();if(e){try{let e=Number(sessionStorage.getItem(iO)??0);if(Date.now()-e<aO)return;sessionStorage.setItem(iO,String(Date.now()))}catch{return}e.reload()}}function lO(e=()=>window.location.reload()){if(typeof window>`u`)return;let t=window,n=t[oO];if(n){n.reload=e;return}t[oO]={reload:e},window.addEventListener(`vite:preloadError`,()=>cO())}var uO=Oe();rO(),lO(),nO(),(0,uO.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,K.jsx)(q.StrictMode,{children:(0,K.jsx)(YD,{})}));export{zy as $,Wr as $n,$s as $t,pT as A,bi as An,Im as At,BS as B,_i as Bn,Yf as Bt,gT as C,fa as Cn,s_ as Ct,cT as D,$i as Dn,Yh as Dt,uT as E,Qi as En,ng as Et,Qw as F,Di as Fn,Am as Ft,jx as G,ci as Gn,bu as Gt,OS as H,fi as Hn,df as Ht,Ew as I,Oi as In,tm as It,ix as J,$r as Jn,xl as Jt,Nx as K,oi as Kn,Hl as Kt,UC as L,Ai as Ln,Tp as Lt,eT as M,Si as Mn,Mm as Mt,Yw as N,Ci as Nn,jm as Nt,mT as O,Wi as On,Dh as Ot,$w as P,Ei as Pn,Nm as Pt,Zy as Q,Gr as Qn,Zs as Qt,KS as R,ki as Rn,dp as Rt,sT as S,ua as Sn,p_ as St,vT as T,Zi as Tn,n_ as Tt,fS as U,di as Un,Au as Ut,RS as V,mi as Vn,Hf as Vt,Mx as W,ui as Wn,Su as Wt,yb as X,Jr as Xn,Js as Xt,$b as Y,Xr as Yn,bl as Yt,nb as Z,Kr as Zn,Xs as Zt,zT as _,Sa as _n,H_ as _t,PD as a,Z as an,Cr as ar,jy as at,hT as b,oa as bn,v_ as bt,oD as c,Y as cn,Qn as cr,Wv as ct,iE as d,eo as dn,iv as dt,ec as en,Ur as er,By as et,$T as f,Ha as fn,nv as ft,HT as g,Ca as gn,G_ as gt,UT as h,La as hn,Y_ as ht,MD as i,Q as in,wr as ir,Ly as it,fT as j,wi as jn,Pm as jt,lT as k,Bi as kn,yh as kt,YE as l,J as ln,Xn as lr,av as lt,VT as m,Ra as mn,X_ as mt,BD as n,Jo as nn,Ar as nr,ky as nt,ND as o,jo as on,lr as or,Iy as ot,XT as p,Ia as pn,J_ as pt,Ax as q,ai as qn,Vl as qt,ID as r,$ as rn,kr as rr,Ay as rt,FD as s,X as sn,sr,Yv as st,cO as t,Ys as tn,Vr as tr,Ey as tt,JE as u,Do as un,Bn as ur,rv as ut,LT as v,ma as vn,w_ as vt,_T as w,ca as wn,o_ as wt,oT as x,aa as xn,m_ as xt,IT as y,pa as yn,S_ as yt,GS as z,xi as zn,lp as zt};
|